akhauriyash/Code-Regression huggingface dataset:
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int a, b;
    cin >> a >> b;
    if(a > 0){
        cout << "Positive";
    }else if(a <= 0 && b >= 0){
        cout << "Zero";
    }else{
        int len = abs(b) - abs(a) + 1;
        if(len & 1){
            cout << "Negative";
        }else{
            cout << "Positive";
        }
    }
    return 0;
}


Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INF 1<<29
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 



/*****************************************************************************/
signed main(void) {
	cin.tie(0); ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	if (abs(n - m) >= 2) {
		cout << 0;
		return 0;
	}
	if (n == m) {
		cout << (factorial(n)*factorial(m) * 2) % MOD;
	}
	else {
		cout << (factorial(n)*factorial(m)) % MOD;
	}
	return 0;
}

Measured memory_bytes: 256
def check_s(tmp1, tmp2, tmp3):
    S_min = 2 ** 50
    S_max = 0
    S_min = min(S_min, tmp1, tmp2, tmp3)
    S_max = max(S_max, tmp1, tmp2, tmp3)
    return S_max - S_min

if __name__ == "__main__":
    H,W = map(int, input().split())
    if (H > W):
        H,W = W,H
    if (H % 3 == 0 or W % 3 == 0):
        print (0)
        exit()

    result = 2 ** 50
    for x in range(1, W + 1):
        H1 = H // 2
        H2 = H - H1

        W1 = x
        W2 = W - W1

        W3 = W2 // 2
        W4 = W2 - W3

        tmp1 = W1 * H
        tmp2 = W3 * H
        tmp3 = W4 * H

        result = min(result, check_s(tmp1, tmp2, tmp3))
        tmp1 = W1 * H
        tmp2 = W2 * H1
        tmp3 = W2 * H2
        result = min(result, check_s(tmp1, tmp2, tmp3))

    for y in range(1,  H+ 1):
        H1 = y
        H2 = H - H1

        H3 = H2 // 2
        H4 = H3 - H2

        W1 = W // 2
        W2 = W - W1


        tmp1 = H1 * W
        tmp2 = H3 * W
        tmp3 = H4 * W

        result = min(result, check_s(tmp1, tmp2, tmp3))
        tmp1 = H1 * W
        tmp2 = H2 * W1
        tmp3 = H2 * W2
        result = min(result, check_s(tmp1, tmp2, tmp3))


    print (result)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin >> n;
    ll b[n-1];
    for(ll i = 0; i < n-1; i++)cin >> b[i];
    ll tot = b[0];

    for(ll i = 0; i < n-1; i++){
        tot += min(b[i],b[i+1]);
    }
    cout << tot << endl;



    return 0;
}


Measured memory_bytes: 256
using System;
//using System.Collections;
//using System.Collections.Generic;
using System.Linq;

namespace problem
{
  class Test
  {
    static void Main()
    {
        while (true){
            var a = (Console.ReadLine().Split().Select(int.Parse).ToArray());
            int x = a[0];
            int y = a[1];
            if (x == 0 && y == 0) break;
            if (x < y) Console.WriteLine("{0} {1}", x, y);
            else Console.WriteLine("{0} {1}", y, x);
        }
    }
  }
}


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

