malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t = 1, n, k = 0, flag = -1, b = 0;     while (t--) {       scanf( %lld , &n);       k = 0;       while (n != flag) {         if (n / 10 == 0 && b == 0) {           flag = n;           b = 1;         }         k++;         n++;         while (n % 10 == 0) {           n = n / 10;         }       }       printf( %lld n , k);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t[40008];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m, k, l, p;     cin >> n;     string s;     map<string, string> ex;     map<string, int> kol;     map<string, int> wh;     for (int u = 1; u <= n; u++) {       cin >> s;       for (int i = 0; i < s.length(); i++) {         string q;         for (int j = i; j < s.length(); j++) {           q += s[j];           if (wh[q] == u) continue;           if (kol[q] == 0) {             ex[q] = s;           }           wh[q] = u;           kol[q]++;         }       }     }     int kk;     cin >> kk;     for (int i = 0; i < kk; i++) {       string s;       cin >> s;       int kko = kol[s];       cout << kko <<    ;       if (kko == 0) {         cout <<  - n ;       } else {         cout << ex[s] <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int mid = (m + 1) / 2;     int cnt = 0;     int ans[m + 1];     if (m % 2) {       int i = 1;       int cnt = 1;       int k = 1;       ans[k++] = mid;       while (true) {         if (cnt > m) break;         ans[k++] = mid - i;         cnt++;         if (cnt > m) break;         ans[k++] = mid + i;         cnt++;         i++;       }     } else {       int i = 1;       int cnt = 0;       int k = 1;       while (true) {         if (cnt > m) break;         ans[k++] = mid - i + 1;         cnt++;         if (cnt > m) break;         ans[k++] = mid + i;         cnt++;         i++;       }     }     int k = 1;     for (int i = (1); i <= (n); i++) {       cout << ans[k++] << endl;       if (k > m) k = 1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, d[105];   char x[205];   int main() {     scanf( %d%d%s , &n, &m, x);     d[0] = 1;     for (int i = 0; i < n; i++)       if (x[i] ==  1  && d[i])         for (int j = 1; j <= m; j++)           if (x[i + j] ==  1  && (!d[i + j] || d[i + j] > d[i] + 1))             d[i + j] = d[i] + 1;     printf( %d n , d[n - 1] - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;      int main(){    int t,n,d;    int a[110],b[110];            scanf( %d ,&t);    while(t--){     scanf( %d%d ,&n,&d);     int fir=200,sec=200;     int fid,sid;     int x[110];     int xid[110];     int c=0;          for(int i=1;i<=n;i++){      scanf( %d ,&a[i]);      if(a[i]<fir){       sec=fir;fir=a[i];       sid=fid;fid=i;      }      else if(a[i]<sec){sec=a[i];sid=i;}      if(a[i]>d){       x[++c]=a[i];       xid[c]=i;      }     }     if(fir>d||sec>d||(c>=1&&fir+sec>d))printf( NO n );     else printf( YES n );    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   inline void chkmin(T1 &first, T2 second) {     if (first > second) first = second;   }   template <typename T1, typename T2>   inline void chkmax(T1 &first, T2 second) {     if (first < second) first = second;   }   const string FileName =  input ;   const int MAXN = 3e5 + 100;   int n, k, b, c;   vector<int> arr;   vector<int> event[5];   long long sum, mod, ans = 1e18;   multiset<long long> que;   long long f(long long s, long long t) {     return ((t - s) / 5) * b + ((t - s) % 5) * c;   }   int main(int argc, char const *argv[]) {     srand(time(0));     ios::sync_with_stdio(0);     cin >> n >> k >> b >> c;     arr.resize(n);     b = min(b, c * 5);     for (int i = 0; i < n; ++i) {       cin >> arr[i];     }     sort(arr.begin(), arr.end());     for (int i = 0; i < n; ++i) {       for (int j = 0; j < 5; ++j) {         event[(((arr[i] + j) % 5) + 5) % 5].push_back(arr[i] + j);       }     }     for (int j = 0; j < 5; ++j) {       int L = 0;       sum = 0, mod = 0;       que.clear();       for (int i = 0; i < n; ++i) {         while (L < n && arr[L] <= event[j][i]) {           que.insert(-f(arr[L], event[j][i]) - mod);           sum += f(arr[L], event[j][i]);           ++L;         }         while (que.size() > k) {           sum += *que.begin() + mod;           que.erase(que.begin());         }         if (que.size() == k) {           ans = min(ans, sum);         }         if (i != n - 1) {           assert(event[j][i] <= event[j][i + 1]);           mod -= f(event[j][i], event[j][i + 1]);           sum += f(event[j][i], event[j][i + 1]) * que.size();         }       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, a[400010];   map<int, int> m;   set<pair<int, int> > s;   long long ans = 0;   int main() {     cin >> n >> k;     for (int i = 1; i <= n; ++i) cin >> a[i];     a[0] = 0;     for (int l = 1, r = 0; l <= n; ++l) {       s.erase(make_pair(-m[a[l - 1]], a[l - 1]));       m[a[l - 1]]--;       s.insert(make_pair(-m[a[l - 1]], a[l - 1]));       while (-s.begin()->first < k) {         ++r;         if (r >= n + 1) break;         s.erase(make_pair(-m[a[r]], a[r]));         m[a[r]]++;         s.insert(make_pair(-m[a[r]], a[r]));       }       ans += max(n + 1 - r, 0);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long a[n];       vector<long long> v;       for (long long i = 0; i < n; i++) {         cin >> a[i];         v.push_back(a[i]);       }       bool ans = true;       sort(v.begin(), v.end());       for (long long i = 0; i < n; i++) {         if (a[i] != v[i] && a[i] % v[0] > 0) {           ans = false;           break;         }       }       if (ans)         cout <<  YES ;       else         cout <<  NO ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 10;   int fa[maxn], cnt[maxn], vis[maxn], arr[maxn];   int fi(int x) { return x == fa[x] ? x : fa[x] = fi(fa[x]); }   int main(int argc, char const *argv[]) {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; ++i) fa[i] = i, cnt[i] = 0, vis[i] = 0, arr[i] = 0;     for (int i = 1, a, b; i <= m; ++i) {       scanf( %d %d , &a, &b);       cnt[a]++;       cnt[b]++;       vis[a] = 1;       vis[b] = 1;       int fx = fi(a), fy = fi(b);       if (fx != fy) fa[fx] = fy;     }     int ans = 0, tot = 0;     for (int i = 1; i <= n; ++i) {       if (cnt[i] % 2 == 1) {         arr[fi(i)]++;       }     }     int ff = 0;     int cnt2 = 0, cnt1 = 0;     for (int i = 2; i <= n; ++i)       if (vis[i] == 1) ff = 1;     int cnt = 0;     for (int i = 1; i <= n; ++i) {       if (vis[i] && fa[i] == i && arr[i] >= 2) {         tot = tot + (arr[i] - 2) / 2;         ++cnt2;       }       if (vis[i] && fa[i] == i) tot += 1, cnt++;     }     cnt1 = cnt - cnt2;     if (cnt == 1) {       if (cnt1 == 1) {         if (vis[1] == 0)           printf( 2 n );         else           printf( 0 n );       } else if (cnt2 == 1) {         if (vis[1] == 0) tot++;         printf( %d n , tot);       }     } else if (cnt == 0) {       printf( 0 n );     } else if (cnt >= 2) {       if (vis[1] == 0) ++tot;       printf( %d n , tot);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   void input() { cin >> n; }   void solve() {     int cnt = 0;     for (int i = 1; i <= n; ++i) {       if (cnt == n) {         break;       }       printf( %d 1 n , i);       ++cnt;       if (cnt == n) {         break;       }       if ((i % 2) == 0) {         printf( %d 4 n , i);         ++cnt;       }     }   }   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(NULL);     int t;     t = 1;     while (t--) {       input();       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int l = s.length();     cout << 4 << endl;     cout <<  R   << l - 1 << endl;     cout <<  L   << 2 << endl;     cout <<  L   << l + 1 << endl;     cout <<  L   << 2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const int dx[] = {0, 1, 0, -1};   const int dy[] = {1, 0, -1, 0};   int n, k;   string s;   int main() {     cin >> n >> k;     cin >> s;     int sum = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  # ) sum++;       if (sum >= k) {         puts( NO );         return 0;       }       if (s[i] ==  . ) sum = 0;     }     puts( YES );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int b[65], p = 1e9 + 7;   long long pow_(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = res * a % p;       b >>= 1, a = a * a % p;     }     return res % p;   }   void solve(int n, int x) {     int t = 0;     long long ans = 0;     while (x) {       if (x & 1) ans = (ans + pow_(n, t)) % p;       x >>= 1, t++;     }     cout << ans % p << endl;   }   int main() {     ios::sync_with_stdio(!true);     int t, n, k;     cin >> t;     while (t--) cin >> n >> k, solve(n, k);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5000 + 10;   const int BASE = 1e9 + 7;   int n;   int memo[N][N], _memo[N][N];   string s;   int _solve(int pos_1, int pos_2) {     if (pos_1 > n || pos_2 > n) return 0;     if (_memo[pos_1][pos_2] != -1) return _memo[pos_1][pos_2];     int cur = 0;     if (s[pos_1] == s[pos_2]) cur += _solve(pos_1 + 1, pos_2 + 1) + 1;     return _memo[pos_1][pos_2] = cur;   }   int solve(int pos, int len) {     if (s[pos] ==  0 ) return 0;     if (pos + len - 1 > n) return 0;     if (pos + len - 1 == n) return 1;     if (memo[pos][len] != -1) return memo[pos][len];     int cur = 0;     cur = (cur + solve(pos, len + 1)) % BASE;     if (pos + 2 * len - 1 <= n) {       int tmp = _solve(pos, pos + len);       if (tmp < len && s[pos + tmp] < s[pos + len + tmp]) {         cur = (cur + solve(pos + len, len)) % BASE;       } else         cur = (cur + solve(pos + len, len + 1)) % BASE;     }     return memo[pos][len] = cur;   }   int main() {     ios ::sync_with_stdio(0);     cin.tie(0);     cin >> n >> s;     s =  @  + s;     memset(memo, -1, sizeof(memo));     memset(_memo, -1, sizeof(_memo));     cout << solve(1, 1);   }
#include <bits/stdc++.h>   using namespace std;   int parent[100005];   int coun[100005];   bool isLucky(int a) {     while (a) {       int x = a % 10;       if (x == 4 || x == 7) {       } else         return false;       a = a / 10;     }     return true;   }   int findp(int a) {     if (parent[a] == a) {       return a;     }     parent[a] = findp(parent[a]);     return parent[a];   }   void uni(int x, int y) {     int parx = findp(x);     int pary = findp(y);     if (parx != pary) {       parent[parx] = pary;       coun[pary] += coun[parx];     }   }   vector<int> vec[100005];   int main() {     ios::sync_with_stdio(false);     cin.tie();     cout.tie();     long long int n, i, j, k, x, y, c = 0, ans = 0, z, z1;     cin >> n;     for (int i = 1; i < n + 1; i++) {       coun[i] = 1;       parent[i] = i;     }     for (int i = 0; i < n - 1; i++) {       cin >> x >> y >> z;       if (!isLucky(z)) {         vec[x].push_back(y);         vec[y].push_back(x);         uni(x, y);       }     }     for (i = 1; i <= n; i++) {       int x = findp(i);       int y = coun[x];       ans += (n - y) * (n - y - 1);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fscpp() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int main() {     fscpp();     long long n;     cin >> n;     long long ct = 0;     long long xm, ym;     long long x, y;     cin >> xm >> ym;     vector<long long> vx(n), vy(n);     vx[0] = xm;     vy[0] = ym;     for (long long int i = 1; i < n; i++) {       cin >> x >> y;       vx[i] = x;       vy[i] = y;     }     vector<long long> mvx(vx), mvy(vy);     sort(mvx.begin(), mvx.end());     sort(mvy.begin(), mvy.end());     long long max1 = mvx[n - 1], max2 = mvx[n - 2];     long long min1 = mvy[0], min2 = mvy[1];     long long len = min1 - max1;     if (len < 0) len = 0;     long long rx, ry;     for (long long int i = 0; i < n; i++) {       if (max1 == vx[i])         rx = max2;       else         rx = max1;       if (min1 == vy[i])         ry = min2;       else         ry = min1;       if (ry - rx > len) len = ry - rx;     }     len--;     cout << len + 1;     int p = 23;     string s = std::bitset<63>(p).to_string();     string h;     string g;     g = s;     for (long long int i = s.size() - 2; i < s.size(); i++) h += s[i];     y = h.size();     s.clear();     for (long long int i = 0; i < 31 - y; i++) {       s +=  1 ;     }     sort(s.begin(), s.end());     s.erase(unique(s.begin(), s.end()), s.end());     for (long long int i = 0; i < y; i++) {       s += h[i];     }     y = std::bitset<63>(g).to_ulong();     g.clear();     if (g.size() != 0) cout <<  yedhukku n t n ;     reverse(s.begin(), s.end());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxint = -1u >> 1;   const double pi = 3.14159265358979323;   const double eps = 1e-8;   int n, k, a[100100];   set<long long> vis;   int main() {     scanf( %d%d , &n, &k);     for (int i = (0); i < (n); i++) scanf( %d , &a[i]);     sort(a, a + n);     int ans = 0;     for (int i = (0); i < (n); i++) {       if (vis.find(a[i]) == vis.end()) {         ans++;         vis.insert(1LL * a[i] * k);       } else         continue;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string str;     cin >> str;     int t = 0;     while (str[t]) {       if (str[t] ==  . ) {         cout << 0;         t++;       } else if (str[t] ==  -  && str[t + 1] ==  . ) {         cout << 1;         t += 2;       } else if (str[t] ==  -  && str[t + 1] ==  - ) {         cout << 2;         t += 2;       }     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 100 + 10;   const int MAX_V = 200 + 10;   const int MAX_S = 1 << 7;   const int INF = 1000000;   const int dx[] = {-1, 0, 1, 0};   const int dy[] = {0, 1, 0, -1};   int N, M, K, S;   int w[MAX_N][MAX_N];   int f[MAX_N][MAX_N][MAX_S];   int pre[MAX_N][MAX_N][MAX_S];   int qx[MAX_V];   int qy[MAX_V];   int in[MAX_N][MAX_N];   int cov[MAX_N][MAX_N];   void Init() {     int x, y;     scanf( %d%d%d , &N, &M, &K);     S = 1 << K;     for (int i = 1; i <= N; ++i)       for (int j = 1; j <= M; ++j) scanf( %d , &w[i][j]);     for (int i = 1; i <= N; ++i)       for (int j = 1; j <= M; ++j)         for (int k = 1; k < S; ++k) {           f[i][j][k] = INF;           pre[i][j][k] = INF;         }     for (int i = 0; i < K; ++i) {       scanf( %d%d , &x, &y);       f[x][y][1 << i] = w[x][y];     }   }   void SPFA(int s) {     int qh = 0, qt = 0;     for (int i = 1; i <= N; ++i)       for (int j = 1; j <= M; ++j) {         qx[qt] = i;         qy[qt++] = j;         in[i][j] = true;       }     int nx, ny, px, py;     for (; qh < qt;) {       px = qx[qh];       py = qy[qh++];       for (int i = 0; i < 4; ++i) {         nx = px + dx[i];         ny = py + dy[i];         if (nx > 0 && nx <= N && ny > 0 && ny <= M &&             f[nx][ny][s] > f[px][py][s] + w[nx][ny]) {           f[nx][ny][s] = f[px][py][s] + w[nx][ny];           pre[nx][ny][s] = -i;           if (!in[nx][ny]) {             in[nx][ny] = true;             qx[qt] = nx;             qy[qt++] = ny;           }         }       }       in[px][py] = false;     }   }   void DFS(int x, int y, int s) {     cov[x][y] = true;     int tmp = pre[x][y][s];     if (tmp == INF) return;     if (tmp <= 0)       DFS(x - dx[-tmp], y - dy[-tmp], s);     else       DFS(x, y, tmp), DFS(x, y, s - tmp);   }   void Solve() {     for (int s = 1; s < S; ++s) {       for (int i = 1; i <= N; ++i)         for (int j = 1; j <= M; ++j)           for (int ns = (s - 1) & s; ns; ns = (ns - 1) & s)             if (f[i][j][s] > f[i][j][ns] + f[i][j][s - ns] - w[i][j]) {               f[i][j][s] = f[i][j][ns] + f[i][j][s - ns] - w[i][j];               pre[i][j][s] = ns;             }       SPFA(s);       if (0) {         printf( Now is state %d n , s);         for (int i = 1; i <= N; ++i) {           for (int j = 1; j <= M; ++j) printf( %d  , f[i][j][s]);           printf(  n );         }       }     }     int ax, ay, ans = INF;     for (int i = 1; i <= N; ++i)       for (int j = 1; j <= M; ++j)         if (f[i][j][S - 1] < ans) {           ans = f[i][j][S - 1];           ax = i, ay = j;         }     printf( %d n , ans);     DFS(ax, ay, S - 1);     for (int i = 1; i <= N; ++i) {       for (int j = 1; j <= M; ++j) putchar(cov[i][j] ?  X  :  . );       putchar(  n );     }   }   int main() {     Init();     Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isprime(long long n) {     if (n < 2) return false;     if (n == 2) return true;     if (n % 2 == 0) return false;     for (int i = 3; i * i <= n; i = i + 2) {       if (n % i == 0) return false;     }     return true;   }   int main() {     int w, h, k;     cin >> w >> h >> k;     int sum = 0;     while (k--) {       sum += (2 * w + (2 * (h - 2)));       w -= 4;       h -= 4;     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, r, s;     cin >> n;     if (n % 2 == 1) {       if (n == 1) {         cout <<  -1 ;       } else {         r = (n * n - 1) / 2;         s = (n * n + 1) / 2;         cout << r <<     << s;       }     } else {       if (n == 2) {         cout <<  -1 ;       } else {         r = (n / 2) * (n / 2) - 1;         s = (n / 2) * (n / 2) + 1;         cout << r <<     << s;       }     }     cout << endl;   }
#include <bits/stdc++.h>   const double eps = 1e-11;   int dx[] = {-1, 0, 1, 0};   int dy[] = {0, 1, 0, -1};   using namespace std;   const int maxn = 1005;   int n;   typedef struct node_ {     int x, y;   } N;   N node[maxn];   pair<int, pair<int, int> > ans[100005];   int cnt;   void deal(int t, int a, int b) {     ans[cnt].first = t, ans[cnt].second.first = a, ans[cnt++].second.second = b;   }   int main() {     while (scanf( %d , &n) == 1) {       cnt = 0;       for (int i = (1); i < (n); i++) {         scanf( %d%d , &node[i].x, &node[i].y);       }       for (int i = 1; i < n; i++) {         int tmp;         if (node[i].x != i + 1) {           tmp = node[i].x;           for (int j = (1); j < (n); j++) {             if (node[j].x == tmp) {               node[j].x = i + 1;             } else if (node[j].x == i + 1) {               node[j].x = tmp;             }           }           deal(1, tmp, i + 1);         }         if (node[i].y > i) {           tmp = node[i].y;           for (int j = (1); j < (n); j++) {             if (node[j].y == tmp) {               node[j].y = i;             } else if (node[j].y == i) {               node[j].y = tmp;             }           }           deal(2, tmp, i);         }       }       printf( %d n , cnt);       for (int i = 0; i < cnt; i++) {         printf( %d %d %d n , ans[i].first, ans[i].second.first,                ans[i].second.second);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 6;   namespace AC {   int tot, tr[N][26];   int fail[N];   int cnt[N];   int sid[N];   int next[N];   bool vis[N];   int isend[N];   int in[N];   int val[N];   int victim[N];   queue<int> q;   void init() {     memset(fail, 0, sizeof(fail));     memset(tr, 0, sizeof(tr));     memset(cnt, 0, sizeof(cnt));     memset(vis, false, sizeof vis);     memset(sid, 0, sizeof sid);     memset(val, 0, sizeof val);     memset(isend, 0, sizeof isend);     memset(victim, 0, sizeof victim);     memset(next, 0, sizeof next);     tot = 0;   }   void insert(char *s, int id) {     int u = 0;     for (int i = 1; s[i]; i++) {       if (!tr[u][s[i] -  a ]) tr[u][s[i] -  a ] = ++tot;       u = tr[u][s[i] -  a ];     }     sid[id] = u;     isend[u] = true;   }   void build() {     next[0] = 0;     for (int i = 0; i < 26; i++)       if (tr[0][i]) q.push(tr[0][i]);     while (q.size()) {       int u = q.front();       q.pop();       for (int i = 0; i < 26; i++) {         if (tr[u][i]) {           fail[tr[u][i]] = tr[fail[u]][i], q.push(tr[u][i]);           in[fail[tr[u][i]]] += 1;         } else           tr[u][i] = tr[fail[u]][i];         next[tr[u][i]] =             isend[fail[tr[u][i]]] ? fail[tr[u][i]] : next[fail[tr[u][i]]];       }     }   }   int query(char *t) {     int u = 0, res = -1;     for (int i = 1; t[i]; i++) {       u = tr[u][t[i] -  a ];       for (int x = u; x; x = next[x]) {         if (isend[x]) {           res = max(res, victim[x]);         }       }     }     return res;   }   void query(char *t, int) {     int u = 0;     for (int i = 1; t[i]; i++) {       u = tr[u][t[i] -  a ];       val[u] += 1;     }   }   void topoSort() {     for (int i = 0; i < N; ++i)       if (in[i] == 0) q.push(i);     while (!q.empty()) {       int u = q.front();       q.pop();       int v = fail[u];       in[v]--;       val[v] += val[u];       if (in[v] == 0) q.push(v);     }   }   }  // namespace AC   char s[N];   int val[N];   map<int, int> mp[N];   int main() {     int ans = 0;     int n, m;     cin >> n >> m;     AC::init();     for (int i = 0; i < n; i++) {       scanf( %s , s + 1);       AC::insert(s, i);       mp[AC::sid[i]][0] += 1;     }     AC::build();     while (m--) {       int x, c, v;       scanf( %d , &x);       if (x == 1) {         scanf( %d %d , &c, &v);         mp[AC::sid[c - 1]][val[c - 1]] -= 1;         if (mp[AC::sid[c - 1]][val[c - 1]] == 0) {           mp[AC::sid[c - 1]].erase(val[c - 1]);         }         val[c - 1] = v;         mp[AC::sid[c - 1]][v] += 1;         AC::victim[AC::sid[c - 1]] = (*--mp[AC::sid[c - 1]].end()).first;         continue;       }       scanf( %s , s + 1);       cout << AC::query(s) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> a;   vector<pair<int, int> > s;   int main() {     ios::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       a.push_back(x);     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n - 1; j++) {         if (a[j] > a[j + 1]) {           swap(a[j], a[j + 1]);           s.push_back({j + 1, j + 2});         }       }     }     for (auto a : s) {       cout << a.first <<     << a.second <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     short n, before, after;     cin >> n;     string a;     bool flag = false;     for (short i = 0; i < n; i++) {       cin >> a;       cin >> before;       cin >> after;       if (after >= 2400 && before >= 2400 && after - before > 0) flag = true;     }     if (flag == true)       cout <<  YES ;     else       cout <<  NO ;   }
#include<bits/stdc++.h>   #define pb push_back   #define int long long   using namespace std;   int p=998244353,tt,n,m,fac[25];   void prepare(){    fac[0]=1;    for(int i=1;i<25;i++){     fac[i]=(fac[i-1]*i)%p;    }   }   int inv(int z){    int s=p-2,t=z,ans=1;       while(s>0){        if(s%2)ans=(ans*t)%p;        t=(t*t)%p;        s/=2;       }       return ans;   }   void solve(){    prepare();    cin>>n>>m;    int a[n+1][m+1],x=0;    for(int i=1;i<=n;i++){     for(int j=1;j<=m;j++){      cin>>a[i][j];     }    }    for(int i=1;i<=m;i++){     vector<int> v;     for(int j=1;j<=n;j++)v.pb(a[j][i]);        sort(v.begin(),v.end());        int c=1;        for(int i=0;i<n;i++){         c=(c*(v[i]-i-1))%p;        }        x=(x+fac[n]-c+p)%p;    }       cout<<((x*inv(fac[n]))%p)<<  n ;    }      signed main(){       #ifndef ONLINE_JUDGE       freopen( input.txt , r ,stdin);       freopen( output.txt , w ,stdout);       #endif       ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);       //cin>>tt;       //while(tt--)       solve();   }