akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = (a); i <(b); i++)
#define forn(i,a,b) for (int i = (a); i >(b); i--)
#define mod 1000000007
#define multiple_testcases_t int t;cin>>t;while(t--){solve();}
#define single_testcase_t solve();
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


int root(int Arr[],int i)
    {
        while(Arr[i] != i)
        {
            Arr[i] = Arr[Arr[i]]; 
            i = Arr[ i ]; 
        }
    return i;
    }

bool find(int Arr[],int A,int B)
    {
        if( root(Arr,A)==root(Arr,B) )
        return true;
        else
        return false;
    }

void weighted_union(int Arr[],int size[],int A,int B)
    {
        int root_A = root(Arr,A);
        int root_B = root(Arr,B);
        if(size[root_A] < size[root_B ])
        {
         Arr[ root_A ] = Arr[root_B];
         size[root_B] += size[root_A];
        }
        else
        {
         Arr[ root_B ] = Arr[root_A];
         size[root_A] += size[root_B];
        }
    }

void initialize(int Arr[],int size[],int N)
    {
        for(int i = 0;i<N;i++)
        {
          Arr[ i ] = i;
          size[ i ] = 1;
        }
    } 

// <----- Actual solve() function to print output -----> //

void solve()
{
   ll n,m,k=0,p,q,ans=0;
   cin>>n>>m;
   int arr[n],size[n];
   initialize(arr,size,n);
   forp(i,0,m)
   {
      cin>>p>>q;
      p--,q--;
      weighted_union(arr,size,p,q);
   }
vector<int> v;
int count[n]={0};
   forp(i,0,n)
   {
       count[root(arr,i)]++;
       if(count[root(arr,i)]>ans)
       ans=count[root(arr,i)];
   }
   cout<<ans;
   //cout<<m*w<<" ";
   //cout<<"\n";      //if t>1 uncomment this
}

// MAIN function --------------------------------------------------------------------------//
int main()
{
    fast_io
//  if taking input from input.txt then uncomment below line
//    freopen("input.txt", "r", stdin);
//  if writing output to output.txt then uncomment below line
//    freopen("output.txt", "w", stdout);

    single_testcase_t   //Uncomment this if only single testcase & single answer to print
  //multiple_testcases_t  //Uncomment this if t>1(t is given in question)(multiple testcases)
return 0;
}





Measured memory_bytes: 5976
while True:
    m, f, r = [int(i) for i in input().split()]

    if m == f == r == -1:
        break

    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')

    elif total < 50 and r < 50:
        print('D')

    elif total < 65:
        print('C')
        
    elif total < 80:
        print('B')

    else:
        print('A')
        

Measured memory_bytes: 7652
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vecint a(n);
  REP(i,n) cin>>a[i];
  vector<bool> v(n+1, false);
  int cnt=0;
  for(int i=n; i>0; --i) {
    bool f = false;
    for (int j=i*2; j<=n; j += i) {
      if (v[j]) f = !f;
    }
    if (a[i-1]) {
      v[i] = !f;
    } else {
      v[i] = f;
    }
    if(v[i]) ++cnt;
  }
  cout<<cnt<<endl;
  bool first = true;
  FOR(i,1,n+1) {
    if (v[i]) {
      if (!first) cout<<' ';
      else first = false;
      cout<<i;
    }
  }
  if (cnt) cout<<endl;
  return 0;
}


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

vector<vector<int>> makeCH(string A){
  int n = A.size();
  
  vector<vector<int>> res(n+1, vector<int>(26,n));
 
  
  for(int i = n-1; i >= 0; i--){
    for(int j = 0; j < 26; j++){
      
      res[i][j] = res[i+1][j];
      
      res[i][A[i]-'a'] = i;
    }
  }
  
  return res;
}
      
int main(){
  string S; cin >> S;
  
  int N = (int) S.size();
  
  auto ch = makeCH(S);
  
  vector<int> dp(N+1, N);
  vector<pair<char,int>> recon(N+1,{'?',N});
  
  for(int i = N-1; i >= 0; i--){
    for(int j = 0; j < 26; j++){
      
      //次の文字がない場合
      if( ch[i][j] == N){
        if( dp[i] > 1){
         dp[i] = 1; recon[i] = {'a'+j, N};
        }
      }
      //次の文字がある場合
      else{
        if( dp[i] > dp[ch[i][j]+1]+1){
          dp[i] = dp[ch[i][j]+1]+1; 
          recon[i] = {'a'+j, ch[i][j]+1};
        }
      }
    }
  }
  
  int index = 0;
  string res = "";
  while( index < N){
    auto p = recon[index];
    
    res += p.first;
    index = p.second;
  }
  
  cout << res << endl;
  
  return 0;
}
    
    
        
        
      
      
      
  
  
  
  
  

