akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
  int N;
  cin >> N;
  int tmp;
  int c = 0;
  for (int i = 1; i <= N; i++) {
    cin >> tmp;
    if (tmp % 2 == 1 and i % 2 == 1) {
      c++;
    }
  }
  cout << c;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の
string型配列と同じような感じ） map<int, string> mp; for (auto itr =mp.begin();
itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


Measured memory_bytes: 3564
import decimal

N = int(input())
A = [int(decimal.Decimal(input()) * 10 ** 9) for _ in range(N)]
B = [[0] * 19 for _ in range(19)]
for a in A:
    cnt2 = 0
    while a % 2 == 0:
        cnt2 += 1
        a //= 2
    cnt5 = 0
    while a % 5 == 0:
        cnt5 += 1
        a //= 5
    B[min(cnt2, 18)][min(cnt5, 18)] += 1
ans = 0
for i in range(361):
    a, r = divmod(i, 19)
    if a >= 9 and r >= 9:
        ans -= B[a][r]
    for j in range(361):
        b, s = divmod(j, 19)
        if a + b >= 18 and r + s >= 18:
            ans += B[a][r] * B[b][s]

ans //= 2
print(ans)

Measured memory_bytes: 276228
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  ll N;
  cin >> N;
  vector<ll> V;
  rep(i, 5) {
    ll v;
    cin >> v;
    V.push_back(v);
  }

  sort(V.begin(), V.end());

  ll target = V[0];

  ll additional = ceil(1.0 * N / target) - 1;

  ll result = 5 + additional;

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int,input().split())))
B = [0 for _ in range(N+1)]
for i in range(N):
    B[i+1] = B[i]+A[i]
cnt = 1
for i in range(N-2,-1,-1):
    if 2*B[i+1]>=A[i+1]:
        cnt += 1
    else:
        break
print(cnt)

Measured memory_bytes: 14404
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

struct BIT {
	vector<int> bit;

	BIT(int n) : bit(n+1) {}

	int sum(int i) {
		int s = 0;
		while(i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}

	void add(int i,int x) {
		while(i <= bit.size()) {
			bit[i] += x;
			i += i & -i;
		}
	}
};

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

