akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int L;
int used[606];
ll dp[606][306][306];
ll mo=1000000007;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	L=2*N;
	
	int F=0;
	FOR(i,N) {
		cin>>x>>y;
		if(x>y) swap(x,y);
		
		if(y==-1) {
			F++;
		}
		else if(x==-1 && y!=-1) {
			used[y]=1;
		}
		else if(x>-1) {
			used[x]=used[y]=2;
		}
	}
	
	dp[L][0][0]=1;
	for(i=L;i>=1;i--) FOR(x,N+1) FOR(y,N+1) {
		ll v=dp[i][x][y];
		if(v==0) continue;
		
		if(used[i]==2) {
			(dp[i-1][x][y]+=v)%=mo;
		}
		else if(used[i]==1) {
			(dp[i-1][x][y+1]+=v)%=mo;
			if(x) (dp[i-1][x-1][y]+=v)%=mo;
		}
		else {
			(dp[i-1][x+1][y]+=v)%=mo;
			if(x) (dp[i-1][x-1][y]+=v)%=mo;
			if(y) (dp[i-1][x][y-1]+=v*y)%=mo;
		}
	}
	
	ll ret=dp[0][0][0];
	while(F) ret=ret*(F--)%mo;
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

const int N=2e5+20;

int n,mod,m[N];
long long dp[N],p[N],ans;
char a[N];

int main()
{
	scanf("%d%d %s",&n,&mod,a+1);

	if(mod==2 or mod==5)
	{
		for(int i=1;i<=n;i++)
			if((a[i]-'0')%mod==0) ans+=i;
		return 0 * printf("%lld",ans);
	}

	p[0]=1;
	for(int i=1;i<=n;i++)
	{
		p[i]=(p[i-1]*10)%mod;
		dp[i]=(dp[i-1]*10+a[i]-'0')%mod;
	}

	for(int i=n;i>=1;i--)
	{
		dp[i]=(dp[i]*p[n-i])%mod;
		m[dp[i]]++;
		ans+=m[dp[i]]-1;
	}

	printf("%lld",ans+m[0]);
}

Measured memory_bytes: 7072
N,M,K=map(int,input().split())

par=[-1]*N
num=[0]*N

def find(x):
    if par[x]<0:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def union(x,y):
    p,q=find(x),find(y)
    if p==q:
        return
    if p>q:
        p,q=q,p
    par[p]+=par[q]
    par[q]=p   

def size(x):
    return -par[find(x)]

def same(x,y):
    return find(x)==find(y)
        

for _ in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    union(a,b)
    num[a]+=1
    num[b]+=1

for _ in range(K):
    c,d=map(int,input().split())
    c-=1
    d-=1
    if same(c,d):
        num[c]+=1
        num[d]+=1

for i in range(N):
    print(size(i)-1-num[i],end=" ")


Measured memory_bytes: 6396
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
    static decimal result;
static Hashtable ht=new Hashtable();
static StringBuilder sb = new StringBuilder();
static int N,M,K;
static long[,] table;
    static void Main()
    {
Read4();
      Read2();
      result++;
      int kyori=0;
for(int i=0;i<N;i++){
kyori+=s[i];
if(kyori>K){break;}else{result++;}
}
      
      Console.WriteLine(result.ToString());

    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {

 
    }


}

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

