Datasets:
				
			
			
	
			
			
	
		
		Upload 4 files
Browse files
    	
        cpp_dataset/train/train.jsonl
    CHANGED
    
    | @@ -53,3 +53,48 @@ | |
| 53 | 
             
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const long long INF = 1e18; n const int maxn = 2e6 + 10; n int a[maxn], cnt[maxn]; n long long sum[maxn]; n int main(void) { n   int n, x, y; n   scanf( %d %d %d , &n, &x, &y); n   int z = x / y; n   for (int i = 1; i <= n; i++) n     scanf( %d , a + i), cnt[a[i]]++, sum[a[i]] += a[i]; n   for (int i = 1; i <= 2000000; i++) cnt[i] += cnt[i - 1], sum[i] += sum[i - 1]; n   long long ans = INF; n   for (int i = 2; i <= 1000000; i++) { n     long long tmp = 0; n     int zz = min(z, i - 1); n     for (int j = 1; (j - 1) * i < 1000000; j++) { n       if (i - zz - 2 >= 0) n         tmp += (long long)(cnt[j * i - zz - 1] - cnt[j * i - i]) * x; n       if (zz) n         tmp += ((long long)i * j * (cnt[j * i - 1] - cnt[j * i - zz - 1]) - n                 (sum[j * i - 1] - sum[j * i - zz - 1])) * n                y; n     } n     ans = min(ans, tmp); n   } n   printf( %I64d n , ans); n   return 0; n } n "}
         | 
| 54 | 
             
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int md = 1e9 + 7; n int n; n char s[111]; n int f[111][3333]; n int main() { n   int t; n   f[0][0] = 1; n   for (int i = 1; i <= 100; ++i) { n     for (int j = 0; j <= 3000; ++j) { n       for (int c = 0; c <= min(j, 25); ++c) { n         f[i][j] += f[i - 1][j - c]; n         f[i][j] %= md; n       } n     } n   } n   scanf( %d , &t); n   while (t--) { n     scanf( %s , s); n     int sum = 0; n     for (int i = 0; i < strlen(s); ++i) sum += s[i] -  a ; n     printf( %d n , (f[strlen(s)][sum] + md - 1) % md); n   } n   return 0; n } n "}
         | 
| 55 | 
             
            {"func_code_string": "#include <bits/stdc++.h> n #pragma GCC optimize ( O3 ) n #pragma GCC target ( sse4 ) n   n using namespace std; n   n typedef long long ll; n typedef long double ld; n typedef complex<ld> cd; n   n typedef pair<int, int> pi; n typedef pair<ll,ll> pl; n typedef pair<ld,ld> pd; n   n typedef vector<int> vi; n typedef vector<ld> vd; n typedef vector<ll> vl; n typedef vector<pi> vpi; n typedef vector<pl> vpl; n typedef vector<cd> vcd; n  n template<class T> using pq = priority_queue<T>; n template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>; n   n #define FOR(i, a, b) for (int i=a; i<(b); i++) n #define F0R(i, a) for (int i=0; i<(a); i++) n #define FORd(i,a,b) for (int i = (b)-1; i >= a; i--) n #define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--) n #define trav(a,x) for (auto& a : x) n #define uid(a, b) uniform_int_distribution<int>(a, b)(rng) n   n #define sz(x) (int)(x).size() n #define mp make_pair n #define pb push_back n #define f first n #define s second n #define lb lower_bound n #define ub upper_bound n #define all(x) x.begin(), x.end() n #define ins insert n  n template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } n template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } n   n mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); n  n void __print(int x) {cerr << x;} n void __print(long x) {cerr << x;} n void __print(long long x) {cerr << x;} n void __print(unsigned x) {cerr << x;} n void __print(unsigned long x) {cerr << x;} n void __print(unsigned long long x) {cerr << x;} n void __print(float x) {cerr << x;} n void __print(double x) {cerr << x;} n void __print(long double x) {cerr << x;} n void __print(char x) {cerr <<      << x <<     ;} n void __print(const char *x) {cerr <<     << x <<    ;} n void __print(const string &x) {cerr <<     << x <<    ;} n void __print(bool x) {cerr << (x ?  true  :  false );} n  n template<typename T, typename V> n void __print(const pair<T, V> &x) {cerr <<  { ; __print(x.first); cerr <<  ,  ; __print(x.second); cerr <<  } ;} n template<typename T> n void __print(const T &x) {int f = 0; cerr <<  { ; for (auto &i: x) cerr << (f++ ?  ,   :   ), __print(i); cerr <<  } ;} n void _print() {cerr <<  ] n ;} n template <typename T, typename... V> n void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr <<  ,  ; _print(v...);} n #ifdef DEBUG n #define dbg(x...) cerr <<   [91m <<__func__<< : <<__LINE__<<  [  << #x <<  ] = [ ; _print(x); cerr <<   [39m  << endl; n #else n #define dbg(x...) n #endif n  n  n const int MOD = 1000000007; n const char nl =   n ; n const int MX = 200001;  n  n int dist[MX]; n int A[MX]; n set<pi> rem; n pqg<pi> q; n  n void add(int p, int pre, bool ty) { n     auto it1 = rem.lb({p, -1}); n     if (it1 != rem.end()) { n         int v = it1->s; n         int d = max(pre, abs(A[v]-p)); n         if (ty) { n             d = pre + abs(A[v]-p); n         } n         if (d < dist[v]) { n             dist[v] = d; n             q.push({d, v}); n         } n     } n     if (it1 != rem.begin()) { n         it1--; n         int v = it1->s; n         int d = max(pre, abs(A[v]-p)); n         if (ty) { n             d = pre + abs(A[v]-p); n         } n         if (d < dist[v]) { n             dist[v] = d; n             q.push({d, v}); n         } n     } n } n  n void push(int p, int K) { n     while (rem.lb({p, -1}) != rem.end() && rem.lb({p, -1})->f <= p+K) { n         int x = rem.lb({p, -1})->s; n         rem.erase({A[x], x}); n         q.push({K, x}); n         dist[x] = K; n     } n     auto it = rem.lb({p, -1}); n     while (it != rem.begin()) { n         it--; n         if (it->f < p-K) break; n         int x = it->s; n         rem.erase({A[x], x}); n         q.push({K, x}); n         dist[x] = K; n         it = rem.lb({p, -1}); n     } n } n  n  n void solve() { n     int N, Q; cin >> N >> Q; n     F0R(i, N) dist[i] = 100000000; n     int S; cin >> S; S--; n     int D; cin >> D; n     F0R(i, N) { n         cin >> A[i]; n         if (i != S) rem.ins({A[i], i}); n     } n     dist[S] = 0; n     add(A[S]+D, 0, true); n     add(A[S]-D, 0, true); n     bool vis[MX]; F0R(i, N) vis[i] = false; n     while (!q.empty()) { n         int v = q.top().s; n         int d = q.top().f; n         q.pop(); n         if (vis[v]) continue; n         vis[v] = true; n         //dbg(v, d); n         rem.erase({A[v], v}); n         add(A[v], d, true); n         push(A[v]+D, d); n         push(A[v]-D, d); n         add(A[v]+D, 0, true); n         add(A[v]-D, 0, true); n     } n     /*F0R(i, N) { n         cout << dist[i] <<    ; n     } n     cout << nl;*/ n  n     while(Q--) { n         int X, V; cin >> X >> V; X--; n         cout << (dist[X]<=V? Yes : No ) << nl; n     } n } n   n int main() { n     cin.tie(0)->sync_with_stdio(0);  n     cin.exceptions(cin.failbit); n  n     int T = 1; n //    cin >> T; n     while(T--) { n         solve(); n     } n  n  return 0; n } n  n  n "}
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 53 | 
             
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const long long INF = 1e18; n const int maxn = 2e6 + 10; n int a[maxn], cnt[maxn]; n long long sum[maxn]; n int main(void) { n   int n, x, y; n   scanf( %d %d %d , &n, &x, &y); n   int z = x / y; n   for (int i = 1; i <= n; i++) n     scanf( %d , a + i), cnt[a[i]]++, sum[a[i]] += a[i]; n   for (int i = 1; i <= 2000000; i++) cnt[i] += cnt[i - 1], sum[i] += sum[i - 1]; n   long long ans = INF; n   for (int i = 2; i <= 1000000; i++) { n     long long tmp = 0; n     int zz = min(z, i - 1); n     for (int j = 1; (j - 1) * i < 1000000; j++) { n       if (i - zz - 2 >= 0) n         tmp += (long long)(cnt[j * i - zz - 1] - cnt[j * i - i]) * x; n       if (zz) n         tmp += ((long long)i * j * (cnt[j * i - 1] - cnt[j * i - zz - 1]) - n                 (sum[j * i - 1] - sum[j * i - zz - 1])) * n                y; n     } n     ans = min(ans, tmp); n   } n   printf( %I64d n , ans); n   return 0; n } n "}
         | 
| 54 | 
             
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int md = 1e9 + 7; n int n; n char s[111]; n int f[111][3333]; n int main() { n   int t; n   f[0][0] = 1; n   for (int i = 1; i <= 100; ++i) { n     for (int j = 0; j <= 3000; ++j) { n       for (int c = 0; c <= min(j, 25); ++c) { n         f[i][j] += f[i - 1][j - c]; n         f[i][j] %= md; n       } n     } n   } n   scanf( %d , &t); n   while (t--) { n     scanf( %s , s); n     int sum = 0; n     for (int i = 0; i < strlen(s); ++i) sum += s[i] -  a ; n     printf( %d n , (f[strlen(s)][sum] + md - 1) % md); n   } n   return 0; n } n "}
         | 