int main() {
  string S;
  cin >> S;

  int count = 0;
  bool ans  = true;
  if (S[0] != 'A')
    ans = false;
  for (int i = 1; i < S.size(); i++) {
    if (isupper(S[i])) {
      if (i == 1 || i == S.size() - 1 || S[i] != 'C')
        ans = false;
      else
        count++;
    }
  }
  if (count != 1)
    ans = false;
  if (ans)
    cout << "AC" << endl;
  else
    cout << "WA" << 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>;
 
struct L{
  int a,b,c;
  L(int a=0, int b=0, int c=0): a(a), b(b), c(c) {}
};

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


int main(){
  int n, m;
  cin >> n >> m;
  map<int, int> mpX,mpY;
  mpX[0]= 0;
  mpY[0] =0;
  
  vector<L> lh,lv;
  rep(i,n){
    int a,b,c;
    cin >>a>>b>>c;
    mpX[a]=0;
    mpX[b]=0;
    mpY[c]=0;
    lh.emplace_back(a,b,c);
  }
  rep(i,m){
    int a,b,c;
    cin >>c>>a>>b;
    mpY[a]=0;
    mpY[b]=0;
    mpX[c]=0;
    lv.emplace_back(a,b,c);
  }
  
  vector<int> xs,ys;

  for (auto& p: mpX){
    p.second=xs.size();
    xs.push_back(p.first);
  }
  for (auto& p: mpY){
    p.second=ys.size();
    ys.push_back(p.first);
  }
  int h =xs.size()*2;
  int w = ys.size()*2;
  
  vector<vector<int>> d(h,vector<int>(w));
  rep(i,n){
    int a =mpX[lh[i].a]*2;
    int b =mpX[lh[i].b]*2;
    int c =mpY[lh[i].c]*2;
    for (int x=a;x<=b; ++x) d[x][c]=-1;
  }
  rep(i,m){
    int a =mpY[lv[i].a]*2;
    int b =mpY[lv[i].b]*2;
    int c =mpX[lv[i].c]*2;
    for (int y=a;y<=b; ++y) d[c][y]=-1;
  }
  
  queue<P> q;
  int sx =mpX[0]*2, sy =mpY[0]*2;
  d[sx][sy]=1;
  q.emplace(sx,sy);
  while(!q.empty()){
    int x=q.front().first;
    int y=q.front().second;
    q.pop();
    rep(v,4){
      int nx=x+dx[v], ny =y+dy[v];
      if(nx<0 || nx>=h) continue;
      if(ny<0 || ny>=w) continue;
      if(d[nx][ny]!=0) continue;
       d[nx][ny]=1;
      q.emplace(nx,ny);
    }
  }
  
  ll ans=0;
  rep(x,h) rep(y,w){
    if (d[x][y]!=1) continue;
    if(x==0|| x==h-1|| y==0||y==w-1){
     cout <<"INF"<<endl;
     return 0;
    }
    if( (x%2)*(y%2)==0) continue;
    ll ex=xs[x/2+1]-xs[x/2];
    ll ey =ys[y/2+1]-ys[y/2];
    ans +=ex*ey;
  }
  cout <<ans <<endl;
  return 0;
}

Measured memory_bytes: 144496
import math
N = int(input())
XY = [[int(i) for i in input().split()] for i in range(N)]

sum_distance = 0
for i in range(N-1):
    for j in range(i, N):
        dist = (XY[i][0] - XY[j][0])**2 + (XY[i][1]-XY[j][1])**2
        dist = dist ** 0.5
        sum_distance += dist
        
ans = (sum_distance * math.factorial(N-1)*2) / math.factorial(N)
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;

int main() {
  ll N,M,ans;
  cin>>N>>M;
  if(N==1||M==1){
    ans=N*M-2;
  }
  else{
    ans=(N-2)*(M-2);
  }
  if(ans==-1){
    ans=1;
  }
  cout<<ans;
}

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

using namespace std;
typedef long long LL;

const int MAXN = 123456;
map<LL, int> mp;

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    LL ans = 0, presum = 0;
    mp[0] = 1;
    for (int i = 1; i <= N; i++) {
        int tmp;
        scanf("%d", &tmp);
        presum = (presum + tmp) % M;
        ans += mp[presum];
        mp[presum]++;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4224
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n,ans;
bool isP(ll n){
	if(n==1)return false;
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0)return false;
	}
	return true;
}
void solve(){
	cin>>n;
	while(!isP(n)){
		n++;
	} 
	cout<<n;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
class UnionFind :
    def __init__(self, size) :
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        return self.size[self.root(index)]

    def getComponent(self) :
        return self.component

N, M = map(int, input().split())
P = list(map(int, input().split()))

tree = UnionFind(N + 1)
for _ in range(M):
    fr, to = map(int, input().split())
    tree.union(fr, to)

ans = 0
for i, p in enumerate(P, start=1):
    if tree.isSameRoot(i, p):
        ans += 1

print(ans)

Measured memory_bytes: 14452
import java.util.*;

public class Main {    
    
  public static void main(String[] args) {
   
    Scanner sc = new Scanner(System.in);                  
                
    long N = sc.nextLong();
    long M = sc.nextLong();
    
    long result = 0;
    
    if(M >= 2*N){
       result = N + (M - 2*N)/4;
    }else{              
       result = M/2;
    }      
    
    System.out.println(result);
    
  }    
}

Measured memory_bytes: 21844
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=35;
int T[MAXN];
int n,m;
int main()
{
	int k,x;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) {
		scanf("%d",&k);
		for(int i=1;i<=k;i++) {
			scanf("%d",&x);
			T[x]++;
		}
	}
	int ans=0;
	for(int i=1;i<=m;i++)
		if(T[i]==n)
			ans++;
	printf("%d",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	const int mod = 1e9 + 7;
	int n; cin >> n;
	vi c(n), dp(n + 1);
	map<int, int> prev;
	rep(i, n) cin >> c[i];
	
	dp[n] = 1;
	
	for(int i = n - 1; i >= 0; i--){
		if(prev.count(c[i]) && prev[c[i]] != i + 1){
			dp[i] += dp[prev[c[i]]];
		}
		prev[c[i]] = i;
		(dp[i] += dp[i + 1]) %= mod;
	}
	cout << dp[0] << endl;
	return 0;
}

Measured memory_bytes: 11264
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n, a, b;
        n = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            int ans = 0;
            int tmp = 1;
            int num = i;
            for (int j = 0; j < 5; j++) {
                tmp *= 10;

                ans += (num % tmp) / (tmp / 10);
                num -= num % tmp;
            }
            if (ans >= a && ans <= b) {
//                System.out.println(i);
                sum += i;
            }
        }
        System.out.println(sum);

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    // Your code here!
    vector<string> YN{"NO","YES"};
    vector<string> yn{"No","Yes"};
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a==b?c:(a==c?b:a))<<endl;
}


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

