akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;
int MOD = 1000000007;
signed main(){

    int n,k;
    cin >> n >> k;
    if(n+1 >= 2*k)cout << "YES";
    else cout << "NO";
    cout << endl;



    
    return 0;   
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://arc060.contest.atcoder.jp/tasks/arc060_a

Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define int long long
#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vecotor<vector<int> >
#define VPII vector<pair<int,int> >

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val) {
	std::fill( (T*)array, (T*)(array + N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言
int H, W, sh, sw, gh, gw;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};//BFS関連







//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}

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



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main() {
	//入力の高速化用のコード
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	int N, K;
	cin >> N >> K;
	cout<<min(N%K,K-(N%K))<<endl;



	return 0;

}







Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;
const int INF=1000000000;
int main(){
	int A,B,C,D,E,F,ansa=0,anse=0;
	cin>>A>>B>>C;
	if(A==B)cout<<C<<endl;
	if(A==C)cout<<B<<endl;
	if(C==B)cout<<A<<endl;	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using ll = long long;
using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<int> d(n);
  for(int&x:d) cin >> x;
  map<int,int> count;
  for(int x:d) ++count[x];
  ll answer = 0;
  if(d[0] == 0 && count[0] == 1) answer = 1;
  FOR(i,1,n) answer = (answer*count[d[i]-1])%998244353;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = scanner.nextInt();
			y[i] = scanner.nextInt();
		}

		double sum = 0;
		int c;
		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				c = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
				sum += Math.sqrt(c) * 2 / n;
			}
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rushb() scanf("%d",&t);while(t--)
#define rusha() scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define debug() cout<<"LBWNB"<<'\n'
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define p() puts("");
using namespace std;
typedef long long ll;
const int mod=998244353;
const int inf=1e9+7;
const int maxn=2e5+7;
ll n,m,k;
int main(){
    cin>>n>>m>>k;
    __int128 d2=k-n-m,d1=4*n*m;
    if(d2<=0) {puts("No");return 0;}
    printf("%s\n",(d1<d2*d2)?"Yes":"No");
    return 0;
}










//const int M=1<<20;
//ll t1[M*2+5],t2[M*2+5],ans,ca[M],cb[M];
//inline void upd(int i){t1[i]=t1[i<<1]+t1[i<<1|1];t2[i]=max(t2[i<<1],t1[i<<1]+t2[i<<1|1]);}
//inline void add(int i,int v){for(t1[i+=M]+=v;i>>=1;upd(i));}
//int n,m,p,x,y,i,j;
//struct mons{int x,y,z;}a[M];
//int main(){
//	for(i=0;i<M;++i)ca[i]=cb[i]=1ll<<60;ans=-(1ll<<60);
//	scanf("%d%d%d",&n,&m,&p);
//	for(i=1;i<=n;++i)scanf("%d%d",&x,&y),ca[x]=min(ca[x],(ll)y);
//	for(i=1;i<=m;++i)scanf("%d%d",&x,&y),cb[x]=min(cb[x],(ll)y);
//	for(i=0;i<M;++i)t2[i+M]=-cb[i];for(i=M-1;i;--i)upd(i);
//	for(i=1;i<=p;++i)scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
//	sort(a+1,a+p+1,[&](const mons&a,const mons&b){return a.x<b.x;});
//	for(i=0,j=1;i<M;++i){
//		for(;j<=p && a[j].x<i;++j)add(a[j].y,a[j].z);
//		ans=max(ans,t2[1]-ca[i]);
//	}
//	printf("%lld\n",ans);
//	return 0;
//}


Measured memory_bytes: 256
#include <stdio.h>

/* ????¨?????????? */
typedef struct tagsExaminationScore {
	int m_score;	/* ??????????¨? */
	int f_score;	/* ??????????¨? */
	int r_score;	/* ???????¨? */
} S_EXAMINATION_SCORE;

int main(void)
{
	S_EXAMINATION_SCORE studentScore;
	char studentGrage;

	while(1) {
		/* ????¨???????????????\??? */
		scanf("%d %d %d", &studentScore.m_score, 
						  &studentScore.f_score,
						  &studentScore.r_score);
		
		/* ??\???????????????-1?????¨??????????????? */
		if(studentScore.m_score == -1 &&
		   studentScore.f_score == -1 &&
		   studentScore.r_score == -1){
			   break;
		   }

		if(studentScore.m_score == -1 || studentScore.f_score == -1){
			/* ??????????¨??????????????¨?????????????????¬???? */
			studentGrage = 'F';
		}else if(80 <= (studentScore.m_score + studentScore.f_score )){
			/* ??????????¨???¨??????????¨????????¨??????°???80??\??? */
			studentGrage = 'A';
		}else if(65 <= (studentScore.m_score + studentScore.f_score ) &&
			/* ??????????¨???¨??????????¨????????¨??????°??? 65 ??\??? 80 ?????? */
				 (studentScore.m_score + studentScore.f_score ) < 80){
			studentGrage = 'B';
			
		}else if(50 <= (studentScore.m_score + studentScore.f_score ) &&
			/* ??????????¨???¨??????????¨????????¨??????°??? 50 ??\??? 65 ?????? */
				 (studentScore.m_score + studentScore.f_score ) < 65){
			studentGrage = 'C';
			
		}else if(30 <= (studentScore.m_score + studentScore.f_score ) &&
				 (studentScore.m_score + studentScore.f_score ) < 50){
			/* ??????????¨???¨??????????¨????????¨??????°??? 30 ??\??? 50 ?????? */
			/* ???????????????????¨?????????°???50 ??\???????????°?????????C */
			if(50 <= studentScore.r_score){
				studentGrage = 'C';
			}else{
				studentGrage = 'D';
			}
		}else if((studentScore.m_score + studentScore.f_score ) < 30){
			/* ??????????¨???¨??????????¨????????¨??????°??? 30 ?????? */
			studentGrage = 'F';
		}else{
			/* do nothing */
		}

		/* ????????¨??? */
		printf("%c\n", studentGrage);
	}

	return 0;
}

Measured memory_bytes: 600
import sys
def main():
    INF=sys.maxsize
    N,K=tuple(map(int,sys.stdin.readline().split()))
    h=tuple(map(int,sys.stdin.readline().split()))
    dp=[INF for _ in range(N)]
    dp[0]=0
    for i in range(1,N):
        for j in range(1,K+1):
            if i-j>=0:
                dij=dp[i-j]+abs(h[i]-h[i-j])
                if dij<dp[i]:dp[i] = dij
    print(dp[N-1])
if __name__=='__main__':main()

Measured memory_bytes: 92780
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const int INF = 1e9;


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



mint dp[100010][15];

int main(){
    string s;
    cin >> s;
    int l = s.size();
    rep(i,100010){
        rep(j,15){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    rep(i,l){
        if(s[i]=='?'){
            rep(x,10){
                rep(j,13){
                    dp[i+1][(10*j+x)%13]+=dp[i][j];
                }
            }
        }
        else{
            int x = s[i]-'0';
            rep(j,13){
                dp[i+1][(10*j+x)%13]+=dp[i][j];
            }
        }
    }
    cout << dp[l][5] << endl;


    return 0;
}


Measured memory_bytes: 12160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    int[] march = new int[5];

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            switch (sc.next().charAt(0)) {
                case 'M':
                    march[0]++;
                    break;
                case 'A':
                    march[1]++;
                    break;
                case 'R':
                    march[2]++;
                    break;
                case 'C':
                    march[3]++;
                    break;
                case 'H':
                    march[4]++;
                    break;
            }
        }
        solve();
    }

    void solve() {
        long count = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = i + 1; j < 4; j++) {
                for (int k = j + 1; k < 5; k++) {
                    count += (long)march[i] * march[j] * march[k];
                }
            }
        }
        System.out.println(count);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 34868
