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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n), ma(n, 0);
    rep(i, n)cin >> h[i];
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        ma[a] = max(ma[a], h[b]);
        ma[b] = max(ma[b], h[a]);
    }
    int ans = 0;
    rep(i, n){
        if(h[i] > ma[i])ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4052
#include<stdio.h>
int main(){
  int x[5];
  for(int i=0;i<5;i++){
    scanf("%d",&x[i]);
  }
  for(int w=0;w<5;w++){
    if(x[w]==0){
      printf("%d",w+1);
    }
  }
  return 0;
}

Measured memory_bytes: 1712
import math


def main():
    K = int(input())
    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                t = math.gcd(i, j)
                ans += math.gcd(t, k)
    print(ans)


main()


Measured memory_bytes: 69976
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ii>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a);  a = (a * a);  b/=2;  }  return res; }
#define rs resize
long long readLI(){  register char c;  for(c = getchar(); !(c>='0' && c<='9'); c = getchar());  register long long a=c-'0';
    for(c = getchar(); c>='0' && c<='9'; c = getchar())
        a = (a<<3)+(a<<1)+c-'0';
    return a;
}
const ll N = 1009;
ll a,b;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b;
    cout<<2*b - a;
    return 0;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
c = [list(input()) for i in range(H)]

ans = 0

for i in range(2**(H+W)):
    h = set()
    for j in range(H):
        if (i >> j) % 2 == 1:
            h.add(j)
    w = set()
    for j in range(W):
        if (i >> (j + H)) % 2 == 1:
            w.add(j)
    tmp = 0
    for j in range(H):
        if j in h:
            continue
        for k in range(W):
            if k in w:
                continue
            if c[j][k] == '#':
                tmp += 1

    if tmp == K:
        ans += 1

print(ans)


Measured memory_bytes: 9208
using System;
using System.Collections.Generic;
using System.Linq;

