akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define y2 azdfsdgwre

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 2e6 + 123, MOD = 998244353;
int n, m, fact[N], rev[N];

int binpow(int x, int y) {
    int res = 1;
    while (y > 0) {
        if (y & 1) {
            res = (ll)res * x % MOD;
        }
        x = (ll)x * x % MOD;
        y /= 2;
    }
    return res;
}

int c(int x, int y) {
    if (y > x) {
        return 0;
    }
    return ((ll)fact[x] * rev[y] % MOD) * rev[x - y] % MOD;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    fact[0] = rev[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = (ll)fact[i - 1] * i % MOD;
        rev[i] = (ll)rev[i - 1] * binpow(i, MOD - 2) % MOD;
    }
    cin >> n >> m;
    int res = 0;
    for (int i = 0; i <= m; i++) {
        if ((3 * m - i) & 1) {
            continue;
        }
        res += (ll)c((3 * m - i) / 2 + n - 1, n - 1) * c(n, i) % MOD;
        if (res >= MOD) {
            res -= MOD;
        }
    }
    int bad = 0;
    for (int i = 0; i < m; i++) {
        if ((m - 1 - i) & 1) {
            continue;
        }
        bad += (ll)c((m - 1 - i) / 2 + n - 1, n - 1) * c(n, i) % MOD;
        if (bad >= MOD) {
            bad -= MOD;
        }
    }
    bad = (ll)bad * n % MOD;
    cout << (res - bad + MOD) % MOD;
}


