akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"

using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
//#define int long long
using vi=vector<int>;
using vvi=vector<vi>;

//#define INF 0x3f3f3f3f


const int MAX = (1 << 20) + 1;
int cost[MAX], dp[MAX];
bool indx[MAX], indy[MAX];

bool E[41][41];

const int MAX_N = 41;
int weight[MAX_N];
vector<int> G[MAX_N];
int N;
int dfs(long long flag, int w) {
	//cerr << bitset<7>(flag) << " " << w << endl;
	if ((1LL << N) - 1 == flag)return w;
	int v = 0;
	//int x = ~flag;
	//x& (-x);
	rep(i, 0, N) {
		if (!(flag >> i & 1)) {
			v = i;
			break;
		}
	}
	int deg = 0;
	int max_weight = weight[v];
	for (auto x : G[v])
		if (!(flag >> x & 1)) {
			deg++;
			max_weight = max(max_weight, weight[x]);
		}
	int ret = 0;
	// v を使わない
	flag |= 1LL << v;
	if (v != 0 && (deg >= 2 || max_weight > weight[v])) {
		ret = dfs(flag, w);
	}
	// v を使う
	for (auto x : G[v])
		flag |= 1LL << x;
	ret = max(ret, dfs(flag, w + weight[v]));
	return ret;
}

signed main() {

	for (; cin >> N && N;) {
		vector<string> A(N);
		vector<int> B(N), C(N);
		vector<vector<string>> D(N);

		rep(i, 0, N) {
			cin >> A[i] >> B[i] >> C[i];
			D[i].assign(C[i], "");
			rep(j, 0, C[i]) {
				cin >> D[i][j];
			}
		}

		map<string, int> id;
		rep(i, 0, N)id[A[i]] = i;

		rep(i, 0, N)
			G[i].clear();
		rep(i, 0, N)rep(j, 0, C[i]) {
			G[i].push_back(id[D[i][j]]);
		}

		rep(i, 0, N)
			weight[i] = B[i];

		cout << dfs(0, 0) << endl;

	}

	return 0;
}


Measured memory_bytes: 3320
N = list(input().split())
A = int(N[0])
b1,b2 = N[1].split('.')
B = int(b1+b2)
prd = list(str(A*B))
ans = 0
if len(prd) < 3:
    ans = 0
else:
    prd.pop()
    prd.pop()
    ans = int(''.join(prd))
print(ans)


Measured memory_bytes: 8916
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000000007;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) {return b?gcd(b, a%b):a;}
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans*(b&1?a:1);
}
inline constexpr int modpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
template<class T> inline bool chmax(T& a,T b) {if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b) {if(a>b){a=b;return 1;} return 0;}
const ll LINF=0x1fffffffffffffff;

struct unionfind{
    vector<ll> d;
    unionfind(ll x):d(x,-1){}
    ll root(ll x) {return d[x]<0?x:d[x]=root(d[x]);}
    ll size(ll x) {return -d[root(x)];};
    bool unite(ll x,ll y) {x=root(x),y=root(y); if(x!=y){if(d[x]>d[y])swap(x,y);d[x]+=d[y];d[y]=x;}return x!=y;}
    bool find(ll x,ll y) {return root(x)==root(y);}
};
int main(){
    ll n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<ll> l(q),r(q),rui(n);
    rep(i,0,q) cin>>l[i]>>r[i];
    rep(i,0,n-1){
        if(s[i]-'A')continue;
        if(s[i+1]-'C')continue;
        rep(j,i+1,n) rui[j]++;
    }
    rep(i,0,q){
        cout<<rui[r[i]-1]-rui[l[i]-1]<<"\n";
    }
}



Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>

using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;

	int T;
	cin >> T;

	int ans = 999999;
	for (int i = 0; i < n; i++)
	{
		int c, t;
		cin >> c >> t;

		if (t <= T)
		{
			ans = min(ans, c);
		}
	}
	if (ans == 999999)
	{
		cout << "TLE\n";
	}
	else
	{
		cout << ans << "\n";
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define F first
#define S second
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n = 0, k = 0;
  cin >> n >> k;
  ll ar[n];
  ll ans = 0;
  for (ll i = 0; i < n; ++i) cin >> ar[i];
  sort(ar, ar + n);
  for (ll i = 0; i < n - k; ++i) {
    ans += ar[i];
  }
  cout << ans;
}



Measured memory_bytes: 5208
import std.stdio;
import std.conv;
import std.string;

void main()
{
    int[] input = readln.split.to!(int[]);
    int k = input[0];
    int s = input[1];
    long ans = 0;

    foreach_reverse (i; 0..k + 1) {
        foreach_reverse (j; 0..k + 1) {
            auto tmp = s - i - j;
            if (tmp <= k && tmp >= 0){
                ans++;
            }
        }
    }

    writeln(ans);
}


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