namespace WelcomeAtcordet
{
    class Program
    {
        static void Main(string[] args)
        {
            List<char> A = new List<char>((Console.ReadLine()).ToCharArray());
            List<char> B = new List<char>((Console.ReadLine()).ToCharArray());
            List<char> C = new List<char>((Console.ReadLine()).ToCharArray());

            char next = A[0];
            A.RemoveAt(0);

            string ans = null;
            bool end = false;

            do
            {
                if (next.Equals('a'))
                {
                    if (A.Count != 0)
                    {
                        next = A[0];
                        A.RemoveAt(0);
                    }
                    else
                    {
                        ans = "A";
                        end = true;
                    }
                }
                else if (next.Equals('b'))
                {
                    if (B.Count != 0)
                    {
                        next = B[0];
                        B.RemoveAt(0);
                    }
                    else
                    {
                        ans = "B";
                        end = true;
                    }
                }
                else
                {
                    if (C.Count != 0)
                    {
                        next = C[0];
                        C.RemoveAt(0);
                    }
                    else
                    {
                        ans = "C";
                        end = true;
                    }
                }
            } while (!end);

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define reg(i,a,b) for(int i=a;i<=b;i++)
#define reh(i,a,b) for(int i=a;i>b;i--)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
#define lson(q) q<<1
#define rson(q) q<<1|1
using namespace std;
typedef long long ll;
const int mx=1e5+10;
int a[mx];
int t;
ll n,m;
int res;

int main(){
//	scanf("%lld",&n);
cin>>n;
--n;
	cout << n * (n +1)  / 2;

	return 0;
}




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

int N;
long long int x;
long long int a[2000];
long long int b[2000][2000];//呪文をk回唱えた時に色iのスライムを飼うのにかかる時間がb[k][i]

long long int min(long long int a, long long int b){
    if(a < b){
        return a;
    }else{
        return b;
    }
}

long long int sum(int k){
    if(k==0){
        long long int ans = 0;
        for(int i=0;i<N;i++){
            b[0][i]=a[i];
            ans += a[i];
        }
        return ans;
    }else{
        long long int ans = 0;
        for(int i=0;i<N;i++){
            b[k][i] = min(b[k-1][i], a[(i-k+N)%N]);
            ans += b[k][i];
        }
        return ans;
    }
}

int main()
{
    scanf("%d %lld", &N, &x);
    for(int i=0;i<N;i++) {
        scanf("%lld", &a[i]);
    }

    long long int ans = sum(0);
    long long int tmp;
    for(int k=1;k<=N-1;k++){
        tmp = k * x + sum(k);
        if(tmp < ans) ans = tmp;
    }

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

    return 0;
}

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

using namespace std;

const int N = 1000010;
const int M = 1000000;
const int P = 1e9 + 7;

int n, m, k;
int fac[N], inv[N], power[N];

int Power(int x, int k) {
	if (k == 1) return x;
	int ret = Power(x, k >> 1);
	ret = 1LL * ret * ret % P;
	if (k & 1) ret = 1LL * ret * x % P;
	return ret;
}

void Init() {
	fac[0] = 1;
	for (int i = 1; i <= M; i++) {
		fac[i] = 1LL * fac[i - 1] * i % P;
	}
	inv[M] = Power(fac[M], P - 2);
	for (int i = M - 1; i >= 0; i--) {
		inv[i] = 1LL * inv[i + 1] * (i + 1) % P;
	}
	power[0] = 1;
	for (int i = 1; i <= M; i++) {
		power[i] = 1LL * power[i - 1] * 3 % P;
	}
}

int C(int n, int m) {
	if (n < m) return 0;
	return 1LL * fac[n] * inv[m] % P * inv[n - m] % P; 
}

int main() {
	Init();
	scanf("%d %d %d", &n, &m, &k);
	int ansL = 1, ans = 0;
	for (int L = n; L <= n + m + k; L++) {
		ans += 1LL * ansL * C(L - 1, n - 1) % P * power[n + m + k - L] % P;
		if (ans >= P) ans -= P;
		ansL <<= 1;
		if (ansL >= P) ansL -= P;
		ansL -= (C(L - n, m) + C(L - n, k)) % P;
		if (ansL < 0) ansL += P;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11904
#include <stdio.h>
#include <ctype.h>
int main(){
    char s[1001] ;
	int box[1000]={0};
	int cnt,i,p;
	i=0;
	while(1){
		p=0;
		gets(s);
		while(s[p]!='\0'){  			
			box[i] += s[p]-('1'-1);
			p++;
		}

		if(box[i]==0){cnt=i;break;}
		i++;
	}
	for(i=0;i<cnt;i++){
		printf("%d\n",box[i]);
	}
	return 0;
}

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

typedef long long ll;
const int mod = 1e+9 + 7;

ll r1, r2, c1, c2;

ll qPow(ll a, ll b)
{
	a %= mod;
	
	ll res = 1;
	while(b) {
		if(b & 1) res = res * a % mod;
		a = a * a % mod, b >>= 1;
	}
	return res;
}

ll C(ll n, ll m)
{
	if(n < m) return 0;
	
	ll res = 1;
	for(int i = 1; i <= m; ++i)
		res = res * (n - i + 1) % mod * qPow(i, mod - 2) % mod;
	return res;
}

int main()
{
	scanf("%lld%lld%lld%lld", &r1, &c1, &r2, &c2);
	
	++r2, ++c2;
	printf("%lld", ((C(r2 + c2, c2) - C(r1 + c2, c2) - C(r2 + c1, c1) + C(r1 + c1, c1)) % mod + mod) % mod);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
     
#define endl '\n'
     
using namespace std;
     
int N,K;
     
int h[100001];
     
long long dp[100001];
     
long long ans(int i){
     
  if(dp[i]!=-1){
    return dp[i];
  }
  if (i==N-1){
    return dp[i]=0;
  }else {

    long long minn=ans(i+1)+abs(h[i+1]-h[i]);
          
    if(K<=N-i-1){
      
      for(int j=2;j<=K;j++){
    
	minn=min(ans(i+j)+abs(h[i+j]-h[i]),minn);
	
      }
      
    }else{

      for(int j=2;j<=N-i-1;j++){
	minn=min(ans(i+j)+abs(h[i+j]-h[i]),minn);
      }
    }

    return dp[i]=minn;

  }
    
}
     
int main(){
     
  cin.tie(0); // cout と cin の同期を切る
  ios::sync_with_stdio(false); /* cの stdioストリーム (printfとか)と*/
     
  cin>>N>>K;
     
  memset(dp,-1,sizeof(dp));
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
     
  cout<<ans(0)<<endl;
     
  return 0;
     
}


Measured memory_bytes: 6144
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

//また何回か同じの投げてみるか

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char cn[300100], * ci = cn, ct;
int N, A, B, C;

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

	fread(cn, 1, 300100, stdin);
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	while ((ct = *ci++) >= '0') B = B * 10 + ct - '0';
	while ((ct = *ci++) >= '0') C = C * 10 + ct - '0';

	int kei = A + B + C;
	

	int OK = 1;
	char *di = cn;

	char* S = ci;

	for (int i = 0; i < 3 * N; i += 3) {
		if (S[i] == 'B') {
			if (C == 0 && B == 0) OK = 0;
			if (C == 1 && B == 1) {
				if (i == 3 * N - 3 || S[i + 4] == 'C') {
					*di++ = 'C';
					*di++ = '\n';
					C++;
					B--;
				}
				else {
					*di++ = 'B';
					*di++ = '\n';
					B++;
					C--;
				}
			}
			else if (C <= B) {
				*di++ = 'C';
				*di++ = '\n';
				C++;
				B--;
			}
			else {
				*di++ = 'B';
				*di++ = '\n';
				B++;
				C--;
			}
		}
		else if (S[i + 1] == 'B') {
			if (A == 0 && B == 0) OK = 0;
			if (A == 1 && B == 1) {
				if (i == 3 * N - 3 || S[i + 3] == 'A') {
					*di++ = 'A';
					*di++ = '\n';
					A++;
					B--;
				}
				else {
					*di++ = 'B';
					*di++ = '\n';
					B++;
					A--;
				}
			}
			else if (A <= B) {
				*di++ = 'A';
				*di++ = '\n';
				A++;
				B--;
			}
			else {
				*di++ = 'B';
				*di++ = '\n';
				B++;
				A--;
			}
		}
		else {
			if (A == 0 && C == 0) OK = 0;
			if (A == 1 && C == 1) {
				if (i == 3 * N - 3 || S[i + 4] == 'C') {
					*di++ = 'C';
					*di++ = '\n';
					C++;
					A--;
				}
				else {
					*di++ = 'A';
					*di++ = '\n';
					A++;
					C--;
				}
			}
			else if (A <= C) {
				*di++ = 'A';
				*di++ = '\n';
				A++;
				C--;
			}
			else {
				*di++ = 'C';
				*di++ = '\n';
				C++;
				A--;
			}
		}
	}
	if (OK) {
		printf("Yes\n");
		fwrite(cn, 1, di - cn, stdout);
	}
	else printf("No\n");

	Would you please return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
int n,l,r;
string str;
int main(){
	cin>>n;
	cin>>str;
	for (int i=0;i<n;i++){
		if (str[i]=='('){
			l++;
		}else{
			if (l>0){
				l--;
			}else{
				r++;
			}
		}
	}
	for (int i=0;i<r;i++) cout<<'(';
	cout<<str;
	for (int i=0;i<l;i++) cout<<')';
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,C;
vector<P> st[35];
ll emos[100010]={};
int main(){
    cin>>N>>C;
    for(ll i=0;i<N;i++){
        ll s,t,c;
        cin>>s>>t>>c;
        st[c].push_back(P(s,t));
    }
    for(ll i=1;i<=C;i++){
        sort(st[i].begin(),st[i].end());
        ll pre=-1;
        for(auto s:st[i]){
            if(pre==s.first){
                s.first++;
            }
            emos[s.first]++;
            emos[s.second+1]--;
            pre=s.second;
        }
    }
    ll ans=0;
    for(ll i=1;i<100010;i++){
        emos[i]+=emos[i-1];
        ans=max(ans,emos[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define N               200005
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define inp(arr,n)      for(ll x=0;x<n;x++) cin>>arr[x];
#define w(x)            ll x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fio(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int p[1000001];
vi primes;

void sieve(){
    p[0] = p[1] = 0;

    for(ll g=2;g<=1000000;g++){
        if(p[g]){
            primes.push_back(g);
            for(ll h=g*g;h<=1000000;h+=g){
                p[h] = 0;
            }
        }
    }

}

mii factorize(ll n){

    mii pf;

    ll j = 0;
    ll m = primes[j];

    while(m*m <= n){
        if(n%m == 0){
            while(n%m == 0){
                n /= m;
                pf[m] += 1;
            }
        }
        j++;
        m = primes[j];
    }
    if(n != 1)  pf[n] += 1;

    return pf;

}

int main(){
    fio();

    memset(p,1,sizeof(p)/sizeof(int));
    sieve();

    ll n;
    cin>>n;

    ll res = 0;
    for(ll y=1;y<n;y++){
        ll j = n - y;
        mii fac = factorize(j);
        ll d = 1;
        for(auto &k: fac) d *= (k.ss + 1);
        res += d;
    }

    cout<<res;

    return 0;
}

Measured memory_bytes: 7692
#include <iostream>
#include <queue>
#include <utility>
#define inf 1000000000

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

struct edge{
	int to, cost;
	edge(int a, int b){
		to = a, cost = b;
	}
};

int N, M, H, K;
int a[505], b[505], c[505], h[505], r[505];
int S, T, C;
int ticket[256];
int state[256];

int V;
vector<edge> G[2505];
int dist[2505];

void dijkstra()
{
	for(int i = 0; i < V; i++) dist[i] = inf;
	dist[S] = 0;
	
	priority_queue< P, vector<P>, greater<P> > Q;
	Q.push( make_pair(0, S) );
	
	int d, v;
	while(Q.size()){
		d = Q.top().first; v = Q.top().second;
		Q.pop();
		if(d > dist[v]) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > dist[v] + G[v][i].cost){
				dist[G[v][i].to] = dist[v] + G[v][i].cost;
				Q.push( make_pair(dist[G[v][i].to], G[v][i].to) );
			}
		}
	}
}

int main(void)
{
	while(1){
		cin >> N >> M >> H >> K;
		if(N == 0 && M == 0 && H == 0 && K == 0) break;
		
		for(int i = 0; i < M; i++){
			cin >> a[i] >> b[i] >> c[i] >> h[i] >> r[i];
			a[i]--, b[i]--;
		}
		cin >> S >> T >> C; S--, T--;
		int l, d, k, bit;
		for(int i = 0; i < (1<<K); i++) ticket[i] = inf;
		for(int i = 0; i < C; i++){
			cin >> l >> d;
			bit = 0;
			for(int j = 0; j < l; j++){
				cin >> k;
				bit |= (1 << (k-1));
			}
			ticket[bit] = d;
		}
		
		for(int s = 0; s < (1 << K); s++) state[s] = inf;
		state[0] = 0;
		for(int s = 0; s < (1 << K); s++){
			for(int i = 0; i < (1 << K); i++){
				state[s | i] = min(state[s | i], state[s] + ticket[i]);
			}
		}
		
		int ans = inf;
		for(int s = 0; s < (1<<K); s++){
			if(state[s] == inf) continue;
			
			V = (H+1) * 100;
			for(int i = 0; i < V; i++) G[i].clear();
			
			int cost;
			for(int i = 0; i < M; i++){
				if(s & (1 << (r[i]-1))) cost = 0;
				else cost = c[i];
				for(int j = 0; j <= H; j++){
					if(j + h[i] > H) break;
					G[a[i]+j*100].push_back( edge(b[i]+(j+h[i])*100, cost) );
					G[b[i]+j*100].push_back( edge(a[i]+(j+h[i])*100, cost) );
				}
			}
			dijkstra();
			
			int res = inf;
			for(int i = 0; i <= H; i++){
				res = min(res, dist[T + i*100]);
			}
			ans = min(ans, res + state[s]);
		}
		if(ans >= inf) ans = -1;
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3556
package main

import "fmt"

func main() {

  var a,b int
  fmt.Scan(&a,&b)
  bigger := max(a,b)
  smaller := min(a,b)
  
  if bigger >= smaller+1 {
    fmt.Print(bigger * 2 -1 )
  }else {
    fmt.Print(bigger+smaller)
  }
  
}

func max(a,b int)  int {

  if a > b {
    return a
  } else {
    return b
  }
}

func min(a,b int)  int {

  if a < b {
    return a
  } else {
    return b
  }
}


Measured memory_bytes: 512
def solve():
    N = int(raw_input())
    W = [int(_) for _ in raw_input().split()]
    bef = W[0]
    aft = sum(W[1:])
    ret = abs(bef - aft)
    for T in range(1,N-1):
        bef += W[T]
        aft -= W[T]
        ret = min(ret, abs(bef - aft))
    print ret

if __name__ == '__main__':
    solve()


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

int main(){
    string s, t("CODEFESTIVAL2016");
    cin >> s;
    long ans(0);
    for(int i = 0; i < 16; ++i)ans += !!(s[i] ^ t[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

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

func main() {
	n, err := strconv.Atoi(input())
	if err != nil {
		log.Fatal(err)
	}

	a := make([]int, n)
	for i, _ := range a {
		a[i], err = strconv.Atoi(input())
		if err != nil {
			log.Fatal(err)
		}
	}

	count := 0
	for ; ; count++ {
		for i, v := range a {
			if v % 2 == 1 {
				fmt.Println(count)
				return
			}
			a[i] = v / 2
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 640
import java.util.*;

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

		if (b >= a) {
			System.out.println(a);
		} else {
			System.out.println(a - 1);
		}
  }
}


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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second

using namespace std;

int H, stage[15][10];

int main() {
  while(1){
    cin>>H;
    if(H==0) break;
    REP(i,0,H){
      REP(j,0,5){
        cin>>stage[i][j];
      }
    }

    long long ans = 0;
    while(1){
      //fall
      REP(j,0,5){
        int botom = -1;
        for(int i=H-1; 0<=i; i--){
          if(stage[i][j]==-1){
            botom = i;
            break;
          }
        }
        int pos=botom-1;
        while(0<=pos && 0<botom){
          if(stage[pos][j]!=-1){
            swap(stage[pos][j],stage[botom][j]);
            botom--;
          }
          pos--;
        }
      }

      //delete
      bool flag = true;
      REP(i,0,H){
        int cnt = 1;
        REP(j,1,5){
          if(stage[i][j-1] == stage[i][j]){
            cnt++;
          }else{
            if(cnt>=3 && stage[i][j-1]!=-1){
              REP(k,j-cnt,j){
                ans += stage[i][k];
                stage[i][k] = -1;
                flag = false;
              }
            }
            cnt = 1;
          }
        }
        if(cnt>=3 && stage[i][5-1]!=-1){
          REP(k,5-cnt,5){
            ans += stage[i][k];
            stage[i][k] = -1;
            flag = false;
          }
        }
      }
      if(flag) break;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3068
a, b, c = gets.split.map(&:to_i)

puts (a * b * Math.sin(c * Math::PI / 180) / 2.0).round(5)
puts a + b + ((a ** 2.0 + b ** 2.0 - 2.0 * a * b * Math.cos(c * Math::PI / 180))** 0.5)
puts ( b * Math.sin(c * Math::PI / 180)).round(5)

Measured memory_bytes: 9004
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
   int  s,w;
   cin>>s>>w ;
   if(w>=s) 
  cout << "unsafe" <<endl ; 
   else
   cout<<"safe" <<endl;
    return 0;
}

Measured memory_bytes: 3592
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(tuple(map(int, input().split())))
AB = list(set(AB))


G = [[] for _ in range(N)]
for el in AB:
    A, B = el
    A -= 1
    B -= 1
    G[A].append(B)
    G[B].append(A)
# print(H)
# print(G)

cnt = 0
for i in range(N):
    flag = True
    for next in G[i]:
        if H[i] <= H[next]:
            flag = False
    if flag:
        # print(i)
        cnt += 1
print(cnt)

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

lli f(lli n, lli x)
{
  lli sum = 0;
  sum += 3 * x * ((n - x) / x);
  lli y = ((n - x) % x);
  if (y) sum += f(x + y, y);
  return sum;
}

int main(int argc, char *argv[])
{
  lli n, x;
  while (cin >> n >> x) {
    cout << f(n, x) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)


int main(){
    int N,K,Q;
    cin >> N >> K >> Q;
    map<int ,int> mp;
    rep(i,Q){
        int a;
        cin >> a;
        mp[a-1] +=1;
    }
    rep(i,N){
        if(K-(Q-mp[i])>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 7820
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 1000000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % 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;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int x, y; cin >> x >> y;
		COMinit();
		if ((x + y) % 3) {
			cout << 0 << endl;
			return;
		}
		int n = (x + y) / 3;
		x -= n; y -= n;
		if (x < 0 || y < 0) {
			cout << 0 << endl;
			return;
		}
		long long ans = COM(x + y, x);
		cout << ans << endl;
    return;
}

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



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

using namespace std;

int main() {
    
    int t;
    t=1;
    // cin >> t;
    while(t--){
        int n;
        cin >> n;
        
        int arr[n];
        int dp[n];
        for(int i=0;i<n;i++){
            cin >> arr[i];
            dp[i] = 0;
        }
        dp[1] = abs(arr[1]-arr[0]);
        for(int i=2;i<n;i++){
            dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
        }
        
        cout << dp[n-1] << endl;
    }
    return 0;

}

Measured memory_bytes: 1024
w = int(input())
n = int(input())
nums = [i for i in range(1, w+1)]
ab = []
for i in range(n):
    a, b = map(int, input().split(','))
    nums[a-1], nums[b-1] = nums[b-1], nums[a-1]
for i in nums:
    print(i)


Measured memory_bytes: 5604
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 2e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

signed main() {
	char b;
	cin >> b;
	if (b == 'A') cout << 'T' << endl;
	if (b == 'C') cout << 'G' << endl;
	if (b == 'T') cout << 'A' << endl;
	if (b == 'G') cout << 'C' << endl;
}

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


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

/* vector<int> A(N); 
    vector<pair<int, int> > tasks; ＃ソートした場合、１つ目でソート
　tie(b, a) = p.at(i); #pairを分割
    tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
　xの二乗:  pow(x, 2.0) 
    小さい順: sort(v.begin(), v.end());
    大きい順: reverse(v.begin(), v.end());
    int: -2,147,483,648 ～ 2,147,483,647
    ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807
    // int型の2次元配列(3×4要素の)の宣言
    vector<vector<int>> data(3, vector<int>(4));
*/
 
int main() {
  
  double N, M, count=0, ans=0;
  double C;
  string D, E;
  cin >> N >> M;
  vector<double> A(N);

  rep(i,N){
  	cin >> A[i];
    count+=A[i];
  }
  
  C = count/(4*M);
  
  rep(i,N){
  	if ( A[i] >= C ) ans++;
  }
  
  if ( ans >= M ){
  	cout <<"Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }

}






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

int main() {
    int h,m,s,i,g;
	while(cin >> h >> m >> s) {
     if (h+m+s==-3) break;
	 g=s=7200-(3600*h+60*m+s);
	 for (i=0;i<2;i++) {
     h=s/3600; s-=h*3600; m=s/60; s-=m*60;
	 printf("%.2d:%.2d:%.2d\n",h,m,s);
	 s=g*3;
	 }
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include <cmath>
//#include <bits/stdc++.h>
using namespace std;

int main(){
    long int N,K;
    cin>>N>>K;
    long int d[K];
    long int x[N],y[N];
    for (int i=0;i<N;i++){
        x[i]=1;
    }
    for (int i=0;i<K;i++){
        cin>>d[i];
//        long int A[d[i]];
        for (int j=0;j<d[i];j++){
            long int A;
            cin>>A;
            x[A-1]=0;
        }
    }
    long int ans=0;
    for (int i=0;i<N;i++){
        if (x[i]==1) ans+=1;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int r, c, n;
	scanf("%d %d %d", &r, &c, &n);
	map<int, int> mp;
	for(int i=0; i<n; i++){
		int x1, y1, x2, y2;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		if(!((y1==0 || y1==c || x1==0 || x1==r) && (y2==0 || y2==c || x2==0 || x2==r))) continue;
		int a1,a2;
      if(y1==0){
			a1=x1;
		}else if(y1==c){
			a1=2*r+c-x1;
		}else if(x1==0){
			a1=2*r+2*c-y1;
		}else{
			a1=r+y1;
		}
		if(y2==0){
			a2=x2;
		}else if(y2==c){
			a2=2*r+c-x2;
		}else if(x2==0){
			a2=2*r+2*c-y2;
		}else{
			a2=r+y2;
		}
      if(a1>a2) swap(a1, a2);
      mp[a1]=a2;
	}
	if(mp.empty()){
		printf("%s\n", "YES");
		return 0;
	}
  set<int> st;
	for(auto itr=mp.begin(); itr!=mp.end(); itr++){
      int a1=itr->first, a2=itr->second;
      if(st.empty()){
        st.insert(a2);
        continue;
      }
      auto itr2=st.lower_bound(a2);
      if(itr2==st.begin()){
        st.insert(a2);
        continue;
      }
      itr2--;
      if(*itr2>a1){
        printf("%s\n", "NO");
        return 0;
      }
      st.insert(a2);
    }
	printf("%s\n", "YES");
	return 0;
}


Measured memory_bytes: 9600
def modPow(a, n, mod):
    if n == 1:
        return a
    if n % 2 == 1:
        return (a * (modPow(a, n//2, mod) ** 2)) % mod
    else:
        return (modPow(a, n//2, mod) ** 2) % mod


def modInverse(a, p):
    # calculates the modular multiplicative of a mod m.
    # (assuming p is prime).
    return modPow(a, p-2, p)


def modBinomial(n, k, p):
    # calculates C(n,k) mod p (assuming p is prime).

    numerator = 1  # n * (n-1) * ... * (n-k+1)
    for i in range(k):
        numerator = (numerator * (n-i)) % p

    denominator = 1  # k!
    for i in range(1, k+1):
        denominator = (denominator * i) % p

    # numerator / denominator mod p.
    return (numerator * modInverse(denominator, p)) % p


mod = 10 ** 9 + 7
n, a, b = map(int, input().split())

nn = modPow(2, n, mod)
nn = (nn+mod-1) % mod


ab = (modBinomial(n, a, mod) + modBinomial(n, b, mod)) % mod

ans = (nn-ab+mod) % mod

print(ans)


Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIII pair< int, pair<int,int> >
const int MXN = 1e5;
const int INF = 1e9;
int a[MXN+5];
ll dp[MXN+5];
int N,K;

ll rec(int pos){

    if(pos==N) return 0;
    if(dp[pos]!=-1) return dp[pos];
    ll ret = INF;
    for(int i=1; i<=K; i++){
        int next = pos + i;
        if(next<=N){
            ret = min( ret , (ll) rec(next) + abs(a[next]-a[pos]) );
        }else
            break;
    }

    return dp[pos]=ret;
}

void solve(){

    cin>>N>>K;
    memset(dp,-1,sizeof(dp));
    for(int i=1; i<=N; i++) cin>>a[i];
    cout<< rec(1) << "\n";
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){ cin >> a.at(i); }

    vector<ll> b = a;
    b.insert(b.end(), ALL(a));

    vector<ll> next_index(b.size(), -1);
    map<ll, ll> nmap;
    RREP(i, b.size()){
        const auto bi = b.at(i);
        if(nmap.count(bi)){
            const auto j = nmap[bi];
            if(j + 1 < 2 * n && next_index[j + 1] != -1){
                next_index[i] = next_index[j + 1];
            }else{
                next_index[i] = j + 1;
            }
        }
        nmap[bi] = i;
    }

    next_index.resize(n + 1);
    // cerr << "0 ";
    REP(i, n + 1){
        if(next_index.at(i) == -1){
            next_index.at(i) = i % n;
        }else{
            next_index.at(i) -= n;
        }
        assert(next_index.at(i) >= 0 && next_index.at(i) <= n);
        // cerr << next_index.at(i) << ' ';
    }
    // cerr << endl;

    vector<vector<ll>> next2p(42, vector<ll>(n + 1));
    next2p.at(0) = next_index;
    for(ll i = 1; i < next2p.size(); ++i){
        // cerr << i << ' ';
        REP(j, n + 1){
            const ll j2 = next2p.at(i - 1).at(j);
            next2p.at(i).at(j) = next2p.at(i - 1).at(j2);
            // cerr << next2p.at(i).at(j) << ' ';
        }
        // cerr << endl;
    }

    ll cur_idx = 0;
    k--;
    REP(i, next2p.size()){
        if((k >> i) & 1){
            cur_idx = next2p.at(i).at(cur_idx % n);
        }
    }

    // cerr << "cur_idx=" << cur_idx << endl;

    vector<ll> ans;
    set<ll> used;
    for(; cur_idx < n; ++cur_idx){
        const auto ai = a.at(cur_idx);
        if(used.count(ai)){
            while(used.count(ai)){
                used.erase(ans.back());
                ans.pop_back();
            }
        }else{
            ans.push_back(ai);
            used.insert(ai);
        }
    }

    REP(i, ans.size()){
        cout << ans.at(i);
        if(i + 1 < ans.size()){
            cout << ' ';
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 100080
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<string.h>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;

int rest(ll n)
{
    int res = 0;
    while (n != 0)
    {
        n /= 10;
        res++;
    }
    return res;
}

int main()
{
    ll n;
    int res = 100;
    cin >> n;
    for (ll i = 1; i*i <= n; i++)
    {
        if (n % i != 0) continue;
        ll b = n / i;
        res = min(res, max(rest(i), rest(b)));
    }
    cout << res << endl;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    ll a, b, c, x, y, ss, sss;
    cin >> a >> b >> c >> x >> y;
    ll d = (a * x);
    ll e = (b * y);
    ll s = d + e;
    if(x >= y) {
       ll p = x - y;
       ll q = (c * (y*2));
       ll k =  a * p;
       ss = (q + k);
       sss = (x * c * 2);
    }
    else {
       ll p = y - x;
       ll q = (c * (x*2));
       ll k =  b * p;
       ss = (q + k);
       sss= (y*c * 2);
    }
    cout << min(s, min(ss, sss)) << endl;
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

const int INF=1001001001001001001ll;

int N;
int A[2222];

int dp[2222][2222];

signed main(){
	cin>>N;
	rep(i,N)cin>>A[i];

	vpint ord;
	rep(i,N)ord.eb(A[i],i);
	sort(all(ord));reverse(all(ord));

	fill_n(*dp,2222*2222,-INF);
	dp[0][0]=0;
	rep(i,N){
		rep(j,N){
			int k=ord[i].se;
			chmax(dp[i+1][j+1],dp[i][j]+A[k]*abs(j-k));
			chmax(dp[i+1][j],dp[i][j]+A[k]*abs(N-(i-j)-1-k));
		}
	}

	int ans=-INF;
	rep(i,N+1)chmax(ans,dp[N][i]);
	cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 42232
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

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

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

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int n; cin >> n;
    int ans = INF;
    rep(i,n){
        int a; cin >> a;
        int cnt = 0;
        while (a % 2 == 0){
            a /= 2;
            cnt++;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <functional>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		sum += 2 * min(x, k - x);
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

bool isprime(ll n){
    if(n==2)return true;
    if(n==1)return false;
    ll hn=ceil(sqrt(n));
    if(hn*hn==n)return false;
    for(ll i=2;i<=hn;i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

int main() {
    ll a,b;
    cin>>a>>b;
    ll sa=ceil(sqrt(a));
    ll sb=ceil(sqrt(b));
    set<ll> pa;
    for(ll i=1;i<=sa+1;i++){
        if(a%i==0){
            if(isprime(i))pa.insert(i);
            if(isprime(a/i))pa.insert(a/i);
        }
    }
    set<ll> pb;
    for(ll i=1;i<=sb+1;i++){
        if(b%i==0){
            if(isprime(i))pb.insert(i);
            if(isprime(b/i))pb.insert(b/i);
        }
    }
    set<ll> ans;
    set_intersection(pa.begin(), pa.end(), pb.begin(), pb.end(),inserter(ans,ans.end()));
    cout<<ans.size()+1<<endl;
}


Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

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 = 1000000007;
static const int SIZE = 200005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int 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 a, b;
    cin >> a >> b;
    bool f[4] = {};
    f[a] = f[b] = true;
    for( int i = 1; i <= 3; ++i ) {
        if( !f[i]) cout << i << endl;

    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,b) for(int i(a);i<b;i++)
#define rep(i,n) for(int i(0);i<n;i++)
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define pres(x) cout<<fixed; cout<<setprecision(x);
#define open freopen("input.txt","r",stdin) ; freopen("output.txt","w",stdout);
#define watch(x) cout<<(#x)<<" is "<<x<<"\n";
#define mod 1000000007

int32_t main(){
	
	fast;
	//open;

	int a,p,ans;
	cin>>a>>p;
	ans = (3*a+p)/2;
	cout<<ans;

	return 0;
}

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

const int N=100005;

struct node{
	int x,d;
	node(){}
	node(int x,int d):x(x),d(d){}
};
int n,m,x,y,d;
bool flag;
int pos[N];
bool vis[N];
vector<node> lev[N];
queue<int> q;

void bfs(int s){
	int k,u,d,l,j;
	q.push(s); pos[s]=0; vis[s]=1;
	while (!q.empty()){
		k=q.front(); q.pop();
		l=lev[k].size();
		for (j=0;j<l;j++){
			u=lev[k][j].x; d=lev[k][j].d;
			if (!vis[u]){
				pos[u]=pos[k]+d;
				vis[u]=1;
				q.push(u);
			}
			else if (pos[u]!=pos[k]+d){
				flag=0;
				return;
			}
		}
	}
}

int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++){
		scanf("%d%d%d",&x,&y,&d);
		lev[x].push_back(node(y,d));
		lev[y].push_back(node(x,-d));
	}
	flag=1;
	for (i=1;i<=n;i++){
		if (!vis[i]) bfs(i);
		if (!flag) break;
	}
	if (flag) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int s,w;
    cin >> s >> w;

    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;

    cout << endl;
    return 0;
}

Measured memory_bytes: 3656
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int LMAX=50;
int nlig,ncol,deplacement[4][2]={{1,0},{-1,0},{0,-1},{0,1}};

char terrain[LMAX][LMAX];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
		
	cin >> nlig >> ncol;
	bool ans=true;
	for(int l=0;l<nlig;l++){
		for(int c=0;c<ncol;c++){
			cin >> terrain[l][c];
		}
	}
	
	for(int l=0;l<nlig;l++){
		for(int c=0;c<ncol;c++){
			int possible=false;
			for(int d=0;d<4;d++){
				int lig=l+deplacement[d][0],col=c+deplacement[d][1];
				
				if(nlig>lig && lig>=0 && ncol>col && col>=0 && terrain[lig][col]=='#'){
					possible=true;
				}
			}
			
			if(terrain[l][c]=='#' && !possible){
				ans=false;
			}
		}
	}
	
	if(ans){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
	
}


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

int N,x;
int a[110];

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

    for (int i = 0; i < N; i++)
    {
        cin>>a[i];
    }
    
    sort(a,a+N);

    long long sum=0;
    int ans=0;
    for (int i = 0; i < N; i++)
    {
        sum += a[i];
        if(sum<=x) ans++;

        if(i==N-1 && sum<x) ans--;
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
        char a;
        cin >> a;
        char b = a;
        int anum = a - 'a';
        int bnum = b - 'A';
        if (anum >= 0 && anum <= 25) {
                cout << 'a' << endl;
        }
        else {
                cout << 'A' << endl;
        }

}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; 
    cin>>n;
    int ans=10000000;
    for(int i=0; i<=10; i++){
        int tmp=i*1000;
        if(tmp>=n){
        ans=min(ans,tmp-n);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
s=input()
flag = "AC"
if s[0] != "A":
    flag = "WA"
else:
    if not "C" in s[2:-1]:
        flag = "WA"
    else:
        ls = [c for c in s]
        ls.remove("A")
        ls.remove("C")
        for c in ls:
            if c.isupper():
                flag = "WA"
print(flag)

Measured memory_bytes: 38384