| 55 | 
             
            {"func_code_string": "#include <bits/stdc++.h> n #pragma GCC optimize ( O3 ) n #pragma GCC target ( sse4 ) n   n using namespace std; n   n typedef long long ll; n typedef long double ld; n typedef complex<ld> cd; n   n typedef pair<int, int> pi; n typedef pair<ll,ll> pl; n typedef pair<ld,ld> pd; n   n typedef vector<int> vi; n typedef vector<ld> vd; n typedef vector<ll> vl; n typedef vector<pi> vpi; n typedef vector<pl> vpl; n typedef vector<cd> vcd; n  n template<class T> using pq = priority_queue<T>; n template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>; n   n #define FOR(i, a, b) for (int i=a; i<(b); i++) n #define F0R(i, a) for (int i=0; i<(a); i++) n #define FORd(i,a,b) for (int i = (b)-1; i >= a; i--) n #define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--) n #define trav(a,x) for (auto& a : x) n #define uid(a, b) uniform_int_distribution<int>(a, b)(rng) n   n #define sz(x) (int)(x).size() n #define mp make_pair n #define pb push_back n #define f first n #define s second n #define lb lower_bound n #define ub upper_bound n #define all(x) x.begin(), x.end() n #define ins insert n  n template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } n template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } n   n mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); n  n void __print(int x) {cerr << x;} n void __print(long x) {cerr << x;} n void __print(long long x) {cerr << x;} n void __print(unsigned x) {cerr << x;} n void __print(unsigned long x) {cerr << x;} n void __print(unsigned long long x) {cerr << x;} n void __print(float x) {cerr << x;} n void __print(double x) {cerr << x;} n void __print(long double x) {cerr << x;} n void __print(char x) {cerr <<      << x <<     ;} n void __print(const char *x) {cerr <<     << x <<    ;} n void __print(const string &x) {cerr <<     << x <<    ;} n void __print(bool x) {cerr << (x ?  true  :  false );} n  n template<typename T, typename V> n void __print(const pair<T, V> &x) {cerr <<  { ; __print(x.first); cerr <<  ,  ; __print(x.second); cerr <<  } ;} n template<typename T> n void __print(const T &x) {int f = 0; cerr <<  { ; for (auto &i: x) cerr << (f++ ?  ,   :   ), __print(i); cerr <<  } ;} n void _print() {cerr <<  ] n ;} n template <typename T, typename... V> n void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr <<  ,  ; _print(v...);} n #ifdef DEBUG n #define dbg(x...) cerr <<   [91m <<__func__<< : <<__LINE__<<  [  << #x <<  ] = [ ; _print(x); cerr <<   [39m  << endl; n #else n #define dbg(x...) n #endif n  n  n const int MOD = 1000000007; n const char nl =   n ; n const int MX = 200001;  n  n int dist[MX]; n int A[MX]; n set<pi> rem; n pqg<pi> q; n  n void add(int p, int pre, bool ty) { n     auto it1 = rem.lb({p, -1}); n     if (it1 != rem.end()) { n         int v = it1->s; n         int d = max(pre, abs(A[v]-p)); n         if (ty) { n             d = pre + abs(A[v]-p); n         } n         if (d < dist[v]) { n             dist[v] = d; n             q.push({d, v}); n         } n     } n     if (it1 != rem.begin()) { n         it1--; n         int v = it1->s; n         int d = max(pre, abs(A[v]-p)); n         if (ty) { n             d = pre + abs(A[v]-p); n         } n         if (d < dist[v]) { n             dist[v] = d; n             q.push({d, v}); n         } n     } n } n  n void push(int p, int K) { n     while (rem.lb({p, -1}) != rem.end() && rem.lb({p, -1})->f <= p+K) { n         int x = rem.lb({p, -1})->s; n         rem.erase({A[x], x}); n         q.push({K, x}); n         dist[x] = K; n     } n     auto it = rem.lb({p, -1}); n     while (it != rem.begin()) { n         it--; n         if (it->f < p-K) break; n         int x = it->s; n         rem.erase({A[x], x}); n         q.push({K, x}); n         dist[x] = K; n         it = rem.lb({p, -1}); n     } n } n  n  n void solve() { n     int N, Q; cin >> N >> Q; n     F0R(i, N) dist[i] = 100000000; n     int S; cin >> S; S--; n     int D; cin >> D; n     F0R(i, N) { n         cin >> A[i]; n         if (i != S) rem.ins({A[i], i}); n     } n     dist[S] = 0; n     add(A[S]+D, 0, true); n     add(A[S]-D, 0, true); n     bool vis[MX]; F0R(i, N) vis[i] = false; n     while (!q.empty()) { n         int v = q.top().s; n         int d = q.top().f; n         q.pop(); n         if (vis[v]) continue; n         vis[v] = true; n         //dbg(v, d); n         rem.erase({A[v], v}); n         add(A[v], d, true); n         push(A[v]+D, d); n         push(A[v]-D, d); n         add(A[v]+D, 0, true); n         add(A[v]-D, 0, true); n     } n     /*F0R(i, N) { n         cout << dist[i] <<    ; n     } n     cout << nl;*/ n  n     while(Q--) { n         int X, V; cin >> X >> V; X--; n         cout << (dist[X]<=V? Yes : No ) << nl; n     } n } n   n int main() { n     cin.tie(0)->sync_with_stdio(0);  n     cin.exceptions(cin.failbit); n  n     int T = 1; n //    cin >> T; n     while(T--) { n         solve(); n     } n  n  return 0; n } n  n  n "}
         | 
| 56 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n long long k, b, n, t; n int main() { n   ios_base ::sync_with_stdio(0); n   cin.tie(0); n   cin >> k >> b >> n >> t; n   long long num = 1; n   long long step = n; n   while (t >= num) { n     num = num * k + b; n     step--; n   } n   if (step < 0) { n     cout << 0; n     return 0; n   } n   cout << step + 1; n   return 0; n } n "}
         | 
| 57 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n const long double pi = 3.14159265359; n const long long N = 1e9 + 7; n using namespace std; n int main() { n   ios_base::sync_with_stdio(0); n   cin.tie(0); n   cout.tie(0); n   long long n, m, arr[200005]; n   cin >> n >> m; n   long long cntne = 0, cntpo = 0; n   for (int i = 0; i < n; i++) { n     cin >> arr[i]; n     if (arr[i] == -1) n       cntne++; n     else n       cntpo++; n   } n   vector<long long> v; n   for (int i = 0; i < m; i++) { n     long long l, r; n     cin >> l >> r; n     r++; n     long long ans = abs(l - r); n     if ((ans % 2 == 0) && (cntne >= ans / 2) && (cntpo >= ans / 2)) n       v.push_back(1); n     else n       v.push_back(0); n   } n   for (int i = 0; i < ((long long)((v).size())); i++) cout << v[i] << endl; n   return 0; n } n "}
         | 
| 58 | 
            +
            {"func_code_string": "#include <iostream> n #include <vector> n #include <algorithm> n #include <string> n  n #define ll long long n  n using namespace std; n  n int main() { n     ll qua; n     cin >> qua; n     for (int i = 0; i < qua; ++i) { n         ll n; n         cin >> n; n         vector<int> vec(n); n         for (int j = 0; j < n; ++j) { n             cin >> vec[j]; n         } n         cout << 0 <<    ; n         for (int j = 1; j < n; ++j) { n             ll r = (vec[j] | vec[j - 1]) - vec[j]; n             cout << r <<    ; n             vec[j] += r; n         } n         cout <<   n ; n     } n     return 0; n } n "}
         | 
| 59 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int MaxN = 100005; n const int MaxM = MaxN * 2; n const int oo = 0x3F3F3F3F; n int ax[MaxM], K; n int ret[MaxN]; n set<pair<int, int> > tr[MaxM]; n struct event { n   int l, r, v, tp; n   event() {} n   event(int l, int r, int v, int tp) : l(l), r(r), v(v), tp(tp) {} n   bool operator<(const event& e) const { n     if (r != e.r) n       return r > e.r; n     else n       return tp < e.tp; n   } n } e[MaxM]; n int getId(int v) { return lower_bound(ax, ax + K, v) - ax + 1; } n void add(int k, pair<int, int> v) { n   while (k <= K) { n     tr[k].insert(v); n     k += k & -k; n   } n } n int read(int k, int v) { n   pair<int, int> ret = make_pair(oo, -1); n   while (k) { n     set<pair<int, int> >::iterator it = tr[k].lower_bound(make_pair(v, 0)); n     if (it != tr[k].end()) ret = min(ret, *it); n     k -= k & -k; n   } n   return ret.second; n } n int main() { n   int N, M, en; n   int l, r, t; n   scanf( %d%d , &N, &M); n   K = en = 0; n   for (int i = 0; i < N; i++) { n     scanf( %d%d%d , &l, &r, &t); n     e[en++] = event(l, r, t, -i - 1); n     ax[K++] = l; n   } n   for (int i = 0; i < M; i++) { n     scanf( %d%d%d , &l, &r, &t); n     e[en++] = event(l, r, t, i); n     ax[K++] = l; n   } n   sort(ax, ax + K); n   K = unique(ax, ax + K) - ax; n   sort(e, e + en); n   for (int i = 0; i < en; i++) { n     if (e[i].tp < 0) { n       add(getId(e[i].l), make_pair(e[i].v, -e[i].tp)); n     } else { n       ret[e[i].tp] = read(getId(e[i].l), e[i].v); n     } n   } n   for (int i = 0; i < M; i++) { n     printf( %d  , ret[i]); n   } n   puts(  ); n   return 0; n } n "}
         | 