signed main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k % 2) cout << b - a << endl;
  else cout << a - b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n, i, ryo1, ryo2, ryo3, yen, sum;
	int a[100000];

	scanf("%d", &n);
	a[0]=0;
	for(i=1; i<=n; i++){
		scanf("%d", &a[i]);
	}
	a[n+1]=0;

	sum = 0;
	yen = 0;
	for(i=0; i<=n; i++){
		yen = a[i+1]-a[i];
		if(yen < 0){
			yen *= -1;
		}
		sum += yen;
	}

	for(i=0; i<n; i++){
		ryo1 = a[i+1] - a[i];
		ryo2 = a[i+2] - a[i+1];
		ryo3 = a[i+2] - a[i];
		if(ryo1<0){
			ryo1 *= -1;
		}
		if(ryo2<0){
			ryo2 *= -1;
		}
		if(ryo3<0){
			ryo3 *= -1;
		}
		printf("%d\n", sum-ryo1-ryo2+ryo3);
	}

	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>
#include <complex>
#include <bitset>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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

class UnionFind {
public:
    int n;
    vector<int> parent;
    vector<int> rank;
    UnionFind(int m) {
        n = m;
        parent.resize(n);
        rank.resize(n, 0);
        for (int i = 0; i < n; i++) {
            parent[i] = i;
        }
    }

    int find(int node) {
        if (parent[node] == node) {
            return node;
        } else {
            parent[node] = find(parent[node]);
            return parent[node];
        }
    }

    void unite(int node1, int node2) {
        node1 = find(node1);
        node2 = find(node2);
        if (node1 == node2) {
            return;
        } else {
            if (rank[node1] < rank[node2]) {
                parent[node1] = node2;
            } else if (rank[node1] > rank[node2]) {
                parent[node2] = node1;
            } else {
                parent[node1] = node2;
                rank[node1] += 1;
            }
        }
    }

    bool same(int node1, int node2) {
        node1 = find(node1);
        node2 = find(node2);
        if (node1 == node2) {
            return true;
        } else {
            return false;
        }
    }
};

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n); rep(i, n) cin >> a[i];
    UnionFind uf(n);
    rep(i, m) {
        int x, y; cin >> x >> y;
        uf.unite(x, y);
    }

    ll ans = 0;
    int group = 0;
    vector<vector<int>> box(n);
    rep(i, n) {
        if (uf.find(i) == i) group++;
        int p = uf.find(i);
        box[p].push_back(a[i]);
    }
    if (group == 1) {
        cout << 0 << endl;
        return 0;
    }
    if ((group-1)*2 > n) {
        cout << "Impossible" << endl;
        return 0;
    }

    vector<int> box2;
    rep(i, n) {
        if (uf.find(i) == i) {
            sort(box[i].begin(), box[i].end());
            ans += box[i][0];
            for (int j = 1; j < box[i].size(); j++) {
                box2.push_back(box[i][j]);
            }
        }
    }

    sort(box2.begin(), box2.end());
    rep(i, group-2) ans += box2[i];
    cout << ans << endl;


    return 0;
}


    


Measured memory_bytes: 6912
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end


n = gif
a = gi
r = array 2, 0
i = 0
a.sort.reverse.each do |aa|
  r[i % 2] += aa
  i += 1
end

puts r[0]-r[1]


Measured memory_bytes: 2428
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);
#define pi 3.1415926535897

ll n;
vector<ll> t(4*Nmax,INF);
vector<bool> marked(4*Nmax,0);

void push(ll v) {
    if (marked[v]) {
        t[v*2] = min(t[v*2],t[v]);
        t[v*2+1] = min(t[v*2+1],t[v]);
        marked[v*2] = marked[v*2+1] = true;
        marked[v] = false;
    }
}

void build(ll v, ll tl, ll tr) {
    if (tl == tr) {
        t[v] = (tl==1 ? 0 : INF);
    } else {
        ll tm = (tl + tr) / 2;
        build(v*2, tl, tm);
        build(v*2+1, tm+1, tr);
    }
}

void update(ll v, ll tl, ll tr, ll l, ll r, ll new_val) {
    if (l > r) 
        return;
    if (l == tl && tr == r) {
        t[v] = min(t[v],new_val);
        marked[v] = true;
    } else {
        push(v);
        ll tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), new_val);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, new_val);
    }
}

ll find(ll v, ll tl, ll tr, ll pos) {
    if (tl == tr) {
        return t[v];
    }
    push(v);
    ll tm = (tl + tr) / 2;
    if (pos <= tm) 
        return find(v*2, tl, tm, pos);
    else
        return find(v*2+1, tm+1, tr, pos);
}

