akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll gcd(ll a, ll b){
  ll a1 = a, b1 = b;
  ll tmp;

  while(b1 != 0){
    tmp = b1;
    b1 = a1 % b1;
    a1 = tmp;
  }

  return a1;
}

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

int main(){
  ll N;
  cin >> N;
  vl T(N);
  rep(i, N) cin >> T[i];
  
  ll ans = T[0];

  rep(i, N) ans = lcm(ans, T[i]);

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


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,d[9][9];
  int i,j,k,y,t,s;
  scanf("%d",&n);
  for(k=0;k<n;k++){
    int c[9][9]={{0}};
    for(j=0;j<9;j++){
      for(i=0;i<9;i++){
	scanf("%d",&d[j][i]);
      }
    }
    for(i=0;i<9;i++){
      int w[10]={0};
      for(j=0;j<9;j++){
	w[d[i][j]]++;
      }
      for(j=0;j<9;j++){
	if(w[d[i][j]]>1){
	  c[i][j]=1;
	}
      }
    }
    for(i=0;i<9;i++){
      int w[10]={0};
      for(j=0;j<9;j++){
	w[d[j][i]]++;
      }
      for(j=0;j<9;j++){
	if(w[d[j][i]]>1){
	  c[j][i]=1;
	}
      }
    }
    for(i=0;i<9;i++){
      int w[10]={0};
      for(j=0;j<9;j++){
	w[d[((i/3)*3)+j/3][((i%3)*3)+j%3]]++;
      }
      for(j=0;j<9;j++){
	if(w[d[((i/3)*3)+j/3][((i%3)*3)+j%3]]>1){
	  c[((i/3)*3)+j/3][((i%3)*3)+j%3]=1;
	}
      }
    }
    if(k!=0)printf("\n");
    for(i=0;i<9;i++){
      for(j=0;j<9;j++){
	if(c[i][j]==1)printf("*");
	else          printf(" ");
	printf("%d",d[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i =0; i<N; i++){
    cin >> vec.at(i);
  }
  
  vector<int> con(N,3);
  
  for (int i=0; i<N; i++){
    if (vec.at(i)%2==0){
      con.at(i) = vec.at(i);
    }
  }
  
  for (int i=0; i<N;i++){
    if (con.at(i)%3 ==0 || con.at(i)%5 ==0){
    con.at(i)=0;
    }
  }
  string ans;
  vector<int> zero(N,0);
    
  
  if (con == zero){
     ans ="APPROVED";
  }
  else{
    ans =  "DENIED";
  }
  cout << ans << endl;
  
  return 0;
}
     


Measured memory_bytes: 256
class BinaryIndexedTree():
    def __init__(self, max_n):
        self.size = max_n + 1
        self.tree = [0] * self.size
        self.depth = self.size.bit_length()
 
    def initialize(self, seq):
        for i, x in enumerate(seq[1:], 1):
            self.tree[i] += x
            j = i + (i & (-i))
            if j < self.size:
                self.tree[j] += self.tree[i]
 
    def __repr__(self):
        return self.tree.__repr__()
 
    def get_sum(self, i):
        s = 0
        while i:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i < self.size:
            self.tree[i] += x
            i += i & -i
 
    def find_kth_element(self, k):
        x, sx = 0, 0
        dx = (1 << self.depth)
        for i in range(self.depth - 1, -1, -1):
            dx = (1 << i)
            if x + dx >= self.size:
                continue
            y = x + dx
            sy = sx + self.tree[y]
            if sy < k:
                x, sx = y, sy
        return x + 1
"""
n = 2*10**5
bit = BinaryIndexedTree(n) #サイズn
bit.add(1,1) #1スタート
"""


n,q = map(int,input().split())
c = [0]+list(map(int,input().split()))
query = [list(map(int,input().split()))+[i] for i in range(q)]
query.sort(key=lambda x:x[1])

memo = [0]*(n+1)
ans = [0]*q

bit = BinaryIndexedTree(n)
now = 0
for i in range(q):
    l,r,ind = query[i]
    for j in range(now+1,r+1):
        color = c[j]
        if memo[color] == 0:
            memo[color] = j
            bit.add(j,1)
        else:
            bit.add(memo[color],-1)
            bit.add(j,1)
            memo[color] = j
    now = r
    ans[ind] = bit.get_sum(r)-bit.get_sum(l-1)

for a in ans:
    print(a)

Measured memory_bytes: 244200
N,K=list(map(int,input().split()))
h=[int(input()) for i in range(N)]
 
h.sort()
 
m="a"
for i in range(N-K+1):
	if m=="a" or m>h[i+K-1]-h[i]: m=h[i+K-1]-h[i]
 
print(m)

Measured memory_bytes: 7384
//https://atcoder.jp/contests/dp/tasks/dp_l

#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  


#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long int ll;

const int precision = 16;
const int modulo =  1000000007; // 10^9 + 7
using ll = long long;
const double EPS = 1e-9;

pair<ll, ll> recSolve2(int l, int r, vector<int> & seq, bool player) {
	if(l > r) return {0,0};

	if(player == false) {  //taro

		auto fleft = recSolve2(l + 1, r, seq, true);
		auto fRight = recSolve2(l, r - 1, seq, true);

		if(seq[l] + fleft.first - fleft.second >
		seq[r] + fRight.first - fleft.second) {
			return {seq[l] + fleft.first, fleft.second};
		}  else {
			return {seq[r] + fRight.first, fRight.second};
		}
	} else {
		auto fleft = recSolve2(l + 1, r, seq, false);
		auto fRight = recSolve2(l, r - 1, seq, false);

		if(fleft.first - seq[l] - fleft.second <
		fRight.first - seq[r] - fRight.second) {
			return {fleft.first, seq[l] + fleft.second};
		} else {
			return {fRight.first, seq[r] + fRight.second};
		}
	}
}


ll recSolve(int l, int r, vector<int> & seq, vector<vector<ll>> & memo) {
	if(l > r) return 0;
	if(memo[l][r] != -1) return memo[l][r];

	ll leftTaken = seq[l] + min(recSolve(l + 2, r, seq, memo), 
		recSolve(l + 1, r - 1, seq, memo));
	ll rightTaken = seq[r] + min(recSolve(l + 1, r - 1, seq, memo), 
		recSolve(l, r - 2, seq, memo));

	memo[l][r] =  max(leftTaken, rightTaken);
	return memo[l][r];
}

ll solveDeque() {
	int n; cin >> n;
	vector<int> seq(n);
	for(auto & v : seq) {
		cin >> v;
	}

	vector<vector<ll>> memo(3000, vector<ll>(3000, -1));

	ll taroAcc = recSolve(0, n - 1, seq, memo);
	ll acc = accumulate(seq.begin(), seq.end(), 0l);
	ll jiroAcc = acc - taroAcc;

	return taroAcc - jiroAcc;
}

ll solveDequeDP() {
	int n; cin >> n;
	vector<int> seq(n);
	for(auto & v : seq) {
		cin >> v;
	}
	
	
	vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));

	for(auto delta = 0; delta < n; ++delta) {
		for(auto l = 0; l < n - delta; ++l) {
			auto r = l + delta;
			if(l > r) continue;

			if(l == r){
				dp[l][r] = seq[l];
			} else {
				auto leftTaken = seq[l] + min(dp[l + 2][r], dp[l + 1][r - 1]);
				auto rightTaken = seq[r] + min(dp[l][r - 2], dp[l + 1][r - 1]);

				dp[l][r] = max(leftTaken, rightTaken);
			}
		}
	}

	ll taroAcc = dp[0][n - 1];
	ll acc = accumulate(seq.begin(), seq.end(), 0l);
	ll jiroAcc = acc - taroAcc;
	return taroAcc - jiroAcc;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(precision);
	cout.setf(ios_base::fixed);

	auto ret = solveDequeDP();
	cout << ret << endl;
	
	return 0;
}


Measured memory_bytes: 70784
<?php 
    $s = explode(' ', trim(fgets(STDIN)));
	if($s[1] >= $s[2]){
    	echo "delicious";
    }elseif($s[0] >= $s[2] - $s[1]){
    	echo "safe";
    }elseif($s[0] < $s[2] - $s[1]){
    	echo "dangerous";
    }
?>

Measured memory_bytes: 4604
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = input()
    b = input()
    c = input()
    count = 0
    for i in range(n):
        if a[i] == b[i] == c[i]:
            count+=0
        elif a[i] == b[i]:
            count+=1
        elif a[i] == c[i]:
            count+=1
        elif b[i] == c[i]:
            count+=1
        else:
            count+=2
    print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  string S;cin>>S;
  
  for(int i=0;i<3;i++){
    if(S[i]==S[i+1]){
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  
  cout<<"Good"<<endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final int N = sc.nextInt();
    		final int[] X = new int[N];

    		double total = 0;
    		for (int i=0; i<N; i++) {
    			X[i] = sc.nextInt();
    			total += X[i];
    		}
    		double average = Math.round(total / N);
    		// System.out.println(average);

    		long totalCost = 0;
    		for (int i=0; i<N; i++) {
    			totalCost += (average - X[i]) * (average - X[i]);
    		}

    		System.out.println(totalCost);

    	} finally {
    		sc.close();
    	}
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A);
  vector<int> b(B);
  int min_a = 1000000;
  int min_b = 1000000;
  for(int i=0; i<A; i++){
    cin >> a.at(i);
    if(a.at(i) < min_a){
      min_a = a.at(i);
    }
  }
  for(int i=0; i<B; i++){
    cin >> b.at(i);
    if(b.at(i) < min_b){
      min_b = b.at(i);
    }
  }
  int min = min_a + min_b;
  for(int i=0; i<M; i++){
    int x, y, c;
    cin >> x >> y >> c;
    int ans;
    ans = a.at(x-1) + b.at(y-1) - c;
    if(ans < min){
      min = ans;
    }
  }
  cout << min << endl;
  
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x;
    cin>>n>>m;
   while(m--)
   {
       cin>>x;
       n-=x;
   }
   if(n>0)cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    s = list(input())
    if n % 2 != 0:
        print("No")
    else:
        if n == 2:
            if s[0] == s[1]:
                print("Yes")
            else:
                print("No")
        else:
            div = n // 2
            if s[:div-1] == s[div:n-1]:
                print("Yes")
            else:
                print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int N,M;
    cin >> N >> M;
    vector<P> s(M);
    REP(i,M){
        cin >> s[i].first;
        cin >> s[i].second;
    }
    sort(all(s),greater<>());
    int top = 10,sec = 10,thi = 10;
    bool ok = 1;
    REP(i,M){
        if(s[i].first == 1){
            if(s[i].second == 0){
                if(N != 1)ok = 0;
            }
            if(top == 10){
                top = s[i].second;
            }else if(top != s[i].second){
                ok = 0;
            }
        }else if(s[i].first == 2){
            if(sec == 10){
                sec = s[i].second;
            }else if(sec != s[i].second){
                ok = 0;
            }
        }else{
            if(thi == 10){
                thi = s[i].second;
            }else if(thi != s[i].second){
                ok = 0;
            }
        }
    }
    if(top == 10 && N != 1){
        top = 1;
    }else if(top == 10){
        top = 0;
    }
    if(sec == 10)sec = 0;
    if(thi == 10)thi = 0;
    if(N == 3 && ok == 1)cout <<top<<sec<<thi<< "\n";
    if(N == 2 && ok == 1)cout <<top<<sec<< "\n";
    if(N == 1 && ok == 1)cout <<top<< "\n";
    if(ok == 0)cout <<-1<< "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	vector<char>s[n+5];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			char c;
			cin>>c;
			s[i].push_back(c);
		}
	}
	int ans=0;
	map<pair<int,int>,int>mp;
	for(int i=0;i<(1<<n);i++)
	{
		for(int j=0;j<(1<<m);j++)
		{
			map<int,int>rows,columns;
			int k1=i;
			stack<int>st;
			vector<char>s1[n+5];
		    for(int i1=0;i1<n;i1++)
            {
                for(int j1=0;j1<m;j1++)
                    s1[i1].push_back(s[i1][j1]);
            }
			while(k1)
			{
				st.push(k1%2);
				k1=k1/2;
			}
			int count=st.size()-1;;
			while(!st.empty())
			{
				int t=st.top();
				st.pop();
				if(t==1){
				rows[count]++;
				}
				count--;
			}
			k1=j;
			while(k1)
			{
				st.push(k1%2);
				k1=k1/2;
			}
			count=st.size()-1;
			while(!st.empty())
			{
				int t=st.top();
				st.pop();
				if(t==1){
				columns[count]++;
				}
				count--;
			}
			for(int i1=0;i1<n;i1++)
			{
				if(rows.find(i1)!=rows.end())
				{
					for(int j1=0;j1<m;j1++)
					s1[i1][j1]='a';
				}
			}
			for(int j1=0;j1<m;j1++)
			{
				if(columns.find(j1)!=columns.end())
				{
					for(int i1=0;i1<n;i1++)
					s1[i1][j1]='a';
				}
			}
			count=0;
			for(int i1=0;i1<n;i1++)
			{
				for(int j1=0;j1<m;j1++)
				{
					if(s1[i1][j1]=='#')
					count++;
				}
			}
			if(count==k)
            {
                //cout<<i<<" "<<j<<'\n';
				/*int i2=i;
				int j2=j;
				if(i2%2==0)
				i2=i2/2;
				if(j2%2==0)
				j2=j2/2;
				if(mp.find({i2,j2})!=mp.end())
				continue;
				mp[{i2,j2}]++;*/
                /*for(int i1=0;i1<n;i1++)
                {

                    for(int j1=0;j1<m;j1++)
                        cout<<s1[i1][j1]<<" ";
                    cout<<'\n';
                }*/
                ans++;
            }
		}
	}
	cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 3005
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << fim
#define max3(x, y, z) max(x, max(y, z))
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll MOD = 1e9+7;
ll expo(ll a, ll b){
    if(b == 0) 
		return 1;
    ll x = expo(a, b/2);
    return (b & 1 ? ((x*x)%MOD*a)%MOD : (x*x) % MOD);
}
ll fat(int x) {
	ll res = 1;
	for(int i = 1; i <= x; i++)
		res = (res*i)%MOD;
	return res;
}