| 60 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n template <typename T, typename U> n std::istream& operator>>(std::istream& i, pair<T, U>& p) { n   i >> p.first >> p.second; n   return i; n } n template <typename T> n std::istream& operator>>(std::istream& i, vector<T>& t) { n   for (auto& v : t) { n     i >> v; n   } n   return i; n } n template <typename T, typename U> n std::ostream& operator<<(std::ostream& o, const pair<T, U>& p) { n   o << p.first <<     << p.second; n   return o; n } n template <typename T> n std::ostream& operator<<(std::ostream& o, const vector<T>& t) { n   if (t.empty()) o <<   n ; n   for (size_t i = 0; i < t.size(); ++i) { n     o << t[i] <<    n [i == t.size() - 1]; n   } n   return o; n } n template <typename T> n using minheap = priority_queue<T, vector<T>, greater<T>>; n template <typename T> n using maxheap = priority_queue<T, vector<T>, less<T>>; n unsigned int logceil(long long first) { n   return first ? 8 * sizeof(long long) - __builtin_clzll(first) : 0; n } n namespace std { n template <typename T, typename U> n struct hash<pair<T, U>> { n   hash<T> t; n   hash<U> u; n   size_t operator()(const pair<T, U>& p) const { n     return t(p.first) ^ (u(p.second) << 7); n   } n }; n }  // namespace std n template <typename T, typename F> n T bsh(T l, T h, const F& f) { n   T r = -1, m; n   while (l <= h) { n     m = (l + h) / 2; n     if (f(m)) { n       l = m + 1; n       r = m; n     } else { n       h = m - 1; n     } n   } n   return r; n } n template <typename F> n double bshd(double l, double h, const F& f, double p = 1e-9) { n   unsigned int r = 3 + (unsigned int)log2((h - l) / p); n   while (r--) { n     double m = (l + h) / 2; n     if (f(m)) { n       l = m; n     } else { n       h = m; n     } n   } n   return (l + h) / 2; n } n template <typename T, typename F> n T bsl(T l, T h, const F& f) { n   T r = -1, m; n   while (l <= h) { n     m = (l + h) / 2; n     if (f(m)) { n       h = m - 1; n       r = m; n     } else { n       l = m + 1; n     } n   } n   return r; n } n template <typename F> n double bsld(double l, double h, const F& f) { n   unsigned int r = 200; n   while (r--) { n     double m = (l + h) / 2; n     if (f(m)) { n       h = m; n     } else { n       l = m; n     } n   } n   return (l + h) / 2; n } n template <typename T> n T gcd(T a, T b) { n   if (a < b) swap(a, b); n   return b ? gcd(b, a % b) : a; n } n template <typename T> n class vector2 : public vector<vector<T>> { n  public: n   vector2() {} n   vector2(size_t a, size_t b, T t = T()) n       : vector<vector<T>>(a, vector<T>(b, t)) {} n }; n template <typename T> n class vector3 : public vector<vector2<T>> { n  public: n   vector3() {} n   vector3(size_t a, size_t b, size_t c, T t = T()) n       : vector<vector2<T>>(a, vector2<T>(b, c, t)) {} n }; n template <typename T> n class vector4 : public vector<vector3<T>> { n  public: n   vector4() {} n   vector4(size_t a, size_t b, size_t c, size_t d, T t = T()) n       : vector<vector3<T>>(a, vector3<T>(b, c, d, t)) {} n }; n template <typename T> n class vector5 : public vector<vector4<T>> { n  public: n   vector5() {} n   vector5(size_t a, size_t b, size_t c, size_t d, size_t e, T t = T()) n       : vector<vector4<T>>(a, vector4<T>(b, c, d, e, t)) {} n }; n class GOmkarAndPies { n  public: n   vector<std::pair<int, int>> D; n   int N, M, K; n   void fix(int p) { n     for (int i = 0; i < K; ++i) { n       int s = p ^ 1 << i; n       if (D[s].first > D[p].first + 1) { n         D[s] = {D[p].first + 1, D[p].second}; n         fix(s); n       } n     } n   }; n   void solve(istream& cin, ostream& cout) { n     cin >> N >> M >> K; n     string S, T; n     cin >> S >> T; n     vector<std::pair<int, int>> P(N); n     cin >> P; n     for (std::pair<int, int>& p : P) { n       p.first--; n       p.second--; n     } n     vector<int> X(K); n     iota(X.begin(), X.end(), 0); n     vector<vector<int>> W{X}; n     for (int i = 0; i < N; ++i) { n       swap(X[P[i].first], X[P[i].second]); n       vector<int> I(K); n       for (int j = 0; j < K; ++j) I[X[j]] = j; n       W.push_back(X); n     } n     auto apply = [&](int first, string S) { n       int p = 0; n       for (int i = 0; i < K; ++i) { n         p |= (S[i] -  0 ) << W[first][i]; n       } n       return p; n     }; n     D.assign(1 << K, {K + 1, -1}); n     pair<int, std::pair<int, int>> ans{K + 1, {-1, -1}}; n     for (int i = N - M; i >= 0; --i) { n       int TX = apply(i + M, T); n       D[TX] = {0, i + M}; n       fix(TX); n       int SX = apply(i, S); n       ans = min(ans, {D[SX].first, {i + 1, D[SX].second}}); n     } n     cout << K - ans.first <<   n  << ans.second <<   n ; n   } n }; n int main() { n   ios_base::sync_with_stdio(false); n   cin.tie(nullptr); n   cout.tie(nullptr); n   GOmkarAndPies solver; n   std::istream& in(std::cin); n   std::ostream& out(std::cout); n   solver.solve(in, out); n   return 0; n } n "}
         | 
| 61 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   string s; n   cin >> s; n   cout << (regex_match(s, regex( (1|14|144)* )) ?  YES  :  NO ); n } n "}
         | 
| 62 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int N = 3e3 + 5; n int dw[N], up[N], E[N][2], Mn; n vector<pair<int, int> > g[N]; n void dfs_down(int v, int p) { n   dw[v] = 0; n   for (pair<int, int> u : g[v]) n     if (u.first != p) dfs_down(u.first, v), dw[v] += dw[u.first] + u.second; n } n void dfs_up(int v, int p, int f = -1) { n   if (f != -1) { n     up[v] = up[p] + dw[p] - dw[v] + f - (f == 0); n   } else n     up[v] = 0; n   Mn = min(Mn, dw[v] + up[v]); n   for (pair<int, int> u : g[v]) n     if (u.first != p) dfs_up(u.first, v, u.second ^ 1); n } n int main() { n   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); n   int n; n   cin >> n; n   if (n == 1) return cout <<  0 n , 0; n   for (int i = 0; i < n - 1; i++) { n     cin >> E[i][0] >> E[i][1]; n     g[E[i][0]].push_back({E[i][1], 0}); n     g[E[i][1]].push_back({E[i][0], 1}); n   } n   int ans = n; n   for (int i = 0; i < n - 1; i++) { n     Mn = n, dfs_down(E[i][0], E[i][1]), dfs_up(E[i][0], E[i][1]); n     int cur = Mn; n     Mn = n, dfs_down(E[i][1], E[i][0]), dfs_up(E[i][1], E[i][0]); n     cur += Mn; n     ans = min(ans, cur); n   } n   cout << ans <<   n ; n } n "}
         | 
| 63 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   int n; n   cin >> n; n   cout << ceil(n / 2.0) - 1; n } n "}
         | 
| 64 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int N = 2e5 + 10; n int y[N], pos[N]; n int main() { n   int n, m, t = 0, ans = 0, cnt = 0; n   scanf( %d %d , &n, &m); n   for (int i = 1; i <= n; i++) scanf( %d , &y[i]); n   for (int i = 1; i <= m; i++) { n     int y1, y2, x; n     scanf( %d %d %d , &y1, &y2, &x); n     if (y1 == 1) { n       pos[++t] = y2; n     } n     if (y2 == 1e9) { n       ans++; n     } n   } n   sort(y + 1, y + 1 + n); n   sort(pos + 1, pos + 1 + t); n   int i = 1, j = 1; n   cnt = t, ans += n; n   while (i <= n) { n     while (j <= t) { n       if (pos[j] < y[i]) { n         j++, cnt--; n       } else n         break; n     } n     ans = min(ans, cnt + i - 1); n     i++; n   } n   cout << ans; n } n "}
         | 
| 65 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n inline int read() { n   int x = 0, f = 1; n   char c = getchar(); n   while (c <  0  || c >  9 ) { n     if (c ==  - ) f = -1; n     c = getchar(); n   } n   while (c >=  0  && c <=  9 ) n     x = (x << 3) + (x << 1) + (c ^  0 ), c = getchar(); n   return x * f; n } n const int N = 505, mod = 1e9 + 7; n inline int inc(int x, int y) { n   x += y - mod; n   return x + (x >> 31 & mod); n } n inline int mul(int x, int y) { return 1ll * x * y % mod; } n inline void Inc(int &x, int y) { x = inc(x, y); } n int n, a[N], f[N][N]; n int main() { n   n = read(); n   for (int i = 1; i <= n; i++) a[i] = read(), f[i][i] = 1; n   for (int i = 1; i <= n + 1; i++) f[i][i - 1] = 1; n   for (int len = 2; len < n; len++) n     for (int l = 1; l <= n - len + 1; l++) { n       int r = l + len - 1; n       f[l][r] = f[l + 1][r]; n       for (int k = l + 1; k <= r; k++) n         if (a[k] > a[l]) Inc(f[l][r], mul(f[l + 1][k - 1], f[k][r])); n     } n   printf( %d n , f[2][n]); n   return 0; n } n "}
         | 
| 66 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int MAXN = 2001; n char a[MAXN][MAXN]; n int n, v[MAXN], r[MAXN], c[MAXN]; n int gao() { n   int ret = 0; n   memset(r, 0, sizeof(int) * n); n   memset(c, 0, sizeof(int) * n); n   for (int i = 0; i < n - 1; ++i) { n     for (int j = n - 1; j > i; --j) { n       if (a[i][j] ^ r[i] ^ c[j]) { n         ++ret; n         r[i] ^= 1; n         c[j] ^= 1; n       } n     } n   } n   for (int i = 0; i < n; ++i) v[i] ^= (r[i] ^ c[i]); n   memset(r, 0, sizeof(int) * n); n   memset(c, 0, sizeof(int) * n); n   for (int i = n - 1; i > 0; --i) { n     for (int j = 0; j < i; ++j) { n       if (a[i][j] ^ r[i] ^ c[j]) { n         ++ret; n         r[i] ^= 1; n         c[j] ^= 1; n       } n     } n   } n   for (int i = 0; i < n; ++i) v[i] ^= (r[i] ^ c[i]); n   for (int i = 0; i < n; ++i) ret += v[i]; n   return ret; n } n int main() { n   while (scanf( %d , &n) != EOF) { n     memset(v, 0, sizeof(int) * n); n     for (int i = 0; i < n; ++i) { n       scanf( %s , a[i]); n       for (int j = 0; j < n; ++j) a[i][j] -=  0 ; n       v[i] ^= (int)a[i][i]; n     } n     printf( %d n , gao()); n   } n   return 0; n } n "}
         | 
