akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a,b;
    scanf("%c %c",&a,&b);
    if(a>b)
        cout<<">"<<endl;
    else if(a<b)
        cout<<"<"<<endl;
    else
        cout<<"="<<endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
S=[list(input()) for i in range(N)]
def issym(IL):
    for i in range(N):
        for j in range(i+1,N):
            if IL[i][j]!=IL[j][i]:
                return False
    return True
def changelist(A,B):
    T=[["" for i in range(N)] for j in range(N)]
    for i in range(N):
        for j in range(N):
            T[i][j]=S[(i+A)%N][(j+B)%N]
    return T
ans=0
for i in range(N):
    L=changelist(i,0)
    if issym(L):
        ans+=N
print(ans)


Measured memory_bytes: 137736
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int N[6], K, d[9], ans[6], sz;
string s;
bool dd[10] = {};
bool boo = 0;

bool solve(int i, int j) {
	if (i == s.size()) return true;
	for (; j < 10; j++) {
		if (!dd[j] && N[i] <= j) {
			ans[i] = j;
			if (N[i] < j)
				boo = 1;
			if (solve(i + 1, 0)) return true;
		}
		if (!dd[j] && i && boo) {
			ans[i] = j;
			if (solve(i + 1, 0)) return true;
		}
	}
	return false;
}
int main() {
	cin >> s;
	cin >> K;
	for (int i = 0; i < s.size(); i++) {
		N[i] = s[i] - '0';
	}
	for (int i = 0; i < K; i++) {
		cin >> d[i];
		dd[d[i]] = 1;
	}
	sz = s.size();
	if (!solve(0, 0)) {
		for (int i = 1; i < 10; i++)
			if (!dd[i]) {
				ans[s.size()] = i;
				break;
			}
		for (int i = 0; i < s.size(); i++) {
			for (int j = 0; j < 10; j++) {
				if (!dd[j]) {
					ans[i] = j;
					break;
				}
			}
		}
		sz++;
	}
	if (s.size() != sz)
		cout << ans[s.size()];
	for (int i = 0; i < s.size(); i++)
		cout << ans[i];
	cout << endl;
}