Measured memory_bytes: 29376
#include <stdio.h>

int main(void) {
	int h, m, s;
	int sum;
	while (1) {
		scanf("%d %d %d", &h, &m, &s);
		if (h == -1 && m == -1 && s == -1)
			break;
		sum = 2*3600 - (h*3600+m*60+s);
		printf("%02d:%02d:%02d\n", sum/3600, sum%3600/60, sum%60);
		sum *= 3;
		printf("%02d:%02d:%02d\n", sum/3600, sum%3600/60, sum%60);
	}
	return 0;
}

Measured memory_bytes: 612
#include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>K;
	vector<int>v(N+2);
	for(int i=1;i<=N;i++)cin>>v[i];
	vector<vector<vector<long long int>>>dp(N+1,vector<vector<long long int>>(K+1,vector<long long int>(N+1,MOD*MOD)));
	dp[0][0][0]=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<=K;j++){
			for(int k=0;k<=i;k++){
				if(j+1<=K)dp[i+1][j+1][k]=min(dp[i][j][k],dp[i+1][j+1][k]);
				if(v[i+1]<v[k])dp[i+1][j][i+1]=min(dp[i+1][j][i+1],dp[i][j][k]);
				else dp[i+1][j][i+1]=min(dp[i+1][j][i+1],dp[i][j][k]+v[i+1]-v[k]);
				//cout<<dp[i][j][k]+v[i+1]-v[k]<<endl;
				//cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl;
			}
		}
	}
	long long int ans=MOD*MOD;
	for(int i=0;i<=K;i++){
		for(int j=0;j<=N;j++){
			ans=min(ans,dp.back()[i][j]);
//			cout<<i<<" "<<j<<" "<<dp.back()[i][j]<<endl;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 216832
using System;

namespace CSsample
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long A = long.Parse(Console.ReadLine());
            long B = long.Parse(Console.ReadLine());
            long C = long.Parse(Console.ReadLine());
            long D = long.Parse(Console.ReadLine());
            long E = long.Parse(Console.ReadLine());
            long min = Math.Min(A, Math.Min(B, Math.Min(C, Math.Min(D, E))));
            long num = (N - N % min) / min + 5;
            if(min == 1)
            {
                num = N + 4;
            }
            Console.WriteLine(num);
        }
    }
}



Measured memory_bytes: 13140
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#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(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加

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() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define pause system("pause")


signed main() {
	int N;
	cin >> N;
	N = N % 10;
	if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
		cout << "hon" << endl;
	}
	if (N == 0 || N == 1 || N == 6 || N == 8) {
		cout << "pon" << endl;
	}
	if (N == 3) {
		cout << "bon" << endl;
	}
	pause;
}

Measured memory_bytes: 3660
N,A,B=map(int,input().split())
S=input()
cnt1,cnt2=0,0
for i,s in enumerate(S):
    if s=="c":
        print("No")
        continue
    if s=="a":
        if cnt1<A+B:
            print("Yes")
            cnt1+=1
        else:
            print("No")
    else:
        if cnt1<A+B and cnt2<B:
            print("Yes")
            cnt1+=1
            cnt2+=1
        else:
            print("No")

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

using namespace std;

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

	int n,t;
	vector <int> v;
	int res = 0;

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}

	sort(v.rbegin(),v.rend());
	res += (v[0]/2);
	for(int i=1;i<n;i++)
	{
		res+=v[i];
	}

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

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll n; cin >> n;
    ll in;
    set<ll> st;
    map<ll, ll> mp;
    rep(i, n){
        cin >> in;
        st.insert(in);
        mp[in]++;
    }

    ll ans = 0;
    for(auto x:st){
        if(mp[x]>x) ans += mp[x]-x;
        else if(mp[x]<x) ans += mp[x];
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int d,l;
    cin >> d >> l;
    
    cout << d/l+d%l << endl;
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int min3(int a,int b,int c){
  int ans=min(a,min(b,c));
  return ans;
}
int main(void){
  int n,x,y,a[5001];
  cin>>n>>x>>y;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      int s1,s2,s3;
      s1=abs(i-j);
      s2=abs(i-x)+1+abs(j-y);
      s3=abs(i-y)+1+abs(j-x);
      ++a[min3(s1,s2,s3)];
    }
  }
  for(int i=1;i<n;i++){
    cout<<a[i]/2<<endl;
  }
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <cassert>
#include <vector>
#include <iomanip>

using namespace std;

typedef complex<double> P;

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

const double eps = 1e-10;