a,b = map(int,input().split())
s = list(input())
t1 = s[:a]
t2 = s[a]
t3 = s[a+1:]

t1 = ''.join(t1)
t3 = ''.join(t3)

def is_int(s):
    try:
        int(s)
        return True
    except ValueError:
        return False

if is_int(t1) == True and is_int(t3) == True and t2 == '-':
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    string S;
    cin >> S;
    bool YYMM = false;
    bool MMYY = false;
    ll tmp = stoll(S);
    ll f = tmp / 100;
    ll s = tmp % 100;
    if (1 <= f && f <= 12) {
        if (1 <= s && s <= 12) print("AMBIGUOUS");
        else print("MMYY");
    } else {
        if (1 <= s && s <= 12) print("YYMM");
        else print("NA");
    }
    return 0;
}

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

  long num1,num2,n1,n2,lcm, rem;
  scanf("%ld %ld", &num1,  &num2);

  n1=num1;
  n2 = num2;

  while (n2!=0){
    rem = n1%n2;
    n1=n2;
    n2=rem;
  }
  lcm=(num1*num2)/n1;
  printf("%ld", lcm);
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int a[20];
	int v[20];
	int n;
	int b;
	int i;
	int max;
	
	scanf("%d", &n);
	
	max = 0;
	for (i = 0; i < n; i++){
		scanf("%d %d", &a[i], &v[i]);
		if (max < v[i]){
			max = v[i];
			b = a[i];
		}
	}
	
	for (i = 0; i < n; i++){
		if (max == v[i] && a[i] < b){
			b = a[i];
		}
	}
		printf("%d %d\n", b, max);
	
	return(0);
}

