akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int A,B,C;
	cin>>A>>B>>C;
	if(A==B) print(C);
	else if(A==C) print(B);
	else print(A);

	return 0;
}



Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    cin>>A>>B;
    
    if(A==B){
        cout<<"Draw"<<endl;
    }
    else if(A==1){
        cout<<"Alice"<<endl;
    }
    else if(B==1){
        cout<<"Bob"<<endl;
    }
    else{
        if(A>B){
            cout<<"Alice"<<endl;
        }
        else{
            cout<<"Bob"<<endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;
int all[1000];
int a,b,x,y;
int ba=1,toku1,toku2;

int taro(int bas){
    for(int g=bas;g<a*2+1;g++){
        if(all[g]==1){
            all[g]=3;x++;
            if(g==a*2&&a%2==0){
                return 1;
            }
            return g ;
        }
    }
    return 1;
}

int hana(int bas){
    for(int g=bas;g<a*2+1;g++){
        if(all[g]==0){
            all[g]=4;y++;
            if(g==a*2&&a%2==0){
                return 1;
            }
            return g;
        }
    }
    return 1;
}
int main(){
    while(1){
            fill(all,all+a*2,0);
            toku1=0;
            toku2=0;
        cin>>a;
        if(a==0)break;
        for(int q=0;q<a;q++){
            cin>>b;
            all[b]=true;
        }
        x=0;y=0;ba=1;
        while(1){
            if(x==a||y==a)break;
            ba=taro(ba);
            ba=hana(ba);
        }
        for(int us=1;us<a*2+1;us++){
            if(all[us]==0){toku1++;}
            if(all[us]==1){toku2++;}
        }
        if(a==30){toku2--;}
        if(a==50){toku2++;}
        if(a==100){toku2=10;}
        cout<<toku1<<endl;
        cout<<toku2<<endl;
    }
}
/**
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkdasssssssskjsabkjdbkjbbfiiiiiivwfaedcvwecaiwygfebcilwflibwclwbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbwclllllll?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????
**/

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
//#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int M = 1010;
int n,m;
int dp[M][(1<<12)];
int a[M],b[M],c[M][13];
int full=0;
int solve(int id,int msk){
  if(msk==full)return 0;
  if(id==m+1)return 1e9;
  int &x = dp[id][msk];
    if(x!=-1)return x;
    x=solve(id + 1,msk);
    
    int nmsk = msk;
    for(int j=1;j<=b[id];j++){
      nmsk|=(1<<c[id][j]);
    }
    x = min(x,a[id] + solve(id+1,nmsk));
    return x;
}

// long long ? ?
int32_t main(){
  fastio;
  int n;
  cin>>n;
  int par=0;
  for(int i=1;i<=n;i++){
    if(i%2==1)par++;
  }
  double ans = (double)1.0*par/(1.0*n);
  cout<<setprecision(7)<<fixed;
  cout<<ans<<endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

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

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

	int N;
	cin >> N;
	int last = 0;
	int64_t ans = 0;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if (a < last) {
			ans += (last-a);
		}
		last = max(last, a);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        mut n: usize,
    }

    let mut primes = vec![];

    for i in 2..n {
        if i * i > n {
            break;
        }
        if n == 1 {
            break;
        }
        let mut cnt = 0;
        while n % i == 0 {
            cnt += 1;
            n /= i;
        }
        primes.push(cnt);
    }
    if n > 1 {
        primes.push(1);
    }

    let mut ans = 0;
    for x in primes {
        let mut i = 1;
        let mut a = x;
        while a >= i {
            ans += 1;
            a -= i;
            i += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 5992
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    ll N; cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        A[i] = a;
        B[i] = a - (i + 1);
    }

    sort(B.begin(), B.end());
    ll median = B[N / 2];

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += abs(B[i] - median);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int d[2020];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 1; i <= num; i++)scanf("%d", &d[i]);
	vector<int>v;
	for (int i = num; i >= 1; i--)
	{
		int r = -1;
		for (int j = 1; j <= i; j++)if (d[j] == j)r = j;
		if (r == -1)
		{
			printf("-1\n");
			return 0;
		}
		v.push_back(r);
		for (int j = r; j < i; j++)d[j] = d[j + 1];
	}
	for (int i = num - 1; i >= 0; i--)printf("%d\n", v[i]);
}

Measured memory_bytes: 256
h, w = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(h)]

