akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n;
  cin >> n;
  vector<ll> a(n, 0), ans(n, 0);
  rep(i, n) cin >> a[i];
  ll x = 0;
  rep(i, n) x ^= a[i];
  rep(i, n) cout << (x ^ a[i]) << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 6356
def e_knapsack2(N, W, Goods):
    """
    Dと同じ設定だが、制約が違う(1 <= v_i <= 10^3 と価値の制約がゆるめ)
    """
    from collections import defaultdict

    # dp[v]: 価値vを達成するために要求される重さの最小値
    dp = defaultdict(lambda: float('inf'))
    dp[0] = 0
    # w, vの順序が逆になっているのはdpテーブルの都合上
    for w, v in Goods:
        for nv, nw in list(dp.items()):
            if nw + w <= W:
                dp[nv + v] = min(dp[nv + v], nw + w)
    # 遷移の仕方により、keyの値を達成する品物の重さの和がWを超えることは
    # ないので、keyの最大値を解とすればいい
    return max(dp.keys())

N, W = [int(i) for i in input().split()]
Goods = [[int(i) for i in input().split()] for j in range(N)]
print(e_knapsack2(N, W, Goods))

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

#define pii pair<int, int>
using namespace std;
typedef long long LL;
int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
const int N = 1000002;
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}
void put(int x) {
	if(x < 0) x = -x, putchar('-');
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

pii hh[3];
char ss[N];
bool del[N];
int n, a[N], bak[3], now[3], sum;

void pr(int o) {sum++; putchar(bak[o] + 'A');}

void solve0() {
	int zz = hh[2].first - hh[1].first, last = 0, len;
	if(!zz) return ;
	int tp = 0;
	for(int i = 1; i <= n; i++) {
		if(a[i] == 2 && a[i - 1] != a[i + 1] && zz) zz--;
		else a[++tp] = a[i];
	} n = tp; a[n + 1] = -1; tp = 1;
	if(!zz) return ;
	for(int i = 2; i <= n; i++) {
		if((a[i - 1] + a[i] == 2) && zz && a[i - 2] != a[i + 1] && !del[i - 1]) {
			tp--, zz--, hh[0].first--; del[i] = 1;
		} else a[++tp] = a[i];
	} n = tp;
}

void solve1() {
	int zz = hh[1].first - hh[0].first, last = 0, len;
	for(int i = 1; i <= n; i++) {
		if(!a[i]) {
			len = i - last - 1;
			if(!len) pr(0);
			else if(len == 1) pr(a[i - 1]), pr(0);
			else if(len == 2) pr(a[i - 2]), pr(a[i - 1]), pr(0);
			else {
				int k = _min(zz, len / 2), st = last + 1;
				if(k * 2 == len) k--;
				zz -= k;
				for(int j = st + 2 * k; j <= i; j++) pr(a[j]);
			} last = i;
		}
	} len = n - last;
	if(len == 1) pr(a[n]);
	else if(len == 2) {
		if(!zz) pr(a[n - 1]), pr(a[n]);
	} else if(len > 2) {
		int k = _min(zz, len / 2), st = last + 1;
		zz -= k;
		for(int j = st + 2 * k; j <= n; j++) pr(a[j]);
	} puts("");
}

int main() {
	scanf("%s", ss + 1);
	int len = strlen(ss + 1);
	for(int i = 1; i <= len; i++) if(ss[i] != ss[i - 1]) a[++n] = ss[i] - 'A';
	a[0] = a[n + 1] = -1; for(int i = 1; i <= n; i++) hh[a[i]].first++;
	hh[0].second = 0, hh[1].second = 1, hh[2].second = 2;
	sort(hh, hh + 3); if(!hh[0].first) {puts(""); return 0;}
	for(int i = 0; i < 3; i++) bak[i] = hh[i].second, now[hh[i].second] = i;
	for(int i = 1; i <= n; i++) a[i] = now[a[i]];
	solve0();
	for(int i = 2; i <= n; i++) if(a[i] == a[i - 1]) puts("YES");
	solve1();
	return 0;
}

Measured memory_bytes: 6272
def main():
  import sys
  n,s,_,*t=sys.stdin.buffer.read().split()
  n=int(n)
  d=[0]*n+[1<<c-97for c in s]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  for q,a,b in zip(*[iter(t)]*3):
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i>1:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    print(bin(s).count('1'),flush=False)
main()

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

int main() {
	int y, m, d;
	scanf("%d/%d/%d", &y, &m, &d);
	if (y < 2019) {
		puts("Heisei");
	} else if (y > 2019) {
		puts("TBD");
	} else {
		if (m < 4) {
			puts("Heisei");
		} else if (m > 4) {
			puts("TBD");
		} else {
			puts("Heisei");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#define mod 1000000007
#define maxn 200010
#define LL long long
using namespace std;
LL f[maxn],inv[maxn];//f[i]=i!,inv[i]=j  i!的乘法逆元是j
LL quick_pow(LL a,LL b){
	LL ret=1;
	while(b){
		if(b&1)ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
LL C(LL n,LL m){
	LL ans;
	ans=f[n]*inv[n-m]%mod*inv[m]%mod;
	return ans;
}
int main(){
	LL n,k,i,ans=0;
	scanf("%lld%lld",&n,&k);
	f[0]=1;
	for(i=1;i<=n;i++)f[i]=f[i-1]*i%mod;
	for(i=0;i<=n;i++)inv[i]=quick_pow(f[i],mod-2)%mod;
	k=min(k,n-1);
	for(i=0;i<=k;i++)
		ans=(ans+C(n,i)*C(n-1,i)%mod)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  vector<int> cnt(4,0);
  REP(i,3) {
    int a, b; cin>>a>> b;
    cnt[a-1]++;
    cnt[b-1]++;
  }
  sort(cnt.begin(), cnt.end());
  bool ok = true;
  if(cnt[0] != 1) ok = false;
  if(cnt[1] != 1) ok = false;
  if(cnt[2] != 2) ok = false;
  if(cnt[3] != 2) ok = false;
  cout << (ok ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

const int MOD = 1000000007;
const int INF = 1 << 30;

struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind fr(n);
    vi A(m), B(m), C(k), D(k);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        A[i] = a;
        B[i] = b;
        fr.unite(a, b);
    }
    rep(i, k) {
        int c, d;
        cin >> c >> d;
        c--; d--;
        C[i] = c;
        D[i] = d;
    }

    vi res(n, 0);

    rep(i, n) {
		res[i] = fr.size(i) - 1;
    }

	rep(i, m) {
		if (!fr.same(A[i], B[i])) continue;
		res[A[i]]--;
		res[B[i]]--;
	}

	rep(i, k) {
		if (!fr.same(C[i], D[i])) continue;
		res[C[i]]--;
		res[D[i]]--;
	}

	rep(i, n) {
		cout << res[i] << " ";
	}
	cout << endl;

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;

const int INF=1e18+5;

int32_t main()
{
    fast

   int test=1;
   //cin>>test;


  while(test--)
  {
  string s,t;
  cin>>s>>t;
  int m=s.size(),n=t.size();
  int L[m+1][n+1];
  for(int i=0;i<=m;i++)
  {
    for(int j=0;j<=n;j++)
    {
      if(i==0||j==0)L[i][j]=0;
      else if(s[i-1]==t[j-1])L[i][j]=L[i-1][j-1]+1;
      else L[i][j]=max(L[i-1][j],L[i][j-1]);
    }
  }

  int index=L[m][n];
  char ans[index+1];
  ans[index]='\0';
  int i=m,j=n;
  while(i>0&&j>0)
  {
    if(s[i-1]==t[j-1])
    {
      ans[index-1]=s[i-1];
      i--;
      j--;
      index--;
    }
    else if(L[i-1][j]>L[i][j-1])i--;
  else j--;
  }

  cout<<ans;

  //while loop ending 
  }



return 0;
}

Measured memory_bytes: 70656
from collections import deque
K = int(input())

d = deque()

for i in range(1,10):
	d.append(i)

for i in range(K):
	x = d.popleft()
	if x % 10 != 0:
		d.append(10*x+(x%10)-1)
	d.append(10*x+(x%10))
	if x % 10 != 9:
		d.append(10*x+(x%10)+1)

print(x)


Measured memory_bytes: 11908
N, K = list(map(int, input().split()))
X = list(map(int, input().split()))

mn = 1000000000
for i in range(N - K + 1):
	x1 = X[i]
	x2 = X[i + K - 1]
	if x1 >= 0:
		m = x2
	elif x2 <= 0:
		m = - x1
	else:
		m = x2 - x1 + min(x2, -x1)

	if mn > m:
		mn = m

print(mn)

Measured memory_bytes: 14228
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	if (a < b)swap(a, b);
	return (a / gcd(a, b))*b;
}

int main() {

	int n;
	cin >> n;
	pr(n / 3);

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;
const int INF = 1001001001;
 
int main() {
  int N, K;
  cin >> N >> K;
 
  vector<int> h(N, 0);
  rep(i,0,N-1) cin >> h[i];
  sort(h.begin(), h.end());
 
  int ans = INF;
  for (int i = 0, j = K - 1 + i; j < N; i++, j++) {
    int p = h.at(j) - h.at(i);
    ans = min(ans, p);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<math.h>
#include<limits.h>

#define long long ll

using namespace std;

main()
{
	int n,k;
	cin>>n>>k;
	
	int i,j;
	int a[n];
	int dp[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	
	for(i=2;i<n;i++)
	{
		dp[i] = INT_MAX;
		for(j=1;j<=k;j++)
		{
			int val = (i-j>=0) ? abs(a[i] - a[i-j]) + dp[i-j] : INT_MAX;
			dp[i] = min( dp[i] , val);
		}
	}
	cout<<dp[n-1];
	
	
}



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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            for(var i = 0; i <= 25; i++)
                for(var j = 0; j <= 15; j++)
                {
                    if(i*4 + j*7 == N)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }                  
                }
            Console.WriteLine("No");
        }       
    }
}


Measured memory_bytes: 13140
s = input()
k = int(input())
n = len(s)
if n == 1:
    print(s)
elif n == 2:
    l2 = sorted(list(set([s[i:i+2] for i in range(n-1)])))
    print(l2[0])
elif n == 3:
    l1 = list(set(s))
    l2 = list(set([s[i:i+2] for i in range(n-1)]))
    l3 = list(set([s[i:i+3] for i in range(n-2)]))
    out = sorted(l1 + l2 + l3)
    print(out[k-1])
elif n == 4:
    l1 = list(set(s))
    l2 = list(set([s[i:i+2] for i in range(n-1)]))
    l3 = list(set([s[i:i+3] for i in range(n-2)]))
    l4 = list(set([s[i:i+4] for i in range(n-3)]))
    out = sorted(l1 + l2 + l3 + l4)
    print(out[k-1])
else:
    l1 = list(set(s))
    l2 = list(set([s[i:i+2] for i in range(n-1)]))
    l3 = list(set([s[i:i+3] for i in range(n-2)]))
    l4 = list(set([s[i:i+4] for i in range(n-3)]))
    l5 = list(set([s[i:i+5] for i in range(n-4)]))
    out = sorted(l1 + l2 + l3 + l4 + l5)
    print(out[k-1])

Measured memory_bytes: 4272
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N,M;
vector<int> L,R,X;
vector<int> ri[303];

i64 dp[303][303][303];
i64 MOD = 1e9 + 7;
int main(){
  cin >> N >> M;
  L.resize(M);
  R.resize(M);
  X.resize(M);
  rep(i,0,M - 1) cin >> L[i] >> R[i] >> X[i];
  rep(i,0,M - 1) ri[R[i]].push_back(i);
  dp[0][0][0] = 1;

  rep(r,0,N - 1){
    rep(g,0,N - 1){
      rep(b,0,N - 1){
        int next = max({r,g,b}) + 1;
        //red
        {
          bool ok = true;
          int MIN = min({g,b});
          int MAX = max({g,b});
          for(auto idx : ri[next]){
            int cnt = 1;
            if(MAX >= L[idx]) cnt++;
            if(MIN >= L[idx]) cnt++;
            ok = ok && cnt == X[idx];
          }
          if(ok){
            dp[next][g][b] += dp[r][g][b];
            dp[next][g][b] %= MOD;
          }
        }
        {
          bool ok = true;
          int MIN = min({r,b});
          int MAX = max({r,b});
          for(auto idx : ri[next]){
            int cnt = 1;
            if(MAX >= L[idx]) cnt++;
            if(MIN >= L[idx]) cnt++;
            ok = ok && cnt == X[idx];
          }
          if(ok){
            dp[r][next][b] += dp[r][g][b];
            dp[r][next][b] %= MOD;
          }
        }
        {
          bool ok = true;
          int MIN = min({g,r});
          int MAX = max({g,r});
          for(auto idx : ri[next]){
            int cnt = 1;
            if(MAX >= L[idx]) cnt++;
            if(MIN >= L[idx]) cnt++;
            ok = ok && cnt == X[idx];
          }
          if(ok){
            dp[r][g][next] += dp[r][g][b];
            dp[r][g][next] %= MOD;
          }
        }
      }
    }
  }

  i64 ans = 0;
  rep(i,0,N - 1){
    rep(j,0,N - 1){
      ans = (dp[N][i][j] + ans) % MOD;
      ans = (dp[i][N][j] + ans) % MOD;
      ans = (dp[i][j][N] + ans) % MOD;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 217344
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<vector>
#include<ctime>
#define ll long long
#define pr(x) cerr<<#x<<"="<<x<<endl
using namespace std;
int n,o,a[1000000],ans,i;
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (i=1;i<n;i++)
	{
		if (a[i]==i) 
		{
			if (a[i]==i+1) swap(a[i-1],a[i]),ans++;
			else swap(a[i],a[i+1]),ans++;
		}
	}
	if (a[n]==n) ans++;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int counter = 0;
	int n = s.length();
	for (int i = 0; i < n; i++)
	{
		if (s[i] != t[i])
			counter++;
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 3552
def gcd(x,y):
    if x<y:
        x,y=y,x
    #x>y
    if y==0:
        return x
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)

N=int(input())
A=list(map(int, input().split()))

L = [0] * N
R = [0] * N

ans = 0

for i in range(1,N):
    L[i] = gcd(L[i-1], A[i-1])

for i in range(N-1)[::-1]:
    R[i] = gcd(R[i+1], A[i+1])

for i in range(N):
    ans = max(ans, gcd(L[i],R[i]))


print(ans)

Measured memory_bytes: 14076
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define mp make_pair
#define CHECK(x) if(!(x)) return false;
#define CHECKRET(x, y) if(!(x)) return (y);
#define SKIP(x) if((x)) continue;
typedef pair<int, int> pii;

const int MAXN = 100010;
bool withmagic[MAXN];
int nomagic;
int nrMagic = 0;
int N;

void mkTrue(int pos) {
  if (pos < 0 || pos >= N) return;
  if (!withmagic[pos]) ++nrMagic;
  withmagic[pos] = true;
}

int main() {
  int Q;
  scanf("%d%d", &N, &Q);
  nomagic = 0;
  nrMagic = 0;
  while (Q--) {
    mkTrue(nomagic - 1);
    mkTrue(nomagic + 1);
    int l, r;
    scanf("%d%d", &l, &r);
    --l, --r;
    if (nomagic == l) nomagic = r;
    else if (nomagic == r) nomagic = l;

    swap(withmagic[l], withmagic[r]);

    mkTrue(nomagic - 1);
    mkTrue(nomagic + 1);
  }

  mkTrue(nomagic);
  printf("%d\n", nrMagic);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+2;

int main()
{
    fastio;
    ll i, j, k, n, m, t;

    for ( i = 0; i < 5; i++)
    {
        cin>>j;
        if(j==0){

        cout<<i+1<<endl;return 0;
        }
    }
    

        
    return 0;
}

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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,n=3;
    cin>>a>>b>>c;
    if(a==b)n--;
    if(a==c)n--;
    if(b==c)n--;
    if(n==0)n++;
    cout<<n;
    return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265 
double p1(int a, int b, int x) {
	double ans = 2 * x * 1.0 / (a * b);
	double t = b / ans;
	return 180 * atan(b / ans) / pi;
	//printf("%.6f", );

}
double p2(int a, int b, int x) {
	double h = x*1.0 / (a * a);
	double c = 2 * h - b;
	double s = b - c;
	return 180 * atan(s / a) / pi;
	//printf("%.6f", );

}
int main()
{
	int a, b, x;
	double ans;
	cin >> a >> b >> x;
	if (2 * x <= a * a * b)ans= p1(a, b, x);
	else ans= p2(a, b, x);
	printf("%.6f", ans);
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto x = readln.chomp.split.to!(int[]);
  auto k = readln.chomp.to!int;
  int index;
  int m;
  foreach (i, e; x) {
    if (e > m) {
      m = e;
      index = i.to!int;
    }
  }
  x[index] *= 2 ^^ k;
  x.sum.writeln;
}


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

int gcd(int a,int b){ return b==0?a:gcd(b,a%b); }
int gcd3(int a,int b,int c)
{
    long long m=gcd(a,b);
    m=gcd(m,c);
    return m;
}
int main(){
	long long n,a1,a2,a3,sum;
	cin>>n;
	sum=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum+=gcd3(i,j,k);
			}
		}
	}
	cout<<sum;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int k = 0; k < W; k++) cin >> data.at(i).at(k);
  }
  
  for (int i = 0; i < H; i++) {
    bool disc = true;
    for (int k = 0; k < W; k++) {
      if (data.at(i).at(k) == '.') continue;
      disc = false; 
      break;
    }
    if (disc) {
      for (int k = 0; k < W; k++) data.at(i).at(k) = 'o';
    }
  }
  
  for (int k = 0; k < W; k++) {
    bool disc = true;
    for (int i = 0; i < H; i++) {
      if (data.at(i).at(k) == '.' || data.at(i).at(k) == 'o') continue;
      disc = false;
      break;
    }
    if (disc) {
      for (int i = 0; i < H; i++) data.at(i).at(k) = 'o';
    }
  }
  
  for (int i = 0; i < H; i++) {
    bool disc = false;
    for (int k = 0; k < W; k++) {
      if (data.at(i).at(k) != 'o') {cout << data.at(i).at(k); disc = true;}
    }
    if (disc) cout << endl;
  }
}

Measured memory_bytes: 256
fun calcCumulativeSumList(list: List<Int>) = list.fold(mutableListOf(0)) { acc, value ->
    acc += acc.last() + value
    acc
}

fun sumIntFromOneTo(last: Int) = last * (last + 1) / 2
fun calcExpectedValueForDice(value: Int) = sumIntFromOneTo(value) / value.toDouble()
fun calcMaxIndex(list: List<Int>) = list.indices.maxBy { list[it] }!!

fun main(args: Array<String>) {
    val (n, k) = readIntegerList()
    val pList = readIntegerList()

    val cs = calcCumulativeSumList(pList)
    (0..(pList.size - k)).map { cs[it + k] - cs[it] }
        .let(::calcMaxIndex)
        .let { it until (it + k) }
        .map { pList[it] }
        .map(::calcExpectedValueForDice)
        .sum()
        .let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 81496
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  vll h(n);
  rep(i,n) cin>>h[i];
  ll l=0;
  ll r=1e9;
  ll mid=(l+r)/2;
  while(l+1<r){
    ll cu=0;
    rep(i,n){
      if(h[i]-b*mid>0){
        cu+=(h[i]-b*mid+a-1-b)/(a-b);
      }
    }
    if(cu<=mid){
      r=mid;
    }
    else l=mid;
    mid=(l+r)/2;
  }
  COUT(r);
}


Measured memory_bytes: 1024
from collections import Counter

N=int(input())
a=list(map(int,input().split()))
A=list(set(a))
ans=0
count = Counter(a)

for i in A:
    if count[i]>i:
        ans+=count[i]-i
    elif count[i]<i:
        ans+=count[i]

print(ans)

Measured memory_bytes: 21100
function main(input) {
    var args = input.trim().split(" ");
    var A = Number(args[0]);
    var B = Number(args[1]);

    var total = A + B;

    if (total % 2 !== 0) {
        console.log("IMPOSSIBLE");
        return;
    }

    console.log(total / 2);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include"bits/stdc++.h"
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> W(N);
	for (int i = 0;i < N;++i) cin >> W.at(i);
	int ans = -1;
	for (int i = 1;i < N;++i) {
		int S1 = 0, S2 = 0;
		for (int j = 0;j < i;++j) S1 += W.at(j);
		for (int j = i;j < N;++j) S2 += W.at(j);
		if (ans < 0) ans = abs(S1 - S2);
		else if (abs(S1 - S2) < ans) ans = abs(S1 - S2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
public class Main{
    
    
    public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       int k =  sc.nextInt();
       String s = sc.next();
       char [] ss = s.toCharArray();
       int len = 0;
       
       if(ss.length<= k){
           System.out.println(s);
       }
       else{
           for(int i=0;i<k;i++){
               System.out.print(ss[i]);
           }
           System.out.println("...");

       }
    }
   
    
       
    
}

Measured memory_bytes: 27096
n, t = map(int, input().split())

c = []

for i in range(0,n):
    c_i, t_i = map(int, input().split())

    if t_i <= t:
        c.append(c_i)

if len(c) > 0:
    print(min(c))
else:
    print("TLE")

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	
	int n, k; cin >> n >> k;
	vector<char> d(k);
	for (int i = 0; i < k; i++) {
		cin >> d[i];
	}
	int ans = 0;
	for (int i = n; i <= 100000 ; i++) {
		string tmp = to_string(i);
		bool can = true;
		for (int j = 0; j < tmp.size(); j++) {
			for (int x = 0; x < k; x++) {
				if (tmp[j] == d[x]) {
					can = false;
				}
			}			
		}
		if (can) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

#define MAX_N 100
#define MAX_W 10000

void solve();

int N,W;
int v[MAX_N+1], w[MAX_N+1];
int dp[MAX_N+1][MAX_W+1];

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

    v[0]=0;
    w[0]=0;

    for(int i=1; i<=N; i++){
        cin >> v[i] >> w[i];
    }
    solve();
    cout << dp[N][W] << endl;
    return 0;
}

void solve(){
    for(int i=1; i<=N; i++){
        for(int j=0; j<=W; j++){
            if(j<w[i]){
                dp[i][j]=dp[i-1][j];
            }else{
                dp[i][j]=max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
            }
        }
    }
}


Measured memory_bytes: 7028
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct BIT {
    ll n;
    vll a;
    BIT(ll n) : n(n), a(n + 1, 0) {}
    void add(ll i, ll w){
        for(ll x = i; x <= n; x += x & -x) a[x] += w;
    }
    ll sum(ll i) { // sum of [1, i]
        ll ret = 0;
        for(int x = i; x > 0; x -= x & -x) ret += a[x];
        return ret;
    }
    ll sum(ll l, ll r) { // sum of [l, r]
        return sum(r) - sum(l - 1);
    }
};

struct BIT_range {
    BIT p, q;
    BIT_range(ll n) : p(n + 1), q(n + 1) {}
    void add(ll l, ll r, ll x) {  // add x to [l, r)
        p.add(l, -x * l);
        p.add(r, x * r);
        q.add(l, x);
        q.add(r, -x);
    }
    ll sum(ll i) {  // sum in [1, i)
        return p.sum(i) + q.sum(i) * i;
    }
    ll sum(ll l, ll r) {    // sum of [l, r)
        return sum(r) - sum(l);
    }
};

void solve() {
    ll n, q;
    cin >> n >> q;
    BIT_range b(n);
    vll ans;
    for(ll i = 0; i < q; i++) {
        ll c;
        cin >> c;
        if(c == 0) {
            ll s, t, x;
            cin >> s >> t >> x;
            b.add(s, t + 1, x);
        }
        else {
            ll p;
            cin >> p;
            ans.push_back(b.sum(p, p + 1));
        }
    }
    for(auto i : ans) cout << i << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 5404
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"stdio.h"
#include"stdlib.h"
#include"assert.h"
#include"ctype.h"
#include"string.h"
#include"math.h"
#include"string"
#include"deque"
#include"iostream"
#include"set"
#include"map"
#include"vector"
#include"algorithm"
#include"bitset"
#include"stack"
#include"queue"
#include"sstream"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

int32_t main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	IOS;

	string s, t;
	cin >> s;

	map<char, int> mp;

	for(char c : s)
		mp[c]++;

	string ans = "Yes";

	if(mp.size() != 2)
		ans = "No";
	for(auto i : mp)
		if(i.y != 2)
			ans = "No";

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,i,ans=0,now=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++){
        if(now<a[i]){
            ans+=a[i]-now;
            now=a[i];
        }
        else now = a[i];
    }
    printf("%d",ans);
}


Measured memory_bytes: 1732
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kamol Paul
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define long long long
typedef pair < long , long > pii;

class ECrestedIbisVsMonster {
public:
    static bool cmp(pii a, pii b){
        return (a.second/a.first) > (b.second/b.first);
    }

	void solve(std::istream& in, std::ostream& out) {
	    long h,n;
	    in>>h>>n;
	    vector <pair< long,long>> data(n);
	    for(auto& x: data) in>>x.first>>x.second;
	    sort(data.begin(),data.end(),cmp);
	    long tk[h+100];
	    for(int i=0;i<=h+10;i++){
	        tk[i]= LONG_MAX;
	    }
	    tk[0]=0;
	    for(int i=0;i<n;i++){
	        long cost = data[i].second;
	        long cover= data[i].first;
	        for(int j=1;j<cover && j<=h;j++){
	            tk[j] = min(tk[j], cost);
	        }
	        for(int j= cover;j<=h;j++){
	            tk[j] = min(tk[j],(tk[j-cover])+cost);
	        }

	    }
	    out<<tk[h]<<endl;

	}
};


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
	ECrestedIbisVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline

n, m, s = map(int,input().split())
A = [list(map(int,input().split())) for i in range(m)]
C = [list(map(int,input().split())) for i in range(n)]

for i in range(m):
    for j in range(2):
        A[i][j] -= 1

ma = max([A[i][2] for i in range(m)])
mc = ma * n + 3
vv = n * mc
M = [[] for i in range(vv)]

# print(ma,mc,vv)

for i in range(n):
    for j in range(mc-1):
        p0 = i * mc + j
        p1 = i * mc + min(mc-1, j+C[i][0])
        d = C[i][1]
        M[p0].append([p1, d])

# print(M)

for i in range(n):
    for j in range(1, mc):
        p0 = i * mc + j
        p1 = i * mc + j-1
        d = 0
        M[p0].append([p1, d])

# print(M)
# print("")


for i in range(m):
    for j in range(mc):
        p0 = A[i][0] * mc + j
        p1 = A[i][1] * mc + j-A[i][2]
        d = A[i][3]
        if j-A[i][2] >= 0:
            M[p0].append([p1, d])

        p0 = A[i][1] * mc + j
        p1 = A[i][0] * mc + j-A[i][2]
        d = A[i][3]
        if j-A[i][2] >= 0:
            M[p0].append([p1, d])

# print(M)

import heapq

st = min(s, mc-1)
nn = n
n = len(M)
D = [float("inf")] * n  # 頂点0からの距離
# P = [-1] * n  # 頂点0からの最短距離において、そこの直前の頂点(経路復元に利用)
D[st] = 0
V = [0] * n  # その頂点のD[i]が最短距離と確定したら1
Q = []  # 優先度付きキュー
for v in range(n):
    heapq.heappush(Q, [D[v], v])

le = len(Q)
while le > 0:
    q = heapq.heappop(Q)
    u = q[1]
    du = q[0]
    if V[u] == 0:
        V[u] = 1
        le -= 1
        for i in range(len(M[u])):
            v = M[u][i][0]
            luv = M[u][i][1]
            if V[v] == 0:
                alt = du + luv
                if D[v] > alt:
                    D[v] = alt
                    # P[v] = u
                    heapq.heappush(Q, [alt, v])

# print(D)

for i in range(1, nn):
    print(min(D[i*mc : (i+1)*mc]))

Measured memory_bytes: 181388
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{
    int a;
  cin>> a;
  cout<<a/3<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror

#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率
ll mod = 1e9 + 7;




//提出コード
long double a, b, h, m;
long double ax, ay, bx, by, arad, brad, ans;

//degree → radian
long double chg_DegRad(long double deg) {
	return deg * PI / 180.0;
}



int main() {
	cin >> a >> b >> h >> m;
	
	arad = chg_DegRad(30 * h + m / 2);
	brad = chg_DegRad(6 * m);

	ax = a * sin(arad);
	ay = a * cos(arad);
	bx = b * sin(brad);
	by = b * cos(brad);

	ans = sqrt(pow(abs(ax - bx), 2) + pow(abs(ay - by),2));
	cout << setprecision(10) << ans << endl;



	return 0;
}



Measured memory_bytes: 4096
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const char nl = '\n';

void solve() {
    int n;
    cin >> n;
    vi v(n);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    int ans = -1;
    for(int i = -100; i <= 100; ++i){
        int cost(0);
        for(int j = 0; j < v.size(); ++j){
            cost += pow(v[j] - i, 2);
        }
        if(ans < 0 or ans > cost){
            ans = cost;
        }
    }
    cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
ll gcd(ll a,ll b){
	return a%b==0?b:gcd(b,a%b);
}
int main(void)
{
	int t,i;
	ll a,b,c,d,g;
	scanf("%d\n",&t);
	while(t-->0){
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if(b>a) puts("No");
		else if(b>d) puts("No");
		else if(c>=b) puts("Yes");
		else{
			g=gcd(b,d);
			if(b-g+a%g>c) puts("No");
			else puts("Yes");
		}
	}
	return 0;
}
    
    
    


Measured memory_bytes: 128
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>

using namespace std;

int a[4];
int N = 0;
int buf=1;
string result;
int aa=0;
bool enda=false;
stringstream bufSS[4];

int main() {
	cin >> N;
	a[3] = N % 10;
	a[2] = N % 100;
	a[2] /= 10;

	a[1] = N % 1000;
	a[1] /= 100;

	a[0] = N / 1000;

	for (int i = 0; i < 4; i++) {
		bufSS[i] << a[i];
	}

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				result.clear();
				aa = a[0];
				result = bufSS[0].str().c_str();

				if (i == 0) {
					aa += a[1];
					result += "+";
				}
				else {
					aa -= a[1];
					result += "-";
				}
				result += bufSS[1].str().c_str();

				if (j == 0) {
					aa += a[2];
					result += "+";
				}
				else {
					aa -= a[2];
					result += "-";
				}
				result += bufSS[2].str().c_str();
				if (k == 0) {
					aa += a[3];
					result += "+";
				}
				else {
					aa -= a[3];
					result += "-";
				}
				result += bufSS[3].str().c_str();
				result += "=7";
				if (aa == 7 && enda==false) {
					cout << result.c_str() << endl;
					enda = true;
					break;
				}

			}

		}

	}


return 0;
}

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

ll s;

// claudio van
int main() {
  scanf("%lld", &s);
  ll x1 = 1e9, y1;
  ll x2 = 1, y2 = ceil((double) s / x1);
  ll x3 = 0, y3 = 0;
  y1 = x1 * y2 - s;
  printf("%lld %lld ", x1, y1);
  printf("%lld %lld ", x2, y2);
  printf("%lld %lld", x3, y3);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int n;
long long int a[10005];

long long int solver(){
  long long int cnt[10005];
  long long int sum = 0;
  for(int i = 0; i < n; ++i){
    cnt[i] = 0;
  }
  for(int i = 0; i < n; ++i){
    long long int tmp = a[i];
    while(tmp % 2 == 0){
      cnt[i]++;
      tmp = tmp / 2;
    }
    sum += cnt[i];
  }
  return sum;
}

int main(){
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  cout << solver() << endl;
}

Measured memory_bytes: 512
#include <iostream>

void solve() {
    int a, b;
    std::cin >> a >> b;

    for (int n = 0; n <= 100000; ++n) {
        if (n * 8 / 100 == a && n * 10 / 100 == b) {
            std::cout << n << std::endl;
            return;
        }
    }
    std::cout << -1 << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


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

int main()
{
    int n=3;
    int ara[n+1][n+1];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin>>ara[i][j];
        }
    }
    for(int i=1; i<n; i++){
        for(int j=1; j<n; j++){
            if((ara[i][j-1]-ara[i-1][j-1])!=(ara[i][j]-ara[i-1][j])){
                cout<<"No";
                return 0;
            }
        }
    }
    for(int j=1; j<n; j++){
        for(int i=1; i<n; i++){
            if((ara[i][j-1]-ara[i-1][j-1])!=(ara[i][j]-ara[i-1][j])){
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
import heapq
class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)
 
    def pop(self):
        return heapq.heappop(self.hq) * self.sign
 
    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)
 
    def top(self):
        return self.hq[0] * self.sign
N,M = map(int,input().split())
A_s = list(map(int,input().split()))
answer = sum(A_s)
A_s = Heapq(A_s,True)
for i in range(M):
    temp = A_s.pop()
    answer -= temp-temp//2
    temp //= 2
    A_s.push(temp)
print(answer)

Measured memory_bytes: 72484
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int>arr(n);
  for(int i=0;i<n;i++)
    cin>>arr[i];
  sort(arr.begin(),arr.end());
  int sum=0;
  for(int i=0;i<k;i++)
    sum=sum+arr[i];
  cout<<sum;
}

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

int main(void) {
	int i,j,k,a[10];
	for(i=0;i<5;i++)
		scanf("%d",&a[i]);
	scanf("%d",&k);
	for(i=0;i<5;i++) {
		for(j=0;j<5;j++) {
			if(abs(a[i]-a[j])>k) {
				puts(":(");
				return 0;
			}
		}
	}
	puts("Yay!");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=300010;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,k,a[N];
int main()
{
	file();
	read(k),read(n);
	if(k==1){For(i,1,(n+1)/2)printf("%d ",1);exit(0);}
	if(k&1)
	{
		For(i,1,n)a[i]=k/2+1;
		int x=n/2;
		while(x--)
		{
			int p=n;
			while(a[p]==0&&p)p--;
			if(--a[p++])For(i,p,n)a[i]=k;
		}
		For(i,1,n)
		{
			if(!a[i])break;
			printf("%d ",a[i]);
		}
	}
	else
	{
		printf("%d ",k/2);
		For(i,2,n)printf("%d ",k);
	}
	return 0;
}


Measured memory_bytes: 3456
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
			final List<Integer> numList = Arrays.stream(args.get(0).split(" ")).map(Integer::valueOf).collect(Collectors.toList());
			System.out.println((numList.get(2) / numList.get(0)) * numList.get(1));
        };
    }

}


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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()

int ctoi(char c) {
    return c - '0';
}

int f(char c) {
    int ret = 0;
    if(c == 'm') ret = 1000;
    if(c == 'c') ret = 100;
    if(c == 'x') ret = 10;
    if(c == 'i') ret = 1;
    return ret;
}

int conv(string s) {
    reverse(ALL(s));
    int n = s.size();
    s += "$";
    
    int ret = 0;
    rep(i,n) {
        if(!isdigit(s[i])) {
            int p = f(s[i]);
            if(isdigit(s[i+1])) ret += p * ctoi(s[i+1]);
            else ret += p * 1;
        }
    }
    return ret;
}


string inv(int n) {
    string ret = "";
    while(n > 0) {
        string t = "";
        if(n >= 1000) {
            int p = n / 1000;
            t += (p!=1 ? to_string(p) : "");
            n -= 1000*p;
            ret += t + "m";
        }
        else if(n >= 100) {
            int p = n / 100;
            t += (p!=1 ? to_string(p) : "");
            n -= 100*p;
            ret += t + "c";
        }
        else if(n >= 10) {
            int p = n / 10;
            t += (p!=1 ? to_string(p) : "");
            n -= 10*p;
            ret += t + "x";
        }
        else if(n >= 1) {
            int p = n / 1;
            t += (p!=1 ? to_string(p) : "");
            n -= p;
            ret += t + "i";
        }
    }

    return ret;
}

int main() {
    int n; cin>>n;
    rep(i,n) {
        string s1, s2;
        cin>>s1>>s2;
        int sum = conv(s1) + conv(s2);
        string ans = inv(sum);
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 3268
S=gets.chomp
y1=(S[0]+S[1]).to_i
y2=(S[2]+S[3]).to_i
if y1 != 0 and y1 <=12
  if y2 != 0 and y2 <=12
    puts "AMBIGUOUS"
  else
    puts "MMYY"
  end
else
  if y2 != 0 and y2 <=12
    puts "YYMM"
  else
    puts "NA"
  end
end

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(){
char c;
cin>>c; 
if (c=='a'){ cout<<"vowel";}
else if (c=='e'){ cout<<"vowel";}
else if (c=='i'){ cout<<"vowel";}
else if (c=='u'){ cout<<"vowel";}
else if (c=='o'){ cout<<"vowel";}
else cout<<"consonant";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

struct Point {
	ll x, y;
	Point(){}
	Point(ll x, ll y):x(x), y(y){}
};
int main() {
	ll h, w;
	cin >> h >> w;
	queue<Point> blacks;
	vector<vector<ll>> distance;
	distance.resize(h);
	for (ll i = 0; i < h; i++) {
		string s;
		cin >> s;
		distance[i].resize(w);
		for (ll j = 0; j < w; j++) {
			if (s[j] == '#') {
				blacks.push(Point(i, j));
				distance[i][j] = 0;
			}
			else {
				distance[i][j] = -1;
			}
		}
	}
	ll ans = 0;
	while (!blacks.empty()) {
		Point now = blacks.front();
		blacks.pop();
		ll x = now.x;
		ll y = now.y;
		ll nowDis = distance[x][y];
		if (ans < nowDis) {
			ans = nowDis;
		}

		Point tmp[4];
		for (ll i = 0; i < 4; i++) {
			tmp[i] = now;
		}
		tmp[0].x++;
		tmp[1].x--;
		tmp[2].y++;
		tmp[3].y--;
		for (ll i = 0; i < 4; i++) {
			Point& nowtmp = tmp[i];
			if (0 <= nowtmp.x && nowtmp.x < h && 0 <= nowtmp.y && nowtmp.y < w && distance[nowtmp.x][nowtmp.y] == -1) {
				distance[nowtmp.x][nowtmp.y] = nowDis + 1;
				
				blacks.push(nowtmp);
			}
		}
	}
	/*for (ll i = 0; i < h; i++) {
		for (ll j = 0; j < w; j++) {
			cout << distance[i][j];
		}
		cout << endl;
	}*/
	cout << ans << endl;
	
}


Measured memory_bytes: 27380
#include <bits/stdc++.h>
#define COUT(x) cout << #x << " = " << (x) << ", "
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  ll K,N;
  cin >> K >> N;
  vector<ll> A(N);
  ll res = -1;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  for(int i = 1; i < N; i++){
    ll tmp = A[i] - A[i-1];
    res = max(res, tmp);
  }
  ll tmp = K - A[N-1] + A[0];
  res = max(res, tmp);
  cout << K - res << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define F first
#define S second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
ll HRX=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ll a,b,c;
 cin>>a>>b>>c;
 ll ans=b+c-a;
 if(ans>=0)
   cout<<ans<<endl;
 else
    cout<<"0"<<endl;
 return 0;
}


Measured memory_bytes: 256