/*2232 9
0 1 3 4 5 6  9 7 8
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << (a+b>=c?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int n,a[21],b2[21],c[21],ans=LONG_MAX;
void bt(int i,int r,int b)
{
    //cout<<i<<" "<<r<<" "<<b<<'\n';
    if(r>n/2+n%2||b>n/2)return;
    if(i>n&&b==n/2)
    {
        vector<PII> red,blue;
        for(int j=1;j<=n;j++)
            if(j&1)
            {
                if(c[j]==0)red.pb({a[j],j});
                if(c[j]==1)blue.pb({b2[j],j});
            }
            else
            {
                if(c[j]==0)red.pb({b2[j],j});
                if(c[j]==1)blue.pb({a[j],j});
            }
        sort(all(red),greater<PII>());
        sort(all(blue),greater<PII>());
        int cur=-1,pos[30],val[30];
        for(int i=1;i<=n;i++)
        {
            if(i&1)
            {
                if(red.back().fi<cur)return;
                cur=red.back().fi;
                pos[i]=red.back().se;
                red.pop_back();
            }
            else
            {
                if(blue.back().fi<cur)return;
                cur=blue.back().fi;
                pos[i]=blue.back().se;
                blue.pop_back();
            }
        }
        for(int i=1;i<=n;i++)val[i]=i;
        int res=0,id;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                if(pos[j]==i)
                {
                   //cout<<val[j]<<'\n';
                   res+=max(0LL,val[j]-i);
                   id=j;
                }
            }
            for(int j=id;j>1;j--)pos[j]=pos[j-1];
        }
        //for(int i=1;i<=n;i++)cout<<pos[i]<<" ";cout<<'\n';
        //cout<<res<<'\n';
        ans=min(ans,res);
        return;
    }
    else
    {
        c[i]=0;
        bt(i+1,r+1,b);
        c[i]=1;
        bt(i+1,r,b+1);
    }
}
void solve()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b2[i];
    bt(1,0,0);
    if(ans==LONG_MAX)cout<<-1;
    else cout<<ans;
}
int32_t main()
{
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    //freopen("XORQUERY.inp","r",stdin);
    //freopen("XORQUERY.out","w",stdout);
    //int test;cin>>test;while(test--)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int m1,d1,m2,d2;
	scanf("%d%d%d%d",&m1,&d1,&m2,&d2);
	if(m1!=m2) printf("1\n");
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 256
//112
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include <vector>
using namespace std;

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



}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n+1);rep(i,n)cin>>a[i+1];
  int cnt = 0;
  for(int i = n;i >= 1;--i){
    for(int j = 2;i*j <= n;++j){
      a[i]=(a[i]+a[i*j])%2;
    }
    cnt+=a[i];
  }
  print(cnt);
  rep(i,n+1){
    if(!i)continue;
    if(a[i])cout<<i<<' ';
  }
  cout<<endl;
  return 0;
} 

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
 
int main(){
  int a, b, c, d, e, k;
  scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);
  
  if ((e-a) > k) {
    printf(":(");
  } else {
    printf("Yay!");
  }
  return 0;
}

Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

bool func(int a, int b, string&s) {
	if (a < b) {
		if (s[b - a-1] == '0')return true;
		return false;
	}
	else {
		if (s[a - b-1] == '0')return false;
		return true;
	}
}

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

	int N;
	cin >> N;
	string s;
	cin >> s;
	vector<int>v(1<<N);
	for (auto &i : v)cin >> i;
	vector<vector<int>>tapi(N, vector<int>(1 << N));
	for (int i = 0; i < 1 << N; i++) {
	//	cout << v[i] << " " << v[(i + 1) % (1 << N)] << endl;
		if (func(v[i], v[(i + 1) % (1 << N)], s)) {
			tapi[0][i] = v[i];
		}
		else {
			tapi[0][i] = v[(i + 1) % (1 << N)];
		}
	}
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < 1 << N; j++) {
			if (func(tapi[i - 1][j], tapi[i - 1][(j + (1 << i)) % (1 << N)], s)) {
				tapi[i][j] = tapi[i - 1][j];
			}
			else {
				tapi[i][j] = tapi[i - 1][(j + (1 << i)) % (1 << N)];
			}
		}
	}
	for (auto i : tapi.back())cout << i << endl;
}


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

int main(){
  string str;
  vector<int> flag;
  getline(cin,str);
  string a = "apple", p = "peach";

  string::size_type a_p(str.find(a));
  flag.push_back(a_p);

  while(a_p != string::npos){
    str.replace(a_p, a.size(), p);
    a_p = str.find(a, a_p + a.size());
	flag.push_back(a_p);
  }

  string::size_type p_p(str.find(p));
  vector<int>::iterator check = find(flag.begin(),flag.end(),p_p);

  while(p_p != string::npos){
    if(check == flag.end()){
	  str.replace(p_p, p.size(), a);
	}
    p_p = str.find(p, p_p + p.size());
	check=find(flag.begin(),flag.end(),p_p);
  }

  cout << str << endl;

  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    string s;
    int n;
    cin >> n >> s;
    FOR(i, s.length())
        s[i] = ((s[i]-'A')+n)%26 + 'A';
    cout << s << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#define int long long 
#define mod 1000000007
using namespace std;

signed main(){
//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;cin>>n;
int ans = n-1;
for(int i = 2;i<n;i++)
 if(n%i == 0) ans+=n/i,ans--;
 else ans+=n/i;

cout<<ans<<endl;


}





Measured memory_bytes: 3632
#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>;
const int INF=1001001001;
int main(){
   int n,m,x;
   cin>>n>>m>>x;
   vector<int> c(n);
   int a[12][12];
   rep(i,n){
      cin>>c[i];
      rep(j,m) cin>>a[i][j];
   }
   int ans=INF;
   rep(s,1<<n){
      int cost=0;
      vector<int> d(m);
      rep(i,n){
         //sのiビット目が1であるときのみ
         if(s>>i&1){
            cost+=c[i];
            rep(j,m) d[j]+=a[i][j];
         }
      }
      bool ok=true;
      rep(j,m){
         //一つでも超えてないとだめ
         if(d[j]<x) ok=false;
      }
      if(ok) ans=min(ans,cost);
   }
   //目標を達成できないとき
   if(ans==INF) cout<<-1<<endl;
   else cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3632
# coding: utf-8
 
a=list(map(int,input().split()))
#読み込み
N = a[0]
M = a[1]
 
b=list(map(int,input().split()))
#総得票数
Sum_vote = sum(b)
list.sort(b, reverse=True)

if b[M-1] < (Sum_vote /( 4 * M)):
    print("No")
else :
    print("Yes")

Measured memory_bytes: 3064
rcards = dict()
bcards = dict()
N = int(input())
for i in range(0, N):
    s = input()
    if s not in bcards.keys():
        bcards[s] = 0
    bcards[s] += 1
M = int(input())
for i in range(0, M):
    s = input()
    if s not in rcards.keys():
        rcards[s] = 0
    rcards[s] += 1
ans = int()
for s in bcards.keys():
    tmp = bcards[s]
    if s in rcards.keys():
        tmp -= rcards[s]
    if ans < tmp:
        ans = tmp
print(ans)


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> list=new ArrayList<>();
        for(int i=0;i<5;i++){
            list.add(sc.nextInt());
        }
        System.out.println(list.indexOf(0)+1);
    }
}

Measured memory_bytes: 35604
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc151/tasks/abc151_c
N, M = read_ints()
is_ac = [False] * N
n_wa = [0] * N
for _ in ra(M):
    p, S = read().split()
    p = int(p) - 1
    if is_ac[p]:  # すでにACしてたら何もしない
        continue
    if S == 'WA':
        n_wa[p] += 1
    else:
        is_ac[p] = True
n_pena = 0
for ac, n in zip(is_ac, n_wa):
    if ac:
        n_pena += n

print(sum(is_ac), n_pena)


Measured memory_bytes: 42204
#include <iostream>

using namespace std;

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

int main() {
    int n,k;
    cin >> n >> k;
    long GCD;
    cin >> GCD;
    long _max = GCD;
    bool f = k == GCD;
    for (int i=1; i<n; i++) {
        long a;
        cin >> a;
        f = f || k==a;
        GCD = gcd(GCD, a);
        _max = max(_max, a);
    }


    if (f || (k%GCD==0 && k <= _max)) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int n,a,b,c;
  ll dp[3][2];
  dp[0][0]=0;
  dp[1][0]=0;
  dp[2][0]=0;
  cin >> n;
  REP(i,n){
    cin >> a >> b >> c;
    dp[0][1]=max(dp[1][0]+a,dp[2][0]+a);
    dp[1][1]=max(dp[0][0]+b,dp[2][0]+b);
    dp[2][1]=max(dp[0][0]+c,dp[1][0]+c);
    dp[0][0]=dp[0][1];
    dp[1][0]=dp[1][1];
    dp[2][0]=dp[2][1];
  }
 	cout << max(max(dp[0][0],dp[1][0]),max(dp[1][0],dp[2][0])) <<endl;
    return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

#define v(T) vector<T>
#define vv(T) v(v(T))

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

const int MX = 3005;
int dp[MX][MX];

int main() {
    string s,t;
    cin >> s >> t;
    rep(i,sz(s))rep(j,sz(t)) {
        dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
        if (s[i]==t[j]) maxs(dp[i+1][j+1], dp[i][j]+1);
    }
    int i = sz(s), j = sz(t);
    string ans = "";
    while(i+j) {
        int x = dp[i][j];
        if (i && dp[i-1][j] == x) --i;
        else if (j && dp[i][j-1] == x) --j;
        else {
            --i; --j;
            ans += s[i];
        }
    }
    reverse(all(ans));
    cout << ans << endl;
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int count = 0;
  for(int i = 0; i < S.size()/2; i++){
    if(S[i] != S[S.size()-i-1]) count++;
  }
  cout << count << endl;
}


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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' '; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n;
	vector<tuple<ll,int,int>> chk;
	REP(i,n) {
    	s = to_string(i+1);
    	chk.push_back(make_tuple(i+1,s.front()-'0',s.back()-'0' ));
    }
	vi arr(100,0);
	ll a, b;
	REP(i,10) {
      FOR(j,i,10) {
      	cnt = 0;
        a = 0; b = 0;
        if (i == j) {
        	cnt += count_if(ALL(chk),[&](tuple<ll,int,int> x){
              return (get<1>(x) == i && get<2>(x) == j);
            });
        	ans += cnt*cnt;
        	//dbg(cnt);
        } else {
            a += count_if(ALL(chk),[&](tuple<ll,int,int> x){
              return (get<1>(x) == i && get<2>(x) == j);
            });
        	b += count_if(ALL(chk),[&](tuple<ll,int,int> x){
              return (get<1>(x) == j && get<2>(x) == i);
            });
        	ans += a*b;
        	ans += b*a;
        }
        //dbg(get<2>(chk[i*10+j]));
        //ans += cnt;
        //ans += cnt*cnt;
      }
      //dbg('|');
    }
    cout << ans << endl;
}


Measured memory_bytes: 6512
def main():
    a = input()
    if a == 'A' or a == 'B' or a == 'C' or a == 'D' or a == 'E' or a == 'F' or a == 'G' or a == 'H' or a == 'I' or a == 'J' or a == 'K' or a == 'L' or a == 'N' or a == 'M' or a == 'O' or a == 'P' or a == 'Q' or a == 'R' or a == 'S' or a == 'T' or a == 'U' or a == 'V' or a == 'W' or a == 'H' or a == 'Y' or a == 'Z':
        print('A')
    else:
        print('a')


if __name__ == '__main__':
    main()



Measured memory_bytes: 61792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b; cin >> a >> b;
    rep(i,max(a,b)) {
        cout << min(a,b);
    }
    cout << endl;


    return 0;
}

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


int main(){
    long long N;
    cin >> N;
    string res = "";
    while(N>0){
        N--;
        res += (char)('a'+ (N%26));
        N/=26;
    }

    reverse(res.begin(),res.end());
    cout << res << endl;
}

Measured memory_bytes: 3620
s=int(input())
ss=[s]
n=s
for i in range(2,10**6):
  if n%2==0:
    n=n/2
    if n in ss:
        print(i)
        quit()
    ss.append(n)
  else:
    n=3*n+1
    if n in ss:
        print(i)
        quit()
    ss.append(n)

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

using namespace std;

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

int n;
int imos[86400];

void solve() {
    rep(i, n) {
        int s[3];
        int t[3];
        scanf("%d:%d:%d", &s[0], &s[1], &s[2]);
        scanf("%d:%d:%d", &t[0], &t[1], &t[2]);

        // hh:mm:ss を 秒に変換
        int S = s[2] + 60 * (s[1] + s[0] * 60);
        int T = t[2] + 60 * (t[1] + t[0] * 60);
        
        // 入る時間に +1
        imos[S]++;

        // 出る時間に -1
        imos[T]--;

        // ナイーブな実装 (写経しなくて良い)
        // for(int j = S; j <= T; j++) imos[j]++;
    }

    // 累積和を計算する
    rep(i, 86400) if(i) imos[i] += imos[i-1];

    int ans = 0;
    rep(i, 86400) ans = max(ans, imos[i]);

    cout << ans << endl;
}

int main() {
    // こう書くとn==0のときにwhileループが停止する
    while(cin >> n, n) {
        rep(i, 86400) imos[i] = 0;
        solve();
    }
}


Measured memory_bytes: 3476
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll cnt[2][202020];

int main(){
    int n;
    cin>>n;
    ll a[n+1];
    rep(i,n)cin>>a[i];
    rep(j,2){
        vector<pint> st;
        st.push_back({inf,0});
        rep(i,n-1){
            int ret=0;
            ll res=a[i];
            while(a[i+1]>res){
                res*=4;
                ++ret;
            }
            cnt[j][i+2]=cnt[j][i+1];
            while(ret){
                cnt[j][i+2]+=2*(i+1-st.back().second);
                if(--st.back().first==0){
                    st.pop_back();
                }
                --ret;
            }
            res=a[i+1];
            while(4*res<a[i]){
                res*=4;
                ++ret;
            }
            if(ret)st.push_back({ret,i+1});
        }
        reverse(a,a+n);
    }
     ll ans=longinf;
     rep(i,n+1){
         ans=min(ans,cnt[0][i]+cnt[1][n-i]+i);
     }
     cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

ll calc(vector<ll> ar) {
    int n = ar.size();
    ll rs = 0;
    for(int i = 1; i < n; i++) {
        rs += abs(ar[i] - ar[i - 1]);
    }
    return rs;
}

int main()
{
    int n; cin >> n;
    deque<ll> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a.begin(), a.end());

    ll nax = 0;

    {
        deque<ll> deq = a;
        vector<ll> ar(n);
        for(int i = 1; i < n - 1; i++) {
            if(i & 1)ar[i] = deq.back(), deq.pop_back();
            else ar[i] = deq.front(), deq.pop_front();
        }
        ar[0] = deq.front();
        ar[n - 1] = deq.back();
        nax = max(nax, calc(ar));
    }

    {
        deque<ll> deq = a;
        vector<ll> ar(n);
        for(int i = 1; i < n - 1; i++) {
            if(i % 2 == 0)ar[i] = deq.back(), deq.pop_back();
            else ar[i] = deq.front(), deq.pop_front();
        }
        ar[0] = deq.front();
        ar[n - 1] = deq.back();
        nax = max(nax, calc(ar));
    }
    cout << nax << endl;

}

Measured memory_bytes: 3408
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, L = LI()

    ans = (2 * L + N - 1) * N // 2
    if 0 <= L:
        ans -= L
    elif L + N <= 0:
        ans -= L + N - 1

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9976
n = gets.to_i
n.times do
  ukv = gets.split.map(&:to_i)
  ukv.shift; ukv.shift
  vs = ukv
  ans = Array.new(n){ 0 }
  vs.each do | v |
    ans[v-1] = 1
  end
  puts ans.join(' ')
end



Measured memory_bytes: 6936
#include <stdio.h>
/*
int main(void)
{
    int x,y,tmp;
   do{       
	scanf("%d %d\n", &x,&y);
        
        if(x==0 && y==0){          
		 break;   
        }             
	    if(x > y){           
		    tmp=y; 
		    y=x;          
		    x=tmp;          
		 }      
	 printf("%d %d\n", x,y);   
	}while(x != 0 && y != 0);        
	
	 return 0;
}
*/
int main()
{
    int x,y,tmp;
    while(1) {
        scanf("%d %d\n", &x,&y);
        if(x==0 && y==0){
            break;
        }
        if(x >y){
            tmp=y;
            y=x;
            x=tmp;
        }
        printf("%d %d\n",x,y);
    }
    return 0;
}