	BIT bit(n);
	rep(i, q) {
		int a, b, c;
		cin >> a >> b >> c;

		if(a == 0) {
			bit.add(b, c);
		} else {
			cout << bit.sum(c) - bit.sum(b-1) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1532
#include<cstdio>
#include<iostream>
#include<string.h>
#include<cstring>
using namespace std;

string s;
int now,last;
int ans;

int main(){
    cin >> s;
    while(now < s.size()){
        if(now-last == 0){
            if(s[now] != s[now+1]){
                ans++;now++;last++;continue;
            }
            if(s[now] == s[now+1]){
                ans++;now += 2;last++;continue;
            }
        }
        else
            ans++;now++;last = now;        
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  int n, m;
  cin >> n >> m;
  map<int, bool> broken;
  rep(i, m) {
    int a;
    cin >> a;
    broken[a] = true;
  }

  vector<ll> dp(n + 1);
  dp[0] = 1;
  if (!broken[1]) dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (broken[i]) continue;
    dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    // dp[i] %= mod;
  }

  cout << dp[n] << endl;
  return 0;
}

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

int main(){
  int n,k[10001],hoge,flag;
  
  while(1){
    flag=0;
    hoge=0;
    cin >> n;
    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin >> k[i];
      if(k[i]>=2){
	flag=1;
      }
      if(k[i]>0){
	hoge++;
      }
    }
    if(flag==0){
      cout << "NA\n";
    }else if(n==1){
      cout << "2\n";
    }else{
      cout << hoge+1 << '\n';
    }
  }
  return 0;
}
      



Measured memory_bytes: 3140
n,m = map(int,input().split())
item = list(map(int,input().split()))

#品物を高い順に並び替える
item.sort(reverse=True)

#割引券がなくなるまで操作を繰り返す
while m != 0:
    
    #品物の高いものから順に割引券を使用していく
    for i in range(n):
        
        #一番高い品物の割引券を使用した後の値段はtempとして保持しておく
        if i == 0:
            item[i] = int(item[i]/2)
            m -= 1
            temp = item[i]
            if m == 0:
                break
            continue
        
        #tempよりも品物の値段が高い間は割引券を使用しながらfor文を回し続ける
        if item[i] > temp:
            item[i] = int(item[i]/2)
            m -= 1
            if m == 0:
                break
            continue
        
        #tempよりも品物の値段が安くなったら、もう一度値段の高い順にソートし直して操作を繰り返す
        item.sort(reverse=True)
        break

#品物の値段を合計して出力        
print(sum(item))

Measured memory_bytes: 14224
N=int(input())
S=[1,2,3,4,5,6,7,8,9,10,11,12,13]
H=[1,2,3,4,5,6,7,8,9,10,11,12,13]
C=[1,2,3,4,5,6,7,8,9,10,11,12,13]
D=[1,2,3,4,5,6,7,8,9,10,11,12,13]
for i in range(N):
    L=list(map(str,input().split()))
    
    if L[0]=="S":
        S.remove(int(L[1]))
    elif L[0]=="H":
        H.remove(int(L[1]))
    elif L[0]=="C":
        C.remove(int(L[1]))
    else:
        D.remove(int(L[1]))
for i in S:
    print("S",i)
for j in H:
    print("H",j)
for k in C:
    print("C",k)
for z in D:
    print("D",z)




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

using namespace std;

#define rep(i,s,e) for(int i=s; i<e; i++)

int main(){
    int k, s;
    cin >> k >> s;

    int sum = 0;
    rep(i,0,k+1){
        rep(j,0,k+1){
            int t = s - i - j;
            if( t >= 0 && t <= k ) sum++;
        }
    }

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


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a[] = new int[3];
		for(int i=0;i<a.length;i++)a[i]=scan.nextInt();
		scan.close();
		Arrays.sort(a);
		System.out.println(a[1]-a[0]+a[2]-a[1]);
	}
}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N,M,K;



ll dfs(int n, int s){
  if(n==N) return max(1, s);
  ll res = 0;
  for(int i=1;i<=M;i++){
    res += dfs(n+1, s+i);
  }
  return res;
}

int main(){
  while(cin >> N >> M >> K && N+M+K){
    cout << fixed << setprecision(12) << dfs(0, -K)/(double)pow(M, N) << endl;
  }
  return 0;
}

Measured memory_bytes: 1288
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		100000									// 最大配列数

// 内部変数
static FILE *szpFpI;											// 入力
static long long sl1ArrayA[D_ARRAY_MAX];						// 配列A
static long long sl1ArrayB[D_ARRAY_MAX];						// 配列B
static int siACnt;												// 配列数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
long long
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 配列数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siACnt);

	// 配列 - 取得
	for (i = 0; i < siACnt; i++) {
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%lld%lld", &sl1ArrayA[i], &sl1ArrayB[i]);
	}

	// 回数 - 取得
	long long llCnt = 0;
	for (i = siACnt - 1; i >= 0; i--) {
		sl1ArrayA[i] += llCnt;
		llCnt += (sl1ArrayB[i] - sl1ArrayA[i] % sl1ArrayB[i]) % sl1ArrayB[i];
	}

	return llCnt;
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// １行出力
	sprintf(lc1Buf, "%lld\n", llRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
int main(void) {
    int i,y,x[100];
    scanf("%d", &y);
    for(i=0; i<y; i++){
        scanf("%d", &x[i]);
    }
    for(i=y-1; i>=0; i--){
        if(i != y-1){
            printf(" ");
        }
        printf("%d", x[i]);
    }
    puts("");
    return 0;
}


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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    int n,ans=0;
    cin>>n;
    Vi a(n),b(n);
    REP(i,0,n) cin>>a[i];
    REP(i,0,n) cin>>b[i];
    REP(i,0,n) if(a[i]>b[i]) ans+=(a[i]-b[i]);
    cout<<ans<<ENT;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 256
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_owned()
}

fn reads<T>() -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    read_line()
        .split_whitespace()
        .map(|w| w.parse().unwrap())
        .collect()
}

fn main() {
    let n: i32 = reads()[0];
    let s: Vec<String> = reads();

    println!(
        "{}",
        if s.iter().any(|c| c == "Y") {
            "Four"
        } else {
            "Three"
        }
    );
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[30][30];
ll dp[25][2100000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        REP(j, N) {
            cin >> A[i][j];
        }
    }
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    ll p = pow(2LL, N);
    vector<ll> v;
    v.push_back(0);
    REP(i, N) {
        vector<ll> t;
        for (auto &b:v) {
            REP(j, N) {
                if (((b >> j) & 1) == 1)
                    continue;
                if (A[i][j] == 0)
                    continue;
                dp[i + 1][b | (1LL << j)] += dp[i][b];
                dp[i + 1][b | (1LL << j)] %= MOD;
                t.push_back(b | (1LL << j));
            }
        }
        sort(t.begin(), t.end());
        t.erase(unique(t.begin(), t.end()), t.end());
        swap(v, t);
    }
    cout << dp[N][p - 1] << endl;
    return 0;
}

