akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <iomanip>
#include <cassert>
using namespace std;

const int LIM = 300000;

bool isprime[LIM];

void eratosthenes(void){
    for(int i = 0; i < LIM; i++) isprime[i] = true;
    isprime[0] = isprime[1] = false;
    for(int i = 2; i * i < LIM; i++){
        if(isprime[i]){
            for(int j = i * i; j < LIM; j += i){
                isprime[j] = false;
            }
        }
    }
}

int main(){
    eratosthenes();
    int N;
    while(true){
        scanf("%d", &N);
        if(N == 0) break;
        int ans = 0;
        for(int i = N + 1; i <= 2 * N; i++){
            if(isprime[i]) ++ ans;
        }
        printf("%d\n", ans);
    }
    
    return 0;
}

Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
bool sym (int n){
  if (n % 10 == n / 10000){
    n /= 10;
    if (n % 10 == (n / 100) % 10){
      return true;
    }
  }
  else return false;
}

int main() {
  int A, B;
  cin >> A >> B;
  int count = 0;
  for (int i = A; i <= B; i++){
    if (sym(i)) count++;
  }
  cout << count << endl;
  return 0;
}


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

int main(void){
    int N;
    cin >> N;
    vector<ll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = v[0];
    for(int i = 1; i < N; i++){
        ans = (ans + v[i]) / 2.0;
    }
    printf("%10.10f\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define ll long long
#define Maxn 3005
int n,mo;
ll C[Maxn][Maxn],g[Maxn][Maxn];
ll mi(ll x,ll y,ll mo)
{
	ll ans=1;
	while (y)
	{
		if (y&1) ans=ans*x%mo;
		x=x*x%mo;
		y>>=1;
	}
	return ans;
}
void pre()
{
	C[0][0]=g[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		C[i][0]=g[i][0]=1;
		for (int j=1;j<=i;j++)
		{
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
			g[i][j]=(g[i-1][j-1]+g[i-1][j]*(j+1)%mo)%mo;
		}
	}
}
int main()
{
	scanf("%d%d",&n,&mo);pre();
	ll ans=0,now=1;
	for (int i=0;i<=n;i++)
	{
		ll x=0,y=1,X=mi(2,n-i,mo);
		for (int j=0;j<=i;j++)
		{
			x=(x+g[i][j]*y%mo)%mo;
			y=y*X%mo;
		}
		ans=(ans+x*C[n][i]*now%mo*mi(2,mi(2,n-i,mo-1),mo)%mo)%mo;
		now=-now;
	}
	printf("%lld\n",(ans+mo)%mo);
	return 0;
}


Measured memory_bytes: 139520
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
string s;

int main(){
	cin>>n>>s;
	int t=0;
	for(int i=0;i<n;i++) if(s.substr(i,3)=="ABC") t++;
	cout<<t<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    string n;
    cin>>n;
    bool ja=true;
    for(int i=1; i<n.size(); i++)
    {
        if(n[i]!='9')
            ja=false;
    }
    if(ja)
    {
        cout<<(n.size()-1)*9+n[0]-'0'<<endl;
        return 0;
    }
    cout<<(n.size()-1)*9+n[0]-'0'-1<<endl;
}


Measured memory_bytes: 3636
Scanf.scanf "%d %d %d" (fun rr cc k ->
    let mat = Array.make_matrix rr cc 0 in
    for i = 1 to k do
        Scanf.scanf " %d %d %d" (fun rr cc v ->
            mat.(rr - 1).(cc - 1) <- v
        )
    done;

    let dp = Array.init rr (fun _ -> Array.init cc (fun _ -> Array.make 5 0)) in
    dp.(0).(0).(1) <- mat.(0).(0);
    for y = 0 to rr - 1 do
        for x = 0 to cc - 1 do
            for c = 0 to 3 do
                let v = mat.(y).(x) in
                if c = 0 || v = 0 then (
                    let q = if y > 0 then dp.(y - 1).(x).(4) else 0 in
                    let q = max q (if x > 0 then dp.(y).(x - 1).(c) else 0) in
                    dp.(y).(x).(c) <- max dp.(y).(x).(c) q
                ) else (
                    let q =        if y > 0 then max dp.(y - 1).(x).(4) (dp.(y - 1).(x).(4) + v) else 0 in
                    let q = max q (if x > 0 then max dp.(y).(x - 1).(c) (dp.(y).(x - 1).(c - 1) + v) else 0) in
                    dp.(y).(x).(c) <- max dp.(y).(x).(c) q
                )
            done
        done;
        for x = 0 to cc - 1 do
            dp.(y).(x).(4) <- Array.fold_left max 0 dp.(y).(x)
        done
    done;
    Printf.printf "%d\n" (dp.(rr - 1).(cc - 1).(4))
)

Measured memory_bytes: 572668
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

typedef unsigned long long ll;

ll p[55], nlen[55];

ll solve(ll n, ll x)
{
    if(x <= n) return 0;
    if(x >= nlen[n] - 1) return p[n];
    if(x == nlen[n] / 2 + 1) return (p[n] / 2 + 1);
    else if(x < nlen[n] / 2 + 1)
        return solve(n - 1, x - 1);
    else
        return p[n] / 2 + 1 + solve(n - 1, x - nlen[n] / 2 - 1);
}

int main()
{
    for(int i = 0; i <= 50; ++i)
    {
        p[i] = pow(2, i + 1) - 1;
        nlen[i] = pow(2, i - 1) * 8 - 3;
    }
    ll n, x;
    cin>>n>>x;
    cout<<solve(n, x)<<endl;
    return 0;
}

Measured memory_bytes: 256
a = b = c = 0
while 1:
    l = sorted(map(int, raw_input().split()))
    if l[0] + l[1] <= l[2]:
        print a+b+c, a, b, c
        break
    if l[0]**2 + l[1]**2 == l[2]**2: a+=1
    elif l[0]**2 + l[1]**2 > l[2]**2: b+=1
    else: c+=1

Measured memory_bytes: 6452
import itertools
import sys

def readline():
    return sys.stdin.readline()

def read_int_list():
    return list(map(int, readline().split()))

def read_int():
    return int(readline())

def main():
    N, M, R = read_int_list()

    r = [a-1 for a in read_int_list()]

    d = [[float('inf')]*N for _ in range(N)]

    for _ in range(M):
        a, b, c = read_int_list()
        d[a-1][b-1] = c
        d[b-1][a-1] = c

    for a in range(N):
        d[a][a] = 0

    res = float('inf')

    for k in range(N):
        for i in range(N):
            for j in range(N):
                dd = d[i][k]+d[k][j]
                if dd < d[i][j]:
                    d[i][j] = min(d[i][j], dd)

    for perm in itertools.permutations(r):
        a = 0
        for i in range(len(perm)-1):
            a += d[perm[i]][perm[i+1]]
        res = min(a, res)

    print(res)

if __name__ == '__main__':
    main()


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

int main()
{ 
  int64_t a, b, x ;
  cin >> a >> b >> x ;

  int64_t answer = 0 ;
  if(a == 0) //0もカウントに含まれるため
  {
    answer += 1 ;
  }

  int64_t calcu = 0 ;
  if(a != 0)
  {
    calcu = (a - 1) / x ;
  }
  answer += b / x ;


  cout << answer - calcu << endl ;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int calc_min(int pos, int K, int* h, int* c)
{
    int range = K;
    if (pos <= K) {
        range = pos -1;
    }

    int cost[range + 1] = {0};
    for (int i = 1; i <= range; ++i) {
        cost[i] = c[pos-i] + std::abs(h[pos-i] - h[pos]);
    }

    return *(std::min_element(cost + 1, cost + range + 1));
}

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

    int h[N+1] = {0};
    for (int i = 1; i <= N; ++i) {
        std::cin >> h[i];
    }

    int c[N+1] = {0};

    for (int i = 1; i <= N; ++i) {
        if (i == 1) {
            c[i] = 0;
        } else if (i == 2) {
            c[i] = std::abs(h[i-1] - h[i]);
        } else {
            c[i] = calc_min(i, K, h, c);
        }
    }

    std::cout << c[N] << std::endl;


    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main(){
    long long int k;
    cin>>k;
    long long int m=k;
    int ans=0;
    while(k>0){
        ans+=k%10;
        k/=10;
    }
    if(m%ans==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
### constant

W = 4
H = 5
WH = W * H

NBRS = [[1, 0], [-1, 1], [0, 1], [1, 1]]

### subroutines

def min_cards(cards)
  cl = cards.length
  return 0 if cl == 0

  min_c = cl

  for y0 in (0...H)
    for x0 in (0...W)
      id0 = y0 * W + x0
      break if id0 >= cl

      crd0 = cards[id0]

      for nbr in NBRS
        x1 = x0 + nbr[0]
        y1 = y0 + nbr[1]
        next if x1 < 0 || x1 >= W || y1 >= H

        id1 = y1 * W + x1
        break if id1 >= cl

        crd1 = cards[id1]
        next if crd0 != crd1

        cards.delete_at(id1)
        cards.delete_at(id0)

        c = min_cards(cards)
        return 0 if c == 0

        cards.insert(id0, crd0)
        cards.insert(id1, crd1)

        min_c = c if min_c > c
      end
    end
  end

  min_c
end

### main

n = gets.to_i

n.times do
  cards = []
  H.times do
    cards += gets.split.map(&:to_i)
  end
  #p cards

  min_c = min_cards(cards)
  puts min_c
end

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e9+7;
int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n+1, 0);
    rep(i, n) cin >> a[i+1];
    int cnt = 0;
    for ( int i = n; i >= 1; --i ) {
        int sum = 0;
        int j = i + i;
        while(1) {
            if ( j > n ) break;
            sum ^=b[j];
            j += i;
        }
//        for ( int j = i + i; j <= n; j+= i) {
//            sum ^= b[j];
//        }
        b[i] = sum^a[i];
    }
//        cout << i << " " << tmp_sum << endl;
//        if (  (tmp_sum & 1) && a[i-1] == 0 ) b[i-1] = 1, ++cnt;
//        if ( !(tmp_sum & 1) && a[i-1] == 0 ) b[i-1] = 0;
//        if (  (tmp_sum & 1) && a[i-1] == 1 ) b[i-1] = 0;
//        if ( !(tmp_sum & 1) && a[i-1] == 1 ) b[i-1] = 1, ++cnt;
//    }
//    cout << cnt << endl;
    vector<int> ans;
    for ( int i = 1; i <= n; i++ ) {
        if ( b[i] ) ans.push_back(i);
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) printf("%d ", ans[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if(k <= a) a -= k;
    else b = max(0ll, b - (k-a)), a = 0;
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
# all_split("abc") -> [['abc'], ['ab', 'c'], ['a', 'bc'], ['a', 'b', 'c']]
def all_split(s):
    if len(s) == 1:
        return [s]
    
    ans = []
    for i in range(2 ** (len(s) - 1)):
        b = list(map(int, format(i, "0" + str(len(s) - 1) + "b")))
        ans.append(split(s, b))
    return ans


def split(s, split_positions):
    assert len(s) - 1 == len(split_positions)

    ans = []
    pre = 0
    for i, is_split in enumerate(split_positions, start=1):
        if is_split:
            ans.append(s[pre:i])
            pre = i

    ans.append(s[pre:])
    return ans


def main():
    s = input()
    ans = 0
    for a in all_split(s):
        ans += eval("+".join(a))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1e9+7;

int main(){

	int h;
	cin>>h;

	int n;
	cin>>n;

	int sum = 0;

	for(int i = 0; i < n; i++)
	{
		int m;
		cin>>m;
		sum+=m;
	}

	if(sum >= h)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;


void array_show(int *a,int n){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?' ':'\n'));
}
void array_show(LL *a,int n){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?' ':'\n'));
}

int t[100005][3];
LL s[100005][2];
vector<P> v1;
priority_queue<int> q1;

int main(){
	int x,y,z,n;
	LL a,b,c;
	int i,j,k;
	cin>>x>>y>>z;
	n=x+y+z;
	for(i=0;i<n;i++){
		cin>>t[i][0]>>t[i][1]>>t[i][2];
		v1.push_back(make_pair(t[i][1]-t[i][0],i));
	}
	sort(v1.begin(),v1.end());
	for(i=0,a=0;i<x;i++){
		j=v1[i].second;
		q1.push(t[j][2]-t[j][0]);
		a+=t[j][0];
	}
	s[x][0]=a;
	for(i=x;i<x+z;i++){
		j=v1[i].second;
		b=q1.top(),c=t[j][2]-t[j][0];
		a+=t[j][2];
		if(b>c){
			a+=b-c,q1.pop();
			q1.push(c);
		}
		s[i+1][0]=a;
	}
	while(!q1.empty())q1.pop();
	for(i=n-1,a=0;i>=x+z;i--){
		j=v1[i].second;
		q1.push(t[j][2]-t[j][1]);
		a+=t[j][1];
	}
	s[x+z][1]=a;
	for(i=x+z-1;i>=x;i--){
		j=v1[i].second;
		b=q1.top(),c=t[j][2]-t[j][1];
		a+=t[j][2];
		if(b>c){
			a+=b-c,q1.pop();
			q1.push(c);
		}
		s[i][1]=a;
	}
	for(a=0,i=x;i<=x+z;i++){
		a=max(a,s[i][0]+s[i][1]);
	}
	cout<<a<<endl;
	return 0;
}


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

int main()
{
        ll N; cin >> N;
        vector<ll> a(N, 0);
        ll base = 0;
        rep(i, N) {
                cin >> a[i];
                base = base ^ a[i];
        }
        vector<ll> b(N, 0);
        rep(i, N) {
                b[i] = base ^ a[i];
        }
        rep(i, N) {
                cout << b[i] << " ";
        }
        cout << endl;
}


Measured memory_bytes: 6424
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) ((abs(a-b)<EPS))
const int INF=100000000;

int main(){

	int n;
	while(cin>>n&&n!=0){
		double reasonableBMI=INF;
		int bnum;
		for(int i = 0; i < n; i++){
			int n,w;
			double h;
			cin>>n>>h>>w;
			h/=100;
			double bmi=(double)w/(h*h);

			if(( abs(bmi-22)<abs(reasonableBMI-22))||(EQ(reasonableBMI,INF)) ){
				reasonableBMI=bmi;
				bnum=n;
			}
			else if(EQ(reasonableBMI,bmi)){
				if(bnum>n)
					bnum=n;
			}
		}
		cout<<bnum<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MAXN 100010
int n, head[MAXN], to[MAXN << 1], next[MAXN << 1], tot = 0;
inline void $(int u, int v) {
	next[tot] = head[u], to[tot] = v, head[u] = tot++;
	next[tot] = head[v], to[tot] = u, head[v] = tot++;
}
int sg[MAXN];
void dp(int x, int fa) {
	sg[x] = 0;
	for (int i = head[x]; ~i; i = next[i]) {
		if (to[i] == fa) continue;
		dp(to[i], x);
		sg[x] ^= sg[to[i]] + 1;
	}
}
int main() {
	scanf("%d", &n);
	memset(head, -1, sizeof(head));
	for (int i = 1, u, v; i < n; i++) scanf("%d%d", &u, &v), $(u, v);
	dp(1, 0);
	puts(sg[1] ? "Alice" : "Bob");
	return 0;
}

Measured memory_bytes: 7168
#include <cstdio>
#include <iostream>
#include <cstring>
#define Int register int
using namespace std;
typedef long long LL;

static inline char Get_Char() {
	static char buffer[100000], *S = buffer, *T = buffer;
	if (S == T) {
		T = (S = buffer) + fread(buffer, 1, 100000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}

//#define Get_Char() getchar()

static inline int Read() {
	int f = 1, x = 0;
	register char sign = Get_Char();
	for (; sign > '9' || sign < '0'; sign = Get_Char())
		if (sign == '-') f = -1;
	for (; sign >= '0' && sign <= '9'; sign = Get_Char())
		x = (x << 3) + (x << 1) + (sign ^ 48);
	return x * f;
}
/*
issiii
issiii

2
*/
int main() {
	string s;
	cin >> s;
	LL K, Ans = 0;
	scanf("%lld", &K); 
	int len = s.length(), First, Second, g;
	for (g = 0; g < len - 1; ++ g) {
		if (s[g] != s[g + 1])
			break;
	}
	if (g == len - 1) {
		printf("%lld\n", len * K >> 1);
		return 0;
	}
	if (s[0] == s[len - 1]) {
		int j = 0;
		while(s[j] == s[j + 1] && j < len) ++ j;
		First = j + 1;
	} 
	if (s[0] == s[len - 1]) {
		int j = len - 1;
		while (s[j] == s[j - 1] && j >= 1) -- j;
		Second = len - 1 - j + 1;
	}
	
	//printf("%d %d\n", First, Second);
	int Const = 0;
	if (First & 1 == 0 && Second & 1 == 0) --Const;
	if (First & 1 == 1 && Second & 1 == 1) ++Const; 
	for (Int i = 0; i < len - 1; ++ i) {
		int Rec = i; 
	 	while (s[i] == s[i + 1] && i < len - 1) {
	 		++i; 
		} 
		int val = i - Rec + 1;
		Ans += val >> 1;
	}
	
	printf("%lld", Ans * K + (K - 1) * Const);
	return 0;
}
/*
aaaa
56
*/

Measured memory_bytes: 256
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

const int N = 3050, MOD = 998244353;

int n, s, a[N], g[N][N], h[N][N];

int ta[N], tb[N];
inline void update(int &a, int b) {
    a = (a + b)% MOD;
}

int main(int argc, char const *argv[]) {
    // code
    scanf("%d%d", &n, &s);
    for (int i=1; i<=n; ++i) {
        scanf("%d", &a[i]);
        // dp[i][0] = 1;
    }
    h[0][0] = g[0][0] = 1;
    for (int i=1; i<=n; ++i) {
        for (int j=0; j<=s; ++j) {
            update(h[i][j], h[i-1][j]);
            if (j > a[i])
                update(h[i][j], h[i-1][j-a[i]]);
        }
        update(h[i][a[i]], i);
        for (int j=0; j<=s; ++j) {
            update(g[i][j], g[i-1][j]);
            update(g[i][j], h[i][j]);
        }
    }


    cout << g[n][s] << endl;
    return 0;
}


Measured memory_bytes: 72320
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> p;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    std::vector<int> a;
    int fcount = 0;
    int bcount = 0;
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        a.pb(temp);
        if (temp % 4 == 0) {
            fcount++;
        } else if (temp % 2 == 0) {
            bcount++;
        }
    }
    if (n / 2 <= fcount + bcount / 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}

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

const int MOD = 1e9 + 7;

#define debug(x) cerr << "> " << #x << "\n" << x << endl;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
  s << "{" << endl;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    s << "\t" << (*itr).first << " : " << (*itr).second << endl;
  }
  s << "}" << endl;
  return s;
}

int main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<int> fiv(9);
  fiv[0] = 1;
  fiv[1] = 1;
  for (int i = 2; i <= 8; i++) {
    fiv[i] = fiv[i - 1] + fiv[i - 2];
  }

  vector<vector<ll>> dp(H + 1, vector<ll>(W, 0));
  dp[0][0] = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      dp[i + 1][j] += dp[i][j] * fiv[j] * fiv[W - j - 1];
      if (j > 0) {
        dp[i + 1][j] += dp[i][j - 1] * fiv[j - 1] * fiv[W - j - 1];
      }
      if (j < W - 1) {
        dp[i + 1][j] += dp[i][j + 1] * fiv[j] * fiv[W - j - 2];
      }
      dp[i + 1][j] %= MOD;
    }
  }
  cout << dp[H][K - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    while(1)
    {
        int H,W;
        cin>>H>>W;
        if(H==0&&W==0) break;
        
        int s;
        for(s=0;s<H;s++)
        {
            if(s%2==0)
            {
                int t;
                for(t=0;t<W;t++)
                {
                    if(t%2==0)
                    {
                        cout<<"#";
                    }
                    else
                    {
                        cout<<".";
                    }
                }
                cout<<endl;
            }
            
            else
            {
                int t;
                for(t=0;t<W;t++)
                {
                    if(t%2==0)
                    {
                        cout<<".";
                    }
                    else
                    {
                        cout<<"#";
                    }
                }
                cout<<endl;
            }

        }
        cout<<endl;
    }
}


Measured memory_bytes: 3080
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	h := make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	sort.Ints(h)

	d := n - k
	if d < 1 {
		d = 0
	}
	ans := 0
	for _, i := range h[:d] {
		ans += i
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6912
#include <iostream>

using namespace std;

int main() {
  long long n, k;
  cin >> n >> k;

  long long a = n / k;
  long long b = (n + (k / 2)) / k;

  if (k & 1) {
    cout << a * a * a << endl;
  } else {
    cout << a * a * a + b * b * b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define resort(v) sort((v).rbegin(), (v).rend())
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
//const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

/*signed*/int main(void) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a != c)puts("1");
    else puts("0");
}

Measured memory_bytes: 3616
n=int(input())
a=list(map(int,input().split()))
aa=[a[i-1]-i for i in range(1,n+1)]


aaa=sorted(aa)
if len(aaa)%2==0:
    m1=aaa[len(aaa)//2]
    m2=aaa[len(aaa)//2-1]
else:
    m1=aaa[len(aaa)//2]
    m2=m1
ans1,ans2=0,0
for i in aa:
    ans1+=abs(i-m1)
    ans2+=abs(i-m2)
print(min(ans1,ans2))

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

int main(void){
	int N,M,result=0;
	string S;
	map<string,int> mpB,mpR;
	
	cin>>N;
	REP(i,N){
		cin>>S; mpB[S]++;
	}
	cin>>M;
	REP(i,M){
		cin>>S; mpR[S]++;
	}
	for(auto itr=mpB.begin();itr!=mpB.end();itr++){
		int tem=itr->second-mpR[itr->first];
		chmax(result,tem);
	}
	print(result);
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
int end,k;
char s[100];
void solve(int end){
	char v='a';
	rep(i,1,end-1)if(v<s[i])v=s[i];
	rep(i,0,v-'a'+1){
		s[end]='a'+i;
		if(end==k)pf("%s\n",s+1);
		else solve(end+1);
	}
}
int main(){
	sc(k);
	s[1]='a';
	if(k==1){
		pf("%s\n",s+1);return 0;
	}
	solve(2);
}

Measured memory_bytes: 1536
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  vector<int> C(N);
  for(int i = 0; i < N; ++i) cin >> C[i];
  int c_max = *max_element(C.begin(), C.end());
  vector<vector<int>> I(c_max+1);
  for(int i = 0; i < N; ++i){
    I[C[i]].push_back(i);
  }
  vector<long long> dp(N+1,0);
  dp[0] = 1;
  for(int i = 0; i < N; ++i){
    dp[i+1] += dp[i];
    dp[i+1] %= mod;
    int idx = lower_bound(I[C[i]].begin(), I[C[i]].end(), i+1)-I[C[i]].begin();
    if(idx == (int)I[C[i]].size() or I[C[i]][idx] == i+1) continue;
    dp[I[C[i]][idx]] += dp[i];
    dp[I[C[i]][idx]] %= mod;
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> t(n), a(n);
    rep(i, 0, n) cin >> t[i];
    rep(i, 0, n) cin >> a[i];
    vector<int> dt(n, -1), da(n, -1);
    int now = -1;
    bool f = true;
    rep(i, 0, n){
        if(now != t[i]){
            if(t[i] < now) f = false;
            dt[i] = t[i];
            now = t[i];
        }
    }
    now = -1;
    repb(i, n - 1, 0){
        if(now != a[i]){
            if(a[i] < now) f = false;
            da[i] = a[i];
            now = a[i];
        }
    }
    if(t[n - 1] != a[0]) f = false;
    int ans = 1;
    rep(i, 0, n){
        if(da[i] != -1 && dt[i] != -1){
            if(da[i] != dt[i]) f = false;
        }else if(da[i] != -1){
            if(t[i] < a[i]) f = false;
        }else if(dt[i] != -1){
            if(a[i] < t[i]) f = false;
        }else{
            ans = (ans * min(t[i], a[i])) % mod;
        }
    }
    if(f == false) cout << 0 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;

  a--;
  b--;
  c--;
  d--;

  s += "aaaa";

  FOR(i, a, c) {
    if (s[i] == '#' && s[i + 1] == '#') return print("No"), 0;
  }
  FOR(i, b, d) {
    if (s[i] == '#' && s[i + 1] == '#') return print("No"), 0;
  }

  if (c > d) {
    bool ok = false;
    FOR(i, b, d + 1) {
      if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') ok = true;
    }
    print((ok ? "Yes" : "No"));
    return 0;
  }
  print("Yes");
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    ll n, x;
    cin >> n >> x;
    // レベル L バーガーの層枚数, パティ枚数
    vector<ll> sum(51), p(51);
    sum[0] = 1;
    p[0] = 1;
    for (int i = 1; i <= 50; i++)
    {
        sum[i] = sum[i - 1] * 2 + 3;
        p[i] = p[i - 1] * 2 + 1;
    }
    ll res = 0;
    int level = n;
    while (x)
    {
        if (level == 1)
        {
            if (x == 5)
                res += 3;
            else if (x != 1)
                res += x - 1;
            break;
        }
        if (x >= sum[level] - 1)
        {
            res += p[level - 1] * 2 + 1;
            break;
        }
        if (x >= sum[level - 1] + 2)
        {
            res += p[level - 1];
            x -= sum[level - 1];
            res++;
            x -= 2;
            level--;
            continue;
        }
        if (x == sum[level - 1] + 1)
        {
            res += p[level - 1];
            break;
        }
        x--;
        level--;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        int K = nextInt();

        /*
        int R = nextInt();
        int S = nextInt();
        int P = nextInt();
         */

        int[] score = {nextInt(), nextInt(), nextInt()};

        char[] T = next().toCharArray();

        char[] a = {'p', 'r', 's'};

        char[] janken = new char[N];

        long ten = 0;
        for(int i=0; i<N; i++){
            char me = a[b(T[i])];
            if(i<K){
                ten += score[b(me)];
            }else{
                char no = janken[i-K];
                if(me == no){
                    janken[i] = 'a';
                    continue;
                }
                ten += score[b(me)];
            }
            janken[i] = me;
        }
        println(ten);
    }

    static int b(char a){
        if(a == 'r'){
            return 0;
        }
        if(a == 's'){
            return 1;
        }
        if(a == 'p'){
            return 2;
        }
        return -1;
    }

    static int c(char a){
        if(a == 'p'){
            return 0;
        }
        if(a == 'r'){
            return 1;
        }
        if(a == 's'){
            return 2;
        }
        return -1;
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 26980
while True:
    a, op, b = map(str, input("").split())
    a = int(a)
    b = int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    elif op == "?":
        break

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

main(){
  int N;
  cin >> N;
  vector<int64_t> vec(N + 2);
  vec.at(0) = 2LL;
  vec.at(1) = 1LL;

  for(int i = 0; i < N ; i++){
    vec.at(i + 2) = vec.at(i + 1) + vec.at(i);
  }

  cout << vec.at(N) << endl;
}


Measured memory_bytes: 256
s=input()
if len(s)==2:
  if s[0]==s[1]:
    print(1,2)
  else:
    print(-1,-1)
else:
  for i,(a,b,c) in enumerate(zip(s,s[1:],s[2:])):
    tmp=set([a,b,c])
    if len(tmp)!=3:
      print(i+1,i+3)
      exit()
  print(-1,-1)


  
  
  


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  vector<vector<pair<int, bool>>> A(3, vector<pair<int, bool>>(3, make_pair(0, false)));

  cin >> A[0][0].first >> A[0][1].first >> A[0][2].first;
  cin >> A[1][0].first >> A[1][1].first >> A[1][2].first;
  cin >> A[2][0].first >> A[2][1].first >> A[2][2].first;
  int N;
  cin >> N;
  rep(i, N)
  {
    int b;
    cin >> b;
    rep(j, 3) rep(k, 3)
    {
      if (A[j][k].first == b)
        A[j][k].second = true;
    }
  }

  bool is_ok = false;
  rep(i, 3)
  {
    if (A[i][0].second && A[i][1].second && A[i][2].second)
      is_ok = true;
  }

  rep(i, 3)
  {
    if (A[0][i].second && A[1][i].second && A[2][i].second)
      is_ok = true;
  }
  if (A[0][0].second && A[1][1].second && A[2][2].second)
    is_ok = true;
  if (A[0][2].second && A[1][1].second && A[2][0].second)
    is_ok = true;

  if (is_ok)
  {
    printYes();
  }
  else
  {
    printNo();
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int r;
	long x, count = 0;

	scanf("%ld", &x);

	r = x % 11;
	if(r > 6)
		count = 2*(x / 11) + 2;
	else if(r > 0)
		count = 2*(x / 11) + 1;
	else
		count = 2*(x / 11);
	printf("%ld", count);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int N,M,K,A,num[40]={};
int main(){
  cin >> N >> M;
  for(int i=0;i<N;i++){
    cin >> K;
    for(int j=0;j<K;j++){
      cin >> A;
      num[A]++;
    }
  }
  int ans=0;
  for(int i=0;i<40;i++){
    if(num[i]==N) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

void solve(void)
{
	int a, b;
	cin >> a >> b;
	if ((a-b)%2 == 0)
	{
		cout << (a + b) / 2 << endl;
	}
	else
	{
		cout << "IMPOSSIBLE\n";
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

int main() {
  long n, m;
  pair<long, long> a[110000];
  cin >> n >> m;
  for(int i = 0; i < n; i++)
    cin >> a[i].first >> a[i].second;
  
  sort(a, a+n);

  long sum = 0;
  for(int i = 0; i < n; i++) {
    if(m >= a[i].second) {
      sum += a[i].first * a[i].second;
      m -= a[i].second;
      if(m == 0) break;
    }
    else {
      sum += a[i].first * m;
      break;
    }
  }
  cout << sum << endl;
}

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

int main() {
  int x;
  rep(i, 5){
    cin >> x;
    if(x == 0){
      cout << i+1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MAX (ll)(8e1 + 7)
#define INF (ll)(1e18)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;

int main () {
	int n = 5, ans;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (!x) {
			ans = i + 1;
		}
	}	
	cout << ans << "\n";
}


Measured memory_bytes: 3580
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Change a Little Bit
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

int cs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) scanf("%d", cs + i);
  sort(cs, cs + n, greater<int>());

  int sum = 0;
  for (int i = 0; i < n; i++)
    sum = (sum + (ll)cs[i] * (i + 2) % MOD) % MOD;

  for (int i = 1; i < n; i++)
    sum = (ll)sum * 4 % MOD;

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 1024
def minkowski_dist(x, y, pn)
	n = x.length
	z = Array.new(n)
	for i in 0..n-1
		z[i] = (x[i] - y[i]).abs()
	end
	case pn
	when 0 
		return z.max
	else 
		return (z.reduce(0.0){|sum, zi| sum += zi**pn}) ** (1/pn.to_f)
	end
end

n = gets.to_i
x = gets.strip.split(" ").map{|i| i.to_f}
y = gets.strip.split(" ").map{|i| i.to_f}

for pn in 1..3
	puts minkowski_dist(x, y, pn)
end
puts minkowski_dist(x, y, 0).floor(5)


Measured memory_bytes: 6944
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;

int res(vector<int> v, int n){
    int ress =0;
    for(int i = 0; i< n; i++){
        ress += v[i];
    }
    return ress;
}

int main()
{
    int n;
    cin >> n;
    //int res = 0;
    vector<int> v(n,0);
    for(int i = 0; i< n; i++)
    {
        int l,r;
        cin >> l >> r;
        v[i] = r-l+1;
        //res += r-l+1;
    }

    //cout << accumulate(v.begin(), v.end(), 0) << endl;
    cout << res(v,n) << endl;
}


Measured memory_bytes: 256
a = gets.to_i

b = []
jpy = 0
btc = 0
a.times.each do |i|
  b << gets.split(" ").map(&:to_s)

  if b[i][1] == 'JPY'
    jpy += b[i][0].to_i
  else
    btc += b[i][0].to_f
  end
end

#puts btc * 380000.0.to_i

puts "#{jpy + btc * 380000.0.to_i}"

Measured memory_bytes: 1788
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------


int main()
{
	boost
	ll x,a;
  	cin>>x>>a;
  	if(x<a)
      cout<<0<<endl;
  	else
      cout<<10<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	
	int ans = a[0] + a[1] + a[2] - *max_element(a,a+3);
	
	cout << ans;

	return 0;
}



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

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

    int a,b,ans[3],max = -1000000;
    cin >> a >> b;

    ans[0] = a + b;
    ans[1] = a - b;
    ans[2] = a * b;

    rep(i,3){
        if(max < ans[i]){
            max = ans[i];
        }
    }

    cout << max << endl;

    return 0;
}

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

#define int long long
#define pii pair<int,int>
int res;

signed main(){
  int n,ans;
  cin >> n;

  vector<int> v(n);
  for(auto &i:v)cin >> i;
for(int i = 0;i<n;i++){
    v[i]-=(i+1);
}
  sort(v.begin(), v.end());
    
    if(n%2){
        ans = v[n/2];
    }
    else ans = (v[n/2]+v[n/2-1])/2;

    for(int i = 0;i<n;i++){
        res+=abs(v[i]-ans);
    }

  cout << res << endl;
  return 0;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

//Write From this Line

int main()
{
	ll a, b, c, d; 
	cin >>  a>> b>> c>> d; 
	ll all = b - a + 1 ;
	a--;
	all -= (b / c - a / c );
	all -= (b / d - a / d );
	ll G = c /__gcd(c,d) * d ;
	all +=( b / G - a / G );
	cout << all << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    long long n, k; cin >> n >> k;
    vector<long long> a(n);
    for(long long i=0; i<n; i++) cin >> a[i];

    // 0;自分が負け　1;自分が勝ち
    vector<long long> dp(k+1, 0); dp[0] = 0;
    for(long long i=0; i<=k; i++){
        for(long long j=0; j<n; j++){
            // i個の状態からa[j]個取って負けに遷移させれるなら勝ち
            long long tmp = i-a[j];
            if(tmp < 0) break;
            if(dp[tmp] == 0) dp[i] = 1;
        }
    }
    cout << ((dp[k] == 1) ? "First" : "Second") << endl;
}

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

int main() {
    int n, q;
    cin >> n >> q;
    vector<vector<int>> a(n, vector<int>(0));
    for (int i = 0; i < q; ++i) {
        int t, d;
        cin >> t >> d;
        if (t == 0) {
            int x;
            cin >> x;
            a[d].push_back(x);
        } else if (t == 1) {
            for (int j = 0; j < a[d].size(); ++j) j == 0 ? cout << a[d][0] : cout << " " << a[d][j];
            cout << endl;
        } else a[d].clear();
    }
}



Measured memory_bytes: 5732
import numpy as np

N, M, C = map(int, input().split())
b_array = np.array([int(v) for v in input().split()]).reshape(1,-1)

a_array = np.array([int(v) for v in input().split()]).reshape(1, -1)
for n in range(N-1):
    a_add = np.array([int(v) for v in input().split()]).reshape(1, -1)
    a_array = np.concatenate((a_array, a_add), axis=0)
    
ab_array = (a_array * b_array).sum(axis=1) + C

print(np.sum(ab_array>0))

Measured memory_bytes: 12440
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            String[] nums = line.split(" ");
            Integer num1 = Integer.parseInt(nums[0]);
            Integer num2 = Integer.parseInt(nums[1]);
            System.out.println(num1 + num2);
        }
    }
}

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

int main() {
  int i,N;
  cin >> N;
  
  for (i=0;i<N;i++){
    int l,r,a;
    cin >> l >> r;
    a += r-l+1;
      if (i==N-1){
        cout << a << endl;
  }
}
}

Measured memory_bytes: 256
#include<stdio.h>

static const int N = 100;
void bubbleSort(int [], int);
void swap(int *, int *);

main(){
  int i, n;
  int A[N + 1];
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  bubbleSort(A, n);
  return 0;
}

void bubbleSort(int A[], int n){
  int i, j, count = 0;
  
  for(i = 0; i < n; i++){
    for(j = n - 1; j > i; j--){
      if (A[j] < A[j - 1]){
	swap(&A[j], &A[j - 1]);
	count++;
      }
    }
  }
  
  for(i = 0; i < n; i++){
    printf("%d", A[i]);
    if(i != n - 1) printf(" ");
  }
  
  printf("\n");
  printf("%d\n", count);
}

void swap(int *p, int *q){
  int swap;
  swap = *p;
  *p = *q;
  *q = swap;
}

Measured memory_bytes: 604