akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inc(i, l, r) for (int i = l; i <= r; i++)
#define dec(i, l, r) for (int i = l; i >= r; i--)
#define pii pair<ll, ll>
#define fi first
#define se second
#define pb push_back
const int maxn = 1e6 + 5;

int t;
ll n, a, b, c, d;

int main() {
    cin >> t;
    while (t--) {
        map<ll, ll> dp;
        cin >> n >> a >> b >> c >> d;
        ll inf = 1e13;
        dp[0] = inf;
        priority_queue<pii, vector<pii>, greater<pii> > que;
        que.push(pii(0, n));
        while (que.size()) {
            pii t = que.top();
            que.pop();
            if (t.se != n && t.fi > dp[t.se]) continue;
            if (dp[0] >= t.fi && (dp[0] - t.fi) / d >= t.se) {
                dp[0] = t.fi + t.se * d;
            }
            if (t.fi > inf) {
                continue;
            }
            if (t.se & 1) {
                if (!dp[t.se / 2] || dp[t.se / 2] > t.fi + a + d) {
                    dp[t.se / 2] = t.fi + a + d;
                    que.push(pii(dp[t.se / 2], t.se / 2));
                }
                if (!dp[t.se / 2 + 1] || dp[t.se / 2 + 1] > t.fi + a + d) {
                    dp[t.se / 2 + 1] = t.fi + a + d;
                    que.push(pii(dp[t.se / 2 + 1], t.se / 2 + 1));
                }
            } else {
                if (!dp[t.se / 2] || dp[t.se / 2] > t.fi + a) {
                    dp[t.se / 2] = t.fi + a;
                    que.push(pii(dp[t.se / 2], t.se / 2));
                }
            }
            if (t.se % 3 <= 1) {
                if (!dp[t.se / 3] || dp[t.se / 3] > t.fi + b + t.se % 3 * d) {
                    dp[t.se / 3] = t.fi + b + t.se % 3 * d;
                    que.push(pii(dp[t.se / 3], t.se / 3));
                }
            } else {
                if (!dp[t.se / 3 + 1] ||
                    dp[t.se / 3 + 1] > t.fi + b + (3 - t.se % 3) * d) {
                    dp[t.se / 3 + 1] = t.fi + b + (3 - t.se % 3) * d;
                    que.push(pii(dp[t.se / 3 + 1], t.se / 3 + 1));
                }
            }
            if (t.se % 5 <= 2) {
                if (!dp[t.se / 5] || dp[t.se / 5] > t.fi + c + t.se % 5 * d) {
                    dp[t.se / 5] = t.fi + c + t.se % 5 * d;
                    que.push(pii(dp[t.se / 5], t.se / 5));
                }
            } else {
                if (!dp[t.se / 5 + 1] ||
                    dp[t.se / 5 + 1] > t.fi + c + (5 - t.se % 5) * d) {
                    dp[t.se / 5 + 1] = t.fi + c + (5 - t.se % 5) * d;
                    que.push(pii(dp[t.se / 5 + 1], t.se / 5 + 1));
                }
            }
        }
        cout << dp[0] << "\n";
    }
}

Measured memory_bytes: 4436
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  char tmp;
  string ans = "Three";
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(tmp=='Y') ans = "Four";
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3600
#include <iostream>
using namespace std;
typedef long long ll;
ll a[1010], sum[1010], n, k, ans;
bool jud[1010][1010];


ll pow(ll x, ll y){
    if (y == 0) return 1;
    if (y % 2) return x * pow(x, y - 1);
    else {
        ll yy = pow(x, y / 2);
        return yy * yy;
    }
}

