akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int id;
    edge(int t, int w) : to(t),id(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<edge>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){

    int n; cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1) cin >> a.at(i);
    ll ans = 0;
    if(n == 0){
        if(a.at(0) == 1){
            cout << 1 << endl;
            return 0;
        } 
        else{
            cout << -1 << endl;
            return 0;
        }
    } 
    if(a.at(0) != 0){
        cout << -1 << endl;
        return 0;
    }
    reverse(all(a));
    vector<pair<ll,ll>> p(n+1);
    p.at(0).first = 0;
    p.at(0).second = a.at(0);
    p.at(n).first = 1;
    p.at(n).second = 0;

    for(int i = 1; i < n; i++){
        p.at(i).first = p.at(i-1).first+p.at(i-1).second;
        p.at(i).second = a.at(i);
    }

    reverse(all(p));

    for(int i = 0; i <= n-2; i++){
        if(p.at(i+1).second > p.at(i).first*2){
            cout << -1 << endl;
            return 0;
        }
        chmin(p.at(i+1).first,p.at(i).first*2-p.at(i+1).second);
    }
    if(p.at(n-1).first*2 < p.at(n).second){
        cout << -1 << endl;
        return 0;
    }
    rep(i,n+1){
        ans += p.at(i).first + p.at(i).second;
    }
    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string.h>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>
#include <regex>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

template <typename T> ostream& operator<<(ostream& out, vector<T> &v){
  for (int i = 0; i < (int)v.size(); i++) {
    out<<v[i]<<' ';
  }
  return out;
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n = 0;
  rep(i, 5){
    cin >> n;
    if(n == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }




  return 0;
}


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

int main(){
  ll N = 0,ans = 0;
  cin >> N;
  vector<int>A(N);
  rep(i,N){
    cin >> A[i];
  }
  rep(i,10000000){
    rep(j,N){
      if(A[j] % 2 != 0){
        cout << i;
        return 0;
      }
      else{
        A[j] /= 2;
      }
    }
  }
}

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

public class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int i = 1;

		while(true) {

			int x = Integer.parseInt(br.readLine());

			if(x == 0) {
				break;
			}else{
				System.out.println("Case " + i + ": " + x);
				i++;
			}
		}
	}

}

Measured memory_bytes: 31872
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	count := 0
	for i := 0; i < n-2; i++ {
		str := string([]rune(s)[i : i+3])
		if str == "ABC" {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double pi = acos(-1);
  double ans = sqrt(a*a + b*b -2 * a * b * cos((60*h + m) * pi * 11 / 360));
  printf("%.10f",ans);
  return 0;
}

Measured memory_bytes: 4160
#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
#ifdef _WIN32
#include <windows.h>
#define print(x) PRINT(x, #x)
template<typename T> inline const void PRINT(T VARIABLE, string NAME)
{
#ifndef ONLINE_JUDGE /// ONLINE_JUDGE IS DEFINED ON CODEFORCES
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, 10);
    cerr << NAME << " = " << VARIABLE;
    SetConsoleTextAttribute(hConsole, 7);
    cerr << '\n';
#endif
}
#else
#define print(x) 0
#endif
struct pair_hash
{
    template<typename T1, typename T2>
    size_t operator () (const pair<T1, T2> &p) const
    {
        auto h1 = hash<T1> {}(p.first);
        auto h2 = hash<T2> {}(p.second);
        return h1 ^ h2;
    }
};
typedef long long ll;
typedef unsigned long long ull;
const ll INFLL = 2 * (ll)1e18 + 100;
const int INFINT = 2 * (int)1e9 + 100;
//ifstream fin(".in");
//ofstream fout(".out");
void die()
{
    cout << "-1\n";
    exit(0);
}
const int NMAX = 1e6 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;

string s;

int main()
{
    FASTIO;
    cin >> s;
    if(s.size() <= 3) return cout << "No", 0;
    else if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') cout << "Yes"; else cout << "No";

    return 0;
}


