akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

void rec(vector<string>& ss, int depth, string& curs, char mcv, unordered_set<char>& seen) {
  if(depth == 0) {
    ss.push_back(curs);
  } else {
    //今まで出たもの
    for(char c : seen) {
      curs.push_back(c);
      rec(ss, depth - 1, curs, mcv, seen);
      curs.pop_back();
    }
    
    curs.push_back(mcv + 1);
    seen.emplace(mcv + 1);
    //新たなもの
    rec(ss, depth - 1, curs, mcv + 1, seen);
    curs.pop_back();
    seen.erase(mcv + 1);
  }
}
signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, N);
  
  vector<string> ss;
  string curs;
  curs.push_back('a');
  unordered_set<char> seen;
  seen.emplace('a');
  rec(ss, N - 1, curs, 'a', seen);
  
  sort(all(ss));
  
  for(string s : ss){
    fin(s);
  }
}

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

int main()
{
//enter two inte
int a;
int b;
int W;

cin>>W>>a>>b;

if(a<b)
{
  if(a+W < b)
	  cout<<abs((a+W)-b)<<endl;
  else
	  cout<<0<<endl;
}
else
{
if(b+W < a)
	  cout<<abs((b+W)-a)<<endl;
  else
	  cout<<0<<endl;

}


return 0;
}//main

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
using Graph = vector<vector<int>>;

int main() {
	int N, M, D[100005] = { -1 };
	cin >> N >> M;
	Graph G(N);
	rep(i, M) {
		int A, B;
		cin >> A >> B;
		G[A - 1].push_back(B - 1);
		G[B - 1].push_back(A - 1);
	}

	vector<int> dist(N, -1);
	queue<int> que;

	dist[0] = 0;
	que.push(0);

	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int nv : G[v]) {
			if (dist[nv] != -1) continue;
			dist[nv] = dist[v] + 1;
			D[nv] = v;
			que.push(nv);
		}
	}
	rep(v, N) {
		if (dist[v] == -1) {
			cout << "No" << endl;
			return 0;
		}
		// cout << v + 1 << ": " << dist[v] << endl;
	}
	cout << "Yes" << endl;
	for (int i = 1; i < N; i++) {
		cout << D[i] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 10720
N = input()
K = int(input())

if len(N) < K:
  print(0)
  exit()

ans = [1, int(N[-1]), 0, 0];
nine = [1, 9, 81, 729]

def combination(N,K):
  if N < K:
    return 0
  elif K == 0:
    return 1
  elif K == 1:
    return N
  elif K == 2:
    return N*(N-1)//2
  else:
    return N*(N-1)*(N-2)//6

for k in range(1, len(N)):
  if int(N[-k-1]) > 0:
    a = [1, 0, 0, 0]
    for j in range(1, K+1):
      a[j] += nine[j]*combination(k, j)
      a[j] += (int(N[-k-1])-1)*combination(k, j-1)*nine[j-1] + ans[j-1]
    ans = a
print(ans[K])

Measured memory_bytes: 9148
#include <stdio.h>

int main() {
	int n, a, b = 0, r = 0, i;
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		int t;
		scanf("%d", &t);
		t == r + 1 ? r++ : b++;
	}
	printf("%d", r == 0 ? -1 : b);
	return 0;
}

Measured memory_bytes: 128
INT_MAX=10**18+7
x=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
GETA=123
###############################################################################
import math as M
n=int(input())
A=INPUT()
sum=0
for ele in A:
    sum+=ele
ans=sum/n
#print(ans)
ans1=int(ans)+1
sum1=0
sum2=0
ans2=int(ans)
for ele in A:
    sum1+=(ele-ans1)**2
for ele in A:
    sum2+=(ele-ans2)**2
print(min(sum1,sum2))


Measured memory_bytes: 3064
NMXY = list(map(int, input().split()))
xlist = list(map(int, input().split()))
ylist = list(map(int, input().split()))

if max(xlist) < min(ylist) and NMXY[2] < NMXY[3] and max(xlist) < NMXY[3] and NMXY[2] < min(ylist):
    print('No War')
else:
    print('War')

