malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, temp, sum = 0;     cin >> n;     int arr[n];     memset(arr, 0, sizeof(arr));     for (int i = 0; i < n; i++) {       cin >> arr[i];       sum += arr[i];       if (i == 0)         temp = arr[0];       else if (arr[i] > temp)         temp = arr[i];     }     while (((temp * n) - sum) <= sum) {       temp++;     }     cout << temp;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 10000;   const int MAXM = 100000;   const int INF = 0x3f3f3f3f;   pair<int, int> nxt[3][3];   int cot[3][3];   map<pair<int, int>, pair<long long, long long> > ma;   int main() {     long long k;     int a, b;     scanf( %I64d%d%d , &k, &a, &b);     a--, b--;     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         int x;         scanf( %d , &x);         x--;         nxt[i][j].first = x;       }     }     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         int x;         scanf( %d , &x);         x--;         nxt[i][j].second = x;       }     }     pair<int, int> s = pair<int, int>(a, b);     pair<long long, long long> now = pair<long long, long long>(0, 0);     int cc = 0;     while (ma.count(s) == 0) {       if (k == 0) break;       k--;       cot[s.first][s.second] = cc++;       ma[s] = now;       if ((s.first + 1) % 3 == s.second)         now.second++;       else if (s.first == (1 + s.second) % 3)         now.first++;       s = nxt[s.first][s.second];     }     if (ma.count(s)) {       pair<long long, long long> ans = now;       now.first -= ma[s].first;       now.second -= ma[s].second;       long long lun = cc - cot[s.first][s.second];       long long kk = k / lun;       k %= lun;       ans.first += now.first * kk;       ans.second += now.second * kk;       now = pair<long long, long long>(0, 0);       while (k--) {         if ((s.first + 1) % 3 == s.second)           now.second++;         else if (s.first == (1 + s.second) % 3)           now.first++;         s = nxt[s.first][s.second];       }       ans.first += now.first;       ans.second += now.second;       printf( %I64d %I64d n , ans.first, ans.second);     } else {       s = nxt[s.first][s.second];       printf( %I64d %I64d n , now.first, now.second);     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T GCD(T a, T b) {     return b ? GCD(b, a % b) : a;   }   template <class T>   inline T LCM(T a, T b) {     if (a < 0) return LCM(-a, b);     if (b < 0) return LCM(a, -b);     return a * (b / GCD(a, b));   }   int main() {     int n, s;     cin >> n >> s;     int dol[n];     int cent[n];     int sweet = 0;     int y = 0;     int flag = 0;     for (int i = 0; i < n; i++) {       cin >> dol[i] >> cent[i];       if (cent[i] != 0)         sweet = 100 - cent[i];       else         sweet = 0;       if (dol[i] < s || (dol[i] == s && cent[i] == 0)) {         flag = 1;         if (y < sweet) {           y = sweet;         }       }     }     if (flag == 0)       cout <<  -1  << endl;     else       cout << y << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000100;   int bit[MAXN];   int main() {     ios::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       int w;       cin >> w;       bit[w]++;     }     int step = 0;     for (int i = 0; i < MAXN - 1; ++i) {       bit[i + 1] += bit[i] / 2;       bit[i] %= 2;       step += bit[i];     }     cout << step << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10, mod = 1e9 + 7;   int ans[N], a[N];   vector<pair<int, int> > v;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     long long sum = 0;     for (int i = 0; i < m; i++) {       cin >> a[i];       sum += a[i];     }     if (sum < n) return cout << -1, 0;     int cur = 0;     for (int i = 0; i < m; i++) {       if (n - cur < a[i]) return cout << -1, 0;       ans[i] = cur;       sum -= a[i];       cur++;       a[i]--;       while (a[i] && n - cur > sum) cur++, a[i]--;     }     for (int i = 0; i < m; i++) cout << ans[i] + 1 <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e5 + 5;   const long long mod = 1e9 + 7;   const double eps = 1e-9;   const double pi = acos(-1.0);   const long long inf = 0x3f3f3f3f;   long long n, m;   long long a[maxn];   long long s1[maxn], s2[maxn];   long long sum1[maxn], sum2[maxn];   int main() {     cin >> n >> m;     a[1] = 0;     for (long long i = 2; i <= n + 1; i++) scanf( %lld , &a[i]);     a[n + 2] = m;     n++, n++;     long long k1 = 1, k2 = 1;     for (long long i = 1; i < n; i += 2) {       s1[k1++] = a[i + 1] - a[i];     }     for (long long i = 2; i < n; i += 2) {       s2[k2++] = a[i + 1] - a[i];     }     for (long long i = 1; i < k1; i++) sum1[i] = sum1[i - 1] + s1[i];     for (long long i = 1; i < k2; i++) sum2[i] = sum2[i - 1] + s2[i];     long long ans = sum1[k1 - 1];     for (long long i = 1; i < n; i++) {       long long sum = 0;       if ((a[i + 1] - a[i] != 1) && (i % 2 != 0)) {         sum += sum1[i / 2] + a[i + 1] - 1 - a[i];         long long num = n - i;         long long nn = n;         if (num % 2) nn--;         sum += sum2[nn / 2] - sum2[i / 2];       } else if (a[i + 1] - a[i] != 1 && (i % 2 == 0)) {         sum += sum1[i / 2] + a[i + 1] - (a[i] + 1);         long long num = n - (i + 1);         long long nn = n;         if (num % 2) nn--;         sum += sum2[nn / 2] - sum2[i / 2];       }       ans = max(ans, sum);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization( unroll-loops )   using namespace std;   void solve() {     long long n;     cin >> n;     vector<long long> a(n);     for (auto &x : a) cin >> x;     if (*min_element(a.begin(), a.end()) == 1) {       cout << n + 1 <<    ;       for (long long i = 1; i <= n; i++) cout << i <<    ;     } else {       long long k;       for (long long i = n - 1; i >= 0; i--) {         if (!a[i]) {           k = i;           break;         }       }       for (long long i = 0; i <= k; i++) cout << i + 1 <<    ;       cout << n + 1 <<    ;       for (long long i = k + 1; i <= n - 1; i++) cout << i + 1 <<    ;     }     cout <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   set<int> s;   int n, t;   char a[maxn];   int pos;   int main() {     register int i, tail, g;     scanf( %d%d , &n, &t);     scanf( %s , a + 1);     for (i = 1; i <= n; i++)       if (a[i] ==  . ) {         pos = i;         break;       }     g = pos;     for (i = pos; i <= n; i++)       if (a[i] >=  5 ) {         g = i;         break;       }     a[0] =  0 ;     bool f;     tail = n;     while (t-- && (g > pos && a[g] >=  5 )) {       a[g] =  0 ;       tail = g;       if (g != pos + 1) {         a[g - 1]++;         f = true;         g = g - 1;       } else {         a[g - 2]++;         g = g - 2;       }       while (g >= 0 && a[g] ==  : ) {         if (g - 1 == pos) {           a[g] =  0 ;           a[g - 2]++;           g -= 2;         } else {           a[g] =  0 ;           a[g - 1]++;           --g;         }       }     }     if (a[0] !=  0 ) printf( %c , a[0]);     for (i = 1; i < pos; i++) printf( %c , a[i]);     while (a[tail] ==  0 ) --tail;     if (tail != pos) {       printf( %c , 46);       for (i = pos + 1; i <= tail; i++) printf( %c , a[i]);     }     puts(  );   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, const U &b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, const U &b) {     if (a < b) a = b;   }   int a[2020];   struct Dinic {     int V, E, src, tar;     int head[2020], work[2020], dis[2020];     int to[8080], nxt[8080];     long long cap[8080];     int q[2020], qf, qb;     void init(int n, int s, int t) {       V = n + 1;       E = 0;       src = s;       tar = t;       for (int i = 0; i <= V; i++) head[i] = -1;     }     void add(int u, int v, long long c) {       to[E] = v;       cap[E] = c;       nxt[E] = head[u];       head[u] = E++;       to[E] = u;       cap[E] = 0;       nxt[E] = head[v];       head[v] = E++;     }     bool bfs() {       for (int i = 0; i <= V; i++) dis[i] = -1;       qf = qb = 0;       q[qb++] = src;       dis[src] = 0;       while (qf < qb && dis[tar] == -1) {         int u = q[qf++];         for (int i = head[u]; i >= 0; i = nxt[i]) {           int v = to[i];           if (dis[v] == -1 && cap[i] > 0) {             dis[v] = dis[u] + 1;             q[qb++] = v;           }         }       }       return dis[tar] >= 0;     }     long long dfs(int u, long long &bot) {       int v;       long long bot1, delta;       if (u == tar) return bot;       for (int &i = work[u]; i >= 0; i = nxt[i]) {         int v = to[i];         if (dis[v] != dis[u] + 1 || cap[i] == 0) continue;         bot1 = min(bot, cap[i]);         if (delta = dfs(v, bot1)) {           cap[i] -= delta;           cap[i ^ 1] += delta;           bot = bot1;           return delta;         }       }       return 0;     }     long long dinic() {       long long ans = 0, delta, bot;       while (bfs()) {         memcpy(work, head, sizeof(int) * V);         delta = 0x3f3f3f3f3f3f3f3fLL;         while (delta = dfs(src, bot = 0x3f3f3f3f3f3f3f3fLL)) ans += delta;       }       return ans;     }   } dinic;   int main() {     int n, m;     scanf( %d %d , &n, &m);     int src = n + m + 1, tar = src + 1;     dinic.init(tar, src, tar);     for (int i = 1; i <= n; i++) {       scanf( %d , a + i);       dinic.add(src, i, a[i]);     }     long long ans = 0;     for (int i = n + 1, u, v, w; i <= n + m; i++) {       scanf( %d %d %d , &u, &v, &w);       dinic.add(u, i, 0x3f3f3f3f3f3f3f3fLL);       dinic.add(v, i, 0x3f3f3f3f3f3f3f3fLL);       dinic.add(i, tar, w);       ans += w;     }     printf( %I64d n , ans - dinic.dinic());   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 0.000001;   const long double pi = acos(-1);   const int maxn = 1e7 + 9;   const int mod = 1e9 + 7;   const long long MOD = 1e18 + 9;   const long long INF = 1e18 + 123;   const int inf = 2e9 + 11;   const int mxn = 1e6 + 9;   const int N = 1e6 + 123;   const int M = 22;   const int pri = 997;   const int Magic = 2101;   const int dx[] = {-1, 0, 1, 0};   const int dy[] = {0, -1, 0, 1};   int n, m, k;   int cnt[N];   string s;   int a[N];   vector<int> g[N];   int u[N];   int ans, res;   int cur;   long long fac[N];   long long bpow(long long a, long long b) {     long long res = 1;     while (b > 0) {       if (b & 1) (res *= a) %= mod;       b /= 2;       a *= a;       a %= mod;     }     return res;   }   inline void upd(long long &ans, long long l, long long r) {     ans *= fac[r];     ans %= mod;     ans = (ans * bpow(fac[l - 1], mod - 2)) % mod;   }   inline long long calc(vector<int> &pw) {     long long ans = 1, pref = 0;     vector<long long> f;     for (auto e : pw) {       f.push_back((n / e) - pref);       (ans *= f.back()) %= mod;       pref = n / e;     }     long long cur = 1;     for (int i = (int)(pw.size()) - 1; ~i; --i) {       upd(ans, cur, cur + f[i] - 2);       cur += f[i];     }     return ans;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     vector<int> pw;     pw.push_back(1);     while (pw.back() * 2 <= n) {       pw.push_back(pw.back() * 2);     }     reverse(pw.begin(), pw.end());     fac[0] = 1;     for (int i = 1; i <= n; i++) fac[i] = (fac[i - 1] * i) % mod;     long long ans = calc(pw);     if (pw[0] * 3ll <= n * 2ll) {       for (int i = 1; i < (int)(pw.size()); i++) {         vector<int> o = pw;         for (int j = 0; j < i; j++) {           o[j] = 3ll * o[j] / 2ll;         }         ans += calc(o);         if (ans >= mod) ans -= mod;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int maxn = 100005;   int a[maxn], lefts[maxn], rights[maxn];   int main() {     int n, l, r, q1, q2;     cin >> n >> l >> r >> q1 >> q2;     memset(lefts, 0, sizeof(lefts));     memset(rights, 0, sizeof(rights));     for (int i = 0; i < n; i++) {       cin >> a[i];       lefts[i + 1] += (lefts[i] + a[i]);     }     for (int i = n - 1; i >= 0; i--) {       rights[n - i] += (rights[n - i - 1] + a[i]);     }     int sum = 0, ans = INF;     for (int i = 0; i <= n; i++) {       sum = 0;       sum += ((lefts[i] * l) + rights[n - i] * r);       if (i > (n - i))         sum += ((2 * i - n - 1) * q1);       else if (i < (n - i))         sum += ((n - 2 * i - 1) * q2);       ans = min(ans, sum);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma )   #pragma GCC optimize( unroll-loops )   using namespace std;   double eps = 1e-12;   long long hcf(long long p, long long q) {     if (p > q) return hcf(q, p);     if (!p) return q;     return hcf(q % p, p);   }   long long lcm(long long p, long long q) { return p * q / hcf(p, q); }   long long power(long long a, long long n, long long mod) {     long long ans = 1;     while (n) {       if (n % 2) ans *= a;       a *= a;       n /= 2;       a %= mod;       ans %= mod;     }     return ans;   }   long long fac(long long k, long long mod) {     long long ans = 1;     for (long long i = 1; i < k + 1; i++) {       ans *= i;       ans %= mod;     }     return ans;   }   void solve() {     long long a, b, c;     cin >> a >> b >> c;     long long k = a - b;     if (k + c > 0 && k - c > 0)       cout <<  + ;     else if (k + c < 0 && k - c < 0)       cout <<  - ;     else if (k + c == 0 && k - c == 0)       cout << 0;     else       cout <<  ? ;     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100005], b[100005];   const long long INF = 1000000009;   int main() {     int n, x, y;     cin >> n >> x >> y;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) b[i] = INF;     for (int i = 0; i < n; i++)       for (int j = i - y; j <= i + x && j < n; j++)         if (j >= 0 && j != i) b[j] = min(a[i], b[j]);     int k = 0;     while (b[k] < a[k]) k++;     cout << k + 1;     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, m, i, a;     int f[105] = {0};     scanf( %d%d , &n, &m);     while (m--) {       scanf( %d , &a);       for (i = a; i <= n; i++)         if (f[i] == 0) f[i] = a;     }     for (i = 1; i < n; i++) printf( %d  , f[i]);     printf( %d n , f[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s, p;   vector<int> a, b, x, y;   int main() {     cin >> s >> p;     a.push_back(0);     b.push_back(0);     x.push_back(0);     y.push_back(0);     for (int i = 0; i < s.size(); i++) {       a.push_back(a[a.size() - 1]);       x.push_back(x[x.size() - 1]);       if (s[i] !=  A ) {         a[a.size() - 1]++;         x[x.size() - 1] = i + 1;       }     }     for (int i = 0; i < p.size(); i++) {       b.push_back(b[b.size() - 1]);       y.push_back(y[y.size() - 1]);       if (p[i] !=  A ) {         b[b.size() - 1]++;         y[y.size() - 1] = i + 1;       }     }     int q;     int r1, r2;     cin >> q;     int i, j, k, l;     int moze;     for (; q > 0; q--) {       moze = 1;       cin >> i >> j >> k >> l;       if ((b[l] - b[k - 1]) - (a[j] - a[i - 1]) < 0) {         moze = 0;       }       if (((b[l] - b[k - 1]) - (a[j] - a[i - 1])) % 2 != 0) {         moze = 0;       }       r2 = l - y[l];       r1 = j - x[j];       if (r1 > j - i + 1) r1 = j - i + 1;       if (r2 > l - k + 1) r2 = l - k + 1;       if (r1 < r2) {         moze = 0;       } else if ((a[j] - a[i - 1]) == 0 && (b[l] - b[k - 1]) > 0 && r1 == r2)         moze = 0;       else {         if ((r1 - r2) % 3 != 0 && (b[l] - b[k - 1]) - (a[j] - a[i - 1]) == 0) {           moze = 0;         }       }       cout << moze;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   const int mod = 1e9 + 7;   const double eps = 1e-8;   const double PI = acos(-1.0);   int a[N], l[N], r[N], d[N], cha[N];   int m, n, k, t;   bool check(int x) {     if (!x) return true;     for (int i = 0; i <= n + 1; i++) cha[i] = 0;     int g = a[x];     for (int i = 1; i <= k; i++) {       if (d[i] > g) {         cha[l[i]]++, cha[r[i] + 1]--;       }     }     int res = 0;     for (int i = 1; i <= n + 1; i++) {       cha[i] += cha[i - 1];       if (cha[i] > 0) res++;     }     return res * 2 + n + 1 <= t;   }   int main() {     std::ios::sync_with_stdio(false);     cin >> m >> n >> k >> t;     for (int i = 1; i <= m; i++) cin >> a[i];     sort(a + 1, a + 1 + m, greater<int>());     for (int i = 1; i <= k; i++) cin >> l[i] >> r[i] >> d[i];     int L = 0, R = m, M, ans = 0;     while (L <= R) {       M = (L + R) >> 1;       if (check(M)) {         ans = M;         L = M + 1;       } else         R = M - 1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, Count = 0, a[2005], Free[2005];   vector<int> V;   int main() {     cin >> n >> k;     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (a[i] <= k)         Free[a[i]]++;       else         V.push_back(i);     }     for (int i = 1; i <= k; i++)       while (V.size() > 0 && Free[i] < n / k) {         Free[i]++;         Count++;         a[V.back()] = i;         V.pop_back();       }     for (int i = 1; i <= k; i++)       if (Free[i] < n / k) {         for (int j = 1; j <= n; j++)           if (Free[a[j]] > n / k) {             Free[a[j]]--;             Free[i]++;             Count++;             a[j] = i;             if (Free[i] == n / k) break;           }       }     cout << n / k <<     << Count <<   n ;     for (int i = 1; i <= n; i++) cout << a[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 35;   const int MOD = 1e9 + 7;   long long n;   int K, c, res;   struct mat {     int d[N][N];     mat() { memset(d, 0, sizeof d); }   } F[N * 2][N], P[N * 2][N], Q[N * 2][N], G;   int lst[N * 2];   mat operator*(mat a, mat b) {     mat c;     for (int i = 0; i <= K; ++i)       for (int j = 0; j <= K; ++j)         for (int k = 0; k <= K; ++k)           c.d[i][k] = (c.d[i][k] + 1ll * a.d[i][j] * b.d[j][k]) % MOD;     return c;   }   int main() {     cin >> n >> K;     while (n) lst[c++] = n % K, n /= K;     for (int i = 0; i < c; ++i) {       if (i == 0) {         for (int j = 0; j < K; ++j) {           for (int p = 0; p < K; ++p) F[i][j].d[p][p] = 1;           for (int p = 0; p <= K; ++p) F[i][j].d[j][p] = 1;           F[i][j].d[K][K] = 1;         }       } else {         for (int j = 1; j < K; ++j) F[i][j] = Q[i - 1][j] * P[i - 1][j - 1];         F[i][0] = Q[i - 1][0];       }       P[i][0] = F[i][0];       for (int j = 1; j < K; ++j) P[i][j] = P[i][j - 1] * F[i][j];       Q[i][K - 1] = F[i][K - 1];       for (int j = K - 2; ~j; --j) Q[i][j] = F[i][j] * Q[i][j + 1];     }     for (int i = 0; i <= K; ++i) G.d[i][i] = 1;     for (int i = c - 1, s = 0; ~i; --i) {       for (int j = 0; j < lst[i]; ++j) G = G * F[i][(s + j) % K];       s = (s + lst[i]) % K;     }     res = 1;     for (int i = 0; i < K; ++i) res = (res + G.d[i][K]) % MOD;     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long aabs(long long a) {     if (a < 0)       return -a;     else       return a;   }   struct node {     long long num;     int id;     bool operator<(const node &a) const { return aabs(num) > aabs(a.num); }   };   long long a[200005];   long long n, k, x;   int main() {     int i;     scanf( %I64d%I64d%I64d , &n, &k, &x);     int sign = 1;     priority_queue<node> que;     for (i = 1; i <= n; i++) {       scanf( %I64d , &a[i]);       if (a[i] < 0) sign = -sign;       que.push((node){a[i], i});     }     while (k--) {       node temp = que.top();       que.pop();       if (a[temp.id] < 0) {         if (sign == -1)           a[temp.id] -= x;         else           a[temp.id] += x;         if (a[temp.id] >= 0) sign = -sign;       } else {         if (sign == -1)           a[temp.id] += x;         else           a[temp.id] -= x;         if (a[temp.id] < 0) sign = -sign;       }       que.push((node){a[temp.id], temp.id});     }     for (i = 1; i < n; i++) {       printf( %I64d  , a[i]);     }     printf( %I64d n , a[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long const N = 1e5 + 100, INF = 1ll * 1e9 * 1e9 + 100;   long long n, m, s, t;   long long h[N], d[N], dis[2][N], ans[N];   pair<pair<long long, long long>, long long> e[N];   vector<long long> f[N], g[N];   set<pair<long long, long long> > st;   bool vis[N];   void dij(bool b, long long s) {     dis[b][s] = 0;     st.insert({0, s});     while (st.size()) {       long long v = st.begin()->second;       st.erase(st.begin());       for (long long i : g[v]) {         long long u = e[i].first.first + e[i].first.second - v, w = e[i].second;         if (b ^ (u != e[i].first.second)) continue;         if (dis[b][v] + w < dis[b][u]) {           st.erase({dis[b][u], u});           dis[b][u] = dis[b][v] + w;           st.insert({dis[b][u], u});         }       }     }   }   void cut_edge(long long v = 0, long long i = -1) {     long long p = (~i ? e[i].first.first + e[i].first.second - v : -1);     vis[v] = 1;     d[v] = h[v];     for (long long j : f[v]) {       long long u = e[j].first.first + e[j].first.second - v;       if (vis[u]) {         if (i != j) {           ans[j] = 1;           d[v] = min(d[v], h[u]);           if (h[u] == h[p]) ans[i] = 1;         }         continue;       }       h[u] = h[v] + 1;       cut_edge(u, j);       if (d[u] != h[u]) ans[j] = 1;       d[v] = min(d[v], d[u]);     }   }   int32_t main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     fill(d, d + N, INF);     fill(dis[0], dis[0] + N, INF);     fill(dis[1], dis[1] + N, INF);     cin >> n >> m >> s >> t;     s--, t--;     for (long long i = 0, u, v, w; i < m; i++) {       cin >> u >> v >> w;       u--, v--;       e[i] = {{u, v}, w};       g[u].push_back(i);       g[v].push_back(i);     }     dij(0, s), dij(1, t);     for (long long i = 0; i < m; i++) {       long long u = e[i].first.first, v = e[i].first.second, w = e[i].second;       long long path = dis[0][u] + w + dis[1][v];       if (path == dis[0][t]) {         f[u].push_back(i);         f[v].push_back(i);       } else {         ans[i] = path - dis[0][t] + 1;       }     }     cut_edge(s);     for (long long i = 0; i < m; i++) {       long long w = e[i].second;       if (w - ans[i] <= 0)         cout <<  NO n ;       else if (!ans[i])         cout <<  YES n ;       else         cout <<  CAN   << ans[i] <<   n ;     }   }