malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300000 + 100;   int n, m, sz, l, r;   int head[maxn], Next[maxn], to[maxn], in[maxn], out[maxn], deg[maxn], q[maxn];   void init() {     sz = 0;     memset(deg, 0, sizeof(deg));     memset(head, -1, sizeof(head));   }   void add_edge(int a, int b) {     ++sz;     to[sz] = b;     Next[sz] = head[a];     head[a] = sz;   }   struct Edge {     int from, to;   } edges[maxn];   int main() {     init();     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       int a, b;       scanf( %d%d , &a, &b);       edges[i].from = a;       edges[i].to = b;       add_edge(a, b);       deg[b]++;     }     l = r = 0;     for (int i = 1; i <= n; i++) {       if (!deg[i]) {         q[r++] = i;       }     }     while (l < r) {       int u = q[l++];       if (l == r) {         out[u] = n - r;       } else if (l + 1 == r) {         int v = q[l];         int flag = 1;         for (int i = head[v]; i != -1; i = Next[i]) {           int vv = to[i];           if (deg[vv] == 1) {             flag = 0;             break;           }         }         if (!flag)           out[u] = -n;         else           out[u] = n - r;       } else         out[u] = -n;       for (int i = head[u]; i != -1; i = Next[i]) {         int v = to[i];         deg[v]--;         if (!deg[v]) q[r++] = v;       }     }     init();     for (int i = 1; i <= m; i++) {       add_edge(edges[i].to, edges[i].from);       deg[edges[i].from]++;     }     l = r = 0;     for (int i = 1; i <= n; i++) {       if (!deg[i]) {         q[r++] = i;       }     }     while (l < r) {       int u = q[l++];       if (l == r) {         in[u] = n - r;       } else if (l + 1 == r) {         int v = q[l];         int flag = 1;         for (int i = head[v]; i != -1; i = Next[i]) {           int vv = to[i];           if (deg[vv] == 1) {             flag = 0;             break;           }         }         if (!flag)           in[u] = -n;         else           in[u] = n - r;       } else         in[u] = -n;       for (int i = head[u]; i != -1; i = Next[i]) {         int vv = to[i];         deg[vv]--;         if (!deg[vv]) q[r++] = vv;       }     }     int ans = 0;     for (int i = 1; i <= n; i++) {       if (in[i] + out[i] >= n - 2) {         ans++;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     if (n == 1 || n == 2 || n == 3) {       cout <<  NO  << endl;       return 0;     }     cout <<  YES  << endl;     if (n % 2 == 0) {       printf( 1 * 2 = 2 n );       printf( 2 * 3 = 6 n );       printf( 6 * 4 = 24 n );     } else {       printf( 3 - 1 = 2 n );       printf( 5 - 2 = 3 n );       printf( 2 * 3 = 6 n );       printf( 6 * 4 = 24 n );     }     if (n % 2 == 0) {       for (int i = n; i >= 6; i -= 2) {         printf( %d - %d = 1 n , i, i - 1);         printf( 24 * 1 = 24 n );       }     } else {       for (int i = n; i >= 7; i -= 2) {         printf( %d - %d = 1 n , i, i - 1);         printf( 24 * 1 = 24 n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int r[105][105], d[105][105], vis[105][105];   int w, h, n;   int bfs(int x, int y) {     queue<pair<int, int> > q;     q.push({x, y});     vis[x][y] = 1;     int area = 0;     while (!q.empty()) {       int cx = q.front().first, cy = q.front().second;       q.pop();       ++area;       if (!d[cx][cy] && cx > 1 && !vis[cx - 1][cy])         q.push({cx - 1, cy}), vis[cx - 1][cy] = 1;       if (!r[cx][cy] && cy < w && !vis[cx][cy + 1])         q.push({cx, cy + 1}), vis[cx][cy + 1] = 1;     }     return area;   }   int main() {     cin >> w >> h >> n;     int x1, x2, y1, y2;     for (int i = 1; i <= n; ++i) {       cin >> x1 >> y1 >> x2 >> y2;       if (x1 == x2)         for (int j = y1 + 1; j <= y2; ++j) r[j][x1] = 1;       else         for (int j = x1 + 1; j <= x2; ++j) d[y1 + 1][j] = 1;     }     vector<int> ans;     for (int i = h; i >= 1; --i)       for (int j = 1; j <= w; ++j)         if (!vis[i][j]) ans.push_back(bfs(i, j));     sort(ans.begin(), ans.end());     for (auto& x : ans) cout << x <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   struct data {     int points;     string name;     data(int p, string n) {       points = p;       name = n;     }     data() {       points = -1;       name =   ;     }   };   inline bool cmp(data d1, data d2) { return (d1.points > d2.points); }   int main() {     int n, m, r, points;     cin >> n >> m;     string name;     vector<vector<data>> reg(m);     for (auto i(0); i < n; ++i) {       cin >> name >> r >> points;       r--;       if (reg[r].size() < 3) {         reg[r].push_back(data(points, name));         sort(reg[r].begin(), reg[r].end(), cmp);       } else {         reg[r].push_back(data(points, name));         sort(reg[r].begin(), reg[r].end(), cmp);         reg[r].resize(3);       }     }     for (auto i(0); i < m; ++i) {       if (reg[i].size() == 2) {         cout << reg[i][0].name <<     << reg[i][1].name << endl;         ;       } else if (reg[i][1].points == reg[i][2].points) {         cout <<  ?  << endl;       } else {         cout << reg[i][0].name <<     << reg[i][1].name << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10, M = 1e6 + 5;   long long T, l[N], dp[N], fen[M][2];   vector<int> adj[N];   int n, x[N], t[N];   void add(int p, int x) {     for (long long y = 1LL * x * p; p < M; p += p & -p)       fen[p][0] += x, fen[p][1] += y;   }   long long get(int p, int id) {     long long ans = 0;     for (; p; p -= p & -p) ans += fen[p][id];     return ans;   }   void dfs(int u) {     add(t[u], x[u]);     int L = 0, R = M;     while (L + 1 < R) {       int mid = L + R >> 1;       (T < 2 * l[u] + get(mid, 1) ? R : L) = mid;     }     long long mx[2] = {};     for (int v : adj[u]) {       l[v] += l[u], dfs(v);       dp[v] > mx[1] ? mx[0] = mx[1], mx[1] = dp[v] : mx[0] = max(mx[0], dp[v]);     }     dp[u] =         max(get(L, 0) + (R < M && T > 2 * l[u]) * (T - 2 * l[u] - get(L, 1)) / R,             mx[!u]);     add(t[u], -x[u]);   }   int main() {     cin >> n >> T;     for (int u = 0; u < n; u++) cin >> x[u];     for (int u = 0; u < n; u++) cin >> t[u];     for (int u = 1, v; u < n; u++) {       cin >> v >> l[u];       adj[--v].push_back(u);     }     dfs(0), cout << dp[0];   }
#include <bits/stdc++.h>   using namespace std;   long long f[(1 << 20) + 10], num[21], sum[21][21];   int main() {     int n, m = 20;     scanf( %d , &n);     for (int i = 1, x; i <= n; i++) {       scanf( %d , &x);       x--, num[x]++;       for (int j = 0; j < 20; j++) {         sum[j][x] += num[j];       }     }     memset(f, 0x3f, sizeof f);     f[0] = 0;     for (int i = 1; i < 1 << m; i++) {       for (int j = 0; j < m; j++) {         if (i >> j & 1) {           long long cur = 0;           for (int k = 0; k < m; k++) {             if ((i >> k & 1) && k != j) {               cur += sum[k][j];             }           }           f[i] = min(f[i], f[i ^ (1 << j)] + cur);         }       }     }     printf( %lld n , f[(1 << m) - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[7];   long long T, X, Y, ans;   long long ABS(long long x) { return (x > 0) ? x : -x; }   int main() {     scanf( %lld , &T);     while (T--) {       scanf( %lld%lld , &X, &Y);       for (int i = 1; i <= 6; i++) scanf( %lld , &a[i]);       a[1] = min(a[1], a[6] + a[2]);       a[6] = min(a[6], a[5] + a[1]);       for (int i = 2; i <= 5; i++) {         a[i] = min(a[i], a[i - 1] + a[i + 1]);       }       if (X <= Y && X >= 0) {         X = ABS(X);         Y = ABS(Y);         ans = a[1] * X + a[2] * (Y - X);       } else if (X < 0 && Y >= 0) {         X = ABS(X);         Y = ABS(Y);         ans = a[2] * Y + a[3] * X;       } else if (X < 0 && -X >= -Y && Y < 0) {         X = ABS(X);         Y = ABS(Y);         ans = a[4] * Y + a[3] * (X - Y);       } else if (X <= 0 && Y < 0 && -X < -Y) {         X = ABS(X);         Y = ABS(Y);         ans = a[4] * X + a[5] * (Y - X);       } else if (X > 0 && Y <= 0) {         X = ABS(X);         Y = ABS(Y);         ans = a[6] * X + a[5] * Y;       } else {         X = ABS(X);         Y = ABS(Y);         ans = a[1] * Y + a[6] * (X - Y);       }       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   bool check(int s) { return (int)sqrt(s) * (int)sqrt(s) == s; }   int main() {     int i, j, a, b, c, d, s1, s2, s3, s4;     scanf( %d%d , &n, &m);     for (a = 1; a <= 100; a++)       for (b = 1; b <= 100; b++)         for (c = 1; c <= 100; c++)           for (d = 1; d <= 100; d++) {             s1 = (m - 1) * a * a + b * b;             s2 = (n - 1) * a * a + c * c;             s3 = (n - 1) * b * b + d * d;             s4 = (m - 1) * c * c + d * d;             if (check(s1) && check(s2) && check(s3) && check(s4)) goto hhh;           }   hhh:     for (i = 1; i < n; i++) {       for (j = 1; j < m; j++) printf( %d  , a);       printf( %d n , b);     }     for (i = 1; i < m; i++) printf( %d  , c);     printf( %d n , d);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     vector<float> coordinates;     for (int i = 0; i < (int)(n); ++i) {       float a, b;       cin >> a >> b;       coordinates.push_back(a);       coordinates.push_back(b);     }     float sum = 0;     std::cout << fixed;     std::cout << setprecision(9);     for (int i = 0; i < coordinates.size() - 2; i += 2) {       sum += sqrt(pow(abs(coordinates[i] - coordinates[i + 2]), 2) +                   pow(abs(coordinates[i + 1] - coordinates[i + 3]), 2)) /              50;     }     cout << sum * k <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v[300005], one[300005];   map<pair<int, int>, int> mp;   int size[300005], ji[300005], xx[300005], yy[300005];   char ans[300005];   void dfs1(int p, int fa) {     size[p] = 1;     ji[p]++;     for (int i = 0; i < v[p].size(); i++) {       int to = v[p][i];       if (to == fa || ji[to]) continue;       dfs1(to, p);       size[p] += size[to];     }     for (int i = 0; i < one[p].size(); i++) {       int to = one[p][i];       if (to == fa) continue;       mp[pair<int, int>(p, to)] = 1;       if (ji[to]) continue;       dfs1(to, p);       size[p] += size[to];     }   }   void dfs2(int p, int fa) {     size[p] = 1;     ji[p]++;     for (int i = 0; i < v[p].size(); i++) {       int to = v[p][i];       if (to == fa || ji[to]) continue;       dfs2(to, p);       size[p] += size[to];     }     for (int i = 0; i < one[p].size(); i++) {       int to = one[p][i];       if (to == fa) continue;       mp[pair<int, int>(to, p)] = 1;     }   }   int main() {     int n, m, s, tot = 0;     scanf( %d%d%d , &n, &m, &s);     for (int i = 0; i < m; i++) {       int f, x, y;       scanf( %d%d%d , &f, &x, &y);       if (f == 1)         v[x].push_back(y);       else {         one[x].push_back(y);         one[y].push_back(x);         xx[tot] = x;         yy[tot++] = y;       }     }     dfs1(s, 0);     printf( %d n , size[s]);     for (int i = 0; i < tot; i++) {       if (mp[pair<int, int>(xx[i], yy[i])])         printf( + );       else         printf( - );     }     printf(  n );     memset(ji, 0, sizeof(ji));     mp.clear();     dfs2(s, 0);     printf( %d n , size[s]);     for (int i = 0; i < tot; i++) {       if (mp[pair<int, int>(xx[i], yy[i])])         printf( + );       else         printf( - );     }     printf(  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 n, k;     cin >> n >> k;     vector<string> notes, names(55);     for (int i = 0; i <= n - k; i++) {       string m;       cin >> m;       notes.push_back(m);     }     for (int i = 0; i < 26; i++) {       names[i] = (i +  A );     }     if (n >= 26) {       for (int i = 26; i <= n; i++) {         names[i] = names[i - 26] +  a ;       }     }     for (int i = 0; i <= n - k; i++) {       if (notes[i] ==  NO ) names[i + k - 1] = names[i];     }     for (int i = 0; i < n; i++) {       cout << names[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     double d, h, v, e;     cin >> d >> h >> v >> e;     double ans = (3.14159265358979323846 * pow(d, 2) * h) /                  (4 * v - 3.14159265358979323846 * pow(d, 2) * e);     if (ans < 0)       cout <<  NO n ;     else {       cout <<  YES n ;       cout << setprecision(10) << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   bool taken[1001];   int a[1001], b[1001], ans[1001];   vector<int> problem;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     for (int i = 0; i < n; ++i) {       cin >> b[i];       if (b[i] == a[i])         ans[i] = b[i], taken[a[i]] = true;       else         problem.push_back(i);     }     if (problem.size() == 1) {       for (int i = 1; i <= n; ++i) {         if (!taken[i]) {           ans[problem[0]] = i;           break;         }       }     } else {       vector<int> possible[2];       for (int i = 1; i <= n; ++i) {         if (!taken[i]) {           if (a[problem[0]] == i || b[problem[0]] == i) possible[0].push_back(i);           if (a[problem[1]] == i || b[problem[1]] == i) possible[1].push_back(i);         }       }       if (possible[0].size() == possible[1].size()) {         if (possible[0].size() == 1) {           ans[problem[0]] = possible[0][0];           ans[problem[1]] = possible[1][0];         } else {           ans[problem[0]] = possible[0][0];           ans[problem[1]] = possible[1][1];         }       } else {         if (possible[0].size() == 1) {           ans[problem[0]] = possible[0][0];           ans[problem[1]] = (possible[0][0] == possible[1][0] ? possible[1][1]                                                               : possible[1][0]);         } else {           ans[problem[0]] = (possible[1][0] == possible[0][0] ? possible[0][1]                                                               : possible[0][0]);           ans[problem[1]] = possible[1][0];         }       }     }     for (int i = 0; i < n; ++i) {       cout << ans[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     multiset<int> s;     s.insert(0);     int q;     cin >> q;     while (q--) {       char c;       int x;       cin >> c >> x;       if (c ==  + ) {         s.insert(x);       } else if (c ==  - ) {         s.erase(s.find(x));       } else {         int cur = 0;         for (int i = 30; i >= 0; i--) {           if (((1 << i) & x) == 0) {             cur |= (1 << i);             auto it = s.lower_bound(cur);             if (it == s.end() || (cur >> i) != (*it >> i)) cur ^= (1 << i);           } else {             auto it = s.lower_bound(cur);             if (it == s.end() || (cur >> i) != (*it >> i)) cur |= (1 << i);           }         }         cout << (x ^ cur) <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     int n;     long long mmax = 0;     long long sum = 0;     long long num;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> num;       sum += num;       mmax = max(mmax, num);     }     cout << 2 * mmax - sum + 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::cin.tie(0);     std::ios::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       int n, m, k;       cin >> n >> m >> k;       int nn = n - (n % 2 == 1);       int mm = m - (m % 2 == 1);       long long maxx = (nn / 2) * (mm / 2) * 2;       if (n != nn) {         maxx += m / 2;         if (m / 2 > k || (k - m / 2) % 2 == 1) {           cout <<  NO  << endl;           continue;         }       } else {         if (k % 2 == 1) {           cout <<  NO  << endl;           continue;         }       }       if (maxx < k) {         cout <<  NO  << endl;         continue;       }       vector<vector<char>> l = {{ a ,  b ,  c ,  d }, { x ,  y ,  z ,  w }};       vector<char> let = { m ,  n };       int q = 0;       vector<vector<char>> ans(n, vector<char>(m));       if (n != nn) {         for (int i = 0; i < m; i += 2) {           k--;           ans[n - 1][i] = let[q];           ans[n - 1][i + 1] = let[q];           q = (q + 1) % 2;         }       }       q = 0;       if (m != mm) {         for (int i = 0; i < n; i += 2) {           ans[i][m - 1] = let[q];           ans[i + 1][m - 1] = let[q];           q = (q + 1) % 2;         }       }       q = 0;       for (int i = 0; i < nn; i += 2) {         int f = (i % 4 == 0);         q = 0;         for (int j = 0; j < mm; j += 2) {           if (k > 0) {             ans[i][j] = l[f][q];             ans[i][j + 1] = l[f][q];             q = (q + 1) % 4;             ans[i + 1][j] = l[f][q];             ans[i + 1][j + 1] = l[f][q];             q = (q + 1) % 4;             k -= 2;           } else {             ans[i][j] = l[f][q];             ans[i + 1][j] = l[f][q];             q = (q + 1) % 4;             ans[i][j + 1] = l[f][q];             ans[i + 1][j + 1] = l[f][q];             q = (q + 1) % 4;           }         }       }       cout <<  YES  << endl;       for (int i = int(0); i < int(n); i++) {         for (int j = int(0); j < int(m); j++) cout << ans[i][j];         cout << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   vector<vector<pair<long long, long long> > > g;   void fun() {     cin >> n >> m >> k;     g.resize(n);     map<pair<int, int>, int> index;     for (long long i = 0; i < m; i++) {       long long x, y, z;       cin >> x >> y >> z;       x--;       y--;       g[x].push_back({y, z});       g[y].push_back({x, z});       index[{x, y}] = i + 1;       index[{y, x}] = i + 1;     }     vector<long long> dis(n, LLONG_MAX), par(n);     dis[0] = 0;     set<pair<long long, long long> > s;     s.insert({0, 0});     while (!s.empty()) {       pair<long long, long long> d = *s.begin();       s.erase(s.begin());       for (auto j : g[d.second]) {         if (dis[j.first] > dis[d.second] + j.second) {           s.erase({dis[j.first], j.first});           dis[j.first] = dis[d.second] + j.second;           par[j.first] = d.second;           s.insert({dis[j.first], j.first});         }       }     }     vector<pair<long long, int> > dissort;     for (int i = 0; i < n; i++) dissort.push_back({dis[i], i});     sort((dissort).begin(), (dissort).end());     cout << min(n - 1, k) <<   n ;     k = min(n - 1, k);     int j = 1;     while (k--) {       int x = dissort[j].second;       cout << index[{x, par[x]}] <<    ;       j++;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     srand(time(0));     ;     int t = 1;     while (t--) fun();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     long long m, k;     scanf( %d%lld%lld , &n, &m, &k);     long long a[n], asum[n + 1];     asum[0] = 0;     for (int((i)) = (0); ((i)) < ((n)); ++((i))) {       scanf( %lld , &a[i]);       asum[i + 1] = asum[i] + a[i];     }     long long dp[m];     for (int((i)) = (0); ((i)) < ((m)); ++((i))) dp[i] = 1e18;     long long ans = 0;     for (int((i)) = (0); ((i)) < ((n)); ++((i))) {       dp[i % m] = min(dp[i % m] + k, asum[i] + k);       for (int((j)) = (0); ((j)) < ((m)); ++((j)))         ans = max(ans, asum[i + 1] - dp[j]);     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int E9 = 1e9;   const int E8 = 1e8;   const int E7 = 1e7;   const int E6 = 1e6;   const int E5 = 1e5;   const int E4 = 1e4;   const int E3 = 1e3;   const int N = 5e5 + 7;   const int MOD = 1e9 + 7;   const long long INF = 1e18;   int n;   bool dp[101][51][2][201];   string s;   void calc(int com, int kol, int dir, int pos) {     if (dp[com][kol][dir][pos]) {       return;     }     dp[com][kol][dir][pos] = 1;     if (com == (int)s.size()) {       return;     }     for (int i = 0; i <= n - kol; i++) {       if (i % 2 == 0) {         if (s[com] ==  F ) {           calc(com + 1, kol + i, dir, pos + (dir == 0 ? 1 : -1));         } else {           calc(com + 1, kol + i, (dir ^ 1), pos);         }       } else {         if (s[com] ==  T ) {           calc(com + 1, kol + i, dir, pos + (dir == 0 ? 1 : -1));         } else {           calc(com + 1, kol + i, (dir ^ 1), pos);         }       }     }   }   int main() {     cin >> s >> n;     calc(0, 0, 0, 100);     int sz = (int)s.size();     int mx = 0;     for (int i = 0; i <= 200; i++) {       if (dp[sz][n][0][i] || dp[sz][n][1][i]) {         mx = max(mx, abs(i - 100));       }     }     cout << mx;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     unsigned long long n, sum = 0;     cin >> n;     if (n % 2 == 0) {       if ((n / 2) % 2 == 0)         cout << 0 << endl;       else         cout << 1 << endl;     } else {       if ((n / 2) % 2 == 0)         cout << 1 << endl;       else         cout << 0 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long inf = 1e9 + 7;   long long mod = 998244353;   using namespace std;   vector<long long> g[200005];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long T, N, i, j, k, L, l, m, n;     long long s;     cin >> N >> s;     for (i = 0; i < N - 1; i++) {       long long u, v;       cin >> u >> v;       u--;       v--;       g[u].push_back(v);       g[v].push_back(u);     }     long double ans = 0.0;     if (N == 2)       ans = (long double)s / 2.0;     else {       long long cnt = 0;       for (i = 0; i < N; i++) {         if (g[i].size() == 1) cnt++;       }       ans = (long double)s / (long double)cnt;     }     printf( %.12Lf n , 2 * ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     vector<int> debt(n + 1, 0);     for (int i = 0; i < m; i++) {       int poor, rich, amt;       cin >> poor >> rich >> amt;       debt[poor] -= amt;       debt[rich] += amt;     }     int ans = 0;     for (int &it : debt) {       if (it < 0) {         ans += -it;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 + 10, INF = 1e9;   double arr[maxn];   int main() {     int n;     double mina = 0, maxa = INF;     cin >> n;     for (int i = 0; i < n; i++) cin >> arr[i];     for (int i = 0; i < n; i++) {       mina = max(mina, arr[i] * 10 / (i + 1));       maxa = min(maxa, (arr[i] + 1) * (10) / (i + 1));     }     int k1, k2;     k1 = (mina) * (n + 1) / 10;     k2 = ceil((maxa) * (n + 1) - 1) / 10;     if (k1 != k2)       cout <<  not unique  << endl;     else {       cout <<  unique  << endl;       cout << k1 << endl;     }     return 0;   }