Measured memory_bytes: 3060
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	float a,b,c,d,e,f;
	while(scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f)!=EOF)
	{
		float x,y;
		y=((f*a)-(d*c))/((a*e)-(d*b));
		x=(c-(b*y))/a;
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 3112
#!/usr/bin/env python3
import sys

MOD = 2  # type: int


def solve(N: int, A: "List[int]"):
    count = 0
    def func(count, lists):
        B = []
        for n in lists:
            if n % 2 != 0:
                print(count)
                break
            else:
                B.append(n/2)
        else:
            count += 1
            func(count, B)
    
    func(count, A)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
// 何回操作を行うことができるか
import 'dart:io';

void main() {
  int n = int.parse(stdin.readLineSync()); // 一つ入力
  List ai = stdin
      .readLineSync()
      .split(" ")
      .map((x) => int.parse(x))
      .toList(); // 一行に複数入力

  int count;

  count = 0;

  bool even;
  even = true;
  while (even) {
    for (int i = 0; i < n; i++) {
      if (ai[i] % 2 != 0) {
        even = false;
        print(count);
        return;
      }

      ai[i] = (ai[i] / 2).floor();
    }
    count++;
  }

  print(count);
}


Measured memory_bytes: 13452
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sqr(x) (x) * (x)

using namespace std;
using namespace __gnu_pbds;

mt19937_64 gen(time(0));

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//const int inf = 2e9 + 34333;
//const ll mod = 1e9 + 7;
const int maxn = 2e5 + 55;

int a[maxn];

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a + n);
    ll ans = 0;
    int cnt = 1;
    for(int i = n - 1; i >= 0 && cnt < n; --i)
    {
        ans += a[i];
        ++cnt;
        if (i < n - 1 && cnt < n)
        {
            ans += a[i];
            ++cnt;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4440
import java.util.Scanner;

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

		int n1 = X + (K-1);
		int n2 = X - (K-1);

		for (int i = n2; i <= n1; i++) {
			if (i != n1) {
				System.out.print(i + " ");
			} else {
				System.out.print(i);
			}
		}
	}
}

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

typedef long long ll;
const int N=1e5+5;
vector<int> t[N];
int zqm,n;
ll f[N],g[N],le[N],ri[N];

void dfs(int u) {
	f[u]=1;
	for(int v:t[u]) {
		for(int i=t[v].size()-1;i>=0;--i) if(t[v][i]==u) t[v].erase(t[v].begin()+i);
		dfs(v);
		f[u]=f[u]*(f[v]+1)%zqm;
	}
}

void Dfs(int u) {
	int sz=t[u].size();
	if(sz==0) return;
	le[0]=f[t[u][0]]+1;
	for(int i=1;i<sz;++i) le[i]=le[i-1]*(f[t[u][i]]+1)%zqm;
	ri[sz]=1;
	for(int i=sz-1;i>=0;--i) ri[i]=ri[i+1]*(f[t[u][i]]+1)%zqm;
	g[t[u][0]]=(g[u]*ri[1]%zqm+1)%zqm;
	for(int i=1;i<sz;++i) g[t[u][i]]=(g[u]*le[i-1]%zqm*ri[i+1]%zqm+1)%zqm;
	for(int v:t[u]) Dfs(v);
}

int main() {
	//freopen("1.in","r",stdin);
	//freopen("1.ans","w",stdout);
	
	scanf("%d%d",&n,&zqm);
	for(int i=1,u,v;i<n;++i) {
		scanf("%d%d",&u,&v);
		t[u].push_back(v),t[v].push_back(u);
	}
	dfs(1);
	/*for(int i=1;i<=n;++i) {
		printf("%d -> ",i);
		for(int u:t[i]) printf("%d ",u);
		puts("");
	}*/
	//for(int i=1;i<=n;++i) printf("%lld ",f[i]); puts("");
	g[1]=1,Dfs(1);
	//for(int i=1;i<=n;++i) printf("%lld ",g[i]); puts("");
	for(int i=1;i<=n;++i) printf("%lld\n",f[i]*g[i]%zqm);
	
	return 0;
}


Measured memory_bytes: 14976
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  char c;
  cin>>c;
  if(c>='a' && c<='z')cout<<'a'<<endl;
  else cout<<'A'<<endl;



  return 0;
}


