akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<cstring>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

//文字から数値に変換する//
int getChar(char ch) {
	if (ch == 'A')return 1;
	else if (ch == 'C')return 2;
	else if (ch == 'G')return 3;
	else if (ch == 'T')return 4;
	else return 0;
}

//文字列から数値へ変換してkeyを生成する//
long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0)return 1;
		else if (strlen(H[h]) == 0)return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h;
	key = getKey(str);//文字列を数値に変換//
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0)return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main() {
	int i, n, h;
	char str[L], com[9];
	for (i = 0; i < M; i++) {
		H[i][0] = '\0';
	}
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", com, str);

		if (com[0] == 'i') {
			insert(str);
		}
		else {
			if (find(str)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}
	
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    const ll mod = 998244353;
    ll n; cin >> n;
    vector<ll> d(n), cnt(n);
    inv(n,d);
    if(d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    rep(i, n){
        cnt[d[i]]++;
        if(i != 0 && d[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    for(int i = 1; i < n; i++){
        ans *= cnt[d[i]-1];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  for(int i = 0;i<S.size()-1;i++){
    if(S[i] == S[i+1]){
      N -= 1;
    }
  }
  cout << N << endl;
}

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

using namespace std;

int main()
{
	int X,N;
	int vis[105] = {0};
	scanf("%d%d",&X,&N);
	for(int i = 1;i <= N; ++ i)
	{
		int v; scanf("%d",&v);
		vis[v] = 1;
	}
	for(int i = 0;; ++ i)
	{
		if(!vis[X - i]) return printf("%d\n",X - i),0;
		if(!vis[X + i]) return printf("%d\n",X + i),0
;	}
}

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

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

    int H[N][3];

    for (int i = 0; i < N; i++)
    {
        cin >> H[i][0] >> H[i][1] >> H[i][2];
    }

    ll dp[N][3];
    for (int i = 0; i < N; i++)
    {
        dp[i][0] = -1;
        dp[i][1] = -1;
        dp[i][2] = -1;
    }
    dp[0][0] = H[0][0];
    dp[0][1] = H[0][1];
    dp[0][2] = H[0][2];

    for (int i = 0; i < N - 1; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (j == k)
                    continue;
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + H[i + 1][k]);
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < 3; i++)
    {
        ans = max(ans, dp[N - 1][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N,D,X;
    cin >> N >> D >> X;
    vector<int> consume(N);
    for(int i=0;i<N;i++){
        int a;
        int cnt = 1;
        cin >> a;
        for(int j=1;j>0;j++){
            if( (j*a+1) <= D){
                cnt++;
            }
            else{
                consume[i]=cnt;
                break;
            }
        }
    }
    ll total=0;
    for(int i=0;i<N;i++){
        total = total + consume[i];
    }
    ll ans = total + X;
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
void TravelingBudget() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << min(A + C, min(A + D, min(B + C, B + D))) << endl;
}
int main() {
	TravelingBudget();
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        int hour, minute, second;
        Scanner scan = new Scanner(System.in);
        int input = scan.nextInt();
        minute = input / 60;
        second = input % 60;
        hour = minute / 60;
        minute = minute % 60;

        System.out.println(hour + ":" + minute + ":" + second);
    }
}



Measured memory_bytes: 26188
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if (c<=a+b+1)
	{
		cout<<b+c<<endl;
	}
	else
	{
		cout<<a+1+b+b<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long n, long long m, long long q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d){
    lint fres = 0LL;
    lint dat[n];

    REP(i, n){
        dat[i] = 1LL;
    }

    while(1){

        IREP(i, n){
            if (dat[i] > m) {
                dat[i] = dat[i - 1];
                dat[i - 1] += 1LL;
            } else {
                break;
            }
        }

        int ispass = 0;

        IFOR(i, 1, n){
            if (dat[i - 1] > dat[i] ) {
                ispass = 1;
                break;
            }
        }


        if (ispass == 1) {
            dat[n - 1] += 1;
            if (dat[0] >= m) {
                break;
            }
            continue;
        }

        lint res = 0;


        REP(i, q) {
            if (dat[b[i] - 1] - dat[a[i] - 1] == c[i]) {
                res += d[i];
            }
        }

        fres = max<lint>(fres, res);

        dat [n-1] += 1LL;


        if (dat[0] >= m) { break;}
    }
    cout << fres << endl;
}

int main(){

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> a(Q);
    std::vector<long long> b(Q);
    std::vector<long long> c(Q);
    std::vector<long long> d(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
    }
    int i;
    // REP(i, Q) cout << a[i] << b[i] << endl;
    solve(N, M, Q, std::move(a), std::move(b), std::move(c), std::move(d));
    return 0;
}



Measured memory_bytes: 3728
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int X[200200]; rep(i, N) cin >> X[i];
    int Y[200200]; rep(i, N) Y[i] = X[i];
    sort(Y, Y + N);
    rep(i, N) {
        if(X[i] < Y[N / 2]) {
            cout << Y[N / 2] << endl;
            continue;
        } else {
            cout << Y[N / 2 - 1] << endl;
        }
    }
	return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int n;
    cin >> n;
    string s;
    int    temp = 0;
    int    cnt  = 0;
    rep1(i, n) {
        s    = to_string(i);
        temp = s.size();
        if (temp % 2 != 0) {
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
#define eps 1e-9
using namespace std;
 
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
    //~ freopen("file.in", "r", stdin);
    long double n;
    cin>>n;
	for(int i=1;i<=3500;i++)
		for(int j=1;j<=3500;j++){
			long double ii=i;
			long double jj=j;
			long double val=4.0/n-1.0/ii-1/jj;
			long double k=1.0/val;
			if(k<0)
				continue;
			if(k-int(k)<eps){
				cout<<i<<" "<<j<<" "<<int(k)<<endl;
				return 0;
			}
		}
	return 0;
}

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

namespace ABC175C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long X = long.Parse(input[0]);
            long K = long.Parse(input[1]);
            long D = long.Parse(input[2]);
            if (X < 0)
            {
                X *= -1;
            }
            if (X == 0)
            {
                if (K % 2 == 0)
                {
                    Console.WriteLine(0);
                }
                else
                {
                    Console.WriteLine(D);
                }
            }
            else
            {
                if (D <= X / K)
                {
                    Console.WriteLine(X - D * K);
                }
                else
                {
                    long amari = X % D;
                    long count = ((X - amari) / D) + 1;
                    long temp = X - (D * count);
                    if ((K - count) % 2 == 0)
                    {
                        Console.WriteLine(temp * (-1));
                    }
                    else
                    {
                        Console.WriteLine(temp + D);
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 27440
def main():
    a,b,c=map(int,input().split())
    k=int(input())
    cnt=0
    while cnt < k:
        cnt+=1
        if a >= b: b*=2
        elif b >= c: c*=2
        else: 
            break
    if a < b and b < c: print('Yes')
    else: print('No')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int main(){
    int N;
    cin >> N;
    int a[N];
    LL sum=0;
    for(int i=0;i<N;i++){
       cin >> a[i];
       sum+=a[i];
    }
    sort(a,a+N);
    int alice=0;
    for(int i=N-1;i>=0;i-=2){
        alice+=a[i];
    }
    cout << 2*alice-sum << endl;
    return 0;
}

Measured memory_bytes: 256
# 解説解法

# ちゃんとした括弧列 s=(s1,...,sn):
# - '('と')'の個数は等しい
# - 任意のprefixにおいて，'('の個数 >= ')'の個数 (これがないと閉じない)
#
# di = (s1,...,si)の '('の個数 - ')'の個数
# x = min(d1, ..., dn)
# 
# '('を1つ入れる → dnは1増える xは0 or 1増える (場所による)
# ')'を1つ入れる → dnは1減る xは0 or 1減る (場所による)
#
# 2つの値(a=dn, b=x)を管理する
#
# 4つの操作を考える
#  [a] a += 1
#  [b] a += 1, b += 1
#  [c] a -= 1
#  [d] a -= 1, b -= 1
#
# - b <= 0 から b == 0にしないといけないので，[b]を-b回行う (dはムダなのでやらない)
# - aの値が a + bになっている， a >= bよりa >= 0
# - 次にaを0にしたい．そのため，cを a + b回やる
# - つまり挿入回数は a - 2b = dn - x 回数未満
#
# 構成法
# - 一番左に '(' を -x 回
# - 一番右に ')' を dn - x回

n = int(input())
s = list(input())
# d = []
# co, cc = 0, 0
# for ch in s:
#     if ch == '(':
#         co += 1
#     elif ch == ')':
#         cc += 1
#     d.append(co - cc)

# # 計算
# x = min(d)

# str_left = '(' * (-x)
# str_right = ')' * (d[-1] - x)

# print("{}{}{}".format(str_left, "".join(s), str_right))


co, cc = 0, 0
for ch in s:
    if ch == '(':
        co += 1
    if ch == ')':
        if co > 0:
            co -= 1
        else:
            cc += 1

ans = "(" * cc + "".join(s) + ")" * co
print(ans)

Measured memory_bytes: 38256
N=int(input())
A,B=map(int,input().split())
a=list(map(int,input().split()))
j=k=l=0
for i in a:
    if i<(A+1):
        j=j+1
    elif A<i<(B+1):
        k=k+1
    else:
        l=l+1
if j<k and j<l:
    print(j)
elif k<j and k<l:
    print(k)
else:
    print(l)

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

int main() {
  int H,N; cin>>H>>N;
  vector<int> A(N);
  vector<int> B(N);
  rep(i,N) cin>>A.at(i)>>B.at(i);
  vector<int> DP(30000,167167167);
  DP[0]=0;
  for(int i=0;i<20000;i++){
    rep(j,N){
      DP[i+A.at(j)]=min(DP[i+A.at(j)],DP[i]+B.at(j));
    }
  }
  sort(A.begin(),A.end());
  int c=A.at(N-1);
  int ans=167167617;
  for(int i=H;i<=H+c;i++){
    ans=min(ans,DP[i]);
  }
  cout<<ans;
}


Measured memory_bytes: 3756
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    string n;
    cin >> n;
    for (int i = 0; i < 3; i++){
        if (n[i] == '1'){
            n[i] = '9';
        } else {
            n[i] = '1';
        }
    }
    cout << n << endl;;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

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

    int len[3];
    rep(i, 3){
        cin >> len[i];
    }
    //printArray(len, 3);
    sort(len, len + 3);
    //printArray(len, 3);
    int s = len[0] * len[1] / 2;
    cout << s << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		long num[]=new long[N];
		for(int i=0;i<N;i++) {
			num[i]=sc.nextLong();
		}
		sc.close();
		long border=1000000000000000000l;
		long result=1l;
		for(int i=0;i<N;i++) {
			if(num[i]==0) {
				System.out.println(0);
				System.exit(0);
			}
		}
		for(int i=0;i<N;i++) {
			if(result>border/num[i]) {
				System.out.println(-1);
				System.exit(0);
			}else {
				result*=num[i];
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 60952
d={}
d['AC']=0
d['WA']=0
d['TLE']=0
d['RE']=0
for i in range(int(input())):
    s=input()
    d[s]+=1
print('AC'+" x "+str(d['AC']))
print('WA'+" x "+str(d['WA']))
print('TLE'+" x "+str(d['TLE']))
print('RE'+" x "+str(d['RE']))
    

Measured memory_bytes: 9196
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val x = readLine()!!.split(" ").map { it.toInt() }
    val sortedX = x.sorted()
    val r = sortedX[n/2]
    val l = sortedX[n/2-1]

    for (n in x)
        if (n <= l) println(r)
        else println(l)
}

Measured memory_bytes: 100280
def main():
    n = int(input())
    x_lst = list(map(int, input().split()))
    ans = 10 ** 12

    for p in range(1, 101):
        sum_hp = 0
        for x in x_lst:
            sum_hp += (x - p) ** 2
        if sum_hp < ans:
            ans = sum_hp

    print(ans)


if __name__ == "__main__":
    main()


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

typedef long long unsigned ll;

char cot[101];
int main(){

    int ret,tmp,n;
    char c;
    cin>>n;

    ret=tmp=0;

    scanf("%s",cot);

    for(int i=0;i<n;i++){
        ret = max(ret,tmp);

        if(cot[i]=='I') tmp++;
        else tmp--;

        ret = max(ret,tmp);
    }
    cout<<ret;
    return 0;
}


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

#define MAX 100
#define NIL -1

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

Node T[MAX];
int preorder[MAX], inorder[MAX], postorder[MAX];

int count_pre = 0;
void preOrder(int n) {
    preorder[count_pre] = n;
    count_pre++;
    if(T[n].left!=NIL) {
        preOrder(T[n].left);
    }
    if(T[n].right!=NIL) {
        preOrder(T[n].right);
    }
}

int count_in = 0;
void inOrder(int n) {
    if(T[n].left!=NIL) {
        inOrder(T[n].left);
    }
    inorder[count_in] = n;
    count_in++;
    if(T[n].right!=NIL) {
        inOrder(T[n].right);
    }
}

int count_post = 0;
void postOrder(int n) {
    if(T[n].left!=NIL) {
        postOrder(T[n].left);
    }
    if(T[n].right!=NIL) {
        postOrder(T[n].right);
    }
    postorder[count_post] = n;
    count_post++;
}

int main() {
    int n;
    int id, l, r, p;
    cin >> n;
    for(int i=0; i<n; i++) {
        T[i].parent = T[i].left = T[i].right = NIL;
    }
    for(int i=0; i<n; i++) {
        cin >> id >> l >> r;
        //idの左右の子供を入力する
        T[id].left = l;
        T[id].right = r;
        //逆に左右の子供の親としてidを登録する
        //左右の子供の兄弟としてお互いを登録する
        if(l!=NIL) {
            T[l].parent = id;
        }
        if(r!=NIL) {
            T[r].parent = id;
        }
    }
    //根の番号を特定する
    for(int i=0; i<n; i++) {
        if(T[i].parent==NIL) {
            p = i;
        }
    }

    preOrder(p);
    cout << "Preorder\n";
    cout << " ";
    for(int i=0; i<n; i++) {
        cout << preorder[i];
        if(i!=n-1) {
            cout << " ";
        }
    }
    cout << endl;

    inOrder(p);
    cout << "Inorder\n";
    cout << " ";
    for(int i=0; i<n; i++) {
        cout << inorder[i];
        if(i!=n-1) {
            cout << " ";
        }
    }
    cout << endl;

    postOrder(p);
    cout << "Postorder\n";
    cout << " ";
    for(int i=0; i<n; i++) {
        cout << postorder[i];
        if(i!=n-1) {
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3092
import java.util.Scanner;
 
class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int rate[] = {0,0,0,0,0,0,0,0};
		int exCollers = 0;
		int N = sc.nextInt();
		int i = 0;
		int tmp = 0;
		int tmp2 = 0;
		while(i<N){
			tmp = sc.nextInt();
			tmp2 = (int)tmp/400;
			if(tmp2>=8){
				exCollers++;
			}else{
				rate[tmp2]=1;
			}
			i++;
		}
		int min = 0;
		for(int j=0;j<=7;j++){
			min += rate[j];
		}
		int max = min + exCollers;
		
		if(min == 0){
			min =1;
		}
		System.out.println(min + " " + max);
	}
 
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;

int n,a,b,c;
vector<int> l;
vector<int> s;
vector<int> m;

void dfs(int i,int sum1, int sum2, int sum3,int merge1,int merge2, int merge3){
    if(i==n){
        if(merge1==0 || merge2==0 || merge3==0) return;
        int dis = abs(sum1-a)+abs(sum2-b)+abs(sum3-c);
        s.push_back(dis);
        int tot = merge1 + merge2 + merge3;
        if(merge1!=0) tot--; 
        if(merge2!=0) tot--; 
        if(merge3!=0) tot--; 
        m.push_back(tot);
        return;
    }
    dfs(i+1,sum1,sum2,sum3,merge1,merge2,merge3);
    dfs(i+1,sum1+l[i],sum2,sum3,merge1+1,merge2,merge3);
    dfs(i+1,sum1,sum2+l[i],sum3,merge1,merge2+1,merge3);
    dfs(i+1,sum1,sum2,sum3+l[i],merge1,merge2,merge3+1);
}

int main(){
    cin >> n >> a >> b >> c;
    rep(i,n) {
        int tmp;
        cin >> tmp;
        l.push_back(tmp);
    }
    dfs(0,0,0,0,0,0,0);
    int ans = 1e9;
    rep(i,(int)s.size()){
        int now;
        now = s[i] + m[i]*10;
        ans = min(now,ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

	vector<pair<string, int>> a;

	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;

		bool b = true;
		for (int j = 0; j < a.size(); j++)
		{
			if (s == a.at(j).first)
			{
				a.at(j).second++;
				b = false;
				break;
			}
		}

		if (b)
		{
			a.push_back(make_pair(s, 1));
		}
	}

	cin >> m;

	for (int i = 0; i < m; i++)
	{
		string t;
		cin >> t;

		for (int j = 0; j < a.size(); j++)
		{
			if (t == a.at(j).first)
			{
				a.at(j).second--;
				break;
			}
		}
	}

	int maxi = 0;
	for (int i = 0; i < a.size(); i++)
	{
		maxi = max(maxi, a.at(i).second);
	}

	cout << maxi << endl;
}

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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

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

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 100000;

int N, H, W;


struct S{
	int x, y, d;
	bool operator <(const S &a)const{
		return d<a.d;
	}
};
vector<S> v;

ll ans;

vector<int> gp[MAX_N*2+1];
bool chk[MAX_N*2+1];

int g[MAX_N*2+1];

void init_g(){
	for(int i=2; i<=H+W; i++)	g[i] = i;
}

int find_g(int x){
	return (x==g[x])?x:g[x] = find_g(g[x]);
}

void union_g(int x, int y){
	x = find_g(x); y = find_g(y);
	g[x] = y;
}

void make(int x, int y){
	chk[x] = true;
	for(int i : gp[x]){
		if(i!=y){
			make(i, x);
		}
	}
}

int main(){
	cin>>N>>H>>W;
	init_g();
	for(int i=1; i<=N; i++){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		v.pb((S){a, b+H, c});
	}
	sort(v.begin(), v.end());
	while(!v.empty()){
		S now = v.back(); v.pop_back();
		if(chk[now.x] && !chk[now.y]){
			make(now.y, 0);
			ans+=(ll)now.d;
		}
		else if(!chk[now.x] && chk[now.y]){
			make(now.x, 0);
			ans+=(ll)now.d;
		}
		else if(!chk[now.x] && !chk[now.y]){
			if(find_g(now.x)==find_g(now.y)){
				make(now.x, 0);
			}
			gp[now.x].pb(now.y);
			gp[now.y].pb(now.x);
			union_g(now.x, now.y);
			ans+=(ll)now.d;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 14452
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> p_num(51, 0);
    vector<ll> t_num(51, 0);
    p_num[0] = 1;
    t_num[0] = 1;
    for (int i = 1; i <= 50; ++i) {
        p_num[i] = p_num[i-1] * 2 + 1;
        t_num[i] = t_num[i-1] * 2 + 3;
    }
    int idx = n;
    ll ans = 0;
    //cout << idx << " " << x << endl;
    while(1) {
        if (x == 0 || idx < 0) break;
        //cout << t_num[idx] << endl;
        if (x == t_num[idx]) {
            ans += p_num[idx];
            break;
        }
        if (x == t_num[idx] / 2LL + 1LL) {
            ans += p_num[idx-1] + 1LL;
            break;
        }
        else if (x > t_num[idx] / 2LL + 1LL) {
            ans += p_num[idx-1] + 1LL;
            x -= t_num[idx-1] + 2LL;
        }
        else {
            //cout << "test" << endl;
            x -= 1LL;
        }
        --idx;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
MOD=1000000007
N=int(input())
d = {}
pairs=[-1]*N

for i in range(N):
    c = int(input())
    if c in d and i-d[c]>1:
        pairs[d[c]] = i
    d[c]=i
    
dp1,dp2=[0]*N,[0]*N
prev=1
for src in range(N):
    dp2[src]=(prev+dp1[src])%MOD
    dst = pairs[src]
    if dst>0:
        dp1[dst] = (dp1[dst]+dp2[src])%MOD
    prev=dp2[src]
print(dp2[-1])


Measured memory_bytes: 74328
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int MAX = 1e5 + 1;
struct edge{
    int v; // 次の頂点.
    LL  w; // 距離.
};
LL dist[MAX]; // 距離を保存

// グラフを幅優先探索する.
// https://ja.wikipedia.org/wiki/幅優先探索
// ※bfsの動作確認用.
// @param G: グラフ.
// @param s: グラフの探索開始頂点.
// @return: 特に無し.
void bfs(vector<vector<edge>> &G, int s){
    
    // 1. 空のキュー.
    queue<int> q;
    
    // 2. 訪問済みフラグ設定.
    // ※スタート地点は, 距離ゼロを指定.
    dist[s] = 0;
    
    // 3. 探索地点 s をキュー q に追加.
    q.push(s);
    while(!q.empty()){

        // 4. キューから取り出す.
        int u = q.front();
        q.pop();

        // 5. 取り出した要素を処理.
        for(auto &e : G[u]){
            // 6. 訪問済であれば, 処理をスキップ.
            // cout << "u=" << u << " e.v=" << e.v << " e.w=" << e.w << endl;
            if(dist[e.v] > 0)              continue;
            if(dist[e.v] == 0 && e.v != s) dist[e.v] = dist[u] + e.w, q.push(e.v);
        }
    }
    return;
}

int main() {
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    vector<vector<edge>> graph(N);
    for(LL i = 0; i < N - 1; i++){
        int u, v;
        LL w;
        scanf("%d %d %lld", &u, &v, &w);
        edge e1, e2;
        u--, v--;
        // u -> v
        e1.v = v, e1.w = w;
        graph[u].push_back(e1);
        // v -> u
        e2.v = u, e2.w = w;
        graph[v].push_back(e2);
    }
    
    // 2. 頂点を一つ固定して, そこから各頂点への距離を保存.
    bfs(graph, 0);
    // for(int i = 0; i < N; i++) printf("%lld ", dist[i]);
    // printf("\n");
    
    // 3. 出力 ～ 後処理.
    // 頂点 0 からの距離が, 偶数: 白色, 奇数: 黒色.
    for(int i = 0; i < N; i++){
        LL d = dist[i];
        if(d % 2 == 0) printf("%d\n", 0);
        else           printf("%d\n", 1);
    }
    return 0;
    
}

Measured memory_bytes: 8704
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def grundy(a,k):
    while 1:
        if a<k:return 0
        if a%k==0:return a//k
        once=a//k+1
        seg=a%k
        cnt=(seg+once-1)//once
        a-=cnt*once

win=0
for _ in range(II()):
    a,k=MI()
    win^=grundy(a,k)

if win:print("Takahashi")
else:print("Aoki")


Measured memory_bytes: 63948
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

ll max3(ll a, ll b, ll c){
    if(a >= b && a >= c)return a;
    if(b >= a && b >= c)return b;
    return c;
}

ll min3(ll a, ll b, ll c){
    if(a <= b && a <= c)return a;
    if(b <= a && b <= c)return b;
    return c;
}

int main() {
    ll h, w, ans = inf;
    cin >> h >> w;
    REP(i, h){
        ll a, b, c;
        a=i*w;b=(h-i)/2*w;c=((h-i)-(h-i)/2)*w;
        ans = min(ans, max3(a,b,c)-min3(a,b,c));
        a=i*w;b=w/2*(h-i);c=(w-w/2)*(h-i);
        ans = min(ans, max3(a,b,c)-min3(a,b,c));
        a=(h-i)*w;b=i/2*w;c=(i-i/2)*w;
        ans = min(ans, max3(a,b,c)-min3(a,b,c));
        a=(h-i)*w;b=w/2*i;c=(w-w/2)*i;
        ans = min(ans, max3(a,b,c)-min3(a,b,c));
    }
    swap(h, w);
    REP(i, h){
        ll a, b, c;
        a=i*w;b=(h-i)/2*w;c=((h-i)-(h-i)/2)*w;
        ans = min(ans, max3(a,b,c)-min3(a,b,c));
        a=i*w;b=w/2*(h-i);c=(w-w/2)*(h-i);
        ans = min(ans, max3(a,b,c)-min3(a,b,c));
        a=(h-i)*w;b=i/2*w;c=(i-i/2)*w;
        ans = min(ans, max3(a,b,c)-min3(a,b,c));
        a=(h-i)*w;b=w/2*i;c=(w-w/2)*i;
        ans = min(ans, max3(a,b,c)-min3(a,b,c));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    s = input()
    s = s.replace('BC', 'D')
    a = 0; d = 0
    ans = 0
    for t in s:
        if a > 0:
            if t == 'D':
                d += 1
            elif t == 'A':
                if d > 0:
                    ans += a*d
                    d = 0
            elif t != 'D' and d > 0:
                ans += a*d
                a = 0
                d = 0
            else:
                a = 0
                d = 0
        a += (t == 'A')
    if a > 0 and d > 0:
        ans += a*d
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9332
import java.util.Scanner;
public class Main {
 public static void main(String[] args) {
  Scanner sc=new Scanner(System.in);
  int N=sc.nextInt();
  int hm [][]=new int[200][5];
  for(int i=0;i<N;i++){
   for(int k=0;k<3;k++){
    hm[i][k]=sc.nextInt();
   }
   hm[i][3]=0;
  }
  for(int j=0;j<3;j++){
   for(int a=0;a<N;a++){
	hm[a][4]=0;
    for(int b=0;b<N;b++){
     if(a!=b && hm[a][j]==hm[b][j]){
      hm[a][4]=1;
     }
    }
    if(hm[a][4]==0){
     hm[a][3]=hm[a][3]+hm[a][j];
    }
   }
  }
  for(int d=0;d<N;d++){
	  System.out.println(hm[d][3]);
  }
 }
}

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

int getDivNum(int n){
    int res = 1;
    for(int i = 2;i <= sqrt(n);++i){
        if(n % i == 0)
        {
            if(i != n / i) res++;
            res++;
        }
    }
    if(n != 1) res++;
    return res;
}

void calculate(){
    int N;
    cin >> N;
    int res = 0;
    for(int i = 1;i <= N;i += 2)
        if(getDivNum(i) == 8) res++;
    cout << res << '\n';
}

int main(int, char**) {
    calculate();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, t, a; cin >> n >> t >> a;
    vector<int> h(n); rep (i, n) cin >> h[i];
    double best = 1e10;
    int ans = 0;
    rep (i, n) if (chmin(best, abs((double)a - ((double)t - 0.006 * h[i])))) ans = i + 1;
    cout << ans << "\n";
    return 0;
}

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

#define MAXLEN 2*10000


int mycmp(const void* aa, const void* bb) {
	const int* a = aa;
	const int* b = bb;
	if (*a > *b) {
		return 1;
	} else if (*a < *b) {
		return -1;
	} else {
		return 0;
	}
}

int main(void) {
	unsigned int n;
	scanf("%u", &n);

	//long unsigned int as[MAXLEN], bs[MAXLEN];
	/*for (size_t i = 0; i < MAXLEN; i++) {
		as[i] = -1;
		bs[i] = -1;
	}*/

	long unsigned int* as = malloc(sizeof(long unsigned int) * n);
	long unsigned int* bs = malloc(sizeof(long unsigned int) * n);

	for (unsigned int i = 0; i < n; i++) {
		scanf("%lu %lu", as+i, bs+i);
	}

	qsort(as, n, sizeof(long unsigned int), mycmp);
	qsort(bs, n, sizeof(long unsigned int), mycmp);

	long unsigned int ans;
	
	if (n % 2 == 1) {
		long unsigned int a, b;
		a = as[(n-1)/2];
		b = bs[(n-1)/2];
		ans = b - a + 1;
	} else {
		long unsigned int a0, a1, b0, b1;
		a0 = as[(n-1)/2];
		a1 = as[n/2];
		b0 = bs[(n-1)/2];
		b1 = bs[n/2];
		ans = b0 - a0 + b1 - a1 + 1;
	}
	
	printf("%lu\n", ans);
	//fprintf(stderr, "OK!\n");
	return 0;
}


Measured memory_bytes: 6392
import sys
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    if N == 1:
        ans = 1
    else:
        ans = 2 ** int(math.log2(N))
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    ll N;

    cin >> N;

    if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8){
        cout << "pon" << endl;
    }else if(N % 10 == 3){
        cout << "bon" << endl;
    }else{
        cout << "hon" << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    if(k*2>=b-a+1){
        for(int i=a;i<=b;i++)
            cout<<i<<'\n';
    }
    else{
        for(int i=a;i<=a+k-1;i++)
            cout<<i<<'\n';
        for(int i=b-k+1;i<=b;i++)
            cout<<i<<'\n';
    }
    return 0;
}

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

double inf = numeric_limits<double>::infinity();

#define REP(i,n) for(int i=0;i<n;i++)
using LL = long long int;
LL GCD(LL a,LL b){ if(a<b) return GCD(b,a); else if(a%b==0) return b; else return GCD(b,a%b); }
LL LCM(LL a,LL b){ return (a/GCD(a,b))*b; }

vector<vector<LL>> v;
vector<LL> color;

int main() {
    int h, w;
    cin >> h >> w;
    char v[h][w];
    REP(i,h) {
        REP(j,w) {
            char k;
            cin >> k;
            v[i][j] = k;
        }
    }
    
    REP(i,h) {
        REP(j,w) {
            int cnt = 0;
            for (int x = i-1; x <= i+1; x++) {
                for (int y = j-1; y <= j+1; y++) {
                    if (v[i][j] != '#' && x >= 0 && x < h && y >= 0 && y < w) {
                        if (!(x == i && y == j) && v[x][y] == '#') {
                            cnt++;
                        }
                    }
                }
            }
            if (v[i][j] != '#') {
                v[i][j] = '0' + cnt;
            }
         }
    }
    
    REP(i,h) {
        REP(j,w) {
            cout << v[i][j];
        }
        cout << endl;
    }
}


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

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if ((b-a)%2==0) {
        cout << (b-a)/2 << endl;
        return 0;
    }
    else {
        cout << min(a+(b-a)/2,n-b+1+(b-a-1)/2) << endl;
        return 0;
    }
    return 0;
}


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

int main()
{
  int a;
  string b;
  cin >> b;
  if (b[0] == '1')
    a++;
  if (b[1] == '1')
    a++;
  if (b[2] == '1')
    a++;
  cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
using namespace std;

int main(){
    long n;
    cin >> n;
    double m = n;
    long ans = 1000000000000;
    double sqrt = pow(m, 0.5);
    for(long i = 1; i <= (long)sqrt; i++){
        if(n%i == 0){
            long j = n/i;
            long tmp = i+j-2;
            ans = min(ans, tmp);
        }
    }
    cout << ans <<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main(){
    int n,max=0;
    int in[100]={0};
    while(cin>>n){
        in[n]++;
        if(max<in[n])max=in[n];
    }
    for(int i=0;i<100;i++){
     
        if(max==in[i])cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 2984
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 1000000007
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif
const int INF = 0x7fffffff;
const int N=2e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}
ll ans;
int bin[21],n,llst[21],a[N][21],lst[21];
int main(){
#ifdef Devil_Gary
	freopen("in.txt","r",stdin);
#endif
	n=read();
	bin[0]=1;
	for(int i=1;i<=20;i++) bin[i]=bin[i-1]<<1;
	for(int i=1;i<=n;i++){
		int x=read();
//		bug(x);
	 	for(int j=0;j<=20;j++) {
			a[i][j]=(x&bin[j])>0;
//			bug(a[i][j]);
		 	if(a[i][j]) llst[j]=lst[j],lst[j]=i;	
		}
		int tmp=0;
		for(int j=0;j<=20;j++){
			tmp=max(tmp,llst[j]+1);
		}
		ans+=(i-tmp+1);
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
 
void solve() {
    string s, t;
  	cin>>s>>t;
  	int ans=0;	
  	for(int i=0; i<s.size(); i++) {
    	if(s[i]!=t[i]) ans++;
    }
  	cout<<ans;
}
 
int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    long long t=1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3716
#include <stdio.h>

int main(void){
	int hb,mb,sb,ha,ma,sa,h[3],m[3],s[3];
	int byoub,byoua,byou;
	int i;

	for(i=0;i<3;i++){
		scanf("%d %d %d %d %d %d\n",&hb,&mb,&sb,&ha,&ma,&sa);

		byoub=hb*60*60+mb*60+sb;
		byoua=ha*60*60+ma*60+sa;
		byou=byoua-byoub;

		s[i]=byou%60;
		byou-=s[i];
		m[i]=byou%(60*60);
		byou-=m[i];
		h[i]=byou;

		m[i]/=60;
		h[i]/=60*60;
	}

	for(i=0;i<3;i++){
		printf("%d %d %d\n",h[i],m[i],s[i]);
	}
	return 0;
}

Measured memory_bytes: 1032
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX 1000000001
using ll=long long;

int n;
vector<int> h(100);

int main(){
    cin>>n;
    rep(i,n) cin>>h[i];
    bool flag;
    int count=0;
    do{
        int i;
        for(i=0;i<n;){
            while(h[i]==0) i++;
            if(i>=n) break;
            int j=i;
            while(h[j]!=0&&j<n) j++;
            j--;
            for(int k=i;k<=j;k++) h[k]--;
            count++;
            i=j+1;
        }

        flag=false;
        for(int i=0;i<n;i++)if(h[i]>0){
            flag=true;break;
        }
    }while(flag);

    cout<<count<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//a??¨b?????§?????????

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//a??¨b????°??????????

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//a??¨b???????????¶??????

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//p????´???°,a???b??????p??§?????£?????????

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//p????´???°,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//?????§??¬?´???°

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//????°???¬?????°

int main() {
	
	int x, y;

	while (1) {

		cin >> x >> y;
		if (x == 0 && y == 0)break;
		else printf("%d %d\n", min(x, y), max(x, y));

	}

	return 0;
}

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

using namespace std;

int main()
{
    long int a, b,p;
    cin>>a>>b;
    p=a*b;
    if(p%2 == 0){
        cout<<"Even"<<endl;

    }
    else
    {
               cout<<"Odd"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
<?php
 
while($line = fgets(STDIN)){
    $arrA = explode(" ", trim($line));
     
    $line = fgets(STDIN);
    $arrB = explode(" ", trim($line));
     
    $hit = 0;
    $brow = 0;
    for($i = 0; $i < count($arrA); $i++){
        if($arrA[$i] == $arrB[$i]){
            $hit++;
        }
        for($j = 0; $j < count($arrB); $j++){
            if($arrA[$i] == $arrB[$j]){
                $brow++;
            }
        }
    }
     
    $brow -= $hit;
    echo "{$hit} {$brow}\n";
}

Measured memory_bytes: 15296
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------

int main() {

  ll n;
  cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];

  ll res = a[0];
  for(int i=1; i<n; ++i) {
    res = gcd(res, a[i]);
  }

  cout << res << endl;

  return 0;
}


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

int main(){
  string s; cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i] >= 'D' && s[i] <= 'Z') s[i] -= 3;
    else s[i] += 23;
  }
  cout << s << endl;
}

Measured memory_bytes: 1180