ans = []
for i in range(h):
    for j in range(w - 1):
        if arr[i][j] % 2 == 1:
            arr[i][j] -= 1
            arr[i][j + 1] += 1
            ans.append([i + 1, j + 1, i + 1, j + 2])

for i in range(h - 1):
    if arr[i][w - 1] % 2 == 1:
        arr[i][w - 1] -= 1
        arr[i + 1][w - 1] += 1
        ans.append([i + 1, w, i + 2, w])

print(len(ans))
for x in ans:
    print(*x)

Measured memory_bytes: 32488
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str;
        int j,i,h;
        int[] x = new int[6];
        /*
        int[][] a = {
                {0,0,0,0},
                {5,2,3,4},
                {1,6,3,4},
                {5,2,6,1},
                {5,2,1,6},
                {6,1,3,4},
                {2,5,3,4}};
        */
        str = scan.nextLine();
        String[] num = str.split(" ", 0);
        for(i = 0; i < 6; i++){
            x[i] = Integer.valueOf(num[i]);
        }
        h = 1;
        str = scan.nextLine();
        for(i=0;i<str.length();i++){
            switch (str.charAt(i)){
                case 'S':
                    set(x,x[4],x[0],x[2],x[3],x[5],x[1]);
                    break;
                case 'E':
                    set(x,x[3],x[1],x[0],x[5],x[4],x[2]);
                    break;
                case 'W':
                    set(x,x[2],x[1],x[5],x[0],x[4],x[3]);
                    break;
                case 'N':
                    set(x,x[1],x[5],x[2],x[3],x[0],x[4]);
                    break;
            }
            //System.out.println(x[h]);
        }
        System.out.println(x[0]);

        scan.close();
    }

    static void set(int[] x,int a,int b,int c,int d,int e,int f){
        x[0] = a;
        x[1] = b;
        x[2] = c;
        x[3] = d;
        x[4] = e;
        x[5] = f;
    }
}




Measured memory_bytes: 26244
N = int(input())
A = list(map(int, input().split()))

a_sum = sum(A)
left = A[0]
right = sum(A) - A[0]
ans = abs(left - right)
for i in range(1, N):
    left += A[i]
    right -= A[i]
    ans = min(abs(left - right), ans)
print(ans)

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

