akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll=long long;
using vi=vector<int>;

vi prime_factrize(int n){
    vi prime_factrize_ret;
    int temp=n;
    for(int i=2;i*i<=n;i++){
        while(temp%i==0){
            prime_factrize_ret.push_back(i);
            temp/=i;
        }
    }
    if(temp!=1) prime_factrize_ret.push_back(temp);
    return prime_factrize_ret;
}

int main(){
    map<int,int> mp;
    map<int,int> mp2;
    for(int i=2;i<=1e5;i++){
        vi temp=prime_factrize(i);
        if(temp.size()==1){
            mp[i]++;
            mp2[i*2]++;
        }
    }
    vi ans(1e5+1);
    for(auto x:mp){
        if(mp2[x.first+1]!=0){
            ans[x.first]=1;
        }
    }
    for(int i=1;i<=1e5;i++){
        ans[i]+=ans[i-1];
    }
    int q;
    cin >> q;
    rep(i,q){
        int l,r;
        cin >> l >> r;
        cout << ans[r]-ans[l-1] << endl;
    }

}

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> ls(n);
  rep(i, n){
    int x, l;
    cin >> x >> l;
    ls[i] = make_pair(x, l);
  }
  sort(ls.begin(), ls.end());
  
  int currentX = -1;
  int ans = n;
  rep(i, n) {
    int now = ls[i].first;
    int l = ls[i].second;
    int min = now-l;
    if (min < 0) min = 0;
    int max = now+l;
    if (1000000000 < max) max = 1000000000;
    if (currentX <= min) {
      currentX = max;
    } else if (min < currentX && currentX <= max) {
      ans--;
    } else {
      ans--;
      currentX = max;
    }
  }
  cout << ans << endl;
  return 0;
}

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

w = [None] * N
for i in range(N):
    w[i] = input()

if len(w) != len(set(w)):
    print('No')
else:
    for i in range(1, N):
        if w[i-1][-1] != w[i][0]:
            print('No')
            break
    else:
        print('Yes')

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
    cin>>n;
    if(n%2==1)
    cout<< n/2 + 1;
    else
    cout<< n/2;
	

	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)


int diff(int x, int y ){
    if( x > y ){
        return x - y;
    }else{
        return y -x;
    }
}

