akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

S = input().replace('\n', '')
T = input().replace('\n', '')

alphabet = 'abcdefghijklmnopqrstuvwxyz'
len_alphabet = len(alphabet)
dict_alphabet = {chara: i for i, chara in enumerate(alphabet)}


def calc_state(target_string):
    state_idx = [[] for _ in range(len_alphabet)]
    state_count = [0 for _ in range(len_alphabet)]

    for i, chara in enumerate(target_string):
        alphabet_idx = dict_alphabet[chara]
        state_idx[alphabet_idx].append(i)
        state_count[alphabet_idx] += 1

    return state_idx, state_count


state_idx_s, state_count_s = calc_state(S)
state_idx_t, state_count_t = calc_state(T)


if sorted(state_count_s) != sorted(state_count_t):
    print('No')
    exit()
else:
    print('Yes')

Measured memory_bytes: 20528
using System;
using System.Collections;

public class p0001{
	public static int Main (string[] args)
	{
		string str;
		int[] ary = new int[10];
		
		while ((str = Console.ReadLine()) != null) {
			ary [0] = int.Parse (str);
			
			for (int i = 1; i < 10; ++i) {
				str = Console.ReadLine ();
				ary [i] = int.Parse (str);
			}
			
			Array.Sort (ary);
			for (int i = 0; i < 3; ++i)
				Console.WriteLine ("{0}", ary[9-i]);
		}
		
		return 0;
	}
}

Measured memory_bytes: 5772
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c=0,d=1,e;
  cin>>a>>b;
 if(a*2<=b){
    c=a;
    b-=a*2;   
   a=0;
  }
  else {
	c=b/2;
    b=b%2;
  }
 /*/ while(true){
    if(a==0||b<=1) break;
    a--;
    b-=2;
    c++;
  }/*/
  cout<<c+(b/4)<<"\n";
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string SA, SB, SC;

void game(char a){
    char b;
    if (a == 'a')
    {
        if ((int)(SA.length()) == 0)
        {
            cout << 'A' << endl;
        }else
        {
            b = SA[0];
            SA.erase(0, 1);
            game(b);
        }
        
    }else if (a == 'b')
    {
        if ((int)(SB.length()) == 0)
        {
            cout << 'B' << endl;
        }else
        {
            b = SB[0];
            SB.erase(0, 1);
            game(b);
        }

    }else if (a == 'c')
    {
        if ((int)(SC.length()) == 0)
        {
            cout << 'C' << endl;
        }else
        {
            b = SC[0];
            SC.erase(0, 1);
            game(b);
        }
    }
     
}

