akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int n;
double x[10], y[10];

int main(){
    cout << setprecision(10) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    double res = 0;
    for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++){
        res += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) * 2 / n;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int A, B;
	char op;
	cin >> A >> op >> B;
	if (op == '+') cout << A + B << endl;
	else cout << A - B << endl;
	return 0;
}

Measured memory_bytes: 3576
import static java.lang.System.*;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner s = new Scanner(in);
		
		int goal = s.nextInt();
		
		int cur = 0;
		int x = 1;
		while(cur<goal)
			cur+= x++;
		
		out.println(x-1);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn = 1e5+10;
int main()
{
    string s;
    cin>>s;
    int len=s.length();
    if(s[len-1]=='s')
        s+='e',s+='s';
    else s+='s';
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    ll N; cin >> N;
    ll ans = 0;
    repm(i, N-1, 0) {
        ans += i;
    }
    cout << ans << endl;
}


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

int main() {
	int n, m; cin >> n >> m;
	vector<bool> check(m, true);
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		vector<bool> v(m, false);
		for (int j = 0; j < k; j++) {
			int a; cin >> a;
			v.at(a - 1) = true;
		}
		for (int j = 0; j < m; j++) {
			if (v.at(j) == false) check.at(j) = false;
		}
	}
	int ans = 0;
	for (int i = 0; i < m; i++) {
		if (check.at(i) == true) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long gcd(long long m, long long n)
{
  while (m>0&&n>0){
    n = n % m;
    if (n>0)
      m = m % n;
  }
  if (n==0)
    return m;
  else
    return n;
}
int main()
{
  long long x,res;
  cin >> x;
  if(x>180)
    x=360-x;
  res=(long long)360/gcd(360,x);
  cout << res << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int n;
  cin >> n;
  vector<ll> a(n + 1), sum(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  ll ret = 1e18;
  for (int i = 1; i < n; i++) {
    ll l = sum[i], r = sum[n] - l;
    ret = min(ret, abs(l - r));
  }
  cout << ret << endl;
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>

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

using namespace std;

int main(){
	int N, M;
	int a[100], b[100], c[100], d[100];
	int min;
	int ind;

	cin >> N >> M;
	for(int i = 0; i < N; i++){
		cin >> a[i] >> b[i];
	}
	for(int i = 0; i < M; i++){
		cin >> c[i] >> d[i];
	}

	for(int i = 0; i < N; i++){
		min = 1000000000;
		ind = 0;
		for(int k = 0; k < M; k++){
			if(min > abs(a[i] - c[k]) + abs(b[i] - d[k])){
				min = abs(a[i] - c[k]) + abs(b[i] - d[k]);
				//cout << " min:" << min;
				ind = k;
			}
		}
		cout << ind + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = [(1/num)*(num)*(num+1)/2 for num in p]
d = deque(p[:k])
result = temp = sum(d)
popleft = d.popleft
dappend = d.append
for el in p[k:]:
    temp -= popleft()
    dappend(el)
    temp += el
    if result < temp:
        result = temp
print(result)

Measured memory_bytes: 25700
n=int(input())
a=list(map(int,input().split()))
x=0

m=[]
for i in range(n):
  m+=[(a[(i+1)%n]-a[i])*2]
#print(x)
#print(m)

ans=[0 for _ in range(n)]
for i in range(1,n):
  ans[2*i%n]=+m[2*(i-1)%n]
for i in range(n-1):
  m[2*(i+1)%n]+=m[2*i%n]
#print(m)
for i in range(n):
  x+=a[i]
  x-=m[2*i%n]
#print(x)
ans[0]=x//n
for i in range(1,n):
  ans[2*i%n]+=ans[2*(i-1)%n]
#print(ans)
for i in range(n-1):
  print(ans[i],end=" ")
print(ans[n-1])

Measured memory_bytes: 66404
import itertools


len_lucky = int(input())
lucky = input()

numbers = ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")

count = 0
for i, j, k in itertools.product(numbers, repeat=3):
    try:
        i_index = lucky.index(i, 0)
        j_index = lucky.index(j, i_index+1)
        k_index = lucky.index(k, j_index+1)
        if min(i_index, j_index, k_index) != -1:
            count += 1
    except ValueError:
        continue

print(count)


Measured memory_bytes: 3064
long a,b;main(i,c){for(;c=getchar()-48,c>0;b=b*10+i*c,i*=2)a+=a+b;printf("%ld",a+b);}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<utility>
#include<queue>
using namespace std;
#define INF 100000000
typedef pair<int, int> P;

void solve() {
	int h, w, m[20][20], ans = 0;
	char s[20][21];
	int dx[] = { 0, 1, 0, -1 }, dy[] = { 1, 0, -1, 0 };
	queue<P> que;
	cin >> h >> w;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			m[i][j] = INF;
	for (int i = 0; i < h; ++i)
		cin >> s[i];

	int nx, ny, res = 0;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (s[i][j] == '.') {
				m[i][j] = 0;
				que.push(P(i, j));
			}
			while (que.size() != 0) {
				P p = que.front(); que.pop();
				for (int i = 0; i < 4; ++i) {
					nx = p.first + dx[i]; ny = p.second + dy[i];
					if (0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] != '#' && m[nx][ny] == INF) {
						que.push(P(nx, ny));
						m[nx][ny] = m[p.first][p.second] + 1;
						res = max(res, m[nx][ny]);
					}
				}
			}
			ans = max(ans, res);
			for (int i = 0; i < h; ++i)
				for (int j = 0; j < w; ++j)
					m[i][j] = INF;
		}

	}

	cout << ans << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int(i)=0 ; (i)<(int)(n) ; ++(i))
#define per(i,n) for(int(i)=(int)(n-1) ; (i)>=0 ; --(i))
#define replu(i,l,u) for(int(i)=(int)(l) ; (i)<=(int)(u) ; ++(i))
#define repul(i,u,l) for(int(i)=(int)(u) ; (i)>=(int)(l) ; --(i))
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
typedef vector<int>  vi ;
typedef pair<int,int> pii ;
typedef vector<pair<int,int> > vpii ;
typedef long long ll ;
const long mod=1e9+7 ;
const ll inf=2e9+10 ;

ll n, m ;
int ans ;
int main() {
  // ios::sync_with_stdio(false) ;
   //cin.tie(NULL) ;
   cin >> n ;
   m = n ;
   int sum=0, len = 0 ;
   while(m) {
      len++ ;
      sum += m%10 ;
      m/=10 ;
   }
   ans = sum ;
   rep(i,len) {
       sum-=n%10 ;
       ans = max(ans, sum + 9*i + (int)n%10 -1) ;
       n/=10 ;
   }
   cout << ans << "\n" ;
   return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int frower[7][2] = {{0,0},{2,380},{3,550},{5,850},{10,1520},{12,1870},{15,2244}};
  int dp[51][7] = {0};
  for(int i=0; i<51; i++){
    for(int j=1; j<7; j++){
      if(!i){
	for(int k=1;k*frower[j][0]<51;k++){
	  if(!dp[k*frower[j][0]][j]){dp[k*frower[j][0]][j] = frower[j][1]*k;}
	  else{dp[k*frower[j][0]][j] = min(dp[k*frower[j][0]][j],frower[j][1]*k);}
	}
      }
      else{
	if(dp[i][j-1]){
	  for(int k=0;i+k*frower[j][0]<51;k++){
	    if(!dp[i+k*frower[j][0]][j]){dp[i+k*frower[j][0]][j] = dp[i][j-1]+frower[j][1]*k;}
	    else{dp[i+k*frower[j][0]][j] = min(dp[i+k*frower[j][0]][j],dp[i][j-1]+frower[j][1]*k);}
	  }
	}
      }
    }
  }
  int n;
  while(cin>>n,n){
    for(int i=n/100; i<51; i++){
      if(dp[i][6]){cout <<dp[i][6]<<endl;break;}
    }
  }
  return 0;
}

Measured memory_bytes: 1160
import itertools
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]
M_chr = []
for i in range(1,M+1):
    M_chr.append(i)
As = list(itertools.combinations_with_replacement(M_chr, N))
pointA_max = 0
for i, A in enumerate(As):
    pointA = 0
    for i in range(Q):
        if A[abcd[i][1]-1]-A[abcd[i][0]-1] == abcd[i][2]:
            pointA = pointA + abcd[i][3]
    if pointA_max < pointA:
        pointA_max = pointA
print(pointA_max)

Measured memory_bytes: 21388
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	int S[2000], T[2000];
	rep(i, N) cin >> S[i];
	rep(i, M) cin >> T[i];

	int mod = 1e9 + 7;
	int dp[4001];
	int dpsa[4001] = {};

	rep(i, N + M + 1) dp[i] = 1;
	for (int i = N; i > 0; i--) {
		for (int j = i; j < i + M; j++) {
			if (S[N - i] == T[j - i]) {
				dp[j] = dp[j - 1] + dp[j + 1];
				dpsa[j] = dp[j + 1];
			}
			else {
				dp[j] = dp[j - 1] + dpsa[j + 1];
				dpsa[j] = dpsa[j + 1];
			}
			if (dp[j] >= mod) dp[j] -= mod;
		}
	}
	co(dp[M]);

	Would you please return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    for(int i = 0; i < R; ++i){
        cin >> r[i];
        --r[i];
    }
    vector<vector<int>> dist(N, vector<int>(N, INF));
    for(int i = 0; i < M; ++i){
        int u, v, c;
        cin >> u >> v >> c;
        --u, --v;
        dist[u][v] = dist[v][u] = c;
    }
    for(int i = 0; i < N; ++i)  dist[i][i] = 0;
    
    for(int k = 0; k < N; ++k){
        for(int i = 0; i < N; ++i){
            for(int j = 0; j < N; ++j){
                chmin(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    sort(r.begin(), r.end());
    ll ans = 1e+15;
    do {
        ll total = 0;
        for(int i = 0; i + 1 < R; ++i){
            total += dist[r[i]][r[i + 1]];
        }
        chmin(ans, total);
    } while(next_permutation(r.begin(), r.end()));

    cout << ans << endl;
}

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

int main() {
int N;
  cin >> N;
if(N % 10 == 2||N % 10 == 4||N % 10 == 5||N % 10 == 7||N % 10 == 9)cout << "hon" << endl;
if(N % 10 == 0||N % 10 == 1||N % 10 == 6||N % 10 == 8)cout << "pon" << endl;
  if(N % 10 == 3)cout << "bon" << endl;


}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int n;
double item_dist[21][21];
double boss_dist[20];

double distance(pii a, pii b) {
    return hypot(a.first - b.first, a.second - b.second);
}

bool dfs(int p, double t, int remain) {
    if (remain == 0) return true;
    REP(i, n) {
        if (remain & (1 << i)) {
            double next_t = t + item_dist[i][p];
            REP(j, n) {
                if(remain & (1 << j) && next_t + item_dist[i][j] >= boss_dist[j]) goto next;
            }
            if(dfs(i, next_t, remain & ~(1 << i))) return true;
        next : {}
        }
    }
    return false;
}

int main() {
    int x, y, hx, hy;
    while (cin >> n >> x >> y >> hx >> hy, n|x|y|hx|hy) {
        fill_n((int *)item_dist, 21*21, 0);
        fill_n((int *)boss_dist, 21*21, 0);

        vector<pii> items;
        REP(i, n) {
            int a, b;
            cin >> a >> b;
            items.push_back({a, b});
        }
        items.push_back({x, y});
        REP(i, n+1) {
            FOR(j, i+1, n+1) {
                item_dist[i][j] = item_dist[j][i] = distance(items[i], items[j]);
            }
        }
        REP(i, n) {
            boss_dist[i] = distance(items[i], {hx, hy});
        }

        if (dfs(n, 0.0, (1 << n)-1)) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

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

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

ll n , k ;
ll ans = 0;

int main(){
    migmig
	cin >> n >> k;
	if(k == 0)dokme(n*n);
    for(int i = k+1 ; i<= n ;i ++){
		ll boz = (n / i);
		ll rmn = n-  (n/i)*i;
		ans+=(i - k)*boz;
		ans+=max(rmn - k + 1, 0LL);
	}
    cout << ans;
    return(0);
}

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

int main()
{
	int N,Y,x,y,z;
	
	cin>>N>>Y;
	
	for(x=0;x<=Y/10000;x++)
	  for(y=0;y<=Y/5000;y++)
	  {
	  	z=N-x-y;
	  	if(z>=0 &&x*10000+y*5000+z*1000==Y)
	  	{
	  		cout<<x<<" "<<y<<" "<<z;
	  		return 0;
	  	}
	  }
	  cout<<"-1 -1 -1"<<endl;
	  return 0;
}

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

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

int showAll(vector<char> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
  return 0;
}

int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  map<int, int>::iterator itr;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    itr = mp.find(tmp);
    if (itr != mp.end()) mp[tmp]++;
    else mp[tmp] = 1;
  }

  long count = 0;
  for (itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->first > itr->second) {
      count += itr->second;
    } else if (itr->first < itr->second) {
      count += (itr->second - itr->first);
    }
  }


  cout << count << endl;


  return 0;
}



Measured memory_bytes: 4736
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const string hand = "rsp";

ll solve(const string& T, const vector<int>& gain) {
  vector<ll> dp(3, 0);
  for (char c : T) {
    vector<ll> ndp(3, 0);
    int e = hand.find_first_of(c);
    for (int p = 0; p < 3; p++) {
      for (int x = 0; x < 3; x++) {
        if (x == p) continue;
        if ((x + 1) % 3 == e) {
          chmax(ndp[x], dp[p] + gain[x]);
        } else {
          chmax(ndp[x], dp[p]);
        }
      }
    }
    dp.swap(ndp);
  }
  return *max_element(dp.begin(), dp.end());
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K, R, S, P;
  string T;
  while (cin >> N >> K >> R >> S >> P >> T) {
    vector<int> gain = {R, S, P};
    ll res = 0;
    for (int s = 0; s < K; s++) {
      string sub = "";
      for (int i = s; i < N; i += K) {
        sub += T[i];
      }
      res += solve(sub, gain);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 640
N = int(input())
D = list(map(int, input().split()))
D.append(0)
D.sort()
min_v = D[1]
for i in range(1,N+1):
  D[i]=D[i] if i&1 else 24-D[i]
D.sort()
for i in range(1, N+1):
  min_v = min(min_v, D[i] - D[i - 1])
print(min_v)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);

        final String[] str = scanner.nextLine().split(" ");
        final int n = Integer.parseInt(str[0]);
        final int m = Integer.parseInt(str[1]);

        final int[] breaks = new int[m];
        for (int i = 0; i < m; i++) {
            breaks[i] = Integer.parseInt(scanner.nextLine());
        }

        final Long[] counts = new Long[n];
        for (int i = 0; i < breaks.length; i++) {
            counts[breaks[i] - 1] = 0L;
        }

        if (counts[0] == null) counts[0] = 1L;
        if (counts.length == 1) {
            System.out.println(counts[0]);
            return;
        }

        if (counts[1] == null) counts[1] = 1L + counts[0];
        for (int i = 2; i < counts.length; i++) {
            if (counts[i] != null) continue;
            counts[i] = (counts[i - 1] + counts[i - 2]) % 1000000007L;
        }

        System.out.println(counts[counts.length - 1]);

    }
}

Measured memory_bytes: 91540
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner n = new Scanner(System.in);
		int a = n.nextInt();
		int b = n.nextInt();
		int c = n.nextInt();
		
		if( a < b && b < c ) {
			System.out.println( "Yes" );
		}
		else {
			System.out.println( "No" );
		}
		
	}

}

Measured memory_bytes: 26320
using System;

namespace ITP1_8_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            foreach (var c in str)
            {
                if (char.IsLower(c)) Console.Write(char.ToUpper(c));
                else if (char.IsUpper(c)) Console.Write(char.ToLower(c));
                else Console.Write(c);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9112
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int a1 = 0;
		int a2 = 0;
		int mi = 0;
		for (int i = 0; i < n; i++) {
			int a = in.nextInt();
			if (a2 > a)
				continue;
			a2 = a;
			if (a1 < a2) {
				int t = a1;
				a1 = a2;
				a2 = t;
				mi = i;
			}
		}
		for(int i=0;i<n;i++)
			if(i==mi)
				System.out.println(a2);
			else
				System.out.println(a1);
		in.close();
	}
}


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

