akhauriyash/Code-Regression huggingface dataset:
import random
D=int(input())                                          #コンテの日数
c=list(map(int,input().split()))                        #26タイプ(AAC~AZC)のコンテストの満足度低下度
s=[list(map(int,input().split())) for _ in range(D)]    #s[d][i]...d(1<=d<=D)日目にi(1<=i<=26)番目のコンテストを行った時の満足度上昇
#types=[int(input()) for _ in range(D)]                  #コンテタイプ(1~26)
#満足度低下はΣ(1<=i<=26)ci*(d-last(d,i))                  #なおlast(d,i)=d日目以前に最後にタイプiのコンテストをやった日にち(ない場合0)
#よって満足度はs[d][i]-Σ(1<=i<=26)ci*(d-last(d,i))
#i日目のスコアはmax(10^6+s[d][i]-Σ(1<=i<=26)ci*(d-last(d,i)),0)
#last=[0]*26                                             #typeごとに、最後に使われた日にちを記録するよ
typ=0
ans=0
#greedyに最大とりまーす
#D=365
types=[(i%26)+1 for i in range(D)]
#print(l)
sc = [0] * D
last=[0]*26
for i in range(D):
    typ = types[i] - 1
    score = s[i][typ]
    dwn = 0
    last[typ] = (i + 1)
    for j in range(26):
        dwn = dwn + c[j] * ((i + 1) - last[j])
    ans = score - dwn
    # print(score,last)
    sc[i] = ans
all = sum(sc)
for _ in range(800):
    types2 = []
    mi=float("inf")
    ind=0
    for i in range(D):
        if mi>sc[i]:
            mi=sc[i]
            ind=i
    l=list(range(1,27))
    #print(l)
    #print(ind,types[ind]-1)
    lab1=l.pop(types[ind]-1)
    lab2=random.choice(l)
    spans=ind//26
    types2=types
    for i in range(spans*26,min((spans+1)*26,D)):
        if types[i]==lab2:
            types[i]=lab1
            types[ind]=lab2
            break
    sc2=[0]*D
    last=[0]*26
    for i in range(D):
        typ = types[i] - 1
        score = s[i][typ]
        dwn = 0
        last[typ] = (i + 1)
        for j in range(26):
            dwn = dwn + c[j] * ((i + 1) - last[j])
        ans = score - dwn
                # print(score,last)
        sc2[i] = ans
    all2 = sum(sc2)
    if all2<all:
        types=types2
    else:
        sc=sc2
        all=all2
    #print(max(all,all2))
for i in range(D):
    print(types[i])



Measured memory_bytes: 84768
package main

import (
	"fmt"
	"sort"
)

func main() {
	var x, y, z, k int
	fmt.Scan(&x, &y, &z, &k)

	as := make([]int, x)
	bs := make([]int, y)
	cs := make([]int, z)
	for i := 0; i < x; i++ {
		fmt.Scan(&as[i])
	}
	for i := 0; i < y; i++ {
		fmt.Scan(&bs[i])
	}
	for i := 0; i < z; i++ {
		fmt.Scan(&cs[i])
	}

	ab := make([]int, 0)
	for _, a := range as {
		for _, b := range bs {
			ab = append(ab, a+b)
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ab)))
	ab = ab[0:min(len(ab), 3000)]

	abc := make([]int, 0)
	for _, v := range ab {
		for _, c := range cs {
			abc = append(abc, v+c)
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(abc)))

	for i := 0; i < k; i++ {
		fmt.Println(abc[i])
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 93764
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



int main()
{
    const double pi = 3.14159265358979;
    int R;
    cin >> R;
    cout << 2*pi*R << endl;
}


Measured memory_bytes: 3772
def dfs(_h):
    if len(_h) == 0:
        return
    min_h = min(_h)
    global ans
    ans += min_h
    tmp = []
    for i in range(len(_h)):
        if _h[i] == min_h:
            tmp.append(i)
    tmp.append(N)
    head = 0
    sp = []
    for i in tmp:
        sp.append([x - min_h for x in _h[head:i]])
        head = i+1
    for s in sp:
        dfs(s)

N = int(input())
h = [int(x) for x in input().split()]
ans = 0
dfs(h)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string s;
int a,b;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='0') a++;
		else b++;
	}
	cout<<min(a,b)*2;
 	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll calc(int r, int d, ll x){
	ll res = r*x - d;
	cout << res << "\n";
	return res;
}

int main() {
	ll r, D, x2000, x;
	cin >> r >> D >> x2000;
	x = x2000;
	for(int i = 0; i < 10; i++)
	x = calc(r, D, x);
	return 0;
}


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

int main(){
  int N,K; cin >> N >> K;
  int L[50];
  for(int i=0; i<N; i++) cin >> L[i];
  sort(L,L+N);
  int result=0;
  for(int i=N-K; i<N; i++) result+=L[i];
  cout << result << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        while (true) {
            int a = scan.nextInt();
            String op = scan.next();
            int b = scan.nextInt();

            if (op.equals("?")) {
                break;
            }

            if (op.equals("+")) {
                System.out.println(a + b);
            } else if (op.equals("-")) {
                System.out.println(a - b);
            } else if (op.equals("*")) {
                System.out.println(a * b);
            } else if (op.equals("/")) {
                System.out.println(a / b);
            }
        }
    }
}