struct cell{
    int A;
    int B;
    int diff(){ return ::diff(A,B);};
    bitset<160*80> nums;
};

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll H, W;

    cin >> H >> W;
    vector<vector<cell>> table(H, vector<cell>(W));

    REP(i, H){
        REP(j, W) { 
            int a;
            cin >> a;
            table[i][j].A = a;
        }
    }

    REP(i, H){
        REP(j, W) { 
            int b;
            cin >> b;
            table[i][j].B = b;
        }
    }

    table[0][0].nums.set(table[0][0].diff());

    REP(i, H){
        REP(j, W){
            if( i == 0 && j  == 0 ) continue;
            if( i == 0 ){
                for(int k = 0; k < 160*80; k++ ){
                    if( table[i][j-1].nums[k] ){
                        table[i][j].nums.set( k + table[i][j].diff());
                        table[i][j].nums.set( diff(k , table[i][j].diff()));
                    }
                }
            }else if( j == 0 ){
                for(int k = 0; k < 160*80; k++ ){
                    if( table[i-1][j].nums[k] ){
                        table[i][j].nums.set( k + table[i][j].diff());
                        table[i][j].nums.set( diff(k , table[i][j].diff()));
                    }
                }
            }else{
                for(int k = 0; k < 160*80; k++ ){
                    if( table[i-1][j].nums[k] ){
                        table[i][j].nums.set( k + table[i][j].diff());
                        table[i][j].nums.set( diff(k , table[i][j].diff()));
                        continue;
                    }
                    if( table[i][j-1].nums[k] ){
                        table[i][j].nums.set( k + table[i][j].diff());
                        table[i][j].nums.set( diff(k , table[i][j].diff()));
                    }
                }

            }
        }
    }

    for(int i = 0 ; i < 160*80; i++ ){
        if( table[H-1][W-1].nums[i] ){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 10368
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  string s;
  cin>>s;
  rep(i,s.size()){
    if(i%2==1)
    {if(s[i]=='0')p++;else q++;}
    else 
    {if(s[i]=='1')p++;else q++;}
  }
  print(min(p,q))
}

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

int main(){
 int A, B, result=0;
 int a, b, d, e; //abcde
 cin >> A >> B;
 
 
 for(int i=A;i<=B;i++){
   	a = (i/10000%10);
    b = (i/1000%10);
    d = (i/10%10);
    e = i%10;
   	if(a==e&&b==d) result++;
 }
 
  cout << result << endl;
}

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

int main(){
    string predict, result;
    cin >> predict >> result;
    int ans = 0;
    for(int i=0; i<3; i++){
      if( predict.substr(i,1)==result.substr(i,1) ){
        ans++;
      }
    }
    cout << ans << endl;
}

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

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

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

class starry_sky_tree{
	int n;
	vector<lint> dat1,dat2;

	void add(int l,int r,int a,int b,int u,lint val){
		if(b<=l || r<=a) return;
		if(l<=a && b<=r){ dat1[u]+=val; return; }

		add(l,r,a,(a+b)/2,2*u+1,val);
		add(l,r,(a+b)/2,b,2*u+2,val);

		dat2[u]=max(dat2[2*u+1]+dat1[2*u+1],dat2[2*u+2]+dat1[2*u+2]);
	}

	lint query_max(int l,int r,int a,int b,int u){
		if(b<=l || r<=a) return -INF;
		if(l<=a && b<=r) return dat1[u]+dat2[u];

		lint res1=query_max(l,r,a,(a+b)/2,2*u+1);
		lint res2=query_max(l,r,(a+b)/2,b,2*u+2);
		return max(res1,res2)+dat1[u];
	}

public:
	starry_sky_tree(int N){
		for(n=1;n<N;n*=2);
		dat1.assign(2*n,0);
		dat2.assign(2*n,0);
	}

	void add(int l,int r,lint val){ add(l,r,0,n,0,val); }
	void update_max(int x,lint val){
		lint tmp=query_max(x,x+1);
		if(tmp<val) add(x,x+1,val-tmp);
	}

	lint query_max(int l,int r){ return query_max(l,r,0,n,0); }
};

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<vector<pair<int,int>>> Ev(n+1);
	rep(i,m){
		int l,r,val; scanf("%d%d%d",&l,&r,&val); l--;
		Ev[r].emplace_back(l,val);
	}

	// dp[x] = ([0,t) に含まれる区間のみを考えて, 文字列の先頭から x 文字目までを決めたとき,
	//          x 文字目を 1 にして得られる最大スコア) (x は 1-indexed)
	// t = 0, 1, 2, ... について, 同じ dp 配列を使いまわして更新していく
	starry_sky_tree dp(n+1);
	dp.add(1,n+1,-INF);
	for(int x=1;x<=n;x++){
		// update dp[x]
		lint tmp=dp.query_max(0,x);
		for(auto p:Ev[x]){
			int val=p.second;
			tmp+=val;
		}
		dp.update_max(x,tmp);

		// update dp[y] for 0<=y<x
		for(auto p:Ev[x]){
			int l,val; tie(l,val)=p;
			dp.add(l+1,x,val);
		}
	}
	printf("%lld\n",dp.query_max(0,n+1));

	return 0;
}


Measured memory_bytes: 19328
p1=list(map(int,input().split()))
p2=list(map(int,input().split()))
p3=list(map(int,input().split()))
p=p1+p2+p3
n=int(input())
for _ in range(n):
    b=int(input())
    if b in p:
        p[p.index(b)]=0
if p[0]+p[1]+p[2]==0 or p[3]+p[4]+p[5]==0 or p[6]+p[7]+p[8]==0 or p[0]+p[3]+p[6]==0 or p[1]+p[4]+p[7]==0 or p[2]+p[5]+p[8]==0 or p[0]+p[4]+p[8]==0 or p[2]+p[4]+p[6]==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<iostream>
#include <cmath>
#include <string>
#include <iomanip>

#define loop(k) for(int i=0;i<k;i++)
#define looop(k) for(int j=0;j<k;j++)
#define swap(a,b) a^=b^=a^=b;

using namespace std;

int main(){
    int a,n=1;
    loop(3){
    cin>>a;
        if(a==5){
        n*=1;
        }else if(a==7){
        n*=2;
        }else{
        n*=0;
        }
    }
    cout<<(n==2?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main{
	public static void main(String[] a){
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				System.out.println((i+1)+"x"+(j+1)+"="+(i+1)*(j+1));
			}
		}
	}
}

