malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,fma )   #pragma GCC optimize( fast-math )   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( Ofast )   using namespace std;   const long long mod = 1e9 + 7, mod2 = 998244353;   const long double eps = 1e-6;   const long long inf = 1e18;   const int base = 1e9;   const long double PI = 3.1415926;   void deb(long double first){};   int n, a[100 * 1000];   long long k;   unsigned int bitcount(unsigned long long val) {     return __builtin_popcount(val) + __builtin_popcount(val >> 32);   }   void local() { freopen( test.in ,  r , stdin); }   void remote() {}   void read() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];   }   long long cnt(long long bound, vector<int> &v) {     long long res = 0;     for (int i = 0; i < n; i++) {       int l = 0, r = a[i] + 1;       while (r - l > 1) {         int m = (r + l) / 2;         if (a[i] - 3 * 1ll * m * (m - 1) - 1 >= bound)           l = m;         else           r = m;       }       v[i] = l;       res += l;     }     return res;   }   int main() {     remote();     read();     vector<int> v(n);     long long l = -4e18, r = 4e18;     while (l < r) {       long long m = l + (r - l) / 2;       long long val = cnt(m, v);       if (val > k) {         l = m + 1;       } else         r = m;     }     long long val = cnt(l, v);     vector<int> res = v;     long long val2 = cnt(l - 1, v);     for (int i = 0; i < n; i++)       if (v[i] == res[i] + 1 && val < k) res[i]++, val++;     for (int i = 0; i < n; i++) cout << res[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const int MAX = 200005;   int cnt[MAX], pre[MAX], suf[MAX];   int bpow(int a, int b) {     int ans = 1;     while (b) {       if (b & 1) ans = 1LL * ans * a % MOD;       b >>= 1;       a = 1LL * a * a % MOD;     }     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int val;       cin >> val;       cnt[val]++;     }     pre[0] = 1;     for (int i = 1; i < MAX; i++)       pre[i] = 1LL * pre[i - 1] * (cnt[i - 1] + 1) % (MOD - 1);     suf[MAX - 1] = 1;     for (int i = MAX - 2; i >= 0; i--)       suf[i] = 1LL * suf[i + 1] * (cnt[i] + 1) % (MOD - 1);     int ans = 1;     for (int i = 0; i < MAX; i++)       for (int j = 1; j <= cnt[i]; j++)         ans = 1LL * ans *               bpow(bpow(i, j), 1LL * pre[i] * suf[i + 1] % (MOD - 1)) % MOD;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[200010];   long long l[200010];   long long r[200010];   int main() {     ios_base::sync_with_stdio(0);     long long n, h;     cin >> n >> h;     vector<long long> rast2(n + 1, 0);     for (int i = 1; i <= n; i++) {       cin >> l[i] >> r[i];       rast2[i] = r[i] - l[i];     }     for (int i = 1; i <= n; i++) {       rast2[i] += rast2[i - 1];     }     vector<long long> rast(n + 1, 0);     for (int i = 1; i < n; i++) {       rast[i] = l[i + 1] - r[i];     }     rast[n] = 2e9;     for (int i = 1; i <= n; i++) {       rast[i] += rast[i - 1];     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       long long r =           lower_bound(rast.begin(), rast.end(), h + rast[i - 1]) - (rast.begin());       if (r <= n) ans = max(ans, (rast2[r] - rast2[i - 1]) + h);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int n;   set<pair<int, int> > s;   vector<int> od;   int p[512];   vector<int> v[512];   inline void dfs(int b, int pr = -1) {     od.push_back(b);     p[b] = pr;     auto it = s.lower_bound(make_pair(b, -1));     while (it != s.end() && (*it).first == b) {       if (it->second == pr) {         it = next(it);         continue;       }       dfs(it->second, b);       v[b].push_back(it->second);       v[it->second].push_back(b);       it = next(it);     }   }   bool us[512];   void init() {     for (int i = 0; i <= n; i++) {       v[i].clear();       us[i] = false;     }   }   int sz[512];   inline pair<int, int> cent(int b, int ALL, int pr) {     sz[b] = 1;     pair<int, int> ret = make_pair(INT_MAX, -1);     int mx = -1;     for (int go : v[b]) {       if (us[go]) continue;       if (go == pr) continue;       ret = min(ret, cent(go, ALL, b));       sz[b] += sz[go];       mx = max(mx, sz[go]);     }     mx = max(mx, ALL - sz[b]);     ret = min(ret, make_pair(mx, b));     return ret;   }   inline void er(int a, int b) {     s.erase(make_pair(a, b));     s.erase(make_pair(b, a));   }   inline void ins(int a, int b) {     s.insert(make_pair(a, b));     s.insert(make_pair(b, a));   }   bool ok(vector<int> &vv, int num, int root, int root2) {     cout << 1 << endl;     cout << root << endl;     cout << num + 1 << endl;     for (int j = 0; j <= num; j++) {       if (j) printf(   );       printf( %d , vv[j]);     }     puts(  );     cout << root2 << endl;     fflush(stdout);     int way;     scanf( %d , &way);     if (way == num + 1) {       return true;     }     return false;   }   inline void df(int b, int add) {     cent(b, 0, -1);     b = cent(b, sz[b], -1).second;     vector<int> z;     for (int go : v[b]) {       z.push_back(go);     }     us[b] = true;     int mint = 0;     int maxt = z.size();     if (z.size() && ok(z, 0, add, b) == false) {       maxt = mint;     }     while (mint + 1 < maxt) {       int mid = (mint + maxt) / 2;       if (ok(z, mid, add, b)) {         mint = mid;       } else {         maxt = mid;       }     }     if (maxt == z.size()) {       ins(b, add);       return;     }     if (us[z[maxt]] == false) {       df(z[maxt], add);       return;     }     er(z[maxt], b);     ins(z[maxt], add);     ins(add, b);   }   int zz[512];   vector<int> o;   bool cmp(int a, int b) { return zz[a] > zz[b]; }   int main() {     cin >> n;     zz[1] = n;     for (int i = 2; i <= n; i++) {       cout << 1 << endl;       cout << 1 << endl;       cout << n - 1 << endl;       for (int j = 2; j <= n; j++) {         if (j > 1) printf(   );         printf( %d , j);       }       puts(  );       printf( %d n , i);       fflush(stdout);       int a;       scanf( %d , &a);       zz[i] = a;     }     for (int i = 2; i <= n; i++) o.push_back(i);     sort(o.begin(), o.end(), cmp);     for (int i : o) {       od.clear();       init();       dfs(1);       reverse(od.begin(), od.end());       df(1, i);     }     puts( ANSWER );     for (auto it : s) {       if (it.first > it.second) continue;       printf( %d %d n , it.first, it.second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M;   map<string, string> m1;   int main() {     cin >> N >> M;     string s1;     string s2;     for (int i = 1; i <= N; i++) {       cin >> s1;       cin >> s2;       m1[s2] = s1;     }     for (int i = 1; i <= M; i++) {       cin >> s1;       cin >> s2;       s2.erase(s2.begin() + s2.size() - 1);       cout << s1 <<    ;       cout << s2 <<  ; #  << m1[s2] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int p[110];   int main() {     int n, cnt;     cin >> n;     for (int i = 0; i < n; i++) cin >> p[i];     string s;     getline(cin, s);     for (int i = 0; i < n; i++) {       cnt = 0;       getline(cin, s);       for (int j = 0; j < s.size(); j++)         if (s[j] ==  a  || s[j] ==  e  || s[j] ==  i  || s[j] ==  o  ||             s[j] ==  u  || s[j] ==  y )           cnt++;       if (cnt != p[i]) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename S>   ostream &operator<<(ostream &os, const pair<T, S> &v) {     os <<  ( ;     os << v.first <<  ,  << v.second <<  ) ;     return os;   }   template <typename T>   ostream &operator<<(ostream &os, const vector<T> &v) {     os <<  [ ;     long long sz = v.size();     for (long long i = 0; i < sz; ++i) {       os << v[i];       if (i != sz - 1) os <<  , ;     }     os <<  ] n ;     return os;   }   template <typename T>   ostream &operator<<(ostream &os, const set<T> &v) {     T last = *v.rbegin();     os <<  [ ;     for (auto it : v) {       os << it;       if (it != last) os <<  , ;     }     os <<  ] n ;     return os;   }   template <typename T, typename S>   ostream &operator<<(ostream &os, const map<T, S> &v) {     for (auto it : v) {       os << it.first <<   :   << it.second <<   n ;     }     return os;   }   long long power(long long a, long long b) {     long long res = 1;     while (b) {       if (b % 2) {         res = (res * a) % 1000000007;       }       b /= 2;       a = (a * a) % 1000000007;     }     return res;   }   template <typename Arg1>   void __f(const char *name, Arg1 &&arg1) {     cerr << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char *names, Arg1 &&arg1, Args &&...args) {     const char *comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, T;     cin >> n >> T;     vector<pair<long long, long long> > arr;     for (__typeof(1) i = 1; i <= n; i++) {       long long t;       cin >> t;       long long from = t - i;       long long to = T - i;       if (to > from && to > 0) {         arr.push_back({from, 1});         arr.push_back({to, -1});       }     }     sort((arr).begin(), (arr).end());     long long curr = 0, ans = 0;     for (auto it : arr) {       curr += it.second;       ans = max(ans, curr);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     long long int t;     cin >> t;     while (t--) {       long long int x = 0;       long long int n, m;       cin >> n >> m;       for (long long int i = 0; i < n; i++) {         long long int a, b, c, d;         cin >> a >> b >> c >> d;         if (b == c && m % 2 != 1 && x != 1) {           cout <<  Yes  << endl;           x = 1;         }       }       if (x == 0) cout <<  No  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200020;   long long int n;   int main() {     cin >> n;     for (long long int i = 1; i <= n - 1; i++) {       for (long long int j = 1; j <= n - 1; j++) {         if (i == j)           cout <<  0  ;         else           cout << 1 + (i + j - 2) % (n - 1) <<    ;       }       cout << (2 * i - 2) % (n - 1) + 1 << endl;     }     for (long long int i = 1; i <= n - 1; i++) {       cout << (2 * i - 2) % (n - 1) + 1 <<    ;     }     cout <<  0  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   struct P {     int x, y;     bool operator<(const P &a) const { return x > a.x; }   } a[N];   int main() {     static int n, b[N * 2];     cin >> n;     for (int i = 1; i <= n; i++) scanf( %d , (int *)(a + i)), a[i].y = i * 2 - 1;     sort(a + 1, a + 1 + n);     for (int i = 1; i < n; i++) printf( %d %d n , a[i].y, a[i + 1].y);     for (int i = 1; i <= n; i++) b[i] = a[i].y;     for (int i = 1, aid, *bid; i <= n; i++) {       aid = a[i].y + 1, bid = b + i + a[i].x;       if (!*bid)         printf( %d %d n , aid, *(bid - 1)), *bid = aid;       else         printf( %d %d n , aid, *--bid);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> graph[100005];   int a[100005], b[100005];   vector<int> ans;   void dfs(int source, int parent, int oddlevel, int evenlevel, int depth) {     if (depth % 2 == 1)       a[source] ^= oddlevel;     else       a[source] ^= evenlevel;     if (a[source] != b[source]) {       a[source] ^= 1;       if (depth % 2 == 1)         oddlevel++;       else         evenlevel++;       oddlevel %= 2, evenlevel %= 2;       ans.push_back(source);     }     for (int i = 0; i < graph[source].size(); i++) {       int child = graph[source][i];       if (child == parent) continue;       dfs(child, source, oddlevel, evenlevel, depth + 1);     }   }   int main() {     int n;     cin >> n;     for (int i = 1; i < n; i++) {       int x, y;       cin >> x >> y;       graph[x].push_back(y);       graph[y].push_back(x);     }     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= n; i++) cin >> b[i];     dfs(1, 0, 0, 0, 0);     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++) {       cout << ans[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     while (cin >> n) {       string s;       cin >> s;       int l[3005], r[3005];       memset(l, -1, sizeof(l));       memset(r, -1, sizeof(r));       int cnt = 0, t1 = 0, t2 = 0;       for (int i = 0; i < n; ++i) {         if (s[i] ==  L ) {           l[t1++] = i;           continue;         }         if (s[i] ==  R ) {           r[t2++] = i;           continue;         }       }       if (l[0] == r[0]) {         cout << n << endl;         continue;       }       if (l[0] == -1) {         cout << r[0] << endl;         continue;       }       if (r[0] == -1) {         cout << n - l[0] - 1 << endl;         continue;       }       if (l[0] < r[0]) {         cnt += l[0] + 1;         for (int i = 1; i < t1; ++i) {           int t = l[i] - r[i - 1];           cnt += t + 1;           if (t % 2 == 0) cnt--;         }         if (t1 == t2) cnt += n - r[t2 - 1];       } else {         for (int i = 0; i < t1; ++i) {           int t = l[i] - r[i];           cnt += t + 1;           if (t % 2 == 0) cnt--;         }         if (t2 > t1) cnt += n - r[t2 - 1];       }       cout << n - cnt << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 100100;   const long double INF = 1e100;   const long double eps = 1e-6;   const long double PI = 3.14159265358979323846264338328;   long long x[maxN], y[maxN];   long double Dis(long long a, long long b, long long p, long long q) {     long double aa = 1.0 * a, bb = 1.0 * b, pp = 1.0 * p, qq = 1.0 * q;     return (aa - pp) * (aa - pp) + (bb - qq) * (bb - qq);   }   long double DfromL(long long X1, long long Y1, long long aa, long long bb,                      long long pp, long long qq) {     long double X = 1.0 * X1, Y = 1.0 * Y1, a = 1.0 * aa, b = 1.0 * bb,                 p = 1.0 * pp, q = 1.0 * qq;     bool Inf = (a == p);     long double m = (Inf) ? INF : ((b - q) / (a - p));     long double c = (Inf) ? INF : ((b - m * a));     bool zero = (!Inf && m == 0.0);     long double m1 = (Inf) ? (0) : (zero) ? INF : (-1.0 / m);     long double c1 = (Inf) ? (Y) : (zero) ? INF : (Y - m1 * X);     long double XX = (Inf) ? (a) : (zero) ? (X) : ((c1 - c) / (m - m1));     long double YY = (Inf) ? (Y) : (zero) ? (b) : ((m * c1 - m1 * c) / (m - m1));     if (XX >= min(a, p) && XX <= max(a, p) && YY >= min(b, q) &&         YY <= max(b, q)) {       if (Inf) return (X - XX) * (X - XX);       if (zero) return (Y - YY) * (Y - YY);       return ((m * X - Y + c) * (m * X - Y + c)) / (1.0 + m * m);     } else       return -1.0;   }   int main() {     ios::sync_with_stdio(false);     long long n, X, Y;     cin >> n >> X >> Y;     for (int i = 0; i < n; i++) cin >> x[i] >> y[i];     long double maxR = -1.0, minR = INF;     for (int i = 0; i < n; i++) {       long double dis = Dis(X, Y, x[i], y[i]);       maxR = max(maxR, dis);       minR = min(minR, dis);       long double diS = DfromL(X, Y, x[i], y[i], x[(i + 1) % n], y[(i + 1) % n]);       if (diS != -1.0) {         maxR = max(maxR, diS);         minR = min(minR, diS);       }     }     long double ans = PI * (maxR - minR);     cout << setprecision(20) << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[500005];   int q[500005];   int n, k, d;   int main() {     scanf( %d%d%d , &n, &k, &d);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     sort(a + 1, a + n + 1);     int l = 1, r = 1;     q[l] = 0;     for (int i = k; i <= n; i++) {       while (l <= r && a[i] - a[q[l] + 1] > d) l++;       if (l <= r && i - q[l] >= k) q[++r] = i;     }     if (q[r] == n)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     vector<int> a(n + 1);     for (int i = 1; i <= n; ++i) {       cin >> a[i];     }     sort(a.begin(), a.end());     vector<vector<vector<int>>> dp(         2, vector<vector<int>>(k + 1, vector<int>(k + 1)));     dp[0][0][0] = 1;     int ans = 0;     set<int> sad;     for (int i = 1; i <= n; ++i) {       for (int j = 0; j <= k; ++j) {         for (int l = 0; l <= j; ++l) {           int i2 = i % 2;           dp[i2][j][l] = dp[abs(i2 - 1)][j][l];           if (a[i] <= j) {             dp[i2][j][l] =                 max(dp[abs(i2 - 1)][j][l], dp[abs(i2 - 1)][j - a[i]][l]);             if (a[i] <= l) {               dp[i2][j][l] =                   max(dp[i2][j][l], dp[abs(i2 - 1)][j - a[i]][l - a[i]]);             }           }           if (i == n && j == k && dp[i2][j][l] != 0) {             ++ans;             sad.insert(l);           }         }       }     }     cout << ans << endl;     for (auto i : sad) {       cout << i <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long int gcd(long long int m, long long int n) {     if (n == 0) return m;     return gcd(n, m % n);   }   int MOD = 1000000000;   long long int powmod(long long int a, long long int b) {     if (b == 0) return 1;     long long int x = powmod(a, b / 2);     long long int y = (x * x) % MOD;     if (b % 2) return (a * y) % MOD;     return y % MOD;   }   int main() {     std::ios::sync_with_stdio(false);     int n, k;     cin >> n >> k;     int z;     int a[10000];     for (int i = 0; i < n; i++) cin >> a[i];     int ans = 0;     for (int i = 0; i < n - 1; i++) {       if (a[i] > 8) {         a[i + 1] = a[i + 1] + a[i] - 8;         k = k - 8;       } else         k = k - a[i];       if (k <= 0) {         cout << i + 1 << endl;         return 0;       }     }     if (k - min(a[n - 1], 8) > 0)       cout <<  -1  << endl;     else       cout << n << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool pid_comp_second(pair<int, double> a, pair<int, double> b) {     if (a.second == b.second) return a.first < b.first;     return a.second > b.second;   }   int main() {     double x, y, z;     cin >> x >> y >> z;     map<int, string> expr;     expr[1] =  x^y^z ;     expr[2] =  x^z^y ;     expr[3] =  (x^y)^z ;     expr[5] =  y^x^z ;     expr[6] =  y^z^x ;     expr[7] =  (y^x)^z ;     expr[9] =  z^x^y ;     expr[10] =  z^y^x ;     expr[11] =  (z^x)^y ;     vector<pair<int, double> > nums;     if (x < 1 || x < 1 || x < 1) {       nums.push_back(make_pair(1, pow(y, z) * log(x)));       nums.push_back(make_pair(2, pow(z, y) * log(x)));       nums.push_back(make_pair(3, y * z * log(x)));       nums.push_back(make_pair(5, pow(x, z) * log(y)));       nums.push_back(make_pair(6, pow(z, x) * log(y)));       nums.push_back(make_pair(7, x * z * log(y)));       nums.push_back(make_pair(9, pow(x, y) * log(z)));       nums.push_back(make_pair(10, pow(y, x) * log(z)));       nums.push_back(make_pair(11, x * y * log(z)));     } else {       nums.push_back(make_pair(1, z * log(y) + log(log(x))));       nums.push_back(make_pair(2, y * log(z) + log(log(x))));       nums.push_back(make_pair(3, log(y) + log(z) + log(log(x))));       nums.push_back(make_pair(5, z * log(x) + log(log(y))));       nums.push_back(make_pair(6, x * log(z) + log(log(y))));       nums.push_back(make_pair(7, log(x) + log(z) + log(log(y))));       nums.push_back(make_pair(9, y * log(x) + log(log(z))));       nums.push_back(make_pair(10, x * log(y) + log(log(z))));       nums.push_back(make_pair(11, log(x) + log(y) + log(log(z))));     }     sort(nums.begin(), nums.end(), pid_comp_second);     cout << expr[nums[0].first] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   ofstream fo( test.out );   ifstream fi( test.inp );   const long long MOD = 1e9 + 7;   const long long base = 269;   const int N = 1e5 + 5;   long long n, m, q, K, pos, t, rs, r;   long long cnt10, cnt11;   string s, a, b;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n;     cin >> a >> b;     for (long long(i) = 0; (i) < (n); (i)++) {       if (a[i] ==  1  && b[i] ==  0 ) cnt10++;       if (a[i] ==  1  && b[i] ==  1 ) cnt11++;     }     for (long long(i) = 0; (i) < (n); (i)++) {       if (a[i] ==  0  && b[i] ==  0 ) {         rs += cnt11;         rs += cnt10;       }       if (a[i] ==  0  && b[i] ==  1 ) rs += cnt10;     }     cout << rs;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n, ind;     cin >> t;     while (t--) {       cin >> n;       ind = -1;       int a[n];       for (int i = 0; i < n; ++i) {         cin >> a[i];         if (a[i] % 2 == 0) ind = i;       }       if (ind != -1)         cout <<  1 n  << ind + 1 <<   n ;       else if (n > 1)         cout <<  2 n1 2 n ;       else         cout <<  -1 n ;     }   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   struct my {     int a;     double b;   };   bool Cmp(my a, my b) { return a.b <= b.b; }   int main() {     int n, m;     cin >> n >> m;     my mine[n];     for (int i = 0; i < n; ++i) {       int a;       cin >> a;       double b;       cin >> b;       mine[i].a = a;       mine[i].b = b;     }     sort(mine, mine + n, Cmp);     int ord[n];     for (int i = 0; i < n; ++i) {       ord[i] = mine[i].a;     }     int dp[n];     for (int i = 0; i < n; ++i) {       dp[i] = 1;     }     for (int i = 0; i < n; i++) {       for (int j = i - 1; j >= 0; j--) {         if (ord[j] <= ord[i]) {           dp[i] = max(dp[j] + 1, dp[i]);         }       }     }     cout << n - *max_element(dp, dp + n) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 1e7 + 10, M = 998244353;   int n, m, k, inv[Maxn], s[Maxn], idk[Maxn];   int mo2(int x) { return (x < 0) ? x + M : x; }   int fpow(int a, int p = M - 2) {     int ret = 1;     for (; p; p >>= 1, a = 1ll * a * a % M)       if (p & 1) ret = 1ll * ret * a % M;     return ret;   }   void init(int n) {     inv[1] = 1;     for (int i = 2; i <= n; i++) inv[i] = M - 1ll * inv[M % i] * (M / i) % M;   }   void get_idk(int k) {     for (int i = 0; i <= k; i++) idk[i] = fpow(i, k);   }   int main() {     scanf( %d%d%d , &n, &m, &k);     int p = fpow(m);     init(k);     s[k] = 1;     int pw = 1, C = 1;     for (int i = k - 1; i >= 0; i--) {       pw = 1ll * pw * (M - p) % M;       C = 1ll * C * (n - i - 1 + M) % M * inv[k - i] % M;       s[i] = (1ll * (1 - p + M) * s[i + 1] + 1ll * C * pw) % M;     }     int E = 0;     pw = C = 1;     get_idk(k);     for (int i = 1; i <= k; i++) {       pw = 1ll * pw * p % M;       C = 1ll * C * (n - i + 1 + M) % M * inv[i] % M;       E = (E + 1ll * idk[i] * C % M * pw % M * s[i]) % M;     }     printf( %d n , E);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000009;   const double PI = acos(-1.0);   const double eps = 1e-8;   const int MAXN = 0;   const int MAXM = 0;   bool a[5002];   int i, j, k, n, h, m, id, p, hesh;   map<int, int> M;   char c;   int ans = 0;   int main() {     cin >> h >> m >> n;     for (i = 0; i < n; i++) {       cin >> c;       if (c ==  - ) {         cin >> id;         a[M[id]] = 0;       } else {         cin >> id >> hesh;         while (a[hesh] != 0) {           hesh = (hesh + m) % h;           ans++;         }         a[hesh] = true;         M[id] = hesh;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, a, b, x, y, ans = 0;     scanf( %d , &n);     printf( YES n );     for (int i = 1; i <= n; i++) {       scanf( %d %d %d %d , &a, &b, &x, &y);       x = min(a, x);       y = min(y, b);       ans = abs(x) % 2;       ans = ans * 2 + (abs(y) % 2);       printf( %d n , ans + 1);     }   }