malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   const int INFMEM = 63;   const int INF = 1061109567;   const long long LINF = 4557430888798830399LL;   const double DINF = numeric_limits<double>::infinity();   const long long MOD = 1000000007;   const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};   const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};   const double PI = 3.141592653589793;   inline void open(string a) {     freopen((a +  .in ).c_str(),  r , stdin);     freopen((a +  .out ).c_str(),  w , stdout);   }   inline void fasterios() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   long long cnt[1000005];   pair<long long, long long> isi[100005];   bool isAscent[100005];   int main() {     fasterios();     long long n;     cin >> n;     long long cntascent = 0;     for (int i = 1; i <= n; i++) {       long long k;       cin >> k;       pair<long long, long long> cur;       long long pre = -1;       bool ascent = 0;       for (int j = 1; j <= k; j++) {         long long tmp;         cin >> tmp;         if (j == 1) {           cur.first = cur.second = tmp;           pre = tmp;         } else {           if (pre < tmp) ascent = 1;           pre = tmp;         }         cur.first = min(cur.first, tmp);         cur.second = max(cur.second, tmp);       }       isi[i] = cur;       if (!ascent) cnt[cur.first]++;       isAscent[i] = ascent;       cntascent += ascent;     }     for (int i = 0; i <= 1000000; i++) cnt[i] += cnt[i - 1];     long long ans = 0;     for (int i = 1; i <= n; i++) {       if (isAscent[i]) {         ans += n;         continue;       }       long long now = isi[i].second;       ans += cnt[now - 1];       ans += cntascent;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> m;   vector<int> fr;   int v[100100];   int main() {     int n;     scanf( %d  , &n);     int mf = 0;     for (int i = 0; i < n; i++) {       int t;       scanf( %d  , &t);       v[i] = t;       m[t]++;       mf = max(mf, m[t]);     }     sort(begin(v), end(v));     fr.assign(mf + 2, 0);     for (auto& it : m) {       fr[it.second - 1]++;     }     int rs = 0;     int ma = 0;     for (int i = fr.size() - 2; i >= 0; i--) {       fr[i] = fr[i + 1] + fr[i];     }     for (int i = 0; i < fr.size(); i++) {       rs += fr[i];       ma = max(ma, rs - i - 1);     }     printf( %d n , ma);   }
#include <bits/stdc++.h>   using namespace std;   long long numC[200011];   long long numQ[200011];   long long numBC[200011];   long long numBQ[200011];   long long numQC[200011];   long long numQQ[200011];   long long triple(int n) {     if (n < 0) return 0;     if (n == 1) return 3;     if (n == 0) return 1;     long long temp = triple(n / 2);     long long res = (temp * temp) % 1000000007;     if (n % 2 == 0)       return res;     else       return (res * 3) % 1000000007;   }   int main() {     int n;     string str;     cin >> n >> str;     int qNum = 0;     for (int i = 0; i < n; i++)       if (str[i] ==  ? ) qNum++;     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  c )         numC[i] = numC[i + 1] + 1;       else         numC[i] = numC[i + 1];     }     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  ? )         numQ[i] = numQ[i + 1] + 1;       else         numQ[i] = numQ[i + 1];     }     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  b )         numBC[i] = numBC[i + 1] + numC[i + 1];       else         numBC[i] = numBC[i + 1];       numBC[i] %= 1000000007;     }     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  b )         numBQ[i] = numBQ[i + 1] + numQ[i + 1];       else         numBQ[i] = numBQ[i + 1];       numBQ[i] %= 1000000007;     }     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  ? )         numQC[i] = numQC[i + 1] + numC[i + 1];       else         numQC[i] = numQC[i + 1];       numQC[i] %= 1000000007;     }     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  ? )         numQQ[i] = numQQ[i + 1] + numQ[i + 1];       else         numQQ[i] = numQQ[i + 1];       numQQ[i] %= 1000000007;     }     long long t1 = 0;     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  a ) t1 += numBC[i + 1];     t1 %= 1000000007;     long long t2 = 0;     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  a ) t2 += numQC[i + 1];     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  a ) t2 += numBQ[i + 1];     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  ? ) t2 += numBC[i + 1];     t2 %= 1000000007;     long long t3 = 0;     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  a ) t3 += numQQ[i + 1];     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  ? ) t3 += numBQ[i + 1];     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  ? ) t3 += numQC[i + 1];     t3 %= 1000000007;     long long t4 = 0;     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  ? ) t4 += numQQ[i + 1];     t4 %= 1000000007;     long long ans = (t1 * triple(qNum)) % 1000000007 +                     (t2 * triple(qNum - 1)) % 1000000007 +                     (t3 * triple(qNum - 2)) % 1000000007 +                     (t4 * triple(qNum - 3)) % 1000000007;     cout << ans % 1000000007;   }
#include <bits/stdc++.h>   using namespace std;   int sol[123123];   int on[123123];   int matrix[142][142];   int matrix_2[142][142];   int main() {     int n, m, h;     cin >> n >> m >> h;     for (int i = 1; i <= m; i++) cin >> on[i];     for (int i = 1; i <= n; i++) cin >> sol[i];     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         cin >> matrix[i][j];         matrix_2[i][j] = 31231212;       }     for (int i = 1; i <= m; i++)       for (int j = 1; j <= n; j++)         if (matrix_2[j][i] > on[i]) matrix_2[j][i] = on[i];     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (matrix_2[i][j] > sol[i]) matrix_2[i][j] = sol[i];     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++)         if (matrix[i][j])           cout << matrix_2[i][j] <<    ;         else           cout <<  0  ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug& operator<<(const c&) {       return *this;     }   };   const int MAX_N = 1e5 + 7;   void solve() {     int n;     cin >> n;     vector<int> a(n);     vector<int> srt(n + 1);     srt.assign(n + 1, 0);     for (long long i = 0; i < int(n); i++) {       cin >> a[i];       srt[a[i]]++;     }     int res = 0;     for (int i = 0; i < n; ++i) {       long long sum = 0, cnt = 0;       for (int j = i; j < n; ++j) {         sum += a[j];         cnt++;         if (sum <= n && srt[sum] > 0 && cnt > 1) {           res += srt[sum];           srt[sum] = 0;         }       }     }     cout << res <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 155;   int f[maxn][maxn * maxn], a[maxn];   int n, K, s, ans = 2e9, cur;   void solve() {     sort(a + 1, a + n + 1);     ans = 0;     for (int i = 1; i <= K; i++) ans += a[i];     printf( %d n , ans);   }   int main() {     scanf( %d%d%d , &n, &K, &s);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     if (s >= n * (n - 1) / 2) {       solve();       return 0;     }     memset(f, 0x3f, sizeof f);     f[0][0] = 0;     for (int j = 1; j <= n; j++)       for (int i = K - 1; i >= 0; i--)         for (int k = 0; k <= min(s, n * i); k++)           f[i + 1][k + j - (i + 1)] =               min(f[i + 1][k + j - (i + 1)], f[i][k] + a[j]);     for (int i = 0; i <= s; i++) ans = min(ans, f[K][i]);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long one = 1;   const long long INF = 2e18;   const long long MOD = 1e9 + 7;   const long long N = 40040 + 10;   const long long nul = 0;   signed main() {     vector<long long> cnt(6);     for (long long &i : cnt) cin >> i;     vector<pair<pair<long long, long long>, long long> > smth;     long long n;     cin >> n;     map<string, long long> dict;     dict[ S ] = 0;     dict[ M ] = 1;     dict[ L ] = 2;     dict[ XL ] = 3;     dict[ XXL ] = 4;     dict[ XXXL ] = 5;     bool can = 0;     vector<string> sz = { S ,  M ,  L ,  XL ,  XXL ,  XXXL };     vector<string> ans(n);     for (long long i = 0; i < n; i++) {       string s;       cin >> s;       string now =   ;       pair<long long, long long> q;       bool flag = 0;       for (char i : s) {         if (i ==  , ) {           q.first = dict[now];           now =   ;           flag = 1;         } else {           now += i;         }       }       if (flag) {         q.second = dict[now];         if (q.second < q.first) {           swap(q.first, q.second);         }         smth.push_back({q, i});       } else {         if (cnt[dict[now]] == 0) {           can = 1;         } else {           cnt[dict[now]]--;           ans[i] = now;         }       }     }     if (can)       cout <<  NO n ;     else {       sort((smth).begin(), (smth).end());       for (auto i : smth) {         long long one = i.first.first, two = i.first.second;         if (cnt[one] == 0) {           if (cnt[two] == 0) {             can = 1;             break;           } else {             ans[i.second] = sz[two];             cnt[two]--;           }         } else {           ans[i.second] = sz[one];           cnt[one]--;         }       }       if (can)         cout <<  NO n ;       else {         cout <<  YES n ;         for (auto i : ans) cout << i << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   inline int IN() {     char c;     register int first = 0;     for (; (c = getchar()) < 48 && c ^  -  || c > 57;)       ;     bool f = c ==  - ;     if (f) (c = getchar());     for (; c > 47 && c < 58; (c = getchar()))       first = (first << 3) + (first << 1) + c - 48;     if (f) first = -first;     return first;   }   inline void glance() { freopen( ha.in ,  r , stdin); }   int root, last, node, n, ans, L, R, seg_node, go[400010][26];   vector<int> li[400010];   typedef int Arr[400010];   Arr len, par, dp, rt, sky, sad;   int l[8000000], r[8000000];   inline void init() { node = root = last = 1; }   inline void append(int w) {     int p = last, u = ++node;     len[u] = len[p] + 1;     sad[u] = 1;     sky[u] = len[u];     for (; p && !go[p][w]; p = par[p]) go[p][w] = u;     if (!p)       par[u] = root;     else {       int t = go[p][w];       if (len[t] == len[p] + 1)         par[u] = t;       else {         int nt = ++node;         for (int _r = 26, i = 0; i < _r; ++i) go[nt][i] = go[t][i];         len[nt] = len[p] + 1;         par[nt] = par[t];         par[t] = par[u] = nt;         sky[nt] = len[u];         for (; p && go[p][w] == t; p = par[p]) go[p][w] = nt;       }     }     last = u;   }   int Merge(int u, int v) {     if (!u || !v) return u + v;     int first = ++seg_node;     l[first] = Merge(l[u], l[v]);     r[first] = Merge(r[u], r[v]);     return first;   }   void ins(int v, int &u, int ll, int rr, int pos) {     u = ++seg_node;     l[u] = l[v];     r[u] = r[v];     if (ll == rr) return;     int mm = ll + rr >> 1;     if (pos <= mm)       ins(l[v], l[u], ll, mm, pos);     else       ins(r[v], r[u], mm + 1, rr, pos);   }   bool Qs(int u, int ll, int rr) {     if (!u) return 0;     if (L <= ll && rr <= R) return 1;     int mm = ll + rr >> 1;     bool res = 0;     if (L <= mm) res = Qs(l[u], ll, mm);     if (R > mm) res = res || Qs(r[u], mm + 1, rr);     return res;   }   void dfs(int u) {     for (int v : li[u]) dfs(v), rt[u] = Merge(rt[u], rt[v]);     if (sad[u]) ins(rt[u], rt[u], 1, n, sky[u]);   }   void DFS(int u, int jc) {     for (int v : li[u]) {       if (u == root) {         dp[v] = 1;         DFS(v, v);       } else {         L = sky[v] - len[v] + len[jc];         R = sky[v] - 1;         if (L <= R && Qs(rt[jc], 1, n))           ans = max(ans, dp[v] = dp[jc] + 1), DFS(v, v);         else           DFS(v, jc);       }     }   }   int main() {     n = IN();     init();     for (char c; isalpha((c = getchar()));) append(c -  a );     for (int _r = node, i = 2; i <= _r; ++i) li[par[i]].push_back(i);     dfs(root);     ans = 1;     DFS(root, 0);     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N, tot = 0, i, temp1, temp2, temp3, fin;     char inp1[1005], inp2[1005];     scanf( %d%s%s , &N, inp1, inp2);     for (i = 0; i < N; i++) {       temp1 = abs(inp1[i] - inp2[i]);       temp2 = abs( 9  - inp1[i]) + (inp2[i] -  0 ) + 1;       temp3 = abs(inp1[i] -  0 ) + ( 9  - inp2[i]) + 1;       fin = min(min(temp1, temp2), temp3);       tot += fin;     }     printf( %d n , tot);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using pii = pair<int, int>;   const int N = 2e3 + 7, Max = 1e6 + 7;   int n, m, res;   pii a[N], b[N];   int surf[Max];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     while (t--) {       res = 1e9;       fill(surf, surf + Max, 0);       cin >> n >> m;       for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second;       for (int i = 1; i <= m; ++i) cin >> b[i].first >> b[i].second;       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= m; ++j)           if (a[i].first <= b[j].first && a[i].second <= b[j].second)             surf[b[j].second - a[i].second] =                 max(surf[b[j].second - a[i].second], b[j].first - a[i].first + 1);       for (int i = Max - 2; i >= 0; --i) {         surf[i] = max(surf[i], surf[i + 1]);         res = min(res, i + surf[i]);       }       cout << res <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[110];   int b[110];   int main() {     int n, m;     int maxx;     int maxx1;     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       maxx = 1;       maxx1 = 0;       for (int j = 1; j <= n; j++) {         scanf( %d , &a[j]);         if (a[j] > maxx1) {           maxx = j;           maxx1 = a[j];         }       }       b[maxx]++;     }     maxx = 1;     maxx1 = 0;     for (int i = 1; i <= n; i++) {       if (b[i] > maxx1) {         maxx = i;         maxx1 = b[i];       }     }     printf( %d n , maxx);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       if (n % 2 == 0)         cout << n / 2 <<     << n / 2 <<   n ;       else {         long long int x = -1;         for (long long int i = 3; i <= sqrt(n); i += 2) {           if (n % i == 0) {             x = i;             break;           }         }         if (x == -1)           cout << n - 1 <<     << 1 <<   n ;         else {           long long int y = n / x;           cout << y * 1 <<     << y * (x - 1) <<   n ;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   string a, b;   int m, d;   long long int memo[2000][2000][2][2];   long long int dp(int i, int rem, bool hf, bool lf) {     if (i >= a.length()) {       if (rem == 0) {         return 1;       }       return 0;     }     if (memo[i][rem][hf][lf] != -1) return memo[i][rem][hf][lf];     int lo = 0;     int hi = 9;     if (lf) lo = b[i] -  0 ;     if (hf) hi = a[i] -  0 ;     long long int ans = 0;     if (i % 2 == 0) {       for (int j = lo; j <= hi; j++) {         if (j == d) continue;         ans += dp(i + 1, (rem * 10 + j) % m, hf & (j == (a[i] -  0 )),                   lf & (j == (b[i] -  0 )));         ans %= 1000000007;       }     } else {       if ((d >= lo) && (d <= hi))         ans += dp(i + 1, (rem * 10 + d) % m, hf & (d == (a[i] -  0 )),                   lf & (d == (b[i] -  0 )));       ans %= 1000000007;     }     memo[i][rem][hf][lf] = ans;     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     cin >> m >> d;     cin >> b >> a;     for (int i = 0; i < 2000; i++) {       for (int j = 0; j < 2000; j++) {         for (int k = 0; k < 2; k++) {           for (int l = 0; l < 2; l++) {             memo[i][j][k][l] = -1;           }         }       }     }     cout << dp(0, 0, 1, 1) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     vector<int> a;     int temp = 0, sumb = 0, sumc = 0;     for (int i = 0; i < t; i++) {       cin >> temp;       a.push_back(temp);     }     for (int i = 0; i < t; i++) {       int tem = 0;       if (a[0] < a[a.size() - 1]) {         tem = a[a.size() - 1];         a.erase(a.end() - 1);       } else if (a[0] > a[a.size() - 1]) {         tem = a[0];         a.erase(a.begin() + 0);       }       if (i % 2 == 0)         sumb += tem;       else         sumc += tem;     }     if (t % 2 != 0)       cout << sumb + a[0] <<     << sumc << endl;     else       cout << sumb <<     << sumc + a[0] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long double PI = acosl(-1.0);   const long double E = 1e-15;   mt19937_64 rnd(time(0));   long long n, m, r, pr[100001], dp[100001];   pair<long long, pair<long long, long long> > a[100001];   long long binpow(long long h, long long r, long long md = MOD) {     bool t = 0;     if (h < 0) t = 1, h = -h;     if (r % 2 == 0) t = 0;     long long l = 1;     while (r) {       if (r & 1) l *= h, l %= md;       h *= h;       h %= md;       r /= 2;     }     if (t) l = -l;     return l;   }   long long gcd(int x, int y) {     if (x < y) swap(x, y);     while (x && y) {       x %= y;       swap(x, y);     }     return x + y;   }   void solve() {     cin >> r >> n;     a[0].second = make_pair(1, 1);     long long ans = 0;     for (int i = 1; i <= n; i++) {       cin >> a[i].first >> a[i].second.first >> a[i].second.second;       long long o = 0;       for (int j = i - 1; j >= max(i - r * 2, 0ll); j--)         if (abs(a[i].second.first - a[j].second.first) +                 abs(a[i].second.second - a[j].second.second) <=             a[i].first - a[j].first) {           o = max(o, dp[j] + 1);         }       if (i > r * 2) o = max(o, pr[i - r * 2] + 1);       if (o == 0) o = -1e9;       pr[i] = max(pr[i - 1], o);       dp[i] = o;       ans = max(ans, o);     }     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   const int maxn = 403;   int n, m;   int a[maxn][maxn];   void read() {     cin >> n >> m;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) cin >> a[i][j];   }   int min_r[maxn];   long long s[maxn * maxn][7];   int find_first_bit(long long num) { return 63 - __builtin_clzll(num & -num); }   int find_last_bit(long long num) { return 63 - __builtin_clzll(num); }   int find_prev(int c, int idx) {     int pos = idx / 63;     idx %= 63;     long long left = (s[c][pos] & ((1ll << idx) - 1));     if (left) return pos * 63 + find_last_bit(left);     for (int i = pos - 1; i >= 0; i--)       if (s[c][i]) return i * 63 + find_last_bit(s[c][i]);     return -1;   }   int find_next(int c, int idx) {     int pos = idx / 63;     idx %= 63;     long long curr = (s[c][pos] >> (idx + 1));     if (curr) return pos * 63 + idx + 1 + find_first_bit(curr);     for (int i = pos + 1; i < 7; i++)       if (s[c][i]) return i * 63 + find_first_bit(s[c][i]);     return -1;   }   void solve() {     int ans = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) min_r[j] = m + 1;       for (int j = 1; j < maxn * maxn; j++)         for (int k = 0; k < 7; k++) s[j][k] = 0;       for (int j = i; j <= n; j++) {         for (int k = 1; k <= m; k++) {           int pos = (k - 1) / 63, r = (k - 1) % 63;           if (s[a[j][k]][pos] & (1ll << r))             min_r[k] = k;           else {             s[a[j][k]][pos] ^= (1ll << r);           }         }         for (int k = 1; k <= m; k++) {           int f1 = find_prev(a[j][k], k - 1), f2 = find_next(a[j][k], k - 1);           if (f1 != -1) min_r[f1 + 1] = min(min_r[f1 + 1], k);           if (f2 != -1) min_r[k] = min(min_r[k], f2 + 1);         }         int curr = m + 1;         for (int k = m; k >= 1; k--) {           curr = min(curr, min_r[k]);           ans = max(ans, (curr - k) * (j - i + 1));         }       }     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     read();     solve();   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, m, x;     cin >> n >> x >> m;     long long a, b;     long long mn = 1e9 + 1, mx = 1;     bool f = false;     while (m--) {       cin >> a >> b;       if (!f) {         if (x >= a && x <= b) {           f = true;           mn = a;           mx = b;         }       } else {         if (a < mn && b >= mn) {           mn = a;         }         if (b > mx && a <= mx) {           mx = b;         }       }     }     if (f == false) {       cout <<  1 n ;     } else {       cout << (mx - mn) + 1 <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long T;     cin >> T;     while (T--) solve();   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = double;   void err(istream_iterator<string> it) {}   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cout << *it <<   =   << a << endl;     err(++it, args...);   }   const ll MODBASE = 1000000007LL;   const int MAXN = 100010;   const int MAXM = 110;   const int MAXK = 110;   string s, t;   int f[26];   set<pair<int, int> > se;   int main() {     ios::sync_with_stdio(0);     cin.tie(nullptr);     cin >> s >> t;     for (int i = (0); i <= (25); i++) f[i] = -1;     for (int i = (0); i <= (int((s).size()) - 1); i++)       if (s[i] != t[i]) f[s[i] -  a ] = t[i] -  a ;     for (int i = (0); i <= (25); i++)       if (f[i] != -1) {         if (f[f[i]] == -1) {           f[f[i]] = i;         } else if (f[f[i]] != i) {           cout << -1;           return 0;         }       }     for (int i = (0); i <= (int((s).size()) - 1); i++)       if (f[s[i] -  a ] != -1) s[i] = char(f[s[i] -  a ] +  a );     if (s == t) {       for (int i = (0); i <= (25); i++)         if (f[i] != -1) {           if (i < f[i])             se.insert(pair<int, int>(i, f[i]));           else             se.insert(pair<int, int>(f[i], i));         }       cout << int((se).size()) <<   n ;       for (__typeof((se).begin()) it = (se).begin(); it != (se).end(); it++)         cout << char(it->first +  a ) <<     << char(it->second +  a ) <<   n ;     } else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   const int N = 7 + 1e9;   using namespace std;   const int p = 1e6 + 10;   int arr[p];   int power(int x, int y);   void pre() {     int j = 1;     for (int i = 1; i < p; i++) {       if (i % 3 != 0) {         if (i % 10 != 3) {           arr[j] = i;           j++;         }       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     pre();     long long T;     cin >> T;     while (T--) {       long long n;       cin >> n;       cout << arr[n] <<   n ;     }     return 0;   }