malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   int main() {     long double x1, y1, r1, x2, y2, r2;     while (~scanf( %Lf%Lf%Lf%Lf%Lf%Lf , &x1, &y1, &r1, &x2, &y2, &r2)) {       long double de = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);       long double d = sqrt(de);       if (d >= (r1 + r2)) {         printf( 0.00000000000000000000 n );         continue;       }       if (d <= fabs(r1 - r2)) {         printf( %.20Lf n , pi * min(r1, r2) * min(r1, r2));         continue;       }       long double s1 = acos((r1 * r1 + de - r2 * r2) / (2.0 * r1 * d));       long double s2 = acos((r2 * r2 + de - r1 * r1) / (2.0 * r2 * d));       long double v1 = s1 * r1 * r1;       long double ss1 = 1.0 / 2.0 * r1 * r1 * sin(2.0 * s1);       long double v2 = s2 * r2 * r2;       long double ss2 = 1.0 / 2.0 * r2 * r2 * sin(2.0 * s2);       printf( %.20Lf n , v1 + v2 - ss1 - ss2);     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   template <class t>   using V = vector<t>;   constexpr ll INF = 1e16;   int n, m;   ll dp[1502][1502];   int tab[1502][1502];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i)       for (int k = 1; k <= m; ++k) scanf( %d , &tab[i][k]);     for (int i = 1; i <= n; ++i)       for (int k = 1; k <= m; ++k) tab[i][k] += tab[i][k - 1];     for (int i = 1; i <= n + 1; ++i)       for (int k = 0; k <= m + 1; ++k) dp[i][k] = -INF;     for (int i = 1; i <= n; ++i) {       if (i & 1) {         for (int k = 1; k <= m; ++k)           dp[i - 1][k] = max(dp[i - 1][k - 1], dp[i - 1][k]);         for (int k = 2; k <= m; ++k) dp[i][k] = dp[i - 1][k - 1] + tab[i][k];       } else {         for (int k = m; k >= 1; --k)           dp[i - 1][k] = max(dp[i - 1][k], dp[i - 1][k + 1]);         for (int k = 1; k <= m - 1; ++k) dp[i][k] = dp[i - 1][k + 1] + tab[i][k];       }     }     ll res = -INF;     for (int i = 1; i <= m; ++i) res = max(res, dp[n][i]);     printf( %lld n , res);   }
#include <bits/stdc++.h>   using namespace std;   bool alph[26] = {1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1,                    0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0};   bool check(string s) {     for (int i = 0; i < s.length(); i++)       if (!alph[s[i] -  A ]) return false;     return true;   }   int main() {     string s;     cin >> s;     string t = s;     reverse(s.begin(), s.end());     if (s == t && check(s))       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     if (n == 5) {       cout <<  >...v  << endl            <<  v.<..  << endl            <<  ..^..  << endl            <<  >....  << endl            <<  ..^.<  << endl            <<  1 1 ;       return 0;     }     if (n == 3) {       cout <<  >vv  << endl <<  ^<.  << endl <<  ^.<  << endl <<  1 3 ;       return 0;     }     for (int i = 0; i < 50; i++) {       for (int j = 0; j < 50; j++) {         cout <<  > ;       }       for (int j = 0; j < 24; j++) {         cout <<  .> ;       }       cout <<  .v  << endl;       cout <<  ^. ;       for (int j = 0; j < 24; j++) {         cout <<  <. ;       }       for (int j = 0; j < 50; j++) {         cout <<  < ;       }       cout << endl;     }     cout <<  1 100 ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long tests, a, b, c;     cin >> tests;     while (tests--) {       cin >> a >> b >> c;       vector<long long> v;       v.push_back(a);       v.push_back(b);       v.push_back(c);       sort(v.begin(), v.end());       a = v[0];       b = v[1];       c = v[2];       if (a + c <= b)         cout << a + c <<   n ;       else if (a + c > b) {         cout << (a + b + c) / 2 <<   n ;       }     }   }
#include <bits/stdc++.h>   const int MAXN = 200000;   using namespace std;   inline int read() {     int x = 0, w = 1;     char c =    ;     while (c <  0  || c >  9 ) {       c = getchar();       if (c ==  - ) w = -1;     }     while (c >=  0  && c <=  9 ) {       x = (x << 1) + (x << 3) + (c ^ 48);       c = getchar();     }     return x * w;   }   int n, a[MAXN + 5];   void init() {     n = read();     for (int i = 1; i <= n; ++i) a[i] = read();   }   int mx, mxi, ans[MAXN + 5], len;   map<int, int> dp;   int main() {     init();     for (int i = 1; i <= n; ++i) {       dp[a[i]] = dp[a[i] - 1] + 1;       if (dp[a[i]] > mx) {         mx = dp[a[i]];         mxi = a[i];       }     }     printf( %d n , mx);     for (int i = n; i > 0; --i)       if (mxi == a[i]) {         --mxi;         ans[++len] = i;       }     for (int i = len; i > 0; --i) printf( %d  , ans[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>      using namespace std;      int main()   {      int t;      cin>>t;      while(t--)      {          int n,m;          int count=0;          cin>>n>>m;          map <int, int > ma;          int a[n],b[m];          for(int i=0;i<n;i++)          {              cin>>a[i];              ma[a[i]]++;          }          for(int i=0;i<m;i++)          {              cin>>b[i];              ma[b[i]]++;          }          for(auto i=ma.begin();i!=ma.end();i++)          {              if(i->second>1)              {                  count=count+2;              }          }          cout<<count/2<<  n ;      }          return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   struct Line {     int k, b;   } a[100100];   struct Fraction {     int x, y;   } b[100100];   int gcd(int x, int y) {     if (x == 0)       return y;     else       return gcd(y % x, x);   }   bool cmp(const Fraction &t1, const Fraction &t2) {     if (t1.x != t2.x) return (t1.x < t2.x);     return (t1.y < t2.y);   }   int main() {     scanf( %d , &n);     int tot = 0;     for (int i = 1; i <= n; ++i) {       scanf( %d%d , &a[i].k, &a[i].b);       if (a[i].k != 0) {         b[++tot].x = -a[i].b;         b[tot].y = a[i].k;         if (b[tot].x < 0) {           b[tot].x *= -1;           b[tot].y *= -1;         }         int g = gcd(abs(b[tot].x), abs(b[tot].y));         b[tot].x /= g;         b[tot].y /= g;         if (b[tot].x == 0) b[tot].y = 1;       }     }     sort(b + 1, b + tot + 1, cmp);     int ans = 0;     for (int i = 1; i <= tot; ++i) {       if (i == 1 || b[i].x != b[i - 1].x || b[i].y != b[i - 1].y) ans++;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 10;   int n, a[N], b[N], c[N];   int Log[N];   int l[19][N], r[19][N];   struct rmq {     int st[N][19], val[N];     int type;     inline int Max(int x, int y) { return (val[x] < val[y]) ? y : x; }     void build(int *b, int n, int _type) {       type = _type;       for (int i = 1; i <= n; i++) st[i][0] = i, val[i] = type * b[i];       for (int j = 1; j <= Log[n]; j++) {         for (int i = 1; i + (1 << j) - 1 <= n; i++)           st[i][j] = Max(st[i][j - 1], st[i + (1 << j - 1)][j - 1]);       }     }     inline int query(int l, int r) {       int k = Log[r - l + 1];       return Max(st[l][k], st[r - (1 << k) + 1][k]);     }   } rmq_l, rmq_r;   int main() {     scanf( %d , &n);     for (int i = 2; i <= 3 * n; i++) Log[i] = Log[i >> 1] + 1;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       a[i + n] = a[i + n * 2] = a[i];     }     if (n == 1) return puts( 0 ), 0;     for (int i = 1; i <= 3 * n; i++) {       b[i] = max(1, i - a[i]);       c[i] = min(3 * n, i + a[i]);     }     for (int i = 0; i <= Log[3 * n]; i++) r[i][3 * n] = 3 * n, l[i][1] = 1;     for (int i = 1; i <= 3 * n; i++) {       l[0][i] = b[i];       r[0][i] = c[i];     }     rmq_l.build(l[0], n * 3, -1);     rmq_r.build(r[0], n * 3, 1);     for (int i = 1; i <= Log[3 * n]; i++)       for (int j = 1; j <= 3 * n; j++) {         int posl = rmq_l.query(l[i - 1][j], r[i - 1][j]);         int posr = rmq_r.query(l[i - 1][j], r[i - 1][j]);         l[i][j] = min(l[i - 1][posl], l[i - 1][posr]);         r[i][j] = max(r[i - 1][posl], r[i - 1][posr]);       }     for (int j = n + 1; j <= n * 2; j++) {       int u = j, v = j;       int ans = 0;       for (int i = Log[3 * n]; i >= 0; i--) {         if (max(r[i][v], r[i][u]) - min(l[i][u], l[i][v]) + 1 >= n) continue;         int nu = rmq_l.query(l[i][u], r[i][v]);         int nv = rmq_r.query(l[i][u], r[i][v]);         u = nu;         v = nv;         ans += 1 << i;       }       ans++;       printf( %d  , ans);     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     char str[105];     scanf( %s , str);     int l = 0, r = 0, u = 0, d = 0;     for (int i = 0; i < n; i++)       if (str[i] ==  L )         l++;       else if (str[i] ==  R )         r++;       else if (str[i] ==  U )         u++;       else if (str[i] ==  D )         d++;     printf( %d n , min(l, r) * 2 + min(u, d) * 2);   }
#include <bits/stdc++.h>   using namespace std;   string a, b, c;   long long n, x, y, z;   pair<long long, long long> f[2000];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> a >> b >> c;     for (auto i : a) {       f[i].first++;       x = max(x, f[i].first);     }     for (auto i : b) {       if (f[i].second != 2) f[i] = {0, 2};       f[i].first++;       y = max(y, f[i].first);     }     for (auto i : c) {       if (f[i].second != 3) f[i] = {0, 3};       f[i].first++;       z = max(z, f[i].first);     }     if (n == 1) {       if (a.size() == x) a.erase(0, 1);       if (b.size() == y) b.erase(0, 1);       if (c.size() == z) c.erase(0, 1);     }     x = min(x + n, (long long)a.size());     y = min(y + n, (long long)b.size());     z = min(z + n, (long long)c.size());     if (x > y && x > z) return cout <<  Kuro , 0;     if (y > x && y > z) return cout <<  Shiro , 0;     if (z > x && z > y) return cout <<  Katie , 0;     cout <<  Draw ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace {   int CC_;   const double EPS = 1E-9;   const double PI = 2 * acos(0.0);   const long long MOD = 1000000007;   template <class T>   void DA(T i, T e) {     while (i != e) {       cout <<  Con>>(   << ++CC_ <<   )   << *i++ <<   n ;     }   }   template <class T>   void DA(T* x, int l) {     for (int i = 0; i < l; i++) cout <<  [  << i <<  ]>>   << x[i] <<   n ;   }   template <class T>   inline void sary(T* st, T* nd) {     while (st < nd) cin >> *st++;   }   template <class T>   void tobin(T n, char* bin) {     int pos = 1 << ((int)log2(n));     while (pos >= 1) {       if ((n & pos) == 0)         *bin =  0 ;       else         *bin =  1 ;       pos >>= 1;       bin++;     }     *bin =   0 ;   }   template <class T>   int strOccur(string& s, T& tgt) {     int oc = 0, p = s.find(tgt);     while (p != string::npos) {       p = s.find(tgt, p + 1);       oc++;     }     return oc;   }   template <class T>   inline T LCM(T x, T y) {     return ((x * y) / __gcd(x, y));   }   long long todec(string& num, int b) {     long long dec = num[0] - (isupper(num[0]) ?  A  - 10 :  0 );     for (int i = 1; num[i]; i++) {       if (num[i] >=  A  && num[i] <=  Z )         num[i] -=  A  - 10;       else         num[i] -=  0 ;       dec *= b;       dec += num[i];     }     return dec;   }   int bigMod(int b, int e, int m) {     if (e == 0) return 1;     if (!(e & 1)) {       int temp = bigMod(b, e / 2, m) % m;       return (temp * temp) % m;     } else       return ((b % m) * (bigMod(b, e - 1, m)) % m) % m;   }   bool comp(const int a, const int b) { return a > b; }   }  // namespace   const int sss = 1E6;   int a[200019];   void solve(void) {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int lim = n / 2;     for (int i = 0, j = n - 1; i < lim; i++, j--) {       if (i % 2 == 0) {         swap(a[i], a[j]);       }     }     for (int i = 0; i < n; i++) {       cout << a[i] <<    ;     }     cout <<   n ;     ;   }   int main(void) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 10;   const long long M = 998244353;   const long double PI = acos(-1);   long long n, k;   long long a[N], d[N], mn[N] = {INT_MAX};   signed main() {     long long i, s = 0, ans = 0;     cin >> n >> k;     for (i = 1; i <= n; i++) cin >> a[i];     for (i = 1; i <= n; i++) cin >> d[i], mn[i] = min(mn[i - 1], d[i]);     for (i = n; i >= 1; i--) a[i] += a[i + 1];     if (k == 0) {       for (i = 1; i <= n; i++) ans = max(ans, a[i] - d[i]);       cout << ans;     } else if (k == 1) {       for (i = 2; i <= n; i++)         ans = max(ans, max(0ll, a[1] - a[i] - mn[i - 1]) + max(0ll, a[i] - d[i]));       for (i = 1; i < n; i++)         ans = max(ans, a[1] - (a[i + 1] - a[i + 2]) - d[1] +                            max(0ll, a[i + 1] - a[i + 2] - d[i + 1]));       cout << ans;     } else       cout << max({0ll, a[1] - mn[n - 1], a[n] - d[n]});     return 0;   }
#include <bits/stdc++.h>   using namespace std;   multiset<int64_t> h, hl, v, vl;   int main() {     cin.tie(0), ios_base::sync_with_stdio(0);     int W, H, q, r, c, nr, nc, pr, pc;     auto tmp = h.begin();     char t;     cin >> W >> H >> q;     int64_t mv = H, mh = W;     h.insert(0);     h.insert(W);     hl.insert(W);     v.insert(0);     v.insert(H);     vl.insert(H);     while (q--) {       cin >> t;       if (t ==  H ) {         cin >> r;         tmp = v.insert(r);         nr = *next(tmp);         pr = *prev(tmp);         vl.erase(vl.find(nr - pr));         vl.insert(r - pr);         vl.insert(nr - r);       } else {         cin >> c;         tmp = h.insert(c);         nc = *next(tmp);         pc = *prev(tmp);         hl.erase(hl.find(nc - pc));         hl.insert(c - pc);         hl.insert(nc - c);       }       cout << *prev(hl.end()) * *(prev(vl.end())) <<   n ;     }     return 0;     ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     char str[1000][1000];     int i;     for (i = 0; i < n; i++) {       scanf(  %[^ n] , str[i]);     }     int cnt = 0;     int j;     for (i = 0; i < n; i++) {       if (strcmp(str[i],  -1 ) == 0) continue;       cnt++;       int flag = 0;       for (j = i + 1; j < n; j++) {         if (strcmp(str[j],  -1 ) == 0) continue;         if (strcmp(str[i], str[j]) == 0) {           strcpy(str[j],  -1 );         }       }     }     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18 + 9;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long n, k;     cin >> n >> k;     vector<long long> a(n);     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     sort(a.begin(), a.end());     vector<long long> pref(n, 0), suf(n, 0);     for (long long i = 1, sm = a[0]; i < n; i++) {       pref[i] = a[i] * i - sm;       sm += a[i];     }     for (long long i = n - 2, sm = a[n - 1]; i >= 0; i--) {       suf[i] = sm - a[i] * (n - i - 1);       sm += a[i];     }     long long ans = INF;     for (long long i = 0, j = 0; i < n; i = j) {       for (; j < n && a[j] == a[i]; j++)         ;       long long prev = 0, forw = 0;       long long base = INF;       prev += pref[i];       prev -= i;       if (i >= k - j + i) base = min(base, prev);       forw += suf[j - 1];       forw -= (n - j);       if (n - j >= k - j + i) base = min(base, forw);       base = min(base, prev + forw);       ans = min(ans, base + k - (j - i));       if (j - i >= k) ans = 0;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int test;     cin >> test;     while (test--) {       long long int n;       cin >> n;       long long int a[n];       for (int i = 0; i < n; i++) {         cin >> a[i];       }       long long int total_sum = 0;       for (int i = 0; i < n; i++) {         total_sum += a[i];       }       if (total_sum < 0 && n == 1) {         cout <<  YES  << endl;         continue;       } else if (total_sum < 0) {         cout <<  NO  << endl;         continue;       }       long long int sum = 0;       long long int max_so_far = 0;       long long int element = 0;       long long int element_f = 0;       for (int i = 0; i < n; i++) {         sum = sum + a[i];         element++;         if (sum <= 0) {           element = 0;           sum = 0;         } else if (sum > max_so_far) {           element_f = element;           max_so_far = sum;         }       }       if (max_so_far >= total_sum && element_f < n)         cout <<  NO  << endl;       else         cout <<  YES  << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int maxn = 1e5 + 3;   int n;   int k;   int A;   int a[maxn];   int ans[maxn];   int main() {     int sum = 0;     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]), sum += a[i];     if (sum % k) {       puts( No );       return 0;     }     sum /= k;     for (int i = 1; i <= n;) {       int now = 0, nowsum = 0;       while (nowsum < sum && i <= n) nowsum += a[i++], ++now;       if (nowsum > sum) {         puts( No );         return 0;       }       ans[++A] = now;     }     puts( Yes );     for (int i = 1; i < A; ++i) printf( %d  , ans[i]);     printf( %d n , ans[A]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   ifstream fi( test.txt );   ifstream fir( inp.txt );   ofstream fo( out.txt );   const long long MOD = 1e9 + 7;   const long long base = 269;   const int ooi = 1 << 30;   const int N = 1e5 + 5;   long long n, m, q, k, pos, rs, t, T, cnt, rs1;   long long maxx = -1e9, minn = 1e9;   long long a[N], b[N];   vector<long long> c[N];   int main() {     cin >> n >> k;     for (long long(i) = 0; (i) < (n); (i)++) {       cin >> a[i];     }     for (long long(i) = 0; (i) < (n); (i)++) {       cin >> b[i];       c[a[i]].push_back(b[i]);     }     for (long long(i) = 1; (i) <= (k); (i)++) {       sort(c[i].begin(), c[i].end());       if (c[i].size()) c[i].pop_back(), cnt++;     }     cnt = k - cnt;     vector<long long> ans;     for (long long(i) = 1; (i) <= (k); (i)++) {       for (long long(j) = 0; (j) < (c[i].size()); (j)++) ans.push_back(c[i][j]);     }     sort(ans.begin(), ans.end());     for (long long(i) = 0; (i) < (cnt); (i)++) rs += ans[i];     cout << rs;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> gr[200011];   vector<long long> v;   vector<long long> v1;   bool vis[200011];   queue<pair<long long, bool> > q;   long long n, m;   void bfs(long long s, bool k) {     q.push({s, k});     while (!q.empty()) {       long long node = q.front().first;       bool z = q.front().second;       q.pop();       if (vis[node]) continue;       if (z)         v.push_back(node);       else         v1.push_back(node);       vis[node] = 1;       for (int i = 0; i < gr[node].size(); i++)         if (!vis[gr[node][i]]) q.push({gr[node][i], !z});     }   }   int main() {     ios::sync_with_stdio(0);     long long q, i, x, y;     cin >> q;     while (q--) {       cin >> n >> m;       for (i = 0; i < m; i++) {         cin >> x >> y;         gr[x].push_back(y);         gr[y].push_back(x);       }       v.clear();       v1.clear();       bfs(1, 0);       if (v.size() <= n / 2) {         cout << v.size() << endl;         for (i = 0; i < v.size(); i++) cout << v[i] <<    ;         cout << endl;       } else {         cout << v1.size() << endl;         for (i = 0; i < v1.size(); i++) cout << v1[i] <<    ;         cout << endl;       }       for (i = 1; i <= n; i++) {         vis[i] = 0;         gr[i].clear();       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   using vc = vector<T>;   template <class T>   using vvc = vc<vc<T>>;   template <class T>   void mkuni(vector<T>& v) {     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());   }   template <class T>   void print(T x, int suc = 1) {     cout << x;     if (suc == 1)       cout <<   n ;     else       cout <<    ;   }   template <class T>   void print(const vector<T>& v, int suc = 1) {     for (int i = 0; i < v.size(); i++)       print(v[i], i == (int)(v.size()) - 1 ? suc : 2);   }   const int INF = 0x3f3f3f3f;   const int maxn = 2e5 + 7;   const int mod = 998244353;   long long quick(long long a, long long b) {     long long ret = 1;     while (b) {       if (b & 1) ret = ret * a % mod;       a = a * a % mod;       b >>= 1;     }     return ret;   }   long long inv(long long a) { return quick(a, mod - 2); }   long long sufm[maxn], sufsum[maxn];   int p[maxn];   long long calc(int l, int r) {     long long ret = sufsum[l] - sufsum[r];     ret = (ret + mod) % mod;     ret = ret * inv(sufm[r]) % mod;     return ret;   }   int main() {     std::ios::sync_with_stdio(false);     cin.tie(nullptr);     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> p[i];     sufm[n + 1] = 1;     for (int i = n; i >= 1; i--) {       sufm[i] = sufm[i + 1] * (100 * inv(p[i]) % mod) % mod;       sufsum[i] = (sufsum[i + 1] + sufm[i]) % mod;     }     long long ans = sufsum[1];     cout << ans << endl;   }
#include <bits/stdc++.h>      using namespace std;   #define  ll long long   #define f first   #define s second   const int N = 2e5+5;      int n , dp[N] , ans;   vector<int> adj[N];      void dfs(int node , int par)   {       vector<int> v;       for(auto ch : adj[node])       {           if (ch==par) continue;           dfs(ch , node);           v.push_back(dp[ch]+1);       }       sort(v.begin() , v.end());          if (v.size())       {           if (node != 1)           {               int mx = v.back() , mn = v[0];               if (adj[node].size() > 1) ans = max(ans , mx+1);                  dp[node] = mn;           }           else           {               int mx = v.back() , mn;               v.pop_back();               if (v.size()) mn = v.back();               else mn = -1; //second maximum                  ans = max(ans , mn+1);               ans = max(ans , mx);               dp[node] = mx;           }       }   }      void clear()   {       ans = 0;       for(int i=1; i<=n; i++)           adj[i].clear() , dp[i] = 0;   }      int main()   {       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);          int t;       cin >> t;       while(t--)       {           cin >> n;           for(int i=1; i<n; i++)           {               int v,u;               cin >> v >> u;               adj[v].push_back(u) , adj[u].push_back(v);           }              dfs(1,1);              cout << ans <<   n ;              clear();       }             return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     int a[n][2];     int l = 0, r = 0;     for (int i = 0; i < n; i++) {       cin >> a[i][0] >> a[i][1];       l += a[i][0];       r += a[i][1];     }     int ans = abs(l - r);     int ind = 0;     int res = ans;     for (int i = 0; i < n; i++) {       int temp;       temp = abs(l - r + 2 * (a[i][1]) - 2 * a[i][0]);       if (temp > res) {         res = temp;         ind = i + 1;       }     }     cout << ind << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e7 + 5;   int l, r, x, y;   char c;   int main() {     cin >> l >> c >> r;     cin >> x >> c >> y;     l = l * 60 + r;     x = x * 60 + y;     l = l - x;     if (l < 0) {       l += 24 * 60;     }     printf( %02d:%02d n , l / 60, l % 60);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int tc;     cin >> tc;     while (tc-- > 0) {       long long int n;       cin >> n;       if (n % 2 == 0) {         long long int a = 2;         long long int b = n / 2;         cout << a <<     << b <<   n ;       } else {         cout << 2 <<     << n - 1 <<   n ;       }     }     return 0;   }