| 67 | 
            +
            {"func_code_string": "#include<bits/stdc++.h> n using namespace std; n typedef double db; n typedef uint32_t u32; n typedef uint64_t u64; n typedef pair<int, int> pii; n typedef pair<int, int> point; n #define fi first n #define se second n #define pb(x) push_back(x) n #define SZ(x) ((int) (x).size()) n #define all(x) (x).begin(), (x).end() n #define rep(i, l, r) for(int i = l; i < r; i++) n typedef long long ll; n const int mod = 998244353; n  n  n  n int main() { n #ifdef local n  freopen( in.txt ,  r , stdin); n #endif n  ios::sync_with_stdio(false); n  cin.tie(0), cout.tie(0); n  const int mod = 1e9 + 7; n  int n; n  cin >> n; n  vector<int> a(n); n  ll tot = 0; n  for(auto &e : a) { n   cin >> e; n   tot += e; n  } n  if(tot % n) { n   cout <<  0 n ; n   return 0; n  } n  vector<int> fac(n + 1, 1); n  vector<int> ifac(n + 1, 1); n  for(int i = 2; i <= n; i++) { n   fac[i] = (ll) fac[i - 1] * i % mod; n   ifac[i] = (ll) ifac[mod % i] * (mod - mod / i) % mod; n  } n  for(int i = 2; i <= n; i++) { n   ifac[i] = (ll) ifac[i] * ifac[i - 1] % mod; n  } n  auto C = [&](int n, int m) { n   if(n < m || m < 0) return 0ll; n   return (ll) fac[n] * ifac[m] % mod * ifac[n - m] % mod; n  }; n  ll avg = tot / n; n  vector<int> l, r; n  int eq = 0; n  for(auto &e : a) { n   if(e > avg) { n    r.push_back(e); n   } else if(e < avg) { n    l.push_back(e); n   } else { n    eq++; n   } n  } n  int ans = 1; n  if(l.size() > 1 && r.size() > 1) { n   ans = 2; n  } n  if(l.size() == 1) { n   r.push_back(l[0]); n   l.clear(); n  } n  if(r.size() == 1) { n   l.push_back(r[0]); n   r.clear(); n  } n  sort(all(l)); n  sort(all(r)); n  int a1 = fac[l.size()]; n  int a2 = fac[r.size()]; n  for(int i = 0, j = 0; i < (int) l.size(); i = j) { n   while(j < (int) l.size() && l[j] == l[i]) { n    j++; n   } n   a1 = (ll) a1 * ifac[j - i] % mod; n  } n  for(int i = 0, j = 0; i < (int) r.size(); i = j) { n   while(j < (int) r.size() && r[j] == r[i]) { n    j++; n   } n   a2 = (ll) a2 * ifac[j - i] % mod; n  } n  int a3 = C(n, eq); n  ans = (ll) ans * a1 % mod; n  ans = (ll) ans * a2 % mod; n  ans = (ll) ans * a3 % mod; n  cout << ans <<   n ; n  return 0; n } n "}
         | 
| 68 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main(void) { n   int n; n   cin >> n; n   set<int> a, b; n   vector<pair<int, int> > ans(n); n   for (int i = 0; i < n; ++i) { n     cin >> ans[i].first >> ans[i].second; n     --ans[i].first; n     --ans[i].second; n     if (ans[i].first == -1) a.insert(i); n     if (ans[i].second == -1) b.insert(i); n   } n   while (a.size() > 1) { n     int node = *a.begin(); n     a.erase(a.begin()); n     int last = node; n     while (ans[last].second != -1) last = ans[last].second; n     auto nxt = b.begin(); n     if (*nxt == last) ++nxt; n     ans[*nxt].second = node; n     ans[node].first = *nxt; n     b.erase(nxt); n   } n   for (int i = 0; i < n; ++i) n     cout << ans[i].first + 1 <<     << ans[i].second + 1 <<   n ; n   return 0; n } n "}
         | 
| 69 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   int n; n   cin >> n; n   int a[n], sm = 0; n   for (int i = 0; i < n; i++) { n     cin >> a[i]; n     sm += a[i]; n   } n   vector<int> ind, r; n   int need = sm / 2; n   if (a[0] > need) { n     cout << 1 << endl; n     cout << 1; n     return 0; n   } n   for (int i = 1; i < n; i++) { n     if ((2 * a[i]) <= a[0]) { n       ind.push_back(i + 1); n       r.push_back(a[i]); n     } n   } n   bool ok; n   int u = a[0]; n   for (auto x : r) { n     u += x; n   } n   if (u > need) { n     ok = true; n   } else { n     ok = false; n   } n   if (ok) { n     cout << ind.size() + 1 << endl; n     cout << 1 <<    ; n     for (auto x : ind) { n       cout << x <<    ; n     } n   } else { n     cout << 0; n   } n } n "}
         | 
| 70 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int nbVoyages, coutSimple, coutLiaison, maxCartes, coutCarte; n map<pair<string, string>, int> routes; n int main() { n   ios_base::sync_with_stdio(false); n   cin >> nbVoyages >> coutSimple >> coutLiaison >> maxCartes >> coutCarte; n   long long total = 0; n   string derFin =   ; n   for (int iVoyage = 0; iVoyage < nbVoyages; iVoyage++) { n     string a, b; n     cin >> a >> b; n     string der = b, pre = a; n     if (b < a) swap(a, b); n     if (routes.find({a, b}) == routes.end()) routes[{a, b}] = 0; n     if (derFin == pre) { n       routes[{a, b}] += coutLiaison; n       total += coutLiaison; n     } else { n       routes[{a, b}] += coutSimple; n       total += coutSimple; n     } n     derFin = der; n   } n   vector<int> couts; n   for (pair<pair<string, string>, int> route : routes) { n     couts.push_back(route.second); n   } n   sort(couts.begin(), couts.end()); n   for (int iFois = 0; iFois < maxCartes; iFois++) { n     if (!couts.empty() && couts.back() > coutCarte) { n       total += coutCarte - couts.back(); n       couts.pop_back(); n     } n   } n   cout << total << endl; n   return 0; n } n "}
         | 
| 71 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int inf = 0x3f3f3f3f; n const double eps = 1e-6; n const int mod = 1000000007; n int modpow(int x, int y, int md) { n   if (y == 0) return 1; n   int ret = modpow(x, y >> 1, md); n   ret = (long long)ret * ret % md; n   if (y & 1) ret = (long long)ret * x % md; n   return ret; n } n int n; n int sum[5555]; n vector<int> g[5555]; n set<pair<int, int> > ans; n void dfs(int x, int par = 0) { n   sum[x] = 1; n   for (auto to : g[x]) n     if (to != par) dfs(to, x); n   for (auto to : g[x]) n     if (to != par) sum[x] += sum[to]; n   vector<bool> ok(5555, false); n   ok[0] = true; n   for (auto to : g[x]) n     if (to != par) { n       for (int i = 5005; i >= 0; i--) n         if (ok[i] && i + sum[to] <= 5005) ok[i + sum[to]] = true; n     } n   for (int i = 1; i <= 5005; i++) n     if (ok[i] && n - i - 1 >= 1) n       ans.insert(make_pair(i, n - i - 1)), ans.insert(make_pair(n - i - 1, i)); n } n int main() { n   cin >> n; n   for (int i = 1; i < n; i++) { n     int a, b; n     cin >> a >> b; n     g[a].push_back(b); n     g[b].push_back(a); n   } n   dfs(1); n   cout << ans.size() << endl; n   for (auto p : ans) cout << p.first <<     << p.second << endl; n   return 0; n } n "}
         | 
| 72 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n string s[3]; n int N, M, p[3][1000005], a[3][1000005], b[1000005]; n void genPrefix(int pat) { n   int i, k; n   p[pat][0] = 0; n   k = 0; n   i = 1; n   while (i < M) { n     if (s[pat][i] == s[pat][k]) { n       k++; n       p[pat][i] = k; n       i++; n     } else { n       if (k != 0) n         k = p[pat][k - 1]; n       else { n         p[pat][i] = 0; n         i++; n       } n     } n   } n } n void KMPSearch(int txt, int pat) { n   int i, k; n   genPrefix(pat); n   i = k = 0; n   while (i < N) { n     if (s[txt][i] == s[pat][k]) { n       i++; n       k++; n       a[txt][i - k] = i - 1; n     } n     if (k == M) { n       k = p[pat][k - 1]; n     } else if (i < N && s[txt][i] != s[pat][k]) { n       if (k != 0) { n         if (s[txt][i - 1] == s[pat][k]) n           a[txt][i - k] = max(i - 1, a[txt][k - 1]); n         k = p[pat][k - 1]; n         if (k > 0 && s[txt][i - 1] == s[pat][k]) n           a[txt][i - k] = max(i - 1, a[txt][k - 1]); n       } else n         i++; n     } n   } n } n int bs(int low, int high, int v) { n   int mid, x = -1; n   while (low <= high) { n     mid = (low + high) >> 1; n     if (b[mid] >= v) { n       x = mid; n       high = mid - 1; n     } else n       low = mid + 1; n   } n   return x; n } n pair<int, int> solve() { n   s[2] = s[0]; n   reverse(s[2].begin(), s[2].end()); n   memset(a, -1, sizeof(a)); n   KMPSearch(1, 2); n   KMPSearch(0, 1); n   b[0] = a[1][0]; n   int i, j = N, len, k, x; n   int ansx = -1, ansy = -1; n   for (i = 1; i <= N - 1; i++) b[i] = max(b[i - 1], a[1][i]); n   for (i = 0; i <= N - 2; i++) { n     j--; n     if (s[0][i] != s[1][j]) break; n     if (b[0] >= j - 1) { n       ansx = i; n       ansy = i + 1; n     } n     if (a[0][i + 1] <= 0 || i + 1 == N - 1) continue; n     len = min(N - 2, a[0][i + 1]) - i; n     k = bs(0, len, j - 1); n     if (k >= 0 && ansx < i) { n       ansx = i; n       ansy = i + 1 + k; n     } n   } n   return make_pair(ansx, ansy); n } n int main() { n   std::ios_base::sync_with_stdio(0); n   int cases, caseno = 0, n, i, j, k, cnt, m; n   getline(cin, s[0]); n   getline(cin, s[1]); n   N = s[0].size(); n   M = s[1].size(); n   if (N != M) { n     cout <<  -1 -1  <<   n ; n     return 0; n   } n   pair<int, int> ans = solve(); n   cout << ans.first <<     << ans.second <<   n ; n   return 0; n } n "}
         | 
| 73 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   int n, x; n   scanf( %d%d , &n, &x); n   if (n == 1) { n     printf( YES n ); n     printf( %d n , x); n   } else if (n == 2) { n     if (x == 0) n       printf( NO n ); n     else { n       printf( YES n ); n       printf( 0 %d n , x); n     } n   } else { n     printf( YES n ); n     int tmp = 0; n     int a = (1 << 17); n     int b = (1 << 18); n     for (int i = 0; i < n - 3; i++) { n       printf( %d  , i); n       tmp ^= i; n     } n     printf( %d %d %d n , a, b, a ^ b ^ tmp ^ x); n   } n   return 0; n } n "}
         | 
| 74 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n bool psort(std::vector<long long int> p1, std::vector<long long int> p2) { n   return p1[0] < p2[0]; n } n int main() { n   ios_base::sync_with_stdio(false); n   cin.tie(NULL); n   cout.tie(NULL); n   long long int n, m; n   cin >> n; n   std::vector<vector<long long int> > v(n, vector<long long int>(3)); n   for (int i = 0; i < n; ++i) { n     cin >> v[i][0]; n   } n   for (int i = 0; i < n; ++i) { n     cin >> v[i][1]; n   } n   for (int i = 0; i < n; ++i) { n     cin >> v[i][2]; n   } n   sort(v.begin(), v.end(), psort); n   cin >> m; n   long long int start[4] = {0}; n   for (int i = 0; i < m; ++i) { n     long long int k, t, flag = 0; n     cin >> t; n     while (start[t] < n) { n       if (v[start[t]][0] != -1) { n         if (v[start[t]][1] == t || v[start[t]][2] == t) { n           cout << v[start[t]][0] <<    ; n           v[start[t]][0] = -1; n           start[t]++; n           flag = 1; n           break; n         } n       } n       start[t]++; n     } n     if (flag == 0) cout << -1 <<    ; n   } n   return 0; n } n "}
         | 
