akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : abc130_a.cpp
// Author      : abb
// Version     :
// Copyright   : [My copyright notice]
// Description : Hello World in C++, Ansi-style
//============================================================================

/*
 A - Rounding

 実行時間制限: 2 sec / メモリ制限: 1024 MB

 配点 : 100 点

 問題文
 X, A は 0 以上 9 以下の整数です。
 X が A 未満の時 0、A 以上の時 10 を出力してください。

 制約

 ・0 <= X, A <= 9
 ・入力は全て整数である
 */

#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

using ll = long long;
using ull = unsigned long long;

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

/**
 * エントリポイント．
 * @return 0.
 */
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int x, a;
	cin >> x >> a;

	cout << (x < a ? 0 : 10) << endl; // prints [!!!Hello World!!!]
	return 0;
}


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

int main() {
  long long n;
  long long a[5];
  cin >> n;
  for(int i;i<5;i++){
    cin >> a[i];
  }
  sort(a,a+5);
  cout << (n-1)/a[0] + 5 << endl;
}


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


def solve(N: int, s: "List[str]"):

    result = 0
    str_dict = dict()
    for s_i in s:

        s_i = list(s_i)
        s_i.sort()
        s_i = "".join(s_i)

        if s_i in str_dict:
            result += str_dict[s_i]
            str_dict[s_i] += 1
        else:
            str_dict[s_i] = 1

    print(result)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, s)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24980
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
 
int main() {
    int n;
    scanf("%d",&n);
    vector <int> a(n);
    rep(i,n)    scanf("%d",&a[i]);

    int ans=0;
    int res=0;
    rep(i,n) {
        if(a[i]!=i+1-ans) {
            ans++;
        }
    }
    if(ans==n)   printf("%d",-1);
    else    printf("%d",ans);

 return 0;
}

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

vector<vector<long> > vec(200001);
vector<long> res(200001);

int main() {
    long n, q;
    cin >> n >> q;

    vector<long> parent(n + 1);
    for (long i = 0; i < n - 1; i++) {
        long a, b;
        cin >> a >> b;

        parent[b] = a;
    }

    vector<long> score(n + 1);
    for (long i = 0; i < q; i++) {
        long p, x;
        cin >> p >> x;
        score[p] += x;
    }

    for (long i = 1; i <= n; i++) {
            score[i] += score[parent[i]];
            cout << score[i] << endl;
    }
}

