akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>


using namespace __gnu_pbds;
using namespace std;

#define pb                     push_back
#define ll                     long long
#define forn(i,n)              for(int i=0; i<(int)n; i++)
#define forn1(i,n)              for(int i=1; i<=(int)n; i++)

#define sfd(a)                 scanf("%d", &a)
#define sffd(a,b)              scanf("%d%d", &a, &b)
#define sffl(a,b)              scanf("%lld%lld", &a,&b)
#define sfl(a)                 scanf("%lld", &a)

#define pii                    pair<int , int>
#define pll                    pair<ll , ll>
#define ff                     first
#define ss                     second
#define mem(a, val)            memset(a, val, sizeof(a))
#define all(x)                 (x).begin(), (x).end()

//#define mx                     200005
#define INF_mx                 1e18
#define gcd(a,b)               __gcd(a, b)
#define lcm(a,b)               (a*b)/__gcd(a,b)
#define PRINT                  cout<<"hi"<<endl
#define PI acos(-1)
#define fast_in_out          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Q    int q; cin>>q; while(q--)
/*
const ll sz=1000001;
const ll N=1e12;
vector<ll>prime;
bool flag[sz+3];


void sieve(void)
{
    ll i,j,add;
    flag[0]=flag[1]=1;
    prime.push_back(2);
    for(i=4; i<sz; i+=2)
        flag[i]=1;
    for(i=3; i<sz; i+=2)
    {
        if(!flag[i])
        {
            prime.push_back(i);
            if(sz/i>=i)
            {
                add=i*2;
                for(j=i*i; j<sz; j+=add)
                    flag[j]=1;
            }
        }

    }
}

const int MOD = 1000000007 ;
long long int  bigmod ( long long B, int P, int M )
{
    if ( P == 0 )return 1;
    if ( P % 2 ) {
        return ( ( B % M ) * ( bigmod ( B, P-1, M))) % M;
    }
    else {
        long long mod = bigmod (B,P/2,M);
        return ((mod%M)*(mod%M))%M;
    }
}

*/

int main()
{
    ll n,x,t;
    cin>>n>>x>>t;

    ll ans;
    ans=(n+x-1)/x;
    cout<<ans*t<<endl;

    return 0;
}
/*


*/


Measured memory_bytes: 3640
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long int power(long long int a)
{
    int i=5;long long int num=1;
    while(i>0)
    {
        num*=a;
        i--;
    }
    return(num);
}
int main()
{
    long long int i,j;long long int n;
    scanf("%lld",&n);
    long long int num; 
    for(i=-100;i<500;i++)
    {
        for(j=-100;j<500;j++)
        {
            num=power(j)-power(i);
            if(num==n)
            {
                printf("%lld %lld",j,i);
                return 0;
            }
        }
    }
}