double cross(const P& a, const P& b) {
    return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
    return real(conj(a)*b);
}

struct L : public vector<P> {
    L(const P &a, const P &b) {
        push_back(a); push_back(b);
    }
};

P crosspoint(const L &l, const L &m) {
    double A = cross(l[1] - l[0], m[1] - m[0]);
    double B = cross(l[1] - l[0], l[1] - m[0]);
    if (abs(A) < eps && abs(B) < eps) return m[0]; // same line
    if (abs(A) < eps) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
    return m[0] + B / A * (m[1] - m[0]);
}

typedef vector<int> vi;
int main(){
    vi a(5);
    rep(i, 5) cin >> a[i];
    sort(all(a));
    cout << a[4];
    rep(i, 4){
        cout << " " << a[3 - i];
    }
    cout << endl;
}

Measured memory_bytes: 1208
N, M = map(int, input().split())
distinations = [[] for _ in range(N+1)]
for _ in range(M):
  _to, _from = map(int, input().split())
  distinations[_to].append(_from)
  distinations[_from].append(_to)
firsts = distinations[1]
stack = []
for _first in firsts:
  stack.append((_first, 1))
cnt = 1
ans = 0
path = [1]
while len(stack) > 0:
  dist = stack.pop()
  path = path[:dist[1]]
  if dist[0] in path:
    continue
  path += [dist[0]]
  cnt = dist[1] + 1
  if cnt == N:
    ans += 1
    continue
  for node in distinations[dist[0]]:
    stack.append((node, cnt))
print(ans)


Measured memory_bytes: 3064
// AOJ 2013

#include <iostream>
#include <cstdio>

using namespace std;

int data[24][60][60];

int main(void)
{
	int n;
	while (cin >> n, n){
		for (int i = 0; i < 24; i++){
			for (int j = 0; j < 60; j++){
				for (int k = 0; k < 60; k++){
					data[i][j][k] = 0;
				}
			}
		}

		int s[3], e[3];
		for (int i = 0; i < n; i++){
			scanf("%d:%d:%d %d:%d:%d", &s[0], &s[1], &s[2], &e[0], &e[1], &e[2]);
			int h = s[0], m = s[1], sec = s[2];
			data[h][m][sec] += 1;
			while (1){
				if (h == e[0] && m == e[1] && sec == e[2]){
					data[h][m][sec]--;
					break;
				}
				sec++;
				if (sec == 60){
					m++;
					sec = 0;
				}
				if (m == 60){
					h++;
					m = 0;
				}
				data[h][m][sec] += 1;
			}
		}
/*
		for (int i = 0; i < 24; i++){
			for (int j = 0; j < 60; j++){
				int cnt = 0;
				for (int k = 0; k < 60; k++){
					cnt = max(cnt, data[i][j][k]);
				}
				cout << cnt << " ";
			}
			puts("");
		}
*/
		int ret = 0;
		for (int i = 0; i < 24; i++){
			for (int j = 0; j < 60; j++){
				for (int k = 0; k < 60; k++){
					ret = max(ret, data[i][j][k]);
				}
			}
		}
		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 1576
import Data.List
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn :: IO Int
  [a,b] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  ps <- map (read . BS.unpack) . BS.words <$> BS.getLine
  let (p_a,p_bc) = partition (<= a) (ps :: [Int])
      (p_b,p_c) = partition (<= b) p_bc
      na = length p_a
      nb = length p_b
      nc = length p_c
  print $ min na (min nb nc)


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

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			StringTokenizer st = new StringTokenizer(str, " ");

			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			String relationship = "==";
			
			if(a<b){relationship="<";}
			else if (a>b){relationship=">";}
			
			System.out.println("a "+(relationship)+" b");


		}  catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		}



	}

}

Measured memory_bytes: 24264
#include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, H, M; cin >> A >> B >> H >> M;
long double Deg = fabs((H % 12) * 30 - 5.5 * M);
Deg = Deg / 180.0 * acos(-1.0);
printf("%.10Lf\n", sqrt(A * A + B * B - cos(Deg) * 2.0 * A * B));
return 0;
}

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

using namespace std;
#define INFS (1LL<<28)
#define INF (1LL<<60)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
#define all(n) n.begin(),n.end()

