akhauriyash/Code-Regression huggingface dataset:
//Volume2-0228
import java.util.Scanner;

public class Main {

    //declare
	private static final int[][] bit = {{0,1,1,1,1,1,1},  // 0
		                                {0,0,0,0,1,1,0},  // 1
		                                {1,0,1,1,0,1,1},  // 2
		                                {1,0,0,1,1,1,1},  // 3
		                                {1,1,0,0,1,1,0},  // 4
		                                {1,1,0,1,1,0,1},  // 5
		                                {1,1,1,1,1,0,1},  // 6
		                                {0,1,0,0,1,1,1},  // 7
		                                {1,1,1,1,1,1,1},  // 8
		                                {1,1,0,1,1,1,1},  // 9
		                                {0,0,0,0,0,0,0}}; // initial state

    public static void main(String[] args) {

    	final int END  = -1,
    	          INIT = 10;
              int n,prev,num;

        //input
    	Scanner sc = new Scanner(System.in);
    	while((n = sc.nextInt()) != END){
    		prev = INIT;
    		for(int i=0;i<n;i++){
    			num = sc.nextInt();
    			for(int j=0;j<7;j++){

    		    	//calculate,output
    				System.out.print(bit[prev][j] ^ bit[num][j]);
    			}
    			System.out.println();
    			prev = num;
    		}
    	}
    }
}

Measured memory_bytes: 20652
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
seisuu = [0 for i in range(N+1)]
for i in range(N):
    seisuu[A[i]] += 1
        

seisuu.sort()
seisuu.reverse()
for i in range(K, N):
    ans += seisuu[i]
print(ans)


Measured memory_bytes: 25876
# 入力でビンゴが成立しているかを確かめる
def isBingo(bingocard, calledlist):
    # # まずヨコを確かめる
    # for eachline in bingocard:
    #     # 最初はフラグが立っている
    #     # ビンゴが成立しなかったらフラグを下ろす
    #     flg = True
    #     for eachcell in eachline:
    #         print(eachcell)
    #         if eachcell in calledlist:
    #             continue
    #         else:
    #             flg = False
    #             break
    #     if flg:
    #         return 'Yes1'

    # # つぎにタテを確かめる
    # for eachline in [list(x) for x in zip(*bingocard)]:
    #     # 最初はフラグが立っている
    #     # ビンゴが成立しなかったらフラグを下ろす
    #     flg = True
    #     for eachcell in eachline:
    #         if eachcell in calledlist:
    #             continue
    #         else:
    #             flg = False
    #             break
    #     if flg:
    #         return 'Yes2'

    # まずヨコを確かめる
    if bingocard[0][0] in calledlist and bingocard[0][1] in calledlist and bingocard[0][2] in calledlist:
        return 'Yes'
    if bingocard[1][0] in calledlist and bingocard[1][1] in calledlist and bingocard[1][2] in calledlist:
        return 'Yes'
    if bingocard[2][0] in calledlist and bingocard[2][1] in calledlist and bingocard[2][2] in calledlist:
        return 'Yes'
    # つぎにタテを確かめる
    if bingocard[0][0] in calledlist and bingocard[1][0] in calledlist and bingocard[2][0] in calledlist:
        return 'Yes'
    if bingocard[0][1] in calledlist and bingocard[1][1] in calledlist and bingocard[2][1] in calledlist:
        return 'Yes'
    if bingocard[0][2] in calledlist and bingocard[1][2] in calledlist and bingocard[2][2] in calledlist:
        return 'Yes'

    # 最後に斜めを確かめる
    if bingocard[0][0] in calledlist and bingocard[1][1] in calledlist and bingocard[2][2] in calledlist:
        return 'Yes'
    if bingocard[0][2] in calledlist and bingocard[1][1] in calledlist and bingocard[2][0] in calledlist:
        return 'Yes'
    else:
        return 'No'

# 入力を変数に入れる
l1 = [int(each) for each in input().split(' ')]
l2 = [int(each) for each in input().split(' ')]
l3 = [int(each) for each in input().split(' ')]
bingocard = [l1, l2, l3]

calledlist = []
for called in range(int(input())):
    calledlist.append(int(input()))

print(isBingo(bingocard, calledlist))

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

int main(){
  int N;
  cin >> N;
  string s,t,u;
  cin >> s >> t;
  u="";
  for(int i;i<N;i++){
    u = u + s.at(i) + t.at(i);
  }
  cout << u << endl;
}

Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
inline int  in(){int n;scanf("%lld",&n);return n;}
inline void out(int n){printf("%lld\n",n);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n;
vi vec;

signed main(){
    io();
    cin>>n;
    vec.resize(n);
    rep(i,n) cin>>vec[i];

    int ans=0;

    REP(i,1,n){
        if(vec[i]==vec[i-1]){
            ans++;
            i++;
        }
    }
    out(ans);

    return 0;
}


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

#define ll long long
#define ld long double
#define eb emplace_back
#define fi first
#define se second

using namespace std;

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	ll a, b, va, vb, t;
	cin >> a >> va >> b >> vb >> t;
	if (abs(a - b) <= t * (va - vb)) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
#ifdef LOCAL
	cout << setprecision(6) << fixed << (double) clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 3636
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)