Measured memory_bytes: 1688
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int N;
    cin >> N;
    vector<pair<string, int>> V;
    for (int i = 0; i < N; i++) {
        string s;
        int tm;
        cin >> s >> tm;
        V.push_back(make_pair(s, tm));
    }
    string X;
    cin >> X;
    bool OK = false;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (V[i].first == X) {
            OK = true;
            continue;
        }
        if (!OK) continue;
        ans += V[i].second;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int a,b;
	cin>>a>>b;
	if(a<=0&&0<=b){
		puts("Zero");
		return 0;
	}
	if(a>0){
		puts("Positive");
		return 0;
	}
	if((b-a)%2==1){
		puts("Positive");
		return 0;
	}
	puts("Negative");
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string s; cin >> s;
    int N = s.size();
    ll ans = 0;
    REP(i,N){
        REP(k,N-2-i+1){
            ans += (s[i]-'0') * pow(10,k) * pow(2,N-2-k);
        }
        ans += (s[i]-'0') * pow(10,N-1-i) * pow(2,i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4004
N = int(input())

A = list(map(int,input().split()))
s = 0
for i,a in enumerate(A):
    if i%2:
        s -= a
    else:
        s += a

ans = [-1 for i in range(N)]
ans[0] = s

for i in range(1,N):
    ans[i] = (A[i-1]-ans[i-1]//2)*2
print(*ans)


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<LL> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    LL ans[2] = {0, 0};
    for(int i=0;i<2;i++){
        LL sum = 0LL;
        for(int j=0;j<n;j++){
            if(i == 0){
                if(j%2 == 0 && sum+a[j] <= 0){
                    ans[i] += 1-(sum+a[j]);
                    sum = 1;
                }else if(j%2 == 1 && sum+a[j] >= 0){
                    ans[i] += 1+(sum+a[j]);
                    sum = -1;
                }else{
                    sum += a[j];
                }
            }else{
                if(j%2 == 1 && sum+a[j] <= 0){
                    ans[i] += 1-(sum+a[j]);
                    sum = 1;
                }else if(j%2 == 0 && sum+a[j] >= 0){
                    ans[i] += 1+(sum+a[j]);
                    sum = -1;
                }else{
                    sum += a[j];
                }
            }
        }
    }
    cout << min(ans[0], ans[1]) << endl;
    return 0;
}


Measured memory_bytes: 1024
mdl = 10**9 + 7

N, M, K = map(int,input().split())

nm = N*M
mm = M*M % mdl
nn = N*N % mdl

U = 2*10**5
fact = [1] * (U+1)

for i in range(1,U+1):
    fact[i] = (fact[i-1]*i) % mdl

def comb(n,k):
    x = fact[n]
    x *= pow(fact[n-k], mdl-2, mdl)
    x %= mdl
    x *= pow(fact[k], mdl-2, mdl)
    x %= mdl
    return x

def F(N):
    x = N*(N+1) // 2 * N
    y = N*(N+1)*(2*N+1) // 6
    return (x-y) % mdl

ans = mm*F(N) % mdl + nn*F(M) % mdl
ans %= mdl
ans *= comb(nm-2,K-2)
ans %= mdl

print(ans)

Measured memory_bytes: 10868
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int main() {
	string s, t;
	cin >> s >> t;
	rep(i,t.length()){
		cout << s[i] << t[i];
	}
	if(s.length()-t.length()>0) cout << s[s.size()-1];
	return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;


int main(void){
    int n;
    cin >> n;
    if(n%2==0)
        cout << n/2;
    else
    {
        cout << n/2+1;
    }
    
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(){
    char dat[10002];
    int kdc[10]={0,5,6,6,6,6,6,8,6,8};
    char kd[10][10]={"","',.!?","abcABC","defDEF","ghiGHI","jklJKL","mnoMNO","pqrsPQRS","tuvTUV","wxyzWXYZ"};
    int i,t=-1,tc=0,j;
    while (scanf("%s",dat) != EOF){
        for (i=0;dat[i]!=0;i++){
            if (dat[i]-'0' == t){
                tc++;
            }else{
                if (tc>0){
                    if (t==0){
                        if (tc>1){
                            for (j=0;j<tc-1;j++) printf(" ");
                        }
                    }else{
                        while (tc>kdc[t])tc -= kdc[t];
                        printf("%c",kd[t][tc-1]);
                    }
                }
                t=dat[i]-'0';
                tc=1;
            }
            
        }
        if (tc>0){
            if (t==0){
                if (tc>1){
                    for (j=0;j<tc-1;j++) printf(" ");
                }
            }else{
                while (tc>kdc[t])tc -= kdc[t];
                printf("%c",kd[t][tc-1]);
            }
        }
        t=-1;
        tc=0;
        
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using vi  = vector<int>;
using ii  = pair<int,int>;
using vii = vector<ii>;
using ll  = long long;

typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) int((x).size())
#define REP(i, a, b) for (auto (i) = (a); (i) <= (b); (i)++)
#define PER(i, a, b) for (auto (i) = (a); (i) >= (b); (i)--)
#define ITR(i, x) for (auto (i) = (x).begin(); (i) != (x).end(); (i)++)

class FenwickTree {
public:
	vi ft;
	FenwickTree(int n) {
		ft.resize(n+1);
	}

	void update(int i, int k) {
		for (; i < SIZE(ft); i += (i & -i))
			ft[i] += k;
	}

	int sum(int i) {
		int res = 0;
		for (; i; i -= (i & -i)) 
			res += ft[i];
		return res;
	}

	void insert(int i) {
		update(i, 1);
	}

	void remove(int i) {
		update(i, -1);
	}

	int findNumSmaller(int i) {
		return sum(i);
	}
};

const int N = 5e5;
tuple<int,int,int> queries[N+5];
int a[N+5], ans[N+5];
queue<int> idxs[N+5];

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

	int n, q;
	cin >> n >> q;
	REP(i, 0, n-1) {
		cin >> a[i];
		a[i]--;
		idxs[a[i]].push(i);
	}

	FenwickTree ft(N+10);
	REP(i, 0, n-1) {
		if (!idxs[i].empty()) {
			ft.insert(idxs[i].front() + 1);
		}
	}

	REP(m, 0, q-1) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		queries[m] = {l, r, m};
	}
	sort(queries, queries+q);

	int curr = 0;
	int qidx = 0;
	while (qidx < q) {
		int l, r, ansidx;
		tie(l, r, ansidx) = queries[qidx];
		while (curr < l) {
			ft.remove(idxs[a[curr]].front() + 1);
			idxs[a[curr]].pop();
			if (!idxs[a[curr]].empty()) {
				ft.insert(idxs[a[curr]].front() + 1);
			}
			curr++;
		}
		ans[ansidx] = ft.findNumSmaller(r+1);
		// cout << "HELLO " << ansidx << ' ' << ans[ansidx] << '\n';
		qidx++;
	}

	REP(i, 0, q-1) {
		cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 353060
calcs = ["+", "-", "*", "/"]

#a="1 2 + 3 4 - *"
#a="1 2 +"
#lst = a.split()
lst = raw_input().split()

st=[]

def calc(e):

    tot=0
    tmp=0
    first=True

    b = st.pop()
    a = st.pop()

    if e   == "+":
        tot = a + b
    elif e == "-":
         tot = a- b
    elif e == "*":
         tot = a * b
    elif e == "/":
         tot = a / b

    st.append(tot)

for x in lst:
    if x in calcs:
       calc(x)
    else:
       st.append(int(x))

print st.pop()

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int L, R; cin >> L >> R;
    if (R - L > 2019) cout << 0 << endl;
    else {
        int ans = INF;
        REP(i, L, R) REP(j, i+1, R+1) {
            ans = min(ans, (i%2019)*(j%2019)%2019);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	int u,v;
	ll ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		ans+=1ll*i*(n-i+1);//统计有多少个独立的 
	}
	for(int i=1;i<=n-1;i++)
	{
		scanf("%d%d",&u,&v);
		if(u>v) swap(u,v);
		ans-=1ll*u*(n-v+1);
	}
	printf("%lld",ans);
 } 

Measured memory_bytes: 3776
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(0, A + 1):
    for j in range(0, B + 1):
        for k in range(0, C + 1):
            if 500 * i + 100 * j + 50 * k == X: ans += 1
print(ans)

Measured memory_bytes: 9184
//****** @author mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll fast_pow(ll a, ll b) {
    if(b == 0) return 1l;
    ll val = fast_pow(a, b / 2);
    if(b % 2 == 0) return val * val % MOD;
    else return val * val % MOD * a % MOD;
}
int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}
void solve() {

    int n;
    cin >> n;

    vector<vector<pair<int, int>>> XY(n);
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        for(int j=0; j<a; j++){
            int x, y;
            cin >> x >> y;
            XY[i].EB(MP(x-1, y));
        }
    }

    int ans = 0;
    for(int bit=0; bit < (1<<n); bit++){
        int flag = 0;
        for(int i=0; i<n; i++){
            int person = ((bit >> i) & 1);
            for(int j=0; j<XY[i].size(); j++){
                if(person == 1){
                    if(XY[i][j].S != (bit >> (XY[i][j].F) & 1) ){ // initial and final should be same
                        flag = 1;
                    }
                }
            }
        }
        if(flag == 0){
            ans = max(ans, counter(bit));
        }
    }

    cout << ans;



}
int main()
{
    IOS;
    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define NOT_FOUND 0;

int linerSearch(int A[], int key, int n){
	int i=0;
	A[n] = key;
	while(A[i] != key){
		i++;
	}
	return i != n;
}

int main(void){
	int n,i,q;
	
	scanf("%d",&n);
	
	int S[n];
	
	for(i=0;i<n;i++){scanf("%d",&S[i]);}
	
	scanf("%d\n",&q);
	
	int T[q];
	
	for(i=0;i<q;i++){scanf("%d",&T[i]);}
	
	int k=0;
	for(i=0; i<q; i++){
		if(linerSearch(S,T[i],n)){
			k++;
		}
	}
	
	printf("%d\n",k);
	
	return 0;
}


Measured memory_bytes: 2088
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int Y = scan.nextInt();
		int Z = scan.nextInt();
		int tmp = X;
		X = Y;
		Y = tmp;
		tmp = X;
		X = Z;
		Z = tmp;
		System.out.println(X+" "+Y+" "+Z);
	}
}

Measured memory_bytes: 22868
<?php

fscanf(STDIN, "%d %d %d", $n, $m, $q);
$aa = [];
$ba = [];
$ca = [];
$da = [];
for ($i = 0; $i < $q; ++$i) {
    $inputs = explode(' ', trim(fgets(STDIN)));
    $aa[] = $inputs[0];
    $ba[] = $inputs[1];
    $ca[] = $inputs[2];
    $da[] = $inputs[3];
}

/* $patterns = []; */
/* for ($i = 0; $i < (1 << $m); ++$i) { */
/*     $tmp = []; */
/*     for ($j = 0; $j < $m; ++$j) { */
/*         if ($i & (1 << $j)) { */
/*             $tmp[] = $j + 1; */
/*         } */
/*     } */
/*     $patterns[] = $tmp; */
/* } */

$patterns = dfs([], $n, $m);

$max = 0;
foreach ($patterns as $pattern) {
    if (count($pattern) === $n) {
        $tmp = 0;
        for ($i = 0; $i < $q; ++$i) {
            $a1 = $aa[$i] - 1;
            $b1 = $ba[$i] - 1;

            if ($pattern[$b1] - $pattern[$a1] == $ca[$i]) {
                $tmp += $da[$i];
            }
        }

        $max = max($tmp, $max);
    }
}

echo $max;


function dfs($first,  $n, $m) {
    if (count($first) === $n) {
        return [$first];
    }

    $tmparr = [];
    $tmp_max = count($first) === 0 ? 0 : max($first);
    for ($i = 1; $i <= $m; ++$i) {
        if ($i >= $tmp_max) {
            $n_f = $first;
            $n_f[] = $i;

            $tmparr = array_merge( $tmparr, dfs($n_f, $n, $m));
        }
    }

    return $tmparr;
}



Measured memory_bytes: 86112
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-20;
const long INF = 1e10;

int imos[100000];
int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		CLR(imos);
		REP(i,n){
			int h,m,s;char c;
			cin>>h>>c>>m>>c>>s;
			imos[h*3600+m*60+s]++;
			cin>>h>>c>>m>>c>>s;
			imos[h*3600+m*60+s]--;
		}
		int res=0,sum=0;
		for(long i=0;i<=100000;i++){
			sum+=imos[i];
			//if(sum>0)cout<<sum<<endl;
			res=max(res,sum);
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 1556
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextInt();


		if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
			System.out.println(0);
		}else {
			long ans = A * B;
			ans = Math.min(ans,B * C);
			ans = Math.min(ans,A * C);

			System.out.println(ans);
		}

	}

}