int a[1000][1000];
int cnt[1000];
int al[1000];
signed main(){
	int n;
	cin>>n;
	lp(i,n){
		lp(j,n-1){
			cin>>a[i][j];
			a[i][j]--;
		}
	}
	int ans=0;
	lp(z,500000){
		int act=0;
		lp(i,1000)al[i]=0;
		int done=0;
		lp(i,n){
			if(al[i]==1)continue;
			if(cnt[i]==n-1) continue;
			else done=1;
			int t=a[i][cnt[i]];
			if(al[t]==1)continue;
			int hoge;
			//cin>>hoge;
			if(t<i)continue;
			if(a[t][cnt[t]]==i){
				act=1;
				//cout<<ans+1<<" "<<i<<" "<<cnt[i]<<" "<<t<<endl;
				cnt[i]++;
				cnt[t]++;
				al[t]=1;
				al[i]=1;
			}
		}
		ans++;
		if(done==0)break;
		if(act==0){
			cout<<-1<<endl;
			return 0;
		}
	}
	if(ans==500000)cout<<-1<<endl;
	else cout<<ans-1<<endl;
	return 0;
}


Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		if(A*B>=C*D){System.out.println(A*B);}
		else{System.out.println(C*D);}
	}

}


Measured memory_bytes: 22996
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


int main(int argc, char**argv){
    int a, b;
    cin >> a >> b;
    int ans = 0;

    if (a > b) {
        ans += a;
        a--;
    }
    else {
        ans += b;
        b--;
    }

    if (a > b) {
        ans += a;
    }
    else {
        ans += b;
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
public class Program{
    public static void Main(){
        var text= new List<string>();
        int count=0;
        
        var input=Console.ReadLine();
        if((input.Length)%2==0){
            for (int k = 0; k < (input.Length/2); k++){
        
            if (input[k]!=input[input.Length-k-1]){count++;}
        }
        }
        if ((input.Length)%2==1){
            for (int i=0;i<(((input.Length-1)/2));i++){
            if (input[i]!=input[input.Length-i-1]){count++;}  
            }
            
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13140
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

int main(void) {
	int n;
	cin >> n;
	vector<int> x(n);
	REP(i, n) cin >> x[i];

	LONG c1 = 0, c2 = 0;
	LONG sum1 = 0, sum2 = 0;
	REP(i, n) {
		int t1 = (i % 2) * 2 - 1;
		int t2 = t1 * -1;
		if (t1 > 0 && x[i] + sum1 < t1) {
			c1 += t1 - (x[i] + sum1);
			sum1 = t1;
		}
		else if (t1 < 0 && x[i] + sum1 > t1) {
			c1 += (x[i] + sum1) - t1;
			sum1 = t1;
		}
		else {
			sum1 = x[i] + sum1;
		}
		if (t2 > 0 && x[i] + sum2 < t2) {
			c2 += t2 - (x[i] + sum2);
			sum2 = t2;
		}
		else if (t2 < 0 && x[i] + sum2 > t2) {
			c2 += (x[i] + sum2) - t2;
			sum2 = t2;
		}
		else {
			sum2 = x[i] + sum2;
		}
	}
	cout << min(c1, c2) << endl;
	return 0;
}


Measured memory_bytes: 640
def resolve():
    N = int(input())
    
    def isOk(i3, i2, i1, i0):
        if i2 == 0 and i1 == 1 and i0 == 2: return False
        if i2 == 1 and i1 == 0 and i0 == 2: return False
        if i2 == 0 and i1 == 2 and i0 == 1: return False
        if i3 == 0 and i1 == 1 and i0 == 2: return False
        if i3 == 0 and i2 == 1 and i0 == 2: return False
        return True
     
    dp = [[[[0 for _ in range(4)] for __ in range(4)] for ___ in range(4)] for ____ in range(N+1)]
    for i in range(4):
        for j in range(4):
            for k in range(4):
                if isOk(None, i, j, k):
                    dp[3][i][j][k] = 1

    for n in range(3, N):
        for i in range(4):
            for j in range(4):
                for k in range(4):
                    for l in range(4):
                        if not isOk(i, j, k, l):
                            continue
                        dp[n+1][j][k][l] += dp[n][i][j][k]
                        dp[n+1][j][k][l] %= (10**9)+7

    total = 0
    for i in range(4):
        for j in range(4):
            for k in range(4):
                total += dp[N][i][j][k]
                total %= (10**9)+7
    print(total)


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 46576
#include <iostream>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <cstdio>
using namespace std;

typedef complex<double> P;
const double eps = 1e-8;

namespace std {
  bool operator < (const P& a, const P& b) {
    if(a.real() != b.real()) return a.real() < b.real();
    return a.imag() < b.imag();
  }
}

struct L : public vector<P> {
  L(P a, P b) {
    push_back(a);
    push_back(b);
  }
};

double dot(P a, P b) { return a.real()*b.real() + a.imag()*b.imag(); }
double cross(P a, P b) { return a.real()*b.imag() - a.imag()*b.real(); }

int ccw(P p0, P a, P b) {
  a -= p0;
  b -= p0;
  if(cross(a,b) > eps) return 1;
  if(cross(a,b) < -eps) return -1;
  if(dot(a,b) < -eps) return 2;
  if(norm(a) < norm(b)) return -2;
  return 0;
}

bool isIntersect(P a1, P a2, P b1, P b2) {
  return ( ccw(a1,a2,b1)*ccw(a1,a2,b2) <= 0 &&
	   ccw(b1,b2,a1)*ccw(b1,b2,a2) <= 0 );
}

double getDistanceLP(P s1, P s2, P p) {
  return abs(cross(s2-s1,p-s1))/abs(s2-s1);
}

double getDistanceSP(P s1, P s2, P p) {
  if(dot(s2-s1,p-s1) < 0.0) return abs(p-s1);
  if(dot(s1-s2,p-s2) < 0.0) return abs(p-s2);
  return getDistanceLP(s1,s2,p);
}

double getDistance(P a1, P a2, P b1, P b2) {
  if(isIntersect(a1,a2,b1,b2)) return 0.0;
  return min( min(getDistanceSP(a1,a2,b1),getDistanceSP(a1,a2,b2)),
	      min(getDistanceSP(b1,b2,a1),getDistanceSP(b1,b2,a2)) );
}

const int MAX_S = 101;
const int MAX_N = 100000;
const int INF = 1<<28;
int N;
vector<L> Ls;

int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) {
    P a, b;
    cin >> a.real() >> a.imag() >> b.real() >> b.imag();
    if(b < a) swap(a,b);
    Ls.push_back(L(a,b));
  }
  sort(Ls.begin(), Ls.end());

  double ans = INF;
  if(N*2 > MAX_S*MAX_S) {
    ans = 0.0;
  } else {
    for(int i = 0; i < N; ++i) {
      for(int j = i+1; j < N; ++j) {
	if(Ls[j][0].real() - Ls[i][1].real() >= ans) break;
	ans = min(ans,getDistance(Ls[i][0],Ls[i][1],Ls[j][0],Ls[j][1]));
      }
    }
  }
  printf("%.8f\n", ans);
  return 0;
}

Measured memory_bytes: 7196
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int oddCnt = 0;
    int evenCnt = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] % 2 != 0) oddCnt++;
        else evenCnt++;
    }

    if(oddCnt % 2 == 0) {
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  string S;
  cin >> S;
  vector<int> LtoR(S.size(), -1), RtoL(S.size(), INF);
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'L') RtoL[i] = i;
    else LtoR[i] = i;
  }
  for (int i = RtoL.size()-1; i > 0; i--) {
    RtoL[i-1] = min(RtoL[i-1], RtoL[i]);
  }
  for (int i = 0; i < LtoR.size()-1; i++) {
    LtoR[i+1] = max(LtoR[i+1], LtoR[i]);
  }

  vector<int> ans(S.size(), 0);
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'L') {
      int dist = LtoR[i] - i;
      if (dist % 2) ans[LtoR[i]+1]++;
      else ans[LtoR[i]]++;
    } else {
      int dist = i - RtoL[i];
      if (dist % 2) ans[RtoL[i]-1]++;
      else ans[RtoL[i]]++;
    }
  }
  for (auto e : ans) cout << e << ' ';
  cout << endl;
  return 0;
}