Measured memory_bytes: 256
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    s=input()
    t=input()
    ans=0
    for i in range(3):
        if s[i]==t[i]:
            ans+=1
    print(ans)
    
    
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 5608
#include<stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	char id[n];
	
	int x = 0;
	int max = 0;
	
	scanf("%s", id);
	for(int i = 0; id[i] != '\0'; i++){
		if(id[i] == 'I'){
			x++;
			if(max < x){
				max = x;
			}
		}
		else if(id[i] == 'D'){
			x--;
		}
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 1736
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>
#include <cmath>
#include <map>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;
namespace mp = boost::multiprecision;
typedef long long ll;
const ll M = 1000000007;

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

	rep(i, s.length()) {
		s[i] = 'x';
	}

	cout << s;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long weight[100], v[100];
long long dp[101][100010];
int n, w;

long long solve( int idx, int W ) {
    if( idx == n ) return 0;
    long long &ans = dp[idx][W];
    if( ans != -1 ) return ans;
    ans = solve( idx+1, W );
    if( weight[idx] <= W ) {
        ans = max( ans, solve(idx+1, W-weight[idx])+ v[idx] ) ;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> w;
    for( int i = 0; i < n; i++ ) {
        cin >> weight[i] >> v[i];
    }
    memset( dp, -1, sizeof dp );
    cout << solve(0, w) << '\n';
    return 0;
}

Measured memory_bytes: 82420
from heapq import heappush, heappop
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def cross2(p, q):
    return p[0]*q[1] - p[1]*q[0]
def dot2(p, q):
    return p[0]*q[0] + p[1]*q[1]
def dist2(p):
    return p[0]**2 + p[1]**2
def segment_line_dist(x, p0, p1):
    z0 = (p1[0] - p0[0], p1[1] - p0[1])
    z1 = (x[0] - p0[0], x[1] - p0[1])
    if 0 <= dot2(z0, z1) <= dist2(z0):
        return cross2(z0, z1)**2 / dist2(z0)
    z2 = (x[0] - p1[0], x[1] - p1[1])
    return min(dist2(z1), dist2(z2))

def solve():
    W, N = map(int, readline().split())
    if W == N == 0:
        return False
    PS = []
    for i in range(N):
        M = int(readline())
        P = [list(map(int, readline().split())) for i in range(M)]
        PS.append(P)

    G = [[] for i in range(N+2)]
    for i in range(N):
        Pi = PS[i]
        ni = len(Pi)
        for j in range(i+1, N):
            Pj = PS[j]
            r = 10**18
            nj = len(Pj)
            for p1 in Pi:
                for k in range(nj):
                    q1 = Pj[k-1]; q2 = Pj[k]
                    r = min(r, segment_line_dist(p1, q1, q2))
            for q1 in Pj:
                for k in range(ni):
                    p1 = Pi[k-1]; p2 = Pi[k]
                    r = min(r, segment_line_dist(q1, p1, p2))
            d = r**.5
            G[i].append((j, d))
            G[j].append((i, d))
        d = min(x for x, y in Pi)
        G[i].append((N, d))
        G[N].append((i, d))

        d = W - max(x for x, y in Pi)
        G[i].append((N+1, d))
        G[N+1].append((i, d))

    G[N].append((N+1, W))
    G[N+1].append((N, W))
    que = [(0, N)]
    dist = [10**18]*(N+2)
    dist[N] = 0
    while que:
        cost, v = heappop(que)
        if dist[v] < cost:
            continue
        for w, d in G[v]:
            if cost + d < dist[w]:
                dist[w] = cost + d
                heappush(que, (cost + d, w))
    write("%.16f\n" % dist[N+1])
    return True
while solve():
    ...


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

using namespace std;

typedef long long ll;
const int maxn = (int) 2e5 + 1;


int n;
int ans = maxn;
int get(int x){
    int y = n - x, res = 0;
    while(x > 9){
        res += (x % 10);
        x /= 10;
    }
    res += x;
    while(y > 9){
        res += (y % 10);
        y /= 10;
    }
    res += y;
    return res;
}


int main(){
    cin >> n;
    for(int i = 1; i <= n / 2; i++){
        ans = min(ans, get(i));
    }
    cout << ans ;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);
		int K = Integer.parseInt(Ws[1]);

		int ans =1;
		while(N>=Math.pow(K, ans)){
			ans++;
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 21204
N = gets.to_i

set = Hash.new {|h,k| h[k] = 0}
count = 0
while gets
  string = $_.chomp.chars.sort.join
  if set.key?(string)
    count += set[string]
    set[string] += 1
  else
    set[string] += 1
  end
end

puts count


Measured memory_bytes: 17020
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>

using namespace std;

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

pair<int,int> joint[70];
int h,w,c;
int p[8][8];
bool f[8][8];

int solve(int now,int prev,int cnt){
	int ret=cnt;
	
	if(now==6){
		return cnt;
	}
	
	for(int color=1;color<=6;color++){
		int cc=cnt;
		queue<pair<int,int> > q;
		
		if((now==5 && color!=c)||(now==0 && color!=prev)){
			continue;
		}
		
		for(int i=0;i<cnt;i++){
			q.push(joint[i]);
		}
		
		while(!q.empty()){
			int x=q.front().second;
			int y=q.front().first;
			
			q.pop();
			
			for(int i=0;i<4;i++){
				int xx=x+dx[i];
				int yy=y+dy[i];
				
				if(0<=xx && xx<w && 0<=yy && yy<h && p[yy][xx]==color && !f[yy][xx]){
					f[yy][xx]=true;
					joint[cc].first=yy;
					joint[cc].second=xx;
					q.push(joint[cc++]);
				}
			}
		}
		
		if(now==0 || cc!=cnt){
			ret=max(ret,solve(now+1,color,cc));
			
			for(int i=cnt;i<cc;i++){
				int x=joint[i].second;
				int y=joint[i].first;
				f[y][x]=false;
			}
		}
	}
	return ret;
}

int main(){
	
	while(cin>>h>>w>>c,h||w||c){
			
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				cin>>p[y][x];
				f[y][x]=false;
			}
		}
		f[0][0]=true;
		
		cout<<solve(0,p[0][0],1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1204
while True:
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        break
    ans = 0
    for a in range(1,n+1):
        for b in range(1,a):
            for c in range(1,b):
                if a + b + c == x:
                    ans += 1
    print(ans)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t N,K,ans=-1*INF; cin>>N>>K;
  vector<int64_t> P(N);
  rep(i,N) cin>>P.at(i);
  rep(i,N) P.at(i)--;
  vector<int64_t> C(N);
  rep(i,N) cin>>C.at(i);

  rep(i,N){
    vector<bool> seen(N,true);
    vector<int64_t> S,T;
    int64_t k=i,sum=0;
    while(seen.at(k)){
      seen.at(k)=false;
      S.push_back(C.at(k));
      sum+=C.at(k);
      k=P.at(k);
    }
    int64_t t=S.size(),r=K/t,q=K%t,MAX=-1*INF,NMAX,MAX2=-1*INF;
    rep(i,t){
      T.push_back(S.at(i));
      if(i>0) T.at(i)+=T.at(i-1);
      if(T.at(i)>MAX){
        MAX=T.at(i);
        NMAX=i+1;
      }
    }
      if(q<NMAX){
        rep(i,q) MAX2=max(MAX2,T.at(i));
        if(sum<0) ans=max(ans,MAX);
        else{
          auto temp=max(MAX+sum*(r-1),MAX2+sum*r);
          ans=max(ans,temp);
        }
      }
      else{
        if(sum<0) ans=max(ans,MAX);
        else ans=max(ans,MAX+sum*r);
      }
    }
  
  cout<<ans;
}


Measured memory_bytes: 3808
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();

        if ((b-a)%2==0){
            System.out.println((b-a)/2);
            return;
        }

        long ans = 0;

        if ((b-a)%2==1){
            if ((a-1)<(n-b)){
                ans += (a-1);
                b -= (a-1);
                ans += 1;
                ans += (b-1-1)/2;
                System.out.println(ans);
                return;
            }else {
                ans += (n-b);
                a += (n-b);
                ans += 1;
                ans += (n-(a+1))/2;
                System.out.println(ans);
                return;
            }
        }


    }
}

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

main() {
  int X, K;
  cin >> X >> K;
  vector<int> r(K + 1); r[0] = 0;
  for (int i = 0; i < K; i++) cin >> r[i + 1];
  int Q;
  cin >> Q;
  vector<int> t(Q), a(Q);
  for (int i = 0; i < Q; i++) cin >> t[i] >> a[i];

  int now = 0, pos = 0;
  int L = 0, R = X;
  int va = 0, vb = X;
  for (int i = 0; i < Q; i++) {
    for (int j = now + 1; j <= K; j++) {
      if (r[j] > t[i]) break;
      if (j % 2 == 1) {
        pos += r[j] - r[j - 1];
        va = max(0, va - (r[j] - r[j - 1]));
        vb = max(0, vb - (r[j] - r[j - 1]));
      } else {
        pos -= r[j] - r[j - 1];
        va = min(X, va + (r[j] - r[j - 1]));
        vb = min(X, vb + (r[j] - r[j - 1]));
      }
      L = max(L, pos);
      R = min(R, X + pos);
      now++;
    }
    int c;
    if (L <= a[i] && a[i] <= R) c = a[i] - pos;
    if (a[i] < L) c = va;
    if (R < a[i]) c = vb;
    c = (now % 2 == 0) ? max(0, c - (t[i] - r[now])) : min(X, c + (t[i] - r[now]));
    cout << c << endl;
  }
}


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

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin >> n >> m;

    vector<int> v(n);
    for(int i=0;i<n;++i){
        cin >> v[i];
    }
    vector<bool> ans(n,true);
    for(int i=0;i<m;++i){
        int x,y;
        cin >> x >> y;
        x--;y--;
        if(ans[x]){
            if(v[x] <= v[y]){
                ans[x] = false;
            }
        }
        if(ans[y]){
            if(v[y] <= v[x]){
                ans[y] = false;
            }
        }

    }

    int count = 0;
    for(auto a : ans){
        if(a){
            count++;
        }
    }

    cout << count << "\n";


    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    string s,t;cin >> s >> t;
    int n = s.size(), m = t.size();
    vector<vi> is(26);
    rep(i,n) is[s[i]-'a'].push_back(i);
    rep(i,n) is[s[i]-'a'].push_back(i+n);
    /*rep(i,26){
        cout << (char)('a' + i) << " : ";
        for(auto t : is[i]){
            cout << t << " ";
        }
        cout << endl;
    }*/
    ll ans = 0;
    int p = 0;
    rep(i,m){
        int c = t[i] - 'a';
        if(is[c].size()==0){
            cout << -1 << endl;
            return 0;
        }

        p = *lower_bound(is[c].begin(),is[c].end(),p)+1;
        //cout << (char)('a' + c) << endl;
        //cout << p-1 << " ans=";
        if(p >= n){
            p -= n;
            ans += n;
        }
        //cout << ans << endl;
        //call(ans);
    }
    ans += p;
    cout << ans << endl;
}

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