Measured memory_bytes: 35708
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
#define INF 1e9+7

int main(){


    ll q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;

    cout << (n/2)* min(min(8*q,4*h),min(2*s,d)) + (n%2)*min(4*q,min(2*h,s)) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] l = new int[N];
        for (int i = 0; i < N; i++) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        int sum = 0;
        for (int i = 0; i < K; i++) {
            sum += l[N - i - 1];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 24788
#include <iostream>

using namespace std;

int main()
{
	int loan = 100000;
	int n;
	
	cin >> n;
	for (int i = 0; i < n; i++){
		loan *= 1.05;
		if (loan % 1000 != 0){
			loan += 1000 - (loan % 1000);
		}
	}
	cout << loan << endl;
	return (0);
}

Measured memory_bytes: 1160
N , M = map(int,input().split())
A =  map(int,input().split())
A = [a for a in A]

dic = {}
dic[0] = 0
partial_sum = 0
res = 0
i = 0
while i < N:
    partial_sum += A[i]
    a = partial_sum % M
    if a == 0:
        res += 1
    if a in dic:
        dic[a] += 1
        res += dic[a] - 1
    else:
        dic[a] = 1
        res += dic[a] - 1
    #res += dic[a]
    i = i + 1
print(res)

Measured memory_bytes: 14424
#include <stdio.h>
#include <math.h>

int main(){
  double v, height;
  int i;
  while(scanf("%lf", &v) != EOF){
    height =pow(v,2)/19.6;
    for(i=1;;i++){
      if((double)5.0*(i-1)>= height){
	break;
      }
    }
    printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 628
#include<stdio.h>

int main()
{
 int k;
 int out;
 scanf("%d",&k);
 if(k%2==0)
 {
  out=(k/2)*(k/2);
 }else{
  out=((k-1)/2)*((k+1)/2);
 }
 printf("%d\n",out);

 return 0;
}


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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> y(m);

    for(int i=0;i<m;i++){
        cin >> y[i].first >> y[i].second;
    }
    sort(y.begin(), y.end());

    int leftmost = n + 1;
    int cnt = 0;
    for(int i=m-1;i>=0;i--){
        int a = y[i].first, b = y[i].second;
        if(leftmost < b)
            continue;

        cnt++;
        leftmost = a;
    }
    cout << cnt << endl;


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	string a, b;
	int x, y;
	cin >> a >> b >> x >> y;
	string c;
	cin >> c;
	
	if(c == a)
		x--;
	else
		y--;
	
	cout << x << " " << y << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
	string s,t;cin>>s>>t;
	int sl=s.size(),tl=t.size();

	int dp[sl+1][tl+1];
	memset(dp,0,sizeof(dp));

	for(int i=0;i<sl;i++){
		for(int j=0;j<tl;j++){
			if(s[i]==t[j]) dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j+1]);
			dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
			dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1]);
		}
	}

	string res="";
	int i=sl,j=tl;
	while(i>0&&j>0){
		if(dp[i][j]==dp[i-1][j]) i--;

		else if(dp[i][j]==dp[i][j-1]) j--;

		else{
			res=s[i-1]+res;
			i--,j--;
		}
	}

	cout<<res<<endl;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;
	int tebl[h][w];
	for(int p=0;p<h;p++){
		for(int e=0;e<w;e++){
			cin>>tebl[p][e];
		}
	}
	int ans=1<<30,n=0,k,pi,ej;
	for(int p=0;p<h;p++){
		for(int e=0;e<w;e++){
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(e-j<0){
						ej=(e-j)*-1;
					}else{
						ej=e-j;
					}
					if(p-i<0){
						pi=(p-i)*-1;
					}else{
						pi=p-i;
					}
					k=min(ej,pi);
					n+=k*tebl[i][j];
				}
			}
			//printf("a %d t %d y %d\n",n,e,p);
			ans=min(n,ans);
			n=0;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n, k;
    cin >> n >> k;
    cout << n-k+1 << endl;
    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  vector<int> ans;
  map<int,int> mp;
  deque<int> yet;
  rep(i,n) {
    int r = n-1-i;
    ++mp[a[r]];
    yet.push_back(a[i]);
    while( !yet.empty() ) {
      if( mp[yet.front()] ) {
	mp[yet.front()]--;
	yet.pop_front();
      } else break;
    }
    if( yet.empty() ) {
      ans.push_back(i);
    }
  }
  /*
  if( n % 2 == 1 ) {
    if( ans.size() && ans.back() == (int)(n / 2)-1 ) {
      ans.push_back(n/2);
    }
  }
  vector<int> b;
  rep(i,(int)ans.size())  {
    b.push_back(i);
    b.push_back(n-1-i);
  }
  sort(ALL(b));
  b.erase(unique(ALL(b)),b.end());
  */
  vector<int> b = ans;
  rep(i,(int)b.size()) {
    if( i ) printf(" ");
    cout << b[i]+1;
  } puts("");
  compute();
  return 0;
}



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