Measured memory_bytes: 15872
from collections import deque
N, M, P = map(int, input().split())
E1 = [[] for _ in range(N)]
E2 = [[] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    E1[a-1].append((b-1, P-c))
    E2[b-1].append((a-1, P-c))

def BFS(n, E, i0=0):
    Q = deque([i0])
    D = [-1] * n
    D[i0] = 0
    while Q:
        x = Q.popleft()
        for c, d in E[x]:
            if D[c] == -1:
                D[c] = D[x] + 1
                Q.append(c)
    return D

def bellman_ford_chk(n, E, s=0):
    D = [0] * n
    for k in range(n):
        for i in range(n):
            for j, c in E[i]:
                if D[j] > D[i] + c:
                    D[j] = D[i] + c
                    if k == n-1: return 1
    return 0
def bellman_ford_calc(n, E, s=0):
    D = [1<<100] * n
    D[s] = 0
    f = 1
    while f:
        f = 0
        for i in range(n):
            for j, c in E[i]:
                if D[i] < 1<<100 and D[j] > D[i] + c:
                    D[j] = D[i] + c
                    f = 1
    return D
D1 = BFS(N, E1, 0)
D2 = BFS(N, E2, N-1)
L = [i for i in range(N) if D1[i] >= 0 and D2[i] >= 0]

NN = len(L)
LL = [-1] * N
for i in range(NN):
    LL[L[i]] = i

E3 = [[(LL[a], c) for a, c in E1[i] if LL[a] >= 0] for i in range(N) if LL[i] >= 0]
if bellman_ford_chk(NN, E3, 0):
    print(-1)
else:
    print(max(-bellman_ford_calc(NN, E3, 0)[-1], 0))

Measured memory_bytes: 55128
#include <stdio.h>

bool is_up(const float x1, const float y1,
			const float x2, const float y2,
			const float xp, const float yp){
	float y = 0.0;
	y = (y2 - y1)/(x2 - x1)*(xp - x1) + y1;
	return yp > y;
}

bool is_ok(float *x, float *y, float xp, float yp){
	for(int i=0; i<3; ++i){
		if(is_up(x[i], y[i], x[(i+1)%3], y[(i+1)%3], x[(i+2)%3], y[(i+2)%3])
			!= is_up(x[i], y[i], x[(i+1)%3], y[(i+1)%3], xp, yp)){
				return false;
		}
	}
	return true;
}

int main(void){
	float x[3], y[3];
	float xp=0.0, yp=0.0;
	bool ok = false;

	for(int i=0; i<3; ++i){
		x[i] = y[i] = 0.0;
	}

	while(scanf("%f %f %f %f %f %f %f %f",
		x, y, x+1, y+1, x+2, y+2, &xp, &yp) != EOF){
			puts(is_ok(x, y, xp, yp) ? "YES": "NO");
	}
	return 0;
}

Measured memory_bytes: 0
S = list(input())
s = set(S)
S = list(s)
S.sort()
if len(S) == 26:
    print (None)
else:
    tmp = 0
    for i in 'abcdefghijklmnopqrstuvwxyz':
        if tmp >= len(S):
            print (i)
            break
        if i == S[tmp]:
            tmp += 1
        else:
            print (i)
            break
    


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

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

Measured memory_bytes: 3436
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
 
#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
 
const int N=100005;
int n,f[N],h,t;
multiset<int> s[N];
map<pii,int> mp;
pii q[N*50];
int get(int x){
	return x==f[x]?x:f[x]=get(f[x]);
}
int main(){
	scanf("%d",&n);
	For(i,1,n) f[i]=i;
	For(i,1,2*n-2){
		int x,y; scanf("%d%d",&x,&y);
		s[x].insert(y); s[y].insert(x);
		mp[pii(x,y)]++; mp[pii(y,x)]++;
		if (mp[pii(x,y)]==2) q[++t]=pii(x,y);
	}
	multiset<int>::iterator it;
	while (h!=t){
		int x=q[++h].fi,y=q[h].se;
		if ((x=get(x))==(y=get(y))) continue;
		s[x].erase(y); s[y].erase(x);
		if (s[x].size()<s[y].size()) swap(x,y);
		for (it=s[y].begin();it!=s[y].end();it++){
			int i=*it;
			s[i].erase(y); s[i].insert(x);
			++mp[pii(i,x)]; ++mp[pii(x,i)];
			if (mp[pii(x,i)]==2) q[++t]=pii(x,i);
			s[x].insert(i);
		}
		f[y]=x; s[y].clear();
	}
	For(i,1,n) if (get(i)!=get(1))
		return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 94976
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,k = LI()
    s = input()
    for i in range(k-1):
        print(s[i],end = "")
    print(s[k-1].lower(),end = "")
    for i in range(k,n):
        print(s[i],end = "")
    print()
    return

#B
def B():
    s = S()
    k = int(s[0])*10+int(s[1])
    l = int(s[2])*10+int(s[3])
    if k == 0:
        if l == 0:
            print("NA")
        elif l < 13:
            print("YYMM")
        else:
            print("NA")
    elif k < 13:
        if l == 0:
            print("MMYY")
        elif l < 13:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if l == 0:
            print("NA")
        elif l < 13:
            print("YYMM")
        else:
            print("NA")

#C
def C():
    n,k = LI()
    ans = 0
    for i in range(1,n+1):
        l = k/i
        ans += 1/n*1/(2 << max(0,math.ceil(math.log(l,2))))
    print(ans*2)
    return

#D
def D():
    n = I()
    v = [[] for i in range(n)]
    for i in range(n-1):
        x,y,w = LI()
        x -= 1
        y -= 1
        v[x].append((y,w))
        v[y].append((x,w))
    ans = [0 for i in range(n)]
    bfs_map = [1 for i in range(n)]
    bfs_map[0] = 0
    q = deque()
    q.append(0)
    while q:
        x = q.popleft()
        for y,w in v[x]:
            if bfs_map[y]:
                if w%2:
                    ans[y] = ans[x]^1
                else:
                    ans[y] = ans[x]
                bfs_map[y] = 0
                q.append(y)
    for i in ans:
        print(i)
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 72352
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,k,i;
  cin>>k>>a>>b;
  for(i=a;i<=b;i++)
  {
     if(i%k==0)
     {
        cout<<"OK"<<endl;
        return 0;
     }
  }
  cout<<"NG"<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main() {

  int n,i;
  int a[100];

  scanf("%d",&n);


  for(i=0; i< n; i++) {
   
    scanf("%d",&a[i]);
  }

  for (i=n-1; i>=0; i--) {
    printf("%d",a[i]);
    if(i != 0) {
      printf(" ");
    }

  }

  printf("\n");
  return 0;
}

Measured memory_bytes: 600
//q3.cpp
//Fri Aug  7 12:56:42 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int ans = 0;
	rep(i,s.length()){
		for (int j=i;j<s.length();j++){
			int flag = 1;
			string subs = s.substr(i,j-i+1);
			for(int k=0;k<subs.length();k++){
				if (subs[k]!='A' &&
					subs[k]!='T' &&
					subs[k]!='G' &&
					subs[k]!='C'
					){
					flag = 0;
				}
			}
			if (flag){
				int length = subs.length();
				ans = max(ans,length);
			}
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3572
s = int(input())
A = []

A.append(s)
a = s
for i in range(10000):
    if a % 2 == 0:
        a = int(a/2)
        A.append(a)
    else:
        a = 3*a+1
        A.append(a)
    if A.count(a) == 2:
        print(len(A))
        break


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

int main(){
    int m,f,r,count=0;
    int temp=0;
    char result[50];
    while(1){
        cin>>m>>f>>r;
        if(m==-1&&f==-1&&r==-1){
            break;
        }
        if(m==-1||f==-1){
            result[count]='F';
        }else{
            temp=m+f;
            if(temp>=80){
                result[count]='A';
            }else if(temp<80&&temp>=65){
                result[count]='B';
            }else if(temp<65&&temp>=50){
                result[count]='C';
            }else if(temp<50&&temp>=30){
                result[count]='D';
                if(r>=50){
                    result[count]='C';
                }
            }else if(temp <30){
                result[count]='F';
            }
        }
        count++;
    }
    for(int i=0;i<count;i++){
        cout<<result[i]<<endl;
    }
}


Measured memory_bytes: 3080
<?php
$input = (int)fgets(STDIN);

$base = 100;
for ($i = 1; $i <= 100000000000000000; $i++) {
    $benefit = floor($base * 0.01);
    $base += $benefit;
    if ($input <= $base) {
        echo $i;
        break;
    } 
}

Measured memory_bytes: 16096
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
lli dp[1001][1001];

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

    ld p2[20];
    p2[0]=1;
    for(lli i=1;i<20;i++)p2[i]=2*p2[i-1];
    ld n,k;
	ld ans=0;
	cin>>n>>k;
	for(lli i=1;i<=n;i++){
		lli j=0;
		lli t=i;
		for(;j<20;j++){if(t>=k)break;else t*=2;}
			//cout<<j<<endl;
		ans+=((ld)1/p2[j]);
	}
	ans/=n;
	cout<<fixed<<setprecision(12)<<ans;

	return 0;
 }

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

using namespace std;

using int64 = long long;

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  A += B;
  C += D;
  if(A == C) puts("Balanced");
  else if(A > C) puts("Left");
  else puts("Right");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool isprime(int n)
{
    if(n==1)
        return false;
        for(int i=2;i*i<n;++i)
        {
            if(n%i==0&&n!=2)
                return false;
        }
            return true;
}
int main()
{
    int m,j;cin>>m;
    j=m;
    if(isprime(m))
    {
        cout<<m<<endl;
    }
    else
    {
        while(1)
    {
        j++;
        if(isprime(j))
            break;
    }
    cout<<j<<endl;
    }
    return 0;
}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var H = a[0];
            var A = a[1];
            var ans = 0;

            while(true)
            {
                H -= A;
                ans++;
                if(H <= 0)
                {
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#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 n, k;
  	cin >> n >> k;
  	int x = 1;
  	rep(i, n){
    	x = min(x+k, x*2); 
    }
  	cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N, M = map(int, input().split())
    graph = defaultdict(list)

    for _ in range(M):
        A, B = map(int, input().split())
        graph[A].append(B)
        graph[B].append(A)

    route = deque()
    used = set()
    route.appendleft(1)
    used.add(1)
    for n in graph[1]:
        route.append(n)
        used.add(n)
        break

    while True:
        start, end = route[0], route[-1]
        start_ok = True
        for n in graph[start]:
            if n not in used:
                start_ok = False
                route.appendleft(n)
                used.add(n)
                break

        end_ok = True
        for n in graph[end]:
            if n not in used:
                end_ok = False
                route.append(n)
                used.add(n)
                break

        if start_ok and end_ok:
            break

    print(len(route))
    print(*route, sep=" ")


if __name__ == '__main__':
    main()


Measured memory_bytes: 34332
#include <stdio.h>

int main(void){

  int x1, x2, y1, y2;

  scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

  int x3, y3, x4, y4;

  x3 = x2 - (y2 - y1);
  y3 = y2 + (x2 - x1);

  x4 = x1 - (y2 - y1);
  y4 = y1 + (x2 - x1);

  printf("%d %d %d %d", x3, y3, x4, y4);


}


Measured memory_bytes: 128
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    /////////////////////
    // Write code below /
    /////////////////////
    string N;
    cin >> N;
    
    if (N[1] == N[2] && ( N[1] == N[0] || N[1] == N[3]) ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
// coded by- mrNOBODY_
 
 #include <bits/stdc++.h>
 #define ll long long 
 #define ull unsigned long long
 using namespace std;
 
 int main()
 {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    //  cin.sync();

    int x, n;
    cin>>x>>n;

    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }

    int ar1[102];

    for(int i=0; i<102; i++)
    {
        ar1[i] = true;
    }

    for(int i=0; i<n; i++)
    {
        ar1[arr[i]]=false;
    }
    int ans = 0;
    for(int i=0; i<102; i++)
    {
        if(ar1[i])
        {
            if( abs(x-ans) > abs(x-i) )
            {
                ans = i;
            }
        }
    }
    cout<<ans;
 
     return 0;
 }

Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DiceinLine solver = new DiceinLine();
        solver.solve(1, in, out);
        out.close();
    }

    static class DiceinLine {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] p = new int[n];
            long[] sum = new long[n + 1];
            long max = 0;
            for (int i = 0; i < n; i++) {
                p[i] = in.nextInt();
            }

            for (int i = 0; i < n; i++) {
                sum[i + 1] = sum[i] + p[i];
            }

            for (int i = 0; i + k <= n; i++) {
                max = Math.max(max, sum[i + k] - sum[i]);
            }

            out.println((double) (max + k) / 2);

        }

    }
}



Measured memory_bytes: 62168
def main():
  num_r,num_c = map(int,input().split())
  field = [input() for i in range(num_r)]
  q = []
  seen = [0]*(num_c*num_r)
  count = 0
 
  for i in range(num_r):
    for j in range(num_c):
      if field[i][j] == "#":
        seen[i*num_c+j] = 1
        q.append([i,j])
      
  while q:
    tank = []
    for i in q:
      r = i[0]
      c = i[1]
      if (0<=r-1) and (seen[(r-1)*num_c+c] == 0):
        tank.append([r-1,c])
        seen[(r-1)*num_c+c] = 1
      if (r+1<num_r) and (seen[(r+1)*num_c+c] == 0):
        tank.append([r+1,c])
        seen[(r+1)*num_c+c] = 1
      if (0<=c-1) and (seen[r*num_c+(c-1)] == 0):
        tank.append([r,c-1])
        seen[r*num_c+(c-1)] = 1
      if (c+1<num_c) and (seen[r*num_c+(c+1)] == 0):
        tank.append([r,c+1])
        seen[r*num_c+(c+1)] = 1
 
    count = count + 1
    q = tank
 
  print(count-1)
  
if __name__ == '__main__':
    main()

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

constexpr int nullNum = -1;

class Node{
public:
    Node() : 
    id( nullNum ), parent( nullptr ), left( nullptr ), right( nullptr ) {}

    void SetID( int id_ ){
        id = id_;
    }

    void SetParent( Node* prt ){
        parent = prt;
    }

    void SetLeft( Node* l ){
        left = l;
    }

    void SetRight( Node* r ){
        right = r;
    }

    int& ID(){
        return id;
    }

    Node* Parent(){
        return parent;
    }

    Node* Left(){
        return left;
    }

    Node* Right(){
        return right;
    }

    void PreOrderTreeWalk( Node* node ){
        if( node ){
            std::cout << " " << node->ID();
            PreOrderTreeWalk( node->Left() );
            PreOrderTreeWalk( node->Right() );
        }
    }

    void InOrderTreeWalk( Node* node ){
        if( node ){
            InOrderTreeWalk( node->Left() );
            std::cout << " " << node->ID();
            InOrderTreeWalk( node->Right() );
        }
    }

    void PostOrderTreeWalk( Node* node ){
        if( node ){
            PostOrderTreeWalk( node->Left() );
            PostOrderTreeWalk( node->Right() );
            std::cout << " " << node->ID();
        }
    }
    
private:
    int id;
    Node* parent;
    Node* left;
    Node* right;
};

int main(){
    int n;
    std::cin.tie(0);
    std::cin >> n;

    std::vector<Node> tree(n);

    for( auto& elem : tree ){
        elem = Node();
    }
    
    int id;
    int lid;
    int rid; 
    for( int i = 0; i < n; ++i ){
        std::cin >> id >> lid >> rid;
        tree[id].SetID( id );
        if( lid != nullNum ){
            tree[id].SetLeft( &tree[lid] );
            tree[lid].SetParent( &tree[id] );
        }
        if( rid != nullNum ){
            tree[id].SetRight( &tree[rid] );
            tree[rid].SetParent( &tree[id] );
        }
    }

    Node* root = &tree[0];
    while( root->Parent() ){
        root = root->Parent();
    }

    std::cout << "Preorder\n";
    root->PreOrderTreeWalk( root );

    std::cout << "\nInorder\n";
    root->InOrderTreeWalk( root );

    std::cout << "\nPostorder\n";
    root->PostOrderTreeWalk( root );
    std::cout << std::endl;

}


Measured memory_bytes: 3084
#include <stdio.h>
#include <string.h>

int main()
{
    int i, T;
    int test;
    char str[10001];
    char str2[10001];
    scanf("%d", &T);
    scanf(" %s", str);
    for(i = 0; i < strlen(str); i++){
        test = str[i] - 65;

        test = (test+T)%26;
        printf("%c", 65 + test);


    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 1652
#include <bits/stdc++.h>
using namespace std;
#pragma region Macros
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; ll K; cin >> N >> M >> K;
    vector<ll> A(N),B(M); cin >> A >> B;
    vector<ll> sum(M+1,0);
    for (int i=0;i<M;++i) sum[i+1]=sum[i]+B[i];
    ll now=0;
    int ans=upper_bound(ALL(sum),K)-sum.begin()-1;
    for (int i=0;i<N;++i){
        now+=A[i];
        if (now>K) break;
        chmax(ans,i+upper_bound(ALL(sum),K-now)-sum.begin());
    }
    cout << ans << '\n';
}

Measured memory_bytes: 7928
#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() {
    string a, b, c;
    cin >> a >> b >> c;
    char la = a.front() - 32;
    char lb = b.front() - 32;
    char lc = c.front() - 32;
    printf("%c%c%c\n", la, lb, lc);
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

int disp[10] = {
0b1111110, 
0b0110000, 
0b1101101, 
0b1111001, 
0b0110011,
0b1011011, 
0b1011111, 
0b1110010, 
0b1111111, 
0b1111011,};

int main(){
	while(true){
		int n;
		cin>>n;
		if(n==-1) break;
		
		int state = 0;
		REP(i, n){
			int x;
			cin>>x;
			int a = disp[x];
			int c = state ^ a;
			REP(i, 7) printf("%d", (c>>i)%2);
			printf("\n");
			state = a;
		}
	}
}

Measured memory_bytes: 1152
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = []
for _ in range(Q):
    BC.append(list(map(int,input().split())))

ans = sum(A)
numbers_a = [0] * (10**5+10)

for i in range(N):
    numbers_a[A[i]] += 1

for i in range(Q):
    ans = ans - numbers_a[BC[i][0]]*BC[i][0] + numbers_a[BC[i][0]]*BC[i][1]
    print(ans)
    x = numbers_a[BC[i][0]]
    numbers_a[BC[i][1]] += x
    numbers_a[BC[i][0]] = 0

Measured memory_bytes: 32184
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <complex>
using namespace std;
typedef struct UnionFind
{
	vector<int> par;

	UnionFind(int N)
	{
		par.resize(N);
		for(int i=0; i<N; i++)
		{
			par[i] = i;
		}
	}

	int root(int x)
	{
		if(par[x]==x)
		{
			return x;
		}
		else
		{
			return par[x] = root(par[x]);
		}
	}

	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx==ry)
		{
			return;
		}
		par[rx] = ry;
	}

	bool same(int x, int y)
	{
		return root(x) == root(y);
	}
}UnionFind;

