akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX*/

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 998244353;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/


int n, m;
vector<vector<int>> G;
vector<bool> visited;

vector<ll> any;
vector<pair<ll, ll>> bipartite;
vector<int> color;

bool bip; int one; int two;

void dfs(int v, int c = 1)
{
    visited[v] = true;
    color[v] = c;
    if (c==1) one++; else two++;

    for (auto it: G[v])
    {
        if (visited[it] && color[it]==color[v]) bip = false;
        if (!visited[it]) dfs(it, 3-c);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    cin>>n>>m;
    G.resize(n+1);
    visited.resize(n+1);
    color.resize(n+1);
    for (int i = 0; i<m; i++)
    {
        int a, b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for (int i = 1; i<=n; i++) if (!visited[i])
    {
        bip = true; one = 0; two = 0;
        dfs(i);
        if (bip) bipartite.push_back(mp(one, two));
        else any.push_back(one + two);
    }


    ll b = bipartite.size();
    ll a = any.size();
    ll pt = 0;
    for (auto it: bipartite) if (it.first + it.second ==1) pt++;
    b-=pt;

    ll res = 1ll*b*b + 1ll*(b+a)*(b+a);
    res+=pt*pt + 2*pt*(n-pt);

    cout<<res;




}



Measured memory_bytes: 10112
def partition(a,p,r):
    x=a[r][1]
    i=p-1
    for j in range(p,r):
        if a[j][1]<=x:
            i+=1
            temp=a[i]
            a[i]=a[j]
            a[j]=temp
    temp=a[i+1]
    a[i+1]=a[r]
    a[r]=temp
    return i+1

def quicksort(a,p,r):
    if p<r:
        q=partition(a,p,r)
        quicksort(a,p,q-1)
        quicksort(a,q+1,r)


r=int(input())
a=[list(input().split()) for _ in range(r)]
for i in range(r):
    a[i][1]=int(a[i][1])
import copy
b=copy.deepcopy(a)
b.sort(key=lambda x:x[1])
quicksort(a,0,r-1)


if a==b:
    print("Stable")
else:
    print("Not stable")

for i in range(r):
    print(a[i][0],a[i][1])



Measured memory_bytes: 41224
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[3];
		int[] b=new int[3];
		a[0]=sc.nextInt();
		a[1]=sc.nextInt();
		a[2]=sc.nextInt();
		b[0]=sc.nextInt();
		b[1]=sc.nextInt();
		b[2]=sc.nextInt();
		int[] dp1=new int[n+1];
		for(int i=1; i<=n; i++){
			dp1[i]=i;
			for(int j=0; j<3; j++){
				if(i>=a[j]){
					dp1[i]=Math.max(dp1[i],dp1[i-a[j]]+b[j]);
				}
			}
		}
		long[] dp2=new long[dp1[n]+1];
		for(int i=1; i<=dp1[n]; i++){
			dp2[i]=i;
			for(int j=0; j<3; j++){
				if(i>=b[j]){
					dp2[i]=Math.max(dp2[i],dp2[i-b[j]]+a[j]);
				}
			}
		}
		System.out.println(dp2[dp1[n]]);
	}
}