| 75 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   int n; n   cin >> n; n   string fld; n   cin >> fld; n   int l = 1, r = 2 * n; n   int ans = -1; n   while (l <= r) { n     int mid = (l + r) >> 1; n     int posbl = 1; n     int back = -1, flag = 0; n     for (int i = 0; i < n; i++) { n       if (fld[i] ==  * ) n         if (i > back && flag == 0) back = i, flag = 1; n       if (fld[i] ==  P ) { n         if (back == -1) { n           back = i + mid; n         } else { n           if (i <= back) { n             back = max(back, i + mid); n           } else { n             if (flag == 1) { n               if (i - back > mid) { n                 posbl = 0; n                 break; n               } else if (i - back <= mid && mid <= (2 * (i - back))) n                 back = max(i, (mid - (i - back)) / 2 + i); n               else { n                 back = n                     max(mid - (2 * (i - back)) + i, (mid - (i - back)) / 2 + i); n               } n             } else { n               back = i + mid; n             } n           } n         } n         flag = 0; n       } n     } n     if (flag == 1) posbl = 0; n     if (posbl == 1) { n       r = mid - 1; n       ans = mid; n     } else n       l = mid + 1; n   } n   cout << ans <<   n ; n   return 0; n } n "}
         | 
| 76 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int N = 2e5 + 10; n char s[N]; n char t1[7] =  twone ; n char t2[4] =  one ; n char t3[4] =  two ; n int main() { n   int T; n   scanf( %d , &T); n   while (T--) { n     scanf( %s , s); n     int ans = 0; n     int len = strlen(s); n     for (int i = 0; i < len; i++) { n       if (s[i] ==  t ) { n         int f = 0; n         for (int j = i; j <= i + 4; j++) { n           if (s[j] != t1[j - i]) { n             f = 1; n             break; n           } n         } n         if (f == 0) { n           s[i + 2] =  - ; n           ans++; n         } n       } n     } n     for (int i = 0; i < len; i++) { n       if (s[i] ==  t ) { n         int f = 0; n         for (int j = i; j <= i + 2; j++) { n           if (s[j] != t3[j - i]) { n             f = 1; n             break; n           } n         } n         if (f == 0) { n           s[i + 1] =  - ; n           ans++; n         } n       } n     } n     for (int i = 0; i < len; i++) { n       if (s[i] ==  o ) { n         int f = 0; n         for (int j = i; j <= i + 2; j++) { n           if (s[j] != t2[j - i]) { n             f = 1; n             break; n           } n         } n         if (f == 0) { n           s[i + 1] =  - ; n           ans++; n         } n       } n     } n     printf( %d n , ans); n     for (int i = 0; i < len; i++) n       if (s[i] ==  - ) printf( %d  , i + 1); n     printf(  n ); n   } n   return 0; n } n "}
         | 
| 77 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   ios_base::sync_with_stdio(0); n   long long int n, m = 0, p = 0, cnt = 0, f = 0; n   cin >> n; n   long long int a[n]; n   for (long long int i = 0; i < n; i++) { n     cin >> a[i]; n     if (a[i] < 0) { n       m++; n     } n     if (a[i] > 0) p++; n     if (a[i] < 0) { n       cnt = cnt - a[i] - 1; n     } n     if (a[i] > 0) { n       cnt = cnt + a[i] - 1; n     } n     if (a[i] == 0) { n       cnt = cnt + 1; n       f++; n     } n   } n   if (f and m % 2 == 0) cout << cnt << endl; n   if (f and m % 2 != 0) cout << cnt << endl; n   if (!f and m % 2 == 0) cout << cnt << endl; n   if (!f and m % 2 != 0) cout << cnt + 2 << endl; n } n "}
         | 
| 78 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int n, m; n int A[600006]; n vector<int> G[600006]; n int dfn[600006], bc[600006], clo; n int g[600006][20], dep[600006]; n void dfs(int u) { n   dfn[u] = ++clo, bc[clo] = u; n   if (u == 1) dep[u] = 1; n   for (int v : G[u]) { n     g[v][0] = u; n     dep[v] = dep[u] + 1; n     for (int k = (1), kend = (18); k <= kend; ++k) n       if (g[g[v][k - 1]][k - 1]) n         g[v][k] = g[g[v][k - 1]][k - 1]; n       else n         break; n     dfs(v); n   } n } n int lca(int u, int v) { n   if (dep[u] < dep[v]) swap(u, v); n   if (dep[u] != dep[v]) n     for (int k = (18), kend = (0); k >= kend; --k) n       if (dep[g[u][k]] >= dep[v]) u = g[u][k]; n   if (u == v) return u; n   for (int k = (18), kend = (0); k >= kend; --k) n     if (g[u][k] != g[v][k]) u = g[u][k], v = g[v][k]; n   return g[u][0]; n } n int dis(int u, int v) { return dep[u] + dep[v] - 2 * dep[lca(u, v)]; } n set<int> S; n void solve() { n   cin >> n; n   ++n; n   for (int i = (2), iend = (n); i <= iend; ++i) { n     int p; n     scanf( %d , &p); n     G[p].push_back(i); n   } n   dfs(1); n   int s = 1, t = 1, lt = 0; n   auto wkr = [&](int x) { return max(dis(x, s), dis(x, t)); }; n   S.insert(1); n   for (int i = (2), iend = (n); i <= iend; ++i) { n     int is = dis(i, s), it = dis(i, t), flg = 0; n     if (is >= lt && is >= it) n       t = i, lt = is, flg = 1; n     else if (it >= lt && it >= is) n       s = i, lt = it, flg = 1; n     if (!flg) { n       printf( %d n , (int)S.size()); n       continue; n     } n     auto tr = S.lower_bound(dfn[i]), st = tr; n     while (tr != S.end()) { n       if (wkr(bc[*tr]) < lt) n         ++tr; n       else n         break; n     } n     if (tr == S.end()) { n       auto sr = S.begin(); n       while (sr != st) { n         if (wkr(bc[*sr]) < lt) n           ++sr; n         else n           break; n       } n       S.erase(S.begin(), sr); n     } n     S.erase(st, tr); n     tr = S.lower_bound(dfn[i]), st = tr; n     while (tr != S.begin()) { n       --tr; n       if (wkr(bc[*tr]) >= lt) { n         ++tr; n         break; n       } n     } n     if (tr == S.begin()) { n       auto sr = S.end(); n       while (sr != st) { n         --sr; n         if (wkr(bc[*sr]) >= lt) { n           ++sr; n           break; n         } n       } n       S.erase(sr, S.end()); n     } n     S.erase(tr, st); n     S.insert(dfn[i]); n     printf( %d n , (int)S.size()); n   } n } n signed main() { solve(); } n "}
         | 
| 79 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n struct fenwick { n   long long n, fen[100005]; n   void resize(int _n) { n     n = _n + 1; n     memset(fen, 0, sizeof fen); n   } n   int query(int ind) { n     ind++; n     int ans = 0; n     while (ind >= 1) { n       ans += fen[ind]; n       ind -= ind & -ind; n     } n     return ans; n   } n   void update(int ind, int val) { n     ind++; n     while (ind <= n) { n       fen[ind] += val; n       ind += ind & -ind; n     } n   } n   int query(int l, int r) { return query(r) - query(l - 1); } n }; n const int maxn = 100001; n int n, l, w, x, y, sz[maxn]; n long long res; n bool blocked[maxn]; n vector<pair<int, int> > c, v[maxn]; n fenwick tree; n void dfs(int node, int pnode, int curw, int curl) { n   c.push_back(make_pair(curw, curl)); n   for (auto &i : v[node]) n     if (i.first != pnode && !blocked[i.first]) n       dfs(i.first, node, curw + i.second, curl + 1); n } n long long solve(int node, int curw, int curl) { n   long long ret = 0; n   c.clear(); n   dfs(node, 0, curw, curl); n   sort(c.begin(), c.end()); n   for (auto &i : c) tree.update(i.second, 1); n   for (int i = 0, j = c.size() - 1; i < c.size(); i++) { n     while (i <= j && c[i].first + c[j].first > w) n       tree.update(c[j--].second, -1); n     if (j < i) break; n     tree.update(c[i].second, -1); n     ret += tree.query(l - c[i].second); n   } n   return ret; n } n int dfsz(int node, int pnode) { n   sz[node] = 1; n   for (auto &i : v[node]) n     if (i.first != pnode && !blocked[i.first]) sz[node] += dfsz(i.first, node); n   return sz[node]; n } n int find(int node, int pnode, int n) { n   for (auto &i : v[node]) n     if (i.first != pnode && !blocked[i.first] && 2 * sz[i.first] > n) n       return find(i.first, node, n); n   return node; n } n void decompose(int node) { n   int centroid = find(node, 0, dfsz(node, 0)); n   blocked[centroid] = 1; n   res += solve(centroid, 0, 0); n   for (auto &i : v[centroid]) n     if (!blocked[i.first]) res -= solve(i.first, i.second, 1); n   for (auto &i : v[centroid]) n     if (!blocked[i.first]) decompose(i.first); n } n int main() { n   ios_base::sync_with_stdio(0); n   cin.tie(NULL); n   cout.tie(NULL); n   cin >> n >> l >> w; n   tree.resize(n + 1); n   for (int i = 2; i <= n && cin >> x >> y; i++) { n     v[i].push_back(make_pair(x, y)); n     v[x].push_back(make_pair(i, y)); n   } n   decompose(1); n   cout << res << endl; n   return 0; n } n "}
         | 