Measured memory_bytes: 13312
#include <stdio.h>
int main(void){
    int n,s,x,a[10],e[11],c,i,j,m;
    while(~scanf("%d%d",&n,&s)){
        x=c=m=0;
        for(i=0;i<11;i++)e[i]=0;
        for(i=0;i<n;i++){
            a[i]=n-i-1;
            e[a[i]]=1;
            x+=a[i]*(i+1);
        }
        if(s>330) m=n;
        do{
            if(x==s)c++;
            if(x>=s)m++;
            for(i=0;i<n;i++){
                x-=a[i]*(i+1);
                e[a[i]]=0;
                if(i<m)continue;
                if(i==0)
                    a[i]=(s-x<10&&!e[s-x]?s-x:10);
                else
                    do{a[i]++;}while(e[a[i]]);
                if(a[i]>9){m++;continue;}
                e[a[i]]=1;
                x+=a[i]*(i+1);
                for(i--;i>=0;i--){
                    for(j=0;j<10;j++){
                        if(e[j])continue;
                        a[i]=j;
                        e[a[i]]=1;
                        x+=a[i]*(i+1);
                        break;
                    }
                }
                if(x>s) {
                    m++;
                    if(m>=n) break;
                    continue;
                }
                m=0;
                break ;
            }
        } while(m<n);
        printf("%d\n",c);
    }
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>
#include<math.h>
#include"boost/algorithm/string.hpp"

using namespace std;

struct test_t{
	unsigned long long target;
	unsigned long long state;
	long long diff;
	int change;

	friend bool operator<(const test_t& l, const test_t& r)
	{
		return l.diff < r.diff;
	}
};

int main(){
		

	/*Q3*/
	/*Q1*/
	//typedef
	
	int ret = 0;
	int in[4] = {0};
	int total, a, b, max, min;
	
	cin >> total >> a >> b;

	max = a > b ? b : a;

	if (a + b > total){
		min = a + b - total;
	}
	else{
		min = 0;
	}

	cout << max << " " << min;

	return 0;
	/*Q2*/

	/*Q3*/

		/*Q4*/

		//return 0;
}


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

/* Faulty First Draft : Forgot the long long Datatype for DP */

long long get_sum(vector<long long> &prefix, int left, int right)
{
	if(left != 0)
		return prefix[right] - prefix[left-1];
	else
		return prefix[right];
}

void Deque(vector<long long> &a)
{
	int n = a.size();

	vector<long long> prefix = a;

	for(int i = 1; i < n; i++)
		prefix[i] += prefix[i-1];
	
	vector<vector<long long>> dp(n, vector<long long>(n, 0));

	/* dp[i][j] is the maximum value that the starting player of the game can get 
	 * if the game only has the elements arr[i...j] 
	 */

	for(int i = n-1;  i >= 0; i--)
	{
		for(int j = i; j < n; j++)
		{
			int len = j - i + 1;

			if( len == 1)
			{
				dp[i][j] = a[i];
				continue;
			}
			
			// Faulty First Draft. Wrote get_sum(i, j) in both places
			long long pick_first = a[i] + get_sum(prefix, i+1, j) - dp[i+1][j];
			long long pick_last = a[j] + get_sum(prefix, i, j-1) - dp[i][j-1];

			dp[i][j] = max(pick_first, pick_last);
		}
	}
	
	// After simplification, (x-y) =  ( 2*x - total_sum) 
	cout << 2*dp[0][n-1] - get_sum(prefix, 0, n-1) << endl;
}

int main()
{
	int n;
	cin >> n;
	
	vector<long long> a(n);
	for(auto &ele : a)
		cin >> ele;

	Deque(a);
	return 0;
}


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

using namespace std;

const int MAXN=100000;

int n;
long long a[MAXN+10];
long long b[MAXN+10];
long long c[MAXN+10];
long long dp[MAXN+10][4];

void init(){
	int i,j;
	cin>>n;
	for (i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for (i=1;i<=n;i++)cin>>b[i];
	sort(b+1,b+n+1);
	for (i=1;i<=n;i++)cin>>c[i];
	sort(c+1,c+n+1);
}

void solve(){
	int i,j;
	for (i=1;i<=n;i++)dp[i][1]=i;
	for (i=1;i<=n;i++){
		int left=1,right=n,mid;
		while (left<=right){
			mid=(left+right)/2;
			if (b[i]<=a[mid]){
				right=mid-1;
			}
			else {
				left=mid+1;
			}
		}
		dp[i][2]=dp[i-1][2]+dp[right][1];
	} 
	for (i=1;i<=n;i++){
		int left=1,right=n,mid;
		while (left<=right){
			mid=(left+right)/2;
			if (c[i]<=b[mid]){
				right=mid-1;
			}
			else {
				left=mid+1;
			}
		}
		dp[i][3]=dp[i-1][3]+dp[right][2];
	} 
}

void output(){
	cout<<dp[n][3]<<endl;
}

int main()
{
	init();
	solve();
	output();
	return 0;
}


Measured memory_bytes: 5760
from sys import stdin
N, W = map(int, input().split())
s = list(list(map(int, line.split())) for line in stdin.read().splitlines())

sumv = sum(s[i][1] for i in range(N))

INF = 10e12
dp = [INF] * (sumv + 1)  # minimum w required to achieve  value V. dp[v] = w
dp[0] = 0

for n in range(N):
    w0, v0 = s[n]
    for v in range(sumv, v0 - 1, -1):
        dp[v] = min(dp[v], dp[v - v0] + w0)

for i in range(sumv, -1, -1):
    if dp[i] <= W:
        print(i)
        break


Measured memory_bytes: 91988
#include<cstdio>

typedef long long ll;
const int maxn = 300010;
const ll mod = 998244353;

ll n,a,b,k;
ll fac[maxn],inv[maxn];

ll qpow_mod(ll x,ll n){
	int s = 1;
	while(n){
		if(n&1) s=s*x % mod;
		x = x*x % mod;
		n >>= 1;
	}
	return s;
}
void csh(){
	fac[0] = 1;
	for(int i = 1; i<=300000; i++) fac[i] = fac[i-1]*i % mod;
	inv[300000] = qpow_mod(fac[300000],mod-2);
	for(int i = 300000; i>0; i--) inv[i-1] = inv[i]*i % mod;
}
ll C(ll n, ll a){
	return fac[n]*inv[a] %mod * inv[n-a] %mod; 
}
int main()
{
	csh();
	ll ans = 0;
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	for(int i = 0; i<=n; i++){
		if((k - a*i)%b != 0 || (k - a*i)/b > n || (k - a*i)<0)continue;
		ans = (ans + C(n,i)*C(n,(k-a*i)/b))%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
	int n, a[11], count = 1;
	cin >> n;
	ll memo = pow(3, n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0)count *= 2;
	}
	cout << memo - count << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int D = 365;
const int NTYPE = 26;
array<int, NTYPE> c;
array<array<int, NTYPE>, D> s;

void input(){
    int _d;
    cin >> _d;
    REP(i, NTYPE){
        cin >> c.at(i);
    }
    REP(i, D){
        REP(j, NTYPE){
            cin >> s.at(i).at(j);
        }
    }
}

void output(const array<int, D>& sch){
    for(auto x : sch){
        cout << x + 1 << endl;
    }
}

int calc_satisfaction(const array<int, D>& sch){
    int ret = 0;
    array<int, NTYPE> last;
    fill(ALL(last), 0);
    REP(i, D){
        const int cur_d = i + 1;
        const int t = sch.at(i);
        ret += s.at(i).at(t);
        last.at(t) = cur_d;
        REP(j, NTYPE){
            ret -= c.at(j) * (cur_d - last.at(j));
        }
    }
    return ret;
}

void solve(){
    array<int, D> ans;
    array<int, NTYPE> last;
    fill(ALL(last), 0);

    ll score = 0;
    REP(i, D){
        const int cur_d = i + 1;
        int max_type = -1;
        int max_val = numeric_limits<int>::min();
        REP(j, NTYPE){
            int tmp = s.at(i).at(j) + c.at(j) * (cur_d - last.at(j));
            if(max_val < tmp){
                max_type = j;
                max_val = tmp;
            }
        }
        assert(max_type != -1);
        ans.at(i) = max_type;
        score += s.at(i).at(max_type);
        last.at(max_type) = i + 1;
    }

    int cur_score = calc_satisfaction(ans);
    REP(i, 10){
        REP(j, D){
            int best_k = ans.at(j);
            int best_score = cur_score;
            REP(k, NTYPE){
                if(ans.at(j) == k){ continue; }
                const int cur_k = ans.at(j);
                ans.at(j) = k;
                const int tmp = calc_satisfaction(ans);
                ans.at(j) = cur_k;
                if(tmp > best_score){
                    best_k = k;
                    best_score = tmp;
                }
            }
            ans.at(j) = best_k;
            cur_score = best_score;
        }
    }
    // cerr << calc_satisfaction(ans) << endl;
    output(ans);
}

int main(){
    input();
    solve();
    return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

/////////////         modの計算

int mod = 1000000007;

ll mod_adjust(ll a) {//	余りをとる(0～mod-1に調整する)
	if (a >= mod) {
		return a % mod;
	}
	if (a < 0) {
		a *= -1;
		a %= mod;
		return mod - a;
	}
	return a;
}
int mod_add(int a, int b) {//	足し算
	ll k = mod_adjust((ll)a); k += mod_adjust((ll)b);
	k = mod_adjust(k);
	return (int)k;
}
int mod_sub(int a, int b) {//	引き算
	return mod_add(a, -b);
}
int mod_multi(int a, int b) {//	掛け算
	ll k = mod_adjust((ll)a);
	k *= mod_adjust((ll)b);
	k = mod_adjust(k);
	return (int)k;
}
int mod_inv(int a) {//	逆元
	ll k = (int)mod_adjust((ll)a);
	if (k == 0) { return 0; }
	if (k == 1) { return 1; }
	ll p = mod, q = k, m = 0, n = 1, r, c;

	while (q > 1) {
		r = p % q;
		c = p / q;
		c = mod_adjust(m - n * c);
		p = q, m = n, q = r, n = c;
	}
	return (int)mod_adjust(n);
}
int mod_div(int a, int b) {//	割り算
	return mod_multi(a, mod_inv(b));
}
int mod_pow(int x, int n) {//	累乗(logNオーダーなので速い)
	x = (int)mod_adjust((ll)x);
	n = n % (mod - 1);
	if (n < 0) {
		return mod_pow(mod_div(1, x), -n);
	}
	if (n == 0) {
		return 1;
	}
	if (n == 1) {
		return (int)mod_adjust((ll)x);
	}
	if (n % 2 == 0) {
		int k = mod_pow(x, n / 2);
		return mod_multi(k, k);
	}
	else {
		int k = mod_pow(x, n / 2);
		return mod_multi(mod_multi(k, k), x);
	}
}

int* factorial = NULL;			//	階乗
int* factorial_inv = NULL;		//	階乗の逆元

//	階乗を事前に計算しておく関数。
//	Nはmod_combination(n, r)で呼び出されうる最大の数。
void calc_factorial(int N) {////////////////////////// 初めに必ず呼び出すこと！！！
	N = min(mod - 1, N);
	factorial = new int[N + 1];
	factorial_inv = new int[N + 1];

	factorial[0] = 1;
	factorial_inv[0] = 1;
	for (int i = 1; i <= N; i++) {
		factorial[i] = mod_multi(factorial[i - 1], i);
		factorial_inv[i] = mod_inv(factorial[i]);
	}
}

int main() {
	int N, X; cin >> N >> X;

	calc_factorial(N + 1);

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

	S.push_back(1000000);

	int** blue = new int* [N + 1];
	int** red = new int* [N + 1];

	for (int i = 0; i < N + 1; i++) {
		blue[i] = new int[X + 1];
		red[i] = new int[X + 1];
		
		for (int j = 0; j < X + 1; j++) {
			blue[i][j] = 0;
			red[i][j] = 0;
		}
	}

	blue[N][X] = mod_div(1, N);

	for (int i = N - 1; i >= 0; i--) {
		for (int j = 0; j < X + 1; j++) {// blue
			blue[i][j] = mod_add(blue[i][j], mod_multi(i + 1, blue[i + 1][j]));
			blue[i][j] = mod_add(blue[i][j], red[i + 1][j]);
		}
		for (int j = 0; j < X + 1; j++) {// red
			red[i][j % S[i]] = mod_add(red[i][j % S[i]], mod_multi(i + 1, blue[i + 1][j]));
			red[i][j % S[i]] = mod_add(red[i][j % S[i]], red[i + 1][j]);
		}
	}

	int ans = 0;
	for (int i = 0; i < X + 1; i++) {
		ans = mod_add(ans, mod_multi(i, red[0][i]));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 157824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string s;
    cin>>s;
    ll ans=0,cnt=0;
    for(int i=1;i<s.size();i++){
        if(s[i]=='C'&&s[i-1]=='B'){
            ans+=cnt;
            i++;
        }
        else if(s[i-1]=='A') cnt++;
        else cnt=0;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
import numpy as np
                                                               
def ketawa(x):
    return sum(list(map(int, str(x))))
                                                               
N, A, B = map(int, input().split())
new_func = np.frompyfunc(ketawa, 1, 1)
arr = np.arange(1, N + 1)
result = new_func(arr)
print(np.sum(np.where((A <= result) & (result <= B), arr, 0)))

Measured memory_bytes: 27672
#include <stdio.h>

int main()
{
     unsigned long x, a, b;
     scanf("%lu %lu %lu", &x, &a, &b);

     unsigned long d; 

     if(a < b)
     {
          d = b - a;
          if(d <= x) printf("safe\n");
          else printf("dangerous\n");
     }
     else
     {
          printf("delicious\n");
     }
          

     return 0;
}

Measured memory_bytes: 128
def main():
    n, k = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]

    for i in range(n - k):
        if A[i] < A[k + i]:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


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

int main() {
    int64_t N, M;
    cin >> N >> M;
    vector<pair<int64_t, int64_t> > AB;

    for (size_t i = 0; i < N; i++) {
        int64_t a, b;
        cin >> a >> b;
        AB.push_back(make_pair(a, b));
    }

    sort(AB.begin(), AB.end());

    int64_t count = 0, money = 0;
    for(size_t i = 0; i < N; i++) {
        if (M - count >= AB[i].second) {
            count += AB[i].second;
            money += AB[i].first * AB[i].second;
        } else {
            money += AB[i].first * (M - count);
            break;
        }
    }

    cout << money << endl;
}

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


int main(){
	int a,b;
	
	scanf("%d %d", &a,&b);
	
	int tambah=a+b;
	int kurang=a-b;
	int kali=a*b;
	
	printf("%d\n", tambah>=kurang&&tambah>=kali?tambah:(kurang>=kali&&kurang>=tambah?kurang:kali));
	
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = input().split()
b = input().split()

sum = 0
kuriage = 0
for i in range(n):
  if int(b[i]) + kuriage > int(a[i]):
    sum += int(a[i])
    kuriage = kuriage - int(a[i])
    if kuriage > 0:
      kuriage = 0
    kuriage += int(b[i])
    #print("amaru"+a[i])
  else:
    sum += int(b[i]) + kuriage
    #print(int(b[i]) + kuriage)
    kuriage = 0

  #print(kuriage)
    
if kuriage > 0:
  sum += min(kuriage,int(a[n]))
    
print(sum)

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

int main(){
    long int A,i,temp,ans;
    cin>>A;
    ans=A+1;
    for(i=1;i>0;i++){
        if(i*i>A){
            break;
        }
        if(A%i==0){
            temp=i+A/i;
            if(ans>temp){
                ans=temp;
            }
        }
    }
    cout<<ans-2;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <vector>
#define eps 1e-8
#define INF 0x3f3f3f
using namespace std;
const int maxn=1e5+5;
int n,t,a[maxn],b[maxn],ans;
int main ()
{
	while(~scanf("%d",&n))
	{
		ans=INF;
		for(int i=1;n-i>=i;i++)
		{
			int dig1=0,dig2=0,x=i,y=n-i;
			while(x)
			{
				dig1+=(x%10);
				x/=10;
			}
			while(y)
			{
				dig2+=(y%10);
				y/=10;
			}
			ans=min(ans,dig1+dig2);
		}
		printf("%d\n",ans);
	}
}

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

using namespace std;

int h,w;
char s[405][405];
bool v[405][405];
long long a,b,ans;
void dfs(int x,int y){
	v[x][y]=1;
	if(s[x][y]=='#')a++;
	else b++;
	if(x>1&&v[x-1][y]==0&&s[x-1][y]!=s[x][y])dfs(x-1,y);
	if(x<h&&v[x+1][y]==0&&s[x+1][y]!=s[x][y])dfs(x+1,y);
	if(y>1&&v[x][y-1]==0&&s[x][y-1]!=s[x][y])dfs(x,y-1);
	if(y<w&&v[x][y+1]==0&&s[x][y+1]!=s[x][y])dfs(x,y+1);
}
int main()
{
	cin>>h>>w;
	for(int i=1;i<=h;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(v[i][j]==0){
				a=b=0;
				dfs(i,j);
				ans+=a*b;
			}
	printf("%lld",ans);
}


Measured memory_bytes: 13056
from collections import defaultdict
N, K = map(int, input().split())
A = list(map(int, input().split()))

d = defaultdict(int)
for i in range(N):
  d[A[i]] += 1
  
cnt = len(d.keys()) - K
d = sorted(d.items(), key=lambda x:x[1])
ans = 0
for val in d:
  if cnt <= 0:
    print(ans)
    exit()
  ans += val[1]
  cnt -= 1

Measured memory_bytes: 39344
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin>>N;
    int n1=0,n2=0,n4=0;
    for(int i=0;i<N;i++){
    	int t;
    	cin>>t;
    	if(t%4==0){
    		n4++;
		}else if(t%2==0){
			n2++;
		}else{
			n1++;
		}
	}
	if(n1==n4){
		cout<<"Yes";
	}else if(n1-n4==1&&n2==0){
		cout<<"Yes";
	}else if(n4>n1){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

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

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        Int N = 4;
        vector<Int> v(4);
        for (int i = 0; i < 3; ++i) {
            Int a, b;
            cin >> a >> b;
            a--, b--;
            v[a]++;
            v[b]++;
        }

        sort(all(v));

        if (v == vector<Int>{1, 1, 2, 2}) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }


    }
};


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

    Solve().solve();


    return 0;
}


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

int main(){
  int N,T,A;
  cin >> N >> T >> A;
  int h,t;
  int near=0,near_t = 1<<30;
  for(int i=1;i<=N;i++){
    cin >> h;
    t =abs((T*1000-h*6)-A*1000);
    if(t<near_t) {near=i; near_t = t;}
  }
  cout << near << endl;
}    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==1) a=14;
  if(b==1) b=14;
  if(a>b) cout<<"Alice"<<endl;
  else if(b>a) cout<<"Bob"<<endl;
  else cout<<"Draw"<<endl;
  return 0;
}


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

#define MAX 300

int main(){
    int H, A[MAX];
    cin >> H;

    //1オリジンの配列に格納
    for(int i = 1; i <= H; i++){
        cin >> A[i];
    }

    for(int i = 1; i <= H; i++){
        cout << "node " << i << ": ";
        cout << "key = " << A[i] << ", ";
        if(i-1) cout << "parent key = " << A[i/2] << ", ";
        if(2*i <= H) cout << "left key = " << A[2*i] << ", ";
        if(2*i + 1 <= H) cout << "right key = " << A[2*i + 1] << ", ";
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3048
#include <cstdio>
#include <vector>

using namespace std;

int abs(int x) {
  return x < 0 ? -x : x;
}

int main() {
  int n, x;
  vector <int> h, dp;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    h.push_back(x);
  }

  dp.resize(n);
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  for (int i = 2; i < n; i++)
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i - 2] - h[i]));
  printf("%d\n", dp[n - 1]);
  return 0;
}


Measured memory_bytes: 1144
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);
//#define Local = 1;
#ifdef Local
#define debug(x) cout << __LINE__ << " " << #x <<"..." << x << endl
#define dev(x) cout << __LINE__ << " " << #x << "..." ; for(auto &it : x) cout<< it << " "; cout << endl;
#define des(x) cout << __LINE__ << " " << #x << "..." << x << endl;
#else
#define debug(x) ;
#define dev(x);
#define des(x)
#endif

const double PI = 3.141592653589793;

void solve()
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++) cin >> a[i];
	int ans = a[0];
	for(int i=0;i<n;i++)
	{
		ans = __gcd(ans,a[i]);
	}
	cout << ans ;
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T = 1;
	while(T--) solve();
	return 0;
}



