akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=924844033;
#define N 1055050

ll r,c,n;


vector<vector<pii>> v(110000,(vector<pii>)(0));
vector<vector<pii>> G(110000);
bool visited[110000];
vector<ll> temp(110000,INF);
vector<ll> minimum(110000,INF/2);
vector<ll> par(110000,-1);
vector<ll> d(110000,INF);
bool dfs(int x,ll y,int pr){
    //printf("dfs(%d,%d)\n",x,y);
    par[x]=pr;
    if(y==INF){
        temp[x]=0;
        y=minimum[x];
    }
    if(visited[x]) return y==temp[x];
    visited[x]=1;temp[x]=y;
    d[pr]=min(d[pr],temp[x]);
    bool flag=true;
    for(auto p:G[x]){
        flag&=dfs(p.first,p.second+temp[x],pr);
    }
    return flag;
}
bool search(){
    bool flag=true;
    rep2(i,1,c){
        if(visited[i])continue;
        flag&=dfs(i,INF,i);
    }
    return flag;
}
main(){
    r=in(),c=in(),n=in();
    rep(i,n){
        int rr=in(),cc=in();
        ll cost=in();
        v[rr].pb({cc,cost});
        minimum[cc]=min(minimum[cc],cost);
    }
    rep2(i,1,r){
        if(v[i].size()<2)continue;
        ll int std=v[i][0].second;
        ll int now=v[i][0].first;
        rep2(j,1,v[i].size()-1){
            G[now].pb({v[i][j].first,v[i][j].second-std});
            G[v[i][j].first].pb({now,std-v[i][j].second});
        }
    }
    bool flag=search();
    rep2(i,1,c){
        ll tt=minimum[i];
        tt=(tt+d[par[i]]-temp[i]);
        flag&=(tt>=0);
    }
    cout<<(flag?"Yes":"No");
}   


Measured memory_bytes: 14464
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define sortV(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
    int a,b,c,d,e,f;
    cin>>a>>b;
    int res=(a+b)/2;
    if(abs(a-res)==abs(b-res))cout<<res;
    else cout<<"IMPOSSIBLE\n";
   return 0;
}


Measured memory_bytes: 256
#!python3