Measured memory_bytes: 26216
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int N;

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

    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A.at(i);

    REP(i, N) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 != 0 && A[i] % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String[] line0 = reader.readLine().split(" ");
    int N = Integer.parseInt(line0[0]);
    int K = Integer.parseInt(line0[1]);
    int[] dp = new int[N +1];
    int[] h = new int[N + 1];
    String[] line = reader.readLine().split(" ");
    for (int i = 1; i <= N; i++){
      h[i] = Integer.parseInt(line[i - 1]);
    }
    Arrays.fill(dp, 1<<30);
    dp[1] = 0;
    dp[2] = Math.abs(h[2] - h[1]);
    for (int i = 1; i <= N; i++){
      for (int j = 1; j <= K; j++){
        if( i - j >= 1){
          dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]));
        }
      }
    }
    System.out.println(dp[N]);
  }
}


Measured memory_bytes: 33628
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let mut a_arr = vec![0; n as usize];
    for i in 0..n {
        a_arr[i as usize] = read();
    }
    let mut ok = true;
    for a in a_arr.iter() {
        if a % 2 == 0 {
            if !(a % 3 == 0 || a % 5 == 0) {
                ok = false
            }
        }
    }
    if ok {
        println!("APPROVED");
    } else {
        println!("DENIED");
    }
}


Measured memory_bytes: 4352
from collections import deque
N = int(input())
E = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

num = [-1]*N
q = deque()
q.append((0, 0))
num[0] = 0
while q:
    temp = q.popleft()
    u = temp[0]
    n = temp[1]
    for v in E[u]:
        if num[v] >= 0:
            continue
        num[v] = (n+1)%2
        q.append((v, (n+1)%2))

ans = [0]*N
if sum(num) <= N//3 or N-sum(num) <= N//3:
    f = 1
    if N-sum(num) <= N//3:
        f = 0
    s = 1
    t = 3
    for i in range(N):
        if num[i] == f:
            ans[i] = t
            t += 3
    for i in range(N):
        if ans[i] == 0:
            ans[i] = s
            s += 1
            if s%3 == 0 and s < t:
                s += 1
else:
    s = 1
    t = 2
    u = 3
    for i in range(N):
        if num[i] == 0 and s <= N:
            ans[i] = s
            s += 3
        elif num[i] == 1 and t <= N:
            ans[i] = t
            t += 3
        else:
            ans[i] = u
            u += 3

print(*ans)