Measured memory_bytes: 4408
import std.stdio, std.string, std.conv, std.array, std.algorithm, std.range, std.typecons, std.numeric, std.math;

void main() {
    long n = readln.strip.to!long;
    auto ps = readln.strip.split(" ").to!(long[]).array;

    long cnt = 0;
    foreach (i; 0..n) {
        if (ps[i] != i+1) {
            cnt++;
        }
    }

    if (cnt <= 2) {
        writeln("YES");
    } else {
        writeln("NO");
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = Integer.MAX_VALUE;
        for (int i = 1; i <= n / 2; i++) {
            min = Math.min(min, getDigitSum(i) + getDigitSum(n - i));
        }
       System.out.println(min);
    }
    
    static int getDigitSum(int x) {
        int ans = 0;
        while (x > 0) {
            ans += x % 10;
            x /= 10;
        }
        return ans;
    }
}


Measured memory_bytes: 21712
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
int main() {
	using namespace std;
	int n, x, y;
	cin >> n >> x >> y;
	x; y;
	vector<int> l;
	l.resize(n);
	// k=1
	//cout << n << endl;

	for (int i = 1; i < n+1; i++) {
		for (int j = i + 1; j < n+1; j++) {

			int k = min({ (j - i), abs(x - i) + 1 + abs(j - y), abs(i-x)+1+abs(j-y) });

			l[k]++;
		}
	}
	l.erase(l.begin());
	//l[0] = n;
	for (auto e : l) {
		cout << e << endl;
	}
	return 0;
}

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

