akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	string	s,key="keyence";
	cin>>s;
	bool f=0;
	ll x=s.size();
	for(int i=0;i<=7;i++){
		if(s.substr(0,i)+s.substr(x-7+i,7-i)==key)f=1;
	}
	cout<<(f?"YES":"NO")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1
//有根树的表示,左子右兄弟表示法


struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u) {
    int c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";
    
    cout << "[";
    for (int i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

void dep(int u, int p) {
    D[u] = p;
    if (T[u].r != NIL) dep(T[u].r, p);
    if (T[u].l != NIL) dep(T[u].l, p + 1);
}

int main() {
    int l, p, v, d, r, c;
    cin >> n;
    for (int i = 0; i < n; i++) T[i].l = T[i].p = T[i].r = NIL;
    
    for (int i = 0; i < n; i++) {
        cin >> v >> d;
        for (int j = 0; j < d; j++) {
            cin >> c;
           if (j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[l].p = v;
        }
    }
   
    for (int i = 0; i < n; i++) {
        if (T[i].p == NIL) r = i;
    }
    
    dep(r, 0);
    for (int i = 0; i < n; i++) print(i);
    return 0;
}



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

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << "\n";
    
    return 0;
}

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

const int MAX_N = 2e5;
const int MOD = 1e9+7;

int N;
vector<vector<int>> to;

int black[MAX_N],white[MAX_N];
int dep[MAX_N];
bool visited[MAX_N];

void modtime(int &a, int &b){
  a %= MOD;
  b %= MOD;
  a = (a*b)%MOD;
}

void dfs(int a){
  
  black[a] = 1; white[a] = 1;
  
  for(auto u : to[a]){
    
    if( dep[u] <= dep[a] ){continue;}

    dfs(u);
    
    modtime(black[a],white[u]);
    int res = black[u]+white[u];
    modtime(white[a],res);
    
  }
  
  return ;
}
  
  

signed main(void){
  
  cin >> N;
  to.resize(N);
  for(int i = 1; i < N; i++){ 
    int x,y; cin >> x >> y;
    x--; y--;
    to[x].push_back(y);
    to[y].push_back(x);
  }

  //0を根とする木を考え、treeDP
  
  queue<int> Q;
  Q.push(0);
  visited[0] = true;
  
  while(!Q.empty()){
    
    int p = Q.front(); Q.pop();
    
    for(auto q : to[p]){
      if(visited[q]){ continue;}
      else{
        dep[q] = dep[p]+1;
        Q.push(q);
        visited[q] = true;
      }
    }
  }// while - Q
  
  dfs(0);
  
  cout << (black[0]+white[0])%MOD << endl;
  
  return 0;
}
  
    
  

Measured memory_bytes: 13056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
ll n,k;
ll r,s,p;
string t;

unordered_map<char,ll> cost;

char get_rev(char t){
	if( t == 's' ){ return 'r'; }
	if( t == 'p' ){ return 's'; }
	if( t == 'r' ){ return 'p'; }
}

void solve(){
	ll total = 0;
	for(int i=0; i<k; ++i){
		char prev = get_rev(t[i]);
		total += cost[prev];
		for(int j=i+k; j<n; j+=k){
			char should_be = get_rev(t[j]);
			if( should_be != prev ){
				total += cost[should_be];
				prev = should_be;
			}else{
				prev = '$';
			}
		}
	}
	cout<<total<<'\n';
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	cin>>r>>s>>p;
	cost['r'] = r;
	cost['s'] = s;
	cost['p'] = p;
	cin>>t;
	solve();

	return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
 
void output_remain(char mark, int *card)
{
    for(int i=0; i<13; i++){
        if(card[i] == 0)
            cout << mark << " " << i+1 << endl;
    }
}
 
int main()
{
    int total;
    char mark;
    int num;
    int sp[13]={0};
    int di[13]={0};
    int cr[13]={0};
    int ha[13]={0};
 
    cin >> total;
 
    for(int i=0; i<total; i++){
        cin >> mark >> num;
        num--;
        switch(mark){
        case 'S':
            sp[num] = 1;
            break;
        case 'D':
            di[num] = 1;
            break;
        case 'C':
            cr[num] = 1;
            break;
        case 'H':
            ha[num] = 1;
            break;
        }
    }
 
    output_remain('S', sp);
    output_remain('H', ha);
    output_remain('C', cr);
    output_remain('D', di);
    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

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

    int A, B, T;
    cin >> A >> B >> T;


    cout << T/A*B<< endl; 
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
const int N=2e5+1;
char s[N],t[N];
vector<int> S[26],T[26];
int main()
{
	scanf("%s",s+1);
	scanf("%s",t+1);
	register int len=strlen(t+1);
	for(register int i=1;i<=len;++i){
		S[t[i]-'a'].push_back(i);
		T[s[i]-'a'].push_back(i); 
	}
	for(register int i=0;i<26;++i) {
		register int sz=S[i].size();
		register char c;
		if(sz){
			c=s[S[i][0]];
			for(register int j=1;j<sz;++j){
				if(c!=s[S[i][j]]) return puts("No"),0;
			}
		}
		sz=T[i].size();
		if(sz) {
			c=t[T[i][0]];
			for(register int j=1;j<sz;++j){
				if(c!=t[T[i][j]]) return puts("No"),0;
			}
		}
	}
	return puts("Yes"),0;
}

Measured memory_bytes: 3072
using namespace std;
#define M_PI 3.1415926535897932384626433832795
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include <iostream>

int main() {
	string s,a;
	cin>>s;
	int  e=0;
	a=s;
	string c;
	for (int i = 0; i < s.length(); ++i) {
		if(s[i]=='0'){
			c.insert(e,"0");
			e++;
		}else if(s[i]=='1'){
			c.insert(e,"1");
			e++;
		}else{
			if (c[0]!='\0' ) {
				c.erase( e-1, 1 );
				e--;
			}else{

			}
		}
	}
	cout<<c<<endl;
}


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

using namespace std;
int main() {
    int n;
    int sum = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        sum += r-l+1;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

        static class TaskA {
                public void solve(int testNumber, InputReader in, PrintWriter out) {
                        String s = in.s();
                        String s1 = in.s();
                        String s2 = in.s();
                        out.println(s.charAt(0) + "" + s1.charAt(1) + "" + s2.charAt(2));
                }

        }

        static class InputReader {
                InputStream is;
                private byte[] inbuf = new byte[1024];
                public int lenbuf = 0;
                public int ptrbuf = 0;

                public InputReader(InputStream is) {
                        this.is = is;
                }

                private int readByte() {
                        if (lenbuf == -1) throw new InputMismatchException();
                        if (ptrbuf >= lenbuf) {
                                ptrbuf = 0;
                                try {
                                        lenbuf = is.read(inbuf);
                                } catch (IOException e) {
                                        throw new InputMismatchException();
                                }
                                if (lenbuf <= 0) return -1;
                        }
                        return inbuf[ptrbuf++];
                }

                private boolean isSpaceChar(int c) {
                        return !(c >= 33 && c <= 126);
                }

                private int skip() {
                        int b;
                        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
                        return b;
                }

                public String s() {
                        int b = skip();
                        StringBuilder sb = new StringBuilder();
                        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
                                sb.appendCodePoint(b);
                                b = readByte();
                        }
                        return sb.toString();
                }

        }
}



Measured memory_bytes: 20948
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,k;
	cin>>n>>k;
	vector <ll> v(n);
	for(ll i=0;i<n;i++)
	{
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	bool check[k+1];
	memset(check,false,sizeof check);
	check[0]=1;
	for(int i=1;i<=k;i++)
	{
		for(int j=0;j<v.size();j++)
		{
			if(v[j]>i)
			break;
			if(v[j]==i)
			{
				check[i]=true;
			}
			else
			check[i]=check[i] or !check[i-v[j]];
		}
		//cout<<i<<" "<<check[i]<<endl;
	}
	if(check[k])cout<<"First"<<endl;
	else cout<<"Second"<<endl;
} 

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
    char buffer[10];
    int H, W, h, w;
    if (fgets(buffer, 10, stdin) != NULL) {
        H = atoi(strtok(buffer, " "));
        W = atoi(strtok(NULL, " "));
    } else {
        return 1;
    }
    if (fgets(buffer, 10, stdin) != NULL) {
        h = atoi(strtok(buffer, " "));
        w = atoi(strtok(NULL, " "));
    } else {
        return 1;
    }
    printf("%d\n",(H*W)-(h*W+(H-h)*w));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
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)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int X;
    while (cin >> X) {
        if (X < 30) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

















Measured memory_bytes: 3616
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int d[10010];

int main()
{
	int n,x;
	cin >> n >> x;
	vi l(n);
	rep(i,n) cin >> l[i];

	int sum = 1;
	for(int i = 1; i <= n; i++){
		d[i] = d[i-1]+l[i-1];
		if(d[i] <= x) sum++;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define error(...) 42;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;
 
int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  int x;
  cin>>x;
  if(x==1){
    cout<<0<<"\n";
  }else{
    cout<<1<<"\n";
  }
}

Measured memory_bytes: 3644
N=int(input())

def IsPrime(A):
    prime=[2]
    for a in range(3,A+1):
        for p in prime:
            if a%p==0:
                break
        else:
            prime.append(a)
    return prime


prime=IsPrime(N)
#print(prime)
pcount={}
for p in prime:
    pcount[p]=0
for nn in range(2,N+1):
    for p in prime:
        n=nn
        if n<p:
            break
        while n%p==0:
            n//=p
            pcount[p]+=1
#print(pcount)
mcount={}
for i in [75,25,15,5,3]:
    mcount[i]=0
for p in prime:
    for i in [75,25,15,5,3]:
        if pcount[p]>=i-1:
            mcount[i]+=1
#print(mcount)
print(mcount[75]+\
        mcount[25]*(mcount[3]-1)+\
        mcount[15]*(mcount[5]-1)+\
        mcount[5]*(mcount[5]-1)//2*(mcount[3]-2))
#75/25*3/15*5/5*5*3


Measured memory_bytes: 3064
#include <iostream>

using namespace std;
int main()
{
	int H,W,i,j,tmp[110],check[110];
	char a[110][110];
	cin >> H >> W;
	for(i=0; i<H; i++){
		check[i] = 0;
	}
	for(j=0; j<W; j++){
		tmp[j] = 0;
	}
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			cin >> a[i][j];
			if(a[i][j] == '#'){
				tmp[j] = 1;
				check[i] = 1;
			}
		}
	}
	/*for(j=0; j<H; j++){
		for(i=0; i<W; i++){
			if(a[i][j] == '#')
				check[i] = 1;
		}
	}*/
	for(i=0; i<H; i++){
		while(i<H){
			if(check[i] == 1)
				break;
			i++;
		}
		for(j=0; j<W; j++){
			while(j < W){
				if(tmp[j] == 1)
					break;
				j++;
			}
			if(j == W || i == H)
				break;
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
from collections import deque
def main():
    K = int(input())
    l = deque([i for i in range(1,10)])
    for i in range(K):
        t = l.popleft()
        u = t % 10
        if u != 0:
            l.append(t * 10 + u - 1)
        l.append(t*10 + u)
        if u != 9:
            l.append(t*10 + u + 1)
    return t
print(main())


Measured memory_bytes: 11972
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
 
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
const int N = 405;

bool req[N][N];
bool can[N];

int main(){
    fastIO;
    int n, m;
    cin >> n >> m;
    int u[m], v[m];
    for(int i = 0 ; i < m ; i ++ )
        cin >> u[i] >> v[i];
    for(int i = 1; i <= n ; i++ ){
        req[i][i] = true;
        can[i] = true;
        for(int j = m - 1; j >= 0 ; j -- ){
            if(req[i][u[j]]){
                if(req[i][v[j]]){
                    can[i] = false;
                }
                else{
                    req[i][v[j]] = true;
                }
            }
            else if(req[i][v[j]]){
                req[i][u[j]] = true;
            }
        }
    }
    int res = 0;
    bool ok;
    for(int i = 1; i <= n; i ++ ){
        for(int j = i + 1; j <= n; j ++ ){
            if(can[i] && can[j]){
                ok = true;
                for(int z = 1; z <= n; z ++ ){
                    if(req[i][z] && req[j][z])
                        ok = false;
                }
                if(ok)
                    res ++ ;
            }
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 1152
import sys
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	n=II()
	A=LI()
	B=[0]*(n+1)
	ans=1
	B[0]=3

	for i in range(n):
		ans*=(B[A[i]])-(B[A[i]+1])
		ans%=10**9+7
		B[A[i]+1]+=1

	print(ans)








if __name__ == "__main__":
	main()


Measured memory_bytes: 20596
from math import *

n = int(input()) - 1
c = [0] * n
s = [0] * n
f = [0] * n
for i in range(n):
  c[i], s[i], f[i] = map(int, input().split())
  
for i in range(n):
  a = s[i] + c[i]
  for j in range(i + 1, n):
    if a <= s[j]:
      a = s[j] + c[j]
    else:
      a = s[j] + f[j] * ceil((a-s[j])/f[j]) + c[j]
  print(a)
print(0)

Measured memory_bytes: 9156
# 2019-11-11 16:07:35(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

shichigosan = '357'

def main():

    n = int(sys.stdin.readline().rstrip())
    
    count = 0
    for i in range(3, len(str(n)) + 1):
        sub_shichigosan = list(''.join(s) for s in itertools.product(shichigosan, repeat=i))
        for sub in sub_shichigosan:
            for d in shichigosan:
                if d in sub:
                    continue
                else:
                    break
            else:
                if 357 <= int(sub) <= n:
                    count += 1
    
    print(count)

if __name__ == "__main__":
    main()


Measured memory_bytes: 4980
// https://atcoder.jp/contests/abc157/tasks/abc157_b

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int A_IJ_MAX = 100;
const int N_MAX = 10;
const int B_I_MAX = 100;

vector<vector<int>> A;
int N;
vector<int> b;

vector<bool> f;

int main() {
  A = vector<vector<int>>(3, vector<int>(3));
  REP(i, 3) REP(j, 3) cin >> A[i][j];
  cin >> N;
  b = vector<int>(N);
  REP(i, N) cin >> b[i];

  f = vector<bool>(A_IJ_MAX + 1, false);
  REP(i, N) f[b[i]] = true;

  bool cond = false;
  bool bingo;
  REP(i, 3) {
    bingo = true; REP(j, 3) bingo &= f[A[i][j]];
    if (bingo) cond = true;
  }
  REP(i, 3) {
    bingo = true; REP(j, 3) bingo &= f[A[j][i]];
    if (bingo) cond = true;
  }
  bingo = true; REP(i, 3) bingo &= f[A[i][i]];
  if (bingo) cond = true;
  bingo = true; REP(i, 3) bingo &= f[A[i][2 - i]];
  if (bingo) cond = true;

  cout << (cond ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i, n,m;
	int a = 0, b = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &m);
		if (m % 4 == 0)
		{
			b++;
		}
		else if (m % 2 == 0)
		{
			a++;
		}
	}
	if ((n  -1 - b) <=  b&&a==0)
	{
		printf("Yes\n");
	}
else if ((n  -a) <= 2 * b&&a!=0)
	{
		printf("Yes\n");
	}

	else 
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
# https://atcoder.jp/contests/abc138/tasks/abc138_d

from collections import defaultdict
import sys
sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, q = input_int_list()
    cnt = [0] * (n + 1)  # 1-indexed
    tree = defaultdict(list)

    for _ in range(n - 1):
        a, b = input_int_list()
        tree[a].append(b)
        tree[b].append(a)

    # 遅延評価をする O(q)
    for _ in range(q):
        p, x = input_int_list()
        cnt[p] += x

    # 遅延評価（DFS）O(n)
    stack = [(1, 0)]
    visited = set([1])
    while stack:
        e, add = stack.pop()
        cnt[e] += add
        for node in tree[e]:
            if node not in visited:
                visited.add(node)
                stack.append((node, cnt[e]))

    print(" ".join([str(i) for i in cnt[1:]]))
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 170564
import java.util.Scanner;

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

		int k,x;

		Scanner sc = new Scanner(System.in);

		k = sc.nextInt();
		x = sc.nextInt();

		int a = k-1;

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

			System.out.print(x - a + i + " ");

		}

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

			if (i != a) {
				System.out.print(x + i + " ");
			} else {
				System.out.print(x + i);
			}

		}

	}
}


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

odd = [a[i] for i in range(n) if i % 2 == 0]
even = [a[i] for i in range(n) if i % 2 == 1]

if n % 2 == 1:
   b = odd[::-1]
   b.extend(even)
else:
   b = even[::-1]
   b.extend(odd)
print(*b)


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

int main() {
  int N;cin >>N; // ページ数
  int Ans=0;     // 答え：枚数

  if ( N % 2 == 0 ) {
    Ans = N/2;
  } else {
    Ans = N/2+1;
  }

  cout << Ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

long long bins (long long k, long long l, long long r){
    long long q = (r+l) / 2;
    long long qq = r * r;
    //cout << l << ' ' << r << '\n';
    if (r - l <= 1){
        if (qq >= k){
            return l;
        }
        else{
            return r;
        }
    }
    else{
        qq = q*q;
        if (qq >= k){
            return bins (k, l, q-1);
        }
        else {
            return bins (k, q, r);
        }
    }
}

int main() {
    long long n,a,b;
    cin >> n;
    vector <long long> ans;
    for (int i = 0; i<n; i++){


        cin >> a >> b;
        long long k = min (a,b);
        long long q = max (a,b);
        a = k;
        b = q;
        if (b - a <= 1){
            ans.push_back(2*(a-1));
            //cout << 2*(a-1) << '\n';
        }
        else{
            k = a*b;
            q = bins (k, a, b);
            long long ss = min (a,b);
            long long k1, k2;
            k2 = 2*(ss-1);
            k1 = 2*(ss-1);
            k1 += 2*(q - a);
            if (q * (q+1) < k){
                k2 += 2 * (min ((q-a),(b-q-1)) + 1) - 1;
            }
            ss = max(k1, k2);
            ans.push_back(ss);
            //cout << ss << '\n';
        }
    }
    for (int i = 0; i<ans.size(); i++){
        cout << ans[i] << '\n';
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  map<string,int> c;
  for(int i=0;i<N;i++){
    cin >> S.at(i);
    if(c.count(S.at(i)))
      c[S.at(i)]++;
      else
        c[S.at(i)]=1;
  }
    cout << c.size() << endl; 
}


Measured memory_bytes: 25140
#include <iostream>
using namespace std;
void ABC140(void);
void ABC141(void);
void ABC142(void);
void ABC143(void);
void ABC144(void);
void ABC145(void);
void ABC146(void);
void ABC147(void);
void ABC148(void);
void ABC149(void);

int main(void){
    ABC142();
}

void ABC142(){
    int n;
    double ans;
    cin>>n;
    ans=(double)n;
    if(n%2==0)ans=0.5;
    else ans=(ans+1)/(2*ans);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
    // 標準入力
    int n, d;
    cin >> n >> d;

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

    // 距離計算
    int dis, res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            dis = 0;
            for (int k = 0; k < d; k++) dis += (y[i][k] - y[j][k]) * (y[i][k] - y[j][k]);
            
            // sqrt()は浮動小数なので、整数にキャストしたものとの差を取って0であれば２乗数といえる
            if (sqrt(dis) - (int)sqrt(dis) == 0) res++;
        }   
    }
    cout << res << endl;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
h.append(0)
ans = 0
while h.count(0) < N+1:
  count = 0
  for i in range(N+1):
    if h[i] > 0:
      count += 1
      h[i] -= 1
    else:
      if count > 0:
        ans += 1
      count = 0
print(ans)

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e5;
const num inf = 0x3f3f3f3f3f3f3f3f;
int n, m;
num ans;
pair< pair<int, int>, int > dat[nsz + 5];

struct segment_tree {
#define ls (u << 1)
#define rs (u << 1 | 1)
	num mn[4 * nsz + 5], del[4 * nsz + 5];
	
	void inline down(int u) {
		if (del[u] == inf)  return;
		mn[ls] = min(mn[ls], del[u]), mn[rs] = min(mn[rs], del[u]);
		del[ls] = min(del[ls], del[u]), del[rs] = min(del[rs], del[u]);
		del[u] = inf;
	}
	
	void init(int u = 1, int l = 1, int r = n) {
		mn[u] = del[u] = inf;
		if (l == r)  return;
		int md = (l + r) >> 1;
		init(ls, l, md);
		init(rs, md + 1, r);
	}
	
	void upd(int el, int er, num val, int u = 1, int l = 1, int r = n) {
		if (l >= el && r <= er) {
			mn[u] = min(mn[u], val);
			del[u] = min(del[u], val);
			return;
		}
		down(u);
		int md = (l + r) >> 1;
		if (el <= md) {
			upd(el, er, val, ls, l, md);
		}
		if (er >= md + 1) {
			upd(el, er, val, rs, md + 1, r);
		}
		mn[u] = min(mn[ls], mn[rs]);
	}
	
	num qry(int el, int er, int u = 1, int l = 1, int r = n) {
		if (l >= el && r <= er)  return mn[u];
		down(u);
		int md = (l + r) >> 1;
		num res = inf;
		if (el <= md) {
			res = qry(el, er, ls, l, md);
		}
		if (er >= md + 1) {
			res = min(res, qry(el, er, rs, md + 1, r));
		}
		return res;
	}
};
segment_tree tr;

int main() {
	scanf("%d%d", &n, &m);
	cont (i, m) {
		int l, r, w;
		scanf("%d%d%d", &l, &r, &w);
		dat[i] = make_pair(make_pair(l, r), w);
	}
	sort(dat + 1, dat + m + 1);
	tr.init();
	tr.upd(1, 1, 0);
	int it = 1;
	cont (u, n) {
		for (; dat[it].first.first == u; ++it) {
			int l = dat[it].first.first, r = dat[it].first.second, w = dat[it].second;
			tr.upd(l, r, tr.qry(l, r) + w);
		}
	}
	ans = tr.qry(n, n);
	ans = ans == inf ? -1 : ans;
	printf("%lld\n", ans);
}

Measured memory_bytes: 7552
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

int main(void)
{
    int N;
    cin >> N;
    pair<int, int> pair;
    
    vector<int> A(N);
    vector<int> B(N);
    for (int i = 0; i < N; i ++) {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(), B.end(), greater<int>());
    
    for (int i = 0; i < N; i ++) {
        if (A[i] == B[0]) {
            cout << B[1] << endl;
        } else {
            cout << B[0] << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>

using namespace std;

int main() {
    class Dice {
        public:
            int men[6];
            void setMen(int i, int value) {men[i] = value;}
            void getMen() {cout << men[0] << endl;}
            void SwitchMen (char Alpha) {
                switch (Alpha) {
                    case 'S':
                        ChangeMen(men[4], men[0], men[2], men[3], men[5], men[1]);
                        break;
                    case 'N':
                        ChangeMen(men[1], men[5], men[2], men[3], men[0], men[4]);
                        break;
                    case 'E':
                        ChangeMen(men[3], men[1], men[0], men[5], men[4], men[2]);
                        break;
                    case 'W':
                        ChangeMen(men[2], men[1], men[5], men[0], men[4], men[3]);
                        break;
                }
            }
            void ChangeMen (int tmp1, int tmp2, int tmp3, int tmp4, int tmp5, int tmp6) {
                men[0] = tmp1;
                men[1] = tmp2;
                men[2] = tmp3;
                men[3] = tmp4;
                men[4] = tmp5;
                men[5] = tmp6;
            }
    };
    Dice dice;
    for(int i = 0; i < 6; i++) {
        int tmp;
        cin >> tmp;
        dice.setMen(i, tmp);
    }
    char Alpha;
    while(cin >> Alpha) {
        dice.SwitchMen(Alpha);
    }

    dice.getMen();

    // for(int i = 0; i < 6; i++) {
    //     cout << dice.men[i] << endl;
    // }

    return 0;
}


Measured memory_bytes: 3084
n, d = map(int, input().split())

line = []
for i in range(n):
    line.append(list(map(int, input().split())))

cnt = 0

for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (line[i][k] - line[j][k]) ** 2
        if (tmp ** (1/2)) % 1 == 0:
            cnt += 1

print(cnt)


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

int main(){
  int N,T;
  cin >>N>>T;
  
  int c,t;
  int ans = 10000;
  rep(i,1,N){
    cin >>c>>t;
    if(t<=T) ans=min(ans,c);
  }
  if(ans==10000){
    cout <<"TLE"<< endl;
    return 0;
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 256
x = int(input())

ans = 0

for _ in range(10**5):
    if x == 2:
        print(x)
        break
    for i in range(2, int(x**0.5) + 1):
        if (x % i) == 0:
            break
        elif i == int(x**0.5): # ループの最後
            ans = x
        else:
            pass

    if ans != 0:
        print(ans)
        break
    else:
        x += 1


Measured memory_bytes: 3060
N = int(input())
S = input()

tem = S[1:].count("E")
ans = min(N,tem)

for i in range(1,N) :
    if S[i] == "E" :
        tem -= 1
    if S[i-1] == "W" :
        tem += 1
    ans = min(ans,tem)

print(ans)


Measured memory_bytes: 3676
#include<stdio.h>
int main(void){

  int n,a,i=0,sum=0;

  while(1){
    scanf("%d",&n);
    if(n==0)break;
    
    for(i=n/4;i>0;i--)
      { 
	scanf("%d",&a);
	//	printf("%d\n",a);
	sum += a;
      }
    // printf("a:%d\n",a);
    
    printf("%d\n",sum); 
    sum=0; 
  }
  
  return 0;
}

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

#define SAFE_DELETE( x ) { if ( x ){ delete x; x = NULL; } }

class Vector2{
public:
	Vector2() : x( 0 ), y( 0 ), round( false ), check( false ), prev( NULL ), next( NULL ){}
	Vector2( double aX, double aY ) : round( false ), check( false ), prev( NULL ), next( NULL ){
		x = aX;
		y = aY;
	}

	void operator=( Vector2& a ){
		x = a.x;
		y = a.y;
	}

	bool round, check;
	double x, y;
	Vector2 *prev, *next;
};

class VecList{
public:
	VecList() : mSize( 0 ), head( NULL ), tail( NULL ){
		head = new Vector2;
		tail = new Vector2;
		head->next = tail;
		tail->prev = head;
	}
	~VecList(){
		init();
		SAFE_DELETE( tail );
		SAFE_DELETE( head );
	}

	void init(){
		for ( int i = mSize; i > 0; --i ){
			Vector2* a = tail->prev;
			a->prev->next = a->next;
			a->next->prev = a->prev;
			SAFE_DELETE( a );
		}
		mSize = 0;
	}
	void pushBack( Vector2 v ){
		Vector2* a = new Vector2( v.x, v.y );
		a->prev = tail->prev;
		a->next = tail;
		a->prev->next = a;
		a->next->prev = a;
		++mSize;
	}
	int cntInner(){
		int cnt = 0;
		Vector2 *it = head, *a = head->next, *start;
		for ( int i = 0; i < mSize; ++i ){
			it = it->next;
			if ( a->x > it->x ) a = it;
		}
		start = a;

		Vector2* b = head->next;
		if ( b == a ) b = b->next;
		do {
			it = head;
			for ( int i = 0; i < mSize; ++i ){
				it = it->next;
				if ( it == a || it == b ) continue;
				if ( cross( a, b, it ) < 0 ){
					b = it;
				}
			}
			Vector2* t = a;
			a = b;
			b = t;
			++cnt;
		}while ( !( a == start ) );

		return mSize - cnt;
	}

private:
	double cross( Vector2* a, Vector2* b, Vector2* c ){
		return ( b->x - a->x ) * ( c->y - a->y ) - ( b->y - a->y ) * ( c->x - a->x );
	}
	int mSize;
	Vector2 *head, *tail;
};

int main(){
	int n;
	char c;
	VecList list;

	while ( cin >> n && n ){
		list.init();
		Vector2 a;
		for ( int i = 0; i < n; ++i ){
			cin >> a.x >> c >>a.y;
			list.pushBack( a );
		}

		cout << list.cntInner() << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
  int ans = 0, op = 1;
  for(int i = 0; ; i++){
    string c;
    cin >> c;
    if(c == "=") break;
    switch(c[0]){
      case '+': op = 1; break;
      case '-': op = 2; break;
      case '*': op = 3; break;
      case '/': op = 4; break;
    default:
      int x = atoi(c.c_str());
      switch(op){
      case 1: ans += x; break;
      case 2: ans -= x; break;
      case 3: ans *= x; break;
      case 4: ans /= x; break;
      }
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1196
import queue
n,m = map(int, input().split())
V = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int, input().split())
    V[a].append(b)
    V[b].append(a)
ans = [-1]*(n+1)
q = queue.Queue()
q.put(1)
while not q.empty():
    p = q.get()
    for c in V[p]:
        if c > 1 and ans[c] < 0:
            ans[c] = p
            q.put(c)
print('Yes')
for x in ans[2:]: print(x)


Measured memory_bytes: 35108
#include<stdio.h>
#include<string.h>
int Min(int x,int y){return x<y?x:y;}
int m[22][22],h,w;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int F(int n,int ax,int ay)
{
	if(n>9)return 99;
	int res=99,i,x,y;
	for(i=0;i<4;++i)
	{
		x=ax+dx[i],y=ay+dy[i];
		if(m[y][x]==1)continue;
		for(;1<=x&&x<=w&&1<=y&&y<=h;x+=dx[i],y+=dy[i])
		{
			if(m[y][x]==3)return 1;
			if(m[y][x]==1)
			{
				m[y][x]=0;
				res=Min(res,F(n+1,x-dx[i],y-dy[i])+1);
				m[y][x]=1;
				break;
			}
		}
	}
	return res;
}
int main()
{
	int i,j,t,x,y;
	while(scanf("%d%d",&w,&h),w)
	{
		memset(m,0,sizeof(m));
		for(i=1;i<=h;++i)for(j=1;j<=w;++j)
		{
			scanf("%d",&t);
			if(t-2)m[i][j]=t;
			else x=j,y=i;
		}
		t=F(0,x,y);
		if(t>10)t=-1;
		printf("%d\n",t);
	}
	return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  
  double ans=0;
  for(int i=1; i<n+1; i++){
    double pb=1;
    int count=i;
    while(count<m){
      count*=2;
      pb*=0.5; 
    }
    
    
    ans+=pb;
  }
  
  ans/=n;
  
  cout << fixed << setprecision(10) << ans << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int fsz(ll n){
  int res = 0;
  while(n != 0){
    res++;
    n /= 10;
  }
  return res;
}

int main(){
  ll n;
  cin >> n;
  int ans = 1001001001;
  for(ll i = 1; i*i <= n; i++){
    if(n % i != 0) continue;
    ll j = n/i;
    ans = min(ans, max(fsz(i), fsz(j)));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
def divisors(N):
    return sorted(sum((list({n, N // n}) for n in range(1, int(N ** 0.5) + 1) if not N % n), []), reverse=True)
N, K = map(int, input().split())
A = tuple(map(int, input().split()))
D = divisors(sum(A))
for d in D:
    L = sorted(a % d for a in A)
    if not sum(L):
        print(d)
        break
    left, right = 0, N - 1
    count = 0
    while left < right:
        if L[left] + L[right] <= d:
            next_right = right - (L[right] + L[left] == d)
            next_left = left + 1
            L[right] += L[left]
            count += L[left]
            L[left] = 0
        else:
            next_left = left
            next_right = right - 1
            m = d - L[right]
            count += m
            L[right] += m
            L[left] -= m
        left, right = next_left, next_right
    if count <= K:
        print(d)
        break

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
	
	int a[7],b;
	char D[101];
	
	for(int i=0;i<6;i++){
		
		scanf("%d",&a[i]);
	}
	scanf("%s",D);
	
	for(int i=0;D[i]!='\0';i++){
		
		b=a[0];
		if(D[i]=='E'){
			a[0]=a[3];
			a[3]=a[5];
			a[5]=a[2];
			a[2]=b;
		}
		else if(D[i]=='N'){
			a[0]=a[1];
			a[1]=a[5];
			a[5]=a[4];
			a[4]=b;
		}
		else if(D[i]=='S'){
			a[0]=a[4];
			a[4]=a[5];
			a[5]=a[1];
			a[1]=b;
		}
		else if(D[i]=='W'){
			a[0]=a[2];
			a[2]=a[5];
			a[5]=a[3];
			a[3]=b;
		}
	}
	printf("%d\n",a[0]);
	return 0;
}

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

int main() {
    int K;
    cin >> K;
    int a = 0;
    for(int i = 2; i <= K; i += 2) {
        for(int j = 1; j <= K; j += 2) {
            a++;
        }
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define eni(x) template < class c > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; return * this; }
eni(==) return * this << range(begin(i), end(i)); }
template < class c, class b > debug & operator <<(pair < b, c > d) {
  return * this << "(" << d.first << ", " << d.second << ")";
}
template < class c > debug & operator <<(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  return * this << "]";
}
#else
template < class c > debug & operator <<(const c&) { return * this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000050
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=max(b*d,a*c);
    ans=max(b*c,ans);
    ans=max(a*d,ans);
    if(b<0 && c>0) cout<<b*c<<endl;
    else if(a>0 && d<0) cout<<a*d<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n - 1)]
px = [list(map(int, input().split())) for _ in range(q)]

neigh = {}

ans = [0] * n
#print(neigh)
#print(neigh)

for i in range(q) :
    ans[px[i][0] - 1] += px[i][1]

for i in range(n - 1) :
    neigh.setdefault(ab[i][0], []).append(ab[i][1])

sortKey = sorted(neigh.keys())

for k in sortKey :
    for e in neigh[k] :
        ans[e - 1] += ans[k - 1]

print(*ans)

'''
    ans[sortKey]

for i in range(len(sortKey)) :
    for j in range(i + i, len(sortKey)) :
        if sortKey[i] in neigh[sortKey[j]] :
            neigh[sortKey[j]] += neigh[sortKey[i]]
            break

    if px[i][0] in neigh :
        for e in neigh[px[i][0]] :
            ans[e - 1] += px[i][1]


print(*ans)
'''


Measured memory_bytes: 140068
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
int main(){
    fast_io

    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    a-=1;
    ll ans=b-b/c-b/d+b/(c*d/gcd(c,d));
    ll ans2=a-a/c-a/d+a/(c*d/gcd(c,d));
    cout<<ans-ans2<<endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, M;
  cin >> N >> M;
  ll ans;
  if(N * 2 >= M) {
    ans = M / 2;
  } else {
    ans = N;
    M = M - N * 2;
    ans += M / 4;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;

string f(string b, int c){
  string res;
  rep(i, c) res += b[i];
  res += (char)b[c] + 1;
  for (int i = c+1; i < b.size(); i++){
    int back = res.back() - '0';
    char nr;
    if (back) nr = (char)(back - 1) + '0'; 
    else nr = '0';
    res += nr;
  } 
  return res;
}


int main(){
  int k;
  cin >> k;
  vector<string> d(100001);
  rep(i, 10) d[i] = i + '0';
  d[10] = "10";
  for (int i = 11; i <= 100000; i++){
    string s = d[i-1];
    int n = s.size();
    int c = -1;
    for (int j = 1; j < n; j++){
      if (s[j] <= s[j-1] && s[j] != '9') c = j;
    }
    string now;
    if (c == -1){
      if (s[0] == '9') {
        now = "1";
        rep(j, n) now += '0';
      } else {
        c = 0;
        now = f(s, c);
      }
    } else {
      now = f(s, c);
    }
    d[i] = now;
  }
  cout << d[k] << endl;
}

Measured memory_bytes: 6912
N = int(input())
a = []
b = []
for i in range(N):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)
a = sorted(a)
b = sorted(b)

if N % 2 == 1:
    ans_mi = a[N//2]
    ans_ma = b[N//2]
    print(ans_ma-ans_mi+1)
else:
    ans_mi = (a[N//2]+a[N//2-1])/2
    ans_ma = (b[N//2]+b[N//2-1])/2
    ans=(ans_ma-ans_mi)//0.5+1
    print(int(ans))


Measured memory_bytes: 27144
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

int n, x, y;
pair<int, int> xy = make_pair(x, y);
vector<int> done(n), dist(n);

void dfs(int i, int j) {
    if (i < 0 || n <= i) return;
    if (done[i] == 1 && j > dist[i]) return;
    done[i] = 1;
    dist[i] = j;
    dfs(i - 1, j + 1);
    dfs(i + 1, j + 1);
    if (i == x - 1) dfs(y - 1, j + 1);
    if (i == y - 1) dfs(x - 1, j + 1);
}

int main(void) {
    cin >> n >> x >> y;
    done.resize(n);
    dist.resize(n);
    vector<int> mindist(n, 0);
    rep(i, n) {
        rep(j, n) done[j] = 0;
        dfs(i, 0);
        rep(j, n) mindist[dist[j]]++;
    }
    rep(k, n) {
        if (k == 0) continue;
        cout << mindist[k] / 2 << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int a,b;
  cin >> a>>b;
  cout << (a-1)*(b-1) << endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

int main(void){
    int x,y;
    cin>>x>>y;
    int ans=1+x+y-gcd(x,y);
    cout<<ans<<endl;
}





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

int N;
multiset <int> S;

int get(int x) {
	int res = 1;
	while (res <= x)
		res *= 2;
	return res;
}

int main() {
	scanf("%d", &N);
	while (N--) {
		int x;
		scanf("%d", &x);
		S.insert(x);
	}
	
	int ans = 0;
	while (!S.empty()) {
		int x = *S.rbegin();
		S.erase(S.find(x));
		if (S.empty())
			break;
		int pot = get(x);
		auto it = S.find(pot - x);
		if (it != S.end()) {
			S.erase(it);
			ans++;
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
using namespace std;
using ll = long long ;
ll mod = 998244353 ;

ll modpow(ll a,ll b){
	ll res = 1 ;
	while(b>0){
		if(b&1) res = res*a%mod ;
		b >>= 1 ;
		a = a*a%mod ;
	}
	return res ;
}

int main(){
	ll n ; cin >> n ;
	vector<ll> d(n) ;
	for(int i=0;i<n;i++){
		ll x ; cin >> x ;
		if(i==0&&x!=0){
			cout << 0 << endl ;
			return 0 ;
		}
		if(i!=0&&x==0){
			cout << 0 << endl ;
			return 0 ;
		}
		d.at(x)++ ;
	}
	bool ok = false ;
	for(int i=0;i<n;i++){
		if(ok){
			if(d.at(i)!=0){
				cout << 0 << endl ;
				return 0 ;
			}
		}else{
			if(d.at(i)==0) ok = true ;
		}
	}
	ll ans = 1 ;
	for(int i=1;i<n;i++){
		if(d.at(i)==0) break ;
		ans = ans*modpow(d.at(i-1),d.at(i))%mod ;
	}
	cout << ans << endl ;
}



Measured memory_bytes: 1024
import java.util.Scanner;

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

        String color1 = sc.next();
        sc.next();
        int color1Cnt = sc.nextInt();
        int color2Cnt = sc.nextInt();
        String disposed = sc.next();

        if (disposed.equals(color1)) {
            System.out.printf("%d %d", color1Cnt - 1, color2Cnt);
            return;
        }
        System.out.printf("%d %d", color1Cnt, color2Cnt - 1);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;
/*
const int SIZE = 1E5 + 9;
struct EDGES {
	int next, to, w;
} edge[SIZE << 1]; int cnt, head[SIZE];
int dep[SIZE], son[SIZE], top[SIZE], fa[SIZE], sze[SIZE];
int N, Tpos[SIZE], Ipos[SIZE], w[SIZE], Ind;
struct Node {
	int L, R, F; LL w, Lazy;
	Node() : F(Inf) {};
} Node[SIZE << 2];

void Add(int from, int to, int w) {
	edge[cnt].to = to; edge[cnt].w = w; edge[cnt].next = head[from]; head[from] = cnt++;
}

void FDFS(int now, int fat, int deep) {
	dep[now] = deep; fa[now] = fat; sze[now] = 1;
	for (int pos = head[now]; ~pos; pos = edge[pos].next)
		if (edge[pos].to != fat) {
			FDFS(edge[pos].to, now, deep + 1);
			w[edge[pos].to] = edge[pos].w;
			sze[now] += sze[edge[pos].to];
			if (sze[edge[pos].to] > sze[son[now]])
				son[now] = edge[pos].to;
		}
}

void SDFS(int now, int tops) {
	top[now] = tops; Tpos[now] = ++Ind; Ipos[Tpos[now]] = now;
	if (!son[now]) return;
	SDFS(son[now], tops);
	for (int pos = head[pos]; ~pos; pos = edge[pos].to)
		if (edge[pos].to != fa[now] && edge[pos].to != son[now])
			SDFS(edge[pos].to, edge[pos].to);
}

void BUILD(int now, int L, int R) {
	Node[now].L = L; Node[now].R = R;
	if (L == R) {
		Node[now].w = w[Ipos[L]]; return;
	}
	int Mid = (L + R) >> 1;
	BUILD(now << 1, L, Mid); BUILD(now << 1 | 1, Mid + 1, R);
	Node[now].w = max(Node[now << 1].w, Node[now << 1 | 1].w);
}

void Covpush(int now) {
	
}

void CovUpd(int now, int L, int R, LL w) {
	
}

int main() {
	scanf("%d", &N); memset(head, -1, sizeof head);
	for (int pos = 1, from, to, w; pos < N; pos++) {
		scanf("%d%d%d", &from, &to, &w); Add(from, to, w); Add(to, from, w);
	}
	FDFS(1, 0, 1); SDFS(1, 1);
}
*/

int main() {
	string str; cin >> str;
	str.erase(str.begin() + str.size() - 8, str.end());
	cout << str << endl;
}


Measured memory_bytes: 256