int main(){

  char abc[27] = "abcdefghijklmnopqrstuvwxyz";
  bool flag = false, ans_flag = true;
  string s;
  cin >> s;
  int n = s.size();

  for(int i=0; i<26; i++){
    flag = false;
    for(int j=0; j<n; j++){
      if(abc[i]==s[j]){
        flag = true;
      }
    }
    if(!flag){
      cout << abc[i] << endl;
      ans_flag = false;
      break;
    }
  }
  if(ans_flag){
    cout << "None" << endl;
  }
  
  return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	int n = 0;
	string s = "";
	cin >> n >> s;
	int m = 0;
	int x = 0;

	REP(i, n)
	{
		if (s[i] == 'I')
		{
			x++;
		}
		else
		{
			x--;
		}
		m = max(x, m);
	}

	COUT(m);

	return 0;
}

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

static const int NIL = -1;

class TreeNode {
public:
    int parent;
    int left;
    int right;
    TreeNode() : parent(NIL), left(NIL), right(NIL) {}
};

void SetDepth(vector<TreeNode>& tree, vector<int>& depth, int i, int d)
{
    if (i == NIL) return;
    depth[i] = d;
    SetDepth(tree, depth, tree[i].left, d + 1);
    SetDepth(tree, depth, tree[i].right, d + 1);
}