N = int(input())
A = list(map(int, input().strip().split()))

gcd_l = [0] * N

gcd_l[0] = A[0]
for i in range(1, N):
    gcd_l[i] = gcd(gcd_l[i - 1], A[i])

gcd_r = [0] * N

gcd_r[N - 1] = A[N - 1]
for i in reversed(range(0, N - 1)):
    gcd_r[i] = gcd(gcd_r[i + 1], A[i])

gcd_lr = [0] * N

for i in range(N):
    if i == 0:
        gcd_lr[i] = gcd_r[i + 1]
    elif 1 <= i <= N - 2:
        gcd_lr[i] = gcd(gcd_l[i - 1], gcd_r[i + 1])
    elif i == N - 1:
        gcd_lr[i] = gcd_l[i - 1]

print(max(gcd_lr))


Measured memory_bytes: 14400
import java.util.*

tailrec fun isInclude3(n: Int): Boolean = when {
    (n == 0) -> false
    (n % 10 == 3) -> true
    else -> isInclude3(n / 10)
}

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    (1..n).forEach { i ->
        when {
            (i % 3) == 0 -> print(" " + i)
            isInclude3(i) -> print(" " + i)
        }
    }
    println()
}


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

int main() {
    int n;cin>>n;
    pair<int,int> a[n],b[n];
    for (int i=0;i<n+n;i++) {
        int x,y;
        cin>>x>>y;
        if (i<n)
            a[i]={y,x};
        else
            b[i-n]={x,y};
    }
    sort(a,a+n);
    sort(b,b+n);
    int used[n]{};
    int c=0;
    for (int i=0;i<n;i++)
        for (int j=n-1;j>=0;j--)
            if (!used[j]&&a[j].second<b[i].first&&a[j].first<b[i].second) {
                used[j]=1;
                c++;
                break;
            }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MOD=1e9+7;
ll H,W,T;
ll mpw(ll n,ll m){
	ll r=1;
	while(m){
		if(m&1){
			r*=n;
			r%=MOD;
		}
		n*=n;
		n%=MOD;
		m>>=1;
	}
	return r;
}
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll t1slv(ll h,ll w){
	ll ans=mpw(2,w)+MOD-2+mpw(2,h-1)+mpw(2,h-1);
	ll g=gcd(h,w);
	ans+=mpw(2,g)-1;
	ans%=MOD;
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>H>>W>>T;
	ll gh=gcd(H,T),gw=gcd(W,T);
	cout<<mpw(t1slv(H/gh,W/gw),gh*gw)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int h[200005];
int a[200005];
long long dp[200005];
long long seg[1000005];
int upd(int x, int l, int r, int pos, long long val) {
	if(l==r) {
		seg[x]=max(seg[x],val);
	} else {
		if(pos<=(l+r)/2) upd(x*2,l,(l+r)/2,pos,val);
		else upd(x*2+1,(l+r)/2+1,r,pos,val);
		seg[x]=max(seg[x*2],seg[x*2+1]);
	}
} 
long long qry(int x, int l, int r, int ql, int qr) {
	if(l==ql && r==qr) {
		return seg[x];
	} else {
		if(qr<=(l+r)/2) return qry(x*2,l,(l+r)/2,ql,qr);
		if(ql>(l+r)/2) return qry(x*2+1,(l+r)/2+1,r,ql,qr);
		else return max(qry(x*2,l,(l+r)/2,ql,(l+r)/2),qry(x*2+1,(l+r)/2+1,r,(l+r)/2+1,qr));
	}
}
int main() {
	scanf("%d",&n);
	for(int i=0; i<n; i++) scanf("%d",&h[i]);
	for(int i=0; i<n; i++) scanf("%d",&a[i]);
	long long ans=0;
	for(int i=0; i<n; i++) {
		if(h[i]>1)
		dp[i] = qry(1,1,n,1,h[i]-1);
		dp[i] += a[i];
		if(dp[i]>ans) ans=dp[i];
		upd(1,1,n,h[i],dp[i]);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int H, W;
  cin >> H >> W;
  int kyori = -1;
  vector<vector<char>> A(H + 1, vector<char>(W + 1));
  REP(i, H) REP(j, W) {
    cin >> A[i][j];
    if (A[i][j] == '#') kyori++;
  }
  if(A[0][0]=='.'){
    puts("Impossible");
    return 0;
  }
  queue<pair<P, int>> que{};
  que.push(pair<P, int>(P(0, 0), 0));
  while (!que.empty()) {
    P now = que.front().first;
    int dis = que.front().second;
    que.pop();
    if (A[now.first + 1][now.second] == '#')
      que.push(pair<P, int>(P(now.first + 1, now.second), dis + 1));
    if (A[now.first][now.second + 1] == '#')
      que.push(pair<P, int>(P(now.first, now.second + 1), dis + 1));
    if (now.first == H - 1 && now.second == W - 1&&dis==kyori) {
      puts("Possible");
      return 0;
    }
  }
  puts("Impossible");
}

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

public class Main{
	Point2D [] triP;
	Line2D [] triL;
	Point2D cp;
	int cr;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			triP = new Point2D[3];
			int x = sc.nextInt();
			int y = sc.nextInt();
			if((x|y) == 0) break;
			triP[0] = new Point2D.Double(x, y);
			for(int i = 1;  i < 3; i++){
				x = sc.nextInt();
				y = sc.nextInt();
				triP[i] = new Point2D.Double(x, y);
			}
			triL = new Line2D[3];
			for(int i = 0; i < 3; i++){
				triL[i] = new Line2D.Double(triP[i], triP[(i+1) % 3]);
			}
			int cx = sc.nextInt();
			int cy = sc.nextInt();
			cr = sc.nextInt();
			cp = new Point2D.Double(cx, cy);

			boolean res = isB();
			if(res){
				System.out.println("b");
				continue;
			}
			
			boolean res2 = isIn();
			if(res2){
				boolean flg = true;
				for(int i = 0; i < 3; i++){
					double dis = triL[i].ptSegDist(cp);
					if(dis < cr){
						flg = false;
					}
				}
				if(flg){
					System.out.println("a");
				}
				else{
					System.out.println("c");
				}
			}
			else{
				boolean flg = true;
				for(int i = 0; i < 3; i++){
					double dis = triL[i].ptSegDist(cp);
					if(dis <= cr){
						flg = false;
					}
				}
				if(flg){
					System.out.println("d");
				}
				else{
					System.out.println("c");
				}
				
			}
		}
	}
	
	private boolean isIn() {
		int sign = triL[0].relativeCCW(cp);
		for(int i = 1; i < 3;i++){
			int now = triL[i].relativeCCW(cp);
			if(now * sign != 1){
				return false;
			}
		}
		return true;
	}

	private boolean isB() {
		for(int i = 0; i < 3; i++){
			double dis = triP[i].distance(cp);
			if(dis > cr){
				return false;
			}
		}
		return true;
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

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

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

#define int long long

signed main() {
#ifdef _DEBUG
  freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m, s = 1;
  cin >> n >> m;
  if (n != 1 && m != 1) {
    s = (n / 2 + n % 2) * (m / 2 + m % 2) + (n / 2) * (m / 2);
  }
  cout << s << '\n';
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

vector<ll> inv, fact, invfact;
void Mod_build(int n = 101010) {
    fact.resize(n + 1);
    inv.resize(n + 1);
    invfact.resize(n + 1);
    fact[0] = inv[0] = invfact[0] = 1;
    inv[1] = 1;
    for (ll i = 0; i < n; i++) {
        fact[i + 1] = fact[i] * (i + 1) % mod;
        if (i > 0) inv[i + 1] = mod - inv[mod % (i + 1)] * (mod / (i + 1)) % mod;
        invfact[i + 1] = invfact[i] * inv[i + 1] % mod;
    }
}
ll perm(int n, int k) {
    if (n < 0 || k < 0 || k > n) return 0;
    return fact[n] * invfact[n - k] % mod;
}
ll comb(int n, int k) {
    if (n < 0 || k < 0 || k > n) return 0;
    return (fact[n] * invfact[n - k] % mod) * invfact[k] % mod;
}
ll powmod(ll n, ll k) {
    k %= mod - 1;
    if (k < 0) k += mod - 1;
    ll ret = 1;
    while (k) {
        if (k & 1) ret = ret * n % mod;
        n = n * n % mod;
        k >>= 1;
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int s;
    cin >> s;
    Mod_build();
    ll ans = 0;
    for (i = 1; i <= s; i++) {
        ans += comb(s - 2 * i - 1, i - 1);
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5552
def sol(inp=input):
    if determine_res(inp):
        return 'YES'
    return 'NO'
def determine_res(inp=input):
    query=inp()

    goal='keyence'
    if query.startswith(goal):
        return True
    for i,q_c,g_c in zip(range(len(query)),query,goal):
        if q_c!=g_c:
            len_left_mch=i
            break
    return query.endswith(goal[i:])

print(sol())

Measured memory_bytes: 3060
#include<stdio.h>
void func(int,int);
int n,m,max,cnt;
int a[100][100];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(void)
{
	int i,j;
	while(1)	{	
		scanf("%d %d",&n,&m);
		if(n==0&&m==0)	break;
		max=0;
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				a[i][j]=0;
			}
		}
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				scanf("%d",&a[i][j]);
			}
		}
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				if(a[i][j]==1){
					cnt=1;
					func(i,j); //???????£???¶
					a[i][j]=1;
				}	
			}
		}	
		printf("%d\n",max);
	}	
	return 0;
}
void func(int y,int x) //(1)
{
	int i,j,xx,yy;
	//printf("%d %d\n",y,x);
	a[y][x]=0;
	if(max<cnt) max=cnt;	
	for(i=0;i<4;i++){
		xx=x+dx[i]; yy=y+dy[i];
		if(xx<=n&&yy<=m&&xx>=0&&yy>=0&&a[yy][xx]==1){
			cnt++; func(yy,xx); //1????£???¶
			a[yy][xx]=1; cnt--;
		}
	}
}

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert

const int MAX = 3005;
ll dp[MAX][MAX];

void solve(){
    mod =  998244353;
    ll n,s;
    cin>>n>>s;
    ll ans=0;
    ll a[n+1];
    dp[0][0] = 1;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        memcpy(dp[i],dp[i-1] ,sizeof dp[0]);
        (dp[i][a[i]] += i-1)%=mod;
        for(ll j=0 ; j+a[i] <= s ; j++){
            (dp[i][j+a[i]] += dp[i-1][j])%= mod;
        }
        ans += dp[i][s];
        ans %= mod;
    }
    cout << ans << endl;
}

