malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10, logN = 20;   const int M = 350;   int d[N], h[N], floorlog[N << 1];   long long D[N], F1[N], F2[N], lft[N], rgt[N], total = 0;   map<pair<int, int>, long long> st;   vector<pair<int, int> > queries, q;   pair<int, int> rmq1[logN][N], rmq2[logN][N];   int max(int i, int j, long long f[]) { return f[i] > f[j] ? i : j; }   pair<int, int> merge(pair<int, int>& x, pair<int, int>& y, long long f[]) {     if (f[x.first] > f[y.first]) {       return {x.first, max(x.second, y.first, f)};     }     if (x.first == y.first) {       return {y.first, max(x.second, y.second, f)};     }     return {y.first, max(x.first, y.second, f)};   }   void make_rmq(long long f[], pair<int, int> rmq[][N], int n) {     for (int i = n; i >= 1; i--) {       rmq[0][i] = {i, 0};       for (int j = 1; i + (1 << j) - 1 <= n; j++) {         rmq[j][i] = merge(rmq[j - 1][i], rmq[j - 1][i + (1 << (j - 1))], f);       }     }   }   pair<int, int> get(int i, int j, pair<int, int> rmq[][N], long long f[]) {     int k = floorlog[j - i + 1];     return merge(rmq[k][i], rmq[k][j - (1 << k) + 1], f);   }   long long query(int l, int r) {     pair<int, int> P = get(l, r, rmq1, F1);     pair<int, int> Q = get(l, r, rmq2, F2);     long long mx = 0;     if (P.first != Q.first) mx = max(mx, F1[P.first] + F2[Q.first]);     if (P.second != Q.first) mx = max(mx, F1[P.second] + F2[Q.first]);     if (P.first != Q.second) mx = max(mx, F1[P.first] + F2[Q.second]);     if (P.second != Q.second) mx = max(mx, F1[P.second] + F2[Q.second]);     return mx;   }   int main() {     for (int i = 0; (1 << i) < N; i++)       for (int j = (1 << i); j < (1 << (i + 1)); j++) floorlog[j] = i;     int n, m;     scanf( %d , &(n));     scanf( %d , &(m));     for (int i = 1; i <= n; i++) {       D[i] = D[i - 1] + d[i - 1];       scanf( %d , &(d[i]));       total += d[i];     }     for (int i = 1; i <= n; i++) {       scanf( %d , &(h[i]));       F1[i] = D[i] + 2 * h[i];       F2[i] = -D[i] + 2 * h[i];       rgt[i] = max(rgt[i - 1], D[i] + 2 * h[i]);     }     for (int i = n; i >= 1; i--) {       lft[i] = max(lft[i + 1], total - D[i] + 2 * h[i]);     }     F1[0] = -1e18;     F2[0] = -1e18;     make_rmq(F1, rmq1, n);     make_rmq(F2, rmq2, n);     for (int i = 1; i <= m; i++) {       int a, b;       scanf( %d , &(a));       scanf( %d , &(b));       q.push_back({a, b});       if (a > b) {         int l = b + 1, r = a - 1;         printf( %lld n , query(l, r));       } else {         long long ans = 0;         if (b != n && a != 1) ans = max(ans, lft[b + 1] + rgt[a - 1]);         if (b != n) ans = max(ans, query(b + 1, n));         if (a != 1) ans = max(ans, query(1, a - 1));         printf( %lld n , ans);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<int> v(4);     int total = 0;     for (int i = 0; i < 4; i++) {       scanf( %d , &v[i]);       total += v[i];     }     sort(v.begin(), v.end());     do {       int sum = 0;       for (int i = 0; i < 4; i++) {         sum += v[i];         if (2 * sum == total) {           cout <<  YES ;           return 0;         }       }     } while (next_permutation(v.begin(), v.end()));     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug& operator<<(const c&) {       return *this;     }   };   const long long int N = 1e5 + 5;   const long long int INF = 1e10;   long long int mod = 998244353;   long long int dx[4] = {0, 0, +1, -1};   long long int dy[4] = {+1, -1, 0, 0};   long long int n;   void solve() {     cin >> n;     long long int c1 = 0, c2 = 0;     for (long long int i = 0; i < n; i++) {       long long int x;       cin >> x;       (x == 1 ? c1++ : c2++);     }     long long int f = 0;     for (long long int i = 0; i < n; i++) {       if (f == 0 and c2 > 0 and c1 > 0) {         cout << 2 <<     << 1 <<    ;         c2--, c1--;         f = 1;       } else if (c2 > 0) {         cout << 2 <<    ;         c2--;       } else if (c1 > 0) {         cout << 1 <<    ;         c1--;       }     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long int t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e5;   int ans[N], all, u, v, n, m, num, color[N], cnt[2];   vector<int> adj[N], radj[N];   bool used[N];   void output() {     printf( YES n );     for (int i = 0; i < n; ++i) printf( %d%c , ans[i] + 1,    n [i == n - 1]);     exit(0);   }   void dfs(int v, int c) {     color[v] = c, cnt[c]++;     for (int j = 0; j < ((int)(adj[v]).size()); ++j)       if (color[adj[v][j]] == -1) dfs(adj[v][j], c ^ 1);   }   void truecolor() {     int deg = 0;     for (int t = 0; t < 2; ++t) {       for (int i = 0; i < n; ++i)         if (color[i] == t) {           ans[i] = num;           ++deg;           if (deg == 3) {             ++num;             deg = 0;           }         }     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; ++i)       scanf( %d%d , &u, &v), --u, --v, adj[u].push_back(v), adj[v].push_back(u);     memset(color, -1, sizeof(color));     for (int i = 0; i < n; ++i)       if (color[i] == -1) dfs(i, 0);     if (cnt[0] % 3 > cnt[1] % 3) {       for (int i = 0; i < n; ++i) color[i] ^= 1;       swap(cnt[0], cnt[1]);     }     all = 0;     for (int i = 0; i < n; ++i)       if (color[i] == 1) all ^= i;     num = 0;     if (cnt[0] % 3 == 0) {       truecolor();       output();     }     for (int i = 0; i < n; ++i)       if (color[i] == 0)         if (((int)(adj[i]).size()) <= cnt[1] - 2) {           ans[i] = 0, color[i] = 2;           for (int j = 0; j < ((int)(adj[i]).size()); ++j) used[adj[i][j]] = true;           int deg = 2;           for (int j = 0; deg && (j < n); ++j)             if ((color[j] == 1) && !used[j]) {               color[j] = 2;               ans[j] = 0;               --deg;             }           ++num;           truecolor();           output();         } else if (((int)(adj[i]).size()) == cnt[1] - 1) {           int x = all;           for (int j = 0; j < ((int)(adj[i]).size()); ++j) x ^= adj[i][j];           radj[x].push_back(i);         }     int res = 0;     for (int i = 0; i < n; ++i)       if (((int)(radj[i]).size()) >= 2) res++;     if (res <= 1) {       printf( NO n );       return 0;     }     res = 2;     for (int i = 0; res && (i < n); ++i)       if (((int)(radj[i]).size()) >= 2) {         ans[i] = num, color[i] = 2;         for (int j = 0; j < 2; ++j) ans[radj[i][j]] = num, color[radj[i][j]] = 2;         --res;         ++num;       }     truecolor();     output();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   const int mod = 1e9 + 7;   const int inf = 0x3f3f3f3f;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int ans = 0, a, b, c, d, e, f;     cin >> a >> b >> c >> d >> e >> f;     if (e < f) {       int now = min(d, min(b, c));       ans += now * f;       b -= now;       c -= now;       d -= now;     } else {       int now = min(d, a);       ans += now * e;       a -= now;       d -= now;     }     ans += e * min(a, d);     ans += f * min(d, min(b, c));     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int INF = (long long int)1e9 + 10;   const long long int INFLL = (long long int)1e18 + 10;   const long double EPS = 1e-8;   const long long int MOD = 1e9 + 7;   template <class T>   T &chmin(T &a, const T &b) {     return a = min(a, b);   }   template <class T>   T &chmax(T &a, const T &b) {     return a = max(a, b);   }   template <class T>   inline T sq(T a) {     return a * a;   }   int n, m;   bool f[128][2];   int memo[128][128][3][3];   bool isin(int a, int b) { return 0 <= a and a < n and 0 <= b and b < 2; }   vector<pair<int, int> > cg;   void draw(int a, int b) {     if (isin(a, b) and !f[a][b]) {       cg.emplace_back(a, b);       f[a][b] = true;     }   }   void put(int a, int b) {     cg.clear();     draw(a, b);     draw(a - 1, 1 - b);     draw(a, 1 - b);     draw(a + 1, 1 - b);   }   int mex(set<int> &x) {     for (long long int i = (0); i < (long long int)(INF); i++)       if (x.find(i) == x.end()) return i;   }   int grandy(int t, int b, int tf, int bf) {     int &res = memo[t][b][tf][bf];     if (res != -1) return res;     set<int> gs;     for (long long int i = (t); i < (long long int)(b); i++)       for (long long int j = (0); j < (long long int)(2); j++)         if (!f[i][j]) {           put(i, j);           vector<pair<int, int> > ccg = cg;           int x = grandy(t, i, tf, j) ^ grandy(i + 1, b, j, bf);           gs.insert(x);           for (auto &w : ccg) f[w.first][w.second] = false;         }     return res = mex(gs);   }   int main() {     scanf( %d %d , &n, &m);     for (long long int i = (0); i < (long long int)(m); i++) {       int a, b;       scanf( %d %d , &a, &b);       a--;       b--;       put(a, b);     }     for (long long int i = (0); i < (long long int)(128); i++)       for (long long int j = (0); j < (long long int)(128); j++)         for (long long int k = (0); k < (long long int)(3); k++)           for (long long int l = (0); l < (long long int)(3); l++)             memo[i][j][k][l] = -1;     if (grandy(0, n, 2, 2) == 0)       puts( LOSE );     else       puts( WIN );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int m, nn, o, p;   int main() {     long long int n;     cin >> n;     string a, b;     cin >> a >> b;     for (int i = 0; i < n; i++)       if (a[i] ==  0 ) {         if (b[i] ==  0 )           m++;         else           nn++;       } else {         if (b[i] ==  0 )           o++;         else           p++;       }     cout << m * p + m * o + nn * o << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, tms;   void upd(int &x, int y) { x = min(x, y); }   struct trietree {     int node[505][12];     int sum[505];     int dp[505][505][12];     int dp2[505][505][12][12];     bool vis[505][505][15];     int dep[505];     int tot;     void insert(char ch[], int val) {       int now = 0;       int l = strlen(ch);       for (int i = 0; i < l; i++) {         int rt = ch[i] -  0 ;         if (node[now][rt] == 0) node[now][rt] = ++tot, dep[tot] = dep[now] + 1;         now = node[now][rt];       }       sum[now] += val;     }     void dfs(int x, int p, int lft) {       if (vis[x][p][lft]) return;       vis[x][p][lft] = 1;       if (lft > 0) dfs(x, x, lft - 1), upd(dp[x][p][lft], dp[x][x][lft - 1]);       vector<int> ch;       for (int i = 0; i < 10; i++)         if (node[x][i]) ch.push_back(node[x][i]);       dp2[x][p][lft][ch.size()] = 0;       for (int i = ch.size() - 1; i >= 0; i--) {         int t = ch[i];         for (int j = 0; j <= lft; j++) {           dfs(t, p, j);           upd(dp2[x][p][lft][i], dp2[x][p][lft - j][i + 1] + dp[t][p][j]);         }       }       upd(dp[x][p][lft], dp2[x][p][lft][0] + (dep[x] - dep[p]) * sum[x]);     }     int solve() {       memset(dp, 0x3f, sizeof(dp));       memset(dp2, 0x3f, sizeof(dp2));       dfs(0, 0, tms);       return dp[0][0][tms];     }   } trie;   char buf[1008];   int main() {     cin >> n >> tms;     for (int i = 0; i < n; i++) {       scanf( %s , buf);       int gg;       cin >> gg;       trie.insert(buf, gg);     }     cout << trie.solve();     return 0;   }
#include <bits/stdc++.h>   int main(void) {     char a[3][3];     scanf( %3s , a[0]);     scanf( %3s , a[1]);     scanf( %3s , a[2]);     for (int i = 0; i < 3; i++)       for (int j = 0; j < 3; j++)         if (a[i][j] != a[((((i)-1) * -1) + 1)][((((j)-1) * -1) + 1)]) {           puts( NO );           return EXIT_SUCCESS;         }     puts( YES );     return EXIT_SUCCESS;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 100005;   const int Maxm = 500;   int T;   int n, m, k;   vector<int> un;   int my[Maxn];   bool has[Maxm][Maxm];   set<int> neigh[Maxn];   void Solve(priority_queue<pair<int, int> > &Q) {     bool assigned = false;     int inside = n;     while (!Q.empty() && -Q.top().first < k) {       int v = Q.top().second, d = -Q.top().first;       Q.pop();       if (neigh[v].size() != d) continue;       if (neigh[v].size() == k - 1) {         if (!assigned && inside < Maxm) {           int pnt = 0;           for (int i = 1; i <= n; i++)             if (!neigh[i].empty()) my[i] = pnt++;           for (int i = 0; i < pnt; i++) fill(has[i], has[i] + pnt, false);           for (int i = 1; i <= n; i++)             for (auto u : neigh[i]) has[my[i]][my[u]] = true;           assigned = true;         }         vector<int> seq;         for (auto u : neigh[v]) seq.push_back(u);         bool ok = true;         for (int i = 0; i < seq.size() && ok; i++)           for (int j = i + 1; j < seq.size() && ok; j++)             if (assigned)               ok = has[my[seq[i]]][my[seq[j]]];             else               ok = neigh[seq[i]].find(seq[j]) != neigh[seq[i]].end();         if (ok) {           printf( 2 n );           printf( %d , v);           for (int i = 0; i < seq.size(); i++) printf(  %d , seq[i]);           printf(  n );           return;         }       }       for (auto u : neigh[v]) {         neigh[u].erase(v);         if (assigned) has[my[v]][my[u]] = has[my[u]][my[v]] = false;         Q.push(pair<int, int>(-int(neigh[u].size()), u));       }       neigh[v].clear();       inside--;     }     vector<int> seq;     while (!Q.empty()) {       int v = Q.top().second, d = -Q.top().first;       Q.pop();       if (neigh[v].size() != d) continue;       seq.push_back(v);     }     if (seq.empty())       printf( -1 n );     else {       printf( 1 %d n , int(seq.size()));       for (int i = 0; i < seq.size(); i++)         printf( %d%c , seq[i], i + 1 < seq.size() ?     :   n );     }   }   int main() {     scanf( %d , &T);     while (T--) {       scanf( %d %d %d , &n, &m, &k);       for (int i = 1; i <= n; i++) neigh[i].clear();       for (int i = 0; i < m; i++) {         int a, b;         scanf( %d %d , &a, &b);         neigh[a].insert(b);         neigh[b].insert(a);       }       priority_queue<pair<int, int> > Q;       for (int i = 1; i <= n; i++)         Q.push(pair<int, int>(-int(neigh[i].size()), i));       Solve(Q);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = (1 << 20) + 5;   bool used[MAXN];   vector<int> adj[MAXN];   int a[MAXN];   int n;   vector<int> ans;   vector<int>::iterator it[MAXN];   void dfs(int x) {     while (it[x] != adj[x].end()) {       int p = *(it[x]);       if (!used[p / 2]) {         int p = *(it[x]);         it[x]++;         used[p / 2] = true;         dfs(a[p ^ 1]);         ans.push_back(p);       } else {         it[x]++;       }     }   }   int main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < 2 * n; i++) cin >> a[i];     for (int i = 0; i < 2 * n; i++) used[a[i]] = !used[a[i]];     int k;     for (k = 20; k >= 0; k--) {       bool good = true;       for (int i = 0; i < (1 << k); i++) {         if (used[i]) {           good = false;           break;         }       }       if (good) break;       for (int i = 0; i < (1 << (k - 1)); i++) {         used[i] = used[i] ^ used[i + (1 << (k - 1))];       }     }     for (; k >= 0; k--) {       for (int i = 0; i < n; i++) {         used[i] = false;       }       for (int i = 0; i < 2 * n; i++) {         a[i] = a[i] % (1 << k);       }       for (int i = 0; i < (1 << k); i++) adj[i].clear();       for (int i = 0; i < n; i++) {         adj[a[2 * i]].push_back(2 * i);         adj[a[2 * i + 1]].push_back(2 * i + 1);       }       for (int i = 0; i < (1 << k); i++) {         it[i] = adj[i].begin();       }       dfs(a[0]);       if (ans.size() == n) {         cout << k <<   n ;         for (int i = n - 1; i >= 0; i--) {           cout << 1 + ans[i] <<     << 1 + (ans[i] ^ 1) <<    ;         }         return 0;       }       ans.clear();     }   }
#include <bits/stdc++.h>   using namespace std;   const int M = 200 * 1000 + 11;   int main() {     int q;     cin >> q;     vector<int> pos(M);     int curl = 0;     int curr = 0;     for (int i = 0; i < q; ++i) {       string type;       int id;       cin >> type >> id;       if (i == 0) {         pos[id] = curl;         --curl;         ++curr;       } else {         if (type ==  L ) {           pos[id] = curl;           --curl;         } else if (type ==  R ) {           pos[id] = curr;           ++curr;         } else {           cout << min(abs(pos[id] - curl), abs(pos[id] - curr)) - 1 <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e7;   int n;   int m[100], r[100];   bool am[MAX];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> m[i];     for (int i = 1; i <= n; i++) cin >> r[i];     for (int i = 1; i <= n; i++) {       bool da = 0;       for (int k = 0; k * m[i] + r[i] < MAX; k++) am[k * m[i] + r[i]] = 1;     }     int cnt = 0;     for (int i = 1; i < MAX; i++) cnt += am[i];     cout << 1.00 * cnt / (MAX - 1);     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   #pragma warning(disable : 4996)   using namespace std;   int main() {     int Lpos1, Lpos2;     bool p[9][9];     memset(p, true, sizeof(p));     for (int i = 0; i < 2; i++) {       char k[3];       scanf( %s , &k);       int pos1 = k[0] -  a  + 1;       int pos2 = k[1] -  0 ;       if (i == 0) {         Lpos1 = pos1;         Lpos2 = pos2;         for (int j = pos1; j >= 1; j--) p[j][pos2] = false;         for (int j = pos1; j <= 8; j++) p[j][pos2] = false;         for (int j = pos2; j >= 1; j--) p[pos1][j] = false;         for (int j = pos2; j <= 8; j++) p[pos1][j] = false;       } else {         int x = pos1, y = pos2;         p[x][y] = false;         if (x + 1 <= 8 && y + 2 <= 8) p[x + 1][y + 2] = false;         if (x - 1 >= 1 && y + 2 <= 8) p[x - 1][y + 2] = false;         if (x - 2 >= 1 && y + 1 <= 8) p[x - 2][y + 1] = false;         if (x - 2 >= 1 && y - 1 >= 1) p[x - 2][y - 1] = false;         if (x - 1 >= 1 && y - 2 >= 1) p[x - 1][y - 2] = false;         if (x + 1 <= 8 && y - 2 >= 1) p[x + 1][y - 2] = false;         if (x + 2 <= 8 && y - 1 >= 1) p[x + 2][y - 1] = false;         if (x + 2 <= 8 && y + 1 <= 8) p[x + 2][y + 1] = false;       }     }     int x = Lpos1, y = Lpos2;     if (x + 1 <= 8 && y + 2 <= 8) p[x + 1][y + 2] = false;     if (x - 1 >= 1 && y + 2 <= 8) p[x - 1][y + 2] = false;     if (x - 2 >= 1 && y + 1 <= 8) p[x - 2][y + 1] = false;     if (x - 2 >= 1 && y - 1 >= 1) p[x - 2][y - 1] = false;     if (x - 1 >= 1 && y - 2 >= 1) p[x - 1][y - 2] = false;     if (x + 1 <= 8 && y - 2 >= 1) p[x + 1][y - 2] = false;     if (x + 2 <= 8 && y - 1 >= 1) p[x + 2][y - 1] = false;     if (x + 2 <= 8 && y + 1 <= 8) p[x + 2][y + 1] = false;     int d = 0;     for (int i = 1; i <= 8; i++)       for (int j = 1; j <= 8; j++)         if (p[i][j]) d++;     printf( %d , d);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fast_pow(long long x, long long y, long long p);   void solve() {     long long a, b, c;     cin >> a >> b >> c;     long long ans = INT_MAX;     long long ansA = -1, ansB = -1, ansC = -1;     for (long long ta = 1; ta <= 2 * a; ta++) {       for (long long tb = ta; tb <= 2 * b; tb += ta) {         long long sum = abs(a - ta) + abs(b - tb);         if ((c % tb) < (tb - (c % tb))) {           sum += (c % tb);           if (sum < ans) {             ans = sum;             ansA = ta;             ansB = tb;             long long temp = c / tb;             ansC = temp * tb;           }         } else {           sum += (tb - (c % tb));           if (sum < ans) {             ans = sum;             ansA = ta;             ansB = tb;             long long temp = (c / tb) + 1;             ansC = temp * tb;           }         }       }     }     cout << ans <<   n ;     cout << ansA <<     << ansB <<     << ansC <<   n ;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long test = 1;     cin >> test;     while (test--) {       solve();     }     return 0;   }   long long fast_pow(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   int n, t, k;   int a[200005], maxx, b[200005];   vector<int> v[200005];   int cnt = 1, tmp = 0;   int main() {     n = read();     t = read();     k = read();     for (int i = 1; i <= t; ++i) a[i] = read();     for (int i = t; i >= 1; --i) {       maxx += abs(min(0, a[i + 1] - a[i]));       if (i == t)         b[i] = a[i];       else         b[i] = b[i + 1] + a[i] - 1;     }     v[0].push_back(1);     if (k < maxx || k > n - t) {       printf( -1 n );       return 0;     } else {       printf( %d n , n);       for (int i = 1; i <= t; ++i) {         if (k < n - t - tmp) {           v[i].push_back(++cnt);           printf( %d %d n , v[i - 1][0], v[i][0]);           a[i]--;           for (int j = 1; j < v[i - 1].size() && a[i] && k < n - t - tmp; ++j) {             v[i].push_back(++cnt);             printf( %d %d n , v[i - 1][j], v[i][j]);             tmp++;             a[i]--;           }           if (a[i]) {             for (int j = 1; j <= a[i]; ++j) {               v[i].push_back(++cnt);               printf( %d %d n , cnt, v[i - 1][0]);             }           }         } else {           for (int j = 1; j <= a[i]; ++j) {             v[i].push_back(++cnt);             printf( %d %d n , cnt, v[i - 1][0]);           }         }       }     }   }
#include <bits/stdc++.h>   void sort(int a[], int begin, int mid, int end) {     int i = begin, j = mid + 1, k = 0, temp[end - begin + 1];     while (i <= mid && j <= end) {       if (a[i] <= a[j])         temp[k++] = a[i++];       else         temp[k++] = a[j++];     }     for (; i <= mid; ++i) temp[k++] = a[i];     for (; j <= end; ++j) temp[k++] = a[j];     for (i = 0; i < k; ++i) a[begin + i] = temp[i];   }   void partition(int a[], int begin, int end) {     if (begin == end) return;     int mid = (begin + end) / 2;     partition(a, begin, mid);     partition(a, mid + 1, end);     sort(a, begin, mid, end);   }   int main() {     int n;     scanf( %d , &n);     unsigned long long s = 0;     int i, a[n + 1];     for (i = 1; i <= n; ++i) scanf( %d , &a[i]);     partition(a, 1, n);     for (i = 1; i <= n - 1; ++i) s = s + (a[i] * 1LL) * (i + 1);     s = s + (a[n] * 1LL) * n;     printf( %I64d n , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   struct debugger {     static void call(string::iterator it, string::iterator ed) {}     template <typename T, typename... aT>     static void call(string::iterator it, string::iterator ed, T a, aT... rest) {       string b;       for (; *it !=  , ; ++it)         if (*it !=    ) b += *it;       cout << b <<  =  << a <<    ;       call(++it, ed, rest...);     }   };   int main() {     int n, R, r;     cin >> n >> R >> r;     if (n == 1 && r <= R) {       cout <<  YES n ;       return 0;     }     if (n == 2 && 2 * r <= R) {       cout <<  YES n ;       return 0;     }     double ans = asin((double)r / (double)(R - r));     if (ans * n <= pi + 1.0e-8) {       cout <<  YES n ;       return 0;     }     cout <<  NO n ;     return 0;   }