akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

struct treap{
    static const int INF=INT_MAX;

    struct node{
        int val,mini,cnt,pri;
        node *lch,*rch;

        node(int val,int pri):val(val),pri(pri),cnt(1),mini(val){
            lch=rch=NULL;
        }
    };

    node *root;
    treap():root(NULL){srand(time(NULL));}

    int count(node *t){return !t?0:t->cnt;}
    int mini(node *t){return !t?INF:t->mini;}

    node *update(node *t){
        if(!t)return t;
        t->cnt=count(t->lch)+count(t->rch)+1;
        t->mini=min(min(mini(t->lch),mini(t->rch)),t->val);
        return t;
    }

    node *merge(node *l,node *r){
        if(!l||!r)return l?l:r;
        if(l->pri>r->pri){
            l->rch=merge(l->rch,r);
            return update(l);
        }
        r->lch=merge(l,r->lch);
        return update(r);
    }

    pair<node *,node *>split(node *t,int k){
        if(!t)return make_pair((node *)NULL,(node *)NULL);
        if(count(t->lch)>=k){
            pair<node *,node *>s=split(t->lch,k);
            t->lch=s.second;
            return make_pair(s.first,update(t));
        }
        pair<node *,node *>s=split(t->rch,k-count(t->lch)-1);
        t->rch=s.first;
        return make_pair(update(t),s.second);
    }

    node *insert(node *t,int k,int val,int pri){
        pair<node *,node *>s=split(t,k);
        t=merge(s.first,new node(val,pri));
        t=merge(t,s.second);
        return update(t);
    }

    node *erase(node *t,int k){
        pair<node *,node *>s1,s2;
        s2=split(t,k+1);
        s1=split(s2.first,k);
        return update((t=merge(s1.first,s2.second)));
    }


    void insert(int k,int val){
        root=insert(root,k,val,rand());
    }

    void erase(int k){
        root=erase(root,k);
    }

    int rangeMinimumQuery(node *t,int l,int r){
        if(!t)return INF;
        int sz=count(t);
        if(sz<=l||r<=0)return INF;
        if(l<=0&&sz<=r)return mini(t);

        int cnt=count(t->lch);

        int vl=rangeMinimumQuery(t->lch,l,r);
        int vr=rangeMinimumQuery(t->rch,l-cnt-1,r-cnt-1);

        int res=min(vl,vr);
        if(l<=cnt&&cnt<r)res=min(res,t->val);
        return res;
    }

    int rangeMinimumQuery(int l,int r){
        return rangeMinimumQuery(root,l,r);
    }



    void updateNode(int k,int val){
        erase(k);
        insert(k,val);

    }

    void Debug(node *t){
        if(!t)return;
        Debug(t->lch);
        cout<<t->val<<" ";
        Debug(t->rch);
    }

    void Debug(){
        Debug(root);
        cout<<endl;
    }
};