Measured memory_bytes: 56008
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <numeric>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<long long int> a(n);
	long long int d = 0;
	long long int l, r;
	for(int i=0;i<n;i++){
		cin >> a.at(i);
		d += a.at(i);
	}
	l = 0;
	r = d;
	long long int cost = d;
	long long int ans = d;
	for(int i=0;i<n;i++){
		l += a.at(i);
		r -= a.at(i);
		cost = abs(l-r);
		ans = min(ans,cost);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    int ans = 0;
    int d = Math.min(B, C);
    B -= d;
    C -= d;
    ans += 2*d;
    
    int e = Math.min(C, A);
    C -= e;
    A -= e;
    ans += e;
    ans += B;
    if (C > 0) {
      ans++;
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
n=int(input())
L=list(map(int,input().split()))

L=L[::-1]

pre=L[0]
for i in range(1,n):
      if L[i]>pre:
            if L[i]-1>pre:
                  print("No")
                  exit()
            else:
                  pre=L[i]-1
      else:
            pre = L[i]
print("Yes")

Measured memory_bytes: 14252
#include <stdio.h>

int main(void) {
    int i, m, f, r;

    i=1;
    while (i) {
        scanf("%d %d %d", &m, &f, &r);
        if (m==-1 && f==-1 && r==-1) break;
	if (m==-1 || f==-1) {
	    printf("F\n");
	} else if (m+f>=80) {
            printf("A\n");
	} else if (m+f>=65 && m+f<80) {
            printf("B\n");
        } else if (m+f>=50 && m+f<65) {
            printf("C\n");
        } else if (m+f>=30 && m+f<50) {
	    if (r>=50) {
	        printf("C\n");
	    } else printf("D\n");
	} else if (m+f<30) printf("F\n");
    }
    return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <utility> //pair
#include <algorithm> //sort
using namespace std;


int main(){
    string S;
    int N, Q, l, r, AC[100010] = {}, cnt=0;
    cin >> N >> Q >> S;
    //cout << S << endl;
    
    for (int i = 0; i < N-1; i++)
    {
        if (S[i] == 'A' && S[i+1] == 'C') {
            cnt++;
            
            //printf("aer;lgn");
        }
        AC[i+1] = cnt;
        //cout<< AC[i] << endl;
    }

    for (int i = 0; i < Q; i++)
    {
        cin >> l >> r;

        printf("%d\n", AC[r-1]-AC[l-1]);
    }
    
}


Measured memory_bytes: 1536
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int X;
    cin >> X;
    YESNO(X == 7 || X == 5 || X == 3);
}


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

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long ANS = (long) Math.sqrt(N);
        long ans = Long.MAX_VALUE;
        for (long i = 1; i <= (long) Math.sqrt(N); i++) {
            if (N % i == 0) {
                long A = Math.max(N / i, i);
                ans = Math.min(String.valueOf(A).length(), ans);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

bool** table;
int** dp;
int N;

int recursive(int left,int right){

	if(left == right)return dp[left][right] = 0;
	if(dp[left][right] != -1)return dp[left][right]; //?????¢???????????´???
	if((right-left+1)%2 == 1){ //??????????\???°?????´???
		return dp[left][right] = max(recursive(left,right-1),recursive(left+1,right));
	}
	if(table[left][(right-left+1)/2] == true)return dp[left][right] = right-left+1; //left???right?????¨????¶?????????´???
	if(right == left+1 && table[left][1] == false)return 0;

	int ans = 0;
	for(int i = left+1; i <= right-2; i++){
		ans = max(ans,recursive(left,i)+recursive(i+1,right));
	}
	return dp[left][right] = ans;
}

int main(){

	int data[301];
	table = new bool*[301]; //table[left][right] = left???????§?????????????2*right??????????????¨?¶??????§??????????????????
	dp = new int*[301]; //?????????????????????????????§?¶????????????°
	for(int i = 0; i <= 300; i++){
		table[i] = new bool[151];
		dp[i] = new int[301];
	}

	bool FLG;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		if(N <= 1){
			printf("0\n");
			continue;
		}

		//?¶??????????????????????????????????
		for(int i = 0; i <= 300; i++){
			for(int k = 0; k <= 150; k++)table[i][k] = false;
			for(int k = 0; k <= 300; k++){
				dp[i][k] = -1;
			}
		}

		for(int i = 1; i <= N; i++)scanf("%d",&data[i]);

		//????????????2???????¨?
		for(int i = 1; i <= N-1; i++){
			if(abs(data[i+1]-data[i]) <= 1)table[i][1] = true;

		}

		//?¶??????????????????????????¨????
		for(int length = 4; length <= N; length += 2){ //??????????????????
			for(int left = 1; left+length -1 <= N; left++){ //??????????????????
				FLG = false;

				if(table[left+1][(length-2)/2] == true && abs(data[left] - data[left+length-1]) <= 1)FLG = true;//??????????????£?????????length-2??????????¶????????????????????????¨??????+length-1?????´???????????????????¶?????????´???

				if(!FLG){
					for(int i = 2; i <= length-2; i += 2){
						if(table[left][i/2] == true && table[left+i][(length-i)/2] == true){
							FLG = true;
							break;
						}
					}
				}
				if(FLG){
					table[left][length/2] = true;
				}
			}
		}

		printf("%d\n",recursive(1,N));
	}

	return 0;
}

Measured memory_bytes: 3108
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 1000000000000000000
#define MOD 1000000007
 
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

typedef struct {
	long id;
	long par;
	long cnt;
	long need;
	long *counts;
	long clen;
} Data;

long N, M;
long A[100001];
Data data[100001];
long list[100001];
long len = 0;

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

int main() {
	long i, j;
	long ans = 0;
	long idx = 0;
	long id, par;
	
	sl(N);
	for(i=1;i<=N;i++) {
		data[i].id = i;
		data[i].par = -1;
		data[i].cnt = 0;
		data[i].need = 0;
		data[i].clen = 0;
	}
	for(i=2;i<=N;i++) {
		sl(A[i]);
		data[i].par = A[i];
		data[A[i]].need++;
	}
	for(i=1;i<=N;i++) {
		data[i].counts = (long *)malloc(sizeof(long) * (data[i].need + 1));
	}
	
	for(i=2;i<=N;i++) {
		if(data[i].need == 0) {
			list[len++] = i;
		}
	}
	while(idx < len) {
		id = list[idx++];
		par = data[id].par;
		
		data[par].counts[data[par].clen++] = data[id].cnt + 1;
		
		if(data[par].clen == data[par].need) {
			qsort(data[par].counts, data[par].clen, sizeof(long), compare_long);
			for(i=0;i<data[par].clen;i++) {
				data[par].cnt = MAX(data[par].cnt, data[par].counts[i] + i);
			}
			if(par == 1) break;
			list[len++] = par;
		}
	}
	
	pl(data[1].cnt);
	
	return 0;
}

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

int main() {
  int H , W;
  cin >> H >> W;
  vector<vector<int>> jin(10,vector<int>(10));
  for (int i = 0; i < 10; i++){
    for (int k = 0; k < 10; k++){
      cin >> jin.at(i).at(k);
    }
  }
  vector<vector<int>> hw(H,vector<int>(W));
  for (int j = 0; j < H; j++){
    for (int k = 0; k < W; k++){
      cin >> hw.at(j).at(k);
    }
  }
  for (int k = 0; k < 10; k++){
    for (int i = 0; i < 10; i++){
      for (int j = 0; j < 10; j++){
        jin.at(i).at(j)=min(jin.at(i).at(j), jin.at(i).at(k) + jin.at(k).at(j));
      }
    }
  }
  int sum = 0;
  for (int m = 0; m < H; m++){
    for (int n = 0; n < W; n++){
      int l = hw.at(m).at(n);
      if (l==-1){
          continue;
      }
      sum += jin.at(l).at(1);
    }
  }
  cout << sum << endl;
}

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

int a, b;

int main() {
	scanf( "%d%d", &a, &b );
	if( b < 0 ) 
		if( ( b - a ) % 2 == 0 ) printf( "Negative\n" );
		else printf( "Positive\n" );
	else
		if( a > 0 ) printf( "Positive\n" );
		else printf( "Zero\n" );
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
const int x=3;
char a[x];
int n;
cin>>a;
n=strlen(a);
if (n==2)

{
	
cout<<a;

}
else
{
	for (int i=2;i>=0;i--)
	{
		printf("%c",a[i]);
	}
}
}

Measured memory_bytes: 256
def main():
    import sys
    n = int(input())
    a = list(map(int, input().split(' ')))
    if n%2 == 1:
        a.append(0)
    a.sort()
    for i in range(n-1):
        if i%2 == 0:
            if a[i] == a[i+1]:
                continue
            else:
                print(0)
                sys.exit()
        else:
            if a[i]+2 == a[i+1]:
                continue
            else:
                print(0)
                sys.exit()
    result = 2 ** (n//2)
    print(result % (10**9+7))
if __name__ == '__main__':
    main()

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

struct uf {
	int par[200010];
	uf(){ for(int i=1; i<=200000; ++i) par[i]=i; }
	int r(int x){ return (par[x]==x)?x:(par[x]=r(par[x])); }
	void jn(int a, int b){ par[r(a)]=r(b); }
} u[2];
map<pp,int> m;
void w(int k,int i){
	for(;k--;){
		int a, b; read(a, b); u[i].jn(a, b);
	}
}

int main()
{
	int n, k, l;
	read(n, k, l);
	w(k, 0);
	w(l, 1);
	for(int i=1; i<=n; ++i) ++m[pp{u[0].r(i), u[1].r(i)}];
	for(int i=1; i<=n; ++i) printf("%d\n", m[pp{u[0].r(i), u[1].r(i)}]);
    return 0;
}


Measured memory_bytes: 13696
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define oset tree < int ,  null_type ,  less ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define endl '\n'
#define int long long int
#define db long double
#define str string
#define mod 1000000007
#define ff first
#define ss second
#define PQi priority_queue<int>
#define Vi vector<int>
#define Si set<int>
#define Li list<int>
#define mk make_pair
#define pii pair<int,int>
#define all(x) (x.begin(),x.end())
#define pb(x) push_back(x)
#define For(i,n,s) for(int i=s;i<n;i++)
#define mat2D(T,r,c) vector<vector<int> > T(r,vector<int>(c))
#define vec2D vector<vector<int> >
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define getVal(x) {int val;cin>>val;x.pb(val);}
#define debug(x) {for(auto i :x) cout << i << " ";cout << endl;}

void solve() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    // cout << s1[0] - 'a' << s2[0] - 'a' << s3[0] - 'a';
    putchar(toupper(s1[0]));
    putchar(toupper(s2[0]));
    putchar(toupper(s3[0]));
}

int32_t main() {
    fastIO;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
# endif
    solve();
    return 0;
}

Measured memory_bytes: 3608
//Inshallah , Boys played well..!!

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pb push_back
#define pf push_front
#define mk make_pair
#define f(i,j,n) for(ll i=j;i<n;i++)
#define r(i,n,j) for(ll i=n-1;i>=j;i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define Test int t;cin>>t;while(t--)
#define mod 1000000007
#define md 998244353
#define MIN INT_MIN
#define MAX INT_MAX
#define inf LLONG_MAX
#define all(container) container.begin() , container.end()
#define rall(container) container.rbegin() , container.rend()
#define sz(container) (int)container.size()
#define vll vector<long long>
#define vi vector<int>
#define pii pair <int , int>
#define pll pair <ll , ll>
#define fi first
#define se second
#define setp(x) setprecision(x)
#define meme(x,i) memset(x,i,sizeof(x))
const int N = 100005;

void solve() {
    int n;
    cin >> n;
    bool flag=false;
    int c=0;
    while(n--){
        int x,y;
        cin >> x >> y;
         if(x==y){
            c++;
         }
         else
            c=0;
         if(c==3){
            flag=true;
         }
    }
    if(flag)
        cout << "Yes";
    else
        cout << "No";
}

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

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int dig = n % 10;
    if(dig == 3){
        cout << "bon" << endl; 
    }
    else if( dig == 0 || dig == 1 || dig == 6 || dig == 8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;

    return 0;
}

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

int main() {
  int N, W, M = 1e5 + 1;
  cin >> N >> W;
  vector V(M, LONG_MAX);
  V.at(0) = 0;
  for (int w, v; cin >> w >> v;) {
    for (int i = M - 1; i >= 0; i--) {
      if (V.at(i) != LONG_MAX) {
        if (i + v < M && V.at(i) + w <= W) V.at(i + v) = min(V.at(i + v), V.at(i) + w);
      }
    }
  }
  for (int i = M - 1; i >= 0; i--) {
    if (V.at(i) != LONG_MAX) return cout << i << "\n", 0;
  }
}

Measured memory_bytes: 4024
n, m = [int(s) for s in input().split()]
a_list = [input() for _ in range(n)]
b_list = [input() for _ in range(m)]
stop = n - m + 1
for i in range(stop):
    for j in range(stop):
        break_flag = False
        for x in range(m):
            for y in range(m):
                if a_list[i + x][j + y] != b_list[x][y]:
                    break_flag = True
                    break
            if break_flag:
                break
        else:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 9152
import numpy as np

def set_power(a, power_array):
    res = 1
    for i in range(len(power_array)):
        power_array[i] = res
        res *= a


def solve(ans, K, arr):
    p = 0
    for d in range(15):
        pow = arr[d]
        x = pow - 1
        for i in range(1, 10):
            if d > 2:
                y = i * pow + arr[d - 1] - 1
                if y <= (9*(d - 1) + 1)*arr[d - 1]:
                    for j in range(0, 9):
                        if d > 9:
                            z = i*pow + j*arr[d - 1] + arr[d - 2] - 1
                            if z <= (9 * (d - 2) + j + 1) * arr[d - 2]:
                                for j2 in range(0, 9):
                                    ans[p] = z + j2 * arr[d - 2]
                                    p += 1
                        ans[p] = y + j * arr[d - 1]
                        p += 1
            ans[p] = i * pow + x
            p += 1
    return p

K = int(input())
ans = np.empty(10000, dtype=np.int64)
power_array = np.empty(16, dtype=np.int64)
set_power(10, power_array)
p = solve(ans, K, power_array)
print(*ans[:K].tolist(), sep='\n')


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

using namespace std;

typedef long long ll;

int const N = 2 * 100 * 1000 + 16;
int const inf = 1000 * 1000 * 1000;
int const M = inf + 7;

int n, m;
ll a[N];
ll b[N];

ll pa[N];
ll pb[N];

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  cin >> n >> m;
  copy_n(istream_iterator<int>(cin), n, a);
  copy_n(istream_iterator<int>(cin), m, b);

  partial_sum(a, a+n, pa);
  partial_sum(b, b+m, pb);

  // row
  ll r = 0;
  for(int i = 0; i < n; ++i) {
    ll d = (i+1) * a[i] % M - pa[i];
    r += d;
    r %= M;
    r += M;
    r %= M;
  }

  // col
  ll c = 0;
  for(int i = 0; i < m; ++i) {
    ll d = (i+1) * b[i] % M - pb[i];
    c += d;
    c %= M;
    c += M;
    c %= M;
  }

  ll ans = r * c % M;
  ans += M;
  ans %= M;
  cout << ans;

  cout << flush;
}

Measured memory_bytes: 5632
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
count = 0
ans = "No"

N,K = I()
A = l()


for i in range(N-K):
    if  A[K+i]/A[i] > 1:
        print("Yes")
    else:
        print("No")





Measured memory_bytes: 94228
a=int(input())
ene=list(map(int,input().split()))
hero=list(map(int,input().split()))
ans=0
for i in range(a):
  if hero[i]>ene[i]:
    hero[i]-=ene[i]
    ans+=ene[i]
    ene[i]=0
  else:
    ene[i]-=hero[i]
    ans+=hero[i]
    hero[i]=0
  if hero[i]>0:
    if hero[i]>ene[i+1]:
      hero[i]-=ene[i+1]
      ans+=ene[i+1]
      ene[i+1]=0
    else:
      ene[i+1]-=hero[i]
      ans+=hero[i]
      hero[i]=0
print(ans)

Measured memory_bytes: 19004
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

bool dfs(string s){
    if(s == "ABC") return true;
    else if(s.find("ABC") == string::npos) return false;

    string ABC = "A";
    bool res = false;
    rep(i,3){
        string tmp = s;
        string::size_type pos = tmp.find("ABC");
        string::size_type ppos;
        int cnt = 0;
        while(pos != string::npos){
            tmp.replace(pos, 3, ABC);
            pos = tmp.find("ABC", pos + 1);
            cnt++;
        }
        rep(j,tmp.size()){
            if(tmp[j] == ABC[0]) cnt--;
        }
        if(cnt == 0) res |= dfs(tmp);
        ABC[0]++;
    }
    return res;
}

int main(){
    string s;
    cin >> s;
    if(dfs(s)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 15896
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))

n = int(input())

for _ in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                a[j][k] = 0

ans = "No"

for i in range(3):
    c1 = 0
    c2 = 0
    for j in range(3):
        if a[i][j] == 0:
            c1 += 1
        if a[j][i] == 0:
            c2 += 1
    if c1 == 3 or c2 == 3:
        ans = "Yes"

if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0: ans = "Yes"
if a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0: ans = "Yes"

print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _20180307_AOJ
{
    class ALDS1_6A
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                int n = int.Parse(line);
                int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                int[] B = new int[n];
                int k = 10000;
                CountingSort(A, B, k);
                Console.WriteLine(string.Join(" ", B.Select(x => x.ToString()).ToArray()));
            }
        }

        static void CountingSort(int[] A, int[] B, int k)
        {
            int n = A.Length;
            int[] C = new int[k + 1];
            for(int j=0;j< n; j++)
            {
                C[A[j]]++;
            }

            for(int i=1;i<=k;i++)
            {
                C[i] += C[i - 1];
            }

            for(int j= n - 1; j>=0;j--)
            {
                B[C[A[j]] - 1] = A[j];
                C[A[j]]--;
            }
        }
    }
}



