malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     assert(n >= 1 && n <= 10000 && m >= 1 && m <= 10);     if (n == m && (n == 1 || n == 2))       cout << n << endl;     else {       if (n == m)         cout << n << endl;       else {         int t2 = 0, t1 = 0;         if (n & 1) {           n--;           t1++;         }         t2 = n / 2;         while ((t2 + t1) % m != 0 && n > 0) {           n = n - 2;           t1 = t1 + 2;           t2 = n / 2;         }         if (n == 0)           cout << -1 << endl;         else           cout << t1 + t2 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 2e18 + 9;   const long long MAXN = 1e6 + 7;   const long long MAXN1 = 5e2 + 7;   const long long MOD = 1e9 + 7;   const long long ST = 157;   const long long ST1 = 199;   const long double EPS = 1e-9;   const long long BLOCK = 138;   void solve();   signed main() {     srand( a  +  l  +  e  +  x  +  X  +  5  +  1  +  2 );     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();   }   void solve() {     int n;     cin >> n;     vector<pair<long long, int>> v;     for (int i = 0; i < n; i++) {       long long l, r;       cin >> l >> r;       v.emplace_back(l, -1);       v.emplace_back(r, 1);     }     sort(v.begin(), v.end());     vector<long long> ans(n + 1);     int b = -1;     for (int i = 1; i < 2 * n; i++) {       if (v[i].second == -1) {         if (v[i - 1].second == 1) {           ans[-b] += v[i].first - v[i - 1].first - 1;         } else {           ans[-b] += v[i].first - v[i - 1].first;         }       } else {         if (v[i].first != v[i - 1].first || v[i - 1].second == -1) {           if (v[i - 1].second == 1)             ans[-b] += v[i].first - v[i - 1].first;           else             ans[-b] += v[i].first - v[i - 1].first + 1;         }       }       b += v[i].second;     }     for (int i = 1; i <= n; i++) {       cout << ans[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long int t = 1;     cin >> t;     while (t--) {       long long int p, q, x;       cin >> p >> q;       long long int b = 0;       set<long long int> pf;       long long int cq = q;       for (long long int i = 2; i * i <= cq; i++) {         while (cq % i == 0) {           pf.insert(i);           cq /= i;         }       }       if (cq > 1) pf.insert(cq);       for (long long int i : pf) {         long long int cp = p;         while (cp % q == 0) cp /= i;         b = max(b, cp);       }       cout << b << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double v, d, l, g, r;     cin >> l >> d >> v >> g >> r;     double t;     t = d / v;     double k = 0;     while (k <= t) {       k += g;       if (t < k) {         t += (l - d) / v;         cout << setprecision(8) << t;         exit(0);       }       k += r;       if (t < k) {         t += (k - t);         t += (l - d) / v;         cout << setprecision(8) << t;         exit(0);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1);   const double eps = 0.000000001;   double dist(double x, double y) { return x * x + y * y; }   double xx, yy, v, t, x, y, r;   int n;   vector<pair<double, int> > vt;   int main() {     scanf( %lf %lf %lf %lf %d , &xx, &yy, &v, &t, &n);     if (t == 0) {       for (int i = 0; i < n; ++i) {         scanf( %lf %lf %lf , &x, &y, &r);         if (dist(x - xx, y - yy) <= r * r) {           printf( 1.00000 );           return 0;         }       }       printf( 0.00 );       return 0;     }     v *= t;     for (int i = 0; i < n; ++i) {       scanf( %lf %lf %lf , &x, &y, &r);       x -= xx;       y -= yy;       double dd = dist(x, y);       double d = sqrt(dd);       if (dd < r * r + eps) {         printf( 1.0000 );         return 0;       }       if (d - eps > v + r) continue;       double ang, ang1, ang2;       ang = atan2(y, x);       if (ang < 0) ang += pi * 2;       if (dd - r * r < v * v + eps)         ang1 = asin(r / d);       else {         double tmp = 0.5 * (v * v - r * r + dd) / (d * v);         ang1 = acos(tmp);       }       ang2 = ang + ang1;       ang1 = ang - ang1;       if (ang1 < 0) {         vt.push_back(pair<double, int>(ang1 + pi * 2, 1));         vt.push_back(pair<double, int>(pi * 2, -1));         vt.push_back(pair<double, int>(0.0, 1));         vt.push_back(pair<double, int>(ang2, -1));       } else if (ang2 > pi * 2) {         vt.push_back(pair<double, int>(ang1, 1));         vt.push_back(pair<double, int>(pi * 2, -1));         vt.push_back(pair<double, int>(0.0, 1));         vt.push_back(pair<double, int>(ang2 - pi * 2, -1));       } else {         vt.push_back(pair<double, int>(ang1, 1));         vt.push_back(pair<double, int>(ang2, -1));       }     }     double tot = 0, beg = 0;     int cnt = 0;     sort(vt.begin(), vt.end());     for (int i = 0; i < (int)vt.size(); ++i) {       if (cnt > 0) tot += vt[i].first - beg;       cnt += vt[i].second;       beg = vt[i].first;     }     tot /= pi * 2;     printf( %.12lf , tot);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int nexto[120];   int ara[120];   int main() {     std::ios_base::sync_with_stdio(false);     ;     int n;     cin >> n;     for (int i = 0; i <= n - 1; i++) {       cin >> ara[i];     }     int tt = n;     for (int i = n - 1; i >= 0; i--) {       nexto[i] = tt;       if (ara[i] == 1) {         tt = i;       }     }     if (tt == n) {       cout << 0 <<   n ;       return 0;     }     nexto[n] = n;     long long shuru;     if (ara[0] == 1) {       shuru = 0;     } else {       shuru = nexto[0];     }     long long ans = 1;     for (;;) {       if (shuru >= n) {         break;       }       long long shesh = nexto[shuru];       if (shesh >= n) {         break;       }       ans *= (shesh - shuru);       shuru = shesh;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename A, typename B>   inline void chmin(A &a, B b) {     if (a > b) a = b;   }   template <typename A, typename B>   inline void chmax(A &a, B b) {     if (a < b) a = b;   }   string S;   long long dp[3333333];   signed main() {     for (long long i = 0; i < 26; i++) S += (char)( a  + i);     for (long long i = 0; i < 26; i++) S += (char)( A  + i);     fill_n(dp, 1111111, INT_MAX);     dp[1] = 0;     for (long long i = 1; i < 1111111; i++) {       for (long long j = 1; j <= 2; j++) {         chmin(dp[i * j + 1], dp[i] + 1);       }     }     long long n;     cin >> n;     string s;     long long cur = 0;     while (n > 1) {       if ((n - 1) & 1) {         s += string(1, S[cur++]);         n--;       } else {         s += string(2, S[cur++]);         n = (n - 1) / 2;       }     }     for (long long i = 0; i < S.size(); i++) s += S[i];     cout << s <<     << S << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios_base::sync_with_stdio(false);     int n;     long long l, first, second;     cin >> n >> l >> first >> second;     vector<long long> a(n);     map<long long, bool> flag;     for (int i = 0; i < int(n); i++) {       cin >> a[i];       flag[a[i]] = true;     }     bool fx = false, fy = false;     for (int i = n - 1; i >= 0; i--) {       if (flag.count(a[i] - first)) fx = true;       if (flag.count(a[i] - second)) fy = true;     }     if (!fx && !fy) {       long long diff = second - first;       for (int i = 0; i < n; i++) {         if (flag.count(a[i] - diff)) {           if (a[i] + first <= l) {             cout << 1 <<   n ;             cout << a[i] + first;             return 0;           }           if (a[i] - second >= 0) {             cout << 1 <<   n ;             cout << a[i] - second;             return 0;           }         }       }       long long add = first + second;       for (int i = 0; i < n; i++) {         if (flag.count(a[i] + add)) {           if (a[i] + first <= l) {             cout << 1 <<   n ;             cout << a[i] + first;             return 0;           }         }       }       cout << 2 <<   n ;       cout << first <<     << second;     } else if (!fx) {       cout << 1 <<   n ;       cout << first;     } else if (!fy) {       cout << 1 <<   n ;       cout << second;     } else       cout <<  0 n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ull = unsigned long long;   using pii = pair<int, int>;   using pll = pair<ll, ll>;   template <class T>   inline bool Min(T &a, T b) {     return a > b ? (a = b, true) : false;   }   template <class T>   inline bool Max(T &a, T b) {     return a < b ? (a = b, true) : false;   }   inline int ni() {     int a;     scanf( %d , &a);     return a;   }   inline ll nl() {     ll a;     scanf( %lld , &a);     return a;   }   inline double nd() {     double a;     scanf( %lf , &a);     return a;   }   inline void pi(int a) { printf( %d  , a); }   inline void pl(ll a) { printf( %lld  , a); }   inline void pd(double a) { printf( %.12lf  , a); }   const int N = 2e5 + 100;   vector<int> gp[N];   bool is_university[N];   int n, k;   int cnt[N];   ll ans = 0;   void dfs(int v, int p) {     cnt[v] = is_university[v];     for (int next : gp[v])       if (next != p)         dfs(next, v), cnt[v] += cnt[next],             ans += min(cnt[next], k + k - cnt[next]);   }   void solve() {     n = ni();     k = ni();     for (int i = 0; i < (int)(k + k); ++i) is_university[ni()] = true;     for (int i = 0; i < (int)(n - 1); ++i) {       int a = ni();       int b = ni();       gp[a].push_back(b);       gp[b].push_back(a);     }     dfs(1, 1);     pl(ans);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     int a[n], b[n];     map<pair<int, int>, int> mpa, mpb;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < n; i++) {       cin >> b[i];     }     for (int i = 0, j = n - 1; i < j; i++, j--) {       int x = a[i];       int y = a[j];       if (x > y) swap(x, y);       mpa[{x, y}]++;     }     for (int i = 0, j = n - 1; i < j; i++, j--) {       int x = b[i];       int y = b[j];       if (x > y) swap(x, y);       mpb[{x, y}]++;     }     bool ok = true;     for (auto it : mpa) {       if (it.second != mpb[{it.first.first, it.first.second}]) {         ok = false;         break;       }     }     if (n % 2) {       if (a[n / 2] != b[n / 2]) ok = false;     }     cout << (ok ?  YES n  :  NO n );   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     int t = 1;     cin >> t;     for (int i = 1; i <= t; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int m = 0, i = 0, c[100], x, y, s1 = 0, s2 = 0, ans = 0;     scanf( %d , &m);     for (i = 0; i < m; i++) {       scanf( %d , &c[i]);       s1 += c[i];     }     scanf( %d%d , &x, &y);     for (i = 0; i < m; i++) {       s1 -= c[i];       s2 += c[i];       if ((s1 >= x) && (s1 <= y) && (s2 >= x) && (s2 <= y)) {         ans = i + 2;         break;       }     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   int isprime(long long p) {     int i;     double max = sqrt(p);     for (i = 2; i <= max; i++)       if (p % i == 0) break;     if (i > max && p != 1) return 1;     return 0;   }   long long gcd(long long a, long long b) {     long long i;     for (i = a < b ? a : b; i > 0; i--)       if ((a % i == 0) && (b % i == 0)) break;     return i;   }   int comp(const void *a, const void *b) { return (*(int *)a - *(int *)b); }   int issame(int *a, int *b, int l) {     qsort(a, l, sizeof(int), comp);     qsort(b, l, sizeof(int), comp);     int i;     for (i = 0; i < l; i++)       if (a[i] != b[i]) break;     if (i == l) return 1;     return 0;   }   void swap(int *a, int *b) {     int x = *a;     *a = *b;     *b = x;   }   int arrmax(int *a, int l) {     int i;     int max = a[0];     for (i = 1; i < l; i++)       if (a[i] > max) max = a[i];     return max;   }   int arrmin(int *a, int l) {     int i;     int min = a[0];     for (i = 1; i < l; i++)       if (a[i] < min) min = a[i];     return min;   }   long long fact(int a) {     long long p = 1;     while (a > 0) p *= a--;     return p;   }   int min(int a, int b) {     if (a > b) return b;     return a;   }   int max(int a, int b) {     if (a < b) return b;     return a;   }   void sieve(int *a, int n) {     n--;     long long i, j;     for (i = 2; i <= n; i++) a[i] = 0;     for (i = 2; i <= n; i++)       if (!a[i])         for (j = i * i; j <= n; j += i)           if (!a[j]) a[j]++;   }   int main(void) {     int t;     scanf( %d , &t);     while (t--) {       char b[100];       scanf( %s , b);       int l = strlen(b);       char c[l / 2 + 1];       int i;       for (i = 1; i < l; i += 2) c[i / 2 + 1] = b[i];       c[0] = b[0];       for (i = 0; i < l / 2 + 1; i++) printf( %c , c[i]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool chkmin(T &x, T y) {     return y < x ? x = y, 1 : 0;   }   template <class T>   inline bool chkmax(T &x, T y) {     return x < y ? x = y, 1 : 0;   }   inline long long Max(long long x, long long y) { return x > y ? x : y; }   inline long long Min(long long x, long long y) { return x < y ? x : y; }   int n, m;   int res;   map<int, int> lck;   map<int, int>::iterator it;   long long fac[100002], inv[100002];   long long dp[100002];   void Add(long long &x, long long y) {     x += y;     if (x >= 1000000007)       x -= 1000000007;     else if (x < 0)       x += 1000000007;   }   bool check(int x) {     while (x) {       if (x % 10 != 4 && x % 10 != 7) return 0;       x /= 10;     }     return 1;   }   void Init() {     fac[0] = fac[1] = 1;     inv[0] = inv[1] = 1;     for (int i = (2), i_end_ = (100002); i < i_end_; i++)       fac[i] = fac[i - 1] * i % 1000000007;     for (int i = (2), i_end_ = (100002); i < i_end_; i++)       inv[i] = (1000000007 - (1000000007 / i)) * inv[1000000007 % i] % 1000000007;     for (int i = (2), i_end_ = (100002); i < i_end_; i++)       inv[i] = inv[i] * inv[i - 1] % 1000000007;   }   long long C(int n, int m) {     if (n < 0 || m > n) return 0;     return fac[n] * inv[m] % 1000000007 * inv[n - m] % 1000000007;   }   int main() {     Init();     scanf( %d%d , &n, &m);     for (int i = (1), i_end_ = (n); i <= i_end_; i++) {       int x;       scanf( %d , &x);       if (check(x))         lck[x]++;       else         res++;     }     int tot = 0;     dp[0] = 1;     for (it = lck.begin(); it != lck.end(); it++) {       tot++;       for (int i = (min(tot, m)), i_end_ = (1); i >= i_end_; i--)         Add(dp[i], dp[i - 1] * it->second % 1000000007);     }     long long ans = 0;     for (int i = (0), i_end_ = (min(tot, m)); i <= i_end_; i++)       Add(ans, dp[i] * C(res, m - i) % 1000000007);     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long long INF = 1e9 + 9;   const long long N = 500500;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long T;     cin >> T;     while (T--) {       long long n, k;       cin >> n >> k;       string s, t;       cin >> s;       vector<pair<long long, long long> > ans;       for (long long i = 1; i <= k - 1; i++) {         t +=  () ;       }       for (long long i = 1; i <= (n - (2 * k) + 2) / 2; i++) {         t +=  ( ;       }       for (long long i = 1; i <= (n - (2 * k) + 2) / 2; i++) {         t +=  ) ;       }       for (long long i = 0; i < n; i++) {         if (s[i] == t[i]) continue;         for (long long j = i + 1; j < n; j++) {           if (s[j] == t[i]) {             ans.push_back({i + 1, j + 1});             reverse(s.begin() + i, s.begin() + j + 1);             break;           }         }       }       cout << ans.size() <<   n ;       for (auto z : ans) {         cout << z.first <<     << z.second <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, ans = 0, flag = 0;     int arr[100];     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i];       if (arr[i] != arr[i + 1]) {         flag = 1;       }     }     if (flag == 0) {       cout << ans << endl;       return 0;     }     for (int i = 0; i < n; i++) {       if (arr[i] == 0 && arr[i - 1] == 1 && arr[i + 1] == 1) {         arr[i + 1] = 0;         ans++;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5e5 + 5, Mod = 998244353;   char buf[1 << 12], *pp1 = buf, *pp2 = buf, nc;   int ny;   inline char gc() {     return pp1 == pp2 &&                    (pp2 = (pp1 = buf) + fread(buf, 1, 1 << 12, stdin), pp1 == pp2)                ? EOF                : *pp1++;   }   inline int read() {     int x = 0;     for (ny = 1; nc = gc(), (nc < 48 || nc > 57) && nc != EOF;)       if (nc == 45) ny = -1;     if (nc < 0) return nc;     for (x = nc - 48; nc = gc(), 47 < nc && nc < 58 && nc != EOF;          x = (x << 3) + (x << 1) + (nc ^ 48))       ;     return x * ny;   }   int n, k, m, ans = 1, s[MAXN], Mn[MAXN], l[MAXN], r[MAXN], c[MAXN], f[MAXN],                q[MAXN], head, tail;   inline void add(int& x, int y) { x += y, x >= Mod ? x -= Mod : 0; }   inline void sub(int& x, int y) { x -= y, x < 0 ? x += Mod : 0; }   inline int Solve(int k) {     memset(s, 0, sizeof(s));     for (int i = 1; i <= n; i++) Mn[i] = n + 1;     for (int i = 1; i <= m; i++) {       if (c[i] >> k & 1)         s[l[i]]++, s[r[i] + 1]--;       else         Mn[l[i]] = min(Mn[l[i]], r[i]);     }     for (int i = 1; i <= n; i++) s[i] += s[i - 1];     memset(f, 0, sizeof(f)), f[n + 1] = 1, q[head = tail = 1] = n + 1;     int sum = 1;     for (int i = 1; i <= n; i++) {       int tmp = 0;       for (; q[tail] >= Mn[i] && head <= tail;            add(tmp, f[q[tail]]), f[q[tail]] = 0, tail--)         ;       for (f[Mn[i]] = tmp, q[++tail] = Mn[i]; q[head] < i && head <= tail;            sub(sum, f[q[head]]), head++)         ;       if (!s[i]) add(f[n + 1], sum), sum = 2 * sum % Mod;       (q[tail] != n + 1 ? q[++tail] = n + 1 : 0);     }     return f[n + 1];   }   int main() {     n = read(), k = read(), m = read();     for (int i = 1; i <= m; i++) l[i] = read(), r[i] = read(), c[i] = read();     for (int i = 0; i <= k - 1; i++) ans = 1ll * ans * Solve(i) % Mod;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 111111;   const double inf = 0.000001;   const int INF = ~0U >> 1;   const int mod = 1000000007;   int n, a[maxn], m;   int equal(double x, double y) {     if (x - y >= -inf && x - y <= inf)       return 0;     else if (x - y > inf)       return 1;     return -1;   }   int main() {     scanf( %d , &n), scanf( %d , &m);     if (m < n / 2 || (n == 1 && m))       printf( %d n , -1);     else if (n == 1 && m == 0)       printf( %d n , 1);     else {       int ans = m - n / 2 + 1;       printf( %d %d , ans, ans * 2);       ans *= 2;       for (int i = 2; i < n; i++) printf(  %d , (++ans));     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 105;   char ch[2][M];   int dp[M][4], mask[M], n, ans;   void in() { scanf( %s%s , ch[0] + 1, ch[1] + 1); }   void ac() {     n = strlen(ch[0] + 1);     for (int i = 1; i <= n; ++i)       ch[0][i] ==  0  ? (ch[1][i] ==  0  ? mask[i] = 0 : mask[i] = 1)                       : (ch[1][i] ==  0  ? mask[i] = 2 : mask[i] = 3);     for (int i = 1; i <= n; ++i) dp[i][mask[i]] = 1;     dp[0][3] = 1;     for (int i = 1, j; i <= n; ++i) {       for (j = 0; j <= 3; ++j) dp[i][mask[i]] = max(dp[i][mask[i]], dp[i - 1][j]);       if (!mask[i]) {         for (j = 0; j <= 2; ++j) {           if (dp[i - 1][j]) dp[i][3] = max(dp[i - 1][j] + 1, dp[i][3]);         }         if (dp[i - 1][0])           for (j = 1; j <= 2; ++j) dp[i][j] = max(dp[i - 1][0] + 1, dp[i][j]);       } else if ((mask[i] == 1 || mask[i] == 2) && dp[i - 1][0])         dp[i][3] = max(dp[i][3], dp[i - 1][0] + 1);     }     for (int i = 0; i <= 3; ++i) ans = max(ans, dp[n][i]);     printf( %d , ans - 1);   }   int main() {     in();     ac();   }
#include <bits/stdc++.h>   using namespace std;   long long n, k;   vector<vector<long long>> ft(12, vector<long long>(100005, 0));   void add(long long kk, long long ind, long long val) {     while (ind <= n) {       ft[kk][ind] += val;       ind += ind & -ind;     }   }   long long sum(long long kk, long long ind) {     long long res = 0;     while (ind > 0) {       res += ft[kk][ind];       ind -= ind & -ind;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> k;     vector<long long> arr(n + 1);     for (int i = 1; i < n + 1; i++) cin >> arr[i];     for (int i = 1; i < n + 1; i++) {       for (int j = 1; j < 12; j++) {         if (j == 1)           add(1, arr[i], 1);         else {           long long val = sum(j - 1, arr[i] - 1);           add(j, arr[i], val);         }       }     }     cout << sum(k + 1, n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   int n, S = 0;   char x[2], s[MAXN];   int viv[MAXN];   bool use[MAXN];   int cqf() {     int l = -1, r = -1;     int ans = MAXN, sum = 0;     while (true) {       while (r <= n && sum < S) {         r++;         if (!viv[s[r]] && use[s[r]]) sum++;         viv[s[r]]++;       }       if (sum < S) break;       ans = min(ans, r - l + 1);       if (viv[s[l]] == 1 && use[s[l]]) sum--;       viv[s[l]]--;       l++;     }     return ans;   }   int main() {     memset(viv, 0, sizeof(viv));     memset(use, 0, sizeof(use));     scanf( %d , &n);     gets(x);     gets(s);     for (int i = 0; i < n; i++) {       if (use[s[i]] == false) S++;       use[s[i]] = true;     }     printf( %d n , cqf());     return 0;   }
#include <bits/stdc++.h>   int main() {     std::string input(  ), answer(  ), output(  );     getline(std::cin, input);     getline(std::cin, answer);     int count[10] = {0};     char minNonZero( A );     for (int k = 0; k < input.size(); k++) {       ++count[input[k] -  0 ];       if (input[k] >  0  && input[k] < minNonZero) {         minNonZero = input[k];       }     }     if (minNonZero ==  A ) {       output =  0 ;     } else {       --count[minNonZero -  0 ];       output += minNonZero;       for (int digit = 0; digit < 10; digit++) {         while (count[digit]--) {           output += ( 0  + digit);         }       }     }     if (answer == output) {       puts( OK );     } else {       puts( WRONG_ANSWER );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   int S[N], E[N], T[N], C[N];   int t[N], W[N];   int main() {     int n, m;     scanf( %d %d , &n, &m);     int i;     for (i = 1; i <= n; i++) {       t[i] = 1006;       W[i] = -1;     }     for (i = 1; i <= m; i++) {       scanf( %d %d %d %d , &S[i], &E[i], &T[i], &C[i]);       for (int j = S[i]; j <= E[i]; j++) {         if (T[i] < t[j]) {           t[j] = T[i];           W[j] = i;         }       }     }     int sum = 0;     for (i = 1; i <= n; i++) {       if (W[i] != -1) {         sum += C[W[i]];       }     }     printf( %d n , sum);     return 0;   }