int SetHeight(vector<TreeNode>& tree, vector<int>& height, int i)
{
    if (i == NIL) return -1;
    int hl = SetHeight(tree, height, tree[i].left);
    int hr = SetHeight(tree, height, tree[i].right);
    height[i] = 1 + max(hl, hr);
    return height[i];
}

int main()
{
    int n;
    cin >> n;
    vector<TreeNode> tree(n);
    vector<int> depth(n, 0);
    vector<int> height(n, 0);
    for (int i = 0; i < n; i++) {
        int id, left, right;
        cin >> id >> left >> right;
        tree[id].left = left;
        tree[id].right = right;
        tree[left].parent = id;
        tree[right].parent = id;
    }
    int root;
    for (int i = 0; i < n; i++) {
        if (tree[i].parent == NIL)
            root = i;
    }

    SetDepth(tree, depth, root, 0);
    SetHeight(tree, height, root);

    for (int i = 0; i < n; i++) {
        cout << "node " << i << ": parent = " << tree[i].parent << ", sibling = ";
        if (tree[i].parent != NIL) {
            if (tree[tree[i].parent].left == i) {
                cout << tree[tree[i].parent].right;
            } else {
                cout << tree[tree[i].parent].left;
            }
        } else {
            cout << -1;
        }
        cout << ", degree = ";
        int degree = (tree[i].left != NIL ? 1 : 0) + (tree[i].right != NIL ? 1 : 0);
        cout << degree << ", depth = " << depth[i] << ", height = " << height[i] << ", ";
        if (tree[i].parent == NIL) {
            cout << "root";
        } else if (tree[i].left == NIL && tree[i].right == NIL) {
            cout << "leaf";
        } else {
            cout << "internal node";
        }
        cout << endl;
    }

}



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

