malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t;     cin >> t;     while (t--) {       long long x, y, k;       cin >> x >> y >> k;       long long qtd = (((y + 1) * k - 1) + (x - 2)) / (x - 1);       cout << qtd + k <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   const int mod = 1e9 + 7;   const int maxm = 2e5 + 5;   const long long inf = 0x3f3f3f3f3f3f3f3f;   int xx[] = {0, 0, 1, -1};   int yy[] = {1, -1, 0, 0};   int N, M, K;   vector<pair<int, long long> > vec[maxn];   vector<int> V;   vector<long long> S;   int vis[maxn];   long long value[maxn];   void dfs(int u, int p, long long s) {     if (vis[u]) {       S.push_back(value[u] ^ s);       return;     }     vis[u] = 1;     V.push_back(u);     value[u] = s;     for (int i = 0; i < vec[u].size(); i++) {       int v = vec[u][i].first;       long long w = vec[u][i].second;       if (v == p) continue;       dfs(v, u, s ^ w);     }   }   long long ans;   void work() {     int i2 = 0;     long long A = 0;     for (int j = 0; j < S.size(); j++) A |= S[j];     for (int i = 0; i < 60; i++) {       int s = -1;       for (int j = i2; j < S.size(); j++) {         long long v = S[j];         if (v & (1ll << i)) {           s = j;         }       }       if (s == -1) continue;       swap(S[i2], S[s]);       for (int j = i2 + 1; j < S.size(); j++) {         long long &v = S[j];         if (v & (1ll << i)) {           v ^= S[i2];         }       }       i2++;     }     for (int i = 0; i < 60; i++) {       if (A & (1ll << i)) {         ans += (1ll << i) % mod * ((1ll << i2 - 1) % mod) % mod *                (1ll * V.size() * (V.size() - 1) / 2 % mod);         ans %= mod;       } else {         int X = 0, Y = 0;         for (int j = 0; j < V.size(); j++) {           int v = V[j];           if (value[v] & (1ll << i)) {             X++;           } else             Y++;         }         ans += 1ll * X * Y % mod * ((1ll << i2) % mod) % mod * ((1ll << i) % mod);         ans %= mod;       }     }   }   int main(int argc, char *argv[]) {     if (argc > 1) {       freopen(argv[1],  r , stdin);     }     cin >> N >> M;     for (int i = 0; i < M; i++) {       int a, b;       long long c;       scanf( %d%d%lld , &a, &b, &c);       vec[b].push_back(make_pair(a, c));       vec[a].push_back(make_pair(b, c));     }     for (int i = 1; i <= N; i++) {       V.clear();       S.clear();       if (vis[i]) continue;       dfs(i, 0, 0);       work();     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   long long POW(long long m) {     long long t = 1;     for (long long k = 1; k <= m; k++) t *= 4;     return t;   }   int main() {     long long n;     scanf( %I64d , &n);     if (n == 3) {       printf( 24 );       return 0;     }     long long ans = 4 * (3 * POW(n - 3) * 2 + 9 * POW(n - 4) * (n - 3));     printf( %I64d , ans);   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   long long n, m, cnt[55], used[55], add[55];   bool vis[55];   vector<long long> v[55], p;   pair<long long, long long> it[55];   long long fa[55];   long long getfa(long long x) {     if (x == fa[x])       return x;     else       return fa[x] = getfa(fa[x]);   }   void update(long long x, long long y) {     x = getfa(x);     y = getfa(y);     fa[x] = y;   }   void dfs(long long x) {     if (vis[x]) return;     vis[x] = 1;     p.emplace_back(x);     for (auto u : v[x]) {       dfs(u);     }   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     long long x, y;     for (long long i = 1; i <= m; i++) {       cin >> x >> y;       v[x].emplace_back(y);       v[y].emplace_back(x);     }     long long cnt = 0;     for (long long i = 1; i <= n; i++)       if (!vis[i]) {         p.clear();         dfs(i);         long long lst = cnt;         for (auto u : p) {           if (v[u].size() > 2) {             cout <<  NO ;             return 0;           }           if (v[u].size() == 1) {             if (cnt && it[cnt].second == 0) {               it[cnt].second = u;             } else {               it[++cnt].first = u;             }           }           if (v[u].empty()) {             it[++cnt] = make_pair(u, u);           }         }         if (lst == cnt) {           if (p.size() == n) {             cout <<  YES n0 ;             return 0;           } else {             cout <<  NO ;             return 0;           }         }       }     for (long long i = 1; i <= n; i++) fa[i] = i;     for (long long i = 1; i <= cnt; i++) {       if (it[i].first > it[i].second) swap(it[i].first, it[i].second);       used[it[i].first]++;       used[it[i].second]++;       add[it[i].first] = add[it[i].second] = i;     }     sort(it + 1, it + cnt + 1);     cout <<  YES n ;     cout << cnt <<   n ;     for (long long i = 1; i <= n; i++) {       while (used[i]) {         bool f = 1;         for (long long j = i + 1; j <= n; j++)           if (used[j]) {             if (getfa(add[i]) != getfa(add[j])) {               cout << i <<     << j <<   n ;               update(add[i], add[j]);               used[i]--;               used[j]--;               f = 0;               break;             }           }         if (f) break;       }     }     for (long long i = 1; i <= n; i++) {       while (used[i]) {         cout << i <<    ;         used[i]--;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200010, INF = 0x3f3f3f3f;   int n, m, k;   struct books {     int t, id;     bool operator<(const books &w) const { return t < w.t; }   } A[N], B[N], C[N], D[N];   int main() {     cin >> n >> m >> k;     int a = 0, b = 0, c = 0, d = 0;     for (int i = 1; i <= n; i++) {       int first, second, z;       cin >> first >> second >> z;       if (second && z)         C[++c] = {first, i};       else if (second)         A[++a] = {first, i};       else if (z)         B[++b] = {first, i};       else         D[++d] = {first, i};     }     sort(A + 1, A + 1 + a);     sort(B + 1, B + 1 + b);     sort(C + 1, C + 1 + c);     sort(D + 1, D + 1 + d);     int ai = 0, bi = 0, ci = 0, di = 0;     int ans = 0;     while (ci < c && ci < k) ans += C[++ci].t;     while (ai + ci < k && ai < a && bi < b) ans += A[++ai].t + B[++bi].t;     if (ai + ci < k || ai + bi + ci > m) {       puts( -1 );       return 0;     }     while (ai + bi + ci + di < m) {       int op1, op2, op3, op4, op5, minv;       op1 = op2 = op3 = op4 = op5 = INF;       if (ci && ai < a && bi < b) op1 = A[ai + 1].t + B[bi + 1].t - C[ci].t;       if (ai < a) op2 = A[ai + 1].t;       if (bi < b) op3 = B[bi + 1].t;       if (ci < c) op4 = C[ci + 1].t;       if (di < d) op5 = D[di + 1].t;       minv = min(min(min(min(op1, op2), op3), op4), op5);       if (minv == INF) break;       if (minv == op1)         ai++, bi++, ci--;       else if (minv == op2)         ai++;       else if (minv == op3)         bi++;       else if (minv == op4)         ci++;       else if (minv == op5)         di++;       ans += minv;     }     cout << ans << endl;     for (int i = 1; i <= ai; i++) cout << A[i].id <<    ;     for (int i = 1; i <= bi; i++) cout << B[i].id <<    ;     for (int i = 1; i <= ci; i++) cout << C[i].id <<    ;     for (int i = 1; i <= di; i++) cout << D[i].id <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e2 + 1;   int n, k, m, a, cnt[maxn], last[maxn], id[maxn], res[maxn];   void Enter() {     cin >> n >> k >> m >> a;     for (int i = 1; i <= a; ++i) {       int g;       cin >> g;       ++cnt[g];       last[g] = i;     }   }   void Init() {     for (int i = 1; i <= n; ++i) id[i] = i;     sort(id + 1, id + n + 1, [](int i, int j) {       return cnt[i] > cnt[j] || (cnt[i] == cnt[j] && last[i] < last[j]);     });   }   void Solve() {     if (k == n) {       for (int i = 1; i <= n; ++i)         if (cnt[i] == 0)           if (m == a)             cout << 3 <<    ;           else             cout << 2 <<    ;         else           cout << 1 <<    ;       return;     }     int s = 0;     for (int i = 1; i <= k + 1; ++i) s += cnt[id[i]];     for (int t = 1; t <= k; ++t) {       int i = id[t];       s -= cnt[i];       if (cnt[i] != 0)         if ((cnt[i] + 1) * (k + 1 - t) - s <= m - a)           res[i] = 2;         else           res[i] = 1;       else if (m == a)         res[i] = 3;       else         res[i] = 2;     }     for (int t = k + 1; t <= n; ++t) {       int i = id[t];       if (cnt[i] + (m - a) <= cnt[id[k]])         res[i] = 3;       else         res[i] = 2;     }     for (int i = 1; i <= n; ++i) cout << res[i] <<    ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     Enter();     Init();     Solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int S, C = 1;     cin >> S;     int *N = new int[S];     for (int i = 0; i < S; i++) cin >> N[i];     sort(N, N + S);     for (int i = 0; i < S; i++)       if (N[i] >= C) C++;     cout << C;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long arr[n];     for (long long i = 0; i < n; i++) cin >> arr[i];     sort(arr, arr + n);     long long cur = n - 1, mid = (n - 2) / 2, res = 0;     for (long long i = mid; i >= 0; i--)       if (arr[i] * 2 <= arr[cur]) {         cur--;         res++;       }     cout << n - res;   }
#include <bits/stdc++.h>   using namespace std;   long long int nextAlice[7][7];   long long int nextBob[7][7];   long long int nodeNum[7][7];   pair<long long int, long long int> curScore;   pair<long long int, long long int> cycScore;   pair<long long int, long long int> gameScore(long long int x, long long int y) {     if (x == y) return make_pair(0, 0);     if ((x == 3 && y == 2) || (x == 2 && y == 1) || (x == 1 && y == 3))       return make_pair(1, 0);     if ((y == 3 && x == 2) || (y == 2 && x == 1) || (y == 1 && x == 3))       return make_pair(0, 1);   }   void addPair(pair<long long int, long long int> x) {     curScore.first += x.first;     curScore.second += x.second;   }   void addPairCyc(pair<long long int, long long int> x) {     cycScore.first += x.first;     cycScore.second += x.second;   }   int main() {     long long int i, j, k, l, m, n, x, y, z, a, b, r, curnode, curAlice, curBob,         tx, ty;     scanf( %lld , &k);     scanf( %lld , &a);     scanf( %lld , &b);     for (i = 1; i <= 3; i++)       for (j = 1; j <= 3; j++) scanf( %lld , &nextAlice[i][j]);     for (i = 1; i <= 3; i++)       for (j = 1; j <= 3; j++) scanf( %lld , &nextBob[i][j]);     curnode = 1;     curAlice = a;     curBob = b;     while (nodeNum[curAlice][curBob] == 0) {       x = curAlice;       y = curBob;       nodeNum[x][y] = curnode++;       curAlice = nextAlice[x][y];       curBob = nextBob[x][y];     }     x = curAlice;     y = curBob;     l = curnode - nodeNum[x][y];     i = 0;     curAlice = a;     curBob = b;     while (!(curAlice == x && curBob == y)) {       tx = curAlice;       ty = curBob;       i++;       if (i > k) {         printf( %lld %lld n , curScore.first, curScore.second);         return 0;       }       addPair(gameScore(curAlice, curBob));       curAlice = nextAlice[tx][ty];       curBob = nextBob[tx][ty];     }     k = k - i;     bool flag = true;     curAlice = x;     curBob = y;     while (flag || !(curAlice == x && curBob == y)) {       flag = false;       tx = curAlice;       ty = curBob;       addPairCyc(gameScore(curAlice, curBob));       curAlice = nextAlice[tx][ty];       curBob = nextBob[tx][ty];     }     addPair(make_pair(k / l * cycScore.first, k / l * cycScore.second));     k = k % l;     curAlice = x;     curBob = y;     while (k > 0) {       tx = curAlice;       ty = curBob;       addPair(gameScore(curAlice, curBob));       curAlice = nextAlice[tx][ty];       curBob = nextBob[tx][ty];       k--;     }     printf( %lld %lld n , curScore.first, curScore.second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int last[444444], pr[444444], p[444444], pred[444444];   string s[444444], t;   int ans, n, len;   void go(int v, int K) {     int j = last[v];     while (j > 0) {       int k = K, sz = s[j].length();       for (int q = 0; q < sz; q++) {         while (k > 0 && s[j][q] != t[k]) k = pr[k];         if (s[j][q] == t[k]) k++;         if (k == len) ans++;       }       go(j, k);       j = pred[j];     }   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) last[i] = 0;     for (int i = 2; i <= n; i++) {       cin >> p[i] >> s[i];       pred[i] = last[p[i]];       last[p[i]] = i;     }     cin >> t;     len = t.length();     t = t +    ;     pr[1] = 0;     int k = 0;     for (int i = 2; i <= len; i++) {       while (k > 0 && t[i - 1] != t[k]) k = pr[k];       if (t[i - 1] == t[k]) k++;       pr[i] = k;     }     ans = 0;     go(1, 0);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ld = long double;   using vi = vector<int>;   using vll = vector<long long int>;   using vd = vector<double>;   using vvi = vector<vi>;   int ctoi(char c) { return c -  0 ; }   int slen(string s) { return s.length(); }   int vsize(vi a) { return (int)a.size(); }   int in() {     int x;     cin >> x;     return x;   }   long long int n;   void kmin(long long int n, long long int m) {     long long int val = n / m;     n = n - (val * m);     long long int val1 = (m - n) * (val - 1) * (val) / 2;     long long int val2 = n * val * (val + 1) / 2;     long long int val3 = val1 + val2;     cout << val3 <<    ;   }   void kmax(long long int n, long long int m) {     n = n - (m - 1);     long long int val = n * (n - 1) / 2;     cout << val;     cout << endl;   }   const int M = 1000000;   long long int prime(long long int x) {     for (long long int i = 2; i * i <= x; i++) {       if (x % i == 0) return i;     }     return x;   }   vector<pair<long long int, long long int> > v;   set<long long int> s;   bool check(long long int x) {     for (int i = 1; i < n; i++) {       if (v[i].first % x != 0 && v[i].second % x != 0) {         return 0;       }     }     return 1;   }   void get_prime(long long int x) {     if (x % 2 == 0) s.insert(2);     while (x % 2 == 0) x = x / 2;     for (int i = 3; i <= sqrt(x); i += 2) {       if (x % i == 0) {         s.insert(i);         while (x % i == 0) x = x / i;       }     }     if (x > 2) {       s.insert(x);     }   }   vll ar[1000000];   set<long long int> cycle;   vll path;   bool vis[1000000];   int isp(int x) {     if (x < 2) return 0;     for (int i = 2; i * i <= x; i++)       if (x % i == 0) return 0;     return 1;   }   void dfs(int n, int m, int x, int y, bool visited[105][105]) {     if (x >= n || y >= m || x < 0 || y < 0 || visited[x][y]) return;     visited[x][y] = true;     cout << x + 1 <<     << y + 1 <<   n ;     for (int i = 0; i < n; i++) dfs(n, m, i, y, visited);     for (int i = 0; i < m; i++) dfs(n, m, x, i, visited);   }   void solve() {     long long int n, m, ans;     cin >> n >> m;     if (n == m) {       cout << 0;       return;     }     long long int diff = (abs)(n - m);     long long int i = 1;     while (true) {       ans = i * (i + 1) / 2;       if (diff == ans) {         ans = i;         break;       }       if (diff < ans) {         if (ans % 2 == diff % 2) {           ans = i;           break;         }       }       i++;     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long int t = 1;     cin >> t;     while (t--) {       solve();       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 1e9 + 7;   const long long N = 60, K = 10000 + 5;   long long dp[K][N];   long long prob[N][N];   long long n, k;   long long inv[N];   long long power(long long a, long long k) {     if (k == 0) return 1;     long long ans = power(a, k / 2);     ans = (ans * ans) % M;     if (k % 2) ans = (ans * a) % M;     return ans;   }   void pre() {     for (long long i = 1; i < N; i++) inv[i] = power(i, M - 2);   }   void calc(long long id, long long s) {     memset(dp, 0, sizeof dp);     dp[0][s] = 1;     for (long long i = 1; i <= k; i++)       for (long long cur = 0; cur <= s; cur++)         for (long long prev = cur; prev <= s; prev++)           dp[i][cur] = (dp[i][cur] + dp[i - 1][prev] * inv[prev + 1]) % M;     for (long long i = 0; i <= s; i++) {       prob[id][i] = dp[k][i];     }   }   vector<pair<long long, long long> > vec;   bool next(vector<long long> &cur) {     for (long long i = 0; i < vec.size(); i++) {       if (cur[i] < vec[i].second) {         cur[i]++;         return true;       }       cur[i] = 0;     }     return false;   }   int main() {     pre();     cin >> n >> k;     long long id = 0;     for (long long i = 2; i * i <= n; i++) {       if (n % i) continue;       long long cnt = 0;       while (n % i == 0) n /= i, ++cnt;       vec.push_back({i, cnt});       calc(id, cnt);       ++id;     }     if (n > 1) {       vec.push_back({n, 1});       calc(id, 1);       ++id;     }     vector<long long> cur(id, 0);     long long ans = 0;     do {       long long val = 1;       for (long long i = 0; i < id; i++) {         for (long long j = 0; j < cur[i]; j++) val *= vec[i].first;       }       val %= M;       long long pr = 1;       for (long long i = 0; i < id; i++) pr = (pr * prob[i][cur[i]]) % M;       ans = (ans + pr * val) % M;     } while (next(cur));     ans = (ans + M) % M;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, d, e;     cin >> n >> d >> e;     long long a = n, b = n, i;     e = 5 * e;     for (i = 0; e * i <= n; i++) {       a = min(a, (n - (e * i)) % d);     }     for (i = 0; d * i <= n; i++) {       b = min(b, (n - (d * i)) % e);     }     cout << min(a, b);   }
#include <bits/stdc++.h>   using namespace std;   int F[1024];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     int n;     cin >> n;     char a;     int b;     for (int mask = 0; mask < (1 << 10); mask++) {       F[mask] = mask;     }     for (int i = 0; i < n; i++) {       cin >> a >> b;       for (int mask = 0; mask < (1 << 10); mask++) {         if (a ==  | )           F[mask] = (F[mask] | b);         else if (a ==  ^ )           F[mask] = (F[mask] ^ b);         else           F[mask] = (F[mask] & b);       }     }     for (int i = 0; i < (1 << 10); i++) {       for (int j = 0; j < (1 << 10); j++) {         set<int> S;         for (int mask = 0; mask < (1 << 10); mask++) {           int val = mask;           val = (val | i);           val = (val & j);           S.insert((val ^ F[mask]));         }         if (S.size() == 1) {           cout << 3 <<   n ;           cout <<  |   << i <<   n ;           cout <<  &   << j <<   n ;           cout <<  ^   << (*S.begin()) <<   n ;           return 0;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long w, h, k, ans = 0;     cin >> w >> h >> k;     for (long long i = h, j = w; i > 0, j > 0, k > 0; i -= 4, j -= 4) {       ans += 2 * i + 2 * j;       ans -= 4;       k--;     }     cout << ans << endl;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long double t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(0);     int t;     std::cin >> t;     while (t--) {       int n;       std::cin >> n;       std::string res(n,  a );       if (n == 1)         0;       else if (n % 2) {         res[(n - 3) / 2] =  b ;         res[n - 1] =  c ;       } else {         res[n / 2 - 1] =  b ;       }       std::cout << res <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int XI = INT_MAX, NI = INT_MIN, MOD = 1e9 + 7;   string s;   int a[400];   int main() {     cin >> s;     for (int i = 0; i < 26; i++) {       a[s[i]]++;     }     for (int i = 25; i < s.length(); i++) {       bool k = 1;       int cnt = 0;       string second =   ;       for (int j =  A ; j <=  Z ; j++) {         if (a[j] > 1) {           k = 0;           break;         }         if (a[j] == 0) {           cnt++;           second += (char)j;         }       }       if (cnt != a[ ? ]) k = 0;       if (k) {         int y = 0;         for (int x = 0; x < i - 25; x++) {           if (s[x] !=  ? )             cout << s[x];           else             cout <<  A ;         }         for (int x = i - 25; x < i + 1; x++) {           if (s[x] !=  ? )             cout << s[x];           else {             cout << second[y];             y++;           }         }         for (int x = i + 1; x < s.length(); x++) {           if (s[x] !=  ? )             cout << s[x];           else             cout <<  A ;         }         cout << endl;         return 0;       }       if (i + 1 == s.size()) break;       a[s[i + 1]]++;       a[s[i - 25]]--;     }     cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2000 + 10, inf = 1000000000;   int n, k, com[maxn], mn[maxn][maxn], dp[2 * maxn][maxn], ind[maxn][maxn], u = 1;   string s[maxn];   void go(int l, int r) {     if (l == r) return;     ind[l][r] = u++;     int pos = l;     for (int i = l; i < r; i++)       if (com[i] < com[pos]) pos = i;     mn[l][r] = pos;     go(l, pos);     go(pos + 1, r);   }   void solve(int l, int r) {     if (l == r) return;     int id = ind[l][r];     int pos = mn[l][r];     solve(l, pos);     solve(pos + 1, r);     int id1 = ind[l][pos];     int id2 = ind[pos + 1][r];     for (int i = 0; i <= pos - l + 1; i++)       for (int j = 0; j <= r - pos; j++) {         dp[id][i + j] =             max(dp[id][i + j], dp[id1][i] + dp[id2][j] + (j * i * com[pos]));       }   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> s[i];     sort(s + 1, s + 1 + n);     for (int i = 2; i <= n; i++) {       int t = 0;       for (int j = 0; j < min(s[i].size(), s[i - 1].size()); j++, t++) {         if (s[i - 1][j] != s[i][j]) break;       }       com[i - 1] = t;     }     go(1, n);     solve(1, n);     cout << dp[1][k] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, viz[501], a[501][2], l[501], sol[501];   int ABC(int a) { return (a) > 0 ? (a) : (-(a)); }   int main() {     int i, j, x;     cin >> n >> m;     for (i = 0; i < n; i++) cin >> a[i][0] >> a[i][1];     for (i = 0; i < m; i++) cin >> l[i];     for (i = 0; i < n; i++)       for (j = 0; j < m && !viz[i]; j++)         if (i > 0 && i < n - 1) {           if ((x = (ABC(a[i][0] - a[i - 1][0]) + ABC(a[i][1] - a[i - 1][1]) +                     ABC(a[i][0] - a[i + 1][0]) + ABC(a[i][1] - a[i + 1][1]))) ==               l[j]) {             viz[i] = viz[i - 1] = viz[i + 1] = 1;             sol[i - 1] = sol[i + 1] = -1;             sol[i] = j + 1;             l[j] = -1;             break;           }         } else if (!i) {           if ((x = ABC(a[i][0] - a[n - 1][0]) + ABC(a[i][1] - a[n - 1][1]) +                    ABC(a[i][0] - a[i + 1][0]) + ABC(a[i][1] - a[i + 1][1])) ==               l[j]) {             viz[i] = viz[n - 1] = viz[i + 1] = 1;             sol[n - 1] = sol[i + 1] = -1;             sol[i] = j + 1;             l[j] = -1;             break;           }         } else if ((x = ABC(a[i][0] - a[i - 1][0]) + ABC(a[i][1] - a[i - 1][1]) +                         ABC(a[i][0] - a[0][0]) + ABC(a[i][1] - a[0][1])) ==                    l[j]) {           viz[i] = viz[i - 1] = viz[0] = 1;           sol[i - 1] = sol[0] = -1;           sol[i] = j + 1;           l[j] = -1;           break;         }     for (i = 0; i < n; i++)       if (!viz[i]) break;     if (i < n)       cout <<  NO n ;     else {       cout <<  YES n ;       for (i = 0; i < n; i++) cout << sol[i] <<    ;     }     return 0;   }