akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define SIZE 100005
#define PI acosl(-1) //3.14159265358979323846264338327950L 
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) (t*)calloc(N, sizeof(t)) //t型N要素の1次元配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?

typedef long long ll; typedef long double ld;
typedef struct node { int data; struct node *next; } Node;

Node *list[SIZE];
int queue[SIZE]; int q_head = 0, q_tail = 0;

void print_log(); //とりあえず文字を出力してどこまで実行できているか確認(for debug)
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)
void printl_int(int size); //リンクリストを出力(for debug)
Node* add_node(int i, int data); void free_list(Node* head);
int queue_empty(); int queue_full();
void enqueue(int data); int dequeue();

int main() {
    int A, B;
    scanf("%d %d", &A, &B);
    printf("%d\n", A * B);
    return 0;
}

void print_log() {
    printf("=== print log ===\n");
}
void printa_int(int *a, int size) {
    int i;
    printf("[");
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("]\n");
}
void printl_int(int size) {
    int i;
    Node *t;
    rep(i, size) {
        printf("[%d] ", i);
        for (t = list[i]; t; t = t->next) printf("%d, ", t->data);
        printf("\n");
    }
}
Node* add_node(int i, int data) {
    if (!list[i]) {
        list[i] = (Node*)malloc(sizeof(Node*));
        list[i]->data = data;
    } else {
        Node *t;
        t = list[i];
        list[i] = (Node*)malloc(sizeof(Node*));
        list[i]->data = data;
        list[i]->next = t;
    }
    return list[i];
}
void free_list(Node* head) {
    Node *prev = NULL, *t = head;
    while (t) {
        prev = t;
        t = t->next;
        free(prev);
    }
}
int queue_empty() {
    return q_head == q_tail;
}
int queue_full() {
    return (q_head - 1) % SIZE == q_tail % SIZE;
}
void enqueue(int data) {
    if (queue_full()) {
        printf("full!\n");
        return;
    }
    queue[q_tail++] = data;
    q_tail %= SIZE;
}
int dequeue() {
    if (queue_empty()) {
        printf("empty!\n");
        return -444444;
    }
    int data = queue[q_head++];
    q_head %= SIZE;
    return data;
}

Measured memory_bytes: 1724
#include<stdio.h>
int main(void){
	char A[1200];
	int i = 0;
	int a;
	
	gets(A);
	a = strlen(A);
	
	while(1){
		if(A[i] >= 65 && A[i] <= 90){
			A[i] += 32;
		}else if(A[i] >= 97 && A[i] <= 122){
			A[i] -= 32;
		}
		i++;
		if(i == a)break;
	}
	puts(A);
	return 0;
}

Measured memory_bytes: 524
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

a,b,c = get_nums_l()

if a + b - c > 0:
    print("No")
    exit()

x = (a+b-c) ** 2
y = 4 * a * b

print("Yes" if x > y else "No")


Measured memory_bytes: 38372
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def solve(N, i, C, A, M, X):
    tmp = [0] * M
    cost = 0
    for j in range(N):
        if (i >> j) % 2 == 1:
            cost += C[j]
            for k in range(M):
                tmp[k] += A[j][k]

    # print(tmp)
    if all(X <= t for t in tmp):
        return cost
    else:
        return float('inf')


def main():
    N, M, X = inpl()
    C = []
    A = []
    for _ in range(N):
        tmp = inpl()
        C.append(tmp[0])
        A.append(tmp[1:])

    ans = float("inf")
    for i in range(2**N):
        tmp = solve(N, i, C, A, M, X)
        if ans >= tmp:
            ans = tmp

    if ans == float('inf'):
        print(-1)
    else:
        print(ans)
    return


if __name__ == '__main__':
    main()


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

typedef unsigned long long ll;
ll n, mn=1e18, X, s, k, a[200005], b[200005];
int main()
{
	int i, j;
	cin >> n >> X;
	for (i = 1; i <= n; i++) {
		scanf ("%lld", &a[i]);
		a[i] += a[i - 1];
	}
	for (i = 1; i <= n; i++) {
		s = (n + i) * X ;
		k = 5;
		for (j = n; j >= 1; j -= i) {
			s += (a[j] - a[max(j - i, 0)]) * k;
			if(j < n) k += 2;
		}
		mn = min(mn, s);
	}
	cout << mn;
    return 0;
}

//	mn = a[n] * 5 + X * 3;

//	b[1] = b[2] = 5;
//	for (i = 3; i <= n; i++) b[i] = b[i - 1] + 2;
//	for (i = n; i >= 1; i--) {
//		mn += a[i] * b[i];
//	}


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