Measured memory_bytes: 2056
#include<iostream>
#include<cstring>
using namespace std;
int a[100010];
int b[100010];
int main()
{
	int n,i;
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	cin>>n;
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<n;i++)
	{
		b[a[i]+1]+=1;
		b[a[i]]+=1;
		b[a[i]+2]+=1;
	}
	int minn=-1;
	for(i=0;i<100010;i++)
		{
			if(b[i]>minn)
				minn=b[i];
		}
		cout<<minn;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

const int maxn = 55;
ll n , a[maxn] , dp[maxn][maxn][2700] , av;

ll calc(int x , int num , int have)
{
	if(x == n)
	{
		if(!num) return num;
		if(have % num != 0) return 0;
		ll avg = have / num;
		if(avg == av) return 1;
		else return 0;
	}
	if(dp[x][num][have] != -1) return dp[x][num][have];
	ll take = calc(x + 1 , num + 1 , have + a[x]);
	ll dont = calc(x + 1 , num , have);
	return dp[x][num][have] = dont + take;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(NULL);
	memset(dp,-1,sizeof(dp));
	cin >> n >> av;
	for(int i=0;i<n;i++) cin >> a[i];
	cout << calc(0 , 0 , 0);
}

Measured memory_bytes: 64128
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

ll powll(ll n,ll x){
    ll a=1;
    rep(i,x) a*=n;
    return a; 
}

