#include "../../include/aoc.hpp" #include using namespace std; size_t h(vector &v) { size_t ret = 0; for (int i = 0; i < 4; i++) { ret += v[v.size() - 1 - i] << (i * 8); } return ret; } ll mp(ll n, ll o) { return (n ^ o) % 16777216; } int main() { ios::sync_with_stdio(0); cin.tie(0); vector secrets; ll n; while (cin >> n) { secrets.push_back(n); } unordered_map m; for (ll s : secrets) { char sp = s % 10; vector ss; unordered_set done; for (int i = 0; i < 2000; i++) { char oldsp = sp; s = mp(s * 64, s); s = mp(s / 32, s); s = mp(s * 2048, s); sp = s % 10; ss.push_back(sp - oldsp); if (ss.size() >= 4) { auto hss = h(ss); if (done.contains(hss)) { continue; } done.insert(hss); m[hss] += sp; } } } int mx = 0; for (auto n : m) { if (n.second > mx) { mx = n.second; } } cout << mx << '\n'; }