main(){
  char S[100];
  for(int ii=0;ii<100;ii++){
    S[ii]=0;
  }
  cin >> S;
  int n;//桁数
  for(int ii=0;ii<100;ii++){
    if(S[ii]==0){
      n=ii-1;
      break;
    }
  }//keyence
  int ans=0;
  if(S[n-6]=='k'&&S[n-5]=='e'&&S[n-4]=='y'&&S[n-3]=='e'&&S[n-2]=='n'&&S[n-1]=='c'&&S[n]=='e')ans=1;
  if(S[0]=='k'&&S[n-5]=='e'&&S[n-4]=='y'&&S[n-3]=='e'&&S[n-2]=='n'&&S[n-1]=='c'&&S[n]=='e')ans=1;
  if(S[0]=='k'&&S[1]=='e'&&S[n-4]=='y'&&S[n-3]=='e'&&S[n-2]=='n'&&S[n-1]=='c'&&S[n]=='e')ans=1;
  if(S[0]=='k'&&S[1]=='e'&&S[2]=='y'&&S[n-3]=='e'&&S[n-2]=='n'&&S[n-1]=='c'&&S[n]=='e')ans=1;
  if(S[0]=='k'&&S[1]=='e'&&S[2]=='y'&&S[3]=='e'&&S[n-2]=='n'&&S[n-1]=='c'&&S[n]=='e')ans=1;
  if(S[0]=='k'&&S[1]=='e'&&S[2]=='y'&&S[3]=='e'&&S[4]=='n'&&S[n-1]=='c'&&S[n]=='e')ans=1;
  if(S[0]=='k'&&S[1]=='e'&&S[2]=='y'&&S[3]=='e'&&S[4]=='n'&&S[5]=='c'&&S[n]=='e')ans=1;
  if(S[0]=='k'&&S[1]=='e'&&S[2]=='y'&&S[3]=='e'&&S[4]=='n'&&S[5]=='c'&&S[6]=='c')ans=1;
  if(ans==0)cout << "NO" << endl;
  else cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
	float a, b, c, d, e, f;
	float x, y;

	while ( scanf( "%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f ) != EOF )
	{
		x = (float)(( c*e - f*b ) / ( e*a - b*d ));
		y = (float)(( d*c - a*f ) / ( d*b - a*e ));
		if ( -0.0005 <= x && x <= 0 ) x = 0;
		if ( -0.0005 <= y && y <= 0 ) y = 0;
		fprintf( stdout, "%.3f %.3f\n", x, y );
	}

	return 0;
}

Measured memory_bytes: 648
#include <iostream>

using namespace std;
void swap(int &a,int &b){
  int tmp = a;
  a = b;
  b = tmp;
}
int main(int argc, char const *argv[]) {
  int count;
  cin >> count;
  int *a = new int[count];
  for (int i = 0; i < count; i++) {
    cin >> a[i];
  }
  int swap_count = 0;
  for (int i = 0; i < count; i++) {
    int miniIdx = i;
    for (int j = i; j < count; j++) {
      if( a[j] < a[miniIdx]){
        miniIdx = j;
      }
    }
    if(i != miniIdx){
      swap(a[i], a[miniIdx]);
      swap_count++;
    }
  }
  for(int i = 0; i < count; i++){
    cout << a[i];
    if (i == count - 1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
  cout << swap_count << endl;
  delete [] a;
  return 0;
}

Measured memory_bytes: 3096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp5
{
 
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] S1 = str.Split(' ');
            int N = int.Parse(S1[0]);
            int Q = int.Parse(S1[1]);
            string S = Console.ReadLine();
            char[] C = new char[N];
 
            for(int i = 0; i < N - 1; i++)
            {
                if (S[i] == 'A' && S[i+1] == 'C')
                {
                    C[i] = 'a';
                }
                else
                {
                    C[i] = S[i];
                }
            }
            C[N-1] = S[N-1];
 
            int[] t = new int[N];
            for(int i = 1; i<N; i++)
            {
                if(C[i-1] == 'a')
                {
                    t[i]++;
                }
                if(i<N-1){
                	t[i+1] = t[i];
                }
            }
 
            for (int i = 0; i < Q; i++)
            {
                str = Console.ReadLine();
                string[] S2 = str.Split(' ');
                int l = int.Parse(S2[0]);
                int r = int.Parse(S2[1]);
                Console.WriteLine(t[r - 1] - t[l - 1]);
 
            }
 
        }
    }
}

Measured memory_bytes: 16584
package main

import (
	"fmt"
)

func euc(a,b int64) int64 {
	r := int64(a%b)
	x := int64(b)
	for ; r != 0; {
		x, r = r, x%r
	}
	return x
}

func main() {
	var a,b,c,d int64
	fmt.Scan(&a,&b,&c,&d)

	cd := c*d/euc(c,d)
	cdiv := b/c - a/c
	ddiv := b/d - a/d
	com := b/cd - a/cd

	if a%c == 0 {
		cdiv++
	}

	fmt.Println(b-a+1-cdiv-ddiv+com)
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, h, m float64
	fmt.Scan(&a, &b, &h, &m)

	mx := b * math.Cos(6*m*math.Pi/180)
	my := b * math.Sin(6*m*math.Pi/180)

	hrad := 360*(h/12) + 30*(m/60)
	hx := a * math.Cos(hrad*math.Pi/180)
	hy := a * math.Sin(hrad*math.Pi/180)

	calc := (mx-hx)*(mx-hx) + (my-hy)*(my-hy)
	fmt.Println(math.Sqrt(calc))
}


Measured memory_bytes: 1820
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	long long n;
	cin >> n;
	vector<int> a;
	a.resize(n + 1, 0);
	for (long long i = 1; i <= n; ++i) {
		cin >> a[i];
	}

	long long countb = 0;
	vector<int> b;
	b.resize(n + 1, 0);
	for (long long i = n; 0 < i; --i) {
		if (n < i * 2) {
			if (a[i] == 1) {
				b[i] = 1;
				++countb;
			}
			continue;
		}

		int count = 0;
		long long temp = i;
		while (temp <= n) {
			count += b[temp];
			temp += i;
		}

		if (count % 2 == 1) {
			if (a[i] == 0) {
				b[i] = 1;
				++countb;
			}
		}
		else {
			if (a[i] == 1) {
				b[i] = 1;
				++countb;
			}
		}
	}

	cout << countb << endl;
	string s;
	for (long long i = 1; i <= n; ++i) {
		if (b[i] == 1) {
			ostringstream oss;
			oss << i;
			s += oss.str();
			s += " ";
		}
	}
	if (!s.empty()) {
		s.pop_back();
		cout << s << endl;
	}

	return 0;
}

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