Measured memory_bytes: 218196
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Map<Character, Integer>> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            Map<Character, Integer> map = new TreeMap<>();
            for (int j = 0; j < s.length(); j++) {
                map.merge(s.charAt(j), 1, Integer::sum);
            }
            list.add(map);
        }
        Map<Character, Integer> map2 = list.get(0);
        StringBuilder sb = new StringBuilder();
        if (list.size() == 0) {
            for (Map.Entry<Character, Integer> s : map2.entrySet()) {
                int num = s.getValue();
                for (int i = 0; i < num; i++) {
                    sb.append(s.getKey());
                }
            }
            sb.append("\n");
        } else {
            for (Map.Entry<Character, Integer> s : map2.entrySet()) {
                int num = s.getValue();
                boolean hasC = true;
                for (int i = 1; i < list.size(); i++) {
                    Map<Character, Integer> tempMap = list.get(i);
                    if (tempMap.containsKey(s.getKey())) {
                        num = Math.min(tempMap.get(s.getKey()), num);
                    } else {
                        hasC = false;
                        break;
                    }
                }
                if (hasC) {
                    for (int i = 0; i < num; i++) {
                        sb.append(s.getKey());
                    }
                }
            }
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 26580
from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
def printCombination(arr, n, r): 
	data = [0] * r 
	combinationUtil(arr, n, r, 0, data, 0) 
def combinationUtil(arr, n, r, index, data, i): 
	if (index == r): 
		ans=[]
		for j in range(r): 
			ans.append(data[j]) 
		f.append(ans)
		return
	if (i >= n): 
		return
	data[index] = arr[i] 
	combinationUtil(arr, n, r, index + 1, 
					data, i + 1) 
	combinationUtil(arr, n, r, index, 
					data, i + 1) 


n,m,x=map(int,input().split())
cost=[]
l=[]
for i in range(n):
	l.append(list(map(int,input().split())))
z=[i for i in range(n)]
for i in range(1,n+1):
	f=[]
	printCombination(z,n,i)
	for t in f:
		ans=0
		ansd=[0 for i in range(m)]
		for j in t:
			ans+=l[j][0]
			for k in range(m):
				ansd[k]+=l[j][k+1]
		flag=1
		for k in ansd:
			if k<x:
				flag=0
		if flag==1:
			cost.append(ans)
if len(cost)>0:
	print(min(cost))
else:
	print(-1)


Measured memory_bytes: 71120
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
 
    ll x,y,a,b,c,i;
    cin>>x>>y>>a>>b>>c;
    priority_queue<ll> pq;
    vector<ll> v1(a),v2(b),v3(c);
    for(i=0;i<a;i++) cin>>v1[i];
    for(i=0;i<b;i++) cin>>v2[i];
    for(i=0;i<c;i++) cin>>v3[i];
    sort(v1.begin(),v1.end(),greater<ll>());
    sort(v2.begin(),v2.end(),greater<ll>());

    
    for(i=0;i<x;i++) pq.push(v1[i]);
    for(i=0;i<y;i++) pq.push(v2[i]);
    for(i=0;i<c;i++) pq.push(v3[i]);
    ll cn = 0,ans=0;
    while(cn < x+y)
    {
    	ans += pq.top();
    	pq.pop();
    	cn++;
    }
    cout<<ans;
}

Measured memory_bytes: 8816
#include <stdio.h>

int main(void) {  int n ,ai ,i ,max ,min;          

long int sum = 0;    

scanf("%d" ,&n);    

for(i=0;i<n;i++){      

scanf("%d" ,&ai);      

sum += ai;      

if(i==0){        

max = ai;                        

min = ai;

}      

else if(ai>max){        

max = ai;      

}      

else if(ai<min){        

min = ai;       

}

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

Measured memory_bytes: 600
n, t = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
end = 0 + t

for i in range(1, len(l)):
    if l[i] <= end:
        ans += l[i] - l[i-1]
    else:
        ans += t
    end = l[i] + t
ans += t

print(ans)


Measured memory_bytes: 26708
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		double sum = 0;
		for (int i = 1; i <= n; i++) {
			sum += (Math.pow(0.5, count(i, k)) / n);
		}
		System.out.println(sum);
	}


	private static int count(int i, int k) {
		int countDouble = 0;
		while(i < k) {
			i *= 2;
			countDouble++;
		}
		return countDouble;
	}
}


Measured memory_bytes: 21588
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, y = LI()

for i in range(n+1):
    for j in range(n+1):
        if i + j > n:
            continue
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i, j, k)
            quit()
print(-1, -1, -1)
        

Measured memory_bytes: 83440
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String ab = a + b;
        int cur = Integer.valueOf(ab);
        int root = (int) Math.floor(Math.sqrt(cur));

        String ans = "No";
        if((root*root==cur||(root+1)*(root+1)==cur||(root-1)*(root-1)==cur)) ans = "Yes";
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
typedef unsigned long long int uli;
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	for(int i = 0;i<1000000; ++i) {
		if(floor(i * 0.08) == a && floor(i * 0.10) == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#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(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int a,b,c;
    cin >> a >> b >> c;
    cout << (a*b)/2 << endl;




    return 0;
}

Measured memory_bytes: 256
/*Author: Gautam*/


#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define MODULO 1000000007
#define ull unsigned long long int
#define newline cout<<endl


/* TYPE DEFINITIONS */
typedef		long long		i64;
typedef		vector<int>		vi;
typedef		pair<int,int>	pi;



/* ALGEBRA */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 

int f;
/* MACROS */

#define  all(A)			(A).begin() , (A).end()
#define  rall(A)		(A).rbegin() , (A).rend()
#define  sz(A)			(int)(A).size()
#define  pb				push_back
#define  ppb			pop_back
#define  mp				make_pair
#define  ln(X)			(int)(X).length()
#define  square(X)		((X)*(X))
#define  cube(X)		((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)	for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(a*b,c);
}

int main()
{
	FastIO;
	i64 t=1;
    //cin>>t;
	while(t--)solve();
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	string S;
	cin >>N >>S;
	int SS=0;
	for (int i=2; i<N; i++) {
		int j=0;
		int SSS=0;
		while(i+j<N) {
			if (S.at(j)==S.at(j+i)) {
				SSS++;
				SS=max(SS, SSS);
				if (i==SSS)
					break;
			} else
				SSS=0;
			j++;
		}
	}
	cout <<SS <<endl;
	return 0;
}



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