int main()
{
	int N;
	cin>>N;
	vector<int> x(N);
	vector<int> y(N);
	
	int chain = N;
	for(int i=0; i<N; i++)
	{
		cin>>x[i]>>y[i];
	}
	//基準をそろえる
	for(int i=0; i<N; i++)
	{
		for(int j=0; j<N; j++)
		{
			UnionFind uf(N);
			if(i==j)
			{
				continue;
			}
				

			int p = x[i]-x[j];
			int q = y[i]-y[j];

			for(int k=0; k<N; k++)
			{
				for(int l=0; l<N; l++)
				{
					if(x[k]==x[l]-p && y[k]==y[l]-q)
					{
						uf.unite(k,l);
					}
				}
			}
			
			set<int> s;
			for(int i=0; i<N; i++)
			{
				s.insert(uf.root(i));
			}
			int s_size = s.size();
			chain = min(chain,s_size);
		}
	}
	cout<<chain<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int N;
int read(){
    int x=0,f=0; char ch=getchar();
    while(ch<'0'||ch>'9') {f|=(ch=='-');ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return f?-x:x;
}
signed main(){
    N=read();
    printf("%d",(1000-(N%1000))%1000);        
    return 0;
}

Measured memory_bytes: 3752
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll n ;
	cin>> n ;
	ll arr[n];
	for(ll i=0;i<n ;i++)cin>>arr[i];
	ll mx=0 , cnt=0;
	for(ll i=1;i<n ; i++){
		if(arr[i]<=arr[i-1]){
			cnt++;
			mx=max(mx,cnt);
		}
		else{
			cnt=0;
		}
	}
	mx=max(mx,cnt);
	cout<<mx<<endl;

	return 0;
}

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

const int M = 10000001;
ll a[M];
int main() {
    int N;
    cin >> N;
    fill(a, a + M, 1);
    for (ll i = 2; i < M; i++) {
        for (ll j = 1; i * j < M; j++) {
            a[i * j]++;
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        ans += i * a[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 81748
n=int(input())
l=[0]*5
m='MARCH'
for i in range(n):
  s=input()
  f=s[0]
  for i in range(5):
    if f==m[i]:
      l[i]+=1
      break
x=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      x+=l[i]*l[j]*l[k]
print(x)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    ll e1,e2,f1,f2,k,k1,k2;
    e1= (a-1)/c;
    e2= b/c;
    f1= (a-1)/d;
    f2= b/d;
    k = c*d/__gcd(c,d);
    k1= (a-1)/k;
    k2= b/k;

    ll ans = b-a+1-(e2-e1+f2-f1-(k2-k1));
    cout << ans<<endl;
}

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

int main() {
	int n, M = 0, m = 1000000001;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		M = max(M, a);
		m = min(m, a);
	}
	cout << M - m << endl;
}

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

int main(){
int a,count_1,count_2,count_3,count_4;
bool A = true;
  count_1=0;
  count_2=0;
  count_3=0;
  count_4=0;
  for(int i =0; i<6;i++){
  cin >>a;
  if(a==1){
  count_1++;
  }
  else if(a==2){
  count_2++;
  }
  else if(a==3){
  count_3++;
  }
  else if(a==4){
  count_4++;
  }
  }
  
 if(count_1==3 || count_2==3 || count_3==3 || count_4==3){
 A = false;
 }
 if(A==true){
 cout << "YES" <<endl;
 }
 if(A==false){
 cout << "NO"<<endl;
 }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 998244353
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
ll binarySearch(ll arr[], ll l, ll r,ll x) 
{ 
    if (r >= l) 
    { 
        ll mid = l + (r - l) / 2;  
        if (arr[mid] == x) 
        return mid; 
        if (arr[mid] > x) 
        return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
} 
int main()
{
    fast;
        ll a,b,v,t,w,x=0;
        std::cin >> a>>v>>b>>w>>t;
        if(b>a)
        {
            if(w*t+b<=v*t+a)
            x=1;
        }
        else
        {
            if(b-w*t>=a-v*t)
            x=1;
        }
        yesno(x);
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B,C,D;
  cin >>A>>B>>C;
  A-=B;
  B=A/C;
  A-=B*C;
  Out(A);
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
from math import ceil, floor, log2,sqrt
# from collections import deque, defaultdict
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, D = MI()
    X = []
    for i in range(N):
        X.append(LI())
        
    # print(X)
    ans = 0
    for i, j in product(range(N), repeat=2):
        if i == j:
            continue
        Y = X[i]
        Z = X[j]
        dist = 0
        for d in range(D):
            dist += (Y[d] - Z[d])**2
        sq = sqrt(dist)
        # print(dist, sq, dist % sq)
        if dist % sq == 0:
            ans += 1
    print(ans // 2)

if __name__ == '__main__':
    solve()



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

using namespace std;

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

    vector <int> height(no_of_stones + 1, 0);
    for(int i = 1; i <= no_of_stones; i++)
        cin >> height[i];

    vector <int> minimum_cost(no_of_stones + 1);
    minimum_cost[2] = abs(height[2] - height[1]);
    for(int i = 3; i <= no_of_stones; i++)
        minimum_cost[i] = min(minimum_cost[i - 1] + abs(height[i] - height[i - 1]),
                              minimum_cost[i - 2] + abs(height[i] - height[i - 2]));

    cout << minimum_cost[no_of_stones];
    return 0;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
int H, W;
int sum;
VEC<VEC<char>> b;
bool dfs(int h, int w, int len) {
  if (h >= H || w >= W) return 0;
  if (b[h][w] != '#') return 0;

  if (h == H - 1 && w == W - 1) {
  DUMP(len);
    if(len==sum) return 1;
    else return 0;
  }
  if (dfs(h + 1, w, len+1) || dfs(h, w + 1, len+1)) return 1;
  return 0;
}

int main() {
  cin >> H >> W;
  b = MATINIT(char, H, W, '.');
  sum = 0;
  REP(i, 0, H) {
    REP(j, 0, W) {
      cin >> b[i][j];
      if (b[i][j] == '#') ++sum;
    }
  }
  DUMP(sum);
  cout << (dfs(0, 0, 1) ? "Possible" : "Impossible") << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextLong();
            var b = cin.nextLong();
            var k = cin.nextLong();

            if(a + b <= k)
            {
                Console.WriteLine("0 0");
                return;
            }
            long aa = a - k;
            long nokori = Math.Abs(a - k);
            long bb = b;
            if (aa <= 0)
            {
                aa = 0;
                bb = bb - nokori;
            }
            Console.WriteLine(aa + " " + bb);

            
            

        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

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

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

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

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


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

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	int n; cin>>n;
	vector<P> a;
	rep(i,0,n){
		int p; cin>>p;
		a.push_back(make_pair(p,1));
	}
	rep(i,0,n){
		int p; cin>>p;
		a.push_back(make_pair(p,-1));
	}
	sort(a.begin(),a.end());
	int ans=1,val=0;
	rep(i,0,2*n){
		if(val>0&&a[i].second==-1) ans=(1LL*ans*val)%mod;
		if(val<0&&a[i].second==1) ans=(-1LL*ans*val+mod)%mod;
		val+=a[i].second;
	}
	printf("%d",ans);
  	return 0;
}


Measured memory_bytes: 6256
string = input()
string_list = [s for s in string]
 
def find(s, slist):
  index = []
  for i, st in enumerate(slist):
    if st == s:
      index.append(i)
  return index
 
index_of_a = find("A", string_list)
index_of_z = find("Z", string_list)
 
print(index_of_z[-1] - index_of_a[0]+1)

Measured memory_bytes: 13000
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadLong;
            var trans = cin.ReadLongArray(5);

            if(N % trans.Min() != 0)
            {
                Console.WriteLine(N / trans.Min() + 1 + 4);
            }
            else
            {
                Console.WriteLine(N / trans.Min() + 4);
            }

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i=0;i<n;i++)
        cin >> h[i];
    int dp[n];

    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));

    cout << dp[n-1];

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int MAX = 300000;

int main()
{
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    vector<int> x(MAX+2, 0);
    vector<int> prev(MAX+2, 0);
    for(int i=0; i<n; ++i)
        ++ x[a[i]];
    for(int i=1; i<=MAX; ++i){
        if(x[i] == 0)
            prev[i+1] = prev[i];
        else
            prev[i+1] = i;
    }

    while(--t >= 0){
        int q;
        cin >> q;

        int ret = 0;
        int s = MAX+1;
        while(s > 0){
            s -= s % q;
            s = prev[s];
            ret = max(ret, s % q);
        }

        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 4436
// c++include
#include <iostream>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用
using namespace std;

// define, typedef
#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;

// main関数
int main(void) {
	int n, a, i, flag = 0;
	vector<int> h;
	cin >> n;
	rpt(i, n) {
		cin >> a;
		h.push_back(a);
	}
	rpt(i, n) {
		if (i == 0)
			h[i] -= 1;
		else {
			if (h[i - 1] <= h[i] - 1)
				h[i] -= 1;
			else if (h[i - 1] <= h[i])
				continue;
			else {
				flag = 1;
				break;
			}
		}
	}
	if (flag == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 892
def calcdp(i,j):
    global dp, A, BIG_INT
    
    if dp[i][j] != -1:
        return dp[i][j]
    
    if i + 1== j:
        dp[i][j] = 0
        return dp[i][j]
    
    elif i + 2== j:
        dp[i][j] = A[i] + A[i + 1]
        return dp[i][j]
    
    else:
        m = BIG_INT
        for k in range(i + 1, j):
            m = min(calcdp(i, k) + calcdp(k, j), m)
        m += sum(A[i:j])
        dp[i][j] = m
        return dp[i][j]

    
BIG_INT = 10**30
N = int(input())
A = [int(x) for x in input().split()]
dp = [[-1] * (N + 1) for _ in range(N)] 

print(calcdp(0, N))

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

int fib(int n, int a, int b);

int main()
{
	int n;
	cin >> n;
	cout << fib(n - 1, 1, 1) << endl;
	return (0);
}


int fib(int n, int a, int b){
	int f;
	f = a;
	if (n >= 1){
		f = fib(n - 1, a + b, a);
  }
	return (f);
}

Measured memory_bytes: 1164
#include <iostream>
#include <map>
#include <string>

int main(int argc, char *argv[]) {
  int q;
  std::cin >> q;
  std::map<std::string, long> m;
  for (int i = 0; i < q; ++i) {
    int c;
    std::string key;
    std::cin >> c >> key;
    switch (c) {
    case 0:
      int x;
      std::cin >> x;
      m[key] = x;
      break;
    case 1:
      if (m.find(key) != m.end())
        std::cout << m.at(key) << std::endl;
      else
        std::cout << 0 << std::endl;
      break;
    case 2:
      m.erase(key);
      break;
    case 3:
      std::string r;
      std::cin >> r;
      auto begin = m.lower_bound(key), end = m.upper_bound(r);
      for (auto i = begin; i != end; ++i) {
        std::cout << i->first << " " << i->second << std::endl;
      }
      break;
    }
  }
}



Measured memory_bytes: 27860
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    vector <int> num={a,b,c};
    sort(num.begin() , num.end());
    cout << num.at(0) + num.at(1) + (num.at(2)*10) << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace CSharp_Shell
{

    public static class Program 
    {
        public static void Main() 
        {
        int a = int.Parse(Console.ReadLine());
        string b;
        if(30<=a){b = "Yes";}
        else{b = "No";}
        Console.WriteLine(b);
        }
    }
}

Measured memory_bytes: 27084
#include <cstdio>
#include <cstring>

int main()
{
  char string[100000];
  char odd[100000];

  scanf("%s", string);
  int a = 0;
  
  for(int i = 0; i < strlen(string); i++)
  {
    if(i % 2 == 0)
    {
      odd[a] = string[i];
      a++;
    }
  }
  printf("%s", odd);
  return 0;
}


Measured memory_bytes: 384