int main(void){
    // Your code here!
    cin >> n >> k;
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i];
    for (ll i = 0; i < n; i++){
        for (ll j = i + 1; j <= n; j++){
            jud[i][j] = true;
        }
    }
    for (ll i = 40; i >= 0; i--){
        ll cou = 0;
        for (ll j = 0; j < n; j++){
            for (ll l = j + 1; l <= n; l++){
                if (!jud[j][l]) continue;
                if ((pow(2, i) & (sum[l] - sum[j])) > 0) cou++;
            }
        }
        if(cou >= k){
            ans += pow(2, i);
            for (ll j = 0; j < n; j++){
                for (ll l = j + 1; l <= n; l++){
                    if (!jud[j][l]) continue;
                    if ((pow(2, i) & (sum[l] - sum[j])) == 0) jud[j][l] = false;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long N,M;cin>>N>>M;
    if(N==1&&M==1){
        cout<<1<<endl;
        return 0;
    }
    if(min(N,M)>=2){
        cout<<N*M-(N*2+(M-2)*2)<<endl;
        return 0;
    }
    cout<<max(N,M)-2<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  int a, p;
  cin >> a >> p;

  int ans = (3*a+p)/2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <tuple>
#include <map>
#include <numeric>

using namespace std;
#define PI 3.14159265359
#define ll long long int

int main(void)
{
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
typedef long long ll;
int n;
ll k;
int a[maxn];
int fir[maxn];
int lst[maxn];
int nxt[maxn];
int v[maxn];
int s[maxn];
int cnt;
int top;
int main(){
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(!fir[a[i]]) fir[a[i]]=i;
	} 
	nxt[n+1]=1;
	for(int i=n;i>=1;i--){
		if(!lst[a[i]]) nxt[i]=fir[a[i]]+1;
		else nxt[i]=nxt[lst[a[i]]+1];
		lst[a[i]]=i;
	}
	for(int i=1;!v[i];i=nxt[i]) v[i]=1,s[++cnt]=i;
	memset(v,0,sizeof(v));
	for(int i=s[(k-1)%cnt+1];i<=n;i++)
		if(!v[a[i]]){
			s[++top]=a[i];
			v[a[i]]=1;
		}else{
			do{
				v[s[top]]=0;
				top--;
			}while(s[top+1]!=a[i]);
		}
	for(int i=1;i<=top;i++) printf("%d ",s[i]);
	printf("\n");
	return 0; 
} 

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

int n,w;
ull d[110][2];
ull m[110][100005];
bool v[110][100005];

ull dp(int p, ull r){
	if(p==n)
		return 0;
	if(v[p][r])
		return m[p][r];
	ull ans=dp(p+1,r);
	if(r>=d[p][0])
		ans=max(ans, d[p][1]+dp(p+1, r-d[p][0]));
	m[p][r]=ans;
	v[p][r]=1;
	return ans;
}

int main() {
	cin>>n>>w;
	for(int i=0;i<n;i++)
		cin>>d[i][0]>>d[i][1];
	cout<<dp(0, w);
}

Measured memory_bytes: 89984
N, M = map(int, input().split())
rec = []
MOD = 10 ** 9 + 7
K = M
for i in range(2, int(M ** 0.5) + 1):
    if K % i == 0:
        tmp = 0
        while K % i == 0:
            tmp += 1
            K //= i

        rec.append((i, tmp))

if K != 1:
    rec.append((K, 1))
Q = 10 ** 6 + 1
fact = [0] * Q
rfact = [0] * Q
fact[0] = 1
for i in range(1, Q):
    fact[i] = fact[i - 1] * i % MOD

rfact[Q - 1] = pow(fact[Q - 1], MOD - 2, MOD)
for i in range(Q - 2, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1) % MOD


def comb(n, r):
    return fact[n] * rfact[n - r] * rfact[r] % MOD


num = 1
for i in range(len(rec)):
    num *= comb(N + rec[i][1] - 1, rec[i][1])
    num %= MOD

print(num)


Measured memory_bytes: 82420
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define sc second
#define int long long
using namespace std;

void solve()
{

}

int32_t main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int w = 0, r = 0;
    for (auto c : s)
    {
        w += c == 'W';
        r += c == 'R';
    }
    int curw = 0;
    int curr = 0;
    int mn = r;
    for (int i = 0; i < n; i++)
    {
        curw += s[i] == 'W';
        curr += s[i] == 'R';
        mn = min(mn, max(r - curr, curw));
    }
    cout << mn << endl;
}


Measured memory_bytes: 3704
#include <iostream>

int main()
{
    int x[10000];
    int i = 0;

    std::cin >> x[i];
    while (x[i] != 0){
        ++i;
    std::cin >> x[i];
    }
    for (i = 0; x[i] != 0; ++i){
    std::cout << "Case " << i + 1 <<": " << x[i] << "\n";
    }

    return 0;
}



Measured memory_bytes: 3112
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		bool[][][] forbid = new bool[N+1][][];
		for(int i=0;i<N+1;i++){
			forbid[i] = new bool[N+1][];
			for(int j=0;j<N+1;j++){
				forbid[i][j] = new bool[N+1];
			}
		}
		
		for(int k=0;k<M;k++){
			int r = R[k];
			int l = L[k];
			int x = X[k];
			for(int i=0;i<r;i++){
				for(int j=0;j<r;j++){
					int cnt = 1;
					if(l <= i) cnt++;
					if(l <= j) cnt++;
					if(cnt != x){
						forbid[r][i][j] = true;
						forbid[r][j][i] = true;
						forbid[i][r][j] = true;
						forbid[i][j][r] = true;
						forbid[j][i][r] = true;
						forbid[j][r][i] = true;
					}
				}
			}
		}
		
		int mod = (int)1e9 + 7;
		int[][][] dp = new int[N+1][][];
		for(int i=0;i<N+1;i++){
			dp[i] = new int[N+1][];
			for(int j=0;j<N+1;j++){
				dp[i][j] = new int[N+1];
			}
		}
		
		dp[0][0][0] = 1;
		for(int i=0;i<=N;i++){
			for(int j=0;j<=N;j++){
				for(int k=0;k<=N;k++){
					
					if(forbid[i][j][k]){
						dp[i][j][k] = 0;
						continue;
					}
					int nxt = 1 + Math.Max(Math.Max(i, j), k);
					if(nxt > N || dp[i][j][k] == 0) continue;
					dp[nxt][j][k] += dp[i][j][k]; if(dp[nxt][j][k] >= mod) dp[nxt][j][k] -= mod;
					dp[i][nxt][k] += dp[i][j][k]; if(dp[i][nxt][k] >= mod) dp[i][nxt][k] -= mod;
					dp[i][j][nxt] += dp[i][j][k]; if(dp[i][j][nxt] >= mod) dp[i][j][nxt] -= mod;
				}
			}
		}
		
		int tot = 0;
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				tot += dp[i][j][N]; if(tot >= mod) tot -= mod;
				tot += dp[i][N][j]; if(tot >= mod) tot -= mod;
				tot += dp[N][i][j]; if(tot >= mod) tot -= mod;
			}
		}
		Console.WriteLine(tot);
		
	}
	int N, M;
	int[] L,R,X;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		L = new int[M];
		R = new int[M];
		X = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			L[i] = d[0]; R[i] = d[1]; X[i] = d[2];
		
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 177740
#include <stdio.h>
#include <iostream>
#include <string>
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
int dp[200000];
int h[200000];
int main(){
  	int n, k;
  	cin >> n >> k;
	rep(i,n)scanf("%d",&h[i]);
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
  	dp[1] = 0;
	dp[2] = abs(h[1] - h[0]);
  	for(int i=3;i<(n);i++){
      dp[i]=INF;
    }
	for(int i=3;i<(n + 1);i++){
      for(int j=0;j<(k);j++){
        //cout<<(i - 1, h[i-1])<<endl;
        if(i - 2 - j >= 0){
          if(dp[i] > dp[i - 1 - j] + abs(h[i - 1] - h[i - 2 - j])){
                dp[i] = dp[i - 1 - j] + abs(h[i - 1] - h[i - 2 - j]);
          }
        }
        else{
            break;
        }
      }
      //cout<<dp[i-1]<<endl;
	}
  
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int D;
  D = 10*B + C;
  if (D % 4 == 0){
  cout << "YES";
  }else{
  cout << "NO";
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>

using namespace std;

enum{
  A, B, X, Y, W, Z, U, SIZE
};

int g[SIZE][2] = {
  {X, Y}, // A
  {Y, X}, // B
  {U, Z}, // X
  {X, U}, // Y
  {B, Y}, // W
  {W, B}, // Z
  {U, U}  // U
};

int main(){
  char buff[256];
  while(scanf("%s", buff), buff[0] != '#'){
    int pos = A;
    for(int i = 0; buff[i]; i++)
      pos = g[pos][buff[i] - '0'];
    puts(pos == B ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 944
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ss := make([]int, n)
	for i := 0; i < k; i++ {
		var d int
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			var a int
			fmt.Scan(&a)
			a--
			ss[a] = 1
		}
	}
	var cnt int
	for i := range ss {
		if ss[i] == 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 2424
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int M = 0, E = 1, J = 2;

int main()
{
    int n, p[3], sum, ave;
    while(cin >> n && n)
    {
        rep(j,n)
        {
            sum= 0;
            cin >> p[M] >> p[E] >> p[J];
            REP(3) sum+= p[i];
            ave = sum / 3;

            if(p[0] == 100|| p[1] == 100 || p[2] == 100 ||((p[M]+ p[E]) >= 180)|| (ave >= 80)){cout << "A"<< endl; continue;}
            //if((p[M]+ p[E]) >= 180) {cout << "A" << endl; continue;}
            //if(ave >= 80) { cout << "A" << endl; continue;}

            if(ave >= 70 || (ave >=50 && (p[M] >=80 || p[E] >= 80))){cout <<"B" << endl; continue;}

            cout << "C" << endl;
        }    
    }

    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,m,k=0,g,x,f,t,a,b;
    cin>>m>>n>>a>>b;
    x = ceil(a*1.0/n);
    f = ceil(m*1.0/b);
    if(x <= f)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }


}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 998244353;
const int N = int(3e5) + 999;
#define int long long int

#define inf 1e18

int32_t main()
{
    IOS;
    int n, W;
    cin >> n >> W;

    int val = 0;
    int weight[n], value[n];

    for (int i = 0; i < n; i++)
        cin >> weight[i] >> value[i];

    for (int x : value)
        val += x;

    vector<int> dp(val + 1, (int)inf);
    dp[0] = 0;

    for (int i = n - 1; i >= 0; i--)
    {

        for (int item = val - value[i]; item >= 0; item--)
        {
            dp[item + value[i]] = min(dp[item + value[i]], dp[item] + weight[i]);
        }
    }
    int ans = 0;

    for (int i = 0; i <= val; i++)
    {
        if (dp[i] <= W)
            ans = max(ans, i);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
    int i,sum;
    char num[1000];
    while(1)
    {
        scanf("%s",&num);
        sum=0;
        for(i=0;i<strlen(num);i++)
        {
            sum+=num[i]-'0';
        }
        if(sum==0)
            break;
        printf("%d\n",sum);
    }
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1e9+7;
const int INF=1001001001;

int main() {
  int N,K;
  cin>>N>>K;
  cout<<N-(K-1)<<endl;
return 0;  
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=2e6+1;
ll fact[mxn],ifact[mxn];

void multi(ll &a, ll b){
	a%=MOD; b%=MOD; a*=b; a%=MOD;
	return;
}

void jian(ll &a, ll b){
	a-=b;
	if(a<0)a+=MOD;
	return;
}

ll modpow(ll a, ll b) // put b = mod-2, calc for (x!)^(mod-2) % mod only, [use x^(mod-2) when x^-1] 
{
	ll r=1;
	while(b){
		if(b&1)r=(r*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return r;
}

// ncr
ll calc(ll n, ll r){
    ll cur = fact[n];
    multi(cur,ifact[n-r]);
    multi(cur,ifact[r]);
    return cur;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	
	fact[0]=1; ifact[0]=1;
	for(int i=1;i<mxn;i++)
	{
		fact[i]=(fact[i-1]*1LL*i)%MOD;
		ifact[i]=modpow(fact[i],MOD-2);
	}
	
	int k; cin >> k;
	string s; cin >> s;
	int n=s.length();
	ll now = modpow(26,n+k);
	for(int i=0; i<n; i++){
		ll minuss = modpow(25,n+k-i);
		ll times = calc(n+k,i);
		multi(minuss,times);
		jian(now,minuss);
	}
	cout << now;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

using ll    = long long;
using vll   = vector<ll>;
using pll   = pair<ll,ll>;
using ld    = long double;

const ll mod = (ll)1e9 + 7;
const ll mxN = (ll)2e6 + 3;

void solve() {
	vll A(5); 
	for(int i=0;i<5;i++) cin>>A[i];
	for(int i=0;i<5;i++){
		if(A[i]==0) cout<<i+1<<"\n";
	}
	
}
int main() {
//	ios::sync_with_stdio(false);
//	cin.tie(nullptr);
//	cout.precision(20);
//	cout << fixed;
//	pre();
//	ll t;cin>>t;while (t--)
		solve();
}


Measured memory_bytes: 3596
from sys import stdin

n = int(stdin.readline().rstrip())
p = [int(x) for x in stdin.readline().rstrip().split()]
pn = [int(x) for x in range(1, n+1)]

count = 0
for i in range(n):
    if p[i] != pn[i]:
        count += 1

print("YES" if count <= 2 else "NO")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
typedef vector<int> vi;

int main() {
  ll a;
  double b;
  cin >> a >> b;
  ll int_b = b*100+0.1; // 切り捨てで壊れないよに
  a *= int_b;
  a /= 100;
  printf("%lld\n", a);
  return 0;
}

Measured memory_bytes: 3792
n = int(input())
x = []
u = []
for i in range(n):
     a, b = input().split()
     x.append(float(a))
     u.append(b)
for i in range(n):
     if u[i] == "BTC":
          x[i] = x[i] * 380000
print(sum(x))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int N;
long K;
int A[2<<17],T[2<<17],E[2<<17];
main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		A[i]--;
		E[i]=i;
	}
	while(K)
	{
		if(K&1)
		{
			for(int i=0;i<N;i++)T[i]=A[E[i]];
			for(int i=0;i<N;i++)E[i]=T[i];
		}
		K>>=1;
		for(int i=0;i<N;i++)T[i]=A[A[i]];
		for(int i=0;i<N;i++)A[i]=T[i];
	}
	cout<<E[0]+1<<endl;
}


Measured memory_bytes: 5988
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int X, Y;
    cin >> X >> Y;
    int ans = 1;
    while (X * 2 <= Y) {
        X *= 2;
        ans++;
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>

const int mod = 1000000007;
class carr {
	int** c;
	int level;
public:
	carr(int n, int t = 0) {
		for (int i = 0; i < 30; i++) {
			if (1 << i >= n) {
				level = i + 1;
				break;
			}
		}
		c = new int*[level];
		for (int i = 0; i < level; i++) {
			c[i] = new int[1 << (level - 1 - i)];
			for (int j = 0; j < 1 << (level - 1 - i); j++) {
				if (i == 0) {
					c[0][j] = j < n ? t : 0;
				}
				else {
					c[i][j] = c[i - 1][j << 1] + c[i - 1][(j << 1) + 1];
				}
			}
		}
	}
	carr(int n, int *t) {
		for (int i = 0; i < 30; i++) {
			if (1 << i >= n) {
				level = i + 1;
				break;
			}
		}
		c = new int*[level];
		for (int i = 0; i < level; i++) {
			c[i] = new int[1 << (level - 1 - i)];
			for (int j = 0; j < 1 << (level - 1 - i); j++) {
				if (i == 0) {
					c[0][j] = j < n ? t[j] : 0;
				}
				else {
					c[i][j] = c[i - 1][j << 1] + c[i - 1][(j << 1) + 1];
				}
			}
		}
	}
	void cadd(int n, int a = 1) {
		for (int i = 0; i < level; i++) {
			c[i][n >> i] += a;
		}
	}
	void csub(int n, int a = 1) {
		for (int i = 0; i < level; i++) {
			c[i][n >> i] -= a;
		}
	}
	int prev(int n) {
		if (c[0][n])return n;
		for (int i = 0; i < level; i++) {
			if (n&(1 << i) && c[i][(n >> i) - 1]) {
				int r = (n >> i) - 1;
				for (int j = i - 1; j >= 0; j--) {
					r <<= 1;
					if (c[j][r | 1])r |= 1;
				}
				return r;
			}
		}
		return -1;
	}
	int next(int n) {
		if (c[0][n])return n;
		for (int i = 0; i < level; i++) {
			if ((n&(1 << i)) == 0 && c[i][(n >> i) + 1]) {
				int r = (n >> i) + 1;
				for (int j = i - 1; j >= 0; j--) {
					r <<= 1;
					if (c[j][r] == 0)r |= 1;
				}
				return r;
			}
		}
		return -1;
	}
};
int main() {
	int N, M;
	scanf("%d %d", &N, &M);
	std::pair<int, int> *d = new std::pair<int, int>[N];
	for (int i = 0; i < N; i++) {
		int A, B;
		scanf("%d %d", &A, &B);
		d[i].first = -B;
		d[i].second = A - 1;
	}
	std::sort(d, d + N);
	carr c(M, 1);
	int res = 0;
	for (int i = 0; i < N; i++) {
		if (d[i].second > M)continue;
		int r = c.next(d[i].second);
		if (r != -1 && r < M) {
			res -= d[i].first;
			c.csub(r);
		}
	}
	printf("%d", res);
}

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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
ll n;
pll pts[100005];
map<pll,ll> mark;

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    set<pll> tem;
    rep(i,1,n) {
        ll u,v;cin>>u>>v;
        tem.insert(mp(u,v));
    }
    n=0;
    for(pll xp:tem) pts[++n]=xp;
    if(n == 1){
        cout<<0<<endl;
        return 0;
    }
    set<pll> xval,yval;

    rep(i,1,n) {
        xval.insert(pts[i]);
        yval.insert(mp(pts[i].S,pts[i].F));
    }

    priority_queue<pair<ll,pll> ,vector< pair<ll,pll>  > ,greater<pair<ll,pll>  > >pq;
    pq.push(mp(0,pts[1]));
    ll ans=0;
    while(!pq.empty()){
        auto xp=pq.top();
        pq.pop();
        if(mark[xp.S]) continue;
        //cout<<xp.F<<" "<<xp.S.F<<" "<<xp.S.S<<endl;
        ans+=xp.F;
        mark[xp.S]=1;


        auto it = xval.lower_bound(xp.S);
        it++;
        if(it!=xval.end()) {
           // cout<<(*it).F<<" "<<(*it).S<<endl;
            if(!mark[*it]) pq.push(mp((*it).F-xp.S.F,*it));
        }
        it--;

        if(it!=xval.begin()) {
            //cout<<(*it).F<<" "<<(*it).S<<endl;
            it--;
            if(!mark[*it]) pq.push(mp(-(*it).F+xp.S.F,*it));

        }


        auto it2 = yval.lower_bound(mp(xp.S.S,xp.S.F));
        it2++;
        if(it2!=yval.end()) {
            if(!mark[mp((*it2).S,(*it2).F)]) pq.push(mp((*it2).F-xp.S.S,mp((*it2).S,(*it2).F)));
        }
        it2--;
        if(it2!=yval.begin()) {
            it2--;;
            if(!mark[mp((*it2).S,(*it2).F)]) pq.push(mp(-(*it2).F+xp.S.S,mp((*it2).S,(*it2).F)));
        }

    }

    cout<<ans<<'\n';
}


Measured memory_bytes: 30004
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
long long gcd(long long a, long long b) {return b ? gcd(b, a % b) : a;}
long long lcm(long long m, long long n ){if((0 == m )||( 0 == n ))return 0;
    return ((m / gcd(m, n)) * n);
}
signed main(){
    int n; scanf("%lld",&n);
    int array[3000];
    rep(i,n)scanf("%lld",array+i);
    int ans = 0; rep(i,n) ans += i[array]-1;
    printf("%lld",ans);
}




Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

constexpr int MOD = 1'000'000'007;

// get modular inverse for prime MOD with call modPow(a, MOD - 2, MOD)
int modPow(int a, int b, int c = MOD){
    long long x = 1, y = a;
    while (b > 0){
        if (b % 2 == 1){
            x = (x * y) % c;
        }
        y = (y * y) % c;
        b /= 2;
    }
    return x % c;
}

class agc028_b {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            in >> A[i];
        }
        vector<int> frac(N + 1, 0);
        for (int i = 1; i <= N; ++i) {
            frac[i] = modPow(i, MOD - 2);
            frac[i] = (frac[i] + frac[i - 1]) % MOD;
        }
        int ans = 0;
        for (int i = 0; i < N; ++i) {
            int d1 = i + 1, d2 = N - i;
            // compute expected value
            ans = (ans + 1LL * (frac[d1] + frac[d2] - frac[1]) * A[i]) % MOD;
        }
        // multiply by n! to get sum
        for (int i = 1; i <= N; ++i) {
            ans = (1LL * ans * i) % MOD;
        }
        out << ans << "\n";
    }
};

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


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int k, s, count = 0;
	int rest, ymin, ymax;

	scanf("%d%d", &k, &s);

	for(int i=0; i <= k && i <= s; i++) {
		rest = s - i;
		ymin = rest - k;
		ymax = rest;
		if(ymin < 0)
			ymin = 0;
		if(ymax > k)
			ymax = k;
		if(ymin <= ymax)
			count += ymax - ymin + 1;
	}
	printf("%d", count);

	return 0;
}


Measured memory_bytes: 128
import std.algorithm;
import std.stdio;
import std.string;
import std.range;

void main()
{
	auto n = readln;
	auto s = readln.strip;
	
	writeln( solve( s ) );
}

int solve( in string s )
{
	auto lc = new int[ s.length ];
	lc[ 0 ] = 0;
	foreach( i; 1 .. s.length )
	{
		lc[ i ] = lc[ i - 1 ] + ( s[ i - 1 ] == 'E' ? 0 : 1 );
	}
	
	auto rc = new int[ s.length ];
	rc[ $-1 ] = 0;
	foreach_reverse( i; 0 .. s.length-1 )
	{
		rc[ i ] = rc[ i + 1 ] + ( s[ i + 1 ] == 'W' ? 0 : 1 );
	}
	
	return zip( lc, rc ).map!( a => a[ 0 ] + a[ 1 ] ).reduce!( min );
}

unittest
{
	assert( solve( "WEEWW" ) == 1 );
	assert( solve( "WEWEWEEEWWWE" ) == 4 );
	assert( solve( "WWWWWEEE" ) == 3 );
}


Measured memory_bytes: 4436
#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;

int main() {
  int n;
  cin >> n;
  cout << n*800-(n/15)*200 << endl;
}


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

int main ()
{
    bool number[1000001];
    for (int i = 0; i < 1000001; i++) number[i] = true;
    number[0] = number[1] = false;
    for (int i = 2; i < 5001; i++) {
        for (int j = 2; number[i] && i * j <= 1000000; j++) {
            number[i * j] = false;
        }
    }

    int n, m, p;
    while (cin >> n >> m >> p, (n || m || p)) {
        int k = -1;
        while (p) {
            k++;
            if (number[n + m * k]) p--;
        }
        cout << n + m * k << endl;
    }

    return 0;
}

Measured memory_bytes: 2136
N, K = map(int, input().split())
xy = [[int(i) for i in input().split()] for _ in range(N)]

ret = float('inf')
for i in range(N) :
    for j in range(i, N) :
        for k in range(j, N) :
            for l in range(k, N) :
                x, y = zip(xy[i], xy[j], xy[k], xy[l])
                mx, Mx = min(x), max(x)
                my, My = min(y), max(y)
                
                counter = 0
                for m in range(N) :
                    if mx <= xy[m][0] <= Mx and my <= xy[m][1] <= My :
                        counter += 1
                if counter >= K :
                    ret = min(ret, (Mx-mx)*(My-my))
print(ret)

Measured memory_bytes: 53980
#include <iostream>
#include <vector>
#define NIL -1
#define MAX 100000+5
#define INF 10000000

struct Node {
    int depth;
    int parent = NIL;
    int child = NIL;
    int sibling = NIL;
};

std::vector<Node> nodes;

void setDepth(int node_num, int depth) {
    nodes.at(node_num).depth = depth;
    if (nodes.at(node_num).sibling != NIL) /* -> */ setDepth(nodes.at(node_num).sibling, depth);
    if (nodes.at(node_num).child != NIL) /* -> */setDepth(nodes.at(node_num).child, depth+1);
    return;
}

void setNode(int node_num, int children[]) {
    if (children[0] != INF) {
        nodes.at(node_num).child = children[0];
        for (int i=0;children[i]!=INF; i++) /* -> */ nodes.at(children[i]).parent = node_num;
        for (int i=0; children[i+1]!=INF; i++) /* -> */nodes.at(children[i]).sibling = children[i+1];
    }
}

std::vector<int> getChildren(int node_num) {
    std::vector<int> children;
    if (nodes.at(node_num).child != NIL) {
        children.push_back(nodes.at(node_num).child);
        node_num = nodes.at(node_num).child;
        while (nodes.at(node_num).sibling != NIL) {
            children.push_back(nodes.at(node_num).sibling);
            node_num = nodes.at(node_num).sibling;
        }
    }
    return children;
}

void output(Node node, int node_num) {
    std::cout << "node " << node_num << ": ";
    std::cout << "parent = " << node.parent << ", ";
    std::cout << "depth = " << node.depth << ", ";
    if (node.parent == NIL) std::cout << "root" << ", ";
    else if (node.child != NIL) std::cout << "internal node" << ", ";
    else /* if (node.child == NIL) */ std::cout << "leaf" << ", ";    
    std::vector<int> children = getChildren(node_num);
    std::cout << "[";
    if (node.child != NIL) {
        for (int i=0; i<children.size()-1; i++) std::cout << children.at(i) << ", ";
        std::cout << children.at(children.size()-1);
    }
    std::cout << "]" << "\n";
}

int main() {
    int total, node_num, children_num;
    int children[MAX];
    std::cin >> total;
    nodes.resize(total);
    for (int i=0; i<total; i++) {
        std::cin >> node_num >> children_num;
        for (int j=0; j<children_num; j++) {
            std::cin >> children[j];
        }
        children[children_num] = INF;
        setNode(node_num, children);
    }
    int root_num;
    for (int i=0; i<total; i++) {
        if (nodes.at(i).parent == NIL) {
            root_num = i;
            break;
        }
    }
    setDepth(root_num, 0);
    
    for (int i=0; i<nodes.size(); i++) output(nodes.at(i), i);
}



Measured memory_bytes: 8536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

			int  D = sc.nextInt();

			if (D == 22) {
				System.out.println("Christmas Eve Eve Eve");
			}else if(D == 23){
				System.out.println("Christmas Eve Eve");
			}else if (D == 24) {
				System.out.println("Christmas Eve");
			}else {
				System.out.println("Christmas");
			}


	}
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 N,A,B;
    cin >> N >> A >> B;

    cout << min(A*N,B) << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end(),greater<int>());
    cout<<abs(a[0]-a[n-1])<<endl;

    return 0;
}

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

using namespace std;

#define repeat(n) for(int _______ = (n); _______ > 0; --_______)
#define loop(i, l, r) for(auto i = (l), __r = decltype(i)(r); i <= __r; ++i)
#define iloop(i, l, r) for(auto i = (l), __r = decltype(i)(r); i < __r; ++i)
#define rloop(i, r, l) for(auto i = (r), __l = decltype(i)(l); i >= __l; --i)

using LL = long long;

template<typename Container>
inline
int size(const Container& x)
{ return x.size(); }

#ifdef CAI_WEI_HAN

#include "my_print.h"
#include "LOG.h"

#else

#define LOG(...)

#endif

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	constexpr char endl = '\n';
#ifdef CAI_WEI_HAN
	freopen("test.in", "r", stdin);
	register auto program_start_time = clock();
	#define cout cerr
#endif
	
	int n;
	cin >> n;
	
	int ans = 0, now = 0, x = 0;
	repeat(n) {//LOG(ans, now, x);
		int y;
		cin >> y;
		
		if(x >= y) {
			now++;
			ans = max(ans, now);
		}
		
		else
			now = 0;
		
		x = y;
	}
	
	cout << ans;
	
#ifdef CAI_WEI_HAN
	cout << "\n\n--------------------------------\n"
		 << "time:   " << double(clock() - program_start_time) / CLOCKS_PER_SEC;
#endif
}

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

string s[10] = {
  "",
  ".,!? ",
  "abc",
  "def",
  "ghi",
  "jkl",
  "mno",
  "pqrs",
  "tuv",
  "wxyz",
};

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    string t;
    cin >> t;

    int key = 0;
    char now = 0;
    for(char c : t) {
      if(c == '0') {
        if(now) cout << now;
        now = 0;
        key = 0;
      } else {
        auto f = s[c - '0'];
        now = f[key];
        key++;
        key %= f.size();
      }
    }
    cout << "\n";
  }
  return 0;
}