Measured memory_bytes: 221604
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

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

int main()
{
	int n;
	while (cin >> n && n ){
		ll g, l;			// Ååöñ, Å¬ö{
		vector <P> d (n );
		rep (i, n ){
			cin >> d[i].first >> d[i].second;
		} // end rep
		rep (i, n ){
			g = __gcd(d[i].first, d[i].second );	
			d[i].first /= g;
			d[i].second /= g;
		} // end rep

		vector<P> pre;
		do{
			pre = d;
			g = d[0].first;
			for (int i = 1; i < n; i++ )
				g = __gcd (g, d[i].first );
			rep (i, n )
				d[i].first /= g;
		}while (pre != d );
		do{
			pre = d;
			g = d[0].second;
			for (int i = 1; i < n; i++ )
				g = __gcd (g, d[i].second );
			rep (i, n )
				d[i].second /= g;
		}while (pre != d );

		for (int i = 0; i < n; i++ ){
			if (d[i].second % d[i].first == 0 ){
				d[i].second /= d[i].first;
				continue;
			}else{
				ll nextm = d[i].first;
				for (int j = 0; j < n; j++ ){
					if (i != j )
						d[j].second *= nextm;
				} // end for
			} // end if
		} // end for
		do{
			pre = d;
			g = d[0].second;
			for (int i = 1; i < n; i++ )
				g = __gcd (g, d[i].second );
			rep (i, n )
				d[i].second /= g;
		}while (pre != d );

		rep (i, n ){
			cout << d[i].second << endl;
		} // end rep	

	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> fs(n);
    rep(i, n)cin >> fs[i];
    sort(fs.begin(), fs.end());
    ll ans = accumulate(fs.begin(), fs.begin() + k, 0ll);
    cout << ans << endl;
}


Measured memory_bytes: 3632
N, M = map(int,input().split())
value = [list(map(int, input().split())) for _ in range(N)]
ans = 0

for i in [-1, 1]:
	for j in [-1, 1]:
		for k in [-1, 1]:
			s = []
			for x,y,z in value:
				s.append(i*x + j*y + k*z)
			s.sort(reverse=True)
			ans = max(ans, sum(s[:M]))
print(ans)

Measured memory_bytes: 3316
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int N = scan.nextInt();		
		int sumA = 0;

		for (int i=0;i<N;i++){
			sumA = sumA + scan.nextInt();
		}
		if (sumA >= H) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int H,W,Ch,Cw,Dh,Dw;

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

void bfs(vector<vector<char>> &S, vector<vector<int>> &seen) {
    deque<pair<int,int>> que;
    que.push_front(make_pair(Ch,Cw));
    seen[Ch][Cw] = 0;
    
    while(que.size()>0) {
        auto p = que.front();
        que.pop_front();
        int h = p.first;
        int w = p.second;
        rep(i,4) {
                
            int hn = h + dy[i];
            int wn = w + dx[i];
            if (hn>=0 && hn<H && wn>=0 && wn<W) {
                if (S[hn][wn]=='.' && (seen[hn][wn]==-1 || seen[hn][wn]>seen[h][w])) {
                    que.push_front(make_pair(hn,wn));
                    seen[hn][wn] = seen[h][w];
                } 
            }
        }
        rep(i,5) {
            rep(j,5) {
                int hn = h-2+i;
                int wn = w-2+j;
                if (hn>=0 && hn<H && wn>=0 && wn<W) {
                    if (S[hn][wn]=='.' && (seen[hn][wn]==-1 || seen[hn][wn]>seen[h][w]+1)) {
                        que.push_back(make_pair(hn,wn));
                        seen[hn][wn] = seen[h][w] + 1;
                    } 
                }
            }
        }
        
    }

}


int main(){
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    Ch--,Cw--,Dh--,Dw--;
    vector<vector<char>> S(H,vector<char> (W));

    rep(h,H) {
        string s;
        cin >> s;
        rep(w,W) {
            S[h][w] = s[w];
        }
    }
    vector<vector<int>> seen(H,vector<int> (W,-1));

    bfs(S,seen);
    cout << seen[Dh][Dw] << endl;

}


Measured memory_bytes: 8668
/*"Everything in the universe is balanced. Every disappointment
   you face in life will be balanced by something good for you!
                Keep going, never give up."            */
 
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
const ll N=1e6+9;
const ll mod=1e9+7;
 
ll a[N];
 
int add(int x, int y){
	return (x+y)%mod;
}
 
void solve()
{    
    ll n, m ;
    cin >>n >>m ;
    vector<int> a(n+1);
    vector<vector<long long int>> dp(n+1,vector<long long int>(m+1,0)) ;
    for(int i=1 ;i<=n; i++)cin>>a[i];
    if(!m){
    	cout<<1;return;
    }
    for(int i = 0 ; i<=m; i++){
    	dp[0][i] = 1 ;
    }
    for(int i=1; i<=n; i++){
    	for( int j = 0 ; j<=m ; j++){
	
			if(j)dp[i][j] = dp[i][j-1];    
	       	if(j<=a[i]){
	    		dp[i][j] = add(dp[i][j], dp[i-1][j]);
	    	}
	    	else {
	    		dp[i][j] = add(dp[i][j] , (dp[i-1][j]-dp[i-1][j-a[i]-1]+mod)%mod) ;
	    	}
 
    		//cout<<dp[i][j]<< " ";
    	}
    	//cout<<"\n";
    }	
    cout<< (dp[n][m] - dp[n][m-1]+ mod) % mod;
 
}
 
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    while(t--)
    {
      solve();
    }  
}
 
 
// Xorawar

