akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll H, W, K;
    cin >> H >> W >> K;
    VS s(H);
    rep(i, 0, H) cin >> s[i];
    ll ans = 0;
    for(int hbit = 0; hbit < (1<<H); hbit++){
        for(int wbit = 0; wbit < (1<<W); wbit++){
            ll cnt = 0;
            rep(h, 0, H){
                rep(w, 0, W){
                    if((hbit & (1<<(int)h)) || (wbit & (1<<(int)w))) continue;
                    if(s[h][w] == '#') cnt++;
                }
            }
            // cerr << cnt << endl;
            if(cnt == K){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<int, int>;
using vi = vector<int>;
using vpi = vector<pi>;
using ld = long double;
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
//using oset = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn = 1<<20, mod = (119<<23)+1;
struct node {
	int sum = 0;
	node *l, *r;
	node(int s = 0) : sum(s), l(0), r(0) {}
};
deque<node> buffer;
using pnode = node*;
pnode newnode(int x) {
	buffer.emplace_back(x);
	return &buffer.back();
}
pnode merge(pnode l, pnode r) {
	pnode a = newnode(0);
	a->sum = l->sum + r->sum;
	a->l = l;
	a->r = r;
	return a;
}
pnode init(int l, int r) {
	if(l == r) return newnode(0);
	int mid = (l+r)>>1;
	return merge(init(l, mid), init(mid+1, r));
}
pnode upd(int l, int r, int i, int x, pnode rt) {
	if(l > i || i > r) return rt;
	if(l == r) return newnode(rt->sum + x);
	int mid = (l+r)>>1;
	return merge(upd(l, mid, i, x, rt->l), upd(mid+1, r, i, x, rt->r));
}
int get(int l, int r, int ql, int qr, pnode rt) {
	if(qr < l || r < ql) return 0;
	if(ql <= l && r <= qr) return rt->sum;
	int mid = (l+r)>>1;
	return get(l, mid, ql, qr, rt->l) + get(mid+1, r, ql, qr, rt->r);
}
pnode rt[maxn];
int n, m;
vi h[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for(int l, r, i = 0; i < n; i++) {
		cin >> l >> r;
		h[l].pb(r);
	}
	for(int i = 0; i <= m; i++) {
		if(i)
			rt[i] = rt[i-1];
		else
			rt[i] = init(0, m);
		for(auto j : h[i]) rt[i] = upd(0, m, j, 1, rt[i]);
		//cout << i << ":\n";
		//for(int j = 0; j <= m; j++) cout << get(0, m, j, j, rt[i]) << ' '; cout << '\n';
	}
	for(int i = 1; i <= m; i++) {
		int ans = 0;
		for(int j = 0; j <= m; j += i) {
			ans += get(0, m, j, min(m, j+i-1), rt[j]);
		}
		cout << ans << '\n';
	}
}


Measured memory_bytes: 165496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main() {
    int n,ans = 0;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    int sum = 0; // sum も使い回す
    int right = 0;
    for (int left = 0; left < n; ++left) {
        /* sum に a[right] を加えても大丈夫なら right を動かす */
        while (right+1 < n && h[right+1] <= h[right]) {
            ++sum;
            ++right;
        }

        /* break した状態で right は条件を満たす最大 */
        ans = max(right - left,ans);

        /* left をインクリメントする準備 */
        if (right == left) ++right; // right が left に重なったら right も動かす
        //else sum--; // left のみがインクリメントされるので sum から a[left] を引く
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;

int main(){
    int x, n, i, j;
    int p[n];
    cin >> x >> n;
    for(i=0; i<n; i++){
        cin>>p[i];
    }
    for(i=0;;i++){
        for(j=0; j<n; j++){
            if(x-i == p[j]) break;
        }
        if(j==n){
            cout << x-i << endl;
            return 0;
        }
        for(j=0; j<n; j++){
            if(x+i == p[j]) break;
        }
        if(j==n){
            cout << x+i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
using namespace std;

int main(void){
    int K,len=0;
    string S,str;

    cin >> K;
    cin >> S;
    if(K<1||100<K)
        return 0;
    len=S.length();
    if(len<1||100<len)
        return 0;
    for(int i=0;i<len;i++){
        if(isupper(S[i]))
            return 0;
    }

    if(len<=K){
        cout << S << endl;
    }
    else if(len>K){
        str = S.substr(0,K) + "...";
        cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
def main():
    n = int(input())
    A = list(map(int, input().split()))
    s = 0
    c1 = 0
    for i, a in enumerate(A):
        s += a
        if i % 2 == 0:
            if s == 0:
                c1 += 1
            elif s < 0:
                c1 += 1 - s
            else:
                continue
            s = 1
        else:
            if s == 0:
                c1 += 1
            elif s > 0:
                c1 += s + 1
            else:
                continue
            s = -1
    s = 0
    c2 = 0
    for i, a in enumerate(A):
        s += a
        if i % 2 != 0:
            if s == 0:
                c2 += 1
            elif s < 0:
                c2 += 1 - s
            else:
                continue
            s = 1
        else:
            if s == 0:
                c2 += 1
            elif s > 0:
                c2 += s + 1
            else:
                continue
            s = -1
    print(min(c1, c2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20384
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N; cin >> N;
    string color; cin >> color;
    int ans = 1;
    for( int i = 0; i < N-1; i++ ){
        if( color[i+1] == color[i] ) continue;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#define len 12

using namespace std;

char num[12];
int in;

int main () {

  while ( true ) {
    cin >> in;

    if ( in == 0 )
      break;

    for ( int i=11; i>=0; i-- ) {
      num[i] = (in & 7) + '0';
      //num[i] = in%8+'0';
      in = in>>3;
    }
  
    int count = 0;
    while ( num[count] == '0' )
      count++;
  

    for ( int i=count;i <len; i++ ) {
      if ( num[i] == '4' )
	cout << '5';
      else if ( num[i] >'4' )
	cout << (char)(num[i]+2);
      else
	cout << num[i];
    }
    cout << endl;
  }

}

Measured memory_bytes: 852
function main(input) {
    var N = input[0].split(" ")[0]-0;
    var K = input[0].split(" ")[1]-0;
    var list = input[1].split(" ").map(v=>((v-0)+1)/2);
    var ans = 0;
    var tmp = 0;
    for(var i=0;i<K;i++) tmp += list[i];
    ans = tmp;
    for(var i=K;i<N;i++){
        tmp -= list[i-K];
        tmp += list[i];
        ans = Math.max(ans,tmp);
    }
    
    console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 32864
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a[3]={1000,500,100},b[3],p,q;
  while(cin>>p>>q&&p+q){
    q-=p;
    memset(b,0,sizeof(b));
    for(i=0;i<3;i++){
      b[i]+=q/a[i];
      q-=q/a[i]*a[i];
    }
    cout<<b[2]<<" "<<b[1]<<" "<<b[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
  int a, b, d, r;
  double f;
  cin>> a >> b;
  d=a/b;
  r=a%b;
  f=double (a)/double (b);
  printf("%d %d %5f\n",d,r,f);
  
}



Measured memory_bytes: 3204
/*
      author : nishi5451
      created: 11.08.2020 20:48:00
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int R;
    cin >> R;
    if(R<1200) printf("%s\n","ABC");
    else if(R<2800) printf("%s\n","ARC");
    else printf("%s\n","AGC");
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  int p[n];
  for(int i=0;i<n;i++){
	scanf("%d",&p[i]);
  }
    int c=0;
    for(int i=1;i<n-1;i++){
	if(p[i-1]<p[i]&&p[i]<p[i+1]||
       p[i+1]<p[i]&&p[i]<p[i-1])c++;
    }
printf("%d",c);
    return 0;
  }

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int i;
	int n;
	int max;
	int flag;
	int k;

	while (1){
		scanf("%d", &n);
		if (n == 0){
			return (0);
		}

		max = n + 1;
		flag = 1;
		
		for (i = 0; i < n; i++){
			scanf("%d", &k);
				
			if (k > 1){
				flag = 0;
			}
			else if (k == 0){
				max--;
			}
		}
		if (flag == 1){
			printf("NA\n");
		}
		else {
			printf("%d\n", max); 
		}
	}
	return (0);
}

Measured memory_bytes: 612
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll dp[100001][4];
int main() {
	string s;
	cin >> s;
	int n = s.size();
	dp[n][3] = 1;
	rrep(i, n){
		rrep(j, 4){
			dp[i][j] = dp[i + 1][j] * (s[i] == '?' ? 3 : 1);
			if(j < 3 && (s[i] == '?' || s[i] == "ABC"[j]))
				dp[i][j] += dp[i+1][j+1];
			dp[i][j] %= mod;
		}
	}
	cout << dp[0][0] << endl;
	return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

typedef struct {
    int x;
    int y;
} point_t;

int main(int argc, char *argv[])
{
    int i, j, N, M, min, v, idx = 0;
    point_t ab[50], cd[50];
    scanf("%d %d", &N, &M);
    for ( i = 0; i < N; i++ ){
        scanf("%d %d", &ab[i].x, &ab[i].y);
    }
    for ( i = 0; i < M; i++ ){
        scanf("%d %d", &cd[i].x, &cd[i].y);
    }
    for ( i = 0; i < N; i++ ){
        for ( j = 0, min = INT_MAX; j < M; j++ ){
            v = abs(ab[i].x - cd[j].x) + abs(ab[i].y - cd[j].y);
            if ( min > v ){
                min = v;
                idx = j + 1;
            }
        }
        printf("%d\n", idx);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[11];
int main()
{
	scanf("%s",s);
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define F first
#define S second
//const ll mod=1e9+7;
void solve(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    for(int i=0;i<n;i++){
    	if(s[i]!=t[i]){
    		cout<<"No";
    		return;
    	}
    }
    cout<<"Yes";
}
int main(){
    IOS;
    /*int t;
    cin>>t;
    while(t--){
        solve();
    }*/
    solve();
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  string s;
  cin >> s;
  int cnt=0;
  rep(i,3) if(s[i]=='o') cnt+=100;

  cout << 700+cnt << endl;
  return 0;
} 

Measured memory_bytes: 3624
// In the name of God

#include <bits/stdc++.h>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define per(i, a, b) for(int i=a; i>=b; i--)
using namespace std;
#define int long long
map<int,int> mp;
vector<int> types;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n;	
	cin >> n;
	bool nonzero = false;
	rep(i, 0, n) {
		int x;
		cin >> x;
		if(x) nonzero = true;
		mp[x]++;
	}
	if(!nonzero) {
		cout << "Yes";
		exit(0);
	}
	if(n % 3 != 0) {
		cout << "No";
		exit(0);
	}
	for(auto x : mp) {
		types.push_back(x.first);
	}
	if(types.size() == 1) {
		cout << "No";
		exit(0);
	}
	if(types.size() > 3) {
		cout << "No";
		exit(0);
	}
	if(types.size() == 2) {
		if(types[0] != 0 && types[1] != 0) {
			cout << "No";
			exit(0);
		}
		int other = types[0] ? types[0] : types[1];
		if( mp[other] != mp[0]*2) {
			cout << "No";
			exit(0);
		}
		cout << "Yes";
		exit(0);
	}
	assert(types.size() == 3);
	if( mp[types[0]] == mp[types[1]] && mp[types[1]] == mp[types[2]] ) {
		if( (types[0]^types[1]) == types[2] && (types[0]^types[2])==types[1] ) {
			cout << "Yes";
			exit(0);
		}
		else {
			cout << "No";
			exit(0);
		}
	}
	else {
		cout << "No";
		exit(0);
	}
	assert(false);
	return 0;
}


Measured memory_bytes: 6264
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

ll f(ll x){
  ll cnt=0;
  if(x==0) return 0;
  while(x!=0){
   x/=10;
   cnt++;
   }
   return cnt;
}


int main() {
  int n,m;
  cin>>n>>m;
  vector<pair<ll,int>> city[n];
  vector<string> ans(m);
  rep(i,m){
    int p;
    ll y;
    cin >> p >>y;
    p--;
    city[p].emplace_back(y,i);
  }

  rep(cn,n){
    sort(city[cn].begin(),city[cn].end());
    int no = 1;
    for(auto c :city[cn]){
      int cityNum = c.second;
      int numZero = f(cn+1);
      string uid="";
      rep(i,6-numZero) uid+="0";
      uid+=to_string(cn+1);
      numZero = f(no);
      rep(i,6-numZero) uid+="0";
      uid+=to_string(no);
      ans[cityNum] = uid;
      no++;
    }    
  }
  rep(i,m)cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;

#define ll long long

const int mxN=2e5;
int n, m, li, ri, ai;
ll dp, ps[mxN+1], st[1<<19], lz[1<<19];
vector<array<int, 2>> ex[mxN];

void app(int i, ll x) {
	st[i]+=x;
	lz[i]+=x;
}

void psh(int i) {
	app(2*i, lz[i]);
	app(2*i+1, lz[i]);
	lz[i]=0;
}

void upd(int l1, int r1, ll x, int i=1, int l2=0, int r2=n) {
	if(l1<=l2&&r2<=r1) {
		app(i, x);
		return;
	}
	int m2=(l2+r2)/2;
	psh(i);
	if(l1<=m2)
		upd(l1, r1, x, 2*i, l2, m2);
	if(m2<r1)
		upd(l1, r1, x, 2*i+1, m2+1, r2);
	st[i]=max(st[2*i], st[2*i+1]);
}

ll qry(int l1, int r1, int i=1, int l2=0, int r2=n) {
	if(l1<=l2&&r2<=r1)
		return st[i];
	psh(i);
	int m2=(l2+r2)/2;
	return max(l1<=m2?qry(l1, r1, 2*i, l2, m2):0, m2<r1?qry(l1, r1, 2*i+1, m2+1, r2):0);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> m;
	for(int i=0; i<m; ++i) {
		cin >> li >> ri >> ai;
		ps[li-1]+=ai;
		ps[ri]-=ai;
		ex[ri-1].push_back({li, ai});
		upd(li, ri, -ai);
	}
	for(int i=1; i<n; ++i)
		ps[i]+=ps[i-1];
	for(int i=0; i<n; ++i) {
		upd(i+1, i+1, qry(0, i)+ps[i]);
		for(array<int, 2> a : ex[i])
			upd(a[0], i+1, a[1]);
	}
	cout << qry(0, n);
}


Measured memory_bytes: 23040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

template <typename T> class BIT {
  public:
    int n;
    vector<T> nodes;
    BIT(int _n) : n(_n), nodes(_n + 1, 0) {}
    void add(int i, T v) {
        for (++i; i <= n; i += i & (-i)) nodes[i] += v;
    }
    T sum(int i) {
        T res = 0;
        for (++i; i > 0; i -= i & (-i)) res += nodes[i];
        return res;
    }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<int> c(N);
    for (int i = 0; i < N; ++i) cin >> c[i];
    vector<tuple<int, int, int, int>> lr;  // (l, r, index, answer)
    for (int i = 0; i < Q; ++i) {
        int l, r;
        cin >> l >> r;
        lr.emplace_back(l, r, i, 0);
    }

    sort(lr.begin(), lr.end(), [](auto a, auto b) { return get<1>(a) < get<1>(b); });

    vector<int> last(N + 1, -1);  // last[color] = index
    BIT<int> indices(N + 10);

    int k = 0;
    for (int i = 0; i < Q; ++i) {
        while (k < get<1>(lr[i])) {
            if (last[c[k]] != -1) { indices.add(last[c[k]], -1); }
            last[c[k]] = k + 1;
            indices.add(last[c[k]], 1);
            k++;
        }
        get<3>(lr[i]) = indices.sum(get<1>(lr[i])) - indices.sum(get<0>(lr[i]) - 1);
    }

    sort(lr.begin(), lr.end(), [](auto a, auto b) { return get<2>(a) < get<2>(b); });

    for (int i = 0; i < Q; ++i) { cout << get<3>(lr[i]) << endl; }

    return 0;
}

Measured memory_bytes: 17464
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int w,h,c,a,r,z,x;
  cin>>w>>h>>c;
  z=w;
  x=h;
  if(z<x){
    a=z;
    z=x;
    x=a;
  }
  r=z%x;
  while(r!=0){
    z=x;
    x=r;
    r=z%x;
  }
  w=w/x;
  h=h/x;
  cout<<w*h*c<<"\n";
}



Measured memory_bytes: 3104
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	for i := range s {
		first := s[0 : len(s)-i-1]
		second := s[len(s)-1-i:]
		tmp := second + first
		if tmp == t {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
/*input
50 30 -1
30 50 -1
40 40 -1
35 50 -1
20 50 -1
30 40 -1
25 35 -1
35 25 -1
30 35 -1
35 30 -1
25 40 -1
30 49 -1
29 50 -1
50 29 -1
25 25 -1
26 24 -1
50 0 -1
0 50 -1
49 1 -1
1 49 -1
2 49 -1
32 32 -1
50 14 -1
15 15 50
15 15 100
15 15 80
15 15 65
29 29 100
29 29 80
29 29 65
15 15 50
15 15 49
15 15 0
15 15 -1
29 0 -1
29 0 40
29 0 29
-1 50 -1
50 -1 -1
0 0 -1
1 1 -1
15 14 -1
14 15 -1
29 0 -1
0 29 -1
-1 -1 -1
*/
macro_rules! input_vec {
    () => {
        input!()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    ($delimiter:expr) => {
        input!()
            .split($delimiter)
            .map(|x| x.parse().unwrap())
            .collect()
    };
}

macro_rules! input {
    () => {{
        let mut return_ = String::new();
        std::io::stdin().read_line(&mut return_).ok();
        return_.pop();
        return_
    }};
}

fn main() {
    let mut v: Vec<i32>;
    let (mut t1, mut t2);
    loop {
        v = input_vec!();
        if v[0] == -1 && v[1] == -1 {
            break;
        } else if v[0] == -1 || v[1] == -1 {
            println!("F");
            continue;
        }
        t1 = if v[0] != -1 { v[0] } else { 0 };
        t2 = if v[1] != -1 { v[1] } else { 0 };
        if t1 + t2 >= 80 {
            println!("A");
        } else if t1 + t2 >= 65 {
            println!("B");
        } else if t1 + t2 >= 50 {
            println!("C");
        } else if t1 + t2 >= 30 {
            if v[2] >= 50 {
                println!("C");
            } else {
                println!("D");
            }
        } else if t1 + t2 >= 0 {
            println!("F");
        }
    }
}



Measured memory_bytes: 5024
#include <string>
#include <iostream>
using namespace std;

int main()
{
    int n = 0, k = 0, i = 0, j = 0, x = 0;
    cin >> n >> k;
    x = k - 1;
    for(i = 1; i < n; i++)
    {
        k *= x;
    }

    cout << k;




return 0;
}


Measured memory_bytes: 256
e1,e2,e3,e4=map(int,input().split())
if e1==e3 and e2==e4:
    print('yes')
elif e1==e2 and e3==e4:
    print('yes')
elif e4==e1 and e2==e3:
    print('yes')
elif e1==e2==e3==e4:
    print('yas')
else:
    print('no')


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int n,m;cin>>n>>m;
    vector<int> h(n,0);
    for(int i=0;i<n;i++) cin>>h[i];
    vector<vector<int>> gr(n);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        gr[x].pb(y);
        gr[y].pb(x);
    }
    vector<int> sc(n,0);
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<gr[i].size();j++){
            if(h[i]<=h[gr[i][j]]) sc[i]++;
        }
        if(sc[i]==0) ans++;
    }
    cout<<ans<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 9252
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a + 100*b + 50*c == X:
                count += 1
print(count)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;

int main()
{
    ll n;
    cin >> n;

    ll pay = 0;
    while(pay < n)
    {
        pay += 1000;
    }

    cout << pay - n << endl;

    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int w,h,n;
int a1,a2,b1,b2;

int main(){
	cin>>w>>h>>n;
	a2 = w;
	b2 = h;
	while(n--){
		int x,y,a;
		int Now;
		cin>>x>>y>>a;
		if(a == 1) a1 = max(a1, x);
		else if(a == 2) a2 = min(a2, x);
		else if(a == 3) b1 = max(b1, y);
		else b2 = min(b2, y);
	}	
	if(a2 <= a1 || b2 <= b1) cout<< 0 <<endl;
	else cout<<(a2-a1)*(b2-b1)<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
D,X = (int(i) for i in input().split())


count = X

A=[]
for i in range(N):
    tmp = int(input())
    A.append(tmp)

for i in range(N):
    if (A[i] == 1 or D%A[i] == 0):
        count = count + D//A[i]
    else:
        count = count + D//A[i] +1


print(count)

Measured memory_bytes: 3064
from collections import defaultdict

def prime_factors(n):
    d = defaultdict(int)
    while n%2 == 0:
        d[2] += 1
        n //= 2
    i = 3
    while i*i <= n:
        while n%i == 0:
            d[i] += 1
            n //= i
        i += 2
    if n > 2:
        d[n] += 1
    return d

N = int(input())
ans = 0
done = set()
# print(prime_factors(N))
for k,v in prime_factors(N).items():
    p = 0
    while v > 0:
        p += 1
        v -= 1
        if not pow(k, p) in done:
            ans += 1
            done.add(pow(k, p))
            p = 0
print(ans)


Measured memory_bytes: 9464
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

order = [0]*N
for i in range(N):
	 order[A[i] - 1] = i + 1

for i in order:
	print(i, end=" ")

Measured memory_bytes: 76648
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    int ma = 0;
    int cnt = 0;
    int prev = a.at(0);
    for (int i = 1; i < n; i++) {
        if (prev >= a.at(i)) {
            cnt++;
        }
        else {
            ma = max(ma, cnt);
            cnt = 0;
        }
        prev = a.at(i);
    }
    cout << max(ma, cnt) << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  vector<int> a(n); REP (i, n) cin >> a[i];
  sort(ALL(a));
  int ans = 0;
  REP (i, n / 2) {
    ans += abs(a[2 * i] + a[2 * i + 1]);
  }
  if (n % 2) ans += a.back();
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using pll = pair<long long, long long>;

int N;
long long D, A;
vector<long long> X, H;

long long solve() {
    vector<int> ids(N);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return X[i] < X[j];});

    long long res = 0;
    queue<pll> que; // place (right), dameage
    long long damage = 0;
    for (auto i : ids) {
        while (!que.empty() && que.front().first < X[i]) {
            damage -= que.front().second;
            que.pop();
        }
        H[i] -= damage;
        if (H[i] <= 0) continue;
        que.push({X[i] + D*2, H[i]});
        damage += H[i];
        res += H[i];
    }
    return res;
}

int main() {
    cin >> N >> D >> A;
    X.resize(N); H.resize(N);
    for (int i = 0; i < N; ++i) {
        cin >> X[i] >> H[i];
        H[i] = (H[i] + A-1) / A;
    }
    cout << solve() << endl;
}
    


Measured memory_bytes: 5760
#include <stdio.h>
int main() {
	char c;
	scanf("%c", &c);
	for(int i=0;i<4;i++) {
		if (c == 'A') {
			scanf("%c", &c);
			if (c == 'C') {
				printf("Yes");
				return 0;
			}
		}
		else scanf("%c", &c);
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
# frozen_string_literal: true

n = gets.to_i
b = gets.split.map(&:to_i)
a = Array.new(n) { 1000000 }

0.upto(n - 2) do |i|
  a[i] = [a[i], b[i]].min
  a[i + 1] = [a[i], b[i]].max
end

puts a.reduce(:+)


Measured memory_bytes: 1788
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> bool chmin(T& a,const T& b) {
  if(a>b) {
    a=b;
    return true;
  }
  return false;
}
template<class T> bool chmax(T& a,const T& b) {
  if(a<b){
    a=b;
    return true;
  }
  return false;
}

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const lint INF=1e18;

int n;
lint X,D;
lint w[55];
int par[55];

lint sz[55],wei[55],lim[55];
lint glim[55],dlim[55];

lint dp[55][55*55*55];
void solve(){
  debug(sz,sz+n);
  debug(wei,wei+n);
  debug(lim,lim+n);
  dump(X);

  int perm[55];
  REP(i,n) perm[i]=i;
  sort(perm,perm+n,[&](int a,int b){
      return sz[a]*wei[b]>sz[b]*wei[a];
      });

  REP(i,n){
    dlim[i]=min(50ll,lim[i]);
    glim[i]=lim[i]-dlim[i];
  }
  REP(i,55) REP(j,55*55*55) dp[i][j]=INF;
  dp[0][0]=0;

  REP(i,n) REP(j,55*55*55) if(dp[i][j]<=X){
    REP(k,dlim[i]+1) chmin(dp[i+1][j+k*sz[i]],dp[i][j]+k*wei[i]);
  }

  lint res=0;
  REP(j,55*55*55) if(dp[n][j]<=X){
    lint rest=X-dp[n][j];
    lint prof=j;
    REP(i,n){
      int p=perm[i];
      lint take=min(glim[p],rest/wei[p]);
      rest-=take*wei[p];
      prof+=take*sz[p];
    }
    chmax(res,prof);
  }
  cout<<res<<endl;
}
int main(){
  cin>>n>>X>>D;
  REP(i,n){
    cin>>w[i];
    if(i) cin>>par[i];
    --par[i];
  }
  REP(i,n) sz[i]=1,wei[i]=w[i];

  for(int i=n-1;i>0;--i){
    sz[par[i]]+=sz[i];
    wei[par[i]]+=wei[i];
  }
  REP(i,n) lim[i]=D;
  lim[0]=X;

  solve();
  return 0;
}





Measured memory_bytes: 71808
from bisect import bisect_left
I = lambda x: [-1<<50] + [int(input()) for i in range(x)] + [1<<50]

A,B,Q = map(int,input().split())
S,T = I(A),I(B)

for _ in range(Q):
    x = int(input())
    LS_ = bisect_left(S,x)
    LT_ = bisect_left(T,x)



    LS = S[LS_-1]
    RS = S[LS_]
    LT = T[LT_-1]
    RT = T[LT_]

    print(min(
        x-min(LS,LT),
        max(RS,RT)-x,
        (x-LS)*2+(RT-x),
        (x-LT)*2+(RS-x),
        (RT-x)*2+(x-LS),
        (RS-x)*2+(x-LT)
        ))


Measured memory_bytes: 12800
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	int N, C, K, ans=0;
	vector<pll> v;

	cin >> N >> C >> K;
	rep(i,N){
		int T;
		cin >> T;
		v.emplace_back(T, T+K);
	}
	sort( all(v) );

	int lc = 0, ft = -1;
	rep(i,N){
		if( v[i].first <= ft ) lc--;
		else lc = 0;
		if( lc == 0 ){
			ans++;
			lc = C;
			ft = v[i].second;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int f[100010];

int find_fa(int x)
{
    if(x != f[x])
        return find_fa(f[x]);
    return x;
}


int main()
{
    ios;
    int n, m; cin >> n >> m;
    for(int i = 1; i <= n; ++i)
        f[i] = i;
    for(int i = 1; i <= m; ++i)
    {
        int x, y; cin >> x >> y;
        f[find_fa(x)] = find_fa(y);
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i)
        if(f[i] == i)
            ans ++;
    cout << ans-1 << endl;
    return 0;
}


Measured memory_bytes: 4008
import java.util.*;
public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String S = sc.next();
    String T = sc.next();

    char s[] = S.toCharArray();
    char t[] = T.toCharArray();

    for (int i = 0 ; i < n ; i++ ) {
      System.out.print(s[i]);
      System.out.print(t[i]);
    }
  }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  
  string S;
  cin >> S;

  int A = count(S.begin(), S.end(), '0');
  int B = count(S.begin(), S.end(), '1');

  cout << min(A, B) * 2 << endl;
}

Measured memory_bytes: 512
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = [-a for a in A]
heapq.heapify(A)

for i in range(M):
    a = heapq.heappop(A)
    a = a/2
    heapq.heappush(A,a)
for i in range(N):
    A[i] = -int(A[i])
print(sum(A))

Measured memory_bytes: 95128
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++)
    cin >> a[i] >> b[i];
  int cur = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i])
      cur = 0;
    else {
      cur++;
      if (cur == 3) {
        cout << "Yes\n";
        return 0;
      }
    }
  }   
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 3648
<?php
define('MOD', 1000000007);

function mul($a, $b) {
	return (($a % MOD) * ($b % MOD)) % MOD;
}

function power($a, $b) {
	global $memo;
	if (isset($memo[$a][$b])) {
		return $memo[$a][$b];
	}
	if ($b === 0) {
		return 1;
	} else if ($b === 1) {
		return $a;
	} else if ($b % 2 === 0) {
		$bb = $b / 2;
		$ret = pow(power($a, $bb) % MOD, 2);
		return $ret % MOD;
	} else {
		$bb = ($b - 1) / 2;
		$ret = pow(power($a, $bb) % MOD, 2) % MOD;
		$ret = $ret * $a;
		$memo[$a][$b] = $ret;
		return $ret % MOD;
	}
}

function div($a, $b) {
	return mul($a, power($b, MOD - 2));
}

function nCr($n, $r) {
    $ret = 1;
    for ($i = $n; $i > $n - $r; $i--) {
        $ret = mul($ret, $i);
    }
    for ($i = $r; $i > 0; $i--) {
        $ret = div($ret, $i);
    }
    return $ret;
}

fscanf(STDIN, '%d %d %d', $n, $a, $b);
$nn = power(2, $n);
$aa = nCr($n, $a);
$bb = nCr($n, $b);
$ans = $nn - $aa - $bb - 1;
while($ans < 0) {
    $ans += MOD;
}
echo $ans;

Measured memory_bytes: 147960
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

string s,t;

int main()
{
  int mlen=0;

  cin >> s >> t;

  for (size_t i=0; i<s.size()-t.size()+1; i++) {
    int xlen;
    xlen=0;
    for (size_t j=0; j<t.size(); j++) {
      if (s[i+j] == t[j]) xlen++;
    }
    if (xlen>mlen) mlen=xlen;
  }

  cout << t.size()-mlen << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
const int MOD=1000000007;

int na,nb;
int fac[MAXN+1];

int solve() {
	fac[0]=1; FORE(i,1,MAXN) fac[i]=(ll)fac[i-1]*i%MOD;
	if(na>nb) swap(na,nb);
	if(na==nb) {
		return (ll)2*fac[na]*fac[nb]%MOD;
	}
	if(na+1==nb) {
		return (ll)fac[na]*fac[nb]%MOD;
	}
	return 0;
}

void run() {
	scanf("%d%d",&na,&nb);
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 640
s = input().split()
if s[0] == 'H' and s[1] == 'H':
    print("H")
elif s[0] == 'H' and s[1] == 'D':
    print("D")
elif s[0] == 'D' and s[1] == 'H':
    print("D")
else:
    print("H")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define all(v) (v).begin(),v.end()
#define np next_permutation
using namespace std;
using vi=vector<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,j,n) for(int i=j;i<=n;i++)
#define vii vector<vi>
#define vb vector<bool>
#define pr pair<int,int>
#define vl vector<ll>
#define eb emplace_back
#define umap unordered_map<ll,int>
const int N=(int)1e5+11;

int n,t;
string s;

void solve(){
   cin>>n;
   vl a(n);
   for(int i=0;i<n;i++)
       cin>>a[i];
   cin>>s;
   vl b;
   for(int i=n-1;i>=0;i--){
      ll v=a[i];
      for(auto x:b){
        if(v > (v^x))
           v=v^x;
      }
      if(v){
           if(s[i]=='1'){
             cout<<1<<"\n";
             return;
           }
           b.pb(v);
      }
   }
   cout<<0<<"\n";
}
int main(){ 
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cin>>t;
   while(t--) solve();
   return 0;
}


Measured memory_bytes: 3548
N = int(input())
*a, = map(int, input().split())
var = 0
cnt = [0] * 8

for i in a:
	if i < 400:
		cnt[0] = 1
	elif i < 800:
		cnt[1] = 1
	elif i < 1200:
		cnt[2] = 1
	elif i < 1600:
		cnt[3] = 1
	elif i < 2000:
		cnt[4] = 1
	elif i < 2400:
		cnt[5] = 1
	elif i < 2800:
		cnt[6] = 1
	elif i < 3200:
		cnt[7] = 1
	else:
		var += 1

print(max(cnt.count(1), 1), cnt.count(1) + var)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> L(N);
    int num = 0;
    for(int i=0; i<N; i++){
        cin >> L.at(i);
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            for(int k = 0; k < N; k++){
                if((i < j) && (j < k)){
                    if((L.at(i) != L.at(j)) && (L.at(j) != L.at(k)) && (L.at(k) != L.at(i))){
                        if((L.at(i) < L.at(j)+L.at(k))&&(L.at(j) < L.at(i)+L.at(k))&&(L.at(k) < L.at(i)+L.at(j))){
                            num++;
                        }    
                    }
                }    
            }   
        }
    }
    cout << num << endl;
}


Measured memory_bytes: 3552
import sys
sys.setrecursionlimit(10 ** 9)

N = int(input())
S = input()
rot = []
for i in S:
  if ord(i) + N  >= 91:
    a = chr(ord(i) + N - 26) 
  else:
    a =chr(ord(i) + N)
  rot.append(a)
  
print(''.join(rot))
  
  
  
  
  
  

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

s = ["A","B","C","D","E","F"]

x, y = input().split()

if x == "A":
    x = 10
elif x== "B":
    x = 11
elif x== "C":
    x = 12
elif x== "D":
    x = 13
elif x== "E":
    x = 14
else:
    x = 15

if y == "A":
    y = 10
elif y== "B":
    y = 11
elif y== "C":
    y = 12
elif y== "D":
    y = 13
elif y== "E":
    y = 14
else:
    y = 15

if x > y:
    print(">")
elif x < y:
    print("<")
else:
    print("=")



Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::vec::*;
use std::cmp::*;

fn main() {
    let n: usize = read();
    let mut s0: String = read();

    let mut s = Vec::new();

    for _ in 0..n {
        s.push(s0.pop().expect(""));
    }
    s.reverse();

    let mut lc = 0;
    let mut rc = 0;

    for i in 1..s.len() {
        if s[i] == 'E' {rc += 1;}
    }

    let mut m = rc;

    for i in 1..n {
        let mut rc1 = rc;
        let mut lc1 = lc;
        if s[i - 1] == 'W' {
            lc1 += 1;
        }
        if s[i] == 'E' {
            rc1 -= 1;
        }
        m = min(m, lc1 + rc1);
        lc = lc1;
        rc = rc1;
    }

    println!("{}", m);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, X;
  cin >> N >> X;
  int sum = 0;
  int minD = INF;
  REP(i, N) {
    int p;
    cin >> p;
    sum += p;
    chmin(minD, p);
  }
  print((X - sum) / minD + N);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

const int dx[4] = { 0, -1 };
const int dy[4] = { -1, 0 };

int main(){
    int h, w, k; cin >> h >> w >> k;
    vector<vector<int64_t>> value(h, vector<int64_t>(w, 0));
    for (auto i = 0; i < k; i++) {
        int r, c, v; cin >> r >> c >> v; r--; c--;
        value[r][c] = v;
    }
    vector<vector<vector<int64_t>>> dp(h, vector<vector<int64_t>>(w,
            vector<int64_t>(4, 0)));
    dp[0][0][1] = value[0][0];
    for (auto i = 0; i < h; i++) {
        for (auto j = 0; j < w; j++) {
            for (auto l = 0; l < 2; l++) {
                int px = i + dx[l], py = j + dy[l];
                if(px < 0 or py < 0) continue;
                for (auto m = 0; m < 4; m++) {
                    if(l == 1) {
                        // 拾わない場合
                        dp[i][j][0] = max(dp[px][py][m], dp[i][j][0]);
                        // 拾う場合
                        dp[i][j][1] = max(dp[px][py][m] + value[i][j], dp[i][j][1]);
                    } else {
                        // 拾わない場合
                        dp[i][j][m] = max(dp[px][py][m], dp[i][j][m]);
                        // 拾う場合
                        if(m != 3) dp[i][j][m + 1] = max(dp[px][py][m] + value[i][j], dp[i][j][m + 1]);
                    }
                }
            }
        }
    }

    int64_t ans = 0;
    for (auto l = 0; l < 4; l++) ans = max(ans, dp[h - 1][w - 1][l]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 706720
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
    char s[100],t[100];
    int i=0,j=0;
    scanf("%s %s",s,t);
    while(t[i] != '\0'){
        printf("%c",t[i]);
        i++;
    }
    while(s[j] != '\0'){
        printf("%c",s[j]);
        j++;
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main() {
  int n,a;
  cin >> n >> a;
  cout << (n%500<=a?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256