int n; 

inline int read()
{
    int x = 0, w = 1;
    char c = getchar();
    while(c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
    return x * w;
}

int main()
{
	n = read(); 
	printf("%d\n", (n - 2) * 180); 
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

const int MOD = 1000000007;
int pw(int x, int n) { int ret = 1; while (true) { if (n & 1) ret = (ll)ret*x%MOD; if ((n >>= 1) == 0) return ret; x = (ll)x*x%MOD; } }

int want;
bool atleast(int cnt, int len) {
	if (len > 9) return true;
	int num = 9; REP(i, len - 1) num *= 10; return num >= cnt;
}

int calcone(int len) {
	int cnt = want / len;
	if (!atleast(cnt, len)) return 0;
	int num = (ll)9 * pw(10, len - 1) % MOD;
	return (num + MOD - cnt + 1) % MOD;
}
int solveone() {
	int ret = 0;
	for (int x = 1; x*x <= want; ++x) if (want%x == 0) {
		ret = (ret + calcone(x)) % MOD;
		if (x != want / x) ret = (ret + calcone(want / x)) % MOD;
	}
	return ret;
}

int solvetwo() {
	// some of length x, some of length x+1 -> want/cnt-1<x<want/cnt
	int ret = 0;
	for (int cnt = 2; cnt <= want; ++cnt) {
		if (want%cnt == 0) continue;
		int x = want / cnt, nb = want%cnt, na = cnt - nb;
		if (!atleast(na, x) || !atleast(nb, x + 1)) continue;
		//printf("cnt=%d x=%d na=%d nb=%d\n", cnt, x, na, nb);
		++ret;
	}
	return ret;
}

int solvemulti() {
	int ret = 0;
	FORE(slen, 2, 8) {
		int alen = slen - 1, anum = 9 * pw(10, alen - 1);
		ll have = (ll)9 * pw(10, slen - 1)*slen;
		FORE(blen, slen + 1, 9) {
			if (have > want) break;
			int bnum = 9 * pw(10, blen - 1);
			int rem = want - have;
			int acnt = 1; rem -= alen;
			int g = gcd(alen, blen);
			if (rem >= 0 && rem%g == 0) {
				while (rem%blen != 0) ++acnt, rem -= alen;
				if (acnt <= anum&&rem >= 0) {
					int bcnt = rem / blen;
					if (bcnt > bnum) { int x = (bcnt - bnum + alen / g - 1) / (alen / g); bcnt -= x*(alen / g); acnt += x*(blen / g); }
					if (acnt <= anum&&bcnt >= 1) {
						int x = (anum - acnt) / (blen / g), y = (bcnt - 1) / (alen / g);
						ret = (ret + min(x + 1, y + 1)) % MOD;
						//printf("alen=%d blen=%d -> %d\n", alen, blen, min(x + 1, y + 1));
					}
				}
			}
			have += (ll)bnum*blen;
		}
	}
	return ret;
}

void run() {
	scanf("%d", &want);
	int ret = ((ll)solveone() + solvetwo() + solvemulti()) % MOD;
	printf("%d\n", ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define int long long
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = (1LL << 30);
const ll MOD = 1000000007;

//=============================================================
//=============================================================
int N;
vector<int> V;
vector<int> Vev;
vector<int> Vod;
map<int,int> Mev;
map<int,int> Mod;


// O( ~ N^2)
void solve()
{
    int maxE = -1;
    int maxE_i;
    int maxO = -1;
    int maxO_i;
    int ans;
    for(auto x: Mev){
        if (maxE < x.second){
            maxE_i = x.first;
            maxE = x.second;
        }
    }
    for (auto x: Mod){
        if (maxO < x.second){
            maxO_i = x.first;
            maxO = x.second;
        }
    }


    ans = 0;
    if (maxE_i != maxO_i){
        ans = N - maxO - maxE;
        cout<<ans<<endl;
        return;
    }
    else {
        int maxE2 = 0;
        int maxE2_i;
        int maxO2 = 0;
        int maxO2_i;
        for (auto x: Mev){
            if (x.first != maxE_i && maxE2 <= x.second){
                maxE2 = x.second;
                maxE2_i = x.first;
            }
        }
        for (auto x: Mod){
            if (x.first != maxO_i && maxO2 <= x.second){
                maxO2 = x.second;
                maxO2_i = x.first;
            }
        }
        
        int a1 = N - maxO - maxE2;
        int a2 = N - maxE - maxO2;
        ans = min(a1,a2);
        cout<<ans<<endl;
        return;

    }

}
signed main()
{
    cin >> N;
    rep(i,N){
        int tmp;
        cin>>tmp;
        V.push_back(tmp);
        if (i%2){
            Vev.push_back(tmp);
            Mev[tmp]++;
        }
        else {
            Vod.push_back(tmp);
            Mod[tmp]++;
        }
    }
    solve();
    return 0;
}

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

int a[8][8];
int row[8]={};
int col[8]={};
int ru[15]={};
int rd[15]={};

void set(int r,int c,int n){
  a[r][c]=n;
  row[r]=n;
  col[c]=n;
  ru[r+c]=n;
  rd[7+c-r]=n;
}

void unset(int r,int c){
  a[r][c]=0;
  row[r]=0;
  col[c]=0;
  ru[r+c]=0;
  rd[7+c-r]=0;
}

bool can_set(int r,int c){
  return !(row[r]>0 ||
           col[c]>0 ||
           ru[r+c]>0 ||
           rd[7+c-r]>0);
}

void print(){
  for(int r=0;r<8;r++){
    for(int c=0;c<8;c++){
      if(a[r][c]>0){
        cout<<'Q';
      }else{
        cout<<'.';
      }
    }
    cout<<endl;
  }
}

void solve(int r){
  if(r==8){
    print();
    return;
  }
  if(row[r]>0) solve(r+1);
  for(int c=0;c<8;c++){
    if(can_set(r,c)){
      set(r,c,1);
      solve(r+1);
      unset(r,c);
    }
  }
}

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

  for(int i=0;i<8;i++)
    for(int j=0;j<8;j++) a[i][j]=0;

  for(int i=0;i<k;i++){
    int r,c; cin>>r>>c;
    set(r,c,2);
  }

  solve(0);
}

Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main()
{
int a,b=0,c=0;
for(int i=0;i<3;i++)
{  
   cin>>a;
   if(a==5)
   {
      b+=1;
    }
    if(a==7){
      c+=1;
    }
}
if(b==2 && c==1)
{
cout<<"YES"<<endl;
}
else
{
  cout<<"NO"<<endl;
 }


return 0;
}

Measured memory_bytes: 3100
eval"N,A,B,K="+`tr ' ' ,`
*f=s=1
p (0..N.times{f<<s=s*-~_1%M=998244353}).sum{|a|b=(K-A*a)/B
b>N||A*a+B*b!=K||b<0?0:s**2*(f[a]*f[b]*f[~a]*f[~b]).pow(M-2,M)}%M

Measured memory_bytes: 45316
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,cnt;
	int dt[10];
	while(cin>>n,n){
		rep(i,10)dt[i]=0;
		rep(i,n){
			cin>>cnt;
			dt[cnt]++;
		}
		rep(i,10){
			if(dt[i]==0)cout<<"-";
			else rep(j,dt[i])cout<<"*";
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
typedef long long ll;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll MOD = 1000000007;

void solve() {

    ll n;
    cin >> n;
    ll x[n], l[n];
    rep(i,n) cin >> x[i] >> l[i];
    unordered_map<ll,ll> m;
    rep(i, n) m.insert(pair<ll,ll>{x[i], l[i]});
    // rep(i, n) cout << x[i] << ":" << l[i] << endl;
    priority_queue<ll,vector<ll>,greater<ll>> Q;
    rep(i,n) Q.push(x[i]);

    stack<ll> S;
    // cout << Q.top() << endl;
    S.push(Q.top()); Q.pop();
    while(!Q.empty())
    {
        ll prev = S.top();
        ll next = Q.top();
        // cout << "prev: " << prev << ", next: " << next <<endl;
        if((prev + m[prev] ) <= (next - m[next])){
            // cout << "1" << endl;
            S.push(next);
            Q.pop();
        } else if ((prev + m[prev]) >= (next + m[next])){
            // cout << "2" << endl;
            S.pop();
            S.push(next);
            Q.pop();
        } else {
            // cout << "3" << endl;
            Q.pop();
        }
    }
    ll result = 0;
    result = S.size();
    cout << result << endl;
    // rep(i,S.size()){
    //     cout << S.top();
    //     S.pop();
    // }
    return;
}

int main() {
    solve();
    return 0;

}

Measured memory_bytes: 7584
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
#define int ll
using namespace std;	
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int n, t, ans, cur;
vi v;

signed main() {
	fastio;
	cin >> n;
	FOR(i, n) {
		cin >> t;
		v.pb(t);
	}
	cur = v[0];
	FOR(i, n) {
		if (v[i] < cur) ans += cur - v[i];
		else cur = v[i];
	}
	cout << ans;
}

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



int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double n,t,a;
    cin>>n>>t>>a;
    vector<double>h(n);
    rep(i,n)cin>>h[i];

    double dif=1e9;
    int ans=1;
    
    rep(i,n){
        double x=abs(t-h[i]*0.006-a);
        if(dif>=x){
            ans=i+1;
            dif=x;
        }
    }

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


Measured memory_bytes: 256
<?php
$num = explode(" ", trim(fgets(STDIN)));
$animals = $num[0];
$leg = $num[1];

for ($i = 0; $i <= $animals; $i++) {
    $tmp = $animals - $i;
    $a = $i * 2 + $tmp * 4;
    if ($a == $leg) {
        echo 'Yes';
        return;
    } else {
        $res = 'No';
    }
}

if (isset($res)) {
    echo $res;
}


Measured memory_bytes: 16288
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
 
int main(){
  double A,B,H,M;
  cin>>A>>B>>H>>M;
  double pi=acos(-1);
  double tmp=A*cos(2.0*pi*(H+M/60.0)/12)-B*cos(2.0*pi*M/60);
  double tmp2=A*sin(2.0*pi*(H+M/60.0)/12)-B*sin(2.0*pi*M/60);
  cout<<setprecision(10)<<sqrt(tmp*tmp+tmp2*tmp2)<<endl;
}



Measured memory_bytes: 4124
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<cmath>
#include<math.h>
using namespace std;
int main(){
	long int n,a[205],p=0,k=0,s=1000;
	cin>>n;
	for(long int i=0;i<n;i++)cin>>a[i];
	for(long int i=0;i<n-1;i++){
		if(a[i]<=a[i+1]){
			k=k+s/a[i];
			s=s-s/a[i]*a[i];
		}
		if(a[i]>a[i+1]){
			s=s+k*a[i];
			k=0;
		}
	}
	s=s+k*a[n-1];
	cout<<s;
	
    
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define forN(i, n) for(int i = 0; i <n ; ++i)
#define endl "\n"
typedef long long ll;
using namespace  std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int N = 1000 + 5;
string s;

int main(){
    fastIO;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
}


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

typedef long long ll;

string s;
int k;

vector<string> v;

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

    for (int i = 0; i < s.size(); i++){
        for (int j = 1; j <= k; j++){
            if (i+j > s.size()) continue;
            //cout << s.substr(i, j) << endl;
            v.push_back(s.substr(i, j));
        }
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());  //unique関数は初めて知った。

    cout << v[k-1] << endl;
}

Measured memory_bytes: 1660
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	An := make([]int, N)
	nums := make([]int, N)
	combi := make([]int, N)
	combi2 := make([]int, N)
	ans := 0
	for i := 0; i < N; i++ {
		An[i] = nextInt()
		nums[An[i]-1]++
	}
	for i := 0; i < N; i++ {
		combi[i] = combination2(nums[i])
		if nums[i] != 0 {
			combi2[i] = combination2(nums[i] - 1)
		} else {
			combi2[i] = 0
		}
	}
	for i := 0; i < N; i++ {
		ans += combi[i]
	}
	for i := 0; i < N; i++ {
		fmt.Println(ans - (combi[An[i]-1] - combi2[An[i]-1]))
	}
	// fmt.Println(nums, combi, combi2)
	// fmt.Println(ans)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func combination2(num int) int {
	return num * (num - 1) / 2
}


Measured memory_bytes: 45312
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int A[N+1];
int key;
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  for(j=2;j<=n;j++)
{
key=A[j];
i=j-1;
while(i>0&&A[i]>key)
{
A[i+1]=A[i];
i=i-1;
A[i+1]=key;
}
trace(A,n);
}

  return 0;
}

Measured memory_bytes: 608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    ll  N, K;
    cin >> N >> K;

    ll R, S, P;
    cin >> R >> S >> P;

    string game;
    cin >> game;

    ll ans = 0;
    int i = 0;

    while (i < game.length() && i < K)
    {
        switch (game[i]) {
        case 'r':
            ans += P;
            break;
        case 's':
            ans += R;
            break;
        case 'p':
            ans += S;
            break;
        }

        ++i;
    }


    while (i < game.length())
    {
        if (game[i - K] == game[i])
        {
            game[i] = '?';
        }
        else
        {
            switch (game[i]) {
                case 'r':
                    ans += P;
                    break;
                case 's':
                    ans += R;
                    break;
                case 'p':
                    ans += S;
                    break;
            }
        }
        ++i;
    }

    return ans;
}

int main()
{
    cout << solve() << endl;

    return 0;
}

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

typedef long long LL;  
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = 1000000007;

int main()
{
ios_base::sync_with_stdio(0); 
cout.precision(15);
cout.setf(ios::fixed);

int n;

cin>>n;

int k;
LL ans = 0;
int prev = 0;
int i;

for(i=0;i<n;i++)
	{
	cin>>k;
 
	ans = ans + (prev+k)/2;	
	if(k>0)
		prev = (prev+k)%2;
	else
	     prev = 0;
	}

cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int b = int.Parse(input[2]);
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
        if(n==m){
            WriteLine(b);
        }else if(m==b){
            WriteLine(n);
        }else{
            WriteLine(m);
        }
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll f[3005][3005],a[3005],n;
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld",a+i);
    for(int i=1;i<=n;i++)
    for(int j=i;j<=n;j++)
    {
        int l=j-i+1,r=j;
        f[l][r]=max(a[l]-f[l+1][r],a[r]-f[l][r-1]);
    }
    printf("%lld",f[1][n]);
    return 0;
}

Measured memory_bytes: 69888
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,m,a[100],sum=0,count=0,i;
    double x=0;
    scanf("%d",&n);
    scanf("%d",&m);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    
    x=((float)1/(4*m))*sum;
    
    
    for(i=0;i<n;i++)
    {
        if(a[i]>=x)
            count++;
    }
    
    if(count>=m)
        printf("Yes");
    else
        printf("No");
    
    
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;
public class Main {

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

    	// 入力
    	int s = sc.nextInt();
    	ArrayList<Integer> arg = new ArrayList<>();
    	int i;
        arg.add(s);

    	for (i = 0; i < 1000002; i++ ){
        	if(s % 2 == 0){
        		s = s / 2;
        	} else {
        		s = 3 * s + 1;
        	}

        	if (arg.contains(s)){
        		break;

        	}
        	arg.add(s);

    	}

    	// 出力
    	System.out.println(i+2);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n + k, 0);
    rep(i, n) cin >> h[i];

    vector<int> dp(n + k, INF);
    dp[0] = 0;
    rep(i, n) {
        rep(j, k) {
            dp[i + j + 1] =
                min(dp[i + j + 1], dp[i] + abs(h[i] - h[i + j + 1]));
        }
    }

    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int n;
vector<vector<int> > child(1010);
vector<int> x(1010);
int dp[1010][5010];

int cansolve(int node)
{
	if(child[node].size() == 0) return 0;
	vector<pair<int, int> > tmpv;
	// cout << node << " : " << x[node] << endl;
	for(int i = 0; i < child[node].size(); i++){
		int childnode = child[node][i];
		int tmp = cansolve(childnode);
		if(tmp == mod) return mod;
		tmpv.push_back(make_pair(tmp, x[childnode]));
	}
	for(int i = 0; i < tmpv.size(); i++){
		for(int j = 0; j <= x[node]; j++){
			dp[i][j] = mod;
		}
	}
	if(tmpv[0].first <= x[node]) dp[0][tmpv[0].first] = tmpv[0].second;
	if(tmpv[0].second <= x[node]) dp[0][tmpv[0].second] = tmpv[0].first;
	for(int i = 1; i < tmpv.size(); i++){
		int fst = tmpv[i].first;
		int snd = tmpv[i].second;
		for(int j = fst; j <= x[node]; j++){
			dp[i][j] = min(dp[i][j], dp[i - 1][j - fst] + snd);
		}
		for(int j = snd; j <= x[node]; j++){
			dp[i][j] = min(dp[i][j], dp[i - 1][j - snd] + fst);
		}
	}
	int ans = mod;
	for(int i = 0; i <= x[node]; i++){
		ans = min(ans, dp[tmpv.size() - 1][i]);
	}
	// cout << node << " " << ans << " " << x[node] << endl;
	return ans;
}

int main()
{
	cin >> n;
	for(int i = 1; i < n; i++){
		int p;
		cin >> p;
		p--;
		child[p].push_back(i);
	}
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	if(cansolve(0) != mod) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong

signed main(){
    int n;
    string a,b,c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    REP(i,n){
        if(a[i] == b[i]){
            if(b[i] != c[i]) ans ++;
        }
        else{
            ans ++;
            if(a[i] != c[i] and b[i] != c[i]) ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
#define N 100010
typedef long long LL;
int a[N],b[N];
LL s1[N],s2[N];
int main()
{
    int i,j,k,n;
    LL ans;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    a[0]=0;
    a[n+1]=0;
    for(i=1;i<=n+1;i++)
        b[i]=fabs(a[i]-a[i-1]);
    s1[0]=0;
    for(i=1;i<=n+1;i++)
        s1[i]=s1[i-1]+b[i];
    s2[n+2]=0;
    for(i=n+1;i>=1;i--)
        s2[i]=s2[i+1]+b[i];
    for(i=1;i<=n;i++)
    {
        ans=s1[i-1]+s2[i+2]+fabs(a[i+1]-a[i-1]);
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3456
// Problem : B - Count ABC
// Contest : AtCoder Beginner Contest 150
// URL : https://atcoder.jp/contests/abc150/tasks/abc150_b
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int m=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
int n;
cin>>n;
string s;
cin>>s;
int count=0;
for(int i=0;s[i];i++)
{
	if(s[i]=='A')
	{
		if(i+2<=s.size()-1)
		{
			string st=s.substr(i,3);
			if(st=="ABC")
			count++;
		}
	}
	
}
cout<<count;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    int ans = 0;
    int i, j;

    scanf("%d", &n);

    for ( i = 8; i <= n; i++) {
        int cnt = 0;

        for ( j = 1; j <= i; j++) {
            if (i % j == 0) {
                cnt++;
            }
        }

        if (cnt == 8 && (i & 1)) {
            ans++;
        }
    }

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

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	    ll n;
	    cin>>n;
	    ll a[n+1];
	    for(ll i=1;i<=n;i++)
	    	cin>>a[i];
	    vector<ll>pos;
	    vector<ll>neg;
	    pos.push_back(0);
	    neg.push_back(0);
	    vector<ll>bpos(n+2);
	    vector<ll>bneg(n+2);
	    for(ll i=1;i<=n;i++)
	    {
	    	pos.push_back(neg[i-1]+2*a[i]);
	    	neg.push_back(pos[i-1]-2*a[i]);
	    	bpos[n-i+1]=bneg[n-i+2]+2*a[n-i+1];
	    	bneg[n-i+1]=bpos[n-i+2]-2*a[n-i+1];
	    }
	    for(ll i=1;i<=n;i++)
	    {
	    	cout<<(bpos[i]+pos[i-1])/2<<" ";
	    }
}

Measured memory_bytes: 5484
n=gets.to_i
a=gets.split.map &:to_i
gets
m=gets.split
b=(1..n).flat_map{|i|a.combination(i).to_a}.map{|v|v.reduce :+}
m.map{|i|b.index i.to_i}.map{|i|puts i ?:yes: :no}

Measured memory_bytes: 254012
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
ll n,m;
while(1){
	cin>>n>>m;
	if(n==0)return 0;
	ll ans=-1;
	V<ll> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			if(a[i]+a[j]<=m&&ans<a[i]+a[j])ans=a[i]+a[j];
		}
	}
	if(ans==-1)cout<<"NONE"<<endl;
	else cout<<ans<<endl;
}
}



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

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;

const int M = 100100;

int p[M], sz[M];

void ini() {
  iota(p, p + M, 0);
  fill(sz, sz + M, 1);
}

int get(int x) {
  return p[x] = p[x] == x ? x : get(p[x]);
}

void uni(int x, int y) {
  x = get(x);
  y = get(y);
  if (x != y) {
    if (sz[x] < sz[y])
      swap(x, y);
    p[y] = x;
    sz[x] += sz[y];
  }
}

int n, m, a[M];
vector<int> b[M];

void read() {
  ini();
  cin >> n >> m;
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    uni(x, y);
  }
}

void kill() {
  int m = 0;
  for (int i = 0; i < n; ++i) {
    if (get(i) == i)
      ++m;
    b[get(i)].push_back(a[i]);
  }

  if (n < 2 * m - 2) {
    cout << "Impossible\n";
    return;
  }

  if (m == 1) {
    cout << "0\n";
    return;
  }

  vector<int> rem;

  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    sort(all(b[i]));
    if (!b[i].empty()) {
      ans += b[i][0];
      rem.insert(rem.end(), b[i].begin() + 1, b[i].end());
    }
  }
  sort(all(rem));
  assert((int) rem.size() >= m - 2);
  for (int i = 0; i < m - 2; ++i)
    ans += rem[i];
  cout << ans << endl;
}

int main() {
#ifdef LOCAL
  assert(freopen("d.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  read();
  kill();
}



Measured memory_bytes: 6912
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

struct edge{
	int to;
	long long int cost;
};

#define MAX_V 110000

vector<edge> E[MAX_V];

edge func(int u, int pre, int dist){
	edge e;
	e.to = u;
	e.cost = dist;
	for(int i = 0; i < E[u].size(); i++){
		if(E[u][i].to != pre){
			edge ee = func(E[u][i].to, u, dist + E[u][i].cost);
			if(ee.cost > e.cost){
				e = ee;
			}
		}
	}
	return e;
}

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N - 1; i++){
		int u, v;
		edge p;
		cin >> u >> v >> p.cost;
		p.to = v;
		E[u].push_back(p);
		p.to = u;
		E[v].push_back(p);
	}
	
	edge e = func(0, -1, 0);
	
	e = func(e.to, -1, 0);
	
	cout << e.cost << endl;
	
	return 0;
}


Measured memory_bytes: 18240
#include<bits/stdc++.h>
using namespace std;
const int MAXN=510;
const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};
priority_queue<int,vector<int>,greater<int> >q;
struct node{
	int l,r;
};
node c[MAXN*MAXN];
int f[MAXN*MAXN][2];
char a[MAXN][MAXN],ans1[MAXN][MAXN],ans2[MAXN][MAXN];
int n,m,cnt;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++) {
		scanf("%s",a[i]);
	}
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++) if (j==0||a[i][j]=='#'||(i%2==0)&&j<m-1) putchar('#');
		else putchar('.');
		putchar('\n');
	}
	putchar('\n');
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++) if (j==m-1||a[i][j]=='#'||((i&1)&&j>0)) putchar('#');
		else putchar('.');
		putchar('\n');
	}
}

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

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

