akhauriyash/Code-Regression huggingface dataset:
s=input()
a1=0
a2=0
for i,v in enumerate(s):
    if i%2==0:
        if v=="1":
            a1+=1
        else:
            a2+=1
    else:
        if v=="1":
            a2+=1
        else:
            a1+=1
print(min(a1,a2))

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#define MAXNUM 2000001
using namespace std;
int A[MAXNUM];
int n;

int parent(int i){
    return i/2;
}
int left(int i){
    return i*2;
}
int right(int i){
    return i*2+1;
}

void maxHeapify(int A[],int i){
    int l=left(i),r=right(i);
    int k=0;
    if(l<=n && A[l]>A[i]){
        k=l;
    }else k=i;
    if(r<=n && A[r]>A[k])
        k=r;
    if(k!=i){
        int temp=A[k];
        A[k]=A[i];
        A[i]=temp;
        maxHeapify(A,k);
    }
}

void insertToHeap(int A[],int num){
    A[++n]=num;
    int father=parent(n);
    int loc=n;
    while(loc>1){
        father=parent(loc);
        if(A[father]<A[loc]){
            int temp=A[father];
            A[father]=A[loc];
            A[loc]=temp;

            loc=father;
        }else break;
    }
}

int getTop(int A[]){
    if(n<1) return -1;
    int ans=A[1];
    A[1]=A[n--];
    maxHeapify(A,1);

    return ans;
}

void buildMaxHeap(int A[],int n){
    for(int i=n/2;i>0;i--){
        maxHeapify(A,i);
    }
}
int main(){
    n=0;
    string s;
    int k;
    do{
        cin>>s;
        if(s=="extract"){
            cout<<getTop(A)<<endl;
        }else if(s=="insert"){
            cin>>k;
            insertToHeap(A,k);
        }
    }while(s!="end");
    return 0;
}



Measured memory_bytes: 7084
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s, sa, sb;
	cin >> s;
	int n = s.length(), m = n / 2, i, j, k, ans;

	for (i = m - 1; i >= 1; i--) {
		sa = s.substr(0, i);
		sb = s.substr(i, i);
		if (sa == sb) {
			ans = i * 2;
			break;
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
      while (true) {
          
            String line = sc.next();
            if(line.equals("-")) {
                break;
            };
            int n = line.length();
            char[] str = new char[n];
            for(int i=0;i<n;i++){
                str[i] = line.charAt(i);

            }
        int m=sc.nextInt();
       for(int i=0;i<m;i++){
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       }
       for(int k=0;k<n;k++){
        System.out.print(str[k]);

    }
    System.out.println("");



      }


    }
}


Measured memory_bytes: 26144
import sys
import bisect

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
B = LI()
C = LI()

A.sort()
B.sort()
C.sort()
ans = 0

for b in B:
    ok_a = bisect.bisect_left(A,b)
    ok_c = bisect.bisect_right(C,b)
    ans += ok_a*(N-ok_c)
print(ans)

Measured memory_bytes: 29376
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
//ll const INF=1001001001;
//ll const INF=1001001001001001001;
ll const MOD=2019;

ll mpow(ll x,ll n){
    if(n==0) return 1;
    else if(n%2) return x*mpow(x,n-1)%MOD;
    return mpow(x*x%MOD,n/2)%MOD;
}

string S;
ll N;
ll val[200000];
ll sum[200001];
ll cnt[2020];

int main(){
    cin>>S;
    N=S.size();

    ll ten=1;
    for(int i=N-1;i>=0;i--){
        val[i]=(S[i]-'0')*ten%MOD;
        ten*=10;
        ten%=MOD;
        //cout<<i<<' '<<val[i]<<endl;
    }//cout<<endl;
    for(int i=N-1;i>=0;i--){
        sum[i]=sum[i+1]+val[i];
        sum[i]%=MOD;
        //cout<<i<<' '<<sum[i]<<endl;
    }//cout<<endl;
    rep(i,N){
        cnt[sum[i]%MOD]++;
    }

    ll ans=cnt[0];
    rep(i,MOD+1){
        ans+=cnt[i]*(cnt[i]-1)/2;
        //if(cnt[i]>0) cout<<i<<' '<<cnt[i]<<endl;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 6840
#include<iostream>
using namespace std;
int main()
{
  int a,i,f=0,j;
  cin>>a;
  for(i=1; i<10; i++)
  {
    for(j=1; j<=9; j++)
    {
      if(i*j==a)
      {
        f=1;
        break;
      }
    }
  }
  if(f==1)
    cout<<"Yes";
  else
    cout<<"No";

}


Measured memory_bytes: 3604
#include<stdio.h>
//aは降順、bは昇順
int c[100002][2];
void merge(int i,int j,int s[][2]){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d][0]=s[b][0];
        c[d][1]=s[b][1];
        b++;
      }
      else if(j<b){
        c[d][0]=s[a][0];
        c[d][1]=s[a][1];
        a++;
      }
      else if(s[a][1]<s[b][1] || (s[a][1]==s[b][1] && s[a][0]>s[b][0])){
        c[d][0]=s[a][0];
        c[d][1]=s[a][1];
        a++;
      }
      else{
        c[d][0]=s[b][0];
        c[d][1]=s[b][1];
        b++;
      }
    }
    for(d=i;d<=j;d++){
      s[d][0]=c[d][0];
      s[d][1]=c[d][1];
    }
  }
}