int main()
{
  int n;
  cin >> n;
  int64_t ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 ==0 || i % 5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,n,ans,l,r,f,a[200005],b[200005];
    scanf("%d",&n);
    j=1;
    for(i=1;i<=n;i++)
        {scanf("%d",&a[i]);
         b[a[i]]=j;
         j=j+1;
         }
    l=1;
    ans=n;
    for(i=1;i<=n-1;i++)
    {
        if(b[i]<b[i+1])
        {
            l=l+1;

        }
        else
        {
            ans=min(ans,(n-l));
        l=1;
        }
    }
    ans=min(ans,(n-l));
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        final long bill = 2000000000;
        long pos[][] = new long [n][2];
        long neo_pos[][] = new long [n][2];
        long xMax = bill * -1, xMin = bill;
        long yMax = bill * -1, yMin = bill;

        for(int i = 0; i < n; i++){
            pos[i][0] = sc.nextInt();
            pos[i][1] = sc.nextInt();
            //xy座標から座標軸を45度回転させたx'y'座標に変換する
            //本来は√2で割らないといけないが整数計算で処理したいので行わない
            neo_pos[i][0] = pos[i][0] + pos[i][1];
            neo_pos[i][1] = pos[i][0] * -1 + pos[i][1];
            if(xMax < neo_pos[i][0]){
                xMax = neo_pos[i][0];
            }
            if(xMin > neo_pos[i][0]){
                xMin = neo_pos[i][0];
            }
            if(yMax < neo_pos[i][1]){
                yMax = neo_pos[i][1];
            }
            if(yMin > neo_pos[i][1]){
                yMin = neo_pos[i][1];
            }
        }
        //xMax xMin yMax yMinを確認
        //System.out.println("xMax=" + xMax + " xMin=" + xMin);
        //System.out.println("yMax=" + yMax + " yMin=" + yMin);
        
        long dist_x = xMax - xMin;
        long dist_y = yMax - yMin;
        if(dist_x > dist_y){
            System.out.println(dist_x);
        }else{
            System.out.println(dist_y);
        }
    }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> B(N+1);
    vector<int> A;
    B[0] = (int) MOD;
    B[N] = (int) MOD;
    rep(i, N-1) cin >> B[i+1];
    rep(i, N) {
        A.push_back(min(B[i], B[i+1]));
    }
    cout << accumulate(A.begin(), A.end(), 0) << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