int main() {
  int card[3][3];
  bool isSelected[3][3];
  string ans = "No";
  int i, j, a, b;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      cin >> a;
      card[i][j] = a;
      isSelected[i][j] = false;
      //cout << card[i][j] << " ";
    }
    //cout << endl;
  }
  int N;
  cin >> N;
  for (int n = 0; n < N; n++) {
    cin >> b;
    for (i = 0; i < 3; i++) {
      for (j = 0; j < 3; j++) {
        if (card[i][j] == b) {
          isSelected[i][j] = true;
        }
      }
    }
  }
  for(i = 0; i < 3; i++){
      if(isSelected[i][0] == true && isSelected[i][1] == true && isSelected[i][2] == true){
          cout << "Yes" << endl;
          return 0;
      }
  }
  for(j = 0; j < 3; j++){
      if(isSelected[0][j] == true && isSelected[1][j] == true && isSelected[2][j] == true){
          cout << "Yes" << endl;
          return 0;
      }
  }
  if(isSelected[0][0] == true && isSelected[1][1] == true && isSelected[2][2] == true){
      cout << "Yes" << endl;
      return 0;
  }
  if(isSelected[0][2] == true && isSelected[1][1] == true && isSelected[2][0]== true){
      cout << "Yes" <<  endl;
      return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int dis_lst[]={0,0,6,13,18,23,43,58};
	int prc_lst[7][8]={{},
		{0,0,300,500,600,700,1350,1650},
		{0,0,  0,350,450,600,1150,1500},
		{0,0,  0,  0,250,400,1000,1350},
		{0,0,  0,  0,  0,250, 850,1300},
		{0,0,  0,  0,  0,  0, 600,1150},
		{0,0,  0,  0,  0,  0,   0, 500},
	};

	for(int ic1,h1,m1,ic2,h2,m2;cin>>ic1>>h1>>m1>>ic2>>h2>>m2,ic1;){
		if(ic1>ic2)	swap(ic1,ic2);
		int dis=dis_lst[ic2]-dis_lst[ic1];

		bool harf=false;
		if(dis<=40
		&&((60*17+30<=60*h1+m1 && 60*h1+m1<=60*19+30)
		|| (60*17+30<=60*h2+m2 && 60*h2+m2<=60*19+30)))	harf=true;

		int prc=prc_lst[ic1][ic2];
		if(harf){
			prc/=2;
			if(prc%50>0)	prc+=50-prc%50;
		}

		cout<<prc<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n;
	int i = 1;
	cin >> n;
	while (i*i <= n)i++;
	cout << (i - 1)*(i - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Bool

solve :: Array (Int,Int) Char -> ((Int,Int)->[(Int,Int)]) -> Bool
solve bd nFunc = and [ok ix| ix <- indices bd]
    where ok ix | bd ! ix =='.' = True
                | otherwise = or [bd ! adj == '#'| adj <- nFunc ix]

neighbor :: Int -> Int -> (Int,Int) -> [(Int,Int)]
neighbor h w (i,j) = filter inrange [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]
    where inrange (i,j) = and [i>=1, j>=1, i<=h, j<=w]

main = do
    [h,w] <- map read . words <$> getLine
    lines <- replicateM h getLine
    let bd = listArray ((1,1),(h,w)) (concat lines)
    putStrLn $ bool "No" "Yes" (solve bd (neighbor h w))


Measured memory_bytes: 1020
import java.util.Scanner;
 
public class  Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);  
        String a = sc.next();  
        String b = sc.next();  
        String c = sc.next();  
        
        System.out.println("A" + b.substring(0, 1) + "C");
}
}

Measured memory_bytes: 21332
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

l_max = max(a,b,c,d,e)
l_min = min(a,b,c,d,e)

if((l_max-l_min) > k):
    print(':(')
else:
    print('Yay!')


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >>a>>b>>c;
  if(a==b) cout <<c<<'\n';
  if(a==c) cout <<b<<'\n';
  if(b==c) cout <<a<<'\n';
  return(0);
}


Measured memory_bytes: 256
def square() : 
  
  W , H, N = tuple(map(int, input().split()))
  
  leftrange = 0
  lowrange = 0
  rightrange = W
  upperrange = H
  
  for i in range(N) : 
    x, y, a = tuple(map(int, input().split()))
    if a == 1 :
      if x > leftrange : 
        leftrange = x
    if a == 2 : 
      if x < rightrange : 
        rightrange = x
    if a == 3 :
      if y > lowrange : 
        lowrange = y
    if a == 4 : 
      if y < upperrange : 
        upperrange = y
        
  return leftrange, rightrange, lowrange, upperrange