Measured memory_bytes: 16856
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd; 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define pb(v) push_back(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b)
{
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s)
{
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v)
{
	forl(i,v.size())
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
void pa(ll *v,ll size)
{
	forl(i,size)
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
// ll nck(ll N,ll K,ll mod)
// {
// 	if(N<K)
// 	{
// 		return 0;
// 	}
// 	return (((facs[N]*facsinv[N-K])%mod)*facsinv[K])%mod;
// }
ll power(ll x,ll y,ll p)
{
	ll res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		{
			res=(res*x)%p;
		}
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x,ll mod)
{
	if(x>=mod)
	{
		x%=mod;
	}
}
ll sumofgp(ll a,ll n,ll m)
{
	// n = number of terms - 1
	if(n<0)
	{
		return 0;
	}
	if(n==0)
	{
		return 1;
	}
	if(n==1)
	{
		return (1+a)%m;
	}
	ll ans;
	if(n%2)
	{
        ans=(1+a)*sumofgp((a*a)%m,(n-1)/2,m);
	}
    else
    {
        ans=1+((a*(1+a))%m)*sumofgp((a*a)%m,n/2-1,m);
    }
    return ans%m;
}
// void checktime()
// {
// 	struct timespec ts;
// 	printf("Running Program\n");
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	// Call Funcn Here
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	printf("Program ended\nTime = %Lf\n",en-st);
// }
ll arr[200005];
int main(void)
{
	fastio
	ll n,k;
	cin>>n>>k;
	forl(i,n)
	{
		cin>>arr[i];
	}
	if(k>=n)
	{
		cout<<"0\n";
		return 0;
	}
	sort(arr,arr+n);
	ll ans = 0;
	forl(i,n-k)
	{
		ans += arr[i];
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;
bool dp[101][10001];

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

	int s[101];
	int sum = 0;
	rep(i,n){
		cin >> s[i];
		sum +=s[i];
	}

	rep(i,n+1){
		rep(j,sum+1) dp[i][j] = false;
	}
	dp[0][0] = true;

	rep(i,n){
		rep(j,sum){
			if(dp[i][j] == true){
				dp[i+1][j] = true;
				dp[i+1][j+s[i]] = true;
			}
		}
	}

	for(int i=sum; i>=0; i--){
		if(dp[n][i]==true && i%10 != 0){
			cout << i << endl;
			return 0;
		}
	}
	cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int main(void){
  int n, p, d1, d2;
  int i, winnumber, winlength;

   // テヲツつ」ティツ??ヲツ閉ーテ」ツつ津・ツ?・テ・ツ環?
  scanf("%d", &n);
  while(n != 0){
    winlength = 0;
    for(i = 0; i < n; i++){
      // ティツゥツウテァツエツーテ」ツδ?」ツδシテ」ツつソテ・ツ?・テ・ツ環?
      scanf("%d %d %d", &p, &d1, &d2);

      // テ、ツクツ?ァツ閉ェテゥツ閉キテ」ツ??ィツキツ敕ゥツ崢「テ」ツ?凝」ツ?ゥテ」ツ??」ツ?凝・ツ按、テ・ツョツ?
      if(winlength < d1 + d2){
	winnumber = p;
	winlength = d1 + d2;
      }
    }
    printf("%d %d\n", winnumber, winlength);

    // テヲツャツ。テ」ツ?ョテヲツつ」ティツ??ヲツ閉ーテ」ツつ津・ツ?・テ・ツ環?
    scanf("%d", &n);
  }

  return 0;
}

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

int main(void) {
	int n;
	cin >> n;
	while (n) {
		int block,f_hight=-1,max_up=0,max_down=0;
		cin >> block;
		while (block) {
			int hight,dif;
			cin >> hight;
			if (f_hight!= -1) {
				dif = hight - f_hight;
				if (dif > max_up) {
					max_up = dif;
				}
				if (dif < max_down) {
					max_down = dif;
				}
			}
			f_hight = hight;
			block--;
		}
		cout << max_up<<" "<<max_down*-1<<endl;
		n--;
	}
}

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

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

    if(N % 111 == 0) {
        ans = N;
    }
    else {
        ans = (N/111 + 1) * 111;
    }

    cout << ans;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <queue>

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

int main(int argc, char const* argv[])
{
    int h, w;

    std::cin >> h >> w;

    auto map = std::vector<std::vector<int>>(h, std::vector<int>(w, 0));

    auto dot_num = 0;
    auto data = std::vector<std::string>(h);
    for(auto &line: data)
    {
        std::cin >> line;
        for(auto c: line)
        {
            if(c == '.')
            {
                dot_num++;
            }
        }
    }

    //data[0][0] = '1';
    map[0][0] = 1;

    auto queue = std::queue<std::pair<int, int>>();
    queue.push(std::make_pair(0, 0));
    while(!queue.empty())
    {
        auto current = queue.front();
        queue.pop();

        //auto current_cost = data[current.first][current.second] - '0';
        auto current_cost = map[current.first][current.second];

        for(int i=0; i<4;++i)
        {
            auto next_x = current.first + dx[i];
            auto next_y = current.second + dy[i];
            //std::cout << next_x << " : " << next_y << std::endl;

            if(next_x != -1 && next_x != h && next_y != -1 && next_y != w)
            {
                if(data[next_x][next_y] == '.' && map[next_x][next_y] == 0)
                {
                    //data[next_x][next_y] = '0' + current_cost + 1;
                    map[next_x][next_y] = current_cost + 1;
                    queue.push(std::make_pair(next_x, next_y));

                    if(next_x == (h - 1) && next_y == (w - 1))
                    {
                        auto score = dot_num - (current_cost + 1);
                        std::cout << score << std::endl;
                        return 0;
                    }
                }
            }
        }
    }
    std::cout << "-1" << std::endl;
}


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

class MainClass
{
    static void Main()
    {
        int X = int.Parse(ReadLine());
        if (X < 600) WriteLine(8);
        else if (X < 800) WriteLine(7);
        else if (X < 1000) WriteLine(6);
        else if (X < 1200) WriteLine(5);
        else if (X < 1400) WriteLine(4);
        else if (X < 1600) WriteLine(3);
        else if (X < 1800) WriteLine(2);
        else WriteLine(1);
    }
}


Measured memory_bytes: 27536
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define root sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, d, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> a >> b >> c >> d;
  while (a > 0 || c > 0)
  {
    c -= b;
    if (c > 0)
    {
      a -= d;
    }
    else
    {
      break;
    }
  }
  if (a > 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> t(N+1), x(N+1), y(N+1);
    for(int i=1; i<=N; i++)
        cin >> t[i] >> x[i] >> y[i];
    
    for(int i=1; i<=N; i++){
        int dt = t[i] - t[i-1];
        int dx = abs(x[i] - x[i-1]);
        int dy = abs(y[i] - y[i-1]);

        if(dt%2 != (dx+dy)%2 || dt < dx + dy){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
// clang-format on

using VI = vector<int>;
using VVI = vector<VI>;

int main()
{
  IOS;
  int N, K;
  cin >> N >> K;
  VI A(N);
  forn(i, 0, N) cin >> A[i];
  VVI dp(K + 1, VI(2));
  dp[0][1] = 1;
  for (int k = 1; k <= K; k++)
  {
    int x = 0, y = 1;
    for (auto a : A)
      if (k >= a)
      {
        x |= dp[k - a][1];
        y &= dp[k - a][0];
      }
    dp[k][0] = x;
    dp[k][1] = y;
  }

  cout << (dp[K][0] ? "First" : "Second") << endl;

  return 0;
}


Measured memory_bytes: 8724
n=int(input())
a=[int(input()) for i in range(n)]
l=[0]*n
r=[0]*n
t=0
for i in range(n):
  t=max(t,a[i])
  l[i]=t
t=0
for i in range(n-1,-1,-1):
  t=max(t,a[i])
  r[i]=t
# print(l)
# print(r)
for i in range(n):
  if i==0:
    print(r[i+1])
    continue
  if i==n-1:
    print(l[i-1])
    continue
  print(max(r[i+1],l[i-1]))


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

int main(void){
    char c;
    cin >> c;
    if(c == 'A')cout << "T";
    if(c == 'T')cout << "A";
    if(c == 'C')cout << "G";
    if(c == 'G')cout << "C";
    
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x))
#define SORT(x) sort(ALL(x))
#define SUM(x) accumulate(ALL(A), 0)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<string> VS;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	ll N;
	ll result=0;
	cin>>N;
	VI A(N);
	VI tree(N);
	//VVI tree()
	REP(i, N-1) cin >> A[i];
	for (int i = 0; i < N-1; ++i) {
		tree[A[i]-1]++;
	}
	for (int i = 0; i < N; ++i) {
		cout << tree[i] << "\n";
	}
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 6368
#include <stdio.h>
int main(void)
{
	int w,a,b;
	scanf("%d %d %d",&w,&a,&b);  
	if(a+w<b){
		printf("%d\n",b-a-w);
	}
	else if(b+w<a){
		printf("%d\n",a-b-w);
	}
	else{
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 128
using System;

    class Program
    {
        static void Main(string[] args)
        {
            double r, circleArea, circumference;
            string num = Console.ReadLine();
            r = double.Parse(num);

            circleArea = r * r * 3.141592653589;
            circumference = r * 2 * 3.141592653589;

            Console.Write("{0:0.000000}", circleArea + " ");
            Console.WriteLine("{0:0.000000}", circumference);

        }
    }



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

const int N = 100050;
int dp[N];
int n,arr[N];

int rec(int pos)
{
    if(pos==n) return 0;
    int &ret=dp[pos];
    if(ret!=-1) return ret;
    ret=1e9;
    ret=min(ret,abs(arr[pos]-arr[pos+1])+rec(pos+1));
    if(pos+2<=n) ret=min(ret,abs(arr[pos]-arr[pos+2])+rec(pos+2));
    return ret;
}

int main()
{
    memset(dp,-1,sizeof dp);
    scanf("%d",&n);
    for(int i=1; i<=n; i++) scanf("%d",&arr[i]);
    printf("%d\n",rec(1));

}


Measured memory_bytes: 5760
#include <cstdio>
#include <vector>
#include <queue>
#include <tuple>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
using namespace std;

int main() {
    // input
    int n, m; scanf("%d%d", &n, &m);
    vector<vector<int> > g(n);
    repeat (i, m) {
        int a, b; scanf("%d%d", &a, &b); -- a; -- b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int q; scanf("%d", &q);
    vector<int> v(q), d(q), c(q); repeat (t, q) { scanf("%d%d%d", &v[t], &d[t], &c[t]); -- v[t]; }
    // solve
    vector<int> result(n);
    vector<int> used(n, -1);
    repeat_reverse (t, q) {
        queue<int> que;
        auto push = [&](int i, int dist) {
            if (used[i] < dist) {
                used[i] = dist;
                if (not result[i]) result[i] = c[t];
                que.emplace(i);
            }
        };
        push(v[t], d[t]);
        while (not que.empty()) {
            int i = que.front(); que.pop();
            if (used[i] != 0) {
                for (int j : g[i]) {
                    push(j, used[i]-1);
                }
            }
        }
    }
    // output
    repeat (i, n) {
        printf("%d\n", result[i]);
    }
    return 0;
}


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

int main()
{
	string s;
	string maxLenS = "";
	map<string, int> m;
	vector<string> v;
	while (cin >> s)
	{
		if (maxLenS.size() < s.size())
		{
			maxLenS = s;
		}
		if (m.find(s) == m.end())
		{
			m[s] = 0;
			v.push_back(s);
		}
		else
		{
			m[s]++;
		}
	}
	int maxIndex = 0;
	for (int i = 0; i < v.size(); i++)
	{
		if (m[v[i]] > m[v[maxIndex]])
		{
			maxIndex = i;
		}
	}
	cout << v[maxIndex] << " " << maxLenS << endl;
	return 0;
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
const LL MOD=1000000007ll;
const LL INF=2000000000ll;

long power(long a,long b){return b?power(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;}
long comb(int N,int K)
{
	long x=1,y=1;
	for(int i=1;i<=K;i++)
	{
		x=x*(N-i+1)%MOD;
		y=y*i%MOD;
	}
	return x*power(y,MOD-2)%MOD;
}

long hcomb(int N, int K){
    return comb(N+K-1, N-1);
}

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

    int N;
    cin >> N;
    VI P(N),Q(N);
    REP(i,N) cin >> P[i];
	REP(i,N) cin >> Q[i];

    VI order(N);
    REP(i,N) order[i] = i+1;

    int a = 0, b = 0, cnt = 0;

    do {
        REP(i,N) {
            if (order[i] != P[i]) break;
            if (i == N-1) a = cnt;
        }
        REP(i,N) {
            if (order[i] != Q[i]) break;
            if (i == N-1) b = cnt;
        }
    	cnt++;
    } while(next_permutation(ALL(order)));

    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long solve(int K, int A, int B){
    K -= A-1;
    if(B <= A) return 0;
    if(K <= 0) return 0;
    long long m = K/2;
    long long res = B + (m-1)*(B-A);
    if(K%2 == 1) ++res;
    return res;
}

int main(){
    int K, A, B;
    while(cin >> K >> A >> B){
        cout << max(K+1LL, solve(K, A, B)) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}


const int MAX = 510000;
const int MOD = 1000000007;

long long 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){

  COMinit();
  int H, W, A, B;

  cin>>H>>W>>A>>B;

  ll ans=0;

  rep(i,H-A){
    ans+=COM(i+B-1,i)*COM((H-i-1)+(W-B-1),(W-B-1));
    ans= ans%MOD;
  }

  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 12160
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	ll S;
	cin >> S;
	vector<P> ans(3, {0, 0});
	ll daikeiLim = 1e9;

	if (S <= daikeiLim) {
		ans[1] = {0, 1};
		ans[2] = {S, 0};
	} else {
		ll lHen = S / daikeiLim;
		ll rHen = min(lHen + 1, (ll)1e9);
		ll xPos = S - lHen * daikeiLim;
		ans[0] = { 0, lHen };
		ans[1] = { daikeiLim, rHen };
		ans[2] = { xPos, 0 };
	}

	for (auto one : ans) {
		cout << one.first << " " << one.second << " ";
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define anal         '\n'
#define mod 1000000007
#define fst first
#define sec second
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
   


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
      freopen("input.in", "r", stdin);
      freopen("output.in", "w", stdout);
#endif 

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
     
     string s, t;
     cin >> s >> t;
     int ans = 0;
     for(int i = 0; i < s.length(); i++){
          if(s[i] != t[i]){
               ans++;
          }
     }
     cout << ans << anal;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



   

Measured memory_bytes: 3780
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        @SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
        // 複数行の読み込み
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if ((a * b) % 2 == 0) {
        	System.out.println("Even");
        } else {
        	System.out.println("Odd");
        }
    }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; ll D; cin >> N >> D;
    vector<ll> d(N);
    for (int i=0;i<N;++i) cin >> d[i];
    vector<ll> ok(N+1,0),now(N);
    for (int i=N-1;i>=0;--i) ok[i]=(ok[i+1]>=d[i]/2?ok[i+1]+d[i]:ok[i+1]);
    now[0]=D;
    for (int i=0;i<N-1;++i){
        if (d[i]<now[i]) now[i+1]=now[i]-d[i];
        else if (d[i]<now[i]*2) now[i+1]=d[i]-now[i];
        else now[i+1]=now[i];
    }
    int Q; cin >> Q;
    for (;Q--;){
        int q; cin >> q; --q;
        cout << (now[q]<=ok[q+1]?"NO":"YES") << '\n';
    }
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll l[60];
ll p[60];

//レベルnのx層のパティの枚数を返す
ll rec(ll n, ll x) {
    if (n == 0) {
        return 1;
    }

    if (x == 1) {
        return 0;
    }

    if (l[n] / 2 + 1 < x) {
        return 1 + p[n - 1] + rec(n - 1, x - (l[n] / 2 + 1));
    } else if (l[n] / 2 + 1 == x) {
        return 1 + p[n - 1];
    } else {
        return rec(n - 1, x - 1);
    }
}

int main() {

    ll n, x; cin >> n >> x;

    l[0] = 1;
    p[0] = 1;

    for (ll i = 1; i <= 50; ++i) {
        l[i] = 2 * l[i-1] + 3;
        p[i] = 2 * p[i-1] + 1;
    }

    cout << rec(n, x) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

string solve(int T, vector<pair<int, int>>& ct) {
  sort(ct.begin(), ct.end());
  for (auto p : ct) {
    if (p.second <= T) {
      return to_string(p.first);
    }
  }
  return "TLE";
}

int main() {
  int N, T;
  cin >> N >> T;
  vector<pair<int, int>> ct(N);
  REP(i, N) {
    int c, t;
    cin >> c >> t;
    ct[i] = make_pair(c, t);
  }
  cout << solve(T, ct) << endl;
}


Measured memory_bytes: 256
from collections import deque

n, x, y = map(int, input().split())
x -= 1
y -= 1

ans = [0] * (n+1)
INF = 10 ** 10

for i in range(n):
    d = [INF] * n
    q = deque([])
    d[i] = 0
    q.append(i)
    while len(q) > 0:
        v = q.popleft()
        if v - 1 >= 0:
            if d[v-1] == INF:
                q.append(v-1) 
                d[v-1] = d[v] + 1
        if v + 1 < n:
            if d[v+1] == INF:
                q.append(v+1)
                d[v+1] = d[v] + 1
        if v == x:
            if d[y] == INF:
                q.append(y)
                d[y] = d[v] + 1
        if v == y:
            if d[x] == INF:
                q.append(x)
                d[x] = d[v] + 1
    for i in range(n):
        ans[d[i]] += 1

for i in range(1, n):
    ans[i] //= 2     #i→jとj→iを両方カウントしているため
    print(ans[i])

Measured memory_bytes: 50652
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

const int MAXN=10000;
const int MAXLEN=10;

int n;
char s[MAXN][MAXLEN+1];

int solve() {
	int ret=0;
	int na=0,nb=0,nab=0;
	REP(i,n) {
		int len=strlen(s[i]);
		REP(j,len-1) if(s[i][j]=='A'&&s[i][j+1]=='B') ++ret;
		bool endsa=s[i][len-1]=='A',startsb=s[i][0]=='B';
		if(endsa&&startsb) ++nab; else if(endsa) ++na; else if(startsb) ++nb;
	}
	if(nab>0) { ret+=nab-1; nab=0; if(na>0) --na,++ret; if(nb>0) --nb,++ret; }
	ret+=min(na,nb);
	return ret;
}

void run() {
	scanf("%d",&n);
	REP(i,n) scanf("%s",s[i]);
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}

Measured memory_bytes: 384
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))

# 次 A[j] が取り除かれるまでの操作回数
counts = [0] * N
D = {}
for i, a in enumerate(A + A):
    if a not in D:
        D[a] = i
    else:
        if D[a] < N:
            counts[D[a]] = i - D[a]
            D[a] = i

circle = counts[0] + 1
i = (counts[0] + 1) % N
while i != 0:
    circle += counts[i] + 1
    i = (i + counts[i] + 1) % N
rem = N * K % circle

ans = []

i = 0
while rem > 0:
    while rem - counts[i] > 0:
        rem -= counts[i] + 1
        i = (i + counts[i] + 1) % N
    if rem:
        ans.append(A[i])
        rem -= 1
        i = (i + 1) % N

if ans:
    print(*ans)

# hist = []
# stack = []
# for _ in range(K):
#     for a in A:
#         if a in stack:
#             while a in stack:
#                 stack.pop()
#         else:
#             stack.append(a)
#
#         hist.append(a)
#         print(hist)
#         print('', stack)
#         print()


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

int main()
{
  string s;
  cin >> s;
  
  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1') {
      count++;
    }
  }
  
  cout << count << endl;
  return 0;
}

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

using P = pair<int,int>;

void chmax(int &a, int b){
    a = max(a, b);
}

int main() {
    int N, T;
    cin >> N >> T;
    vector<P> v(N);
    for(int i=0;i<N;i++){
        int a, b;
        cin >> a >> b;
        v[i] = P(a, b);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    vector<vector<int> > dp(N+1, vector<int>(T));
    for(int i=0;i<N;i++){
        int a, b;
        a = v[i].first, b = v[i].second;
        for(int j=0;j<T;j++){
            chmax(dp[i+1][j], dp[i][j]);
            if(j+a < T) chmax(dp[i+1][j+a],  dp[i][j] + b);
            else chmax(ans, dp[i][j] + b);
        }
    }
    chmax(ans, dp[N][T-1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35584
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
#define rep(i,n) for (ll i=0;i<n;i++)
using namespace std;

struct UnionFind {
    vector<ll> par;
    vector<ll> rank;

    UnionFind(ll N) : par(N),rank(N){
        // 初期化
        rep(i,N) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    ll root(ll x){
        // unionfind木をたどって頂点を探す
        if(par[x]==x) return x;
        else return par[x] = root(par[x]);
    }

    void unite(ll x,ll y){
        // 高さを考慮し、結合する。
        ll rx = root(x);
        ll ry = root(y);
        if(rx==ry) return;
        if(rank[x]<rank[y]){
            par[rx] = y;
        }else{
            par[ry] = x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(ll x,ll y){
        // 親が同じなら同じグループ
        return root(x)==root(y);
    }

};

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,m;
    cin >> n >> m;

    UnionFind tree(n);

    rep(i,m){
        ll x,y;
        cin >> x >> y;
        x--;y--;
        tree.unite(x,y);
    }
    ll ans = 0;
    vector<ll> cnt(n);
    rep(i,n) cnt[tree.root(i)]++;
    rep(i,n) ans = max(ans,cnt[i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7932
#include <stdio.h>

#define MAX 500000
#define INFTY 2000000000

int L[MAX/2+2],R[MAX/2+2],c;

void merge(int A[],int n,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    c++;
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){
  int A[MAX],n,i;
  c=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,n,0,n);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",c);

  return 0;
}



Measured memory_bytes: 5668
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
#define mod 1000000007

bool vis[200005];
vector<int> vec[2000005], v1;
vector<pair<int, int>> vec2[2000005];
int child[2000005];
int parent[2000005];
int div1[100005];
int min_indx[900005];
int count1 = 0;
int height = 0;
int max_indx[200005];
void dfs(int node)
{

    vis[node] = 1;

    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            parent[vec[node][i]] = node;
            dfs(vec[node][i]);
        }
    }
}

int MAXN = 200005;
int LOGMAXN = (int)log2(200005) + 1;
int M[200005][60];
void process2(int A[], int N)
{
    int i, j;

    //initialize M for the intervals with length 1
    for (i = 0; i < N; i++)
        M[i][0] = i;
    //compute values from smaller to bigger intervals
    for (j = 1; 1 << j <= N; j++)
        for (i = 0; i + (1 << j) - 1 < N; i++)
            if (A[M[i][j - 1]] < A[M[i + (1 << (j - 1))][j - 1]])
                M[i][j] = M[i][j - 1];
            else
                M[i][j] = M[i + (1 << (j - 1))][j - 1];
}
//int parent[200005];
vector<int> vec1;
//bool vis[200005];
//int hei[200005];
int lev[200005];
int dis[200005];
bool cmp(pair<int, int> &a,
         pair<int, int> &b)
{
    return a.second < b.second;
}
void Ios()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //  int t;
}
int32_t main()
{
    //  Ios();
    //  int t;
    int n;
    cin >> n;
    int ans = 0;
    int arr[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
        if (i % 2 && arr[i] % 2)
            ans++;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 97396
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define abs(a) (((a)>0)?(a):(-a))

int main()
{
	char s[111], t[111];
	scanf("%s\n%s", &s, &t);
	int n;
	n = strlen(s);
	for (int i = 0; i < n; i++)
	{
		if (s[i]==t[0])
		{
			int j = 1;
			for (; j < n && s[(i + j) % n] == t[j]; j++)
			{}
			if (j==n)
			{
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}


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

using namespace std;

const int mod = 1e9 + 7;

int add(int a, int b) {
  return a + b - mod * (a + b >= mod);
}

int mul(int a, int b) {
  return int(1ll * a * b % mod);
}

int pwr(int a, int x) {
  if (x == 0) {
    return 1;
  }
  return mul(pwr(mul(a, a), x >> 1), (x & 1 ? a : 1));
}

int dvd(int a, int b) {
  return mul(a, pwr(b, mod - 2));
}

int sub(int a, int b) {
  return a - b + mod * (a < b);
}

void inc(int& a, int b) {
  a = add(a, b);
}

void dec(int& a, int b) {
  a = sub(a, b);
}

const int N = 21;
int a[N][N], dp[1 << N];

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

  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }
  dp[0] = 1;
  for (int mask = 0; mask < (1 << n); ++mask) {
    int j = __builtin_popcount(mask);
    for (int i = 0; i < n; ++i) {
      if (((mask >> i) & 1) == 0 and a[j][i]) {
        inc(dp[mask | (1 << i)], dp[mask]);
      }
    }
  }
  cout << dp[(1 << n) - 1];

  return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)(v).size())
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1);



int main(void) {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int D,N;
	cin >> D >> N;
	ll ans = 0;
	while(N > 0){
		ans += int(pow(100 ,D));
		if (ans % int(pow(100 ,D+1)) == 0){
			ans += int(pow(100 ,D));
	}
		N--;
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    W, H, x, y = LI()
    if x == W/2 and y == H/2: # 小数だいじょうぶ？→入力は全て整数なので大丈夫っぽい。
        multiple_answers = 1
    else:
        multiple_answers = 0
    ans = W * H / 2

    print(ans, multiple_answers)

main()

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

using namespace std;

int main()
{
	int a,b;
	int c;
	int i=0;
	int j;
	vector<int> x;
	vector<int> y;
	
	while(1)
	{
		cin>>a>>b;
		
		if(a==0&&b==0)
			break;
		else
		{
			if(a>b)
			{
				c=a;
				a=b;
				b=c;
			}
			x.push_back(a);
			y.push_back(b);
			i++;
		}
	}
	
	for(j=0;j<i;j++)
	{
		cout<<x[j]<<" "<<y[j]<<endl;
	}
}



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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

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

  string a = s.substr(0, 3);

  cout << a << endl;
}


Measured memory_bytes: 3600
package main

import "fmt"

func main() {
	var h, w int
	var s string
	fmt.Scan(&h, &w)
	a := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&s)
		a[i] = s
	}
	for i := 0; i < 2*h; i++ {
		fmt.Println(a[i/2])
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
 
vector <string> v;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	char a, b;
	cin >> a >> b;
	int a1 = a - '0', b1 = b - '0';
	string s1 = "", s2 = "";
	while(a1--)
	{
		s2 += b;
	}
	while(b1--)
	{
		s1 += a;
	}
	v.pb(s1);
	v.pb(s2);
	sort(all(v));
	cout << v[0];
}                                

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    vs: [[i32; 3]; n]
  }
  let mut dp = vec![vec![0; 3]; n + 1];
  for day in 0..n {
    for thing in 0..3 {
      dp[day + 1][thing] = cmp::max(dp[day][(thing + 1) % 3] + vs[day][thing], dp[day][(thing + 2) % 3] + vs[day][thing]);
    }
  }
  println!("{}", cmp::max(dp[n][0], cmp::max(dp[n][1], dp[n][2])));
}


Measured memory_bytes: 16764