akhauriyash/Code-Regression huggingface dataset:
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"10"# => r#"9"#,
r#"81"# => r#"81"#,
r#"271828182"# => r#"271821169"#,
}


fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
    }
    let mut ans = 0;

    for i in (0..n+1).rev() {
        let t = (i as f64).powf(0.5) as usize;
        if t * t == i {
            ans = i;
            break;
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    ans = 0
    d = list( map( int, input().split()))
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            ans += d[i]*d[j]
    print(ans//2)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int main()
{
    int n; cin >> n;
    string s[n];
    set<string> st;
    ll cntM=0, cntA=0, cntR=0, cntC=0, cntH=0;
    REP(i,n){
        cin >> s[i];
        if(s[i][0]=='M'){
            cntM++;
        }else if(s[i][0]=='A'){
            cntA++;
        }else if(s[i][0]=='R'){
            cntR++;
        }else if(s[i][0]=='C'){
            cntC++;
        }else if(s[i][0]=='H'){
            cntH++;
        }
    }
    ll ans=0;
    int P[10] = {0,0,0,0,0,0,1,1,1,2};
    int Q[10] = {1,1,1,2,2,3,2,2,3,3};
    int R[10] = {2,3,4,3,4,4,3,4,4,4};
    ll D[5];
    D[0]=cntM, D[1]=cntA, D[2]=cntR, D[3]=cntC, D[4]=cntH;
    REP(i,10){
        ans+=D[P[i]]*D[Q[i]]*D[R[i]];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6144
n = int(input())
data = []
for _ in range(n):
    data.append(list(map(int, input().split())))
data = sorted(data, key=lambda x: x[2], reverse=True)

ok = True
res = []
x0, y0, h0 = data[0]
if h0 > 0:
    for cx in range(101):
        for cy in range(101):
            hh = h0 + abs(cx - x0) + abs(cy - y0)
            ok = True
            for i, (x, y, h) in enumerate(data[1:]):
                if h != max(hh - abs(cx - x) - abs(cy - y), 0):
                    ok = False
                    continue
            if ok:
                res = [cx, cy, hh]
                break
        if ok:
            break
else:
    for cx in range(101):
        for cy in range(101):
            for x, y, _ in data:
                if cx != x and cy != y:
                    res = [cx, cy, 1]
print(' '.join(map(str, res)))

Measured memory_bytes: 3064
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<int> a(n+1);
    REP(i,n+1) a[i] = i;
    vector<ll> s(n+2,0);
    REP(i,n+1) {
        s[i+1l] = s[i] + a[i];
    }


    ll ans = 0;
    for(int i = k; i <= n+1; i++) {
        ll min = s[i] - s[0];
        ll max = s[n+1] - s[n-i+1];
        ans = (ans + max-min +1) % 1000000007;
    }
    cout << ans << endl;
    return 0;
}

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

class mcomb {
public:
    vector<ll> fact, ifact;
    ll m;

    mcomb(ll n, ll m_=1e9+7): fact(n+1, 1), ifact(n+1), m(m_) {
        rep(i,n) fact[i+1] = (fact[i]*(i+1)) % m;
        ifact[n] = minv(fact[n]);
        rep(i,n) ifact[n-1-i] = (ifact[n-i]*(n-i)) % m;
    }

    ll operator()(ll n, ll k) {
        if(k < 0 || k > n) return 0;
        return (((ifact[k]*ifact[n-k]) % m)*fact[n]) % m;
    }

    ll minv(ll a) {
        ll b = m, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }    
};

int main()
{
    const ll m = 1e9+7;
    ll n,k;
    cin >> n >> k;

    k = min(k, n-1);
    mcomb mc(n, m);
    ll ans = 0;
    rep(i,k+1) {
        ans += (mc(n,i) * mc(n-1,i)) % m;
        ans %= m;
    }

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

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

int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	int i;
	for (i = n; i > 0; i--) {
		int j;
		for (j = 0; j < i && s[n - i + j] == t[j]; j++) {
		}
		if (j == i) {
			break;
		}
	}
	cout << 2 * n - i << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
const int N = 1e5 + 10;
 
int a[N] , b[N] , f[N] , sz[N] , xorsuma , xorsumb , _a[N] , _b[N] , n , cnt;
 
int F(int x) {
	if (f[x] != x) {
		f[x] = F(f[x]);
	}
	return f[x];
}
 
int main() {
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) {
		scanf("%d",a + i);
 
		_a[i] = a[i];
		xorsuma ^= a[i];
	}
 
	for (int i = 1; i <= n; i++) {
		scanf("%d",b + i);
		_b[i] = b[i];
		xorsumb ^= b[i];
	}
	n++;
	_a[n] = a[n] = xorsuma;
	_b[n] = b[n] = xorsumb;
 
	sort(_a + 1 , _a + 1 + n);
	sort(_b + 1 , _b + 1 + n);
 
	for (int i = 1; i <= n; i++) {
		if (_a[i] != _b[i]) {
			return puts("-1") , 0;
		}
	}
	cnt = unique(_a + 1 , _a + 1 + n) - _a - 1;
 
	for (int i = 1; i <= n; i++) {
		a[i] = lower_bound(_a + 1 , _a + 1 + cnt , a[i]) - _a;
		b[i] = lower_bound(_a + 1 , _a + 1 + cnt , b[i]) - _a;
	}
 
	for (int i = 1; i <= cnt; i++) f[i] = i , sz[i] = 1;
 
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] != b[i]) {
			ans += i < n;
			int fathera = F(a[i]) , fatherb = F(b[i]);
			if (fathera != fatherb) {
				sz[fathera] += sz[fatherb];
				f[fatherb] = fathera;
			}
		}
	}
	for (int i = 1; i <= cnt; i++) {
		if (sz[F(i)] == 1) {
			continue;
		} else if (F(i) == i && sz[F(i)] > 1) {
			ans ++;
		}
	}
	if (sz[F(a[n])] != 1) ans --;
 
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
int main(){
      string s;
      cin>>s;
      if(s=="SUN"){
          cout<<7<<endl;
      }
      else if(s=="MON"){
        cout<<6<<endl;
      }
      else if(s=="TUE"){
        cout<<5<<endl;
      }
      else if(s=="WED"){
        cout<<4<<endl;
      }
      else if(s=="THU"){
        cout<<3<<endl;
      }
      else if(s=="FRI"){
        cout<<2<<endl;
      }
      else if(s=="SAT"){
        cout<<1<<endl;
      }
      
      
      
 return 0;  
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int a,b; cin >> a >> b;
	if(a == 1) a = 14;
	if(b == 1) b = 14;
	cout << (a > b ? "Alice" : a < b ? "Bob" : "Draw" ) << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    ls = []
    n = int(input())
    t = list(map(int, input().split()))
    sum = 0
    for i in range(n):
        sum += t[i]
    m = int(input())
    for i in range(m):
        p, x = map(int, input().split())
        ls.append(sum - (t[p-1]-x))
    for i in range(m):
        print(ls[i])


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

const ll N = 1e7 + 10;
ll spf[N];

void pre() {
    spf[1] = 1;
    for(ll i = 2; i < N; i++) {
        if(spf[i] == 0) {
            for(ll j = i; j < N; j += i) {
                if(spf[j] == 0) spf[j] = i;
            }
        }
    }
}

void solve() {
    pre();
    ll n;
    cin >> n;
    ll ans = 1;
    for(ll i = 2; i <= n; i++) {
        ll cnt = 0, tot = 1, j = i, pspf = spf[j];
        while(j > 1) {
            j /= spf[j];
            cnt++;
            if(spf[j] != pspf) {
                tot *= cnt + 1;
                pspf = spf[j];
                cnt = 0;
            }
        }
        ans += i * tot;
    }
    cout << ans;
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 81740
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	while(1){
		int n;
		int a;
		int num[5001]={0},ans=0;
		cin>>n;
		if(n==0)break;
		cin>>num[0];
		for(int i=1;i<n;i++){
			cin>>a;
			num[i]=num[i-1]+a;
		}
		ans=num[0];
		for(int i=1;i<n;i++){
			ans=max(ans,num[i]);
			for(int j=0;j<i;j++){
				ans=max(ans,num[i]-num[j]);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3092
#include<cstdio>
#include<algorithm>

using namespace std;

const long long MA=1000000000000000000ll+1;

long long gcd(long long a,long long b){
	if(a<b) return gcd(b,a);
	if(b==0) return a;
	return gcd(b,a%b);
}

long long lcm(long long a,long long b){
	if(a==MA||b==MA) return MA;
	long long d=gcd(a,b);
	b/=d;
	if(a>=MA/b+1) return MA;
	return min(MA,a*b);
}

long long num[1<<20];
long double pr[1<<20];

long long a[20];
long double p[20];

int main(){
	int N;
	long long M;
	scanf("%d%lld",&N,&M);
	for(int i=0;i<N;i++) scanf("%lld",a+i);
	for(int i=0;i<N;i++){
		int in;
		scanf("%d",&in);
		p[i]=(long double)in/100;
	}
	for(int stat=0;stat<(1<<N);stat++){
		int cnt=0;
		if(stat==0) num[stat]=0;
		else{
			long long d=1;
			for(int i=0;i<N;i++) if(((stat>>i)&1)==1){
				cnt++;
				d=lcm(d,a[i]);
			}
			num[stat]=M/d;
			if(cnt%2==0) num[stat]*=-1;
		}
		pr[stat]=1;
		for(int i=0;i<N;i++){
			if(((stat>>i)&1)==1) pr[stat]*=p[i];
			else pr[stat]*=(1-p[i]);
		}
	}
	for(int i=0;i<N;i++) for(int j=0;j<(1<<N);j++){
		if(((j>>i)&1)==1){
			num[j]+=num[j&(~(1<<i))];
		}
	}
	long double ans=0;
	for(int stat=0;stat<(1<<N);stat++){
		long double tmp=pr[stat]*num[stat];
		ans+=tmp;
	}
	printf("%.9llf\n",ans);
	return 0;
}

Measured memory_bytes: 25644
#include <iostream>
#include <vector>
#include <queue>
#include <limits>
using namespace std;

struct vec {
    int t, c;
    vec(int to, int cost):t(to),c(cost){}
    bool operator>(const vec &r)const{return t>r.t;}
};
vector<vec> adj[10000];
int d[10000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0; i<n; i++) d[i]=numeric_limits<int>::max();
    for(int i=0; i<n; i++) {
        int u,k;
        cin>>u>>k;
        adj[u].reserve(k);
        for(int j=0; j<k; j++) {
            int v,c;
            cin>>v>>c;
            adj[u].push_back(vec(v,c));
        }
    }
    priority_queue<vec, vector<vec>, greater<vec> >q;
    q.push(vec(0,0));
    while(!q.empty()) {
        vec e=q.top();
        q.pop();
        if(d[e.t]<=e.c) continue;
        d[e.t]=e.c;
        for(vector<vec>::iterator it=adj[e.t].begin(); it!=adj[e.t].end(); ++it) q.push(vec(it->t, e.c+it->c));
    }
    for(int i=0; i<n; i++) cout<<i<<' '<<d[i]<<'\n';
    return 0;
}

Measured memory_bytes: 22236
import java.util.Scanner;

public class Main{
	public static void main(String[] arg){
  		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	double[] x = new double[n];
      	double[] y = new double[n];
      	double len = sc.nextInt();
      int count = 0;
      for (int i=0;i<n;i++){
        x[i] = sc.nextDouble();
        y[i] = sc.nextDouble();
        if (Math.sqrt(Math.pow(x[i],2)+Math.pow(y[i],2))<=len){
          count = count+1;
        }
      }
          System.out.println(count);
        
    }
}

Measured memory_bytes: 66840
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
	int n;
	while(cin >> n,n){
		int cnt = 0;
		while(n /= 5){
			cnt += n;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

using namespace std;

int n;
long long sum;
int a[200010];
bool flag[200010];
long long tong[200010];

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        tong[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(!flag[a[i]])
        {
            sum+=tong[a[i]]*(tong[a[i]]-1)/2ll;
            flag[a[i]]=true;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(tong[a[i]]>=2)
        {
            printf("%lld\n",sum-tong[a[i]]+1);
        }
        else
        {
            printf("%lld\n",sum);
        }
    }
    return 0;
}

Measured memory_bytes: 4096
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(H: int, N: int, A: "List[int]", B: "List[int]"):
    DP = [INF]*(H+1)
    DP[0] = 0
    for i in range(H):
        for a, b in zip(A, B):
            m = min(i+a, H)
            DP[m] = min(DP[i]+b, DP[m])
    print(DP[-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(H, N, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42864
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;

int main(void){
    int h, n;
    cin>>h>>n;
    vector<int> v(n);
    rep(i, n) cin>>v[i];
    int sum=accumulate(v.begin(), v.end(), 0);
    if(sum>=h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 640
<?php

fscanf(STDIN, '%d', $N);
$H = explode(" ",trim(fgets(STDIN)));

$max = 0;
$count = 0;

for ($i=0; $i < $N ; $i++) { 
    if ( $max <= $H[$i] ) {
        $count++;
        $max = $H[$i];
    }
}

echo $count;

?>

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll l = a + b, r = c + d;
    if(l == r) cout << "Balanced" << endl;
    else if(l > r) cout << "Left" << endl;
    else cout << "Right" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, D, x;
    cin >> r >> D >> x;
    rep(i, 10) {
        x = r * x - D;
        cout << x << endl;
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int k = sc.nextInt();
      boolean isOdd = (k % 2 == 1);
      if(isOdd) {
        long cnt = 0;
        for(int i = 1; i <= N; i++)
          if(i % k == 0) cnt++;
        System.out.println(cnt * cnt * cnt);
        return;
      } else {
        long cntZore = 0;
        long cntK = 0;
        for(int i = 1; i <= N; i++) {
          if(i % k == 0) cntZore++;
          else if(i % k == k / 2) cntK++;
        }
        System.out.println(cntZore * cntZore * cntZore + cntK * cntK * cntK);
        return;
      }
  }
}

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

using namespace std;

int main(){
  int N;
  double tmp, sum = 0;
  string tmp2;
  cin >> N;
  for (int i=0; i<N; i++){
    cin >> tmp;
    cin >> tmp2;
    if (tmp2 == "BTC") sum += 380000*tmp;
    else sum += tmp;
  }
  
  cout << sum << endl;
  
  return 0;
}

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

int main() {
  int N, dan = 1;
  cin >> N;

  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }

  sort(d.begin(), d.end(), greater<>());

  for (int i = 1; i < N; i++) {
    if (d.at(i) < d.at(i - 1)) {
      dan++;
    }
  }
  cout << dan << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll X;
    cin>>X;
    ll ans=0;
    for(int i=1;i<=X;i++)
    {
        for(int j=2;j<=10;j++)
        {
            ll y=pow(i,j);
            if(y<=X)
                ans=max(ans,y);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
	int n;
	while(cin >> n){
		while(n > 39){
			n -= 39;
		}
		if(n >= 10){
			printf("3C%d\n", n);
		}else{
			printf("3C0%d\n", n);
		}

	}
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;
struct ho{
  ll f,t,c;
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n+1);
  for(auto &a:A)cin>>a;
  if(n == 0){
    if(A[0] == 1)cout<<1<<endl;
    else cout<<-1<<endl;
    return 0;
  }
  if(A[0] == 1){cout<<-1<<endl;return 0;}
  vector<ho>num(n+1);
  ll now = 0;
  ll sum = 0;
  for(int i=n;i>=0;i--){
    if(i == n){
      num[i] = {0,0,A[i]};
      now = A[i]/2+A[i]%2;
      sum += A[i];
    }else{
      num[i] = {now,sum,A[i]};
      sum += A[i];
      now = (now+A[i])/2 + (now+A[i])%2;
    }
  }
  now = 1;
  ll ans = 1;
  /*
  for(auto a:num){
    cout<<a.f<<" "<<a.t<<" "<<a.c<<endl;
    }*/
  for(int i=1;i<n;i++){
    if(now*2 < num[i].f){
      cout<<-1<<endl;
      return 0;
    }
    now = now*2;
    now -= num[i].c;
    now = min(now,max(num[i].t,num[i+1].f));
    ans += now;
    ans += num[i].c;
    if(now <= 0){
      cout<<-1<<endl;
      return 0;
    }
    //cout<<now<<" "<<ans<<endl;
  }
  cout<<ans+A[n]<<endl;
  return 0;
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;

}
int lvl[N];
int used[N];
vector<int> g[N];
int par[N];
void dfs(int v, int p){
	queue<int> q;
	q.push(v);
	used[v] = 1;
	while(!q.empty()){
		int x = q.front();
		q.pop();
		for(int to : g[x]){
			if(!used[to]){
				used[to] = 1;
				lvl[to] = lvl[x] + 1;
				par[to] = x;
				q.push(to);
			}
		}
	}
}
void solve()
{
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double x = m * 6;
	double y = h * 30;
	y += m / 60 * 30;
	y -= x;
	double c = sqrt(a * a + b * b - 2 * a * b * cos(y * PI / 180));
	cout << fixed << setprecision(9) << c;
}


 // a b c a b c a b c a b c
 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // Red;
  	// precalc();
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 27704
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var [n,x,t] = nexts(3);
  return Math.ceil(n/x)*t;
}

Measured memory_bytes: 29688
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
before = sum(A)
for i in range(N):
    if B[i] <= A[i]:
        A[i] -= B[i]
    else:
        r =  B[i] - A[i]
        A[i] = 0
        A[i+1] -= r
        if A[i+1] < 0:
            A[i+1] = 0
print(before - sum(A))






Measured memory_bytes: 24144
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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

long long int dp[51][51] = {};

int main(void) {
	int N, M, X, Y;
	bool flag = false;

	cin >> N >> M >> X >> Y;

	vector<int> x(N), y(M);

	FOR(i,0,N-1) {
		cin >> x[i];
	}
	
	FOR(i, 0, M-1) {
		cin >> y[i];
	}

	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	FOR(i, X+1, Y) {
		if (x[N - 1] < i&&y[0] >= i) {
			flag = true;
		}
	}

	if (flag) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#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(25) << 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 mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
lli nCr(lli n, lli r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
}
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  Vec(P,lli,N,0);
  COMinit();
  rep(i,0,N)cin >> P[i];
  Sort(P);
  A=0;B=0;
  rep(i,K-1,N){
    A+=P[i]*nCr(i,K-1);
    A+=mod;
    A%=mod;
  }
  Rev(P);
  rep(i,K-1,N){
    B+=P[i]*nCr(i,K-1);
    B+=mod;
    B%=mod;
  }
  Out((A-B+mod)%mod);
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
using ll = long long;

char s[19][1009];

int main(){
  int h,w,l;
  cin>>h>>w>>l;
  rep(i,h){
    rep(j,w){
      cin>>s[i][j];
    }
  }
  int ans=INF;
  rep(i,1<<(h-1)){
    vector<int>bit;
    int n=__builtin_popcount(i);
    rep(j,h-1){
      if((i>>j)&1){
        bit.push_back(j);
      }
    }
    bit.push_back(h-1);
    vector<int>sum(n+1,0);
    int cnt=n;
    rep(j,w){
      int idx=0;
      rep(k,bit.size()){
        while(idx<=bit[k]){
          if(s[idx][j]=='1')sum[k]++;
          idx++;
        }
      }
      bool f=false;
      rep(k,n+1){
        if(sum[k]>l)f=true;
      }
      if(f){
        cnt++;
        rep(k,n+1)sum[k]=0;
        int idx=0;
        rep(k,bit.size()){
          while(idx<=bit[k]){
            if(s[idx][j]=='1')sum[k]++;
            idx++;
          }
        }
        f=false;
        rep(k,n+1){
          if(sum[k]>l)f=true;
        }
        if(f)cnt+=100000;
      }
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;



int main() {
    ll N;
    cin>>N;
    cout<<N*(N-1)/2<<endl;
}


Measured memory_bytes: 256
using System;


class AOJ
{
    public static void Main()
    {

        int[] l = new int[10];
        int v1, v2;
        string str;
        double time, pos;

        while ((str = Console.ReadLine()) != null)
        {

            int suml = 0, com = 0;

            string[] s = str.Split(',');

            for (int i = 0; i < 10; i++)
            {
                l[i] = int.Parse(s[i]);
                suml += l[i];
            }

            v1 = int.Parse(s[10]);
            v2 = int.Parse(s[11]);

            time = (double)suml / (v1 + v2);

            pos = v1 * time;

            for (int i = 0; i < 10; i++)
            {
                com += l[i];
                if (com >= pos)
                {
                    Console.WriteLine(i + 1);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 5604
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean b = true;
        for (int i=0;i<3;i++)if (s.charAt(i)==s.charAt(i+1))b=false;
        if (b)System.out.println("Good");
        else System.out.println("Bad");
    }
}


Measured memory_bytes: 35748
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, p;
	while(cin >> n >> p, n, p){
		int a[n];
		int owan = p;
		int cur = 0;
		for(int i = 0; i < n; i++) a[i] = 0;
		owan -= 1;
		a[0] += 1;
		cur++;
		while(owan != p){
			if(owan){
				owan -= 1;
				a[cur]++;
				if(cur == n - 1) cur = 0;
				else cur++;
			}else{
				owan = a[cur];
				a[cur] = 0;
				if(cur == n - 1) cur = 0;
				else cur++;
			}
		}
		if(!cur) cout << n - 1 << endl;
		else cout << cur - 1 << endl;
	}
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;

    vector<int> v(N), gcd_fr(N), gcd_ba(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i];
    }

    gcd_fr[0] = v[0];
    for(int i = 1; i < N; ++i) {
        gcd_fr[i] = __gcd(gcd_fr[i - 1], v[i]);
    }

    gcd_ba[N - 1] = v[N - 1];
    for(int i = N - 2; i >= 0; --i) {
        gcd_ba[i] = __gcd(gcd_ba[i + 1], v[i]);
    }

    int mx = max(gcd_ba[1], gcd_fr[N - 2]);
    for(int i = 1; i < N - 1; ++i) {
        mx = max(mx, __gcd(gcd_fr[i - 1], gcd_ba[i + 1]));
    }
    cout << mx << endl;

    return 0;
}



Measured memory_bytes: 4468
import sys

for line in sys.stdin:
    [a, op, b] = line.split()
    a = int(a)
    b = int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a / b)
    else:
        break

Measured memory_bytes: 6336
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
    long long N,K;
    cin>>N>>K;
    long long z=N%K;
    long long ans=min(z,K-z);
    cout<<ans<<endl;   
    return 0;
}


Measured memory_bytes: 3200
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

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

int main()
{
	ios_init();
	int h,w;
	while(cin >> h >> w) {
		vector<string> a(h);
		REP(i,h) cin >> a[i];
		int x = 0, y = 0;
		auto check = [&](int x, int y){
			return 0 <= x and x < h and 0 <= y and y < w;
		};
		bool f = true;
		while(f){
			DEBUG(x); DEBUG(y);
			a[x][y] = '.';
			f = false;
			REP(k,2){
				if(check(x+dx[k],y+dy[k]) and a[x+dx[k]][y+dy[k]] == '#'){
					f = true;
					x += dx[k];
					y += dy[k];
					break;
				}
			}
		}
		REP(i,h) DEBUG(a[i]);
		string ans = "Possible";
		if(!(x == h-1 and y == w-1)){
			ans = "Impossible";
		}
		REP(i,h) REP(j,w) if(a[i][j] != '.') ans = "Impossible";
		cout << ans << endl;
	}
	return 0;
}


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

long long k;

string solve();
string dfs(string s, int dig, int now);

int main() {
  cin >> k;
  cout << solve() << endl;
  return 0;
}

string solve() {
  for(int i = 1; i <= 10; ++i) {
    string res = dfs("", i, 0);
    if(res != "") return res;
  }
  return "";
}

string dfs(string s, int dig, int now) {
  if(now == dig) {
    if(--k == 0) return s;
    return "";
  }
  for(int i = 0; i < 10; ++i) {
    if(now != 0 || i != 0) {
      string t = s;
      if(now != 0 && abs(t[now - 1] - '0' - i) > 1)
        continue;
      t += '0' + i;
      t = dfs(t, dig, now + 1);
      if(t != "") return t;
    }
  }
  return "";
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a;
set<int> st;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        st.insert(a);
    }
    if (st.size() == n) cout << "YES" << E;
    else cout << "NO" << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 9600
use std::io::*;
use std::str::FromStr;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
#[allow(non_snake_case, unused_variables)]
fn main() {
    let N: u32 = read();
    let K: u32 = read();
    let ans: u32 = 
        if N%K==0 {
            0
        } else {
            1
        };
    println!("{}", ans);
}



Measured memory_bytes: 4352
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

s = int(input())

if s < 3:
    print(0)
else:
    result = 1
    loop = s//3
    for i in range(2, loop+1):
        result += combinations_count(s-3*i+(i-1), (i-1))
    print(result%1000000007)

Measured memory_bytes: 9168
a, b, c, d = map(int, input().split())

div_c = b // c - (a - 1) // c
div_d = b // d - (a - 1) // d


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


lcm_cd = lcm(c, d)

div_cd = b // lcm_cd - (a - 1) // lcm_cd

print(b - a + 1 - div_c - div_d + div_cd)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+9;
int t,j,cs=0,n,a,b,i;
string s;

int main()
{
    cin>>n;
    int ar[n];
    for(i=0;i<n;i++){
        cin>>ar[i];
    }

    sort(ar,ar+n);

    long long ans=ar[n-1];
    a=n-2;i=0;
    for(j=a;j>0;j--){
        ans+=2*ar[j];
       i+=2;
       if(i>=a) break;
  //     cout<<ans<<endl;
    }
    if(n&1) ans-=ar[j];

    cout<<ans<<endl;
}



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

int main() {
	int N;
  	cin >> N;
  
  for (int i = 0; i < N; i++) {
    
    int A,B;
  	cin >> A >> B;
    int C = B - A + 1;
    int D;
    D += C;
    if ( i == N - 1){
      cout << D << endl;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl

using namespace std;

int main(void) {

	int N;
	int X = 0;
	bool flag = true;
	INPUT(N);
	
	vector<int> H(N,0);
	for(int i = 0 ; i < N ; i++)
		INPUT(H[i]);

	for(int i = 0 ; i < N ; i++){
		flag = true;
		for(int j = 0 ; j < i ; j++){
			if(H[j] > H[i]) flag = false;
		}
		if(flag) X++;
	}
	
	OUTPUT(X);

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
           // dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1]);

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

typedef long long ll;

using namespace std;

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

int main(){
    int n;
    cin >> n;
    int s[n+1];
    rep(i,0,n) cin >> s[i];
    int q;
    cin >> q;
    int key;
    int sum = 0;


    rep(i,0,q){
        int right = n;
        int left = 0;
        cin >> key;
        bool flag = false;
        while(right > left){
            int mid = (right + left) / 2;
            if(s[mid] == key){
                flag = true; 
                break;
            }else if(s[mid] < key){
                left = mid + 1;
            }else{
                right = mid;
            }
        }
        if(flag)sum++;
    }

    cout << sum << endl;


}


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

using namespace std;

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

    vector<vector<int> > s(m);
    for (int i = 0; i < m; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int a;
            cin >> a;
            a--;
            s[i].emplace_back(a);
        }
    }

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

    auto ans = 0L;
    for (unsigned int bit = 0; bit < (1U << n); ++bit) {
        bool isOK = true;
        //電球iがついているかどうか
        for (int i = 0; i < m; ++i) {
            int cnt = 0;
            for (unsigned int v : s[i]) {
                if (bit & (1U << v)) ++cnt;
            }
            if (cnt % 2 != p[i]) isOK = false;
        }
        if (isOK) ++ans;
    }

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

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

using namespace std;

int main(void) {
	int N, M;
	cin >> N >> M;
	char A[50][50], B[50][50];
	bool exist = false;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < M; ++i) {
		for (int j = 0; j < M; ++j) {
			cin >> B[i][j];
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i + M - 1 >= N || j + M - 1 >= N) {

			}else {
				bool match = true;
				for (int y = 0; y < M; y++) {
					for (int x = 0; x < M; x++) {
						if (A[i + y][j + x] != B[y][x]) match = false;
					}
				}
				if (match == true) {
					exist = true;
				}
			}
		}
	}

	if (exist==true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
int main()
{
	int x,y,z,i;
	while(~scanf("%ld %ld %ld",&x,&y,&z))
	{
		i=(x-z)/(z+y);
		printf("%ld\n",i);
	}
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    int n,k;
    int i=0;
    cin >> n >> k;
    while(n>=pow(k,i)){
        i++;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/**
 * Created 2017/06/01.
 */
public class Main {
  public static void main(String[] args) {
    //??\?????¨?????????
    Scanner sc = new Scanner(System.in);
    ArrayList<ArrayList<Integer>> ary_ans = new ArrayList<>();
    while (true) {
      ArrayList<Integer> ary = new ArrayList<>();
      int input1 = Integer.parseInt(sc.next());
      int input2 = Integer.parseInt(sc.next());
      if (input1 == 0 && input2 == 0) break;
      ary.add(input1);
      ary.add(input2);
      ary_ans.add(ary);
    }
    for (ArrayList<Integer> index : ary_ans) {
      for (int i = 0; i < index.get(0);i++){
        System.out.print("#");
        for (int j = 1; j < index.get(1);j++){
          System.out.print("#");
        }
        System.out.println("");
      }
      System.out.println("");
    }
  }
}

Measured memory_bytes: 34504
#include <stdio.h>

int main(){

  int H,W,i,j;

  while(scanf("%d %d",&H,&W),H!=0&&W!=0){

  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if((i%2==1 || j%2==0)&&(i%2==0 || j%2==1)){
          printf("#");
      }else{
          printf(".");
      }
    }
      printf("\n");
    }
      printf("\n");
    }
  return 0;
}


Measured memory_bytes: 572
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
//const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int k;cin>>k;
  vector<int> a(k);
  rep(i,k)cin>>a[i];
  bool flag=true;int inf=2;int sup=2;
  for(int i=k-1;i>=0;i--){
    if(a[i]<=sup){
      int m=(sup)/a[i];
      int n=(inf-1)/a[i]+1;
      if(m*a[i]<inf||n*a[i]>sup)flag=false;
      inf=a[i]*n;
      sup=a[i]*(m+1)-1;
    }
    else{
      flag=false;
      break;
    }
  }
  if(flag){
    cout<<inf<<" "<<sup<<endl;
  }
  else{
    cout<<-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

using namespace std;

int main(void) {
    int N, X, m[100];
    int i;
    int min = 9999;

    scanf("%d %d", &N, &X);
    for (i = 0; i < N; i++) {
        scanf("%d", &m[i]);
        X -= m[i];
        if (min > m[i]) min = m[i];
    }
    printf("%d\n", N + X / min);

    return 0;
}

Measured memory_bytes: 128
if __name__ == "__main__":
    K = int(input())
    num_ls = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    ret = num_ls[K-1]
    print(ret)


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

int main() {
	int n,b=1;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
	    b=a[b-1];
	    if(b==2){
	        cout<<i+1<<endl;
	        break;
	    }
	}
	if(b!=2)cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    int ret = max(a,b);
    while (true) {
        if (a % ret == 0 && b % ret == 0)count++;
        if (count == c) {
            cout << ret << endl;
            break;
        }
        ret--;
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
S=[0]*14
H=[0]*14
C=[0]*14
D=[0]*14
for i in range(n):
    a=input().split()
    b=int(a[1])
    if a[0]=="S":
        S[b]=1
    if a[0]=="H":
        H[b]=1
    if a[0]=="C":
        C[b]=1
    if a[0]=="D":
        D[b]=1
for i in range(1,14):
    if S[i]==0:
        print("S "+str(i))
for i in range(1,14):
    if H[i]==0:
        print("H "+str(i))
for i in range(1,14):
    if C[i]==0:
        print("C "+str(i))
for i in range(1,14):
    if D[i]==0:
        print("D "+str(i))


Measured memory_bytes: 5608