Measured memory_bytes: 1792
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    A, B, K = il()
    st = set()
    for a in range(A, A + K):
        if a > B: break
        st.add(a)
    for b in reversed(range(B - K+1, B+1)):
        if b < A: break
        st.add(b)
    print(*sorted(st), sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 10136
package main

import (
	"bufio"
	"fmt"
	"os"
)

var table = map[string]int{
	"SUN": 7,
	"MON": 6,
	"TUE": 5,
	"WED": 4,
	"THU": 3,
	"FRI": 2,
	"SAT": 1,
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	line := sc.Text()

	fmt.Println(table[line])
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	bool ans;
	int cnt = 0;
	while(a > 0 && c >0){
		if(cnt%2==0)c -= b;
		else a -= d;
		++cnt;
	}
	if(a<=0)ans = false;
	else ans = true;
	cout<<((ans)?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  string S;
  cin>>S;
  SORT(S);
  cout<< ( S=="abc" ? "Yes" : "No" )<<"\n";
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Anurag_Gupta ios_base::sync_with_stdio(0);
#define IIIT_ALLD cin.tie(0);cout.tie(0);
#define mod 987654319
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
    Anurag_Gupta
    IIIT_ALLD
 
   
    
    int n;
    cin>>n;

    map<int,int>mp;

    rep(i,0,n-1)
    {
        int x;
        cin>>x;

        mp[x]++;
    }

    for(int i=1;i<=n;i++)
    cout<<mp[i]<<"\n";

 
 






 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 16308
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> X(N);
  REP(i, N) cin >> X[i];
  vector<int> tmp(100001);
  REP(i, N) tmp[X[i]]++;
  vector<int> cnt(M);
  vector<int> pr(M);
  REP(i, 100001) {
    cnt[i%M] += tmp[i];
    pr[i%M] += tmp[i]/2*2;
  }
  int ans = 0;
  REP(i, M) {
    if(i == M-i || i == 0) {
      ans += cnt[i] / 2;
    } else if(i < M-i){
      int tmp = min(cnt[i], cnt[M-i]);
      ans += tmp;
      cnt[i] -= tmp;
      cnt[M-i] -= tmp;
      if(cnt[i] > 0) ans += min(cnt[i], pr[i])/2;
      else ans += min(cnt[M-i], pr[M-i])/2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import collections


N = int(input())
A = list(map(int,input().split()))
Q = int(input())
c = collections.Counter(A)
ans = sum(A)
for i in range(Q):
    B,C = list(map(int,input().split()))
    ans = ans + c[B]*(C-B)
    c[C] += c[B]
    c[B] = 0
    print(ans)

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

string shuffle (string s) {
  string t;
    for (int j = 0; j < s.size() - 1; j++) {
      t += s[j];
    }
  t = s.back() + t;
  return t;
}

int main () {
  string S, T;
  cin >> S >> T;
  
  for (int i = 0; i < S.size(); i++) {
    S = shuffle(S);
    if (S == T) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		System.out.println(a < b && b < c ? "Yes" : "No");
	}
}

Measured memory_bytes: 26272
#include <iostream>

using namespace std;
int arr[1000005][3];
int ans[1000005][3];
int main()
{
int n;
cin >>n;
for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
    cin >> arr[i][j];
        }
}
for(int i=0;i<3;i++){
    ans[0][i]=arr[0][i];
}
for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            int Max=0;
            for(int k=0;k<3;k++){
                if(k!=j)
                Max=max(Max,arr[i][j]+ans[i-1][k]);
            }
            ans[i][j]=Max;
        }
}
int Max=0;
Max=max(ans[n-1][1],max(ans[n-1][0],ans[n-1][2]));
cout <<Max;
    return 0;
}


Measured memory_bytes: 5504
STACK_SIZE = 64*1024*1024
if ENV['RUBY_THREAD_VM_STACK_SIZE'].to_i < STACK_SIZE
  ENV['RUBY_THREAD_VM_STACK_SIZE'] = STACK_SIZE.to_s
  exec("ruby2.3 --disable-gems ./Main.rb")
end

def dfs(node, edges, known)
  known[node] = true
  edges[node].each do |other|
    unless known[other]
      dfs(other, edges, known)
    end
  end
end

n, m = gets.split.map(&:to_i)
table = m.times.map { gets.split.map(&:to_i) }
known = Array.new(n)
edges = Hash.new { [] }

table.each do |x, y, z|
  x -= 1
  y -= 1
  edges[x] <<= y
  edges[y] <<= x
end

cost = 0
(0...n).each do |i|
  unless known[i]
    cost +=1

    dfs(i, edges, known)
  end
end
puts cost


Measured memory_bytes: 224720
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == x:
        ans+= 1
print(ans)
   

Measured memory_bytes: 39536
#include <stdio.h>

#define SIZE 1000000

int furui[SIZE];
int prime[SIZE];

int main(void) {
	int i, j, k;
	int n;
	long s;

	furui[0] = furui[1] = 1;
	for(i = 2, k = 0; i < SIZE; i++) {
		if(!furui[i]) {
			for(j = i; j < SIZE; j += i) {
				furui[j] = 1;
			}

			prime[k] = i;
			k++;
		}
	}

/*
	if(k > 10000)
		printf("TRUE\n");
	else
		printf("FALSE\n");

	for(i = 0; i < 10; i++) {
		for(j = 0; j < 10; j++) {
			printf("%3d ", prime[i * 10 + j]);
		}

		putchar('\n');
	}
*/

	scanf("%d", &n);
	while(n) {
		for(i = 0, s = 0; i < n; i++) {
			s += prime[i];
		}
		
		printf("%ld\n", s);
		scanf("%d", &n);
	}

	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code
int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}

	VL sub(n);
	for (int i = 0; i < n; i++) {
		sub[i] = a[i] - b[i];
	}
	sort(RALL(sub));
	LL sum_m = 0;
	LL sum_p = 0;
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		if (sub[i] < 0) {
			sum_m += -sub[i];
			ans++;
		}
		else if (sub[i] > 0) {
			sum_p += sub[i];
		}
	}
	if (sum_m > sum_p) {
		cout << -1 << endl;
		return 0;
	}
	if (sum_m == 0) {
		cout << 0 << endl;
		return 0;
	}
	LL p = 0;
	for (int i = 0; i < n; i++) {
		p += sub[i];
		if (p >= sum_m) {
			ans += i+1;
			cout << ans << endl;
			return 0;
		}
	}
	return 0;

}



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