int main(){
    string a;
    cin>>a;
    ll n=a.size();
    ll count=0;
    vvll d(26);
    vll num(n*2-2,0);
    rep(i,n) d[a[i]-'a'].push_back(i);
    rep(i,26){
        count-=(d[i].size()-1)*d[i].size()/2;
    }
    ll beki=0;
    repi(i,1,n*2-2){
        if(i%2==0){
            if(n<i) beki=n-1-i/2;
            else beki=i/2; 
        }else{
            if(n<i) beki=n-1-i/2;
            else beki=i/2+1;
        }
        count+=beki;
    }
    if(count==0) count++;
    if(a.size()==2&&a[0]!=a[1]) count=2;
    cout<<count<<endl;
}


Measured memory_bytes: 6516
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    int all_c = max(X, Y) * 2 * C;
    int else_is_c;
    if(Y >= X)
        else_is_c = X * 2 * C + (Y - X) * B;
    else
        else_is_c = Y * 2 * C + (X - Y) * A;
    int a_b = A * X + B * Y;

    int ans = min({all_c, else_is_c, a_b});

    cout << ans << endl;

    return 0;
}

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

int x[15000][15000],n,q,r,b;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> q >> r;
		for (int j = 0; j < r; j++) {
			cin >> b;
			x[i][b] = true;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n; j++) {
			if (j) { cout << ' '; }
			cout << x[i][j+1];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 5396
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	cout<<fixed<<setprecision(12);
	int n,k;
	cin>>n>>k;
	double ans=0.0;
	for(int i=1;i<=n;++i) {
		int cnt=0;
		int j=i;
		while(j<k) cnt++, j*=2;

		ans+=1.0/n*pow(1.0/2.0, cnt);
	}
	cout<<ans<<"\n";

	return 0;
}