using namespace std;

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

    vector<int> B(N-1);

    for(int i = 0; i < N - 1; i++){
        cin >> B[i];
    }

    int ans = B[0] + B[N-2];

    for(int i = 0; i < N-2; i++){
        ans += min(B[i], B[i+1]);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define  endl 			"\n"
#define  FOR(i, a, n)   for (ll i = a; i < n; i++)
#define  ROF(i, a, n)   for (ll i = a; i >= n; i--)
#define  all(x)         (x).begin(), (x).end()
#define  mset(x, val)   memset(x,val,sizeof(x))
#define  dline          cout<<"///REACHED///\n";

typedef long long ll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  4e+5+7;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//int T;
	//cin >> T;
	//while (T--) {
		
	//}
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(3));
	FOR(i, 0, n) {
		FOR(j, 0, 3) cin >> a[i][j];
	}
	vector<vector<int>> dp(n, vector<int>(3, 0));
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	FOR(i, 0, n-1) {
		FOR(j, 0, 3) {
			FOR(k, 0, 3) {
				if (j!=k)
				dp[i+1][j] = max(dp[i+1][j], dp[i][k]+a[i+1][j]);
			}
		}
		// debug(dp);	
	}
	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
	return 0;
}


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

int main(){
  double l;
  cin >> l;
  double a,v,soko;
  double tmp=0;
  for(int i=1;i<pow(10,8);i++){
    a = double(i)*l*pow(10,-8);
    soko = ((l-a)/2.0)*((l-a)/2.0);
    v = a*soko;
    if(tmp<v) tmp=v;
  }
  cout <<fixed << setprecision(10) << tmp << endl;
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
s=input()
tuuka = [0,0]

for i in range(len(s)):
    if s[i] =="c":
        print("No")
    elif s[i] =="a":
        if tuuka[0] < a+b:
            tuuka[0]+=1
            print("Yes")
        else:
            print("No")
    else:
        if tuuka[0] < a+b and tuuka[1]<b:
            tuuka[0]+=1
            tuuka[1]+=1
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 52824
def modpow(a, b, mod):
    ret = 1
    while b > 0:
        if b % 2 == 1:
            ret = ret * a % mod
        a = a * a % mod
        b //= 2
    return ret


mod = 10 ** 9 + 7
N, K = map(int, input().split())
LUT, ans = [0] * (K + 1), 0
for g in range(K, 0, -1):
    LUT[g] = modpow(K // g, N, mod)
    LUT[g] = (LUT[g] - sum([LUT[i] for i in range(g * 2, K + 1, g)])) % mod
for i in range(K + 1):
    ans = (ans + i * LUT[i]) % mod
print(ans)


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

#define ll  long long
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VC  vector<char>
#define VVI vector<vector<ll>>
#define VVC vector<vector<char>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define l_b(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define u_b(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define p_b push_back
#define p_f push_front
#define m_p make_pair
#define fir first
#define sec second
#define sz size()


ll gcd(ll a, ll b) 
{ 	if(a>b)
		swap(a,b);
    if (a == 0) 
        return b; 
    return gcd(b%a, a); 
} 

VI get_fact(ll a)
	{	VI v;
		ll sqr=sqrt(a);
		lf(i,2,sqr)
		{	if(i==sqr)
			{	if(a%i==0)
				{	v.p_b(sqr);
				}
			}
			else
			{	if(a%i==0)
				{	v.p_b(i);
					v.p_b(a/i);
				}
			}
		}
		v.p_b(a);
		return v;
	}

ll checkpr(VI &v,ll n)
	{	map<ll,ll>mp;
		lf(i,1,n)
		{	VI fact=get_fact(v[i]);
			// cout<<v[i]<<endl;
			// lfl(i,fact)
			// {	cout<<fact[i]<<" ";
			// }
			// cout<<endl;
			lfl(i,fact)
			{	if((fact[i]!=1) && (mp.find(fact[i])!=mp.end()))
					return 0;
				mp[fact[i]]=1;
			}
		}
		return 1;
	}
ll checkst(VI &v,ll n)
	{	ll gc=v[1];
		lf(i,2,n)
		{	gc=gcd(gc,v[i]);
		}
		if(gc==1)
			return 1;
		else
			return 0;
	}
int main() 
{	ll T;
	T=1;
	while(T--)
	{	ll n,m;cin>>n;
		VI v(n+1,0);
		lf(i,1,n)
			cin>>v[i];
		if(checkpr(v,n))
		{	cout<<"pairwise coprime"<<endl;
		}
		else if(checkst(v,n))
		{	cout<<"setwise coprime"<<endl;
		}
		else
		{	cout<<"not coprime"<<endl;
		}
	}  		
}      


Measured memory_bytes: 10988
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, ans;
    cin >> a >> b >> c;

    if(c > a + b)
    {
        ans = a + 2 * b + 1;
    }
    else
    {
        ans = b + c;
    }

    cout << ans << endl;

    return 0;
}


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

//template<class T, size_t N> 
//size_t countof(const T (&array)[N]) { return N; }

int main() {
  string s;
  cin >> s;
  int i=0;
  int num=0;
  int numnum=0;
  for (auto x: s) {
    if (x == '1' && (i%2)==0) num++;
    if (x == '0' && (i%2)==1) num++;

    if (x == '0' && (i%2)==0) numnum++;
    if (x == '1' && (i%2)==1) numnum++;
      i++;
  }
  int min_x = min(num, numnum);
  cout << min_x << endl;
  



  //  int n = sizeof(s)/sizeof(*s);

  //  cout  <<  sizeof(s)/sizeof(*s) << endl;


}


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

using i64 = int64_t;

int main(){
    string s;
    cin >> s;
    set<char> st;
    for(auto c: s)st.insert(c);
    string ans = "";
    for(char c='a';c<='z';++c){
        if(!st.count(c)){
            ans = c;
            break;
        }
    }

    cout << (ans == "" ? "None" : ans) << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

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

        TreeMap<Integer,Integer> map = new TreeMap<>();

        for (int i = 0; i < N; i++) {
            int price = sc.nextInt();
            int inv = sc.nextInt();
            if(!map.containsKey(price)){
                map.put(price,inv);
            }else{
                int val =  map.get(price);
                map.put(price,val+inv);
            }
        }

        long cost = 0;
        for(Map.Entry<Integer,Integer> e : map.entrySet()){
            int price = e.getKey();
            int num = e.getValue();
            if(num >= M){
                cost += (long)M * price;
                break;
            }else{
                cost += (long)price * num;
                M -= num;
            }
        }
        System.out.println(cost);
    }}