| 80 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n const int maxn = 1e5 + 10; n const int N = 5e2 + 10; n using namespace std; n long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); } n long long qpow(long long p, long long q) { n   long long f = 1; n   while (q) { n     if (q & 1) f = f * p % 1000000007; n     p = p * p % 1000000007; n     q >>= 1; n   } n   return f; n } n int n, m, k, t; n vector<int> d[4][11][10]; n char a[maxn], b[maxn]; n int gao(char p) { n   if (p ==  A ) n     return 0; n   else if (p ==  T ) n     return 1; n   else if (p ==  G ) n     return 2; n   else n     return 3; n } n void add(vector<int>& d, int x, int y) { n   while (x < d.size()) d[x] += y, x += x & (-x); n } n int get(vector<int>& d, int x) { n   int ret = 0; n   while (x) ret += d[x], x -= x & (-x); n   return ret; n } n int main() { n   int i, j; n   scanf( %s , a + 1); n   n = strlen(a + 1); n   for (i = 0; i <= (int)3; i++) n     for (j = 1; j <= (int)10; j++) n       for (k = 0; k <= (int)j - 1; k++) d[i][j][k].resize((n + j - 1) / j + 1); n   for (i = 1; i <= n; i++) { n     for (j = 1; j <= 10; j++) { n       add(d[gao(a[i])][j][(i - 1) % j], (i - 1) / j + 1, 1); n     } n   } n   int q; n   scanf( %d , &q); n   while (q--) { n     int op, x, y; n     scanf( %d%d , &op, &x); n     if (op == 1) { n       scanf( %s , b); n       for (i = 1; i <= (int)10; i++) n         add(d[gao(a[x])][i][(x - 1) % i], (x - 1) / i + 1, -1); n       for (i = 1; i <= (int)10; i++) n         add(d[gao(b[0])][i][(x - 1) % i], (x - 1) / i + 1, 1); n       a[x] = b[0]; n     } else { n       scanf( %d%s , &y, b); n       int len = strlen(b), ret = 0; n       for (i = 0; i < len && i < y - x + 1; i++) { n         int mo = (i + x - 1) % len; n         ret += get(d[gao(b[i])][len][mo], (y - 1 - mo) / len + 1) - n                get(d[gao(b[i])][len][mo], (x - 1 + len - 1 - mo) / len); n       } n       printf( %d n , ret); n     } n   } n   return 0; n } n "}
         | 
| 81 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   long long int i, j, t; n   cin >> t; n   for (long long int aa = 0; aa < t; aa++) { n     long long int n, k, d; n     cin >> n >> k >> d; n     long long int mini = k; n     vector<long long int> v(n); n     map<long long int, long long int> m; n     for (i = 0; i < n; i++) { n       cin >> v[i]; n       if (i < d) { n         long long int ss = m.size(); n         m[v[i]]++; n         if (ss < m.size()) m[v[i]] = 1; n       } n     } n     m.size() < mini ? mini = m.size() : mini = mini; n     for (i = 1; i < n - d + 1; i++) { n       m[v[i - 1]]--; n       if (m[v[i - 1]] == 0) m.erase(v[i - 1]); n       long long int ss = m.size(); n       m[v[i + d - 1]]++; n       if (ss < m.size()) m[v[i + d - 1]] = 1; n       m.size() < mini ? mini = m.size() : mini = mini; n     } n     m.size() < mini ? mini = m.size() : mini = mini; n     cout << mini << endl; n   } n   return 0; n } n "}
         | 
| 82 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   int n; n   cin >> n; n   int *p = new int[n + 1], c = 0; n   int *m = new int[n + 1]; n   for (int i = 0; i <= n; i++) { n     p[i] = m[i] = 0; n     c ^= i; n     m[i] = c; n   } n   int f = 0; n   for (int i = 1; i <= n; i++) { n     cin >> p[i]; n     f ^= p[i]; n   } n   int r = 0; n   for (int i = 2; i <= n; i++) { n     int grps = (n / i); n     int rem = n % i; n     if (grps & 1) r ^= m[i - 1]; n     r ^= m[rem]; n   } n   cout << (r ^ f); n   return 0; n } n "}
         | 
| 83 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int maxn = 1e5 + 5; n long long a[maxn], b[maxn], dp[maxn]; n int q[maxn]; n int head = 0, tail = 0; n double A(int i, int j) { return dp[i] - dp[j]; } n double B(int i, int j) { return b[i] - b[j]; } n int main() { n   ios::sync_with_stdio(false); n   cin.tie(0); n   cout.tie(0); n   int n; n   cin >> n; n   for (int i = 1; i <= n; i++) cin >> a[i]; n   for (int i = 1; i <= n; i++) cin >> b[i]; n   dp[1] = 0; n   int head = 1, tail = 1; n   q[tail] = 1; n   for (int i = 2; i <= n; i++) { n     while (head < tail && n            A(q[head + 1], q[head]) / B(q[head + 1], q[head]) >= -a[i]) n       head++; n     dp[i] = dp[q[head]] + b[q[head]] * a[i]; n     while (head < tail && A(i, q[tail]) / B(i, q[tail]) >= n                               A(q[tail], q[tail - 1]) / B(q[tail], q[tail - 1])) n       tail--; n     q[++tail] = i; n   } n   cout << dp[n] <<   n ; n   return 0; n } n "}
         | 
| 84 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int MAX_INT = numeric_limits<int>::max(); n const int MAX_UINT = numeric_limits<unsigned int>::max(); n void get_acum(const vector<int>& v, vector<int>& acum) { n   int sum = 0; n   for (unsigned int i = 0; i < v.size(); ++i) { n     acum.push_back(sum); n     sum += v[i]; n   } n   acum.push_back(sum); n } n int solve(vector<int>& A, vector<int>& B, vector<int>& X, unsigned int k) { n   if (A.size() + X.size() < k || B.size() + X.size() < k) { n     return -1; n   } else { n     sort(A.begin(), A.end()); n     sort(B.begin(), B.end()); n     sort(X.begin(), X.end()); n     vector<int> A_acum, B_acum, X_acum; n     get_acum(A, A_acum); n     get_acum(B, B_acum); n     get_acum(X, X_acum); n     int res = MAX_INT; n     unsigned int max_i = min((unsigned int)X.size(), k); n     for (unsigned int i = 0; i < max_i + 1; ++i) { n       if (k - i < A_acum.size() && k - i < B_acum.size()) { n         int total = A_acum[k - i] + B_acum[k - i] + X_acum[i]; n         if (total < res) res = total; n       } n     } n     return res; n   } n } n int main() { n   ios::sync_with_stdio(false); n   cin.tie(NULL); n   unsigned int n, k; n   cin >> n >> k; n   vector<int> A; n   vector<int> B; n   vector<int> X; n   for (unsigned int i = 0; i < n; ++i) { n     unsigned int ti; n     bool ai, bi; n     cin >> ti >> ai >> bi; n     if (ai && bi) n       X.push_back(ti); n     else if (ai) n       A.push_back(ti); n     else if (bi) n       B.push_back(ti); n   } n   cout << solve(A, B, X, k); n   return 0; n } n "}
         | 
| 85 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n set<long long int> adj[3005]; n map<long long int, long long int> mq; n long long int done[3005][3005]; n int main() { n   ios_base::sync_with_stdio(false); n   long long int n, m, i, ans = 0; n   cin >> n >> m; n   for (i = 0; i < m; i++) { n     long long int x, y; n     cin >> x >> y; n     adj[x].insert(y); n   } n   for (i = 1; i <= n; i++) { n     for (auto it : adj[i]) { n       for (auto it2 : adj[it]) { n         if (mq.find(it2) != mq.end() && it2 != i) { n           ans += mq[it2]; n         } n         mq[it2]++; n       } n     } n     mq.clear(); n   } n   cout << ans <<   n ; n   return 0; n } n "}
         | 
| 86 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } n int main() { n   int a, b, h; n   cin >> a >> b >> h; n   int c = 0; n   while (h != 0) { n     if (c % 2 == 0) { n       h = h - gcd(a, h); n     } else { n       h = h - gcd(b, h); n     } n     c++; n   } n   if (c % 2 == 0) { n     cout << 1 << endl; n   } else n     cout << 0 << endl; n } n "}
         | 
| 87 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int MAXN = 100000 + 5; n const double EPS = 1e-3; n int n; n int t[MAXN]; n int g(double q) { n   bool ok = true; n   for (int i = 1; i < n; i++) n     if (fabs(double(t[i] - t[i - 1] * q)) > EPS) ok = false; n   if (ok) return 0; n   ok = true; n   for (int i = 2; i < n; i++) n     if (fabs(double(t[i] - t[i - 1] * q)) > EPS) ok = false; n   if (ok) return 1; n   ok = true; n   int prev = t[0]; n   for (int i = 1; i < n; i++) n     if (fabs(double(t[i] - prev * q)) > EPS) { n       if (!ok) return 2; n       ok = false; n     } else n       prev = t[i]; n   return 1; n } n int f() { n   if (n == 1) return 0; n   double q1 = 0, q2 = 0; n   if (t[0] != 0) q1 = double(t[1]) / t[0]; n   if (t[n - 2] != 0) q2 = double(t[n - 1]) / t[n - 2]; n   return min(g(q1), g(q2)); n } n int main() { n   scanf( %d , &n); n   for (int i = 0; i < n; i++) scanf( %d , &t[i]); n   printf( %d n , f()); n } n "}
         | 
| 88 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int MAX = 1e6 + 5; n int a[MAX], run[MAX], ans[MAX]; n char s[MAX]; n int main() { n   ios_base::sync_with_stdio(0); n   cin.tie(0); n   int n; n   scanf( %d , &n); n   scanf( %s , s); n   for (int i = 0; i < n; ++i) { n     if (s[i] ==  0 ) n       a[i] = 0; n     else if (s[i] ==  1 ) n       a[i] = 1; n     else n       a[i] = -1; n   } n   vector<pair<int, int>> blocks; n   int it1 = 0, it2 = 0; n   while (it1 != n) { n     while (it2 < n - 1 && a[it1] == a[it2 + 1]) ++it2; n     blocks.emplace_back(it2 - it1 + 1, a[it1]); n     ++it2; n     it1 = it2; n   } n   for (int i = 0; i < (int)blocks.size(); ++i) { n     if (blocks[i].second != -1) continue; n     if (i == 0) n       blocks[i].second = blocks[i + 1].second; n     else if (i == (int)blocks.size() - 1) n       blocks[i].second = blocks[i - 1].second; n     else if (blocks[i - 1].second == blocks[i + 1].second) n       blocks[i].second = blocks[i - 1].second; n   } n   vector<pair<int, int>> compress; n   it1 = 0; n   it2 = 0; n   while (it1 != (int)blocks.size()) { n     int len = blocks[it1].first; n     while (it2 < (int)blocks.size() - 1 && n            blocks[it1].second == blocks[it2 + 1].second) n       it2++, len += blocks[it2].first; n     compress.emplace_back(len, blocks[it1].second); n     ++it2; n     it1 = it2; n   } n   for (auto block : compress) { n     if (block.second == -1) continue; n     for (int len = 1; len <= block.first; len++) ans[len] += block.first / len; n   } n   int max_size = -1, bef = -2; n   int size = compress.size(); n   for (int i = 0; i < size; i++) { n     int len = compress[i].first; n     int type = compress[i].second; n     if (bef != -1 && type != -1) { n       max_size = len; n       if (i != size - 1) max_size += compress[i + 1].first; n       for (int l = 1; l <= max_size; l++) run[l] = len % l; n     } else if (type == -1) { n       for (int l = 1; l <= max_size; l++) { n         if (run[l] + len >= l) n           run[l] += len, ans[l] += run[l] / l, run[l] %= l; n         else n           run[l] = len; n       } n       int add = 0; n       if (i != (int)size - 1) add += compress[i + 1].first; n       if (i != (int)size - 2) add += compress[i + 2].first; n       for (int l = max_size + 1; l <= len + add; ++l) run[l] = (len % l); n       max_size = len + add; n     } else { n       for (int l = 1; l <= max_size; ++l) { n         if (run[l] + (len % l) >= l) n           run[l] += ((len % l) - l), ans[l]++; n         else n           run[l] += (len % l); n       } n     } n     bef = type; n   } n   for (int i = 1; i <= n; ++i) printf( %d  , ans[i]); n   printf(  n ); n   return 0; n } n "}
         | 