#ifndef INT_MAX
#  define INT_MAX std::numeric_limits<int>().max()
#endif
#ifndef INT_MIN
#  define INT_MIN std::numeric_limits<int>().min()
#endif
#define LL_MAX std::numeric_limits<ll>().max()
#define LL_MIN std::numeric_limits<ll>().min()
#define INF LL_MAX

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
// 配列の初期化
#define ZERO(p) memset(p, 0, sizeof(p))
// 配列の初期化(-1)
#define MINUS(p) memset(p, 1, sizeof(p))

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int num = r * 100 + g * 10 + b;
    if(num % 4 == 0) { printf("YES\n"); }
    else { printf("NO\n"); }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define HASH 18014398241046527
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
template <typename T>
ll SIZEOF(T a){return (ll)a.size();}

ll dx[] = {1, 0, -1, 0};
ll dy[] = {0, 1, 0, -1};





void SOLVE(){
    char c;
    cin >> c;
    if(c<='z'&&c>='a'){
        cout << 'a';
    }
    else{
        cout << 'A';
    }
}

int main() {
	fastIO();
	// #ifndef ONLINE_JUDGE
    //     freopen("i.txt", "r", stdin);
    //     freopen("o.txt", "w", stdout);
	// #endif

    ll TC = 1;
    // cin >> TC;
    for(ll tc1=1; tc1<=TC; tc1++){
        // cout << "Case #" << tc1 << ": ";
        SOLVE();
    }
    printclock;
}

Measured memory_bytes: 3788
function Main(input){
	var xs = input.trim().split(' ').map(v=>parseInt(v,10));
    if(xs[0] * xs[1] % 2 != 0){
    console.log('Odd');
    }else{
    console.log('Even');
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 + (y1-y2)
y3 = y2 - (x1-x2)
x4 = x1 + (y1-y2)
y4 = y1 - (x1-x2)
lst = [x3, y3, x4, y4]
print(*lst)

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

int main(){  
  int n,c;
  cin >> n >> c;
  vector<int> w(n,0);
  vector<int> v(n,0);
  vector<vector<ll>> dp(110, vector<ll>(mx,0));
  rep(i,n){ cin >> w[i] >> v[i]; }
    
  rep(i,n){ rep(j,c){
    dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j]+v[i]);
    dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
  } }

  ll ans=0;
  rep(i,c){ ans = max(ans, dp[n][i+1]); }
  cout << ans << endl;
  return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main()
{
    int32 n;
    cin >> n;
    int32 cntB = 0, cntA = 0, cntBA = 0;
    int32 ans = 0;
    REP(i,n){
        string s;
        cin >> s;
        REP(j,s.size()-1){
            if(s[j] == 'A' && s[j+1] == 'B')ans++;
        }
        if(s[0] == 'B' && s.back() == 'A'){
            cntBA++;
        }else if(s[0] == 'B'){
            cntB++;
        }else if(s.back() == 'A'){
            cntA++;
        }
    }
    if(cntB == 0 && cntA == 0){
        ans += max<int32>(cntBA - 1, 0);
    }else if(cntB == 0 || cntA == 0){
        ans += cntBA;
    }else{
        ans += cntBA + 1;
        cntB--;cntA--;
        ans += min(cntB, cntA);
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int N,K;
    scanf("%lld%lld",&N,&K);

    long long int a,b,sum=0;

    for(long long int i=K; i<=N+1; i++)
    {
        sum +=i*(N-i+1)+1;
    }
    b=sum%(1000000007);
    printf("%lld",b);
}


Measured memory_bytes: 1724
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    //ラウンド開始時のポイント
    int K = sc.nextInt();
    //正解数
    int Q = sc.nextInt();
    int[] point = new int[N];
    for(int i=0; i<N; i++){
      point[i] = K - Q;
    }
    for(int i=0; i<Q; i++){
      int ansNum = sc.nextInt();
      point[ansNum - 1]++;
    }
    for(int i=0; i<N; i++){
      if(point[i]>0)System.out.println("Yes");
      else System.out.println("No");
    }
  }
}


Measured memory_bytes: 67612
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int par[200005];
int high[200005];
//n要素で初期化
void init(int n){
  for(int i=0; i<n; i++){
    par[i]=i;
    high[i]=0;
  }
}
//木の根を求める
int find(int x){
  if(par[x]==x){
    return x;
  }
  else{
    return par[x]=find(par[x]);
  }
}
 
