malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const double eps = 1e-8;   const int nm = 1100005;   int n, k, m, t;   long long res;   int cnt[nm], f[nm][23];   int POW(int x, int z) {     if (z == 0) return 1;     if (z == 1) return x % MOD;     int u = POW(x, z >> 1);     u = ((long long)u * u) % MOD;     if (z % 2) u = ((long long)u * x) % MOD;     return u;   }   int main() {     int i, j, x, y, z, w;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d , &x);       cnt[x]++;     }     for (i = (1 << 20) - 1; i >= 0; i--) {       if (i & 1)         f[i][0] = cnt[i];       else         f[i][0] = cnt[i] + cnt[i + 1];       for (j = 1; j < 20; j++) {         if (i & (1 << j))           f[i][j] = f[i][j - 1];         else           f[i][j] = f[i][j - 1] + f[i + (1 << j)][j - 1];       }     }     for (i = (1 << 20) - 1; i >= 0; i--) {       x = __builtin_popcount(i);       if (x & 1)         res -= POW(2, f[i][19]);       else         res += POW(2, f[i][19]);       res = (res + MOD) % MOD;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct edge {     int u, v;   };   int n, m, k, f[1000000 + 1], ans[1000000 + 1], q[1000000 + 1], lq = 0, rq = -1,                                                                  cur;   edge b[1000000 + 1];   vector<int> a[1000000 + 1], e[1000000 + 1];   bool remoed[1000000 + 1], removeti[1000000 + 1];   void removequeue() {     int x, y;     while (lq <= rq) {       x = q[lq];       lq++;       cur--;       for (int i = 0; i < a[x].size(); i++) {         y = a[x][i];         if (remoed[e[x][i]] == false) {           remoed[e[x][i]] = true;           f[y]--;           if (f[y] < k && removeti[y] == false) {             rq++;             q[rq] = y;             removeti[y] = true;           }         }       }     }   }   void removemany() {     for (int i = 1; i <= n; i++) {       if (f[i] < k) {         rq++;         q[rq] = i;         removeti[i] = true;       }     }     removequeue();   }   void solve() {     removemany();     for (int i = m - 1; i >= 0; i--) {       ans[i] = cur;       if (remoed[i] == false) {         remoed[i] = true;         f[b[i].u]--;         f[b[i].v]--;         if (f[b[i].u] < k && removeti[b[i].u] == false) {           rq++;           q[rq] = b[i].u;           removeti[b[i].u] = true;         }         if (f[b[i].v] < k && removeti[b[i].v] == false) {           rq++;           q[rq] = b[i].v;           removeti[b[i].v] = true;         }       }       removequeue();     }     for (int i = 0; i < m; i++) cout << ans[i] <<   n ;   }   void readit() {     cin >> n >> m >> k;     for (int i = 0; i < m; i++) {       cin >> b[i].u >> b[i].v;       a[b[i].u].push_back(b[i].v);       a[b[i].v].push_back(b[i].u);       e[b[i].u].push_back(i);       e[b[i].v].push_back(i);       f[b[i].u]++;       f[b[i].v]++;     }     cur = n;   }   int main() {     readit();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     for (int k = 0; k < n - 1; k++) {       if (s[k] > s[k + 1]) {         cout <<  YES  << endl;         cout << k + 1 <<     << k + 2;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 + 10;   int main() {     int c, d, n, m, k;     while (scanf( %d %d , &c, &d) != EOF) {       scanf( %d %d , &n, &m);       scanf( %d , &k);       int t = n * m - k;       if (t <= 0) {         printf( 0 n );         continue;       }       int res = t / n;       int ans = min(res * n * d, res * c);       ans += min(c, (t - res * n) * d);       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   long long a[100005], k;   map<long long, long long> tr;   long long getans(const long long k) {     long long t1 = 1, t2 = 0, t3 = 0, t4 = 1, ans = 0;     while (t2 < n) {       ans += (a[t1] - a[t2]) * t3;       ++t3;       t2 = t1;       t1 += t4 * k;       t4 *= k;       if (t1 > n) t1 = n;     }     return ans;   }   int main() {     tr.clear();     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %I64d , &a[i]);       a[i] = -a[i];     }     sort(a + 1, a + n + 1);     a[0] = 0;     for (int i = 1; i <= n; ++i) {       a[i] = -a[i];       a[i] += a[i - 1];     }     scanf( %d , &m);     for (int i = 1; i <= m; ++i) {       scanf( %I64d , &k);       if (i != 1) printf(   );       if (!tr.count(k)) tr[k] = getans(k);       printf( %I64d , tr[k]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> cities[100000];   vector<bool> visited(100000);   vector<int> t(100000), low(100000);   map<pair<int, int>, int> b;   int c = 0, ans = 0;   void dfs(int v, int p = -1) {     visited[v] = true;     t[v] = low[v] = c++;     for (int dest : cities[v]) {       if (dest == p) continue;       if (visited[dest]) {         low[v] = min(low[v], t[dest]);       } else {         dfs(dest, v);         low[v] = min(low[v], low[dest]);         if (low[dest] > t[v]) {           b[{v, dest}] = 1;           b[{dest, v}] = 1;         } else {           b[{v, dest}] = 0;           b[{dest, v}] = 0;         }       }     }   }   vector<long long> dist(100001);   void Dijkstra(int r, int e) {     set<pair<int, int> > s;     dist[r] = 0;     s.insert({0, r});     while (!s.empty()) {       pair<int, int> p = *s.begin();       s.erase(s.begin());       int x = p.first, y = p.second;       if (x > dist[y]) {         continue;       } else if (dist[e] != INT_MAX) {         return;       }       for (int j = 0; j < cities[y].size(); j++) {         if (dist[y] + b[{y, cities[y][j]}] < dist[cities[y][j]]) {           dist[cities[y][j]] = dist[y] + b[{y, cities[y][j]}];           s.insert({dist[cities[y][j]], cities[y][j]});         }       }     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m, k;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       cities[x - 1].push_back(y - 1);       cities[y - 1].push_back(x - 1);     }     c = 0;     t.assign(n, -1);     low.assign(n, -1);     visited.assign(n, false);     for (int i = 0; i < n; ++i) {       if (!visited[i]) {         dfs(i);       }     }     cin >> k;     for (int i = 0; i < k; i++) {       ans = 0;       dist.assign(n, INT_MAX);       int root, shop;       cin >> root >> shop;       Dijkstra(root - 1, shop - 1);       cout << dist[shop - 1] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int y, w, x, counter = 0;     cin >> y >> w;     x = max(y, w);     for (int i = x; i <= 6; i++) {       counter++;     }     if (counter == 0)       cout <<  0/1 ;     else if (counter == 1)       cout <<  1/6 ;     else if (counter == 2)       cout <<  1/3 ;     else if (counter == 3)       cout <<  1/2 ;     else if (counter == 4)       cout <<  2/3 ;     else if (counter == 5)       cout <<  5/6 ;     else       cout <<  1/1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 1;     char c = getchar();     while ((c <  0  || c >  9 ) && (c !=  - )) c = getchar();     if (c ==  - ) f = -1, c = getchar();     while (c >=  0  && c <=  9 ) x = x * 10 + c -  0 , c = getchar();     return x * f;   }   const int N = 2e5 + 10;   int n, m, Ans[N];   pair<int, int> a[N], b[N];   inline long long Query(int x) {     long long ret = 0;     if (x < 0) {       x = -x;       for (register int i = (1); i <= (x); i++)         ret += m - a[n - x + i].first + b[i].first,             Ans[a[n - i + 1].second] = b[i].second;       for (register int i = (x + 1); i <= (n); i++)         ret += abs(b[i].first - a[i - x].first),             Ans[a[i - x].second] = b[i].second;     } else {       for (register int i = (1); i <= (x); i++)         ret += a[i].first + m - b[n - x + i].first,             Ans[a[i].second] = b[n - x + i].second;       for (register int i = (x + 1); i <= (n); i++)         ret += abs(a[i].first - b[i - x].first),             Ans[a[i].second] = b[i - x].second;     }     return ret;   }   int main() {     m = read(), n = read();     for (register int i = (1); i <= (n); i++) a[i] = make_pair(read(), i);     for (register int i = (1); i <= (n); i++) b[i] = make_pair(read(), i);     sort(a + 1, a + 1 + n), sort(b + 1, b + 1 + n);     int l = -n, r = n;     while (l < r) {       int mid = l + r >> 1;       if (Query(mid) < Query(mid + 1))         r = mid;       else         l = mid + 1;     }     printf( %lld n , Query(l));     for (register int i = (1); i <= (n); i++) printf( %d  , Ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   long long ma, n, i, j, temp;   long long mi = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;   int main() {     cin >> n;     for (i = 1; i * i * i <= n; i++)       if (n % i == 0)         for (j = i; j * j <= n / i; j++)           if ((n / i) % j == 0) {             temp = (n / i) / j;             ma = max(ma, (i + 2) * (j + 2) * (temp + 1));             ma = max(ma, (i + 2) * (j + 1) * (temp + 2));             ma = max(ma, (i + 1) * (j + 2) * (temp + 2));             mi = min(mi, (i + 2) * (j + 2) * (temp + 1));             mi = min(mi, (i + 2) * (j + 1) * (temp + 2));             mi = min(mi, (i + 1) * (j + 2) * (temp + 2));           }     cout << mi - n <<     << ma - n << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using vi = vector<int>;   using ii = pair<int, int>;   template <typename A, typename B>   ostream& operator<<(ostream& os, pair<A, B> p) {     return os <<  {  << p.first <<  ,   << p.second <<  } ;   }   const int oo = 0x3f3f3f3f;   const ll OO = ll(oo) * oo;   const ll M = 1e9 + 9;   ll p2[100005];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int m;     cin >> m;     ll k = 1;     for (int i = 0; i < m + 1; i++) {       p2[i] = k;       k <<= 1ll;       k %= M;     }     ll ans = 1;     for (int i = 0; i < n; i++) {       if (p2[m] - i - 1 <= 0) {         cout << 0 << endl;         return 0;       }       ans *= (p2[m] - i - 1) % M;       ans %= M;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int a[5005];   int solve(int i, int j) {     int k, vans, hans, mini, s, t;     vans = j - i + 1;     mini = a[i];     for (k = i + 1; k <= j; k++)       if (mini > a[k]) mini = a[k];     hans = mini;     for (k = i; k <= j; k++) a[k] -= mini;     hans = mini;     for (k = i; k <= j;) {       if (a[k] == 0) {         k++;       } else {         s = k;         t = s;         while (t <= j && a[t] != 0) t++;         hans += solve(s, t - 1);         k = t;       }     }     if (vans < hans)       return vans;     else       return hans;   }   int main() {     int n, i;     int vans, hans;     int ans;     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     ans = solve(1, n);     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( Ofast )   #pragma GCC optimize( O3 )   const long long inf = 1e17;   void bfs(int a, vector<vector<int> > &g, vector<int> &da) {     int n = g.size();     queue<int> q;     q.push(a);     vector<bool> u(n, false);     u[a] = true;     da[a] = 0;     while (!q.empty()) {       int v = q.front();       q.pop();       for (int i = 0; i < g[v].size(); i++) {         int x = g[v][i];         if (!u[x]) {           u[x] = true;           da[x] = da[v] + 1;           q.push(x);         }       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int q;     cin >> q;     while (q--) {       int n, m, a, b, c;       cin >> n >> m >> a >> b >> c;       a--;       b--;       c--;       vector<vector<int> > g(n, vector<int>(0));       vector<long long> cost(m);       for (int i = 0; i < m; i++) cin >> cost[i];       sort(cost.begin(), cost.end());       for (int i = 1; i < m; i++) cost[i] += cost[i - 1];       vector<int> da(n, 0), db(n, 0), dc(n, 0);       for (int i = 0; i < m; i++) {         int fr, to;         cin >> fr >> to;         fr--;         to--;         g[fr].push_back(to);         g[to].push_back(fr);       }       bfs(a, g, da);       bfs(b, g, db);       bfs(c, g, dc);       long long ans = inf;       for (int i = 0; i < n; i++) {         if (da[i] + db[i] + dc[i] - 1 > m - 1) continue;         long long cur = 0;         if (da[i] + db[i] + dc[i] != 0) cur += cost[da[i] + db[i] + dc[i] - 1];         if (db[i] > 0) cur += cost[db[i] - 1];         ans = min(ans, cur);       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cache[1005][20][2];   int ret[1005];   int n;   vector<int> ans(1005, INT_MAX);   void query(vector<int> &arr) {     if (!arr.empty()) {       printf( %lu n , arr.size());       for (auto &x : arr) printf( %i  , x);       printf(  n );       fflush(stdout);       for (int x = 1; x <= n; x++) scanf( %i , &ret[x]);     } else       memset(ret, 0, sizeof ret);   }   int main() {     scanf( %i , &n);     for (int x = 2, y = 1; x < 2 * n; x *= 2, y++) {       vector<int> w;       for (int z = 1; z <= n; z += x)         for (int a = 0; a < x / 2 && z + a <= n; a++) w.push_back(z + a);       query(w);       for (int z = 1; z <= n; z++) cache[z][y][0] = ret[z];       w.clear();       for (int z = 1 + x / 2; z <= n; z += x)         for (int a = 0; a < x / 2 && z + a <= n; a++) w.push_back(z + a);       query(w);       for (int z = 1; z <= n; z++) cache[z][y][1] = ret[z];     }     printf( -1 n );     for (int z = 1; z <= n; z++) {       for (int x = 2, y = 1; x < 2 * n; x *= 2, y++) {         for (int a = 0; a <= 1; a++)           if (((z - 1) >> (y - 1) & 1) != a) ans[z] = min(ans[z], cache[z][y][a]);       }       printf( %i  , ans[z]);     }     printf(  n );     fflush(stdout);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 110000;   int a[N], wei[N], r1, r2;   bool can[N], ans[N];   int n, m;   int main() {     int t;     scanf( %d , &t);     while (t--) {       scanf( %d%d , &n, &m);       n--;       for (int i = (1); i <= (int)m; i++) {         scanf( %d , &a[i]);         wei[i] = a[i];         ans[i] = 0;         can[i] = 1;       }       r1 = r2 = 0;       int shiwang = 0;       for (int i = (1); i <= (int)n; i++) {         int x, y;         scanf( %d%d , &x, &y);         if (y == 1) {           if (!shiwang) shiwang = i;         }         if (!shiwang && x == 0) r1++;         if (x == 0) r2++;         if (shiwang) can[x] = 0;         a[x]--;         if (!shiwang) wei[x]--;       }       if (!shiwang) {         for (int i = (1); i <= (int)m; i++)           if (a[i] <= r2)             printf( Y );           else             printf( N );         printf(  n );       } else {         int lu = 0;         for (int i = (1); i <= (int)m; i++)           if (can[i] && wei[i] <= r1) {             ans[i] = 1;             if (r2 - wei[i] > lu) lu = r2 - wei[i];           }         for (int i = (1); i <= (int)m; i++) {           if (a[i] <= lu) ans[i] = 1;           if (ans[i])             printf( Y );           else             printf( N );         }         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long, long long> > A, B;   void getDivisors(long long x, vector<pair<long long, long long> > &X) {     for (long long i = 1; i * i <= x; i++) {       if (x % i) continue;       X.push_back({i, x / i});     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL), cout.tie(NULL);     long long a, b;     cin >> a >> b;     long long area = a + b;     getDivisors(a, A);     getDivisors(b, B);     long long lim = 0;     while (lim * lim <= area) lim++;     for (long long i = lim - 1; i >= 1; i--) {       if (area % i) continue;       int f = 0;       long long x = i;       long long y = area / i;       int ptr =           lower_bound(A.begin(), A.end(), make_pair(x + 1, 0LL)) - A.begin();       if (ptr > 0 && A[ptr - 1].second <= y) f = 1;       ptr = lower_bound(B.begin(), B.end(), make_pair(x + 1, 0LL)) - B.begin();       if (ptr > 0 && B[ptr - 1].second <= y) f = 1;       if (f == 1) {         cout << (x + y) * 2 <<   n ;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 60;   vector<int> adj[maxn];   int n, m;   void read() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       int a, b;       scanf( %d%d , &a, &b);       a--, b--;       adj[a].push_back(b);       adj[b].push_back(a);     }   }   bool vis[maxn];   vector<int> ch;   void dfs(int v) {     vis[v] = 1;     ch.push_back(v);     for (int i = 0; i < int(adj[v].size()); i++) {       int nxt = adj[v][i];       if (!vis[nxt]) dfs(nxt);     }   }   void solve() {     memset(vis, 0, sizeof(vis));     if (m > n) {       puts( NO );       return;     } else if (m == n) {       dfs(0);       for (int i = 0; i < n; i++) {         if (!vis[i] || int(adj[i].size()) != 2) {           puts( NO );           return;         }       }       puts( YES n0 );       return;     } else {       for (int i = 0; i < n; i++) {         if (int(adj[i].size()) > 2) {           puts( NO );           return;         }       }       set<pair<int, int> > line;       for (int i = 0; i < n; i++) {         if (vis[i]) continue;         if (int(adj[i].size()) == 0) {           line.insert(make_pair(i, i));           vis[i] = 1;         }         if (int(adj[i].size()) == 1) {           ch.clear();           dfs(i);           line.insert(make_pair(ch.front(), ch.back()));         }       }       for (int i = 0; i < n; i++) {         if (!vis[i]) {           puts( NO );           return;         }       }       vector<pair<int, int> > ans;       while (int(line.size())) {         if (int(line.size()) == 1) {           ans.push_back(*line.begin());           line.erase(line.begin());         } else {           pair<int, int> a = *line.begin();           line.erase(line.begin());           pair<int, int> b = *line.begin();           line.erase(line.begin());           ans.push_back(make_pair(a.first, b.first));           line.insert(               make_pair(min(a.second, b.second), max(a.second, b.second)));         }       }       puts( YES );       printf( %d n , int(ans.size()));       for (int i = 0; i < int(ans.size()); i++) {         printf( %d %d n , ans[i].first + 1, ans[i].second + 1);       }     }   }   int main() {     read();     solve();   }
#include <bits/stdc++.h>   using namespace std;   vector<int> ed[2000];   int sho[1200][1200];   int col[1200];   int n, m;   int makk[1200];   int sp[1200];   void dfs(int v, int ccc) {     sp[v] = ccc;     for (int a = 0; a < ed[v].size(); a++) {       if (sp[ed[v][a]] == -1) dfs(ed[v][a], ccc);     }   }   void getsho(int v) {     int q[3000];     int dp[3000];     int c[3000];     for (int a = 0; a < n; a++) c[a] = -1;     q[0] = v;     dp[0] = 0;     c[v] = 1;     int bb = 0;     int ee = 0;     while (bb <= ee) {       int vx = q[bb];       sho[v][vx] = dp[bb];       for (int a = 0; a < ed[vx].size(); a++) {         if (c[ed[vx][a]] == -1) {           int vu = ed[vx][a];           c[vu] = 1;           ee++;           q[ee] = vu;           dp[ee] = dp[bb] + 1;         }       }       bb++;     }   }   int isok;   void kolo(int v, int c) {     col[v] = c;     for (int a = 0; a < ed[v].size(); a++) {       if (col[ed[v][a]] == c)         isok = 0;       else if (col[ed[v][a]] == -1)         kolo(ed[v][a], 1 - c);     }   }   int main() {     cin >> n >> m;     for (int a = 0; a < 1200; a++) makk[a] = 0;     isok = 1;     int x, y;     for (int a = 0; a < n; a++)       for (int b = 0; b < n; b++) sho[a][b] = 1000000;     for (int a = 0; a < m; a++) {       cin >> x >> y;       ed[x - 1].push_back(y - 1);       ed[y - 1].push_back(x - 1);     }     for (int a = 0; a < 1100; a++) col[a] = -1;     kolo(0, 0);     if (!isok) {       cout << -1;       return 0;     }     for (int a = 0; a < n; a++) sp[a] = -1;     int ccc = -1;     for (int a = 0; a < n; a++) {       if (sp[a] == -1) {         ccc++;         dfs(a, ccc);       }     }     for (int a = 0; a < n; a++) getsho(a);     int mini = 0;     for (int a = 0; a < n; a++) {       for (int b = a + 1; b < n; b++) {         if (sp[a] == sp[b] && sho[a][b] > makk[sp[a]] && sho[a][b] < 100000)           makk[sp[a]] = sho[a][b];       }     }     int ss = 0;     for (int a = 0; a < 1200; a++) ss += makk[a];     cout << ss;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300 * 1000 + 20;   int n, a[N];   multiset<int> e;   long long ans;   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) {       if (e.size())         if (*e.begin() < a[i]) {           ans += a[i] - *e.begin();           e.erase(e.begin());           e.insert(a[i]);         }       e.insert(a[i]);     }     return cout << ans << endl, 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long max2(long long a, long long int b) {     return (a) > (b) ? (a) : (b);   }   inline long long max3(long long a, long long b, long long c) {     return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c));   }   inline long long min2(long long a, long long b) {     return (a) < (b) ? (a) : (b);   }   inline long long min3(long long a, long long b, long long c) {     return (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c));   }   using namespace std;   const long long modu = 998244353;   long long dr8[] = {0, 0, 1, -1, 1, 1, -1, -1};   long long dc8[] = {1, -1, 0, 0, -1, 1, -1, 1};   long long dr4[] = {0, 1, -1, 0};   long long dc4[] = {1, 0, 0, -1};   inline void deb_vi(vector<long long> a) {     for (long long i = 0; i < a.size(); i++) cout << a[i] <<    ;   }   inline void deb_vll(vector<long long> a) {     for (long long i = 0; i < a.size(); i++) cout << a[i] <<    ;   }   inline bool is_palindrome(const string& s) {     return std::equal(s.begin(), s.end(), s.rbegin());   }   using namespace std::chrono;   long long power(long long a, long long b) {     long long result = 1;     while (b) {       if (b & 1) result = result * a % modu;       a = (a * a) % modu;       b /= 2;       result %= modu;     }     return result;   }   long long fun1(string s) {     long long ans = 0;     long long l = s.length() - 1;     long long exp = 0;     for (long long i = l; i >= 0; i--) {       ans = (s[i] -  0 ) % modu * power(10, exp) + ans;       ans %= modu;       exp += 2;     }     return ans % modu;   }   long long fun2(string s) {     long long ans = 0;     long long l = s.length() - 1;     long long exp = 1;     for (long long i = l; i >= 0; i--) {       ans = (s[i] -  0 ) % modu * power(10, exp) + ans;       ans %= modu;       exp += 2;     }     return ans % modu;   }   int32_t main() {     auto start = high_resolution_clock::now();     {       long long n;       cin >> n;       string a[n];       long long ans = 0;       for (long long i = 0; i < n; i++) {         cin >> a[i];         long long t1 = fun1(a[i]) * n;         t1 %= modu;         long long t2 = fun2(a[i]) * n;         t2 %= modu;         ans += (t1 + t2);         ans %= modu;       }       cout << (ans + modu) % modu;     }     auto stop = high_resolution_clock::now();     auto duration = duration_cast<microseconds>(stop - start);     return 0;   }