int main(){
    int n;
    cin>>n;
    long long a[n],b[n];
    long long ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=n-1;i>=0;i--){
        a[i]+=ans;
        if(a[i]%b[i]!=0){
            ans+=b[i]-a[i]%b[i];
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) x.begin(), x.end()
#define inf 1e9
#define INF 1e15
#define fastio ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
////////////////////////////////////////////////////////////
using namespace std;
 
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<ii> vii;

int main() {
	int n; cin >>n;
	cout << n/2+n%2;
}

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

using namespace std;

template <class T> T gcd( T a, T b )
{
	T r;

    if ( a > b ) swap( a, b );
    r = a%b;
    while ( r ) {
        a = b;
        b = r;
        r = a%b;
    }
    return b; 
}



int main()
{
	int N;

	cin >> N;

	long long *A = new long long [N];
	for ( int i = 0; i < N; i ++ ) cin >> A[i];

	long long last;

	long long *LGCD = new long long[N];
	long long *RGCD = new long long[N];
	last = A[0];
	LGCD[0] = 0;
	for ( int  i = 1; i < N; i ++ ) {
		last = gcd( last, A[i] );
		LGCD[i] = last;
	}
	RGCD[N-1] = 0;
	last = A[N-1];
	for ( int  i = N-2; i >= 0; i -- ) {
		last = gcd( last, A[i] );
		RGCD[i] = last;
	}


	long long gmax = 0;
	for ( int skip = 0; skip < N; skip ++ ) {
		long long lgcd, rgcd;

		// 0 - skip-1
		lgcd = 0;
		if ( skip == 0 ){

		} else if ( skip == 1 ) {
			lgcd = A[0];
		} else if ( skip >= 2 ) {
			lgcd = LGCD[skip-1]; // 0 - skip-1
		}

		// skip+1 - (N-1)
		rgcd = 0;
		if ( skip == N-1 ) {

		} else if ( skip == N-2 ) {
			rgcd = A[N-1];
		} else if ( skip <= N-3 ) {
			rgcd = RGCD[skip+1];
		}

		long long g;
		if ( lgcd == 0 ) {
			g = rgcd;
		} else if ( rgcd == 0 ) {
			g = lgcd;
		} else {
			g = gcd( lgcd, rgcd );
		}

// cout << "skip:" << skip << " " << lgcd << " " << rgcd << " - " << g << endl;
		if ( g > gmax ) gmax = g;
	}

	cout << gmax << endl;


    return 0;
}


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

#define IOS cin.tie(0);ios::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template <class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?' ':'\n'); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);}//最小公倍数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//void print(){}

//----------------------library------------------------//

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

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

int make_num(char a,char b,char c){
    int num=(a-'0')*100+(b-'0')*10+(c-'0');
    return num;
}

double temp(int t,int h){
    return (double)t-h*0.006;
}

signed main(){
//    IOS;
    CIN(N,T,A);
    vi H(N);
    double ans=INF;int palace;
    rep(i,N)cin>>H[i];
    rep(i,N){
        double cls=temp(T,H[i]);
        if(ans>abs((double)A-cls)) {ans=abs((double)A-cls);palace=i+1;}
    }
    printf("%d\n",palace);

    return 0;
}

Measured memory_bytes: 256
function main (s) {
    s=s.split(" ");
	s[0]=parseInt(s[0]);
	s[1]=parseInt(s[1]);
	s[2]=parseInt(s[2]);
	console.log((s[2]>=s[0]&&s[2]<=s[1])?"Yes\n":"No\n");
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
/**
 *   author: r1933
**/
#include "bits/stdc++.h"

using namespace std;

#define all(x) x.begin(), x.end()
using i64 = long long;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  bool get_c = false, get_f = false;
  for (auto e : s) {
    if (e == 'C') get_c = true;
    if (get_c && e == 'F') get_f = true;
  }
  cout << (get_c && get_f ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

int x[15][15];

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

    rep(i, n){
        rep(j, d){
            cin >> x[i][j];
        }
    }

    int cnt = 0;
    rep(i, n){
        FOR(j, i + 1, n){
            int n = 0;
            FOR(k, 0, d){
                int d = abs(x[i][k] - x[j][k]);
                n += d * d;
            }

            bool flag = false;
            for(int k = 0; k <= n; ++k){
                if(k * k == n){
                    flag = true;
                }
            }

            if(flag){
                cnt++;
            }
        }
    }

    println(cnt);
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int r;
    read(r);
    write(3 * r * r);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 256
rgb = set(["r","g","b"])
while 1:
	worm = raw_input()
	if worm == "0": break
	n = len(worm)
	que = [worm]
	ref = set(worm)
	L = 1
	cnt = flag = 0
	while 1:
		for r in range(L):
			Worm = que.pop(0)
			if Worm in ref: continue
			else: ref.add(Worm)
			if len(set(Worm)) == 1:
				flag = 1
				break
			for i in range(n-1):
				if Worm[i] != Worm[i+1]:
					worm = Worm[:]
					nextclr = list(rgb-set(worm[i:i+2]))[0]
					worm = worm[:i] + 2*nextclr + worm[i+2:]
					if worm not in que: que.append(worm)
		L = len(que)
		if flag or L == 0: break
		cnt += 1
		if cnt > 15: break
	print cnt if flag else "NA"

Measured memory_bytes: 5552
#include <stdio.h>
int a[200000];
int tag;
int main()
{
	int i,j,n,sum=0;
	tag=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		if(a[i]<=a[tag])
		{
			sum++;
			tag=i;
		}
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 896
from collections import defaultdict
import bisect
n,k=map(int,input().split())
a=[1]+list(map(int,input().split()))
d = defaultdict(list)
for i in range(n+1):
  a[i]-=1
d[a[0]%k].append(0)
for i in range(n):
  a[i + 1] += a[i]
  d[a[i+1]%k].append(i+1)
ans=0
for l in d.values():
  for i, idx in enumerate(l):
    ans += bisect.bisect_left(l,idx+k)-i-1
print(ans)


Measured memory_bytes: 61416
import sys
from itertools import combinations
import bisect


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()
    ans = 0
    for i, j in combinations(l, 2):
        lb = abs(j - i)
        ub = i + j
        ans += bisect.bisect_left(l, ub) - bisect.bisect_right(l, lb)
        for e in (i, j):
            if e > lb:
                ans -= 1

    print(ans // 3)


if __name__ == "__main__":
    main()


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

 int main () {
   
   int l, r, d;
   cin >> l >> r >> d;
   
   int z;
   z=(r-l+1)%d;
   
   
   if (z==0) {
     cout << (r-l+1)/d << endl;
   }
   else if (d==1) {
     cout << r << endl;
   }
   else if (l%d==0 && r%d==0) {
     cout << (r-l+d)/d << endl;
   }
   else {
     cout << (r-1+1)/d << endl;
   }
 }


Measured memory_bytes: 3632
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int64

let rec solve arr rest r d before =
    match rest with
    | 0 -> arr
    | i ->
        let item: int64 = r * before - d
        let newArr = Array.append arr [| item |]
        solve newArr (i - 1) r d item

()
|> readIntArray
|> fun [| r; d; x |] -> solve [||] 10 r d x
|> Array.map string
|> String.concat "\n"
|> printfn "%s"


Measured memory_bytes: 29728
#include<stdio.h>
int main(void)
{
	int n;
	int a[101];
	int cnt;
	int i,j,temp;
	
	scanf("%d",&n);
	while(n!=0){
		cnt=0;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		for(i=0;i<n;i++){
			for(j=0;j<n-1;j++){
				if(a[j]>a[j+1]){
					cnt++;
					temp=a[j];
					a[j]=a[j+1];
					a[j+1]=temp;
				}
			}
		}
		printf("%d\n",cnt);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1032
#include <cstdio>

int main() {
    int N, cnt = 0;
    scanf("%d", &N);
    char s[101];
    scanf("%s", s);
    for (auto c : s) {
        if (c == 'R') cnt++;
    }
    if (cnt*2 > N) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 128
// ================
// Himanshu Lal
// MNIT Jaipur
// ================
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define INF 1e18
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
// #define mp map<ll,ll>
#define test ll t; cin>>t; while(t--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    TEZ;
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    f(i,0,n)
        cin>>a[i];
    ll dp[n];
    f(i,0,n)
        dp[i]=INT_MAX;
    dp[0]=0;
    f(i,0,n-1){
        ll j=i+1;
        while(j<=i+k and j<n)
        {
            dp[j]=min(dp[j],abs(a[j]-a[i])+dp[i]);
            j++;
        }
    }
    cout<<dp[n-1];
}

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

int main(){
   int h,w,n;
   cin>>h>>w>>n;
   vector<int> a(n);
   for(int i=0;i<n;i++) cin>>a[i];
   vector<vector<int> > c(h,vector<int>(w));
   int sum=0;
   for(int i=0;i<n;i++){
       for(int j=sum;j<sum+a[i];j++){
           
           int k=j/w, l=j%w;
           if(k%2==0) c[k][l]=i+1;
           else c[k][w-l-1]=i+1;
       }
       sum +=a[i];
   }
   for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) cout<<c[i][j]<<" ";
    cout<<endl;
   }
    return 0;

}


Measured memory_bytes: 384
void main()
{
    string s = rdStr;

    long n = s.length;
    bool ok = true;
    foreach (i; 0 .. n/2)
    {
        if (s[i] != s[n-i-1]) ok = false;
    }

    long m = (n - 1) / 2;
    foreach (i; 0 .. m)
    {
        if (s[i] != s[m-i-1]) ok = false;
        if (s[m+i+1] != s[n-i-1]) ok = false;
    }

    writeln(ok ? "Yes" : "No");
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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

const int N = 1e5 + 10, mod = 1e9 + 7;
int n, k, ans, num[N];
vector<int> divs[N];

int sum(int a, int b) {
	return ((1LL * a + b) % mod + mod) % mod;
}

int mul(int a, int b) {
	return ((1LL * a * b) % mod + mod) % mod;
}

int pw(int a, int b) {
	int res = 1, tmp = a;
	while (b) {
		if (b & 1)
			res = mul(res, tmp);
		tmp = mul(tmp, tmp);
		b >>= 1;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = k; i; i--) {
		num[i] = pw(k / i, n);
		for (int j = 2 * i; j <= k; j += i)
			num[i] = sum(num[i], -num[j]);
		ans = sum(ans, mul(i, num[i]));
	}
	return cout << ans << endl, 0;
}


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

struct Node {
    int parent, left, right;
};

Node T[30];
int D[30], H[30];

void setDepth(int u, int d){
    if(u == -1){
        return;
    }
    D[u] = d;
    setDepth(T[u].right, d+1);
    setDepth(T[u].left, d+1);
}

int setHeight(int u){
    int h1 = 0;
    int h2 = 0;
    if(T[u].left != -1){
        h1 = setHeight(T[u].left) + 1;
    }
    if(T[u].right != -1){
        h2 = setHeight(T[u].right) + 1;
    }
    return H[u] = max(h1, h2);
}

int getSibling(int u){
    if (T[u].parent == -1){
        return -1;
    } else if (T[T[u].parent].left != u && T[T[u].parent].left != -1){
        return T[T[u].parent].left;
    } else if (T[T[u].parent].right != u && T[T[u].parent].right != -1){
        return T[T[u].parent].right;
    }
    return -1;
}

int main() {
    int n; cin >> n;
    rep(i, n){
        T[i].parent = -1;
    }
    rep(i, n){
        int id; cin >> id;
        int L; cin >> L;
        int R; cin >> R;
        T[id].left = L;
        T[id].right = R;
        if (L != -1){
            T[L].parent = id;
        }
        if (R != -1){
            T[R].parent = id;
        }
    }

    int r;
    rep(i, n){
        if(T[i].parent == -1){
            r = i;
            break;
        }
    }

    setDepth(r, 0);
    setHeight(r);

    rep(i, n){
        cout << "node " << i << ": parent = " << T[i].parent << ", sibling = " << getSibling(i) << ", degree = ";
        int deg = 0;
        if(T[i].left != -1){
            deg++;
        }
        if(T[i].right != -1){
            deg++;
        }
        cout << deg << ", depth = " << D[i] << ", height = " << H[i] << ", ";
        if(T[i].parent == -1){
            cout << "root" << endl;
        } else if (T[i].left == -1 && T[i].right == -1){
            cout << "leaf" << endl;
        } else {
            cout << "internal node" << endl;
        }

    }

}


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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
template<class T> using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-10;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int k;
void solve() {
    cin >> k;
    ll ans = 0;
    reps(i, k) reps(j, k) reps(l, k) {
        ans += gcd(gcd(i, j), l);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x; cin>>x;
	if (x<1200) cout<<"ABC";
	else cout<<"ARC"<<endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
def ii(): return int(readline())
def mi(): return map(int, readline().rstrip().split())
def li(): return list(readline().rstrip())
def lmi(): return list(map(int, readline().rstrip().split()))
def end(*arg): print(*arg); sys.exit()
# template

import collections
class edge():
    def __init__(self, src, to):
        self.src = src
        self.to = to
    def __str__(self):
        return "(" + str(self._from) + ", " + str(self._to) + ")"

class rootedtree():
    def __init__(self, n):
        l = 0
        while pow(2, l) < n:
            l += 1
        self._l = l
        self.size = n
        self.par = [[-1 for i in range(n + 1)] for i in range(l)]
        self.graph = [[] for i in range(n)]
        self.depth = [-1 for i in range(n)]
        self.root = -1

    def add_edge(self, src, to):
        self.graph[src].append(edge(src, to))
        self.graph[to].append(edge(to, src))

    def parent(self, i):
        return self.par[0][i]

    def __dfs1(self, r) -> None:
        root = r
        self.depth[r] = 0
        que = collections.deque()
        que.append((0, root))
        while len(que) != 0:
            v = que.pop()
            for u in self.graph[v[1]]:
                if u.to != self.parent(v[1]):
                    self.par[0][u.to] = v[1]
                    self.depth[u.to] = v[0] + 1
                    que.append((v[0] + 1, u.to))

    def build(self, _root=0) -> None:
        assert(self.root == -1)
        self.root = _root
        self.__dfs1(self.root)
        for i in range(self._l - 1):
            for j in range(self.size):
                if(self.par[i][j] == -1):
                    self.par[i + 1][j] = -1
                else:
                    self.par[i + 1][j] = self.par[i][self.par[i][j]]

    def lca(self, x: int, y: int) -> int:
        assert(self.root != -1)
        if self.depth[x] > self.depth[y]:
            x, y = y, x
        dif = self.depth[y] - self.depth[x]
        for i in range(self._l - 1, -1, -1):
            if dif & (1 << i):
                y = self.par[i][y]
        if x == y:
            return x
        for i in range(self._l - 1, -1, -1):
            nx = self.par[i][x]
            ny = self.par[i][y]
            if nx != ny:
                x = nx; y = ny
        return self.par[0][x]

    def depth_dif(self, x: int, y: int) -> int:
        assert(self.root != -1)
        z = self.lca(x, y)
        return self.depth[x] + self.depth[y] - 2 * self.depth[z]

def main():
    n, u, v = mi()
    u -= 1; v -= 1
    g = rootedtree(n)
    for _ in range(n - 1):
        a, b = mi()
        g.add_edge(a - 1, b - 1)
    g.build(v)
    ans = -1
    for i in range(n):
        x = g.lca(u, i)
        if g.depth_dif(u, x) < g.depth_dif(v, x):
            ans = max(ans, g.depth_dif(v, i))
    print(ans - 1)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 107756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll a,b;
  char c;
  cin >> a >> c >> b;
  if(c=='+') {
    cout << a+b << endl;
  }
  else cout << a-b << endl;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int, input().split()))

dp=[0]*(n)
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2])

print(dp[-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
#define ll long long
#define inc(a) sort(a.begin(), a.end())
#define dec(a) sort(a.rbegin(), a.rend())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    ll a, b; 
    cin>>a>>b;
    ll count = 1, m = __gcd(a, b);
    for(ll i = 2; i*i<=m; i++){
        if(m%i==0){
            count++;
            while(m%i==0) m/=i;
        }
    }
    if(m!=1)count++;
    cout<<count;
    return 0;
}

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

int main()
{
    int n, l;
    string str_array[1000];
    cin >> n >> l;
    for (int i = 0; i < n; i++) {
        cin >> str_array[i];
    }
    sort(str_array, str_array + n); 
    for (int i = 0; i < n; i++) {
        cout << str_array[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
/*  Kadai4_2
    saitomo   */

#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979
//10^-9以下の誤差になるよう十分に PIを定義

int main(void){
    double len_h,len_m,hour,min;
    //左から順に時針の長さ、分針の長さ、時、分
    scanf("%lf%lf%lf%lf",&len_h,&len_m,&hour,&min);
    double angle,ans;
    //時針と分針の間の角度、答え
    angle=(0.5*(60*hour+min)-6*min)*PI/180;
    /*時針は1分に0.5度、分針は1分に6度動くことを利用し、差をとってからradに直している。
  　この際、cos(x)=cos(-x)より、正負は考えなくて良い*/
    ans=sqrt(len_h*len_h+len_m*len_m-2*len_h*len_m*cos(angle));
    //余弦定理の利用
    printf("%.10lf\n",ans);    
    //10^-10まで出す
    return 0;
}


Measured memory_bytes: 2648
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int N, M, a, b;
	bool start[200000] = { false };
	bool can = false;
	vector<int> goalN;

	cin >> N >> M;

	for (int i = 0; i < M; i++)
	{
		cin >> a >> b;
		if (a == 1) {
			start[b] = 1;
		}
		if (b == N) {
			goalN.push_back(a);
		}
	}

	int gl = (int)goalN.size();

	for (int i = 0; i < gl; i++)
	{
		if (start[goalN.at(i)] == true) {
			can = true;
			break;
		}
	}

	if (can) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 1020
#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;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	int n, m;
	cin >>n >>m;
	
	vector<VI> dt(m, VI(4, 0));
	rep(i, m){
		cin >> dt[i][0] >>dt[i][1];
		dt[i][2] = i;
	}

	sort(all(dt));
	int ct=1;
	rep(i, m){
		if(i==0){ dt[i][3] = ct++; continue;}
		if(dt[i-1][0] != dt[i][0]) ct=1;
		dt[i][3] = ct++;
	}
	
	sort(all(dt), [](VI l, VI r){
		return l[2] < r[2];
	});
	//for(auto xl: dt){for(auto x :xl) printf("%d, ",x); puts("");}
	rep(i, m){
		printf("%06d%06d\n", dt[i][0], dt[i][3]);
	}
}



Measured memory_bytes: 7040
import java.util.*
import java.math.*
import java.lang.Math.*


private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val readListLong: ()->List<Long> = { readLine()!!.split(' ').map(String::toLong) }
private val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }
private val MOD = 1e9.toLong()+7
private val INF = Int.MAX_VALUE/2
private val LINF = Long.MAX_VALUE/2


var PA:Int = 0
var PB:Int = 0
var PC:Int = 0

class StateDfs(val Depth: Int, val Item: List<Int>, val StateSize: Int) {
    private data class Param(var value: Int, var count: Int)
    private data class State(val paramSize: Int, val params:Array<Param>,
                             val path: ArrayList<Int> = ArrayList())
    val INF = Int.MAX_VALUE/2
    private var curState: State
    private var ans: Int = 0
    init {
        this.curState = State(this.StateSize, Array<Param>(this.StateSize){Param(0,0)})
        this.ans = INF
    }
    private tailrec fun _dfs(n: Int, stat: State): Unit {
        if (n >= this.Depth) {
            if (stat.params[0].count>0 && stat.params[1].count>0 && stat.params[2].count>0) {
                var cost = (stat.params[0].count-1 + stat.params[1].count-1 + stat.params[2].count-1) * 10
                cost += abs(PA- stat.params[0].value) + abs(PB - stat.params[1].value) + abs(PC - stat.params[2].value)
                this.ans = min(this.ans, cost)
            }

            return
        } else {
            for(i in 0 until this.StateSize) {
                stat.params[i].value += Item[n]
                stat.params[i].count += 1
                stat.path.add(i)
                this._dfs(n + 1, stat)
                stat.params[i].value -= Item[n];
                stat.params[i].count -= 1;
                stat.path.removeAt(stat.path.lastIndex)
            }
        }
    }
    fun dfs(n: Int): Int {
        this.ans = INF
        this._dfs(n, this.curState)
        return this.ans
    }
}


fun solveC(N: Int, A:Int, B:Int, C:Int, L:List<Int>): Int {
    PA = A; PB = B; PC = C
    val stDfs = StateDfs(N, L.toList(), 4)
    val res = stDfs.dfs(0)

    return res
}


fun main(args: Array<String>) {
    val (N,A,B,C) = readListInt()
    val L = Array<Int>(N){0}
    for(i in 0 until N) {
        L[i] = readInt()
    }

    val ans = solveC(N, A, B, C, L.toList())

    println(ans)
}


Measured memory_bytes: 44084
import java.util.Scanner;

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

		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());

		String a_s = String.valueOf(a);
		String b_s = String.valueOf(b);

		String resultA = "";
		String resultB = "";

		for(int i = 0; i<a; ++i) {
			resultB += b_s;
		}

		for(int i = 0; i<b; ++i) {
			resultA += a_s;
		}

		if(a > b) {
			System.out.println(resultB);
		} else {
			System.out.println(resultA);
		}
	}
}


Measured memory_bytes: 19924
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int>P;

int main(void){
    int n,m; cin >> n >> m;
    priority_queue<int> q;
    vector<P>v(n);
    for(int i=0;i<n;i++){
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(),v.end());

    // for(int i=0;i<n;i++){
    //     cout << v[i].second << endl;
    // }

    int j=0;
    ll ans=0;
    for(int i=1;i<=m;i++){
        while(v[j].first==i){
            q.push(v[j++].second);
        }
        if(q.size()!=0) ans += q.top(),q.pop();
    }
    cout << ans << endl;
    return 0;
}


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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int N, K;
  cin >> N >> K;
  VI V(N);
  REP(i, N){
    cin >> V.at(i);
  }

  int ans=0;

  REP(l, K+1){
    REP(r, K-l+1){
      if(l+r>N) break;
      int d=K-l-r;
      int now=0;//現在価値
      VI S;//拾った宝石
      REP(i, l){
        now += V.at(i);//左からl個
        S.pb(V.at(i));
      }
      FOR(i, N-r, N){
        now += V.at(i);//右からr個
        S.pb(V.at(i));
      }
      SORT(S);
      REP(i, d){
        if(i>=S.size()) break;
        if(S.at(i)>0) break;
        now -= S.at(i);
      }
      ans = max(ans, now);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int a[20],b[20];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%d",a+i);
	rep(i,0,n)scanf("%d",b+i);
	
	int ans=1e9;
	rep(i,0,1<<n){
		//bitが立っていればひっくり返す
		//flag[k]=奇数番目に使えるか？
		int temp[20],flag[20];
		rep(k,0,n){
			temp[k]=bit(i,k)?b[k]:a[k];
			flag[k]=bit(i,k)^(k%2);
		}
//		rep(k,0,n)printf("%d ",temp[k]);puts("");
		int suc=1;
		int cnt=0;
		rep(x,0,n){
			int m=100,mi=-1;
			rep(y,x,n){
				if(temp[y]<m&&flag[y]==x%2){
					m=temp[y];
					mi=y;
				}
			}
			if(mi==-1||(x&&temp[x-1]>m)){
				suc=0;
				break;
			}
			for(int y=mi-1;y>=x;y--){
				int hoge;
				hoge=temp[y];temp[y]=temp[y+1];temp[y+1]=hoge;
				hoge=flag[y];flag[y]=flag[y+1];flag[y+1]=hoge;
				cnt++;
			}
		}
//		rep(i,0,n)printf("%d ",temp[i]);puts("");
		if(suc){
//			printf("%d %d\n",i,cnt);
			ans=min(ans,cnt);
		}
	}
	printf("%d",ans==1e9?-1:ans);
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <boost/rational.hpp>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  int64_t s = 0;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    d[i] = a + b;
    s -= b;
  }

  sort(d.begin(), d.end());
  rep(i, N) {
    if (i % 2 == 0) {
      s += d[N - 1 - i];
    }
  }
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF (1e9)

using namespace std;

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

const int MAX_N = (int)1e5 + 5;

int dp[MAX_N];

int main()
{
	rep (i, MAX_N) dp[i] = INF;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> h(N, 0);
	rep (i,N){
		cin >> h[i];
	} // end rep

	dp[0] = 0;
	rep (i, N){
		if (i - 1 >= 0){
			dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
		} // end if

		if (i - 2 >= 0){
			dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
		} // end if
	} // end rep

	int res = dp[N-1];
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int x;
	cin>>x;
	cout<<!x<<endl;
	return 0;
}


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

int parse(string &S, int l, int r){
  int ret = 0;
  if(S[l] != '['){
    for(int i = l; i < r; ++i){
      ret *= 10;
      ret += S[i] - '0';
    }
    return (ret+1)/2;
  }
  vector<int> V;
  int t = 0;
  for(int i = l; i < r; ++i){
    if(S[i] == '[') ++t;
    else if(S[i] == ']') --t;
    if(!t){
      V.push_back(parse(S,l+1,i));
      l = i+1;
    }
  }
  sort(V.begin(),V.end());
  for(int i = 0; i < ((int)V.size()+1)/2; ++i)
    ret += V[i];
  return ret;
}

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i){
    string S;
    cin >> S;
    cout << parse(S,0,(int)S.size()) << endl;
  }
  return 0;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif

  string s,t;
  cin>>s>>t;
  int n=s.length();
  if(s==t.substr(0,n))
  {
    cout<<"Yes";
  }
  else
  {
    cout<<"No";
  }
  

}


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

#undef max
#undef min

using namespace std;

void SolveA()
{
	size_t N;
	cin >> N;
	size_t cnt1 = 0;
	size_t cnt2 = 0;
	size_t cnt4 = 0;
	for (size_t i = 0; i < N; ++i)
	{
		size_t tmp;
		cin >> tmp;
		if (!(tmp % 4))
			++cnt4;
		else if (!(tmp % 2))
			++cnt2;
		else
			++cnt1;
	}

	size_t lastType = 4;
	for (size_t i = 0; i < N; ++i)
	{
		if (lastType == 4 && cnt1 > 0)
		{
			--cnt1;
			lastType = 1;
		}
		else if (lastType >= 2 && cnt2 > 0)
		{
			--cnt2;
			lastType = 2;
		}
		else if (cnt4 > 0)
		{
			--cnt4;
			lastType = 4;
		}
		else
		{
			cout << "No";
			return;
		}
	}

	cout << "Yes";
}

void SolveB()
{}

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


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

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

  int ans = 0;
  if (S == "SSS"){
    ans = 0;
  }else if (S == "SSR"){
    ans = 1;
  }else if (S == "SRS"){
    ans = 1;
  }else if (S == "SRR"){
    ans = 2;
  }else if (S == "RSS"){
    ans = 1;
  }else if (S == "RSR"){
    ans = 1;
  }else if (S == "RRS"){
    ans = 2;
  }else if (S == "RRR"){
    ans = 3;
  }

  cout << ans << endl;
  return 0;
}


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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) \
    for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
    return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
    for (int i = 0; i < P.size(); ++i) {
        if (i > 0) {
            s << " ";
        }
        s << P[i];
    }
    return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T> > P) {
    for (int i = 0; i < P.size(); ++i) {
        s << endl << P[i];
    }
    return s << endl;
}
template <class T>
ostream& operator<<(ostream& s, set<T> P) {
    EACH(it, P) { s << "<" << *it << "> "; }
    return s << endl;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, map<T1, T2> P) {
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; }
    return s << endl;
}
template <class T>
void show(vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        cerr << v[i] << " ";
    }
    cerr << "\n";
}
typedef long long ll;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int c = 0;
    sort(ALL(p));
    for (int i = 0; i < k; i++) {
        c += p[i];
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3660
import sys
input = sys.stdin.readline

N = int(input())
# dp[i][j][k] := 寿司が 1 つある皿が i 皿、2 つが j 皿、
# 3 つが k 皿の状態から全て食べ終えるまでの操作回数の期待値
dp = [[[float(0)] * (N+1) for _ in range(N+1)] for _ in range(N+1)]

a = list(map(int, input().split()))
I, J, K = a.count(1), a.count(2), a.count(3)

# 小さい方から dp を埋める
for k in range(N+1):
    for j in range(N+1):
        for i in range(N+1):
            if (i+j+k) <= N:
                # 式変形はググった…
                if (i+j+k) != 0:
                    dp[i][j][k] = float(N) / float(i+j+k)
                if i > 0:
                    dp[i][j][k] += dp[i-1][j][k] * float(i) / float(i+j+k)
                if j > 0:
                    dp[i][j][k] += dp[i+1][j-1][k] * float(j) / float(i+j+k)
                if k > 0:
                    dp[i][j][k] += dp[i][j+1][k-1] * float(k) / float(i+j+k)
print(dp[I][J][K])


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

namespace paiza2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Int32.Parse(Console.ReadLine());
            int K = Int32.Parse(Console.ReadLine());
            int X = Int32.Parse(Console.ReadLine());
            int Y = Int32.Parse(Console.ReadLine());
            if (N - K < 0) Console.WriteLine(N * X);
            else Console.WriteLine(K * X + (N - K) * Y);
        }
    }
}