void solve(long long N, long long M,
           std::vector<long long> A, std::vector<long long> B){
    vector<vector<ll>> net(N);
    vector<ll> indeg(N, 0);
    REP(i, A.size()){
        ll ai = A.at(i);
        ll bi = B.at(i);
        ai--; bi--;
        net.at(ai).push_back(bi);
        indeg.at(bi)++;
    }

    ll src = 0;
    REP(i, N){
        if(indeg.at(i) == 0){
            src = i;
            break;
        }
    }

    vector<ll> dist(N, -1);
    vector<ll> par(N, -1);
    queue<ll> que;
    que.emplace(src);
    dist.at(src) = 0;
    while(!que.empty()){
        ll v = que.front(); que.pop();
        for(ll nxt : net.at(v)){
            indeg.at(nxt)--;
            if(dist.at(nxt) < dist.at(v) + 1){
                dist.at(nxt) = dist.at(v) + 1;
                par.at(nxt) = v;
            }
            if(indeg.at(nxt) == 0){
                que.push(nxt);
            }
        }
    }

    REP(i, N){
        if(i == src){
            cout << 0 << endl;
        }else{
            cout << par.at(i) + 1 << endl;
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N-1+M);
    std::vector<long long> B(N-1+M);
    for(int i = 0 ; i < N-1+M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 10240
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    ArrayList<Integer> result = new ArrayList<Integer>();
	    while (true) {
		    String line = br.readLine();

		    if ("0".equals(line)) break;

		    int sum = 0;
		    for (int i = 0; i < line.length(); i++) {
		    	char c = line.charAt(i);
		    	String s = String.valueOf(c);
		    	sum += Integer.parseInt(s);
		    }
		    result.add(sum);
	    }

	    // Display Anaser
	    StringBuilder sb = new StringBuilder();
	    for (int i = 0; i < result.size(); i++) {
	    	sb.append(result.get(i));
    		sb.append("\n");
	    }
	    System.out.print(sb.toString());
	}
}

Measured memory_bytes: 24816
import numpy as np
n = int(input())
ary = np.zeros((10, 10))
for i in range(n):
  ary[int(str(i + 1)[0]) - 1][int(str(i + 1)[-1]) - 1] += 1
print(np.sum(ary * ary.T).astype(np.int32))

Measured memory_bytes: 14472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    string s; cin >> s;
    int n = s.size();
    cout << s.front() << n - 2 << s.back() << endl;
    return 0;
}

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