int main() {
 
    get2(n,m);

    vector<vector<ll>> vecs;
    rep(i,m) {
        get3(a,b,c);
        vecs.push_back(vector<ll>{a,b,c});
    }

    sort(ALL(vecs));

    build(1,1,n);

    ll a1;
    rep(i,m) {
        a1 = find(1,1,n,vecs[i][0]);
        update(1, 1, n, vecs[i][0], vecs[i][1], a1+vecs[i][2]);
    }


    a1 = find(1,1,n,n);
    if(a1==INF)
        printf("-1\n");
    else
        printf("%lld\n",a1);

    return 0;  
}

Measured memory_bytes: 10036
using System;
using System.Linq;

class Test {
	static void Main(string[] args) {
      var inputs = System.Console.ReadLine()
    	.Split(' ')
    	.Select(s => int.Parse(s))
    	.ToArray();
      int a = inputs[0];
      Console.WriteLine(a + Math.Pow(a, 2) + Math.Pow(a, 3));
	}
}

Measured memory_bytes: 19984
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define umap unordered_map
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
#define var(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
const int mod = 1e9 + 7; 
const int inf = 0x3f3f3f3f;
 
template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) { cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n'; }
template <class T1, class T2>
void printPair(pair<T1, T2> p) { cout << p.first << " " << p.second  << '\n'; }
template <class T>
void printArray(vector<T> arr) { for (int i = 0; i<size(arr); i++) {cout << arr[i] << " ";} cout << '\n'; } 
 
int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,c,d; cin >> a >> b >> c >> d;
	ll ret = a*c;
	for (ll x : {a, b}) {
		for (ll y : {c , d}) {
			ret = max(ret, x*y);
		}
	}
	cout << ret << '\n';
}
 


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