//xとyの属する集合を併合
void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(high[x]<high[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(high[x]==high[y])high[x]++;
  }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
  return find(x)==find(y);
}
int main(){
  int n,m;
  cin>>n>>m;
  init(n+m);
  for(int i=0; i<n; i++){
    int k;
    cin>>k;
    for(int j=0; j<k; j++){
      int L;
      cin>>L;
      unite(i,n+L-1);
    }
  }
  bool flag=true;
  for(int i=0; i<n-1; i++){
    if(!same(i,i+1)){
      flag=false;
    }
  }
  cout<<((flag) ? "YES" : "NO" )<<endl;
}
      
  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    int64_t n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    Re(s);
    int64_t num=0;
    int64_t ans=0;
    vector<int> a(n+1);
    a[0]=0;
    //p=2,5の時は10が影響にはいってきちゃうから、特別なやり方を考える
    if(p==2){
        rep(i,n){
            if((s[i]-'0')%2==0){
                ans += (n-i);
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    if(p==5){
        rep(i,n){
            if((s[i]-'0')%5==0){
                ans += n-i;
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    rep(i,n){
        num=num+modpow(10,i,p)*(s[i]-'0')%p;
        num%=p;
        a[i+1]=num;
        //cout<<num<<endl;
    }
    vector<int64_t> cnt(p);
    rep(i,n+1){
        cnt[a[i]]++;
    }
    rep(i,p){
        ans += cnt[i]*(cnt[i]-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4452
n=int(input())
d={2:0}
if n==1: print(0);exit()
nc=n
while n%2==0:
    d[2]+=1
    n=n//2
for i in range(3,int(nc**0.5)+1,2):
    if n==1: break
    if n%i!=0:continue
    d[i]=0
    while n%i==0:
        d[i]+=1
        n=n//i
if n!=1: d[n]=1 
sm=0
for x in d:
    if d[x]==0: continue
    y=1
    ywork=3
    while ywork<=d[x]:
        y+=1
        ywork+=y+1
    sm+=y
print(sm)

Measured memory_bytes: 9492
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]

mi,ma=0,2000
com=list(combinations(range(n),2))

def dist(p,q):
    a,b=p
    c,d=q
    return math.sqrt((a-c)**2+(b-d)**2)

while ma-mi>10**(-9):
    half=(ma+mi)/2
    # print(ma,mi,half)
    lst=[]
    for co in com:
        a,b=co
        ax,ay=xy[a]
        bx,by=xy[b]
        kyori=dist(xy[a],xy[b])/2
        if kyori>half:
            mi=half
            break
        else:
            h=math.sqrt(half**2-kyori**2)
            tyuuten=((ax+bx)/2,(ay+by)/2)
            tmp=h/2/kyori
            lst.append((tyuuten[0]+(ay-by)*tmp,tyuuten[1]-(ax-bx)*tmp))
            lst.append((tyuuten[0]-(ay-by)*tmp,tyuuten[1]+(ax-bx)*tmp))
    else:
        for co in lst:
            bx,by=co
            flag=1
            for i in range(n):
                ax,ay=xy[i]
                if (ax-bx)**2+(ay-by)**2>half**2+9e-7:
                    flag=0
                    break
            if flag==1:
                ma=half
                break
        else:
            mi=half
print(ma)

Measured memory_bytes: 47720
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.sort()
y.sort()

for Z in range(X+1, Y+1):
    if (x[N-1] < Z) and (Z <= y[0]):
        print("No War")
        exit()
print("War")

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

int main(){
    
    int n;
    cin >> n;
    
    long int a[n];
    long int *p;
    p = a;
    long long int sum = 0;
    
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        sum += a[i];
    }
    
    cout << *min_element(p, p+n) << " " << *max_element(p, p+n) << " " << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3152
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll se=0;
ll sume(vector<int> a,int n){

}
int main(){
    string s;cin>>s;
    cout<<s.substr(0,4)<<' '<<s.substr(4,8)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    char c;
    cin >> c;
    
    if(c=='a' || c=='i' || c=='u' || c=='e' || c == 'o'){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
    
}


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


int main(){
  int64_t H,N,ans;
  cin >> H >> N;
  vector<pair<int64_t,int64_t>> X(N);
  vector<int64_t> dp(20001,100000000);
  dp.at(0)=0;
  for(int64_t i=0;i<N;i++){
    cin >> X.at(i).first >> X.at(i).second;
  }
  for(int64_t i=1;i<20001;i++){
    for(int64_t j=0;j<N;j++){
      if(X.at(j).first<=i){
        dp.at(i)=min(dp.at(i),dp.at(i-X.at(j).first)+X.at(j).second);
      }
    }
  }
  ans=dp.at(H);
  for(int64_t i=1;i<10001;i++){
    ans=min(ans,dp.at(i+H));
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>

int main()
{
	int n;
	int ans = 0;
	std::cin >> n;
	for (int i = 1; i <= n; i++)
	{
		if (std::to_string(i).length() % 2 == 1)
			++ans;
	}
	std::cout << ans << '\n';
	return 0;
}


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


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	for(int i = 1; ; i++) {
		int x;
		cin >> x;
		if(x == 0) break;
		cout << "Case " << i << ": " << x << "\n";
	}

	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

int main(int argc, char *argv[]){
    int N,M;
    std::cin >> N >> M;
    std::vector<int> job[M+1];
    int i, A, B;
    for(i=0; i<N; ++i){
        std::cin >> A >> B;
        if(A > M){continue;}
        job[A].emplace_back(B);
    }

    long int r=0;
    std::priority_queue<int> queue;
    for(i=0; i<=M; ++i){
        for(auto b : job[i]){
            queue.push(b);
        }
        if(queue.empty()){ continue; }
        r += queue.top();
        queue.pop();
    }
    std::cout << r << std::endl;
    return 0;
}


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

public class Main {

	private static Scanner in;

    private static int n;
    private static int[] a;
    private static Double[][][] dp;

    public static void main(String[] args) {
        in = new Scanner(System.in);
        n = in.nextInt();
        a = new int[n];

        for(int i=0; i<n; i++) a[i] = in.nextInt();

        dp = new Double[n+1][n+1][n+1];

        int one=0;
        int two=0;
        int three=0;

        for(int i=0; i<n; i++) {
            switch(a[i]) {
	            case 1: one++; break;
	            case 2: two++; break;
	            case 3: three++; break;
                default:
                    break;
            }
        }

        System.out.println(solve(one, two, three));

    }

    private static double solve(int one, int two, int three) {
        if (one<0 || two<0 || three<0) return 0;

        if (one+two+three==0) return 0;

        if (dp[one][two][three]!=null) return dp[one][two][three];

        double A = one*1.0/n*solve(one-1, two, three);
        double B = two*1.0/n*solve(one+1, two-1, three);
        double C = three*1.0/n*solve(one, two+1, three-1);

        return dp[one][two][three] = n*(1+A+B+C)/(one+two+three);

    }

}


Measured memory_bytes: 293888
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
long long i,p=0,r=0;
for(i=0;i<s.size();i++){
    if(i%2==0){
        if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
            p=1;break;
        }
        
    }else{
        if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
            r=1;break;
        }
    }
}if(p==1||r==1)
cout<<"No";
else
cout<<"Yes";

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
#include <cassert>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int L, E[82], dp[80][200][200];

int rec(int k, int e1, int e2) {
  assert(e1 < 200 && e2 < 200);
  if (k == L-2) return e2;
  int& ret = dp[k][e1][e2];
  if (ret >= 0) return ret;
  // れいきする
  if (e2) {
    ret = rec(k+1, e2 - 1, E[k+2] + e1);
  }
  // れいきしない
  ret = max(ret, rec(k+1, e2, E[k+2]));
  return ret;
}

int solve() {
  return rec(0, E[0], E[1]);
}

int main() {
  int N;
  scanf("%d", &N);
  while (N--) {
    scanf("%d", &L);
    rep(i,L) scanf("%d", E+i);
    memset(dp, -1, sizeof dp);
    if (L < 3) {
      printf("%d\n", E[L-1]);
      continue;
    }
    printf("%d\n", solve());
  }
  return 0;
}

Measured memory_bytes: 13700
#include<iostream>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

#define INF 1111111111

struct edge {
  int to, cost;
  edge(int _to, int _cost) {to = _to; cost=_cost;}
};
typedef pair<int,int> P;

int V;
vector<edge> G[105];
int d[105];

void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d + V + 1, INF);
  d[s] = 0;
  que.push(P(0, s));

  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i = 0;i < G[v].size(); i++){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
  }

}

int main(void){
  int k;
  int a, b, c, t;
  for( ; ; ){
    cin >> V >> k;
    if(V + k == 0) break;
    for(int i = 0;i <= V; i++) G[i].clear();
    for(int i = 0;i < k; i++){
      cin >> t >> a >> b;
      if(t){
	cin >> c;
	G[a].push_back(edge(b,c));
	G[b].push_back(edge(a,c));
      }
      else{
	dijkstra(a);
	if(d[b] == INF) cout << "-1" << endl;
	else cout << d[b] << endl;
      }
    }
  }
}


Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
        ret.push_back(i);
        if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){
    ll N; cin >> N;
    vll A(N+1);
    rep(i, 1, N+1){
        cin >> A[i];
    }
    vb ald(1000000, false);
    vll count(1000000, 0);
    ll c = 0;
    rep(i, 1, N+1){
        ald[A[i]] = true;
        count[A[i]]++;
    }
    rep(i, 1, N+1){
        vll t = divisor(A[i]);
        bool f = true;
        for(auto x: t){
            if(x == A[i]){
                continue;
            }
            if(ald[x]){
                f = false;
            }
        }
        if(f){
            if(count[A[i]] < 2){
                c++;
            }
        }
    }
    prt(c);
}


Measured memory_bytes: 12696
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<ll,ll>
#define vint vector<ll>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
ll a,b,A,B,C,D,re,tag;
void get(ll mid){
	a=A-mid/(re+1)*re-mid%(re+1);
	b=B-mid/(re+1);
}
signed main(){
	for(ll T=read();T--;){
		A=read(),B=read(),C=read(),D=read();
		re=max((ll)ceil((double)A/(B+1)),(ll)ceil((double)B/(A+1)));
		ll l=0,r=A+B;
		while(l<r){
			ll mid=l+r>>1;get(mid);
			if(b<=a*re)l=mid+1;
			else r=mid;
		}ll pos=l;get(pos);tag=pos+1+b-a*re;
		for(ll i=C;i<=D;i++){
			if(i<=pos){if(i%(re+1))cout<<'A';else cout<<'B';}
			else{if((i-tag)%(re+1))cout<<'B';else cout<<'A';}
		}cout<<'\n';
	}return signed();
}

Measured memory_bytes: 3748
#include<stdio.h>
int Search(int key, int A[], int n)
{
  int i;
  i = 0;
  A[n] = key;
  while(A[i] != key)
    {
      i++;
      if(i == n)
	{
	  return 0;
	}
    }
  return 1;
}

int main()
{
  int n, i, S[10000], q, key, sum = 0;
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      scanf("%d", &S[i]);
    }
  scanf("%d", &q);
  for(i = 0; i < q; i++)
    {
      scanf("%d", &key);
      if(Search(key, S, n))
	{
	  sum++;
	}
    }
  printf("%d\n", sum);
  return 0;
}




Measured memory_bytes: 2144
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    int n;
    cin >> n;
    char a[1000];
    char b[1000];
    cin >> a >> b;
    char c[2000];
    int i = 0;
    int k = 0;
    int k2 = 0;
	while(i < 2*n)
	{
		c[i++] = a[k++];
		c[i++] = b[k2++];
		
		
	}
    c[i] = '\0';

	cout << c << endl;
    return 0;


}


Measured memory_bytes: 256
n = int(input())
ans = "No"
num_list = sorted([ int(v) for v in input().split() ])

if n % 3 == 0:
    m = n // 3
    a, b, c = num_list[0], num_list[m], num_list[2*m]
    if len(set(num_list[:m])) == 1 and len(set(num_list[m:2*m])) == 1 and len(set(num_list[2*m:])) == 1:
        if a ^ b == c:
            ans = "Yes"
elif num_list == [0] * n:
        ans = "Yes"
print(ans)

Measured memory_bytes: 60784
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] p = new int[n];
		int yono = 0;
		for(int i = 0 ; i < n ; i++){
			p[i] = Integer.parseInt(sc.next());
			yono += p[i];
		}
		sc.close();
		Arrays.sort(p);
		ou.println(yono - p[n - 1] / 2);
		ou.flush();
	}
}