Measured memory_bytes: 96172
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

void solve(){
  int x; cin >> x;
  if(x == 3 || x == 5 || x == 7) cout << "YES\n";
  else cout << "NO\n";
  return;
}

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


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();
    let ans = std::cmp::max(0, c - (a - b));
    println!("{}", ans);
}


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

#define REP(i, n) for(ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
// constexpr ll mod = 1e9+7;

struct UnionFind {
  vector<int> data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
  
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int a, int b){
    return find(a) == find(b);
  }
  
  int size(int k) {
    return (-data[find(k)]);
  }
};

struct Edge{
  int a, b;
  long long weight;
  
  Edge(int a, int b, long long weight) : a(a), b(b), weight(weight){}
  bool operator< (const Edge& r) const {
    if(weight != r.weight) return weight < r.weight;
    if(a != r.a) return a < r.a;
    return b < r.b;
  }
};
 
long long kruskal(int V, vector<Edge>& Edges){
  long long ans = 0; // 辺の重みの総和
  int count =0; // 選んだ辺の数
  int E = Edges.size(); // 辺の数
  sort(Edges.begin(), Edges.end());
  UnionFind uf(V);
  for(int i = 0; i < E; ++i){
    int a = Edges[i].a, b = Edges[i].b;
    if(uf.same(a, b)) continue;
    ans += Edges[i].weight;
    uf.unite(a, b);
    ++count;
  }
  return ans;
}