Measured memory_bytes: 3056
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  ll a,b;
  cin >> a >> b;
  printf("%lld\n", lcm(a,b));
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>

intmax_t gcd(intmax_t m, intmax_t n) {
  while (n) std::swap(m %= n, n);
  return m;
}

intmax_t tenpow(intmax_t k) {
  intmax_t res = 1;
  for (int i = 0; i < k; ++i) res *= 10;
  return res;
}

int main() {
  intmax_t a;
  scanf("%jd.", &a);

  char buf[16] = "";
  scanf("%[^(\n]", buf);
  std::string f0 = buf;
  std::string f1 = "";
  if (scanf("(%[^)\n])", buf) == 1) f1 = buf;

  intmax_t m = f0.length();
  intmax_t n = f1.length();

  intmax_t b = std::stoi("0"+f0);
  intmax_t c = std::stoi("0"+f1);

  if (n == 0) {
    intmax_t q = a * tenpow(m);
    q += b;
    intmax_t d = tenpow(m);

    intmax_t g = gcd(q, d);
    q /= g;
    d /= g;
    printf("%jd/%jd\n", q, d);
    return 0;
  }

  intmax_t q = a * tenpow(m) * (tenpow(n)-1);
  q += b * (tenpow(n)-1);
  q += c;

  intmax_t d = tenpow(m) * (tenpow(n)-1);
  intmax_t g = gcd(q, d);
  q /= g;
  d /= g;
  printf("%jd/%jd\n", q, d);
}



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