Measured memory_bytes: 13140
n,k,q=map(int,input().split())
#p_3,p_4=map(int,input().split())
#n=int(input())
#a=int(input())
#b=int(input())
#s=list(input())
#T=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#s=[list(input())for _ in range(n)]
#b=list(map(int,input().split()))
#b=list(map(int,input().split()))
#c=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#s=[list(map(int,input().split()))for _ in range(n)]
#s=[list(input().split())for _ in range(n)]
a=[int(input()) for _ in range(q)]
score=[-q for _ in range(n)]
for i in range(q):
    score[a[i]-1]+=1
for i in range(n):
    tmp=score[i]+k
    if tmp<=0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 11780
import numpy as np
N,M = map(int, input().split())
P = [input().split() for i in range(M)]
dic = {}
ans = 0
pen = 0

for i in range(N):
  dic[i+1] = [False, 0]

for i in range(M):
  if dic[int(P[i][0])][0] == False:
    if P[i][1] == "WA":
      dic[int(P[i][0])][1] += 1
    else:
      dic[int(P[i][0])][0] = True
      pen += dic[int(P[i][0])][1]
      ans += 1

print(ans,pen)

Measured memory_bytes: 61332
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b;
	while(cin>>a>>b)
	{
		int sum = a + b;
		int cnt = 0;
		while(sum > 0)
		{
			sum /= 10;
			cnt++;
		}
		cout<<cnt<<endl;
	}
}


Measured memory_bytes: 3120
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

int main() {
  string s;
  cin >> s;
  int count = 0;
  if (s[0] == 'o') ++count;
  if (s[1] == 'o') ++count;
  if (s[2] == 'o') ++count;
  cout << (700 + count*100) << endl;
  return 0;
}

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

int main(){
    int N;
    std::cin >> N;

    std::vector<int> a(N);
    for (int i=0;i<N;i++) std::cin >> a.at(i);

    int cnt = 0;
    for (int i=0;i<N;i++) {
        while (a.at(i)%2==0) {
            a.at(i)/=2;
            cnt++;
        }
    }

    std::cout << cnt << '\n';
}

Measured memory_bytes: 256