int main(){
    
    IOS;
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 70784
package main

import (
	"fmt"
)

func main() {
	var n, k, colors int
	var minH, tmp, ans int64
	ans = 1000000000 * 20
	fmt.Scan(&n, &k)
	A := make([]int64, n)
	for i := range A {
		fmt.Scan(&A[i])
	}
	for b := 0; b < (1 << uint(n)); b++ {
		colors = 0
		tmp = 0
		for i, a := range A {
			if i == 0 || a > minH {
				minH = a
				colors += 1
				continue
			}
			if b&(1<<uint(i)) != 0 {
				minH = minH + 1
				tmp += minH - a
				colors += 1
			}
		}
		if ans > tmp && k == colors {
			ans = tmp
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  string w,t;
  int count=0;
  cin>>w;
  while(true){
    cin>>t;
    if(t=="END_OF_TEXT")
        break;
    transform(t.begin(),t.end(),t.begin(),::tolower);
    if(t!=w)continue;
    count++;
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 3216
n=int(input())
d=list(map(int,input().split()))
x=max(d)
li=[0]*(x+1)
for i in range(n):
    li[d[i]]+=1
if d[0]!=0 or li[0]!=1:
    print(0) 
else:
    ans=1
    for i in range(2,len(li)):
        ans*=pow(li[i-1],li[i],998244353)   
    print(ans%998244353)      

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

int takahashi = 0;
char s1 = '+';



void main (){
    char str1[256];
     scanf("%s", str1);
    for(int i = 0; i < 4; i++){
   
    
    if(str1[i] == s1){
        takahashi = takahashi + 1;
    }else {
        takahashi = takahashi - 1;
    }
    }

    printf("%d", takahashi);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

bool oddNumber(int x){
  int count = 0;
  while(x!=0){
    x/=10;
    ++count;
  }
  return count&1;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  int count = 0;
  repp(x,1,N+1)if(oddNumber(x))++count;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())
    result = 0
    for a in range(A + 1):
        for b in range(B + 1):
            for c in range(C + 1):
                if a * 500 + b * 100 + c * 50 == X:
                    result += 1
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <utility>
#include <set>
#include <cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))
using namespace std;
typedef pair<int,int> point;
typedef complex<double> P;
typedef long long ll;

const double eps = 1e-8;
const double INF = 1e12;


double dot(P a,P b){
	return a.real()*b.real()+a.imag()*b.imag();
}
double cross(P a,P b){
	return a.real()*b.imag()-a.imag()*b.real();
}

bool is_orthogonal(P a1,P a2,P b1,P b2){
	return EQ(dot(a1-a2,b1-b2),0.0);
}
bool is_parallel(P a1,P a2,P b1,P b2){
	return EQ(cross(a1-a2,b1-b2),0.0);
}

bool is_point_on_line(P a,P b,P c){
	return EQ(cross(b-a,c-a),0.0);
}

bool is_point_on_linesegment3(P a,P b,P c){
	//|a-c| + |c-b|<=|a-b| ???????????????
	return (abs(a-c)+abs(c-b)<abs(a-b)+EPS);
}

double distance_l_p(P a,P b,P c){
	return abs(cross(b-a,c-a))/abs(b-a);
}


double distance_ls_p(P a,P b,P c){
	if(dot(b-a,c-a)<EPS)return abs(c-a);
	if(dot(a-b,c-b)<EPS)return abs(c-b);
	return abs(cross(b-a,c-a))/abs(b-a);
}

int main(){
	int h,w;
	cin>>h>>w;
	int dt[h][w];
	rep(i,h){
		string s;
		cin>>s;
		rep(j,w){
			dt[i][j]=s[j]-'0';
		}
	}
	int cost[h][w];
	cost[0][0]=dt[0][0];
	loop(i,1,w)cost[0][i]=cost[0][i-1]+dt[0][i];
	loop(i,1,h)cost[i][0]=cost[i-1][0]+dt[i][0];
	loop(i,1,h){
		loop(j,1,w){
			cost[i][j]=min(cost[i-1][j],cost[i][j-1])+dt[i][j];
		}
	}
	cout<<cost[h-1][w-1]<<endl;
	return 0;
}

Measured memory_bytes: 1228
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double ans=0;
		for(int i = 0; i<n; i++){
			double x=sc.nextDouble();
			String s = sc.next();
			if(s.equals("JPY")){
				ans+=x;
			}else{
				ans+=x*380000;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24532
import java.util.Scanner;
 
public class Main{//2 1 5 4 3
    
    public static void solve(int[] arr){
     
        long ans = 0;
        int prev = Integer.MIN_VALUE;
        for(int i= 0; i < arr.length; i++){
            if(arr[i] < prev){
                ans += prev - arr[i];
            }
            
           prev = Math.max(prev,arr[i]);
        }
        
        System.out.println(ans);
    }
 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        long ans=0;
        int[] arr = new int[N];
        for(int i=0;i<N;i++){
            arr[i]=sc.nextInt();
        }
        
        
        solve(arr);
        
        
    }
}

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



struct P
{
    int x,y,z;

    bool operator<(const P &a)const{

        if(x!=a.x) return x>a.x;
        return y>a.y;
    }

};

vector<int> v;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c;

int o[311][333];
int l[1];
int j[1];
int e;


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000009,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[111111];
stack<int> s;
//set<int> se;
//priority_queue<int> q;
//queue<int> q;
//string r,r1;
char r[1111];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;


//deque<int> de;
//srand((int)time(NULL));




bool as(P a,P b)
{
    //if(a.x!=b.x)
    //   return a.x>b.x;
    //return a.y<b.y;
    return a.x+a.y>b.x+b.y;

}

int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
    {
        scanf("%d %d",&u[t].x,&u[t].y);
    }
    sort(u+1,u+a+1,as);
    for(int t=1;t<=a;t++)
        if(t%2) x+=u[t].x;
    else x-=u[t].y;
    printf("%lld",x);
}





Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

ll a, b, k;

int main()
{
    cin >> a >> b >> k;

    if (k < a)
    {
        cout << a - k << " " << b << endl;
    }
    else if (k < b + a)
    {
        cout << 0 << " " << b + a - k << endl;
    }
    else
    {
        cout << 0 << " " << 0 << endl;
    }
}


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

int par[100005];
int rnk[100005];
int cnt[100005];

void init(int n) {
  for (int i=0; i<n; i++) {
    par[i]=i;
    rnk[i]=0;
    cnt[i]=1;
  }
}
int find(int x) {
  if (par[x]==x) {
    return x;
  }
  else {
    return par[x]=find(par[x]);
  }
}

void unite(int x,int y) {
  x=find(x);
  y=find(y);
  if (x==y) return;
  if (rnk[x]<rnk[y]) {
    par[x]=y;
    cnt[y]+=cnt[x];
  }
  else {
    par[y]=x;
    cnt[x]+=cnt[y];
    if (rnk[x]==rnk[y]) rnk[x]++;
  }
}

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


int main(){
  int n,m;
  cin>>n>>m;
  int p[100005];
  rep(i,n){
    int a;
    cin>>a;
    a--;
    p[a]=i;
  }
  init(n);
  rep(i,m){
    int x,y;
    cin>>x>>y;
    x--; y--;
    unite(x,y);
  }
  int ans=0;
  rep(i,n){
    if(find(i)==find(p[i])) ans++;
  }
  cout<<ans<<endl;
  return 0;
}





Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> node[2005];
int n;
map<int,ll> mp;
int dis[2005];
int vis[2005];
void bfs(int s)
{
    for(int i=1;i<=n;i++)
    {
        vis[i]=0;
        dis[i]=0;
    }
    dis[s]=0;
    vis[s]=1;
    queue<int> q;
    q.push(s);
    while(q.size()>0)
    {
        int x=q.front();
        q.pop();
        for(int j=0;j<node[x].size();j++)
        {
            int y=node[x][j];
            if(vis[y]==0)
            {
                vis[y]=1;
                q.push(y);
                dis[y]=dis[x]+1;
                mp[dis[y]]++;
            }
        }
    }
    return;
}
int main()
{
    cin>>n;
    int x,y;
    cin>>x>>y;
    for(int i=1;i<n;i++)
    {
        node[i].push_back(i+1);
        node[i+1].push_back(i);
    }
    node[x].push_back(y);
    node[y].push_back(x);
    for(int i=1;i<=n;i++)
    {
        bfs(i);
    }
    for(int i=1;i<n;i++)
    {
        ll ans=mp[i];
        ans=ans/2LL;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    long long a,b,x;
    cin>>a>>b>>x;
    long long n,m;
    if(a%x==0){
        n=a/x;
    }
    else{
        n=a/x+1;
    }
    m=b/x;
    cout<<m-n+1;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2018/7/21 20:19
# @Version : 1.1
# @Author  : Jade
# @File    : acm.py
# @Software: PyCharm
#
n = int(input())
a = map(int,input().split(' '))
print(sum(a) - n)

Measured memory_bytes: 39280
def base_oct_to_n(x, n):
    tmp = x
    out = ''
    while tmp > 0:
        out = str(tmp % n) + out
        tmp = int(tmp/n)
    return out


n, k = [int(i) for i in input().split()]
print(len(base_oct_to_n(n, k)))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,m;cin>>n>>m;
  vector<string> strListA(50);
  vector<string> strListB(50);
  REP(i,n){
    cin>>strListA[i];
  }
  REP(i,m){
    cin>>strListB[i];
  }
  int ans=0;
  // 始点決定
  REP(i, n-m+1){
    REP(j, n-m+1){
      int count=0;
      // equal?
      REP(k, m){
        REP(l, m){
          if(strListA[i+k][j+l]==strListB[k][l]){
            count++;
          }
        }
      }
      if(count==m*m)ans++;
    }
  }
  if(ans>=1){
    P("Yes");
  }else{
    P("No");
  }
  return 0;
}


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

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

    map<string, int> m;
    m["Sunny"] = 0;
    m["Cloudy"] = 1;
    m["Rainy"] = 2;

    int n = m[in];
    n = (n+1) % 3;

    switch (n)
    {
    case 0:
        cout << "Sunny" << endl;
        break;
    case 1:
        cout << "Cloudy" << endl;
        break;
    case 2:
        cout << "Rainy" << endl;
        break;
    }

    return 0;

}


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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(N)
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    uf.union(a, b)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))
print(ans)



Measured memory_bytes: 14756
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

const int N = 500000;
const int MOD = 1e9 + 7;
const int alpha = 26;

int n;
string s[N];
int minc[N];

signed main()
{
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    cin >> n;
    forn(i, n) cin >> s[i];
    fill(minc, minc + 26, N);
    forn(i, n)
    {
        vector<int> cnt(alpha);
        forn(j, s[i].size()) cnt[s[i][j] - 'a']++;
        forn(j, alpha) minc[j] = min(minc[j], cnt[j]);
    }
    forn(i, alpha) forn(j, minc[i]) cout << (char)(i + 'a');
}


Measured memory_bytes: 4224
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h1,m1,h2,m2,k=LI()
  a=(h2-h1)*60
  a+=m2-m1

  return max(0,a-k)

# main()
print(main())


Measured memory_bytes: 10760
N = int(input())
dam = list(map(int,input().split()))
yama = [0] * N

yama[0] = sum(dam) - 2*(sum( dam[i] for i in range(N) if i % 2 == 1 ))


#雨の量を計算していく
for i in range(1,N):
        yama[i] = 2*dam[i-1] - yama[i-1]

print(" ".join(map(str,yama)))

Measured memory_bytes: 19220
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>
#include <deque>

using namespace std;
using ull = unsigned long long;
using ll = long long;

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

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)

int main() {
	ll A, P;
	cin >> A >> P;

	cout << (A*3 + P)/2 << endl;

	return 0;
}

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

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,l,r) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el
#define ri(n) scanf("%d",&n)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int MAXN = 1e5+200;

int dp[MAXN][3];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>> n;

    int op[n][3];
    forn(i,n) cin>> op[i][0]>> op[i][1]>> op[i][2];
    forn(i,3) dp[0][i]= op[0][i];

    for(int i= 1; i<n; ++i){
        forn(j,3){
            dp[i][j]= max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + op[i][j];
        }
    }
    --n;
    cout<< max(dp[n][0], max(dp[n][1], dp[n][2]))<<el;
}



Measured memory_bytes: 2560
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		long X = Long.parseLong(sc.next());
		System.out.println(patty(N, X));

		// if (0<=X && X<=1) {

		// } else if (1<=X && pow(2, N+1)-2<=X) {

		// } else if (X<=pow(2, N+1)-2 && pow(2, N+1)-1<=X) {

		// } else if (X<=pow(2, N+1)-1 && pow(2, N+2)-4<=X) {

		// } else if (X<=pow(2, N+2)-4 && pow(2, N+2)-3<=X) {

		// }
	}

	static long patty_sum(int N) {
		return pow(2, N+1)-1;
	}

	static long patty(int N, long X) {
		if (0<=X && X<=1) {
			// System.out.println("case 1");
			if (N==0) {
				return 1;
			} else {
				return 0;
			}
		} else if (1<=X && X<=pow(2, N+1)-2) {
			// System.out.println("case 2");
			return patty(N-1, X-1);
		} else if (pow(2, N+1)-2<=X && X<=pow(2, N+1)-1) {
			// System.out.println("case 3");
			return patty_sum(N-1)+1;
		} else if (pow(2, N+1)-1<=X && X<=pow(2, N+2)-4) {
			// System.out.println("case 4");
			return patty_sum(N-1)+1+patty(N-1, X-pow(2, N+1)+1);
		} else { // else if (pow(2, N+2)-4<=X && X<=pow(2, N+2)-3)
			// System.out.println("case 5");
			return patty_sum(N);
		}
	}
	// static long patty(int N, long X, long add) {
	// 	if (0<=X && X<=1) {
	// 		return add;
	// 	} else if (1<=X && pow(2, N+1)-2<=X) {
	// 		return patty(N-1, X-1, 0);
	// 	} else if (X<=pow(2, N+1)-2 && pow(2, N+1)-1<=X) {
	// 		return patty_sum(N-1)+1+add;
	// 	} else if (X<=pow(2, N+1)-1 && pow(2, N+2)-4<=X) {
	// 		return patty(N-1, X-pow(2, N+1)-1, patty_sum(N-1)+1);
	// 	} else { // else if (X<=pow(2, N+2)-4 && pow(2, N+2)-3<=X)
	// 		return patty_sum(N)+add;
	// 	}
	// }

	static long pow(long a,int n) {
	    long res=1;
	    while (n>0) {
	        if ((n-n/2*2)==1) {
	            res=res*a;
	        }
	        a=a*a;
	        n>>=1;
	    }
	    return res;
	}
}