def answer(x1, x2, y1, y2) : 
  if (x1 >= x2 or y1 >= y2) : 
    return 0
  return (x2 - x1) * (y2 - y1)

def main() : 
  leftrange, rightrange, lowrange, upperrange = square()
  print(answer(leftrange, rightrange, lowrange, upperrange))
  
  
main()


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

using namespace std;

// 多次元 mul_array<int, 1, 2, 3> a
//template <typename T, std::size_t... Ns>
//struct index_reverse_for_array;
//template <typename T, std::size_t N, std::size_t... Ns>
//struct index_reverse_for_array<T, N, Ns...> { using type = std::array< typename index_reverse_for_array<T, Ns...>::type, N>; };
//template <typename T, std::size_t N>
//struct index_reverse_for_array<T, N> { using type = std::array<T, N>; };
//template <class T, std::size_t... Ns> using mul_array = typename index_reverse_for_array<T, Ns...>::type;
//
//using u32 = uint32_t;
//using s32 = uint32_t;
//using u64 = uint64_t;
//using s64 = uint64_t;

int main() {
    //cout << fixed << setprecision(10);

    while (true) {
        int n;
        cin >> n;
        if (n == 0)
            break;

        int n2 = 2 * n;

        int counter = 0;
        for (int i = n + 1; i <= n2; i++) {
            bool f = true;
            for (int j = 2; j <= sqrt(i); j++) {
                if (i % j == 0) {
                    f = false;
                    break;
                }
            }
            if (f) {
                counter++;
            }
        }
        cout << counter << endl;
    }

    return 0;
}




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

int main()

{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m;
    cin >> n >> m;
    int a[n];
    for(int i = 0; i < m; i++)
    {
        cin >> a[i];
        n -= a[i];
        if(n < 0)
            break;
    }
    if(n < 0)
        cout << "-1";
    else
        cout << n;
    
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int main(){
  int n;
  cin>>n;
  n%=7;
  string a;
  if(n==1) a="fri";
  if(n==2) a="sat";
  if(n==3) a="sun";
  if(n==4) a="mon";
  if(n==5) a="tue";
  if(n==6) a="wed";
  if(n==0) a="thu";
  cout<<a<<endl;
  return 0;
}



Measured memory_bytes: 3200
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    n, k = map(int, input().split())
    hs = list(map(int, input().split()))
    if n <= k+1:
        print(abs(hs[0]-hs[-1]))
        exit()
    ans_list = [0]*n
    last_hs = hs[-1]
    for i in range(1,k+2):
        ans_list[-i] = abs(last_hs - hs[-i])
    for i in range(k+2,n+1):
        hs_i = hs[-i]
        ans_list[-i] = min([abs(hs_i-x)+y for x,y in zip(hs[1-i:k+1-i],ans_list[1-i:k+1-i])])
    print(ans_list[0])


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

int main() {
	int k , s , x , y , z;
	cin>>k>>s>>x>>y>>z;
	int cnt = 0 ;
	for(int i = 0 ; i <= k ; ++i)
		for(int j = 0 ; j <= k ; ++j){
			int diff = s - (i + j);
			if(diff >= 0 && diff <= k)++cnt;
		}
	cout<<cnt;		
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N;
    cin >> N;
    vector<ll> W(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> W[i];
    }
    int l_sum = 0, r_sum = 0;
    for ( int i = 0; i < N; i++ ) r_sum += W[i];
    int diff_min = 10000;
    for ( int i = 0; i <= N; i++ ) {
        int d = abs(l_sum - r_sum);
        if ( diff_min > d ) diff_min = d;
        if ( i < N ) {
            l_sum += W[i];
            r_sum -= W[i];
        }
    }
    cout << diff_min << '\n';
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);
 
signed main() {
	vector<int> v;
	int n;
	cin >> n;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		v.emplace_back(a);
	}
	sort(v.begin(), v.end());
	int ans = 0;
	int num = v[0];
	int count = 1;
	for (int i = 1; i < n; i++) {
		if (v[i] == num)count++;
		else {
			if (count % 2 == 1)ans++;
			num = v[i];
			count = 1;
		}
	}
	if (count % 2 == 1)ans++;
 
	cout << ans << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	vector<Int> a(n);
	for(auto &i:a) cin >> i;
	Int s = 1;
	Int m = 1e18;
	for(auto i:a){
		if(i == 0){
			s = 0;
			break;
		}
	}
	if(s != 0){
		for(auto i:a){
			if((m+i-1)/i < s){
				s = -1;
				break;
			}
			s *= i;
		}
	}
	if(s > m) s = -1;
	cout << s << "\n";
}

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