Measured memory_bytes: 4288
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

bool cmp(const vector<ll> &a, const vector<ll> &b){
    return a[0] < b[0];
}

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

    vector<vector<ll>> m(n, vector<ll>(2));
    for (int i = 0; i < n; i++){
        cin >> m[i][0] >> m[i][1];
    }
    sort(m.begin(), m.end(), cmp);

    vector<ll> x(n);
    vector<ll> h(n);
    for (int i = 0; i < n; i++){
        x[i] = m[i][0];
        h[i] = m[i][1];
    }

    ll k;
    ll ans = 0;
    vector<ll> v(n + 1, 0);
    for (int i = 0; i < n; i++){
        v[i + 1] += v[i];
        ll hh = h[i] - v[i + 1];
        if (hh <= 0) continue;
        k = (hh + a - 1) / a;
        ans += k;
        int idx = upper_bound(x.begin() + i, x.end(), x[i] + 2 * d) - x.begin();
        v[i + 1] += k * a;
        v[idx + 1] -= k * a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.length();
  int z = 0, cur = 0;
  for (auto& c : s) {
    if (c == '1') {
      cur++;
    } else {
      cur--;
    }
    z = max(z, cur);
  }

  auto f = [&](const int& m) {
    vector<int> v;
    v.push_back(0);
    string t = s;
    for (int i = 0; i < n; i++) {
      if (s[i] == '1') {
        v.push_back(v.back() + 1);
      } else {
        if (s[i] == '?') {
          t[i] = '0';
        }
        v.push_back(v.back() - 1);
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      v[i] = max(v[i], v[i + 1]);
    }
    int add = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '?') {
        if (v[i + 1] + add + 2 <= m) {
          add += 2;
          t[i] = '1';
        }
      }
    }
    v.clear();
    v.push_back(0);
    for (auto& c : t) {
      if (c == '1') {
        v.push_back(v.back() + 1);
      } else {
        v.push_back(v.back() - 1);
      }
    }
    return *min_element(v.begin(), v.end());
  };

  cout << min(z - f(z), (z + 1) - f(z + 1)) << '\n';
  return 0;
}