Measured memory_bytes: 3632
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const as = input[1].split(" ").map(n => Number(n));
  const result = Array(n).fill(0);
  let ans1 = 0;
  const ans2 = [];
  const mid = Math.floor(n/2);
  for (let i = n-1; 0 <= i; i--) {
    const a = as[i];
    if (mid <= i) {
      result[i] = a;
      if (a === 1) {
        ans1++;
        ans2.push(i+1);
      }
      continue;
    }
    const base = i + 1;
    let cnt = 0;
    let sum = 0;
    while(true) {
      cnt++;
      const index = base *(cnt + 1) - 1;
      if (n <= index) break;
      sum += result[index];
    }
    if (sum%2 === a) {
      result[i] = 0;
    } else {
      result[i] = 1;
      ans1++;
      ans2.push(i+1);
    }
  }
  console.log(ans1);
  if (ans1 !== 0) {
    console.log(ans2.join(" ");
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29064
#include<stdio.h>
 #include<vector>
 #include<string.h>

 const int LIMIT=20001;
 const int out=-1;
 const int in=1;
 char str[LIMIT];
 int inOut[LIMIT]={0};


 void setInOut(int sp,int dx){
       int len =strlen(str);
       char c;
       bool isIn=false;
       int outHight,nowHight=0,sum,inP;
      
       std::vector<int> anss;

       for(int i=sp;i>=0&&i<len;i+=dx){
             c=str[i];
             //printf("(%c %d)",c,nowHight);
             if(isIn==true){
                   if(c=='\\'){
                         sum+=outHight-nowHight+1;
                         nowHight--;
                   }else if(c=='/'){
                         nowHight++;
                         sum+=outHight-nowHight;
                   }else if(c=='_'){
                         sum+=outHight-nowHight;
                   }
                   if(nowHight==outHight){
                         //printf("%d ",sum);
                         if(dx==1){
                               inOut[inP]=std::max(sum,inOut[inP]);
                         }else{
                               inOut[i]=std::max(sum,inOut[i]);
                         }
                         isIn=false;
                   }
             }else{
                   if(c=='\\'){
                         //printf("\n<in>");
                         inP=i;
                         isIn=true;
                         sum=1;
                         outHight=nowHight;
                         nowHight--;
                   }else if(c=='/'){
                         nowHight++;
                   }
             }
       }
 }
 void changeSTR(int len){
       for(int i=0;i<len;i++){
             if(str[i]=='\\')str[i]='/';
             else if(str[i]=='/')str[i]='\\';
       }
 }

 int main(){
       scanf("%s",str);
       int len=strlen(str);
       setInOut(0,1);
       changeSTR(len);
       //printf("\n\n");
       setInOut(len-1,-1);
       std::vector<int> anss;
       int all=0;
       for(int i=0;i<len;i++){
             if(inOut[i]>0)anss.push_back(inOut[i]);
             all+=inOut[i];
       }
       printf("%d\n%d",all,anss.size());
       for(int i=0;i<anss.size();i++){
             printf(" %d",anss[i]);
       }
       printf("\n");
 } 

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    ll cNum = 0;

    set<pair<ll, ll>> st;
    rep(i, n){
        ll a; cin >> a;
        auto it = st.upper_bound({-a, INFLL});
        if(it == st.end()){
            cNum++;
            st.insert({-a, cNum});
        }
        else{
            ll cTmp = (*it).second;
            st.erase(it);
            st.insert({-a, cTmp});
        }
    }
    cout << cNum << endl;
}

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

using namespace std;

int main() {
  int a;
  string b;
  cin >> a >> b;
  for(int i = 0; i < b.size(); i++) {
    a *= 10;
    a += (b[i] - '0');
  }
  
  for(int i = 0; i <= 400; i++) {
    if(a == i * i) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;


}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_str():
    return readline().strip()


def slv(N, X):
    C = X.count('1')
    cmr = 0
    cpr = 0
    for b in X:
        b = int(b)
        cpr = ((cpr * 2) + b) % (C+1)
        if C-1 != 0:
            cmr = ((cmr * 2) + b) % (C-1)

    ans = []
    for i in range(N):
        t = 0
        if X[i] == '0':
            x = (cpr + pow(2, N-i-1, C+1)) % (C+1)
            t += 1
        elif X[i] == '1' and C-1 != 0:
            x = (cmr - pow(2, N-i-1, C-1)) % (C-1)
            t += 1
        else:
            x = 0

        while x != 0:
            x %= bin(x).count('1')
            t += 1

        ans.append(t)

    return ans


def main():
    N = read_int()
    X = read_str()
    print(*slv(N, X), sep='\n')


if __name__ == '__main__':
    main()


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T = 1;
	while(T--)
	{
		int n,k;
		cin >> n >> k;
		int sum  = 0;
		vi v;
		rep(i,1,n)
		{
			int x;
			cin >> x;
			v.pb(x);
			sum += x;
		}
		double tot = (double)sum/(double)(4.0 * k);
		int flag=0;
		sort(all(v));
		reverse(all(v));
		repp(i,0,k)
		{
			if(v[i]<tot)
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;
typedef long long ll;
int main(){
	int l,d,r;
	int cnt=0;
	cin>>l>>r>>d;
	for(int i=l;i<=r;i++){
		if(i%d==0)
			cnt++;
	}
	cout<<cnt;
} 

Measured memory_bytes: 3620
#ITP1_11-C Dice 3
store=[]
str=["N","S","E","W"]
rep={
    "N":[4,0,2,3,5,1],
    "S":[1,5,2,3,0,4],
    "E":[2,1,5,0,4,3],
    "W":[3,1,0,5,4,2]
}

def rotate_dice(b,s):
    result = [0,0,0,0,0,0]
    for i in range(6):
        result[i]=b[rep[s][i]]
    return result
    
def check(a,b):
    if (b in store)==False:
        store.append(b)
        for s in str:
            check(a,rotate_dice(b,s))

a = input().split(" ")
b = input().split(" ")
r = check(a,b)
if a in store:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7552
S = input()
keta = len(S)

exp_sum = 0
for i in range(1 << keta-1):
    newS = S
    offset = 1
    for j in range(keta):
        if i & (1 << j):
            newS = newS[:j+offset] + "+" + newS[j+offset:]
            offset += 1
    exp_sum += eval(newS)

print(exp_sum)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int dxy[]={-1,0,1,0,-1};
struct data{
    int x,y;
    data(){}
    data(int _x,int _y):x(_x),y(_y){}
};
int sx,sy,lx,ly;
void update(data d){
    sx=min(sx,d.x);
    sy=min(sy,d.y);
    lx=max(lx,d.x);
    ly=max(ly,d.y);
}
int main(){
    int n;
    while(scanf("%d",&n),n){
        sx=sy=lx=ly=0;
        vector<data>V(n);
        V[0]=data(0,0);
        for(int i=1;i<n;i++){
            int p,d;
            scanf("%d%d",&p,&d);
            data prev=V[p],next;
            next=data(prev.x+dxy[d],prev.y+dxy[d+1]);
            update(next);
            V[i]=next;
        }
        printf("%d %d\n",lx-sx+1,ly-sy+1);
    }
}

Measured memory_bytes: 1032
s = input()
t = input()
q =int(input())
info = [list(map(int,input().split())) for i in range(q)]

s_ruiseki = "X"
for i in range(len(s)):
  if s_ruiseki[-1] == "X":
    s_ruiseki = s_ruiseki+s[i]
  elif s_ruiseki[-1] != s[i]:
    s_ruiseki = s_ruiseki+"X"
  elif s_ruiseki[-1] == s[i] =="A":
    s_ruiseki = s_ruiseki+"B"
  else:
    s_ruiseki = s_ruiseki+"A"    

t_ruiseki = "X"
for i in range(len(t)):
  if t_ruiseki[-1] == "X":
    t_ruiseki = t_ruiseki+t[i]
  elif t_ruiseki[-1] != t[i]:
    t_ruiseki = t_ruiseki+"X"
  elif t_ruiseki[-1] == t[i] =="A":
    t_ruiseki = t_ruiseki+"B"
  else:
    t_ruiseki = t_ruiseki+"A"    

for i in range(q):
  if s_ruiseki[info[i][0]-1]  == "X":
    ans1 = s_ruiseki[info[i][1]]
  elif s_ruiseki[info[i][0]-1]  == "A":
    if s_ruiseki[info[i][1]] == "X":
      ans1 = "B"
    elif s_ruiseki[info[i][1]] == "B":
      ans1 = "A"
    elif s_ruiseki[info[i][1]] == "A":
      ans1 = "X"
  else:
    if s_ruiseki[info[i][1]] == "X":
      ans1 = "A"
    elif s_ruiseki[info[i][1]] == "B":
      ans1 = "X"
    elif s_ruiseki[info[i][1]] == "A":
      ans1 = "B"

  if t_ruiseki[info[i][2]-1]  == "X":
    ans2 = t_ruiseki[info[i][3]]
  elif t_ruiseki[info[i][2]-1]  == "A":
    if t_ruiseki[info[i][3]] == "X":
      ans2 = "B"
    elif t_ruiseki[info[i][3]] == "B":
      ans2 = "A"
    elif t_ruiseki[info[i][3]] == "A":
      ans2 = "X"  
  else:
    if t_ruiseki[info[i][3]] == "X":
      ans2 = "A"
    elif t_ruiseki[info[i][3]] == "B":
      ans2 = "X"
    elif t_ruiseki[info[i][3]] == "A":
      ans2 = "B"  
      
  if ans1 == ans2:
    print("YES")
  else:
    print("NO")

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

const int MAX= 1E5+5;
const int MAXN = 205;
const int MOD = 1E9+7;

int n, X;
vector<int> a(MAXN);
int f[MAXN][MAX];

int dp(int i, int cur){
	int& ret = f[i][cur];
	if(ret != -1) return ret;
	if(i==0) return ret = (cur < a[1]? cur : 0);
	ret = (dp(i-1, cur%a[i]) + (i-1)*dp(i-1, cur))%MOD;
	return ret;
}

signed main() {
	cin >> n >> X;
	for(int i=1; i<= n; ++i) cin >> a[i];
	sort(a.begin()+1, a.begin()+n+1);
	int p = 1, ret = 0;
	memset(f, -1, sizeof f);
	for(int i=n; i>= 1; --i){
		ret += p*dp(i-1, X%a[i]);
		ret %= MOD;
		p *= (i-1);
		p%= MOD;
	}
	cout << ret;
	return 0;
}

Measured memory_bytes: 160384
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005

ll n,capacity;
ll price[100], wt[100];
ll dp[105][MAX];

void bottomUp(){
    memset(dp, 0, sizeof(dp));
    for(int i=0; i<=n; i++){
        for(int j=0; j<=capacity; j++){
            if(i==0||j==0){
                dp[i][j]=0;
            }
            else if(j>=wt[i-1]){
                dp[i][j] = max(dp[i-1][j], price[i-1]+dp[i-1][j-wt[i-1]]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout<<dp[n][capacity]<<endl;
}

ll solve(int i, int j){
    if(i==0||j==0) return 0;

    if(dp[i][j] != -1) return dp[i][j];

    if(wt[i-1]>j) return dp[i][j] = solve(i-1, j);

    return dp[i][j] = max(solve(i-1, j), price[i-1]+solve(i-1, j-wt[i-1]));
}

void topDown(){
    memset(dp, -1, sizeof(dp));
    cout<<solve(n, capacity)<<endl;
}

int main(){
    cin>>n>>capacity;
    for(int i=0; i<n; i++){
        cin>>wt[i]>>price[i];
    }
    // bottomUp();
    topDown();
    return 0;
}

Measured memory_bytes: 82432
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n, t;
P p[101];

int main(){
	cin >> n >> t;
	for(int i = 0; i < n; i++){
		cin >> p[i].first >> p[i].second;
	}
	
	sort(p, p+n);
	
	bool b = 0;
	for(int i = 0; i < n; i++){
		if(p[i].second <= t){
			cout << p[i].first << endl;
			b = 1;
			break;
		}
	}
	if(!b)cout << "TLE" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
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)

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; }

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


int H, W;
vector<vector<int> > a;

typedef pair<int,int> pint;
typedef pair<pint,pint> ppint;

int main() {
    while (cin >> H >> W) {
        a.assign(H, vector<int>(W, 0));
        int odd = 0;
        for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j) {
            cin >> a[i][j];
            if (a[i][j] & 1) ++odd;
        }
        vector<ppint> res;

        int num = 0;
        int x = 0, y = 0;
        for (int iter = 0; iter < W*H; ++iter) {
            if (a[x][y] & 1) ++num;
            
            int nx = x, ny = y;
            if (x % 2 == 0) {
                if (ny == W-1) ++nx;
                else ++ny;
            }
            else {
                if (ny == 0) ++nx;
                else --ny;
            }
            if (num & 1) {
                if (num < odd) res.push_back(ppint(pint(x, y), pint(nx, ny)));
            }
            x = nx, y = ny;
        }
        
        cout << res.size() << endl;
        for (auto p : res) {
            cout << p.first.first+1 << " " << p.first.second+1 << " " << p.second.first+1 << " " << p.second.second+1 << endl;
        }
    }
}






























Measured memory_bytes: 5232
/*
 *  Author : Jun_SH
 *  Solution for ddcc2020-qual B
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
int a[200010],sum[200010]={};
int s2[200010]={};
int as(int x){
    if(x<0)return -x;
    return x;
}
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    for(int i=n;i>=1;--i){
        s2[i]=s2[i+1]+a[i];
    }
    int mi=1e18;
    for(int i=1;i<=n;++i){
        mi=min(mi,as(s2[i+1]-sum[i]));
    }
    cout<<mi<<endl;
}


Measured memory_bytes: 4992
n,k = map(int,input().split())
dk = [1,k,float("inf")]
ans = 0

while k > 2:
    k /= 2
    dk.append(int(-(-k//1)))
    
dk = sorted(dk)[::-1]
    
for i in range(1,n+1):
    for j in range(len(dk)):
        if i >= dk[j]:
            break
            
    ans += 1/n *(0.5**(j-1))
            
print(ans)

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

using namespace std;

using ll = long long;

bool Check(const int n, const vector<string> &w) {
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
            if (w[i] == w[j]) return false;
    for (int i = 1; i < n; ++i)
        if (w[i - 1].back() != w[i].front()) return false;
    return true;
}

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

    int n;

    cin >> n;
    vector<string> w(n);
    for (int i = 0; i < n; ++i) cin >> w[i];
    if (Check(n, w)) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        for (int i = 0; i <= 20000; i++) {
            if (A == (int)Math.floor(i * 0.08) && B == (int)Math.floor(i * 0.1)) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }
}


Measured memory_bytes: 23380
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in a:
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1
cnt,sur=0,0
for i in dic.values():
    if i%2==0:
        cnt+=(i-1)//2
        sur+=1
    else:
        cnt+=i//2
print(n-cnt*2-(sur+1)//2*2)

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

int main(void){
  int n,m;
  vector<int> p;
  int ans;
  
  cin >> n >> m;
  for (int i=1; i*i<=m; i++){ // sqrt(m)以下の約数
    if (m%i==0 && m/i>=n) ans = i;
    if (m%i==0) p.push_back(i);
  }
  for (int i=p.size()-1; i>=0; i--){
    int x = m/p[i];
//    cout << m/p[i] << endl;
    if (m/x>=n) ans = x;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=5e6+10;
const int mod=1e9+7;
int arr[N],iarr[N];
int logi(int n){int p=0;while(n/2){n=n/2;p++;}return p;}
int poww(int x,int y){int pro=1;while(y){if(y&1)pro=((pro%mod)*(x%mod)%mod);y=y>>1;x=((x%mod)*(x%mod)%mod);}return pro;}
map<int,int> mp;
int arr1[1000001],arr2[1000001];

void solve()
{
	int a1,a2,a3;
	cin>>a1>>a2>>a3;
	if((a1+a2+a3)>=22)
	{
		cout<<"bust";
	}
	else
	{
		cout<<"win";
	}
}

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


Measured memory_bytes: 2304
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a1 = []
a2 = []
for i in range(n):
    if i % 2 == 0:
        a1.append(a[i])
    else:
        a2.append(a[i])
if n % 2 == 0:
    a2.reverse()
    print(*a2+a1)
else:
    a1.reverse()
    print(*a1+a2)


Measured memory_bytes: 26368
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef long long LL;
const int MaxN = 2e5;

LL k;
LL ans[55];
int main()
{
	while(scanf("%lld", &k) != EOF)	
	{
		for(LL i = 0; i < 50; i++)
			ans[i] = i;
		LL x = k / 50;
		for(LL i = 0; i < 50; i++)
			ans[i] += x;
		LL y = k % 50;
		for(LL i = 49; i >= 49 - y + 1; i--)
			ans[i] += 1;
		printf("50\n");
		for(LL i = 0; i < 50; i++)
			printf("%lld ", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????

NEXT = 2
DATA = 1
PREV = 0
from collections import deque
def dll_processor(operations):
    
    front = None
    end = None
    dll = deque([])
    for o in operations:
        if o[0] == "insert":
            dll.appendleft(o[1])
            #front, end = insert(front, end, o[1])
        elif o[0] == "delete":
            try:
                dll.remove(o[1])
            except:
                pass
            #front, end = delete(front, end, o[1])
        elif o[0] == "deleteFirst":
            dll.popleft()
            #front, end = delete_first(front, end)
        elif o[0] == "deleteLast":
            dll.pop()
            #front, end = delete_last(front, end)
        #print(get_list(front))
        
    return dll

def get_list(front):
    if not front:
        return []
    
    l = []
    target = front
    while True:
        l.append(target[DATA])
        if not target[NEXT]:
            break
        target = target[NEXT]
    return l

def insert(front, end, target):
    node = [None, target, None]
    if front:
        front[PREV] = node
        node[NEXT] = front
        return node, end
    else:
        return node, node
    
def delete(front, end,target):

    delete_node = front
    while not delete_node[DATA] == target:
        delete_node = delete_node[NEXT]
        if delete_node == None:
            return front, end

    if delete_node[PREV] == None:
        delete_node[NEXT][PREV] = None
        return delete_node[NEXT], end
    elif delete_node[NEXT] == None:
        delete_node[PREV][NEXT] = None
        return front, delete_node[PREV]
    else:
        delete_node[NEXT][PREV] = delete_node[PREV]
        delete_node[PREV][NEXT] = delete_node[NEXT]
        return front, end
    
def delete_last(front, end):
    
    if not end[PREV]:
        return None, None
    else:
        end[PREV][NEXT] = None
        return front, end[PREV]
    
def delete_first(front, end):
    
    if not front[NEXT]:
        return None, None
    else:
        front[NEXT][PREV] = None
        return front[NEXT], end

def main():
    n_list = int(input())
    target_list = [input().split() for i in range(n_list)]
    print(*dll_processor(target_list))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 557380
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Linq
Imports System.IO

Public Class Program


    Public Shared Sub Main(args As String())

        Dim input = Console.ReadLine()
        Select Case Integer.Parse(input.Substring(input.Length - 1))
            Case 2, 4, 5, 7, 9
                Console.WriteLine("hon")
            Case 0, 1, 6, 8
                Console.WriteLine("pon")
            Case 3
                Console.WriteLine("bon")
        End Select


    End Sub




End Class

Measured memory_bytes: 27512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

map<ll,ll> m;
ll t, n, a, b, c, d;

ll solve(ll x){
	if (x == 0) return 1;
	if (x == 1) return d;
	if (m.find(x) != m.end()) return m[x];
	
	ll l2 = (x/2)*2;
	ll r2 = ((x+1)/2)*2;
	ll l3 = (x/3)*3;
	ll r3 = ((x+2)/3)*3;
	ll l5 = (x/5)*5;
	ll r5 = ((x+4)/5)*5;
	
	ll answer = 1e18;
	if (answer/d >= x){
		answer = x*d;
	}
	answer = min(answer, llabs(l2 - x)*d + a + solve(l2/2));
	answer = min(answer, llabs(r2 - x)*d + a + solve(r2/2));
	answer = min(answer, llabs(l3 - x)*d + b + solve(l3/3));
	answer = min(answer, llabs(r3 - x)*d + b + solve(r3/3));
	answer = min(answer, llabs(l5 - x)*d + c + solve(l5/5));
	answer = min(answer, llabs(r5 - x)*d + c + solve(r5/5));
	return m[x] = answer;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> t;
	REP(i, 0, t){
		m.clear();
		cin >> n >> a >> b >> c >> d;
		cout << solve(n) << "\n";
	}
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int main(){
    int x[4],y[4];
    cin>>x[0]>>y[0]>>x[1]>>y[1];
    int dx=x[1]-x[0];
    int dy=y[1]-y[0];

    x[2]=x[1]-dy;
    y[2]=y[1]+dx;

    x[3]=x[0]-dy;
    y[3]=y[0]+dx;

    cout<<x[2]<<" "<<y[2]<<" "<<x[3]<<" "<<y[3]<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
	int N, T, E;
	scanf("%d %d %d", &N, &T, &E);
	int X[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", &X[i]);
	}
	bool found = false;
	for (int i = T - E; i <= T + E; i++) {
		for (int j = 0; j < N; j++) {
			if (i % X[j] == 0) {
				printf("%d\n", j+1);
				found = true;
				goto end;
			}
		}
	}
end:
	if (!found) {
		printf("-1\n");
	}
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  string ans = "Yes";
  for (int i = 0; i < (N - 1) / 2; i++) {
    if (S.at(i) != S.at(N - 1 - i)) {
      ans = "No";
      break;
    }
  }
  for (int i = 0; i < (N - 1) / 4; i++) {
    if (S.at(i) != S.at((N - 1) / 2 - 1 - i)) {
      ans = "No";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int a, b, c;
    cin >> a >> b >> c;
    if (b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    //cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/

int main(){
    ll a,b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
int main () {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=y;i>=x;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
//	ios::sync_with_stdio(false);
//	cin.tie(0);
const int maxx = 2e5+7;
const int maxn = 1e9+7;
typedef long long ll;
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
ll t,n;
ll a[5000];
int main(){
		ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	//ll m=100;
	a[0]=100;
	rept(i,1,3765){
		a[i]=a[i-1]+a[i-1]/100;
		//cout<<a[i]<<endl;
	}
	rept(i,1,3765){
		if(n==a[i]){
			cout<<i<<endl;
			return 0;
		}else if(n>a[i]&&n<a[i+1]){
			cout<<i+1<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3680
N=int(input())
C=[]
ans=0
for i in range(N):
    a,b=map(int,input().split())
    C+=[(a,b,a+b)]
C.sort(key=lambda x:x[2],reverse=True)
for i in range(N):
    if i%2==0:
        ans+=C[i][0]
    else:
        ans-=C[i][1]
print(ans)

Measured memory_bytes: 22136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i;
  cin >> N;
  string op[N];
  bool judge;
  
  judge = 0;

  for (i = 0; i < N; i++) {
    cin >> op[i];
    if (op[i] == "Y") judge = 1;
  }
  
  if (judge == 1) cout << "Four" << endl;
  else cout << "Three" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size()-2;i++){
    if(s[i]==s[i+1]&&s[i]==s[i+2]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            const int BuildingMaxValue = 4;
            const int FloorMaxValue = 3;
            const int RoomMaxValue = 10;
            var college = new int[BuildingMaxValue, FloorMaxValue, RoomMaxValue];
            string partition = new string('#', 20);
            var inputNum = int.Parse(Console.ReadLine());
            for (int i = 0; i < inputNum; i++)
            {
                var inputs = Console.ReadLine().Split(' ');
                var data = Array.ConvertAll(inputs, int.Parse);
                college[data[0] - 1, data[1] - 1, data[2] - 1]  += data[3];
            }

            for (int i = 0; i < BuildingMaxValue; i++)
            {
                for (int j = 0; j < FloorMaxValue; j++)
                {
                    for (int k = 0; k < RoomMaxValue; k++)
                    {
                        Console.Write(" {0}",college[i,j,k]);
                    }
                    Console.WriteLine();
                }
                if (i == 3) break;
                Console.WriteLine(partition);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 5716
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

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

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

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

	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'a') continue;
		if (k == 0) break;
		if (((int)'z' + 1) - (int)s[i] <= k){
			k -= ((int)'z' + 1) - (int)s[i];
			s[i] = 'a';
		}
	}

	if (k > 0){
		for (int i = 0; i < k % 26; i++){
			if (s[s.size() - 1] == 'z'){
				s[s.size() - 1] = 'a';
			} else {
				s[s.size() - 1]++;
			}
		}
	}

	cout << s << endl;
} 


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

#define SORT(c) sort((c).begin(), (c).end())

int main(void){
	string S;
	cin >> S;
	SORT(S);
	string out = "yes";
	for(int i=0; i<S.size()-1; i++){
		if(S[i]==S[i+1]){
			out = "no";
			break;
		}
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n, i, s;

	scanf("%d", &n);

	s = 100000;

	for (i = 0; i < n; i++){
		s = s * 1.05;
		if (s % 1000 != 0){
			s = (s / 1000 + 1) * 1000;
		}
	}	

	printf("%d\n", s);

	return (0);
}

Measured memory_bytes: 592
#include <stdio.h>
#include <string.h>
char a[2][1010], b[1010][40];
const char* str="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(void)
{
    int n, m, q;
    while (scanf("%d%d%d", &n, &m, &q), n) {
        int i, j, k=0;
        memset(a, '0', sizeof(a));
        memset(b, 1, sizeof(b));
        while (q--) {
            char s[60];
            scanf("%s%s", s, a[k]);
            for(i=0;i<n;++i) for(j=0;j<m;++j)
                if ((a[k][j]==a[1-k][j])==(s[i]=='1')) b[j][i]=0;
            k=1-k;
        }
        for(i=0;i<m;++i) {
            int p=0, res;
            for(j=0;j<n;++j) if (b[i][j]==1) { ++p; res=j; }
            putchar(p==1?str[res]:'?');
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int X, Y;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> X >> Y;

  int ans = 0;
  if (X == 1) {
    ans += 300000;
  } else if (X == 2) {
    ans += 200000;
  } else if (X == 3) {
    ans += 100000;
  }
  if (Y == 1) {
    ans += 300000;
  } else if (Y == 2) {
    ans += 200000;
  } else if (Y == 3) {
    ans += 100000;
  }

  if (X == 1 && Y == 1) {
    ans += 400000;
  }

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  int A[7]={1,3,5,7,8,10,12};
  int B[4]={4,6,9,11};
  int C[1]={2};
  for(int i=0;i<=6;i++){
  
    if(x==A[i]){
    
      for(int j=i+1;j<=6;j++){
      
        if(A[j]==y){
        
          cout<<"Yes";
          return 0;
        }
      }
    }
  }
  for(int i=0;i<=3;i++){
  
    if(x==B[i]){
    
      for(int j=i+1;j<=3;j++){
      
        if(B[j]==y){
        
          cout<<"Yes";
          return 0;
        }
      }
    }
  }
  if(x==2&&y==2){
  
    cout<<"Yes";
    return 0;
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3608