int main() {
    int i, n;
    i = 1;
    while (1) {
        cin >> n;
        if (n == 0) break;

        cout << "Case " << i << ": " << n << endl;
        i++;
    }
}


Measured memory_bytes: 3112
#include<stdio.h>
#include <algorithm>

using namespace std;

int n, k, value, dif=0, bolas=0;

struct ball{
    int cant = 0;
    int num = 0;
    /*ball(int cat, int num){
        this->cant = 0;
        this -> num = 0;
    }*/
};

ball cont[200010];

bool compare(ball a, ball b){
    return (a.cant < b.cant);
}

int main(){
    scanf("%d %d", &n, &k);
    for(int i=0; i<n; i++){
        scanf("%d", &value);
        if(cont[value].cant == 0){
            dif += 1;
            cont[value].num = value;
        }
        cont[value].cant += 1;
    }

    sort(cont, cont+n+1, compare);
    /*for(int i=0; i<=n; i++){
        printf("%d: %d\n", cont[i].num, cont[i].cant);
    }*/

    for(int i=0; i<=n; i++){
        if(dif > k){
            if(cont[i].cant != 0){
                bolas += cont[i].cant;
                dif-=1;
                //printf("%d %d\n", cont[i].num, cont[i].cant);
            }
        } else {
            break;
        }
    }
    printf("%d\n", bolas);
}


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