Measured memory_bytes: 13304
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;


int main(){

    ll N, W;
    cin >> N >> W;
    vector< vector<ll> > item(4);

    ll w0;
    for(int i = 0; i < N; i++){
        ll w, v;
        cin >> w >> v;
        if(i == 0) w0 = w;
        item[ (w-w0) ].push_back(v); 
    }

    for(int i = 0; i < 4; i++){
        sort(rall(item[i]) );
    }

    
    vector< vector<ll> > val(4);
    
    for(int i = 0; i < 4; i++){
        val[i].resize(item[i].size() + 1);
        val[i][0] = 0;
        for(int j = 0; j < item[i].size(); j++){
            val[i][j+1] = val[i][j];
            val[i][j+1] += item[i][j];
        }
    }

    /*
    for(int i = 0; i < 4; i++){
        for(int j = 0; j <= item[i].size(); j++){
            cout << val[i][j] ;
        }
        cout << endl;
    }
    */

    ll ans = 0;
    for(ll i1 = 0; i1 <= item[0].size(); i1++){
        for(ll i2 = 0; i2 <= item[1].size(); i2++){
            for(ll i3 = 0; i3 <= item[2].size(); i3++){
                for(ll i4 = 0; i4 <= item[3].size(); i4++ ){

                    if(i1 + i2 + i3 + i4> N ) continue;

                    if(i1 * w0 + i2 * (w0 + 1) + i3 * (w0 + 2) + i4 * (w0 + 3) > W ) continue;
                    ll tmp = val[0][i1] + val[1][i2] + val[2][i3] + val[3][i4];
                    ans = max(ans, tmp);

                }
            }
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef vector<int> vi;
typedef long long int ll;
vector<vector<int>> adj;

class TaskA {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, a, b; in>>n>>a>>b;
		if((b-a+1)&1) out<<"Alice";
		else out<<"Borys";

	}
    void inG(int m, istream& in){ int u,v; adj = vector<vi>(200005);f(i, m){ in>>u>>v; adj[u].push_back(v); adj[v].push_back(u); }}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	TaskA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

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

  int N; cin >> N;
  vector<int> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  vector<int> B(N); for (ll i = 0; i < N; i++) cin >> B[i];
  vector<int> C(N);
  for (int i = 0; i < N; i++) {
    C[i] = A[i] - B[i];
  }
  sort(C.begin(), C.end());

  vector<int> D = C;
  int l = 0, r = N - 1;
  while (C[l] < 0) {
    if (C[r] <= 0) {
      cout << "-1" << '\n';
      return 0;
    } else if (-C[l] == C[r]) {
      C[l] = 0; l++;
      C[r] = 0; r--;
    } else if (-C[l] < C[r]) {
      C[r] = C[r] + C[l];
      C[l] = 0; l++;
    } else {
      C[l] = C[l] + C[r];
      C[r] = 0; r--;
    }
  }

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (C[i] != D[i]) ans++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1792
program main
	implicit none
	integer(8):: N,i,j,t,B,k
	read *, N
    !read(*,*) (A(i), i = 1, N)
    
	i=N/100
	j=(N-i*100)/10
	k=N-i*100-j*10
	if(k==2)print'(a)',"hon"
	if(k==4)print'(a)',"hon"
	if(k==5)print'(a)',"hon"
	if(k==7)print'(a)',"hon"
	if(k==9)print'(a)',"hon"
	if(k==0)print'(a)',"pon"
	if(k==1)print'(a)',"pon"
	if(k==6)print'(a)',"pon"
	if(k==8)print'(a)',"pon"
	if(k==3)print'(a)',"bon"
	
end program main

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

int N;
int A[111111];
int Q;
int B[111111],C[111111];

int cnt[111111];

signed main(){
	cin>>N;
	rep(i,N)cin>>A[i];

	int ans=0;
	rep(i,N){
		cnt[A[i]]++;
		ans+=A[i];
	}

	cin>>Q;
	while(Q--){
		int b,c;
		cin>>b>>c;
		ans+=cnt[b]*(c-b);
		cnt[c]+=cnt[b];
		cnt[b]=0;
		cout<<ans<<endl;
	}

	return 0;
}


Measured memory_bytes: 5160
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

struct edge{
	ll cost;int a,b;
};

int parent[(int)1e5+3];
int find(int a){
	if(parent[a] == a){
		return a;
	}else{
		return parent[a] = find(parent[a]);
	}
}
void unite(int a, int b){
	int pa = find(a);
	int pb = find(b);
	if(pa == pb) return;
	parent[pa] = pb;
	return;
}


vector<edge> G;

int main(void){
	int n;
	cin>>n;
	rep(i,n){
		parent[i] = i;
	}
	int x,y;
	vector<pair<int,int>> xs,ys;
	rep(i,n){
		cin>>x>>y;
		xs.push_back(pair<int,int>{x,i});ys.push_back(pair<int,int>{y,i});
	}
	sort(all(xs));
	sort(all(ys));
	rep(i,n-1){
		G.push_back(edge{xs[i+1].first - xs[i].first, xs[i].second, xs[i+1].second});
		G.push_back(edge{ys[i+1].first - ys[i].first, ys[i].second, ys[i+1].second});
	}
	sort(all(G),[](const edge& a, const edge& b){return a.cost < b.cost;});
	int count = 0;
	ll ans = 0;
	rep(i,G.size()){
		ll cost = G[i].cost;
		int a = G[i].a;
		int b = G[i].b;
		if(find(a) == find(b)){
			continue;
		}
		ans += cost;
		unite(a,b);
		count++;
		if(count == n-1) break;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8296
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;





int main()
{
    int64_t H, W;
    std::cin >> H >> W;

    boost::multi_array<char, 2> mat(boost::extents[H][W]);
    // '.'白, '#'黒

    int64_t initial_white = 0;
    for (auto p = mat.data(); p < (mat.origin() + mat.num_elements()); ++p) {
        std::cin >> *p;
        if (*p == '.') {
            ++initial_white;
        }
    }

    /** 幅優先探索
    距離書き込み版
    幅優先は最短距離を割り出せる。
    深さ優先は、別パスから来た方が近い可能性あり。
    https://qiita.com/nati-ueno/items/a789095aff0aec10d5d0
    */
    auto f = [&mat, H, W](auto y0, auto x0) -> int {
        using axis_t = decltype(x0);
        // using value_t = decltype(mat.data());

        std::queue<std::pair<axis_t, axis_t>> q;

        // setup initilal position
        q.push({y0, x0});

        // 距離計測初期条件 0か1かは問題による
        mat[y0][x0] = 1;

        while (!q.empty()) {

            axis_t y, x;

            std::tie(y, x) = q.front();
            q.pop();

            // 途中の終了条件
            if (x == W-1 && y == H-1) {
                return mat[y][x];
            }

            // 四方に動くパターン
            constexpr std::pair<int, int> dirs4[] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};
            // 八方
            //constexpr std::pair<int, int> dirs8[] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1},
            //                                         {1, 1}, {-1, -1}, {-1, 1}, {1, -1}};
            for (auto dir: dirs4) {
                auto xx = x + dir.second;
                auto yy = y + dir.first;
                if (0 <= xx && xx < W && 0 <= yy && yy < H) {
                    if (mat[yy][xx] == '.' /* 移動可能条件 */) {
                        q.push({yy, xx});
                        // 移動済みマーク兼距離記録
                        mat[yy][xx] = mat[y][x] + 1;
                    }
                }
            }
        } // while()

        // 終了条件にマッチせず探索終了
        return -1;
    };

    if (f(0, 0) == -1) {
        std::cout << -1 << std::endl;
    }
    else {
        std::cout << initial_white - mat[H-1][W-1] << std::endl;
    }

    return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define umap unordered_map
#define uset unordered_set
#define pq priority_queue

const ll MOD = 1e9 + 7;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	string s; cin >> s;
	ll tot = 0;
	for(const char& c : s){
		tot += c - '0';
	}
	if (tot % 9 == 0) {
		cout << "Yes";
	}else{
		cout << "No";
	}
}

Measured memory_bytes: 3748
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define MOD 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=3e2+5;
ll n , cnt[4] ;
ld dp[maxN][maxN][maxN];

// dp[three][two][one][zero] where three is the no of 3 and two is the no of 2 ......
// three=two=one=zero=n=300 (300^4)
// zero=n-one-two - three
// dp[three][two][one]
// if i pich three dp[three-1][two+1][one] 
// if i pick two dp[three][two-1][one+1]
// if i pick one dp[three][two][one-1];
// dp[three][two][one]=(three/n)*dp[three-1][two+1][one] + (two/n)dp[three][two-1][one+1] + 
					// one/n * dp[three][two][one-1] + zero/n * dp[three][two][one];
// dp[three][two][one](1-zero/n)=(three/n)*dp[three-1][two+1][one] + (two/n)dp[three][two-1][one+1] + 
					// one/n * dp[three][two][one-1]
// dp[three][two][one]==((three/n)*dp[three-1][two+1][one] + (two/n)dp[three][two-1][one+1] + 
					// one/n * dp[three][two][one-1])/(1-zero/n)


void solve(){
	cin>>n ;
	for(ll i=0 , x ;i<n ;i++){
		cin>> x ; cnt[x]++;
	}
	dp[0][0][0]=0;
	for(ll three=0 ;three<=n ; three++){
		for(ll two=0 ; two<=n ; two++){
			for(ll one=0 ; one<=n ; one++){
				ll zero=n-three-two-one;
				if(zero==n)continue;
				if(three+two+one>n)continue;
				ld value=1;
				//  picking three
				if(three>0)value+=(1.0*three/n)*dp[three-1][two+1][one];
				if(two>0)value+=(1.0*two/n)*dp[three][two-1][one+1];
				if(one>0)value+=(1.0*one/n)*dp[three][two][one-1];

				dp[three][two][one]=(value)/(1-1.0*zero/n);
			}
		}
	}

	ld ans=dp[cnt[3]][cnt[2]][cnt[1]];
	cout<<fixed<<setprecision(10);
	cout<<ans<<endl;

}

int main(){
	//mahakal();
	fast;
	ll t =1 ;
	//cin>> t ; 
	while(t--)solve();
	//cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}

Measured memory_bytes: 214808
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
int inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int k;
int x;

//inputします
void input() {
    cin >> k >> x;
}

//ライブラリ置き場

//main
int main() {
    input();
    if (500 * k >= x) {
        cout << "Yes" << endl;
        return 0;
    }
    else cout << "No" << endl;
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	int Min,Max;
	cin>>a>>b;
	Min=min(a,b);
	Max=max(a,b);
	for(int i =0;i<Max;i++)
		cout<<Min;
	cout<<'\n';
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,j,m,min,count=0;
	scanf("%d %d",&n,&min);
	for(i=1;i<n;i++)
	{
		scanf("%d",&m);
		if(m>min)
		{
			count++;
		}
		else min=m;
	}
	printf("%d",n-count);
	return 0;
}

Measured memory_bytes: 128