Measured memory_bytes: 491864
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


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


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


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


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, C, D, S):

    C = (C[0]-1, C[1]-1)
    D = (D[0]-1, D[1]-1)
    q = deque()
    q.append((0, C))
    memo = {}
    while q:
        c, (x, y) = q.popleft()
        if (x, y) in memo:
            continue
        memo[(x, y)] = c
        for nx, ny in [(x, y-1), (x, y+1), (x-1, y), (x+1, y)]:
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '.':
                q.appendleft((c, (nx, ny)))

        for nx in range(x-2, x+3):
            for ny in range(y-2, y+3):
                if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '.':
                    q.append((c+1, (nx, ny)))


    return -1 if tuple(D) not in memo else memo[D]


def main():
    H, W = read_int_n()
    C = read_int_n()
    D = read_int_n()
    S = [read_str() for _ in range(H)]
    print(slv(H, W, C, D, S))


if __name__ == '__main__':
    main()


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

using namespace std;

int m, w;
int bm[20], bw[20];
int dp[12][1 << 12];

int cost(int bm, int bw) {
    int diff = abs(bm -bw);
    return diff * (diff - 30) * (diff - 30);
}

int solve(int cnt, int b) {

    if(cnt >= m) {
        return 0;
    }

    if(dp[cnt][b] != -1) {
        return dp[cnt][b];
    }

    int ret = solve(cnt + 1, b);

    for(int i = 0; i < w; ++i) {
        if(!(b >> i & 1)) {
            ret = max(ret, solve(cnt + 1, b | 1 << i) + cost(bm[cnt], bw[i]));
        }
    }

    return dp[cnt][b] = ret;
}

int main() {

    while(cin >> m >> w, m || w) {

        for(int i = 0; i < m; ++i) {
            cin >> bm[i];
        }

        for(int i = 0; i < w; ++i) {
            cin >> bw[i];
        }

        memset(dp, -1, sizeof(dp));
        cout << solve(0, 0) << endl;

    }

}

Measured memory_bytes: 3284
N = int(input())
S = input()
 
r_cnt = S.count('R')
g_cnt = S.count('G')
b_cnt = S.count('B')

ans = r_cnt * g_cnt * b_cnt
 
for i in range(N):
    for j in range(i,N):
        k = 2*j - i
        if k >= N:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans -= 1
#         print(i,j,k)

print(ans)

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