int main(){
  int N;
  string S;
  cin>>N>>S;
  int ans=0;
  for(int i=0;i<N-2;i++){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, k;
	cin >> n >> k;
	
	vector<double> sum(n + 1, 0.0);
	for(int i = 0; i < n; ++i) {
		int p;
		cin >> p;
		
		sum[i + 1] = sum[i] + (double)((p + 1)) / 2.0;
	}
	
	double ans = 0.0;
	for(int i = 0; i < n - k + 1; ++i) {
		ans = max(ans, (sum[i + k] - sum[i]));
	}		

	printf("%.12f\n", ans);
	
	return 0;
}


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

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

    int n;
    long long k;
    cin >> n >> k;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
        A[i]--;
    }

    if(k < n){
        int now = 0;
        for(int i = 0; i < k; i++){
            now = A[now];
        }
        cout << now + 1 << endl;
        return 0;
    }

    int now = 0;
    vector<int> T(n, -1);
    T[0] = 0;
    int li = 0;
    for(int i = 1; i < n; i++){
        li = i;
        now = A[now];
        if(T[now] != -1){
            break;
        }
        T[now] = i;
    }

    int diff = li - T[now];
    k -= li;
    k %= diff;

    for(int i = 0; i < k; i++){
        now = A[now];
    }

    cout << now + 1 << endl;

    return 0;
}


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

