malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2010;   vector<int> edges[MAXN];   queue<int> q;   int visited[MAXN];   int main() {     int n, m, a, b;     char x;     cin >> n >> m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> x;         if (x ==  # ) {           edges[i].push_back(n + j);           edges[n + j].push_back(i);         }       }     }     q.push(n - 1);     q.push(0);     while (!q.empty()) {       a = q.front();       q.pop();       b = q.front();       q.pop();       if (a == 0) {         cout << b;         return 0;       }       for (int i : edges[a]) {         if (!visited[i]) {           q.push(i);           q.push(b + 1);           visited[i] = true;         }       }     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 5;   int n, q;   int a[maxn], b[maxn], f[maxn], g[maxn][30];   int c(int l, int r) {     int k = (int)log2(r - l + 1);     return max(g[l][k], g[r - (1 << k) + 1][k]);   }   void solve() {     cin >> n;     for (int i = 1; i <= n; ++i) cin >> a[i];     cin >> q;     for (int i = 1; i <= q; ++i) {       int id, p, first;       cin >> id;       if (id == 1) {         cin >> p >> first;         a[p] = first;         b[p] = i;       } else         cin >> f[i];     }     for (int i = 1; i <= q; ++i) g[i][0] = f[i];     int m = (int)log2(q) + 1;     for (int j = 1; j <= m; ++j)       for (int i = 1; i + (1 << (j - 1)) - 1 <= q; ++i)         g[i][j] = max(g[i][j - 1], g[i + (1 << (j - 1))][j - 1]);     for (int i = 1; i <= n; ++i) cout << max(a[i], c(max(1, b[i]), q)) <<    ;   }   int main() { solve(); }
#include <bits/stdc++.h>   using namespace std;   string itos(int a) {     if (!a) return  0 ;     string res;     while (a) {       res += (char)( 0  + (a % 10));       a /= 10;     }     reverse((res).begin(), (res).end());     return res;   }   int main() {     int n;     int a[10], can = 0;     ;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       can |= 1 << a[i];     }     if (n > 6) {       cout <<  0  << endl;       return 0;     }     vector<string> v;     vector<int> mask;     for (int i = 0; i < 256; i++) {       string s = itos(i);       int tmp = 0;       for (int j = 0; j < s.size(); j++) {         tmp |= 1 << (int)(s[j] -  0 );       }       if ((tmp & can) == tmp) {         v.push_back(s);         mask.push_back(tmp);       }     }     vector<string> ans;     for (int i = 0; i < (int)(v.size()); i++)       for (int j = 0; j < (int)(v.size()); j++) {         int size = min(v[i].size(), v[j].size());         bool f = true;         for (int k = 0; k < size; k++) {           if (v[i][k] != v[j][v[j].size() - 1 - k]) {             f = false;             break;           }         }         if (!f) continue;         for (int k = 0; k < (int)(v.size()); k++)           for (int l = 0; l < (int)(v.size()); l++) {             if ((mask[i] | mask[j] | mask[k] | mask[l]) != can) continue;             string s = v[i] + v[k] + v[l] + v[j];             bool f = true;             for (int x = 0; 2 * x < s.size(); x++) {               if (s[x] != s[s.size() - 1 - x]) {                 f = false;                 break;               }             }             if (f) ans.push_back(v[i] +  .  + v[k] +  .  + v[l] +  .  + v[j]);           }       }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++) cout << ans[i] << endl;   }
#include <bits/stdc++.h>   #pragma GCC target( avx2 )   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   using namespace std;   long long fn(long long x, long long rn[]) {     if (x == rn[x])       return x;     else       return rn[x] = fn(rn[x], rn);   }   bool un(long long x, long long y, long long rn[], long long sz[]) {     x = fn(x, rn);     y = fn(y, rn);     if (x == y) return false;     if (sz[x] < sz[y]) swap(x, y);     sz[x] += sz[y];     rn[y] = x;     return true;   }   long long gcd(long long a, long long b) {     if (!b) return a;     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }   long long MOD = 998244353;   long long mod = 1000000007;   long long power(long long x, long long y, long long p) {     long long res = 1;     x %= p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long inv(long long val, long long MODx = MOD) {     return power(val, MODx - 2, MODx);   }   vector<long long> fac, ifac;   void preFac(long long sz) {     fac.resize(sz + 1), ifac.resize(sz + 1);     fac[0] = 1;     for (int i = 1; i <= sz; i++) {       fac[i] = (i * fac[i - 1]) % MOD;     }     ifac[sz] = inv(fac[sz]);     for (int i = sz - 1; i >= 0; i--) {       ifac[i] = ((i + 1) * ifac[i + 1]) % MOD;     }   }   long long nCr(long long N, long long R) {     if (R <= N and R >= 0) {       return ((fac[N] * ifac[R]) % MOD * ifac[N - R]) % MOD;     }     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, k;     cin >> n >> k;     map<long long, long long> pos;     long long p[n + 1], q[n + 1];     for (long long i = 1; i <= n; i++) {       cin >> p[i];     }     for (long long i = 1; i <= n; i++) {       cin >> q[i];       pos[q[i]] = i;     }     long long pt = 1;     long long pt_cons = 1;     vector<vector<long long>> comp;     vector<long long> vec;     while (pt <= n) {       vec.push_back(p[pt]);       pt_cons = max(pt_cons, pos[p[pt]]);       if (pt == pt_cons) {         comp.push_back(vec);         vec.clear();         pt_cons = 1;       }       pt++;     }     if (!vec.empty()) {       comp.push_back(vec);     }     if (comp.size() < k) {       cout <<  NO ;       return 0;     }     string ans(n + 1,  * );     char x =  a ;     for (auto u : comp) {       for (auto v : u) {         ans[v] = x;       }       x++;       if (x == ( z  + 1)) {         x =  z ;       }     }     cout <<  YES n ;     for (long long i = 1; i <= n; i++) {       cout << ans[i];     }   }
#include <bits/stdc++.h>   using namespace std;   int n, s;   int c[3];   void init() {     int score;     scanf( %d%d , &n, &s);     for (int i = 0; i < n; i++) {       scanf( %d , &score);       c[score - 3]++;     }   }   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   void extended_gcd(int a, int b, int c, int &x, int &y) {     if (!b) {       x = c / a, y = 0;       return;     }     extended_gcd(b, a % b, c, y, x);     y -= (a / b) * x;   }   void solve() {     int k[3], ret = 0x7FFFFFFF;     int d = gcd(c[1], c[2]);     for (int i = 0; i <= s; i++) {       int A = c[1], B = c[2], C = s - i * c[0], x, y;       if (C < 0) break;       if (C % d != 0) continue;       extended_gcd(A, B, C, x, y);       int delta1 = B / d, delta2 = A / d;       if (y > x && delta2 != 0) {         int delta = (y - x) / delta2;         y -= delta2 * delta;         x += delta1 * delta;       }       for (int step = 17; step >= 0; step--) {         if (y >= x) break;         if (y + delta2 * (1 << step) <= x - delta1 * (1 << step)) {           y += delta2 * (1 << step);           x -= delta1 * (1 << step);         }       }       if (c[1] * x > c[2] * y) {         for (int step = 17; step >= 0; step--)           if (x - delta1 * (1 << step) >= i) {             if (c[1] * (x - delta1 * (1 << step)) >=                 c[2] * (y + delta2 * (1 << step))) {               x -= delta1 * (1 << step);               y += delta2 * (1 << step);             }           }       }       if (y < i && delta2 != 0) {         int delta = (i - y - 1) / delta2 + 1;         y += delta2 * delta;         x -= delta1 * delta;       }       for (int j = 0;; j++) {         if (x >= i && y >= x &&             abs(c[0] * i - c[1] * x) + abs(c[1] * x - c[2] * y) < ret) {           ret = abs(c[0] * i - c[1] * x) + abs(c[1] * x - c[2] * y);           k[0] = i, k[1] = x, k[2] = y;         }         if (y >= x && c[2] * y > c[1] * x) {           break;         }         y += delta2;         x -= delta1;         if (x < i) break;       }     }     if (ret == 0x7FFFFFFF) {       printf( %d n , -1);     } else       printf( %d %d %d n , k[0], k[1], k[2]);   }   int main() {     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const int M = 1e9 + 7;   long long a[N];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long a, b, x, y, z;     cin >> a >> b >> x >> y >> z;     cout << max(0ll, y - (a - 2 * x)) + max(0ll, y - (b - 3 * z));   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     std::cerr << name <<   :   << arg1 << endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     std::cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   const long long MOD = 998244353;   const long long INFLL = 0x3f3f3f3f3f3f3f3f;   const int INF = 0x3f3f3f3f;   const long long MAXN = 1e+5 + 7;   const int m = 998244353;   const int nax = 1e6;   long long fatorial[nax + 1];   long long binary_pow(long long a, long long b) {     a = a % m;     long long ans = 1;     while (b > 0) {       if (b & 1) {         ans = (ans * a) % m;       }       a = (a * a) % m;       b = b >> 1;     }     return ans;   }   long long modular_inverse(long long a) { return binary_pow(a, m - 2); }   void calcula_fatorial() {     fatorial[0] = 1;     for (int i = 1; i <= nax; i++) {       fatorial[i] = (fatorial[i - 1] * i) % m;     }   }   long long binomial_coefficient(int n, int k) {     return fatorial[n] * modular_inverse(fatorial[k]) % m *            modular_inverse(fatorial[n - k]) % m;   }   void solve() {     long long n, k;     cin >> n >> k;     set<long long> evento;     map<long long, long long> entrada, saida;     for (int i = 0; i < n; ++i) {       long long a, b;       cin >> a >> b;       evento.insert(a);       evento.insert(b);       entrada[a]++;       saida[b]++;     }     long long ans = 0, sz = 0;     for (auto e : evento) {       sz += entrada[e];       for (int i = 0; i < saida[e]; ++i) {         if (sz - 1 < k - 1) {           sz--;           continue;         }         ans += binomial_coefficient(sz - 1, k - 1);         ans %= m;         sz--;       }     }     cout << ans <<   n ;   }   int main() {     calcula_fatorial();     ios_base::sync_with_stdio(0);     cin.tie(0);     long long i, j, n;     int t = 1;     while (t--) solve();     return 0;   }
#include<bits/stdc++.h>   using namespace std;      #define INF 1234567890   #define ll long long      int T;   int N, M, P;   vector<int> g[400401], h[400401];   bool vis[400401], reach[400401], loop[400401];   vector<int> st;   int myscc[400401], sz[400401], dp[400401];      void DFS(int n)   {    vis[n] = true;    for(int next : g[n])    {     if (vis[next]) continue;     DFS(next);    }    st.push_back(n);   }   void DFS2(int n)   {    vis[n] = true;    for(int next : h[n])    {     if (vis[next]) continue;     DFS2(next);    }    myscc[n] = P;    sz[P]++;   }   void DFS3(int n)   {    vis[n] = true;    for(int next : g[n])    {     if (vis[next]) continue;     DFS3(next);    }   }      bool isScc(int i)   {    return (sz[myscc[i]] >= 2 || loop[i]);   }      int main()   {    ios::sync_with_stdio(0); cin.tie(0);    cin.exceptions(ios::badbit | ios::failbit);    cin >> T;    while(T--)    {     cin >> N >> M;     // clear     P = 0;     for(int i=1; i<=N; i++)     {      g[i].clear();      h[i].clear();     }     memset(vis, 0, sizeof(bool)*(N+1));     memset(reach, 0, sizeof(bool)*(N+1));     memset(loop, 0, sizeof(bool)*(N+1));     st.clear();        for(int i=0; i<M; i++)     {      int a, b;      cin >> a >> b;      if (a == b) { loop[a] = true; continue; }      g[a].push_back(b);      h[b].push_back(a);     }        DFS(1);     for(int i=1; i<=N; i++)      if (vis[i])       reach[i] = true;        for(int i=1; i<=N; i++)      if (!vis[i])       DFS(i);        memset(vis, 0, sizeof(bool)*(N+1));     reverse(st.begin(), st.end()); // DFS 종료 역순 = 위상정렬순     for(int n : st)     {      if (vis[n]) continue;      sz[P] = 0;      DFS2(n);      P++;     }        memset(vis, 0, sizeof(bool)*(N+1));     for(int i=1; i<=N; i++)      if (reach[i] && isScc(i) && !vis[i])       DFS3(i); // 1 -> scc -> x가 가능한가?        memset(dp, 0, sizeof(int)*(N+1)); // 0,1,2+     dp[1] = 1;     for(int n : st)     {      if (dp[n] > 2) dp[n] = 2;      for(int next : g[n])       dp[next] += dp[n];     }        for(int i=1; i<=N; i++)     {      if (reach[i] == false) cout <<  0  ;      else if (vis[i]) cout <<  -1  ;      else if (dp[i] >= 2) cout <<  2  ;      else cout <<  1  ;     }     cout <<   n ;    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int t;     cin >> t;     vector<int> a(7);     while (t--) {       long long k;       cin >> k;       int sum = 0;       for (int i = 0; i < 7; i++) {         cin >> a[i];         sum += a[i];       }       long long ans = (k / sum) * 7;       long long rem = k % sum;       if (rem == 0) {         ans -= 7;         rem = sum;       }       int min = 7;       int count = 0, count_sum = 0;       for (int i = 0; i < 7; i++) {         count = 0;         count_sum = 0;         for (int j = 0; j < 7; j++) {           count++;           if (a[(i + j) % 7]) {             count_sum++;           }           if (count_sum == rem) {             if (count < min) {               min = count;               break;             }           }         }       }       cout << ans + min << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int go[2], sum;     node(int x0, int x1, int _sum) { go[0] = x0, go[1] = x1, sum = _sum; }   };   node root(-1, -1, 0);   vector<node> t = {root};   int get_sum(int v) { return v == -1 ? 0 : t[v].sum; }   int go(int v, int id) {     if (t[v].go[id] == -1) {       t[v].go[id] = t.size();       t.push_back(node(-1, -1, 0));     }     return t[v].go[id];   }   void add(int a) {     int v = 0;     for (int bit = 29; bit >= 0; bit--) {       int x = (a >> bit) & 1;       v = go(v, x);       t[v].sum++;     }   }   int get(int a, int k) {     int v = 0, ans = 0, bit = 29;     while (bit >= 0) {       int x = (a >> bit) & 1, y = (k >> bit) & 1;       if (x > y) ans += get_sum(t[v].go[0]);       if ((x ^ 1) > y) ans += get_sum(t[v].go[1]);       if (t[v].go[x ^ y] == -1) break;       v = go(v, x ^ y);       bit--;     }     if (bit == -1) ans += t[v].sum;     return ans;   }   void solve() {     int n, k;     cin >> n >> k;     add(0);     long long pref = 0, ans = 0;     for (int i = 1; i <= n; i++) {       int v;       cin >> v;       pref = pref ^ v;       ans += get(pref, k);       add(pref);     }     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);     cout.setf(ios::fixed), cout.precision(20);     solve();   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000009;   long long A[200000];   long long root(long long a) {     long long i = a;     if (A[i] != i) {       A[i] = root(A[i]);     }     return A[a];   }   void unio(long long a, long long b) {     long long ra = root(a);     long long rb = root(b);     if (ra != rb) {       A[ra] = rb;     }   }   signed main() {     long long n, m;     cin >> n >> m;     long long val = 1;     for (long long i = 1; i <= n; i++) {       A[i] = i;     }     for (long long i = 1; i <= m; i++) {       long long a, b;       cin >> a >> b;       if (root(a) == root(b)) {         val = (val * 2LL) % mod;       } else {         unio(a, b);       }       val--;       val = (val + mod) % mod;       cout << val << endl;       val++;     }   }
#include <bits/stdc++.h>   const int maxn = 200005, K = 37, mod = 1e9 + 7;   int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }   int dec(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }   int mul(int a, int b) { return 1ll * a * b % mod; }   int ksm(int a, int b = mod - 2) {     int ret = 1;     for (; b; b >>= 1, a = mul(a, a))       if (b & 1) ret = mul(ret, a);     return ret;   }   int n, a[maxn];   std::tuple<int, int, int> p[maxn];   int f[maxn], c[maxn], mx, ans;   void ins(int x, int v) {     for (; x <= mx; x += x & -x) c[x] = std::max(c[x], v);   }   int ask(int x) {     int res = 0xcfcfcfcf;     for (; x; x -= x & -x) res = std::max(res, c[x]);     return res;   }   int main() {     memset(c, 0xcf, sizeof(c));     memset(f, 0xcf, sizeof(f));     scanf( %d , &n);     for (int i = 1; i <= n; i++)       scanf( %d , a + i), p[i] = std::make_tuple(i - a[i], a[i], i),                           mx = std::max(mx, a[i]);     mx++;     std::sort(p + 1, p + 1 + n);     ins(1, 0);     for (int i = 1; i <= n; i++) {       if (std::get<2>(p[i]) >= std::get<1>(p[i]))         f[i] = ask(std::get<1>(p[i])) + 1;       ins(std::get<1>(p[i]) + 1, f[i]);       ans = std::max(ans, f[i]);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = (1 << 30) - 1;   const long long lINF = (1LL << 62) - 1;   const double dINF = 1e40;   const int MAXT = 1 << 22, MAXN = 1001000;   struct seg_tree {     int sum[MAXT], len;     void build(int n) {       for (len = 1; len < n; len <<= 1)         ;     }     template <int val>     void update(int pos) {       for (int x = pos + len; x > 0; x >>= 1) sum[x] += val;     }     int find(int k) {       int x;       for (x = 1; x < len;) {         x <<= 1;         if (sum[x] < k) {           k -= sum[x];           x ^= 1;         }       }       return x - len;     }   } ds;   int pos[MAXT], val[MAXN];   bool app[MAXN];   int main() {     int n, m;     scanf( %d%d , &n, &m);     ds.build(n + m);     for (int i = 0; i < n; i++) {       pos[m + i] = i;       ds.update<1>(m + i);     }     memset(val, -1, sizeof(val));     bool flag = true;     for (int i = m - 1; i >= 0; i--) {       int k, mark;       scanf( %d%d , &mark, &k);       int p = ds.find(k), op = pos[p];       ds.update<-1>(p);       pos[i] = op;       ds.update<1>(i);       if (val[op] == -1)         val[op] = mark;       else if (val[op] != mark) {         flag = false;         break;       }     }     memset(app, false, sizeof(app));     for (int i = 0; i < n; i++)       if (val[i] != -1) {         if (app[val[i]]) {           flag = false;           break;         }         app[val[i]] = true;       }     if (flag) {       for (int i = 0, v = 1; i < n; i++) {         if (val[i] == -1) {           for (; app[v]; ++v)             ;           app[v] = true;           val[i] = v;         }         if (i == n - 1)           printf( %d n , val[i]);         else           printf( %d  , val[i]);       }     } else       puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = (long long)-1e18;   const int N = 200 * 1000 + 100;   vector<int> g[N];   vector<int> w[N];   vector<pair<long long, long long> > cur;   long long add[N];   long long ans[N];   int a[N];   long long dfs2(int v) {     ans[v] = add[v];     for (int i = 0; i < g[v].size(); i++) ans[v] += dfs2(g[v][i]);     return ans[v];   }   void dfs(int v, int par, long long h) {     if (v != par) {       long long dist = h - a[v];       vector<pair<long long, long long> >::iterator it = lower_bound(           cur.begin(), cur.end(), pair<long long, long long>(dist, INF));       add[par]++;       if (it != cur.begin()) {         it--;         add[it->second]--;       }     }     cur.push_back(pair<long long, long long>(h, v));     for (int i = 0; i < g[v].size(); i++) dfs(g[v][i], v, h + w[v][i]);     cur.pop_back();   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 1; i < n; i++) {       int p, l;       cin >> p >> l;       p--;       g[p].push_back(i);       w[p].push_back(l);     }     dfs(0, 0, 0);     dfs2(0);     for (long long i = 0; i < n; i++) cout << ans[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool isprime(int a) {     for (int i = 2; i * i <= a; i++) {       if (a % i == 0) return false;     }     return true;   }   bool v[10010];   int gcd(int a, int b) {     if (a % b == 0) return b;     return gcd(b, a % b);   }   int main() {     int T;     cin >> T;     for (int i = 2; i < 10010; i++) {       v[i] = isprime(i);     }     while (T--) {       int a;       int b;       cin >> a >> b;       if (a == 1 || b == 1) {         cout <<  Finite  << endl;         continue;       }       if (gcd(a, b) == 1) {         cout <<  Finite  << endl;         continue;       } else {         cout <<  Infinite  << endl;         continue;       }     }     return 0;   }
#include <bits/stdc++.h>   const long long mod = 1000000007;   const long long Inf = 2 * 1e9;   using namespace std;   long long toint(string s) {     long long anss = 0;     for (int(i) = 0; (i) < s.length(); (i)++) anss = anss * 10 + (s[i] -  0 );     return anss;   }   long long gcd(long long a, long long b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   vector<bool> used(200001, false);   vector<int> g(200001);   void dfs(int v) {     used[v] = true;     if (!used[g[v]]) dfs(g[v]);   }   int main() {     int n;     cin >> n;     vector<int> t(n + 1), ch(n + 1);     for (int(i) = 1; (i) < n + 1; (i)++) {       scanf( %d , &t[i]);       if (i > 1) t[i] -= t[1];     }     t[1] = 0;     ch[0] = 0;     for (int(i) = 1; (i) < n + 1; (i)++) {       int ans = 20;       ch[i] = ch[i - 1];       int pos =           lower_bound((t).begin(), (t).end(), max(0, t[i] - 89)) - t.begin();       int sum = ch[i] - ch[max(0, pos - 1)];       ans = min({ans, 50 - sum});       pos = lower_bound((t).begin(), (t).end(), max(0, t[i] - 1439)) - t.begin();       sum = ch[i] - ch[max(0, pos - 1)];       ans = min({ans, 120 - sum});       ch[i] += ans;       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void input() {}   int main() {     input();     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     if (n % 2 == 0)       cout << -1 <<   n ;     else {       for (int i = 0; i < n; i++) cout << i <<    ;       cout <<   n ;       for (int i = 0; i < n; i++) cout << i <<    ;       cout <<   n ;       for (int i = 0; i < n; i++) cout << (2 * i) % n <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int i, j, k, n, m, l;   const int N = 1e5 + 8;   int vis[N];   vector<int> adj[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n;     for (i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);     }     queue<int> q;     q.push(1);     memset(vis, 0, sizeof(vis));     vis[1] = 1;     l = 0;     long long ev = 0, od = 0;     while (1) {       int c = q.size();       if (!c) break;       while (c) {         int s = q.front();         q.pop();         c--;         if (l & 1)           ev++;         else           od++;         for (auto u : adj[s]) {           if (!vis[u]) {             vis[u] = 1;             q.push(u);           }         }       }       l++;     }     cout << (ev * od - (n - 1)) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double r[1000];   double p = atan(1.) * 4.;   int main() {     double rez = 0;     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> r[i];     sort(r, r + n);     bool t = true;     for (int i = n - 1; i >= 0; i--) {       if (t)         rez += r[i] * r[i] * p;       else         rez -= r[i] * r[i] * p;       t = !t;     }     printf( %.6f , rez);     cin >> n;     return 0;   }