malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       vector<int> s[k];       for (int i = 0; i < k; ++i) {         int c;         cin >> c;         for (int j = 0; j < c; ++j) {           int p;           cin >> p;           s[i].push_back(p);         }       }       cout <<  ?   << n <<    ;       for (int i = 1; i <= n; i++) cout << i <<    ;       cout <<   n ;       int max;       cin >> max;       int l = 1, r = n;       while (l < r) {         int mid = (l + r) / 2;         cout <<  ?   << mid - l + 1 <<    ;         for (int i = l; i <= mid; i++) cout << i <<    ;         cout <<   n ;         int temp;         cin >> temp;         if (temp == max)           r = mid;         else           l = mid + 1;       }       int sind = 0;       for (int i = 0; i < k; ++i) {         for (int j : s[i]) {           if (j == l) {             sind = i;             break;           }         }       }       int smax;       cout <<  ?   << n - s[sind].size() <<    ;       for (int i = 1; i <= n; i++) {         bool flag = true;         for (int j : s[sind])           if (j == i) flag = false;         if (flag) cout << i <<    ;       }       cout <<   n ;       cin >> smax;       cout <<  !  ;       for (int i = 0; i < k; i++) {         if (i == sind)           cout << smax <<    ;         else           cout << max <<    ;       }       cout <<   n ;       string x;       cin >> x;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 + 10;   struct fridge {     int w, id;   } f[maxn];   struct edge {     int u, v;   } e[maxn];   bool cmp(fridge a, fridge b) { return a.w < b.w; }   int n, m, a[maxn], ans, fd[maxn];   int main() {     int t;     cin >> t;     while (t--) {       ans = 0;       cin >> n >> m;       for (int i = 1; i <= n; i++) {         scanf( %d , &a[i]);         ans += a[i];       }       if (m < n || n == 2) {         printf( -1 n );         continue;       }       cout << ans * 2 << endl;       for (int i = 1; i < n; i++) {         printf( %d %d n , i, i + 1);       }       printf( %d %d n , n, 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MX = 1e5 + 9;   long long par[MX], num[MX];   void MS(long long v) { par[v] = v, num[v] = 1; }   long long FS(long long v) {     if (par[v] == v) return v;     return par[v] = FS(par[v]);   }   void US(long long a, long long b) {     a = FS(a), b = FS(b);     if (a == b) return;     if (num[a] < num[b]) swap(a, b);     par[b] = a;     num[a] += num[b];   }   bool lucky(string s) {     for (long long i = 0; i < s.size(); i++)       if (s[i] !=  4  && s[i] !=  7 ) return 0;     return 1;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long n;     cin >> n;     for (long long i = 1; i <= n; i++) MS(i);     for (long long i = 1; i < n; i++) {       long long u, v;       string s;       cin >> u >> v >> s;       if (!lucky(s)) US(u, v);     }     long long ans = 0;     for (long long i = 1; i <= n; i++) {       long long sz = n - num[FS(i)];       ans += sz * (sz - 1);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     long long int k = 1, ans = 1;     cin >> n >> m;     for (int i = 0; i < m; i++) {       k *= 2;       k = k % 1000000009;     }     for (int i = 1; i <= n; i++) {       ans *= (k - i);       ans = ans % 1000000009;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     map<string, vector<string> > mp;     vector<string> v;     string pat;     cin >> pat;     int n;     cin >> n;     for (int i = 0; i < n; i++) {       string tx;       cin >> tx;       v.push_back(tx);     }     sort(v.begin(), v.end());     for (int i = 0; i < n; i++) {       for (int j = 0; j < v[i].length(); j++) {         string pr = v[i].substr(0, j + 1);         mp[pr].push_back(v[i]);       }     }     map<string, vector<string> >::iterator itr = mp.begin();     {       if (mp.find(pat) != mp.end()) {         cout << mp[pat][0] << endl;       } else {         cout << pat << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 7;   const int inf = INT_MAX;   const long long inff = 1e18;   const int mod = 1e9 + 7;   string s, t;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     cout << 0 <<     << 0 << endl;     cout << flush;     cin >> s;     if (n == 1) {       cout << 0 <<     << 1000000000 <<     << 1000000000 <<     << 0 << endl;       cout << flush;       return 0;     }     cout << 1000000000 <<     << 1000000000 << endl;     cout << flush;     cin >> t;     if (n == 2) {       if (s == t)         cout << 1 <<     << 0 <<     << 1000000000 <<     << 1000000000 - 1              << endl;       else         cout << 0 <<     << 1000000000 <<     << 1000000000 <<     << 0 << endl;       cout << flush;       return 0;     }     if (s != t) {       int l = 1, r = 1000000000 - 1;       for (int i = 1; i <= n - 2; i++) {         int m = (l + r) >> 1;         cout << m <<     << 0 << endl;         cout << flush;         string now;         cin >> now;         if (now == s)           l = m + 1;         else           r = m - 1;       }       cout << 0 <<     << l <<     << l <<     << 0 << endl;       cout << flush;       return 0;     } else {       int l = 1, r = 1000000000 - 1;       for (int i = 1; i <= n - 2; i++) {         int m = (l + r) >> 1;         cout << m <<     << 0 << endl;         cout << flush;         string now;         cin >> now;         if (now == s)           l = m + 1;         else           r = m - 1;       }       cout << l <<     << 0 <<     << 1000000000 <<     << 1000000000 - l << endl;       cout << flush;       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a1, b1, a2, b2;     scanf( %d%d%d%d , &a1, &b1, &a2, &b2);     int i;     int two1 = 0, three1 = 0, two2 = 0, three2 = 0;     long long s1 = (long long)a1 * b1, s2 = (long long)a2 * b2;     while (!(s1 % 2)) {       two1++;       s1 /= 2;     }     while (!(s1 % 3)) {       three1++;       s1 /= 3;     }     while (!(s2 % 2)) {       two2++;       s2 /= 2;     }     while (!(s2 % 3)) {       three2++;       s2 /= 3;     }     int t1 = 0, th1 = 0, t2 = 0, th2 = 0;     if (s1 != s2) {       printf( -1 n );       return 0;     }     int ans = 0;     while (three1 > three2) {       three1--;       th1++;       two1++;       t1--;       ans++;       if (a1 % 3 == 0) {         a1 /= 3;         a1 *= 2;       } else if (b1 % 3 == 0) {         b1 /= 3;         b1 *= 2;       }     }     while (three1 < three2) {       three2--;       th2++;       two2++;       t2--;       ans++;       if (a2 % 3 == 0) {         a2 /= 3;         a2 *= 2;       } else if (b2 % 3 == 0) {         b2 /= 3;         b2 *= 2;       } else {         puts( -1 );         return 0;       }     }     while (two1 > two2) {       two1--;       t1++;       ans++;       if (a1 % 2 == 0) {         a1 /= 2;       } else if (b1 % 2 == 0) {         b1 /= 2;       } else {         puts( -1 );         return 0;       }     }     while (two1 < two2) {       two2--;       t2++;       ans++;       if (a2 % 2 == 0) {         a2 /= 2;       } else if (b2 % 2 == 0) {         b2 /= 2;       } else {         puts( -1 );         return 0;       }     }     cout << ans << endl;     printf( %d %d n , a1, b1);     printf( %d %d n , a2, b2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int i = -1, j = -1, k = -1, a[n];       for (int l = 0; l < n; l++) {         cin >> a[l];       }       for (int l = 1; l < n - 1; l++) {         j = l;         for (int m = j - 1; m >= 0; m--) {           if (a[m] < a[j]) {             i = m;             break;           }         }         for (int p = j + 1; p < n; p++) {           if (a[p] < a[j]) {             k = p;             break;           }         }         if (i != -1 && k != -1) {           cout <<  YES n  << i + 1 <<     << j + 1 <<     << k + 1 <<   n ;           break;         } else {           i = -1;           k = -1;         }       }       if (i == -1 or k == -1) {         cout <<  NO               <<   n ;       }     }   }
#include <bits/stdc++.h>   int p[100005];   int main(void) {     int n, m, i, x;     scanf( %d%d , &m, &n);     for (i = 1; i <= n; i++) {       scanf( %d , &x);       x %= m;       if (p[x] == 0)         p[x] = 1;       else {         printf( %d n , i);         return 0;       }     }     return 0 * printf( -1 n );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     map<string, string> mp;     for (int i = 0; i < m; i++) {       string s1, s2;       cin >> s1 >> s2;       if (s2.size() < s1.size())         mp[s1] = s2;       else         mp[s1] = s1;     }     for (int i = 0; i < n; i++) {       string s;       cin >> s;       for (auto it = mp.begin(); it != mp.end(); it++) {         if (it->first == s) {           cout << it->second <<    ;           break;         }       }     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Inf = 0x3f3f3f3f;   const long long INF = 0x3f3f3f3f3f3f3f3fll;   struct Shuffle {     vector<int> S;     Shuffle() {}     Shuffle(int len) {       S.resize(len);       iota((S).begin(), (S).end(), 0);     }     friend inline Shuffle operator*(const Shuffle &a, const Shuffle &b) {       static Shuffle res;       res = Shuffle(((int)(a.S).size()));       for (int i = 0; i < (((int)(a.S).size())); ++i) {         res.S[i] = b.S[a.S[i]];       }       return res;     }   };   int n, m;   char s[1 << 20], t[1 << 20];   int main() {     scanf( %s , s);     n = strlen(s);     scanf( %d , &m);     for (int i = 1; i <= (m); ++i) {       int k, d;       scanf( %d%d , &k, &d);       Shuffle a(n), b(n);       for (int j = 0; j < (n); ++j) a.S[j] = (j + n - 1) % n;       vector<vector<int> > ms(d);       for (int j = 0; j < (k); ++j) ms[j % d].push_back(j);       int cnt = 0;       for (int j = 0; j < (d); ++j)         for (int k = 0; k < (((int)(ms[j]).size())); ++k) {           b.S[ms[j][k]] = cnt++;         }       a = b * a;       b = Shuffle(n);       int tms = n - k + 1;       while (tms) {         if (tms & 1) b = b * a;         tms >>= 1;         a = a * a;       }       for (int j = 0; j < (n); ++j) t[b.S[j]] = s[j];       for (int j = 0; j < (n); ++j) s[j] = t[(j + k - 1) % n];       printf( %s n , s);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool major, minor;   map<string, int> P;   string x, y, z;   int k1, k2;   void go(string x, string y, string z) {     if (P[x] <= P[y])       k1 = P[y] - P[x];     else       k1 = 12 - P[x] + P[y];     if (P[y] <= P[z])       k2 = P[z] - P[y];     else       k2 = 12 - P[y] + P[z];     if (k1 == 4 && k2 == 3)       major = true;     else if (k1 == 3 && k2 == 4)       minor = true;   }   int main(int argc, char *argv[]) {     P[ C ] = 1;     P[ C# ] = 2;     P[ D ] = 3;     P[ D# ] = 4;     P[ E ] = 5;     P[ F ] = 6;     P[ F# ] = 7;     P[ G ] = 8;     P[ G# ] = 9;     P[ A ] = 10;     P[ B ] = 11;     P[ H ] = 12;     major = false;     minor = false;     cin >> x >> y >> z;     go(x, y, z);     go(x, z, y);     go(y, x, z);     go(y, z, x);     go(z, x, y);     go(z, y, x);     if (major)       cout <<  major  << endl;     else if (minor)       cout <<  minor  << endl;     else       cout <<  strange  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   vector<int> p, q;   vector<char> d;   int main() {     cin >> n >> k;     p.resize(n);     q.resize(n);     d.resize(n);     for (int i = 0; i < n; i++) {       cin >> d[i] >> p[i] >> q[i];     }     map<int, int> b, s;     for (int i = 0; i < n; i++) {       if (d[i] ==  S ) {         if (s.find(p[i]) == s.end())           s[p[i]] = q[i];         else           s[p[i]] += q[i];       } else {         if (b.find(-p[i]) == b.end())           b[-p[i]] = q[i];         else           b[-p[i]] += q[i];       }     }     int cnt = s.size();     for (map<int, int>::reverse_iterator it = s.rbegin(); it != s.rend(); it++) {       if (cnt <= k) {         cout <<  S   << it->first <<     << it->second <<   n ;       }       cnt--;     }     cnt = 0;     for (map<int, int>::iterator it = b.begin(); it != b.end(); it++) {       if (cnt < k) {         cout <<  B   << -it->first <<     << it->second <<   n ;       } else         break;       cnt++;     }     cin >> n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 0;     char ch;     vector<bool> v(26, 0);     while (cin >> ch) {       cin >> ch;       if (ch ==  {  || ch ==  }  || ch ==  ,  || ch ==    ) continue;       ch -= 97;       if (!v[ch]) {         v[ch] = true;         n++;       }     }     cout << n;   }
#include <bits/stdc++.h>   using namespace std;   int freq[30];   bool dp[30][200005];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     for (int i = (1); i <= (t); i += (1)) {       int n, m, s;       cin >> n >> m >> s;       string S;       cin >> S;       memset(freq, 0, sizeof(freq));       for (int i = (0); i <= (s - 1); i += (1)) {         freq[S[i] -  A  + 1]++;       }       long long ans = 1000000000000000000;       for (int i = (1); i <= (26); i += (1)) {         if (!freq[i]) continue;         int f = freq[i];         freq[i] = 0;         for (int j = (0); j <= (26); j += (1))           for (int k = (0); k <= (n); k += (1)) dp[j][k] = 0;         dp[0][0] = true;         for (int j = (1); j <= (26); j += (1)) {           for (int k = (0); k <= (n); k += (1)) {             dp[j][k] |= dp[j - 1][k];             if (k >= freq[j]) {               dp[j][k] |= dp[j - 1][k - freq[j]];             }             if (j == 26 && dp[j][k]) {               if (k + f >= n) {                 ans = min(ans, 1LL * (n - k) * min(k + f - n, m - (s - f - k)));               }             }           }         }         for (int j = (0); j <= (26); j += (1))           for (int k = (0); k <= (m); k += (1)) dp[j][k] = 0;         dp[0][0] = true;         for (int j = (1); j <= (26); j += (1)) {           for (int k = (0); k <= (m); k += (1)) {             dp[j][k] |= dp[j - 1][k];             if (k >= freq[j]) {               dp[j][k] |= dp[j - 1][k - freq[j]];             }             if (j == 26 && dp[j][k]) {               if (k + f >= m) {                 ans = min(ans, 1LL * (m - k) * min(k + f - m, n - (s - f - k)));               }             }           }         }         freq[i] = f;       }       for (int j = (0); j <= (26); j += (1))         for (int k = (0); k <= (s); k += (1)) dp[j][k] = 0;       dp[0][0] = true;       for (int j = (1); j <= (26); j += (1)) {         for (int k = (0); k <= (s); k += (1)) {           dp[j][k] |= dp[j - 1][k];           if (k >= freq[j]) {             dp[j][k] |= dp[j - 1][k - freq[j]];           }           if (j == 26 && dp[j][k]) {             if (k >= n && k - n <= s - (n + m) ||                 k >= m && k - m <= s - (n + m)) {               ans = 0;             }           }         }       }       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const int INF = 2e9;   const long long INFLL = 1e18;   const int MAX_N = 20;   int N, M, Q;   string str1[MAX_N + 1], str2[MAX_N + 1];   int main() {     scanf( %d%d , &N, &M);     for (int i = 0; i < N; i++) {       cin >> str1[i];     }     for (int j = 0; j < M; j++) {       cin >> str2[j];     }     scanf( %d , &Q);     for (int i = 1; i <= Q; i++) {       int y;       scanf( %d , &y);       y--;       cout << str1[y % N] << str2[y % M] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 7;   const int MOD = 1e9 + 7;   const int MAXN = 1e6 + 3;   long long gcd(long long a, long long b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   long long power(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = res * x;       y = y >> 1;       x = x * x;     }     return res;   }   long long n;   const int maxn = 1e3 + 3;   long long dp1[2 * maxn][2 * maxn];   long long dp2[2 * maxn][2 * maxn];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     n *= 2;     dp1[0][0] = 0ll;     dp2[0][0] = 1ll;     for (long long i = 1; i <= n; i++) {       for (long long j = 0; j <= i; j++) {         if (j == 0) {           dp2[i][j] = (1 + dp1[i - 1][j + 1]) % MOD;           dp1[i][j] = max(dp1[i - 1][j + 1], dp2[i - 1][j + 1]);         } else if (j == i) {           dp2[i][j] = (1 + dp1[i - 1][j - 1]) % MOD;           dp1[i][j] = max(dp1[i - 1][j - 1], dp2[i - 1][j - 1]);         } else {           dp2[i][j] = (1 + dp1[i - 1][j - 1] + dp1[i - 1][j + 1]) % MOD;           dp1[i][j] = max(dp1[i - 1][j - 1] + dp2[i - 1][j + 1],                           dp1[i - 1][j + 1] + dp2[i - 1][j - 1]) %                       MOD;         }       }     }     cout << dp1[n][0] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int inX[1000001] = {0};   int used[1000001] = {0};   vector<int> ans;   int main() {     int n;     scanf( %d , &n);     vector<int> given(n, 0);     for (int i = 0; i < n; i++) {       scanf( %d , &given[i]);       inX[given[i]] = 1;       used[given[i]] = 1;     }     vector<int> pairLeft;     int reqdPairs = 0;     for (int i = 1; i <= 1000000; i++) {       if (inX[i]) {         if (inX[1000000 + 1 - i] == 0) {           used[1000000 + 1 - i] = 1;           ans.push_back(1000000 + 1 - i);         } else {           reqdPairs += 1;         }       } else {         if (inX[i] == inX[1000000 + 1 - i]) pairLeft.push_back(i);       }     }     for (int i = 0; 2 * i < reqdPairs; i++) {       ans.push_back(pairLeft[i]);       ans.push_back(1000000 + 1 - pairLeft[i]);     }     printf( %d n , (int)ans.size());     for (int i = 0; i < (int)ans.size(); i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int a, b, c;     cin >> n;     int tong = 0, tong1 = 0, tong2 = 0;     for (int i = 0; i < n; i++) {       cin >> a >> b >> c;       tong += a;       tong1 += b;       tong2 += c;     }     if (tong == 0 && tong1 == 0 && tong2 == 0)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(nullptr);     int n, k;     cin >> n >> k;     if ((n - 1) / 2 < k)       cout << -1 <<   n ;     else {       cout << (n * k) <<   n ;       ;       for (int i = 1; i <= n; i++)         for (int j = 0; j < k; j++) cout << i <<     << (i + j) % n + 1 <<   n ;       ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[1003], dp[1003][1003], ans = 1e9 + 10, fr[1003][1003], now;   vector<pair<int, int> > res;   void dfs(int x, int wants) {     if (x == 1) return;     if (x == wants) {       res.push_back(make_pair(x - 1, fr[x][wants]));       dfs(x - 2, fr[x][wants]);     }     if (wants + 1 == x) {       res.push_back(make_pair(x, fr[x][wants]));       dfs(x - 2, fr[x][wants]);     }     if (x != wants && x != wants + 1) {       res.push_back(make_pair(x, x - 1));       dfs(x - 2, fr[x][wants]);     }   }   int main() {     for (int i = 0; i < 1003; i++)       for (int j = 0; j < 1003; j++) dp[i][j] = 1e9 + 10;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     if (n == 1) {       cout << a[1];       cout <<   n1 ;       return 0;     }     if (n == 2) {       cout << max(a[1], a[2]);       cout <<   n1 2 ;       return 0;     }     dp[1][1] = 0;     for (int i = 3; i <= n; i += 2)       for (int j = 1; j < i - 1; j++) {         if (dp[i][j] > dp[i - 2][j] + max(a[i], a[i - 1]))           dp[i][j] = dp[i - 2][j] + max(a[i], a[i - 1]), fr[i][j] = j;         if (dp[i][i - 1] > dp[i - 2][j] + max(a[i], a[j]))           dp[i][i - 1] = dp[i - 2][j] + max(a[i], a[j]), fr[i][i - 1] = j;         if (dp[i][i] > dp[i - 2][j] + max(a[i - 1], a[j]))           dp[i][i] = dp[i - 2][j] + max(a[i - 1], a[j]), fr[i][i] = j;       }     if (n % 2 == 1) {       for (int i = 1; i <= n; i++)         if (ans > dp[n][i] + a[i]) ans = dp[n][i] + a[i], now = i;     } else {       for (int i = 1; i < n; i++)         if (ans > dp[n - 1][i] + max(a[i], a[n]))           ans = dp[n - 1][i] + max(a[i], a[n]), now = i;     }     cout << ans <<   n ;     if (n % 2 == 1) {       dfs(n, now);       reverse(res.begin(), res.end());       for (int i = 0; i < res.size(); i++)         cout << res[i].first <<     << res[i].second <<   n ;       cout << now <<   n ;     } else {       dfs(n - 1, now);       reverse(res.begin(), res.end());       for (int i = 0; i < res.size(); i++)         cout << res[i].first <<     << res[i].second <<   n ;       cout << now <<     << n <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int T;     cin >> T;     for (int i = 0; i < T; i++) {       int N;       cin >> N;       vector<int> vec(N);       for (int j = 0; j < N; j++) {         cin >> vec.at(j);       }       if (vec.at(0) + vec.at(1) <= vec.at(N - 1)) {         cout << 1 <<     << 2 <<     << N << endl;       } else {         cout << -1 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t, n, a, b, i, same, unique, ans;     cin >> t;     while (t--) {       cin >> n;       same = 0;       unique = 0;       unordered_map<long long, long long> m;       for (i = 0; i < n; i++) {         cin >> a;         m[a]++;         if (m[a] == 1) {           unique++;         }         same = max(same, m[a]);       }       if (same < unique + 1) unique--;       ans = min(same, unique);       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) {     if (a > b) {       swap(a, b);     }     if (a == 0) return b;     return gcd(b % a, a);   }   int invertBits(int num) {     int x = log2(num) + 1;     for (int i = 0; i < x; i++) num = (num ^ (1 << i));     return num;   }   string add(string f, string s) {     reverse(f.begin(), f.end());     reverse(s.begin(), s.end());     int i = 0, j = 0;     string t =   ;     int carry = 0;     while (i < f.size() && j < s.size()) {       int k = (f[i] -  0 ) + (s[j] -  0 ) + carry;       carry = k / 10;       int sum = k % 10;       t += (sum +  0 );       i++;       j++;     }     while (i < f.size()) {       int k = (f[i] -  0 ) + carry;       carry = k / 10;       int sum = k % 10;       t += (sum +  0 );       i++;     }     while (j < s.size()) {       int k = (s[j] -  0 ) + carry;       carry = k / 10;       int sum = k % 10;       t += (sum +  0 );       j++;     }     if (carry) {       t += (carry +  0 );     }     reverse(t.begin(), t.end());     return t;   }   int mulmod(int a, int b, int mod) {     int res = 0;     a = a % mod;     while (b > 0) {       if (b % 2 == 1) res = (res + a) % mod;       a = (a * 2) % mod;       b /= 2;     }     return res % mod;   }   int main() {     long long int n;     long long int m = 998244353;     cin >> n;     long long int i, a[n];     for (i = 0; i < n; i++) {       cin >> a[i];     }     long long int ans = 0;     for (i = 0; i < n; i++) {       long long int k = a[i];       long long int mul = 1;       while (k != 0) {         long long int r = k % 10;         ans = (ans % m + ((r % m) * (mul % m) * (n % m)) % m) % m;         mul = mul * 10;         mul = mul % m;         ans = (ans % m + ((r % m) * (mul % m) * (n % m)) % m) % m;         mul = mul * 10;         mul = mul % m;         k = k / 10;       }     }     cout << (ans + m) % m;     return 0;   }