Measured memory_bytes: 83160
#include<cstdio>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
	double p1x, p1y, p2x, p2y, p0x, p0y;
	int q;

	scanf("%lf %lf %lf %lf", &p0x, &p0y, &p1x, &p1y);

	pair<double, double> v01 = { p1x - p0x, p1y - p0y };


	scanf("%d", &q);

	for (int i = 0; i < q; i++)
	{
		scanf("%lf %lf", &p2x, &p2y);

		if ((p2x == p0x && p2y == p0y) || (p2x == p1x && p2y == p1y)){
			printf("ON_SEGMENT\n");

			continue;
		}

		pair<double, double> v02 = { p2x - p0x, p2y - p0y };

		if (v01.first*v02.second == v01.second*v02.first)
		{
			if ((v01.first*v02.first < 0)||(v01.second*v02.second<0))
			{
				printf("ONLINE_BACK\n");
				continue;
			}
			else
			{
				if (pow(v01.first,2)+pow(v01.second,2)<pow(v02.first,2)+pow(v02.second,2)){
					printf("ONLINE_FRONT\n");
				}
				else{
					printf("ON_SEGMENT\n");
				}
				continue;
			}
		}
		double sin = (v01.first*v02.second - v01.second*v02.first);

		if (sin > 0){
			printf("COUNTER_CLOCKWISE\n");

			continue;
		}
		else{
			printf("CLOCKWISE\n");

			continue;
		}
	}
}

