malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long a[100005];   int main() {     long long n;     scanf( %lld , &n);     for (long long i = 0; i < n; i++) scanf( %lld , &a[i]);     sort(a, a + n);     long long sm = 0;     for (long long i = 0; i < n / 2; i++) {       sm = ((sm % 10007) + ((a[i] % 10007) * (a[n - i - 1] % 10007)) % 10007) %            10007;     }     sm = (sm * 2) % 10007;     if (n % 2 == 1)       sm = ((sm % 10007) + ((a[n / 2] % 10007) * (a[n / 2] % 10007)) % 10007) %            10007;     cout << sm << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000110;   string str[7] = { monday ,  tuesday ,   wednesday ,  thursday ,                     friday ,  saturday ,  sunday };   int main() {     string s, s1;     while (cin >> s >> s1) {       int i;       int a, b;       for (i = 0; i < 7; i++) {         if (s == str[i]) a = i;         if (s1 == str[i]) b = i;       }       if (b - a == 3 || b - a == 0 || b - a == -4 || b - a == 2 || b - a == -4 ||           b - a == 2 || b - a == 3 || b - a == -4 || b - a == 2 || b - a == 3 ||           b - a == -5)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   int MM[500], FF[500];   int main() {     ios::sync_with_stdio(0);     int N;     cin >> N;     for (int i = 0; i < N; i++) {       char g;       int from, to;       cin >> g >> from >> to;       int *v;       if (g ==  M )         for (int i = from; i <= to; i++) MM[i]++;       else         for (int i = from; i <= to; i++) FF[i]++;     }     int MAX = 0;     for (int i = 1; i < 400; i++) MAX = max(MAX, min(MM[i], FF[i]) * 2);     cout << MAX;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int input() {     int x = 0, f = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) f |= ch ==  0 , ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return f ? -x : x;   }   int n, m, du[2100];   bool Check() {     for (int i = 1; i <= n; i++) {       if (du[i] % 2 == 1) return 0;     }     printf( 1 n );     for (int i = 1; i < n; i++) printf( 1  );     printf( 1 n );     return 1;   }   bitset<2100> s[2100];   void Gauss() {     int x = 1;     for (int j = 1; j <= n; j++) {       for (int i = x; i <= n; i++) {         if (s[i][j] == 1) {           swap(s[i], s[x]);           break;         }       }       if (s[x][j] == 0) continue;       for (int i = 1; i <= n; i++) {         if (i == x) continue;         if (s[i][j] == 1) s[i] ^= s[x];       }       x++;     }   }   int as[2100];   void Solve() {     int x, y;     n = input(), m = input();     for (int i = 1; i <= n; i++) s[i].reset();     memset(du, 0, sizeof du);     for (int i = 1; i <= m; i++) {       x = input(), y = input();       du[x]++, du[y]++;       s[x][y] = 1, s[y][x] = 1;     }     if (Check()) return;     for (int i = 1; i <= n; i++) {       if (du[i] % 2 == 1) s[i][i] = 1, s[i][n + 1] = 1;     }     Gauss();     x = 1;     for (int j = 1; j <= n; j++) {       if (s[x][j] == 0) {         as[j] = 1;         continue;       }       as[j] = s[x][n + 1] + 1;       x++;     }     printf( 2 n );     for (int i = 1; i < n; i++) printf( %d  , as[i]);     printf( %d n , as[n]);   }   int main() {     int T;     T = input();     while (T--) {       Solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   int ans[100000 + 1];   void reverseAns(int l, int r) {     if (l > r) return;     int mid = (l + r) >> 1;     for (int i = 1; i <= mid - l + 1; ++i) {       swap(ans[i + l - 1], ans[r - i + 1]);     }   }   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; ++i) {       ans[i] = i;     }     int block = round(sqrt(n));     int tot = n / block;     for (int i = 1; i <= tot; ++i) {       reverseAns((i - 1) * block + 1, i * block);     }     reverseAns(tot * block + 1, n);     for (int i = 1; i <= n; ++i) {       cout << ans[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, q, j, x[300000 + 10], a, b, sum, t, o[300000 + 10], p[300000 + 10],       h = 1;   int main() {     cin >> n >> q;     for (int i = 0; i < q; i++) {       cin >> a >> b;       if (a == 1) {         j++;         x[j] = b;         o[b]++;         p[b]++;         sum++;         cout << sum << endl;         continue;       }       if (a == 2) {         sum -= o[b];         o[b] = 0;         cout << sum << endl;         continue;       }       if (a == 3) {         for (h; h <= b; h++) {           int n1 = x[h];           if (p[n1] > 0) p[n1]--;           if (p[n1] < o[n1]) {             sum--;             o[n1]--;           }         }         cout << sum << endl;         continue;       }     }   }
#include <bits/stdc++.h>   long long mod(long long x) {     if (x < 0) return -x;     return x;   }   long long expo(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y % 2 == 1) res = (res * x);       y = y >> 1;       x = x * x;     }     return res;   }   using namespace std;   const int MAXN = 500005;   vector<long long> v;   long long a[1000000], b[1000000];   int main() {     ios_base::sync_with_stdio(false);     long long n, t, m, k, x, y;     cin >> n;     string s;     cin >> s;     x = 0;     y = 0;     t = 0;     if (n % 2 != 0) {       cout <<  :( ;       return 0;     }     for (long long i = 0; i < n; i++) {       if (s[i] ==  ) ) {         y++;       }       if (s[i] ==  ( ) {         x++;       }     }     k = n / 2 - x;     for (long long i = 0; i < n; i++) {       if (s[i] ==  ? ) {         s[i] =  ( ;         k--;       }       if (k <= 0) break;     }     k = n / 2 - y;     for (long long i = 0; i < n; i++) {       if (s[i] ==  ? ) {         s[i] =  ) ;         k--;       }       if (k <= 0) break;     }     t = 0;     for (long long i = 0; i < n; i++) {       if (s[i] ==  ) ) {         t--;       }       if (s[i] ==  ( ) {         t++;       }       if (t <= 0 && i != n - 1) {         cout <<  :( ;         return 0;       }       if (t < 0) {         cout <<  :( ;         return 0;       }     }     if (t != 0) {       cout <<  :( ;       return 0;     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dx[4] = {0, 0, -1, 1};   const int dy[4] = {-1, 1, 0, 0};   int main() {     int i, j, k, n;     long int mx, mn, sm = 0;     int t;     cin >> t;     while (t--) {       int f = 0;       cin >> n;       vector<pair<int, int>> v(n);       for (i = 0; i < n; i++) {         int a, b;         cin >> a >> b;         v[i] = (make_pair(a, b));       }       if (v[0].first < v[0].second) f = 1;       for (i = 1; i < n; i++) {         int x = v[i].first - v[i - 1].first;         int y = v[i].second - v[i - 1].second;         if (x < 0 || y < 0 || (v[i].first < v[i].second) ||             (v[i - 1].first < v[i - 1].second) || y > x) {           f = 1;           break;         }       }       if (f)         cout <<  NO               <<   n ;       else {         cout <<  YES               <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   const int maxm = 100005;   typedef int arr[maxn];   arr head, dfn, low, col, st;   int top, depth, color, tot, cnt;   pair<int, int> e[maxm * 2], bridge[maxn];   int euler[maxn * 2], d[maxn * 2][30], pos;   void add(int x, int y) {     e[tot] = make_pair(head[x], y);     head[x] = tot++;   }   void tarjan(int u, int f) {     dfn[u] = low[u] = ++depth;     st[++top] = u;     for (int i = head[u]; i != -1; i = e[i].first) {       int v = e[i].second;       if (v == f) continue;       if (!dfn[v]) {         tarjan(v, u);         low[u] = min(low[v], low[u]);       } else         low[u] = min(low[u], dfn[v]);       if (low[v] > dfn[u]) bridge[cnt++] = make_pair(u, v);     }     if (dfn[u] == low[u]) {       int x;       color++;       do {         col[x = st[top--]] = color;       } while (x != u);     }   }   void dfs(int u, int f) {     euler[++pos] = u;     low[u] = pos;     for (int i = head[u]; i != -1; i = e[i].first) {       int v = e[i].second;       if (v == f) continue;       dfn[v] = dfn[u] + 1;       dfs(v, u);       euler[++pos] = u;     }   }   void RMQ_init() {     for (int i = 1; i <= pos; i++) d[i][0] = i;     for (int j = 1; (1 << j) <= pos; j++) {       for (int i = 1; i + j - 1 <= pos; i++) {         if (dfn[euler[d[i][j - 1]]] < dfn[euler[d[i + (1 << (j - 1))][j - 1]]]) {           d[i][j] = d[i][j - 1];         } else           d[i][j] = d[i + (1 << (j - 1))][j - 1];       }     }   }   int RMQ(int L, int R) {     int k = 0;     if (L > R) swap(L, R);     while ((1 << (k + 1)) <= R - L + 1) k++;     return dfn[euler[d[L][k]]] < dfn[euler[d[R - (1 << k) + 1][k]]]                ? d[L][k]                : d[R - (1 << k) + 1][k];   }   int main() {     for (int n, m; scanf( %d%d , &n, &m) != EOF;) {       depth = color = tot = top = cnt = 0;       for (int i = 1; i <= n; i++) {         head[i] = -1, dfn[i] = 0;       }       for (int i = 1, x, y; i <= m; i++) {         scanf( %d%d , &x, &y);         add(x, y);         add(y, x);       }       tarjan(1, -1);       tot = 0;       for (int i = 0; i <= color; i++) {         head[i] = -1;         dfn[i] = 0;       }       for (int i = 0; i < cnt; i++) {         add(col[bridge[i].first], col[bridge[i].second]);         add(col[bridge[i].second], col[bridge[i].first]);       }       pos = 0;       dfn[1] = 0;       dfs(1, 0);       RMQ_init();       int Q;       scanf( %d , &Q);       for (int i = 1, x, y; i <= Q; i++) {         scanf( %d%d , &x, &y);         int ance = RMQ(low[col[x]], low[col[y]]);         ance = euler[ance];         printf( %d n , dfn[col[x]] + dfn[col[y]] - 2 * dfn[ance]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     int zuo = 0, you = 0;     for (int i = 0; i < n; i++) {       int x, y;       scanf( %d %d , &x, &y);       zuo += x;       you += y;     }     printf( %d n , min(n - zuo, zuo) + min(n - you, you));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxk = 20;   const int maxn = 3e5 + 17;   int N, Q;   int sub[maxn], ans[maxn];   vector<int> graph[maxn];   set<pair<int, int> > DFS(int u) {     sub[u] = 1;     set<pair<int, int> > cur;     for (int v : graph[u]) {       set<pair<int, int> > next = DFS(v);       if (next.size() >= cur.size()) swap(cur, next);       for (auto x : next) cur.insert(x);       sub[u] += sub[v];     }     cur.insert({sub[u], u});     ans[u] = cur.lower_bound({sub[u] + 1 >> 1, 0})->second;     return cur;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> N >> Q;     for (int i = 2; i <= N; i++) {       int x;       cin >> x;       graph[x].push_back(i);     }     DFS(1);     while (Q--) {       int x;       cin >> x;       cout << ans[x] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long rd() {     long long x = 0;     int ch = getchar(), f = 1;     while (!isdigit(ch) && (ch !=  - ) && (ch != EOF)) ch = getchar();     if (ch ==  - ) {       f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 1) + (x << 3) + ch -  0 ;       ch = getchar();     }     return x * f;   }   inline void rt(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x >= 10)       rt(x / 10), putchar(x % 10 +  0 );     else       putchar(x +  0 );   }   const int maxn = 130;   int N;   double a[maxn][maxn], b[maxn][maxn], c[maxn][maxn], p[maxn];   void pow(int x) {     if (x == 1) {       for (int i = 0; i <= (int)N; i++)         for (int j = 0; j <= (int)N; j++) c[i][j] = a[i][j];       return;     }     pow(x >> 1);     memset(b, 0, sizeof b);     for (int k = 0; k <= (int)N; k++)       for (int i = 0; i <= (int)N; i++)         for (int j = 0; j <= (int)N; j++) b[i][j] += c[i][k] * c[k][j];     if (x & 1) {       memset(c, 0, sizeof c);       for (int k = 0; k <= (int)N; k++)         for (int i = 0; i <= (int)N; i++)           for (int j = 0; j <= (int)N; j++) c[i][j] += b[i][k] * a[k][j];     } else       memcpy(c, b, sizeof c);   }   int n, x;   int main() {     n = rd(), x = rd();     for (int i = 0; i <= (int)x; i++) scanf( %lf , &p[i]);     for (N = 1; N <= x; N <<= 1)       ;     N--;     for (int i = 0; i <= (int)N; i++)       for (int j = 0; j <= (int)x; j++) a[i][i ^ j] = p[j];     pow(n);     double ans = 0;     printf( %.8lf n , 1 - c[0][0]);   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( Ofast )   #pragma GCC optimize( O3 )   const long long inf = 1e18;   long long i, j, k, m, n, qq, t, it, ma = -inf, mi = inf, x, y, col,                                       md = 998244353;   string cmp(string second) {     vector<long long> p(second.size(), 0);     for (i = 1; i < second.size(); i++) {       j = p[i - 1];       while (j > 0 && second[i] != second[j]) j = p[j - 1];       if (second[i] == second[j]) j++;       p[i] = j;     }     return second.substr(0, j);   }   int32_t main() {     cin >> qq;     while (qq--) {       string second;       cin >> second;       n = second.size();       k = 0;       while (n - 1 - k >= 0 && k < n / 2 && second[k] == second[n - 1 - k]) k++;       if (k == (n + 1) / 2) {         cout << second <<   n ;         continue;       }       for (i = 0; i < k; i++) cout << second[i];       string t = second.substr(k, max(0ll, n - k - k));       string rt = t;       reverse(rt.begin(), rt.end());       string ans1 = cmp(t +  %  + rt);       string ans2 = cmp(rt +  %  + t);       if (ans1.size() > ans2.size())         cout << ans1;       else         cout << ans2;       for (i = k - 1; i > -1; i--) cout << second[i];       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   char B[1 << 26], *S = B, C;   int X;   inline int read() {     while ((C = *S++) <  0  || C >  9 )       ;     for (X = C -  0 ; (C = *S++) >=  0  && C <=  9 ;)       X = (X << 3) + (X << 1) + C -  0 ;     return X;   }   int f[1000000 + 5], r[1000000 + 5], u[1000000 + 5];   int gf(int k) { return f[k] ? f[k] = gf(f[k]) : k; }   int main() {     fread(B, 1, 1 << 26, stdin);     int n, m, x, y, i, cnt = 1, s = 0;     long long ans = 0;     n = read();     m = read();     for (i = 1; i <= m; ++i) {       x = read();       y = read();       if (x == y)         ++s, u[x] = 1;       else         ++r[x], ++r[y];       if (gf(x) != gf(y)) ++cnt, f[gf(x)] = gf(y);     }     for (i = 1; i <= n; ++i)       if (!u[i] && !r[i]) ++cnt;     if (cnt < n) return 0 * puts( 0 );     for (i = 1; i <= n; ++i) ans += 1LL * r[i] * (r[i] - 1) >> 1;     ans += 1LL * s * (m - s) + (1LL * s * (s - 1) >> 1);     printf( %I64d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     int rc = 0, uc = 0, c = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  R )         rc++;       else         uc++;       if (rc == uc && s[i] == s[i + 1]) c++;     }     cout << c <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int M = 1e9 + 7;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cerr.tie(0);     int n, a[100005], sum = 0;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i], sum += a[i];     sort(a, a + n);     int p[] = {0, -1, -1}, ct = 0, f = 0;     for (int i = 0; i < n; i++) {       if ((a[i] % 3 == sum % 3) && p[sum % 3] == -1 && sum % 3 != 0)         p[sum % 3] = i;       if (a[i] == 0) ct++;     }     if ((n == 1 && a[0] == 0) || (a[n - 1] == 0) ||         (ct >= n - 1 && sum % 3 != 0)) {       cout <<  0 ;       return 0;     }     if (p[sum % 3] == -1 && a[0] == 0) {       if (sum % 3 == 2) {         int p1 = -1, p2 = -1;         for (int i = 0; i < n; i++) {           if (a[i] % 3 == 1) {             if (p1 == -1)               p1 = i;             else if (p2 == -1)               p2 = i;           }         }         if (p2 == -1) {           cout <<  0 ;         } else {           for (int i = n - 1; i >= 0; i--) {             if (i != p1 && i != p2) {               if (a[i] == 0 && f == 0) {                 cout <<  0 ;                 return 0;               } else                 f = 1, cout << a[i];             }           }         }       } else if (sum % 3 == 1) {         int p1 = -1, p2 = -1;         for (int i = 0; i < n; i++) {           if (a[i] % 3 == 2) {             if (p1 == -1)               p1 = i;             else if (p2 == -1)               p2 = i;           }         }         if (p2 == -1) {           cout <<  0 ;         } else {           for (int i = n - 1; i >= 0; i--) {             if (i != p1 && i != p2) {               if (a[i] == 0 && f == 0) {                 cout <<  0 ;                 return 0;               } else                 f = 1, cout << a[i];             }           }         }       }       return 0;     }     if (a[0] != 0 || p[sum % 3] == -1) {       cout << -1;       return 0;     } else {       for (int i = n - 1; i >= 0; i--) {         if (i != p[sum % 3] || a[i] == 0) {           if (f == 0 && a[i] == 0) {             cout <<  0 ;             return 0;           } else             f = 1, cout << a[i];         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int h1, h2, m1, m2, h3, m3;     char s1, s2;     cin >> h1 >> s1 >> m1 >> h2 >> s2 >> m2;     if (h1 == 0) h1 = 24;     if (h2 == 0) h2 = 24;     if (m1 < m2) {       h1--;       m3 = m1 + 60 - m2;     } else       m3 = m1 - m2;     if (h1 < h2) {       h3 = h1 + 24 - h2;     } else       h3 = h1 - h2;     if (m3 >= 10 && h3 >= 10)       cout << h3 << s1 << m3 << endl;     else if (m3 < 10 && h3 >= 10)       cout << h3 << s1 <<  0  << m3 << endl;     else if (h3 < 10 && m3 >= 10)       cout <<  0  << h3 << s1 << m3 << endl;     else       cout <<  0  << h3 << s1 <<  0  << m3 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const double PI =       3.141592653589793238462643383279502884197169399375105820974944;   long long dist(long long a, long long b, long long c, long long d) {     return abs(a - c) + abs(b - d);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long a, b, c, d;     cin >> a >> b >> c >> d;     long long ans = 1000000000;     for (long long i = c - 1; i <= c + 1; i++) {       for (long long j = d - 1; j <= d + 1; j++) {         if (i != c or j != d) {           ans = min(ans, dist(a, b, i, j));         }       }     }     cout << 2 * ans + 8 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, tb[100], w1, w2, l = 1;   int main() {     scanf( %d , &n);     for (int i = 0; i < n / 2; i++) scanf( %d , &tb[i]);     sort(tb, tb + n / 2);     for (int i = 0; i < n / 2; i++) {       w1 += abs(tb[i] - l);       l += 2;     }     l = 2;     for (int i = 0; i < n / 2; i++) {       w2 += abs(tb[i] - l);       l += 2;     }     printf( %d , min(w1, w2));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const long long infl = 1LL << 60;   mt19937 rnd(time(0));   inline int myrand(int l, int r) { return rnd() % (r - l + 1) + l; }   inline int read() {     int x = 0, f = 1;     char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) f = -1;       c = getchar();     }     while (isdigit(c)) {       x = x * 10 + c -  0 , c = getchar();     }     return x * f;   }   const int maxn = 3e5 + 10;   vector<int> linker[maxn];   int n, m, q[maxn], dis[maxn], pre[maxn];   bool mark[maxn], vis[maxn];   vector<int> v;   void dfs(int x) {     vis[x] = 1, v.push_back(x);     for (int cur : linker[x])       if (!vis[cur]) dfs(cur);   }   void print() {     vector<int> ans(0);     int x = n;     while (x) ans.push_back(x), x = pre[x];     reverse(ans.begin(), ans.end());     for (int cur : ans) printf( %d  , cur);     puts(  );   }   int main() {     n = read(), m = read();     for (int i = 1; i <= m; i++) {       int u = read(), v = read();       linker[u].push_back(v);       linker[v].push_back(u);     }     int head = 1, tail = 0;     memset(dis, 0x3f, sizeof dis);     q[++tail] = 1, dis[1] = 0;     while (head <= tail) {       int x = q[head++];       for (int cur : linker[x])         if (dis[cur] == inf) dis[cur] = dis[x] + 1, q[++tail] = cur, pre[cur] = x;     }     if (dis[n] <= 4) return printf( %d n , dis[n]), print(), 0;     for (int cur : linker[1]) mark[cur] = 1;     mark[1] = 1;     for (int cur : linker[1]) {       for (int to : linker[cur])         if (!mark[to]) {           printf( %d n%d %d %d %d %d n , 4, 1, cur, to, 1, n);           return 0;         }     }     vis[1] = 1;     for (int x : linker[1])       if (!vis[x]) {         dfs(x);         for (int y : v) {           if (mark[y] && linker[y].size() - 1 < v.size() - 1) {             printf( %d n , min(dis[n], 5));             if (dis[n] < 5)               print();             else {               memset(mark, 0, sizeof mark);               for (int cur : linker[y]) mark[cur] = 1;               mark[y] = 1;               for (int cur : linker[y])                 if (cur != 1)                   for (int foo : linker[cur])                     if (!mark[foo]) {                       printf( %d %d %d %d %d %d n , 1, y, cur, foo, y, n);                       return 0;                     }             }             return 0;           }         }         v.clear();       }     if (dis[n] == inf)       return puts( -1 ), 0;     else {       printf( %d n , dis[n]);       print();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double v = 1.41421356237;   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     int t = 1;     cin >> t;     while (t--) {       long long int x1, y1, z1, x2, y2, z2;       cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;       long long int m, sum = 0;       m = min(z1, y2);       sum += (2 * m);       m = min(x1, z2);       x1 -= m;       z2 -= m;       m = min(y1, x2);       y1 -= m;       x2 -= m;       sum -= (2 * min(y1, z2));       cout << sum << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 50005;   const unsigned long long MOD = 1e8 + 7;   const unsigned long long MAX = 1e15;   int X[N], Y[N], T[N], K[N];   int n;   double P[N], dp[N], ans = 0;   bool cmp(int a, int b) { return T[a] < T[b]; }   double dist(int i, int j) {     double ans = sqrt((X[K[i]] - X[K[j]]) * (X[K[i]] - X[K[j]]) +                       (Y[K[i]] - Y[K[j]]) * (Y[K[i]] - Y[K[j]]));     return ans;   }   void work() {     for (int i = 1; i <= n; i++) {       dp[i] = P[K[i]];       for (int j = 1; j < i; j++)         if (dist(i, j) + T[K[j]] <= T[K[i]]) dp[i] = max(dp[j] + P[K[i]], dp[i]);       ans = max(ans, dp[i]);     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d%d%lf , &X[i], &Y[i], &T[i], &P[i]);       K[i] = i;     }     sort(K + 1, K + n + 1, cmp);     work();     printf( %.7f n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int n, k, a[10010];   bool vs[3000][3000];   int main() {     cin >> n >> k;     for (int i = n + 1; i <= n + k; i++) {       a[i] = i - n;     }     for (int i = 1; i <= n; i++) a[i] = i;     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= i + k; j++) {         if (!vs[a[i]][a[j]] && !vs[a[j]][a[i]]) {           vs[a[i]][a[j]] = true;           vs[a[j]][a[i]] = true;         } else {           cout << -1;           exit(0);         }       }     }     if (n == 1) {       cout << -1;       exit(0);     }     cout << n * k <<   n ;     for (int i = 1; i <= n; i++)       for (int j = i + 1; j <= i + k; j++) cout << a[i] <<     << a[j] <<   n ;   }