malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int c[1100000], v[1100000], w[1100000], n, K, s1[1100000], s2[1100000], len1,       len2, pre1, pre2;   void insert(int k) {     while (len1 >= pre1 && v[s1[len1]] <= v[k]) len1--;     s1[++len1] = k;     while (len2 >= pre2 && c[s2[len2]] >= c[k]) len2--;     s2[++len2] = k;   }   int main() {     scanf( %d%d , &n, &K);     for (int i = 1; i <= n; i++) scanf( %d , &v[i]);     for (int i = 1; i <= n; i++) scanf( %d , &c[i]);     pre1 = 1;     pre2 = 1;     len1 = 1;     len2 = 1;     int now = 1;     s1[1] = 1;     s2[1] = 1;     for (int i = 1; i <= n; i++) {       if (now < i) insert(i), now++;       while (s1[pre1] < i) pre1++;       while (s2[pre2] < i) pre2++;       while (now < n) {         int k1 = v[s1[pre1]], k2 = c[s2[pre2]];         if (k1 * 100 >= k2) break;         k1 = max(k1, v[now + 1]);         k2 = min(k2, c[now + 1]);         if (k1 * 100 < k2) {           insert(now + 1);           now++;         } else           break;       }       int k1 = v[s1[pre1]], k2 = c[s2[pre2]];       w[i] = min(k1 * 100, k2);       if (now != n) {         k1 = max(k1, v[now + 1]);         k2 = min(k2, c[now + 1]);         w[i] = max(w[i], min(k1 * 100, k2));       }     }     sort(w + 1, w + n + 1);     double ans = 0, noww = (double)K / (double)n;     for (int i = 1; i <= n - K + 1; i++) {       ans = ans + w[i] * noww;       int k1 = n - K + 1 - i, k2 = n - i;       noww = noww * k1 / k2;     }     printf( %.11lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int a[305], ans[305], b[305][305], n, mx = 0;   bool visit[305];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= n; i++) {       cin >> s;       for (int j = 0; j < n; j++) {         b[i][j + 1] = s[j] - 48;       }     }     for (int k = 1; k <= n; k++) {       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           if (b[i][k] && b[k][j]) b[i][j] = 1;         }       }     }     for (int i = 1; i <= n; i++) {       mx = a[i];       for (int j = 1; j <= n; j++) {         if (b[i][j]) {           if (a[j] < mx && !visit[a[j]]) {             mx = a[j];             swap(a[i], a[j]);           }         }       }       visit[mx] = 1;       ans[i] = mx;     }     for (int i = 0; i < n; i++) {       if (i)         cout <<     << ans[i + 1];       else         cout << ans[i + 1];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int isp[100005];   void pp() {     for (long long int i = 2; i <= 100000; i++) {       if (!isp[i]) {         for (long long int j = i * i; j <= 100000; j += i) {           isp[j] = 1;         }       }     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t;     cin >> t;     pp();     while (t--) {       long long int n, i, j, x, y;       cin >> n;       if (!isp[n]) {         for (long long int i = 1; i <= n; i++) {           for (long long int j = 1; j <= n; j++) {             cout << 1 <<    ;           }           cout <<   n ;         }         continue;       }       x = -1;       for (long long int i = n + 1; i <= 100000; i++) {         if (!isp[i] && isp[i - n + 1]) {           x = i - n + 1;           break;         }       }       for (long long int i = 1; i < n; i++) {         for (long long int j = 1; j < n; j++) {           cout << 1 <<    ;         }         cout << x <<   n ;       }       y = 0;       for (long long int i = 1; i < n; i++) {         y += x;         cout << x <<    ;       }       for (long long int i = y; i <= 100000; i++) {         if (!isp[i] && isp[i - y]) {           x = i - y;           break;         }       }       cout << x <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<long long, long long> p;   vector<pair<long long, long long>> adj[101];   long long visited[101];   long long parent[101];   long long maxi = 0;   set<long long, greater<long long>> set1;   vector<long long> arr;   long long ans[101];   void dfs(long long v, long long p) {     for (auto q : adj[v]) {       long long u = q.first;       if (u == p) continue;       dfs(u, v);       ans[v] = max(ans[v], ans[u] + q.second);     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, a, b, c;     cin >> n;     long long z = n - 1;     while (z--) {       cin >> a >> b >> c;       adj[a].push_back(make_pair(b, c));       adj[b].push_back(make_pair(a, c));     }     memset(visited, 0, sizeof(visited));     dfs(0, -1);     cout << ans[0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   vector<int> x[1003];   int a[1003], v[1003];   int n;   void pp() {     for (int i = 1; i <= n; i++) {       for (int j = 0; j < x[i].size(); j++) cout << i <<     << x[i][j] <<   n ;     }   }   int main() {     int m, k;     cin >> n >> m >> k;     for (int i = 1; i <= k; i++) {       cin >> a[i];       v[a[i]] = 1;     }     if (k == n) {       cout <<  -1  <<   n ;       return 0;     }     int l;     for (int i = 1; i <= n; i++) {       if (v[i] == 0) l = i;     }     for (int i = 1; i <= n; i++) {       if (i != l) x[l].push_back(i);     }     int w = n - 1;     if (w == m) {       pp();       return 0;     }     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         if (i != l && i != a[1] && i != a[2] && j != l && j != a[1] &&             j != a[2]) {           x[i].push_back(j);           w++;           if (w == m) {             pp();             return 0;           }         }       }     }     for (int i = 1; i <= n; i++) {       if (i != l && i != a[1] && i != a[2]) {         if (v[i] == 1) {           x[a[1]].push_back(i);           w++;           if (w == m) {             pp();             return 0;           }         } else {           x[a[1]].push_back(i);           w++;           if (w == m) {             pp();             return 0;           }           x[a[2]].push_back(i);           w++;           if (w == m) {             pp();             return 0;           }         }       }     }     cout <<  -1  <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const int INF = 0x3f3f3f3f;   long long n, l, r;   pair<long long, long long> dfs(long long x) {     if (x == 0)       return make_pair(1, 0);     else if (x == 1)       return make_pair(1, 1);     long long tmp = x & 1;     pair<long long, long long> t = dfs(x / 2);     t.first = t.first * 2 + 1;     t.second = t.second * 2 + tmp;     return t;   }   long long get(long long x, long long k) {     if (x == 0)       return 0;     else if (x == 1)       return 1;     pair<long long, long long> t = dfs(x / 2);     if (k <= t.first)       return get(x / 2, k);     else if (k == t.first + 1)       return t.second + (x & 1);     else {       return t.second + (x & 1) + get(x / 2, k - t.first - 1);     }   }   int main() {     scanf( %I64d%I64d%I64d , &n, &l, &r);     printf( %I64d n , get(n, r) - (l - 1 == 0 ? 0 : get(n, l - 1)));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200;   int s[maxn][6], n;   int cnt[maxn];   int get_score(int id, int f, int a) {     if (s[f][id] == -1) return 0;     int sum = 0;     if (s[1][id] == -1 || s[2][id] == -1 || s[1][id] < s[2][id])       sum = cnt[id];     else       sum = cnt[id] + a;     int score = 500;     for (int i = 2; i <= 32; i *= 2) {       if (sum * i > n + a) {         break;       } else {         score += 500;       }     }     return score * (250.0 - s[f][id]) * 250.0;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= 5; j++) scanf( %d , &s[i][j]);     memset(cnt, 0, sizeof(cnt));     for (int i = 1; i <= n; i++)       for (int j = 1; j <= 5; j++)         if (s[i][j] != -1) cnt[j]++;     int sum1 = 0, sum2 = 0;     int ss = -1;     for (int v = 0; v <= 120 * 32; v++) {       sum1 = 0, sum2 = 0;       for (int j = 1; j <= 5; j++) {         sum1 += get_score(j, 1, v);         sum2 += get_score(j, 2, v);       }       if (sum1 > sum2) {         ss = v;         break;       }     }     printf( %d n , ss);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     long long a, b, sum = 0;     cin >> a >> b;     while (true) {       if (a >= b) {         sum += a / b;         a %= b;       }       if (a == 0) {         break;       }       swap(a, b);     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long p = 1000000007;   long long fact[100000];   long long dp[100000];   long long factdp[100000];   long long ar[200000];   int main() {     fact[0] = 1;     fact[1] = 1;     dp[0] = 1;     dp[1] = 1;     factdp[0] = 1;     factdp[1] = 1;     for (int i = 2; i < 10000; i++) {       dp[i] = dp[p % i] * (p - (p / i)) % p;       fact[i] = i * fact[i - 1] % p;       factdp[i] = factdp[i - 1] * (dp[i]) % p;     }     long long n, m;     cin >> n >> m;     long long ans =         (fact[2 * m + n - 1] * factdp[2 * m] % p * factdp[n - 1] % p + p) % p;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   long long cal(long long x) { return (x + 1) * x / 2; }   int main() {     std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     long long n;     cin >> n;     long long l = 0, r = 1e8, ans = -1;     while (l <= r) {       long long mid = (l + r) >> 1;       if (cal(mid) < n)         l = mid + 1, ans = mid;       else         r = mid - 1;     }     cout << n - cal(ans) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int main() {     int n, k;     scanf( %d %d , &n, &k);     int def = 0;     int a[N], d[N] = {};     for (int i = 0; i <= n; i++) {       int a[N];       char c[10];       if (scanf( %d , &a[i]))         d[i] = 1, def++;       else         scanf( %s , c);     }     if (k == 0) {       if (d[0])         printf( %s n , a[0] == 0 ?  Yes  :  No );       else         printf( %s n , def % 2 == 0 ?  No  :  Yes );     } else {       if (def != n + 1) {         printf( %s n , n % 2 ?  Yes  :  No );       } else {         if (k == 1) {           int resp = 0;           for (int i = n; i >= 0; i--) resp += a[i];           printf( %s n , resp == 0 ?  Yes  :  No );         } else {           long long r = 0;           for (int i = 0; i <= n; i++) {             r = r / k + a[i];             if (r % k) break;           }           printf( %s n , r == 0 ?  Yes  :  No );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int INF = (1ll << 60) - 1;   long long int nCrModpDP(long long int n, long long int r, long long int p) {     long long int i, j, C[r + 1];     memset(C, 0, sizeof(C));     C[0] = 1;     for (i = 1; i <= n; i++) {       for (j = min(i, r); j > 0; j--) {         C[j] = (C[j] + C[j - 1]) % p;       }     }     return C[r];   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int tc = 1;     while (tc--) {       long long int fact[1001];       fact[0] = fact[1] = 1;       fact[2] = 2;       fact[3] = 6;       for (long long int i = 4; i < 1001; i++)         fact[i] = ((fact[i - 1] % 1000000007) * (i % 1000000007)) % 1000000007;       long long int n, m;       cin >> n >> m;       long long int ans = nCrModpDP(n + 2 * m - 1, n - 1, 1000000007);       cout << ans % 1000000007;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   long long ans;   int a[100002];   int b[100002];   bool jobs[100002];   priority_queue<int> pq[100002];   priority_queue<int> pq2;   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> b[i];     for (int i = 0; i < n; i++) {       pq[a[i]].push(-b[i]);       jobs[a[i]] = true;     }     for (int i = 1; i <= n; i++) {       while (pq[i].size() > 1) {         pq2.push(pq[i].top());         pq[i].pop();       }     }     for (int i = 1; i <= k; i++) {       if (!jobs[i]) {         ans -= pq2.top();         pq2.pop();       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0;     char c = getchar();     bool f = 0;     while (c < 48) f |= c ==  - , c = getchar();     while (c > 47) x = x * 10 + (c ^ 48), c = getchar();     return f ? -x : x;   }   int n, k;   struct node {     int sz, mn[10], mx[10];     bool operator<(const node& o) const {       for (int i = (0), iend = (k - 1); i <= iend; ++i)         if (mx[i] > o.mn[i]) return 0;       return 1;     }   };   node merge(node A, node B) {     node res;     res.sz = A.sz + B.sz;     for (int i = (0), iend = (k - 1); i <= iend; ++i)       res.mn[i] = min(A.mn[i], B.mn[i]), res.mx[i] = max(A.mx[i], B.mx[i]);     return res;   }   multiset<node> S;   int main() {     cin >> n >> k;     for (int _ = (1), _end = (n); _ <= _end; ++_) {       node cur;       cur.sz = 1;       for (int i = (0), iend = (k - 1); i <= iend; ++i)         cur.mn[i] = cur.mx[i] = read();       while (1) {         auto it1 = S.lower_bound(cur), it2 = S.upper_bound(cur);         if (it1 != it2) {           cur = merge(*it1, cur), S.erase(it1);         } else           break;       }       S.insert(cur);       printf( %d n , S.rbegin()->sz);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e3 + 10, H = 2e5 + 10, MOD = 1e9 + 7;   struct node {     int x, y;   } a[N];   long long fac[H], inv[H], f[N];   int h, w, n;   long long popow(long long x, int y) {     long long t = x, re = 1;     while (y) {       if (y & 1) re = re * t % MOD;       t = t * t % MOD;       y >>= 1;     }     return re;   }   void prepare() {     fac[0] = inv[0] = 1;     for (int i = 1; i <= 2e5; ++i) {       fac[i] = fac[i - 1] * i % MOD;       inv[i] = popow(fac[i], MOD - 2);     }   }   bool cmp(const node &aa, const node &bb) {     return aa.x < bb.x || (aa.x == bb.x && aa.y < bb.y);   }   long long calc(int aa, int bb) {     if (aa < bb) return 0;     return fac[aa] * inv[bb] % MOD * inv[aa - bb] % MOD;   }   int main() {     prepare();     scanf( %d%d%d , &h, &w, &n);     for (int i = 1; i <= n; ++i) scanf( %d%d , &a[i].x, &a[i].y);     ++n;     a[n].x = h;     a[n].y = w;     sort(&a[1], &a[1 + n], cmp);     for (int i = 1; i <= n; ++i) {       f[i] = calc(a[i].x + a[i].y - 2, a[i].x - 1);       for (int j = 1; j < i; ++j)         if (a[j].y <= a[i].y) {           f[i] -= f[j] * calc(a[i].x + a[i].y - a[j].x - a[j].y, a[i].x - a[j].x);           f[i] %= MOD;         }     }     printf( %lld n , (f[n] + MOD) % MOD);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   const int MXN = 2e5 + 10;   const int MXS = MXN * 4;   const int INF = 1e9;   const int Mod = 998244353;   int n, q, num;   int Seg[MXS], MUL[MXS], ADD[MXS];   set<pair<pair<int, int>, int> > st[MXN];   void Shift(int id, int s, int e) {     if (MUL[id] == 1 && ADD[id] == 0) return;     Seg[id] =         ((1ll * Seg[id] * MUL[id] % Mod) + (1ll * ADD[id] * (e - s + 1) % Mod)) %         Mod;     if ((e - s + 1) > 1) {       ADD[(id * 2)] = ((1ll * ADD[(id * 2)] * MUL[id] % Mod) + ADD[id]) % Mod;       ADD[(id * 2 + 1)] =           ((1ll * ADD[(id * 2 + 1)] * MUL[id] % Mod) + ADD[id]) % Mod;       MUL[(id * 2)] = 1ll * MUL[(id * 2)] * MUL[id] % Mod;       MUL[(id * 2 + 1)] = 1ll * MUL[(id * 2 + 1)] * MUL[id] % Mod;     }     ADD[id] = 0, MUL[id] = 1;   }   void Upd(int l, int r, int add, int mul, int id = 1, int s = 1, int e = n) {     Shift(id, s, e);     if (e < l || s > r) return;     if (l <= s && e <= r) {       ADD[id] = add, MUL[id] = mul;       Shift(id, s, e);       return;     }     Upd(l, r, add, mul, (id * 2), s, ((s + e) / 2)),         Upd(l, r, add, mul, (id * 2 + 1), ((s + e) / 2 + 1), e);     Seg[id] = (Seg[(id * 2)] + Seg[(id * 2 + 1)]) % Mod;   }   int Get(int l, int r, int id = 1, int s = 1, int e = n) {     Shift(id, s, e);     if (e < l || s > r) return 0;     if (l <= s && e <= r) return Seg[id];     return (Get(l, r, (id * 2), s, ((s + e) / 2)) +             Get(l, r, (id * 2 + 1), ((s + e) / 2 + 1), e)) %            Mod;   }   void Split(int tp, int p, bool f) {     auto itr = st[tp].upper_bound({{p, INF}, 0});     itr--;     int l, r, sit = itr->second;     tie(l, r) = itr->first;     if (!f && l == p) return;     if (f && r == p) return;     st[tp].erase(itr);     st[tp].insert({{l, p - 1 + f}, sit});     st[tp].insert({{p + f, r}, sit});   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> q;     for (int i = 0; i < MXS; i++) MUL[i] = 1;     for (int i = 1; i <= n; i++) st[i].insert({{1, n}, 0});     for (int i = 0; i < q; i++) {       int t, l, r, x;       cin >> t >> l >> r;       if (t != 2) cin >> x;       if (t == 2) {         cout << Get(l, r) <<   n ;         continue;       }       Split(x, l, 0), Split(x, r, 1);       auto itr = st[x].lower_bound({{l, l}, 0});       while (itr != st[x].end() && itr->first.second <= r) {         int nl, nr, ns = itr->second;         tie(nl, nr) = itr->first;         if (ns) Upd(nl, nr, 0, 2);         if (!ns) Upd(nl, nr, 1, 1);         st[x].erase(itr);         itr = st[x].lower_bound({{nr + 1, nr + 1}, 0});       }       st[x].insert({{l, r}, 1});     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     int arr[n];     for (int i = 0; i < n; i++) cin >> arr[i];     sort(arr, arr + n);     int ok = 0;     for (int i = 0; i < n - 1; i++) {       if (((long long int)arr[i] * 2) > arr[i + 1] and arr[i + 1] > arr[i])         ok = 1;     }     if (ok)       cout <<  YES  <<   n ;     else       cout <<  NO  <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long int arr[1000005], t = 0;   int main() {     int n, cnt;     cin >> n;     map<long long int, int> m;     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     cnt = 1;     long long int t = arr[0];     m[t]++;     for (int i = 1; i < n; i++) {       t = t + arr[i];       m[t]++;       cnt = max(cnt, m[t]);     }     cout << n - cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > v[200010];   int mark[200010];   vector<pair<int, int> > sorted;   int Query[200010];   int main() {     int n, q, i, j;     memset(mark, 0, sizeof(mark));     scanf( %d , &n);     for (i = 0; i < n; i++) {       int x, y;       scanf( %d , &x);       scanf( %d , &y);       v[x].push_back(make_pair(y, i));     }     for (i = 1; i <= n; i++) {       if ((int)v[i].size() == 0) continue;       sorted.push_back(make_pair(v[i][v[i].size() - 1].first, i));     }     sort(sorted.begin(), sorted.end());     scanf( %d , &q);     while (q--) {       int k, x;       scanf( %d , &k);       for (i = 0; i < k; i++) {         scanf( %d , &Query[i]);         mark[Query[i]] = 1;       }       for (i = (int)sorted.size() - 1; i >= 0; --i)         if (!mark[sorted[i].second]) break;       if (i < 0) {         printf( 0 0 n );         for (i = 0; i < k; i++) mark[Query[i]] = 0;         continue;       }       int p = sorted[i].second;       int lo = 0, hi = v[p].size() - 1, mid;       while (lo < hi) {         mid = (lo + hi) / 2;         int pos = v[p][mid].second, val = v[p][mid].first;         int cnt = (int)v[p].size() - 1 - mid;         for (i = 0; i < k; i++) {           if ((int)v[Query[i]].size() == 0) continue;           int pos = upper_bound(v[Query[i]].begin(), v[Query[i]].end(),                                 make_pair(val, 0)) -                     v[Query[i]].begin();           cnt += (int)v[Query[i]].size() - pos;         }         if (cnt == n - 1 - pos)           hi = mid;         else           lo = mid + 1;       }       printf( %d %d n , p, v[p][lo].first);       for (i = 0; i < k; i++) mark[Query[i]] = 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int arr[111];   int main() {     int n;     scanf( %d , &n);     for (int i = (0); i < (n); ++i) scanf( %d , &arr[i]);     sort(arr, arr + n);     int t = 10;     int ans = 0;     int qts = 0;     for (int i = (0); i < (n); ++i) {       t += arr[i];       if (t > 720) break;       qts++;       if (t > 360) ans += (t - 360);     }     printf( %d %d n , qts, ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 10;   int T, N;   int a[MAX];   int main() {     scanf( %d , &T);     while (T--) {       scanf( %d , &N);       for (int i = 1; i <= N; i++) scanf( %d , &a[i]);       sort(a + 1, a + 1 + N);       int l = (N + 1) / 2, r = (N + 1) / 2;       printf( %d , a[l]);       for (int i = 1; i < N; i++) {         if (i & 1)           printf(  %d , a[++r]);         else           printf(  %d , a[--l]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int a, long long int b);   int main() {     long long int a, b, c, i, j, x, k, sum, count;     scanf( %lld , &a);     scanf( %lld , &b);     scanf( %lld , &c);     long long int arr[81];     count = 0;     for (i = 1; i < 82; i++) {       long long int t = power(i, a);       k = ((b * t) + c);       if (k <= 0 && k >= 1000000000) continue;       x = k;       sum = 0;       while (x != 0) {         j = x % 10;         x = x / 10;         sum = sum + j;       }       if (sum == i && k > 0 && k < 1000000000) {         count++;         arr[count - 1] = k;       }     }     cout << count;     if (count) {       cout << endl;       for (i = 0; i < count; i++) {         cout << arr[i] <<    ;       }     }     return 0;   }   long long int power(long long int a, long long int b) {     long long int tpower = 1;     for (int i = 0; i < b; i++) {       tpower = tpower * a;     }     return tpower;   }
#include <bits/stdc++.h>   using namespace std;   int n;   bool r[100], c[100];   int main() {     cin >> n;     vector<int> ans;     for (int i = 1; i <= n * n; i++) {       int x, y;       cin >> x >> y;       if (!r[x] && !c[y]) {         ans.push_back(i);         r[x] = true;         c[y] = true;       }     }     for (int i = 0; i < ans.size(); i++) {       cout << ans[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, i;     char ch;     char str[2010];     scanf( %d , &n);     scanf( %c , &ch);     if (n % 2 == 1) {       scanf( %c , &str[n / 2]);       for (i = 1; i <= n / 2; i++) {         scanf( %c , &str[n / 2 - i]);         scanf( %c , &str[n / 2 + i]);       }     } else {       scanf( %c , &str[n / 2 - 1]);       for (i = 1; i < n / 2; i++) {         scanf( %c , &str[n / 2 - 1 + i]);         scanf( %c , &str[n / 2 - 1 - i]);       }       scanf( %c , &str[n - 1]);     }     str[n] =   0 ;     printf( %s n , str);     return 0;   }