Measured memory_bytes: 600
str = input()
def check_str(str, ans):
    return str.find(ans)

if(check_str(str, "a") == -1):
    print("No")
elif(check_str(str, "b") == -1):
    print("No")
elif(check_str(str, "c") == -1):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int a;
    cin>>a;
    int arr[a+1], dp[a+1];
    for (int i=1; i<=a; i++) cin>>arr[i];
    dp[1]=0, dp[2]=abs(arr[2]-arr[1]);
    for (int i=3; i<=a; i++){
        dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1], abs(arr[i]-arr[i-2])+dp[i-2]);
    }
    cout<<dp[a]<<endl;
}

Measured memory_bytes: 4376
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(min(b,d)-max(a,c)>0){
		cout<<min(b,d)-max(a,c)<<endl;
	}
	
	else cout<<0<<endl;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  lll n;
  vector<lll> a,b,c;
  cin >> n;

  a.resize(n);
  b.resize(n);
  c.resize(n);

  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }
  
  for(ii=0;ii<n;ii++){
    cin >> b[ii];
  }

  for(ii=0;ii<n;ii++){
    cin >> c[ii];
  }

  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());

//  for(ii=0;ii<n;ii++){
//    cout << "bii" << b[ii] << endl;
//  }
  lll sum = 0;
  lll bval,anum,bnum,cnum;
  for(ii=0;ii<n;ii++){

    auto itr  = upper_bound(c.begin(),c.end(),b[ii]);
    auto itr2 = upper_bound(a.begin(),a.end(),b[ii] - 1);
    
    //cout << b[ii] << endl;

    //cout << "a" << *itr2 << endl;
    //cout << "c" << *itr << endl;

    cnum = c.end() - itr;
    anum = itr2 - a.begin() ;

    //cout << "cnum" << cnum << endl;
    //cout << "anum" << anum << endl;
    //cout << cnum * anum << endl;
    sum += cnum*anum;
//    while(itr!=b.end()){
//      //cout << *itr << endl;
//      auto itr2 = upper_bound(c.begin(),c.end(),*itr);
//      if(itr2!=c.end()){
//        sum += c.end() - itr2;
//      }
//      itr++;
//    }

//    if(itr!=b.end()){
//
//      //cout << b.end() - itr << endl;
//      
//
//
//      if(itr2 != c.end()){
//        cout << *itr2 << endl;
//        //cout << c.end() - itr2 << endl;
//        
//        bnum = b.end() - itr;
//        cnum = c.end() - itr2;
//        sum += bnum*cnum;
//        
//      }
//    }

  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2560
a,z,x,i,j;
main(t)
{
  for(scanf("%d",&t);t--;printf("%d %d\n",-z,a))
    for(a=z=0,scanf("%d%d",&x,&i);--x;i=j)
      scanf("%d",&j),i-=j,a=i>a?i:a,z=i<z?i:z;
  a=0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
    Ci, Si, Fi = list(map(int, input().split((" "))))
    C.append(Ci)
    S.append(Si)
    F.append(Fi)

ans = []
for i in range(N):
    t = 0
    for j in range(i, N-1):
        if t < S[j]:
            t = S[j]
        elif t % F[j] == 0:
            pass
        else:
            t = t + F[j] - (t % F[j])
        t += C[j]
    print(t)



Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        System.out.println(A * N < B ?  A * N : B );
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    i64 N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define ll long long
using namespace std;
ll n;
int main(){
	scanf("%lld",&n);
	ll x=(n+999999999)/1000000000,y=x*1000000000-n;
	printf("0 0 1000000000 1 %lld %lld\n",y,x);
}
/*
a.x*b.y-a.y*b.x
*/

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

int main() {

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

	return 0;
}

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

int L;
vector<int> ones;
vector<tuple<int,int,int> > edges;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> L;
	int lg = 31 - __builtin_clz(L), n = lg + 1;
	for(int j = lg-1, i = 1; j >= 0; j--, i++) {
		edges.emplace_back(i, i+1, 1 << j);
		edges.emplace_back(i, i+1, 0);
		if(L >> j & 1) ones.push_back(j);
	}
	for(int j: ones) {
		int add = L >> j+1 << j+1;
		edges.emplace_back(1, lg - j + 1, add);
	}
	cout << n << ' ' << edges.size() << endl;
	for(auto e: edges) {
		int u, v, w; tie(u, v, w) = e;
		cout << u << ' ' << v << ' ' << w << endl;
	}
}

Measured memory_bytes: 256
import sys
import math


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n, d = LI()
ans = 0
for _ in range(n):
    x, y = LI()
    if x ** 2 + y ** 2 <= d ** 2:
        ans += 1
print(ans)


Measured memory_bytes: 9240
import re

S=input()

if re.match("keyence",S) or re.match("^(.*)(keyence)$",S) or re.match("^k(.*)(eyence)$",S) or re.match("^(ke)(.*)(yence)$",S) or re.match("^(key)(.*)(ence)$",S) or re.match("^(keye)(.*)(nce)$",S) or re.match("^(keyen)(.*)(ce)$",S) or re.match("^(keyenc)(.*)(e)$",S)  or re.match("^(keyence)(.*)$",S):
    print("YES")
else:
    print("NO")

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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
    return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

int main()
{
    int n , k;
    cin >> n >> k;

    cout << (n%k != 0 ? 1 : n%k) << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();

		int[] x = new int[n + 1];
		int[] y = new int[m + 1];

		x[n] = X;
		y[m] = Y;

		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		for (int i = 0; i < m; i++) {
			y[i] = sc.nextInt();
		}

		Arrays.sort(x);
		Arrays.sort(y);

		System.out.println(x[n] < y[0] ? "No War" : "War");

		sc.close();
	}

}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d){
        cout << "Left" << endl;
    }else if(a+b < c+d){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
long long N,W;

int 
main(){
	long long X,K;
	long long B[110];

	scanf("%lld",&N);
	long long i,j;

	for(i=0;i<N-1;i++){
		scanf("%lld",&B[i]);
	}


	long long sum=0;
	int prev_a =0;
	for(i=0;i<N;i++){
		if(i==0)sum +=B[0]; // B[i]
		else if(i==N-1) {
			sum += B[i-1];
			//printf("%d'%lld\n",i,B[i-1]);
		}
		else if(i>=1){
			if( B[i-1]<B[i]){
				sum+= B[i-1];
				//printf("+%lld\n",B[i-1]);
			}
			else {
				sum += B[i];
				//printf("++%lld\n",B[i]);
			}
		}
	}
	printf("%lld\n",sum);
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
const double pie  =3.141592653589793238463;
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define POP(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(),A.end());
#define REV(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n" 
const ll dx[4] = { -1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
ll XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
ll YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
#define precise(x) cout<<fixed<<setprecision(x)
#define t1(x)                cerr<<#x<<": "<<x<<endl
#define t2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
void SieveOfEratosthenes(ll n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // for (ll p=2; p<=n; p++) 
       // if (prime[p]) 
          // cout << p << " "; 
} 

ll power(ll x, ll y) 
{ 
    ll res = 1; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x * x; 
    } 
    return res; 
}
int main()
{
    fastio
    ll t,i,j,k,l,m,n,a,x,b,y,z,c,h,d,f,e,p,o,nl,np,q,r,g;
    cin>>n;
    ll arr[n];
    x=0;
    rep(i,0,n)
    {
        cin>>arr[i];
        x=x^arr[i];
    }
    // cout<<x<<endl;

    rep(i,0,n)
    {
        cout<<(x^arr[i])<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 5172
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int a[14],n,t;
int dfs(int s,int x){
  if(x==s)return 1;
  r(i,14)if(a[i]&&(s-x-i)%i==0){
    a[i]--;
    if(dfs(s,x+i)){
      if(x+i!=s)cout<<' ';
      cout<<i;
      return 1;
    }
    a[i]++;
  }
  return 0;
}
main(){
  while(cin>>n,n){
    int sum=0;
    r(i,14)a[i]=0;
    r(i,n){
      cin>>t;
      a[t]++;
      sum+=t;
    }
    if(!dfs(sum,0))cout<<"No";
    cout<<endl;
  }
}

Measured memory_bytes: 2924
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

int p[200010],cnt[200010];

int find(int x){
	if(p[x]!=x) p[x]=find(p[x]);
	return p[x];
}
int main(){
	int n,m;
	int ans=1;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) p[i]=i,cnt[i]=1;
	while(m--){
		int a,b;
		scanf("%d%d",&a,&b);
		int pa=find(a),pb=find(b);
		if(pa!=pb){
			p[pa]=pb;
			cnt[pb]+=cnt[pa];
			ans=max(cnt[pb],ans);
		}
	}
	printf("%d",ans);
} 

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


int main() {
	int H, W;
	cin >> H >> W;
	char s[51][51] = { '.' };
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> s[i][j];
		}
	}
	bool flag = true;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (s[i][j] == '#') {
				if (s[i - 1][j] != '#' && s[i][j - 1] != '#' && s[i + 1][j] != '#' && s[i][j + 1] != '#') {
					flag = false;
					break;
				}
			}
		}
		if (!flag) break;
	}
	cout << ((flag) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF (1LL << 62)
 
typedef long long i64;
typedef pair<i64,i64> P;
 
 
i64 gcd(i64 x, i64 y){
	if(y == 0) return x;
	return gcd(y, x%y);
}
i64 lcm(i64 x, i64 y){
	return x*y / gcd(x,y);
}
 
i64 a,b;
 
int main(){
	cin >> a >> b;
	
	i64 cnt = 0, c = 1;
	set<i64> st;
	for(i64 i = 1; i*i <= min(a,b); i++){
		if(a % i == 0 && b % i == 0){
			st.insert(i);
		}
		i64 d = a / i;
		if(a % d == 0 && b % d == 0){
			st.insert(d);
		}
		d = b / i;
		if(a % d == 0 && b % d == 0){
			st.insert(d);
		}
	}
	for(auto i = st.begin(); i != st.end(); i++){
		if(lcm(c,(*i)) == c * (*i)){
			cnt++;
			c *= (*i);
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl ("\n")
#define pi (3.141592653589)
#define mod 1e9+7
#define INF 1e9+9
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define so sizeof 
#define pii pair<ll,ll>
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define max3(a, b, c) max(c, max(a, b))
#define max4(a, b, c, d) max(d, max(c, max(a, b)))
#define repe(i,a) for(auto i:a)
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=b;i>=a;i--)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
void solve(){
  ll n,w;
  cin>>n>>w;
  ll wt[n+1],val[n+1];
  rep(i,1,n){
    cin>>wt[i]>>val[i];
  }
  ll sum=accumulate(val+1,val+n+1,0);
  ll dp[n+1][sum+1];
  rep(i,1,n){
    rep(j,1,sum){
        dp[i][j]=INF;
    }
  }
  rep(i,0,n)dp[i][0]=0;
  rep(i,1,sum){
     if(i==val[1])
        dp[1][i]=wt[1];
  }
  rep(i,2,n){
    rep(j,1,sum){
    if(j<val[i]){
       dp[i][j]=dp[i-1][j];
    }
    else{
       dp[i][j]=min(dp[i-1][j],wt[i]+dp[i-1][j-val[i]]);
    }
    }
  }
  ll res=0;
  rep(i,1,sum){
    if(dp[n][i]<=w){
        res=i;
    }
  }
  cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
#endif
    fast
    solve();
    return 0;
}

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

int m, n;
int a[128];
string s[] = {"", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"};

int main()
{
	while (cin >> m >> n, m){
		memset(a, 0, sizeof(a));
		a[0] = 1;

		for (int i = 0; i < n; i++){
			for (int j = 100; j >= 0; j--){
				a[j] *= m;
				a[j + 1] += a[j] / 10000;
				a[j] %= 10000;
			}
		}

		for (int j = 100; j >= 0; j--){
			if (a[j]) cout << a[j] << s[j];
		}
		cout << endl;
	}
}

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

int main(){
	int n;
	while (cin >> n && n != 0){
		map<string, string> m;
		string s1, s2;
		for (int i = 0; i < n; i++){
			cin >> s1 >> s2;
			m[s1] = s2;
		}
		cin >> n;
		string line;
		for (int i = 0; i < n; i++){
			cin >> s1;
			if (m.find(s1) != m.end()){
				s1 = m[s1];
			}
			line += s1;
		}
		cout << line << endl;
	}
	return 0;
}




Measured memory_bytes: 3136
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int H[] = new int[N+1];
    int ma[] = new int[N+1];
    for(int i=1;i<=N;i++) {
    	H[i] = sc.nextInt();
    	ma[i] = 0;
    }
    for(int i=0;i<M;i++) {
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	ma[A] = Math.max(ma[A], H[B]);
    	ma[B] = Math.max(ma[B], H[A]);
    }
    int ans = 0;
    for(int i=1;i<=N;i++) {
    	if(H[i]>ma[i]) {
    		ans++;
    	}
    }
    System.out.println(ans);
  }
}

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

int main(){
    int count=0,ndata,i=0;
    cin >> ndata;

    while(i!=1){
        ndata= ndata-2;
        count++;
        if(ndata <= 0){
            i = 1;
        }else if(ndata == 1){
            i = 1;
        }
    }
    if(ndata==1){
        count++;
        cout <<count;
    }else{
        cout <<count;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MAX 26

struct Node {
	int p, l, r; //??????????????????
};
struct Node T[MAX];
int D[MAX];

//??¨node?????±??????D???????´?
void rec(int id, int d) {
	D[id] = d;
	if (T[id].r != -1) {
		rec(T[id].r, d + 1);
	}
	if (T[id].l != -1) {
		rec(T[id].l, d + 1);
	}
}

int hei(int id) {
	int l = -1, r = -1;
	if (T[id].l != -1)l = hei(T[id].l);
	if (T[id].r != -1)r = hei(T[id].r);
	if (l == -1 && r == -1)return 0;
	return max(l, r) + 1;
}

void print(int id) {
	int sib = -1,
		deg = 0;
	if (T[id].p != -1)
		sib = (T[T[id].p].l == id) ? T[T[id].p].r : T[T[id].p].l;
	deg += (T[id].l != -1) ? 1 : 0;
	deg += (T[id].r != -1) ? 1 : 0;

	string type = "internal node";;
	if (T[id].r == -1 && T[id].l == -1)type = "leaf";
	if (T[id].p == -1)type = "root";

	cout << "node " << id;
	cout << ": parent = " << T[id].p;
	cout << ", sibling = " << sib;
	cout << ", degree = " << deg;
	cout << ", depth = " << D[id];
	cout << ", height = " << hei(id);
	cout << ", " << type << endl;
}

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

	//?????????
	for (int i = 0; i < n; i++) {
		T[i].p = T[i].l = T[i].r = -1;
	}

	for (int i = 0; i < n; i++) {
		int id, l, r; cin >> id >> l >> r;
		T[id].l = l; T[id].r = r;
		T[l].p = id; T[r].p = id;
	}

	//??????????????????
	int r;
	for (int id = 0; id < n; id++) {
		if (T[id].p == -1) { r = id; }
	}

	rec(r, 0);

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

	return 0;
}

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

int main(){

  int K,A,B;
  cin >> K >> A >> B;

  for(int i=A;i<=B;i++){
    if(i%K==0){
      cout << "OK" <<endl;
      break;
    }else if(i==B){
      cout << "NG" << endl;
    }
  }
}


Measured memory_bytes: 3556
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		ArrayList<Double> a=new ArrayList<Double>();
		for(int i=0;i<n;i++)
		{
			a.add(in.nextDouble());
		}
		Collections.sort(a);
		for(int i=0;i<n-1;i++)
		{
			double temp=(a.get(0)+a.get(1))/2.0;
			a.remove(0);
			a.remove(0);
			a.add(temp);
			Collections.sort(a);
		}
		System.out.println(a.get(0));
	}
}
	

Measured memory_bytes: 25172
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.09.09 16:46:13
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
    int n, p[100];
    scanf("%d", &n);
    rep1(i, n) {
        scanf("%d", &p[i]);
    }

    int cnt = 0;
    rep1(i, n) {
        if (i != p[i]) {
            // disp(i);
            cnt++;
        }
    }

    if (cnt == 2 || cnt == 0) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
/*切り上げの計算！*/
int maxtime(int x) {
	return(x + 9) / 10 * 10;

}
int main() {
	long long int L, R;
	cin >> L >> R;
	if (R - L >= 2019) {
		cout << 0;
	}else{
		long long int l, r;
		l = L % 2019;
		r = R % 2019;
		if (l > r) {
			cout << 0;
		}
		else{
			int cnt = 2019;
			for (int i = l; i < r; i++) {
				for (int j = i + 1; j <= r; j++) {
					cnt = min(cnt, (i * j) % 2019);
				}
			}
			cout << cnt;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
vector<ll>to[100005];
vector<ll>place[100005];
vector<ll>kyori(100005);

void dfs(ll v, ll p=-1){
  ll x = to[v].size();
  for(int i=0; i<x; i++){
    ll u=to[v][i];
    if(u==p) continue;
    if(kyori[u]) continue;
    kyori[u]=kyori[v]+place[v][i];
    dfs(u,v);
  }
}


int main(){
  ll n;
  cin >> n;
  for(int i=0; i<n-1; i++){
    ll u,v,w;
    cin >> u >> v >> w;
    u--;
    v--;
    place[u].push_back(w);
    place[v].push_back(w);
    to[u].push_back(v);
    to[v].push_back(u);
  }
  kyori[0]=0;
  
  dfs(0);
  
  for(int i=0; i<n; i++){
    if(kyori[i]%2==0) cout << 0 << endl;
    else cout << 1 << endl;
  }
  
}
  
  
  


Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int n;
  while(cin>>n,n){
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int ans=0;
    
    vector<int> p[555];
    for(int i=0;i<n;i++){
      int x=a[i];
      while(x%2==0) x/=2;
      p[x].push_back(a[i]/x);
    }
    auto calc=[](vector<int> &a){
      int sum=accumulate(a.begin(),a.end(),0);
      vector<int> dp(sum+1,-1);
      dp[0]=0;
      for(int x:a){
	for(int i=sum/x*x;i>0;i-=x)
	  if(~dp[i-x]) dp[i]=max(dp[i],dp[i-x]+1);
      }
      int res=0;
      for(int i=1;i<=sum;i<<=1) res=max(res,dp[i]);
      return res;
    };
    for(int i=0;i<555;i++)
      if(!p[i].empty()) ans=max(ans,calc(p[i]));
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3576
n,w = map(int,input().split())
dp = [[0 for _ in range(w+1)] for _ in range(n+1)]
vw = []
for i in range(n):
    vw.append(list(map(int,input().split())))
for i in range(1,n+1):
    vi = vw[i-1][0]
    wi = vw[i-1][1]
    for j in range(1,w+1):
        if wi <= j:
            dp[i][j] = max(dp[i-1][j-wi]+vi, dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[n][w])


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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
  if (A.size() == n + 1) {
    int now = 0;
    for (int i = 0; i < q; ++i) {
      if (A[b[i]] - A[a[i]] == c[i]) {
        now += d[i];
      }
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  for (int i = 0; i < q; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1, 1));
  cout << ans << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define N 100005
using namespace std;
char s[N];
int n,a[N],cnt=1,last=1,fa=1;
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for (int i=1;i<=n;i++) a[i]=s[i]-'0';
    for (int i=1;i<=n-1;i++) if (a[i]^a[n-i]==1) {printf("-1");return 0;}
    if (a[1]==0 || a[n]==1) {printf("-1");return 0;}
    for (int i=2;i<=n/2;i++)
    {
        if (a[i]==1)
        {
            printf("%d %d\n",fa,++cnt);
            int it=cnt;
            for (int j=last+2;j<=i;j++) printf("%d %d\n",it,++cnt);
            last=i,fa=it;
        }
    }
    int it=++cnt;
    printf("%d %d\n",it,fa);
    for (int i=cnt+1;i<=n;i++)
    {
        printf("%d %d\n",it,i);
    }
    return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>
int len(char *a){
	int i;
	int count=0;
	for(i=0;a[i]!='\0';i++)count++;
	return count;
	
	}
int copy(char *a,char *b){
	int i,flag=1;
	int l=len(a);
	for(i=0;i<l;i++){
		if(a[i]!=b[i])flag=0;
		}
	return flag;
	
	}
int main(){
	char a[100000],b[100000];
	int i,j=0,l,temp,count=0;;
	scanf("%s%s",a,b);
	l=len(a);
	
	
	while(j!=1){
		j=copy(a,b);
		if(j==1)break;
		else{
			temp=a[0];
	for(i=0;i<l;i++){
		//temp=a[0];
		a[i-1]=a[i];
		if(i==l-1)a[l-1]=temp;
		}
		count++;
		if(count>l)break;
	}
		//printf("%s\n",a);
	}
	if(j==1)printf("Yes\n");
	else printf("No\n");
	return 0;
	}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int preT = 0;
        int preX = 0;
        int preY = 0;

        for(int i = 0; i < N; i++) {
            int postT = sc.nextInt();
            int postX = sc.nextInt();
            int postY = sc.nextInt();

            int dt = postT - preT;
            int dist = Math.abs(postX - preX) + Math.abs(postY - preY);
            if((dt < dist) || ((dist - dt) % 2 != 0)) {
                System.out.println("No");;
                return;
            }

            preT = postT;
            preX = postX;
            preY = postY;
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 85224
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int A, B;
  cin >> A >> B;
  for (int i = 1; i < 10000; ++i) {
    if (8 * i / 100 == A and 10 * i / 100 == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 256
n , m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]

mi = 0
ma = n
for i in range(m):
  mi = max(mi, lr[i][0])
  ma = min(ma, lr[i][1])
  
  
if ma-mi>=0:
  print(ma-mi+1)
else:
  print(0)

Measured memory_bytes: 27264
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

vector<long long> G[200010];
long long counter[200010];

void dfs(int s, long long add=0){
  counter[s]+=add;
  for(auto v:G[s]){
    dfs(v,counter[s]);
  }
}

void solve(long long N, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> p, std::vector<long long> x){
  REP(i,N){
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
  }
  REP(i,Q){
    p[i]--;
    counter[p[i]]+=x[i];
  }
  dfs(0);
  REP(i,N){
    cout<<counter[i]<<(i==N-1?"\n":" ");
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long Q;
  scanf("%lld",&Q);
  std::vector<long long> a(N-1);
  std::vector<long long> b(N-1);
  for(int i = 0 ; i < N-1 ; i++){
    scanf("%lld",&a[i]);
    scanf("%lld",&b[i]);
  }
  std::vector<long long> p(Q);
  std::vector<long long> x(Q);
  for(int i = 0 ; i < Q ; i++){
    scanf("%lld",&p[i]);
    scanf("%lld",&x[i]);
  }
  solve(N, Q, std::move(a), std::move(b), std::move(p), std::move(x));
  return 0;
}


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

int size(int x){
    if(x > 160) return 6;
    if(x > 140) return 5;
    if(x > 120) return 4;
    if(x > 100) return 3;
    if(x > 80) return 2;
    if(x > 60) return 1;
    return 0;
}

int weight(int x){
    if(x > 25) return 6;
    if(x > 20) return 5;
    if(x > 15) return 4;
    if(x > 10) return 3;
    if(x > 5) return 2;
    if(x > 2) return 1;
    return 0;
}

int price[7] = {600, 800, 1000, 1200, 1400, 1600, 0};

int main(){
    while(1){
        int n, x, y, h, w;
        cin >> n;

        if(n == 0)  break;

        int sum = 0;
        for(int i = 0; i < n; i++){
            cin >> x >> y >> h >> w;
            sum += price[max(size(x+y+h), weight(w))];
        }

        cout << sum << endl;
    }
    return 0;
}


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

// why am I so weak

int n, m;
int a[100055];

int main() {
	scanf("%d %d", &n, &m);

	while (m--) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--, y--;

		a[x] ^= 1, a[y] ^= 1;
	}
	
	for (int i = 0; i < n; i++) if (a[i] & 1) {
		puts("NO");
		return 0;
	}

	puts("YES");

	return 0;
}


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

int main(){
    int A;
    int B;
    int C;
    int D;
    cin >> A >> B >> C >> D;

    while(true){
        C = C - B;
        //cout << "A:" << A  << " C:" << C << endl;
        if(A <=0 || C <= 0) break;
        A = A - D;
        //cout << "A:" << A  << " C:" << C << endl;
        if(A <=0 || C <= 0) break;
    }
    if(A > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}



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

int main(){
	ll n;
	cin >> n;
	if(n % 2 == 0){
		cout << n << endl;
	}else{
		cout << n*2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    cout << N / 3 << endl;
}
  

Measured memory_bytes: 3496