#include <iostream> #include <unordered_map> using namespace std; unordered_map<long long, long long> pos; unordered_map<long long, long long> ord; int main() { long long v=0; for (long long n=1; n<=10000; n++) { ord[v] = 1 + ord[v]; cout << n << ' ' << ord[v] << endl; long long w=v; if (pos.count(w)) { v=n-pos[w]; } else { v=0; } pos[w] = n; } return 0; }