int main()
{
	int number[32];
	int index, pairnum;
	int a,b,tmp,i;
	cin >> index;
	cin >> pairnum;
	for( i = 0; i <32; i++ ) {
		number[i] = i;
	}

	for( i = 0; i < pairnum; i++ ) {
		scanf("%d,%d",&a,&b);
		tmp = number[a];
		number[a] = number[b];
		number[b]= tmp;
	}

	for( i = 1; i < index+1; i++ ) {
		printf("%d\n",number[i]);

	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string n,res="";
    cin >> n;
    int64_t tmp = (n.at(0) - '0') * 111;
    if(tmp >= stoi(n)){
        cout << (n.at(0) - '0') * 111 << endl;
    }else{
        int64_t tmp = n.at(0) - '0' + 1;
        cout << tmp * 111 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

vector<ll> A;
ll cnt[50];
ll mu[50];

string cal(){
    ll num;
    cin >> num;
    A.pb(num);
    string ans = "";
    rep(i, 50){
        if(num % 2 == 0) ans = "0" + ans;
        else ans = "1" + ans;
        num /= 2;
    }
    return ans ;
}

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

    
    ll N , K ;
    cin >> N >> K ;
    
    rep(i, N){
        string inp = cal();
        rep(j, inp.size()){
            if(inp[j] == '1') cnt[j] ++;
        }
    }

    ll now = 1;
    rep(i, 50){
        if(i == 0) mu[49-i] = now;
        else{
            now *= 2;
            mu[49-i] = now;
        }
    }
    
    ll res = 0;
    ll half = N - N/2 ;
    rep(i, 50){
        if(cnt[i] < half){
            if(mu[i] <= K){
                K-=mu[i];
                res += mu[i];
            }
        }
    }
    
    ll ans = 0;
    rep(i, N){
        ans += (res^A[i]);
    }
    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 1e2 + 10;
const int mod = 1e9 + 7;


string h;
int n;
set < int > h_set;
multiset < int > m_set;
int cnt[N];
void rec(int sz)
{
    if (h.size() == sz)
    {
        cout << h << "\n";
        return;
    } else
    {
        int kek = h_set.size();
        for (int j = 0; j <= kek; ++j)
        {
            h += char(j + 'a');
            h_set.insert(j);
            ++cnt[j];
            rec(sz);
            --cnt[j];
            if (!cnt[j]) h_set.erase(j);
            h.pop_back();
        }
    }
}

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    rec(n);

    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define forn(i,n1, n2) for (ll i = n1; i < n2; i++)
#define w(t) ll t;cin>>t;while(t--)
#define en "\n"
#define f first
#define s second
const ll mod = 1000000007;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k,sum=0,i;cin>>k;
    for(i=1;i<=1000005;i++)
    {
        sum*=10;
        sum+=7;
        if(sum%k==0){cout<<i;exit(0);}
        sum=sum%k;
    }
    cout<<-1<<en;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    vs64 minus(n, 0);
    rep (i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (a > b) swap(a, b);
        minus[b] += a + 1;
    }

    s64 dp[2];
    dp[0] = 1;
    s64 ans = dp[0];
    int now = 0;
    for (int i = 1; i < n; ++i)
    {
        dp[now ^ 1] = dp[now] + i + 1 - minus[i];
        now ^= 1;
        ans += dp[now];
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 4716
#include<bits/stdc++.h>
using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;
int main()
{
  int N;
  string  s;
  cin>>N>>s;
  if(s.size()<=N){
    cout<<s;
  }else{
    for(int i=0;i<N;i++){
      cout<<s[i];
    }
    cout<<"...";
  }
  return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, r = 0, b = 0;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			r++;
		} else {
			b++;
		}
	}
	cout << (r > b ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (size_t i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  double a, b, x;
  cin >> a >> b >> x;
  x /= a;
  double Ans = 0.0;
  if (2 * x <= a * b) {
    double a_ = 2 * x / b;
    double c = sqrt(a_ * a_ + b * b);
    double h = 2 * x / c;
    Ans = 90.0 - (asin(h / b) * (180.0 / M_PI));
  } else {
    double x_ = a * b - x;
    double b_ = 2 * x_ / a;
    double c = sqrt(a * a + b_ * b_);
    double h = 2 * x_ / c;
    Ans = (asin(h / a) * (180.0 / M_PI));
  }
  cout << setprecision(10) << Ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;


int main() {
  string S, T;
  cin >> S >> T;
  int a = S.size(), b=T.size();
  int jud = 0;
  if (a+1!=b) jud++; 
  for (int i = 0; i<a; i++) {
    if (S.at(i)!=T.at(i)) jud++;
  }
  if (jud==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
    

}

Measured memory_bytes: 3600
from collections import*
n,k,*h=map(int,open(0).read().split())
dp=defaultdict(int)

for i in range(1,n+1):
    dp[i]=float("inf")
dp[0]=0
for i in range(n):
    for j in range(1,k+1):
        if i+j<n:
            dp[i+j]=min(abs(h[i]-h[i+j])+dp[i],dp[i+j])
        else:
            break
print(dp[n-1])

Measured memory_bytes: 64408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include <math.h>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  double n;
  cin >> n;
  double ans = 2*n*M_PI;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3784
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef int LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline int read(){
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
string s;
int main(){
    cin>>s;
    for(int i=0;i<s.length()-8;i++)putchar(s[i]);
}

Measured memory_bytes: 888
import sys
INPUT = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 9)


def main():
    S = INPUT()
    l = len(S)

    for i in range(2 ** (l - 1)):
        tmp = S[0]
        for j in range(l - 1):
            if (i >> j) & 1: tmp += "+"
            else: tmp += "-"
            tmp += S[j + 1]

        if eval(tmp) == 7:
            print(tmp + "=7")
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
//using
using namespace std;
/*using vi = vector<int>;
using vs = vector<string>;
using vc = vector<char>;*/
//define
#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
//グローバル変数宣言
int a=0,b=0,c=0;

signed main(){
    cin>>a>>b;
    vector<int>x(a),y(a);
    rep(i,a)cin>>x[i]>>y[i];
    rep(i,a){if(b*b>=x[i]*x[i]+y[i]*y[i])c++;}
    cout<<c<<endl;
}

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

int main(void){
    int N;
    long long int C;

    scanf("%d%lld", &N, &C);

    int i;

    long long int *x = (long long int *) malloc(sizeof(long long int) * N);
    int *v = (int *) malloc(sizeof(int) * N);

    for(i = 0; i < N; i ++){
        scanf("%lld%d", x + i, v + i);
    }
    // 右回り
    long long int c = v[0] - x[0];
    long long int c2 = v[0] - 2 * x[0];
    long long int c_max = 0;
    long long int c2_max = 0;
    long long int *c_forward = (long long int *) malloc(sizeof(long long int) * N);
    long long int *c2_forward = (long long int *) malloc(sizeof(long long int) * N);

    if(c > c_max){
        c_max = c;
    }
    if(c2 > c2_max){
        c2_max = c2;
    }
    c_forward[0] = c_max;
    c2_forward[0] = c2_max;

    for(i = 1; i < N; i ++){
        c += v[i] - (x[i] - x[i - 1]);
        c2 += v[i] - 2 * (x[i] - x[i - 1]);

        if(c > c_max){
            c_max = c;
        }
        if(c2 > c2_max){
            c2_max = c2;
        }
        c_forward[i] = c_max;
        c2_forward[i] = c2_max;
    }
    // 左回り
    c = v[N - 1] - (C - x[N - 1]);
    c2 = v[N - 1] - 2 * (C - x[N - 1]);
    c_max = 0;
    c2_max = 0;

    long long int *c_back = (long long int *) malloc(sizeof(long long int) * N);
    long long int *c2_back = (long long int *) malloc(sizeof(long long int) * N);

    if(c > c_max){
        c_max = c;
    }
    if(c2 > c2_max){
        c2_max = c2;
    }
    c_back[N - 1] = c_max;
    c2_back[N - 1] = c2_max;

    for(i = N - 2; i >= 0; i --){
        c += v[i] - (x[i + 1] - x[i]);
        c2 += v[i] - 2 * (x[i + 1] - x[i]);

        if(c > c_max){
            c_max = c;
        }
        if(c2 > c2_max){
            c2_max = c2;
        }
        c_back[i] = c_max;
        c2_back[i] = c2_max;
    }
    // cの最大値を求める
    long long int c_max_all = 0;

    for(i = 0; i < N - 1; i ++){
        c_max = c_forward[i] + c2_back[i + 1];

        if(c_max > c_max_all){
            c_max_all = c_max;
        }
    }
    if(c_forward[N - 1] > c_max_all){
        c_max_all = c_forward[N - 1];
    }
    for(i = N - 1; i > 0; i --){
        c_max = c2_forward[i - 1] + c_back[i];

        if(c_max > c_max_all){
            c_max_all = c_max;
        }
    }
    if(c_back[0] > c_max_all){
        c_max_all = c_back[0];
    }
    printf("%lld\n", c_max_all);

    return 0;
}

Measured memory_bytes: 4480
#include<stdio.h>
//#include<stdlib.h>

int main(void)
{
  int count = 0;
  int W;
  int N;
  while(scanf("%d",&W)){
    if(W==0) break;
    count++;
    scanf("%d",&N);
    char c;
    int va;//お宝の価値
    int wi;//お宝の重さ
    int li[W+1];//袋の限界
    int i,j;
    for(i=0;i<=W;i++)
      li[i]=0;//お宝が入っていない
    
    for(i=0;i<N;i++){
      scanf("%d%c%d",&va,&c,&wi);
      for(j=W;j>=0;j--){
	if(li[j]!=0 && wi+j<=W){
	  if(li[j]+va > li[wi+j])
	    li[wi+j]=li[j]+va;
	}
	if(j==0 && wi <= W){
	  if(va > li[wi])
	    li[wi]=va;
	}
      }
    }
    int ansva=0;
    int answi=0;
    for(i=0;i<=W;i++){
      if(li[i]>ansva){
	ansva = li[i];
	answi = i;
      }
    }
    printf("Case %d:\n",count);
    printf("%d\n%d\n",ansva,answi);
  }

  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
	
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC\n";
	else
		cout << "ABC\n";
		
	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;

int main(){
    long long A,B,C,K;
    cin>>A>>B>>C>>K;
    A*=3; B*=3; C*=3;
    long long ave=(A+B+C)/3;
    A-=ave; B-=ave; C-=ave;
    long long ans=(A-B)/3;
    if(K%2==1) ans*=(-1);
    cout<<ans<<endl;
    
    return 0;
}


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


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

    if(S.size() <= K) cout << S << endl;
    else{
        for(int i = 0; i < K; i++){
            cout << S.at(i);
        }
        cout << "..." << endl;
    }

}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    int i,a,b;
    vector<int> array(n,0);
    for(i = 0;i < m;++i){
        cin >> a >> b;
        ++array.at(a-1);
        ++array.at(b-1);
    }
    for(i = 0;i < n;++i){
        cout << array.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ( abs(a - c) <= d )  cout <<  "Yes"  << endl;
    else if ( abs(a - b) <= d && abs(c - b) <= d)  cout <<  "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc115/tasks/abc115_c
#include <bits/stdc++.h>

using namespace std;

const int INF = (int) 2e9 + 9;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int res = INF;
  for (int i = 0; i < n - k + 1; i++) {
    res = min(res, a[i + k - 1] - a[i]);
  }
  cout << res << "\n";
  return 0;
}



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

int main(void){
    int n, q;
    vector<int> S, T;
    vector<int>::iterator itr, itr2;
    int i;
    int input;
    int result = 0;
    
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> input;
        S.push_back(input);
    }
    
    sort(S.begin(), S.end());
    
    cin >> q;
    for(i = 0; i < q; i++){
        cin >> input;
        T.push_back(input);
    }
    
    sort(T.begin(), T.end());
    
//    for(itr = S.begin(); itr != S.end(); itr++) cout << *itr << " ";
    
    itr = S.begin();
    itr2 = T.begin();
    
    while(true){
        if(*itr == *itr2){
            result++;
            itr2++;
            if(itr2 == T.end()) break;
        }else if(*itr < *itr2){
            itr++;
            if(itr == S.end()) break;
        }else if(*itr > *itr2){
            itr2++;
            if(itr2 == T.end()) break;
        }
    }
    
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3176
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String args[]) {
		FastScanner in=new FastScanner();
		long n=in.nextLong();
		long ans=0;
		for(int a=1;a<n;a++) {
			long low=0, high=n;
			long b=1;
			while(low<high-1) {
				long mid=low+(high-low)/2;
				if(a*mid<n) {
					low=mid;
					b=mid;
				}
				else
					high=mid;
			}
			b=low;
			ans=ans+b;
		}			
		System.out.println(ans);
	}

	///////////////////////////
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 32856
#include <stdio.h>

int func(int a)
{
	if (a == 1)
	{
		return 1;
	}
	else {
		return func(a - 1)+a;
	}
}


int main()
{
	int num, ans;
	//階乗を求める
	scanf("%d", &num);
	ans = func(num);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
function Main(input) {
  input = input.split("\n");
  var A1 = parseInt(input[0].split(" ")[0]);
  var A2 = parseInt(input[0].split(" ")[1]);
  var A3 = parseInt(input[0].split(" ")[2]);
  if(A1+A2+A3>=22){
    var ans ="bust";
  }else{
    var ans ="win";
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22076
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	stack<char> s;
	string k;
	cin >> k;
	for(int i=0; i<(int)k.size(); i++){
		if(k[i] == 'B'){
			if(!s.empty()) s.pop();
		}
		else s.push(k[i]);
	}
	string ans = "";
	while(!s.empty()){
		ans = s.top() + ans;
		s.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import           Control.Exception (assert)

main :: IO ()
main = do
  s <- getLine
  assert (length s == 4) $
    print $ solve s

data Result =
  YYMM | MMYY | AMBIGUOUS | NA
  deriving (Show)

solve :: String -> Result
solve s
  | isMonth i1 && isMonth i2 = AMBIGUOUS
  | isMonth i1 = MMYY
  | isMonth i2 = YYMM
  | otherwise = NA
  where
    (i1, i2) = parse s

parse :: String -> (Int, Int)
parse [c1, c2, c3, c4] = (read [c1, c2], read [c3, c4])
parse _                = undefined

isMonth :: Int -> Bool
isMonth i = i >= 1 && i <= 12


Measured memory_bytes: 508
N,M,K = map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

a,b = [0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

Ans,j = 0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j = j-1
    Ans = max(Ans,i+j)

print(Ans)

Measured memory_bytes: 47436
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	n := oneInt()
	as := scanNums(n)

	ans := calc(as)

	fmt.Println(ans)
}

func calc(as []int) int64 {
	var minusCount int
	var answer int64

	minAbs := abs(as[0])
	for _, ai := range as {
		if ai < 0 {
			minusCount++
		}
		answer += int64(abs(ai))
		minAbs = min(minAbs, abs(ai))
	}
	if minusCount%2 == 0 {
		return answer
	} else {
		answer += int64(minAbs * -2)
	}
	return answer
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

func nextWord(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanNums(n int) (nums []int) {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		s := nextWord(sc)
		num, _ := strconv.Atoi(s)
		nums = append(nums, num)
	}
	return nums
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 5504
#include<cstring>
#include<iostream>
#include<vector>

using namespace std;

int main(void){
  string  s;
  cin >> s ;
  int N = s.length();

  int a =0,b = 0;
  for ( int i =0; i <N; i++){
    if(i%2==0){
      if(s[i] == '0')a++;
      if(s[i] == '1')b++;
    }
    else{
      if(s[i] == '1')a++;
      if(s[i] == '0')b++;

    }
  }
  cout << min(a,b) << endl;
}





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

class D
{
	static void Main()
	{
		Console.ReadLine();
		var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
		var b = a.Select(Math.Abs).OrderBy(x => x).ToArray();
		Console.WriteLine(b.Sum() - (a.Count(x => x < 0) % 2 == 0 ? 0 : 2 * b[0]));
	}
}


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

signed main() {
  int n,m,ans=0;
  pair<int,int> a;
  string s;
  cin>>n>>s;
  int t[n]={};
  for(int i=0;i<n-1;i++){
    if(s[i]==s[n-1]&&i<n-1-t[n-1])ans=max(ans,t[n-1]+1);
  
    for(int j=n-2;j>i;j--){
      if(s[i]==s[j]&&i<j-t[j]){
        ans=max(ans,t[j]+1);
        t[j+1]=t[j]+1;
      }else t[j+1]=0;
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
ans = [-1, -1, -1]
c = 0
for i in range(n + 1):
    if c == 1:
        break
    for j in range(n + 1 - i):
        yu = i
        hi = j
        no = n - i - j
        if no * 1000 + hi * 5000 + yu * 10000 == y:
            ans = [yu, hi, no]
            c = 1
print(" ".join(map(str, ans)))

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

int W, H, N;
int x[100] = {0};
int y[100] = {0};
int a[100] = {0};

int main() {
    cin >> W >> H >> N;
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> a[i];
    
    int x1 = 0;
    int y1 = 0;
    int x2 = W;
    int y2 = H;
    for (int i = 0; i < N; i++) {
        if (a[i] == 1 && x[i] > x1) x1 = x[i];
        if (a[i] == 2 && x[i] < x2) x2 = x[i];
        if (a[i] == 3 && y[i] > y1) y1 = y[i];
        if (a[i] == 4 && y[i] < y2) y2 = y[i];
    }
    int S;
    if (x1 < x2 && y1 < y2) {
        S = (x2 - x1) * (y2 - y1);
        cout << S << endl;
    }
    else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int flgt[500][1000],flgl[1000][500];
int main(void){
	int c,n,d,r,f,rt,fl,cnt,i,j,ans;
	char p[1000][1001];
	cin>>c>>n;
	for(i=0;i<n;i++) cin>>p[i];
	cnt=0;
	for(i=0;i<n;i++){
		for(j=0;j<n/2;j++){
			flgl[i][j]=0;
			if(p[i][j]!=p[i][n-1-j]){
				flgl[i][j]=1;
				cnt++;
			}
		}
	}
	for(i=0;i<n/2;i++){
		for(j=0;j<n;j++){
			flgt[i][j]=0;
			if(p[i][j]!=p[n-1-i][j]){
				flgt[i][j]=1;
				cnt++;
			}
		}
	}
//	cout<<cnt<<endl;
	ans=0;
	if(cnt==0) ans++;
	for(i=1;i<c;i++){
		cin>>d;
		for(j=0;j<d;j++){
			cin>>r>>f;
			if(r>n/2) rt=n-r;
			else rt=r-1;
			if(f>n/2) fl=n-f;
			else fl=f-1;
			r-=1; f-=1;
//			cout<<r<<':'<<f<<' '<<rt<<':'<<fl<<endl;
			if(flgl[r][fl]==0){
				flgl[r][fl]=1;
				cnt++;
			}
			else if(flgl[r][fl]==1){
				flgl[r][fl]=0;
				cnt--;
			}
			if(flgt[rt][f]==0){
				flgt[rt][f]=1;
				cnt++;
			}
			else if(flgt[rt][f]==1){
				flgt[rt][f]=0;
				cnt--;
			}
		}
//		cout<<cnt<<endl;
		if(cnt==0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7900
import java.util.*

fun main(args:Array<String>?): Unit {
    val (n, m, a, b) = readLine()!!.trim().split(' ').map(String::toInt)
    val leaf = readLine()!!.trim().split(' ').map(String::toInt).toIntArray()
    val stack = Stack<Int>()
    for (l in leaf){
        if (l >= a) stack.add(l)
        else break
    }
    if (n - stack.size < m) {
        while(stack.isNotEmpty() && stack.peek() <= b){
            stack.pop()
        }
    }
    println(stack.size)
}



Measured memory_bytes: 34780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }

int D;
vector<int> c(26); 
vector<vector<int>> s(365, vector<int>(26));

int cal_score(vector<int> t){
    int satis = 0;
    vector<int> last(26, 0);
    rep(d, D){
        satis += s[d][t[d] - 1];
        last[t[d] - 1] = d + 1;
        rep(i, 26){
            satis -= c[i] * (d - last[i] + 1);
        }
    }
    return satis;
}

int ch_sch(vector<int> t, int d, int q, int score){
    // change t[d - 1] -> q
    // calculate the score
    int old = t[d - 1];
    score -= s[d - 1][old - 1];
    score += s[d - 1][q - 1];

    int last_old = 0, last_new = 0;
    rep(i, D){
        if(t[i] == old ) last_old = i + 1;
        else if(t[i] == q) last_new = i + 1;
        score += c[old - 1] * (i - last_old + 1);
        score += c[q - 1] * (i - last_new + 1);
    }

    t[d - 1] = q;

    last_old = 0, last_new = 0;
    rep(i, D){
        if(t[i] == old) last_old = i + 1;
        else if(t[i] == q) last_new = i + 1;
        score -= c[old - 1] * (i - last_old + 1);
        score -= c[q - 1] * (i - last_new + 1);
    }
    return score;
}

int main(){
    // input 
    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D){
        rep(j, 26){
            cin >> s[i][j];
        }
    }

    // greedy
    vector<int> last(26, 0);
    vector<int> res(D);

    rep(d, D){
        int max_plus = -10000;
        int use = -1;
        rep(i, 26){
            int tmp = s[d][i] + c[i] * (d - last[i] + 1);
            if(max_plus < tmp){
                max_plus = tmp;
                use = i;
            }
        }
        last[use] = d + 1;
        res[d] = use + 1;
    }

    int cur_score = cal_score(res);

    while((clock() / (double)CLOCKS_PER_SEC) <= 1.98){
        int ch_d = rand() % D + 1;
        int ch_c = rand() % 26 + 1;
        int new_score = ch_sch(res, ch_d, ch_c, cur_score);
        if(cur_score < new_score){
            cur_score = new_score;
            res[ch_d - 1] = ch_c;
        }
    }

    rep(i, D){
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

bool cmp(const string& lhs,const string& rhs)
{
	int lsize=lhs.size();
	int rsize=rhs.size();
	if(lsize!=rsize)
		return lsize<rsize;
	
	for(int i=0;i<lsize;i++)
		if(lhs[i]!=rhs[i])
			return lhs[i]-'0'<rhs[i]-'0';
	return false;
}

int main()
{
	const int cost[]={0,2,5,5,4,5,6,3,7,6};
	const string num[]={"0","1","2","3","4","5","6","7","8","9"};

	int N,M;
	int A[10]={};

	cin >> N >> M;
	for(int i=1;i<=M;i++)
		cin >> A[i];
	
	sort(A+1,A+M+1,greater<int>());

	string dp[10010]={};
	for(int i=0;i<=N;i++)
		dp[i]="";
	for(int i=1;i<=N;i++)
	{
		for(int j=1;j<=M;j++)
		{
			if(i-cost[A[j]]<0)
				continue;
			if(dp[i-cost[A[j]]]=="" && i-cost[A[j]]!=0)
				continue;
			string nxt1=dp[i-cost[A[j]]]+num[A[j]];
			string nxt2=num[A[j]]+dp[i-cost[A[j]]];
			//if(cmp(dp[i],nxt1))
				//dp[i]=nxt1;
			if(cmp(dp[i],nxt2))
				dp[i]=nxt2;
		}
	}
	
	cout << dp[N] << endl;
	return 0;
}



Measured memory_bytes: 33408
import sys, io, os, re
import bisect
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n): return [0] * n
def array2(n, m): return [[0] * m for x in range(n)]
def array3(n, m, l): return [[[0] * l for y in xrange(m)] for x in xrange(n)]

X, N = nn()
P = nn()

if N == 0:
    print(X)
else:
    d = 999
    ans = -1

    for i in range(102):
        if (i in P):
            continue

        t = abs(X - i)
        if t < d:
            d = t
            ans = i

    print(ans)


Measured memory_bytes: 72848
import java.util.Scanner;

public class Main {
		public static void main(String[] args){
			Scanner sc=new Scanner(System.in);
			
			int n=sc.nextInt();
			
			
			String str=sc.next();
			char[] myChar = str.toCharArray();
			
			int current=0;
			
			
			for(int i=0;i<myChar.length;i++){
				current=myChar[i];
				current=current+n;
				
				if(current>90)current=current-26;
				myChar[i]=(char)current;
			}
			
			System.out.println(myChar);
		}

}


Measured memory_bytes: 22228