malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main(void) {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     if (n <= 450 and m == n * (n - 1) / 2) {       cout <<  NO n ;       return 0;     }     vector<set<int>> g(n + 1);     for (int i = 0; i < m; ++i) {       int u, v;       cin >> u >> v;       g[u].insert(v);       g[v].insert(u);     }     int x = -1, y = -1;     for (int i = 1; i <= n and x == -1; ++i) {       if ((int)g[i].size() == n - 1) continue;       for (int j = 1; j <= n and x == -1; ++j) {         if (i == j) continue;         if (g[i].find(j) == g[i].end()) tie(x, y) = tie(i, j);       }     }     vector<int> v1, v2;     int cur = 3;     for (int i = 1; i <= n; ++i) {       if (i == x) {         v1.push_back(1);         v2.push_back(1);       } else if (i == y) {         v1.push_back(2);         v2.push_back(1);       } else {         v2.push_back(cur);         v1.push_back(cur++);       }     }     cout <<  YES n ;     for (auto x : v1) cout << x <<    ;     cout <<   n ;     for (auto x : v2) cout << x <<    ;   }
#include <bits/stdc++.h>   const long long mod = 1e9 + 7;   const long long maxn = 1e5 + 7;   const double pi = acos(-1);   using namespace std;   long long t, n, m;   long long hang;   long long weizhi;   long long temp;   long long four = 1;   long long weishu;   long long weishu2;   long long lie;   int ans[50];   map<int, int> MP;   long long cal() {     long long res = 0;     long long a = 1;     weishu2 = weishu;     for (int i = weishu2; i >= 1; i--) {       res += a * ans[i];       a <<= 2;     }     return res;   }   int main() {     ios::sync_with_stdio(false);     MP[1] = 2;     MP[2] = 3;     MP[3] = 1;     cin >> t;     while (t--) {       memset(ans, 0, sizeof(ans));       weishu = 1;       four = 1;       cin >> n;       hang = (n - 1) / 3 + 1;       while (hang > four) {         hang -= four;         four <<= 2;         weishu++;       }       if (n % 3 == 0) {         lie = 3;       } else {         lie = n % 3;       }       weishu2 = weishu;       temp = hang - 1;       while (temp) {         ans[weishu2--] = temp % 4;         temp >>= 2;       }       ans[1] = 1;       if (lie == 2) {         for (int i = 1; i <= weishu; i++) {           ans[i] = MP[ans[i]];         }       } else if (lie == 3) {         for (int i = 1; i <= weishu; i++) {           ans[i] = MP[ans[i]];           ans[i] = MP[ans[i]];         }       }       cout << cal() << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = LLONG_MAX;   long long gcd(long long x, long long y) {     if (y == 0)       return x;     else       return gcd(y, x % y);   }   long long power(long long x, unsigned long long y) {     long long res = 1;     x = x % MOD;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % MOD;       y = y >> 1;       x = (x * x) % MOD;     }     return res;   }   void solve() {     long long n, m, b, c, d, ans = 0, one = 0;     cin >> n;     long long a[n];     for (long long i = (long long)0; i < n; i++) {       cin >> a[i];       if (a[i] >= 2 * one) {         a[i] -= 2 * one;         ans += one + a[i] / 3;         one = a[i] % 3;       } else {         one += a[i] % 2;         one -= a[i] / 2;         ans += a[i] / 2;       }     }     cout << ans <<   n ;   }   int32_t main() {     std::ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t, n, hold;     cin >> t;     while (t--) {       bool ans = false;       cin >> n;       long long int x;       for (long long int i = 0; i < n; i++) {         cin >> hold;         if (i == 0) x = hold;         if (x != hold) ans = true;       }       if (ans)         cout << 1 << endl;       else         cout << n << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 200005;   vector<long long> byk[MAXN];   long long pangkat(long long x, long long y) {     long long ret = 1;     for (long long i = 1; i <= y; i++) ret *= x;     return ret;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, a;     cin >> n;     for (long long no = 1; no <= n; no++) {       cin >> a;       for (long long i = 2; i * i <= a; i++) {         long long pa = 0;         while (a % i == 0) {           pa++;           a /= i;         }         if (pa) byk[i].push_back(pa);       }       if (a > 1) byk[a].push_back(1);     }     long long ans = 1;     for (long long i = 1; i <= 200000; i++) {       if (byk[i].size() > n - 2) {         sort(byk[i].begin(), byk[i].end());         if (byk[i].size() == n - 1)           ans *= pangkat(i, byk[i][0]);         else           ans *= pangkat(i, byk[i][1]);       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   long long mpow(long long a, long long n, long long mod) {     long long ret = 1;     long long b = a;     while (n) {       if (n & 1) ret = (ret * b) % mod;       b = (b * b) % mod;       n >>= 1;     }     return (long long)ret;   }   using namespace std;   int n, m, s;   pair<int, int> bug[(int)(1e5 + 25)];   int ANS[(int)(1e5 + 25)];   pair<pair<int, int>, int> ch[(int)(1e5 + 25)];   bool chk(int x) {     priority_queue<pair<int, int> > pq;     long long ans = 0;     int last = m;     for (int i = n; i >= 1;) {       int j = i;       while (j > 0 && ch[j].first.first >= bug[last].first) {         pq.push(make_pair(-ch[j].first.second, ch[j].second));         j--;       }       i = j;       if (j == 0) {         break;       }       if (pq.empty()) {         return 0;       }       pair<int, int> temp = pq.top();       pq.pop();       int dum = x;       ans += (-temp.first);       while (last > 0 && dum > 0) {         ANS[bug[last].second] = temp.second;         dum--;         last--;       }       if (last <= 0) {         break;       }     }     while (last > 0) {       if (pq.empty()) {         return 0;       }       pair<int, int> temp = pq.top();       pq.pop();       int dum = x;       ans += (-temp.first);       while (last > 0 && dum > 0) {         ANS[bug[last].second] = temp.second;         dum--;         last--;       }     }     return (ans <= s);   }   void solve() {     scanf( %d , &n);     scanf( %d , &m);     scanf( %d , &s);     for (int i = 1; i <= m; i++) {       scanf( %d , &bug[i].first);       bug[i].second = i;     }     for (int i = 1; i <= n; i++) {       scanf( %d , &ch[i].first.first);     }     for (int i = 1; i <= n; i++) {       scanf( %d , &ch[i].first.second);       ch[i].second = i;     }     sort(bug + 1, bug + m + 1);     sort(ch + 1, ch + n + 1);     int lo = 1, hi = m;     while (lo < hi) {       int mid = (lo + hi) >> 1;       if (chk(mid)) {         hi = mid;       } else {         lo = mid + 1;       }     }     if (!chk(lo)) {       printf( NO );       return;     }     printf( YES n );     for (int i = 1; i <= m; i++) {       cout << ANS[i] <<    ;     }   }   int main() {     int t = 1;     for (int i = 1; i <= t; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dir4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};   int dir8[8][2] = {{-1, 0}, {1, 0},  {0, 1}, {0, -1},                     {-1, 1}, {1, -1}, {1, 1}, {-1, -1}};   int dir8h[8][2] = {{2, 1}, {-2, -1}, {-1, 2}, {1, -2},                      {1, 2}, {-2, 1},  {2, -1}, {-1, -2}};   int setbit(int num, int index, int value) {     return (value) ? (num | (1 << index)) : (num & ~(1 << index));   }   bool getbit(int num, int index) { return ((num >> index) & 1) == 1; }   int cntbits(int num) {     int cnt = 0;     while (num) {       if (num & 1) cnt++;       num /= 2;     }     return cnt;   }   double eps = 1e-8;   const int N = 1e5 + 100;   vector<int> v[N];   bool a[N], can[N];   int root;   bool dfs(int node, int pa) {     if (node != root && v[node].size() == 1) {       if (a[node]) {         can[node] = 1;         return 1;       } else {         can[node] = 0;         return 0;       }     } else {       if (a[node])         can[node] = 1;       else         can[node] = 0;       for (int i = 0; i < v[node].size(); i++) {         if (v[node][i] != pa) {           bool x = dfs(v[node][i], node);           if (!x) can[node] = 0;         }       }       if (a[node]) return 1;       return 0;     }   }   int main() {     ios_base::sync_with_stdio(false);     int n, p, c;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> p >> c;       a[i] = c;       if (p != -1)         v[p].push_back(i), v[i].push_back(p);       else         root = i;     }     bool cc = dfs(root, -1);     vector<int> res;     for (int i = 1; i <= n; i++) {       if (can[i]) res.push_back(i);     }     if (res.size() > 0) {       for (int i = 0; i < res.size(); i++) cout << res[i] <<    ;     } else       cout << -1;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2010;   int n, m1, m2;   int tp1[N], tp2[N];   struct Graph {     int in[N];     bitset<N> e[N];     void floyd() {       for (int k = 2; k <= 2 * n + 1; k++)         for (int i = 2; i <= 2 * n + 1; i++)           if (e[i][k]) e[i] |= e[k];     }     void dfs(int u) {       if (in[u]) return;       in[u] = 1, in[u ^ 1] = -1;       for (int v = 2; v <= 2 * n + 1; v++)         if (e[u][v]) dfs(v);     }     void solve() {       for (int i = 1; i <= n; i++) {         if (!in[2 * i]) {           if (e[2 * i][2 * i + 1])             dfs(2 * i + 1);           else             dfs(2 * i);         }         printf( %d  , in[2 * i] == 1);       }     }   } f, g;   int main() {     scanf( %d%d%d , &n, &m1, &m2);     for (int i = 1; i <= m1; i++) {       int u, v;       scanf( %d%d , &u, &v);       u = (u > 0) ? 2 * u : -2 * u + 1;       v = (v > 0) ? 2 * v : -2 * v + 1;       f.e[u ^ 1][v] = f.e[v ^ 1][u] = 1;     }     for (int i = 1; i <= m2; i++) {       int u, v;       scanf( %d%d , &u, &v);       u = (u > 0) ? 2 * u : -2 * u + 1;       v = (v > 0) ? 2 * v : -2 * v + 1;       g.e[u ^ 1][v] = g.e[v ^ 1][u] = 1;     }     f.floyd(), g.floyd();     bool pd1 = 0, pd2 = 0;     for (int i = 1; i <= n; i++) {       if (f.e[2 * i][2 * i + 1] && f.e[2 * i + 1][2 * i]) pd1 = 1;       if (g.e[2 * i][2 * i + 1] && g.e[2 * i + 1][2 * i]) pd2 = 1;     }     if (pd1 && pd2) {       puts( SIMILAR );       return 0;     }     if (pd1) {       g.solve();       return 0;     }     if (pd2) {       f.solve();       return 0;     }     for (int i = 1; i <= n; i++) {       if (f.e[2 * i][2 * i + 1])         tp1[i] = -1;       else if (f.e[2 * i + 1][2 * i])         tp1[i] = 1;       else         tp1[i] = 0;       if (g.e[2 * i][2 * i + 1])         tp2[i] = -1;       else if (g.e[2 * i + 1][2 * i])         tp2[i] = 1;       else         tp2[i] = 0;       if (tp1[i] == tp2[i]) continue;       if ((tp1[i] == 1 && tp2[i] == -1) || (tp1[i] == -1 && tp2[i] == 1)) {         f.solve();         return 0;       } else if (tp1[i] == 0) {         if (tp2[i] == 1) {           f.dfs(2 * i + 1), f.solve();           return 0;         } else {           f.dfs(2 * i), f.solve();           return 0;         }       } else if (tp2[i] == 0) {         if (tp1[i] == 1) {           g.dfs(2 * i + 1), g.solve();           return 0;         } else {           g.dfs(2 * i), g.solve();           return 0;         }       }     }     for (int i = 2; i <= 2 * n + 1; i++)       for (int j = 2; j <= 2 * n + 1; j++) {         if (i == j || !(f.e[i][j] ^ g.e[i][j])) continue;         if (f.e[i][j]) {           g.dfs(i), g.dfs(j ^ 1), g.solve();           return 0;         }         if (g.e[i][j]) {           f.dfs(i), f.dfs(j ^ 1), f.solve();           return 0;         }       }     puts( SIMILAR );   }
#include <bits/stdc++.h>   using namespace std;   const int N = 51;   const long long inf = (long long)1e14;   const long long real_inf = (long long)1e18;   inline long long value(const pair<long long, long long>& task, long long t) {     return task.first - t * task.second;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<pair<long long, long long>> tasks(n);     for (int i = 0; i < n; ++i) {       cin >> tasks[i].first;       tasks[i].first *= 1000;     }     for (int i = 0; i < n; ++i) {       cin >> tasks[i].second;     }     sort(tasks.begin(), tasks.end());     reverse(tasks.begin(), tasks.end());     auto ok = [&](long long t) -> bool {       long long dp[N][N][N];       for (int i = 0; i < n; ++i) {         for (int j = 0; j <= n; ++j) {           for (int k = 0; k <= n; ++k) {             dp[i][j][k] = real_inf;           }         }       }       dp[0][0][1] = value(tasks[0], t);       for (int i = 0; i < n - 1; ++i) {         for (int j = 0; j <= n; ++j) {           for (int k = 0; k <= n; ++k) {             if (dp[i][j][k] == real_inf) {               continue;             }             if (tasks[i].first == tasks[i + 1].first) {               dp[i + 1][j][k + 1] =                   min(dp[i + 1][j][k + 1], dp[i][j][k] + value(tasks[i + 1], t));               if (j > 0) {                 dp[i + 1][j - 1][k] = min(dp[i + 1][j - 1][k], dp[i][j][k]);               }             } else {               dp[i + 1][j + k][1] =                   min(dp[i + 1][j + k][1], dp[i][j][k] + value(tasks[i + 1], t));               if (j > 0 || k > 0) {                 dp[i + 1][j + k - 1][0] =                     min(dp[i + 1][j + k - 1][0], dp[i][j][k]);               }             }           }         }       }       for (int i = 0; i <= n; ++i) {         for (int j = 0; j <= n; ++j) {           if (dp[n - 1][i][j] <= 0) {             return true;           }         }       }       return false;     };     long long left = 0, right = inf, best = inf;     while (left <= right) {       long long middle = (left + right) / 2;       if (ok(middle)) {         best = middle;         right = middle - 1;       } else {         left = middle + 1;       }     }     cout << best <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int power(int num1, int num2) {     int ans = 1;     for (int i = 0; i < num2; i++) {       ans *= num1;     }     return ans;   }   int main() {     string str;     int num1, help = 0;     cin >> num1 >> str;     for (int i = 0; i < str.size(); i++) {       help += power(10, i) * (str[i] -  0 );     }     cout << help + num1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5;   vector<int> G[MAXN + 5];   int maxFrom[MAXN + 5], down[MAXN + 5], up[MAXN + 5];   int id[MAXN + 5], sz[MAXN + 5], diam[MAXN + 5];   bool flag[MAXN + 5];   int ID;   int n, m, Q;   map<int, int> cnt;   vector<int> accSum[MAXN + 5];   vector<double> accWeightedSum[MAXN + 5];   vector<int> vals[MAXN + 5];   map<pair<int, int>, double> oldAns;   void dfs(int u, int p = -1) {     id[u] = ID;     sz[ID]++;     down[u] = 0;     flag[u] = 1;     for (int v : G[u]) {       if (v == p) continue;       dfs(v, u);       down[u] = max(down[u], 1 + down[v]);     }   }   void dfs2(int u, int p = -1, int parentWithoutme = 0) {     if (~p)       up[u] = 1 + parentWithoutme;     else       up[u] = 0;     maxFrom[u] = max(up[u], down[u]);     diam[ID] = max(diam[ID], maxFrom[u]);     cnt[maxFrom[u]]++;     vector<int> paths = {up[u], 0};     for (int v : G[u]) {       if (v == p) continue;       paths[1] = max(paths[1], 1 + down[v]);       if (paths[0] < paths[1]) swap(paths[0], paths[1]);     }     for (int v : G[u]) {       if (v == p) continue;       dfs2(v, u, ((paths[0] != (1 + down[v])) ? paths[0] : paths[1]));     }   }   void calc(int u) {     cnt.clear();     ID = u;     dfs(u);     dfs2(u);     accSum[ID].resize(cnt.size() + 1);     accWeightedSum[ID].resize(cnt.size() + 1);     accSum[ID][0] = 0;     accWeightedSum[ID][0] = 0;     int i = 0;     for (auto p : cnt) {       vals[ID].push_back(p.first);       accSum[ID][i + 1] = accSum[ID][i] + p.second;       accWeightedSum[ID][i + 1] =           accWeightedSum[ID][i] + p.first * (1. * p.second / sz[ID]);       i++;     }   }   int main() {     int c, c2;     scanf( %d%d%d , &n, &m, &Q);     for (c = 0; c < m; c++) {       int u, v;       scanf( %d%d , &u, &v);       u--;       v--;       G[u].push_back(v);       G[v].push_back(u);     }     for (c = 0; c < n; c++) {       if (flag[c]) continue;       calc(c);     }     for (c = 0; c < Q; c++) {       int u, v;       scanf( %d%d , &u, &v);       u--;       v--;       if (id[u] == id[v])         printf( -1 n );       else {         if (id[u] > id[v]) swap(u, v);         if (oldAns.count({id[u], id[v]}) > 0) {           printf( %.9f n , oldAns[{id[u], id[v]}]);         } else {           if (sz[id[u]] > sz[id[v]]) swap(u, v);           int minDiam = max(diam[id[u]], diam[id[v]]);           double ret = 0;           int j = 0;           for (int x : vals[id[u]]) {             int i =                 lower_bound(vals[id[v]].begin(), vals[id[v]].end(), minDiam - x) -                 vals[id[v]].begin();             double f = 1. * (accSum[id[u]][j + 1] - accSum[id[u]][j]) / sz[id[u]];             ret += f * (accWeightedSum[id[v]].back() - accWeightedSum[id[v]][i] +                         (x + 1.0) * (sz[id[v]] - accSum[id[v]][i]) / sz[id[v]]);             ret += f * (1. * accSum[id[v]][i] / sz[id[v]]) * minDiam;             j++;           }           if (id[u] > id[v]) swap(u, v);           oldAns[{id[u], id[v]}] = ret;           printf( %.9f n , ret);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[105];   int main() {     int n, k, x;     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     int ans = 0;     bool yes = true;     for (int i = 0; i < n; i++)       if (a[i] < k) {         yes = false;         break;       }     while (!yes) {       for (int i = 0; i < n; i++)         if ((a[i] < a[i + 1] || i == n - 1) && a[i] < k) a[i]++;       yes = true;       for (int i = 0; i < n; i++)         if (a[i] < k) {           yes = false;           break;         }       ans++;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[300005] = {0};   long long two[300005] = {0};   const long long mod = 1e9 + 7;   int main() {     two[0] = 1;     for (int i = 1; i <= 300000; i++) {       two[i] = (two[i - 1] * 2LL) % mod;     }     long long res = 0;     int n;     while (cin >> n) {       a[0] = 0;       for (int i = 1; i <= n; i++) {         cin >> a[i];       }       sort(a, a + n + 1);       res = 0;       for (int i = 1; i <= n; i++) {         res += (a[i] * (two[i - 1] - two[n - i]));         res %= mod;       }       cout << res << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char* argv[]) {     cin.sync_with_stdio(false);     cout.sync_with_stdio(false);     int N, M;     cin >> N >> M;     vector<string> data(N);     for (int i = 0; i < N; i++) cin >> data[i];     vector<string> data_rev(M, string(N,  . ));     for (int i = 0; i < N; i++)       for (int j = 0; j < M; j++) data_rev[j][i] = data[i][j];     vector<vector<int> > starts(M);     for (int i = 0; i < M; i++) {       starts[i].push_back(0);       for (int j = 1; j < N; j++) {         if (data_rev[i][j] != data_rev[i][j - 1]) {           starts[i].push_back(j);         }       }       starts[i].push_back(N);     }     vector<vector<short> > already_counted(starts.size());     for (size_t i = 0; i < starts.size(); i++) {       already_counted[i] = vector<short>(starts[i].size(), (short)0);     }     long long main_res = 0LL;     for (int i = 0; i < M; i++) {       for (size_t j = 3; j < starts[i].size(); j++) {         if (!already_counted[i][j - 1]) {           int h = starts[i][j - 1] - starts[i][j - 2];           if (h <= starts[i][j] - starts[i][j - 1] &&               h <= starts[i][j - 2] - starts[i][j - 3]) {             int i_after_last = i + 1;             while (i_after_last < M) {               int j_absolute_1 = starts[i][j - 1];               int j_absolute_2 = starts[i][j - 2];               int j_absolute_3 = starts[i][j - 2] - 1;               if (data_rev[i][j_absolute_1] !=                       data_rev[i_after_last][j_absolute_1] ||                   data_rev[i][j_absolute_2] !=                       data_rev[i_after_last][j_absolute_2] ||                   data_rev[i][j_absolute_3] !=                       data_rev[i_after_last][j_absolute_3]) {                 break;               }               int idx_ =                   lower_bound(starts[i_after_last].begin(),                               starts[i_after_last].end(), starts[i][j - 1]) -                   starts[i_after_last].begin();               if (idx_ < starts[i_after_last].size() &&                   starts[i_after_last][idx_] == starts[i][j - 1] &&                   starts[i_after_last][idx_ - 1] == starts[i][j - 2] &&                   h <= starts[i_after_last][idx_ - 1] -                            starts[i_after_last][idx_ - 2] &&                   h <= starts[i_after_last][idx_ + 1] -                            starts[i_after_last][idx_]) {                 already_counted[i_after_last][idx_] = (short)1;                 i_after_last++;               } else                 break;             }             int sz = (i_after_last - i);             main_res += (sz * (sz + 1)) / 2;           }         }       }     }     cout << main_res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d;     while (~scanf( %d%d%d%d , &a, &b, &c, &d)) {       int t = d - c;       if (c - b == t && b - a == t) {         printf( %d n , d + t);       } else if (a != 0 && b != 0 && c != 0 && d != 0 && b * b == a * c &&                  c * c == b * d && d * d % c == 0) {         printf( %d n , d * d / c);       } else         printf( 42 n );     }     return 0;   }
#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, d;   long long k, now;   int a[1005][1005];   void Dfs(int u, int i) {     if (a[u][i] == k) {       a[u][i] = 0;       a[u][i + 1]++;       Dfs(u, i + 1);     }   }   int main() {     n = read();     k = read();     d = read();     int t = n;     for (int i = 1; i <= d; i++) t = t / k + (int)(t % k > 0);     memset(a, 0, sizeof(a));     if (t == 1) {       for (int u = 2; u <= n; u++) {         for (int i = 1; i <= d; i++) a[u][i] = a[u - 1][i];         a[u][1] += 1;         Dfs(u, 1);       }       for (int i = 1; i <= d; i++) {         for (int j = 1; j <= n; j++) printf( %d  , a[j][i] + 1);         puts(  );       }     } else       puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k, i, j, mx, ans = 0;     cin >> n >> k;     long long int arr[n];     for (i = 0; i < n; i++) cin >> arr[i];     sort(arr, arr + n);     for (i = 0; i < n / 2; i++) swap(arr[i], arr[n - 1 - i]);     for (i = 0; i < n; i++) {       mx = 0;       for (j = 0; j < k && i + j < n; j++) {         mx = max(mx, arr[i + j]);       }       ans += (2 * (mx - 1));       i += k - 1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m;   long long bin(long long l, long long h) {     long long ans;     while (l <= h) {       long long mid = (l + h) / 2;       if (n - (mid * (mid + 1)) / 2 <= 0) {         ans = mid;         h = mid - 1;       } else         l = mid + 1;     }     return ans;   }   int main() {     long long p = 1414213562;     cin >> n >> m;     if (m >= n) {       cout << n << endl;       return 0;     }     long long ans = m;     n -= m;     long long ans2 = bin(1, p);     ans += ans2;     cout << ans << endl;   }