#define maxn 6
#define INF 0x3f3f3f3f
#define mod 1000000007
typedef long long ll;
using namespace std;

int X;
ll ans = 0;

void slove()
{
	cin >> X;
	while (X >= 5)
	{
		if (X >= 500) X -= 500, ans += 1000;
		else if (X >= 5) X -= 5, ans += 5;
	}
	cout << ans << '\n';
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);

	slove();

	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
white_start = ["0" if i%2==0 else "1" for i in range(n)]
#black_start = ["1" if i%2==0 else "0" for i in range(n)]


Wcnt = 0
#Bcnt = 0

for i in range(n):
  if s[i]!=white_start[i]:
    Wcnt +=1
  #else:
    #Bcnt +=1
print(min(Wcnt,n-Wcnt))

Measured memory_bytes: 45544
S = input()

if S[0] != "k":
    if S[-7:] == "keyence":
        print("YES")
    else:
        print("NO")

elif S[-1] != "e":
    if S[:7] == "keyence":
        print("YES")
    else:
        print("NO")

else:
    if S[:1] == "k" and S[-6:] == "eyence":
        print("YES")
    elif S[:2] == "ke" and S[-5:] == "yence":
        print("YES")
    elif S[:3] == "key" and S[-4:] == "ence":
        print("YES")
    elif S[:4] == "keye" and S[-3:] == "nce":
        print("YES")
    elif S[:5] == "keyen" and S[-2:] == "ce":
        print("YES")
    elif S[:6] == "keyenc" and S[-1:] == "e":
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="SUN")cout<<7<<endl;
  else if(s=="MON")cout<<6<<endl;
  else if(s=="TUE")cout<<5<<endl;
  else if(s=="WED")cout<<4<<endl;
  else if(s=="THU")cout<<3<<endl;
  else if(s=="FRI")cout<<2<<endl;
  else if(s=="SAT")cout<<1<<endl;
}