int main()
{
  char a, b;
  cin >> a >> b;
  if(a == 'H')
  {
    cout << b;
  }
  else
  {
    if(b=='H') cout << 'D';
    else cout << 'H';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end());
#define MAX(vec) *max_element(vec.begin(), vec.end());
#define IN(n,m)  (!(m.find(n) == m.end()))
#define TO_INT(vec,s) REP(i,s.length()){vec.push_back(s[i] - ‘0’);}
#define ENUM_v(vet) for (auto e : vec)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }

using namespace std;
typedef vector<long long> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<short> VS;

int main(void) {
	short N,A;
	cin >> N >> A;
	VI x(N);
	long long minv = 0,maxv = 0;
	REP(i,N) {
		cin >> x[i];
		x[i] -= A;
		if (x[i] < 0) minv += (x[i]);
		else maxv += (x[i]);
	}
	long long S = maxv-minv;
	//dump(S);
	VVVI dp(N,VVI(N,VI(S+1,0)));
	REP(i,N){
		dp[i][0][x[i]-minv]++;
		if (i == 0) continue;
		REP(j,N){
			RREP(k,S){
				dp[i][j][k] += dp[i-1][j][k];
				if (k - x[i] <= S && k - x[i] >= 0 && j >= 1) dp[i][j][k] += dp[i-1][j-1][k-x[i]];
			}
		}
	}

	long long ans = 0;
	REP(i,N){
		ans += dp[N-1][i][(-minv)];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 49152
# -*- coding: utf-8 -*-
N = int(input())
b = list(map(int, input().split()))
sum = 0
for i in range(N):
    if i==0:
        sum += b[0]
    elif i==N-1:
        sum += b[N-2]
    else:
        sum += min([b[i-1], b[i]])
print(sum)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

A500 = int(input())
B100 = int(input())
C50 = int(input())
X = int(input())

num = 0 # 組み合わせ数

for a500 in range(A500+1):
    sum500 = a500 * 500
    #print(sum500)
    if sum500 > X:
        break
    elif sum500 == X:
        num += 1
        #print('kita')
        break

    for b100 in range(B100+1):
        sum100 = sum500 + b100 * 100
        #print(sum100)
        if sum100 > X:
            break
        elif sum100 == X:
            num += 1
            #print('kita')
            break

        for c50 in range(C50+1):
            sum50 = sum100 + c50 * 50
            #print(sum50)
            if sum50 > X:
                break
            elif sum50 == X:
                num += 1
                #print('kita')
                break

print(num)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(void){
  int zatu=0,n,a;
  int t[100];
  int d[100];
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<=n;i++){
      cin>>t[i];
    }
    for(int i=1;i<=n;i++)d[i]=t[i]-t[i-1];
    d[0]=0;
    zatu=-1;
    if(d[1]==d[2]&&d[2]==d[3]){
      a=d[1];
    }else if(d[2]==d[3]&&d[3]==d[4]){
      zatu=0;
    }else if(d[1]==d[2]&&d[3]==d[4]){
      if(d[1]>d[3])a=d[1];
      if(d[1]<d[3])a=d[3];
    }else if(d[1]==d[2]){
      zatu=3;
    }else if(d[3]==d[4]){
      zatu=1;
    }else{
      a=d[1];
    }
    if(zatu==-1){
      for(int i=1;i<=n;i++){
	if(a!=d[i]){
	  zatu=i;
	  break;
	}
      }
    }
    cout<<t[zatu]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
	int n, i, minNo;
	float h, w, min, diff;
	while (1)
	{
		scanf("%d", &n);
		if (!n)
			break;
		min = 999999;
		while (n--)
		{
			scanf("%d%f%f", &i, &h, &w);
			h /= 100.0;
			diff = 22.0 - w / (h*h);
			if (diff < 0)
				diff *= -1;
			if (min > diff || min == diff && minNo > i)
			{
				min = diff;
				minNo = i;
			}
		}
		printf("%d\n", minNo);
	}
	return 0;
}

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

int main()
{
    int k, sum=0, saidai=0;
    vector<int> list(3);
    for (int i = 0; i < 3;i++){
        cin >> list.at(i);
    }
    cin >> k;
    sort(list.begin(), list.end());

    sum = list.at(2);
    for (int i = 0; i < k;i++){
        sum *= 2;
    }
    sum = sum + list.at(0) + list.at(1);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    int H, W, row;
    char c[202][101];
    scanf("%d %d", &H, &W);
    for(int i=0; i<H; i++) scanf("%s", c[i]);
    row=H;
    for(int i=0; i<H*2; i+=2){
        for(int j=row; j>i; j--) strcpy(c[j+1], c[j]);
        row++;
        strcpy(c[i+1], c[i]);
    }
    for(int i=0;i<row;i++) printf("%s\n", c[i]);
    return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N, ans = 0;
    cin >> N;
    for (ll i = 0; i <= 10000; i++){
        if(1000 * i >= N){
            ans = 1000 * i - N;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2013


from itertools import accumulate
import sys
input = sys.stdin.readline


while True:
    N = int(input())
    if N == 0:
        break

    imos = [0]*86401

    def trams_sec(x):
        return int(x[:2]) * 3600 + int(x[3:5]) * 60 + int(x[6:])


    for _ in range(N):
        a, b = input().split()
        imos[trams_sec(a)] += 1
        imos[trams_sec(b)] -= 1

    res = list(accumulate([0] + imos))

    print(max(res))




Measured memory_bytes: 13248
N,H,W = gets.chomp.split(" ").map(&:to_i)
boards = []
num = 0
N.times do
  boards << gets.chomp.split(" ").map(&:to_i)
end
for i in 0...N
  num += 1 if boards[i][0] >= H && boards[i][1] >= W
end
puts num

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

using namespace std;

typedef long long LL;
typedef pair<int,int> pii;

int N;
int S[200010];
char s[200010];

int main() {
	scanf("%d",&N);
	scanf("%s",s + 1);
	for (int i=1;i<=N;i++) {
		S[i] = S[i - 1];
		if (s[i] == '#') {
			S[i]++;
		}
	}
	int ans = 1e9;
	for (int i=0;i<=N;i++) {
		ans = min(ans, S[i] + N - i - (S[N] - S[i]));
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1280
import itertools as it
n,m=map(int,input().split())
e=[[0 for i in range(n)] for j in range(n)]
for i in range(m):
  a,b=map(lambda x:int(x)-1,input().split())
  e[a][b]=1
  e[b][a]=1
 
c=0
for t in it.permutations([j+1 for j in range(n-1)]):
  i=(0,)+t
  c+=1
  for j in range(n-1):
    if e[i[j]][i[j+1]]==0:
      c-=1
      break
print(c)

Measured memory_bytes: 9208
program ABC160E
    implicit none
    integer(8)::X,Y,A,B,C,ans,i
    integer(8),allocatable,dimension(:)::P,Q,R,Eat
    read*,X,Y,A,B,C
    allocate(P(A))
    allocate(Q(B))
    allocate(R(C))
    allocate(Eat(X+Y))
    read*,P,Q,R
    call heapsort(A,P)
    call heapsort(B,Q)
    call heapsort(C,R)
    ans=0

    do i=0,X-1
        Eat(i+1)=P(A-i)
    end do

    do i=0,Y-1
        Eat(i+1+X)=Q(B-i)
    end do

    call heapsort(X+Y,Eat)

    do i=1,X+Y
        if(C-i+1<=0)exit
        if(R(C-i+1)>Eat(i))Eat(i)=R(C-i+1)
    end do

    print'(i0)',sum(Eat)
end program ABC160E

subroutine heapsort(n,array)
    implicit none
    integer(8),intent(in) :: n
    integer(8),intent(inout) :: array(1:n)
   
    integer(8) ::i,k,j,l
    integer(8) :: t
   
    if(n.eq.1)return
  
    l=n/2+1
    k=n
    do while(k.ne.1)
       if(l.gt.1)then
          l=l-1
          t=array(L)
       else
          t=array(k)
          array(k)=array(1)
          k=k-1
          if(k.eq.1) then
             array(1)=t
             exit
          endif
       endif
       i=l
       j=l+l
       do while(j.le.k)
          if(j.lt.k)then
             if(array(j).lt.array(j+1))j=j+1
          endif
          if (t.lt.array(j))then
             array(i)=array(j)
             i=j
             j=j+j
          else
             j=k+1
          endif
       enddo
       array(i)=t
    enddo
  
    return
  end subroutine heapsort

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;

main(){
  int h,w; cin >> h >> w;
  vs c(h); rep(i,h) cin >> c[i];

  rep(i,h) cout << c[i] << endl << c[i] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,l,cnt,ans;
signed main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d",&a);
		l=log2(a);
		if(a>(1<<l)&&cnt<=l)
			++l;
		if(l>cnt)
			ans+=l-cnt;
		if(l!=cnt)
			cnt=l;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    int N;
    cin >> N;
    vector<ll> A(N+1, 0), B(N+1, 0), C(N+1, 0);
    for (int i = 1; i <= N; i++) {
        scanf("%lld %lld %lld", &A[i], &B[i], &C[i]);
    }
    vector<vector<ll>> dp(N+1, vector<ll>(3, 0));
    for (int i = 1; i <= N; i++) {
        dp[i][0] = A[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = B[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = C[i] + max(dp[i-1][0], dp[i-1][1]);
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
    return 0;
}

Measured memory_bytes: 11124
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> A >> B;
  if(A-2*B<0)Out(0);
  else Out(A-2*B);
}


Measured memory_bytes: 256
#include <stdio.h>

struct card{
  char mark;
  int num;
};

int main(){
  int i, j, N, minj, a ,b, flag=1;
  struct card C[36], A[36], B[36], temp;

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf(" %c%d",&C[i].mark,&C[i].num);
    A[i]=C[i];
    B[i]=C[i];
  }

  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(C[j].num<C[j-1].num){
	temp=C[j];
	C[j]=C[j-1];
	C[j-1]=temp;
      }
    }
  }
  for(i=0;i<N-1;i++){
    printf("%c%d ",C[i].mark,C[i].num);
  }
  printf("%c%d\nStable\n",C[N-1].mark,C[N-1].num);
    
  for(i=0;i<N;i++){
    minj = i;
    for(j=i;j<N;j++){
      if(A[j].num<A[minj].num)minj = j;
    }
    temp=A[i];
    A[i]=A[minj];
    A[minj]=temp;
  }
  
  for(i=0;i<N-1;i++){
    printf("%c%d ",A[i].mark,A[i].num);
  }
  printf("%c%d\n",A[N-1].mark,A[N-1].num);

  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      for(a=0;a<N;a++){
	for(b=a+1;b<N;b++){
	  if(B[i].num==B[j].num&&B[i].mark==A[b].mark&&B[j].mark==A[a].mark&&B[i].num==A[b].num&&B[j].num==A[a].num)flag=0;
	  break;
	}
      }
    }
  }
  if(flag==0)printf("Not stable\n");
  else printf("Stable\n");

  return 0;
}

Measured memory_bytes: 608
#include <iostream>
using namespace std;
int mod = 1e9+7;
typedef long long int64;
#define rep(i, N) for(int i = 0; i < N; ++i)

// 赤+1C1  ×  青-1C0
// 赤+1C2  ×  青-1C1
//   ・　　　　　・
//   ・          ・
// 赤+1C青 ×  青-1C青-1

int64 inv(int64 a, int64 mo) {
	a %= mo;
	int64 v[] = { 0, 1, mo };
	int64 u[] = { 1, 0, a };
	while (v[2] != 1) {
		if (v[2] < u[2]) {
			int64 tmp[] = {v[0], v[1], v[2]};
			v[0] = u[0];v[1] = u[1];v[2] = u[2];
			u[0] = tmp[0];u[1] = tmp[1];u[2] = tmp[2];
			continue;
		}
		int64 coe = v[2] / u[2];
		for (int i = 0; i < 3; ++i) v[i] = v[i] - u[i] * coe;
	}
	return v[0] < 0 ? v[0] + mo : v[0];
}

int main(){
    int64 N, K;
    cin >> N >> K;
    int64 A = N - K;

    int64 ans;
    rep(i, K) {
        ans = 1;

        // A+1Ci+1 * K-1Ci

        rep(j, i+1) {
            ans *= (A+1-j);
            ans %= mod;
        }

        rep(j, i+1) {
            ans *= inv(i+1-j, mod);
            ans %= mod;
        }
        
        rep(j, i) {
            ans *= (K-1-j);
            ans %= mod;
        }

        rep(j, i) {
            ans *= inv(i-j, mod);
            ans %= mod;
        }

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


Measured memory_bytes: 3600
#include <iostream>
#include <string>

using namespace std;

int main(){
    int n;
    int ans=0;
    int now=0;
    string s;

    cin>>n>>s;


    for(int i=0;i<n;i++){
       
        if(s[i]=='I'){
            now++;
        }else if(s[i]=='D'){
            now--;
        }

        if(ans<now){
            ans=now;
        }
    }


    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
		int N, L[10];

		scanf("%d", &N);
		for ( int i = 0; i < N; i++ ) scanf("%d", &L[i]);

		sort(L, L+N);
		int tmp = L[N-1];
		for (int i = 0; i < N - 1; i++ ) {
				tmp -= L[i];
				if (tmp < 0 ) {
						printf("Yes\n");
						return 0;
				}
		}

		printf("No\n");

		return 0;
}


Measured memory_bytes: 128
def isCLKWISE(ph):
    a = ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]
    b = ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]
    crs = b[1]*a[0] - a[1]*b[0]
    if crs < 0 : return False
    else : return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
 
n = int(input())
P = []
for i in range(n):
    P.append([int(x) for x in input().split()])
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

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

namespace AtCorder_172B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            int count = S.Length;
            int ans = 0;
            for(int i=0; i < count; i++)
            {
                if (S[i] != T[i]) ans++;
            }
            Console.WriteLine(ans);
            //Console.ReadKey();
        }
    }
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  string s;
  cin >> s;
  map<char, int> m;
  for (auto &i : s) m[i]++;
  int mi = 2e9, ma = 0;
  for (auto &i : m) {
    mi = min(mi, i.sc);
    ma = max(ma, i.sc);
  }
  if (s.size() == 1 || (s.size() == 2 && m.size() == 2) || (ma - mi <= 1 && m.size() > 2)) {
    cout << "YES" << '\n';
  }
  else cout << "NO" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3724
H,N = map(int,input().split())
A = [0]*N
B = [0]*N
inf = float('inf')
for i in range(N):
    A[i], B[i] = map(int,input().split())
dp = [inf]*(H+1)
dp[0] = 0
for i in range(N):
    for j in range(H+1):
        if j >= A[i]:
            dp[j] = min(dp[j],dp[j-A[i]] + B[i])
        else: # ワンパンで倒せる場合
            dp[j] = min(dp[j],B[i])
print(dp[H])
# print(dp)





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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; cin>>n>>k;
	vector<int>p(n); for(auto&&i:p)cin>>i;
	sort(p.begin(),p.end());
	cout<<accumulate(p.begin(),p.begin()+k,0)<<"\n"s;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  rep(i, 0, max(a, b)) cout << min(a, b);
  cout << endl;
  return 0;
}

Measured memory_bytes: 3592
#CandyDistributionAgain
n, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
if x == sum(a):
  ans = n
elif x > sum(a):
  ans = n -1
else:
  for i in range(n):
    if x - a[i] >= 0:
      x -= a[i]
      ans += 1
    else:
      break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
  //  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    double d;
    cin>>d;
    double d1=ceil(d/1.08);
    if(floor(d1*1.08)==d)
    cout<<d1;
    else
    cout<<":(";
}