struct vartex{
  int idx, x, y;
  vartex(int idx, int x, int y) : idx(idx), x(x), y(y){};
  vartex(){};
};
bool cmp(vartex l, vartex r){
  return l.x < r.x;
}

bool cmp2(vartex l, vartex r){
  return l.y < r.y;
}
ll cal_cost(vartex a, vartex b){
  return min(abs(a.x-b.x), abs(a.y-b.y));
}

int main(){
  int N;
  cin >> N;
  vector<vartex> xy(N);
  REP(i, N){
    int x, y;
    cin >> x >> y;
    xy[i] = vartex(i, x, y);
  }
  vector<Edge> Edges;
  sort(xy.begin(), xy.end(), &cmp);
  REP(i, N-1){
    // Edges.push_back(Edge(xy[i].idx, xy[i+1].idx, cal_cost(xy[i], xy[i+1])));
    Edges.push_back(Edge(xy[i].idx, xy[i+1].idx, xy[i+1].x - xy[i].x));

  }
  sort(xy.begin(), xy.end(), &cmp2);
  REP(i, N-1){
    // Edges.push_back(Edge(xy[i].idx, xy[i+1].idx, cal_cost(xy[i], xy[i+1])));
    Edges.push_back(Edge(xy[i].idx, xy[i+1].idx, xy[i+1].y - xy[i].y));
  }
  cout << kruskal(N, Edges) << endl;
  return 0;
}


