malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   int ma[10][10];   bool vis[20];   int isok[20][20], tmp[20][20];   int n, m, ok = 0;   int dx[] = {1, 0, -1, 0};   int dy[] = {0, 1, 0, -1};   void solve() {     puts( YES );     if (n > 4) {       for (int i = 1; i <= m; i++) {         if (i % 2) {           for (int j = 1; j <= n; j += 2) printf( %d  , (i - 1) * n + j);           for (int j = 2; j <= n; j += 2) printf( %d  , (i - 1) * n + j);         } else {           for (int j = 2; j <= n; j += 2) printf( %d  , (i - 1) * n + j);           for (int j = 1; j <= n; j += 2) printf( %d  , (i - 1) * n + j);         }         puts(  );       }     } else {       int s1 = 1;       int s2 = 2;       for (int i = 1; i <= m; i++) {         for (int j = 1; j <= n; j++) {           if (j % 2) {             if (s1 > m) s1 = 2;             printf( %d  , (s1 - 1) * n + j);           } else {             if (s2 > m) s2 = 1;             printf( %d  , (s2 - 1) * n + j);           }         }         s1 += 2;         s2 += 2;         puts(  );       }     }   }   void init() {     for (int i = 1; i < (m + 1); ++i)       for (int j = 1; j < (n + 1); ++j) tmp[i][j] = (i - 1) * n + j;     for (int i = 1; i < (n * m + 1); ++i)       for (int j = 1; j < (m * n + 1); ++j) isok[i][j] = 1;     for (int i = 1; i < (m + 1); ++i)       for (int j = 1; j < (n + 1); ++j) {         for (int k = 0; k < (4); ++k) {           int xx = i + dx[k];           int yy = j + dy[k];           if (xx < 1 || xx > m || yy < 1 || yy > n)             continue;           else             isok[tmp[xx][yy]][tmp[i][j]] = isok[tmp[i][j]][tmp[xx][yy]] = 0;         }       }   }   void dfs(int dep) {     if (dep == n * m || ok) {       ok = 1;       return;     } else {       for (int i = 1; i < (n * m + 1); ++i) {         int flag = 1;         if (vis[i])           continue;         else {           int flag = 1;           ++dep;           int row = (dep - 1) / n + 1;           int col = (dep - 1) % n + 1;           if (row > 1) {             int nxt1 = ma[row - 1][col];             if (!isok[nxt1][i]) flag = 0;           }           if (col > 1) {             int nxt2 = ma[row][col - 1];             if (!isok[nxt2][i]) flag = 0;           }           if (flag == 0) {             dep--;             continue;           }           ma[row][col] = i;           vis[i] = 1;           dfs(dep);           if (ok) return;           ma[row][col] = 0;           vis[i] = 0;           --dep;         }       }     }   }   int main() {     scanf( %d%d , &m, &n);     if (max(n, m) > 4)       solve();     else {       init();       for (int i = 1; i < (n * m + 1); ++i)         if (!ok) {           memset(vis, 0, sizeof(vis));           memset(ma, 0, sizeof(ma));           vis[i] = 1;           ma[1][1] = i;           dfs(1);         }       if (!ok)         printf( NO );       else {         puts( YES );         for (int i = 1; i < (m + 1); ++i) {           for (int j = 1; j < (n + 1); ++j) printf( %d  , ma[i][j]);           puts(  );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     for (int i = 0; i < 10; i++) {       cout << i << endl;       getline(cin, s);       if (s ==  great  || s ==  cool  || s ==  not bad  ||           s ==  don t touch me  || s ==  don t think so ) {         cout <<  normal n ;         return 0;       } else if (s ==  don t even  || s ==  are you serious  || s ==  no way  ||                  s ==  worse  || s ==  terrible  || s ==  go die in a hole ) {         cout <<  grumpy n ;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, pair<long long, long long> > mp;   pair<long long, long long> dfs(long long x) {     if (x == 0) return make_pair(0, 0);     if (mp.count(x)) return mp[x];     long long t = pow(x + 0.5, 1.0 / 3);     pair<long long, long long> res = dfs(t * t * t - 1);     pair<long long, long long> tmp = dfs(x - t * t * t);     res = max(res, make_pair(tmp.first + 1, tmp.second + t * t * t));     mp[x] = res;     return res;   }   int main() {     long long m;     scanf( %lld , &m);     pair<long long, long long> ans = dfs(m);     printf( %lld %lld n , ans.first, ans.second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, m, t;   long long sum(int l, int r) {     long long sl = a + (l - 1) * b;     long long sr = a + (r - 1) * b;     return (sl + sr) * (r - l + 1) / 2;   }   bool chk(int l, int x) {     return a + 1LL * (x - 1) * b <= 1LL * t && sum(l, x) <= 1LL * m * t;   }   int main(void) {     int q;     cin >> a >> b >> q;     while (q--) {       int l;       cin >> l >> t >> m;       int lo = l - 1, hi = 1000000000;       while (lo != hi) {         int mi = (lo + hi + 1) / 2;         if (chk(l, mi))           lo = mi;         else           hi = mi - 1;       }       if (lo < l)         cout <<  -1 n ;       else         cout << lo <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void PAUSE() {     char tmp;     cin >> tmp;   }   int M[100001];   int f[100001];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i <= 100000; i++) {       M[i] = -1;     }     int x, k;     for (int i = 0; i < n; i++) {       scanf( %d %d , &x, &k);       if (x - M[k] > 1) {         cout <<  NO ;         return 0;       }       M[k] = x > M[k] ? x : M[k];       f[k] = 1;     }     cout <<  YES ;     PAUSE();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long ans = 0;     long long a, b, c, s;     cin >> s >> a >> b >> c;     ans = s / c + (s / c / a) * b;     cout << ans << endl;   }   int main() {     int T;     cin >> T;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[256], n, k, p;     cin >> n >> k;     memset(a, -1, sizeof(a));     for (int i = 0; i < n; i++) {       cin >> p;       if (a[p] == -1) {         for (int j = max(0, p - k + 1); j <= p; j++)           if (a[j] == -1 || a[j] == j) {             for (int x = j; x <= p; x++) a[x] = j;             break;           }       }       cout << a[p] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = (int)1e9;   const int mod = inf + 7;   const double eps = 1e-9;   int a[100][100];   int n, x, y;   bool u[400], u1[400];   vector<int> v;   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int i = 1; i <= n * n; i++) {       cin >> x >> y;       if (!u[x] && !u1[y]) {         u[x] = 1;         u1[y] = 1;         v.push_back(i);       }     }     for (int i = 0; i < v.size(); i++) {       cout << v[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int n, k;     cin >> n >> k;     long long int a[n + 2];     a[0] = 0;     pair<long long int, long long int> min;     min.first = INT_MAX;     for (long long int i = 1; i <= n; i++) {       cin >> a[i];       a[i] += a[i - 1];       if (i >= k) {         a[i] -= a[i - k];         if (a[i] < min.first) min.first = a[i], min.second = i - k + 1;         a[i] += a[i - k];       }     }     cout << min.second;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1.01e9;   const double eps = 1e-9;   const int N = 22;   double RES = 0;   double rf, re, rs;   double df, de;   int cnt = 0;   int a[N];   int ac = 0;   int b[N];   int bc = 0;   int nf, ne, ns;   double e[N];   double FI[200];   double EN[200];   double FIRE(int p) {     double res = rf * 2;     for (int i = 0; (i) < (bc); ++i) res += FI[abs(b[i] - p)];     res *= df;     return res;   }   double ENERGY(int p) {     double res = re * 2;     for (int i = 0; (i) < (bc); ++i) res += EN[abs(b[i] - p)];     res *= de;     return res;   }   void solve() {     double val = 0;     for (int i = 0; (i) < (ac); ++i) {       double x = FIRE(a[i]);       double y = ENERGY(a[i]);       e[i] = x - y;       val += y;     }     sort(e, e + ac);     reverse(e, e + ac);     for (int i = 0; (i) < (nf); ++i) val += e[i];     RES = max(RES, val);   }   void go(int x, int y, int pos, int cnt1 = 0, int cnt2 = 0) {     if (x == 0 && y == 0) {       cnt++;       solve();       return;     }     if (x >= 1 && cnt1 < 2) {       a[ac++] = pos;       go(x - 1, y, pos + 1, cnt1 + 1, cnt2);       ac--;     }     if (x >= 2) {       a[ac++] = pos;       a[ac++] = pos;       go(x - 2, y, pos + 1, cnt1, cnt2);       ac--;       ac--;     }     if (y >= 1 && cnt2 < 1) {       b[bc++] = pos;       go(x, y - 1, pos + 1, cnt1, cnt2 + 1);       bc--;     }     if (y >= 2) {       b[bc++] = pos;       b[bc++] = pos;       go(x, y - 2, pos + 1, cnt1, cnt2);       bc--;       bc--;     }     if (x >= 1 && y >= 1) {       a[ac++] = pos;       b[bc++] = pos;       go(x - 1, y - 1, pos + 1, cnt1, cnt2);       ac--;       bc--;     }   }   int main() {     scanf( %d%d%d , &nf, &ne, &ns);     scanf( %lf%lf%lf , &rf, &re, &rs);     scanf( %lf%lf , &df, &de);     rf = sqrt(max(0., rf * rf - 1));     re = sqrt(max(0., re * re - 1));     rs = sqrt(max(0., rs * rs - 1));     for (int i = 0; i < 100; ++i) {       double l1 = -rf;       double r1 = rf;       double l2 = i - rs;       double r2 = i + rs;       FI[i] = max(0., min(r1, r2) - max(l1, l2));     }     for (int i = 0; i < 100; ++i) {       double l1 = -re;       double r1 = re;       double l2 = i - rs;       double r2 = i + rs;       EN[i] = max(0., min(r1, r2) - max(l1, l2));     }     go(nf + ne, ns, 0);     fprintf(stderr,  %d n , cnt), fflush(stderr);     printf( %.10f n , RES);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long i, j, k, l, n, m, last, res;   long long a[100009];   queue<long long> q;   int main() {     cin >> n;     for (i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + 1 + n);     q.push(1);     for (i = 2; i <= n; i++) {       if (!q.empty() && a[q.front()] < a[i]) {         res++;         q.pop();       }       q.push(i);     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<pair<int, int> > s;   std::vector<int> vv;   std::vector<std::vector<int> > gr;   std::vector<int> vis;   int k;   pair<int, int> dfs(int u, int l) {     vis[u] = l;     vv.emplace_back(u);     for (int v : gr[u]) {       if ((vis[v]) && (vis[u] - vis[v]) >= k) {         return {vis[v], vis[u]};       } else if (!vis[v]) {         return dfs(v, l + 1);       }     }     return {-1, -1};   }   int32_t main() {     int n;     cin >> n;     int m;     cin >> m;     cin >> k;     gr.resize(n);     for (int i = 0; i < m; ++i) {       int u;       cin >> u;       u--;       int v;       cin >> v;       v--;       gr[u].emplace_back(v);       gr[v].emplace_back(u);     }     vis.resize(n, 0);     auto pp = dfs(0, 1);     cout << pp.second - pp.first + 1 <<   n ;     for (int i = pp.first - 1; i < pp.second; ++i) {       cout << vv[i] + 1 <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   inline void pisz(int n) { printf( %d n , n); }   template <typename T, typename TT>   ostream &operator<<(ostream &s, pair<T, TT> t) {     return s <<  (  << t.first <<  ,  << t.second <<  ) ;   }   template <typename T>   ostream &operator<<(ostream &s, vector<T> t) {     for (int(i) = 0; (i) < (((int)(t.size()))); ++(i)) s << t[i] <<    ;     return s;   }   template <typename T, typename Aug>   struct AugTreap {     struct Node {       T v;       int pr;       Node *le, *ri;       Aug al, ag;     };     Node *root;     AugTreap() : root(0) {}     inline static void recalc(Node *&n) {       Aug left = n->le ? n->le->ag + n->al : n->al;       n->ag = n->ri ? left + n->ri->ag : left;     }     inline void rotle(Node *&n) {       Node *syn = n->le;       n->le = syn->ri;       syn->ri = n;       n = syn;       recalc(n->ri);       recalc(n);     }     inline void rotri(Node *&n) {       Node *syn = n->ri;       n->ri = syn->le;       syn->le = n;       n = syn;       recalc(n->le);       recalc(n);     }     void insert_aux(Node *&n, const T &x, const Aug &aug) {       if (!n) {         n = new Node;         n->v = x;         n->pr = rand();         n->le = n->ri = 0;         n->al = n->ag = aug;       } else if (x < n->v) {         insert_aux(n->le, x, aug);         if (n->pr > n->le->pr)           rotle(n);         else           recalc(n);       } else if (x > n->v) {         insert_aux(n->ri, x, aug);         if (n->pr > n->ri->pr)           rotri(n);         else           recalc(n);       } else {         n->al = n->al + aug;         recalc(n);       }     }     void insert(const T &x, const Aug &aug) { insert_aux(root, x, aug); }     Aug sumgeq_aux(const T &x, Node *n) {       if (!n) return Aug();       if (x > n->v) return sumgeq_aux(x, n->ri);       if (x < n->v) {         Aug left = sumgeq_aux(x, n->le) + n->al;         return n->ri ? left + n->ri->ag : left;       }       return n->ri ? n->al + n->ri->ag : n->al;     }     Aug sumgeq(const T &x) { return sumgeq_aux(x, root); }   };   long long a[100007], prefsum[100007];   int main() {     long long n, k;     cin >> n >> k;     for (int(i) = 1; (i) <= (n); ++(i)) cin >> a[i];     prefsum[0] = 0;     for (int(i) = 1; (i) <= (n); ++(i)) prefsum[i] = prefsum[i - 1] + a[i];     long long best = -1000000000;     best *= 100000;     long long from = best + 1, to = -best;     while (from <= to) {       long long x = (from + to) / 2;       long long dobrychsum = 0, zab = 0;       AugTreap<long long, int> tr;       for (int(i) = 1; (i) <= (n); ++(i)) tr.insert(prefsum[i], 1);       for (int(st) = 1; (st) <= (n); ++(st)) {         dobrychsum += tr.sumgeq(x + zab);         zab += a[st];         tr.insert(zab, -1);       }       if (dobrychsum >= k) {         best = x;         from = x + 1;       } else {         to = x - 1;       }     }     cout << best;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int T;     cin >> T;     while (T--) {       long long n, k;       cin >> n >> k;       if (k % 3) {         if (n % 3)           cout <<  Alice n ;         else           cout <<  Bob n ;       } else {         n %= (k + 1);         if (n == k || n % 3)           cout <<  Alice n ;         else           cout <<  Bob n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int fu[2003];   int jar[2003];   int main() {     int n, refresh;     cin >> n >> refresh;     for (int(i) = 0; (i) < (n); ++(i)) {       cin >> jar[i];     }     for (int(i) = 0; (i) < (n); ++(i)) {       cin >> fu[i];     }     int best = fu[0];     int res = 0;     int gas = 0;     for (int i = 0; i < n; ++i) {       gas += fu[i];       best = max((best), (fu[i]));       while (gas < jar[i]) {         gas += best;         res += refresh;       }       gas -= jar[i];       res += jar[i];     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long cas;   long long a;   long long b;   long long c;   long long d[] = {0, 1, -1};   int main() {     scanf( %lld , &cas);     while (cas--) {       scanf( %lld %lld %lld , &a, &b, &c);       long long ans = 21413524368453;       for (long long i = 0; i < 3; ++i) {         long long aa = a + i;         for (long long j = 0; j < 3; ++j) {           long long bb = b + j;           for (long long k = 0; k < 3; ++k) {             long long cc = c + k;             ans = min(ans, abs(aa - bb) + abs(aa - cc) + abs(bb - cc));           }         }       }       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename TYPE>   void readint(TYPE &x) {     x = 0;     int f = 1;     char c;     for (c = getchar(); !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     x *= f;   }   void err(istream_iterator<string> it) {}   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a << endl;     err(++it, args...);   }   const long long MOD = 998244353LL, MAX = 3e5 + 5;   const int INF = 2e9;   int n;   long long ans;   long long a[MAX];   long long fc[MAX];   long long pot(long long x, long long y) {     if (!y) return 1LL;     if (y & 1)       return (x * pot(x, y - 1)) % MOD;     else {       long long k = pot(x, y / 2);       return (k * k) % MOD;     }   }   long long inv(long long t) { return pot(t, MOD - 2); }   void read(int w[], int n) {     for (long long i = 0; i < n; i++) {       cin >> w[i];     }   }   void solve() {     cin >> n;     fc[0] = 1LL;     for (long long i = 0; i < 2 * n; i++) cin >> a[i];     if (n == 1) {       cout << (a[1] - a[0]) * 2;       return;     }     sort(a, a + 2 * n);     for (long long i = 1; i < n * 2 + 1; i++) fc[i] = (fc[i - 1] * i) % MOD;     for (long long i = 0; i < n; i++) ans += (a[2 * n - 1 - i] - a[i]);     ans %= MOD;     {       string _s =  ans ;       replace(_s.begin(), _s.end(),  , ,    );       stringstream _ss(_s);       istream_iterator<string> _it(_ss);       err(_it, ans);     };     ans = (ans * (fc[n * 2])) % MOD;     ans *= inv((fc[n] * fc[n]) % MOD);     ans %= MOD;     ans %= MOD;     cout << ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long int, long long int> mymap, mymap1;   long long int cum[200010], a[200010];   int main() {     long long int n, i, j, k;     scanf( %lld , &n);     ;     scanf( %lld , &k);     ;     cum[0] = 0;     mymap[0]++;     for (i = 1; i <= n; i++) {       scanf( %lld , &a[i]);       ;       cum[i] = cum[i - 1] ^ a[i];       long long int temp1 = cum[i], temp2 = ((1 << k) - 1) ^ temp1;       if (mymap[temp1] == 0)         mymap[temp2]++;       else         mymap[temp1]++;     }     long long int ans = (n * (n + 1)) / 2;     map<long long int, long long int>::iterator it;     long long int subt = 0;     for (it = mymap.begin(); it != mymap.end(); it++) {       long long int val = it->first, freq = it->second;       long long int temp = freq / 2;       subt += ((temp * (temp - 1)) / 2);       temp = freq - temp;       subt += ((temp * (temp - 1)) / 2);     }     cout << ans - subt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void pv(T a, T b) {     for (T i = a; i != b; ++i) cerr << *i <<    ;     cout << endl;   }   int ans[100000 + 10];   int main() {     for (int N; ~scanf( %d , &N);) {       memset(ans, 0, sizeof(ans));       vector<int> a(N), b(N);       for (int i = 0; i < (int)(N); ++i) scanf( %d , &a[i]);       for (int i = 0; i < (int)(N); ++i) scanf( %d , &b[i]);       vector<long long> c(N);       for (int i = 0; i < (int)(N); ++i) c[i] = a[i] - b[i];       for (int i = 1; i < N; i++) c[i] += c[i - 1];       int small = *min_element((c).begin(), (c).end());       for (int i = 0; i < (int)(N); ++i)         if (c[i] == small) ans[(i + 1) % N] = 1;       for (int i = 0; i < (int)(N); ++i) c[i] = a[i] - b[(i - 1 + N) % N];       for (int i = N - 2; i >= 0; i--) c[i] += c[i + 1];       small = *min_element((c).begin(), (c).end());       for (int i = 0; i < (int)(N); ++i)         if (c[i] == small) ans[(i - 1 + N) % N] = 1;       cout << count(ans, ans + N, 1) << endl;       for (int i = 0; i < (int)(N); ++i)         if (ans[i]) cout << i + 1 <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int val[60];   int n;   int grid[2][60];   int mask1[25][1200008 + 1], mask2[25][1200008 + 1];   void solve(int l, int r, int mask[][1200008 + 1]) {     memset(mask, -1, sizeof mask);     for (int i = 0; i <= 24; i++)       for (int j = 0; j < 1200008 + 1; j++) mask[i][j] = -1;     for (int i = 0; i < (1 << r - l); i++) {       int s = 0;       for (int j = 0; j < r - l; j++)         if ((1 << j) & i) s += val[j + l];       mask[__builtin_popcount(i)][s] = i;     }   }   signed main() {     scanf( %d , &n);     n = n * 2;     for (int i = 0; i < n; i++) scanf( %d , &val[i]);     sort(val, val + n);     int sum = 0;     int base = val[0] + val[1];     grid[0][0] = val[0], grid[1][n / 2 - 1] = val[1];     n -= 2;     for (int i = 0; i < n; i++) val[i] = val[i + 2], sum += val[i];     solve(0, n / 2, mask1);     solve(n / 2, n, mask2);     int ans = 1e9;     long long ansmask = 0;     for (int a = 0; a <= n / 2; a++) {       int b = n / 2 - a;       int j = 1200008;       while (j >= 0 and mask2[b][j] == -1) j--;       for (int i = 0; j >= 0 and i <= 1200008; i++)         if (mask1[a][i] > -1) {           while (j >= 0 and (j + i) * 2 > sum) j--;           while (j >= 0 and mask2[b][j] == -1) j--;           if (j < 0) break;           if (sum - (i + j) * 2 < ans) {             ans = sum - (i + j) * 2;             ansmask = (1ll * mask2[b][j]) << (n / 2);             ansmask += mask1[a][i];           }         }     }     ans = (sum + ans) / 2;     vector<int> v1, v2;     for (int i = 0; i < n; i++)       if ((1ll << i) & ansmask)         v1.push_back(val[i]);       else         v2.push_back(val[i]);     sort(v1.begin(), v1.end());     sort(v2.begin(), v2.end());     reverse(v2.begin(), v2.end());     n += 2;     for (int i = 1; i < n / 2; i++) grid[0][i] = v1[i - 1];     for (int i = 0; i < n / 2 - 1; i++) grid[1][i] = v2[i];     for (int i = 0; i < 2; i++) {       for (int j = 0; j < n / 2; j++) cout << grid[i][j] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 5;   const long long NN = 1e9 + 5;   char a[150][150];   map<char, bool> mp, mp1;   bool used[150][150];   long long n, m;   vector<char> v;   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> a[i][j];       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         for (int l = 1; l <= m; l++) {           if (l != j && a[i][j] == a[i][l]) {             used[i][l] = true;           }         }         for (int l = 1; l <= n; l++) {           if (l != i && a[l][j] == a[i][j]) {             used[i][j] = true;           }         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (!used[i][j]) {           v.push_back(a[i][j]);         }       }     }     for (int i = 0; i < (int)v.size(); i++) {       cout << v[i];     }   }
#include <bits/stdc++.h>   using namespace std;   long long t, n, m, k, x, y, z, a[500005], ans, val;   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     string s;     cin >> s;     for (long long i = 0; i < n; i++) {       if (s[i] ==  ( )         x++;       else         x--;       if (x == -1 && !z)         x = 0, z = 1;       else if (x == -1)         break;     }     if (x == z)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   int pal(string s) {     int i = 0, j = s.length() - 1;     while (i < j) {       if (s[i] != s[j]) return 0;       i++;       j--;     }     return 1;   }   int main() {     ios_base::sync_with_stdio(false);     string str, tp, s;     cin >> str;     int l = str.length();     for (int i = 0; i <= l; i++) {       s = str.substr(0, i);       for (int j = 0; j < 26; j++) {         char ch =  a  + j;         tp = s + ch + str.substr(i);         if (pal(tp)) {           cout << tp << endl;           return 0;         }       }     }     cout <<  NA  << endl;     return 0;   }