Measured memory_bytes: 1032
N,A,B=map(int,input().split())
S=input()
count=0
out=1
for s in S:
    if s=="a" and count<A+B:
        count+=1
        print("Yes")
    elif s=="b" and count<A+B and out<=B:
        count+=1
        out+=1
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4016
p=input().rstrip().split(' ')
q=input().rstrip().split(' ')
l=[0]*10
for i in range(0,len(q)):
    l[int(q[i])]=1;
for i in range(int(p[0]),1000000000000):
    t=list(str(i))
    G=1;
    for j in range(0,len(t)):
        if l[int(t[j])]==1:
            G=0;
            break;
    if G==1:
        print(i)
        break;


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
    int n, m;
    int pi;
    string si;
    const auto AC = std::string("AC");

    cin >> n >> m;

    auto p = vector<int>(m);
    auto ACs = vector<int>(n);
    auto WAs = vector<int>(n);
    auto num_correct = 0;
    auto penalties = 0;

    for (int i = 0; i < m; ++i) {
        cerr << i << "\n";
        cin >> pi >> si;
        pi--;
        if (si != AC) {
            WAs[pi]++;
            continue;
        }
        if (ACs[pi]) {
            continue;
        }

        ACs[pi] = true;
        num_correct++;
        penalties += WAs[pi];
    }


    cout << num_correct << " " << penalties << endl;
    return 0;
}