int main(){

    int n,q;
    scanf("%d%d",&n,&q);

    treap latte;
    for(int i=0;i<n;i++)latte.insert(i,INT_MAX);


    while(q--){
        int type,x,y;
        scanf("%d%d%d",&type,&x,&y);
        if(type==0){
            latte.updateNode(x,y);
        }
        else{
            printf("%d\n",latte.rangeMinimumQuery(x,y+1));
        }
    }
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int sum = 0;
	int m = n;
	while (n > 0)
	{
		sum = sum + n%10;
		n = n / 10;
	}
	if (m % sum == 0)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 
ll N;
ll NN;

int main(){

    cin >> N;
    int A[N];
    int B[N];
    int C[N];

    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N-1) cin >> C[i];

    int ans=0;

    ans+=B[A[0]-1];
    for( int i = 1 ; i <N ; i++ ){
        ans+=B[A[i]-1];
        if(A[i-1] +1 == A[i]){
            ans+=C[A[i-1]-1];
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<map>
#include<queue>
#include<cmath>
#include<ctime>
#include<stack>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
inline int read(){
	int ans=0,fh=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		ans=ans*10+ch-'0',ch=getchar();
	return ans*fh;
}
const int maxn=1000000;
int n,v[maxn];
ll w[maxn],m,f[maxn];
int main(){
//	freopen(".in","r",stdin);
	scanf("%d%lld",&n,&m);
	for(int i=1;i<=100000;i++)
		f[i]=1e12;
	for(int i=1;i<=n;i++) scanf("%lld%d",&w[i],&v[i]);
	for(int i=1;i<=n;i++)
		for(int j=100000;j>=v[i];j--)
			f[j]=min(f[j],f[j-v[i]]+w[i]);
	for(int i=100000;i>=1;i--)
		if(f[i]<=m){
			printf("%d\n",i);
			return 0;
		}
	return 0;
}








Measured memory_bytes: 5120
#include <cstdio>

int main(){
  int a[10],t;
  for(int i = 0 ; i < 10 ; i++){
    scanf("%d",&a[i]);
  }
  for(int i = 0 ; i < 10 ; i++){
    for(int j = 0 ; j + 1 < 10 ; j++){
      if( a[j] < a[j+1] ){
        t = a[j];
        a[j] = a[j+1];
        a[j+1] = t;
      }
    }
  }
  for(int i = 0 ; i < 3 ; i++){
    printf("%d\n",a[i]);
  }
  
  
}

Measured memory_bytes: 2680
from collections import namedtuple
from math import ceil

Problem = namedtuple('Problem', ('count', 'bonus'))

def main():
    d, g = map(int, input().split())
    problems = []
    for _ in range(d):
        count, bonus = map(int, input().split())
        problems.append(Problem(count, bonus))
    
    print(solve(d, g, problems))

def solve(d, g, problems):
    r = float('inf')

    for i in range(2 ** d):
        k = -1
        score = 0
        count = 0
        for j in range(d):
            if (i >> j) & 0x01 != 0:
                score += 100 * (j + 1) * problems[j].count + problems[j].bonus
                count += problems[j].count
            else:
                k = j
        
        if score >= g:
            r = min(r, count)
        else:
            c = ceil((g - score) / (100 * (k + 1)))
            if c <= problems[k].count:
                r = min(r, count + c)

    return r

main()


Measured memory_bytes: 3444
N, W = map(int, raw_input().split())
X = [map(int, raw_input().split()) for _ in range(N)]

dp = {}
dp[0] = 0

for w, v in X:
    d = dp.copy()
    for k in d:
        if k + w > W:
            continue
        if k + w in dp:
            dp[k + w] = max(dp[k + w], d[k] + v)
        else:
            dp[k + w] = d[k] + v

print max(dp.values())


Measured memory_bytes: 3544
// https://atcoder.jp/contests/abc142/tasks/abc142_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, t, cnt = 0;
    cin >> n >> k;
    REP(i, n) {
        cin >> t;
        if (t >= k)
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))
li = [0]*13
for i in d:
    li[i] += 1
if li[0]>0 or li[12]>1:
    print(0)
    exit(0)
l1 = []
l2 = []
for i in range(1, 12):
    if li[i]>2:
        print(0)
        exit(0)
    if li[i]==1:
        l1.append(i)
    elif li[i]==2:
        l2.extend([i, 24-i])
if li[12]:
    l2.append(12)
ans = 0
for i in range(2**len(l1)):
    tl = l2[:]
    for j in range(len(l1)):
        if i>>j&1:
            tl.append(l1[j])
        else:
            tl.append(24-l1[j])
    tl.sort()
    tmp = 24-tl[-1]
    pre = 0
    for j in tl:
        tmp = min(tmp, j-pre)
        pre = j
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 9228
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      
      for(int i=0;i<k;i++){
        if(i%2==0){
          if(a%2==1){
          a--;
          }
          b+=a/2;
          a/=2;
        }else{
          if(b%2==1){
          b--;
          }
          a+=b/2;
          b/=2;
        }
      }
      System.out.println(a+" "+b);
    }
}

Measured memory_bytes: 38620
#include<iostream>
#include<list>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    list<int> l;
    string op;
    for(int i=0; i<n; ++i) {
        cin >> op;
        if(op == "deleteFirst") {
            l.pop_front();
        } else if(op == "deleteLast") {
            l.pop_back();
        } else {
            int x;
            cin >> x;
            if(op == "insert") {
                l.push_front(x);
            } else {
                for(auto it = l.begin(); it != l.end(); ++it) {
                    if(*it == x) {
                        l.erase(it);
                        break;
                    }
                }
            }
        }
    }
    for(auto it = l.begin(); it != l.end(); ++it) {
        if(it != l.begin()) {
            cout << ' ';
        }
        cout << *it;
    }
    cout << endl;
}



Measured memory_bytes: 34388
#include<bits/stdc++.h>  
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(int i = a; i <=b; i++)
#define rep2(i,a,b) for(int i = a; i>=b; i--)
#define PB push_back 
#define MP make_pair
#define db long double
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define cases int testcases;cin>>testcases; while(testcases--)
#define INF 2000000000
const double PI = acos(-1);
const int N = 100005;
#define eps 1e-6
#define MOD 1000000007