Measured memory_bytes: 7664
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            //入力
            int[] a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
            int k = int.Parse(Console.ReadLine());

            //奇数なら(n+1)/2、偶数ならn/2。intは切り捨てなのでこれで解答可能
            Console.WriteLine(a[k -1]);
        }
    }

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

using namespace std;

typedef long long ll;
typedef long double ld;

int dp[2005][2005];
int bit[2005];

map <int, int> u;

const int MOD = 1000000007;

int add(int a, int b){
    return (a+b)%MOD;
}

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

int query(int x){
    int res = 0;
    while(x){
        res = add(res, bit[x]);
        x -= x & -x;
    }
    return res;
}

void upd(int x, int val){
    while(x <= 2000){
        bit[x] = add(bit[x], val);
        x += x & -x;
    }
}

int a[10005];
int b[10005];

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    int n, m;
    cin >> n >> m;
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    for(int i=1; i<=m; i++){
        cin >> b[i];
    }
    dp[0][0] = 1;
    int res = 0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(a[i] != b[j]) continue;
            dp[i][j] = query(j-1) + 1;
            res = add(res, dp[i][j]);
        }
        for(int j=1; j<=m; j++){
            upd(j, dp[i][j]);
        }
    }
    cout << res+1;
    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>

using namespace std;

typedef long long ll;

int main(){
 int N; cin >> N;
  vector<tuple<string,int,int>> A;
    A.clear();
  for(int i = 0; i < N; i++){
    string s; int p; cin >> s >> p;  p = -p;  int c = i + 1;
    A.push_back(tie(s,p,c));}
  
  sort(A.begin(),A.end());
  
  for(int i = 0; i < N; i++){
    cout << get<2>(A[i]) << endl; }
return 0;}
  
  

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

int main() {
  int n;
  map <int, int> m;
  cin >> n;
  rep(i, n) {
    int a;
    cin >> a;
    m.insert(make_pair(a, i));
  }
  for(auto p: m) {
    cout << p.second + 1<< endl;
  }
  return 0;
}


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

