akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define SIZE 110

int a[SIZE][SIZE], cnt[27] = {0};
int main() {
   int h, w;
   cin >> h >> w;
   for (int i = 0 ; i < h ; ++i) {
      for (int j = 0 ; j < w ; ++j) {
         char c;
         cin >> c;
         ++cnt[c - 'a'];
      }
   }

   int mod4 = 0, mod2 = 0, odd = 0;
   for (int i = 0 ; i < 26 ; ++i) {
      if (cnt[i] % 4 == 0) ++mod4;
      else if (cnt[i] % 4 >= 2) ++mod2;
      else if (cnt[i] % 2) ++odd;
   }

   if ((h % 2) && (w % 2)) {
      if (odd != 1 || mod2 > (h / 2 + w / 2) || (h / 2 + w / 2 - mod2) % 2) cout << "No" << endl;
      else cout << "Yes" << endl; 
   }
   else if (w % 2) {
      if (odd != 0 || mod2 > h / 2 || (h / 2 - mod2) % 2) cout << "No" << endl;
      else cout << "Yes" << endl; 
   }
   else if (h % 2) { 
      if (odd != 0 || mod2 > w / 2 || (w / 2 - mod2) % 2) cout << "No" << endl;
      else cout << "Yes" << endl; 
   }
   else {
      if (odd != 0 || mod2 != 0) cout << "No" << endl;
      else cout << "Yes" << endl;
   }
   return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  int H,W; cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  rep(i,H) rep(j,W) cin >> a[i][j];

  vector<int> ch(26);
  rep(i,H) rep(j,W) ch[a[i][j] - 'a']++;

  vector<int> count(4);
  rep(i,26) count[ch[i] % 4]++;

  bool flag = true;
  if (H % 2 == 0 && W % 2 == 0) {
    for (int i = 1; i < 4;i++) if (count[i] != 0) flag = false;
  } else if (H % 2 == 1 && W % 2 == 1) {
    if (count[1] + count[3] != 1) flag = false;
    else if (count[2] > H / 2 + W / 2) flag = false;
  } else if (H % 2 == 1 && W % 2 == 0) {
    if (count[1] != 0 || count[3] != 0) flag = false;
    else if (count[2] > W / 2) flag = false;
  } else if (H % 2 == 0 && W % 2 == 1) {
    if (count[1] != 0 || count[3] != 0) flag = false;
    else if (count[2] > H / 2) flag = false;
  }

  cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  vector<int >h(n,0);
  for(int i=0;i<n;i++)cin>>h[i];
  int maxi=1,curr=1;
  for(int i=1;i<n;i++){
  	if(h[i]<=h[i-1])curr++;
    else{
    	maxi = max(maxi,curr);
      curr=1;
    }
  }
  maxi = max(maxi,curr);
  cout<<maxi-1;
}

Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
  sort(a, a+N);
}
template<class T1> void rsortA_L(int N, T1 a[], void *mem = wmem){
  sortA_L(N, a, mem);
  reverse(a, a+N);
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S divup_L(S a, T b){
  return (a+b-1)/b;
}
int N;
long long K;
int A[200000];
int F[200000];
int main(){
  wmem = memarr;
  long long res;
  long long r;
  long long nd;
  rd(N);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=(0);KL2GvlyY<(N);KL2GvlyY++){
      rd(F[KL2GvlyY]);
    }
  }
  sortA_L(N,A);
  rsortA_L(N,F);
  long long Q5VJL1cS;
  long long e98WHCEY;
  long long cTE1_r3A;
  Q5VJL1cS = 0;
  e98WHCEY = 1000000000000LL;
  while(Q5VJL1cS < e98WHCEY){
    int i;
    if((Q5VJL1cS + e98WHCEY)%2==0){
      cTE1_r3A = (Q5VJL1cS + e98WHCEY) / 2;
    }
    else{
      cTE1_r3A = (Q5VJL1cS + e98WHCEY - 1) / 2;
    }
    r = K;
    for(i=(0);i<(N);i++){
      nd = (long long) A[i] * F[i] - cTE1_r3A;
      if(nd > 0){
        r -=divup_L(nd,F[i]);
      }
    }
    if(r >= 0){
      e98WHCEY = cTE1_r3A;
    }
    else{
      Q5VJL1cS = cTE1_r3A + 1;
    }
  }
  res =e98WHCEY;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191027-1

// --- original code ---
// int N; ll K; int A[2d5], F[2d5];
// {
//   ll res, r, nd;
//   rd(N,K,A(N),F(N));
//   sortA(N,A);
//   rsortA(N,F);
//   res = bsearch_min[ll,x,0,1d12][
//     r = K;
//     rep(i,N){
//       nd = (ll) A[i] * F[i] - x;
//       if(nd > 0) r -= nd /+ F[i];
//     }
//   ](r >= 0);
//   wt(res);
// }