int p[N];
int ok[N];
int ok2[N];


  int32_t main() 
  {
    IOS


        int n,m;
        cin >> n >> m;

  

        int ans1 = 0,ans2 =0;

       
       vector<pair<int,string>> v;

       for(int i = 1; i <= m; i++)
       {
       		int x;
        	string str;
        	cin >> x >> str;
        	v.PB(MP(x,str));
        	if(str == "AC")
        	{
        		ok2[x] = true;
        	}

       }


        for(int i = 0; i <= m-1; i++)
        {
        	int x;
        	string str;
        	x = v[i].first;
        	str = v[i].second;

        	if(ok[x] or !ok2[x])
        	{
        		continue;
        	}
        	else if(str == "WA")
        	{
        		ans2++;
        	}
        	else
        	{
        		ans1++;
        		ok[x] = true;
        	}
        }

        cout << ans1 << " " << ans2;

    return 0;
      }
        

Measured memory_bytes: 8048
#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 print(x)cout<<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;

int main() {
  int n,m;
  cin >> n >> m;
  priority_queue<ll> q;
  rep(i,n){
    ll x;
    cin >> x;
    q.push(x);
  }

  rep(i,m){
    ll x = q.top();
    q.pop();
    q.push(x/2);
  }
  ll ans = 0;
  while(!q.empty()){
    ll x = q.top();
    q.pop();
    ans+=x;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4304
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm> 

using namespace std;

const int maxn = 1e5 + 10;

int fa[maxn],vis[maxn];

int n,m;

int x,y;

int ans;

int get(int x) {
	return fa[x] == x ? x : fa[x] = get(fa[x]);
}

void Union(int x,int y) {
	int xx = get(x);
	int yy = get(y);
	if(xx == yy) return;
	fa[yy] = xx;
	return ;
}

int main(void) {
	cin >> n >> m;
	for(int i = 1; i <= n; i ++) {
		fa[i] = i;
	}
	for(int i = 1; i <= m; i ++) {
		cin >> x >> y;
		if(get(x) == get(y)) continue;
		else {
			Union(x,y);
		}
	}
	for(int i = 1; i <= n; i ++) {
		if(fa[i] == i) ans++;
	}
	cout << ans - 1 << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int sum = 0;
    while (true) {
        sum += 1000;
        if (sum >= n) {
            cout << sum - n << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int MOD = (int)998244353;

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();

        Map<Character, Integer> map = new HashMap<>();

        for (int i=0; i<n; i++) {
            char tmp = sc.next().charAt(0);
            if (tmp == 'M') {
                if (map.containsKey(tmp)) {
                    map.put(tmp, map.get(tmp)+1);
                } else {
                    map.put(tmp, 1);
                }
            } else if (tmp == 'A') {
                if (map.containsKey(tmp)) {
                    map.put(tmp, map.get(tmp)+1);
                } else {
                    map.put(tmp, 1);
                }
            } else if (tmp == 'R') {
                if (map.containsKey(tmp)) {
                    map.put(tmp, map.get(tmp)+1);
                } else {
                    map.put(tmp, 1);
                }
            } else if (tmp == 'C') {
                if (map.containsKey(tmp)) {
                    map.put(tmp, map.get(tmp)+1);
                } else {
                    map.put(tmp, 1);
                }
            } else if (tmp == 'H') {
                if (map.containsKey(tmp)) {
                    map.put(tmp, map.get(tmp)+1);
                } else {
                    map.put(tmp, 1);
                }
            }

        }

//        System.out.println(map);

        List<Integer> list = new ArrayList<>();
        for (int t: map.values()) list.add(t);

//        System.out.println(list);


        long res = 0;

        for (int i=0; i<list.size()-2; i++) {
            for (int j=i+1; j<list.size()-1; j++) {
                for (int k=j+1; k<list.size(); k++) {
                    res += (long)list.get(i) * (long)list.get(j) * (long)list.get(k);
                }
            }
        }

        System.out.println(res);

    }
}



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

int n;

int f(int pos, int cnt, vector<vector<int>> &v){
  cnt += (1 << pos);
  if(cnt == (1<<n) -1) return 1;
  int ans = 0;
  for(int a:v[pos]){
    if(cnt >> a &1) continue;
    ans += f(a,cnt,v);
  }
  return ans;
}

int main(){
  int m, a, b;
  cin >> n >> m;
  vector<vector<int>> vn(n);
  for(int i=0; i<m; ++i){
    cin >> a >> b;
    --a; --b;
    vn[a].push_back(b);
    vn[b].push_back(a);
  }
  int ans = 0;
  ans += f(0,0,vn);
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

#define ll long long
#define PII pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size))           \
  scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name)
#define DEBUG(...) debug(__LINE__,__VA_ARGS__)
#define MOD 1000000007

using namespace std;

string to_string(string s) { return s; }

template <class T>
string to_string(vector<T> v) {
	string ret = "{";
	FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
	if (v.size() > 0) {
		ret += to_string(LAST(v));
	}
	ret += "}";
	return ret;
}

void debug_print() { cerr << endl; }

template <class Head, class... Tail>
void debug_print(Head head, Tail... tail) {
	cerr << to_string(head) << " ";
	debug_print(tail...);
}

template <class... T>
void debug(T... args) {
	debug_print(args...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
	cout << to_string(head) << " ";
	print(tail...);
}

int main() {
	GS(S);
	GS(T);
	GI(q);
	vector<int> accS(S.size(),0),accT(T.size(),0);
	if(S[0]=='A'){
		accS[0]++;
	}else{
		accS[0]--;
	}
	FORIN(i,1,S.size()){
		accS[i]=accS[i-1];
		if(S[i]=='A'){
			accS[i]++;
		}else{
			accS[i]--;
		}
	}
	if(T[0]=='A'){
		accT[0]++;
	}else{
		accT[0]--;
	}
	FORIN(i,1,T.size()){
		accT[i]=accT[i-1];
		if(T[i]=='A'){
			accT[i]++;
		}else{
			accT[i]--;
		}
	}
	FOR(i,q){
		GI2(a,b);
		a--;b--;
		GI2(c,d);
		c--;d--;
		int ctS=accS[b]-(a>0?accS[a-1]:0);
		int ctT=accT[d]-(c>0?accT[c-1]:0);
		if((ctS-ctT)%3==0){
			print("YES");
		}else{
			print("NO");
		}
	}
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	int n,x,y,ans[5009];
	int main(){
		n=read<int>(),x=read<int>(),y=read<int>();
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++){
				int dist=j-i;
				if(i<=x && j>=y) dist=min(dist,j-i-y+x+1);
				else if(i<=x && j<=y && j>=x) dist=min(dist,x-i+y-j+1);
				else if(i>=x && i<=y && j>=y) dist=min(dist,j-y+i-x+1);
				else if(i>=x && j<=y) dist=min(dist,i-x+y-j+1);

			//	cout<<i<<" "<<j<<" "<<dist<<endl;
				ans[dist]++;
			}
		for(int i=1;i<n;i++)
			printf("%d\n",ans[i]);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = min(a, b); i >= 1; --i){
        if(a % i == 0 && b % i == 0){
            if(--k == 0){
                cout << i << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

typedef tree<
        pair<int, int>,
        null_type,
        less<pair<int, int>>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;


const int p = 1e9 + 7;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}


mt19937 rnd(time(0));

struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};

/*
const int N = 1200000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}
*/

void solve()
{
    int n;
    cin>>n;
    vector<ll> a(n);
    for (int i = 0; i<n; i++) cin>>a[i];
    string s;
    cin>>s;

    for (int i = 0; i<n; i++) if (s[i]=='1')
    {
        vector<ll> b;
        for (int j = i+1; j<n; j++) if (s[j]=='0') b.push_back(a[j]);

        ll cur = a[i];

        vector<bool> used(b.size());
        for (int bit = 60; bit>=0; bit--)
        {
            for (int k = 0; k<b.size(); k++) if (!used[k] && b[k]&(1ll<<bit))
            {
                used[k] = true;
                for (int j = 0; j<b.size(); j++) if (!used[j] && b[j]&(1ll<<bit)) b[j]^=b[k];
                if (cur&(1ll<<bit)) cur^=b[k];
                break;
            }
            if (cur&(1ll<<bit)) {cout<<1<<endl; return;}
        }
    }
    cout<<0<<endl;

}

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

    int t;
    cin>>t;
    while(t--) solve();


}


Measured memory_bytes: 3628
a,b,c,d = map(int, input().split())

import math

#while文は使えないことがわかる。

takahashi = math.ceil(a / d) #切り上げ
aoki = math.ceil(c / b) #切り上げ

if takahashi >= aoki:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9120
#include <bits/stdc++.h>

using namespace std;

struct Graph {
    int n, m;
    vector<vector<int>> g;
    bool is_digraph;
    Graph(int _n) : n(_n), m(0) {
        assert(n >= 1);
        g.resize(n);
        set_di(false);
    }
    Graph(int _n, int _m, bool _di=false) : n(_n), m(0) {
        assert(n >= 1);
        assert(1ll*n*(n-1)/2 >= m);
        g.resize(n);
        set_di(_di);
        input(_m);
    }
    inline void add(int u, int v) {
        assert(0 <= u && u < n);
        assert(0 <= v && v < n);
        assert(u != v);
        g[u].emplace_back(v);
        if (!is_digraph)
            g[v].emplace_back(u);
        m++;
    }
    void input(int _m) {
        int u, v;
        for (int i = 0; i < _m; i++) {
            cin >> u >> v;
            u--;v--; // to 0-based
            add(u, v);
        }
    }
    void set_di(bool _di) {
        is_digraph = _di;
        sta = vector<int>(n, 0);
        outdeg =vector<int> (n,0);
        tim=1;
    }
    int tim;
    vector<int> sta;
    vector<int> outdeg;
    void dfs(int u, int p) {
        sta[u] = tim++;
        for (int v: g[u]) if(v!=p){
            if (!sta[v]) {
                dfs(v, u);
                if (outdeg[v]&1) {
                    outdeg[v]++;
                    cout << v+1 << ' ' << u+1 << "\n";
                } else {
                    outdeg[u]++;
                    cout << u+1 << ' ' << v+1 << "\n";
                }
            } else if (sta[u] > sta[v]){
                cout << u+1 << ' ' << v+1 << "\n";
                outdeg[u]++;
            }
        }
    }
    void run() {
        if (m&1) {
            cout << -1; return;
        }
        dfs(0,-1);
    }
};

void solve() {
    int n,m;
    cin >> n >> m;
    Graph g(n,m);
    g.run();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 12928
import itertools
import math

people = int(input())
data = []
truthfulness = [None]*people
i = 0

def contradiction(t,data):
    for i in range(len(t)):
        if t[i] == True:
            for q in data[i]:
                if q[1] == 0:
                    a = False
                else:
                    a = True
                if not t[q[0]-1] == a:
                    return False
    return True

for i in range(people):
    n = int(input())
    a=[]
    for j in range(n):
        a.append(list(map(int,input().split())))
    data.append(a)

num = 0
for v in itertools.product([True,False], repeat=people):
    if(v.count(True) > num):
        if contradiction(v,data):
            num = max(v.count(True),num)
print(num)



Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] h = new int[N + 1];
		int[] hs = new int[N + 1];
		int[] x = new int[N + 1];
		
		for(int i = 1; i <= N; i++) {
			h[i] = sc.nextInt();
			hs[i] = h[i];
			x[i] = 0;
		}
		
		int count = 0;
		Arrays.sort(hs);
		
		for(int j = 1; j <= hs[N]; j++) {
			for(int i = 1; i <= N; i++) {
				if(x[i] < h[i]) {
					x[i] += 1;
					if(i == N || x[i + 1] == h[i + 1]) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	static int n, a[][];

	public static int solve() {
		int ans = 0, max = 0;
		for(int i = 0; i < n; ++i) {
			ans = a[0][0];
			for(int j = 0; j < n; ++j) {
				if(j < i)ans += a[0][j + 1];
				else ans += a[1][j];
			}
			max = Math.max(max,  ans);
		}
		return max;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = new int[2][n];
		for (int i = 0; i < 2; ++i) {
			for (int j = 0; j < n; ++j)
				a[i][j] = sc.nextInt();
		}
		sc.close();
		int ans = solve();
		System.out.println(ans);
	}

}


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

ll solve() {
    ll N, M;
    cin >> N >> M;
    vector<ll> H(N);
    vector<vector<ll>> G(N);
    int a, b;
    for ( int i = 0; i < N; i++ ) {
        cin >> H[i];
    }
    for ( int i = 0; i < M; i++ ) {
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        bool ok = true;
        for( int v : G[i] ) {
            if ( H[i] <= H[v] ) {
                ok = false;
                break;
            }
        }
        if ( ok ) ans++;
    }
    
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
ll findDivisors(ll n) 
{ 
	ll div[n + 1]; 
	memset(div, 0, sizeof div); 
	for (int i = 1; i <= n; i++){
		for (int j = 1; j * i <= n; j++) 
			div[i * j]++; 
	} 
	ll t=0;
	for (int i = 1; i <= n; i++) 
	{
	    t+=i*div[i];
	}
	return t;
} 

// Driver code 
int main() 
{ 
    fast;
	ll n;cin>>n;
	ll ans=findDivisors(n); 
	cout<<ans;
	return 0; 

}

Measured memory_bytes: 81680
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define		vii 			vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
#define     test(i)        cout<<i<<endl
int dx[] = {-1 , 1 , 0 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 0 , 1 ,-1 ,-1 , 1 ,-1 , 1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
const int mxN=2e5+5,oo=0x3f3f3f3f,mod=1e9+7;
int n,w;
ll arr[mxN][2],dp[105][mxN];
ll go(int idx,int val){
    if(val<0)
        return 1e18;
    if(idx==n)
        return val==0?0:1e18;
    ll &ret=dp[idx][val];
    if(~ret)
        return ret;
    return ret=min(go(idx+1,val-arr[idx][1])+arr[idx][0],go(idx+1,val));
}
void solve(){
    cin>>n>>w;
    loop(n,i,0)
        cin>>arr[i][0]>>arr[i][1];
    mem(dp,-1);
    ll res=0;
    loop(1e5+1,i,0){
        if(go(0,i)<=w)
            res=i;
    }
    cout<<res<<endl;
}
int main() {
    fast();
    solve();
}

Measured memory_bytes: 166144
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    X, N = MII()
    p = LII()

    mn = 101
    ans = 0
    for i in range(-1, 102):
        if i not in p:
            if mn > abs(X - i):
                ans = i
                mn = abs(X - i)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9088
#include <bits/stdc++.h>

int main(){
    char a;
    std::cin >> a;
    if(a >= 'a' && a <= 'z'){
        std::cout << 'a' << std::endl;
    }else{
        std::cout << 'A' << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 3632
#include<iostream>
using namespace std;
long long dp[20][2][5];
string N;
long long rec(int k,bool tight,int cnt)
{
	if(k==N.size())
	{
		return cnt==4;
	}
	else if(~dp[k][tight][cnt])
	{
		return dp[k][tight][cnt];
	}
	int r=(tight?N[k]-'0':9);
	long long ans=0;
	if(cnt==2)
	{
		if(k+1>=N.size())return dp[k][tight][cnt]=0;
		r=tight?(N[k]-'0')*10+(N[k+1]-'0'):99;
		for(int i=0;i<=r;i++)
		{
			if(i%10==3)ans+=rec(k+2,tight&&i==r,4);
			else if(i==51)ans+=rec(k+2,tight&&i==r,2);
			else ans+=rec(k+2,tight&&i==r,i%10==5);
		}
	}
	else
	{
		for(int i=0;i<=r;i++)
		{
			if(cnt==4)
			{
				ans+=rec(k+1,tight&&r==i,4);
			}
			else if(i==5)
			{
				ans+=rec(k+1,tight&&r==i,1);
			}
			else if(cnt==1&&i==1)
			{
				ans+=rec(k+1,tight&&r==i,2);
			}
			else if(cnt==3&&i==3)
			{
				ans+=rec(k+1,tight&&r==i,4);
			}
			else
			{
				ans+=rec(k+1,tight&&r==i,0);
			}
		}
	}
	return dp[k][tight][cnt]=ans;
}
int main()
{
	cin>>N;
	for(int i=0;i<20;i++)
	{
		for(int j=0;j<2;j++)
		{
			for(int k=0;k<5;k++)
			{
				dp[i][j][k]=-1;
			}
		}
	}
	cout<<rec(0,1,0)<<endl;
	return 0;
}



Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {
	public static void main(String []args){
		//????????£????????????
		Scanner sc =  new Scanner(System.in);
		//3?¬??????????????????????
		int [][][] list= new int[4][3][10];
		//??£?¨?
		int b = 0;
		int f = 0;
		int r = 0;
		int v = 0;
		//n??¶????????±
		int n = sc.nextInt();
			for(int i = 0; i<n;i++){
			//b?£? ?????±
			b = sc.nextInt();
			//?????? ?????±
			f = sc.nextInt();
			//r??????
			r = sc.nextInt();
			//v??? ?????±
			v = sc.nextInt();
			//??????????????????????´?
			list [b -1][f-1][r-1] += v;
		}
			//????´???????????????¨???
			for(int i = 0; i <  4;i++){
				if(i != 0){
					System.out.println("####################");
				}else{
				}
				for(int j = 0; j < 3; j++){

					for(int k = 0; k < 10; k++){
						//??????????????¨???
						if(k == 9){
							System.out.println(" " + list[i][j][k]);
						}else{
							System.out.print(" " + list[i][j][k]);
						}
					}
				}
			}
	}
}

Measured memory_bytes: 29556
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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 (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    string s;cin >> s;
    if(s=="ARC")cout << "ABC" <<endl;
    else cout << "ARC" <<endl;

    return 0;
}





Measured memory_bytes: 3608
#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++)

int main(){
    ll n;
    string s;
    cin >> n >> s;
    rep(i, 0, s.size()){
        s[i] = 'A' + (s[i] - 'A' + n) % 26;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int f[200][10];
int p[200][20];

signed main(){
	int n;scanf("%d",&n);
	rep(i,n)rep(j,10)scanf("%d",&f[i][j]);
	rep(i,n)rep(j,11)scanf("%d",&p[i][j]);
	int Max=INT_MIN;
	rep(i,1<<10){
		if(i==0)continue;
		int ans=0;
		rep(j,n){
			int cnt=0;
			rep(k,10){
				if((i>>k&1)&&f[j][k]==1)cnt++;
			}
			ans+=p[j][cnt];
		}
		Max=max(Max,ans);
	}
	cout<<Max<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pii >
#define all(x) x.begin(), x.end()
#define M vector<VI >

using namespace std;

int gcd(int a, int b){
	if(!b) return a;
	return gcd(b, a%b);
}

int main(){

	int x, ek = 360;
	cin >> x;

	cout << ek/gcd(x, ek) << '\n';

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <x86intrin.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4,sse4.1,sse4.2,tune=native")

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	VL a(n);
	rep(i, n) cin >>a[i];
	map<ll, int> mp;
	rep(i, m){
		int b,c; cin >>b >>c;
		mp[-c] += b;
	}
	sort(all(a));
	int z=0;
	for(auto x: mp){
		int c= x.first * (-1);
		while(x.second > 0 && c > a[z] && z<n){
			a[z] = c;
			x.second--; z++;
		}
		if(a[z] >=c) break;
	}
	
	cout << accumulate(all(a), 0LL) <<"\n";
	return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<vector>
#include<algorithm>
int main(void) {
	int n, q;
	std::cin >> n;
	if (n == 0) { std::cout << 0 << std::endl; return 0; }
	std::vector<long>S(n);
	for (int i = 0; i < n; ++i) {
		std::cin >> S[i];
	}
	std::sort(S.begin(), S.end());
	std::cin >> q;
	if (q == 0) { std::cout << 0 << std::endl; return 0; }
	std::vector<long>T(q);
	for (int i = 0; i < q; ++i) {
		std::cin >> T[i];
	}
	std::sort(T.begin(), T.end());
	int cnt = 0;
	for (int i = 0; i < q; ++i) {
		std::vector<long>::iterator itr= std::find(S.begin(),S.end(), T[i]);
		if (std::binary_search(itr, S.end(), T[i]))
		{
			cnt++;
			itr++;
		}
	}
	std::cout << cnt << std::endl;
	//	system("pause");
	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> height(n);
  for (int i = 0; i < n; i++)
  {
    cin >> height[i];
  }
  vector<ll> dp(n + 1);
  dp[1] = 0;
  for (int i = 2; i <= n; i++)
  {
    dp[i] = 0x3f3f3f3f;
    for (int j = max(1, i - k); j < i; j++)
    {
      dp[i] = min(dp[j] + abs(height[j - 1] - height[i - 1]), dp[i]);
    }
  }

  cout << dp[n] << endl;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main (){
	int n, k, diferencaDobro, total=1;
	scanf("%d", &n);
	scanf("%d", &k);

	for(int i=0; i<n; i++){
		diferencaDobro = (total *2) - total;
		if (diferencaDobro < k){
			total *= 2;
		} else {
			total += k;
		}
	}
	printf ("%d\n", total);

	return 0;
}


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

int main(){
    double A, B; cin >> A >> B;

    for(int i = 1; i < 1251; ++i) {
        int eight = i * 0.08;
        int ten = i * 0.1;

        if(eight == A && ten == B) {
            cout << i << endl;
            break;
        }

        if(i == 1250) {
            cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Point struct {
	X, Y int
}

func dis (a, b Point) float64 {
	return math.Sqrt(float64((a.X - b.X)*(a.X - b.X) + (a.Y - b.Y)*(a.Y - b.Y)))
}

func perm(a []Point, f func([]Point), i int) {
	if i > len(a) {
		f(a)
		return
	}
	perm(a, f, i+1)
	for j := i + 1; j < len(a); j++ {
		a[i], a[j] = a[j], a[i]
		perm(a, f, i+1)
		a[i], a[j] = a[j], a[i]
	}
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	points := make([]Point, n)
	for i := 0; i < n; i++ {
		points[i] = Point{nextInt(), nextInt()}
	}

	sum := 0.0
	count := 0.0
	perm(points, func(x []Point) {
		for i := 0; i < n-1; i++ {
			sum += dis(x[i], x[i+1])
		}
		count++
	}, 0)

	fmt.Println(sum/count)
}

Measured memory_bytes: 640
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = (int)Console.ReadLine()[0];
            var height = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var max = 0;
            var count = 0;
            var mid = height.Length / 2;
            for (int i = 0; i + 1 < height.Length; i++)
            {
                if (height[i] >= height[i + 1])
                {
                    count++;
                }
                else
                {
                    if (count > max)
                    {
                        max = count;
                    }
                    if (max > mid)
                    {
                        break;
                    }
                    count = 0;
                }
            }
            Console.WriteLine(max > count ? max : count);
        }
    }
}


Measured memory_bytes: 28252
import java.util.Scanner;

   class Main{
      public static void main(String args[]){
       Scanner scan = new Scanner(System.in);

       String w = scan.next();
       int num =0;
 
       while(scan.hasNext()){

          String t1 = scan.next();

             if(t1.equals("END_OF_TEXT")){

             break;

             }

          String t2 = t1.toLowerCase();

             if(t2.equals(w)){

                num++;

             }

       }

       System.out.println(num);

       }
   }


Measured memory_bytes: 26264
H, W = map(int, input().split())
C = [[0 for i in range(W)] for j in range(H)]
for i in range(H):
    C[i] = list(input().split())
CC = [[0 for i in range(W)] for j in range(2 * H)]
for i in range(H):
    CC[2 * i] = C[i]
    CC[2 * i + 1] = C[i]

for i in range(2 * H):
    print(''.join(CC[i]))

    


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

int bubbleSort(int A[], int N) {
  int sw = 0;
  int flag = 1;
  while(flag) {
    flag = 0;
    for ( int j = N - 1; 0 < j; j--) {
      if (A[j] < A[j-1]) {
        swap(A[j-1], A[j]);
        sw++; 
        flag = 1;
      }
    }
  }
  return sw;
}

int main() {
  int A[100], N, sw;
  cin >> N;
  for  ( int i = 0; i < N; i++ ) cin >> A[i];

  sw = bubbleSort(A, N);

  for ( int i = 0; i < N; i++ ) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}


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

int main() {
    int YM_flag = 0, MY_flag = 0;
    int a, b;
    string s;

    cin >> s;

    a = atoi(&s[0]) / 100;
    b = atoi(&s[2]);

    if (0 < b && b < 13) {
        YM_flag = 1;
    } 

    if (0 < a && a < 13) {
        MY_flag = 1;
    }

    if (YM_flag == 1 && MY_flag == 1) {
        cout << "AMBIGUOUS" << endl;
    } else if (YM_flag == 1) {
        cout << "YYMM" << endl;
    } else if (MY_flag == 1) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }
    
    return 0;
}

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

int main(){
  int n,k;
  cin >>n >>k;
  int sum = 0;
  rep(i,n){
    int a;
    cin >>a;
    int dista = a*2;
    int distb = (k-a)*2;
    sum += min(dista,distb);
  }
  cout << sum << endl;
  return 0;
}

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

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
Vi accum(Vi v){Vi ret((v).size());ret[0]=v[0];REP(i,1,(v).size()) ret[i]=ret[i-1]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}
signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
    int n,k;
    cin>>n>>k;
    Vi a(n);
    REP(i,0,n) cin>>a[i];

    Vi dp(k+1,-1);
    dp[0]=0;
    REP(i,1,k+1){
        int win=0;
        REP(j,0,n){
            if(i-a[j]<0) continue;
            if(dp[i-a[j]]==0) win=1;
        }
        dp[i]=win;
    }
    if(dp[k]==1) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

namespace ABC143_B
{
    class Program
    {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split();
            var list = new List<int>();
            for(int i = 0; i < n; i++) {
                list.Add(int.Parse(input[i]));
            }

            int ans = 0;
            for (int index = 0; index < n - 1; index++) {
                for(int j = index + 1; j < n; j++) {
                    ans += list[index] * list[j];
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
Imports System

Module Program
    Sub Main(args As String())

        Dim RGB() As Integer = Console.ReadLine().Split(" ").Select(Function(x) Integer.Parse(x)).ToArray()
        Dim K As String = Console.ReadLine()

        Dim ans As String = "No"
        For i As Integer = 1 To K
            If RGB(0) < RGB(1) AndAlso RGB(1) < RGB(2) Then
                Exit For
            End If
            If RGB(1) >= RGB(2) Then
                RGB(2) *= 2
            Else
                If RGB(0) >= RGB(1) Then
                    RGB(1) *= 2
                End If
            End If
        Next
        If RGB(0) < RGB(1) AndAlso RGB(1) < RGB(2) Then
            ans = "Yes"
        End If

        Console.WriteLine(ans)

    End Sub
End Module


Measured memory_bytes: 29204
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

typedef long long ll;

vector<pair<ll, ll> > v;

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

  if(n == 1){
    cout << p << endl;
    return 0;
  }

  if(n >= 40){
    cout << 1 << endl;
    return 0;
  }

  ll ans = 1;
  for(ll i = 2;;){
    ll po = pow(i, n);
    if(po > p){
      break;  
    }else if(p % po == 0){
      p /= po;
      ans *= i;
    }else{
      i++;
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    string S;
    cin >> S;
    if(S=="ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3572