| 89 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n inline int read() { n   int f = 1, x = 0; n   char ch = getchar(); n   while (ch <  0  || ch >  9 ) { n     if (ch ==  - ) { n       f = -1; n     } n     ch = getchar(); n   } n   while (ch >=  0  && ch <=  9 ) { n     x = x * 10 + ch -  0 ; n     ch = getchar(); n   } n   return x * f; n } n const int N = 55; n struct W { n   int x, y, tx, ty, id; n } up[N], down[N]; n bool cmp_down(W a, W b) { return a.tx == b.tx ? a.ty < b.ty : a.tx > b.tx; } n bool cmp_up(W a, W b) { return a.x == b.x ? a.y < b.y : a.x < b.x; } n vector<pair<int, int> > ans_fr, ans_to; n bool has[N][N]; n void move_up(int& x, int y) { n   int dx = x; n   has[x][y] = 0; n   has[x - 1][y] = 1; n   ans_fr.push_back(make_pair(dx, y)); n   ans_to.push_back(make_pair(dx - 1, y)); n   --x; n } n void move_down(int& x, int y) { n   int dx = x; n   has[x][y] = 0; n   has[x + 1][y] = 1; n   ans_fr.push_back(make_pair(dx, y)); n   ans_to.push_back(make_pair(dx + 1, y)); n   ++x; n } n void move_left(int x, int& y) { n   int dy = y; n   has[x][y] = 0; n   has[x][y - 1] = 1; n   ans_fr.push_back(make_pair(x, dy)); n   ans_to.push_back(make_pair(x, dy - 1)); n   --y; n } n void move_right(int x, int& y) { n   int dy = y; n   has[x][y] = 0; n   has[x][y + 1] = 1; n   ans_fr.push_back(make_pair(x, dy)); n   ans_to.push_back(make_pair(x, dy + 1)); n   ++y; n } n void move_row(int& x, int& y, int tx, int ty) { n   while (y < ty && has[x][y + 1] == 0) { n     move_right(x, y); n   } n   while (y > ty && has[x][y - 1] == 0) { n     move_left(x, y); n   } n } n void move(int& x, int& y, int tx, int ty) { n   while (x < tx) { n     move_down(x, y); n   } n   while (x > tx) { n     move_up(x, y); n   } n   while (y < ty) { n     move_right(x, y); n   } n   while (y > ty) { n     move_left(x, y); n   } n } n int check(W a) { n   if (a.x == a.tx) { n     return a.y == a.ty ? 0 : 1; n   } else { n     return a.y == a.ty ? 2 : 3; n   } n } n int nx[N], ny[N]; n char mp[N][N]; n int vis[N]; n void write(int n) { n   for (int i = 1; i <= n; i++) { n     cout << mp[i] + 1 << endl; n   } n   puts( ---------------------- ); n } n void deal(int n, int m) { n   if (n == 1) { n     puts( 0 ); n   } else { n     if (m == 1) { n       move(up[1].x, up[1].y, up[1].tx, up[1].ty); n     } else { n       if (cmp_up(up[1], up[2]) == 0) { n         swap(up[1], up[2]); n       } n       if (up[1].x == 2) { n         move_up(up[1].x, up[1].y); n         move_up(up[2].x, up[2].y); n       } else if (up[2].x == 2) { n         move_up(up[2].x, up[2].y); n       } n       switch (check(up[1])) { n         case 0: n           break; n         case 1: n           move(up[2].x, up[2].y, 2, 1); n           move_right(up[1].x, up[1].y); n           break; n         case 2: n           move(up[1].x, up[1].y, up[1].tx, up[1].ty); n           break; n         case 3: n           move(up[1].x, up[1].y, up[1].tx, up[1].ty); n           move_left(up[2].x, up[2].y); n           break; n       } n       move(up[2].x, up[2].y, up[2].tx, up[2].ty); n     } n     cout << ans_fr.size() << endl; n     for (int i = 0; i < ans_fr.size(); i++) { n       int xx1 = ans_fr[i].first, xx2 = ans_to[i].first; n       int yy1 = ans_fr[i].second, yy2 = ans_to[i].second; n       printf( %d %d %d %d n , xx1, yy1, xx2, yy2); n     } n   } n } n int main() { n   int n = read(), m = read(); n   for (int i = 1; i <= n; i++) { n     for (int j = 1; j <= n; j++) { n       mp[i][j] =  . ; n     } n   } n   for (int i = 1; i <= m; i++) { n     up[i].id = i; n     nx[i] = up[i].x = read(); n     ny[i] = up[i].y = read(); n     has[nx[i]][ny[i]] = 1; n     mp[nx[i]][ny[i]] = i +  0 ; n   } n   for (int i = 1; i <= m; i++) { n     up[i].tx = read(); n     up[i].ty = read(); n   } n   if (n <= 2) { n     deal(n, m); n     return 0; n   } n   copy(up + 1, up + 1 + m, down + 1); n   sort(up + 1, up + 1 + m, cmp_up); n   int cnt = m; n   while (cnt) { n     for (int i = 1; i <= m; i++) { n       if (vis[i] == 0) { n         int id = up[i].id; n         move_row(nx[id], ny[id], 1, i); n         if (ny[id] == i) { n           vis[i] = 1; n           cnt--; n         } n       } n     } n   } n   for (int i = 1; i <= m; i++) { n     int id = up[i].id; n     while (nx[id] > 1) { n       move_up(nx[id], ny[id]); n     } n   } n   for (int i = 1; i <= m; i++) { n     move_down(nx[i], ny[i]); n     move_down(nx[i], ny[i]); n   } n   sort(down + 1, down + 1 + m, cmp_down); n   for (int i = 1; i <= m; i++) { n     int id = down[i].id; n     move_up(nx[id], ny[id]); n     move_row(nx[id], ny[id], 1, i); n     move_up(nx[id], ny[id]); n   } n   for (int i = 1; i <= m; i++) { n     int id = down[i].id; n     while (nx[id] < down[i].tx) { n       move_down(nx[id], ny[id]); n     } n   } n   cnt = m; n   while (cnt) { n     for (int i = 1; i <= m; i++) { n       if (vis[i] == 1) { n         int id = down[i].id; n         move_row(nx[id], ny[id], nx[id], down[i].ty); n         if (ny[id] == down[i].ty) { n           vis[i] = 2; n           cnt--; n         } n       } n     } n   } n   assert(ans_fr.size() == ans_to.size()); n   assert(ans_fr.size() <= 10800); n   cout << ans_fr.size() << endl; n   for (int i = 0; i < ans_fr.size(); i++) { n     int xx1 = ans_fr[i].first, xx2 = ans_to[i].first; n     int yy1 = ans_fr[i].second, yy2 = ans_to[i].second; n     printf( %d %d %d %d n , xx1, yy1, xx2, yy2); n   } n   return 0; n } n "}
         | 
| 90 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   int n, m; n   cin >> n >> m; n   int a[m], b[m]; n   int ndup = n; n   for (int i = 0; i < m; i++) { n     cin >> a[i]; n     b[i] = a[i]; n   } n   sort(a, a + m); n   sort(b, b + m, greater<int>()); n   int mn = 0, mx = 0; n   for (int i = 0; i < m; i++) { n     while (a[i] > 0 && n > 0) { n       mn += a[i]; n       a[i]--; n       n--; n     } n   } n   while (ndup > 0) { n     mx += b[0]; n     b[0]--; n     ndup--; n     sort(b, b + m, greater<int>()); n   } n   cout << mx <<     << mn; n } n "}
         | 
| 91 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   long long a, b, c, d, e, f, g, h, i, j, k, l, m, n, t; n   cin >> t; n   while (t--) { n     cin >> n; n     cout << (n + 1) / 2 << endl; n   } n } n "}
         | 
| 92 | 
            +
            {"func_code_string": "//...START BY DOING WHAT IS NECESSARY, THEN WHAT IS POSSIBLE AND SUDDENLY YOU ARE DOING THE IMPOSSIBLE...  n #include <bits/stdc++.h> n using namespace std; n #define FAST_FURIER ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); n #define pb push_back n #define mk make_pair n #define rep(i,a,N) for(ll i=a;i<N;i++) n #define rrep(i,a,N) for(ll i=a;i>N;i--) n typedef long long ll; n #define M 1000000007 n bool comp(int x,int y) n { n     return x > y; n } n   n   n /*..............................code starts here........................*/ n // C is first won in M n   n   n int main() { n     FAST_FURIER; n     int tt=1; n     cin >> tt; n     ll m,d,k; n    //ll a,b,c; n     while(tt--) n     { n         cin >> d >> k; n         ll x = 0,y = 0; n         int f = 0; n         while(true){ n             ll d1 = pow(x+k,2)+pow(y,2), d2 = pow(x,2)+pow(y+k,2); n             f = abs(f-1); n             if(d1 < d2 and d1 <= d*d){ n                 x += k; n             } n             else if(d2 <= d1 and d2 <= d*d) y += k; n             else break; n         } n         if(f) cout <<  Utkarsh ; n         else cout <<  Ashish ; n         cout << endl; n  n     } n } n   n   n   n // Author : shivam_123 n   n // g++ -std=c++17"}
         | 
| 93 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n long long a, b, c, e[200000], mix, l, r, o, d[200000]; n vector<long long> v[100000], v1; n set<long long> st; n map<long long, long long> mp, mp1; n string s; n pair<int, int> p[100000], p1[100000]; n char ch[10]; n deque<char> dq; n int main() { n   cin >> a; n   for (int i = 0; i < a / 4; i++) n     if ((a - 2 * (i + 1)) % 2 == 0) c++; n   if (a % 4 == 0) { n     cout << c - 1; n   } else n     cout << c; n } n "}
         | 