const int INF=1e9;
int n,k,S;

int main() 
{
	ios_base::sync_with_stdio(false);
	cin>>n>>k>>S;
	for(int i=1;i<=k;i++)
		cout<<S<<' ';
	for(int i=k+1;i<=n;i++)
		if(S<INF)
			cout<<INF<<' ';
		else
			cout<<1<<' ';
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <unordered_map>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

UINT gcd(UINT a, UINT b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

UINT lcm(UINT a, UINT b)
{
	return a * b / gcd(a, b);
}

const UINT mod = 1000000007;
const double pi = 3.141592653589793238462;
const INT intmax = 9223372036854775807;

UINT _PowMod(UINT x, UINT y, UINT _mod)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % _mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = _PowMod(x, y / 2, _mod);
		return tmp * tmp % _mod;
	}
	else
	{
		auto tmp = _PowMod(x, y / 2, _mod);
		return (tmp * tmp % _mod) * x % _mod;
	}
}


UINT PowMod(UINT x, UINT y)
{
	return _PowMod(x, y, mod);
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

INT nCrMod(INT start, INT n, INT r)
{
	if (n < r)
	{
		return 0;
	}
	INT a = start;
	for (size_t i = n; i >= n - r + 1; i--)
	{
		a *= i;
		a %= mod;
	}
	for (size_t i = 1; i <= r; i++)
	{
		a *= getModInv(i);
		a %= mod;
	}
	return a;
}

INT nHrMod(INT start, INT n, INT r)
{
	return nCrMod(start, n + r - 1, r);
}

INT _nCrMod(INT start, INT n, INT r)
{
	if (n <= 0)
	{
		return 0;
	}
	return nCrMod(start, n, r);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

bool lineCol(INT a1x, INT a1y, INT a2x, INT a2y, INT b1x, INT b1y, INT b2x, INT b2y)
{
	auto ta = (b1x - b2x) * (a1y - b1y) + (b1y - b2y) * (b1x - a1x);
	auto tb = (b1x - b2x) * (a2y - b1y) + (b1y - b2y) * (b1x - a2x);
	auto tc = (a1x - a2x) * (b1y - a1y) + (a1y - a2y) * (a1x - b1x);
	auto td = (a1x - a2x) * (b2y - a1y) + (a1y - a2y) * (a1x - b2x);

	return tc * td < 0 && ta * tb < 0;
}

INT powInt(INT a, INT b)
{
	if (b == 0)
	{
		return 1;
	}
	if (b == 1)
	{
		return a;
	}
	INT tmp = powInt(a, b / 2);
	return (b % 2 == 1 ? a * tmp * tmp : tmp * tmp);
}

INT _sMod(string n, INT mod)
{
	INT k = (n[0] - '0') % mod;
	for (size_t i = 1; i < n.length(); i++)
	{
		k *= 10;
		k += (n[i] - '0');
		k %= mod;
	}
	return k;
}

#define forin(v, n)				\
for (size_t i = 0; i < n; i++)	\
{								\
	cin >> v[i];				\
}

#define vec(t, name, n)			vector<t> name(n)
#define vec_(t, name, n, init)	vector<t> name(n, init)

#define vec2(t, name, n, m)			vector<vector<t>> name(n, vector<t>(m))
#define vec2_(t, name, n, m, init)	vector<vector<t>> name(n, vector<t>(m, init))

struct xy
{
	INT x, y;
	xy() :x(0), y(0) {}
	xy(INT _x, INT _y) : x(_x), y(_y) {}
};

int main()
{	
	INT a, b, h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n;
ll ans=1,a[1<<17];
long double tot;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",a+i);
		if(a[i]==0)puts("0"),exit(0);
		tot+=log10(a[i]);
	}
	if(tot>18.1)puts("-1"),exit(0);
	for(int i=1;i<=n;i++)ans*=a[i];
	if(ans<=1e18l)printf("%lld\n",ans);
	else puts("-1");
	return 0;
}


Measured memory_bytes: 4748
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] c = new int[m];
		for(int i=0; i<m; i++) {
			c[i] = sc.nextInt();
		}
		
		int[] dp = new int[n+1];
		for(int i=1; i<=n; i++) {
			int min = Integer.MAX_VALUE;
			for(int j=0; j<m; j++) {
				if(i-c[j] >= 0 && dp[i-c[j]] < min) {
					min = dp[i-c[j]];
				}
			}
			dp[i] = min + 1;
		}
		
		System.out.println(dp[n]);
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 25052
f=lambda:map(int,input().split())
N,K=f()
A=list(f())