Measured memory_bytes: 1792
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


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

int main(){
    ll n,w;
    cin>>n>>w;
    ll A[n+1][2];
    for(ll i = 1; i <= n; i++){
        cin>>A[i][0]>>A[i][1];
    }
    ll dp[n+1][w+1];
    memset(dp,0,sizeof dp);
    for(ll i = 1; i <= n; i++){
        for(ll j = 0; j <= w; j++){
            if(j >= A[i][0]){
                dp[i][j] = max(dp[i-1][j],A[i][1] + dp[i-1][j-A[i][0]]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= w; i++){
        ans = max(ans,dp[n][i]);
    }
    cout<<ans;
    return 0;
}




//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
//ios::sync_with_stdio(0);cin.tie(0);


Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) A[i] = sc.nextInt();

		long x2 = 0;
		for (int i = 0; i < N; i++) {
			if(i % 2 == 0) x2 += A[i];
			else x2 -= A[i];
		}
		long[] ans = new long[N];
		ans[0] = x2 / 2;
		for (int i = 0; i < N - 1; i++) ans[i + 1] = A[i] - ans[i];
		for (int i = 0; i < N; i++) ans[i] *= 2;
		for (int i = 0; i < N; i++) System.out.println(ans[i] + " ");
	}
}

Measured memory_bytes: 73784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;


const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    long long X, Y; cin >> X >> Y;

    COMinit();

    long long X1, Y1, X2, Y2;
    X1 = Y1 = X2 = Y2 = 0;
    
    while(true)
    {
        ++X1; ++Y1;
        if(Y1 > Y || X1 > X)
        {
            cout << 0 << endl;
            return 0;
        }
        if(Y - Y1 + X - X1 == X1)
        {
            break;
        }
    }

    X2 = X - X1; X1 -= X2;
    Y2 = Y - Y1; Y1 -= Y2;
    long long ans = 0;

    //cout << X1 << " " << Y1 << " " << X2 << " " << Y2 << endl;

    ans = COM(X1 + X2, X1);

    cout << ans << endl;
}

Measured memory_bytes: 123172
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()
a = na()

print(n-sum(a) if n-sum(a) >= 0 else -1)

Measured memory_bytes: 9880
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

// s = "112223" -> [[1,2],[2,3],[3,1]]
vector<pair<int,int>> rle (vector<int> x) {
  vector<pair<int,int>> res;
  int n = (int)x.size();
  for (int i = 0; i < n;) {
    int j = i;
    int cnt = 0;
    while (j < n && x[j] == x[i]) {
      ++j;
      ++cnt;
    }
    //res.emplace_back(x[i], cnt);
    res.emplace_back(cnt, x[i]);
    i = j;
  }
  return res;
}