Measured memory_bytes: 24020
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int gcd(int c, int d) {
	if (c % d == 0)
		return d;
	else
		return gcd(d, c%d);
}

int main()
{

	/*
		cでもdでも割り切れない
		cで割れない　かつ　dで割れない　もの
		cで割れる　または　dで割れる　もの

		numC = end/c - (start-1)/c
		 offsetC = c - start%c がオフセット
	
	*/
	long long start, end, c, d;
	cin >> start >> end >> c >> d;
	long long cd = c * d / gcd(c, d);

	long long numC, numD, numCD;

	numC = end / c - (start - 1) / c;
	numD = end / d - (start - 1) / d;
	numCD = end / cd - (start - 1) / cd;

	cout << end - (start - 1) - (numC + numD - numCD);
}

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


struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  
  while(x->left != NIL){
    x = x -> left;
  }
  return x;
  
}

Node treeSearch(Node u, int k){
  
  if(u == NIL || k == u->key){
    return u;
  }
  
  if(k < u->key){
    return treeSearch(u->left,k);
  }
  else {
    return treeSearch(u->right,k);
  }

}

Node treeSuccessor(Node x){
  
  Node y;

  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  
  y = x->parent;
  
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return x;
  
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if (z->left == NIL || z->right == NIL){ 
       y = z;
  }
  else {
    y = treeSuccessor(z);
  } 

  if (y->left != NIL){
    x = y->left;
  }
  else {
    x = y->right;
  }
  

  if (x != NIL){
    x->parent = y->parent; 
  }

  if (y->parent == NIL){
      root = x;
  } 
  else if(y == y->parent->left){ 
    y->parent->left = x;
  }
  else{                  
    y->parent->right = x;
  }

  
  if (y != z){
    z->key = y->key;
  }
  
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  y = NIL;
  x = root;

  while(x != NIL){
    y = x;
    
    if(z->key < x->key){
      x = x->left;
    }     
    else {
      x = x->right;
    }
  }
  
  z->parent = y;
  
  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else {
    y->right = z;
  }
  
}