bool used[26];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    char a[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
        'n','o','p','q','r','s','t','u','v','w','x','y','z'};
    if(s.length() < 26){
        for(int i = 0; i < s.length(); i++){
            for(int j = 0; j < 26; j++){
                if(s[i] == a[j]) used[j] = true;
            }
        }
        for(int i = 0; i < 26; i++){
            if(!used[i]){
                cout << s << a[i] << endl;
                return 0;
            }
        }
    }
    for(int i = 24; i >= 0; i--){
        if(s[i] < s[i+1]){
            char q = 'z';
            for(int j = i+1; j < 26; j++){
                if(s[i] < s[j] && q > s[j]) q = s[j];
            }
            for(int j = 0; j < i; j++){
                cout << s[j];
            }
            cout << q << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

int main(){
	int i,j,r,c,date[101][101]={0};
	char input[1024],*num;
	
	fgets(input,sizeof(input),stdin);
	sscanf(input,"%d %d",&r,&c);
	
	fgets(input,sizeof(input),stdin);
	num=strtok(input," ");
	date[0][0]=atoi(num);
	
	date[0][c]+=date[0][0];
	date[r][0]+=date[0][0];
	date[r][c]+=date[0][0];
	for(i=0;i<r;i++){
		if(i!=0){
			fgets(input,sizeof(input),stdin);
			num=strtok(input," ");
			date[i][0]=atoi(num);
			
			date[i][c]+=date[i][0];
			date[r][0]+=date[i][0];
			date[r][c]+=date[i][0];
		}
		for(j=1;j<c;j++){
			num=strtok(NULL," ");
			date[i][j]=atoi(num);
			
			date[i][c]+=date[i][j];
			date[r][j]+=date[i][j];
			date[r][c]+=date[i][j];
		}
	}
	
	for(i=0;i<r+1;i++){
		for(j=0;j<c+1;j++){
			printf("%d",date[i][j]);
			if(j!=c){
				printf(" ");
			}
		}
		printf("\n");
	}
	
	
	return 0;
}

Measured memory_bytes: 656
A,B,M=map(int,input().split(" "))

a=list(map(int,input().split(" ")))
b=list(map(int,input().split(" ")))
#aは冷蔵庫の値段列
#bは電子レンジの値段列

x=[]
y=[]
m=[]

for i in range(M):
    kari=input().split(" ")
    x.append(int(kari[0]))
    y.append(int(kari[1]))
    m.append(int(kari[2]))

waribiki=[]

for i in range(M):
    waribiki.append(a[x[i]-1]+b[y[i]-1]-m[i])

aa=min(waribiki)
bb=min(a)+min(b)

print(min(aa,bb))


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

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

int main() {
  int N;

  cin >> N;

  ll l = 1, r = 100000, m;

  while (r - l > 1) {
    m = (r + l) / 2;

    if (m * m <= N) {
      l = m;
    }
    else {
      r = m;
    }
  }

  cout << l * l << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin.env python

n,d = map(int, input().split())
n = int(n)
d = int(d)

x = []

for i in range(n):
    x_t = input().split()
    for j,k in enumerate(x_t):
        x_t[j] = int(x_t[j])
    x.append(x_t)

c = 0
for i,j in enumerate(x):
    for a,b in enumerate(x[i+1:]):
        dis = 0
        for m,n in enumerate(j):
            dis += (j[m] - b[m])**2
        dis = dis ** (1/2)
        if dis.is_integer() == True:
            c += 1

print(c)

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

bool operator!=(std::pair<int, int> const &lhs, std::pair<int, int> const &rhs)
{
    return lhs.first != rhs.first || lhs.second != rhs.second;
}

int main()
{
    int H, W, M;
    std::cin >> H >> W >> M;
    std::vector<int> target_x(W + 1);
    std::vector<int> target_y(H + 1);
    std::vector<std::pair<int, int>> map;
    map.reserve(M);
    int max_x = 0;
    int max_y = 0;
    for (int i = 0; i < M; i++)
    {
        int h, w;
        std::cin >> h >> w;
        map.emplace_back(std::make_pair(w, h));
        target_x[w]++;
        target_y[h]++;
        if (target_x[w] > max_x)
        {
            max_x = target_x[w];
        }
        if (target_y[h] > max_y)
        {
            max_y = target_y[h];
        }
    }
    int count_xy = 0;
    for (auto const &e : map)
    {
        if (target_x[e.first] == max_x && target_y[e.second] == max_y)
            count_xy++;
    }
    int count_x_ = std::count(target_x.begin(), target_x.end(), max_x);
    int count_y_ = std::count(target_y.begin(), target_y.end(), max_y);

    if (count_xy == count_x_ * count_y_)
    {
        std::cout << max_x + max_y - 1 << std::endl;
    }
    else
    {
        std::cout << max_x + max_y << std::endl;
    }
}

Measured memory_bytes: 8008
#include <iostream>

using namespace std;

int main() {
    int a, b, c, i, ans;
    cin >> a >> b >> c;
    ans = 0;
        for(i=a; i<=b; i++)
        {
          if(c % i == 0)
           ans++;
        }
        cout<< ans << endl;
}


Measured memory_bytes: 3112
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>

using namespace std;
long long a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(b>=a){cout<<1<<' '<<endl;return 0;}
	if(b<=c){cout<<-1<<endl;return 0;}
	if((a-b)%(b-c)==0)cout<<(a-b)/(b-c)*2+1<<endl;
	else cout<<a/(b-c)*2+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int n, y, k;
	scanf("%d%d", &n, &y);
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			k = n - i - j;
			if (k >= 0 && i * 10000 + j * 5000 + k * 1000 == y) {
				printf("%d %d %d\n", i, j, k);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 128
package main
import "fmt"
func main(){
    var n, l int
    fmt.Scan(&n, &l)
    sum := l * n + n * (n - 1) / 2
    if l <= 0 && (n + l - 1) >= 0 {
        fmt.Println(sum)
    }else if l > 0 {
        fmt.Println(sum - l)
    }else{
        fmt.Println(sum - (n + l - 1))
    }
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
//每一行的棋子
void chess(int a){
    if(a%2==0)
    cout<<".";
    else
    cout<<"#";
}
//第b行的棋盘
void chessboard(int a,int b){
    if(a%2==0){
        for(int i=0;i<b;i++)
            chess(i);
            cout<<endl;
    }
    else{
        for(int i=1;i<=b;i++)
            chess(i);
            cout<<endl;
    }
}

int main(){
    int a,b;
    while(cin>>a>>b){
        if(a==0&&b==0)
            break;

        for(int i=1;i<=a;i++)
                chessboard(i,b);
            cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3116
A,B,C,D = map(int,input().split())

def judge(ans):
	if ans > 0:
		print(ans)
	else:
		print(0)

if A < C :
	if B < D: 
		judge(B-C)
	else: 
		judge(D-C)
else:
	if B > D:
		judge(D-A)
	else:
		judge(B-A)



Measured memory_bytes: 2940
n=int(input())
lst=list(map(int,input().split()))
min_lst=sorted(lst)
ans=[]

for i in range(min_lst[0],min_lst[-1]+1):
  #print("O",i)
  sum=0
  for j in lst:
    sum+=(i-j)**2
    #print("A",sum)
  ans.append(sum)
  #print("B",ans)
print(min(ans))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	int arr[10000];
	int cnt = -1;
	do{
		cnt++;
		scanf("%d",&arr[cnt]);
	}while(arr[cnt] != 0);
	for(int i = 0; i < cnt; i++){
		printf("Case %d: %d\n",i+1,arr[i]);
	}
	return 0;
}



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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll n; cin >> n;
  if (n % 2 == 1) {
    cout << "0\n";
    return 0;
  }
  ll cnt = 0;
  ll div = 10;
  while (div <= n) {
    cnt += n / div;
    div *= 5;
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbg(x) cerr << ">>> " << x << endl
#define _ << ", " <<

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int solve1(std::vector<int> a) {
  int ans = 0;
  std::sort(a.begin(), a.end());
  for(int k = 30; k >= 0; k--) {
    int n = (int) a.size();
    std::vector<bool> got(n, false);
    for(int l = 0, r = n - 1; l < n; l++) {
      if(got[l]) continue;
      while(r >= 0 && a[l] + a[r] > (1 << k)) r--;
      while(r >= 0 && got[r]) r--;
      if(l >= r) break;
      if(!got[l] && !got[r] && a[l] + a[r] == (1 << k)) {
        got[l] = got[r] = true;
        ans++;
      }
    }
    std::vector<int> b;
    for(int i = 0; i < n; i++) {
      if(!got[i]) b.push_back(a[i]);
    }
    a.swap(b);
  }
  return ans;
}

int solve2(std::vector<int> a) {
  int ans = 0;
  std::sort(a.begin(), a.end());
  for(int k = 0; k <= 30; k++) {
    int n = (int) a.size();
    std::vector<bool> got(n, false);
    for(int l = 0, r = n - 1; l < n; l++) {
      if(got[l]) continue;
      while(r >= 0 && a[l] + a[r] > (1 << k)) r--;
      while(r >= 0 && got[r]) r--;
      if(l >= r) break;
      if(!got[l] && !got[r] && a[l] + a[r] == (1 << k)) {
        got[l] = got[r] = true;
        ans++;
      }
    }
    std::vector<int> b;
    for(int i = 0; i < n; i++) {
      if(!got[i]) b.push_back(a[i]);
    }
    a.swap(b);
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for(int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  std::cout << std::max(solve1(a), solve2(a)) << '\n';
  return 0;
}

Measured memory_bytes: 5572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		
		int count = 0;
		
		for(int i = a; i<=b; i++) {
			
			if(c%i == 0 ) {
				
				count=count+1;
			
			}
				
				
			
		}
		System.out.println(count); 
	}
}


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

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

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

  int mi = 1e9, id;
  for ( int i = 0; i < N; i++ ) {
    if ( mi > abs(sum - a[i]*N) ) {
      mi = abs(sum - a[i]*N);
      id = i;
    }
  }

  cout << id << endl;

  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n; cin >>n;
  int c[10][10]; memset(c,0,sizeof(c));
  for(int i=1; i<=n; i++){
    int x=i,y=i%10;
    while(x>9) x/=10;
    c[x][y]++;
  }
  int ans=0;
  for(int i=1; i<10; i++) for(int j=1; j<10; j++) ans+=c[i][j]*c[j][i];
  cout <<ans;
}

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

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B_013_48
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            new Logic_A().Start();

        }

        public class Logic_A
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var a = str[0];
                var b = str[1];
                var c = str[2];

                Console.WriteLine("A" + b[0].ToString().ToUpper() + "C");
            }
        }
    }
}

Measured memory_bytes: 13140
ABCD=list(map(int,input().split()))
A=ABCD[0]
B=ABCD[1]
C=ABCD[2]
D=ABCD[3]

E=list(range(A,B+1))
F=list(range(C,D+1))

if len(list(set(E)&set(F)))==0:
    print(0)
else:
    print(len(list(set(E)&set(F)))-1)


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007LL
#define INF INT32_MAX / 2
#define PIE 3.14159265358979323

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>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

template <class T>
void MODinit(T MAX, T M, vector<T> &fac, vector<T> &finv) {
    // fac,finvは空配列でok
    fac.resize(2, 1);
    finv.resize(2, 1);
    vector<T> inv(2, 1);
    for (T i = 2; i < MAX; i++) {
        fac.push_back(fac[i - 1] * i % M);
        inv.push_back(M - inv[M % i] * (M / i) % M);
        finv.push_back(finv[i - 1] * inv[i] % M);
    }
}

template <class T>
T com(T n, T k, vector<T> &fac, vector<T> &finv, T M) {
    // nCk
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % M) % M;
}

