malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int M = 100005;   long long dp[M][2];   vector<int> G[M];   int color[M];   void dfs(int x) {     long long ones, zeros;     ones = color[x];     zeros = 1 - color[x];     int u;     for (int i = 0; i < G[x].size(); i++) {       u = G[x][i];       dfs(u);       ones = (ones * dp[u][1] + ones * dp[u][0] + zeros * dp[u][1]) % 1000000007;       zeros = (zeros * dp[u][1] + zeros * dp[u][0]) % 1000000007;     }     dp[x][1] = ones;     dp[x][0] = zeros;   }   int main() {     int n;     scanf( %d , &n);     int x;     for (int i = 0; i < n - 1; i++) {       scanf( %d , &x);       G[x].push_back(i + 1);     }     for (int i = 0; i < n; i++) {       scanf( %d , &color[i]);     }     dfs(0);     printf( %d n , dp[0][1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3fLL;   const double EPS = 1e-8;   const int MOD = 1000000007;   const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int h, w;     cin >> h >> w;     vector<int> y{1}, x{1};     int ue = 1, shita = h;     while (ue < shita) {       for (int ue_x = 1, shita_x = w; ue_x <= w && shita_x >= 0; --shita_x) {         y.emplace_back(shita);         x.emplace_back(shita_x);         ++ue_x;         if (ue_x <= w) {           y.emplace_back(ue);           x.emplace_back(ue_x);         }       }       ++ue;       --shita;       if (ue <= shita) {         y.emplace_back(ue);         x.emplace_back(1);       }     }     if (ue == shita) {       int hidari = 1, migi = w;       while (hidari < migi) {         y.emplace_back(ue);         x.emplace_back(migi);         ++hidari;         if (hidari < migi) {           y.emplace_back(ue);           x.emplace_back(hidari);         }         --migi;       }     }     set<pair<int, int> > st;     for (int i = (1); i < (y.size()); ++i)       st.emplace(y[i] - y[i - 1], x[i] - x[i - 1]);     if (st.size() < h * w - 1) assert(false);     for (int i = (0); i < (y.size()); ++i) cout << y[i] <<     << x[i] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   int n;   long long power[300009], arr[300009];   long long len, l, r, ans, add;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     power[0] = 1;     for (int i = 1; i <= n; i++) {       power[i] = power[i - 1] * 2;       power[i] += MOD;       power[i] = power[i] % MOD;     }     sort(arr, arr + n);     ans = 0;     for (int i = 1; i < n; i++) {       l = i;       r = n - i;       len = arr[i] - arr[i - 1];       add = ((power[l] - 1 + MOD) * (power[r] - 1 + MOD)) % MOD * len;       add = add % MOD;       ans += add;       ans += MOD;       ans = ans % MOD;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, deg[100100], t[100100], legs[100100];   vector<int> adj[100100];   void dfs(int x, int px) {     t[x] = 1;     for (int i = 0; i < adj[x].size(); i++) {       int u = adj[x][i];       if (u == px) continue;       if (deg[u] <= 2) dfs(u, x);     }   }   int main() {     cin >> n;     for (int i = 1; i <= n - 1; i++) {       int x, y;       cin >> x >> y;       adj[x].push_back(y);       adj[y].push_back(x);       deg[x]++;       deg[y]++;     }     for (int i = 1; i <= n; i++)       if (deg[i] == 1) dfs(i, 0);     for (int i = 1; i <= n; i++) {       int x = adj[i].size();       for (int j = 0; j < x; j++) {         int v = adj[i][j];         if (t[v]) legs[i]++;       }     }     bool fl = false;     for (int i = 1; i <= n; i++) {       if (t[i]) continue;       int cou = 0;       for (int j = 0; j < adj[i].size(); j++) {         int v = adj[i][j];         if (!t[v] && deg[v] - min(legs[v], 2) >= 2) cou++;         if (cou > 2) {           fl = true;           break;         }       }     }     if (fl)       puts( No );     else       puts( Yes );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double inf = 1e10;   inline int cmp(double x, double y = 0, double tol = 1e-7) {     return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;   }   struct ball {     double x, v, m;     int id;     ball(double x = 0.0, double v = 0.0, double m = 0.0) : x(x), v(v), m(m) {}     bool operator<(const ball &q) const { return cmp(x, q.x) < 0; }   };   bool comp(ball a, ball b) { return a.id < b.id; }   ball p[100];   int n, T;   inline double calcula(double m1, double m2, double v1, double v2) {     return ((m1 - m2) * v1 + 2 * m2 * v2) / (m1 + m2);   }   void solve() {     double t = 0.0;     while (cmp(t, T) < 0) {       double time = inf;       for (int i = 0; i < n - 1; i++) {         int j = i + 1;         if (cmp(p[i].v - p[j].v) == 0) continue;         double tmp = (p[j].x - p[i].x) / (p[i].v - p[j].v);         if (cmp(tmp) <= 0) continue;         time = min(time, tmp);       }       if (cmp(time, inf) == 0 || cmp(T, t + time) <= 0) break;       for (int i = 0; i < n; i++) p[i].x = p[i].x + time * p[i].v;       for (int i = 0; i < n - 1; i++) {         int id1 = i, id2 = i + 1;         if (cmp(p[id1].x, p[id2].x) != 0) continue;         double aux = p[id1].v;         p[id1].v = calcula(p[id1].m, p[id2].m, p[id1].v, p[id2].v);         p[id2].v = calcula(p[id2].m, p[id1].m, p[id2].v, aux);       }       t += time;     }     for (int i = 0; i < n; i++) p[i].x = p[i].x + (T - t) * p[i].v;   }   int main() {     cin >> n >> T;     for (int i = 0; i < n; i++) {       scanf( %lf %lf %lf , &p[i].x, &p[i].v, &p[i].m);       p[i].id = i;     }     sort(p, p + n);     solve();     sort(p, p + n, comp);     for (int i = 0; i < n; i++) printf( %.9lf n , p[i].x);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char buf[1 << 15], *fs, *ft;   inline char getc() {     return (fs == ft &&             (ft = (fs = buf) + fread(buf, 1, 1 << 15, stdin), fs == ft))                ? 0                : *fs++;   }   inline int read() {     int x = 0, f = 1;     char ch = getc();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getc();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getc();     }     return x * f;   }   const int MAXN = 200010;   int n, len;   long long ans, sz[MAXN][2];   int f[MAXN][2];   inline int getfather(int x, int y) {     return f[x][y] == x ? x : f[x][y] = getfather(f[x][y], y);   }   inline void merge(int x, int y, int z) {     int xx = getfather(x, z);     int yy = getfather(y, z);     sz[yy][z] += sz[xx][z];     f[xx][z] = yy;   }   int main() {     n = read();     for (int i = 1; i <= n; ++i) f[i][0] = f[i][1] = i, sz[i][0] = sz[i][1] = 1;     for (int i = 1; i < n; ++i) {       int x, y;       x = read();       y = read();       merge(x, y, read());     }     for (int i = 1; i <= n; ++i) {       int w1 = getfather(i, 0);       int w2 = getfather(i, 1);       if (w1 == i) ans += sz[w1][0] * (sz[w1][0] - 1);       if (w2 == i) ans += sz[w2][1] * (sz[w2][1] - 1);       ans += (sz[w1][0] - 1) * (sz[w2][1] - 1);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 5 + 2e5;   int in[MAX], k = 1;   long long s[MAX], sorted[MAX], tos[MAX << 1], BIT[MAX << 1];   map<long long, int> mp;   void add(int i, int val) {     while (i > 0) {       BIT[i] += val;       i -= (i & (-i));     }   }   long long at_index(int i) {     long long sum = 0;     while (i <= k) {       sum += BIT[i];       i += (i & (-i));     }     return sum;   }   int main() {     ios::sync_with_stdio(0);     long long x = 0, t, ans = 0;     int n, i;     cin >> n >> t;     for (i = 0; i < n; ++i) cin >> in[i];     for (i = 0; i < n; ++i) {       x += in[i];       s[i] = x;       sorted[i] = x;       tos[i] = x;     }     int N = 1 + 2 * n;     for (i = 0; i < n; ++i) tos[n + i] = t + tos[i];     tos[n + i] = t;     sort(sorted, sorted + n);     sort(tos, tos + N);     for (i = 0; i < N; ++i) {       if (mp.find(tos[i]) == mp.end()) {         mp[tos[i]] = k;         ++k;       }     }     for (i = 0; i < n; ++i) {       x = upper_bound(sorted, sorted + n, t - 1) - sorted;       ans += (x - at_index(mp[t]));       t += in[i];       add(k, 1);       add(mp[s[i]], -1);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n;     cin >> n;     vector<long long> dp(n + 1, 0);     long long s_odd = 0, s_even = 0;     for (long long i = 1; i <= n; i++) {       dp[i] = 1;       if (i & 1) {         dp[i] += s_even;         s_odd += dp[i];       } else {         dp[i] += s_odd;         s_even += dp[i];       }       s_even %= 1000000007;       s_odd %= 1000000007;     }     s_even += s_odd;     s_even %= 1000000007;     cout << s_even;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char conten[101];     int count1 = 0, count2 = 0, i;     cin >> conten;     int s = strlen(conten);     for (i = 0; i <= s; i++) {       if (conten[i] >= 65 && conten[i] <= 90) {         count1++;       }       if (conten[i] >= 97 && conten[i] <= 122) {         count2++;       }     }     if (count1 > count2) {       for (i = 0; i <= s; i++) {         if (conten[i] >= 97 && conten[i] <= 122) {           conten[i] -= 32;         }       }     }     if (count1 <= count2) {       for (i = 0; i <= s; i++) {         if (conten[i] >= 65 && conten[i] <= 90) {           conten[i] += 32;         }       }     }     cout << conten;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int v[1000005];   int main() {     int n, m, i, first, second, lastdif = -0x3f3f3f3f;     cin >> n;     for (i = 1; i <= n; ++i) cin >> v[i];     for (i = 2; i <= n; ++i) {       if (v[i] - v[i - 1] != lastdif && lastdif != -0x3f3f3f3f) {         cout << v[n];         return 0;         ;       }       lastdif = v[i] - v[i - 1];     }     cout << v[n] + lastdif;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     string s;     cin >> s;     int now = 0;     for (int i = 0; i < n - 1; ++i)       if (s[i] ==  .  && s[i + 1] ==  . ) ++now;     while (m--) {       int pos;       char ch;       cin >> pos >> ch;       --pos;       if (ch ==  . ) {         if (s[pos] ==  . ) {           cout << now << endl;           continue;         }         if (pos < n - 1 && s[pos + 1] ==  . ) ++now;         if (pos && s[pos - 1] ==  . ) ++now;         s[pos] = ch;       } else {         if (s[pos] !=  . ) {           cout << now << endl;           continue;         }         if (pos < n - 1 && s[pos + 1] ==  . ) --now;         if (pos && s[pos - 1] ==  . ) --now;         s[pos] = ch;       }       cout << now << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5, INF = 1e9;   bool check(int n, string s) {     for (int i = 1; i <= n; i++)       if (s[i] ==  0 ) return false;     cout << 1 <<     << n - 1 <<     << 2 <<     << n << endl;     return true;   }   void sol(int n, string s) {     for (int i = 1; i <= n; i++)       if (s[i] ==  0 ) {         if (i - 1 >= n / 2)           cout << 1 <<     << i <<     << 1 <<     << i - 1 << endl;         else           cout << i <<     << n <<     << i + 1 <<     << n << endl;         return;       }   }   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       int n;       string s;       cin >> n >> s;       s =  #  + s;       if (!check(n, s)) sol(n, s);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   double f[2][810];   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i * i <= n; ++i) f[0][i] = 0;     int st = min(max(800.0, sqrt(n)), 1.0 * n);     int c = 0;     for (int i = 1; i <= n; ++i) {       c ^= 1;       for (int j = 1; j <= st; ++j) {         f[c][j] = 1.0 * (k - 1) / k * f[c ^ 1][j] +                   1.0 * j / k / (j + 1) * f[c ^ 1][j] +                   1.0 / k / (j + 1) * (f[c ^ 1][j + 1] + (1.0 + j) * j / 2.0 + j);         if (f[c][j] <= 1e-100) f[c][j] = 0;       }     }     printf( %.10lf , f[c][1] * k);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 111111;   pair<char, string> ev[N];   int n;   int solve(char le) {     set<char> st;     for (int i = ( a ); i <= ( z ); i++) {       st.insert(i);     }     int need = 0, has = 0;     bool found = false;     for (int i = (1); i <= (n); i++) {       if (ev[i].first ==  . ) {         for (auto c : ev[i].second) {           st.erase(c);         }       } else if (ev[i].first ==  ! ) {         has++;         set<char> keep;         for (auto c : ev[i].second) {           keep.insert(c);         }         for (int c = ( a ); c <= ( z ); c++) {           if (keep.find(c) == keep.end()) {             st.erase(c);           }         }       } else if (i != n && ev[i].first ==  ? ) {         char gu = ev[i].second[0];         if (gu == le) {           return -1;         } else {           st.erase(gu);         }         has++;       } else if (!found && i == n && ev[i].first ==  ? ) {         return 0;       }       if (st.find(le) == st.end()) return -1;       if (!found && (int)(st).size() == 1 && *(st.begin()) == le) {         found = true;         need = has;       }     }     if (!found) return -1;     return has - need;   }   signed main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = (1); i <= (n); i++) {       cin >> ev[i].first >> ev[i].second;     }     int ans = -1;     for (int c = ( a ); c <= ( z ); c++) {       ans = max(ans, solve(c));     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   int main(void) {     int n;     scanf( %d , &n);     int a = 0, b = 1023;     for (int i = 1; i <= n; ++i) {       char ch[2];       int x;       scanf( %s%d , ch, &x);       if (ch[0] ==  & ) {         a &= x;         b &= x;       } else if (ch[0] ==  | ) {         a |= x;         b |= x;       } else if (ch[0] ==  ^ ) {         a ^= x;         b ^= x;       }     }     int ans1 = 0, ans2 = 0;     for (int T = 0; T < 10; T++) {       int flag1 = (b & (1 << T));       int flag2 = (a & (1 << T));       if (flag1 && flag2) {         ans1 |= (1 << T);       } else if (!flag1 && flag2) {         ans2 ^= (1 << T);       } else if (!flag1 && !flag2) {         ans1 |= (1 << T);         ans2 ^= (1 << T);       }     }     printf( 2 n| %d n^ %d n , ans1, ans2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s[] = {  ,         January ,   February ,  March ,   April ,                  May ,      June ,      July ,      August ,  September ,                  October ,  November ,  December };   int main() {     string t;     int k;     cin >> t >> k;     int x;     for (int i = 1; i <= 12; ++i) {       if (s[i] == t) {         x = i;         break;       }     }     k %= 12;     x += k;     cout << s[x % 12 ? x % 12 : 12] << endl;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   using PII = pair<int, int>;   int main() {     int n;     scanf( %d , &n);     LL ansx, ansy;     ansx = ansy = 0;     n *= 2;     for (int i = 1; i <= n; i++) {       int x, y;       scanf( %d%d , &x, &y);       ansx += x;       ansy += y;     }     n /= 2;     printf( %lld %lld n , ansx / n, ansy / n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   ll dp[2][5005];   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     int n, k, x;     cin >> n >> k >> x;     if (n / k > x) return cout << -1, 0;     vector<int> a(n);     for (auto &x : a) cin >> x;     x = min(x, n);     for (int i = 0; i < k; ++i) dp[1][i] = a[i];     for (int z = 2; z <= x; ++z) {       deque<ll> d;       int c = (z & 1);       int p = 1 - c;       int m = min(n, z * k);       memset(dp[c], 0, sizeof dp[c]);       for (int i = 0; i < m; ++i) {         while (d.size() && i - d.front() > k) d.pop_front();         if (i >= z - 1) dp[c][i] = a[i] + dp[p][d.front()];         while (d.size() && dp[p][d.back()] <= dp[p][i]) d.pop_back();         d.emplace_back(i);       }     }     ll ans = 0;     for (int i = n - 1; i >= 0; --i) {       if (n - i <= k) {         ans = max(ans, dp[x & 1][i]);       } else {         break;       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int l[10], r[10];   double Prob(int id, int a, int b) {     int ini = max(a, l[id]);     int fim = min(b, r[id]);     if (b < l[id] || a > r[id]) return 0.0;     double ret = (fim - ini + 1) * 1.0 / (double)(r[id] - l[id] + 1);     return ret;   }   int main() {     double ret = 0;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d %d , &l[i], &r[i]);     }     int ini = l[0], fim = r[0];     for (int i = 0; i < n; i++) {       ini = min(l[i], ini);       fim = max(r[i], fim);     }     for (int val = ini; val <= fim; val++) {       double prob = 0;       for (int i = 0; i < n; i++) {         double aux3 = Prob(i, val + 1, r[i]);         double aux = 1;         for (int j = 0; j < n; j++) {           if (i == j) continue;           aux *= Prob(j, l[j], val - 1);         }         double aux2 = 1;         for (int j = 0; j < n; j++) {           if (i == j) continue;           aux2 *= Prob(j, l[j], val);         }         aux3 *= (aux2 - aux);         prob += aux3;       }       double p2, aux1, aux2, aux3;       p2 = 0;       for (int i = 0; i < n; i++) {         aux1 = Prob(i, val, val);         for (int j = 0; j < n; j++) {           if (i == j) continue;           aux1 *= Prob(j, l[j], val - 1);         }         p2 += aux1;       }       aux1 = p2;       aux2 = 1;       for (int i = 0; i < n; i++) aux2 *= Prob(i, l[i], val - 1);       aux3 = 1;       for (int i = 0; i < n; i++) aux3 *= Prob(i, l[i], val);       prob += aux3 - aux2 - aux1;       ret += prob * val;     }     printf( %.10lf n , ret);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, ar[5005], bit[5005];   void add(int i) {     while (i > 0) {       bit[i]++;       i -= (i & (-i));     }   }   int ask(int i) {     int tmp = 0;     while (i <= n) {       tmp += bit[i];       i += (i & (-i));     }     return tmp;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &ar[i]);       ar[i]++;     }     long long old = 0, best = 0, pair = 0;     for (int i = 1; i <= n; i++) {       memset(bit, 0, sizeof(bit));       for (int j = i + 1; j <= n; j++) {         if (ar[i] < ar[j]) continue;         old++;         int dec = 1 + 2 * ask(ar[j]);         if (dec > best)           best = dec, pair = 1;         else if (dec == best)           pair++;         add(ar[j]);       }     }     printf( %I64d %I64d n , old - best, pair);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, i;     long long a, b;     cin >> n;     i = a = 0, b = 1000000001;     int arr[n];     while (i < n) {       cin >> arr[i];       i++;     }     i = n - 1;     while (i >= 0) {       if (arr[i] < b) {         a += arr[i];         b = arr[i];         if (b == 1) break;       } else if (arr[i] >= b) {         b--;         a += b;         if (b == 1) break;       }       i--;     }     cout << a << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double esp = 1e-5;   int dis[30][30], du[30], id[30][30];   double p[30], a[500][500];   double solve(int i, int j, int x, int y) {     double ans = 0;     if (i == x && j == y)       ans = p[i] * p[j];     else if (i == x && j != y)       ans = p[i] * (1 - p[j]) / du[j] * dis[j][y];     else if (i != x && j == y)       ans = p[j] * (1 - p[i]) / du[i] * dis[i][x];     else if (i != x && j != y)       ans = (1 - p[i]) * (1 - p[j]) / du[i] / du[j] * dis[i][x] * dis[j][y];     return ans;   }   int main() {     int n, m, st1, st2;     scanf( %d%d%d%d , &n, &m, &st1, &st2);     for (int i = 1; i <= m; i++) {       int u, v;       scanf( %d%d , &u, &v);       du[u]++;       du[v]++;       dis[u][v] = dis[v][u] = 1;     }     for (int i = 1; i <= n; i++) scanf( %lf , &p[i]);     if (st1 == st2) {       for (int i = 1; i <= n; i++) {         if (i == st1)           printf( %.6f%c , 1.0, i == n ?   n  :    );         else           printf( %.6f%c , 0.0, i == n ?   n  :    );       }       return 0;     }     int cnt = 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (i != j) id[i][j] = ++cnt;     int len = n * n - n;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (i == j) continue;         int u = id[i][j];         a[u][u] = -1;         for (int x = 1; x <= n; x++) {           for (int y = 1; y <= n; y++) {             if (x == y) {               a[u][len + x] -= solve(i, j, x, y);               continue;             }             int v = id[x][y];             a[u][v] += solve(i, j, x, y);           }         }       }     }     for (int i = 1; i <= len; i++) {       if (fabs(a[i][i]) < esp) {         int pos = -1;         for (int j = i + 1; j <= len; j++)           if (fabs(a[j][i]) >= esp) {             pos = j;             break;           }         swap(a[i], a[pos]);       }       for (int j = i + 1; j <= len; j++) {         double f = a[j][i] / a[i][i];         for (int k = i; k <= n * n; k++) a[j][k] -= f * a[i][k];       }     }     for (int i = len; i >= 1; i--) {       double f = a[i][i];       for (int j = len + 1; j <= n * n; j++) a[i][j] /= f;       a[i][i] = 1;       for (int j = i - 1; j >= 1; j--) {         f = a[j][i];         for (int k = len + 1; k <= n * n; k++) a[j][k] -= f * a[i][k];       }     }     for (int i = 1; i <= n; i++)       printf( %.6f%c , a[id[st1][st2]][len + i], i == n ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   int main() {     long int n, i, j, k, a, b, c, sum, ht;     scanf( %ld , &n);     i = 1;     sum = 1;     ht = 0;     while (n > 0) {       n = n - sum;       sum = sum + i + 1;       i++;       if (n >= 0) {         ht++;       }     }     printf( %ld n , ht);   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int ansx, ansy;   int a[300005][10];   int b[300005];   int check(long long x) {     memset(b, 0, sizeof(b));     for (int i = 1; i <= n; i++) {       int p = 0;       for (int j = 1; j <= m; j++) {         if (a[i][j] >= x) p += (1 << (j - 1));       }       b[p] = i;     }     int k = (1 << m);     int c = (1 << m) - 1;     for (int i = 0; i <= k; i++) {       for (int j = 0; j <= k; j++) {         if (b[i] && b[j] && ((i | j) == c)) {           ansx = b[i];           ansy = b[j];           return 1;         }       }     }     return 0;   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         scanf( %d , &a[i][j]);       }     }     long long l = 0, r = 1e9;     while (l <= r) {       long long mid = (l + r) / 2;       if (check(mid)) {         l = mid + 1;       } else {         r = mid - 1;       }     }     printf( %d %d n , ansx, ansy);   }
#include <bits/stdc++.h>   using namespace std;   int mm[110][110];   int main() {     int n, ss = 0, md;     scanf( %d , &n);     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) scanf( %d , &mm[i][j]);     if (n % 2 == 0)       md = n / 2;     else       md = (n / 2) + 1;     md--;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) {         if (i == j) ss += mm[i][j];         if (i + j == n - 1) ss += mm[i][j];       }     for (int qq = 0; qq < n; qq++) ss += mm[md][qq];     for (int qq = 0; qq < n; qq++) ss += mm[qq][md];     printf( %d n , ss - mm[md][md] * 3);     return 0;   }