Measured memory_bytes: 35708
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n, h;
  cin >> h;
  cin >> n;
  int ch = 0;
  vector<int> A(n);
  for(int i=0; i<n; i++) {
    cin >> A[i];
}
  rep(i, n){
    if(h-A[i]<=0){
      ch = 1;
      cout << "Yes" << endl;
      break;
    }
    else h -= A[i];
  }
  if(ch==0) cout << "No" << endl;

} 

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String line = input.readLine();
		int n = Integer.parseInt(line);

		System.out.println((n % 2 == 0)?n:n*2);
	}
}


Measured memory_bytes: 21588
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using ar2 = array<ll, 2>;
constexpr ll INF = 1ll << 60;
int digit(char c) {
    return c - '0';
}

int main()
{
    string s;
    cin >> s;
    ll N = s.size();

    reverse(s.begin(), s.end());
    s += "0";
    vector<ar2> dp(N + 1);
    rep(i, N + 1)dp[i][0] = dp[i][1] = INF;
    dp[0][0] = 10 - digit(s[0]);
    dp[0][1] = digit(s[0]);

    REP(i, 1, N + 1) {
        dp[i][0] = min(
            dp[i - 1][0] + abs(digit(s[i]) + 1 - 10),
            dp[i - 1][1] + abs(digit(s[i]) - 10)
        );
        dp[i][1] = min(
            dp[i - 1][0] + digit(s[i]) + 1,
            dp[i - 1][1] + digit(s[i])
        );
    }
    cout << min(dp[N][1], dp[N - 1][1]) << endl;
    return 0;
}