signed main() {
    int s;
    cin >> s;
    vector<int> fac(0);
    vector<int> finv(0);
    MODinit(100000LL, MOD, fac, finv);
    int ans = 0;
    for (int i = 1; s - 3 * i >= 0; i++) {
        ans += com(s - 2 * i - 1, i - 1, fac, finv, MOD);
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5844
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100000
#define LEN 100000

typedef struct pro{
  char name[100];
  int t;
}Pro;

Pro Q[LEN+1];
int head, tail, n;

void init(){
  head = tail = 0;
}

int isEmpty(){ //キューが空かどうかを調べます
  if(head == tail) return 0;
  else return 1;
}

int isFull(){ //キューが満杯かどうかを調べます
  if(head == ((tail + 1) % MAX)) return 0;
  else return 1;
}

void enqueue(Pro x){ //キューの末尾に要素 x を追加します
  if(isFull() == 0){
    fprintf(stderr,"erorr!\n");
    exit(8);
  }
  Q[tail] = x;
  if(tail+1 == MAX) tail = 0;
  else tail++;
}

Pro dequeue(){ //キューの先頭から要素を取り出します
  Pro x;
  if(isEmpty() == 0){
    fprintf(stderr,"erorr!\n");
    exit(8);
  }
  else{
    x = Q[head];
    if(head + 1 == MAX) head = 0;
    else head++;
    return x;
  }
}

int main(){
  int elaps = 0, c;
  int i, j, q;
  Pro u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n + 1;

  for(i = 0 ; head != tail ;i++){
    u = dequeue();
    if(q < u.t) c = q;
    else c = u.t;
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else printf("%s %d\n",u.name,elaps);
  }

  return 0;
}



Measured memory_bytes: 11880
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

const int INF = 1001001001;

int main(void)
{
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s += '0';
    int n = s.length();
    int dp[1000100][2];
    //fill(dp, dp + 1000100 * 2, INF);
    REP(i, 1000100)
    REP(j, 2)
    dp[i][j] = INF;
    dp[0][0] = 0;

    REP(i, n)
    {
        REP(j, 2)
        {
            int num = s[i] - '0';
            num += j;
            REP(a, 10)
            {
                int ni = i + 1;
                int nj = 0;
                int b = a - num;
                if (b < 0)
                {
                    nj = 1;
                    b += 10;
                }
                dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b);
            }
        }

        /*
        if (i > 0)
        {
            dp[i][0] = min(dp[i - 1][0] + num, dp[i - 1][1] + 10 - num);
            dp[i][1] = min(dp[i - 1][0] + num + 1, dp[i - 1][1] + 10 - num + 1);
        }
        else
        {
            dp[i][0] = num;
            dp[i][1] = num + 1;
        }
        */
    }
    cout << min(dp[n][0], dp[n][1]) << endl;
}

Measured memory_bytes: 9220
import numpy as np

def main():
    n=int(input())
    t=[]
    for i in range(n):
        t.append(int(input()))

    ans=1
    for elem in t:
        ans=lcm(ans,elem)

    print(ans)


def inputList():
    a=list(map(int,input().split()))
    return a


def multisort(li,index):
    return sorted(li,key=lambda x: x[index])

def gcd(a,b):
    if(b==0):
        return a
    return gcd(b,a%b)

def lcm(a,b):
    return a*b//gcd(a,b)

if(__name__=='__main__'):
    main()


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

int h,w,ni,nj,nmuki=0,ans=-1,sum=0;
string s;
char grid[51][51];
int Y[4]={-1,0,1,0};
int X[4]={0,1,0,-1};
bool memo[51][51][4][1001]={},C=false;

bool check(char c){
  bool flag=false;
  if(c=='N' && nmuki==0)flag=true;
  else if(c=='E' && nmuki==1)flag=true;
  else if(c=='S' && nmuki==2)flag=true;
  else if(c=='W' && nmuki==3)flag=true;
  else if(c=='C' && grid[ni+Y[nmuki]][nj+X[nmuki]]=='#')flag=true;
  else if(c=='T')flag=true;
  return flag;
}

void solve(int a,int b){

  for(int k=a;k<b;k++){
    //cout<<ni<<" "<<nj<<" "<<nmuki<<" "<<sum<<" "<<s[k]<<endl;
    if(C)return;
    if(memo[ni][nj][nmuki][k]){
      C=true;
      return;
    }
    memo[ni][nj][nmuki][k]=true;
    if(s[k]=='['){
      bool B;
      int index=k+1,l=0,r=0;
      if(s[index]!='~')B=check(s[index]);
      else B=!check(s[++index]);
      for(int i=k;i<s.length();i++){
	if(s[i]=='[')l++;
	if(s[i]==']')r++;
	if(l==r){
	  if(B)solve(index+1,i);
	  k=i;
	  break;
	}
      }
    }
    else if(s[k]=='{'){
      int tmp=k;
      bool B;
      int index=k+1,l=0,r=0;
      if(s[index]!='~')B=check(s[index]);
      else B=!check(s[++index]);
      for(int i=k;i<s.length();i++){
	if(s[i]=='{')l++;
	if(s[i]=='}')r++;
	if(l==r){
	  tmp=i;
	  break;
	}
      }
      if(B)solve(index+1,tmp);
      if(C)return;
      if(ans!=-1)return;
      if(B)k=k-1;
      else k=tmp;
    }
    else if(s[k]=='^'){
      int y=ni+Y[nmuki],x=nj+X[nmuki];
      if(grid[y][x]!='#'){
	ni=y;
	nj=x;
      }
      sum++;
    }
    else if(s[k]=='>'){
      nmuki=(nmuki+1)%4;
      sum++;
    }
    else if(s[k]=='v'){
      int y=ni+Y[(nmuki+2)%4],x=nj+X[(nmuki+2)%4];
      if(grid[y][x]!='#'){
	ni=y;
	nj=x;
      }
      sum++;
    }
    else if(s[k]=='<'){
      nmuki=(nmuki+3)%4;
      sum++;
    }
    if(grid[ni][nj]=='g'){
      ans=sum;
      return;
    }
  }
  return;
}

int main()
{
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>grid[i][j];
      if(grid[i][j]=='s'){
	ni=i;
	nj=j;
      }
    }
  }
  cin>>s;
  memo[0][0][0][0]=true;
  solve(0,s.length());
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 10648
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int n;
	int a[6]={0};
	
	cin >> n;

	for(int i=0; i<n; ++i){
		double k;
		cin >> k;
		
		if(k<165) ++a[0];
		else if(k<170) ++a[1];
		else if(k<175) ++a[2];
		else if(k<180) ++a[3];
		else if(k<185) ++a[4];
		else ++a[5];
	}
	
	for(int i=0; i<6; ++i){
		printf("%d:", i+1);
		
		for(int j=0; j<a[i]; ++j)
			printf("*");
		printf("\n");
	}	

	return 0;
}

Measured memory_bytes: 1220
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

n = int(input())
A = inpl()

if n == 1:
    print(A[0])
else:
    if n % 2 == 0:
        print(" ".join(map(str, A[1::2][::-1] + A[::2])))
    else:
        print(" ".join(map(str, A[::2][::-1] + A[1::2])))

Measured memory_bytes: 27940
S=list(input())
N=len(S)
a=False
b=False


if all(S[i]==S[N-i-1] for i in range(N)):
  a=True

if all(S[j]==S[((N-1)//2)-j-1] for j in range((N-1)//2)):
  b=True

if a==True and b==True:
  print("Yes")
else:
  print("No")
    

Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
int main() {
int n;
cin >> n;
int res = 0;
while (true){
	if (n == 1) break;
	n /= 2;
	res++;	
}
int k = 1;
for (int i = 0; i < res; ++i) {
	k *= 2;
}
cout << k << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int i,l,r,d,ans=0;
    scanf("%d %d %d",&l,&r,&d);
    for(i=l; i<=r; i++){
        if(i%d==0)ans++;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1680