malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct edge {     int u;     int v;     long long cost;     edge() {}     edge(int u, int v, long long c) : u(u), v(v), cost(c) {}   };   long long comb2(long long n) { return (n * (n - 1)) / 2; }   const int MAXN = 100100;   int n;   vector<int> G[MAXN];   edge es[MAXN];   int childNum[MAXN];   long long usedNum[MAXN];   int dfs(int v, int par) {     if (childNum[v] >= 0) return childNum[v];     int ret = 1;     for (int i = 0; i < (int)G[v].size(); i++) {       int next = G[v][i];       if (next != par) ret += dfs(next, v);     }     return childNum[v] = ret;   }   int main(void) {     cin >> n;     for (int i = 0; i < n - 1; i++) {       cin >> es[i].u >> es[i].v >> es[i].cost;       G[es[i].u].push_back(es[i].v);       G[es[i].v].push_back(es[i].u);     }     for (int i = 1; i <= n; i++) childNum[i] = -1;     dfs(1, 0);     double sum = 0;     for (int i = 0; i < n - 1; i++) {       int x = min(childNum[es[i].u], childNum[es[i].v]);       usedNum[i] = 2 * (x * comb2(n - x) + (n - x) * comb2(x));       sum += (double)usedNum[i] * (double)es[i].cost;     }     int q;     long long div = (long long)n * (long long)(n - 1) * (long long)(n - 2) / 6;     cin >> q;     while (q--) {       int id;       long long cost;       cin >> id >> cost;       id--;       long long diff = es[id].cost - cost;       es[id].cost = cost;       sum -= (double)diff * (double)usedNum[id];       printf( %.10lf n , sum / (double)div);     }     return 0;   }
#include <bits/stdc++.h>   const int N = 5e5, mo = 1e6 + 3;   int n, m, i, j, ans;   bool h[N][2], l[N][2];   char s[N];   int main() {     scanf( %d%d , &n, &m);     ans = 1;     for (i = 0; i < n; i++)       for (scanf( %s , s), j = 0; j < m; j++)         if (s[j] !=  . ) {           int x = s[j] - 48;           h[i][(x <= 2) ^ (j & 1)] = 1;           l[j][(x == 1 || x == 4) ^ (i & 1)] = 1;         }     for (i = 0; i < n; i++) ans = ans * (2 - h[i][0] - h[i][1]) % mo;     for (j = 0; j < m; j++) ans = ans * (2 - l[j][0] - l[j][1]) % mo;     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int t = n % 4;     int a = 0;     for (int i = 0; i < 4; i++) {       if ((i * 7) % 4 == t) a = i;     }     int b = -1, c;     for (int j = (n - a) / 4 * 4 + a; j >= a; j -= 4) {       if ((n - 7 * j) % 4 == 0 && (n - 7 * j >= 0)) {         c = j;         b = (n - 7 * j) / 4;         break;       }     }     if (b == -1) {       cout << -1;       return 0;     }     for (int i = 0; i < b; i++) cout << 4;     for (int i = 0; i < c; i++) cout << 7;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class Solution {    public:     void solve(vector<pair<int, int>>& edges, vector<int>& xs, vector<int>& ys,                int n) {       vector<vector<int>> graph(n + 1);       for (auto& p : edges) {         int u = p.first, v = p.second;         graph[u].push_back(v);         graph[v].push_back(u);       }       cout <<  B   << ys[0] << endl;       fflush(stdout);       int root = -1;       cin >> root;       vector<int> dis(n + 1, INT_MAX);       dis[root] = 0;       queue<int> q;       q.push(root);       while (!q.empty()) {         auto u = q.front();         q.pop();         int d = dis[u];         for (auto v : graph[u]) {           if (dis[v] > d + 1) {             dis[v] = d + 1;             q.push(v);           }         }       }       int x = -1;       for (auto v : xs) {         if (x == -1 || dis[x] > dis[v]) {           x = v;         }       }       cout <<  A   << x << endl;       fflush(stdout);       int y = -1;       cin >> y;       bool found = false;       for (auto v : ys) {         if (v == y) {           found = true;           break;         }       }       if (found) {         cout <<  C   << x << endl;       } else {         cout <<  C   << -1 << endl;       }       fflush(stdout);       return;     }   };   int main(int argc, char** argv) {     ios::sync_with_stdio(false);     cin.tie(0);     Solution sol;     int t;     cin >> t;     while (t-- > 0) {       int n;       cin >> n;       vector<pair<int, int>> edges;       edges.reserve(n - 1);       for (int i = 0, u = 0, v = 0; i < n - 1; ++i) {         cin >> u >> v;         edges.emplace_back(u, v);       }       int k;       cin >> k;       vector<int> xs(k);       for (int i = 0; i < k; ++i) {         cin >> xs[i];       }       cin >> k;       vector<int> ys(k);       for (int i = 0; i < k; ++i) {         cin >> ys[i];       }       sol.solve(edges, xs, ys, n);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000 * 1000 * 1000 + 9;   const int MAX_N = 1000 * 1000 + 10;   long long dp1[MAX_N];   int main() {     int n;     scanf( %d , &n);     n /= 2;     if (n == 1) {       printf( %d n , 10);       return 0;     }     dp1[1] = 5;     for (int i = 2; i <= n - 2; i++) dp1[i] = (3 + 2 * dp1[i - 1]) % MOD;     long long dp2 = 1;     for (int i = 0; i < (n - 2); i++)       dp2 = (1 + dp1[n - 2 - i] * (3 + dp2)) % MOD;     dp2 += 5;     dp2 = 1 + dp2 * dp2;     dp2 *= 2;     dp2 %= MOD;     printf( %d n , (int)dp2);     return 0;   }
#include <bits/stdc++.h>   int a[100100];   int f[100100][3];   int s[100100];   char tmp[100100];   int n;   void maximize(int &x, const int &y) {     if (x < y) x = y;   }   void swap(int &a, int &b) {     int sw;     sw = a;     a = b;     b = sw;   }   void init(void) {     scanf( %d , &n);     int i;     for (i = 1; i <= n; i = i + 1) scanf( %d , &a[i]);     scanf( %s , tmp);     for (i = 0; i < n; i = i + 1) s[i + 1] = tmp[i] - 48;     for (i = 1; i <= n; i = i + 1) {       if (i >= n + 1 - i) break;       swap(a[i], a[n + 1 - i]);       swap(s[i], s[n + 1 - i]);     }   }   void optimize(void) {     int i, j, k;     memset(f, -1, sizeof f);     f[0][0] = 0;     for (i = 0; i < n; i = i + 1)       for (j = 0; j < 2; j = j + 1)         if (f[i][j] >= 0)           for (k = 0; k < 2; k = k + 1)             if (j || (k <= s[i + 1]))               maximize(f[i + 1][j || (k < s[i + 1])], f[i][j] + a[i + 1] * k);     if (f[n][0] > f[n][1])       printf( %d , f[n][0]);     else       printf( %d , f[n][1]);   }   int main(void) {     init();     optimize();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long long INF = 1e9 + 9;   const long long N = 500500;   char s[4][4];   long long dot, cross, nought, first_wins, second_wins;   long long first_win_rows, first_win_col, second_win_row, second_win_col;   long long total;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     for (long long i = 1; i <= 3; i++) {       for (long long j = 1; j <= 3; j++) {         cin >> s[i][j];         if (s[i][j] ==  . ) dot++;         if (s[i][j] ==  X ) cross++;         if (s[i][j] ==  0 ) nought++;       }     }     total += cross + nought;     if (!(cross == nought || cross == nought + 1)) {       cout <<  illegal ;       return 0;     }     for (long long i = 1; i <= 3; i++) {       set<char> st;       for (long long j = 1; j <= 3; j++) {         st.insert(s[i][j]);       }       if (st.size() == 1 && *st.begin() ==  X ) {         first_wins++;       }       if (st.size() == 1 && *st.begin() ==  0 ) {         second_wins++;       }     }     for (long long j = 1; j <= 3; j++) {       set<char> st;       for (long long i = 1; i <= 3; i++) {         st.insert(s[i][j]);       }       if (st.size() == 1 && *st.begin() ==  X ) {         first_wins++;       }       if (st.size() == 1 && *st.begin() ==  0 ) {         second_wins++;       }     }     set<char> st;     st.insert(s[1][1]);     st.insert(s[2][2]);     st.insert(s[3][3]);     if (st.size() == 1 && *st.begin() ==  X ) {       first_wins++;     }     if (st.size() == 1 && *st.begin() ==  0 ) {       second_wins++;     }     st.clear();     st.insert(s[1][3]);     st.insert(s[2][2]);     st.insert(s[3][1]);     if (st.size() == 1 && *st.begin() ==  X ) {       first_wins++;     }     if (st.size() == 1 && *st.begin() ==  0 ) {       second_wins++;     }     if (first_wins > 0 && second_wins > 0) {       cout <<  illegal ;       return 0;     }     if (first_wins > 0 || second_wins > 0) {       if (first_wins == 1 && total & 1) {         cout <<  the first player won ;       } else if (second_wins == 1 && total % 2 == 0) {         cout <<  the second player won ;       } else if (first_wins == 2 && total & 1) {         if (first_win_col == 2 || first_win_rows == 2) {           cout <<  illegal ;         } else {           cout <<  the first player won ;         }       } else if (second_wins == 2 && total % 2 == 0) {         if (second_win_col == 2 || second_win_row == 2) {           cout <<  illegal ;         } else {           cout <<  the second player won ;         }       } else {         cout <<  illegal ;       }       return 0;     }     if (dot > 0) {       if (cross == nought)         cout <<  first ;       else         cout <<  second ;     } else {       cout <<  draw ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int mx = 0, sum = 0;   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) {       int a;       cin >> a;       mx = max(mx, a);       sum += a;     }     sum *= 2;     sum += n;     sum /= n;     cout << max(sum, mx) << endl;     return 0;   }
/*    Author : Prakhar Rai    */   #include<bits/stdc++.h>   #define ll long long   #define ld long double   #define LB(x,num) lower_bound(x.begin(),x.end(),num) - x.begin()   #define UB(x,num) upper_bound(x.begin(),x.end(),num) - x.begin()   #define BS(x,num) binary_search(x.begin(),x.end(),num)   #define pb push_back   #define mp make_pair   #define fs first   #define sc second   #define vci vector<int>   #define vcll vector<ll>   #define vcd vector<long double>   #define line(x) sort(x.begin(),x.end())   #define all(x) x.begin(),x.end()   #define newl   n    #define vc vector   #define loop(i,a,b) for(int i = a; i < b; i++)   #define lol(i,a,b) for(ll i = a; i < b; i++)   #define lod(i,a,b) for(ld i = 0; i < b; i++)   #define mod 1000000007   #define read(v,n) lol(i,0,n) {ll x; cin >> x; v.pb(x);}   #define run(a,x) for(auto x : a)   #define yes  YES    #define no  NO    ll cnt;   using namespace std;   // ll dp[10000000];   // memset(dp, -1, sizeof(dp));      void solve() {    ll n; cin >> n;    vcll v;    read(v, n + 2);    sort(all(v));    ll sum = 0;       lol(i, 0, n) {     sum += v[i];    }       if (sum == v[n]) {     lol(i, 0, n) {      cout << v[i] <<    ;     }     cout << newl;     return;    }       sum += v[n];       lol(i, 0, n + 1) {     if (sum - v[i] == v[n + 1]) {      lol(j, 0, n + 1) {       if (i == j) {        continue;       } else {        cout << v[j] <<    ;       }      }      cout << newl;      return;     }    }       cout << -1 << newl;    return;   }      // FILE WITH TEST CASE      void init() {   #ifndef ONLINE_JUDGGE    freopen( input.txt ,  r , stdin);    freopen( output.txt ,  w , stdout);   #endif   }      int main() {   //  init();    ios_base::sync_with_stdio(false); cin.tie(0);    int t; cin >> t;    while (t--)     solve();   }   /* This is my journey and i shall endure the work to reach the top .*/
#include <bits/stdc++.h>   using namespace std;   int play(int n) {     int x = 1;     for (;;) {       if (x * 2 > n)         break;       else         x *= 2;     }     return x / 2;   }   int main() {     int n, b, p, k, x = 1, btl = 0, twl = 0;     scanf( %d %d %d , &n, &b, &p);     twl = n * p;     while (1) {       int pl = play(n);       btl += (2 * b + 1) * pl;       n = pl + n - pl * 2;       if (n == 1) break;     }     cout << btl <<     << twl << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int h, w;     cin >> h >> w;     string line;     char table[h + 2][w + 2];     memset(table,  0 , sizeof table);     for (int i = 1; i <= h; i++) {       cin >> line;       line =     + line;       for (int j = 1; j <= w; j++) {         table[i][j] = line[j];       }     }     int dph[h + 3][w + 3];     int dpv[h + 3][w + 3];     int dp[h + 3][w + 3];     int c = 0;     memset(dp, 0, sizeof dp);     memset(dpv, 0, sizeof dpv);     memset(dph, 0, sizeof dph);     for (int y = 1; y <= h; y++) {       for (int x = 1; x <= w; x++) {         c = 0;         if (table[y][x] ==  . ) {           if (table[y + 1][x] ==  .  && y != h) {             c += 1;             dpv[y][x] = 1;           }           if (table[y][x + 1] ==  .  && x != w) {             dph[y][x] = 1;             c += 1;           }         }         dp[y][x] = dp[y][x - 1] + c;       }     }     int tt;     cin >> tt;     while (tt--) {       int y1, x1, y2, x2, x, y, ans = 0;       cin >> y1 >> x1 >> y2 >> x2;       for (int y = y1; y < y2; y++) {         ans += dp[y][x2 - 1] - dp[y][x1 - 1];       }       for (int x = x1; x < x2; x++) {         ans += dph[y2][x];       }       for (int y = y1; y < y2; y++) {         ans += dpv[y][x2];       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename _T, typename _T2>   string to_string(pair<_T, _T2> x) {     return  <  + to_string(x.first) +  ,   + to_string(x.second) +  > ;   }   template <typename _T>   string to_string(vector<_T> vec) {     string s =  [  ;     for (auto el : vec) s += to_string(el) +  ,  ;     s[s.size() - 1] =  ] ;     s[s.size() - 2] =    ;     return s;   }   template <typename _T>   string to_string(set<_T> vec) {     string s =  {  ;     for (auto el : vec) s += to_string(el) +  ,  ;     s[s.size() - 1] =  } ;     s[s.size() - 2] =    ;     return s;   }   template <typename _T, typename _T2>   string to_string(map<_T, _T2> vec) {     string s =  {  ;     for (auto el : vec)       s +=  mp[  + to_string(el.first) +  ]=   + to_string(el.second) +  ,  ;     s[s.size() - 1] =  } ;     s[s.size() - 2] =    ;     return s;   }   template <typename _T>   inline void _DBG(const char *s, _T x) {     cerr << s <<   =   << to_string(x) <<   n ;   }   template <typename _T, typename... args>   void _DBG(const char *s, _T x, args... a) {     while (*s !=  , ) cerr << *s++;     cerr <<   =   << to_string(x) <<   n ;     _DBG(s + 1, a...);   }   mt19937 rng___(chrono::steady_clock::now().time_since_epoch().count());   const long long MOD = 998244353;   const long long LLINF = 1e18 + 7;   long long d, m;   long long powe(long long n, long long k) {     if (k == 0) return 1;     long long pom = powe(n, k / 2);     pom = (pom * pom) % m;     if (k & 1) pom = (pom * n) % m;     return pom;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     ;     int t;     cin >> t;     while (t--) {       cin >> d >> m;       long long dp[32][32];       for (int i = 0; i < 32; i++)         for (int j = 0; j < 32; j++) dp[i][j] = 0;       dp[0][0] = 1;       long long ans = 0;       for (int i = 1; i < 32; i++) {         for (int j = 1; j < 32; j++) {           int b = j - 1;           if ((1 << b) > d) break;           long long summ = 0;           for (int k = 0; k < j; k++) {             summ += dp[i - 1][k];           }           summ = summ % m;           dp[i][j] = (summ * 1LL * min(d - (1 << b) + 1, 1LL << b)) % m;           ans = (ans + dp[i][j]) % m;         }       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     long long s[100005]{0};     pair<long long, long long> p[100005];     for (int i = 0; i < m; i++) {       int u, v;       long long d;       cin >> u >> v >> d;       u--;       v--;       s[u] -= d;       s[v] += d;     }     for (int i = 0; i < n; i++) p[i] = pair<long long, long long>(s[i], i);     sort(p, p + n);     vector<int> u, v;     vector<long long> d;     int i = 0;     int j = n - 1;     while (i < j) {       if (p[i].first + p[j].first < 0) {         u.push_back(p[i].second);         v.push_back(p[j].second);         d.push_back(p[j].first);         p[i].first += p[j].first;         p[j].first = 0;         j--;       } else if (p[i].first + p[j].first > 0) {         u.push_back(p[i].second);         v.push_back(p[j].second);         d.push_back(-p[i].first);         p[j].first += p[i].first;         p[i].first = 0;         i++;       } else {         if (p[i].first == 0) {           i++;           j--;           continue;         }         u.push_back(p[i].second);         v.push_back(p[j].second);         d.push_back(p[j].first);         p[i].first = 0;         p[j].first = 0;         i++;         j--;       }     }     int l = u.size();     cout << l << endl;     for (int i = 0; i < l; i++)       cout << u[i] + 1 <<     << v[i] + 1 <<     << d[i] << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &res) {     register char ch = getchar();     res = 0;     register int g = 1;     while (!isdigit(ch)) {       if (ch ==  - ) g = -1;       ch = getchar();     }     while (isdigit(ch)) {       res = (res << 3) + (res << 1) + (ch ^ 48);       ch = getchar();     }     res *= g;   }   priority_queue<int> q;   int n, m, a[202000], ans[202000], sum = 0, t = 0;   int main() {     read(n);     read(m);     for (register int i = 1; i <= n; i++) {       read(a[i]);     }     for (register int i = 1; i <= n; i++) {       t = 0;       sum = 0;       while (!q.empty()) q.pop();       for (register int j = 1; j <= i - 1; j++) {         t += a[j];         q.push(a[j]);       }       while (t + a[i] > m) {         t -= q.top();         q.pop();         sum++;       }       printf( %d  , sum);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, i;   long long r, c = 1000000000000000000LL;   void solve(int n, long long x) {     for (int i = 1; i * i <= n; i++)       if (!(n % i)) {         r = max(r, (i + 2LL) * (n / i + 2LL) * x);         c = min(c, (i + 2LL) * (n / i + 2LL) * x);       }   }   int main() {     scanf( %d , &n);     for (int i = 1; i * i <= n; i++)       if ((n % i) == 0) {         solve(i, n / i + 1LL);         solve(n / i, i + 1LL);       }     printf( %I64d %I64d n , c - n, r - n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long i, t, n, m, c, d, a[100005];     cin >> n >> m;     if (n == 1 && m == 0) {       cout << 10000000;       return 0;     }     if (m < n / 2 || n < 2) {       cout << -1;       return 0;     }     c = 1000000000LL;     for (int i = n - 1; i > 1; i--) {       a[i] = c--;     }     int tem;     if (n % 2)       m = m - (n - 3) / 2;     else       m = m - (n - 2) / 2;     a[1] = m;     a[0] = m * 2;     for (__typeof(0) i = 0; i <= n - 1; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, string> p;   int ans = 0;   string tmp =  abcdef ;   void doit(int n, string s) {     if (n == 0) {       int f = 0;       while (true) {         if (s.length() == 2) {           if (p.find(s) == p.end()) {             f = 1;             break;           }           if (p[s] !=  a ) {             f = 1;           }           break;         }         string s1 = s.substr(0, 2);         string s2 =   ;         if (s.length() > 2) {           s2 += s.substr(2, s.length() - 2);         }         if (p.find(s1) == p.end()) {           f = 1;           break;         } else {           s = p[s1] + s2;         }       }       if (f == 0) ans++;       return;     }     for (int i = 0; i < 6; i++) {       string tmp1 = s;       tmp1.push_back(tmp[i]);       doit(n - 1, tmp1);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, q;     cin >> n >> q;     for (int i = 0; i < q; i++) {       string s1, s2;       cin >> s1 >> s2;       p.insert(make_pair(s1, s2));     }     for (int i = 0; i < 6; i++) {       string s;       s.push_back(tmp[i]);       doit(n - 1, s);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long const Mod = 1000000007;   unsigned long long sq_sum(unsigned long long n) {     unsigned long long ret = n;     ret = (n * (n + 1));     ret /= 2;     if (ret % 3 == 0) {       return ((ret / 3) % Mod * (2 * n + 1)) % Mod;     } else {       return ((ret % Mod) * ((2 * n + 1) / 3)) % Mod;     }   }   unsigned long long check(unsigned long long a, unsigned long long b) {     unsigned long long ret = 0;     for (unsigned long long x = b; x < 100000; ++x) {       if (x % b != 0) {         unsigned long long t1 = x / b;         unsigned long long t2 = x % b;         if (t1 % t2 == 0 && t1 / t2 <= a) ret += x;       }     }     return ret;   }   int main() {     unsigned long long a, b;     while (cin >> a >> b) {       cout << (((a * (a + 1) / 2) % Mod * b + a) % Mod *                ((b * (b - 1) / 2) % Mod)) %                   Mod            << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long segs[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};   int n, m, k;   long long a[200005];   vector<pair<int, int> > q;   int res[200005];   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < m; i++) {       int r, t;       cin >> r >> t;       if (q.empty()) {         q.push_back(make_pair(r, t - 1));       } else {         while (!q.empty() && t - 1 >= q.back().second) {           q.pop_back();         }         q.push_back(make_pair(r, t - 1));       }     }     q.push_back(make_pair(1, 0));     int l = 0, r = n - 1, ind = n - 1;     for (int i = 0; i < q.size(); i++) {       if (i == q.size() - 1) {         res[ind] = a[l];         break;       }       if (!i) {         while (r > q[0].second) {           res[r] = a[r];           r--;           ind--;         }         sort(a, a + r + 1);       }       if (q[i].first == 1) {         while (ind > q[i + 1].second) {           res[ind] = a[r];           ind--;           r--;         }       } else {         while (ind > q[i + 1].second) {           res[ind] = a[l];           ind--;           l++;         }       }     }     for (int i = 0; i < n; i++) {       if (i) cout <<    ;       cout << res[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c;   long long exgcd(long long a, long long b, long long& x, long long& y) {     if (b == 0) {       x = 1;       y = 0;       return a;     }     long long d = exgcd(b, a % b, x, y);     long long z = x;     x = y;     y = z - y * (a / b);     return d;   }   int main(int argc, char const* argv[]) {     cin >> a >> b >> c;     long long x, y;     long long d = exgcd(a, b, x, y);     if (c % d) {       cout << -1 << endl;     } else {       x = -c / d * x;       y = -c / d * y;       cout << x <<     << y << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, cn, n, nr, p10;   int main() {     cin >> t;     while (t--) {       cin >> n;       cn = n;       nr = 0;       p10 = 1;       while (cn) {         if (cn % 10) nr++;         cn /= 10;       }       cout << nr <<   n ;       while (n) {         if (n % 10) cout << n % 10 * p10 <<    ;         n /= 10;         p10 *= 10;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, amazing = 0, maxx, minn, k;     cin >> n;     cin >> k;     maxx = k;     minn = k;     for (int i = 1; i < n; i++) {       cin >> k;       if (k > maxx) {         maxx = k;         amazing++;       } else if (k < minn) {         minn = k;         amazing++;       }     }     cout << amazing << endl;     return 0;   }