def isOK(X):
    if X<=0:
        return False
    return sum([-a//X*-1-1 for a in A])<=K


ok=10**10
ng=-1
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if isOK(mid):
        ok=mid
    else:
        ng=mid
print(ok)

Measured memory_bytes: 219080
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int a = 0;
  int b = 0;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == 'A') {
      a++;
    }
    else {
      b++;
    }
  }
  if (a != 0 && b != 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

int main()
{
    int N; cin >> N;
    set<int> Set;
    
    for(int i = 0; i < N; ++i)
    {
        int Command; cin >> Command;
        
        if(Command == 0)
        {
            int Val; cin >> Val;
            Set.insert(Val);
            cout << Set.size() << endl;
        }
        else if(Command == 1)
        {
            int Val; cin >> Val;
            cout << (Set.find(Val) != Set.end()) << endl;
        }
        else if(Command == 2)
        {
            int Val; cin >> Val;
            Set.erase(Val);
        }
        else if(Command == 3)
        {
            int LB, UB; cin >> LB >> UB;
            
            set<int>::iterator ite = Set.lower_bound(LB);
            set<int>::iterator last = Set.upper_bound(UB);
            
            while(ite != last)
            {
                cout << *ite << endl;
                ++ite;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 12368
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int A,B,C,D;

  cin>>A>>B>>C>>D;
  int time=0;
  if(A<=C&&C<B)time=min(D,B)-C;
  else if(C<=A&&A<D) time=min(D,B)-A;
    
  cout<<time<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, ans = 0;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (a[i] > b[i]) {
      ans += a[i] - b[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))

next = 1
exist=[0]*n
ans=[]
ans.append(1)


for i in range(n):
    if i+1==k:
        print(a[next-1])
        exit()
    if exist[a[next-1]-1]!=0:
        flag=a[next-1]
        break
    else:
        ans.append(a[next-1])
        exist[next-1]=1
        next=a[next-1]

aa=ans.index(flag)
cycle = len(ans)-aa
po = (k-aa)%cycle

print(ans[po+aa])




Measured memory_bytes: 32376
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(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 REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    string s; cin >> s;
    cout << s.at(0) << s.size() - 2 << s.at(s.size() - 1) << endl;
}

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

int tax(int a, int t){
    int p;
    p = a*(100+t)/100;
    return p;
}

int main(){
    int x,y,s;
    while (cin >> x >> y >> s && s>0){
        int m = 0;
        for (int i=1; i<s; ++i){
               for (int j=1; j<s; ++j){
                   if (tax(i,x) + tax(j,x) == s){
                       m = max(m, tax(i,y) + tax(j,y));}
               }
           }
        cout << m << endl ;
    }
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <inttypes.h>

int N;
int64_t A[114514];
int64_t B[114514];

int64_t sorubu(void) {
	int i;
	int64_t horieyui = 0;
	int64_t mizukinana = 0;
#if 0
	for (i = 0; i < N; i++) {
		if (A[i] <= horieyui) {
			horieyui = B[i];
			mizukinana += A[i];
		} else if (A[i] <= horieyui + B[i]) {
			horieyui = B[i] - (A[i] - horieyui);
			mizukinana += A[i];
		} else {
			horieyui = 0;
			mizukinana += horieyui + B[i];
		}
	}
	if (A[N] <= horieyui) {
		mizukinana += A[N];
	} else {
		mizukinana += horieyui;
	}
#else
	if (A[0] >= B[0]) {
		mizukinana += B[0];
		horieyui = 0;
	} else {
		mizukinana += A[0];
		horieyui = B[0] - A[0];
	}
	for (i = 1; i < N; i++) {
		int64_t hidari = A[i] <= horieyui ? A[i] : horieyui;
		int64_t nokori, migi;
		mizukinana += hidari;
		nokori = A[i] - hidari;
		migi = nokori <= B[i] ? nokori : B[i];
		mizukinana += migi;
		horieyui = B[i] - migi;
	}
	if (horieyui <= A[N]) {
		mizukinana += horieyui;
	} else {
		mizukinana += A[N];
	}
#endif
	return mizukinana;
}

int main(void) {
	int i;
	int64_t minaseinori, ogurayui;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N + 1; i++) {
		if (scanf("%" SCNd64, &A[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd64, &B[i]) != 1) return 1;
	}
	minaseinori = sorubu();
	for (i = 0; i < (N + 1) - 1 - i; i++) {
		int64_t t = A[i]; A[i] = A[(N + 1) - 1 - i]; A[(N + 1) - 1 - i] = t;
	}
	for (i = 0; i < N - 1 - i; i++) {
		int64_t t = B[i]; B[i] = B[N - 1 - i]; B[N - 1 - i] = t;
	}
	ogurayui = sorubu();
	printf("%" PRId64 "\n", minaseinori >= ogurayui ? minaseinori : ogurayui);
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

std::vector<int> digit(int128_t n, const int128_t b) {
    // 基数bでの表示。0は0桁。非常に大きい数を入れても問題ないようにint128_tとする。intやlong longを入れても問題ないはず。
    // size()をとれば桁数になる。
    assert(1 < b);
    std::vector<int> ret;
    while (0 < n) {
        ret.push_back(n % b);
        n /= b;
    }
    return ret;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int N;

int main(int argc, char **argv) {
    std::cin >> N;
    int ret = 0;
    rep (i, 1, N) {
        auto dig = digit(i, 10);
        if (dig.size() % 2 == 1) {
            ret++;
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
h = [int(i) for i in input().split()]

link = 0
ans = 0
while True:
    for i in range(N):
        if i < N-1:
            if h[i] > 0:
                h[i] -= 1
                if h[i+1] > 0:
                    link = 1
                else:
                    link = 0
                if link == 0:
                    ans += 1
        else:
            if h[i] > 0:
                h[i] -= 1
                link = 0
                ans += 1

    if all([v == 0 for v in h]):
        print(ans)
        exit()

Measured memory_bytes: 3064
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    bool ispal1 = true, ispal2 = true, ispal3 = true;
    for (int i = 0; i < n; i++) {
        if (s[i] != s[n - i - 1]) {
            ispal1 = false;
            break;
        }
    }

    for (int i = 0; i < ((n - 1) >> 1); i++) {
        if (s[i] != s[((n - 1) >> 1) - i - 1]) {
            ispal2 = false;
            break;
        }
    }

    for (int i = (n + 3) >> 1; i < n; i++) {
        if (s[i] != s[n - i - 1]) {
            ispal3 = false;
            break;
        }
    }

    if (ispal1 && ispal2 && ispal3) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  fore(i, 0, n) cin >> v[i];
  sort(all(v));
  cout << accumulate(v.begin(), v.begin() + k, 0) << '\n';
  return 0;
}

Measured memory_bytes: 3660
n=int(input())
f=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for j in range(n)]

l=[]
for k in range(1,1024):
  l.append(format(k,'010b'))

L=[]
for m in range(1023):
  C=0
  for q in range(n):
    c=0
    for r in range(10):
      if f[q][r]*int(l[m][r])==1:
        c+=1
    C+=p[q][c]
  L.append(C)
print(max(L))

Measured memory_bytes: 3188
#![allow(non_snake_case)]

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = read();
    let K: usize = read();
    let mut hash = std::collections::HashSet::new();
    for i in 0..s.len() {
        for j in i+1..std::cmp::min(i+K, s.len())+1 {
            hash.insert(s[i..j].to_string());
        }
    }
    let mut dict: Vec<String> = hash.iter().map(|x| x.to_string()).collect();
    dict.sort();
    println!("{}", dict[K-1]);
}


Measured memory_bytes: 6396
int check[30];

int c, n, a;

int main() {

  for (int bit = 29; bit >= 0; bit--) {
    check[bit] = 0;
  }

  n = 0;
  while (1) {
    c = getchar_unlocked();
    if ('0' <= c && c <= '9')
      n = n * 10 + c - '0';
    else
      break;
  }

  int xor_sum = 0;
  for (int i = 0; i < n; i++) {
    a = 0;
    while (1) {
      c = getchar_unlocked();
      if ('0' <= c && c <= '9')
        a = a * 10 + c - '0';
      else
        break;
    }
    xor_sum ^= a;
    a = a ^ (a - 1);

    switch (a) {
    case 1073741823:
      check[29] = 1;
      break;
    case 536870911:
      check[28] = 1;
      break;
    case 268435455:
      check[27] = 1;
      break;
    case 134217727:
      check[26] = 1;
      break;
    case 67108863:
      check[25] = 1;
      break;
    case 33554431:
      check[24] = 1;
      break;
    case 16777215:
      check[23] = 1;
      break;
    case 8388607:
      check[22] = 1;
      break;
    case 4194303:
      check[21] = 1;
      break;
    case 2097151:
      check[20] = 1;
      break;
    case 1048575:
      check[19] = 1;
      break;
    case 524287:
      check[18] = 1;
      break;
    case 262143:
      check[17] = 1;
      break;
    case 131071:
      check[16] = 1;
      break;
    case 65535:
      check[15] = 1;
      break;
    case 32767:
      check[14] = 1;
      break;
    case 16383:
      check[13] = 1;
      break;
    case 8191:
      check[12] = 1;
      break;
    case 4095:
      check[11] = 1;
      break;
    case 2047:
      check[10] = 1;
      break;
    case 1023:
      check[9] = 1;
      break;
    case 511:
      check[8] = 1;
      break;
    case 255:
      check[7] = 1;
      break;
    case 127:
      check[6] = 1;
      break;
    case 63:
      check[5] = 1;
      break;
    case 31:
      check[4] = 1;
      break;
    case 15:
      check[3] = 1;
      break;
    case 7:
      check[2] = 1;
      break;
    case 3:
      check[1] = 1;
      break;
    case 1:
      check[0] = 1;
      break;
    }
  }

  int ans = 0;
  for (int bit = 29; bit >= 0; bit--) {
    if (((1 << bit) & xor_sum) == 0) {
      continue;
    }
    int x = (1 << (bit + 1)) - 1;

    if (check[bit] > 0) {
      xor_sum ^= x;
      ans += 1;
    }
  }

  if (xor_sum != 0) {
    printf("-1\n");
  } else {
    printf("%d\n", ans);
  }
}

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

using namespace std;

#define ll long long

string rev(string s) {
	reverse(s.begin(),s.end());
	return s;
}
int main(){
	string s;
	getline(cin,s);
	int n1=stoi(s);
	int n2=stoi(rev(s));
	if(n1==n2) puts("Yes");
	else puts("No");
	return 0;
}




Measured memory_bytes: 3620