akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 998244353
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
#define lg length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<ll,ll> a,pair<ll,ll> b){
    if(a.fi!=b.fi)
        return  a.se<b.se;
    else
        return a.se>b.se;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(int argc, char * argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("big.txt", "r", stdin);
    //freopen("out3.txt", "w", stdout);
    //------------------------------
    ll k;cin>>k;
    while(k--)cout<<"ACL";
    cout<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------








































Measured memory_bytes: 3536
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = String.valueOf(sc.nextInt());
		String rn="";
		for(int i = 0;i < 3;i++) {
			if(n.charAt(i) == '1') rn += "9";
			else rn += "1";
		}
		System.out.println(Integer.valueOf(rn));
	}
}

Measured memory_bytes: 23252
// https://atcoder.jp/contests/abc108/tasks/abc108_a
#include <bits/stdc++.h>
using namespace std;
using P = pair<double, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    cout << (k / 2) * ceil((double)k / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==7 && b==5 && b==c || b==7 && a==5 && c==a || c==7 && a==5 && b==a) cout<<"YES\n";
    else cout<<"NO\n";
    
    return(0);
}

Measured memory_bytes: 3592
#include <stdio.h>
int main()
{
      int n, t, d, index, h;
      double tmp, s, m=1000000;
      scanf("%d %d %d", &n,&t, &d);
      for(int i=1;i<=n;i++)
      {
            scanf("%d", &h);
            tmp=t-h*0.006 - d; 
            s= (tmp>0) ? tmp:-tmp;
            if( s < m ) m=s, index=i;
       }
       printf("%d", index);
       return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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


int main(){
    int n;
    cin >> n;
    ll ans=1;
    rep(i,n){
        ll tmp;
        cin >> tmp;
        if(inf/ans < tmp && tmp != 0){
            ans = -1;
        }else{
            ans *= tmp;
        }
        if(ans == 0){
            break;
        }
    }
    if(ans < 0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

}



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

int main(){
    int N,L;
    cin >> N >> L;
    
    vector<string> S(N);

    for (int i = 0; i < N; i++){
        cin >> S[i];
    }
    sort(S.begin(),S.end());

    for (int i = 0; i < N; i++){
        cout << S[i];
    }
    cout << endl;
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int comp(const void *a,const void *b){
  return *(int*)a-*(int*)b;
}

int main(){
  int n,m,ans=0;
  scanf("%d %d",&n,&m);
  int x[m],d[m];
  for(int i=0;i<m;i++){
    scanf("%d",&x[i]);
  }
  qsort(x,m,sizeof(int),comp);
  for(int i=0;i<m-1;i++){
    d[i]=x[i+1]-x[i];
  }
  qsort(d,m-1,sizeof(int),comp);
  for(int i=0;i<m-n;i++){
    ans+= d[i];
  }
  printf("%d",ans);
}

Measured memory_bytes: 1396
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
ll sum;
ll dp[101][3501];

int main(void){
	scanf("%d%d",&n,&k);
	sum=(ll)n*k*(k+1LL)/2LL;
	ll tmp=1;
	for(int i=0;i<n-1;i++){
		tmp=(ll)tmp*(k+1)%MOD;
	}
	sum=sum*tmp%MOD;
	dp[n][0]=1;
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<=3400;j++){
			for(int l=0;l<=k;l++){
				if(l<=i+1){
					dp[i][j+(l+j)/(i+1)]+=dp[i+1][j];
					dp[i][j+(l+j)/(i+1)]%=MOD;
				}
				else{
					dp[i][j]+=dp[i+1][j];
					dp[i][j]%=MOD;
				}
			}
		}
	}
	for(ll i=1;i<3400;i++){
		sum-=dp[0][i]*i%MOD;
		if(sum<0LL)sum+=MOD;
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<queue>
#include<set>

using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

int main(){
  string button;
	vector<string> push(10);
	push[0] = " ";
	push[1] = "',.!?";
	push[2] = "abcABC";
	push[3] = "defDEF";
	push[4] = "ghiGHI";
	push[5] = "jklJKL";
	push[6] = "mnoMNO";
	push[7] = "pqrsPQRS";
	push[8] = "tuvTUV";
	push[9] = "wxyzWXYZ";
	while(cin>>button){
		int key = -1;
		int cnt = 0;
		string out;
		for(int i=0;i<button.size();i++){
			if(key == button[i]-48){
				if(key == 0)
					cout<<" ";
				cnt++;
			}
			else{
				if(key>0)
					cout<<push[key][cnt%(push[key].size())];
				cnt = 0;
				key = button[i]-48;
			}
		}
		cout<<push[key][cnt%(push[key].size())]<<endl;
	}
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int lmax = 0;
    int rmin = 100000;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        lmax = max(lmax, l);
        rmin = min(rmin, r);
    }
    cout << max(0, rmin - lmax + 1) << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  vector<vector<int>> c(3,vector<int>(3));
  rep(i,3){
    rep(j,3) cin>>c[i][j]; 
  }
  ///////
  bool ans=true;
  rep(j,2){
  rep(i,3){
     
       int d=c[0][j+1]-c[0][j];
         if(c[i][j+1]-c[i][j]!=d ) ans=false;
     
    
    
  }
  }
  
  rep(j,2){
  rep(i,3){
     
       int d=c[j+1][0]-c[j][0];
         if(c[j+1][i]-c[j][i]!=d ) ans=false;
     
    
    
  }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  for (int i = 1; i < n; i++) ans = (ans + v[i])/2;
  printf("%.10f\n", ans);
  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);	
    
    string s;
    cin >> s;
    bool a = false;
    for(char c: s) if(c == '7') a = true;
    
    cout << (a==true ? "Yes" : "No");
    
    
    return 0;
}



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

int main(){
    int H,N,R=0;
    cin >> H >> N;
    int A[N];
    for(int i=0;i<N;i++) {
        cin >> A[i];
        R=R+A[i];
    }
    if(H<=R){cout<<"Yes";}
    else {cout<<"No";}
    cout << "\n";
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define fur(i,x,y) for(i=x;i<=y;i++)
#define fdr(i,x,y) for(i=x;i>=y;i--)
#define Fur(i,x,y) for(ll i=x;i<=y;i++)
#define Fdr(x,y) for(ll i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
#define cpy(x,y) memcpy(x,y,sizeof(x))
#define fl(i,x) for(ll i=head[x],to;to=e[i].to,i;i=e[i].next)
#define inf 233333333
using namespace std;
/*---------------------------------------*/
namespace fib{char b[300000]= {},*f=b;}
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
struct foce{~foce(){pob;fflush(stdout);}} _foce;
namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}
inline void outn(ll x){out(x);pc('\n');}
inline void swap(ll &x,ll &y){ll t=x;x=y;y=t;}
inline ll jdz(ll x){return x>=0?x:-x;}
/*------------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------------*/
#define N 100001
ll a,b;
int main(){
	in2(a,b);if(b<a)a--;outn(a);
}

/*

*/

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int answer = 0;
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j) {
            answer += v[i] * v[j];
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
package main

import (
    "fmt"
    "bufio"
    "os"
)
var r = bufio.NewReader(os.Stdin)

func main(){
    var a, b, c int
    fmt.Fscan(r, &a, &b, &c)
    if a < b && b < c {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}



Measured memory_bytes: 1124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Ans {
	int A;
	int x[15], y[15];
};

int check(int N, int mask, struct Ans a[15])
{
	fprintf(stderr, "check mask 0x%x\n", mask);
	for (int i = 0; i < N; i++) {
		int honest = mask & (1 << i);
		if (!honest)
			continue;
		fprintf(stderr, "%d is honest\n", i);
		for (int j = 0; j < a[i].A; j++) {
			int xij = a[i].x[j] - 1;
			int yij = a[i].y[j];

			fprintf(stderr, "0x%x (%d %d) %d %d\n", mask, i, j, xij, yij);
			if (yij) {
				if (mask & (1 << xij))
					continue;
				fprintf(stderr, "no\n");
				return 0;
			} else {
				if (!(mask & (1 << xij)))
					continue;
				fprintf(stderr, "no\n");
				return 0;
			}
		}
	}
	fprintf(stderr, "mask 0x%x ok\n", mask);
	return 1;
}

int main(int argc, char **argv)
{
	int N;
	struct Ans a[15];

	scanf("%d", &N);

	for (int i = 0; i < N; i++) {
		struct Ans *pa = &a[i];
		scanf("%d", &pa->A);
		for (int j = 0; j < pa->A; j++)
			scanf("%d %d", &pa->x[j], &pa->y[j]);
	}

	// solve

	// 16bit enough
	int m = 1 << N;
	int mn = 0;
	for (int i = 1; i < m; i++) {
		if (!check(N, i, a))
			continue;
		// ok count
		int n = 0;
		for (int k = 0; k < N; k++) {
			if (i & (1 << k))
				++n;
		}
		if (n > mn)
			mn = n;
	}
	printf("%d\n", mn);

	return 0;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    int aa[100001];
    int a[100001];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> aa[i];
        a[i] = aa[i];
    }

    int mn = INF;

    // a[0] > 0
    {
        int cnt;
        int sum;
        if (a[0] > 0)
        {
            cnt = 0;
        }
        else
        {
            cnt = 1 - a[0];
            a[0] = 1;
        }
        sum = 0;
        for (int i = 1; i < n; i++)
        {
            if (i % 2 == 0)
            {
                if (sum + a[i - 1] + a[i] <= 0)
                {
                    // cout << i << endl;
                    cnt += 1 - sum - a[i - 1] - a[i];
                    a[i - 1] = 1 - sum - a[i];
                }
            }
            else
            {
                if (sum + a[i - 1] + a[i] >= 0) //NG
                {
                    cnt += sum + a[i - 1] + a[i] + 1;
                    a[i - 1] = -1 - sum - a[i];
                }
            }
            sum += a[i - 1];
        }
        // cout << cnt << endl;
        // cout << cnt << endl;
        // cout << mn << endl;
        mn = min(mn, cnt);
    }

    for (int i = 0; i < n; i++)
        a[i] = aa[i];
    // a[0] < 0
    {
        int cnt;
        int sum;
        if (a[0] < 0)
        {
            cnt = 0;
        }
        else
        {
            cnt = a[0] + 1;
            a[0] = -1;
        }
        sum = 0;
        for (int i = 1; i < n; i++)
        {
            if (i % 2 == 0)
            {
                if (sum + a[i - 1] + a[i] >= 0)
                {
                    cnt += sum + a[i - 1] + a[i] + 1;
                    a[i - 1] = -1 - sum - a[i];
                }
            }
            else
            {
                if (sum + a[i - 1] + a[i] <= 0) //NG
                {
                    cnt += 1 - sum - a[i - 1] - a[i];
                    a[i - 1] = 1 - sum - a[i];
                }
            }
            sum += a[i - 1];
        }
        // cout << mn << " " << cnt << endl;
        mn = min(mn, cnt);
    }
    cout << mn << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    vector<int> b(a);
    sort(b.begin(), b.end());
    for(int i=0;i<n;i++){
        if(a[i] < b[n-1]){
            cout << b[n-1] << endl;
        }else{
            cout << b[n-2] << endl;
        }
    }
}

Measured memory_bytes: 3200
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(1000000)
n, m, *a = map(int, open(0).read().split())
dp = [1] + [-1] * n
dp[1] = 1
for i in a:
    dp[i] = 0

def count(n):
    if dp[n] != -1:
        return dp[n]
    dp[n] = (count(n - 1) + count(n - 2)) % (10**9 + 7)
    return dp[n]


print(count(n))


Measured memory_bytes: 279508
#include <iostream>
using namespace std;
int main()
{
	int h, n, count=0;
	int i;
	cin>>h>>n;
	int ai[n];
	for(i=0; i<n; i++)
	{
		cin>>ai[i];
	}
	for (i=0; i<n; i++)
	{
		h = h-ai[i];
		if (h<=0)
		{
			count=1;
		}
	}
	if (count==1)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 768
# coding: utf-8
# Your code here!
import sys

current = 100
count = 0
X = int(input())

def run(num, count):
    num = int(num * 1.01)
    count += 1
    return num, count 
    
while X > current:
    current, count = run(current, count)

print(count)

Measured memory_bytes: 9180
dic = {}
N = int(input())
for _ in range(N):
  x = int(input())
  if x in dic:
    dic[x] += 1
  else:
    dic[x] = 1
counter = 0
for i in dic.keys():
  if dic[i] %2 == 1:
    counter +=1
print(counter)

Measured memory_bytes: 15076
mod=10**9+7
n,k=map(int,input().split())
ans=(n+1)*( (n+k+1)*(n-k+2)/2 - (n+2)*(2*n+3)/6 )+k*(k-1)*(2*k-1)/6+(n-k+2)
ans=round(ans)%mod
print(ans)

Measured memory_bytes: 61880
#include<iostream>
#include<string>
#include<cstdio>
#include<cctype>


int main(){
    std::string str;
    int i;
    int sum[26]={0};
    char str2;
    
    str2='a';
    
    while(std::getline(std::cin,str)){
        for(i=0;i<str.size();i++){
           if ((str[i]>='a'&&str[i]<='z')){
                int num =str[i]-'a';
                sum[num]+=1;
            }else if((str[i]>='A'&&str[i]<='Z')){
                int num =str[i]-'A';
                sum[num]+=1;
            }
        }
    }
    

    for(i=0;i<26;i++){
    printf("%c : %d\n",str2,sum[i]);
    str2+=1;
    }

    return 0;
}



Measured memory_bytes: 3288
import math

def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = {}
    for val in a:
        cnt[val] = cnt.get(val, 0) + 1
    distinct = True
    for val in cnt:
        if cnt[val] > 1:
            distinct = False
    if distinct:
        print("YES")
    else:
        print("NO")

if __name__ == '__main__':
    main()

Measured memory_bytes: 109524
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007
#define MAXP 0x0FFFFFFF

typedef struct{
	TLong x;
	TLong y;
} point;

int MHD(point p1,point p2){
	return abs(p1.x - p2.x) + abs(p1.y - p2.y);
}

int main(int argc, char const *argv[])
{
	int n,m;
	int pNum;
	TLong min;
	point std[53],cp[53];
	scanf("%d%d",&n,&m);
	for (int i = 0; i < n; ++i)	scanf("%lld%lld", &std[i].x, &std[i].y);
	for (int i = 0; i < m; ++i)	scanf("%lld%lld", &cp[i].x, &cp[i].y);
	for (int i = 0; i < n; ++i)
	{
		min = MAXP;
		pNum = 0;
		for (int j = 0; j < m; ++j)
		{
			if(MHD(std[i],cp[j]) < min){
				min = MHD(std[i],cp[j]);
				pNum = j;
			}
		}
		printf("%d\n",pNum + 1);
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
ll ans[2020];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n,x,y;cin>>n>>x>>y;
    x--;y--;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            ll mind=mmin(j-i,abs(x-i)+1+abs(j-y));
            ans[mind]++;
        }
    }
    for(ll k=1;k<=n-1;k++){
        cout<<ans[k]<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





























Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, m;
    int h2, m2;
    cin >> h >> m >> h2 >> m2;
    int start = h * 60 + m;
    int end = h2 * 60 + m2;
    int k;
    cin >> k;
    cout << end - k - start << endl;
}

Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int A = int.Parse(s[0]);
        int B = int.Parse(s[1]);
        int sum = 0;
        for (int i = 0; i <= 9; i++)
        {
            for (int j = 0; j <= 9; j++)
            {
                for (int k = 0; k <= 9; k++)
                {
                    int PalindromeCount = 10001 * i + 1010 * j + 100 * k;
                    if (B >= PalindromeCount && PalindromeCount >= A)
                        sum++;
                }
            }
        }
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

vector<pair<ll, ll>> p;
int main() {
	ll n, h; cin >> n >> h;
	ll maxA = 0;
	rep(i, 0, n) {
		ll x, y; cin >> x >> y;
		p.push_back(make_pair(y, x));
		maxA = max(maxA, x);
	}

	sort(p.begin(), p.end());
	reverse(p.begin(), p.end());

	ll cnt = 0;
	rep(i, 0, n) {
		if (p[i].first >= maxA) {
			h -= p[i].first;
			cnt++;
			if (h <= 0) {
				cout << cnt << endl;
				return 0;
			}
		}
		else {
			break;
		}
	}
	if (h > 0) {
		cnt += h / maxA + (h % maxA > 0 ? 1 : 0);
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 2420
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define fastestiointhewest   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{  
   int n; cin>>n;
   int a[n],ans,cur=INF,sum=0;
   rep(i,0,n) cin>>a[i],sum+=a[i];
   rep(i,0,n)
   {
     if(cur>abs(sum-n*a[i])) ans=i,cur=abs(sum-n*a[i]);
   }
   cout<<ans;
}  
int main()
{   
    fastestiointhewest;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

const lli mod = 1000000007;

lli p(lli x, lli n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        lli t = p(x, n / 2);
        return (t * t) % mod;
    } else {
        return (x * p(x, n - 1)) % mod;
    }
}

int main() {
    lli N, M;
    cin >> N >> M;
    const int SZ = 200010;
    vector<lli> pr(SZ + 1, 1);
    vector<lli> ipr(SZ + 1, 1);
    REP(i, 1, SZ + 1) {
        pr[i] = (pr[i - 1] * i) % mod;
    }
    ipr[SZ] = p(pr[SZ], mod - 2);
    for (int i = SZ; i > 0; i--) {
        ipr[i - 1] = (ipr[i] * i) % mod;
    }
    auto nCr = [&](int n, int r) -> lli {
        return (((pr[n] * ipr[r]) % mod) * ipr[n - r]) % mod;
    };
    lli tmp = M;
    lli ans = 1;
    for (lli i = 2; i * i <= M; i++) {
        int cnt = 0;
        while (tmp % i == 0) {
            tmp /= i;
            cnt++;
        }
        if (cnt > 0) {
            ans = (ans * nCr(N + cnt - 1, cnt)) % mod;
        }
    }
    if (tmp != 1) {
        ans = (ans * N) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int a,b,c,x,cnt;
int main()
{
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
	{
		for(int j=0;j<=b && j<=x-500*i;j++)
		{
			for(int k=0;k<=c && k<=x-500*i-100*j;k++)
			{
				if(i*500+j*100+k*50==x)
				{
					cnt++;
				}
			}
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

S = input()

ans = 0
for i in range(len(S)):
    tmp = 0
    if S[i] in ('A', 'C', 'G', 'T'):
        tmp += 1
        for j in range(i + 1, len(S)):
            if S[j] in ('A', 'C', 'G', 'T'):
                tmp += 1
            else:
                i = j
                ans = max(tmp, ans)
                break
        ans = max(tmp, ans)

print(ans)


Measured memory_bytes: 3060
# coding: UTF-8
s = raw_input()

if 'N' in s and 'W' in s and 'S' in s and 'E' in s:
    print "Yes"
elif 'N' in s and not 'W' in s and 'S' in s and not 'E' in s:
    print "Yes"
elif not 'N' in s and 'W' in s and not 'S' in s and 'E' in s:
    print "Yes"
else :
    print "No"


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll i,j,k,n,a,b,x,y,z;
int main()
{
  for(cin>>n,i=n;n!=0;n/=10)a+=n%10;
  cout<<(i%a==0?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char a[2];
	int f;
	
	scanf("%s",&a);
	if(a[0]=='a')puts("vowel");
	else if(a[0]=='e')puts("vowel");
	else if(a[0]=='i')puts("vowel");
	else if(a[0]=='u')puts("vowel");
	else if(a[0]=='o')puts("vowel");
	else puts("consonant");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>

using namespace std;


bool is_prime(long long n){
    if(n == 2){
        return true;
    }
    if(n % 2 == 0){
        return false;
    }
    for(long long i = 3; i < sqrt(n); i+=2){
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

int main(){
    long long n;
    cin >> n;
    while(true){
        if(is_prime(n)){
            cout << n << endl;
            break;
        }
        n++;
    }
}

Measured memory_bytes: 888
n = gets.to_i
n.times do
  xa, ya, ra, xb, yb, rb = gets.split.map(&:to_f)
  dis = ((xa-xb)**2 + (ya-yb)**2)**0.5
  if ra+rb < dis
    puts 0
  elsif (ra-rb).abs <= dis
    puts 1
  elsif ra - rb > dis
    puts 2
  elsif rb - ra > dis
    puts -2
  end
end

Measured memory_bytes: 8732
while s = gets
  (0..25).each { |i| 
    sb = s.bytes.to_a
    s = sb.map { |c| 
      c < 97 || c > 122 ? c.chr : c.chr == 'z' ? 'a' : (c + 1).chr
    }.join
    puts s if s =~ /th[is|at|e]/
  }
end

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

long long mod = 1000000007;

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

	const size_t ls = l.size();

	vector<long long> dp1(ls+1);	// L と同じ
	vector<long long> dp2(ls+1);	// L より小さい

	dp1[0] = 1;
	dp2[0] = 0;

	for(size_t i = 1; i <= ls; ++i){
		if (l[i-1] == '0') {
			dp1[i] = dp1[i-1];
			dp2[i] = (((dp2[i - 1] + dp2[i - 1]) % mod) + dp2[i - 1]) % mod;
		}
		else {
			dp1[i] = (dp1[i - 1] + dp1[i - 1]) % mod;
			dp2[i] = (((((dp2[i - 1] + dp2[i - 1]) % mod) + dp2[i - 1]) % mod) + dp1[i - 1]) % mod;
		}
	}

	cout << (dp1[ls] + dp2[ls]) % mod << endl;

	return 0;
}

Measured memory_bytes: 2048
import sys

loops1 = 4
loops2 = 5
arg1 = 0
arg2 = 1

i=0
j=0

args = [int(input()) for i in range(6)]

for i in range(arg1,loops1):
	for j in range(arg2,loops2):
		if (args[j] - args[i]) > args[5]:
			print(":(")
			sys.exit()
print("Yay!")
	                

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.Scanner;

class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        long MOD = (long)(Math.pow(10, 9) +7);
        int n = sc.nextInt();
        int m = sc.nextInt();
        char a[][] = new char[n][m];
        long res[][] = new long[n][m];
        for(int i=0;i<n;i++) {
            String s = sc.next();
            for(int j=0;j<m;j++) {
               a[i][j] = s.charAt(j);
            }
        }
        res[n-1][m-1] = 0;
        for(int i=n-2;i>=0;i--) {
            if(i== n-2) {
                if(a[i][m-1] == '.') res[i][m-1] = 1;
                else res[i][m-1] = 0;
            }
            else {
                if(a[i][m-1] == '.') res[i][m-1] = (res[i+1][m-1])%MOD;
                else res[i][m-1] = 0;
            }
        }

        for(int i=m-2;i>=0;i--) {
            if(i== (m-2)) {
                if(a[n-1][i] == '.') res[n-1][i] = 1;
                else res[n-1][i] = 0;
            }
            else {
                if(a[n-1][i] == '.') res[n-1][i] = (res[n-1][i+1])%MOD;
                else res[n-1][i] = 0;
            }
        }
        for(int i= n-2;i>=0;i--) {
            for(int j=m-2;j>=0;j--) {
                if(a[i][j] != '#') {
                    res[i][j] = (res[i][j+1]+ res[i+1][j])%MOD;
                }
            }
        }
        System.out.println(res[0][0]%MOD);
    }
}


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

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

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

  int N;
  cin >> N;

  vector<int> A(N);
  int sum = 0;
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];
    sum ^= A[i];
  }

  for ( int i = 0; i < N; i++ ) {
    if ( i ) cout << " ";
    cout << (sum ^ A[i]);    
  }
  cout << endl;
  
  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  string s;
  while (cin >> s) {
    int cnt = 0;
    for (int i = 0; i + 1 < s.size(); ++i) {
      cnt += (s[i] != s[i + 1]);
    }
    cout << cnt << endl;
  }
  
  return 0;
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N;
    cin >> N;

    vector<i64> a(N);
    rep(i,0,N) cin >> a[i];

    vector<long double> pow4(31);
    pow4[0]=1;
    rep(i,1,pow4.size()) pow4[i]=pow4[i-1]*4;

    i64 size=16;
    vector<vector<i64>> memo1(N,vector<i64>(size));
    vector<vector<bool>> done1(N,vector<bool>(size));
    function<i64(i64,i64)> rec1=[&](i64 i,i64 x){
        if(x>15) return rec1(i,15)+(N-i-1)*(x-15);
        if(done1[i][x]) return memo1[i][x];
        done1[i][x]=true;
        if(i==N-1) return memo1[i][x]=0;
        i64 y=0;
        while(a[i]*pow4[x]>a[i+1]*pow4[y]+eps) ++y;
        return memo1[i][x]=rec1(i+1,y)+y;
    };

    vector<vector<i64>> memo2(N,vector<i64>(size));
    vector<vector<bool>> done2(N,vector<bool>(size));
    function<i64(i64,i64)> rec2=[&](i64 i,i64 x){
        if(x>15) return rec2(i,15)+i*(x-15);
        if(done2[i][x]) return memo2[i][x];
        done2[i][x]=true;
        if(i==0) return memo2[i][x]=0;
        i64 y=0;
        while(a[i]*pow4[x]>a[i-1]*pow4[y]+eps) ++y;
        return memo2[i][x]=rec2(i-1,y)+y;
    };

    i64 ans=min(rec1(0,0)*2,rec2(N-1,0)*2+N);
    rep(i,1,N) {
        ans = min(ans, rec1(i, 0) * 2 + rec2(i - 1, 0) * 2 + i);
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 126848
#include <iostream>
#include <cstdlib>
#include <stack>
#include <vector>
using namespace std;
int main()
{
    vector<stack <int>> a;
    int n, q, t, x, query;
    cin >> n >> q;
    a.resize(n);
    for (int i=0; i<q; ++i){
        cin >> query;
        switch(query){
            case 0:
                cin >> t >> x;
                a[t].push(x);
                break;
            case 1:
                cin >> t;
                if(!a[t].empty()){
                    cout << a[t].top() << endl;
                }
                break;
            case 2:
                cin >> t;
                if(!a[t].empty()){
                    a[t].pop();
                }
                break;
        }
    }
}


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

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w;
    cin >> n >> w;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    vector<ll> dp(w+1);
    for (int i = 0; i < n; ++i) {
        for (int j = w; j >= 0; --j) if (dp[j] > 0 && j+a[i] <= w) {
            dp[j+a[i]] = max(dp[j+a[i]], dp[j]+b[i]);
        }
        if (a[i] <= w) {
            dp[a[i]] = max(dp[a[i]], b[i]);
        }
    }
    ll an = 0;
    for (int j = 0; j <= w; ++j) {
        an = max(an, dp[j]);
    }
    cout << an << endl;
    return 0;
}


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

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    int A,B,M;cin>>A>>B>>M;
    int a[A],b[B];
    for(int i=0;i<A;i++) cin>>a[i];
    for(int i=0;i<B;i++) cin>>b[i];
    int x[M],y[M],c[M];
    for(int i=0;i<M;i++){
        cin>>x[i]>>y[i]>>c[i];
    }
    int ans=*min_element(a,a+A)+*min_element(b,b+B);
    for(int i=0;i<M;i++){
        ans=min(ans,a[x[i]-1]+b[y[i]-1]-c[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b;
    cin >> a >> b;
    int ans = (a+b+1)/2;
    
    cout << ans << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x<<","<<#y":"<<x<<","<<y<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
    ll N,X;
    cin >> N >> X;
    X = min(N-X,X);
    if(N%X==0){
        cout << N-X + X*2*((N-X)/X) << endl;
    }else{
        ll h = N - X;
        ll ans = 0;
        ans += N;
        ll n=X;
        while(1){
            if(h%n==0){
                ll k = h/n;
                k = k*2-1;
                ans += k*n;
                //                cout << h/n << endl;
                break;
            }
            ll a = h/n;
            ll b = h%n;
            //            cout << n*a*2 << endl;
            ans += n*a*2;
            h = n;
            n = b;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

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

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

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

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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

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

ll ks[1000005];
rep(i,1000004){
	ks[i]=0;
}

vector <ll> vec;
while (n >= 2) {
	bool so = true;
	for (ll i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			vec.push_back(i);
			n /= i;
			so = false;
			break;
		}
	}
	if (so) {
		vec.push_back(n);
		break;
	}
}

ll largep=0;

for(int i=0;i<vec.size();i++){
	if(vec[i]>=1000005){largep++;
	continue;}
ks[vec[i]]++;
}

ll ans=0;
for(int i=1;i<=1000004;i++){
	if(ks[i]){
ll k=0;
ll cnt=0;
while(k<=ks[i]){cnt++;
k+=cnt;
}
ans+=cnt-1;
	}
	

}

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




Measured memory_bytes: 11444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int  main()
{
    ll  ut,t,p;
    cin>>ut>>t>>p;
    ll  answer=0;
    if(p<=ut)
    {

        answer+=p;
        answer+=t;
        cout<<answer<<"\n";
        return 0;
    }
    else
    {
        answer+=(ut);
        p-=ut;
        if(p<=t)
        {
            answer+=(2*p);
            t-=p;
            answer+=t;


        }
        else
        {

            answer+=t;
            answer+=(t+1);


        }


        cout<<answer<<"\n";

    }



return 0;}


Measured memory_bytes: 256
import collections
N,M = map(int,input().split())
road = [[] for _ in range(N+1)]
for _ in range(M):
    A,B = map(int,input().split())
    road[A].append(B)
    road[B].append(A)

no_visit =set(range(1,N+1))
q = collections.deque([])
cnt = 0
while no_visit:
    q.append(no_visit.pop())
    cnt +=1
    while q:
        now = q.popleft()
        for nxt in road[now]:
            if nxt in no_visit:
                q.append(nxt)
                no_visit.discard(nxt)
print(cnt-1)
    


Measured memory_bytes: 34168
import sys

input = sys.stdin.readline


def main():
    N, x = map(int, input().split())
    A = list(map(int, input().split()))

    ans = 0
    for i in range(N - 1):
        if A[i] + A[i + 1] <= x:
            continue
        if A[i] >= x:
            ans += (A[i] - x) + A[i + 1]
            A[i] = x
            A[i + 1] = 0
        else:
            ans += (A[i] + A[i + 1] - x)
            A[i + 1] = x - A[i]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19888
#!/usr/bin/env python3
import sys


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    N, M = IL(int)
    print(N * M)

solve()


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

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

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

  int n, m; cin >> n >> m;
  // vector<int> 型の配列
  vector<int> task[100010];
  rep(i, n) {
    int a, b; cin >> a >> b;
    task[a].push_back(b);
  }

  ll ans = 0;
  priority_queue<int> que;
  for(int i = 1; i <= m; i++) {
    // i 日かかるうち最大賃金順にソート
    for(auto e : task[i]) que.push(e);
    if(que.size()) {
      ans += que.top();
      que.pop();
    }
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 5632
n = int(input())
t = [int(x) for x in input().split()]
s=sorted(t)
deep,a,b,c = 0,1,0,1
for i in range(n):
  if s[i] == deep:
    b += 1
  elif i == n:
    c *= a ** b
  elif s[i] == deep + 1:
    c *= a ** b
    a = b
    b = 1
    deep += 1
  else:
    c = 0
    break
    
  if i == n-1:
    if s[i] == deep:
      c *= a ** b
      c = c % 998244353
    elif s[i] == deep + 1:
      c *= a ** b
      c = c % 998244353
    else:
      c = 0
      break

if s.count(0) != 1:
  print(0)
elif t[0] != 0:
  print(0)
else:
  print(c)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A * N, B) <<endl;
} 


Measured memory_bytes: 3652
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring> 
using namespace std;
int n,m,k,l;
int a[4];
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3,cmp);
	int s = a[0]*10+a[1]+a[2];
	cout<<s;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin>>a>>b;
  b*=2;
  b++;
  cout<<(a+b-1)/b<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#define elif else if
#define pb push_back
typedef long long ll;
const int INF=0x3f3f3f3f;

using namespace std;
int a[201000];
signed main(){
	std::ios::sync_with_stdio(false);
	int n;cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	int now=0;ll ans=0;
	for(int l=1,r=1;r<=n;++r){
		while(now&a[r])now^=a[l++];
		now|=a[r];
		ans+=r-l+1;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

    int count = 0;

    for(int i = a; i <= b; i++){
        if(c % i == 0){
            count++;
        }
    }
    cout << count++ << endl;
    return 0;
}


Measured memory_bytes: 3116