void inorder(Node u){
  if(u != NIL){
    
    
    
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
    
  }
}
void preorder(Node u){
 if(u != NIL){
   printf(" %d",u->key);
   preorder(u->left);
   preorder(u->right);
  
 }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

int main(){
	char s[99];
	scanf("%s",s);
	int n=strlen(s);
	if(n!=1){
		int f=0;
		rep(i,1,n)if(s[i]!='9')f=1;
		printf("%d\n",(n-1)*9+s[0]-'0'-f);
	}
	else printf("%d",s[0]-'0');
	return 0;
}

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

int main(void){
	int n,min=0;

	scanf("%d",&n);

	for(;n>0;n/=10){
		min+=(n%10);
	}
	if(min==1){
		min=10;
	}
	printf("%d\n",min);
	
	return 0;
}


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

int main() {
	int n, l;
	std::cin >> n >> l;
	std::vector<std::string> vec(n);
	for (auto &v : vec) {
		std::cin >> v;
	}
	std::sort(vec.begin(), vec.end());
	for (const auto &v : vec) {
		std::cout << v;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int int64_t

signed main(){
	int n,q; cin>>n>>q;
	string s;
	cin>>s;
	int memo[n],ac=0;
	memo[0]=0;
	rep(i,n-1){
		if(s.at(i)=='A'&&s.at(i+1)=='C')ac++;
		memo[i+1]=ac;
	}
	//rep(i,n)cout<<memo[i]<<' '<<flush;
	//cout<<endl;
	rep(i,q){
		int l,r;
		cin>>l>>r;
		r--; l--; //0-indexed
		cout<<memo[r]-memo[l]<<endl;;
	}
}

Measured memory_bytes: 1792
use std::str::FromStr;
use std::fmt::Debug;
use std::collections::HashMap;
use std::collections::BinaryHeap;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let line: Vec<usize>  = read_as_vec();
    let (n, k) = (line[0], line[1]);

    let mut heap = BinaryHeap::new();
    for _ in 0..n{
        let line: Vec<i64>  = read_as_vec();
        heap.push((line[1], line[0]));
    }

    let mut kind_counter = HashMap::new();

    let mut eaten_sushis = BinaryHeap::new();
    for _ in 0..k{
        let max_taste = heap.pop().unwrap();
        *kind_counter.entry(max_taste.1).or_insert(0) += 1;
        eaten_sushis.push((-max_taste.0, max_taste.1));
    }
    let kind_bonus = (kind_counter.len() as i64) *
        (kind_counter.len() as i64);
    let mut ans_max: i64 = eaten_sushis.iter().map(|x| -x.0).sum::<i64>() +
        kind_bonus;
    //heap (taste, kind)
    //eaten_sushis (-taste, kind)
    /*
    println!("heap = \n{:?}", heap);
    println!("eaten_sushis = \n{:?}", eaten_sushis);
    */

    let mut cur_ans: i64 = ans_max;
    while !heap.is_empty() && !eaten_sushis.is_empty(){
        /*
        println!("---------");
        println!("before update");
        println!("kind_counter ={:?}", kind_counter);
        */
        let gv_sushi = heap.pop().unwrap();
        //if the kind of popped sushi is already contained in eaten_sushis,
        //go next loop
        if let Some(&x) = kind_counter.get(&gv_sushi.1){
            if x > 0 {continue;}
        }

        let mut lv_sushi: (i64, i64) = (0,0);
        while !eaten_sushis.is_empty(){
            lv_sushi = eaten_sushis.pop().unwrap();
            lv_sushi = (-lv_sushi.0, lv_sushi.1);

            let counter = *kind_counter.get(&lv_sushi.1).unwrap();
            if counter > 1{
                *kind_counter.entry(lv_sushi.1).or_insert(0) -= 1;

                break;
            }else{
                lv_sushi = (0,0);
            }
        }

        if lv_sushi.0 == 0{
            break;
        }
        /*
        println!("grtst value sushi = {:?}", gv_sushi);
        println!("least value sushi = {:?}", lv_sushi);
        */
        
        *kind_counter.entry(gv_sushi.1).or_insert(0) += 1;
        eaten_sushis.push((-gv_sushi.0, gv_sushi.1));
        /*
        println!("after update");
        println!("kind_counter ={:?}", kind_counter);
        */
        cur_ans = cur_ans -  lv_sushi.0 + gv_sushi.0 +
            2*kind_counter.len() as i64 -1;
        ans_max = cmp::max(cur_ans, ans_max);
        /*
        println!("tmp_ans = {}", cur_ans);
        println!("ans_max = {}", ans_max);
        */
    }

    println!("{}", ans_max);
}


Measured memory_bytes: 14340
#include <iostream>
#include <stack>

int main(){
	std::stack<int> trains;
	int in;

	while(std::cin >> in){
		if(in == 0){
			std::cout << trains.top() << std::endl;
			trains.pop();
		}
		else
			trains.push(in);
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n,l;
  cin >> n >> l;
  
  if(l>=0)cout << (2*l+n-1)*n/2-l << endl;
  else if(n>-l)cout << (2*l+n-1)*n/2 << endl;
  else cout << (2*l+n-1)*n/2-l-n+1 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long
#define read freopen("input/test (4).txt","r",stdin)
#define write freopen("output/test (4).txt","w",stdout)
#define fr first
#define sc second
#include <sstream>
#define FIO std::ios_base::sync_with_stdio(false);
#define ii pair < int , int >
#define mp make_pair
using namespace std;

int main()
{
  int n,m;
  cin>>n>>m;
  int a[n];
  for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
  ll sum = 0;
  for(int i=1;i<n;i++)
  {
      int last = a[i]+a[i-1];
      if(last > m)
      {
       ll R   = (last-m);
       sum+=(last-m);
       a[i]-=R;
       if(a[i] < 0)
       {
           a[i-1]+=a[i];
           a[i] = 0;
       }
      }
  }
  cout<<sum<<endl;
}


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

int main() {
    string S;
    cin >> S;
    if (S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin>>s;
	ll i,j,f=0;
	for(i=0;i<s.size()-1;i++)
	{
		if(s[i]!=s[i+1])
		{
			f=1;break;
		}
	}
	if(f==1) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

a,b=get_i
puts a.lcm(b)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define N 55
#define EPS 1e-10
#define db double
int n;db r;
struct Point
{
	db x,y;
	Point(db _x=0,db _y=0) {x=_x;y=_y;}
	Point operator + (Point t) {return Point(x+t.x,y+t.y);} 
	Point operator - (Point t) {return Point(x-t.x,y-t.y);}
	Point operator * (db t) {return Point(x*t,y*t);}
	Point operator / (db t) {return Point(x/t,y/t);}
}O,a[N];
db dst(Point x) {return sqrt(x.x*x.x+x.y*x.y);}
db crsMul(Point x,Point y) {return x.x*y.y-x.y*y.x;}
Point rot90(Point x) {return Point(x.y,-x.x);}
Point getI(Point x,Point y,Point z)
{
	Point M1,M2,v1,v2;M1=(x+y)/2;M2=(x+z)/2;v1=rot90(y-x);v2=rot90(z-x);
	return M1+v1*crsMul(M2-M1,v2)/crsMul(v1,v2);
}
int main()
{
	srand(time(0));scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%lf %lf",&a[i].x,&a[i].y);
	random_shuffle(a+1,a+n+1);
	for(int i=1;i<=n;++i) if(dst(O-a[i])>r+EPS)
	{
		O=a[i];r=0;
		for(int j=1;j<i;++j) if(dst(O-a[j])>r+EPS)
		{
			O=(a[i]+a[j])/2;r=dst(O-a[j]);
			for(int k=1;k<j;++k) if(dst(O-a[k])>r+EPS)
				O=getI(a[i],a[j],a[k]),r=dst(O-a[k]);
		} 
	}printf("%.10lf\n",r);return 0;
}

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

using namespace std;

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

int main(){
    string s;
    cin >> s;
    rep(i, s.size()){
        s[i] = 'x';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

ll l[55],p[55];

ll dfs(ll N,ll X){
    if(N==0){
        return ((X<=0)?0:1);
    }else if(X<=1+l[N-1]){
        return dfs(N-1,X-1);
    }else{
        return p[N-1]+1+dfs(N-1,X-l[N-1]-2);
    }
}

int main(){
    ll N,X; cin>>N>>X;
    l[0]=1; p[0]=1;
    for(int i=1;i<=N;++i){
        l[i]=2*l[i-1]+3;
        p[i]=2*p[i-1]+1;
    }

    cout<<dfs(N,X)<<endl;

    return 0;
}



Measured memory_bytes: 256