int main () {
  int N ;
  cin >> N ;
  vector<int> line(N) ;
  for(int i = 0 ; i < N ;i++) cin >> line[i] ;
  reverse(line.begin(),line.end()) ;
  for(int i = 0 ; i < N-1 ;i++) cout << line[i] <<" ";
  cout << line[N-1]<<endl ;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int x,y,z; cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	K, A, B := nextInt(), nextInt(), nextInt()
	ans := "NG"
	for i := A; i <= B; i++ {
		if i%K == 0 {
			ans = "OK"
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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

const int N = 1e5 + 5;

int n, a[N];
int amt[N];
map<int, int> cmp;

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

	cin >> n;

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

	int nums = 0;
	for(auto &v : cmp) {
		v.second = nums++;
	}

	for(int i = 0; i < n; i++) {
		a[i] = cmp[a[i]];
	}

	for(int i = 0; i < n; i += 2) {
		amt[a[i]]++;
	}

	sort(a, a + n);
	int ans = 0;
	for(int i = 0; i < n; i += 2) {
		if(--amt[a[i]] < 0) ans++;
	}

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

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

typedef long long ll;

int main() {
    string S;
    cin >> S;
    ll a = 0, b = 0, c = 0;
    rep(i, S.size()) {
        if (S[i] == 'W') {
            b += a;
            c += i;
            a++;
        }
    }
    cout << c - b << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
/* 
int get(int x)
{
	if(x==fa[x])	return x;
	return fa[x]=get(fa[x]);
}//路径压缩 
int merge(int x,int y)
{
	fa[get(x)]=get(y);
}//合并 */ 
int main()
{
	int n,ans=0,l;
	cin>>n>>l;
	for(int i=1;i<=n;i++)
	{
		int p;
		cin>>p;
		if(p>=l)	ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
using vpii = vector<pii>;
using vpll = vector<pll>;

int main(){
  string S;
  cin >> S;

  long N = S.size() / 2;
  long cnt = 0;

  rep(i, N){
    if(S[i] != S[S.size() - 1 - i]) cnt++;
  }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"math"
	"os"
)

type vecF struct{ x, y float64 }

func (a vecF) add(b vecF) vecF     { return vecF{a.x + b.x, a.y + b.y} }
func (a vecF) sub(b vecF) vecF     { return vecF{a.x - b.x, a.y - b.y} }
func (a vecF) dot(b vecF) float64  { return a.x*b.x + a.y*b.y }
func (a vecF) det(b vecF) float64  { return a.x*b.y - a.y*b.x }
func (a vecF) len2() float64       { return a.x*a.x + a.y*a.y }
func (a vecF) dis2(b vecF) float64 { return a.sub(b).len2() }
func (a vecF) len() float64        { return math.Hypot(a.x, a.y) }

func (a *vecF) adds(b vecF) { a.x += b.x; a.y += b.y }
func (a *vecF) subs(b vecF) { a.x -= b.x; a.y -= b.y }


// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var a, b, h, m float64
	Fscan(in, &a, &b, &h, &m)

	calcP := func(d,r float64) vecF {
		//d=-d
		d*=2
		if d <=0.5 {
			d*=math.Pi
			return vecF{r * math.Sin(d), r*math.Cos(d)}
		}
		d-=0.5
		if d <=0.5 {
			d*=math.Pi
			return vecF{r * math.Cos(d), -r*math.Sin(d)}
		}
		d-=0.5
		if d <=0.5 {
			d*=math.Pi
			return vecF{-r * math.Sin(d), -r*math.Cos(d)}
		}
		d-=0.5
		d*=math.Pi
		return vecF{-r * math.Cos(d), r*math.Sin(d)}
	}

	h += m / 60
	h/=12
	m/=60
	h=-h
	m=-m
	x,y := calcP(h,a),calcP(m,b)
	dd := x.dis2(y)
	Fprintf(out,"%.13f", math.Sqrt(dd))
}

func main() { run(os.Stdin, os.Stdout) }


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

using namespace std;

int main()
{
    long long a, b, n, q, h, s, d;
    scanf("%lld%lld%lld%lld", &q, &h, &s, &d);
    {
        scanf("%lld", &n);
        a=min(min(q*4, h*2), s);
        b=min(a*2, d);
        printf("%lld\n", n/2*b+(n%2)*a);
    }

    return 0;
}


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

int main() {
    int n;cin>>n;
    double d[n],tmp,ans=0;
    
    for(int i=0;i<n;++i){
        cin>>tmp;
        d[i]=1/tmp;
        ans+=d[i];
    }
    
    cout<<1/ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iterator>

using namespace std;

int main()
{
  int N; cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) cin >> v[i];

  int ans = 1100000000;
  for (int i = 0; i < N-1; i++) {
    int S1 = 0, S2 = 0;
    for (int j = 0; j < N; j++) {
      if (j <= i) S1 += v[j];
      else S2 += v[j];
    }
    ans = min(ans, abs(S1-S2));
  }
  cout << ans << endl;
  return 0;
}


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

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define LL(n) ll n;assert(0<scanf("%lld", &n))
#define VL(v,n) vector<ll> v(n);REP(i,n){assert(0<scanf("%lld",&v[i]));}
#define MSET(arr,val)  memset(arr,val,sizeof(arr))

ll gcd(ll a, ll b){
  if (b == 0){
    return a;
  } else {
    return gcd(b, a % b);
  }
}

int main(){
  LL(n); VL(as, n);
  ll ans = accumulate(as.begin()++, as.end(), *as.begin(), [](ll x, ll y){return x / gcd(x, y) * y;});
  printf("%lld\n", ans);
  return 0;
}

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

#define MAX_N (52)
#define SIZE_BUF (30)
#define NUM_MOD (1000000007)

long solve(const char *S, int N, int j) {
  if (j >= N) {
    return 1;
  }
  const int cur_pattern = S[j + 0 * N] == S[j + 1 * N];
  if (j > 0) {
    const int prev_pattern = S[j - 1 + 0 * N] == S[j - 1 + 1 * N];
    if (prev_pattern && cur_pattern) {
      return (2 * solve(S, N, j + 1)) % NUM_MOD;
    } else if (prev_pattern && !cur_pattern) {
      return (2 * solve(S, N, j + 2)) % NUM_MOD;
    } else if (!prev_pattern && cur_pattern) {
      return (1 * solve(S, N, j + 1)) % NUM_MOD;
    } else {
      return (3 * solve(S, N, j + 2)) % NUM_MOD;
    }
  } else {
    if (cur_pattern) {
      return (3 * solve(S, N, j + 1)) % NUM_MOD;
    } else {
      return (6 * solve(S, N, j + 2)) % NUM_MOD;
    }
  }
}

int main(int argc, char *argv[]) {
  // read inputs
  int N;
  char S[2 * MAX_N + 1], buf[SIZE_BUF];
  scanf("%d", &N);
  fgets(buf, SIZE_BUF, stdin);
  for (int i = 0; i < 2; i++) {
    scanf("%s", &S[i * N]);
    fgets(buf, SIZE_BUF, stdin);
  }

  // solve
  printf("%ld\n", solve(S, N, 0));

  return 0;
}


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

using namespace std;

int main()
{
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    int n,c;
    int a;int b=1e9;
    cin >> n;
    vector<int> v;
    for (int i=0;i<n;++i){
        cin >> c;
        v.push_back(c);
    }

    for (int i=-100;i<=100;++i){
        int a=0;
        for (int j=0;j<n;++j){
            a += (v[j]-i)*(v[j]-i);

        }b = min(a,b);
    }
    cout << b;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
 
const int maxn=1e4+10;
const ll N=LLONG_MAX;

ll dp[maxn][maxn];

int main() {
	// your code goes here
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m,w[maxn];
	ll v[maxn];
	memset(dp,0,sizeof(dp));
	cin >> n >> m;
	FOR(i,1,n) cin >> w[i] >> v[i];
	
	FOR(j,0,m)
	FOR(i,1,n)
	  if (j==0) dp[j][i]=LLONG_MAX;
	  else if (i>=w[j]) dp[j][i]=min(dp[j-1][i],v[j]+dp[j][i-w[j]]);
	  else dp[j][i]=min(v[j],dp[j-1][i]);
	cout << dp[m][n];
}

Measured memory_bytes: 783104
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for _ in range(n):
    name = input()
    if name[0] in d:
        d[name[0]] += 1

initial = ['M', 'A', 'R', 'C', 'H']
combi = []
for i in range(len(initial)):
    for j in range(i + 1, len(initial)):
        for k in range(j + 1, len(initial)):
            combi.append((initial[i], initial[j], initial[k]))

ans = 0
for a, b, c in combi:
    x, y, z = d.get(a), d.get(b), d.get(c)
    ans += x * y * z
print(ans)

Measured memory_bytes: 43496
def f(n,k):
    count = 0
    for x in range(1,n+1):
        for y in range(x,n+1):
            for z in range(y,n+1):
                if x + y + z == k:
                    if x != y and y != z and z != x:
                        count += 1
    return count

while True:
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        break
    print(f(n,x))

Measured memory_bytes: 7740
import sys
N = int(input())
H = list(map(int, input().split()))

H.reverse()
for n in range(1, N):
    if H[n]-H[n-1]==1:
        H[n] -= 1
    elif H[n]-H[n-1] > 1:
        print("No")
        sys.exit(0)
print("Yes")

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

int main() {
  int n;
  cin >> n;
  rep(i,11) {
    if (n <= i * 1000) {
      cout << i * 1000 - n << endl;
      return 0;
    }
  }
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long double ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b;
    cin >> a >> b;
    cout << (long long)(a * b);
    return 0;
}


Measured memory_bytes: 3740
def main():
    N = int(input())
    a = [int(input()) for _ in range(N)]
    i = 1
    ans = 0

    for K in range(N):
        i = a[i-1]
        ans += 1
        if i == 2:
            return ans
    ans = -1
    return ans

print(main())         


Measured memory_bytes: 7084
import itertools

a=[int(input()) for j in range(5)]
#print(a)

x=list(itertools.permutations(a))
#print(x)

def cal(b,c):
  if b <= c:
    return c
  else:
    c+=10
    return cal(b,c)
  
ans=100000000  
for i in range(len(x)):
  time1=cal(x[i][0],0)
  time2=cal(time1+x[i][1],0)
  time3=cal(time2+x[i][2],0)
  time4=cal(time3+x[i][3],0)
  time5=time4+x[i][4]

  if time5 < ans:
    ans=time5
    
print(ans)



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


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class AHarmony {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int a,b;
        cin >> a >> b;
        int k = (a + b) / 2;

        if (abs(a - k) == abs(b - k)){
            cout << k << endl;
        }else{
            cout << "IMPOSSIBLE" << endl;
        }
	}
};


int main() {
	AHarmony solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int a,b;
    scanf("%d%d" ,&a ,&b);
    int r=0;
    for(int i=a;i<=b;i++){
            int s=i%10,t=i/10000%10;
            int u=i/10%10,v=i/1000%10;
            if(s==t&&u==v)r++;
    }
    printf("%d\n ",r);
    return 0;
}



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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Io.Read<int>();
            var output = N * N * N;
            Io.Write(output.ToString());
        }
    }

    class Io
    {
        public static string Read()
        {
            return Console.ReadLine();
        }

        public static IEnumerable<string> ReadRepeat(int count)
        {
            return Enumerable.Range(0, count).Select(_ => Read());
        }

        public static T Read<T>()
        {
            return (T)Convert.ChangeType(Read(), typeof(T));
        }

        public static IEnumerable<T> ReadRepeat<T>(int count)
        {
            return Enumerable.Range(0, count).Select(_ => Read<T>());
        }

        public static string[] ReadList(char devide = ' ')
        {
            return Read().Split(devide);
        }

        public static T[] ReadList<T>(char devide = ' ')
        {
            return ReadList(devide)
                .Select(s => (T)Convert.ChangeType(s, typeof(T)))
                .ToArray();
        }

        public static IEnumerable<T[]> ReadListRepeat<T>(int count, char devide = ' ')
        {
            return Enumerable.Range(0, count).Select(_ => ReadList<T>(devide));
        }

        public static void Write(string value)
        {
            Console.WriteLine(value);
        }
    }
}


Measured memory_bytes: 11220
n = int(input())
m=-2
t=0
pos=0
ans=[]
while n!=t:
  if (n-t)%m == 0:
    ans.insert(0,0)
  else:
    ans.insert(0,1)
  t+=ans[0]*(m//-2)
  m=m*(-2)

if n == 0:
  print(0)
else:
  ans = [str(n) for n in ans]
  print("".join(ans))

Measured memory_bytes: 3064
def main():
    N = int(input())
    uv = [list(map(int, input().split())) for _ in range(N -1)]

    ans = 0
    # 頂点の足し合わせ
    for i in range(N):
        ans += (i + 1) * (N - i)

    # 辺の数を引く
    for u, v in uv:
        ans -= min(u, v) * (N - max(u, v) + 1)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45288
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  const S=input[1].split(' ')[0];
  const T=input[1].split(' ')[1];
  var ret=''
  for(var i=0;i<N;i++){
    ret+=S[i];
    ret+=T[i];
  }
  console.log(ret);
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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


Measured memory_bytes: 2140
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

int main(){
    ll n,k;
    cin>>n>>k;
    ll hoge = n % k;
    cout<<min(hoge,k-hoge)<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
e = s.count("E")
w = n - e
ans = 10**9
if s[0] == "W":
    cnt = e
else:
    cnt = e-1
num = cnt
for i in range(n-1):
    if s[i] == s[i+1] and s[i] == "E":
        cnt -= 1
    elif s[i] == s[i+1]:
        cnt += 1
    ans = min(ans,cnt,num)
    ans = max(ans,0)
print(max(ans,0))

Measured memory_bytes: 68108
/*
*@Author  Chand Vachhani
*/

#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define vi          vector<int>
#define vii         vector<vector<int>>
#define pii         pair<int,int>
#define mii         map<int,int>
#define pb          push_back
#define pf          push_front
#define mp(a,b)          make_pair((a),(b))
#define vpii        vector<pair<int,int>>
#define fo(i,l,n)   for(int i{l}; i<n; i++)
#define rf(s)       for(auto &c : s)
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define PI          3.141592653589
#define sz(x)       (int)x.size()
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007  

using namespace std;

signed main(){
    tezz
   
   int n;
   cin >> n;
   double p;
   vector<double> dp(n+2);
   dp[0]=1;
   fo(i,0,n){
       cin >> p;
       for(int j=n+1; j>=0; j--){
           dp[j]=( j==0 ? 0 : dp[j-1]*p ) + dp[j]*(1-p);
       }
        // for(auto it: dp)cout << it << " ";
        // cout << endl;
   }
   double ans=0;
   for(int i=0; i<=n; i++){
       int t=n-i;
       if(i>t){
           ans+=dp[i];
       }
   }
   cout <<setprecision(15)<< ans;
    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int room=sc.nextInt();
		int arien=0;
		for(int i=0; i<room; i++) {
			int a=sc.nextInt();
			int hen=1;
			boolean b=false;
			while(hen*hen*2+hen<=a) {
				if((a-hen)%(hen*2+1)==0) {
					b=true;
					break;
				}
				hen++;
			}
			if(!b) {
				arien++;
			}
		}
		pl(arien);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 37912
#include <iostream>
using namespace std;
const int MAX = 10000001;

bool prime[MAX];

void pr(){
  prime[0] = prime[1] = true;

  for(int i = 2 ; i*i < MAX ; i++){
    if(!prime[i]){
      for(int j = i*i ; j < MAX ; j+=i){
	prime[j] = true;
      }    
    }
  }
}

int main(){
  int n;

  pr();
  while(cin >> n ,n){
    for(int i = n ; i >= 0 ; i--){
      if(!prime[i]&&!prime[i-2]&&!prime[i-6]&&!prime[i-8]){
	cout << i << endl;
	break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 10924
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;cin>>N;
	int now=0;
	while(N--){
		int x,y;cin>>x>>y;
		if(x==y){
			x++;y++;
			now++;
			if(now==3){
				cout<<"Yes\n";return 0;
			}
		}else now=0;
	}
	cout<<"No\n";
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ld A,B,H,M;
    cin>>A>>B>>H>>M;
    ld Ans;
    ld C=abs((H*60+M)/2-6*M);
    ld rad=C*pi/180;
    ld x2=A*A+B*B-2*A*B*cos(rad);
    ld x=sqrt(x2);
    cout<<fixed<<setprecision(12)<<x<<endl;
}

Measured memory_bytes: 4196
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    int minn=1001;
    for (int i=0; i<=s.size()-t.size(); i++){
        int tot=0;
        for (int j=i; j<i+t.size(); j++)
            if (s[j]==t[j-i]) tot++;
        minn=min(minn, int(t.size())-tot);
    }
    cout << minn << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        String s = Long.toString(n, 26);
        StringBuilder sb = new StringBuilder();
        int len = s.length();
        int idx = 0;
        if (n <= 26) {
            s = Long.toString(n - 1, 26);
            int num = Integer.parseInt(s, 26);
            sb.append((char) ('a' + num));
        } else {
            while (s.length() >= 1) {
                if (s.substring(s.length() - 1).equals("0")) {
                    long dec = Long.parseLong(s, 26) - 1;
                    String ss = Long.toString(dec, 26);
                    int num = Integer.parseInt(ss.substring(ss.length() - 1), 26);
                    sb.append((char) ('a' + num));
                    s = ss;
                    idx++;
                } else {
                    int num = Integer.parseInt(s.substring(s.length() - 1), 26) - 1;
                    sb.append((char) ('a' + num));
                }
                s = s.substring(0, s.length() - 1);
            }
        }
        System.out.println(sb.reverse().toString());
    }
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
typedef struct {
	vector <int> to;
	bool visited;
} node;

int main( void ){
	// initialize();
	int N, M;
	cin >> N >> M;
	vector <vector<int>> G( N );
	vector <int> dir( N, -1 );
	rep( i, 0, M ){	// グラフ定義, 0オリジン
		int a, b; cin >> a >> b;
		a--; b--;
		G[ a ].push_back( b );
		G[ b ].push_back( a );
	}

	queue <int> que;
	que.push( 0 );
	dir[0] = 0;
	while(!que.empty()){	// BFS
		int q = que.front(); que.pop();
		for(auto to:G[ q ]){	// つながってる部屋毎に
			if (dir[to] != -1)
				continue;
			dir[ to ] = q+1;
			que.push( to );
		}
	}
	bool can = true;
	for(auto d:dir){	// 到達してない部屋確認
		if (d == -1){
			can = false;
			break;
		}
	}
	if(!can)
		cout << "No\n";
	else {
		cout << "Yes\n";
		rep(i,1, N)
			cout << dir[i] << endl;

	}
}


Measured memory_bytes: 10168
<?php
//$N = (int)trim(fgets(STDIN));
//list($N,$Q) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$S = trim(fgets(STDIN));
$x = array_map('intval',explode(" ",trim(fgets(STDIN))));

foreach($x as $k=>$v) {
  if ($v==0) {
    printf("%d\n",$k+1);
    break;
  }
}


Measured memory_bytes: 16164
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
  long long n;
  cin >> n;

  bool flag = false;
  long long i;
  vector<long long> a(1000001,n + 1);
  for(i = 1;i * i <= n;i++){
    if(n % i == 0){
      a[i] = i + n / i - 2;
    }
  }

  cout << *min_element(a.begin(), a.end()) << endl;
  return 0;
}


Measured memory_bytes: 8192
from collections import deque

N = int(input())
d_list = [[] for _ in range(N+1)]
costs = [0] * (N+1)
for _ in range(N-1):
  a, b, c = map(int, input().split())
  d_list[a].append((a, b, c))
  d_list[b].append((b, a, c))
Q, K = map(int, input().split())
que = deque([])
for e in d_list[K]:
  que.append(e)
while len(que) > 0:
  _from, _to,  _cost = que.popleft()
  costs[_to] += costs[_from] + _cost
  for e in d_list[_to]:
    if e[1] != _from:
      que.append(e)
for _ in range(Q):
  f, t = map(int, input().split())
  print(costs[f] + costs[t])
  

  

Measured memory_bytes: 90016
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=gets.to_i
p a[k-1]

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,ans=-1;cin>>a>>b;
  for(ll price=0;price<1010;++price) {
    if(a==floor(price*0.08)&&b==floor(price*0.10)) {
      ans=price;break;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

    char mj1[100];
    int i = 0;

    scanf("%s", mj1);

    if (mj1[i] == 'S')
    {
        i++;
        if (mj1[i] == 'U')
        {
            printf("7");
        }
            if (mj1[i] == 'A')
            {
                printf("1");
            }
    }
    if (mj1[i] == 'T')
    {
        i++;
        if (mj1[i] == 'U')
        {
            printf("5\n");
        }
        if (mj1[i] == 'H')
        {
            printf("3\n");
        }
    }
    if (mj1[i] == 'M')
    {
        printf("6\n");
    }
    if (mj1[i] == 'W')
    {
        printf("4\n");
    }
    if (mj1[i] == 'F')
    {
        printf("2\n");
    }

    return 0;
}


Measured memory_bytes: 128
N,M,X = map(int,input().split())
BOOK = [list(map(int,input().split())) for i in range(N)]

costs = []

for i in range(2 ** N):
    t = [0] * M
    cost = 0
    for j in range(N):
        if ((i >> j) & 1) == 1:
            for k in range(M):
                t[k] += BOOK[j][k+1]
            cost += BOOK[j][0]
    
    if all(t[l] >= X for l in range(M)):
        costs.append(cost)

if len(costs) == 0:
    print("-1")
else:
    print(min(costs))

Measured memory_bytes: 9216
#include <stdlib.h>
#include <limits.h>
#include <iostream>
using namespace std;

int COIN_TYPE_NUM = 6;
int coin_price[] = {1, 5, 10, 50, 100, 500};

int coin_payment(int p, int* coin_num);
int change_num(int p);
int pay(int p, int* coin_num);
int main(){
	int p;
	int* coin_num = (int*)malloc(COIN_TYPE_NUM * sizeof(int));

	while(true){
		cin >> p;
		for(int i = 0; i < COIN_TYPE_NUM; ++i){
			cin >> coin_num[i];
		}
		if(p == 0) break;
		int ideal_payment = coin_payment(p, coin_num);
		cout << ideal_payment << endl;
	}
	return 0;
}

int coin_payment(int p, int* coin_num){
	int min_coin_num = INT_MAX;

	for(int i = p; i < p+500; ++i){
		int pay_num = pay(i, coin_num);
		if(pay_num == -1) continue;
		pay_num += change_num(i-p);
		if(pay_num < min_coin_num) min_coin_num = pay_num;
	}

	return min_coin_num;
}


int change_num(int p){
	int retval = 0;
	for(int coin_type = COIN_TYPE_NUM-1; coin_type >= 0; coin_type--){
		int p_num = p / coin_price[coin_type];
		p -= p_num*coin_price[coin_type];
		retval += p_num;
		if(p == 0) return retval;
	}
	return retval;
}

int pay(int p, int* coin_num){
	int retval = 0;
	for(int coin_type = COIN_TYPE_NUM-1; coin_type >= 0; coin_type--){
		int p_num = p / coin_price[coin_type];
		if(p_num > coin_num[coin_type]) p_num = coin_num[coin_type];
		p -= p_num*coin_price[coin_type];
		retval += p_num;
		if(p == 0) return retval;
	}
	return -1;

}

Measured memory_bytes: 3028
#include <iostream>

using namespace std;

int main(){
	long long S;
	cin >> S;
	
	long long x_2 = 1e9;
	
	int x_3 = (x_2 - S % x_2) % x_2;
	int y_3 = (S + x_3) / x_2;
	
	cout << "0 0 1000000000 1 " << x_3 << " " << y_3 <<endl;


    return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, d, a;
  cin >> n >> d >> a;
  
  vector<pair<ll, ll>> m(n);
  for(int i = 0; i < n; i++) cin >> m.at(i).first >> m.at(i).second;
  
  sort(m.begin(), m.end());
  
  ll ans = 0, nowdmg = 0, ite = 0;
  vector<pair<ll, ll>> x;
  for(int i = 0; i < n; i++){
    if(nowdmg > 0 && ite < x.size()){
      while(m.at(i).first > x.at(ite).first){
        nowdmg -= x.at(ite).second;
        ite++;
        if(ite == x.size()) break;
      }
    }
    //cout << "1 " << nowdmg << endl;
    if(m.at(i).second <= nowdmg) continue;
    
    ans += ((m.at(i).second - nowdmg) + a - 1) / a;
    ll keep = a * (((m.at(i).second - nowdmg) + a - 1) / a);
    nowdmg += keep;
    x.push_back(make_pair(m.at(i).first + 2 * d, a * ((keep + a - 1) / a)));
    //cout << "2 " << nowdmg << endl;
  }
  
  cout << ans << '\n';
}

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

typedef long long ll;

void solve() {
    int H, W, N, a, c = 1;
    cin >> H >> W >> N;
    vector<int> ans;
    rep(i, N) {
        cin >> a;
        rep(j, a) ans.push_back(c);
        c++;
    }
    rep(i, H) rep(j, W) {
        if (i % 2) cout << ans[i * W + W - 1 - j];
        else cout << ans[i * W + j];
        if (j < W - 1) cout << " ";
        else cout << endl;
    }
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 384