Measured memory_bytes: 1408
#include"iostream"
#include"cstdio"
#include"cmath"
#include"cstring"
#include"algorithm"
#include"stack"
#include"queue"
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long 
#define ull unsigned long long
#define MAXN 1000005 

char a[MAXN],b[MAXN];
int ans=0;

int main()
{
	scanf("%s%s",a,b);
	int lena=strlen(a);
	for(int i=0;i<lena;i++) if(a[i]!=b[i]) ans++; 
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 4048
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

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

int main(void){
	int n, i;
	scanf("%d", &n);
	int m1=0, m2=0;
	int x;
	for(i=0; i<n; i++){
		int a;
		scanf("%d", &a);
		if(a>m1){
			m2=m1;
			m1=a;
			x=i;
		}else if(a>m2){
			m2=a;
		}
	}
	for(i=0; i<n; i++){
		printf("%d\n", i==x?m2:m1);
	}
}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

struct Node{
	int s;
	queue<int> Q;
};

int main(){
	int n;
	cin >> n;
	Node node[n + 1];
	for(int i = 1; i <= n; i++){
		int u, k, v;
		cin >> u >> k;
		node[u].s = -1;
		while(k--){
			cin >> v;
			node[u].Q.push(v);
		}
	}

	int p = 1, next, m;
	queue<int> move;
	node[p].s = 0;
	move.push(p);

	while(!move.empty()){
		p = move.front();
		//cout << "Pivot is " << p << endl;
		if(node[p].Q.empty()){
			//cout << "Nowhere to go from " << p << endl;
			move.pop();
		} else {
			m = node[p].Q.size();
			while(m--){
				next = node[p].Q.front();
				node[p].Q.pop();
				//cout << "Checking " << next << endl;
				if(node[next].s < 0){
					//cout << "Can go to " << next << endl;
					node[next].s = node[p].s + 1;
					move.push(next);
				}
			}
			move.pop();
		}
	}

	for(int i = 1; i <= n; i++)
		cout << i << " " << node[i].s << endl;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	ll x = 0;
	VL dp(n+5); dp[0]=1;
	rep2(i, 3, n+1){
		(x += dp[i-3]) %=MD;
		dp[i] = x;
	}
	cout <<dp[n] <<"\n";
	return 0;
}



Measured memory_bytes: 3660
#include<stdio.h>
#include<stdlib.h>

int main(){
    int a;
    scanf("%d",&a);
    int str[3];
    str[2]=a%10;
    a =a/10;
    str[1]=a%10;
    a =a/10;
    str[0]=a%10; 
    for(int i=0;i<3;i++){
        if(str[i]==7){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 1728
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
ll in(){ll x; cin >> x; return x;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	reverse(all(a));

	ll ans = 0;
	VecB used(n, false);
	rep(i, n){
		if(used[i]) continue;
		else used[i] = true;
		ll b = 1;
		while(b <= a[i]) b <<= 1;
		ll c = b-a[i];
		if(i != n-1 && a[i] == a[i+1] && a[i+1] == c){
			ans++;
			used[i+1] = true;
			continue;
		}
		ll p = lower_bound(all(a), c, greater<>())-a.begin();
		while(p != n && a[p] == c){
			if(!used[p]){
				ans++;
				used[p] = true;
				break;
			}
			p++;
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = Math.max(a + b, a - b);
    ans = Math.max(ans, a * b);
    System.out.println(ans);
  }
}


Measured memory_bytes: 22612
#include<stdio.h>

int main(){
	int price[51]={0,0,0,0,0,
	850,1100,1230,1400,1610,
	1520,1950,1870,2070,2250,
	2244,2620,2624,2794,3004,
	3040,3344,3390,3590,3740,
	3764,4120,4114,4314,4494,
	4488,4864,4868,5038,5248,
	5284,5588,5634,5834,5984,
	6008,6364,6358,6558,6738,
	6732,7108,7112,7282,7492,
	7528},n;
	while(scanf("%d",&n),n){
		printf("%d\n",price[n/100]);	
	}
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main()
{
    int sx,sy,tx,ty,i;
    while(scanf("%d%d%d%d",&sx,&sy,&tx,&ty)!=EOF)
    {

        for(i=sy+1;i<=ty;i++)
        {
            printf("U");
        }
        for(i=sx+1;i<=tx;i++)
        {
            printf("R");
        }
        for(i=ty-1;i>=sy;i--)
        {
            printf("D");
        }
        for(i=tx-1;i>=sx;i--)
        {
            printf("L");
        }
        printf("L");
        for(i=sy+1;i<=ty+1;i++)
        {
            printf("U");
        }
        for(i=sx;i<=tx;i++)
        {
            printf("R");


        }
        printf("D");
        printf("R");
        for(i=ty-1;i>=sy-1;i--)
        {
            printf("D");
        }
        for(i=tx;i>=sx;i--)
        {
            printf("L");
        }
        printf("U");
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(string& s) {
        int n = s.length();

        int res = 0;
        for (int i = 0, j = n - 1; i < j; ++i, --j) {
            if (s[i] != s[j]) {
                ++res;
            }
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    Solution sol;
    cout << sol.solve(s) << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n+1];
		for(int i=0; i<n; i++) {
			p[i] = sc.nextInt();
		}

		int cnt=0;
		for(int i=1; i<n-1; i++){
			if(p[i-1] < p[i] && p[i] < p[i+1]) cnt++;
			else if(p[i-1] > p[i] && p[i] > p[i+1]) cnt++;
		}
		System.out.println(cnt);
	}
}


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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    long long n;
    cin >> n;
    long long sum = 0;
    for (long long i = 1; i <= n; i++) {
        if ((i % 3 != 0) && (i % 5 != 0)) sum += i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3624