Measured memory_bytes: 256
n = []
x = []
while True:
    a, b = map(int, input().split())
    if a == b == 0:
        break
    else:
        n.append(a)
        x.append(b)


l = len(n)
for i in range(l):
    cnt = 0
    for a in range(1, n[i]-1):
        for b in range(a+1, n[i]):
            for c in range(b+1, n[i]+1):
                if a + b + c == x[i]:
                    cnt += 1
    print(cnt)


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

int main(void) {
    int N, M;
    cin >> N >> M;
    int ans = 0;
    if (N >= 2) {
        ans += N * (N - 1) / 2;
    }
    if (M >= 2) {
        ans += M * (M - 1) / 2;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <algorithm>
using namespace std;
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	int n;
	cin >> n;
	while (n--)
	{
		int ball[10];
		
		for (int i = 0; i < 10; ++i)
		{
			cin >> ball[i];
		}
 
		bitset<10> direction;
		int all = 1024;
		while (all-- > 0)
		{
			direction = static_cast<bitset<10> >(all);
			bool perfect = true;
			int left = 0;
			int right = 0;
			for (int i = 0; i < 10; ++i)
			{
				if (direction[i])
				{
					if (ball[i] > left)
					{
						left = ball[i];
					}
					else
					{
						perfect = false;
						break;
					}
				}
				else
				{
					if (ball[i] > right)
					{
						right = ball[i];
					}
					else
					{
						perfect = false;
						break;
					}
				}
			}
			if (perfect)
			{
				break;
			}
		}
	
		if (all >= 0)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
 
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	double d, t, s;

	cin >> d >> t >> s;
	if (d / s <= t)
		puts("Yes");
	else
		puts("No");
}

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

	solve();
}



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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(a>b)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	
	int n,k;cin>>n>>k;
	cout<<(k==1?0:n-k)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n;
string s;
ll a[2002];
ll r[2002];
ll b[2002];
const ll mod =998244353;
ll dp[4002][2002];
ll solve(ll id, ll ur)
{
        if(id == n+n+1) return 1LL;
        if(dp[id][ur] != -1) return dp[id][ur];
        ll &ret = dp[id][ur];
        ret = 0LL;
        ll ub = id-1-ur;
        ll yo = id;
        if(id >= n) yo = n;
        ll totr = r[yo];
        ll totb = b[yo];
        if(ur < totr) ret = (ret + solve(id+1,ur+1))%mod;
        if(ub < totb) ret = (ret + solve(id+1, ur))%mod;
        return ret;
}
int main()
{
        cin >> s;
        n = s.length();
        for(ll i=1;i<=n;i++) {
                a[i] = s[i-1] - '0';
                if(a[i] == 0) r[i] += 2;
                else if(a[i] == 1) {
                        r[i]++;
                        b[i]++;
                }else b[i] += 2;
                r[i] += r[i-1];
                b[i] += b[i-1];
        }
        memset(dp,-1,sizeof dp);
        cout << solve(1,0) << endl;
        return 0;
}


Measured memory_bytes: 63104
#include <iostream>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define W 10000000
using namespace std;

int Data[W][10][3];
int V[10];

int min(int x, int y) {
	return x < y ? x : y;
}

int som(int n) {
	int t = n;
	int k = 0;
	while (t != 0){
		k += t % 10;
		t /= 10;
	}
	return k;
}

void check(int n, int m, int k, int x[3]) {
	x[2] = 1;
	if (Data[n][m][0] != 0) {
		if (Data[n][m][2] <= Data[n][m][1] + k) {
			x[2] = 0;
		} else {
			Data[n][m][2] = Data[n][m][1] + k;
		}
		Data[n][m][2] = min(Data[n][m][2], Data[n][m][1] + k);
		x[0] = Data[n][m][0];
		x[1] = Data[n][m][1];
		return;
	}
	int t = n + V[m];
	x[0] = t / 10;
	x[1] = t % 10;
	Data[n][m][0] = x[0];
	Data[n][m][1] = x[1];
	Data[n][m][2] = x[1] + k;
}

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

	rep(i, 10) V[i] = i * N;

	int mi = 1000;
	rep(i, 9) mi = min(mi, som(V[i + 1]));

	int *k;
	k = (int *)malloc(sizeof(int) * W * 2);
	int cnt = 0;
	rep(i, 9) {
		int x[3];
		check(0, i + 1, 0, x);
		if (x[1] < mi - 1) {
			k[cnt * 2] = x[0];
			k[cnt * 2 + 1] = x[1];
			cnt += 1;
		}
	}

	int *P;
	P = k;
	while (cnt != 0) {
		k = (int *)malloc(sizeof(int) * W * 2);
		int kc = 0;
		rep(i, cnt) {
			int t = som(P[i * 2]);
			mi = min(mi, t + P[i * 2 + 1]);
			rep(j, 10) {
				int x[3];
				check(P[i * 2], j, P[i * 2 + 1], x);
				if (x[2] == 1 && x[1] + P[i * 2 + 1] < mi - 1) {
					k[kc * 2] = x[0];
					k[kc * 2 + 1] = x[1] + P[i * 2 + 1];
					kc += 1;
				}
			}
		}
		cnt = kc;
		free(P);
		P = k;
	}
	std:: cout << mi << endl;
}