int main() {
  int n, m;
  cin >> n >> m;
  int p[m];
  string s[m];
  for (int i = 0; i < m; i++) {
    cin >> p[i] >> s[i];
    p[i]--;
  }
  bool ac[n] = {};
  int wa[n] = {};
  for (int i = 0; i < m; i++) {
    if (!ac[p[i]]) {
      if (s[i] == "AC") ac[p[i]] = true;
      else wa[p[i]]++;
    }
  }
  int ans[2] = {};
  for (int i = 0; i < n; i++) {
    if (ac[i]) {
      ans[0]++;
      ans[1] += wa[i];
    }
  }
  cout << ans[0] << " " << ans[1] << endl;
}

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

using namespace std;

int main() {
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size() / 2; ++i) {
		if (s[i] != s[s.size() - i - 1]) ans++;
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
    int a, b;
    cin >>a>>b;
    int min1 = min(a,b);
    int max1 = max(a, b);
    int ans=0;
    rep(i, max1){
        ans+=min1*pow(10, i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
int main (){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int b[n];
	for(int i=0;i<n;i++){
		b[i]=0;
	}
	int x=n/2;
	int ch=1;
	b[x]=a[0];
	if(n%2==0){
	for(int i=0;i<n;i+=2){
		if(i==n-1)continue;
		b[x-ch]=a[i+1];
		b[x+ch]=a[i+2];
		++ch;
	}}
	else{
		for(int i=0;i<n;i+=2){
		if(i==n-1)continue;
		b[x+ch]=a[i+1];
		b[x-ch]=a[i+2];
		++ch;
	}
	}
	for(int i=0;i<n;i++){
		cout<<b[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b))?(b):(a))
#define chmin(a, b) a = (((a)<(b))?(a):(b))

const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

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

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};

#define lengthof(x) (sizeof(x) / sizeof(*(x)))


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}

signed main(){
  string a,b; cin>>a>>b;
  int x = stoi(a+b);
  cerr << x << endl;
  cerr << pow(x,0.5) << endl;
  if(pow((int)pow(x,0.5),2)==x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
using namespace std;
int n,a[200010],tag[200010];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if (i-a[i]>0) tag[i-a[i]]=i;
		else {printf("-1");return 0;}
	}
	int pre=0;
	long long ans=0;
	//for (int i=1;i<=n;i++) printf("%d ",tag[i]);
	for (int i=1;i<=n;i++)
	{
		if (tag[i]==0) continue;
		if (tag[i]<pre) {printf("-1");return 0;}
		if (tag[i]>pre) ans+=tag[i]-i;
		pre=tag[i];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1792
/**
 * @author: shashankchdhry
 * @made:   2020-04-02 08:17:15 
**/
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

const ll MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    unordered_map<int, int> ump;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        ump[temp]++;
    }

    ll ans = 1;

    bool flag = true;
    if (n%2 && ump[0] != 1)
        flag = false;
    int start = n%2?2:1;
    while (start < n && flag)
    {
        if (ump[start] != 2)
            flag = false;
        ans *= 2;
        ans %= MOD;
        start += 2;
    }
    if (flag)
        cout << ans << "\n";
    else
    {
        cout << 0 << "\n";
    }

    return 0;
}

Measured memory_bytes: 3724
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, std::string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

void warshallfloyd(vvi& d)
{
  REP(i, 10) d[i][i] = 0;
  REP(k, 10) REP(i, 10) REP(j, 10) {
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }
}

signed main()
{
  for (int n; n = in(), n;) {
    vvi d(10, vi(10, INF));
    REP(i, n) {
      int a = in(), b = in(), c = in();
      d[a][b] = c; d[b][a] = c;
    }
    warshallfloyd(d);
    pii ans = mp(INF, INF);
    REP(i, 10) {
      pii t = mp(0, i);
      int cnt = 0;
      REP(j, 10) {
        //debug(d[i][j]);
        if (d[i][j] == INF) cnt++;
        else t.Fi += d[i][j];
      }
      if (cnt == 9) t.Fi = INF;
      ans = min(ans, t);
    }
    cout << ans.Se << " " << ans.Fi << '\n';
  }

  return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <cstdlib>
#include <iomanip>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0);
const int M = 1e9+7;
const int N = 1e5;
using namespace std;
ll dp[N+5][2];
vector<int> adj[N];

void solve(int v, int fa){
    dp[v][1] = dp[v][0] = 1;
    for(int child : adj[v]){
        if(child==fa)
            continue;
        solve(child, v);
        dp[v][1] = (dp[v][1]*(dp[child][0]+dp[child][1]))%M;
        dp[v][0] = (dp[v][0]*dp[child][1])%M;
    }
}

int main(){
    AC
    int n;
    cin>>n;
    for(int i=0; i<n-1; i++){
        int a, b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }


    solve(1, 0);
    cout<<(dp[1][0]+dp[1][1])%M<<endl;
}

Measured memory_bytes: 17428
n = int(input())
nums = [int(i) for i in input().split()]
ans = 0


def count(num):
    cnt = 0
    while True:
        if num % 2 == 0:
            cnt += 1
        else:
            break
        num = num // 2
    return cnt


for num in nums:
    ans += count(num)
print(ans)


Measured memory_bytes: 4148
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
  ll n,d[100],i,j,sum=0;

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

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      sum+=d[i]*d[j];
    }
  }
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 256