int main () {
  int n;
  cin >> n;
  vi v(n);
  rep(i,n) cin >> v[i];
  
  if (count(rng(v),v[0]) == v.size()) {
    cout << n/2 << endl;
    return 0;
  }

  vi ve, vo;
  rep(i,n) {
    if (i%2 == 0) ve.pb(v[i]);
    else vo.pb(v[i]); 
  }

  sort(ve.begin(), ve.end());
  sort(vo.begin(), vo.end());

  auto pe = rle(ve);
  auto po = rle(vo);

  sort(pe.rbegin(), pe.rend());
  sort(po.rbegin(), po.rend());

  int ne = pe[0].fi;
  int no = po[0].fi;

  if (pe[0].se == po[0].se) {
    if (pe[1].fi >= po[1].fi) ne = pe[1].fi;
    else no = po[1].fi;
  }

  int ans = n - (ne + no);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2424
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define For(i,m,n) for(int i=m;i<n;i++)
#define Forr(i,m,n) for(int i=m;i>n;i--)
#define Sort(a) sort(a.begin(),a.end())
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll>>
#define INF 999999999999

int main(){
  int N,R;
  cin>>N>>R;
  if(N>=10) cout<<R<<endl;
  else cout<<R+100*(10-N)<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{
 string a;
 int k;
 cin>>k>>a;
 if(a.size()<=k) {for(int i=0;i<a.size();i++) cout<<a[i];cout<<endl;return 0;}
 for(int i=0;i<k;i++) cout<<a[i];
 cout<<"..."<<endl;
 return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N, M;
    cin >> N >> M;
    vector<int> a;
    int tmp;
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        a.push_back(tmp);
        sum += tmp;
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int cnt = 0;
    for (int i = 0; i < M; i++)
    {
        if (a[i] * 4 * M >= sum)
        {
            cnt++;
        }
    }
    if (cnt == M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

int main() {
  int a, b, c, x, ans = 0;
  cin >> a >> b >> c >> x;
  for (int i = 0; i <= a; ++i) {
    for (int j = 0; j <= b; ++j) {
      for (int k = 0; k <= c; ++k) {
	if (500 * i + 100 * j + 50 * k == x) {
	  ans++;
	}
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}


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

int main(){
  long long n,m,ansn=1,ansm=1,o,p;
  cin>>n>>m;
  o=n;
  p=m;
  if(abs(n-m)>=2){
    cout<<0<<endl;
    return 0;
  }
  while(n){
    ansn*=n;
    ansn%=(1000000007);
    n--;
  }
  while(m){
    ansm*=m;
    ansm%=(1000000007);
    m--;
  }
  cout<<(o-p?((ansn*ansm)%(1000000007)):((ansn*ansm)*2)%(1000000007))<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <queue>

using namespace std;

const int N = 300000, M = 500000;

int d[N], used[N], S, T;
queue<int>Qe;

struct edge{
	edge *next,*other;
	int u,v,dis;
}e[M], *P=e, *point[N];

inline void add_edge(int x, int y, int dis)
{
	edge *Q = ++P;++P;
	P->u = x; P->v = y; P->next = point[x]; point[x]=P;
	Q->u = y; Q->v = x; Q->next = point[y]; point[y] = Q;
	P->dis = Q->dis = dis;
}

int SPFA()
{
	memset(d, 0x7f, sizeof(d));
	memset(used, 0, sizeof(used));
	
	Qe.push(S);
	used[S]=1; d[S]=0;
	
	while(!Qe.empty())
	{
		int x = Qe.front(); Qe.pop();
		used[x] = false;
		for(edge *j = point[x]; j; j=j->next)
		{
			if(d[x] + j->dis < d[j->v])
			{
				d[j->v] = d[x] + j->dis;
				if(!used[j->v])
				{
					used[j->v] = true; Qe.push(j->v);
				}
			}
		}
	}
	
	return d[T];
}

int n, s, t;

int main()
{
	int n,m,ts,te;
	scanf("%d%d", &n, &m);
	S = 1; T = n;
	for(int i = 1; i <= m; i++)
	{
		int a,b,c;scanf("%d%d", &a, &b);
		add_edge(a,b,1);
	}
	
	if(SPFA()==2)
		cout<<"POSSIBLE"<<endl;
	else
		cout<<"IMPOSSIBLE"<<endl;
}

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


const int maxn=200005;

vector<int>E[maxn];
int n,m;
ll d[maxn][3]; //dis ij，代表到第i个点的距离%3=j

void init()
{
   for(int i=0;i<maxn;i++)
    E[i].clear();
    for(int i=1;i<maxn;i++)
        for(int j=0;j<3;j++)
        d[i][j]=-3;  //让-3/3=-1

}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
        init();
        for(int i=0;i<m;i++)
        {
            int x,y;
            cin>>x>>y;
            E[x].push_back(y);
        }
        int s,t;
        cin>>s>>t;
       queue<pair<int,int>>q;
        d[s][0]=0;
        q.push({s,0});
        while(!q.empty())
        {
            int cx=q.front().first,cy=q.front().second,ny=(cy+1)%3;//+1是因为要到下一个点
            q.pop();
            for(int i=0;i<int(E[cx].size());i++)
            {
                int nx=E[cx][i];
                if(d[nx][ny]==-3)
                {
                    d[nx][ny]=d[cx][cy]+1;//在转回来cy就是ny
                    q.push({nx,ny});
                }
            }
        }
        if(d[t][0]==1e15)
            cout<<-1<<'\n';
        else
           {
              cout<<d[t][0]/3<<'\n';
           }

}


Measured memory_bytes: 12800
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 2010
#define MOD 1000000007
using namespace std;
typedef long long ll;
vector<int> fac;
int n;
ll k,sum[MAXN];
void get_fac(int x){
	for(int i=1;i*i<=x;i++)
		if(x%i==0){
			fac.push_back(i);
			if(i*i!=x)
				fac.push_back(x/i);
		}
	sort(fac.begin(),fac.end());
}
ll fsp(ll x,int y){
	ll res=1;
	while(y){
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;	
	}
	return res;
}
int main(){
	SF("%d%lld",&n,&k);
	get_fac(n);
	ll ans=0;
	for(int i=0;i<fac.size();i++){
		sum[i]=fsp(k,(fac[i]+1)/2);
		for(int j=0;j<i;j++){
			if(fac[i]%fac[j]==0){
				sum[i]-=sum[j];
				sum[i]%=MOD;
			}
		}
		if(fac[i]%2)
			(ans+=sum[i]*fac[i]%MOD)%=MOD;
		else
			(ans+=sum[i]*(fac[i]/2ll)%MOD)%=MOD;
	}
	PF("%lld",(ans+MOD)%MOD);
}

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

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define INF 10000000

typedef unsigned long long ll;
typedef pair<double, double> P;
typedef std::priority_queue<P, std::vector<P>, std::greater<P> > PrioQueue; //A->Z

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

void solve(void){
    ll cheaper[4];
    ll price;
    rep(4, i) {
        cin >> price;
        if (i == 0) cheaper[0] = price;
        else {
            cheaper[i] = min(cheaper[i-1]*2, price);
        }
    }
    //double -> Int
    ll N; cin >> N; N *= 4;
    ll ans = 0;
    rep(4, i) {
        ans += N / (ll)pow(2, (3-i)) * cheaper[3-i];
        N -= N / (ll)pow(2, (3-i)) * pow(2, (3-i));
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, M;
  vector<long long int> s_v;
  string S;
  cin >> S;

  for (int i = 0; i < S.size(); i++) {
    s_v.push_back(S[i] - '0');
  }
  long long int size = S.size();
  long long int cnt0 = 0, cnt1 = 0;
  for (int i = 0; i < size; i++) {
    switch(s_v[i]) {
    case 0:
      cnt0++;
      break;
    case 1:
      cnt1++;
      break;
    }
  }
  cout << min(cnt0,cnt1)*2 << endl;
  // for (int i = 0; i < M; i++) {
  //   cin >> a_v.at(i);
  // }
  // // f_n = f_{n-1} + f_{n-2}
  // // f_0 = 1
  // // f_1 = 1
  // // f_2 = 2
  // // f_3 = 3
  // long long int j = 0;
  // for (int i = 0; i <= N; i++) {
  //   if (a_v[j] == i) {
  //     j++;
  //   }
  //   else {
  //     if (i >= 2) {
  //       f[i] = (f[i-1] + f[i-2]) % 1000000007;
  //     }
  //     else if (i == 1) {
  //       f[i] = f[i-1] + 0;
  //     }
  //     else if (i == 0) {
  //       f[i] = 1;
  //     }
 
  //   }
  // }
  // for (int i = 0; i <= N; i++) {
  //   //cout << "f" << f[i] << endl;
  // }
  // //cout << "j:" << j << endl;
 
  // cout << f[N]%1000000007 << endl;
  return 0;
}


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

int main() 
{
	string s,ss;
	cin >> s >> ss;
	int a,b;
	cin >> a >> b;
	string ch;
	cin >> ch;
	if(ch==s)a--;
	else b--;
	cout << a <<" " << b <<endl;
    return 0;
}


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

// Description: ????????????
// Verifyed: various problem 
using namespace placeholders;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P c;R r;};

auto& operator >> (istream& is,P& p){ R x,y; is >> x >> y,p=P(x,y); return is;}
auto& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline P vec(L l){return l.t-l.s;}
auto sdot = bind(sgn,bind(dot,_1,_2,_3));
auto sdet = bind(sgn,bind(det,_1,_2,_3));

//projection verify AOJ CGL_1_A
P proj(L l,P p){ R u=real((p-l.s)/vec(l)); return (1-u)*l.s+u*l.t;}

P cross(L a,L b){
	R u=det(a.s,b.s,b.t)/det(0,vec(a),vec(b));
	return (1-u)*a.s+u*a.t;
}

// Polygon
#define at(a,i) (a[(i + a.size()) % a.size()])

R area(const VP& pol){
	R sum=0.0;
	rep(i,pol.size()) sum+=det(0,at(pol,i),at(pol,i+1));
	return abs(sum/2.0L);
}

// convex_cut 
// verified: AOJ CGL_4_C
VP convex_cut(const VP& pol,const L& l) {
	VP res;
	rep(i,pol.size()){
		P a = at(pol,i),b=at(pol,i+1);
		int da=sdet(l.s,l.t,a),db=sdet(l.s,l.t,b);
		if(da>=0) res.emplace_back(a);
		if(da*db<0) res.emplace_back(cross({a,b},l));
	}
	return res;
}

int main(void){
	int n,q;
	cin >> n;
	VP pol;
	rep(i,n){
		P p;
		cin >> p;
		pol.push_back(p); 
	}
	cin >> q;
	cout.precision(20);
	rep(i,q){
		P a,b;
		cin >> a >> b;
		L l={a,b};
		cout << fixed <<  area(convex_cut(pol,l)) << endl;
	}
	return 0;
}

Measured memory_bytes: 3252
# # ABC126D.py, ATC001A.py などを参照
import sys
sys.setrecursionlimit(1000000)
N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    edge[u-1].append([v-1, w])
    edge[v-1].append([u-1, w])


# 各頂点までの距離をdfsで求める
depth = [-1] * N
depth[0] = 0


def dfs(edge, s):
    for v in edge[s]:
        if depth[v[0]] == -1:  # 未訪問なら更新する
            depth[v[0]] = depth[s] + v[1]
            dfs(edge, v[0])


dfs(edge, 0)
for d in depth:
    if d % 2 == 0:
        print(0)
    else:
        print(1)


Measured memory_bytes: 88020
N = int(input())
p = [int(x) for x in input().split()]
n = [int(y) for y in range(1, N+1)]
ans = 'YES'
count = 0
for i in range(N):
    if p[i] == n[i]:
        pass
    else:
        if count <= 1:
            count +=1
        else:
            ans = 'NO'
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;

int main(void)
{
	int N;
	cin >> N;
	vector<int> A[N];
	vector<int> buka(N);
	rep(i,N) buka[i] = 0;
	int a;
	rep(i,N-1)
	{
		cin >> a;
		a--;
		buka[a]++;
	}
	rep(i,N) cout << buka[i] << endl;
	return 0;
}


Measured memory_bytes: 8776
# coding: utf-8
N, M = map(int, input().split())
l = {}
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if b != 0:
        if a not in l.keys():
            l[a] = [b]
        else:
            l[a].append(b)
for k1 in l[0]:
    if k1 not in l.keys():
        continue
    for k2 in l[k1]:
        if k2 == N - 1:
            print("POSSIBLE")
            exit()
print("IMPOSSIBLE")


Measured memory_bytes: 30672
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

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

int H, W, dat_h[2019][2019], dat_v[2019][2019];
string s[2019];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (j == 0) {
				if (s[i][j] == '#') dat_h[i][j] = 0;
				else dat_h[i][j] = 1;
			}
			else {
				if (s[i][j] == '#') dat_h[i][j] = 0;
				else dat_h[i][j] = 1 + dat_h[i][j - 1];
			}
		}
		bool flag = false;
		for (int j = W - 1; j >= 0; j--) {
			if (s[i][j] == '#') {
				flag = false;
				dat_h[i][j] = 0;
			}
			else {
				if (!flag) {
					flag = true;
				}
				else {
					dat_h[i][j] = dat_h[i][j + 1];
				}
			}
		}
	}
	for (int j = 0; j < W; j++) {
		for (int i = 0; i < H; i++) {
			if (i == 0) {
				if (s[i][j] == '#') dat_v[i][j] = 0;
				else dat_v[i][j] = 1;
			}
			else {
				if (s[i][j] == '#') dat_v[i][j] = 0;
				else dat_v[i][j] = 1 + dat_v[i - 1][j];
			}
		}
		bool flag = false;
		for (int i = H - 1; i >= 0; i--) {
			if (s[i][j] == '#') {
				flag = false;
				dat_v[i][j] = 0;
			}
			else {
				if (!flag) {
					flag = true;
				}
				else {
					dat_v[i][j] = dat_v[i + 1][j];
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			ans = max(ans, dat_h[i][j] + dat_v[i][j] - 1);
		}
	}
	cout << ans << "\n";
	//system("pause");
	return 0;
}

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

int main() {
    string s;
    ll k;
    cin >> s >> k;
    int n = s.size();

    ll ans = 0;
    if (all_of(s.begin(), s.end(), [s](char x) { return x == s[0]; }))
        ans = n * k / 2;
    else {
        ll cnt = 0;
        rep(i, n - 1) {
            if (s[i] == s[i + 1] && s[i] == s[i + 2])
                cnt++, i += 1;
            else if (s[i] == s[i + 1])
                cnt++;
        }
        ans = cnt * k;
        if (s[0] == s[n - 1]) {
            int a = 0, b = 0;
            rep(i, n) {
                if (s[0] == s[i])
                    a++;
                else
                    break;
            }
            for (int i = n - 1; i >= 0; i--) {
                if (s[n - 1] == s[i])
                    b++;
                else
                    break;
            }
            ans -= (a / 2 + b / 2 - (a + b) / 2) * (k - 1);
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = (int)4e6 + 3;
bitset<N> a;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int n;
	int S = 0;
	a.set(0);
	scanf("%d", &n);
	while(n--) {
		int x;
		scanf("%d", &x);
		S += x;
		a |= a << x;
	}
	S = (S + 1) / 2;
	for (int x = S;; x++) {
		if (a[x]) {
			printf("%d\n", x);
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 1664
s = input()
K = int(input())
list = ["zzz" for i in range(K)]
for i in range(len(s)):
    for j in range(len(s)-i):
        if j > 5:
            continue
        if len(list) < K or s[i : i+j+1] < list[K-1]:
            if not s[i : i+j+1] in list:
                list[K-1] = s[i : i+j+1]
                list.sort()
print(list[K - 1])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<17;



int main(){
    int a,b;
    cin >> a >> b;
    if(a*b%2) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int N, M;
	scanf("%d %d\n", &N, &M);
	int a[M], b[M];
	int count[N];

	char yomikomi[32];
	for(int i=0;i<M;i++){
		fgets(yomikomi, 32, stdin);
		int n = sscanf(yomikomi, "%d %d", &a[i], &b[i]);
		if(n != 2) printf("error\n");
	}

	for(int i=0;i<N;i++) count[i] = 0;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			if(a[j] == i+1 || b[j] == i+1) count[i] += 1;
		}
	}
	for(int i=0;i<N;i++) printf("%d\n", count[i]);
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int size=s.size();
  stack<char> st;
  for(int i=0;i<size;i++){
    if(s.at(i)!='B')
    st.push(s.at(i));
    else if(!st.empty() && s.at(i)=='B')
    st.pop();
  }
  int si=st.size();
  vector<char> v(si);
  for(int i=si-1;i>=0;i--){
    v.at(i)=st.top();
    st.pop();
  }
  for(int i=0;i<si;i++){
    cout << v.at(i);
  }
  cout << endl;
}



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



void solve() {
  string s;
  cin >> s;
  vector<int>alp(26,0);
  for(auto x : s) {
    alp[x - '0' - 49]++;
  }
  for (auto x : alp) {
    if(x%2) {
      cout << "No";
      return;
    }
  }
  cout << "Yes";
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<pair<ll, ll>> v(N);
    for(int i = 0; i < N; i++) cin >> v[i].first >> v[i].second;

    ll ans = longinf;
    for(int a = 0; a < N; a++) {
        for(int b = 0; b < N; b++) {
            for(int c = 0; c < N; c++) {
                for(int d = 0; d < N; d++) {
                    ll left = min(v[a].first, min(v[b].first, min(v[c].first, v[d].first)));
                    ll right = max(v[a].first, max(v[b].first, max(v[c].first, v[d].first)));
                    ll under = min(v[a].second, min(v[b].second, min(v[c].second, v[d].second)));
                    ll top = max(v[a].second, max(v[b].second, max(v[c].second, v[d].second)));

                    int cnt = 0;
                    for(int i = 0; i < N; i++) {
                        if(left <= v[i].first && v[i].first <= right && under <= v[i].second && v[i].second <= top) cnt++;
                    }
                    if(cnt >= K && (right - left) * (top - under) != 0) ans = min(ans, (right - left) * (top - under));
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

struct UnionFind {
  vector<int> par;
  int cnt;
  UnionFind(int size_) : par(size_, -1), cnt(size_) { }
  void unite(int x, int y) {
    if ((x = find(x)) != (y = find(y))) {
      if (par[y] < par[x]) swap(x, y);
      par[x] += par[y]; par[y] = x; cnt--;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
  int size(int x) { return -par[find(x)]; }
  int size() { return cnt; }
};

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, q, com, x, y;
  cin >> n >> q;
  UnionFind uf = UnionFind(n);
  for (int i = 0; i < q; i++) {
    cin >> com >> x >> y;
    if (com == 0) uf.unite(x, y);
    else if (com == 1) cout << (uf.same(x, y) ? 1 : 0) << endl;
  }
  return 0; 
}

Measured memory_bytes: 1244
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d" , &a, &b, &c);
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

const int bound = 300500;
const int mb = 100000;
vector<int> graph[bound];
int dist[bound];
bool besucht[bound];

int main(){
	int n, m; cin >> n >> m;
	for( int i = 0; i < m; ++i ){
		int x, y; cin >> x >> y; --x; --y;
		graph[x].push_back(mb+y);
		graph[mb+x].push_back(2*mb+y);
		graph[2*mb+x].push_back(y);
	}
	int s, g; cin >> s >> g; --s; --g;
	fill_n(dist, bound, inf);
	queue<pair<int, int>> q;
	q.emplace(s, 0);
	while( !q.empty() ){
		auto p = q.front(); q.pop();
		if( p.first == g ){
			cout << p.second/3 << endl;
			return 0;
		}
		if( besucht[p.first] ) continue;
		besucht[p.first] = true;
		for( auto nextp : graph[p.first] ){
			q.emplace(nextp, p.second+1);
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll n;
  cin >> n;
  string s="";
  ll m=1;
  if(n==0){
    cout << 0 << endl;
    return 0;
  }
  while(n!=0){
    if(abs(n)%(abs(m)*2)!=0){
      s='1'+s;
      n-=m;
    }
    else s='0'+s;
    m*=-2;
  }
  cout << s << endl; 
}  


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()
	{
		int N = Int32.Parse(Console.ReadLine());
		string S = Console.ReadLine();

		int ans = 0;
		for(int i = 1; i < N; i++)
		{
			bool[] exists = new bool[26];
			for(int j = 0; j < i; j++)
				exists[(int)(S[j] - 'a')] = true;
			
			int tmp = 0;
			for(int j = 0; j < 26; j++)
			{
				if(!exists[j])
					continue;

				if(S.Substring(i, N - i).IndexOf((char)(j + 'a')) != -1)
					tmp++;
			}
			ans = Math.Max(ans,tmp);
		}

		Console.WriteLine(ans);
	}
}





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

int main() {
  char a, b;
  cin >> a >> b;

  if(a=='H' && b=='H'){
    cout << 'H' << endl;
  }
  else if(a=='D' && b=='D'){
    cout << 'H' << endl;
  }
  else{
    cout << 'D' << endl;
  }

return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  rep(i,N) cin >> X[i];
  sort(all(X));
  
  vector<int> S(X[N-1]-X[0]+1);
  
  for (int P=X[0]; P<=X[N-1]; ++P) {
    rep(i,N) S[P-X[0]] += (X[i]-P)*(X[i]-P);
  }
  
  sort(all(S));
  dunk(S[0]);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
 int n,o;
  cin>>n;
  o=n%10;
  if(o==2||o==4||o==5||o==7||o==9)
    cout<<"hon";
 else if(o==0||o==1||o==6||o==8)
    cout<<"pon";
  else
    cout<<"bon";
  return 0;
}
  

Measured memory_bytes: 3628
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [int(input()) for i in range(m)]
ans = []
for i in a:
  total = 0
  for j in range(m):
    total += i[j] * b[j]
  ans.append(total)
for k in ans:
  print(k)


Measured memory_bytes: 5980
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#include "bits/stdc++.h"
#define YES "YES"
#define Yes "Yes"
#define NO "NO"
#define No "No"
#define YESNO(x) OUT(three(x,YES,NO))
#define YesNo(x) OUT(three(x,Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define all ALL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef LL ll;
typedef double ld;
typedef LL ut;
const LL INF = 1LL << 60;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ppr, Vppr ,greater<ppr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,1,1,-1,-1,0 }, dy[] = { 1,0,-1,0,1,-1,1,-1,0 };
const int SIZE1 =2e6 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 22;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;const long double EPS = 1e-7;
ut N, M, K, X, L, Y,H,W,Q,D;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
LL A[SIZE], B[SIZE],I[SIZE];
LL solve() {
	LL Q, H, S, D;
	cin >> Q >> H >> S >> D;
	cin >> N;
	MN(H, Q * 2);
	MN(S, H * 2);
	MN(D, S * 2);
	cout << N / 2 * D + ((N&1)?S:0) << endl;
	return 0;
}
signed main() {
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	solve();
	//	cin >> N;
	return 0;
}

Measured memory_bytes: 48384
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 99999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    int a,b,x,y,z,ans;
    cin >> a >> b;
    x = a+b;
    y = a-b;
    z = a*b;
    ans = max(x,max(y,z));
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  map<int, int> m;
  for (int i = 0; i < n; i++) m[a.at(i)]++;
  if (m[0] == n) {
    puts("Yes");
    return 0;
  } else if (n % 3) {
    puts("No");
    return 0;
  }
  vector<int> h;
  for (auto x : m) {
    if (x.second % (n / 3)) {
      puts("No");
      return 0;
    }
    for (int i = 0; i < x.second / (n / 3); i++) {
      h.push_back(x.first);
    }
  }
  if ((h.at(0) ^ h.at(1) ^ h.at(2)) == 0) {
    puts("Yes");
  } else {
    puts("No");
  }
}


Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
using namespace	std; //?????????????????????                                 
int main()
{
  int n,a;
  cin >> n;

  int min = 1000000, max = -1000000; //??\????????´??°????????§???????°????                   
  long  sum = 0; // long??????????????¨?????????                                          
    for (int i=0; i<n; i++)
      {
        cin >> a;//???????????\???????????§OK????????????\???????????£????????´???                    
	if (a<min) min = a; //???????????¶??????????????????true                            
	if (a>max) max = a; //????§?                                                
        sum += a; //sum????¨??????????                                                 
      }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int H, W; cin >> H >> W;
  rep(i, H) {
    string C;
    cin >> C;
    cout << C << endl;
    cout << C << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int m,f,r;
    cin >> m >> f >> r;
    while(m != -1 || f != -1 || r != -1) {
        if(m == -1 || f == -1) {
            cout << 'F' << endl;
        }
        else if(m + f >= 80) {
            cout << 'A' << endl;
        }
        else if(m + f >= 65) {
            cout << 'B' << endl;
        }
        else if(m + f >= 50 || (m + f >= 30 && r >= 50)) {
            cout << 'C' << endl;
        }
        else if(m + f >= 30) {
            cout << 'D' << endl;
        }
        else {
            cout << 'F' << endl;
        }
        
        cin >> m >> f >> r;
    }
}


Measured memory_bytes: 3096
n = int(input())
l = sorted(list(map(int,input().split())))
 
count = 0 
 
for i in range(n - 2):
    for j in range(i+1,n-1):
        
        if l[i] + l[j] > l[n-1]:
            count += n-j-1
            
            continue
        
        low = j+1
        high = n-1
        
        while low < high:
            
            mid = (low + high)//2
            
            if l[i] + l[j] > l[mid]:
                
                low = mid +1
            
            else:    
                
                high = mid 
        else:
            
            count += low - j -1
print(count)            

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

using ll = long long;

int main() {
  int N, M;
  cin >> N >> M;
  ll x[N], y[N], z[N];
  for (int i = 0; i < N; i++) scanf("%lld %lld %lld", x + i, y + i, z + i);
  
  ll ans = 0;
  for (int i = 0; i < 8; i++) {
    bool plus[3];
    fill(plus, plus + 3, false);
    for (int j = 0; j < 3; j++) {
      if ((i >> j) & 1) plus[j] = true;
    }
    ll sum[N];
    for (int j = 0; j < N; j++) {
      ll xx = x[j];
      ll yy = y[j];
      ll zz = z[j];
      if (!plus[0]) xx *= -1;
      if (!plus[1]) yy *= -1;
      if (!plus[2]) zz *= -1;
      sum[j] = xx + yy + zz;
    }
    sort(sum, sum + N);
    ll tmp = 0;
    for (int j = N - 1; j >= N - M; j--) tmp += sum[j];
    ans = max(ans, tmp);
  }
  
  cout << ans << endl;
  return 0;
}


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

struct node {
    int key;
    struct node *left, *right;
    node(int k):key(k),left(NULL),right(NULL){}
};

class bintree {
    node *root;
    bool first;
    void inorder(node *t) {
        if(t) {
            inorder(t->left);
            cout<<' '<<t->key;
            inorder(t->right);
        }
    }
    void preorder(node *t) {
        if(t) {
            cout<<' '<<t->key;
            preorder(t->left);
            preorder(t->right);
        }
    }
    public:
    bintree():root(NULL){}
    void insert(int k)
    {
        node *n = new node(k);
        node *y=NULL;
        node *x=root;
        while(x!=NULL) {
            y=x;
            if(k<x->key) x=x->left;
            else x=x->right;
        }
        if(y==NULL) {
            root=n;
        } else {
            if(k<y->key) y->left=n;
            else y->right=n;
        }
    }
    void inorder(){
        inorder(root);
        cout<<'\n';
    }
    void preorder(){
        preorder(root);
        cout<<'\n';
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    bintree t;
    int n;
    string com;
    int key;
    cin>>n;
    for(int i=0; i<n; i++) {
        cin>>com;
        switch(com[0]) {
        case 'i':
            cin>>key;
            t.insert(key);
            break;
        case 'p':
            t.inorder();
            t.preorder();
        }
    }
    return 0;
}

Measured memory_bytes: 16844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    S[K-1] = tolower(S[K-1]);

    cout << S << '\n';

    return 0;
}

Measured memory_bytes: 888
a,b,x = map(int, input().split())

import math

if x==a*a*b:
    print(0)
    exit()

if x > (a*a*b)/2:
    theta = math.atan(((a*a*a)/(a*a*b-x))/2)
else:
    theta = math.atan((2*x) / (a*b*b))

print(90-math.degrees(theta))

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

int n;
string s;
int ans;

void solve() {
    cin >> n;
    cin >> s;
    ans = 0;
    for (int p1 = 0, p2 = n - 1; p1 < p2;) {
        if (s[p1] == 'R') p1++;
        else
        if (s[p2] == 'W') p2--;
        else {
            p1++; p2--;
            ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
}

Measured memory_bytes: 3772
#include <iostream>
using namespace std;
typedef long long ll;

ll f(ll w, ll h) {
	if(w > h) swap(w, h);

	if(h % w == 0) {
		return w * ((h / w) * 2 - 1);
	}
	return w * (h / w) * 2 + f(h % w, w);
}

int main() {
	ll N, X;
	cin >> N >> X;

	cout << N + f(X, N - X) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define For(i,j,k) for(int i=j;i<=k;++i)
#define Dor(i,j,k) for(int i=j;i>=k;--i)
#define ll long long
using namespace std;
int main(){
	ll m,x,y;
	scanf("%lld",&m);
	while(m--){
		scanf("%lld%lld",&x,&y);
		ll z=sqrt(x*y);
		ll ans=z*2ll-1ll;
		if(z*z==x*y&&x!=y)--ans;
		if(z*(z+1ll)>=x*y)--ans;
		printf("%lld\n",ans);
	}
	return 0;
}


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

int main() {
  int N,R;
  cin >> N >> R;
  if(N>9) cout << R << endl;
  else cout << 100*(10-N)+R << endl;
  
  return 0;
}


Measured memory_bytes: 3556