| 94 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n char s[5000005]; n int len[1000005]; n int idx[1000005]; n int sum[1000005]; n int sz = 0; n int dp[1000005][20]; n int p[1000005]; n int main() { n   int n, r, c; n   scanf( %d%d%d , &n, &r, &c); n   gets(s); n   gets(s); n   int cnt = 0, slen = 0; n   for (int i = 0; s[i]; i++, slen++) { n     if (s[i] ==     && cnt != 0) { n       len[sz] = cnt; n       idx[sz++] = i - cnt; n       cnt = 0; n     } else n       cnt++; n   } n   if (cnt > 0) { n     len[sz] = cnt; n     idx[sz++] = slen - cnt; n     cnt = 0; n   } n   sum[0] = len[0]; n   for (int i = 1; i < n; i++) sum[i] = sum[i - 1] + 1 + len[i]; n   for (int i = n - 1; i >= 0; i--) { n     int id = upper_bound(sum, sum + n, (i > 0 ? sum[i - 1] + 1 : 0) + c) - sum; n     if (id > n) id = n; n     dp[i][0] = id - i; n   } n   for (int j = 2, t = 1; j <= r; j *= 2, t++) { n     for (int i = n - 1; i >= 0; i--) n       dp[i][t] = dp[i][t - 1] + dp[i + dp[i][t - 1]][t - 1]; n   } n   int maid = -1, ma = 0; n   for (int i = 0; i < n; i++) { n     int idx = i, rr = r, cur = 0; n     for (int j = 20; j >= 0; j--) { n       if (rr >= (1 << j)) { n         rr -= (1 << j); n         cur += dp[idx][j]; n         idx += dp[idx][j]; n       } n     } n     if (cur > ma) maid = i, ma = cur; n   } n   int cn = 1, cs = dp[maid][0]; n   for (int i = maid; i < maid + ma; i++) { n     s[idx[i] + len[i]] = 0; n     if (cn < cs) { n       printf( %s  , s + idx[i]); n       cn++; n     } else { n       printf( %s n , s + idx[i]); n       cs = dp[i + 1][0]; n       cn = 1; n     } n   } n   return 0; n } n "}
         | 
| 95 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n char change(char curranswer) { n   if (curranswer ==  z ) n     curranswer =  A ; n   else if (curranswer ==  Z ) n     curranswer =  0 ; n   else if (curranswer ==  9 ) n     ; n   else n     curranswer++; n   return curranswer; n } n int main() { n   long long i, j, t; n   cin >> t; n   while (t--) { n     long long r, c, k; n     long long rice = 0; n     char a[100][100]; n     cin >> r >> c >> k; n     for (i = 0; i < r; i++) { n       for (j = 0; j < c; j++) { n         cin >> a[i][j]; n         if (a[i][j] ==  R ) rice++; n       } n     } n     long long ans = rice / k; n     long long maxx = rice - k * ans; n     long long minn = k - maxx; n     char curranswer =  a ; n     long long currcount = 0; n     bool flag = true; n     for (i = 0; i < r; i++) { n       for (flag ? (j = 0) : (j = c - 1); flag ? (j < c) : j >= 0; n            flag ? j++ : j--) { n         bool local = false; n         if (a[i][j] ==  R ) local = true; n         a[i][j] = curranswer; n         if (local) { n           currcount++; n           if (maxx > 0) { n             if (currcount == ans + 1) { n               maxx--; n               currcount = 0; n               curranswer = change(curranswer); n             } n           } else if (minn > 0) { n             if (currcount == ans) { n               minn--; n               currcount = 0; n               if (minn) curranswer = change(curranswer); n             } n           } n         } n       } n       flag = !flag; n     } n     for (i = 0; i < r; i++) { n       for (j = 0; j < c; j++) cout << a[i][j]; n       cout << endl; n     } n   } n } n "}
         | 
| 96 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n long long gcd(long long x, long long y) { n   if (y == 0) n     return x; n   else n     return gcd(y, x % y); n } n long long expo(long long n, long long m) { n   long long r = 1; n   while (m > 0) { n     if (m % 2) r = (r * n) % 1000000009; n     n = (n * n) % 1000000009; n     m = m / 2; n   } n   return r % 1000000009; n } n long long lx = 0, ly = 0; n bool check(long long x, long long y) {} n int main() { n   ios::sync_with_stdio(0); n   cin.tie(0); n   cout.tie(0); n   ; n   long long a, b; n   cin >> a >> b; n   string s; n   cin >> s; n   long long p = 0, q = 0; n   if (a == 0 && b == 0) { n     cout <<  Yes ; n     return 0; n   } n   for (long long i = 0; i < s.size(); i++) { n     if (s[i] ==  U ) { n       ly++; n     } else if (s[i] ==  D ) n       ly--; n     else if (s[i] ==  L ) n       lx--; n     else n       lx++; n     if (lx == a && ly == b) { n       cout <<  Yes ; n       return 0; n     } n   } n   if (lx == 0 && ly == 0) { n     cout <<  No ; n     return 0; n   } n   for (long long i = 0; i < s.size(); i++) { n     if (s[i] ==  U ) { n       q++; n     } else if (s[i] ==  D ) n       q--; n     else if (s[i] ==  L ) n       p--; n     else n       p++; n     long long x = a - p, y = b - q, X = lx, Y = ly; n     if (lx == 0) { n       if (ly > 0 && y > 0 && x == 0 && y % ly == 0) { n         cout <<  Yes ; n         return 0; n       } else if (ly < 0 && y < 0 && x == 0) { n         ly = -1 * ly, y = -1 * y; n         if (y % ly == 0) { n           cout <<  Yes ; n           return 0; n         } n       } n     } else if (ly == 0) { n       if (lx > 0 && x > 0 && y == 0 && x % lx == 0) { n         cout <<  Yes ; n         return 0; n       } else if (lx < 0 && x < 0 && y == 0) { n         lx = -1 * lx, x = -1 * x; n         if (x % lx == 0) { n           cout <<  Yes ; n           return 0; n         } n       } n     } else { n       if (lx > 0 && x > 0) { n         if (ly > 0 && y > 0) { n           if (x / lx == y / ly && x % lx == 0 && y % ly == 0) { n             cout <<  Yes ; n             return 0; n           } n         } else if (ly < 0 && y < 0) { n           ly = -1 * ly, y = -1 * y; n           if (x / lx == y / ly && x % lx == 0 && y % ly == 0) { n             cout <<  Yes ; n             return 0; n           } n         } n       } else if (lx < 0 && x < 0) { n         lx = -1 * lx, x = -1 * x; n         if (ly > 0 && y > 0) { n           if (x / lx == y / ly && x % lx == 0 && y % ly == 0) { n             cout <<  Yes ; n             return 0; n           } n         } else if (ly < 0 && y < 0) { n           ly = -1 * ly, y = -1 * y; n           if (x / lx == y / ly && x % lx == 0 && y % ly == 0) { n             cout <<  Yes ; n             return 0; n           } n         } n       } n     } n     lx = X, ly = Y; n   } n   cout <<  No ; n   return 0; n } n "}
         | 
| 97 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int N = int(3e5), mod = int(1e9) + 7; n int n; n int a[N], c[N]; n long long t[N]; n long long x[N], pref[N]; n long double p[N]; n long long suf[N]; n void upd(int v, int val) { n   v += n - 1; n   t[v] += val; n   c[v]++; n   while (v > 1) { n     v >>= 1; n     t[v] = t[v + v] + t[v + v + 1]; n     c[v] = c[v + v] + c[v + v + 1]; n   } n } n long long get(int l, int r) { n   l += n - 1; n   r += n - 1; n   long long res = 0; n   while (l <= r) { n     if (l & 1) res += t[l]; n     if (!(r & 1)) res += t[r]; n     l = (l + 1) >> 1; n     r = (r - 1) >> 1; n   } n   return res; n } n int cnt(int l, int r) { n   l += n - 1; n   r += n - 1; n   int res = 0; n   while (l <= r) { n     if (l & 1) res += c[l]; n     if (!(r & 1)) res += c[r]; n     l = (l + 1) >> 1; n     r = (r - 1) >> 1; n   } n   return res; n } n int main() { n   scanf( %d , &n); n   for (int i = 1; i <= n; i++) { n     scanf( %d , &a[i]); n   } n   long long all = 1ll * n * (n + 1) / 2; n   long double res = 0; n   for (int i = 1; i <= n; i++) { n     long long cur = get(1, a[i] - 1); n     long double p = (cur + 0.0) * (n - i + 1) / all; n     res += p * 0.5; n     cur = get(a[i] + 1, n); n     p = (cur + 0.0) * (n - i + 1) / all; n     res += cnt(a[i] + 1, n); n     res -= p * 0.5; n     upd(a[i], i); n   } n   printf( %.12lf , double(res)); n   return 0; n } n "}
         | 
| 98 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   long long a, b; n   cin >> a >> b; n   long long ans = 0; n   while (true) { n     long long x = max(a, b); n     long long y = min(a, b); n     if (x == 0 || y == 0) break; n     long long n = x / y; n     ans += n; n     x -= n * y; n     a = x; n     b = y; n   } n   cout << ans; n   return 0; n } n "}
         | 
| 99 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   ios_base::sync_with_stdio(0); n   cin.tie(0); n   cout.tie(0); n   int x, test; n   cin >> test; n   while (test--) { n     int n, c0, c1, h; n     string s; n     cin >> n >> c0 >> c1 >> h >> s; n     int cnt0 = 0, cnt1 = 0; n     for (auto &z : s) { n       cnt0 += z ==  0 ; n       cnt1 += z ==  1 ; n     } n     int cost = (cnt0 * c0) + (cnt1 * c1); n     int cost0 = (c0 * n) + (cnt1 * h); n     int cost1 = (c1 * n) + (cnt0 * h); n     cout << min({cost, cost0, cost1}) <<   n ; n   } n   return 0; n } n "}
         | 
| 100 | 
            +
            {"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int inf = int(1e9) + 123; n int main() { n   int n, v; n   cin >> n >> v; n   vector<int> a; n   for (int i = 1; i <= n; i++) { n     int x; n     cin >> x; n     a.push_back(x); n   } n   sort(a.begin(), a.end()); n   int sum = 0; n   for (int i = 0; i < a.size() - 1; i++) { n     sum += a[i]; n   } n   if (sum <= v) { n     cout <<  YES ; n   } else { n     cout <<  NO ; n   } n   return 0; n } n "}
         |