Measured memory_bytes: 256
<?php
$arr = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < 3; $i++) {
    $arr[$i] = (int)$arr[$i];
}
rsort($arr);

$k = intval(($arr[0] - $arr[1]) / 2) + ($arr[0] - $arr[1]) % 2;

$arr[2] += ($arr[0] - $arr[1]) % 2;

if (($arr[0] - $arr[2]) % 2 === 0) {
    $k += ($arr[0] - $arr[2]) / 2;
} else {
    $k += intval(($arr[0] - $arr[2]) / 2) + 2;
}

echo $k . PHP_EOL;

Measured memory_bytes: 4856
#include<iostream>
using namespace std;
int main() {
	int n, a,b,c,d, r[5][4][12] = { 0 };
	cin >> n;
	while (n--) {
		cin >> a >> b >> c >> d;
		r[a][b][c] += d;
	}
	for (int i = 1; i <= 4; i++) {
		for (int j = 1; j <= 3; j++) {
			for (int k = 1; k <= 10; k++) {
				cout << ' ' << r[i][j][k];
			}
			cout << endl;
		}
		if (i == 4);
		else cout << "####################" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

#define MAX 100000



typedef struct{
  int parent;
  int left;
  int right;
  int degree;
}node;

int getdepth(int);
int getsibling(int);
int getheight(int);

node T[MAX];

int main(){
  int i, j, sib, deg, id, k, n, depth;

  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].parent = T[i].left = T[i].right = -1;

  for(i=0 ; i<n ; i++){

    scanf("%d",&id);
    scanf("%d%d",&T[id].left,&T[id].right);
    if(T[id].left != -1){
      T[T[id].left].parent = id;
      T[id].degree++;
    }
    if(T[id].right != -1){
      T[T[id].right].parent = id;
      T[id].degree++;
    }
/*
    for(j=0 ; j<k ; j++){

      scanf("%d",&deg);

      if(j==0) T[id].left = deg;

      else T[sib].right = deg;

      sib = deg;
      T[deg].parent = id;
    }*/
  }

  for(i=0 ; i<n ; i++){

    depth = getdepth(i);
    //printf("here\n");
    if(depth==0) printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, root\n", i, T[i].parent, getsibling(i), T[i].degree, depth, getheight(i));

    else if(T[i].left==-1 && T[i].right==-1) printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n", i, T[i].parent, getsibling(i), T[i].degree, depth, getheight(i));

    else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n", i, T[i].parent, getsibling(i), T[i].degree, depth, getheight(i));
    /*
    //printf("here\n");
    printf("[");

    if(T[i].left != -1){
      id = T[i].left;
      printf("%d",id);

      while(id != -1){
        id = T[id].right;

        if(id != -1) printf(", %d",id);
      }
    }

    printf("]\n");
*/
  }
  return 0;
}

int getdepth(int i){//printf("in\n");
  int id = T[i].parent;
  int cnt = 0;

  while(id != -1){
    id = T[id].parent;
    cnt++;
    //printf("while\n");
  }

  return cnt;
}

int getsibling(int i){
  if(T[i].parent == -1) return -1;
  else if(T[T[i].parent].left == i) return T[T[i].parent].right;
  else return T[T[i].parent].left;
}

int getheight(int i){
  int l, r;
  if(i==-1) return -1;

  l = getheight(T[i].left);
  r = getheight(T[i].right);

  if(l>r) return l+1;
  else return r+1;

}

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

int main() {
  int N;
  cin >> N;
  int q = sqrt(N);
  int mx = 1;
  
  for (int i = 2; i <= q; i++) {
    int a = 1;
    while (a * i <= N) {
      a *= i;
    }
    mx = max(mx, a);
  }
  
  cout << mx << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			var a = cin.ArrayLong(n);

			long ans = 0;
			for (int i = 0; i < 62; i++) {
				long val = (long)1 << i;
				long cnt = 0;
				for (int j = 0; j < n; j++) {
					if ((a[j] & val) != 0) {
						++cnt;
					}
				}

				if (cnt == 0) {
					continue;
				}

				long rem = n - cnt;
				long temp = (cnt * rem) % MOD;
				long val2 = val % MOD;
				temp = (temp * val2) % MOD;
				ans = (long)((ans + temp) % MOD);
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 54216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
int m=N/7;
if (m*7==N){ cout<<"Yes"<<endl;return 0;}

while (m>=0){
  if((N-m*7)%4==0){cout<<"Yes"<<endl;return 0;}
  m--;
}
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256