malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   ifstream fin( test.in );   struct intr {     int l, r, id;   };   intr q[200005];   int p, n, qq;   long long sol;   int a[200005];   long long rez[200005];   int mp[5 * 200005];   bool cmp(intr &q1, intr &q2) {     return (q1.r / p < q2.r / p || (q1.r / p == q2.r / p && q1.l < q2.l));   }   void add(int x) {     int v = mp[x];     sol = sol - 1LL * v * v * x;     sol = sol + 1LL * (v + 1) * (v + 1) * x;     mp[x]++;   }   void del(int x) {     int v = mp[x];     sol = sol - 1LL * v * v * x;     if (v >= 1) {       sol = sol + 1LL * (v - 1) * (v - 1) * x;       mp[x]--;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int i, lx, rx;     cin >> n >> qq;     for (i = 1; i <= n; i++) cin >> a[i];     p = sqrt(n);     for (i = 1; i <= qq; i++) {       cin >> q[i].l >> q[i].r;       q[i].id = i;     }     sort(q + 1, q + qq + 1, cmp);     lx = 1;     rx = 0;     sol = 0;     for (i = 1; i <= qq; i++) {       while (q[i].r > rx) add(a[++rx]);       while (q[i].r < rx) del(a[rx--]);       while (q[i].l > lx) del(a[lx++]);       while (q[i].l < lx) add(a[--lx]);       rez[q[i].id] = sol;     }     for (i = 1; i <= qq; i++) cout << rez[i] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long int vis1[1000000];   long long int ara1[100005], ara2[100005];   map<long long int, long long int> vis;   map<long long int, long long int> str2;   priority_queue<long long int> pq;   vector<long long int> vec;   int main() {     long long int a, b, c = 0, sum = 0, n;     scanf( %lld , &n);     for (long long int i = 1; i <= n; i++) {       scanf( %lld , &a);       long long int mx = 0;       string str;       cin >> str;       c = -1;       for (long long int i = 0; i < a; i++) {         if (str[i] !=  A  && c != -1) {           c++;           if (c > mx) mx = c;         } else if (str[i] ==  A )           c = 0;       }       cout << mx << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int const inf = 1e18;   long long int const maxn = 2e5 + 5;   long long int const mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     vector<long long int> arr(26);     for (auto &u : arr) cin >> u;     string s;     cin >> s;     long long int n = s.length();     map<long long int, long long int> mp[26];     vector<long long int> brr(n);     for (long long int i = 0; i < n; i++) {       brr[i] = arr[s[i] -  a ];       if (i != 0) brr[i] += brr[i - 1];     }     long long int ans = 0;     mp[s[0] -  a ][brr[0]]++;     for (long long int i = 1; i < n; i++) {       ans += mp[s[i] -  a ][brr[i - 1]];       mp[s[i] -  a ][brr[i]]++;     }     cout << ans <<   n ;     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 20;   long long n, m, dp[N][1 << N], B, res, cb[1 << N];   bool used[N][1 << N], w[N][N];   long long cbit(long long x) {     long long c = 0;     while (x) {       c += x & 1;       x /= 2;     }     return c;   }   signed main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n >> m;     for (long long i = 0; i < m; ++i) {       long long a, b;       cin >> a >> b;       a--;       b--;       w[a][b] = 1;       w[b][a] = 1;     }     B = 1 << n;     for (long long i = 0; i < B; ++i) cb[i] = cbit(i);     queue<pair<long long, long long>> q;     for (long long i = 0; i < n; ++i) {       for (long long j = 0; j < n; ++j) {         for (long long ma = 0; ma < B; ++ma) {           dp[j][ma] = 0;           used[j][ma] = 0;         }       }       q.push({i, 1 << i});       dp[i][1 << i] = 1;       while (!q.empty()) {         long long v = q.front().first, mask = q.front().second, nmask;         q.pop();         for (long long u = i; u < n; ++u) {           nmask = mask | (1 << u);           if (nmask == mask || !w[u][v]) continue;           dp[u][nmask] += dp[v][mask];           if (!used[u][nmask]) {             used[u][nmask] = 1;             q.push({u, nmask});           }         }       }       long long av = 0;       for (long long j = 0; j < n; ++j) {         for (long long mask = 0; mask < B; ++mask) {           if (cb[mask] >= 3 && w[i][j] && dp[j][mask]) {             av += dp[j][mask];           }         }       }       res += av / 2;     }     cout << res <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 4e5 + 100;   vector<int> vec[maxn];   int n, m, k;   int d[maxn], cnt;   bool vis[maxn];   void dfs(int x) {     vis[x] = 1;     d[++cnt] = x;     for (int i = 0; i < vec[x].size(); i++) {       if (vis[vec[x][i]]) continue;       dfs(vec[x][i]);       d[++cnt] = x;     }   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= m; i++) {       int u, v;       scanf( %d%d , &u, &v);       vec[u].push_back(v);       vec[v].push_back(u);     }     dfs(1);     int x = (2 * n + k - 1) / k;     for (int i = 1; i <= k; i++) {       int c = min(x, cnt);       if (c == 0) {         cout <<  1 1  << endl;         continue;       }       cout << c <<    ;       for (int i = 1; i <= c && cnt != 0; i++, cnt--) {         cout << d[cnt] <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, c, d;     cin >> a >> b >> c >> d;     if (abs(c - d) > 1) {       cout <<  -1 ;       return 0;     }     if (max(c, d) > min(a, b)) {       cout <<  -1 ;       return 0;     }     if (a + b <= c + d) {       cout <<  -1 ;       return 0;     }     if (c == d) {       a--;       for (int i = 1; i <= a - c; i++) cout <<  4 ;       if (a == c - 1 && b > 1) {         cout <<  7 ;         b--;       }       for (int i = 1; i <= c; i++) cout <<  47 ;       for (int i = 1; i <= b - c; i++) cout <<  7 ;       if (a - c >= 0) cout <<  4 ;     }     if (c > d) {       for (int i = 1; i <= a - c; i++) cout <<  4 ;       for (int i = 1; i <= c; i++) cout <<  47 ;       for (int i = 1; i <= b - c; i++) cout <<  7 ;     }     if (c < d) {       if (b > 1) {         cout <<  7 ;         b--;       }       for (int i = 1; i < a - c; i++) cout <<  4 ;       for (int i = 1; i <= c; i++) cout <<  47 ;       for (int i = 1; i <= b - c; i++) cout <<  7 ;       cout <<  4 ;     }   }
#include<bits/stdc++.h>   #define rep(i,a,b) for(int i=a;i<=b;i++)   #define pre(i,a,b) for(int i=a;i>=b;i--)   #define N 505   using namespace std;   int f[52][95][905][2],n,mx=450,cc=45;   char s[N];   int calc(int x,int cur,int res,int op){    if(x==n+1&&!cur)return 0;    if(abs(cur)>cc||abs(res)>mx||x==n+1)return 0x3f3f3f3f;    if(~f[x][cur+cc][res+mx][op==1])return f[x][cur+cc][res+mx][op==1];    f[x][cur+cc][res+mx][op==1]=min(calc(x,cur,res+op,op)+n-x+1,min(calc(x+1,cur*10+s[x+1]- 0 -res,res,1),calc(x+1,cur*10+s[x+1]- 0 -res,res,-1)));    return f[x][cur+cc][res+mx][op==1];   }   int main(){    scanf( %s ,s+2);n=strlen(s+2);s[1]= 0 ;    memset(f,~0,sizeof(f));    printf( %d n ,calc(0,0,0,1));    return 0;   }    /*   #include<bits/stdc++.h>   #define rep(i,a,b) for(int i=a;i<=b;i++)   #define pre(i,a,b) for(int i=a;i>=b;i--)   #define N 505   using namespace std;   int f[52][95][905][2],n,mx=450,cc=45;   char s[N];   int calc(int x,int cur,int res,int op){    if(x==n+1&&!cur)return 0;    if(abs(cur)>cc||abs(res)>mx||x==n+1)return 0x3f3f3f3f;    if(~f[x][cur+cc][res+mx][op==1])return f[x][cur+cc][res+mx][op==1];    f[x][cur+cc][res+mx][op==1]=min(calc(x,cur,res+op,op)+n-x+1,min(calc(x+1,cur*10+s[x+1]- 0 -res,res,1),calc(x+1,cur*10+s[x+1]- 0 -res,res,-1)));    return f[x][cur+cc][res+mx][op==1];   }   int main(){    scanf( %s ,s+2);n=strlen(s+2);s[1]= 0 ;    memset(f,~0,sizeof(f));    printf( %d n ,calc(0,0,0,1));    return 0;   }    */
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 10;   long long int dp1[N], dp2[N], Sa[N], Sw[N], dp[20][N], A[N];   int P[20][N], H[N], n, q;   vector<pair<int, int> > adj[N];   void preDFS(int v, int p = -1) {     if (!~p) P[0][v] = v;     for (int i = 1; i < 20; i++) P[i][v] = P[i - 1][P[i - 1][v]];     for (pair<int, int> u : adj[v]) {       if (u.first != p) {         P[0][u.first] = v;         H[u.first] = H[v] + 1;         Sw[u.first] = Sw[v] + u.second, Sa[u.first] = Sa[v] + A[u.first];         preDFS(u.first, v);       }     }   }   int getpar(int v, int h) {     for (int i = h; i; i -= i & -i) v = P[__builtin_ctz(i)][v];     return v;   }   int LCA(int u, int v) {     if (H[u] < H[v]) swap(u, v);     u = getpar(u, H[u] - H[v]);     if (u == v) return v;     for (int i = 19; ~i; i--)       if (P[i][u] != P[i][v]) u = P[i][u], v = P[i][v];     return P[0][v];   }   void DFSdn(int v, int p = -1) {     for (pair<int, int> u : adj[v]) {       if (u.first != p)         DFSdn(u.first, v),             dp1[v] += max(0ll, dp1[u.first] - 2 * u.second + A[u.first]);     }   }   void DFSup(int v, int p = -1) {     for (pair<int, int> u : adj[v]) {       if (u.first != p) {         dp2[u.first] =             max(0ll, A[v] + dp2[v] + dp1[v] -                          max(0ll, dp1[u.first] - 2 * u.second + A[u.first]));         dp2[u.first] = max(0ll, dp2[u.first] - 2 * u.second);         DFSup(u.first, v);       }     }   }   void NIMA(int v, int p = -1) {     for (pair<int, int> u : adj[v]) {       if (u.first != p) {         dp[0][u.first] =             dp1[v] - max(0ll, dp1[u.first] - 2 * u.second + A[u.first]);         NIMA(u.first, v);       }     }   }   long long int get(int v, int h) {     long long int ret = 0;     for (int i = h; i; i -= i & -i)       ret += dp[__builtin_ctz(i)][v], v = P[__builtin_ctz(i)][v];     return ret;   }   int main() {     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) scanf( %lld , &A[i]);     for (int i = 1; i < n; i++) {       int u, v, w;       scanf( %d%d%d , &u, &v, &w);       adj[u].push_back({v, w});       adj[v].push_back({u, w});     }     preDFS(1);     DFSdn(1);     DFSup(1);     NIMA(1);     for (int i = 1; i < 20; i++)       for (int j = 1; j <= n; j++)         dp[i][j] = dp[i - 1][j] + dp[i - 1][P[i - 1][j]];     for (; q; q--) {       int u, v;       scanf( %d%d , &u, &v);       if (H[u] < H[v]) swap(u, v);       if (u == v) {         printf( %lld n , dp1[u] + dp2[u] + A[u]);         continue;       }       int p = LCA(u, v);       long long int a = get(u, H[u] - H[p]), b = get(v, H[v] - H[p]);       long long int ret =           Sa[u] - Sa[p] + A[p] + Sa[v] - Sa[p] - (Sw[u] - Sw[p] + Sw[v] - Sw[p]);       printf( %lld n , a + b + dp2[p] - dp1[p] + ret + dp1[u] + dp1[v]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e6 + 10, mod = 1e9 + 7, inf = 2e9, lg = 22,                   maskm = (1 << lg) - 1, maxm = (1 << lg) + 7;   long long a[maxn], dp[maxm];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       dp[a[i]] = a[i];     }     for (int i = 1; i < maxm; i++) {       for (int j = i; j && dp[i] == 0; j -= (j & -j)) {         dp[i] = dp[i ^ (j & -j)];       }     }     for (int i = 0; i < n; i++) {       long long tmp = maskm ^ a[i];       if (dp[tmp] == 0)         cout << -1 <<    ;       else         cout << dp[tmp] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   bool vis[100010];   vector<int> dp[5][100010];   int k, l;   int a[6][6];   int dfs(int now) {     int i, j, x = 0, sum = 0;     for (i = 0; i < now; i++) x = x * 10 + a[now][i];     if (i == l - 1) return dp[1][x].size();     for (i = 0; i < dp[l - now][x].size(); i++) {       int tem = dp[l - now][x][i];       for (j = l - 1; j >= now; j--) {         a[j][now] = a[now][j] = tem % 10;         tem /= 10;       }       sum += dfs(now + 1);     }     return sum;   }   int main() {     int i, j, n;     int m = sqrt(100000.5);     for (i = 2; i <= m; i++)       if (!vis[i]) {         for (j = i * i; j <= 100000; j += i) vis[j] = 1;       }     for (i = 2; i < 100000; i++)       if (!vis[i]) {         int tem = i;         tem /= 10;         for (j = 1; j <= 4; j++) {           dp[j][tem].push_back(i);           tem /= 10;         }       }     scanf( %d , &n);     char str[7];     for (j = 1; j <= n; j++) {       scanf( %s , str);       l = strlen(str);       for (i = 0; str[i] !=   0 ; i++) {         a[0][i] = a[i][0] = str[i] -  0 ;       }       printf( %d n , dfs(1));     }   }
#include <bits/stdc++.h>   const int maxn = 5e5 + 10;   using namespace std;   int main() {     string s;     long long n;     cin >> n;     while (n--) {       cin >> s;       int b = 0, e = s.size() - 1;       while (b < e && s[b] == s[e]) b++, e--;       if (b >= e)         cout << s <<   n ;       else {         string s1, s2, cmax;         for (int i = b; i <= e; i++) {           s1 += s[i];           s2 = s1;           reverse(s2.begin(), s2.end());           if (s1 == s2) cmax = s1;         }         string s3, s4, cmax2;         for (int i = e; i >= b; i--) {           s3 += s[i];           s4 = s3;           reverse(s4.begin(), s4.end());           if (s3 == s4) cmax2 = s3;         }         if (cmax.size() > cmax2.size())           cout << s.substr(0, b) << cmax << s.substr(e + 1) << endl;         else           cout << s.substr(0, b) << cmax2 << s.substr(e + 1) << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     x = 0;     int 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();     }     x *= f;   }   const int MAXN = 2e3 + 7;   int n;   string ch[MAXN][2];   vector<int> g[MAXN];   inline int neg(int u) { return (u > n ? u - n : n + u); }   inline void eadd(int u, int v) { g[u].push_back(v); }   inline void iadd(int u, int v) {     eadd(u, v);     eadd(neg(v), neg(u));   }   bool mk[MAXN];   int dt[MAXN], cmp[MAXN], t = 0, cc = 0;   stack<int> stk;   int scc(int u) {     stk.push(u);     mk[u] = true;     int lw = dt[u] = ++t;     for (auto v : (g[u])) {       if (!dt[v]) {         int nl = scc(v);         lw = min(lw, nl);       } else if (mk[v])         lw = min(lw, dt[v]);     }     mk[u] = false;     if (dt[u] == lw) {       ++cc;       while (stk.top() != u) {         cmp[stk.top()] = cc;         if (cmp[neg(stk.top())] == cc) return -1;         stk.pop();       }       if (cmp[neg(stk.top())] == cc) return -1;       cmp[stk.top()] = cc;       stk.pop();     }     return lw;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = (1); i <= (n); ++i) {       string s0, s1;       cin >> s0 >> s1;       ch[i][0] = s0.substr(0, 3);       ch[i][1] = s0.substr(0, 2) + s1.substr(0, 1);     }     for (int i = (1); i <= (n); ++i)       for (int j = (1); j <= (n); ++j)         if (i != j) {           if (ch[i][0] == ch[j][0]) iadd(i, neg(j)), iadd(neg(i), neg(j));           ;           if (ch[i][1] == ch[j][1]) iadd(neg(i), j);           if (ch[i][0] == ch[j][1]) iadd(i, j);         }     for (int i = (1); i <= (2 * n); ++i)       if (!dt[i])         if (scc(i) < 0) {           cout <<  NO n ;           return 0;         }     cout <<  YES n ;     for (int i = (1); i <= (n); ++i) {       if (cmp[i] > cmp[neg(i)])         cout << ch[i][1] <<   n ;       else         cout << ch[i][0] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7, N = 100007;   int n;   long long ts, tf, t, a[N], ans = (long long)1e18, id;   int main() {     cin >> ts >> tf >> t;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     while (a[n] > tf - t) n--;     a[++n] = tf - t + 1;     long long cur = 0;     for (int i = 1; i <= n; i++) {       cur = max(cur, ts);       if (ans > cur - (a[i] - 1)) {         ans = cur - (a[i] - 1);         id = a[i] - 1;       }       if (cur < a[i]) {         cout << cur;         return 0;       }       cur = max(cur, a[i]);       cur += t;       if (cur >= tf - t + 1) break;     }     cout << id;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 100;   int n, m, q;   long long suma[N], b[N], sumb[N];   long long solve(long long x) {     int pos = lower_bound(sumb + n, sumb + m + 1, x) - sumb;     if (pos > m) return x - sumb[m];     if (pos == n) return sumb[pos] - x;     return min(x - sumb[pos - 1], sumb[pos] - x);   }   int main() {     scanf( %d %d %d , &n, &m, &q);     for (int i = 1; i <= n; i++) {       scanf( %lld , &suma[i]);       if (i & 1)         suma[i] = suma[i - 1] + suma[i];       else         suma[i] = suma[i - 1] - suma[i];     }     for (int i = 1; i <= m; i++) {       scanf( %lld , &b[i]);     }     for (int i = 1; i <= n; i++) {       if (i & 1)         sumb[i] = sumb[i - 1] + b[i];       else         sumb[i] = sumb[i - 1] - b[i];     }     int f = -1;     if (n & 1) f = 1;     for (int i = 1; i <= m - n; i++) {       sumb[i + n] = -(sumb[i + n - 1] - b[i]) + b[i + n] * f;     }     sort(sumb + n, sumb + m + 1);     long long a = suma[n];     printf( %lld n , solve(a));     for (int i = 1; i <= q; i++) {       int l, r, x;       scanf( %d %d %d , &l, &r, &x);       if ((r - l + 1) & 1) {         if (l & 1)           a += x;         else           a -= x;       }       printf( %lld n , solve(a));     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000005;   int n;   char s1[maxn], s2[maxn];   int main() {     scanf( %d%s%s , &n, s1 + 1, s2 + 1);     reverse(s1 + 1, s1 + n);     for (int i = 1; i < n; ++i) {       if (s1[i] ==  N )         s1[i] =  S ;       else if (s1[i] ==  S )         s1[i] =  N ;       else if (s1[i] ==  W )         s1[i] =  E ;       else         s1[i] =  W ;     }     unsigned long long h1 = 0, h2 = 0, fa = 1;     for (int i = 1; i < n; ++i) {       h1 = h1 + s1[i] * fa;       h2 = h2 * 233u + s2[n - i];       fa *= 233u;       if (h1 == h2) return puts( NO ), 0;     }     puts( YES );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     int x, y, a, b;   };   point rotate(point p) {     point p1 = p;     int x = p1.x - p1.a, y = p1.y - p1.b;     p1.x = -y + p1.a;     p1.y = x + p1.b;     return p1;   }   bool comp(point p1, point p2) {     if (p1.x == p2.x) return p1.y < p2.y;     return p1.x < p2.x;   }   bool issq(point p[]) {     sort(p, p + 4, comp);     if (p[0].x == p[3].x && p[0].y == p[3].y) return false;     if (p[0].x == p[1].x && p[0].y == p[1].y) return false;     int d11 = (p[0].x - p[1].x) * (p[0].x - p[1].x) +               (p[0].y - p[1].y) * (p[0].y - p[1].y);     int d22 = (p[0].x - p[2].x) * (p[0].x - p[2].x) +               (p[0].y - p[2].y) * (p[0].y - p[2].y);     int d1 = (p[0].x - p[3].x) * (p[0].x - p[3].x) +              (p[0].y - p[3].y) * (p[0].y - p[3].y);     int d2 = (p[1].x - p[2].x) * (p[1].x - p[2].x) +              (p[1].y - p[2].y) * (p[1].y - p[2].y);     if (p[0].x + p[3].x == p[1].x + p[2].x &&         p[0].y + p[3].y == p[1].y + p[2].y && d11 == d22 && d1 == d2)       return true;     return false;   }   int main() {     int n;     cin >> n;     while (n--) {       point p[4];       for (int i = 0; i < 4; i++) cin >> p[i].x >> p[i].y >> p[i].a >> p[i].b;       int ans = 17;       for (int i = 0; i < 4; i++) {         for (int j = 0; j < 4; j++) {           for (int k = 0; k < 4; k++) {             for (int l = 0; l < 4; l++) {               point pc[4];               for (int il = 0; il < 4; il++) pc[il] = p[il];               if (issq(pc)) ans = min(ans, i + j + k + l);               p[3] = rotate(p[3]);             }             p[2] = rotate(p[2]);           }           p[1] = rotate(p[1]);         }         p[0] = rotate(p[0]);       }       if (ans == 17)         cout << -1;       else         cout << ans;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     string s;     cin >> n >> s;     n += 3;     vector<int> a(n), la(n), ra(n), lmi(n), lma(n), rmi(n), rma(n);     int j = 2;     for (int i = 0; i < n - 3; i++) {       if (s[i] ==  ( ) {         a[j] = 1;       } else if (s[i] ==  ) ) {         a[j] = -1;       } else if (s[i] ==  R ) {         j++;       } else if (s[i] ==  L ) {         j--;         j = max(j, 2);       } else {         a[j] = 0;       }       la[j] = la[j - 1] + a[j];       ra[j] = ra[j + 1] - a[j];       lmi[j] = min(lmi[j - 1], la[j]);       lma[j] = max(lma[j - 1], la[j]);       rmi[j] = min(rmi[j + 1], ra[j]);       rma[j] = max(rma[j + 1], ra[j]);       if (lmi[j] >= 0 && rmi[j + 1] >= 0 && la[j] == ra[j + 1]) {         cout << max(lma[j], rma[j + 1]) <<    ;       } else {         cout <<  -1  ;       }     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   ;   const long long maxn = 1e5 + 7;   const long double pi = 3.14159265358979323846;   struct pirog {     long long r;     long long h;     long long i;   };   long long V[4 * maxn];   pirog A[maxn];   vector<pirog> C;   void update(long long v, long long tl, long long tr, long long i,               long long color) {     if (tl == tr) {       V[v] = color;       return;     }     long long tm = (tl + tr) / 2;     if (tm >= i) {       update(2 * v, tl, tm, i, color);     } else {       update(2 * v + 1, tm + 1, tr, i, color);     }     V[v] = max(V[2 * v], V[2 * v + 1]);   }   long long mx(long long v, long long tl, long long tr, long long l,                long long r) {     if (tl > r || l > tr) {       return 0;     }     if (tl == l && tr == r) {       return V[v];     }     long long tm = (tl + tr) / 2;     return max(mx(2 * v, tl, tm, l, min(tm, r)),                mx(2 * v + 1, tm + 1, tr, max(l, tm + 1), r));   }   bool cmp(pirog a, pirog b) { return a.h * a.r * a.r < b.h * b.r * b.r; }   long long X[maxn];   int main() {     long long q, w, e, k, n;     cin >> n;     cout << fixed << setprecision(10);     for (q = 0; q < n; q++) {       cin >> A[q].r >> A[q].h;       A[q].i = q;       C.push_back(A[q]);     }     sort(C.begin(), C.end(), cmp);     long long l = 0;     for (q = 0; q < n; q++) {       long long x = mx(1, 0, n - 1, 0, C[q].i) + C[q].h * C[q].r * C[q].r;       X[q] = x;       if (C[q].r * C[q].r * C[q].h == C[q + 1].r * C[q + 1].r * C[q + 1].h) {         continue;       }       for (w = l; w <= q; w++) {         update(1, 0, n - 1, C[w].i, X[w]);       }       l = q + 1;     }     cout << mx(1, 0, n - 1, 0, n - 1) * pi;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 100;   int main() {     int flag = 0;     long long n, a, b;     cin >> n >> a >> b;     long long x = a, y = b;     if (a > b) {       swap(a, b);       flag = 1;     }     if (a * b > 6 * n) {       printf( %lld n , a * b);       printf( %lld %lld n , a, b);       return 0;     }     long long ans = 0x3f3f3f3f3f3f3f3f, l = 0, r = 0;     long long len = sqrt(6 * n) + 1;     for (int i = a; i <= len + 5; i++) {       if (6 * n % i == 0 && 6 * n / i >= b) {         l = i;         r = 6 * n / i;         break;       }       y = 6 * n / i + 1;       y = max(y, b);       if (i * y < ans) {         l = i;         r = y;         ans = l * r;       }     }     if (flag) swap(l, r);     printf( %lld n , l * r);     printf( %lld %lld n , l, r);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e4 + 7;   const int inf = 0x3f3f3f3f;   int a[maxn];   char s[150];   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       scanf( %s , s);       int x = 0, y = 0;       for (int i = 0; i < n; i++) {         if (s[i] ==  < )           x++;         else           break;       }       for (int i = n - 1; i >= 0; i--) {         if (s[i] ==  > )           y++;         else           break;       }       cout << min(x, y) << endl;     }     return 0;   }