int main() {
    int K, S; cin >> K >> S;
    int count = 0;
    for (int x = 0; x <= K; ++x) {
        for (int y = 0; y <= K; ++y) {
            int z = S - x - y;
            if (z >= 0 && z <= K) {
                ++count;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3624
n,m=map(int,input().split())
dict1={}
dict2={}
for i in range(m):
    x,y=map(int,input().split())
    try:
        dict1[x].append([y,i+1])
    except:
        KeyError
        dict1[x]=[[y,i+1]]
ansarr=["0"]*m
for i in dict1.keys():
    dict1[i].sort()
    s1=(6-len(str(i)))*'0'+str(i)
    for j in range(len(dict1[i])):
        s2=(6-len(str(j+1)))*'0'+str(j+1)
        #print(dict1[i][j][1])
        ansarr[dict1[i][j][1]-1]=s1+s2
for i in range(m):
    print(ansarr[i])

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

using namespace std;

#define int long long

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

    int a, b, c;
    cin >> a >> b >> c;

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


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

using namespace std;

#pragma GCC optimize("-O3")
#pragma GCC target("avx2")

#define int long long

const int INF = 1e18;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (n % 2 == 1)
    {
        cout << b[n / 2] - a[n / 2] + 1 << endl;
    }
    else
    {
        cout << (b[n / 2] + b[n / 2 - 1]) - (a[n / 2] + a[n / 2 - 1]) + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 6364
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    auto arr = readln.chomp.split.map!(to!long).array;
    
    immutable int MD = 10 ^^ 9 + 7;
    immutable int MXB = 61;
    
    int ans = 0;
    int[MXB] cnt;
    cnt[] = 0;
    foreach_reverse (i, e; arr) {
        foreach (bt; 0 .. MXB) {
            int totake;
            if ((e & (1L << bt)) > 0) {
                totake = (n-1 - i.to!int) - cnt[bt];
            } else {
                totake = cnt[bt];
            }
            
            auto cur = (1L << bt) % MD * totake % MD;
            ans = (ans + cur) % MD;
        }
        
        foreach (bt; 0 .. MXB) {
            if ((e & (1L << bt)) > 0) { ++cnt[bt]; }
        }
    }
 
    ans.writeln;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

vector<int> Solve() {
  int n, k;
  cin >> n >> k;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  // bool is_all_zero = [&]() {
  //   for (int i = 0; i < n; i++) {
  //     if (xs[i] > 0) return false;
  //   }
  //   return true;
  // }();

  // if (is_all_zero) return xs;

  auto is_all_n_fn = [&]() {
    for (int i = 0; i < n; i++) {
      if (xs[i] < n) return false;
    }
    return true;
  };

  for (int t = 0; t < k; t++) {
    vector<int> deltas(n + 1);
    for (int i = 0; i < n; i++) {
      deltas[max(i - xs[i], 0)]++;
      deltas[min(i + xs[i] + 1, n)]--;
    }
    int current = 0;
    for (int i = 0; i < n; i++) {
      current += deltas[i];
      xs[i] = current;
    }

    if (is_all_n_fn()) {
      return xs;
    }
  }
  return xs;
}

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

  auto ans = Solve();
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 4936
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func Max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func Min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	X := nextInt()

	for i := -118; i < 120; i++ {
		for j := -119; j < 119; j++ {
			if (i*i*i*i*i)-(j*j*j*j*j) == X {
				fmt.Println(i, j)
				return
			}
		}
	}
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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 main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> p(N);
    for (auto &&i : p) {
        cin >> i;
    }

    int ans = 0;
    if (p[0] == 1) {
        swap(p[0], p[1]);
        ans++;
    }
    FOR(i, 1, N) {
        if (p[i] == i + 1) {
            ans++;
            if (p[i + 1] == i + 2)
                i++;
        }
    }
    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 640
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int main(){
	cin>>n;
	int year,m,day;
	vector<int> kai;
	for(int i = 0;i < n;i++){
		int sum = 1;
		cin>>year>>m>>day;
		if(year%3==0){
			sum +=(10-m)*20+(20-day);
		}else{
			sum +=(5*19+5*20);
			for(int i = 1;i <m;i++){
				if(i%2==0){
					sum -=19;
				}else{
					sum -=20;
				}
			}
			if(m%2==0){
				sum -=day;
			}else{
				sum -=day;
			}
		}
		if(i<999){
			for(int i =year+1;i <1000;i++){
				if(i%3==0){
					sum +=(10*20);
				}else{
					sum +=(5*19+5*20);
				}
			}
		}
		kai.push_back(sum);
	}
	for(int i = 0;i <kai.size();i++){
		cout <<kai[i]<<endl;
	}
	return 0;
}

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

int main(){
  int a[26]={},i;
  char s[30];
  scanf("%s",s);
  for(i=0;i<strlen(s);i++){
    a[s[i]-97]++;
    if(a[s[i]-97]>1){
      i=0;
      break;
    }
  }
  puts(i?"yes":"no");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)2e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int n, d, a;
int pre[N];
vector<pair<int, int> > x;

int find_pos(int pos) {
    int low = 0, high = n - 1;
    int ans = -1;
    while(low <= high) {
        int mid = (low + high) >> 1;
        if(x[mid].first > pos) {
            high = mid - 1;
        }
        else {
            ans = mid;
            low = mid + 1;
        }
    }
    assert(ans != -1);
    return ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>n>>d>>a;
    f(i, n) {
        int u, v;
        cin>>u>>v;
        x.pb({u, v});
    }
    s(x);
    int ans =0;
    int curr = 0;
    f(i, n) {
        curr += pre[i];
        int need = (x[i].second - curr + a - 1)/ a;
        if(need <= 0) continue;
        int pos = find_pos(x[i].first + 2 * d);
        pre[i + 1] += need * a;
        pre[pos + 1] -= need * a;
        ans += need;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    getline(cin,S);
    for(int i=0;i<S.size();i++){
        if(65<=S.at(i)&&S.at(i)<=90){
            S.at(i)=S.at(i)+32;
        }
        else if(97<=S.at(i)&&S.at(i)<=122){
            S.at(i)=S.at(i)-32;
        }
        cout<<S.at(i);
    }
    cout<<endl;
}



Measured memory_bytes: 3144