import sys

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    S = list(input())
    Q = int(input())

    c0 = ord('a')
    smap = [1<<(i-c0) for i in range(c0, ord('z')+1)]

    T = [0]*N + [smap[ord(S[i])-c0] for i in range(N)]

    for i in range(N-1, 0, -1):
        i2 = i << 1
        T[i] = T[i2] | T[i2|1]

    ans = []
    #print(T)
    for cmd, i, j in zip(*[iter(sys.stdin.read().split())]*3):
        i = int(i) - 1
        if cmd == "1":
            if S[i] == j:
                continue

            S[i] = j
            i0 = N + i
            T[i0] = smap[ord(j)-c0]
            while i0 > 1:
                i0 = i0 >> 1
                T[i0] = T[i0+i0] | T[i0-~i0]
        elif cmd == "2":
            i += N
            j = int(j) + N

            d1 = 0
            while i < j:
                if i & 1:
                    d1 |= T[i]
                    i += 1
                if j & 1:
                    j -= 1
                    d1 |= T[j]

                i >>= 1; j >>=1

            ans.append(bin(d1).count('1'))

    print(*ans, sep="\n")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 33280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception{
        Deque<Integer> stack = new ArrayDeque<Integer>();
        int n;
        try (Scanner sc = new Scanner(System.in)){
            while(sc.hasNextInt()){
                n = sc.nextInt();
                if (n==0){
                    System.out.println(stack.pop());
                }else{
                    stack.push(n);
                }
            }
        }
    }
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    ll M; cin >> M;
    ll c[M], d[M];
    rep(i,M) cin >> d[i] >> c[i];
    ll res = 0;
    vector<int> N;
    rep(i,M){
        vector<ll> out;
        while(c[i] != 1){
            if(c[i]%2 == 1){
                out.push_back(d[i]);
                --c[i];
            }
            int d_tmp = d[i]+d[i];
            res += c[i]/2;
            if(d_tmp >= 10){
                d_tmp = 1 + (d_tmp%10);
                res += c[i]/2;
            }
            d[i] = d_tmp;
            c[i] /= 2;
        }
        for(int o: out){
            res++;
            int d_tmp = d[i]+o;
            if(d_tmp >= 10){
                res++;
                d_tmp = 1 + d_tmp % 10;
            }
            d[i] = d_tmp;
        }
        N.push_back(d[i]);
    }
    int m_tmp = -1;
    for(int m : N){
        if(m_tmp < 0){
            m_tmp = m;
        }else{
            res++;
            m_tmp = m_tmp + m;
            if(m_tmp >= 10){
                res++;
                m_tmp = 1 + (m_tmp % 10);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 7332
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
string s[ohara];
bool fl;
struct edge{int to,cost;};
ld bi=0.0;
ld a[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)cin>>a[i]>>s[i];
    rep(i,n){
        if(s[i]=="JPY")ans+=(ll)a[i];
        else bi=bi+a[i];
    }
    bi*=380000.0;
    bi=bi+(ld)ans;
    doublecout(bi);
    return 0;
}


Measured memory_bytes: 9344
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
#include<random>
using namespace std;
#define int long long
//#define double long double
//typedef unsigned long long ulong;
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 61ll)
#define mod 1000000007

int N;
string s;
bool flag[2][30300][10];

signed main(){
    cin >> N;
    cin >> s;
    for(int i = 0; i < N; i++){
        flag[0][i + 1][(char)s[i] - '0'] = true;
        if(i != N - 1){
            flag[1][N - 1 - i - 1][(char)s[N - 1 - i] - '0'] = true;
        }
    }
    for(int i = 1; i < N; i++){
        for(int j = 0; j < 10; j++){
            flag[0][i][j] |= flag[0][i - 1][j];
            flag[1][N - 1 - i][j] |= flag[1][N - 1 - i + 1][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                for(int r = 0; r < N; r++){
                    if(j == (char)s[r] - '0'){
                        if(flag[0][r][i] && flag[1][r][k]){
                            ans++;
                            break;
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

/*

*/

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int i, h, m, s;
    cin >> i;
    h= i / 3600;
    m= i / 60 - h * 60;
    s=  i % 60;
    cout << h << ":" << m << ":" << s << endl;
 
    return 0;
}



Measured memory_bytes: 3060
import java.util.Scanner;

class Problem {
    private int N;
    private String S;

    Problem() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        S = sc.next();
    }

    String solve() {
        int r = 0;
        int b = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == 'R') {
                r++;
            } else {
                b++;
            }
        }
        return r > b ? "Yes" : "No";
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
}


Measured memory_bytes: 23124
#import numpy as np
#n = int(input())
x = [int(i) for i in input().split()]
#s = list(input())
x.sort()
a = x[0]
b = x[1]
c = x[2]

k = b-a
j = c-b

cnt = 0
cnt += j

if k % 2 == 0:
    cnt += k/2
else:
    cnt += k/2 +1.5
print(int(cnt))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll n; cin >> n;
  vector<ll> s(n);
  REP(i,n) cin >> s[i];
  ll state = 0;
  ll ans = 0;
  ll cnt = 0;
IFOR(i,0,n-1){
    if(state>=0 && s[i]>=s[i+1]){
      cnt++;
      state = 1;
    }else{
      ans = max(ans,cnt);
      cnt = 0;
      state = 0;
    }
  }
  ans = max(cnt,ans);
  cout << ans << endl;
}

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

#define ll long long

int main()
{
    ll a, b, c, d;
    std::cin >> a >> b >> c >> d;

    ll max = -1000000000000000000;
    max = max > (a * c) ? max : (a*c);
    max = max > (a * d) ? max : (a*d);
    max = max > (b * c) ? max : (b*c);
    max = max > (b * d) ? max : (b*d);

    std::cout << max << std::endl;
}

Measured memory_bytes: 3664
n = int(input())

ba = []

for _ in range(n):
    a, b = map(int, input().split())
    ba.append([b, a])

ba.sort()
totala = 0
totalb = 0

flag = True
for b, a in ba:
    totala += a
    totalb = b
    if totala > totalb:
        flag = False
        break

print('Yes' if flag else 'No')

Measured memory_bytes: 35620
N,A,B = map(int,input().split())


sall = 0

for i in range(1,N+1):
    s =0
    x =i
    while x !=0:
        s =s + x%10
        x =x//10
    if A<=s<=B:
        sall =sall +i
        
print(sall)



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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N = 1e5 + 100;
int arr[N];
int n;
ll dp[N];

ll f(int id){
    if(id >= n) return (1LL<<40);
    if(id == n-1) return 0;
    if(dp[id] != -1) return dp[id];
    return dp[id] = min(f(id+1) + abs(arr[id+1] - arr[id]) , f(id+2) + abs(arr[id+2]- arr[id]));
}

int main()
{
    int i = 0, j = 0, cs = 0, in;
    cin>>n;
    for(i = 0; i < n; i++) cin>>arr[i];
    mem(dp,-1);
    cout << f(0) << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Coffee(void) {
	string S; cin >> S;
	cout << ((S[2] == S[3] && S[4] == S[5]) ? "Yes" : "No");
	return;
}

int main(void) {

	A_Coffee();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long i64;
const int P=1e9+7;
int n,m,k,dfn[55],low[55],tk=0,TK=0,ed[55];
struct edge{
	int to,nx;
}e[207];
int e0[55],ss[207],sp=0,ep=2,ans=1,C[207][207];
void mins(int&a,int b){if(a>b)a=b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int pw(int a,int n){
	int v=1;
	for(;n;n>>=1,a=i64(a)*a%P)if(n&1)v=i64(v)*a%P;
	return v;
}
void cal(int n,int m){
	if(n>m){
		ans=i64(ans)*k%P;
	}else if(n==m){
		int s=0;
		for(int i=1;i<=n;++i)s=(s+pw(k,gcd(i,n)))%P;
		ans=ans*i64(s)%P*pw(n,P-2)%P;
	}else{
		ans=i64(ans)*C[m+k-1][m]%P;
	}
}
int chk(int x){
	return ed[x]!=TK?ed[x]=TK,1:0;
}
void tj(int w,int pa){
	dfn[w]=low[w]=++tk;
	for(int i=e0[w];i;i=e[i].nx){
		int u=e[i].to;
		if(u==pa)continue;
		if(!dfn[u]){
			ss[++sp]=i;
			tj(u,w);
			mins(low[w],low[u]);
			if(low[u]>=dfn[w]){
				int c1=0,c2=0,z;
				++TK;
				do{
					z=ss[sp--];
					++c2;
					c1+=chk(e[z].to)+chk(e[z^1].to);
				}while(z!=i);
				cal(c1,c2);
			}
		}else{
			if(dfn[u]<dfn[w])ss[++sp]=i;
			mins(low[w],dfn[u]);
		}
	}
}
int main(){
	C[0][0]=1;
	for(int i=0;i<200;++i){
		for(int j=0;j<=i;++j){
			(C[i+1][j]+=C[i][j])%=P;
			(C[i+1][j+1]+=C[i][j])%=P;
		}
	}
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1,a,b;i<=m;++i){
		scanf("%d%d",&a,&b);
		e[ep]=(edge){b,e0[a]};e0[a]=ep++;
		e[ep]=(edge){a,e0[b]};e0[b]=ep++;
	}
	for(int i=1;i<=n;++i)if(!dfn[i])tj(i,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm> 
#include<queue>
using namespace std;
int main()
{
int n;
cin>>n;
int c[101],d[101],sum[101]={},ans=0;
for(int i=0;i<n;i++)
cin>>c[i];
for(int i=0;i<n;i++)
cin>>d[i];
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{if(j<=i)
 sum[i]+=c[j];
 if(j>=i)
 sum[i]+=d[j];}
for(int i=0;i<n;i++)
if(sum[i]>ans)
ans=sum[i]; 
cout<<ans;
system("pause"); 
return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  if (2*K-1<=N) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int R,Q,N;
  cin>>R>>Q>>N;
  VI X(N*2),Y(N*2);
  rep(i,N) cin>>X[i]>>Y[i]>>X[N+i]>>Y[N+i];
  VI S(N);
  vector<PII> A,B,C,D;
  rep(i,N*2){
    if(X[i]==0 or X[i]==R or Y[i]==0 or Y[i]==Q) S[i%N]++;
    if(X[i]>0 and Y[i]==0) A.pb(mp(X[i],i%N));
    else if(X[i]==R and Y[i]>0) B.pb(mp(Y[i],i%N));
    else if(X[i]<R and Y[i]==Q) C.pb(mp(-X[i],i%N));
    else if(X[i]==0 and Y[i]<Q) D.pb(mp(-Y[i],i%N));
  }
  sort(all(A));
  sort(all(B));
  sort(all(C));
  sort(all(D));
  stack<int> E;
  rep(i,A.size()){
    if(S[A[i].second]==2){
      if(!E.empty() and E.top()==A[i].second) E.pop();
      else E.push(A[i].second);
    }
  }
  rep(i,B.size()){
    if(S[B[i].second]==2){
      if(!E.empty() and E.top()==B[i].second) E.pop();
      else E.push(B[i].second);
    }
  }
  rep(i,C.size()){
    if(S[C[i].second]==2){
      if(!E.empty() and E.top()==C[i].second) E.pop();
      else E.push(C[i].second);
    }
  }
  rep(i,D.size()){
    if(S[D[i].second]==2){
      if(!E.empty() and E.top()==D[i].second) E.pop();
      else E.push(D[i].second);
    }
  }
  if(E.empty()) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



Measured memory_bytes: 4696
#include <stdio.h>
int a,b;
int fuck(int x)
{
	int m, i;
	int sum1 = 0;
	for(i = 1 ; i <= 5 ; i++)
	{
		if(x < 0)break;
		m = x % 10;
		sum1 = sum1 + m;
		x = x / 10;
	}
	if(sum1 <= b && sum1 >= a)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}
int main()
{
	int n,i;
	scanf("%d %d %d",&n, &a, &b);
	int sum = 0;
	int vis;
	for(i = 1 ; i <= n ; i++)
	{
		vis = fuck(i);
		if(vis == 1)
		{
			sum = sum + i;
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e18
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

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

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
	double x1 = 0;
	double y1 = 0;
	double x2 = 0;
	double y2 = 0;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	x2 = pow(x2-x1, 2);
	y2 = pow(y2-y1, 2);
	x2 = sqrt(x2+y2);
	printf("%.5lf", x2);
}



Measured memory_bytes: 2720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main() {
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(is,1<<h)rep(js,1<<w){
        int cnt = 0;
        rep(i,h)rep(j,w){
            if(is>>i&1) continue;  //i行目を消す
            if(js>>j&1) continue;  //j列目を消す
            if(s[i][j] == '#') cnt++;
        } 
        if(cnt == k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#define N 100

void display(int,int[N]);

int main(){
  int n,i,a[N];
  int j,v;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
display(n,a);
  for(i=1;i<=n-1;i++){
    v = a[i];
    j = i-1;
    while( (j>=0) && (a[j]>v) ){
      a[j+1] = a[j];
      j--;
      a[j+1] = v;
    }
    display(n,a);
  }

  return 0;
}

void display(int n,int a[N]){
  int i;

  for(i=0;i<n-1;i++){
    printf("%d ",a[i]);
  }
printf("%d\n",a[i]);
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int A, B, C;
  cin >> A >> B >> C;
  int K;
  cin >> K;
  if (K <= A) {
    cout << K << endl;
  } else if (A < K && K <= A + B) {
    cout << A << endl;
  } else {
    cout << A - (K - A - B) << endl;
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

vector<int> G[MAX_N];
int dp[MAX_N];

void dfs(int u){
    vi vec;
    rep(i,len(G[u])){
        dfs(G[u][i]);
        vec.pb(dp[G[u][i]]);
    }
    sort(all(vec));
    int mx = 0;
    rep(i,len(vec)){
        mx = max(mx+1,vec[i]+1);
    }
    dp[u] = mx;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int a;
        cin >> a;
        G[a-1].pb(i+1);
    }
    dfs(0);
    cout << dp[0] << "\n";
    return 0;
}


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

using namespace std;

const int INF = 1e9 + 9;

void up(long long & x, long long y)
{
    if(x > y)
        x = y;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 ///   freopen("input.txt", "r", stdin);

    int n, w;
    cin >> n >> w;

    const int MaxValue = n * 1e3;

    vector <long long> dp(MaxValue + 1, INF);

    dp[0] = 0;
    for(int i = 1; i <= n; ++i)
    {
        int a, b;
        cin >> a >> b;

        for(int i = MaxValue; i >= b; --i)
            up(dp[i], dp[i - b] + a);
    }

    for(int i = MaxValue; i >= 0; --i)
        if(dp[i] <= w)
        {
            cout << i << '\n';
            break;
        }

    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
     
int main(){
   int n,i,j,gun[100001],kin[100001],mg,mgi,mg2,mgi2,mk,mki,mk2,mki2;
    
   scanf("%d",&n);
   for (i=0;i<=100000;i++) gun[i]=kin[i]=0;
   for (i=0;i<n;i++) {
     scanf("%d",&j);
     if (i%2==0) gun[j]++;
     else        kin[j]++;
   }

   mg=mg2=-1;
   for (i=1;i<=100000;i++)
      if (mg<gun[i]) {
         mg2=mg;mgi2=mgi;mg=gun[i];mgi=i;
      } else if (mg2<gun[i]) {
         mg2=gun[i];mgi2=i;
      }

   mk=mk2=-1;
   for (i=1;i<=100000;i++)
      if (mk<kin[i]) {
         mk2=mk;mki2=mki;mk=kin[i];mki=i;
      } else if (mk2<kin[i]) {
         mk2=kin[i];mki2=i;
      }

   if (mki!=mgi) printf("%d\n",n-mk-mg);
   else if (mk+mg2>mk2+mg) printf("%d\n",n-mk-mg2);
   else printf("%d\n",n-mk2-mg);
   return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<ll> A;
    for (int i = 0; i < N; ++i)
    {
        ll temp;
        cin >> temp;
        A.push_back(temp);
    }
    for (int i = 0; i < N; ++i)
    {
        if (A[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    for (int i = 0; i < N; ++i)
    {
        if (A[i] <= 1000000000000000000 / ans)
        {
            ans *= A[i];
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4292
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NM = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, M) = (NM[0], NM[1]);

        int Combination(int n, int r)
        {
            var a = 1;

            for (int i = n; i > (n - r); i--)
                a *= i;
            for (int i = 1; i <= r; i++)
                a /= i;

            return a;
        }

        var ans = 0;

        if (2 <= N)
            ans += Combination(N, 2);
        if (2 <= M)
            ans += Combination(M, 2);

        WriteLine(ans);
    }
}


Measured memory_bytes: 28148
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int sum(int x) {
	string z = to_string(x);
	int len = z.length();
	int csum = 0;
	for (int i = 0; i < len; i++) {
		csum += z[i] - '0';
	}
	return csum;
}
int main() {
	int n; cin >> n; int mi = (int)MOD;
	for (int i = 1; i <= n/2; i++) {
		mi = min(mi, sum(i) + sum(n - i));
	}
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 256
S=input()
l=len(S)

ls=[i for i in range(1,l)]
    
sa=[]
for i in range(len(S)):sa+=[S[i],'']
sa=sa[:-1]

import copy
import itertools as it
ans=0
for i in range(l):
 for j in it.combinations(ls, i):
    sx=copy.copy(sa)
    for k in j:sx[2*k-1]='+'
    ans+=eval(''.join(sx))
print(ans)

Measured memory_bytes: 9244
from itertools import permutations

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

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

road = [[float("inf")]*N for _ in range(N)]

for i in range(M):
    a, b, c = map(int, input().split())
    road[a-1][b-1] = c
    road[b-1][a-1] = c

for j in range(N):
    road[j][j] = 0

road = warshall_floyd(road)

# print(road)
ans = float("inf")

for v in permutations(r, len(r)):
    # print("v", v)
    tmp = 0
    for i in range(len(r)-1):
        tmp += road[v[i]-1][v[i+1]-1]
    # print(tmp)
    ans = min(ans, tmp)

print(ans)

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


#define P pair<ll, ll>
const int N_MAX = pow(10,5)+10;
struct edge { ll to; ll cost; };
vector<edge> adj[N_MAX], radj[N_MAX];

ll d[N_MAX];
ll N, M, T;

void dijkstra(ll s) {
  priority_queue<P, vector<P>, greater<P>> q;
  fill_n(d, N, LLINF); d[s] = 0; q.push(P(0, s));
  while (!q.empty()) {
    P p = q.top(); q.pop();
    ll v = p.second;
    if (d[v] < p.first) continue;
    for (auto e: adj[v]) {
      if (d[e.to] > d[v]+e.cost) {
        d[e.to] = d[v]+e.cost;
        q.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  cin >> N >> M;
  rep(i,M) {
    int L, R, C; cin >> L >> R >> C; L--; R--;
    edge tmp = {R, C};
    adj[L].push_back(tmp);
  }
  rep(i,N-1) adj[i+1].push_back((edge){i, 0});
  dijkstra(0);
  ll result = (d[N-1]!=LLINF) ? d[N-1] : -1;
  // rep(i,N) cout << d[i] << " "; cout << endl;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 11772
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

vector<int> eratosthenes(const int &n) {
  vector<int> v(n);
  v[0] = v[1] = false;
  loop(i, 2, v.size()) v[i] = true;
  for (int i = 2; i * i < n; i++) {
    if (v[i]) {
      for (int j = i * 2; j < n; j += i) {
        v[j] = false;
      }
    }
  }
  return v;
}

void solve() {
  int n;
  while (cin >> n, n) {
    vi v = eratosthenes(n + 1);
    vi w;
    rep(i, v.size()) if (v[i]) w.pb(i);
    reverse(all(w));
    loop(i, 1, w.size()) {
      if (w[i - 1] == w[i] + 2) {
        cout << w[i] << ' ' << w[i - 1] << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int a[200001];
int b[200001];
vector<int>G[200001];
LL C[200011];
LL rC[200011];
LL MOD=1e9+7;
LL chose(LL n, LL x){
	LL ans=C[n];
	ans*=rC[x];
	ans%=MOD;
	ans*=rC[n-x];
	ans%=MOD;
	return ans;
}
LL reverse(LL x){
	LL temp=MOD-2;
	LL now=x;
	LL ans=1;
	while(temp!=0){
		if(temp%2==1){
			ans*=now;
			ans%=MOD;
		}
		now*=now;
		now%=MOD;
		temp/=2;
	}
	return ans;
}

void init(){
	C[0]=1;
	C[1]=1;
	REP(i,200011){
		if(i==0)continue;
		C[i]=C[i-1]*i;
		C[i]%=MOD;
	}
	REP(i,200011){
		rC[i]=reverse(C[i]);
	}
}
LL d[200011];
LL size[200011];
LL dfs(int x,int p){
	/*if(G[x].size()==1){
		d[x]=1;
		size[x]=1;
		return 1;
	}*/
	LL ans=1;
	LL temp=0;
	REP(i,G[x].size()){
		if(G[x][i]!=p){
			dfs(G[x][i],x);
			ans*=d[G[x][i]];//下のdp値
			ans%=MOD;
			LL aa=size[G[x][i]];
			temp+=aa;//下のサイズ
			ans*=rC[aa];
			ans%=MOD;
		}
	}
	ans*=C[temp];
	ans%=MOD;
	d[x]=ans;
	size[x]=temp+1;
	return d[x];
}

LL answer[200011];
LL dfs2(int x, int p,LL vv, LL ss){
	//cout<<x<<" "<<p<<" "<<vv<<" "<<ss<<endl;
	LL ans=C[N-1];
	ans*=vv;
	ans%=MOD;
	ans*=rC[ss];
	ans%=MOD;
	REP(i,G[x].size()){
		if(G[x][i]!=p){
			ans*=rC[size[G[x][i]]];
			ans%=MOD;
			ans*=d[G[x][i]];
			ans%=MOD;
		}
	}
	answer[x]=ans;
	REP(i,G[x].size()){
		if(G[x][i]!=p){
			LL temp=ans;
			temp*=reverse(d[G[x][i]]);
			temp%=MOD;
			temp*=reverse(chose(N-1,size[G[x][i]]));
			temp%=MOD;
			dfs2(G[x][i],x,temp,N-size[G[x][i]]);
		}
	}
}

int main(){
	cin>>N;
	REP(i,N-1){
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	init();
	dfs(0,-1);
	dfs2(0,-1,1,0);
	/*REP(i,N){
		cout<<d[i]<<endl;
	}
	cout<<endl;*/
	REP(i,N){
		cout<<answer[i]<<endl;
	}
}

Measured memory_bytes: 23284
import java.util.Scanner;


public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //System.out.print("入力してください > ");
        //int    x = Integer.parseInt(scanner.nextLine());
        //int n = Integer.parseInt(scanner.nextLine());
        String d = scanner.nextLine();
        
        if(d.equals("SUN")) System.out.println(7);
        if(d.equals("MON")) System.out.println(6);
        if(d.equals("TUE")) System.out.println(5);
        if(d.equals("WED")) System.out.println(4);
        if(d.equals("THU")) System.out.println(3);
        if(d.equals("FRI")) System.out.println(2);
        if(d.equals("SAT")) System.out.println(1);
                
        
        // Scannerクラスのインスタンスをクローズ
        scanner.close();
    }
}

Measured memory_bytes: 21716
def solve():
    X = int(input())
    while len(prime_factorize(X)) != 1:
        X += 1
    print(X)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if __name__ == '__main__':
    solve()


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

int main() {
  int x, y;
  cin >> x >> y;
  if (y % 2 != 0 || y / 2 - x < 0 || 2 * x - y / 2 < 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	
	public static void main(String... ac) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt(), m = sc.nextInt(), x = sc.nextInt();
		
		int cnt = 0;
		
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			if (a < x) cnt++;
		}
		
		System.out.println(Math.min(cnt, m - cnt));
		
	}
	
}

Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define INF (1<<29)
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  int n,a,b;
  scanf("%d %d %d",&n, &a, &b);
  int res = 0;
  for(int i = 1 ;i <= n; i++){
    int c = 0, t = i;
    for (int j = 0; j < 5; j++){
        c += t%10;
        t = t/10;
    }
    if (a <= c && c <= b){
      res += i;
    }
  }
  printf("%d\n",res);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(a-x)<abs(b-x)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}



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

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int times = (A - 1) / D + 1;
  cout << ((B * times >= C)? "Yes" : "No") << '\n';
  return 0;
}

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

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

int sieve[1000001];
bool F[1000001] = {};
int g = -1;
bool setwise = true;

int main(){
 rep(i,1000001) sieve[i]=i;
 for(int i=2; i<=1000; i++){
  if(sieve[i] != i) continue;
  for(int j=i*i; j<=1000000; j+=i)
   sieve[j] = i;
 }

 int N; scanf("%d",&N);
 rep(i,N){
  int a; scanf("%d",&a);
  if(g==-1) g=a; else g=gcd(g,a);
  while(a!=1){
   int p = sieve[a];
   if(F[p]) setwise=false;
   F[p]=true;
   while(sieve[a]==p) a/=p;
  }
 }

 if(setwise) printf("pairwise coprime\n");
 else if(g==1) printf("setwise coprime\n");
 else printf("not coprime\n");

 return 0;
}

Measured memory_bytes: 8640
<?php
$ans=0;
$roop = fgets(STDIN);

$num = fgets(STDIN);
$array = explode(" ",$num);

for($j=0;$j<=$roop;$j++)
if($array[$j]%2!=0 && ($j+1)%2!=0){
    $ans++;
}
echo $ans."\n";

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int cnt = 0;
  rep(i, 3) {
    char c;
    cin >> c;
    cnt += c == '1';
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e18;
const int inf=2e9;
const ll MOD=1000000007;

int main(){
    int check[110000];
    rep(i,110000)check[i]=1;
    check[0]=0;check[1]=0;
    set<int> prime;
    rep(i,110000){
        if(check[i]==1){
            prime.insert(i);
            int p=i;
            while(p<=110000){
                check[p]=0;
                p+=i;
            }
        }
    }
    int N;cin>>N;
    cout<<*lower_bound(prime.begin(),prime.end(),N)<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int a[114514];
int main(){
	int s,d,f;
	cin>>s;
	cin>>d>>f;
	int iwa=0;
	for(int i=0;i<s;i++){cin>>a[i];}
	for(int i=0;i<s;i++){
		iwa+=(d-1)/a[i]+1;
	}
	cout<<f+iwa<<endl;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];
    ll ans = 0;
    REP(i, N)
    {
        ll num = a[i];
        while(num % 2 == 0)
        {
            ans++;
            num /= 2;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

// Solve when the interval [a, b] contains no ><
// -> It has form <<<<<<>>>>>>>
ll solve(const string& str, int a, int b) {
	int x = 0;
	int y = 0;
	for (int i = a; i <= b; ++i) {
		if (str[i] == '<') ++x;
		else ++y;
	}
	// Middle element: max(x, y)
	ll res = max(x, y);

	// Left side: 1 + 2 + ... + x-1
	res += (ll)x * (x-1) / 2;
	
	// Right side: 1 + 2 + ... + y-1
	res += (ll)y * (y-1) / 2;

	return res;
}

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

	string str;
	cin >> str;
	int n = str.size();

	// If we have ><, we want zero in the middle
	// Divide and conquer on occurrences of ><

	ll sum = 0;
	int p = 0;
	for (int i = 0; i+1 < n; ++i) {
		if (str[i] == '>' && str[i+1] == '<') {
			sum += solve(str, p, i);
			p = i+1;
		}
	}
	sum += solve(str, p, n-1);

	cout << sum << '\n';
}


Measured memory_bytes: 1172
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

#include <bits/stdc++.h>
using namespace std;

#define forn(i, a, n) for (int i = (a); i < (int)n; i++)
#define fora(x, arr) for (auto &x : arr)
#define sz(x) (int)x.size()
using Matrix = std::vector<vector<int>>; 
using ll = long long;

// benq
const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;

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


    int n, mw; 
    cin >> n >> mw;

	vector<ll> values (n+7), ws(n+7);
	vector<ll> dp(10e5+7);

    for (int i = 0; i < n; i++) {
    	cin >> ws[i] >> values[i];
    }

    for (int i = 0; i < n; i++) {
    	for (int j = mw-ws[i]; j >=0; --j) {
    		dp[j+ws[i]] = max(dp[j] + values[i], dp[j+ws[i]]);
    	}
    }

   
    cout << dp[mw];
    
    return 0;
}	

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

#define int long long

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

        int ans = 0;
        for(int i = 1; i <= 10000; i++) {
                int x = floor(i * 0.08);
                int y = floor(i * 0.10);
                if(x == a && y == b) {
                        cout << i << endl;
                        return 0;
                }
        }

        cout << -1 << endl;
        return 0;
}

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

int main(){
	long n;
	cin >> n;
	vector<long> a(n,0),b(n,0);
	
	for(long i=0;i<n;i++){
		cin >> a[i];
		b[a[i]-1]=i+1;
	}
	
	for(long i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2432
a, b, c = io.read():match("(%d+) (%d+) (%d+)")
 a, b, c = tonumber(a), tonumber(b), tonumber(c)
 z = math.min(a, c)
 a = a - z
 c = c - z
 z = math.min(b, c)
 b = b - z
 io.write(a, " ", b, "\n")

Measured memory_bytes: 760
#include <cstdio>
#include <string>
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    printf("%d\n", n*(n+1)/2);
}

Measured memory_bytes: 256
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define pii pair<int,int>
#define MOD 1000000007
#define int long long
using namespace std;
#define s second
#define f first
int32_t main()
{
    fastio;
    int n;
    cin>>n;
    int A[n];
    bool flag=false;
    int ans = 1, temp = 1, mx = 1e18;
    for(auto& x:A)
    {
      cin>>x;
      if( x == 0 )
        flag = true;
    }
    if( flag )
    {
        cout<<'0';
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        ans*=A[i];
        if(ans>mx or ans < temp  )
        {
            ans=-1;
            break;
        }
        temp = ans;
    }
    cout<<ans;
}

Measured memory_bytes: 4428
program OE1I
    implicit none
    integer(8)::N,M,i
    integer(8)::result=1

    read(5,*)N,M

    if(abs(N-M)>1)then
        print'(i0)',0
    else
        do i=1,N
            result=result*i
            if(result>1000000007)then
                result=mod(result,1000000007)
            end if
        end do

        do i=1,M
            result=result*i
            if(result>1000000007)then
                result=mod(result,1000000007)
            end if
        end do

        if(N==M)then
            result=result*2
        end if

        result=mod(result,1000000007)

        print'(i0)',result
    end if

end program OE1I

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


	public class Main {
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			int[] x = new int[n];
			int[] y = new int[n];
			
			for(int i=0;i<n;i++) {
				x[i]=sc.nextInt();
				y[i] = x[i];
			}
			
			Arrays.sort(y);
			
			int a = y[n/2-1];
			int b = y[n/2];
			
			
			for(int i=0;i<n;i++) {
				if(x[i]<=a) {
					System.out.println(b);
				}else {
					System.out.println(a);
				}
			}
			
		}
		
	}


Measured memory_bytes: 93828
from collections import deque


r, p = map(int, input().split())
graph = [[] for _ in range(r)]

for x in range(p):
    x1, x2 = map(int, input().split())
    graph[x1-1].append(x2-1)
    graph[x2-1].append(x1-1)

q = [0]
res = [-1]*r
res[0] = 0
while q:
    l = q.pop(0)
    for x in graph[l]:
        if res[x] == -1:
            res[x] = l
            q.append(x)
if -1 in res[1:]:
    print("No")
    exit()
print("Yes")
for x in res[1:]:
    print(x+1)

Measured memory_bytes: 34948