int main(){
  int n,m,i,count=0,sum=0,mass;
  scanf("%d%d",&n,&m);
  int a[m+1][2];
  for(i=0;i<m;i++)
    scanf("%d%d",&a[i][0],&a[i][1]);
  merge(0,m-1,a);
  for(i=0;i<m;i++){
    if(i==0){
      mass=a[i][1];
      sum++;
    }
    else if(a[i][1]!=a[i-1][1] && a[i][0]>=mass){
      mass=a[i][1];
      sum++;
    }
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
int N,M;
int a[100001];
const ll mod=1e9+7;

ll mod_pow(ll x ,ll n ,ll mod){
  ll res=1;
  while(n>0){
    if(n&1)res=res*x%mod;
    x=x*x%mod;
    n >>= 1;
  }
  return res;
}
int main(){
  cin >> N >> M;
  ll ans=1;
  if(N<M){
    int temp=N;
    N=M;
    M=temp;
  }
  if(N==M){
   
    for(int i=1;i<=N;i++){
      ans=(ans*i)%mod;
    }
    for(int i=1;i<=M;i++){
      ans=(ans*i)%mod;
    }
    ans*=2;
    cout << ans%mod << endl;
  }
  else if(N-M==1){
     for(int i=1;i<=N;i++){
      ans=(ans*i)%mod;
    }
    for(int i=1;i<=M;i++){
      ans=(ans*i)%mod;
    }
     cout << ans%mod << endl;
  }
  else{
    cout << "0" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
suma = sum(a)
sunuke = 0
arai = suma
for i in range(N-1):
    sunuke += a[i]
    arai -= a[i]
    sub = abs(sunuke - arai)
    if i == 0:
        ans = sub
    else:
        ans = min(ans,sub)
print(ans)


Measured memory_bytes: 30536
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
int v[105][105];
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    //fin;
    cls(v, - 1);
    int n;
    int x, h, w;
    cin >> h >> w >> n;
    vector<int> aux(n);
    fore(k, 0, n){
        cin >> aux[k];
    }
    int pos = 0;
    int val = 1;
        for(int i = 0; i < h; i++){
            if(!(i & 1))
                for(int j = 0; j < w; j++){
                    if(aux[pos]){
                        v[i][j] = val;
                        aux[pos]--;
                    }
                    if(aux[pos] == 0){
                        val++;
                        pos++;
                    }
                }
            else
                for(int j = w - 1; j >= 0; j--){
                    if(aux[pos]){
                        v[i][j] = val;
                        aux[pos]--;
                    }
                    if(aux[pos] == 0){
                        val++;
                        pos++;
                    }
                }
        }
    fore(i, 0, h){
        fore(j, 0, w)
            cout << v[i][j] << ' ';
        cout << '\n';   
    }

    return 0;
}   

Measured memory_bytes: 384
#include<cstdio>
#define re register
#define int long long
using namespace std;
int n,a,b,c,d;
inline int gcd(re int x,re int y){
	return x%y?gcd(y,x%y):y;
}
signed main(){
	scanf("%lld%lld",&a,&b);
printf("%lld",a*b/gcd(a,b));
}


Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include<random>
#include<iostream>
using namespace std;


int main() {
	string S;
	string d[7] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };

	cin >> S;
	for (int i = 0; i < 7; i++) {
		if (S == d[i]) {
			cout << 7 - i << "\n";
		}
	}

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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 ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  double t, x;
  cin >> t >> x;
  cout << t / x << endl;

  return 0;
}


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

int main(void) {
  int a, b;
  cin >> a >> b;
  if (abs(a - b) % 2 == 0) {
    cout << abs(a + b) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int A=sc.nextInt();
		int B=sc.nextInt();
		if(A<=5) {
			System.out.println(0);
		}else if(A>=13) {
			System.out.println(B);
		}else {
			System.out.println(B/2);
		}
		pw.close();
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 21204
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in a:
    while i % 2 == 0:
        cnt += 1
        i = i//2
print(cnt)
"""cnt = 0
for i in a:
    while i % 2 == 0:
        i = i // 2
        cnt += 1
print(cnt)"""

Measured memory_bytes: 40688
/// [Amberjack] CUT BEGIN
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define __GET_REP_MACRO(_1,_2,_3,NAME,...) NAME
#define __REP0(i,n) for(_loop_int i=0;i<(n);++i)
#define __REP1(i,a,b) for(_loop_int i=(a);i<(b);++i)
#define __REPR0(i,n) for(_loop_int i=(n)-1;i>=0;--i)
#define __REPR1(i,a,b) for(_loop_int i=(b)-1;i>=(a);--i)
#define REP(...) __GET_REP_MACRO(__VA_ARGS__,__REP1,__REP0)(__VA_ARGS__)
#define REPR(...) __GET_REP_MACRO(__VA_ARGS__,__REPR1,__REPR0)(__VA_ARGS__)

#ifdef BURI
#define __DEBUG0() "Hello"
#define __DEBUG1(x) #x"("<<(x)<<")"
#define __DEBUG2(x,...) #x"("<<(x)<<"), " __DEBUG1(__VA_ARGS__)
#define __DEBUG3(x,...) #x"("<<(x)<<"), " __DEBUG2(__VA_ARGS__)
#define __DEBUG4(x,...) #x"("<<(x)<<"), " __DEBUG3(__VA_ARGS__)
#define __DEBUG5(x,...) #x"("<<(x)<<"), " __DEBUG4(__VA_ARGS__)
#define __GET_DEBUG_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define __DEBUG(...) __GET_DEBUG_MACRO(__VA_ARGS__,__DEBUG5,__DEBUG4,__DEBUG3,__DEBUG2,__DEBUG1,__DEBUG0)(__VA_ARGS__)
#define DEBUG(...) cerr<<__DEBUG(__VA_ARGS__)<<endl
#else
#define DEBUG(...)
#endif

#define gc getchar_unlocked
inline void getll(ll &x){
  int sgn=1;x=0;
  char c=gc();
  while(c!='-'&&(c<'0'||c>'9'))c=gc();
  if(c=='-') sgn=-1; else x=c-'0';
  c=gc();
  while('0'<=c&&c<='9'){
    x*=10;
    x+=c-'0';
    c=gc();
  }
  x*=sgn;
}
inline void read(ll &x){getll(x);}
inline void read(int &x){ll y;getll(y);x=y;}
inline void read(float &x){scanf("%f",&x);}
inline void read(double &x){scanf("%lf",&x);}
inline void read(long double &x){scanf("%Lf",&x);}
inline void read(char *s){scanf("%s",s);}
inline void read(string &s){int len=s.size();char *buf=(char*)malloc(len*sizeof(char));scanf("%s",buf);s=string(buf);free(buf);}
inline void read(char &c){char *buf=(char*)malloc(5*sizeof(char));scanf("%s",buf);c=buf[0];free(buf);}
inline void read(){}
template<typename S,typename ...T>
inline void read(S& first, T&... rest){
  read(first);
  read(rest...);
}
/// [/Amberjack] CUT END

int w,h;
ll p[125252],q[125252];
int main(){
  read(w,h);
  REP(i,w)read(p[i]);
  REP(i,h)read(q[i]);
  sort(p,p+w);
  sort(q,q+h);
  int j=0,k=0;
  ll ans=0;
  REP(i,w+h){
    if((j<w&&k<h&&p[j]<q[k]) || k==h){
      ans += (ll)(h+1-k)*p[j++];
    }else{
      ans += (ll)(w+1-j)*q[k++];
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
    /*int c; cin >> c;
    if (30 <= c) cout << "Yes" << endl;
    else cout << "No" << endl;
    */

    ll n, d; cin >> n >> d;
    d *= d;
    int ans = 0;
    rep(i, n) {
        ll x, y; cin >> x >> y;
        ll dd = x * x + y * y;
        if (dd <= d) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

vector<int> cont(const vector<Pii>& r,const vector<Pii>& l){
	vector<int> ret((int)r.size());
	int r_i = 0, l_i = 0;
	while(r_i < (int)r.size()){
		while(l_i < (int)l.size() &&
			(r[r_i].first >= l[l_i].first || r[r_i].second >= l[l_i].second)){
				l_i++;
		}
		ret[r_i] = l_i;
		r_i++;
	}
	return ret;
}

int memo[1000][2];

vector<int> v[2];
int func(int val,int a){
	if(memo[val][a] != -1) return memo[val][a];
	if(val == sz(v[a])) return memo[val][a] = 0;
	return memo[val][a] = max(func(val+1,a),func(v[a][val],a^1)) + 1;
}

int main(){
	int n,m;
	while(cin>>n,n){
		memset(memo,-1,sizeof(memo));
		vector<Pii> a(n);
		FOR(i,n) cin>>a[i].first>>a[i].second;
		cin>>m;
		vector<Pii> b(m);
		FOR(i,m) cin>>b[i].first>>b[i].second;
		v[0] = cont(a,b), v[1] = cont(b,a);
		int ans = max(func(0,0),func(0,1));

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void main()
{
    char s[25];

    scanf("%s", s);

    int i = rand() % (strlen(s) - 2);

    printf("%c%c%c", s[i], s[i + 1], s[i + 2]);
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
 
const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;
 
char s[N];
int n;
int main()
{
	scanf("%s", s);
	n = strlen(s);
	for(int i = 0; i < n; i += 2){
		if(s[i] == 'h' && s[i + 1] == 'i')
			continue;
		printf("No");
		return 0;
	}
	printf("Yes");
}



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

import sys
from copy import deepcopy

sys.setrecursionlimit(10 ** 9)
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()))
INF=float('inf')

# ワーシャルフロイド(頂点数, 隣接行列(0-indexed))
def warshall_floyd(N: int, graph: list) -> list:
    res = deepcopy(graph)
    for i in range(N):
        # 始点 = 終点、は予め距離0にしておく
        res[i][i] = 0
    # 全頂点の最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                res[i][j] = min(res[i][j], res[i][k] + res[k][j])
    # 負の閉路(いくらでもコストを減らせてしまう場所)がないかチェックする
    for i in range(N):
        if res[i][i] < 0:
            return []
    return res

N,M=MAP()
G=[[INF]*N for i in range(N)]
for i in range(M):
    s,t,d=MAP()
    G[s][t]=d

ans=warshall_floyd(N, G)

if not len(ans):
    print('NEGATIVE CYCLE')
    exit()
for i in range(N):
    for j in range(N):
        if ans[i][j]==INF:
            ans[i][j]='INF'
for i in range(N):
    print(*ans[i])



Measured memory_bytes: 7244
package main

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

func main() {
	a := getString()
	b := getString()

	switch {
	case len(a) > len(b):
		fmt.Println("GREATER")
	case len(a) < len(b):
		fmt.Println("LESS")
	default:
		for i := 0; i < len(a); i++ {
			if a[i] > b[i] {
				fmt.Println("GREATER")
				return
			} else if a[i] < b[i] {
				fmt.Println("LESS")
				return
			}
		}
		fmt.Println("EQUAL")
	}
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
	long long N, K;
	cin >> N >> K;
	long long tmp = N % K;
	if (tmp==0) tmp = K;
	long long ans;
	if (tmp > K) ans = tmp - K;
	else ans = K - tmp;
	
	ans = min(ans, N);

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N, K;


//---------- 1000000007 ----------
const int MOD = 1000000007;
int m_add(int a, int b)
{
	return (a + b) % MOD;
}
int m_sub(int a, int b)
{
	return (a + MOD - b) % MOD;
}
int m_mul(int a, int b)
{
	return (a * b) % MOD;
}
int m_pow(int x, int n)
{
	if (n == 0) return 1;
	ll res = m_pow((x * x) % MOD, n / 2);
	if (n & 1) res = (res * x) % MOD;
	return res;
}
int m_divide(int a, int b)
{
	return m_mul(a, m_pow(b, MOD - 2));
}

int m_comb(int n, int r)
{
	int i;
	int p = 1;
	for (i = 1; i <= r; i++)
	{
		p = m_mul(p, (n - i + 1));
		p = m_divide(p, i);
	}
	return p;
}

int m_comb_with_rep(int n, int r)
{
	return m_comb(n + r - 1, r);
}


int calc(int a)
{
	int b = K;
	int r = N - K;

	int bb = b - a;
	int rr = r - (a - 1);

	if (bb < 0 || rr < 0)
	{
		return 0;
	}

	int ba = a;
	int ra = a + 1;

	int bc = m_comb_with_rep(ba, bb);
	int rc = m_comb_with_rep(ra, rr);

	return m_mul(bc, rc);
}

signed main()
{
	cin >> N >> K;

	int ans = 0;
	for (int i = 1; i <= K; i++)
	{
		int c = calc(i);
		cout << c << endl;
	}
}




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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    vector<int> prime;
    prime.push_back(2);
    for (long long int i = 3; i < 999999; i++)
    {
        double temp = sqrt(i);
        for (int j = 0;; j++)
        {
            if (temp < prime[j])
            {
                prime.push_back(i);
                break;
            }
            if (i % prime[j] == 0)
            {
                break; //this is not prime
            }
        }
    }
    int n;
    int i;
    while (cin >> n)
    {
        for (i = 0; i<prime.size()&&prime[i] <= n; i++);
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 3208
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
    int i,n;
    cin>>n;
    int x[n],y[n];
    for(i=0;i<n;i++)cin>>x[i]; 
    for(i=0;i<n;i++)cin>>y[i];
    double manhattan=0,euclidean2=0,euclidean3=0,chebyshev=0;
    for(i=0;i<n;i++){
        manhattan+=abs(x[i]-y[i]);
        if(chebyshev<abs(x[i]-y[i]))chebyshev=abs(x[i]-y[i]);
    }
    for(i=0;i<n;i++)euclidean2+=pow(abs(x[i]-y[i]),2);
    for(i=0;i<n;i++)euclidean3+=pow(abs(x[i]-y[i]),3);
    printf("%.5f\n%.5f\n%.5f\n%.5f\n",manhattan,sqrt(euclidean2),cbrt(euclidean3),chebyshev);
    return 0;
}


Measured memory_bytes: 3320
n=int(input())
a=list(map(int, input().split()))
c1, c2 = 0, 0
s = 0
for i in range(len(a)):
    S = s+a[i]
    if i%2 == 0:
        if S > 0:
            s = S
        else:
            c1 += abs(S)+1
            s = 1
    else:
        if S < 0:
            s = S
        else:
            c1 += abs(S)+1
            s = -1
s=0
for i in range(len(a)):
    S = s+a[i]
    if i%2 != 0:
        if S > 0:
            s = S
        else:
            c2 += abs(S)+1
            s = 1
    else:
        if S < 0:
            s = S
        else:
            c2 += abs(S)+1
            s = -1
print(min(c1, c2))

Measured memory_bytes: 14468
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}

int main() {

	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	ll ans = 0;

	// 最小で何円で変えるか

	priority_queue<int> pq;
	rep(i, n) {
		pq.push(a[i]);
	}

	rep(i, m) {
		ll ma = pq.top();
		pq.pop();
		ma /= 2;
		pq.push(ma);
	}

	while (!pq.empty()) {
		ans += pq.top();
		pq.pop();
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1660
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>

int A, B, K;
vector<int> list;
int minimum;

int main(){
    cin >> A >> B >> K;
    minimum = min(A, B);
    for (int i = minimum ; i >= 1; i--){
        if ((A % i == 0) && (B % i == 0)){
            list.push_back(i);
        }
    }
    cout << list[K - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
typedef pair<int,int> P;
#define INF 1e9
#define rep(i,N) for(int i=0;i<N;i++)

const ll MAX = 1000001;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    COMinit();
    ll x,y;
    cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    ll m = -(x-2*y)/3;
    ll n = -(y-2*x)/3;
    //cout<<"n:"<<n<<" m:"<<m<<endl;
    cout<<COM(n+m,n)<<endl;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	cout<<read()/3<<endl;
	return 0;
}



Measured memory_bytes: 256
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    a = input()
    dic = {}
    for s in a:
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    
    ans = 0
    n = len(a)
    for v in dic.values():
        ans += v * (n - v)
    ans = ans//2 + 1
    print(ans)
if __name__ =='__main__':
    main()  

Measured memory_bytes: 3500
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define UPADHYAY int t;cin>>t;while(t--)
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    string s;
    cin>>s;
    ll k=0,i,j;
    for(i=0;i<s.length();i++){
        j=s[i]-'0';
        k+=j;
    }
    if(k%9==0)cout<<"Yes"<<"\n";
    else
    cout<<"No";
}

Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	int x;
	cin >> x;
	if (x == 0)
		cout << 1 << endl;
	else
		cout << 0 << endl;
	return 0;
}

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

class Program {
  static void Main() {
    Console.ReadLine();
    var s = Console.ReadLine();
    int a = 0;
    for (int i = 1; i < s.Length; i++) {
      a = Math.Max(a, s.Substring(0, i).Intersect(s.Substring(i)).Count());
    }
    Console.WriteLine(a);
  }
}

Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var a = Console.ReadLine();
        if (IsUpperString(a)) 
        {
            Console.WriteLine("A");
        }
        else
        {
            Console.WriteLine("a");
        }
    }

    static public bool IsUpperString(string s)
    {
        // 指定した文字列が大文字かどうかを判定します。
        if (string.IsNullOrEmpty(s)) { return false; }

        foreach (char c in s)
        {
            if (!Char.IsUpper(c))
            {
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 25832
import sys

input = sys.stdin.readline
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 == 0:
            a = int(a/2)
        else:
            a = int((a-1)/2)
        b += a
    else:
        if b%2 == 0:
            b = int(b/2)
        else:
            b = int((b-1)/2)
        a += b
print(a, b)


Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    }

    let mut count = 0;
    loop {
        let mut ok = true;
        for a in a.iter_mut() {
            if *a % 2 == 0 {
                *a /= 2;
            } else {
                ok = false;
                break;
            }
        }
        if !ok {
            break;
        }
        count += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 2172
#include <iostream>
using namespace std;
int main(){
    int h,w;
    while(1){
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0;j < w; j++){
        cout << '#';
        }
        cout << "\n";
}
      if(h==0 && w==0) break;
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iso646.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;
ll s = 0;
vll a, b, c, d;
ll N, M, Q;

void dfs(vll &A, ll m) {
    if(A.size() == N) {
        ll i;
        ll s_tmp = 0;
        for(i = 0; i < Q; i++) {
            if(A[b[i] - 1] - A[a[i] - 1] == c[i]) {
                s_tmp += d[i];
            }
        }
        s = max(s, s_tmp);
        return;
    } else {
        for(ll i = m; i <= M; i++) {
            A.push_back(i);
            dfs(A, i);
            A.pop_back();
        }
    }
    return;
}

int main() {
    cin >> N >> M >> Q;

    ll i;
    ll ans = 0;
    for(i = 0; i < Q; i++) {
        ll ai, bi, ci, di;
        cin >> ai >> bi >> ci >> di;
        a.push_back(ai);
        b.push_back(bi);
        c.push_back(ci);
        d.push_back(di);
    }
    vll A;
    dfs(A, 1);
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
const long long mod=1e9+7;
#define ll long long
using namespace std;
int lim=0;

/*ll power(ll n)
{
    if(n==0) return 0%mod;
    if(n==1) return 1%mod;
    return ((power(n-1)%mod) + (power(n-2)%mod ))%mod;
}
int main()
{
    ll n;cin>>n;
    cout<<power(n%mod)%mod;
}*/
ll pw(ll x,ll n)
{
    ll res=1;
    while(n)
    {
        if(n&1) res=res*x*1ll%mod;
        x=x*x*1ll%mod;
        n/=2;
    }return res;
}
int main()
{
    int x,y;
    cin>>x>>y;
    if((x<=9&&x>=1)&&(y<=9&&y>=1))
    {
        cout<<(x*y)<<endl;

    }else cout<<-1;
}
// C++ program to find sum of two large numbers.
/*#include<bits/stdc++.h>
using namespace std;

// Function for finding sum of larger numbers
string findSum(string str1, string str2)
{
    // Before proceeding further, make sure length
    // of str2 is larger.
    if (str1.length() > str2.length())
        swap(str1, str2);

    // Take an empty string for storing result
    string str = "";

    // Calculate length of both string
    int n1 = str1.length(), n2 = str2.length();

    // Reverse both of strings
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());

    int carry = 0;
    for (int i=0; i<n1; i++)
    {
        // Do school mathematics, compute sum of
        // current digits and carry
        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');

        // Calculate carry for next step
        carry = sum/10;
    }

    // Add remaining digits of larger number
    for (int i=n1; i<n2; i++)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }

    // Add remaining carry
    if (carry)
        str.push_back(carry+'0');

    // reverse resultant string
    reverse(str.begin(), str.end());

    return str;
}

// Driver code
int main()
{
    string str1 ,str2 ;
    cin>>str1>>str2;
    cout << findSum(str1, str2);
    return 0;
}
*/
// CPP program to find (a^b) % MOD where a and
// b may be very large and represented as strings.




Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri Aug  9 21:40:03 2019

@author: Yamazaki Kenichi
"""

S = input()
N = len(S)

T = [0 for i in range(N)]
memo = []
memo2 = []
p = 'R'
counta = 0
for i in range(N):
    if p == S[i]:
        counta += 1
    else:
        memo.append(counta)
        memo2.append(i)
        p = S[i]
        counta = 1
memo.append(counta)
memo2.append(i)
for i in range(len(memo2)//2):
    T[memo2[2*i]-1] = (memo[2*i]+1)//2 + memo[2*i+1]//2
    T[memo2[2*i]] = memo[2*i]//2 + (memo[2*i+1]+1)//2

print(' '.join(map(str,T)))

Measured memory_bytes: 15200
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)    (x).begin(),(x).end()
# define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
# define mp        make_pair
# define eb        emplace_back
# define REP(i, a) for (int i = 0; i < (a); i++)
# define INIT      std::ios::sync_with_stdio(false);std::cin.tie(0);


int main() {
	int n;
	cin >> n;
	int game[205][4];
	for (int i = 1; i <= n; i++) {
		cin >> game[i][1] >> game[i][2] >> game[i][3];
	}
	int ans[205] = {};
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= 3; j++) {
			bool isok = true;
			for (int k = 1; k <= n; k++) {
				if (i == k)continue;
				if (game[i][j] == game[k][j])isok = false;
			}
			if (isok)ans[i] += game[i][j];
		}
	}
	for (int i = 1; i <= n; i++)cout << ans[i] << endl;
}

Measured memory_bytes: 2992
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>

int main() {
    double fInput;
    double s, l;
    
    scanf("%lf", &fInput);

    s = fInput * fInput * M_PI;
    l = 2 * M_PI * fInput;

    printf("%.6lf %.6lf\n", s, l);

    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define Int long long
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;}

struct FastIO{
	FastIO(){
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
	Int n;
	cin>>n;
	vector<Int> as(n);
	for(Int i=0;i<n;i++)cin>>as[i],as[i]--;
	
	vector<Int> cs(n,0);
	//for(int a=0;a<as.size();++a)と同様
	for(Int a:as) 
	{
		cs[a]++;
	}
	
	vector<Int> ds(n+1,0);
	for(Int c:cs)
	{
		ds[c]++;
	}
	
	vector<Int> sm1(n+2,0),sm2(n+2,0);
	for(Int i=0;i<=n;i++){
		sm1[i+1]=sm1[i]+i*ds[i];
		sm2[i+1]=sm2[i]+1*ds[i];
	}
	vector<Int> fs(n+1,n+1);
	for(Int i=1;i<=n;i++)
	{
		fs[i]=(sm1[i+1]+i*(sm2[n+1]-sm2[i+1]))/i;
	}
	for(Int k=1,p=n;k<=n;k++){
		while(k>fs[p])p--;
		cout<<p<<"\n";
	}
	cout<<flush;
	return 0;
}


Measured memory_bytes: 14976
#include<stdio.h>
int main(void)
{
	int n,i;
	int pm,pe,pj;
	int meh,h;
	int flg=0;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&pm,&pe,&pj);
			meh=(pm+pe)/2;
			h=(pm+pe+pj)/3;
			if(pm>=80 || pe>=80){
				flg=1;
			}
			if(pm==100 || pe==100 || pj==100){
				printf("A\n");
			}
			else if(meh>=90){
				printf("A\n");
			}
			else if(h>=80){
				printf("A\n");
			}
			else if(h>=70){
				printf("B\n");
			}
			else if(h>=50 && flg==1){
				printf("B\n");
			}
			else{
				printf("C\n");
			}
			flg=0;
		}
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1012
#include <algorithm>
#include <cstdio>
using namespace std;
int n, k;
long long int a[200005], s[200005], ps = 0;
const long long MOD = 1e9 + 7;
int main() {
  scanf("%d %d", &n, &k);
  long long res = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  sort(a, a + n);

  if (k % 2) {
    res = a[n - 1];
    int sign = res > 0 ? 1 : -1;  // if negative pick smallest abs()
    int l = 0, r = n - 2, cnt = 1;
    while (cnt < k && l < r) {
      if (sign * a[l] * a[l + 1] > sign * a[r] * a[r - 1]) {
        s[ps++] = a[l++];
        s[ps++] = a[l++];
        cnt += 2;
      } else {
        s[ps++] = a[r--];
        s[ps++] = a[r--];
        cnt += 2;
      }
    }
  } else {
    res = 1;
    int l = 0, r = n - 1, cnt = 0;
    while (cnt < k && l < r) {
      if (a[l] * a[l + 1] > a[r] * a[r - 1]) {
        s[ps++] = a[l++];
        s[ps++] = a[l++];
        cnt += 2;
      } else {
        s[ps++] = a[r--];
        s[ps++] = a[r--];
        cnt += 2;
      }
    }
  }
  for (int i = 0; i < ps; ++i) {
    res = (1l * (s[i] % MOD) * (res % MOD) + MOD) % MOD;
  }
  res = (res % MOD + MOD) % MOD;
  printf("%lld\n", res);
  return 0;
}


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

using namespace std;


int n;
int main()
{
  cin >> n;
  for (int i = 1; i < 10; i++)
  if (n / i < 10 && n % i == 0) {
      cout << "Yes";
    return 0;
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Here your code !
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
C = 0

def binary_search(A,n):
    """no recursion version"""
    l = len(A)
    left = l/2
    right = l-1
    while A[left] != n:
        if left == right and A[left] != n:
            #print left,right,"if"
            return False
        elif A[left] > n: # n????????????????????´???
            right = left
            left = left/2
            #print left,right,"elif1"
        elif A[left] < n: # n????????????????????´???
            right = right
            left = (left + right-1)/2 + 1
            #print left,right,"elif2"
    else:
        return True

for item in T:
    if binary_search(S,item):
        C += 1
print C

Measured memory_bytes: 12884
import java.util.*;

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

    int n = sc.nextInt();
    String[] s = new String[n];
    long ans = 1;

    for(int i = 0; i < n; i++){
      s[i] = sc.next();
    }

    Arrays.sort(s);

    for(int i = 0; i < n - 1; i++){
      if(s[i].equals(s[i + 1])){
        ans -= 1;
      }
      ans += 1;
    }

    System.out.println(ans);
  }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
  ll c = 0, sum = 0;
  ll all_ballset = n / (a+b);
  ll diff_ball = n - all_ballset * (a+b);
  if (diff_ball < a) {
    cout << all_ballset * a + diff_ball << endl;
  } else {
    cout << all_ballset * a + a << 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;
using P = pair<int, int>;

int main()
{
  ll x, n;
  cin >> x >> n;
  vector<ll> ps(n);
  rep(i, n) cin >> ps[i];
  map<int, bool> m;

  rep(i, n) {
    m.insert(make_pair(ps[i], true));
  }

  ll cnt = 0;
  ll ans;
  while(true) {
    ll up = x+cnt;
    ll down = x-cnt;
    if (!m.count(down)) {
      ans = down;
      break;
    }
    if (!m.count(up)) {
      ans = up;
      break;
    }
    cnt++;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
import numpy as np
mod = 10 ** 9 + 7

def f(n,k):
    
    ans = 1
    for i in range(k):
        ans = ans * n % mod
        n -= 1
    return ans


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
p = mod 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

# print( cmb(4, 2, mod) )

N, K = map(int, input().split())
A = sorted(map(int, input().split()))
R = sorted(A, reverse=True)

sum = 0

for i in range(N-K+1):
    
    t = cmb( N-i-1, K-1, mod)
    k = A[i] * t % mod
    # print(A[i], t, k)
    sum = ( sum + k ) % mod

sum = -sum

for i in range(N-K+1):
    
    t = cmb( N-i-1, K-1, mod)
    k = R[i] * t % mod
    # print(R[i], t, k)
    sum = ( sum + k ) % mod

print(sum)



Measured memory_bytes: 34972
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

int main() {
  long long base = 0;
  int n, X;
  scanf("%d%d", &n, &X);
  /*n = 200000;
  X = 1000000000; */ 
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
    //x[i] = 1000000000;
    base += X;
  }
  vector<long long> xsum(n + 1);
  for (int i = 0; i < n; i++) {
    xsum[i + 1] = xsum[i] + x[i];
  }
  long long ans = LLONG_MAX;
  for (int jump = 1; jump <= n; jump++) {
    long long level = 0;
    long long cur = base + (long long) jump * X;
    for (int k = n; k > 0; k -= jump) {
      int sind = max(0, k - jump);
      int eind = k;
      // [sind, eind)
      long long range = xsum[eind] - xsum[sind];

      long long prev = cur;

      if (level == 0) {
        cur += range * (1 + 4);
      }
      else {
        cur += range * (2 * level + 3);
      }

      if (prev > cur) {
        cur = LLONG_MAX;
        break;
      }
      level++;
    }
    ans = min(ans, cur);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 2560
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Float_Text_IO;
use Ada.Text_IO;
use Ada.Integer_Text_IO;
use Ada.Float_Text_IO;

procedure hoge is
 k: Integer;
 a: Integer;
 b: Integer;
 flag: Integer :=0;
begin
 get(k);
 get(a);
 get(b);
 for i in a..b loop
  if (i rem k)=0 then
   flag:=1;
  end if;
 end loop;
 if flag = 1 then
  put_line("OK");
 else
  put_line("NG");
 end if;
end hoge;

Measured memory_bytes: 3620
#include<stdio.h>

int main() {
	char str[21];
	int len;
	int i;
	char tmp;
	scanf("%s", str);
	len = strlen(str);
	for (i = 0; i < len / 2; i++) {
		tmp = str[i];
		str[i] = str[len - 1 - i];
		str[len - 1 - i] = tmp;
	}
	printf("%s\n",str);
	return 0;
}

Measured memory_bytes: 520
#include <bits/stdc++.h>
const int Maxv = 200010; 
int num[Maxv], n,i; 
long long ans; 
int main() {
    scanf("%d", &n); 
    for (i = 0; i < n; i++) {
        scanf("%d", &num[i]); 
        num[i] -= i + 1; 
    }
    std::sort(num, num + n); 
    int tmp = num[(n >> 1)]; 
    for (i = 0; i < n; i++) 
        ans += abs(num[i] - tmp); 
    printf("%lld\n", ans); 
    return 0; 
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)

	L := make([]int, 2*N)
	for i := range L {
		fmt.Scan(&L[i])
	}

	sort.Ints(L)
	ans := 0
	for i, v := range L {
		if i%2 == 0 {
			ans += v
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512