int n, t;
ll dp[3005][6005];
vector<pii> p(MAXN);

ll solve(int i, int k) {
	ll &ans = dp[i][k];
	if(ans != -1)
		return ans;
	if(i == n or k == 0)
		return ans = 0;
	ans = 0;

	if(k >= p[i].f) 
		ans = max(ans, solve(i+1, k-p[i].f)+p[i].s);
	
	return ans = max(ans, solve(i+1, k));

}

bool cmp(pii a, pii b) {
	if(a.f != b.f)
		return a.f > b.f;
	if(a.s != b.s)
		return a.s > b.s;
	return false;
}

int main() {
	cin >> n >> t;
	t--;
	for(int i = 0; i < n; i++) 
		cin >> p[i].f >> p[i].s;
	memset(dp, -1, sizeof dp);
	sort(p.begin(), p.end(), cmp);
	ll ans = 0;
	for(int i = 1; i <= n; i++)
		ans = max(ans, solve(i, t)+p[i-1].s);
	cout << ans << endl;
}


Measured memory_bytes: 141440
//Yazar: Mehmet Kutay Bozkurt
//Auther: Mehmet Kutay bozkurt
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
typedef long long int lo;
#define pb push_back
#define st first
#define nd second
lo a,b,c,d,e,n,m,x,y,z,a1[500005],a2[100005],k,t;
char c1,c2,c3,c4;
string s1,s2,s3,s4,den[3];
bool av=false;
map <char,lo> mp;
vector <lo> v;
vector <lo> v1;
int main() {
    // freopen("gir.gir","r",stdin);
	// freopen("cik.cik","w",stdout);
	cin>>n>>m;
    for(lo i=0;i<n;i++){
        cin>>a1[i];
    }
    x=0;
    sort(a1,a1+n);
    for(lo i=0;i<n-m;i++){
        x+=a1[i];
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
const int64_t INF = 1000000000000000;
const int64_t MOD = 1000000007;


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

int64_t x, y;cin >> x >> y;
int64_t cnt = 0;

if (abs(y) == abs(x)) 
    cout << "1\n";
else if (y > 0){
    if (x > 0){
        if (x < y) cout << y - x << endl;
        else cout << 2 + x - y << endl;
    }
    else if (x < 0){
        if (-x < y) cout << 1 + y + x << endl;
        else cout << -x - y + 1 << endl;
    }
    else cout << y << endl;
}
else if (y < 0){
    if (x > 0){
        if (x < -y) cout << -y - x + 1 << endl;
        else cout << x + y + 1 << endl;
    }
    else if (x < 0){
        if (-x < -y) cout << 2 - y + x << endl;
        else cout << -x + y << endl;
    }
    else cout << -y + 1  << endl;
}
else {
    if (x < 0) cout << -x << endl;
    else cout << 1 + x << endl;
}



}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

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

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll n,a[120000],b[120000],c[120000],d;
  cin >> n;
  d=0;
  rep(i,n)cin >> a[i] >> b[i];
  rep(i,n)c[i]=a[i]+b[i];
  sort(c,c+n);
  rep(i,n)d+=a[i];
  if(n%2==0)rep(i,n)if(i%2==0)d-=c[i];
  if(n%2==1)rep(i,n)if(i%2==1)d-=c[i];
  printf("%lld",d);
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

signed _main(){
  int m,n; cin >> m >> n;
  cout << modpow(m,n,MOD) << endl;
  return 0;
}



Measured memory_bytes: 3232
from math import sqrt, ceil

N = int(input())
sq = ceil(sqrt(N))
min_st = N - 1

for i in range(2, sq + 1):
    if N % i == 0:
        if i + N // i - 2 < min_st:
            min_st = i + N // i - 2

print(min_st)

Measured memory_bytes: 40172
var
 n,i,x:int64;
 y:string;
begin
 readln(n);
 i:=1;
 while i<=trunc(sqrt(n)) do
  begin
   if n mod i=0 then x:=n div i;
   inc(i);
  end;
 str(x,y);
 writeln(length(y));
end.

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

using namespace std;

int main() {

	string w;
	cin >> w;
	map<char, int> a;
	for (int i = 0; i < w.size(); i++) {
		a[w[i]]++;
	}
	for (auto itr = a.begin(); itr != a.end(); itr++) {
		if (itr->second % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
n, l = map(int, input().split())

a = []
b = float('inf')
for i in range(1,n+1):
    a.append(i+l-1)
    if abs(i+l-1) < b:
        c = i+l-1
        b = abs(i+l-1)

A = sum(a)

print(A-c)

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

int main(void)
{
	char O[50];
	char E[50];
	scanf("%s", O);
	scanf("%s", E);
	int i = 0;
	int j = 0;
	int o,e;
	o = strlen(O);
	e = strlen(E);
	
	while (1)
	{
		if (i <= o - 1)
			printf("%c", O[i]);
		if (j <= e - 1)
			printf("%c", E[j]);
		i++;
		j++;
		if (o < e)
		{
			if (j == e)
				break ;
		}
		else
		{
			if (i == o)
				break ;
		}
	}
	return(0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int k, a, b;
    cin >> k >> a >> b;
    int flag = 0;
    for(int i=a; i<=b; i++){
        if(i % k == 0){
            flag = 1;
        }
    }
    if(flag == 1) cout << "OK";
    else cout << "NG";
    return 0;
}

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

int main(){

	ll n;

	cin >> n;
	vector<ll> v(10001);
	ll val;
	for(int i = 1; i <= 100; i++){
		for(int j = 1; j <= 100; j++){
			for(int k = 1; k <= 100; k++){
				val = i*i + j*j + k*k + i*j + j*k + k*i;
				if(val > 10000){
					break;
				}
				v[val]++;		
			}
		}
	}

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


}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
int main(void)
{
    int n, cnt=0;
    cin >> n;
    REP(i,1,n+1){
        string s = to_string(i);
        if(s.size()%2) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
const int N = 1e5 + 5;
using namespace std;

int n, a[N], L, p = -1;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> L;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <  n; i++) {
        if (a[i] + a[i+1] >= L) {
            p = i; break;
        }
    }
    if (p == -1){
        cout << "Impossible";
        return 0;
    }
    cout << "Possible\n";
    for (int i = 1; i < p; i++) cout << i << "\n";
    for (int i = n-1; i >= p+1; i--) cout << i << "\n";
    cout << p;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
long long n;
int f(long long a, long long b){
  int cnt1 = 0, cnt2 = 0;
  while(a){
    cnt1++, a/=10;
  }while(b){
    cnt2++, b/=10;
  }
  return max(cnt1, cnt2);
}
int main(){
  cin >> n;
  int ans = INT_MAX;
  for(long long i = 1; i *i <= n; i++){
    if(n%i == 0)
      ans = min(ans,f(i,n/i) );
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#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;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

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 a, b, c;
  cin >> a >> b >> c;
  if(a == b && b == c) {
    cout << (a%2 ? 0 : -1) << endl;
    return 0;
  }
  int ans = 0;
  while(!(a%2 || b%2 || c%2)) {
    int na = (b+c)/2;
    int nb = (a+c)/2;
    int nc = (a+b)/2;
    a = na;
    b = nb;
    c = nc;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main() {
    string s;
    cin>>s;
    
    if(s[s.size()-1]=='s')
    {
        s+='e';
        s+='s';
    }
    else
    {
        s+='s';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <math.h>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#pragma GCC optimize ("-O3")
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define ll long long int
ll max(ll a, ll b) {  return a > b ? a : b; }
ll gcd(ll a, ll b) { if (a == 0) return b; return b == 0 ? a : gcd(b, a % b);}
#define case(i) cout<<"Case #"<<i<<": ";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << '\n'; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
#define debug2(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
void err(istream_iterator<string> it, T a, Args... args) { cerr << "[ " << *it << " = " << a << " ]"; err(++it, args...);}
#define time__(d) for (auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second; debug2("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define pii pair <ll , ll >
#define pb push_back
#define PRECISION 10
const ll inf = 9223372036854775800;
const int MAXN = 100001;
const int LOGN = 22;
const int MAXBIT = 62;
const long double PI = 3.141592653589793;
const int DIGITSIZE = 18;
ll mod = 1e9 + 7;
ll MOD = 998244353;
int x4[] = {1, -1, 0, 0};
int y4[] = {0, 0, 1, -1};
int x8[] = {1, 1, 1, -1, -1, -1, 0, 0};
int y8[] = {1, 0, -1, 1, 0, -1, 1, -1};
bool takeTestCases = 0;
bool printCaseNo = 0;

void getac(int T) {
    ll n,d;
    cin>>n>>d;
    ll ans=0;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        ll dist = x*x + y*y;
        if(dist<=d*d){
            ans++;
        }
    }
    cout<<ans<<'\n';
}
int  main()
{
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
//     freopen("error.txt", "w", stderr);
// #endif
    fastio;
    int t = 1;
    if (takeTestCases) cin >> t;
    int t_t = 1;
    while (t--) {
        if (printCaseNo)
        case (t_t);
        getac(t_t);
        t_t++;
    }
    cerr << "Total time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 3792
N = int(input())

A = 4
B = 7
max_num = N // 4 + 1
res = "No"
for i in range(max_num + 1):
    for j in range(max_num - i):
        if (A * i + B * j) == N:
            res = "Yes"
            break

print(res)

Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;

const long long mod = 1000000007;
long long inv[1001001] = { 0,1 }, fact[1001001] = { 1,1 }, ifact[1001001] = { 1,1,1 };

int main()
{
	for (int i = 2; i < 1001001; i++) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		fact[i] = fact[i - 1] * i % mod;
		ifact[i] = ifact[i - 1] * inv[i] % mod;
	}

	int N; scanf("%d", &N);
	long long ans = N * fact[N-1] % mod;
	for (int p = 1; p < N; p++) {
		int u = 2 * p;
		if (u < N) continue;
		int h = N-1-p;
		if (h > p - 1) continue;
		long long v = fact[p] * fact[p - 1] % mod * ifact[p - 1 - h] % mod;
		ans = (ans + mod -  v) % mod;
	}

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

	return 0;
}

Measured memory_bytes: 23680
#include<iostream>
#include<algorithm>
#include<string>
#include<deque>
using namespace std;

int const N = 2e5 + 41;
int const INF = 1e7 + 41;

int n, k;
char s[N], ans[N];
int a[N];
deque<int> q;

void solve(){
	scanf("%d %d",&n,&k);
	scanf("%s",&s);
	for(int i=0;i<n;++i) a[i] = s[i] - 'A';
	int x = 0;
	for(int i=0;i<n;++i) q.push_back(a[i]);
	if(k > INF) k = INF + ( (k - INF) % 2 == 1 ? 1 : 0);
	while(k--){
		if( (q.front() ^ x) == 0){
			q.front() = (1 ^ x);
		}else{
			x ^= 1;
			q.pop_front();
			q.push_back(x);
		}
	}
	for(int i=0;i<n;++i) ans[i] = 'A' + (q[i] ^ x);
	
	printf("%s\n",ans);
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void)
{
	int n;
	int x;
	int sum;
	int i;
	
	scanf("%d", &n);
	
	while (n != 0){
		x = n;
		sum = 0;
		while (x != 0){
			x /= 5;
			sum += x;
		}
		printf("%d\n",sum);
		scanf("%d", &n);
	}
	
	return (0);
}

Measured memory_bytes: 0
S = input()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[3]:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(){

  int n,count=0,count2=0,i,j,m,m2,p;
  char a[100]={},b[100]={};

  scanf("%d",&n);

  for(j=0;j<n;j++){
   
    scanf("%s",a);
    m=strlen(a);
    scanf("%s",b);
    m2=strlen(b);
    if(m>m2) p=m;
    else if(m<m2) p=m2;
    else p=m;
    for(i=0;i<p;i++){
      if(a[i]<b[i]){
	count+=3;
	break;
      }
      else if(a[i]>b[i]){
	count2+=3;
	break;
      }
      else if (i==p-1 && a[i]==b[i]){
	  count++;
	  count2++;
	}
    }
  }

  printf("%d %d\n",count2,count);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
const long long v=100010,p=1e9+7;
long long s[v],t,z,n,m,h[v],jc[v],inv[v];
long long read()
{
	long long f=1,x=0;
	char c=getchar();
	for(;!isdigit(c);c=getchar())
	if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c&15);
	return x*f;
}
long long ksm(long long x,long long q)
{
	long long w=1;
	for(;q;x=(x*x)%p,q/=2)
	if(q&1)w=(w*x)%p;
	return w;
}
long long C(long long x,long long y)
{
	long long q;
	q=jc[y]*ksm(jc[x],p-2)%p;
	q=q*ksm(jc[y-x],p-2)%p;
	//printf("%lld %lld %lld %lld %lld\n",x,y,jc(y),ksm(jc(x),p-2),ksm(jc(y-x),p-2));
	return q;
}
int main()
{
	long long i;
	n=read();m=read();jc[0]=1;
	for(i=1;i<=n;i++)s[i]=read();
	for(i=1;i<=n;i++)jc[i]=jc[i-1]*i%p;
	//阶乘可预处理，防止超时 
	sort(s+1,s+n+1);
	for(i=1;i<=n-m+1;i++)t=(t+(s[i]*C(m-1,n-i))%p)%p;
	for(i=m;i<=n;i++)z=(z+(s[i]*C(m-1,i-1))%p)%p;
	cout<<((z-t)%p+p)%p;
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>

int main(){
  int x,y,n = 1;

  scanf("%d%d",&x,&y);
  if(1 > x || x > 1000000000 || 1 > y || y > 1000000000) exit(1);

  if(x == y) printf("%d\n",x);

  else if(x > y){
    x = x % y;
    while(1){
      n = y % x;
      if(n == 0){
	printf("%d\n",x);
	break;
      }
      y = x;
      x = n;
    }
  }
  
  else{
    y = y % x;
    while(1){
      n = x % y;
      if(n == 0){
	printf("%d\n",y);
	break;
      }
      x = y;
      y = n;
    }
  }

  return 0;
}



Measured memory_bytes: 2104
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()
tugi = [0]+a
town  =1
route = [0]*n
route[0] = town
used = [False]*n
used[0] = True
for i in range(n):
    town = tugi[town]
    if used[town-1]:
        i = route.index(town)
        notcycle = route[:i]
        cycle = route[i:]
        break
    used[town-1] = True
    route[i+1] = town

for i in range(n):
    if cycle[i] == 0:
        cycle = cycle[:i]
        break

if len(notcycle) >k:
    print(notcycle[k])
else:
    k -= len(notcycle)
    print(cycle[k%len(cycle)])

Measured memory_bytes: 97332
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M  998244353
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
ll lcm(ll a,ll b)
{
    ll g=__gcd(a,b);
    return ((a*b)/g);
}
int pal(string S)
{
    int n=S.length();
    int ok=1,i;
    for(i=0;i<n;i++)
    {
        if(S[i]!=S[n-i-1])
        {
            ok=0;
            break;
        }
    }
    return ok;
}
ll d(ll n)
{
    ll y=n*(n-1);
    y/=2;
    return y;
}
int main()
{
  double L;
  cin>>L;
  double p,q,r;
  p=L/3;
  q=L-p;
  q/=2;
  r=L-p-q;
  double ans=p*q*r;
  cout<<setprecision(12)<<fixed<<ans;
}


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

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

using namespace std;

int main() {
  int n;
  cin>>n;
  REP(i,n) {
    vector<vector<int>> cnt(3, vector<int>(12, 0));
    string rgb="RGB";
    vector<int> clr(9), num(9);
    REP(j,9){
      cin>>num[j];
      --num[j];
    }
    REP(j,9){
      string s;
      cin>>s;
      clr[j] = rgb.find(s[0]);
    }
    REP(j,9){
      ++cnt[clr[j]][num[j]];
    }
    int sets = 0;
    REP(j,3){
      REP(k,9){
        sets += cnt[j][k] / 3;
        cnt[j][k] %= 3;
        while (cnt[j][k] && cnt[j][k+1] && cnt[j][k+2]) {
          --cnt[j][k];
          --cnt[j][k+1];
          --cnt[j][k+2];
          ++sets;
        }
      }
    }
    cout << (sets == 3) << endl;
  }
  return 0;
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int n, k; cin >> n >> k;
  int l = 1, r = 0;
  vec a(n); rep(i,n) {
    cin >> a[i];
    r = max(r, a[i]);
  }

  while (l != r) {
    int mid = (l+r)/2;
    ll c = 0;
    rep(i,n) {
      c += (a[i]-1)/mid;
    }
    if (c <= k) r = mid;
    else l = mid+1;
  }

  cout << l << endl;
}


Measured memory_bytes: 4056
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

ll x(ll n){
    if(n%2==0){
           if(n%4==0) return 0^n;
        else return 1^n;
    }
    else{
        if(n%4==1) return 1;
        else return 0;
    }
}



int main(){
    ll A,B;
    cin>>A>>B;
    ll C =x(A-1)^x(B);
    cout <<C<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
   int i,n,max=0,x=0;
   char str[101];

   scanf("%d%s",&n,str);

   for(i=0;i<n;i++){
      if(str[i]=='I') x++;
      else x--;

      if(x>max) max=x;
   }

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

   return 0;
}

Measured memory_bytes: 128
// ALDS1_2_C Stable Sort
import java.io.*;
import java.util.*;

class Main {
   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         int N = Integer.parseInt(br.readLine());
         Trump[] card = new Trump[N];
         String[] inputAry = br.readLine().split(" ");
         for (int i = 0; i < N; i++) {
            card[i] = new Trump(inputAry[i]);
         }
         Trump[] bubble, selection;
         bubble = BubbleSort(card, N);
         selection = SelectionSort(card, N);
         for (int i = 0; i < N; i++) {
            if (i == N - 1) {
               System.out.println(bubble[i].getCard());
            } else {
               System.out.print(bubble[i].getCard() + " ");
            }
         }
         System.out.println("Stable");
         for (int i = 0; i < N; i++) {
            if (i == N - 1) {
               System.out.println(selection[i].getCard());
            } else {
               System.out.print(selection[i].getCard() + " ");
            }
         }
         if (isStable(bubble, selection, N)) {
            System.out.println("Stable");
         } else {
            System.out.println("Not stable");
         }
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   }
   static Trump[] BubbleSort(Trump[] card, int N) {
      Trump[] tmpAry = Arrays.copyOf(card, card.length);
      Trump tmp;
      boolean flag = true;
      while (flag) {
         flag = false;
         for (int j = N - 1; j >= 1; j--){
            if (tmpAry[j].getValue() < tmpAry[j - 1].getValue()) {
               tmp = tmpAry[j];
               tmpAry[j] = tmpAry[j - 1];
               tmpAry[j - 1] = tmp;
               flag = true;
            }
         }
      }
      return tmpAry;
   }
   static Trump[] SelectionSort(Trump[] card, int N) {
      Trump[] tmpAry = Arrays.copyOf(card, card.length);
      Trump tmp;
      int minj;
      for (int i = 0; i < N; i++) {
         minj = i;
         for (int j = i; j < N; j++) {
            if (tmpAry[j].getValue() < tmpAry[minj].getValue()){
               minj = j;
            }
         }
         if (i != minj) {
            tmp = tmpAry[i];
            tmpAry[i] = tmpAry[minj];
            tmpAry[minj] = tmp;
         }
      }
      return tmpAry;
   }
   static boolean isStable(Trump[] in, Trump[] out, int N) {
      for (int i = 0; i < N; i++) {
         if (in[i].getValue() == out[i].getValue() && in[i].getSuit() != out[i].getSuit()) {
            return false;
         }
      }
      return true;
   }
}

class Trump {
   String card;

   public Trump(String card) {
      this.card = card;
   }

   char getSuit() {
      char suit = card.charAt(0);
      return suit;
   }
   int getValue() {
      int value = Integer.parseInt(card.substring(1,2));
      return value;
   }
   String getCard() {
      return card.toString();
   }
}

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

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

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

int main(void){
  int N, ans;
  cin >> N;
  
  if(N % 1000) ans = 1000 -(N % 1000);
  else ans = 0;
  cout << ans << endl;
  
  return 0; 
}



Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	long double d;
};


///////////////////////////

struct dijksra {

	ll N;
	vector<vector<edge>> g;
	ll s;

	vector<long double> ans;

	dijksra(ll N0, ll s, vector<vector<edge>> g0) {//頂点数、始点、グラフ(頂点は1indexか0index)
		N = N0;
		g = g0;

		ans.assign(N + 1, INF);


		priority_queue<pair<long double, ll>> q;//(-キョリ、頂点)

		ans[s] = 0;
		q.push({ 0,s });

		while (!q.empty()) {
			auto x = q.top();
			q.pop();

			long double dis = -x.first;
			ll v = x.second;

			if (dis > ans[v]) { continue; }


			for (edge e : g[v]) {
				ll w = e.to;
				if (dis + e.d < ans[w]) {
					ans[w] = dis + e.d;
					q.push({ -ans[w], w });
				}
			}


		}
	}

	long double d(ll t) {//sからtまでの最短距離を出力
		return ans[t];
	}


};



int main() {

	long double xs, xt, ys, yt;
	cin >> xs >> ys >> xt >> yt;

	ll N;
	cin >> N;

	vector<long double> x(N + 3), y(N + 3), r(N + 3,0);

	repn(i, N) cin >> x[i] >> y[i] >> r[i];


	x[N + 1] = xs;
	y[N + 1] = ys;
	x[N + 2] = xt;
	y[N + 2] = yt;

	vector<vector<edge>> g(N + 3);

	repn(i, N+2) {
		repn(j, N+2) {
			if (i == j) { continue; }
			long double dis = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
			//cout << dis << endl;
			dis = dis - r[i] - r[j];
			if (dis < 0) { dis = 0; }
			g[i].push_back({ 0,i,j,dis });

			//cout << i << j << dis << endl;
		}
	}

	dijksra dij(N + 2, N + 1, g);

	cout << fixed << setprecision(15);

	cout << dij.d(N + 2);



	system("PAUSE");

}





Measured memory_bytes: 151788
A = list(map(str, input().split()))
A7 = 0
A5 = 0
for i in A:
  if i == "7":
    A7 += 1
  elif i == "5":
    A5 += 1

if A5 == 2 and A7 == 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int cnt[100000][26];

int main()
{
	string s;
	int ans=0;
	
	cin>>s;
	fill(cnt[0],cnt[100000],0);
	int len=s.length();
	for(int i=0;i<len;i++)
	{
		cnt[i][s[i]-'a']++;
	}

	for(int i=0;i<26;i++)
	{
		int j=0;
		while(j<len)
		{
			while(cnt[j][i]==0 && j<len)
				j++;
			//初めてcnt[j][i]=1
			int l=j;
			int r=-1;
			for(int k=l+1;k<l+3 && k<len;k++)
			{
				if(s[k]=='a'+i)
				{
					r=k;
					cout<<l+1<<" "<<r+1<<endl;
					return 0;
				}
			}
			j=l+3;
		}
	}
	cout<<-1<<" "<<-1<<endl;
	return 0;
}

Measured memory_bytes: 10624
a,b=map(int,input().split())
j=0
while b>=2**j:
    j+=1
if b==0:
    j=1
k=1
l=[0 for i in range(j)]
bia=[0 for i in range(j)]
A=a
i=0
while A>2**(k-1):
    l[i]=A%(2**k)
    m=(l[i]-2**(k-1))
    if m<=0:
        bia[i]=0
    else:
        if m%2==1:
            bia[i]=1
        else:
            bia[i]=0
    k+=1
    i+=1
if (A//2)%2==0:
    bia[0]=0
else:
    bia[0]=1
k=1
l=[0 for i in range(j)]
bib=[0 for i in range(j)]
B=b+1
i=0
while B>2**(k-1):
    l[i]=B%(2**k)
    m=(l[i]-2**(k-1))
    if m<=0:
        bib[i]=0
    else:
        if m%2==1:
            bib[i]=1
        else:
            bib[i]=0
    k+=1
    i+=1
if (B//2)%2==0:
    bib[0]=0
else:
    bib[0]=1
ans=0
for i in range(j):
    if bia[i]==bib[i]:
        ans=ans
    else:
        ans+=2**i
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int32_t main()
{
	IOS;
	double a, b;
	cin>>a>>b;
	cout<<fixed<<setprecision(12)<<a/b;
	return 0;
}


Measured memory_bytes: 764
N = gets.to_i
X = gets.split.map(&:to_i)
M = gets.to_i
A = gets.split.map(&:to_i)
A.each do |a|
    p_now = X[a-1]
    p_next = p_now + 1
    if p_next > 2019 then
    elsif X.include?(p_next) then
    else
        X[a-1] += 1
    end
end
X.each{|x| p x}


Measured memory_bytes: 6880
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdlib>
#include <cstdio>
using namespace std;

#define next '\n'
#define rep(i, n) for(int (i) = (0); (i) < (n); (i++))
using ll = long long;

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

    string s, t; cin >> s >> t;
    int ans = 0;
    if(s[0] == t[0]) ans++;
    if(s[1] == t[1]) ans++;
    if(s[2] == t[2]) ans++;

    cout << ans << next;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> fl(n);
    for (int i = 0; i < n; i++)
        cin >> fl[i];
        int sum = 0;
        for(int i = 1; i < n; i++){
            if(fl[i] - fl[i - 1] < 0)
            sum += abs(fl[i] - fl[i - 1]);
        }
    sum += fl[n -1];
    cout << sum << "\n";
}

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

const ll INF = 1LL << 60;
struct edge { ll cost, u, v; };

bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

class UnionFind {
public:
  //親の番号を格納する。親だった場合は-(その集合のサイズ)
  vector<int> Parent;

  //作るときはParentの値を全て-1にする
  //こうすると全てバラバラになる
  UnionFind(int N) {
    Parent = vector<int>(N, -1);
  }

  //Aがどのグループに属しているか調べる
  int root(int A) {
    if (Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }

  //自分のいるグループの頂点数を調べる
  int size(int A) {
    return -Parent[root(A)];//親をとってきたい]
  }

  //AとBをくっ付ける
  bool connect(int A, int B) {
    A = root(A);
    B = root(B);
    if (A == B) {
      return false;
    }

    if (size(A) < size(B)) swap(A, B);

    Parent[A] += Parent[B];

    Parent[B] = A;

    return true;
  }
};

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

    // edge es[100100];
    vector<edge> es;

    vector<P> a;
    vector<P> b;

    // 辺の数
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        a.push_back(P(x, i));
        b.push_back(P(y, i));
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    for (int i = 1; i <= N - 1; i++) {
        P prev = a[i - 1];
        P current = a[i];

        ll w = abs(prev.first - current.first);
        edge e { w, prev.second, current.second };
        es.push_back(e);
    }

    for (int i = 1; i <= N - 1; i++) {
        P prev = b[i - 1];
        P current = b[i];

        ll w = abs(prev.first - current.first);
        edge e { w, prev.second, current.second };
        es.push_back(e);
    }

    sort(es.begin(), es.end(), comp);
    UnionFind uf = UnionFind(N);

    ll cost = 0;
    rep(i, es.size()) {
        if (uf.root(es[i].u) != uf.root(es[i].v)) {
            uf.connect(es[i].u, es[i].v);
            cost += es[i].cost;
        }
    }
    cout << cost << endl;
}

Measured memory_bytes: 10724