malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int n, i, a[10001], p = 0;   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     for (i = 1; i <= n; i++) {       if (a[i] == 1) p++;     }     if (n > 1) {       if (p == (n - 1))         printf( YES );       else         printf( NO );     } else {       if (p == 1)         printf( YES );       else         printf( NO );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 505;   const int dr[4] = {0, 0, -1, 1};   const int dc[4] = {-1, 1, 0, 0};   int n, K, mien, ans, res, t;   int sz[N * N], vis[N * N], c[N][N];   char a[N][N];   bool ok(int x, int y) {     return x >= 1 && x <= n && y >= 1 && y <= n && a[x][y] ==  . ;   }   void dfs(int x, int y) {     if (c[x][y]) return;     c[x][y] = mien;     sz[mien]++;     for (int i = 0; i < 4; i++)       if (ok(x + dr[i], y + dc[i])) dfs(x + dr[i], y + dc[i]);   }   void add(int x, int y) {     if (ok(x, y) && vis[c[x][y]] != t) res += sz[c[x][y]], vis[c[x][y]] = t;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> K;     for (int i = 1; i <= n; i++) cin >> a[i] + 1;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (a[i][j] ==  .  && !c[i][j]) mien++, dfs(i, j);     for (int x = 1; x + K - 1 <= n; x++) {       for (int i = 0; i < K; i++)         for (int j = 0; j < K; j++) sz[c[x + i][j + 1]]--;       for (int y = 1; y + K - 1 <= n; y++) {         res = 0;         t++;         for (int k = 0; k < K; k++)           add(x - 1, y + k), add(x + K, y + k), add(x + k, y - 1),               add(x + k, y + K);         ans = max(ans, res);         if (y + K - 1 != n)           for (int i = 0; i < K; i++) sz[c[x + i][y]]++, sz[c[x + i][y + K]]--;         else           for (int i = 0; i < K; i++)             for (int j = 0; j < K; j++) sz[c[x + i][n - j]]++;       }     }     cout << ans + K * K;     return 0;   }
#include <bits/stdc++.h>      #define all(x) (x).begin(),(x).end()   #define sz(x) int(x.size())      using namespace std;   using ll = long long;   using pii = pair<int, int>;   template<typename... T> void rd(T&... args) {((cin>>args), ...);}   template<typename... T> void wr(T... args) {((cout<<args<<   ), ...); cout<<  n ;}      int main() {       ios::sync_with_stdio(false);       cin.tie(nullptr);       int tt;       cin>>tt;   next:       while (tt--) {           int n, u, v;           cin>>n>>u>>v;           vector<int> a(n);           for (auto& i : a) cin>>i;           int ans=2e9;           for (int i=1; i<n; i++) {               if (abs(a[i]-a[i-1])>1) {                   cout<< 0 n ;                   goto next;               }               if (abs(a[i]-a[i-1])==1) ans=min(ans, min(u, v));           }           ans=min(ans, v+min(u, v));           cout<<ans<<  n ;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f[1 << 21], a[210000], i, j, minn, ans, n, l, k;   char c[22];   void Min(int &x, int y) {     if (y < x) x = y;   }   int main() {     scanf( %d , &n);     for (i = 1; i <= n; ++i) {       scanf( %s , c + 1);       l = strlen(c + 1);       for (j = 1; j <= l; ++j) a[i] = a[i] * 2 + c[j] - 48;     }     memset(f, 3, sizeof(f));     f[1] = 0;     ans = 0;     for (i = 1; i <= n; ++i) {       for (j = l; j >= 1; --j)         if (i != 1 && (a[i - 1] & ((1 << j) - 1)) == (a[i] >> l - j)) break;       minn = 1 << 30;       for (k = 0; k <= l; ++k)         Min(minn, f[(a[i] >> l - k) | (1 << k)] + l - k + ans);       ans += l - j;       if (i != 1)         for (k = 0; k <= l; ++k)           Min(f[(a[i - 1] & ((1 << k) - 1)) | (1 << k)], minn - ans);     }     minn = 1 << 30;     for (i = 0; i < 1 << l + 1; ++i) Min(minn, f[i]);     printf( %d n , minn + ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int name[100], i, j = 0;     string codename;     cin >> codename;     for (i = 0; i < codename.length(); i++) {       name[j] = (int)codename[i];       j++;     }     sort(name, name + j);     int count = 0;     for (int k = 1; k < j; k++) {       if (name[k] != name[k - 1]) {         count++;       }     }     if (count % 2 == 0) {       cout <<  IGNORE HIM! n ;     } else {       cout <<  CHAT WITH HER! n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d;     cin >> a >> b >> c >> d;     if (max((3 * a / 10), a - a / 250 * c) == max((3 * b / 10), b - b / 250 * d))       cout <<  Tie ;     else if (max((3 * a / 10), a - a / 250 * c) >              max((3 * b / 10), b - b / 250 * d))       cout <<  Misha ;     else if (max((3 * a / 10), a - a / 250 * c) <              max((3 * b / 10), b - b / 250 * d))       cout <<  Vasya ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int a[100005];   int main() {     long long int n, b, k;     cin >> k >> b >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     long long int ans = 0;     if (b == 0) {       for (int i = 0; i < n;) {         long long int now = a[i];         long long int cnt = 0;         while (i < n && a[i] == now) {           i++;           cnt++;         }         if (now == 0) {           ans += (cnt * (cnt + 1) / 2);         }       }       cout << ans << endl;       return 0;     }     if (b == k - 1) b = 0;     long long int ans2 = 0;     if (b == 0) {       for (int i = 0; i < n;) {         long long int now = a[i];         long long int cnt = 0;         while (i < n && a[i] == now) {           i++;           cnt++;         }         if (now == 0) {           ans2 += (cnt * (cnt + 1) / 2);         }       }     }     map<long long int, long long int> mp;     mp[0]++;     for (int i = 0; i < n; i++) {       if (i > 0) a[i] += a[i - 1];       long long int mod = a[i] % (k - 1);       long long int need = (mod - b + k + k - 2) % (k - 1);       if (mp.find(need) != mp.end()) {         ans += mp[need];       }       mp[mod]++;     }     cout << ans - ans2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int solve() {     int n;     cin >> n;     int e = 0, o = 0;     int x;     for (int i = 0; i < n; i++) {       cin >> x;       if (i % 2 == 0 && x % 2 == 1) o++;       if (i % 2 == 1 && x % 2 == 0) e++;     }     if (o == e) return o;     return -1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     for (int i = 0; i < t; i++) {       cout << solve() <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using ll = long long;   using namespace std;   using pii = pair<ll, ll>;   ll mod = 998244353;   int get_p2(int n) {     int i = 0;     while ((1 << i) <= n) i++;     return i - 1;   }   int main() {     ios_base::sync_with_stdio(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       string a, b;       cin >> a >> b;       int need0 = 0, need1 = 0, nneed0 = 0, nneed1 = 0;       for (int i = 0; i < n; i++) {         if (a[i] != b[i]) {           if (a[i] ==  0 )             need0++;           else             need1++;         } else {           if (a[i] ==  0 )             nneed0++;           else             nneed1++;         }       }       int ans = -1;       if (nneed1 - nneed0 == 1) ans = nneed1 + nneed0;       if (need0 == need1)         ans = (ans < 0 ? need0 + need1 : min(ans, need0 + need1));       cout << ans <<   n ;     }     cout.flush();   }
#include <bits/stdc++.h>   using namespace std;   const string sf[6] = { lios ,  liala ,  etr ,  etra ,  initis ,  inites };   char a[1100000], s[1100000];   int n, sd, p, num[3];   int gender;   int suffix(int x) {     int len = strlen(s);     if (len < (int)sf[x].length()) return 0;     for (int i = len - sf[x].length(); i < len; i++)       if (s[i] != sf[x][i - len + sf[x].length()]) return 0;     return 1;   }   int kind() {     for (int k = 0; k < 6; k++)       if (suffix(k)) {         if (gender != -1) {           if (gender != (k & 1)) return -1;         } else           gender = (k & 1);         return k >> 1;       }     return -1;   }   void work() {     memset(num, 0, sizeof(num));     n = strlen(a);     s[0] = 0;     sd = p = 0;     gender = -1;     while (scanf( %s , s) != EOF) {       if (!strlen(s)) continue;       if (sd) {         printf( NO n );         return;       }       int k = kind();       if (k < 0) {         printf( NO n );         return;       }       if (k == 0) {         if (num[k + 1] || num[k + 2]) {           printf( NO n );           return;         } else           num[k]++;       }       if (k == 1) {         if (num[k] || num[k + 1]) {           printf( NO n );           return;         } else           num[k]++;       }       if (k == 2) {         if (!num[k - 1]) {           if (!num[k - 2] && !num[k]) {             sd = 1;             num[k]++;           } else {             printf( NO n );             return;           }         } else           num[k]++;       }     }     if (num[0] + num[1] + num[2] > 1 && num[1] == 0) {       printf( NO n );       return;     }     printf( YES n );   }   int main() {     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q, n, i, a[201], start, tmp, yn;     cin >> q;     while (q--) {       cin >> n;       for (i = 0; i < n; i++) {         cin >> a[i];         if (a[i] == 1) start = i;       }       yn = 0;       tmp = 1;       for (i = 0; i < n - 1; i++)         if (a[(start + i + 1) % n] != a[(start + i) % n] + 1) tmp = 0;       yn += tmp;       tmp = 1;       for (i = 0; i < n - 1; i++)         if (a[(1 + start + i + 1) % n] != a[(1 + start + i) % n] - 1) tmp = 0;       yn += tmp;       cout << (yn == 0 ?  NO n  :  YES n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   ifstream Cin( input.txt );   ofstream Cout( output.txt );   pair<bool, long long> Try(long long A, long long B, long long N) {     long long err = 0, C;     while (A > 0 && B > 0 && N > 0) {       if (A == 1 && B != 1) {         C = B - 1;         A = B = 1;       } else if (A >= B) {         C = A / B;         A %= B;       } else {         C = B / A;         B %= A;       }       err += C - 1;       N -= C;     }     return make_pair(N == 0 && A == 0 && B == 1, err);   }   string get(long long A, long long B, long long N) {     string TMP;     while (N) {       N--;       if (A >= B) {         A -= B;         TMP.push_back( T );       } else {         B -= A;         TMP.push_back( B );       }     }     reverse(TMP.begin(), TMP.end());     return TMP;   }   int main() {     long long n, r, i, A, B, ER = (long long)1e15;     pair<bool, long long> Cur;     cin >> n >> r;     for (i = 1; i <= r; i++) {       Cur = Try(i, r, n);       if (Cur.first) {         if (Cur.second < ER) {           ER = Cur.second;           A = i;           B = r;         }       }       Cur = Try(r, i, n);       if (Cur.first) {         if (Cur.second < ER) {           ER = Cur.second;           A = r;           B = i;         }       }     }     if (ER == (long long)1e15)       cout <<  IMPOSSIBLE ;     else       cout << ER << endl << get(A, B, n);   }
#include <bits/stdc++.h>   using namespace std;   int l;   char s[205];   int exe(int a, int b) {     int u = 0, r = 0;     for (int i = a; i < b; i++) {       switch (s[i]) {         case  U :           u++;           break;         case  D :           u--;           break;         case  R :           r++;           break;         case  L :           r--;           break;       }     }     return u == 0 and r == 0;   }   int main() {     scanf( %d n , &l);     gets(s);     int r = 0;     for (int i = 0; i < l; i++)       for (int j = i + 1; j <= l; j++) r += exe(i, j);     printf( %d , r);   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   void solve() {     long long n;     cin >> n;     vector<long long> v(n);     for (long long i = 0; i < n; ++i) {       cin >> v[i];     }     long long ans = 0;     map<long long, long long> mp;     for (long long i = 0; i < n; i++) {       map<long long, long long> tp;       long long cur = 0;       for (long long j = i + 1; j < n; j++) {         if (v[j] == v[i]) ans += cur;         tp[v[j]]++;         if (mp.count(v[j])) cur += mp[v[j]];       }       mp[v[i]]++;     }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     long long t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 201;   int n, a[N], cum[N][N], k, freq[N];   vector<int> hs;   int calc(int l, int r) {     priority_queue<int> qu;     int res = 0;     for (int i = l; i <= r; ++i) {       qu.push(-hs[a[i]]);       res += hs[a[i]];     }     int sz = hs.size(), op = k;     bool E = false;     for (int i = sz - 1; i >= 0 && !E; --i) {       int can = min(freq[i] - (cum[r + 1][i] - cum[l][i]), op);       while (!qu.empty() && can > 0) {         int v = -qu.top();         qu.pop();         if (v > hs[i]) {           E = true;           break;         }         res -= v;         res += hs[i];         --op;         --can;       }     }     return res;   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);       hs.push_back(a[i]);     }     sort(hs.begin(), hs.end());     hs.resize(unique(hs.begin(), hs.end()) - hs.begin());     for (int i = 0; i < n; ++i) {       a[i] = lower_bound(hs.begin(), hs.end(), a[i]) - hs.begin();       for (size_t j = 0; j < hs.size(); ++j) cum[i + 1][j] = cum[i][j];       ++cum[i + 1][a[i]];       ++freq[a[i]];     }     int best = -2e9;     for (int i = 0; i < n; ++i)       for (int j = i; j < n; ++j) best = max(best, calc(i, j));     printf( %d n , best);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 5;   int n, x[2], need[N][2];   pair<int, int> p[N];   int main() {     ios::sync_with_stdio(false);     cin >> n >> x[0] >> x[1];     for (int i = 0; i < n; i++) {       int c;       cin >> c;       p[i] = {c, i};     }     sort(p, p + n);     for (int i = 0; i < n; i++)       for (int j = 0; j < 2; j++) {         int c = p[i].first;         need[i][j] = (x[j] + c - 1) / c;       }     for (int i = n - 1; i >= 0; i--) {       if (i + need[i][0] < n && need[i][0] + need[i + need[i][0]][1] <= n - i) {         vector<int> a, b;         for (int j = i; j < i + need[i][0]; j++) a.push_back(p[j].second);         for (int j = i + need[i][0]; j < i + need[i][0] + need[i + need[i][0]][1];              j++)           b.push_back(p[j].second);         cout <<  Yes n ;         cout << a.size() <<     << b.size() <<   n ;         for (int x : a) cout << x + 1 <<    ;         cout <<   n ;         for (int x : b) cout << x + 1 <<    ;         cout <<   n ;         return 0;       }       if (i + need[i][1] < n && need[i][1] + need[i + need[i][1]][0] <= n - i) {         vector<int> a, b;         for (int j = i; j < i + need[i][1]; j++) b.push_back(p[j].second);         for (int j = i + need[i][1]; j < i + need[i][1] + need[i + need[i][1]][0];              j++)           a.push_back(p[j].second);         cout <<  Yes n ;         cout << a.size() <<     << b.size() <<   n ;         for (int x : a) cout << x + 1 <<    ;         cout <<   n ;         for (int x : b) cout << x + 1 <<    ;         cout <<   n ;         return 0;       }     }     cout <<  No n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double Eps = 1e-9;   int Mod = 1000000000 + 7;   int n, m, q, k;   int Arr[100010];   bool prime[10010];   bool ok = true;   void sieve() {     for (int i = 2; i * i <= 1e4; i++) {       if (prime[i] == true)         for (int j = i * 2; j <= 1e4; j++) {           prime[j] = false;         }     }   }   int dp[100010];   int cnt;   int main() {     ios::sync_with_stdio(0);     ;     memset(prime, true, sizeof(prime));     sieve();     cin >> n;     for (int i = 0; i < n; i++) {       cnt = 0;       cin >> Arr[i];       if (Arr[i] & 1 && Arr[i] >= 9) {         Arr[i] -= 9;         cnt++;       }       if (Arr[i] % 4 == 0 && Arr[i] >= 0) {         cout << cnt + Arr[i] / 4 << endl;         continue;       } else if ((Arr[i] - 6) % 4 == 0 && (Arr[i] - 6) >= 0) {         cout << cnt + 1 + (Arr[i] - 6) / 4 << endl;         continue;       }       cout << -1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int N;   vector<int> fen, v;   void _update(int i) {     while (i <= N) {       fen[i]++;       i += i & -i;     }   }   int _sum(int i) {     int ret = 0;     while (i > 0) {       ret += fen[i];       i -= i & -i;     }     return ret;   }   int _bin(int i) {     int sum = _sum(i);     int imin = 1, imax = i;     while (imin <= imax) {       int imid = (imin + imax) / 2;       if (sum - _sum(imid - 1) >= v[i])         imin = imid + 1;       else         imax = imid - 1;     }     return imax;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int Q;     cin >> N >> Q;     v = vector<int>(N + 1);     for (int n = 1; n <= N; ++n) {       cin >> v[n];     }     for (int n = 1; n <= N; ++n) {       v[n] = n - v[n];     }     vector<int> answer(Q);     vector<vector<pair<int, int>>> _query(N + 1);     for (int q = 0; q < Q; ++q) {       int x, y;       cin >> x >> y;       _query[N - y].push_back({x + 1, q});     }     fen = vector<int>(N + 1);     for (int r = 1; r <= N; ++r) {       if (v[r] == 0) {         _update(r);       } else if (v[r] > 0) {         int tmp = _bin(r);         if (tmp) _update(tmp);       }       for (auto x : _query[r]) {         answer[x.second] = _sum(r) - _sum(x.first - 1);       }     }     for (auto x : answer) cout << x <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[1010][105], po[1010], po2[1010];   long long qui(long long a, long long n, long long m) {     long long ans = 1;     while (n) {       if (n & 1) ans = (ans * a) % m;       n >>= 1;       a = (a * a) % m;     }     return ans;   };   int main() {     long long n, k, m;     while (cin >> n >> k >> m) {       po[0] = 1;       for (int i = 1; i <= n; i++) po[i] = (po[i - 1] * 10) % m;       po2[0] = 1;       for (int i = 1; i <= n; i++) po2[i] = (po2[i - 1] * 10) % k;       long long sum = 0;       memset(dp, 0, sizeof(dp));       for (int i = 1; i < 10; i++) dp[1][i % k]++;       if (n >= 2) sum = (sum + dp[1][0] * 9 * po[n - 2]) % m;       for (int i = 1; i < n - 1; i++) {         for (int j = 1; j < k; j++)           for (int x = 0; x < 10; x++)             dp[i + 1][(j + x * po2[i]) % k] =                 (dp[i + 1][(j + x * po2[i]) % k] + dp[i][j]) % m;         for (int x = 1; x < 10; x++)           dp[i + 1][x * po2[i] % k] = (dp[i + 1][x * po2[i] % k] + 1) % m;         sum = (sum + ((dp[i + 1][0] * 9) % m) * po[n - i - 2]) % m;       }       if (n >= 2) {         for (int j = 1; j < k; j++)           for (int x = 1; x < 10; x++)             dp[n][(j + x * po2[n - 1]) % k] =                 (dp[n][(j + x * po2[n - 1]) % k] + dp[n - 1][j]) % m;         for (int x = 1; x < 10; x++)           dp[n][x * po2[n - 1] % k] = (dp[n][x * po2[n - 1] % k] + 1) % m;       }       sum = (sum + dp[n][0] % m) % m;       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     char c = getchar();     int t = 0, f = 1;     while (c >  9  || c <  0 ) f = (c ==  - ) ? -1 : 1, c = getchar();     while (c >=  0  && c <=  9 ) t = t * 10 + c -  0 , c = getchar();     return t * f;   }   struct node {     int L, R, po, id;     bool operator<(const node &b) const {       if (po == b.po) return R < b.R;       return po < b.po;     }   } p[200005];   int n, Q, K, sq, a[200005], op[200005], id[200005], uid[200005], did[200005],       cnt[200005];   long long sum[200005], st[200005], ans[200005], now;   int main() {     n = read(), K = read(), sq = sqrt(n);     for (int i = 1; i <= n; i++) op[i] = (read() == 1) ? 1 : -1;     for (int i = 1; i <= n; i++)       a[i] = read(), st[i] = sum[i] = sum[i - 1] + a[i] * op[i];     st[n + 1] = 0, sort(st + 1, st + n + 2);     int tp = unique(st + 1, st + n + 2) - st - 1;     for (int i = 0; i <= n; i++) {       id[i] = lower_bound(st + 1, st + tp + 1, sum[i]) - st;       int up = lower_bound(st + 1, st + tp + 1, sum[i] + K) - st;       if (st[up] == sum[i] + K) uid[i] = up;       int down = lower_bound(st + 1, st + tp + 1, sum[i] - K) - st;       if (st[down] == sum[i] - K) did[i] = down;     }     Q = read();     for (int i = 1, x, y, z; i <= Q; i++)       x = read() - 1, y = read(), z = x / sq, p[i] = (node){x, y, z, i};     sort(p + 1, p + Q + 1);     for (int i = p[1].L; i <= p[1].R; i++) now += cnt[did[i]], cnt[id[i]]++;     ans[p[1].id] = now;     for (int i = 2; i <= n; i++) {       int L = p[i - 1].L, R = p[i - 1].R;       while (R < p[i].R) R++, now += cnt[did[R]], cnt[id[R]]++;       while (R > p[i].R) cnt[id[R]]--, now -= cnt[did[R]], R--;       while (L > p[i].L) L--, now += cnt[uid[L]], cnt[id[L]]++;       while (L < p[i].L) cnt[id[L]]--, now -= cnt[uid[L]], L++;       ans[p[i].id] = now;     }     for (int i = 1; i <= Q; i++) printf( %lld n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   long long int pow_mod(long long int a, long long int b) {     long long int res = 1;     while (b != 0) {       if (b & 1) {         res = (res * a) % 1000000007;       }       a = (a * a) % 1000000007;       b /= 2;     }     return res;   }   void solve() {     long long int h;     cin >> h;     long long int a[h + 1];     for (long long int i = 0; i < h + 1; i++) cin >> a[i];     bool f = true;     for (long long int i = 1; i < h + 1; i++) {       if (a[i] > 1 && a[i - 1] > 1) {         f = false;         break;       }     }     if (f)       cout <<  perfect n ;     else {       cout <<  ambiguous n ;       long long int p1[h + 1];       long long int p2[h + 1];       long long int sz = 0;       bool f = true;       long long int capture = -1;       for (long long int i = 0; i < h + 1; i++) {         for (long long int j = 0; j < a[i]; j++) {           p1[i] = sz;           cout << sz <<    ;         }         if (i > 0 && a[i] > 1 && a[i - 1] > 1) capture = i;         sz += a[i];       }       cout << endl;       for (long long int i = 0; i < h + 1; i++) {         if (i == capture) cout << (p1[i] - 1) <<    ;         for (long long int j = 0; j < a[i]; j++) {           if (j == 0 && capture == i) continue;           cout << p1[i] <<    ;         }       }       cout << endl;     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t;     t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int y, a, b, c, d, temp;     while (cin >> y) {       temp = y + 1;       while (temp != 0) {         a = temp % 10;         b = (temp % 100) / 10;         c = (temp % 1000) / 100;         d = temp / 1000;         if (a == b || b == c || c == d || d == a || d == b || a == c)           temp++;         else           break;       }       cout << temp << endl;     }     return 0;   }