int main(int argc, char const *argv[])
{
    cin >> SA >> SB >> SC;
    char s = SA[0];
    game(s);

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>//"geometry.cpp"
#include<iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
#include<queue>
#include<string>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<algorithm>
#include<functional>//"greater<T>" Ex. sort(a,a+n,greater<int>());
#include<cmath>//"abs", "sqrt"
using namespace std;
#define pb push_back
#define fi first
#define sc second
#define mp make_pair
#define is insert	//tentative

//the maximum number of variants
#define MATRIX_MAX_X 625//Caution! You need additional information here.

#define MATRIX_T int//Caution! You need additional information here.
typedef vector<MATRIX_T> vec;//Be careful of the clash of type names, especially with vec in "geometry.cpp".
typedef vector<vec> mat;

vec gauss_jordan(mat A,vec b){//MATRIX_T should be double, etc.
	int rk=0,f[MATRIX_MAX_X];
	fill(f,f+A[0].size(),-1);
	mat B(A.size(),vec(A[0].size()+1));
	for(int i=0;i<A.size();++i){
		for(int j=0;j<A[0].size();++j){
			B[i][j]=A[i][j];
		}
	}
	for(int i=0;i<A.size();++i){
		B[i][A[0].size()]=b[i];
	}
	for(int j=0;j<A[0].size()&&rk<A.size();++j){
		int pivot=rk;
		for(int i=rk+1;i<A.size();++i){
			if(abs(B[i][j])>abs(B[pivot][j])){
				pivot=i;
			}
		}
		if(B[pivot][j]==0){
			continue;
		}
		swap(B[rk],B[pivot]);
		f[j]=rk;
		for(int i=0;i<A.size();++i){//B[rk][j]????????????????????????
			if(i!=rk){
				for(int k=j+1;k<=A[0].size();++k){
					B[i][k]-=B[i][j]*B[rk][k];
					B[i][k]=abs(B[i][k]);
					B[i][k]%=2;
				}
				B[i][j]=0;
			}
		}
		++rk;
	}
	for(int i=rk;i<A.size();++i){
		if(B[i][A[0].size()]!=0){
			return vec();//the case where there're no solutions.
		}
	}
	vec x(A[0].size());
	for(int j=0;j<A[0].size();++j){
		if(f[j]<0){
			x[j]=0;
		}else{
			x[j]=B[f[j]][A[0].size()];
		}
	}
	return x;//Note that this case includes the case where there're more than 1 solutions.
}

void solve(int m,int n,int d){
	vec s(m*n);
	for(int k=0;k<n;++k){
		for(int l=0;l<m;++l){
			cin>>s[m*k+l];
		}
	}
	mat A(m*n,vec(m*n));
	for(int i=0;i<n;++i){//[i][j] corresponds to m*i+j.
		for(int j=0;j<m;++j){
			for(int k=0;k<n;++k){
				for(int l=0;l<m;++l){
					int e=abs(k-i)+abs(l-j);
					if(e==0||e==d){
						A[m*k+l][m*i+j]=1;
					}else{
						A[m*k+l][m*i+j]=0;
					}
				}
			}
		}
	}
	if(gauss_jordan(A,s)==vec()){
		cout<<0<<endl;
	}else{
		cout<<1<<endl;
	}
}

int main(){
	while(true){
		int m,n,d;
		cin>>m>>n>>d;
		if(m==0){
			break;
		}
		solve(m,n,d);
	}
}

Measured memory_bytes: 7616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int D;
    cin >> D;
    
  	if(D == 25)
      cout << "Christmas" << endl;
  	else if(D == 24)
      cout << "Christmas Eve" << endl;
  	else if(D == 23)
      cout << "Christmas Eve Eve" << endl;
  	else if(D == 22)
      cout << "Christmas Eve Eve Eve" << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  cin>>s;
  int n=s.size();
  REP(i,n){
    if(i<n-1){
      if(s[i]==s[i+1]){
        cout<<i+1<<' '<<i+2<<endl;
        return 0;
      }
    }
    if(i<n-2){
      if(s[i]==s[i+2]){
        cout<<i+1<<' '<<i+3<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<' '<<-1<<endl;
  return 0;
}


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

int main () {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  long long minPrice = INFINITY;
  for (int i = 0; i/2 <= max(x, y); i += 2) { //abピザをi枚買う
    int p, q;
    p = x - i / 2;
    q = y - i / 2;
    if (p < 0) p = 0;
    if (q < 0) q = 0;
    long long price = a*p + b*q + c*i;
    minPrice = min(minPrice, price);
  }
  cout << minPrice << endl;
}

Measured memory_bytes: 256
//Tue Dec 22 22:01:34 JST 2009
#include<cstdio>
#include<set>
#include<iostream>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp make_pair
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};
#define CONNECT true
#define UNCONNECT false
#define CANMOVE true
#define CANNOTMOVE false
int gx,gy;

class state{
public:
  int len;
  int x[8],y[8];
  int cnt;
  bool is_connected(int me,int you){
    if ( x[me]==x[you]){
      if ( y[me]-1 == y[you] || y[me]+1 == y[you] || y[me]==y[you])return CONNECT;
    }else if ( x[me]+1 == x[you]){
      if (y[me] ==y[you] || y[me]-1==y[you])return CONNECT;
    }else if ( x[me]-1==x[you]){
      if (y[me] ==y[you] || y[me]+1 == y[you])return CONNECT;
    }

    return UNCONNECT;
  }

  bool can_good_pos(int cur){
    rep(i,cur-1){
      if ( is_connected(cur,i)==CONNECT)return false;//©ªÌOÈOÌâÂÆÂÈªÁÄ¢éÌÅ¾ßB
    }
    if (cur==0 ||  is_connected(cur,cur-1)==CONNECT)return true;//©ªÆOÌâÂÆÂÈªÁÄ¢éÌÅ¨
    return false;
  }
  
  bool make_next(int now,queue<state>&Q,set<state>&S,bool flag,set<pair<int,int> > & NG){
    if ( now == len){
      if ( S.find((*this))==S.end()){
	cnt++;
	if ( x[0]==gx && y[0]==gy)return true;
	S.insert(*this);
	Q.push(*this);
	cnt--;
      }
      return false;
    }

    //don't move
    
    if (can_good_pos(now) ){
      if (make_next(now+1,Q,S,CANMOVE,NG))return true;
    }

    if ( flag == CANNOTMOVE)return false;//OÌª®¢Ä½ç©ªÍ®¯È¢

    rep(i,6){
      x[now]+=dx[i];
      y[now]+=dy[i];

      if (max(x[now],gx)-min(x[now],gx)>20||
	  max(y[now],gy)-min(y[now],gy)>20)continue;
      
      if (NG.find(mp(x[now],y[now])) == NG.end() && can_good_pos(now)){
	if (make_next(now+1,Q,S,CANNOTMOVE,NG))return true;//©ªª®¢½çÌÍ®¯È¢B
      }
      x[now]-=dx[i];
      y[now]-=dy[i];
    }
    return false;
  }
  
  bool operator<(const state & a)const{
    rep(i,len){
      if ( x[i]!=a.x[i])return x[i]<a.x[i];
      if ( y[i]!=a.y[i])return y[i]<a.y[i];
    }
    return false;
  }
  
};



int bfs(state ini,int dx,int dy,set<pair<int,int> > &NG){
  queue<state> Q;
  set<state> S;
  Q.push(ini);
  S.insert(ini);
  while(!Q.empty()){
    state now = Q.front();
    Q.pop();
    if (20<now.cnt+(max(now.x[0],dx)-min(now.x[0],dy)+max(now.y[0],dy)-min(now.y[0],dy))/2)continue;
    if ( now.x[0]==dx && now.y[0]==dy){
      return now.cnt;
    }
    if ( now.make_next(0,Q,S,CANMOVE,NG))return now.cnt;
  }
  return -1;
}


main(){
  int n,m,dx,dy;
  while(scanf("%d",&n)!=-1 && n){
    state ini;
    set<pair<int,int> > NG;
    
    ini.len=n;
    ini.cnt=0;
    rep(i,n)scanf("%d%d",&ini.x[i],&ini.y[i]);
    scanf("%d",&m);
    rep(i,m){
      int f,s;
      scanf("%d%d",&f,&s);
      NG.insert(mp(f,s));
    }
    scanf("%d%d",&dx,&dy);
    gx=dx;gy=dy;
    cout << bfs(ini,dx,dy,NG)<<endl;
  }
  return false;
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
#define p(x) cout<<(x)<<endl;
#define pv(v) for(auto a: v){ cout << a << endl; }

int main() {
  int a, b; cin >> a >> b;

  if (a >= 13){
    p(b);
  } else if (a <= 5){
    p(0);
  } else {
    p(b/2)
  }
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
c=[]
for i in reversed(range(n)):
  j=0
  k=2
  while k*(i+1)<=n:
    j=j+b[k*(i+1)-1]
    k=k+1
  j=j%2
  if a[i]!=j:
    b[i]=1
print(sum(b))
for i in range(n):
  if b[i]==1:
    print(i+1,end=' ')

Measured memory_bytes: 7248
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	int N;
	cin >> N;

	string S;
	cin >> S;

	int ssum[3][4001]{};
	for (int i = N; i--; ) {
		ssum[0][i] = ssum[0][i + 1] + (S[i] == 'R');
		ssum[1][i] = ssum[1][i + 1] + (S[i] == 'G');
		ssum[2][i] = ssum[2][i + 1] + (S[i] == 'B');
	}

	ll ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) if (S[i] != S[j]) {
			int t;
			if (S[i] == 'R') {
				if (S[j] == 'G') t = 2;
				else t = 1;
			}
			else if (S[i] == 'G') {
				if (S[j] == 'R') t = 2;
				else t = 0;
			}
			else {
				if (S[j] == 'R') t = 1;
				else t = 0;
			}

			ans += ssum[t][j + 1];
			if (j + j - i < N && S[j + j - i] == "RGB"[t]) --ans;
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    for(int n; cin >> n, n;){
        vector<vi> table(30);
        vector<char> ops(30);
        int depth = 0;

        vector<string> ins(n);
        for(auto & e : ins) cin >> e;
        ins.push_back("_");

        for(auto & in : ins){
            int cd = in.size() - 1;

            while(depth > cd){
                int len = table[depth].size();
                int cur = table[depth][0];

                if(ops[depth - 1] == '+'){
                    rep(i, 1, len){
                        cur += table[depth][i];
                    }
                }
                else {
                    rep(i, 1, len){
                        cur *= table[depth][i];
                    }
                }

                table[depth - 1].push_back(cur);
                depth--;
            }

            depth = cd;

            char c = in.back();
            if('0' <= c and c <= '9'){
                table[depth].push_back(c - '0');
            }
            else {
                ops[depth] = c;
                table[depth + 1] = {};
            }
        }

        cout << table[0][0] << endl;
    }

    return 0;
}

Measured memory_bytes: 3192
if __name__ == "__main__":
    a = int(input())
    a = int(a)
    flag=False
    for i in range(1, 10):
        for j in range(1, 10):
            if a == i*j:
                flag=True
                break
        if flag:
            break
            
    if flag==False :
        print('No')
    else :
        print('Yes')

Measured memory_bytes: 3060
n=int(input())
x,y=[],[]
for i in range(n):
    x_,y_=map(int,input().split())
    x.append(x_)
    y.append(y_)
for i in range(n-2):
    if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 62284
#include <bits/stdc++.h>
#define debug(...)
#include <complex.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;


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

     vector<string> v = { "SUN", "MON", "TUE", "WED", "THU", "FRI",  "SAT"};
     map <string , int > ans;
     int t = 7;
     for(auto s : v){
        ans[s] = t;
        t--;
     }
     string s;
     cin >> s;
     cout << ans[s] << '\n';



    return 0;
}













Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 998244353;

ll dp[3005][3005];

int main(){
    int n,s;
    ll ans = 0;
    cin >> n >> s;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n+1){
        dp[i][0] = i+1;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=s;j++){
            if(j-a[i-1]>=0) dp[i][j] = (dp[i-1][j] + dp[i-1][j-a[i-1]])%MOD;
            else dp[i][j] = dp[i-1][j];
        }
        ans += dp[i][s];
        ans %= MOD;
    }
    cout << ans << endl;
    /*
    rep(i,n+1){
        rep(j,s+1){
            cout << dp[i][j] << " ";
        }
         cout << endl;
    }
    */
    return 0;
}