int main() {
  int N,L;
  cin >> N >> L;
  
  vector<string> vec(N);
  
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  for(int i = 0; i < N; i++){
    cout << vec.at(i);
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
H = [int(x) for x in input().split()]

dp = [0] * N
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
    dp[i] = min(dp[i-k] + abs(H[i]-H[i-k]) for k in [1,2])

answer = dp[-1]
print(answer)

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

int main(){
    int n, k;
    cin >> n >> k;
    string str;
    cin >> str;
    char c = str.at(k-1);
    char c2 = c + 0x20;
    str[k-1] = c2;
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc;
	
	String reverse(String s) {
		String tmp = "";
		for (int i=s.length()-1;i>=0;i--) tmp += s.charAt(i);
		return tmp;
	}
	
	void run() {
		sc = new Scanner(System.in);
		int count = 0;
		while(sc.hasNext()) {
			String s = sc.next();
			String left = s.substring(0,s.length()/2);
			String right = s.substring(s.length()-s.length()/2);
			right = reverse(right);
			if(left.compareTo(right)==0) count++;
		}
		System.out.println(count);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
using namespace std;

template<typename InputIterator> constexpr std::string join(InputIterator first, InputIterator last, const std::string &sep) {
  if (first == last) return "";
  std::stringstream ss;
  ss << *(first++);
  for_each(first, last, [&](auto &x) { ss << sep << x; });
  return ss.str();
}

main {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  list<int> l;
  while (n--) {
    string cmd;
    cin >> cmd;
    int x;
    if (cmd == "insert" || cmd == "delete") cin >> x;
    if (cmd == "insert") l.push_front(x);
    if (cmd == "delete") {
      auto iter = find(all(l), x);
      if (iter != l.end()) l.erase(iter);
    }
    if (cmd == "deleteFirst") l.pop_front();
    if (cmd == "deleteLast") l.pop_back();
  }
  cout << join(all(l), " ") << endl;
}

Measured memory_bytes: 33992
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

in gcd(in a, in b) {return b != 0 ? gcd(b, a % b) : a;}//最大公約数
in lcm(in a, in b) {return a / gcd(a, b)*b;}//最小公倍数

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n;
    cin>>n;
    vector<in> t(n,0);
    rep(i,n) cin>>t.at(i);
    in ans=1ll;
    rep(i,n){
        ans =lcm(ans,t[i]);
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
	int H, W, N;
	cin >> H;
	cin >> W;
	cin >> N;

	for (int i = 1; i < H * N; i++)
	{
		if (N <= W* i)
		{
			cout << i;
			break;
		}
		if (N <= H* i)
		{
			cout << i;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int H;

void print(int* u, int i){
  printf("node %d: key = %d, ",i,u[i]);

  if(i/2 != 0) printf("parent key = %d, ",u[i/2]);

  if(2*i <= H) printf("left key = %d, ",u[2*i]);

  if(2*i+1 <= H) printf("right key = %d, ",u[2*i+1]);
  printf("\n");
}

int main(){
  int u[250],i;
  
  scanf("%d",&H);
  for(i=1;i<H+1;i++)  scanf("%d",&u[i]);

  for(i=1;i<H+1;i++) print(u,i);
  return 0;
}



Measured memory_bytes: 2052
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        int n = scanner.nextInt();
        int[] array = new int[n];
        for(int i=0;i<n;i++) {
        	array[i] = scanner.nextInt();
        }

        Arrays.sort(array);

        System.out.println(array[n/2]-array[(n/2)-1]);
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 37332
S = gets.chomp.split("")
bit = S.size - 1
sum = 0

(2**bit).times do |i|
    ope = ("%#{bit}b" % i).gsub("1", "+").split("").map { |o| o.gsub(/ |0/, "") }
    f = S.zip(ope).flatten.join
    sum += eval(f)
end

puts sum

Measured memory_bytes: 2044
# 桁DP問題
N = int(input())
K = int(input())

dp = [[[0,0] for _ in range(4)] for _ in range(101)]

dp[0][0][0] = 1

# i = Nの●桁目
# j = 0以外の数字を何回利用しているか
# k == 0 Nを超えないように注意が必要
# k == 1 N以下が保証されている

keta = len(str(N))
for i in range(keta):
  for j in range(4):
    for k in range(2):
      num = int(str(N)[i])

      for n in range(10):
        ni, nj, nk = i+1, j, k

        if n != 0:
          nj += 1 # 0以外の数字を利用した数が増えた
        if nj > K: 
          continue # すでにKを使い切っているときはカウントしない
        if k == 0:
          if n > num:
            continue # Nを超えているので飛ばす
          if n < num:
            nk = 1 # 何でもOK

        dp[ni][nj][nk] += dp[i][j][k]

print(dp[keta][K][0] + dp[keta][K][1])

Measured memory_bytes: 3064
#![allow(non_snake_case,unused_imports)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn dfs_tree_dist(N:usize,E:&Vec<HashMap<usize,usize>>,start:usize) -> Vec<isize>{
    let mut D = (0..N).map(|_| -1).collect::<Vec<_>>();
    D[start] = 0;
    let mut q = vec![start];
    while q.len()>0{
        let i = q.pop().unwrap();
        for (&j,&c) in E[i].iter(){
            if D[j]!=-1{continue;}
            D[j] = D[i]+c as isize;
            q.push(j);
        }
    }
    D
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N = iter.next().unwrap().parse::<usize>().unwrap();
    let UVW = (0..N-1).map(|_| (
        iter.next().unwrap().parse::<usize>().unwrap()-1,
        iter.next().unwrap().parse::<usize>().unwrap()-1,
        iter.next().unwrap().parse::<usize>().unwrap()
    )).collect::<Vec<_>>();

    let mut E = (0..N).map(|_| HashMap::new()).collect::<Vec<_>>();
    for (u,v,w) in UVW{
        E[u].insert(v,w);
        E[v].insert(u,w);
    }
    let D = dfs_tree_dist(N,&E,0);
    for d in D{
        println!("{}",d%2);
    }
}

Measured memory_bytes: 92536
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14
 
typedef long long ll;
#define pb push_back
#define mp make_pair
 
const int maxm = 100000 + 5;
bool primes[maxm];
void prime_gen(int n)
{
    fill(primes, primes + maxm, true);
    primes[0] = primes[1] = false;
    for(int i = 2; i <= n; i++)
    {
        if(primes[i])
        {
            if(i * 1ll * i <= n)
            {
                for(int j = i * i; j <= n; j += i)
                {
                    primes[j] = false;
                }
            }
        }
    }
}
 
int cnt[maxm];
 
void solve()
{
    prime_gen(maxm - 1);
    for(int i = 3; i < maxm; i++)
    {
        cnt[i] = cnt[i - 1];
        if((i & 1) && primes[i] && primes[(i + 1) / 2])
        {
            cnt[i]++;
        }
    }
    
    int q;
    cin >> q;
    for(int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l - 1] << "\n";
    }
}
 
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(void){
  char array[4] ;
  char x,y;
  int count_x = 1, count_y = 1;

  scanf("%s",array);
  x = array[0]; // x:1文字目

  if(x != array[1]){ // 1文字目と2文字目が違う
    y = array[1];
    if(x == array[2])
      count_x++;
    else if(y == array[2])
      count_y++;
    if(x == array[3])
      count_x++;
    else if(y == array[3])
      count_y++;
  }
  else{              // 1文字目と2文字目が同じ 
    count_x++;
    y = array[2];
    if(y == array[3]){
      count_y++;
      if(x == y)   //全て同じ文字のとき
	count_x--; //後の条件から外す
    }
  }


  if(count_x == 2 && count_y == 2)
    printf("Yes\n");
  else
    printf("No\n");


  return 0;
}


Measured memory_bytes: 128
using System;

namespace ABC170A
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = Console.ReadLine().Trim().Split(' ');
            for(int i=0;i<5;i++){
                if(int.Parse(t[i])== 0) Console.WriteLine(i+1);
            }
        }
    }
}


Measured memory_bytes: 27480
/*template date:2019/12/27*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
#include<limits.h>
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
double to_deg(double r){return r*180.0/(atan(1.0)*4.0);}
typedef struct{
    int x;
    int y;
}pair_t;
int asc_cmp_t(const void* X,const void* Y){int x=(*(pair_t*)X).x,y=(*(pair_t*)Y).y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp_t(const void* X,const void* Y){int x=(*(pair_t*)X).x,y=(*(pair_t*)Y).y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    char s[200],t[200];scanf("%s %s",s,t);
    printf("%s%s\n",t,s);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <stack>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double PI = 3.14159;

int main(){
	int plen, cnum, width, cspace;
	while(cin >> plen && plen){
		cin >> cnum >> width >> cspace;
		vector<string> vs[200];
		string s;
		string space(cspace, '.');
		string spacec(width, '.');
		int count = 0;
		getline(cin,s);
		while(getline(cin,s) && s != "?"){
			while(s.size() > width){
				string s1(s.begin(), s.begin() + width);
				string s2(s.begin() + width, s.end());
				vs[count++%plen].push_back(s1);
				s = s2;
			}
			while(s.size() < width) s.push_back('.');
			vs[count++%plen].push_back(s);
		}
		for(int i = 0; i < plen; i++){
			while(vs[i].size() % cnum != 0) vs[i].push_back(spacec);
		}
		int page = vs[0].size() / cnum;
		for(int i = 0; i < plen; i++){
			while(vs[i].size() < vs[0].size()) vs[i].push_back(spacec);
		}
		for(int i = 0; i < page; i++){
			for(int j = 0; j < plen; j++){
				for(int k = 0; k < cnum; k++){
					cout << vs[j][k+i*cnum];
					if(k != cnum - 1) cout << space;
				}
				cout << endl;
			}
			cout << "#" << endl;
		}
		cout << "?" << endl;
	}
	return 0;
}
		

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

int main(){
	string s;
	cin >> s;
	vector<bool> a(30,0);
	for(long i=0;i<s.size();i++){
		a[(s[i]-'a')]=true;
	}
	for(int i=0;i<30;i++){
		if(i==26){
			cout << "None" << endl;
			return 0;
		}
		if(a[i]==false){
			cout << (char)(i+'a') << endl;
			return 0;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 512