class Program {
    static void Main (string[] args) {
        char[] S = Console.ReadLine ().ToCharArray ();
        char[] T = Console.ReadLine ().ToCharArray ();
        long ans = 0;
        for (int i = 0; i < S.Length; i++) {
            if (S[i] != T[i]) {
                ans++;
            }
        }
        Console.WriteLine (ans);

    }

}

//dotnet run --project test

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
    ll x;
cin>>x;
ll A = x/100 , B = x % 100;
int a=1;
if(B%5==0)a--;
if(A >= B/5 + a){
    cout<<1<<endl;
}else
{
    cout<<0<<endl;
}

    return 0;
}


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

using namespace std;

int main()
{
string s;
cin>>s;
if(s=="SUN")
cout<<"7"<<endl;
else if(s=="MON")
cout<<"6"<<endl;
else if(s=="TUE")
cout<<"5"<<endl;
else if(s=="WED")
cout<<"4"<<endl;
else if(s=="THU")
cout<<"3"<<endl;
else if(s=="FRI")
cout<<"2"<<endl;
else if(s=="SAT")
cout<<"1"<<endl;

}

Measured memory_bytes: 256
using System;

namespace abc122_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            int max = 0;

            string array = Console.ReadLine();

            for(int i=0; i<array.Length; i++)
            {
                char ch = array[i];
                if(ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T')
                {
                    count += 1;
                }
                else
                {
                    if (max < count)
                    {
                        max = count;
                    }
                    count = 0;
                }
                if (max < count)
                {
                    max = count;
                }
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13140
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n,m;
int rt[300005],sizee[300005];
void initialize()
{
    for(int i=0;i<=n+2;i++)
    {
        rt[i]=i;
        sizee[i]=1;
    }
}
int root(int i)
{
    while(rt[i]!= i)
    {
        rt[i]=rt[rt[i]]; 
        i=rt[i];
    }
    return i;
}
void merge(int A,int B)
{
    int root_A = root(A);
    int root_B = root(B);
    if(rt[root_A]==rt[root_B])
        return;
    if(sizee[root_A] < sizee[root_B])
    {
        rt[root_A] = rt[root_B];
        sizee[root_B] += sizee[root_A];
    }
    else
    {
        rt[root_B] = rt[root_A];
        sizee[root_A] += sizee[root_B];
    }
}
int32_t main()
{
    IOS;
    cin>>n>>m;
    initialize();
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        merge(a,b);
    }
    int maxi=0;
    for(int i=1;i<=n;i++)
        maxi=max(maxi,sizee[root(i)]);
    print(maxi);
}


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

using namespace std;
using ll = long long;

int dh[4] = { 1, 0, -1, 0 };
int dw[4] = { 0, 1, 0, -1 };

int main() {
	int H, W;
	cin >> H >> W;
	int Ch, Cw, Dh, Dw;
	cin >> Ch >> Cw >> Dh >> Dw;
	Ch--; Cw--; Dh--; Dw--;
	vector<string> field(H);
	for (int i = 0; i < H; i++) cin >> field[i];

	vector<vector<bool>> seen(H, vector<bool>(W, false));
	queue<pair<int, int>> q1, q2;
	seen[Ch][Cw] = true;
	q1.push(make_pair(Ch, Cw));
	bool ok = true;
	int warp = 0;
	while (ok) {
		ok = false;
		while (!q1.empty()) {
			ok = true;
			pair<int, int> p = q1.front();
			q2.push(p);
			int h = p.first;
			int w = p.second;
			q1.pop();
			for (int dir = 0; dir < 4; dir++) {
				int nh = h + dh[dir];
				int nw = w + dw[dir];
				if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
				if (seen[nh][nw]) continue;
				if (field[nh][nw] == '#') continue;
				seen[nh][nw] = true;
				q1.push(make_pair(nh, nw));
			}
		}

		if (seen[Dh][Dw]) break;
		

		while (!q2.empty()) {
			pair<int, int> p = q2.front();
			int h = p.first;
			int w = p.second;
			q2.pop();
			for (int i = -2; i <= 2; i++) {
				for (int j = -2; j <= 2; j++) {
					int nh = h + i;
					int nw = w + j;
					if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
					if (seen[nh][nw]) continue;
					if (field[nh][nw] == '#') continue;
					seen[nh][nw] = true;
					q1.push(make_pair(nh, nw));
				}
			}
		}
		warp++;
	}
	if (seen[Dh][Dw]) cout << warp << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 5720
#include <bits/stdc++.h>
#define    ll long long
using namespace std;
const int maxn  = 2000005;
int mp[405][405];
int vis[405][405];
int dis[405][405];
char a[30][30];
int main()
{
   int n,m;
   cin>>n>>m;
   for(int i=0;i<n;i++)
        cin>>a[i];
   for(int i=0;i<n*m;i++){
        for(int j=0;j<n*m;j++)
            dis[i][j] = maxn;
        dis[i][i] = 0;
   }

   //cout<<1111<<endl;
   for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            if(a[i][j]=='.'){
                if(i>0&&a[i-1][j]=='.')     dis[(i-1)*m+j][i*m+j] = 1,dis[(i)*m+j][(i-1)*m+j] = 1;
                if((i+1)<n&&a[i+1][j]=='.') dis[(i+1)*m+j][i*m+j] = 1,dis[(i)*m+j][(i+1)*m+j] = 1;
                if(j>0&&a[i][j-1]=='.')     dis[i*m+j][(i)*m+j-1] = 1,dis[(i)*m+j-1][(i)*m+j] = 1;
                if((j+1)<m&&a[i][j+1]=='.') dis[i*m+j][(i)*m+j+1] = 1,dis[(i)*m+j+1][(i)*m+j] = 1;
            }

    for(int i=0;i<(n*m);i++){
        if(a[i/m][i%m]=='#') continue;
        for(int j=0;j<(n*m);j++){// cout<<222<<endl;
            if(a[j/m][j%m]=='#') continue;
            for(int l=0;l<(n*m);l++){
                if(a[l/m][l%m]=='#') continue;
                if(dis[i][j]>dis[i][l]+dis[l][j]){
                    dis[i][j]=dis[i][l]+dis[l][j];
                }
            }
        }

    }
     for(int i=0;i<(n*m);i++){
        if(a[i/m][i%m]=='#') continue;
        for(int j=0;j<(n*m);j++){// cout<<222<<endl;
            if(a[j/m][j%m]=='#') continue;
            for(int l=0;l<(n*m);l++){
                if(a[l/m][l%m]=='#') continue;
                if(dis[i][j]>dis[i][l]+dis[l][j]){
                    dis[i][j]=dis[i][l]+dis[l][j];
                }
            }
        }

    }
    for(int i=0;i<(n*m);i++){
        if(a[i/m][i%m]=='#') continue;
        for(int j=0;j<(n*m);j++){// cout<<222<<endl;
            if(a[j/m][j%m]=='#') continue;
            for(int l=0;l<(n*m);l++){
                if(a[l/m][l%m]=='#') continue;
                if(dis[i][j]>dis[i][l]+dis[l][j]){
                    dis[i][j]=dis[i][l]+dis[l][j];
                }
            }
        }

    }
    for(int i=0;i<(n*m);i++){
        if(a[i/m][i%m]=='#') continue;
        for(int j=0;j<(n*m);j++){// cout<<222<<endl;
            if(a[j/m][j%m]=='#') continue;
            for(int l=0;l<(n*m);l++){
                if(a[l/m][l%m]=='#') continue;
                if(dis[i][j]>dis[i][l]+dis[l][j]){
                    dis[i][j]=dis[i][l]+dis[l][j];
                }
            }
        }

    }
    int minn = 0;
    for(int i=0;i<(n*m);i++){
        if(a[i/m][i%m]=='#') continue;
        for(int j=0;j<(n*m);j++){
            if(a[j/m][j%m]=='#') continue;
           // cout<<i/m<<" "<<i%m<<endl;
           //  cout<<j/m<<" "<<j%m<<":  ";
           // cout<<dis[i][j]<<endl;
            if(dis[i][j]<10000)
                minn = max(minn,dis[i][j]);
        }
    }
    cout<<minn<<endl;


}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	long long q,h,s,d;
	scanf("%lld %lld %lld %lld",&q,&h,&s,&d);
	long long n;
	scanf("%lld",&n);
	long long temp=min(s,min(2*h,min(h+2*q,4*q)));
	if(2*temp<=d)
	{
		printf("%lld\n",n*temp);
	}
	else
	{
		if(n%2!=0)
			printf("%lld\n",temp+(n/2)*d);
		else
			printf("%lld\n",(n/2)*d);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int zh(string x)
{
	int k=0;
	for(int i=0;i<x.size();i++)
		k=k*10+x[i]-'0';
	return k;
}
int main()
{
	string a,b;
	int ans=0;
	cin>>a>>b;
	a+=b;
	ans=zh(a);
	if(sqrt(ans)==int(sqrt(ans)))cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int n = s.length();
		int k = sc.nextInt();
		List<String> list = new ArrayList<>();

		for (int i = 1; i <= k; i++) {
			for (int j = 0; j < n - i + 1; j++) {
				String tmp = s.substring(j, j + i);
				list.add(tmp);
			}
		}

		Collections.sort(list);
		Set<String> set = new LinkedHashSet<String>();
		set.addAll(list);

		String[] array = set.toArray(new String[set.size()]);

		System.out.println(array[k - 1]);

		sc.close();
	}
}


Measured memory_bytes: 25404
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())



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

ll X,Y,Z,K;
ll pmax = 30000000000;
vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

ll gcd(ll m, ll n){
  if(m<n) swap(m,n);
  if(n==0) return m;
  return gcd(n, m%n);
}



int main() {



  ll N;
  cin>>N;
  vint a(N,0);
  rep(i,N){cin>>a[i];}

  vint l(N,0),r(N,0);
  l[0]=a[0];
  r[N-1]=a[N-1];

  repf(i,1,N){
    l[i]=gcd(l[i-1], a[i]);
    r[N-1-i]=gcd(r[N-i], a[N-1-i]);
  }

  ll ans = r[1];
  ans = max(l[N-2], ans);

  repf(i,1,N-1){
    ll tmp = gcd(l[i-1], r[i+1]);
    ans = max(tmp, ans);
  }
  cout << ans << endl;

}

















//


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	int cnt1=0,cnt2=0,amari=n%9;
	int ans=1e9;
	for(int i=n/9;i>=0;--i){
		int m=n-i*9,k=m%6;
		cnt1=i;
		cnt2=m/6;
		while(cnt2>0){
			k+=cnt2%6;
			cnt2/=6;
		}
		while(cnt1>0){
			k+=cnt1%9;
			cnt1/=9;
		}
		ans=min(k,ans);
	}
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
N = INT()
A = LIST()
i = 0
C = [[0] * W for i in range(H)]
k = 0
cnt = 0
for h in range(H):
    if h % 2 == 0:
        for w in range(W):
            C[h][w] = k + 1
            A[k] -= 1
            if A[k] == 0:
                k += 1
    else:
        for w in range(W-1, -1, -1):
            C[h][w] = k + 1
            A[k] -= 1
            if A[k] == 0:
                k += 1

for c in C:
    print(*c, end="\n")







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

int main(){
	int N, W, volume[100001], value[100001];
	long long** dp = new long long*[102];
	for(int i=1; i<=101; i++) dp[i] = new long long[100001];
	for(int i=1; i<=101; i++){
		for(int j=0; j<=100000; j++){
			dp[i][j] = 0;
		}
	}
	
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	cin >> N >> W;
	for(int i=1; i<=N; i++) cin >> volume[i] >> value[i];
	
	for(int obj=1; obj<=N; obj++){
		for(int vol=0; vol<=W; vol++){
			if(volume[obj] > vol)
				dp[obj+1][vol] = dp[obj][vol];
			else
				dp[obj+1][vol] = max(dp[obj][vol], dp[obj][vol-volume[obj]]+value[obj]);
		} 
	}
	
	cout << dp[N+1][W] << '\n';    //lel
}

Measured memory_bytes: 82824