int main(){
	int n;
	cin >> n;
	int Y,M,D;


	for (int i = 0; i <= n-1; i++){
		cin >> Y >> M >> D;
		int year = Y;
		int month = M;
		int day = D;
		int num = 0;

		while ( !(year == 1000) ){
			num++;
			day++;
			if ((year%3 == 1)||(year%3 == 2)){
				if ((month%2 == 1)&&(day == 21)){
					month++;
					day = 1;
					if (month == 11){
						year++;
						month = 1;
					}
				}
				else if ((month%2 == 0)&&(day == 20)){
					month++;
					day = 1;
					if (month == 11){
						year++;
						month = 1;
					}
				}
			}
			else if (year%3 == 0){
				if (day == 21){
					month++;
					day = 1;
					if (month == 11){
						year++;
						month = 1;
					}
				}
			}
			//cout << "year: " << year << "month: " << month << "day: " << day << endl;
		}
		cout << num << endl;
	}
}

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

int sa[101010], sb[101010], ta[101010], tb[101010];

int main() {
    string S, T;
    cin >> S >> T;
    int q;
    cin >> q;

    for (int i=1; i<=S.size(); ++i) {
        sa[i] = sa[i-1] + (S[i-1] == 'A');
        sb[i] = sb[i-1] + (S[i-1] == 'B');
    }
    for (int i=1; i<=T.size(); ++i) {
        ta[i] = ta[i-1] + (T[i-1] == 'A');
        tb[i] = tb[i-1] + (T[i-1] == 'B');
    }

    rep(i, q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int x = sa[b] - sa[a-1] + (sb[b] - sb[a-1]) * 2;
        int y = ta[d] - ta[c-1] + (tb[d] - tb[c-1]) * 2;

        //cout << x << ", " << y << endl;
        if (x%3 == y%3) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2432
R, G, B, N_1 = map(int, input().split())
cnt = 0

for r in range(N_1//R + 1):
    N_2 = N_1
    N_2 -= r*R
    for g in range(N_2//G + 1):
        N_3 = N_2
        N_3 -= g*G

        if N_3%B == 0:
            cnt += 1

print(cnt)


Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	X := sc.NextInt()
	Y := sc.NextInt()
	Z := sc.NextInt()
	K := sc.NextInt()
	A := make([]int, X)
	B := make([]int, Y)
	C := make([]int, Z)
	for i := 0; i < X; i++ {
		A[i] = sc.NextInt()
	}
	for i := 0; i < Y; i++ {
		B[i] = sc.NextInt()
	}
	for i := 0; i < Z; i++ {
		C[i] = sc.NextInt()
	}
	AB := make([]int, X*Y)
	for i := 0; i < X; i++ {
		for j := 0; j < Y; j++ {
			AB[Y*i+j] = A[i] + B[j]
		}
	}
	sort.Ints(AB)

	all := make([]int, len(C)*min(K, len(AB)))
	for i := 0; i < min(K, len(AB)); i++ {
		for j := 0; j < len(C); j++ {
			all[len(C)*i+j] = AB[len(AB)-1-i] + C[j]
		}
	}

	sort.Ints(all)
	for i := 0; i < K; i++ {
		fmt.Println(all[len(all)-1-i])
	}

}

func vmin(v []int) int {
	mn := math.MaxInt32
	for i := 0; i < len(v); i++ {
		mn = min(mn, v[i])
	}
	return mn
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt64() int64 {
	i, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 33152
from collections import deque
n=int(input())
A=list(map(int,input().split()))
ans = deque([])
for i in range(n):
  if i % 2 == 0:
    ans.append(A[i])
  else:
    ans.appendleft(A[i])
if n % 2 == 1:
  ans = list(ans)[::-1]
print(*ans)

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

const int maxn = 200100;

int ord[maxn];
int a[maxn];
int ans[maxn];

bool cmp(int aa,int bb){
	return a[aa]<a[bb];
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		ord[i]=i;
	}
	sort(ord,ord+n,cmp);
	//for(int i=0;i<n;i++)printf("%d ",a[ord[i]]);puts("");
	for(int i=0;i<n;i++){
		if(i<n/2){
			ans[ord[i]]=a[ord[n/2]];
		}else{
			ans[ord[i]]=a[ord[n/2-1]];
		}
	}
	for(int i=0;i<n;i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

static const int INF = 1000000000;

int ans = INF;
int N, M, R;
int r[10];
int d[205][205];

void floyd() {
  rep(k, 1, N+1) {
    rep(i, 1, N+1) {
      rep(j, 1, N+1) {
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }

}

int main(void) {
    scanf("%d %d %d", &N, &M, &R);
    rep(i, 0, R)  scanf("%d", &r[i]);
    
    rep(i, 1, N+1) {
      rep(j, 1, N+1) {
        d[i][j] = INF;
      }
    }

    rep(i, 0, M) {
      int a, b, c;
      scanf("%d %d %d", &a, &b, &c);
      d[a][b] = d[b][a] = c;
    }

    floyd();
    
    sort(r, r+R);
    
    do {
      int dist = 0;
      rep(i, 0, R-1) dist += d[r[i]][r[i+1]];
      ans = min(ans, dist);
    
    } while (next_permutation(r, r+R));


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


Measured memory_bytes: 384
//    freopen("/Users/wangjiaolv/Desktop/test/in.txt", "r", stdin);
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
int n, a[N], mx[N];
struct node{
    int x, y;
    friend bool operator < (node a, node b){
        return a.x > b.x;
    }
}b[2][N];
int main()
{
//    freopen("/Users/wangjiaolv/Desktop/test/in.txt", "r", stdin);
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);
    for(int j=0;j<2;j++){
        for(int i=1+j;i<=n;i+=2) {
            b[j][a[i]].x ++;
            b[j][a[i]].y = a[i];
        }
    }
    sort(b[0]+1, b[0]+1+N-10);
    sort(b[1]+1, b[1]+1+N-10);
    int ans = n;
    for(int i=1; i<=2; i++){
        for (int j=1; j<=2; j++) {
            if(b[0][i].y != b[1][j].y) ans = min(ans, n - b[0][i].x - b[1][j].x);
        }
    }
    printf("%d\n", ans);
    
    return 0;
}



Measured memory_bytes: 2176
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{

        //List<int> a = new List<int>();
        //List<int> b = new List<int>();

        string[] s = Console.ReadLine().Split(' ');

        long a = long.Parse(s[0]);
        long b = long.Parse(s[1]);
       


        Console.WriteLine("{0} {1} {2}",a/b,a%b,(decimal)a/(decimal)b);

		//Console.WriteLine("");


	}
}

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

using namespace std;
int V, E, Q, a, b; vector<int> G[100009], rG[100009], vs; bool used[100009]; int cmp[100009];
void add_edge(int from, int to) {
	G[from].push_back(to);
	rG[to].push_back(from);
}
void dfs(int v) {
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		if (!used[G[v][i]]) dfs(G[v][i]);
	}
	vs.push_back(v);
}
void rdfs(int v, int k) {
	used[v] = true;
	cmp[v] = k;
	for (int i = 0; i < rG[v].size(); i++) {
		if (!used[rG[v][i]]) rdfs(rG[v][i], k);
	}
}
int scc() {
	fill(used, used + V, false);
	vs.clear();
	for (int v = 0; v < V; v++) {
		if (!used[v]) dfs(v);
	}
	fill(used, used + V, false);
	int k = 0;
	for (int i = vs.size() - 1; i >= 0; i--) {
		if (!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;
}
int main() {
	scanf("%d%d", &V, &E);
	for (int i = 0; i < E; i++) {
		scanf("%d%d", &a, &b);
		add_edge(a, b);
	}
	scc();
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d%d", &a, &b);
		printf("%d\n", (cmp[a] == cmp[b]) ? 1 : 0);
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

vector<string> v;
int n;

void dfs(int d, int x, string s){
	if(d == n){
		v.push_back(s);
		return;
	}

	if(d == 0){
		dfs(1, 1, "a");
		return;	
	}

	for(int i = 0; i < x + 1; i++){
		s.push_back((char) 'a' + i);
		if(i == x) dfs(d+1, x+1,  s);
		else dfs(d+1, x, s);
		s.pop_back();
	}
}

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

	cin >> n;
	dfs(0, 0, "");

	sort(v.begin(), v.end());
	ll m = v.size();
	rep(i, m) cout << v[i] << endl;

}


Measured memory_bytes: 9332
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main() {
  int n, m; cin >> n >> m;
  vector<string> a(n), b(m);
  REP(i, n) cin >> a[i];
  REP(i, m) cin >> b[i];
  bool yes = false;
  REP(i, n - m + 1) {
    int l = (int)a[i].find(b[0]);
    if (l > -1) {
      yes = true;
      REP(j, m) {
        if (a[i + j].substr(l, m) != b[j]) yes = false;
      }
    }
    if (yes == true) break;
  }
  cout << (yes ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	Int len_s = s.size();

	Int K;
	cin >> K;

	vector<string> raw;

	//Int num = 0;
	string temp;
	map<string, Int> overlap;
	for (Int i = 1; i <= 5; i++) {
		for (Int j = 0; j < len_s-(i-1); j++) {
			temp = s.substr(j, i);
			if (overlap[temp] == 0) {
				overlap[temp]++;
				raw.emplace_back(temp);
			}
		}
	}

	sort(raw.begin(), raw.end());

	cout << raw[K - 1] << endl;

}

Measured memory_bytes: 2048
#include<iostream>
using namespace std;
#define int long long
#define MOD (long long)(1e9+7)
#define MAX_V (long long)(1e5*2+100)

long long MAX_VAL;
long long fac[MAX_V], mmi[MAX_V], temp[MAX_V];

void factorial(){
	fac[0] = fac[1] = 1;
	for(long long i = 2; i < MAX_VAL; fac[i]%=MOD,i++)
		fac[i] = fac[i-1]*(i%MOD);
}


long long power_mod(long long x, long long n){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
		if(n&1)ans*=x;
	return ans%MOD;
}

void modular_multiplicatibe_inverse(){
	mmi[MAX_VAL-1] = power_mod(fac[MAX_VAL-1],MOD-2);
	for(long long i = MAX_VAL-2; i >= 0; mmi[i]%=MOD,i--)
		mmi[i] = mmi[i+1]*((i+1)%MOD);
}

long long combination(long long n, long long r){
	return fac[n]*(mmi[r]*mmi[n-r]%MOD)%MOD;
}

signed main(){
	int H, W, A, B, ans = 0;
	cin>>H>>W>>A>>B;
	MAX_VAL = max(W+H-A-2,A+W-1)+100;
	factorial();
	modular_multiplicatibe_inverse();

	for(int i = B+1; i <= W; ans%=MOD,i++)
		ans += combination(i+H-A-2,H-A-1)*combination(A+W-i-1,W-i)%MOD;
	
	cout<<ans<<endl;

}

Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> inputString = Arrays.asList(br.readLine().split(" "));
            int month = Integer.parseInt(inputString.get(0));
            int day = Integer.parseInt(inputString.get(1));

            int takahashiDayCount = 0;

            for (int i = 1; i <= month; i++) {
                if (i <= day || !(i == month)) {
                    takahashiDayCount += 1;
                }
            }

            System.out.println(takahashiDayCount);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 20948
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();
    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    let xs = line.trim().split_whitespace();
    let mut result = Vec::new();

    for x in xs {
        let ans = x.parse::<T>().map_err(|_| format!("{}", "parse error"))?;
        result.push(ans);
    }
    Ok(result)
}

fn main() {
    let n = read_parameters::<usize>().unwrap();
    let n = n[0];
    let a = read_parameters::<usize>().unwrap();

    for (i, x) in a.iter().rev().enumerate() {
        if i == n - 1 {
            print!("{}\n", x);
        } else {
            print!("{} ", x);
        }
    }
}



Measured memory_bytes: 5040
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    q,h,s,d = LI()
    d = min(d,2*s,4*h,8*q)
    s = min(s,2*h,4*q)
    h = min(h,2*q)
    n = I()
    n *= 4
    ans = d*(n>>3)
    n &= (1<<3)-1
    ans += s*(n>>2)
    n &= (1<<2)-1
    ans += h*(n>>1)
    n &= (1<<1)-1
    ans += q*n
    print(ans)
    return
#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 38512
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		long startTime = System.currentTimeMillis();
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); // 3e5
		int[] A = new int[N];
		int[] cnt = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
			--A[i];
			++cnt[A[i]];
		}
		class Pair {
			long height;
			long duplicate;

			public Pair(long height, long duplicate) {
				this.height = height;
				this.duplicate = duplicate;
			}
		}
		Arrays.sort(cnt);
		ArrayDeque<Pair> dq = new ArrayDeque<>();
		int sz = 0;
		for (int i = 0; i < cnt.length; ++i) {
			if (cnt[i] == 0)
				continue;
			int j = i;
			while (j + 1 < cnt.length && cnt[i] == cnt[j + 1])
				++j;
			dq.addLast(new Pair(cnt[i], j - i + 1));
			sz += j - i + 1;
			i = j;
		}
		dq.addLast(new Pair((long) 1e6, 1));
		long[] ans = new long[N + 1];
		PrintWriter pw = new PrintWriter(System.out);
		long res = 0;
		for (int K = N; K >= 1; --K) {
			if (K > sz)
				continue;
			while (res > 0) {
				if (dq.size() >= 2) {
					Pair p1 = dq.pollFirst();
					Pair p2 = dq.pollFirst();
					if (p1.duplicate * (p2.height - p1.height) <= res) {
						res -= p1.duplicate * (p2.height - p1.height);
						p2.duplicate += p1.duplicate;
						dq.addFirst(p2);
						continue;
					} else if (p1.duplicate <= res) {
						p1.height += res / p1.duplicate;
						res %= p1.duplicate;
						dq.addFirst(p2);
						dq.addFirst(p1);
					} else if (p1.duplicate > res) {
						long d0 = p1.duplicate;
						p1.duplicate = d0 - res;
						Pair p = new Pair(p1.height + 1, res);
						if (p.height == p2.height) {
							p2.duplicate += p.duplicate;
							dq.addFirst(p2);
						} else {
							dq.addFirst(p2);
							dq.addFirst(p);
						}
						dq.addFirst(p1);
						res = 0;
					}
				} else if (dq.size() == 1) {
					throw new AssertionError();
				}
			}
			res += dq.peek().height;
			ans[K] = dq.peek().height;
			dq.peek().duplicate--;
			if (dq.peek().duplicate == 0)
				dq.poll();
		}
		for (int i = 1; i <= N; ++i) {
			pw.println(ans[i]);
		}
		pw.close();
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int a = 0;
    rep(i,0,4){
        int b;
        cin >> b;
        a += b;
    }
    cout << a << "\n";
}


Measured memory_bytes: 3108
#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);
  }
  sort(a.begin(),a.end());
  int ans=100000000;
  for(int i=a.at(0);i<=a.at(n-1);i++){
    int tmp=0;
    for(int j=0;j<n;j++){
      tmp+=(a.at(j)-i)*(a.at(j)-i);
    }
    ans=min(ans,tmp);
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 3584
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;


void main() {
    int n; scan(n);
    auto a = readln.split.to!(long[]);

    long[long] cnt;
    cnt[0] = 1;

    long s;
    long ans;

    foreach (i ; 0 .. n) {
        s += a[i];

        if (s in cnt) {
            ans += cnt[s];
            cnt[s]++;
        }
        else {
            cnt[s] = 1;
        }
    }

    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 25860
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  float T,A;
  cin >> N >> T >> A;
  vector<float> H(N);
  float mi = 99999999;
  float tem;
  int ind = 1;
  for(int i=0; i<N; i++){
    cin >> H.at(i);
    tem = abs(A-(T-(H.at(i)/1000*6)));
    //cout << tem << endl;
    if(mi > tem){
      mi = tem;
      ind = i+1;
    }
  }
  cout << ind << endl;
}

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

int N;
lint res = 0;

int main(){
    cin >> N;
    
    for(int i = 1; i <= N; i++){
        if(N % i == 0) res += N/i-1;  //C0阻止
        else res += N/i;
    }

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


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

const int N = 200005;
int n, a[N], ans[N];
vector<int> e[N], v[2];

void dfs(int x, int fa, int d) {
    v[d].push_back(x);
    for (int to : e[x])
        if (to != fa)
            dfs(to, x, d ^ 1);
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    dfs(1, 0, 0);
    int k1 = n / 3, k2 = n / 3;
    if (n % 3 == 1)
        k1++;
    else if (n % 3 == 2)
        k1++, k2++;
    if (v[0].size() > v[1].size())
        swap(v[0], v[1]);
    if (k1 <= v[0].size() && k2 <= v[1].size()) {
        for (int i = 0; i < k1; i++)
            ans[v[0][i]] = 1;
        for (int i = 0; i < k2; i++)
            ans[v[1][i]] = 2;
    } else {
        for (int i = 0; i < k1; i++)
            ans[v[1][i]] = 1;
        for (int i = k1; i < k1 + k2; i++)
            ans[v[1][i]] = 2;
    }
    int now0 = 3, now1 = 1, now2 = 2;
    for (int i = 1; i <= n; i++) {
        if (!ans[i])
            a[i] = now0, now0 += 3;
        else if (ans[i] == 1)
            a[i] = now1, now1 += 3;
        else
            a[i] = now2, now2 += 3;
    }
    for (int i = 1; i <= n; i++){
        printf("%d ", a[i]);
    }
}


Measured memory_bytes: 22516
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
#include <math.h>
using namespace std;
#define _USE_MATH_DEFINES

int main() {
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0)
			break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 10000; // 998244353;

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 win(int i){
    if(i==0) return 2;
    else if(i==1) return 0;
    else return 1;
}

void Main(){
    int N,K; cin >> N >> K;
    int s[3]; REP(i,3) cin >> s[i];
    VVI T(K);
    REP(i,N){
        char c; cin >> c;
        if(c=='r') T[i%K].push_back(0);
        else if(c=='s') T[i%K].push_back(1);
        else T[i%K].push_back(2);
    }

    int ans = 0;
    REP(i,K){
        if(T[i].empty()) continue;
        int k = T[i].size();
        vector<P> v{P(T[i][0],1)};
        REP(j,k-1){
            if(v.back().first == T[i][j+1]) v.back().second++;
            else v.emplace_back(T[i][j+1],1);
        }
        for(auto& p : v){
            ans += s[win(p.first)] * ((p.second+1)/2);
        }
    }

    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 7888