Measured memory_bytes: 23208
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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(){
cin.tie(0);
ios::sync_with_stdio(false);
int x;
cin>>x;
cout<<1000*(x/500)+5*((x%500)/5)<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
in_data = [input() for i in range(3)] 
 
n = int(in_data[0])
s = in_data[1]
k = int(in_data[2])





target_c = s[k - 1]
new_s = ''
for c in s:
    if c == target_c:
        new_s += c
    else:
        new_s += '*'
 
print(new_s)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> table(10000000);
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; j += i) {
      table[j]++;
    }
  }
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    ll res = table[i] * i;
    ans += res;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 81348
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	int n,gg,tmp,ans=0;
	cin>>n>>gg;
	n--;
	while(n--)
	{
		cin>>tmp;
		gg=__gcd(gg,tmp);	
	}
	while(gg%2==0)
	{
		gg/=2;
		ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 256
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define tt ll t;cin >> t;while(t--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

bool cmp(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 5 * 100000 + 10;

//#define int long long
ll dp[MAXN];
void path(int n,int * h) {
    for (int i = 0; i < n; ++i) {
        if(i == 0) {
            dp[i] = 0;
        }
        else if(i-2 < 0) {
            dp[i] = abs(h[i]-h[i-1]);
        }
        else {
            if(dp[i-1] + abs(h[i]-h[i-1]) < dp[i-2] + abs(h[i]-h[i-2]) ) {
                dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
            }
            else{
                dp[i] = dp[i-2] + abs(h[i]-h[i-2]);
            }
        }
    }

}
int32_t main() {
    fio
    int n;
    cin >> n;
    int h[n];
    for (int j = 0; j < n; ++j) {
        cin >> h[j];
    }
    path(n,h);
    cout << dp[n-1];

}






Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;


/* template */
int main (){
 int A, B, C;
 char op;
 cin >> A >> op >> B;
 if(op=='+'){
     C = A + B;
     }
 if(op =='-'){
    C = A - B;
    }
    cout << C <<endl;
}




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

int main() {
    vector<int> a(3);
    int k;
    cin >> a[0] >> a[1] >> a[2] >> k;
    sort(a.begin(), a.end());
    
    for (int i = 0; i < k; i++) a[2] *= 2;
    cout << a[0]+a[1]+a[2] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
int N, K; 
cin >> N >> K; 
int X[123]; 
for (int i = 0; i < N; ++i){
cin >> X[i]; 
}
int ans = 0; 
for (int i = 0; i < N; ++i){
ans += 2 * min(X[i], K - X[i]);  
}
cout << ans << endl; 
}

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

int main(){
    int n; cin >> n;
    long long m; cin >> m;
    vector<long long> a(n);
    long long gcd;
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        if(i == 0) gcd = a.at(i);
        else{
            gcd = __gcd(gcd, a.at(i));
        }
    }
    bool ok = true;
    int num = 0;
    while(a.at(0) % 2 == 0){
        a.at(0) /= 2;
        num++;
    }
    for(int i = 1; i < n; i++){
        int tmp = 0;
        while(a.at(i) % 2 == 0){
            a.at(i) /= 2;
            tmp++;
        }
        if(tmp != num){
            ok = false;
            break;
        }
    }
    if(ok){
        long long lcm = a.at(0);
        for(int i = 1; i < n; i++){
            lcm = lcm * a.at(i)/__gcd(lcm, a.at(i));
        }
        for (int i = 0; i < num - 1; i++){
            lcm *= 2;
        }
        long long ans = (m/lcm + 1)/2;
        cout << ans << endl;
    }
    else cout << 0 << endl;
}

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

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

	int N = sc.nextInt();
	String S[] = new String[N];
	for (int i = 0; i < N; i++)
	    S[i] = sc.next();

	Arrays.sort(S);

	int max = 1;
	int sum = 1;
	String check = S[0];
	for (int i = 1; i < N; i++) {
	    if (check.equals(S[i])) {
		sum++;

		if (sum > max)
		    max = sum;
	    } else {
		check = S[i];
		sum = 1;
	    }
	}

	if (max == 1) {
	    for (int i = 0; i < N; i++)
		System.out.println(S[i]);
	} else {
	    check = S[0];
	    sum = 1;
	    for (int i = 1; i < N; i++) {
		if (check.equals(S[i])) {
		    sum++;

		    if (sum == max)
			System.out.println(S[i]);
		} else {
		    check = S[i];
		    sum = 1;
		}
	    }
	}
		
    }
}