Measured memory_bytes: 70656
S=input()

l = len(S)
ans1 = 0
ans2 = 0

for i in range(l):
    if i%2 == 0:
        if S[i] == '0':
            ans1 += 1
    else:
        if S[i] == '1':
            ans1 += 1
            
for i in range(l):
    if i%2 == 0:
        if S[i] == '1':
            ans2 +=1
    else:
        if S[i] == '0':
            ans2 += 1
            
print(min(ans1,ans2))

Measured memory_bytes: 3188
//ABC108B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include<stdio.h>
#include<climits>
#include<cfloat>
using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << c+b-d << " " << d+c-a << " " << a+b-d << " " << b+c-a << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a * c < b) {
            System.out.println(c);
        } else {
            System.out.println(b / a);
        }
    }
}


Measured memory_bytes: 22100
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }

    if s.iter().all(|&x| x == 'A') || s.iter().all(|&x| x == 'B') {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint x;
  cin>>x;
  lint ans=((x-1)/11+1)*2;
  if((x-1)%11<6)ans--;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

ll c[100][100];
bool b[100][100];
ll dx[8] = {0, 0, 1, 1, 1, -1, -1, -1}, dy[8] = {1, -1, 0, 1, -1, 0, -1, 1};
ll w, h;

void dfs(ll x, ll y) {
    b[x][y] = true;
    rep(i, 8) {
        ll nx = x + dx[i], ny = y + dy[i];
        if (0 <= nx && nx < h && 0 <= ny && ny < w && c[nx][ny] == 1) {
            if (b[nx][ny]) continue;
            dfs(nx, ny);
        }
    }
}

int main() {
    vector<ll> vec;
    while(cin >> w >> h) {
        if(w == 0 && h == 0) {
            for(auto v : vec) cout << v << endl;
            return 0;
        }

        rep(i, h) rep(j, w) cin >> c[i][j];
        rep(i, h) rep(j, w) b[i][j] = false;

        ll ans = 0;
        rep(i, h) rep(j, w) {
            if (c[i][j] == 1 && b[i][j] == false) {
                ans++;
                dfs(i, j);
            }
        }
        vec.push_back(ans);
    }
}



Measured memory_bytes: 3216
import math
def is_prime(x):
    if x == 1: return False
    for i in range(2,int(math.sqrt(x))+1):
        if x%i == 0: return False
    return True
n = int(input())
ans = 0
for i in range(n):
    x = int(input())
    ans += is_prime(x)
print(ans)


Measured memory_bytes: 5676
nx = input().split()
n = int(nx[0])
x = int(nx[1])
l = input().split()
l = [int(l[i]) for i in range(n)]
haneru = [0]
for i in range(n):
  tmp = haneru[i] + l[i]
  haneru.append(tmp)

tmp = 1
for i in range(len(haneru)):
  if haneru[i] > x:
    break
  else:
    tmp = i
print(tmp+1)

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <complex>
#include <algorithm>
using namespace std;

typedef complex<double> Point;

Point ps[4];

int main() {
  while (1) {
    for (int i=0; i<4; i++) {
      double x, y;
      if (scanf("%lf%lf", &x, &y) != 2) return 0;
      ps[i] = Point(x, y);
    }

    bool found = false;
    for (int i=0; i<3; i++) {
      Point a0 = ps[(i+1)%3]-ps[i];
      Point b0 = ps[(i+2)%3]-ps[i];
      Point c0 = ps[3]-ps[i];
      if (abs(arg(c0/a0)) > abs(arg(b0/a0))) {
        puts("NO");
        found = true;
        break;
      }
    }

    if (!found) puts("YES");
  }
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;
    

int main(){
    ll n;
    cin>>n;
    vector<int> t(100000,0);
    for(int i=1;i<=sqrt(n);i++){
        for(int j=1;j<=sqrt(n);j++){
            for(int k=1;k<=sqrt(n);k++){
                ll s = i*i+j*j+k*k+i*j+j*k+k*i;
                t[s]++;
            }
        }
    }
    for(ll i=1;i<=n;i++){
        cout<<t[i]<<endl;
    }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

void solve() {
    int n;
    cin >> n;
    vector<int> ans(n + 1, 0);
    for (int i = 1; i < n; ++i) {
        int x;
        cin >> x;
        ans[x] = ans[x] + 1;
    }

    for (int i = 1; i <= n; ++i) {
        cout << ans[i] << "\n";
    }
}

int main() {
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/

    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin >> t;

    // while(t--)
    solve();

    return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        map<string, ll> mp;
        rep(i, 0, N) {
                string s;
                cin >> s;
                mp[s]++;
        }
        vector<pair<ll, string>> data;
        for (auto x : mp) {
                data.push_back(pair<ll, string>{x.second, x.first});
        }
        sort(data.rbegin(), data.rend());
        ll mx = data[0].first;
        set<string> ans;
        rep(i, 0, len(data)) {
                if (data[i].first == mx) {
                        ans.insert(data[i].second);
                }
        }

        for (auto x : ans) {
                cout << x << endl;
        }
}

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

int main(){
    string s;
    cin >> s;
    int anum = 0, bnum = 0, cnum = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'a') anum++;
        else if(s[i] == 'b') bnum++;
        else cnum++;
    }

    if(abs(anum-bnum) <= 1 && abs(bnum-cnum) <= 1 && abs(cnum-anum) <= 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3724
open Batteries
open Printf
let () =
  let a,b,c = Scanf.scanf "%s %s %s " (fun a b c -> a,b,c) in
  let a = String.to_list a in
  let b = String.to_list b in
  let c = String.to_list c in

  let rec aux a b c next =
    if next = 'a' then 
      (
        match a with
        | [] -> "A"
        | next::tl -> aux tl b c next
      )
    else if next = 'b' then 
      (
        match b with
        | [] -> "B"
        | next::tl -> aux a tl c next
      )
    else if next = 'c' then 
      (
        match c with
        | [] -> "C"
        | next::tl -> aux a b tl next
      )
    else ""
  in
  Printf.printf "%s\n" @@
  aux a b c 'a'


Measured memory_bytes: 1152
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

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

	int count = 0;

	for (int i = 0; i < n;i++) {
		ll x, y;
		cin >> x >> y;
		if (d*d>=x*x+y*y) {
			count++;
		}
	}

	cout <<count<< endl;
	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14
 
char H[M][L];

//将字符串转换为数值 
int getChar(char ch){
	if (ch == 'A') return 1;
	else if(ch == 'C') return 2;
	else if(ch == 'G') return 3;
	else if(ch == 'T') return 4;
	else return 0;
}

//将字符串转换为数值并生成key
long long getKey(char str[]){
	long long sum = 0, p = 1, i;
	for(i = 0; i < strlen(str); i++){
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
} 

int h1(int key){
	return key % M;
}

int h2(int key){
	return 1 + (key % (M - 1));
}

int find(char str[]){
	long long key, i, h;
	key = getKey(str);  //将字符串转换为数值
	for(i = 0; ;i++){
		h = (h1(key) + i * h2(key)) % M;
		if( strcmp(H[h],str) == 0) return 1;
		else if(strlen(H[h]) == 0) return 0;
	} 
	return 0;
}

int insert(char str[]){
	long long key, i, h;
	key = getKey(str); //将字符串转换为数值
	for(i = 0; ; i++){
		h = (h1(key) + i * h2(key)) % M;
		if( strcmp(H[h],str) == 0) return 1;
		else if( strlen(H[h]) == 0) {
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int main(){
	int i, n, h;
	char str[L],com[9];
	for(i = 0; i < M; i++) H[i][0] = '\0';
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%s %s",com,str);
		if( com[0] == 'i'){
			insert(str);
		}
		else{
			if(find(str)){
				printf("yes\n");
			}
			else printf("no\n");
		}
	}
	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if (b == 1) cout << 0 << '\n';
    else if (a >= b) cout << 1 << '\n';
    else {
        int ans = 1;
        ans += (b - a) / (a - 1);
        if ((b - a) % (a - 1)) ans++;
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll mod = 998244353;
ll fact[101010];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	string S;
	cin >> N >> S;
	fact[0] = 1;
	for (ll i = 1; i < 101010; i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= mod;
	}

	ll ans = fact[N];
	map<char, int>mp;
	mp['R'] = 0;
	mp['G'] = 0;
	mp['B'] = 0;
	for (int i = 0; i < 3 * N; i++) {
		char c = S[i];
		vector<pair<int, char>>v;
		fore(x, mp)v.pb({x.second,x.first});
		sort(all(v));
		if (mp[c] == v[0].first) {
			if (v[0].first < v[1].first)ans *= v[1].first - v[0].first;
			else if(v[1].first < v[2].first) ans *= v[2].first - v[0].first;
		}
		else if (mp[c] == v[1].first) {
			if (v[1].first < v[2].first)ans *= v[2].first - v[1].first;
		}
		mp[c]++;
		ans %= mod;
	}
	puts(ans);

	return 0;
}


Measured memory_bytes: 1428
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

int gcd(int a, int b){
	return b != 0 ? gcd(b, a%b) : a;
}

int lcm(int a, int b){
	return a*b / gcd(a, b);
}

#define N_MAX 310
#define MOD 1000000007

void solv()
{
	char S[110], T[110]; scanf("%s%s", S, T);
	printf("%s%s\n", T, S);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#coding:utf-8

N, H, W = list(map(int, input().split()))

A = []
B = []
for i in range(N):
    A_i, B_i = list(map(int, input().split()))
    A.append(A_i)
    B.append(B_i)

count = 0
for i in range(N):
    if A[i] >= H and B[i] >= W:
        count += 1

print(count)


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

int main() {
 
    int N,K,min;
    
    cin>>N;
    cin>>K;
    
    min=1;      
 
    
    for(int i=0;i<N;i++){
        
      if(min*2 >min+K)
      {
          min=min+K;
      }
       else
       {
          min=min*2;
       }
        
    
    
    }
    cout<<min<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector <ll> v
#define vii vector<pair<ll,ll>>v
#define pb push_back
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define while_ int t;cin>>t;while(t--)
#define t32 32
using namespace std;

ll find_min_sum(int n, int k, int A[])
{
    ll dp[n];
    dp[0]=0;dp[1]=abs(A[1]-A[0]);
    f(i,2,n)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k && j<=i;j++)
          {
              ll mini_sum=(abs(A[i]-A[i-j]))+dp[i-j];
              dp[i]=min(dp[i],mini_sum);
          }
          
    }
    return dp[n-1];
}

int main() {
    fastio
   
        int n; cin>>n;
        int k; cin>>k;
        int A[n];
        f(i,0,n) cin>>A[i];
        cout<<find_min_sum(n,k,A);
    
    
}













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

int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  ll x;
  if(B - 1 > N) x = N;
  else x = B - 1;
  cout << (A * x / B) - A * (x / B) << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>


#include <map>

using namespace std;

typedef long long LL;

int n;

int a[114], b[114], h[114];

int mx;

int main() {
    
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i] >> b[i] >> h[i];
        if (h[i]) mx = i;
    }
    
    for (int i = 0; i <= 100; ++i) {
        for (int j = 0; j <= 100; ++j) {
            bool setup = false, succ = true;
            a[0] = i, b[0] = j;
            
            h[0] = abs(i - a[mx]) + abs(j - b[mx]) + h[mx];

            for (int k = 1; k <= n && succ; ++k) {
                if (h[k] != max(h[0] - abs(i - a[k]) - abs(j - b[k]), 0)) {
                    succ = false;
                }
                    
            }

            if (succ) {
                printf("%d %d %d", i, j, h[0]);
                return 0;
            }

            
        }
    }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int main(){

	int N,ans = BIG_NUM;

	scanf("%d",&N);

	int* table = new int[N+1];

	int** dp = new int*[N+1];
	for(int i = 0; i <= N; i++){
		dp[i] = new int[4];
		for(int k = 0; k <= 3; k++)dp[i][k] = BIG_NUM;
	}

	for(int i = 0; i < N; i++){
		scanf("%d",&table[i+1]);
	}

	for(int i = 0; i <= table[1]; i++){
		dp[1][table[1] - i] = i;
	}

	for(int right = 2; right <= N; right++){
		for(int left_rest = 0; left_rest <= 3; left_rest++){
			if(dp[right-1][left_rest] == BIG_NUM)continue;
			for(int i = left_rest; i <= max(left_rest,table[right]);i++){
				dp[right][max(0,table[right]-i)] = min(dp[right][max(0,table[right]-i)],
						dp[right-1][left_rest]+2*i);
			}
		}
	}

	for(int i = 0; i <= table[N]; i++){
		ans = min(ans,dp[N][i] + i);
	}

	printf("%d\n",ans);

   return 0;
}

Measured memory_bytes: 2896
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

vector<int> x;
vector<int> y;

bool test(const vector<int> &v, int X)
{
	set<int> st;
	st.insert(v[0]);
	for(int i = 1; i < v.size(); i++){
		vector<int> tmp;
		for(auto& a: st){
			tmp.push_back(a + v[i]);
			tmp.push_back(a - v[i]);
		}
		st.clear();
		for(auto& a: tmp){
			st.insert(a);
		}
	}
	return st.count(X);
}

int main(){
	string s;
	cin >> s;
	int X, Y;
	cin >> X >> Y;

	bool f = true;
	int num = 0;
	y.push_back(0);
	for(auto& c: s){
		if(c == 'F'){
			num++;
		}else{
			(f ? x : y).push_back(num);
			f = !f;
			num = 0;
		}
	}
	(f ? x : y).push_back(num);
	bool ans = (test(x, X) && test(y, Y));
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 552
#include<iostream>

using namespace std;

int main(){
    string a, b;
    cin >> a >> b;

    int alen=0, blen=0;
    int j = 0;
    while(a[j]){
        alen++;
        j++;
    }
    j = 0;
    while(b[j]){
        blen++;
        j++;
    }
    if(alen>blen){
        cout << "GREATER" << endl;
        return 0;
    }else if(alen<blen){
        cout << "LESS" << endl;
        return 0;
    }
    for(int i=0;i<alen;i++){
        if(int(a[i])>int(b[i])){
            cout << "GREATER" << endl;
            return 0;
        }else if(int(a[i])<int(b[i])){
            cout << "LESS" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define R cin>>
#define C cout<<
const int INF = 1000000007;
typedef long long ll;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  REP(i,1,10){
    if(i * 111 >= n){
     cout <<  i * 111 << endl;
      return 0;
    }
    }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> P;

vector<int> a, b, c;
map<P, int> mp1;
map<P, int> mp2;
int N, Ma, Mb;

void dfs(int i, P sum, int cost)
{
  if (i > N / 2) {
    if (mp1.count(sum))
      mp1[sum] = min(mp1[sum], cost);
    else
      mp1[sum] = cost;
    return;
  }

  dfs(i + 1, make_pair(sum.FI, sum.SE), cost);
  dfs(i + 1, make_pair(sum.FI + a[i], sum.SE + b[i]), cost + c[i]);
}

void dfs2(int i, P sum, int cost)
{
  if (i == N) {
    if (mp2.count(sum))
      mp2[sum] = min(mp2[sum], cost);
    else
      mp2[sum] = cost;
    return;
  }
  dfs2(i + 1, make_pair(sum.FI, sum.SE), cost);
  dfs2(i + 1, make_pair(sum.FI + a[i], sum.SE + b[i]), cost + c[i]);
}

int main()
{
  cin >> N >>  Ma >> Mb;
  a.resize(N);
  b.resize(N);
  c.resize(N);
  REP(i, N) cin >> a[i] >> b[i] >> c[i];

  dfs(0, make_pair(0, 0), 0);
  dfs2(N/2 + 1, make_pair(0, 0), 0);

  /*cout << endl;
  REP(i, vv1.size()) cout << vv1[i].FI.FI << ' ' << vv1[i].FI.SE << ' ' << vv1[i].SE << endl;
  cout << endl;
  REP(i, 10) for (auto e : vv2[i]) cout << e.FI << ' ' << e.SE << endl;*/

  int ans = INF;
  for (int i = 1; i <= 40; i++) {
    for (auto e : mp1) {
      //if (i == 1) cout << e.FI.FI << ' ' << e.FI.SE << ' ' << e.SE << endl;
      int ta = e.FI.FI;
      int tb = e.FI.SE;
      int c = e.SE;
      if (mp2.count(MP(i*Ma - ta, i*Mb - tb))) {
        ans = min(ans, c + mp2[MP(i*Ma - ta, i*Mb - tb)]);
      }
    }
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;

	return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
ll LMC(ll a,ll b){
	/*最小公倍数*/
	ll r,x,tmp;
	if(a<b){
		tmp = a;
		a = b;
		b = tmp;
    }
	x=a*b;
    r = a % b;
	while(r!=0){
		a = b;
		b = r;
		r = a % b;
	}
	return (x/b);
}
int main(){
	ll a,b,c,d,al,l;
	ll x,y,z;
	cin>>a>>b>>c>>d;
	l=LMC(c,d);
	al=(b-a+1);
	x=((b/c)-(a/c));
	y=((b/d)-(a/d));
	z=((b/l)-(a/l));
	if(a%c==0) x++;
	if(a%d==0) y++;
	if(a%l==0) z++;
	cout<<(ll)(al-x-y+z);
	return 0;
}	

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int main() {
    
    ll x, y;
    cin >> x >> y;
    int cnt = 1;
    
    while( x*2 <= y ) {
        x*=2;
        cnt++;
    }
    cout<<cnt<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	std::vector<int> a(n+1);
	std::vector<int> ans;
	for(int i = 1; i <= n; i++) {
		std::cin >> a[i];
	}
	for(int i = n; i > 0; i--) {
		for(int j = i+i; j <= n; j += i) {
			a[i] ^= a[j];
		}
		if(a[i]) ans.push_back(i);
	}
	std::cout << ans.size() << '\n';
	for(int i = 0; i < (int) ans.size(); i++) {
		std::cout << ans[i] << (i + 1 == (int) ans.size() ? '\n' : ' ');
	}
}

Measured memory_bytes: 2424
#include <stdio.h>
int main(void)
{
  int a[1000][1000];
  int b[1001][1001];
  int c,r;
  int i,j;

  scanf("%d",&r);
  scanf("%d",&c);

  for (i=0; i<r; i++) {
    for (j=0; j<c; j++) {
      scanf("%d",&a[i][j]);
    }
  }

  for (i=0; i<r; i++) {
    for (j=0; j<c; j++) {
      a[i][c]+=a[i][j];
    }
  }

  for (j=0; j<c; j++) {
    for (i=0; i<r; i++) {
      a[r][j]+=a[i][j];
    }
  }

  for (i=0; i<r; i++) {
    a[r][c]+=a[i][c];
  }
  
  for (i=0; i<r+1; i++) {
    for (j=0; j<c+1; j++) {
      if (j==c) printf("%d\n",a[i][j]);
      else printf("%d ",a[i][j]);
    }
  }
  return 0;
}

Measured memory_bytes: 2692
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	int ans = 1;
	for (int i = 0; i < N; ++i) {
		ans = min(ans + K, 2 * ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3608
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt()
  val a = Array.fill(n)(sc.nextLong())

  val mod = 1000000007

  def minus(a: Long, b: Long): Long = (a - b + mod) % mod
  def times(a: Long, b: Long): Long = (a * b) % mod

  val b = a.filter(_ != 0).map(e => (e.abs, e)).sorted
  if (b.length < k) {
    println(0)
  } else if (b.length == k) {
    if (b.count(_._2 < 0) % 2 == 0) {
      println(b.map(_._1).reduceLeft(times))
    } else {
      if (a.contains(0)) {
        println(0)
      } else {
        println(minus(0, b.map(_._1).reduceLeft(times)))
      }
    }
  } else {
    if (b.forall(_._2 > 0)) {
      println(b.takeRight(k).map(_._1).reduceLeft(times))
    } else if (b.forall(_._2 < 0)) {
      if (k % 2 == 0) {
        println(b.takeRight(k).map(_._1).reduceLeft(times))
      } else {
        if (a.contains(0)) {
          println(0)
        } else {
          println(minus(0, b.take(k).map(_._1).reduceLeft(times)))
        }
      }
    } else {
      val (r, c) = b.splitAt(b.length - k)
      if (c.count(_._2 < 0) % 2 == 0) {
        println(c.map(_._1).reduceLeft(times))
      } else {
        val pf = c.indexWhere(_._2 > 0)
        val mf = c.indexWhere(_._2 < 0)
        if (pf == -1) {
          c(mf) = r.findLast(_._2 > 0).get
        } else {
          val ml = r.findLast(_._2 < 0)
          val pl = r.findLast(_._2 > 0)

          if (ml.isEmpty) {
            c(mf) = pl.get
          } else if (pl.isEmpty) {
            c(pf) = ml.get
          } else {
            if (c(pf)._1 * pl.get._1 < c(mf)._1 * ml.get._1) {
              c(pf) = ml.get
            } else {
              c(mf) = pl.get
            }
          }
        }
        println(c.map(_._1).reduceLeft(times))
      }
    }
  }
}


Measured memory_bytes: 77192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

		System.out.println(a*a-b);

	}
}


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

int main() {
  int N, Y, n = 0, y = 0;
  cin >> N >> Y;
  stringstream ss;
  string str;
  for (int i=0; i<=N; i++) {
    for (int j=0; j<=N-i; j++) {
      n = N - i - j;
      int sum = 10000*i + 5000*j + 1000*n;
      if (sum == Y) {
        ss << i << ' ' << j << ' ' << n;
        str = ss.str();
        goto OUT;
      } else {
        str = "-1 -1 -1";
      }
    }
  }
  OUT: cout << str << endl;
}


Measured memory_bytes: 384
list = []

N = int(input())

for i in range(N):
    list.append(int(input()))
    
size = 1

max = max(list)

loop = True

while loop:
    loop = False
    max_temp = 0
    for i in range(N):
        if list[i] < max and list[i] > max_temp:
            max_temp = list[i]
    if max_temp != 0:
        loop = True
        max = max_temp
        size += 1

print(size)
        

Measured memory_bytes: 3060
import java.util.*;

class Main{
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int temp = 0;
    int max = 0;
    for(int i = 0; i < n; i++) {
    	if(s.charAt(i) == 'I') {
    		temp++;
    		if(temp > max) {
    			max = temp;
    		}
    	} else {
    		temp--;
    	}
    }
    System.out.println(max);
}
}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int main(){
unsigned int a,b;
cin>>a>>b;
if(a <= 100 && b <= 1000 && b % 2 == 0){
   if (a >= 13){
    cout<<b<<endl;
   }
   else if (a >= 6 && a<=12){
       cout<<b*0.5<<endl;
   }
   else{
    cout<<"0"<<endl;
   }
}
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N,i;
    int count = 0;
    int count2 = 0;
    int countm = 0;
    int sa = 0;
    int min = 99999;
    int W[256];
    scanf("%d",&N);
    for (i = 0; i < 256; i++){
        W[i] = 0;
    }
    for (i = 0; i < N; i++){
        scanf("%d",&W[i]);
        countm = countm + W[i];
    }
    
    for (i = 0; i < N; i++){
        count2 = count2 + W[i];
        count = countm - count2;
        sa = count - count2;
        if (sa < 0){
            sa = sa * -1;
        }
        if (min > sa){
            min = sa;
        }
    }
    printf("%d",min);
}


Measured memory_bytes: 128