text: used[i]) { vector<int> arr; euler(i, arr); reverse((arr).begin(), (arr).end()); cycles.push_back({}); for (int i = 0; i < (int)(arr).size(); ++i) { int j = (i + 1) % (int)(arr).size(); cycles.back().push_back(pos[{arr[i], arr[j]}].back()); pos[{arr[i], arr[j]}].pop_back(); } } } vector<vector<int>> res; if (s - m > 1 && (int)(cycles).size() > 1) { int len = min((int)(cycles).size(), s - m); res.push_back({}); vector<int> newcycle; for (int i = (int)(cycles).size() - len; i < (int)(cycles).size(); ++i) { res.back().push_back(cycles[i].back()); for (int j : cycles[i]) { newcycle.push_back(j); } } reverse((res.back()).begin(), (res.back()).end()); for (int i = 0; i < len; ++i) { cycles.pop_back(); } cycles.push_back(newcycle); } for (int i = 0; i < (int)(cycles).size(); ++i) { res.push_back(cycles[i]); } cout << (int)(res).size() << endl; for (int i = 0; i < (int)(res).size(); ++i) { cout << (int)(res[i]).size() << endl; for (int j : res[i]) { cout << j + 1 << " "; } cout << endl; } }