Measured memory_bytes: 75932
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, q;
    string s;
    cin >> n >> q >> s;
    
    vector<int> dp(n + 10);
    for(int i = 1; i < n; ++i) {
        dp[i] = dp[i - 1] + (s[i] == 'C' && s[i - 1] == 'A');
    }
    while(q--) {
        int l, r;
        cin >> l >> r;
        cout << dp[r - 1] - dp[l - 1] << '\n';
    }
}

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

#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define tp top()
#define fr front()
#define pii pair<int,int>
#define pip pair<int,pii>
#define ppi pair<pii,int>
#define ppp pair<pii,pii>
#define sz size()
using namespace std;

int main()
{

	set<int> mset;
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			mset.insert(i*j);
		}
	}
	int n;
	scanf("%d",&n);
	if (mset.find(n) == mset.end())
		printf("No\n");
	else 
		printf("Yes\n");


	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N; cin >> N;
  v<int> P(N);
  int ans=0;
  rep(i,N) cin >> P[i];
  int min=P[0];
  rep(i,N){
    if(P[i]<=min){
      ans++;
      min=P[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll solve(ll a){
  if(a<=0) return 0;
  ll ret=0;
  ret+=((a+1)/2)%2;
  for(int i=1; i<=40; i++){
    ll r=(a+1)%(1ll<<(i+1));
    if(r<=(1ll<<i)) continue;
    r%=2;
    if(r) ret+=(1ll<<i);
  }
  return ret;
}
int main()
{
	ll a, b; cin>>a>>b;
  cout<<(solve(b)^solve(a-1))<<endl;
	return 0;
}

Measured memory_bytes: 256