akhauriyash/Code-Regression huggingface dataset:
//
// Created by ?????°?????? on 2016/04/05.
//

#include <iostream>
using namespace std;
const int MAX = 100000;
const int NIL = -1;

struct Node{
    // ????????????????§????
    int parent;
    int left_child;
    int right_sibling;
};

Node T[MAX];
int n,D[MAX];

void print(int u){
    int i,c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << D[u] << ", ";
    
    if(T[u].parent == NIL) cout << "root, ";
    else if (T[u].left_child == NIL) cout << "leaf, ";
    else cout << "internal node, ";
    
    cout << "[";
    for (int i = 0 , c = T[u].left_child; c != NIL ; ++i, c = T[c].right_sibling) {
        if(i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int getDepth(int u){
    int d = 0;
    while(T[u].parent != NIL){
        u =T[u].parent;
        d++;
    }
    return d;
}

int main (){
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        T[i].left_child = T[i].right_sibling = T[i].parent = NIL;
    }

    int num,degree,child,left_child,right_sibling,depth;
    for (int i = 0; i < n ; ++i) {
        cin >> num >> degree;
        for (int j = 0; j < degree ; ++j) {
            cin >> child;
            if(j == 0) T[num].left_child = child;
            else T[left_child].right_sibling = child;
            left_child = child;
            T[child].parent = num;
        }
    }
    for (int i = 0; i < n ; ++i) {
        if (T[i].parent == NIL) right_sibling = i;
    }
    for (int i = 0; i < n ; ++i) {
    D[i] = getDepth(i);        
    }

    for (int i = 0; i < n ; ++i) {
        print(i);
    }
    return 0;
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    int S = w*h;

    int ox=0, oy=0;
    rep(i,n) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a==1) {
            if (x<w&&x>=ox)
                ox = x;
            else if (x>=w) {
                P(0);
                return 0;
            }
        }
        else if (a==2) {
            if (x>ox&&x<=w)
                w = x;
            else if (x<=w){
                P(0);
                return 0;
            }
        }
        else if (a==3) {
            if (y<h&&y>=oy)
                oy = y;
            else if (y>=h) {
                P(0);
                return 0;
            }
        }
        else if (a==4) {
            if (y>oy&&y<=h)
                h = y;
            else if (y<=h){
                P(0);
                return 0;
            }
        }
    }
    P((w-ox)*(h-oy));
    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from numpy.fft import rfft, irfft

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 200003
    P=mod

    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    A = list(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    cur=1
    base=2
    atoi=[0]*P
    itoa=[0]*(P-1)
    cnt=[0]*(P-1)
    for i in range(0,P-1):
        atoi[cur]=i
        itoa[i]=cur
        cur=cur*base%mod

    ta2=0
    for a in A:
        if a==0:
            continue
        i=atoi[a]
        cnt[i]+=1
        ta2+=a*a%P
    rf=rfft(cnt, 2*(P-1))
    X = irfft(rf * rf)
    #printe(X,sum(X))
    ans=0
    for i in range(P-1):
        ans+=itoa[i]*round(X[i]+X[P-1+i])

    print(int((ans-ta2)//2))

if __name__ == "__main__":
    main()

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

using namespace std;
#define ll               long long
#define dl               double
#define ull              unsigned long long
#define ft               first
#define sd               second
#define pi               acos(-1)
#define ct(tc)           scanf("%lld",&tc)
#define scnm(n,m)        scanf("%lld %lld",&n,&m);
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(a,max(b,max(c,d)))
#define min3(a,b,c)      min(a,min(b,c))
#define min4(a,b,c,d)    min(a,min(b,min(c,d)))
#define pb               push_back
#define srt              sort(v.begin(),v.end())
#define rsrt             reverse(v.begin(),v.end())
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll tc;
    ct(tc);
    ll r;
    r=tc%10;
    if(r==2||r==4||r==5||r==7||r==9)
    {
        printf("hon\n");
    }
    else if(r==0||r==1||r==6||r==8)
    {
        printf("pon\n");
    }
    else if(r==3)
    {
        printf("bon\n");
    }

    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;



int a[50][50][50][50]={0};
int vis[50][50];
int main(){
	int w,h;
	int v[4][2]={0,1,0,-1,1,0,-1,0};
	//cout<<v[0][0]<<" "<<v[0][1]<<endl;
	//return 0;
	//cin>>w>>h;
	/*
	rep(i,4){
		cout<<v[i][0]<<" "<<v[i][1]<<endl;
	}
	*/
	while(cin>>w>>h,w){
		memset(a,0,sizeof(a));
		memset(vis,0,sizeof(vis));
		rep(j,w-1){
			int t;
			cin>>t;
			//cout<<t<<" ";
			//cout<<t<<endl;
			if(t==1){
				a[0][j][0][j+1]=a[0][j+1][0][j]=1;
				//cout<<0<<" "<<j<<"  "<<0<<" "<<j+1<<endl;
			}
		}
		//cout<<endl;
		rep(i,h-1){
			rep(j,w){
				int t;
				cin>>t;
				//cout<<t<<" ";
				if(t==1){
					a[i][j][i+1][j]=a[i+1][j][i][j]=1;
					//cout<<i<<" "<<j<<"  "<<i+1<<" "<<j<<endl;
				}
			}
			//cout<<endl;
			rep(j,w-1){
				int t;
				cin>>t;
				//cout<<t<<" ";
				
				if(t==1){
					a[i+1][j][i+1][j+1]=a[i+1][j+1][i+1][j]=1;
					//cout<<i+1<<" "<<j<<"  "<<i+1<<" "<<j+1<<endl;
				}
			}
			//cout<<endl;
		}
		//cout<<endl;
		int t;
		//cout<<a[0][0][0][1]<<endl;
		//cout<<"a"<<a[0][0][0][1]<<" "<<a[0][0][1][0]<<" "<<a[0][1][0][0]<<" "<<a[1][0][0][0]<<endl;
		pii pos=mkp(0,0);
		queue<pii> q;
		q.push(pos);
		int ans=0;
		bool flag=false;
		vis[0][0]=1;
		while(!q.empty()){
			int qs=q.size();
			
			//cout<<pos.F<<" "<<pos.S<<endl;
			
			
			ans++;
			rep(k,qs){
				pii tq = q.front();
				q.pop();
				if(tq.F==h-1&&tq.S==w-1){
					cout<<ans<<endl;
					flag=true;
					break;
				}	
				rep(i,4){
					pii tpos=tq;
					tpos.F+=v[i][0];
					tpos.S+=v[i][1];
					//cout<<"tpos "<<tpos.F<<" "<<tpos.S<<endl;
					if(tpos.F>=0&&tpos.S>=0&&tpos.F<=h-1&&tpos.S<=w-1&&a[tq.F][tq.S][tpos.F][tpos.S]==0&&vis[tpos.F][tpos.S]==0){
						vis[tpos.F][tpos.S]=1;
						//cout<<"tpos "<<tpos.F<<" "<<tpos.S<<endl;
						q.push(tpos);
					}
				}
			}
		}
		if(!flag) cout<<0<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 25644
def read_input():
    r, g, b = map(int, input().split())

    return r, g, b

def submit():
    r, g, b = read_input()

    check = (r*100 + g*10 + b) % 4
    if check:
        print('NO')
    else:
        print('YES')


if __name__ == '__main__':
    submit()

Measured memory_bytes: 38256
#include <stdio.h>

int main()
{
  int a;
  int b;
  int h;
  int ans = 0;

  if (scanf("%d", &a) < 1) {
    return 1;
  }
  if (scanf("%d", &b) < 1) {
    return 1;
  }
  if (scanf("%d", &h) < 1) {
    return 1;
  }
  
  ans = (a + b) * h / 2;
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll lcm(ll a,ll b)
{
	return (a/__gcd(a,b))*b;
}
bool cmp(pair<string,ll> a,pair<string,ll> b)
{
	if(a.first<b.first)
		return 1;
	else if(a.x==b.x)
	{
		return a.y<b.y;
	}
	return 0;
}
void solve()
{
	ll n;
	cin>>n;
	ll fm=0;
	ll sm=-1;
	ll a[n];
	rep(i,0,n)
	{
		cin>>a[i];
		if(a[i]>fm)
		{
			sm=fm;
			fm=a[i];
		}
		else if(a[i]>sm)
		{
			sm=a[i];
		}
	}
	rep(i,0,n)
	{
		if(a[i]==fm)
			cout<<sm<<"\n";
		else
		{
				cout<<fm<<"\n";
		}
		
	}
}	

int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstring>
const int oo = 1e9;
using namespace std;
void fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
int n, m;
vector<int>g[200000 + 2];
bool vis[200000 + 2];
int l[200000 + 2];
void bfs(int u){
	queue<int>q;
	q.push(u);
	l[u] = 0;
	vis[u] = 1;
	while (!q.empty()){
		int v = q.front();
		q.pop();
		for (int i = 0; i < g[v].size(); i++){
			int tt = g[v][i];
			if (!vis[tt]){
				l[tt] = l[v] + 1;
				vis[tt] = 1;
				q.push(tt);
			}
		}
	}
}
int main(){
	fast();
	cin >> n >> m;
	for (int i = 0; i <= n; i++)l[i] = 3;
	for (int i = 0; i < m; i++){
		int u, v; cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	bfs(1);
	if (l[n] <= 2){
		cout << "POSSIBLE" << endl;
	}
	else{
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}
//mosta7il_

Measured memory_bytes: 13424
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int n;
  	cin >> n;
	cout << n*n*n << endl;
	return;
}

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


Measured memory_bytes: 256
#include <iostream>

inline int abs(int x){
  if (x > 0) {
    return(x);
  } else {
    return(-x);
  }
}

using namespace std;

int main(){
  int n, k, x[100001];
  cin >> n >> k;
  for (int i=0;i<n;i++) {
    int tmp;
    cin >> tmp;
    x[i] = tmp;
  }
  int ans = 1000000000;//abs(x[n-1]) > abs(x[0])?abs(x[n-1]):abs(x[n-1]);
  //  ans = x[n-1] - x[0] > ans?x[n-1] - x[0]:ans;
  for (int i=0;i+k-1<n;i++) {
    int ll = abs(x[i]);
    int lr = abs(x[i+k-1]);
    int l = ll < lr?ll:lr;
    int L = x[i+k-1] - x[i];
    ans = L+l < ans?L+l:ans;
    //    cout << i << "\t" << ans << endl;
  }
  cout << ans << endl;
  return(0);
}


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

int main(){
    while(true){
        int n, m; cin >> n >> m;
        if(n == 0 && m == 0) break;
        vector<pair<int, int>> dp(n);
        int ans = 0;
        for(int i = 0; i < n; i++){
            int a, b; cin >> a >> b;
            ans += a * b; //護衛なしの期待値
            dp.at(i) = make_pair(b, a); //ソートしやすいように期待値を先にする
        }
        sort(dp.rbegin(), dp.rend());
        for(int i = 0; i < n; i++){
            if(m >= dp.at(i).second){
                ans -= dp.at(i).first * dp.at(i).second;
                m -= dp.at(i).second;
            }
            else{
                ans -= m * dp.at(i).first;
                break;
            }
        }
        cout << ans << endl;
    }
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll A[N], B[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    ll a_large = 0;
    ll rem = 0;
    rep(i, N) a_large += max(0ll, A[i]-B[i]);
    rep(i, N) B[i] = (A[i] > B[i]) ? A[i] : B[i];
    rep(i, N){
        if((B[i]-A[i]) % 2) rem++;
        a_large -= (B[i]-A[i])/2;
    }
    //sum(B)-sum(A)=rem
    //a_large回だけ2をAのどこかに足さなきゃ
    if(a_large <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3816
def main():
    N, M = map(int, input().split())
    L = [0 for i in range(M)]
    R = [0 for i in range(M)]

    for i in range(M):
        L[i], R[i] = map(int, input().split())
    ans = range(max(L), min(R) + 1)
    print(len(ans))


if __name__ == '__main__':
    main()


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

#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define fastio ios::sync_with_stdio(false); cin.tie(0)

int main(){
    fastio;
 	int n, k;
 	cin >> n >> k;
 	if(k == 1) cout << 0;
 	else cout << n - k;
 	cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        System.out.println(calcLeastCommonMultiple(a, b));
        sc.close();
    }

    // aとbの最大公約数：ユークリッドの互除法
    private static long calcGreatestCommonDivisor(int a, int b) {
        int max = Math.max(a, b);
        int min = Math.min(a, b);
        // 大きい数を小さい数で割る。
        // 余りが0の場合は小さい数が最小公倍数になる
        if ((max % min) == 0) {
            return min;
        }
        // 割られる数に「小さい数」を、割る数に「余り」をセットして繰り返す
        return calcGreatestCommonDivisor(min, max % min);
    }

    // 最小公倍数：2つの数aとbの積を、aとbの最小公倍数で割った値が最小公倍数になる
    private static long calcLeastCommonMultiple(int a, int b) {
        return ((long) a * (long) b) / calcGreatestCommonDivisor(a, b);
    }

}


Measured memory_bytes: 35620
#include "bits/stdc++.h"
using namespace std;
const int nmax = 1e6 + 10;
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef double db;
int a,b,c,d;
int main() {
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if((abs(a-b) <= d && abs(b-c) <=d)  || abs(a-c) <= d) puts("Yes");
	else puts("No");
	return 0;
}

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

using namespace std;

bool cmp(char a,char b)
{
    return a>b;
}

int main()
{
    char s1[105],s2[105];
    scanf("%s %s",s1,s2);
    int len1=strlen(s1),mn1='z'+1,mx2='a'-1;
    int len2=strlen(s2);
    sort(s1,s1+len1);
    sort(s2,s2+len2,cmp);
    for(int i=0;i<=min(len1,len2);i++)
    {
        if(s1[i]<s2[i])
        {
            printf("Yes\n");
            return 0;
        }
        else if(s1[i]>s2[i])
        {
            printf("No\n");
            return 0;
        }
    }
    printf("No\n");
}


Measured memory_bytes: 256
use std::io;

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {
    let n = read_one::<usize>();

    let prime = [3, 13, 23, 43, 53, 73, 83, 103, 113, 163, 173,
                 233, 263, 283, 293, 313, 353, 373, 383, 433, 443, 463,
                 503, 523, 563, 593, 613, 643, 653, 673, 683, 733, 743,
                 773, 823, 883, 953, 983, 1013, 1033, 1063, 1093, 1103,
                 1123, 1153, 1163, 1193, 1213, 1223, 1303, 1373, 1423, 1433, 1453,
                 1483, 1493, 1523, 1613, 1733, 1873, 2213];

    let s = &prime[0..n].iter().fold(String::from(""), |a, b| a + &*b.to_string() + " ");
    println!("{}", s.trim());
}

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

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

using namespace std;

int main(){
	int n,k; cin>>n>>k;
	vector<vector<int>> B(2*k+1,vector<int>(2*k+1));
	rep(i,n){
		int x,y;
		char c; cin>>x>>y>>c;
		if(c=='W') y+=k;
		B[y%(2*k)+1][x%(2*k)+1]++;
	}
	rep(i,2*k) rep(j,2*k) B[i+1][j+1]+=B[i+1][j]+B[i][j+1]-B[i][j];

	int ans=0;
	rep(i,k+1) rep(j,k+1) {
		int cnt=0;
		cnt+=B[k+i][k+j]-B[i][k+j]-B[k+i][j]+B[i][j];
		cnt+=B[2*k][2*k]-B[k+i][2*k]-B[2*k][k+j]+B[k+i][k+j];
		cnt+=B[i][j];
		cnt+=B[i][2*k]-B[i][k+j];
		cnt+=B[2*k][j]-B[k+i][j];
		ans=max({ans,cnt,n-cnt});
	}
	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

int main(){
    int n, a[200009],b[200009], ans=0;
    vector<int> A, prime;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i+1];
    }

    for(int i=n;i>0;i--){
        int ans=a[i];
        for(int j=2;j*i<=n;j++){
            ans^=b[j*i];
        }
        b[i] = ans;
        if(ans==1){
            A.push_back(i);
        }
    }
    cout << A.size() << endl;
    for(int i=0;i<A.size();i++){
        cout << A[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 3064
// Submitted by Subhash
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
	

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String s=sc.next(),t=sc.next();
		char c1[]=s.toCharArray();
		
		char c2[]=t.toCharArray();
		int n=c1.length,m=c2.length;
		int max=0;
		
		for(int i=0;i<m;i++) {
			for(int j=i;j<n&&n-j>=m-i;j++) {
				
				if(c2[i]==c1[j]) {
					
					int c=0;
					int k=0;
					
					for(int i1=j-i;i1<j-i+m;i1++) {
						if(c2[k++]==c1[i1]) c++;
					}
					
					max=Math.max(max, c);
				}
				
			}
		}
		
		System.out.println(m-max);
		
		
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] readLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}

Measured memory_bytes: 33072
#include<stdio.h>
int main(void)
{
	int a,b,n,s[100],f[100],i,j,flg;
	scanf("%d %d",&a,&b);
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d %d",&s[i],&f[i]);
	flg=0;
	for(i=0;i<n;i++){
		if(s[i]<a&&a<f[i]||s[i]<b&&b<f[i])	flg=1;
		if(s[i]==a&&f[i]==b)	flg=1;
		if(s[i]>a&&b>f[i])	flg=1;
	}
	printf("%d\n",flg);
	return 0;
}



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

int main()
{
	int n;
	while(cin >> n){
		if(!n)
			break;
		int count = 0;
		for(int i=1;i*i<n;i++){
			if(i==1)
				count++;
			else if(n%i == 0){
				count+=(i+n/i);
			}
		}
		if(count == n)
			cout << "perfect number" << endl;
		else if(count > n)
			cout << "abundant number" << endl;
		else
			cout << "deficient number" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;

int n;
int p[1000];
int x[1000];
vector<int> et[1000];

//部分木vの頂点に書いた値の和を返す. (各vで最小化したい)
int dfs(int v, int p = -1) {
	if (p != -1 && et[v].size() == 0) {	//葉
		//cout << "*s[" << v << "] = " << x[v] << endl;
		return x[v];
	}
	
	int i, j;
	
	//ナップザック問題を解く
	int N = et[v].size();
	int W = x[v];
	
	vector<vector<bool>> dp;
	vector<int> ws;
	for (i = 0; i <= N; i++) { dp.push_back(vector<bool>(W + 1, false)); }
	for (i = 0; i < N; i++) {
		int s = dfs(et[v][i], v);
		if (s == -1) return -1;
		ws.push_back(s);
	}
	
	dp[0][0] = true;
	for (i = 0; i < N; i++) {
		for (j = 0; j <= W; j++) {
			if (!dp[i][j]) continue;
			
			int a = x[et[v][i]];
			int b = ws[i] - x[et[v][i]];
			//aを足す
			if (j + a <= W) {
				dp[i + 1][j + a] = true;
			}
			//bを足す
			if (j + b <= W) {
				dp[i + 1][j + b] = true;
			}
		}
	}
	
	for (i = W; i >= 0; i--) if (dp[N][i]) break;
	if (i < 0) return -1;
	
	//x[v] + Σws - iを返す. (iは, 子の部分木の中でvと同じ色で塗る頂点の書かれた値の和)
	int ret = x[v] - i;
	for (j = 0; j < ws.size(); j++) ret += ws[j];
	//cout << "s[" << v << "] = " << ret << endl;
	return ret;
}

signed main() {
	int i;
	
	cin >> n;
	for (i = 1; i < n; i++) {
		cin >> p[i];
		p[i]--;
		et[p[i]].push_back(i);
	}
	for (i = 0; i < n; i++) cin >> x[i];
	
	if (dfs(0) != -1) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 1016
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[i]<0:
        cnt+=1
        a[i]*=(-1)
if cnt%2==0:
    print(sum(a))
else:
    print(sum(a)-min(a)*2)    
    




Measured memory_bytes: 15020
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	//sort(a.begin(),a.end());
	int n;
	cin >> n;
	vector<int> a(n+1),b(n);
	rep(i, n + 1) cin >> a[i];
	ll ans = 0;
	rep(i, n) cin >> b[i];
	rep(i, n) {
		int le = min(a[i], b[i]);
		ans += le;
		a[i] -= le;
		b[i] -= le;
		int ri = min(a[i + 1], b[i]);
		ans += ri;
		a[i + 1] -= ri;
		b[i] -= ri;
	}
	cout << ans;

	return 0; 
}









Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<limits.h>
#include<utility>
#include<cstdlib>
#define LP(i,n) for(int i=0;i<n;i++)
#define LPIN(n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  if(a >=13)cout << b << endl;
 else if(a <=5)cout << "0" << endl;
  else cout << b /2<< endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll dp[500][2];
int main() {
    ll l, k;
    cin >> l >> k;
    dp[0][0] = 1;
    ll ans = 0;
    for(ll before = 0; before <= l; before++) {
        //cerr << dp[before][0] << endl;
        dp[before + 1][0] += dp[before][1];
        dp[before+1][1] += dp[before][0];
        dp[before+k][1] += dp[before][0];
        ans += dp[before][1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3072
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;


int main(){
	char a[1000];
	char b[1000];
	ss(a);
	int count0 = 0;
	int lena = len(a);
	for(int i = 0; i < lena; i ++){
		if(a[i] == '1' || a[i] == '0'){
			b[count0++] = a[i];
		}else if(a[i] == 'B'){
			if(count0 != 0){
				count0 --;
			} 
		}
		 
	}
	b[count0] = '\0';
	ps(b) pn
    return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
a = min(X)
b = max(X)
r = 100000000000
for i in range(a,b+1):
  t = (X[0]-i)**2
  for j in range(1,N):
    t += (X[j]-i)**2
  if t < r:
    r = t
print(r)

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

int main() {
    int n,y;
    cin >> n >> y;
    y /= 1000;
    for(int i=0; i<=y/10; i++) {
        for(int j=0; j<=(y-10*i)/5; j++) {
            if((y-10*i-5*j)==(n-i-j)) {
                cout<<i<<" "<<j<<" "<<n-i-j;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int aryN,i,j,k;
  int key;
  int A[1000];
  scanf("%d",&aryN);
  for(i = 1; i <= aryN; i++)
  {
      scanf("%d", &A[i]);
  }
 
  for(j = 1; j <= aryN; j++)
    {   
          key = A[j];       
          i = j-1;
          while(i>0 && A[i]>key)
        {
          A[i+1] = A[i];  
          i = i-1;
        }
          A[i+1] = key;
          
          for(k = 1; k <= aryN; k++)
          {
              if(k == aryN)
              {
                  printf("%d\n",A[k]);
              }
              else
              {
                  printf("%d ",A[k]);
              }
          }
    }
   
  return 0;
}


Measured memory_bytes: 2696
#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;
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(){
	int n;cin>>n;
	int a=0,b=0,c=0,d=0;
	for(int i = 0; i < n; i++) {
		string s;cin>>s;
		if (s == "AC")a++;
		else if(s == "WA")b++;
		else if (s == "TLE")c++;
		else d++;
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << b<< endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;
	return 0;
}

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

int main()
{
    int a[5],i;

    for(i=0;i<5;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<5;i++)
    {
        if(a[i]==0)
        {
            cout<<i+1<<endl;
        }
    }
}


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

int main() {
  int a, b, c, d, e, f, s, o;
  double ct = 0;
  cin >> a >> b >> c >> d >> e >> f;
  for(int i = 0; a * i <= f / 100; i++) {
    for(int j = 0; a * i + b * j <= f / 100; j++) {
      if(i + j == 0)
        continue;
      for(int k = 0; a * 100 * i + b * 100 * j + c * k <= f; k++) {
        for(int l = 0; a * 100 * i + b * 100 * j + c * k + d * l <= f; l++) {
          if(ct <= 100.0 * (c * k + d * l) /
                       ((a * i + b * j) * 100 + c * k + d * l) &&
             c * k + d * l <= (a * i + b * j) * e) {
            ct = 100.0 * (c * k + d * l) /
                 ((a * i + b * j) * 100 + c * k + d * l);
            s = (a * i + b * j) * 100 + c * k + d * l;
            o = c * k + d * l;
          }
        }
      }
    }
  }
  cout << s << ' ' << o << endl;
}

Measured memory_bytes: 256
s=input()
x,y=map(int,input().split())
dpx=set()
dpy=set()
xs=[]
ys=[]
tmp=0
d=0
for c in s:
    if c=='F':
        tmp+=1
    elif c=='T':
        if tmp:
            if d==0:
                xs.append(tmp)
            else:
                ys.append(tmp)
        d^=1
        tmp=0
if tmp:
    if d==0:
        xs.append(tmp)
    else:
        ys.append(tmp)
if s[0]=='F':
    dpx.add(xs[0])
    xs=xs[1:]
else:
    dpx.add(0)
dpy.add(0)
for a in xs:
    tmp=set()
    for dx in dpx:
        tmp.add(dx+a)
        tmp.add(dx-a)
    dpx=tmp
for a in ys:
    tmp=set()
    for dy in dpy:
        tmp.add(dy+a)
        tmp.add(dy-a)
    dpy=tmp

#print(dpx,dpy)
if x in dpx and y in dpy:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3816
#include<stdio.h>
int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=S%3600/60;
	s=S%3600%60;

	printf("%d:%d:%d\n",h,m,s);

	return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int gcd(int a, int b){
  if (a < b){
    swap(a,b);
  }
  if (a % b != 0){
    return gcd(b,a % b);
  }
  else{
    return b;
  }
}

int main(){
  int k,sum = 0;
  cin >> k;
  for (int a = 1; a <= k; a++){
    for (int b = 1; b <= k; b++){
      for (int c = 1; c <= k; c++){
        sum += gcd(a,gcd(b,c));
      }
    }
  }
  cout << sum << '\n';
  return 0;
}

Measured memory_bytes: 3648
#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, a, b;
    cin >> n >> a >> b;
    cout << min(b, a*n) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll cost[105];
ll wt[105];
ll dp[100005][105];
ll func(ll w,ll i)
{
	ll d=0;
	if(i<1||w==0)
		return 0;
	if(dp[w][i]!=-1)
		return dp[w][i];
	if((w-wt[i])>=0)
		d=func(w-wt[i],i-1)+cost[i];
	dp[w][i]=max(d,func(w,i-1));
	return dp[w][i];
}
int main()
{
	ll n,w,i,j;
	cin>>n>>w;
	for(i=1;i<=n;i++)
		cin>>wt[i]>>cost[i];
	for(i=0;i<=w;i++)
	{
		for(j=1;j<=n;j++)
			dp[i][j]=-1;
	}
	cout<<func(w,n)<<endl;
}


Measured memory_bytes: 82304
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Math.*;

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        int[] a = intarr();
        int[] c = new int[111];
        for(int i=a[0];i<=a[1];i++) {
            c[i]++;
        }
        for(int i=a[2];i<=a[3];i++) {
            c[i]++;
        }
        int res = 0;
        for(int x: c) {
            if(x == 2) {
                res++;
            }
        }
        out(max(0,res-1));
    }

    private int[] intarr() throws IOException {
        return intarr(rd.readLine());
    }

    private int[] intarr(String s) {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    }

    private String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}


Measured memory_bytes: 22740
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int compare(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

int cycle1(int a, int m) {
	int x, i;

	x = a % m;
	for (i = 1; x != 1; i++) {
		x = a * x % m;
	}
	return i;
}

int64_t lcm2(int64_t m, int64_t n) {
	int64_t tmp;

	while (n) {
		tmp = n;
		n = m % n;
		m = tmp;
	}
	return m;
}

int64_t gcd3(int64_t m, int64_t n, int64_t o) {
	m = m * n / lcm2(m, n);
	n = n * o / lcm2(n, o);
	if (m > n)
		return m * n / lcm2(m, n);
	return m * n / lcm2(n, m);
}

int64_t count_cycle(int in[6]) {
	in[0] = cycle1(in[0], in[1]);
	in[1] = cycle1(in[2], in[3]);
	in[2] = cycle1(in[4], in[5]);
	qsort(in, 3, sizeof(int), compare);
	return gcd3(in[0], in[1], in[2]);
}

int main(void) {
	int in[6];

	while (1) {
		scanf("%d %d %d %d %d %d", in, in+1, in+2, in+3, in+4, in+5);
		if (!in[0])
			break;
		printf("%lld\n", count_cycle(in));
	}
	return 0;
}

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

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rreb(i,b,n) for(int i = b-1; i >= n; i--)
#define rrep(i,n) reb(i,n,0)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v) for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;

using namespace std;
using std::stringstream;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

typedef long long ll; typedef unsigned long long ull;
typedef pair <int, int> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

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

int main(int argc, char *argv[])
{
    int k, n;
    vi v;
    int ans = INF;

    cin >> k >> n;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        v.pb(tmp);
    }

    for (int i=0; i<n-1; i++) {
        ans = min(ans, (k - (v[(i+1)] - v[i])));
    }

    int last_dist = v[n-1] - v[0];
    ans = min(ans, last_dist);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define MAX 1000000000000
#define N 1005
int h,w;
char s[N][N];
ll dp[N][N];
int dx[]={1,0};
int dy[]={0,1};
ll solve(int u,int v)
{
    if(u==h-1 && v==w-1) return 1;
    if(dp[u][v]!=-1) return dp[u][v];
    ll ans=0;
    for(int i=0;i<2;i++)
    {
        int x=u+dx[i];
        int y=v+dy[i];
        if(x>=0 && x<h &&  y>=0 && y<w && s[x][y]!='#') ans=(ans+solve(x,y))%mod;
    }
    return dp[u][v]=ans;
}
int main()
{
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++)
    {
        scanf("%s",s[i]);
    }
    memset(dp,-1,sizeof dp);
    ll ans=solve(0,0)%mod;
    printf("%d",ans);
}


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

int main(){
    ll n,k;
    double ans=0,total=0;
    cin >> n >> k;
    vector<double> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    rep(i,k){
        total+=(vec[i]+1.0)/2.0;;
    }
    
    ans=total;
    
    for(ll i=k;i<n;i++){
        total+=(vec[i]+1.0)/2.0;
        total-=(vec[i-k]+1.0)/2.0;
        ans=max(ans,total);
    }
    
   
    printf("%.8f",ans);

    return 0;
}








Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var Ai = Sarray();
            var Q = Sarray()[0];
            var Mi = Sarray();

            Func<long, long, bool> solve = null;
            solve = (fi, fm) =>
             {
                 if (fm == 0) return true;
                 if (N <= fi) return false;
                 return solve(fi + 1, fm) || solve(fi + 1, fm - Ai[fi]);
             };
            for (var i = 0; i < Q; ++i)
            {
                if (solve(0, Mi[i]))
                    WriteLine("yes");
                else
                    WriteLine("no");
            }
        }
    }
}


Measured memory_bytes: 18360
import java.util.*;
public class Main{
    
    public static void main(String[] args){
        int N,A,B,K;
        Scanner Sc = new Scanner(System.in);
        N = Sc.nextInt();
        A = Sc.nextInt();
        B = Sc.nextInt();
        K = N * A;
        if (K > B){
            System.out.println(B);
        }else{
            System.out.println(K);    
        }
    }
}

Measured memory_bytes: 23636
program multiple_of_2019
  implicit none
  character(200000) :: s
  integer :: n, d, k, i, j, l = 0
  integer(8) :: dp(0:1,0:2018) = 0, c(0:2018) = 0
  read(*,*) s
  n = len_trim(s)
  do i = 1, n
    l = 1-l
    dp(l,:) = 0
    d = ichar(s(i:i))-48
    do j = 0, 2018
      k = mod(10*j+d,2019)
      dp(l,k) = dp(l,k)+dp(1-l,j)
      c(j) = c(j)+dp(1-l,j)
    end do
    dp(l,d) = dp(l,d)+1
  end do
  write(*,'(i0)') c(0)+dp(l,0)
end program multiple_of_2019

Measured memory_bytes: 3292
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int n, k, l, chk1[200020], chk[200020], a=1, b=1;
vector<int> L[200020], T[200020];
map< pair<int, int>, int > cnt;
void dfs(int x, int y)
{
    chk[x] = y;
    for(int i = 0 ; i < L[x].size() ; i++ )
        if( !chk[L[x][i]] ) dfs(L[x][i], y);
}
void dfs2(int x, int y)
{
    chk1[x] = y;
    for(int i = 0 ; i < T[x].size() ; i++)
        if( !chk1[T[x][i]] ) dfs2(T[x][i], y);
}
int f(int x)
{

}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k>>l;
    for(int i = 0 ; i < k ; i++ )
    {
        int a, b;
        cin>>a>>b;
        L[a].push_back(b);
        L[b].push_back(a);
    }
    for(int i = 0 ; i < l ; i++ )
    {
        int a, b;
        cin>>a>>b;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    for(int i = 1 ; i <= n ; i++ )
        if( !chk[i] ) dfs(i, a++);
    for(int i = 1 ; i <= n ; i++ )
        if( !chk1[i] ) dfs2(i, b++);
    for(int i = 1 ; i <= n ; i++ )
        cnt[{chk[i], chk1[i]}]++;
    for(int i = 1 ; i <= n ; i++ )
        cout<<cnt[{chk[i], chk1[i]}]<<(i==n?"\n":" ");
}


Measured memory_bytes: 27904
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;


int main() {
    int N, M; cin >> N >> M;
    map<PII, int>table;
    for(int i=0; i<M; i++){
        int p, y; cin >> p >> y;
        table[PII(p, y)] = i;
    }
    
    map<int, PII> ID;
    int prePN;
    int i=0;
    int order = 1;
    for(auto m:table){
        int PN = m.first.first;
        int Num = m.second;
        if(i==0) ID[Num] = PII(PN, order);
        else {
            if(PN != prePN) order = 1;
            ID[Num] = PII(PN, order);
        }

        i++;
        order++;
        prePN = PN;
    }
    
    for(auto id:ID){
        cout << setfill('0') << right << std::setw(6) << id.second.first;
        cout << setfill('0') << right << std::setw(6) << id.second.second << endl;;
    }

}


Measured memory_bytes: 13952
#include <stdio.h>
int main()
{
    int n,d,x,i,s[105],j,sum=0;
    scanf("%d %d %d",&n,&d,&x);
    for(i=0;i<n;i++)
        scanf("%d",&s[i]);
    for(i=0;i<n;i++)
    {
        sum=sum+1;
        for(j=1;;j++)
        {
            if(s[i]*j+1<=d)
                sum=sum+1;
            else
                break;
        }
    }
    printf("%d\n",sum+x);
    return 0;
}


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

int main() {

    int n;
    string s, t;

    cin >> n;
    cin >> s >> t;

    string output;
    for(int i = 0; i < n; i++){
        // printf("%c",s[i]);
        // printf("\n");
        // printf("%c",t[i]);
        // printf("\n");
        output += s[i];
        output += t[i];
        // printf("%c %c\n", s[i], t[i]);
        // cout << output << endl;
    }

    cout << output << endl;

    return 0;
}

Measured memory_bytes: 256