Measured memory_bytes: 17028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n;
set <int> s;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        int d; cin>>d;
        s.insert(d);
    }
    cout<<s.size()<<newl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e5 + 7, M = 1e9 + 7;

int dp[N];
int qpow(int a, int b) {
	if(b == 0) return 1;
	int t = qpow(a, b/2);
	t = t * t % M;
	if(b & 1) return t * a % M;
	return t;
}

signed main()
{
	IO_OP;
	
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for(int i = k; i >= 1; i--) {
		dp[i] = qpow(k / i, n);
		for(int j = i * 2; j <= k; j += i)
			dp[i] = (dp[i] + M - dp[j]) % M;
		ans += dp[i] * i % M;
	}
	cout << ans % M << endl;
}





Measured memory_bytes: 4420
import sys
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
ans_flag = True
ans_flag2 = True
ans = [[False, False, False], [False, False, False], [False, False, False]]

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            ans[i][j] = True

for i in range(3):
    if ans[0][i] and ans[1][i] and ans[2][i]:
        print('Yes')
        sys.exit()
    if ans[i][0] and ans[i][1] and ans[i][2]:
        print('Yes')
        sys.exit()
    if not ans[i][i]:
        ans_flag = False
    if not ans[i][2-i]:
        ans_flag2 = False

if ans_flag or ans_flag2:
    print('Yes')
else:
    print('No')

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

int main(){
    ll N;
    std::cin >> N;
    //int i=1;
    ll SS = N;
    ll I, J;
    

    /*while(true){
        if(N%i == 0){
            int S = N/i - i;
            if(S < 0){
                break;
            }
            if(i==1){
                SS = S;
                I = i;
                J = N/i;
            }else if(S < SS){
                SS = S;
                I = i;
                J = N/i;
            }
        }
        i++;
    }*/
    int sqrN = sqrt(N);
    //std::cout << sqrN << std::endl;
    for(int i=1; i<=sqrN; i++){
        if(N%i == 0){
            //int S = N/i - i; 
            //std::cout << i << std::endl;         
            I = i;
            J = N/i;
            ll ans = I + J -2;
            if(SS > ans){
                SS = ans;
            }

        }
    }
    
    std::cout << SS << std::endl;
    return 0;
}

Measured memory_bytes: 256