akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
int read()
{
	int out = 0, sgn = 1;
	char jp = getchar();
	while (jp != '-' && (jp < '0' || jp > '9'))
		jp = getchar();
	if (jp == '-')
		sgn = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * sgn;
}
const int N = 2e3 + 10, inf = 1e9;
vector<int> G[N];
int n, ans = inf, a[N], tot[N], cnt[N];
void dfs(int u, int fa)
{
	cnt[u] = a[u], tot[u] = 0;
	for (int v : G[u])
		if (v != fa)
		{
			dfs(v, u);
			cnt[u] += cnt[v];
			tot[u] += tot[v] + cnt[v];
		}
}
int calc(int u, int fa)
{
	int mx = 0;
	for (int v : G[u])
		if (v != fa)
			if (tot[v] >= tot[mx])
				mx = v;
	if (mx == 0)
		return 0;
	int k = calc(mx, u) + cnt[mx];
	if (tot[u] - tot[mx] - cnt[mx] >= k)
		return tot[u] & 1;
	return k - (tot[u] - tot[mx] - cnt[mx]);
}
char buf[N];
int main()
{
	n = read();
	scanf("%s", buf + 1);
	for (int i = 1; i <= n; ++i)
		if (buf[i] == '1')
			a[i] = 1;
	for (int i = 1; i < n; ++i)
	{
		int u = read(), v = read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for (int rt = 1; rt <= n; ++rt)
	{
		dfs(rt, 0);
		if (calc(rt, 0) == 0)
			ans = min(ans, tot[rt] >> 1);
	}
	printf("%d\n", ans < inf ? ans : -1);
	return 0;
}


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

int digitSum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int main(void){
  int N;
  cin >> N;

  if (N % digitSum(N) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3616
Rect = []
cnt = 0
while True:
    H, W = map(int, input().split())
    if (H, W) == (0, 0):
        break
    Rect.append((H, W))
    cnt += 1

for n in range(cnt):
    H, W = Rect[n]
    for i in range(H):
        if i % 2 == 0:
            print("#."*(W//2)+"#"*(W%2))
        else:
            print(".#"*(W//2)+"."*(W%2))
    print()


Measured memory_bytes: 5628
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>

using namespace std;

int main()
{
  int N;
  cin >> N;

  vector<int> P;

  for (int n=0; n<N; ++n) {
    int p;
    cin >> p;
    P.push_back(p);
  }
  
  int count = 0;
  for (int n=1; n<N-1; ++n) {
    int _max = max(P[n-1],max(P[n],P[n+1]));
    int _min = min(P[n-1],min(P[n],P[n+1]));
    if (_max != P[n] && _min != P[n])
      ++count;
  }

  cout << count << endl;

  return 0;
}


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

#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define drng(i,a,b) for(int i=int(a);i>int(b);i--)
typedef long long LL;


void test_case(){
	
}
int main() {
    fastio
    int a;
    cin>>a;
    rng(i,1,10){
    	if(a%i == 0 && (a/i)<10){
    		cout<<"Yes"<<endl;
    		// cout<<i<<endl;
    		exit(0);
    	}
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = A*B;

		if(T%2 == 1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 22612
const int N = 400005;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n; cin >> n;
    vector<int> p(n); forn(i, n) cin >> p[i], p[i]--;
    int ans = 0;
    int cnt = 0;
    forn(i, n)
    {
        if (p[i] == i) cnt++;
        if (p[i] == i && (i + 1 == n || p[i + 1] != i + 1))
        {
            ans += (cnt + 1) / 2;
            cnt = 0;
        }
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,A[200000],num[200001]={0};
    cin>>n;
    rep(i,n) cin>>A[i];
    vector<int> B;
    for(int i=n;i>0;i--){
        if(num[i]%2!=A[i-1]){
            B.push_back(i);
            int p=i;
            for(int j=1;j<=sqrt(p);j++)if(p%j==0){
              if(j!=p/j) num[j]++,num[p/j]++;
              else num[j]++;
            }
        }
    }
    cout<<B.size()<<endl;
    rep(i,B.size()) cout<<B[i]<<" ";
}

Measured memory_bytes: 3192
import sys
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def input():
    return next(args)
def parse(*params):
    if len(params) == 1:
        return params[0](next(args))
    return tuple(p(v) for p, v in zip(params, next(args).split()))
def debug(*v):
    if __debug__:
        print(*v, file=sys.stderr)

# エントリーポイント
def main():
    N, Q = parse(int, int)
    edges = [[] for _ in range(N + 1)]
    for _ in range(N - 1):
        a, b = parse(int, int)
        edges[a] += [b]
        edges[b] += [a]
    vals = [0] * (N + 1)
    for _ in range(Q):
        p, x = parse(int, int)
        vals[p] += x

    counter = [0] * (N + 1)
    que = deque()
    que.append((1, 0))
    alr = [False] * (N + 1)
    while que:
        v, x = que.pop()
        alr[v] = True
        counter[v] += x + vals[v]
        for n in edges[v]:
            if not alr[n]:
                que.append((n, counter[v]))

    for v in counter[1:]:
        print(v)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split("\n"))
    main()


Measured memory_bytes: 93764
import math

L, R, d = map(int, input().split())
Lt = L%d
Rt = R%d
ans = 0

if Lt!=0 and Rt!=0:
    ans = math.floor(R/d) - math.floor(L/d)
elif Lt==0 and Rt==0:
    ans = int(R/d - L/d +1)
elif Lt!=0 and Rt==0:
    ans = int(R/d) - math.floor(L/d)
else:
    ans = math.floor(R/d) - int(L/d)

print(ans)



Measured memory_bytes: 9208
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll dp[101][100001],n,W;
pair<ll,ll> p[100001];
ll solve(ll i,ll w)
{
	if(i==n)
	{
		return 0;
	}
	if(dp[i][w]!=-1) return dp[i][w];
	ll ans1=0,ans2=0;
	ans1 = solve(i+1,w);
	if(w+p[i].fi<=W)ans2 = p[i].se+solve(i+1,w+p[i].fi);
	return dp[i][w]=max(ans2,ans1);
}
int main()
{
	boost
	cin>>n>>W;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++)
	{
		cin>>p[i].fi>>p[i].se;
	}
	cout<<solve(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
const int Ex = 11;
vector<int> v;

int main(){
while(1){//start
	int n, m;
	cin >> n >> m;
	if(n == 0 and m == 0) break;
	v.resize(Ex);

	//input data
	for(int i = 0; i < n; i++){
		int d, p;
		cin >> d >> p;
		v[p] += d;
	}

	//sub
	for(int i = 10; i > 0; i--){
		if(m - v[i] >= 0){
			m -= v[i];
			v[i] = 0;
		}
		else{
			v[i] -= m;
			break;
		}
	}

	//debug
	//for(int i = 1; i < 11; i++) cout << "test = " << v[i] << endl;

	//cluc
	int ans = 0;
	for(int i = 10; i > 0; i--){
		ans += i * v[i];
	}

	cout << ans << endl;
	v.clear();
}//end
	return 0;
}



Measured memory_bytes: 3088
import sys, io, os
input = sys.stdin.readline
inputt = lambda: range(int(input()))
inputn = lambda n = 1: range(n)
inputi = lambda: map(int, input().split())
inputl = lambda: list(inputi())
from math import *
from heapq import *
from bisect import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict
from builtins import *

N, M = inputi()
A = inputl()
S = sum(A)
t = ceil(S / (4 * M))
b = (sum(a >= t for a in A) >= M)
if b:
    print("Yes")
else:
    print("No")

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

int main() {
  vector<int> v = {2, 3, 5, 7};
  for(int i = 11; i < 100004; i += 2){
    bool b = 1;
    for(int j = 1; j < v.size(); ++j){
      if(i % v.at(j) == 0){
        b = 0;
        break;
      }
    }
    if(b) v.push_back(i);
  }
  int x, n;
  cin >> x;
  for(int i = 0; i < v.size(); ++i){
    if(v.at(i) >= x){
      n = v.at(i);
      break;
    }
  }
  cout << n << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

//ll comb_mod(ll a, ll b, ll mod){
//    ll num = 1;
//    ll div = 1;
//    for(int i = 0; i < b; i++){
//        num = (num * (a-i)) % mod;
//        div = (div * (b-i)) % mod;
//    }
//
//    ll ret = (num * mod_pow(div, mod-2, mod)) % mod;
//    return ret;
//}

const int MAX_N = 2000000;

ll fact[MAX_N+100];
ll frev[MAX_N+100];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}


void calc_fact(){
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }
}


ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}

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

    //in main function
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }

    ll size = S.size();

    ll ans = 0;
    for(ll m = 0; m <= K; m++){
        ll right = mod_pow(26, m, MOD);
        ll left = mod_pow(25, K-m, MOD);
        //ll com = comb_mod(K-m+size-1, size-1, MOD);
        ll com = comb(K-m+size-1, size-1);

        ll add = right * left;
        add %= MOD;
        add *= com;
        add %= MOD;

        ans += add;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35608
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
long long a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	if(a+b>c+d) cout<<"Left\n"; else 
		if(a+b==c+d) cout<<"Balanced"; else
			cout<<"Right\n";
	return 0;
}

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

int n, c[100001] = {};
long long ans = 0;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> c[i];
		
	for (int i = 1; i <= n; i++)
	{
		ans += c[i] / 2;
		c[i] %= 2;
		
		if (i < n && c[i] == 1 && c[i + 1] != 0)
		{
			ans++;
			c[i + 1]--;
		}	
	}	
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main(){
  int M;
  std::cin >> M;
  std::vector<int > d(M);
  std::vector<long long > c(M);
  long long ans = 0;
  long long sum = 0;
  for (int i=0; i<M; i++) {
    std::cin >> d[i] >> c[i];
    ans += c[i];
    sum += c[i]*(long long)d[i];
  }
  ans--;
  ans += (sum-1)/9;
  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e5 + 10;
ll n , w , x , y;
vector<pair<ll , ll>> v;
ll dp[110][N];
ll check(int ind , int x)
{
    ll sum = 0;
    if(dp[ind][x] != -1)    return dp[ind][x];
    if(ind == v.size())    return 0;
    if(v[ind].first <= x)
    {
        sum = max(v[ind].second + check(ind + 1 , x - v[ind].first) , check(ind + 1 , x)); 
    }else
    {
        sum = check(ind + 1 , x);
    }
    dp[ind][x] = sum;
    return sum;
}
int main()
{
    cin >> n >> w;
    memset(dp , -1 , sizeof dp);
    for(int i = 1 ; i <= n ; i ++)
    {
        cin >> x >> y;
        v.push_back({x , y});
    }
    cout << check(0 , w);
    return 0;
}

Measured memory_bytes: 89580
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

int main() {
  int n; cin >> n;
  vector<int> A(n);
  loop(i,0,n) cin >> A[i];
  map<int, int> C_ODD, C_EVEN;
  loop(i,0,n) {
    if (i&1) C_ODD[A[i]]++;
    else C_EVEN[A[i]]++;
  }
  vector<int> R_ODD(2), R_EVEN(2);
  {
    int max_ = 0;
    for (auto &m: C_ODD) if (max_ < m.second) { max_ = m.second; R_ODD[0] = m.first; }
  }
  {
    int max_ = 0;
    for (auto &m: C_EVEN) if (max_ < m.second) { max_ = m.second; R_EVEN[0] = m.first; }
  }
  {
    int max_ = 0;
    for (auto &m: C_ODD) {
      if (R_ODD[0] == m.first) continue;
      if (max_ < m.second) { max_ = m.second; R_ODD[1] = m.first; }
    }
  }
  {
    int max_ = 0;
    for (auto &m: C_EVEN) {
      if (R_EVEN[0] == m.first) continue;
      if (max_ < m.second) { max_ = m.second; R_EVEN[1] = m.first; }
    }
  }
  
  if (R_ODD[0] != R_EVEN[0]) {
    cout << (n/2 - C_ODD[R_ODD[0]]) + (n/2 - C_EVEN[R_EVEN[0]]) << endl;
    return 0;
  }
  if (R_ODD[0] == R_EVEN[0]) {
    ll cost1 =  (n/2 - C_ODD[R_ODD[1]]) + (n/2 - C_EVEN[R_EVEN[0]]);
    ll cost2 =  (n/2 - C_ODD[R_ODD[0]]) + (n/2 - C_EVEN[R_EVEN[1]]);
    cout << min(cost1, cost2) << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 8288
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define f first 
# define s second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)

using namespace std;

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

# define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
# define debug cerr<<"ERROR"<<endl
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int inf=1e9,mod=998244353,N=2e5+5;


void solve(){
	int n,k;
	cin>>n>>k;
	vector<int>a(n);
	rep(i,n){
		cin>>a[i];
	}
	sort(all(a));
	int ans=inf;
	rep(i,n){
		if(i+k-1<n){
			umin(ans,a[i+k-1]-a[i]);
		}
	}
	cout<<ans;
}

int main(){
 	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}

Measured memory_bytes: 3732
import java.io.*;
import java.util.Arrays;


public class Main  {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] temp = br.readLine().split(" ");
        int N = Integer.parseInt(temp[0]);
        int K = Integer.parseInt(temp[1]);
        temp = br.readLine().split(" ");
        int[] arr = new int[N];
        for(int i=0;i<N;i++)arr[i] = Integer.parseInt(temp[i]);
        Arrays.sort(arr);

        int sum = 0;
        for(int i=0;i<K;i++){
            sum += arr[i];
        }

        System.out.println(sum);
       
    }


}



Measured memory_bytes: 32956
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

int dp[13][100005];

inline void solve(){
    int yen; cin>>yen; 
    int a[13]={0,1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
    fill(dp[0]+1,dp[0]+100005,1e9);
    for (int i=1;i<=12;i++){
    	for(int j=1;j<=yen;j++){
    		if (a[i]>j) dp[i][j] = dp[i-1][j] ; 
    		else dp[i][j] = min(dp[i-1][j],dp[i][j-a[i]]+1);
    	}
    }
    cout << dp[12][yen] << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 13632
#include "bits/stdc++.h"
using namespace std;
 
int main() {
    string s;
    cin >> s;
    string odd = "RUD", even = "LUD";
    int n = s.size();
    for(int i = 0; i < n; i++){
        bool t = true;
        if(i%2 == 0){
            if(s[i] == 'L') t = false;
        }else{
            if(s[i] == 'R') t = false;
        }
        if(!t){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;
char in[110];
int main(){
  int a,b;scanf("%d%d",&a,&b);
  for(int i=0;i<b;i++)in[i]='0'+a;
  string L=in;
  for(int i=0;i<a;i++)in[i]='0'+b;
  in[a]=0;
  string R=in;
  printf("%s\n",min(L,R).c_str());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)
ll dp[305][305];
int h[305];
int main()
{
    int n,i,j,t,p;
    boost;
    int k;
    cin>>n>>k;
    
    rep(i,0,n)cin>>h[i+1];
    rep(i,1,n+2)rep(j,0,k+1)dp[i][j]=1e15;
    rep(i,1,n+2)
    {
        rep(p,0,i)
        {
            rep(j,0,k+1)
            {
                int col=j+i-p-1;
                if(col>k)break;
                int cost;
                if(h[p]>=h[i])cost=0;
                else cost=h[i]-h[p];
                dp[i][col]=min(dp[i][col],dp[p][j]+cost);
            }
        }
    }

    ll ans=1e15;
    rep(i,0,k+1)ans=min(ans,dp[n+1][i]);
    cout<<ans;


    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>

int main(void){

int n,i,max=-1000000,max1,f[100],b[100];
scanf("%d",&n);
for(i=0; i<n; i++){
scanf("%d %d",&b[i],&f[i]);
if(max < f[i]){
max=f[i];
max1=b[i];
}
else if(max==f[i]){
  if(b[i]<max1){
   max=f[i];
   max1=b[i];
   }
}

}

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


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int main(){
    std::vector<int> vec(3);
    for(int i = 0; i < 3; ++i){
        std::cin >> vec.at(i);
    }
    std::sort(vec.begin(), vec.end());

    int k;
    std::cin >> k;
    for(int i = 0; i < k; ++i){
        vec.at(2) *= 2;
    }

    std::cout << std::accumulate(vec.begin(), vec.end(), 0);

    return 0;
}

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

typedef long long ll;
typedef std::pair<ll, ll> P;

constexpr ll INF = 1e15;
constexpr ll mod = 1e9 + 7;

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

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

int main() {
	int n;
	cin >> n;
	vector<P> vs(n);
	vector<bool> eq(n);
	rep(i, n) {
		cin >> vs[i].first >> vs[i].second;
		eq[i] = vs[i].first == vs[i].second;
	}
	rep(i, n - 2) {
		if (eq[i] && eq[i + 1] && eq[i + 2]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3628
import java.util.*;
import java.lang.*;
import java.math.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
    void run(){
        int[][] map = new int[14][14];
        int[][][] ink = {
                {{0,0,0,0,0},{0,0,1,0,0},{0,1,1,1,0},{0,0,1,0,0},{0,0,0,0,0},},
                {{0,0,0,0,0},{0,1,1,1,0},{0,1,1,1,0},{0,1,1,1,0},{0,0,0,0,0},},
                {{0,0,1,0,0},{0,1,1,1,0},{1,1,1,1,1},{0,1,1,1,0},{0,0,1,0,0},},
        };
        for(;sc.hasNext();){
            String buf = sc.next().replace(',', ' ');
//          if(buf.equals("a")) break;
            Scanner sc2 = new Scanner(buf);
             
            int x = sc2.nextInt()+2;
            int y = sc2.nextInt()+2;
            int size = sc2.nextInt() -1;
            for(int i = 0;i<5;i++){
                for(int j=0;j < 5;j++){
                    map[i+x-2][j+y-2] += ink[size][i][j]; 
                }
            }
        }
        int max = 0;
        int count = 0;
        for(int i=2;i<12;i++){
            for(int j=2;j<12;j++){
                if(map[i][j] == 0){
                    count++;
                }
                if(max < map[i][j]){
                    max = map[i][j];
                }
            }
        }
        System.out.println(count);
        System.out.println(max);
    }
    public static void main(String[] args){
        Main m = new Main();
        m.run();
         
    }
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, M;
	static int[][][] f;

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			M = sc.nextInt();
			int P = sc.nextInt();
			f = new int[N][N][N];
			int[][] h = new int[N][N];
			int win = 0;
			int turn = 0;
			int hand = 1;
			for (int i = 0; i < P; ++i, hand *= -1) {
				int xp = sc.nextInt() - 1;
				int yp = sc.nextInt() - 1;
				if (win != 0) continue;
				f[xp][yp][h[xp][yp]++] = hand;
				if (check(hand)) {
					win = hand;
					turn = i + 1;
				}
			}
			if (win == 1) {
				System.out.println("Black " + turn);
			} else if (win == -1) {
				System.out.println("White " + turn);
			} else {
				System.out.println("Draw");
			}
		}
	}

	static boolean check(int hand) {
		for (int x = 0; x < N; ++x) {
			for (int y = 0; y < N; ++y) {
				for (int z = 0; z < N; ++z) {
					if (f[x][y][z] != hand) continue;
					for (int dx = -1; dx <= 1; ++dx) {
						for (int dy = -1; dy <= 1; ++dy) {
							for (int dz = -1; dz <= 1; ++dz) {
								if (dx == 0 && dy == 0 && dz == 0) continue;
								boolean ok = true;
								int cx = x;
								int cy = y;
								int cz = z;
								for (int i = 0; i < M; ++i) {
									if (!inside(cx) || !inside(cy) || !inside(cz)) {
										ok = false;
										break;
									}
									if (f[cx][cy][cz] != hand) {
										ok = false;
										break;
									}
									cx += dx;
									cy += dy;
									cz += dz;
								}
								if (ok) return true;
							}
						}
					}
				}
			}
		}
		return false;
	}

	static boolean inside(int v) {
		return 0 <= v && v < N;
	}

}

Measured memory_bytes: 62216
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
int main() {
  cin >> n;
  cout << n * (n - 1) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
 
      if(S.equals (T.substring(0,S.length()))){
    System.out.println("Yes");
      }else{
	System.out.println("No");
      }
      }
}

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

long long n,cnt=0,ans=0;
char a[200005];

signed main()
{
	ios::sync_with_stdio(0);
	
	cin >> n;
	
	for (long long i=1; i<=n; i++) 
	{ 
		cin >> a[i];
	} 
		
	for (long long i=1;i<=n;i++)
	{
		if (a[i]=='W')  
		{ 
			cnt++;
		} 
	}
	
	for (long long i=n-cnt+1;i<=n;i++)
	{
		if (a[i]!='W') 
		{ 
			ans++;
		} 
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3836
n = int(input())
li = list(map(int,input().split()))
lee = len(li)
sorted_li = sorted(li)
mid = sorted_li[lee//2]
mid_mae = sorted_li[lee//2-1]
tmp = mid
for l in li:
    if l < mid:
        print(mid)
    else:
        print(mid_mae)

Measured memory_bytes: 25224
import java.io.IOException;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) throws IOException {
		//File fi=new File("file.txt");

		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		 String type;
		 int b,f,r,v;
		 int[][][] tp=new int[5][4][11];
		for(int i=0;i<t;i++){
			b=sc.nextInt();
			f=sc.nextInt();
			r=sc.nextInt();
			v=sc.nextInt();
			tp[b][f][r]+=v;
			int x=tp[b][f][r];
			if(x<0)x=0;
			else if(x>10)x=9;
			tp[b][f][r]=x;
			}sc.close();
		for(int i=1;i<5;i++){
			for(int l = 1;l<4;l++){
				for(int m=1;m<11;m++){
					System.out.print(" "+tp[i][l][m]);
				}System.out.println();				
				}if(i!=4)System.out.println("####################");
			}
		}
		
		
	}

Measured memory_bytes: 21068
#include<iostream>
using namespace std;
int main(){
	int H,W,i,j;
	for(;;){
		cin>>H>>W;
		if(W==0&&H==0){
			break;
		}
	for(i=1;i<=H;i++){
		for(j=1;j<=W;j++){
			if(i==1||j==1||i==H||j==W){
				cout<<"#";
			}
			else{cout<<".";
			}
		}cout<<endl;
	}
	cout<<endl;}
	return 0;
}


Measured memory_bytes: 3116
l = input().strip().split(' ')
l = list(map(lambda x: int(x), l))
if (l[0] * l[1] * l[2]) % 2 == 0:
	print(0)
else:
	print(min(l[0] * l[1], l[1] * l[2], l[2] * l[0]))



Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int a,b,c,d,n,l,i,j,r;
    char x[102],z,y[102];
    gets(x);
    gets(y);
    l=strlen(x);
    for(i=0;i<l;i++)
    {z=x[0];
        for(j=1;j<l;j++)
        {
            x[j-1]=x[j];
        }
        x[l-1]=z;
        c=strcmp(x,y);
        if(c==0)
        {
            printf("Yes\n");
            break;
        }
    }
    if(c!=0){printf("No\n");}

return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);

        Console.WriteLine(a +
            (a > b ? - 1 : 0));
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <climits>
#include <vector>

using namespace std;

int main()
{
    vector<int> vec;
    
    int N; cin >> N;
    for(int i = 0; i < N; ++i)
    {
        int Num; cin >> Num;
        vec.push_back(Num);
    }
    
    cin >> N;
    for(int i = 0; i < N; ++i)
    {
        int Command; cin >> Command;
        int Start, End; cin >> Start >> End;
        if(Command == 0)
        {
            int Min = INT_MAX;
            
            for(int j = Start; j < End; ++j)
              if(Min > vec[j])
                Min = vec[j];
                
            cout << Min << endl;    
        }
        else if(Command == 1)
        {
            int Max = INT_MIN;
            
            for(int j = Start; j < End; ++j)
              if(Max < vec[j])
                Max = vec[j];
            cout << Max << endl;    
        }
        
    }
    
    
    return 0;
    
}


Measured memory_bytes: 3168
N,X=map(int,input().split())
x=list(map(int,input().split()))
lst=[]
for i in range(N):
  lst.append(abs(X-x[i]))
  
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if a==b:
    return a
  else:
    if a%b==0:
      return b
    else:
      return gcd(b,a%b)
if N==1:
  print(lst[0])
else:
  tmp=gcd(lst[0],lst[1]) 
  if N==2:
    print(tmp)
  elif N>=3:
    for i in range(2,N):
      tmp=gcd(tmp,lst[i])
    print(tmp)

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if(a + b > c + d){
    cout << "Left" << endl;
  }
  else if(a + b == c + d){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

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


Measured memory_bytes: 256
K = int(input())
from collections import deque
que=deque([1,2,3,4,5,6,7,8,9])
for i in range(K):
    x=que.popleft()
    if x%10!=0:
        que.append(10*x+(x%10-1))
    que.append(10*x+x%10)
    if x%10!=9:
        que.append(10*x+(x%10+1))
print(x)

Measured memory_bytes: 12384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		if(k==1) {
			System.out.println("0");
			return;
		}
		System.out.println(n-k);

	}

}


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

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

  int ans = a - (b + c);

  if(ans >= 0) {
    cout << 0;
    return 0;
  }
  if(ans < 0){
    cout << -1 * ans;
      return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, K;
  cin >> N >> K;
  vector<pair<long, long>> data(N);
  vector<long> x(N), y(N);
  for(int i = 0; i < N; i++){
    cin >> data.at(i).first >> data.at(i).second;
    x.at(i) = data.at(i).first;
    y.at(i) = data.at(i).second;
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  long ans = ((long)1000000000 * 2) * ((long)1000000000 * 2) + 1;
  long count;
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      if(x.at(i) == x.at(j))continue;
      for(int k = 0; k < N; k++){
        for(int l = k + 1; l < N; l++){
          if(y.at(k) == y.at(l))continue;
          count = 0;
          for(int m = 0; m < N; m++){
            if(x.at(i) <= data.at(m).first && x.at(j) >= data.at(m).first){
              if(y.at(k) <= data.at(m).second && y.at(l) >= data.at(m).second){
                count++;
              }
            }
            if(count >= K)ans = min(ans, (x.at(j) - x.at(i)) * (y.at(l) - y.at(k)) );
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
Hanit Banga
*/

// #include <iostream>
#include <cstdio>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
template <typename has_less>
using ordered_set =
tree <has_less,
null_type,
less <has_less>,
rb_tree_tag,
tree_order_statistics_node_update
>;

const int N = 3e5 + 5, M = 1e5 + 5, INF = 1e7;

int ans[M] = {0};
pii s[N];
vector <pii> events;
vector <int> trains[M];
ordered_set <pii> current;

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);	

	for (int i = 1; i <= n; ++i)
	{
		scanf("%d%d", &s[i].first, &s[i].second);
		events.pb({s[i].first, i});
		events.pb({s[i].second + 1, -i});
	}

	sort(events.begin(), events.end());
	for (int i = 1; i <= m; ++i)
		for (int j = i; j <= m; j += i)
			trains[j].pb(i);

	int cur_event = 0;
	for (int i = 1; i <= m; ++i)
	{
		while (cur_event < 2*n)
		{
			auto cur = events[cur_event];
			if (cur.first > i)
				break;

			if (cur.second > 0)
				current.insert({cur.first, cur.second});

			else
				current.erase({s[-cur.second].first, -cur.second});

			++cur_event;
		}

		for (auto &j : trains[i])
		{
			int temp = current.order_of_key({i - j, INF});
			ans[j] += current.size() - temp;
		}
	}

	for (int i = 1; i <= m; ++i)
		printf("%d\n", ans[i]);
}

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

int main()
{
	int n,x,i,j,k,count=0;

	while(1)
	{
		count = 0 ;
		cin >> n >> x ;
		if((n==0)&&(x==0)) break ;

		for(k=1;k<=n;k++)
		{
			for(j=1;j<=n;j++)
			{
				for(i=1;i<=n;i++)
				{
					if(i!=j&&j!=k&&k!=i)
					{
						if(x==i+j+k) count++;
					}
				}
			}
		}
		cout << count/(3*2) << endl ;
	}

	


	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    ll d, t, s;
    cin>>d>>t>>s;
    ld x = (ld)d/(ld)s;
    //cout<<x<<endl;
    if(x<=(ld)t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "@===================ok===================@" <<endl;
#define WTF cout <<"< "<<lo<<" | "<< hi <<" >" << endl;

using namespace std;

int main()
{
	//
    // vll v,q;
    // //v.pb(12);
	// v.pb(1);
	// v.pb(1);
	// for(int i=2;i<31;i++){
	// 	v.pb(1LL*i*v[i-2]);
	// }
	//
	// for(int i=0;i<v.size();i+=2){
	// 	cout << i <<"->"; cout << v[i] <<" : ";
	// 	int cn=0;
	// 	while(v[i]%10==0){
	// 		cn++;
	// 		v[i]/=10;
	// 	}
	// 	cout << cn << endl;
	// 	q.pb(cn);
	// }
	ll n;
	cin >> n;
	if(n%2){
		cout << 0 << endl;
	}
	else{

		ll p=10;
		ll ans=0;
		for(int i=1;p<=1000000000000000000LL;){
			ans+=n/p;
			p*=5;
		}

		cout << ans << endl;

	}
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static final String[] KEYWORD = {"the","that","this"};

	public static void main(String args[]) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String cipher;
		while((cipher = br.readLine()) != null){
			int movement = getMovement(cipher);
			System.out.println(decrypt(movement, cipher));
		}
	}
	public static String decrypt(int movement, String cipher){
		char[] c = cipher.toCharArray();
		for(int i=0;i<c.length; i++){
			if(c[i]<'a'||'z'<c[i]){
				continue;
			}
			c[i]=(char)(c[i]+movement);
			if(c[i]>'z'){
				int fixMovement = c[i] - 'z';
				c[i] = (char)('a'-1+fixMovement);
			}
		}
		return String.valueOf(c);
	}
	private static int getMovement(String cipher){
		int movement = 0;
		for(int i =1; i<26; i++){
			if( decrypt(i,cipher).contains(KEYWORD[0]) ||
					decrypt(i, cipher).contains(KEYWORD[1])||
					decrypt(i, cipher).contains(KEYWORD[2]) ){
				movement = i;
				break;
			}
		}
		return movement;

		}
	}

Measured memory_bytes: 17836
#include <vector>

using namespace std;

using u8 = unsigned char;
using uint = unsigned int;

class bitVector {
public:
    uint length, cnum, bnum;
    // bit列の長さ、chunk数、chunk毎のblock数

    static int cw, bw;
    // chunkの幅、blockの幅 今回は256, 32

    vector<uint> bit;
    vector<uint> chunk;
    vector<vector<u8>> blocks;


    explicit bitVector(int N) : length(N) {
        cnum = (length + cw - 1) / cw;
        // length / cwを切り上げたものが必要なchunkの個数
        bnum = cw / bw;

        bit.assign(cnum * bnum, 0);
        chunk.assign(cnum + 1, 0);
        // +1は先頭の0が入っているやつの分
        blocks.assign(cnum, vector<u8>(bnum, 0));
    }

    // pos桁目をbに変える
    void set(int pos, int b) {
        int bpos = pos / bw;
        // bit内でposが存在するblockの番号
        int offset = pos % bw;
        // そのblock内でのposのindex

        if (b == 0) {
            bit[bpos] &= ~(1 << offset);
        } else if (b == 1) {
            bit[bpos] |= (1 << offset);
        }
    }

    // pos桁目のbitを返す
    int access(int pos) const {
        // assert(pos < length);

        int bpos = pos / bw;
        int offset = pos % bw;
        return bit[bpos] >> offset & 1;
    }

    uint popCount(uint num) const {
        // __builtin_popcountが使えなければ黒魔術
        return __builtin_popcount(num);
    }

    // chunkとblocksを適切に埋める
    void build() {
        chunk[0] = 0;
        for (int i = 0; i < cnum; ++i) {
            blocks[i][0] = 0;
            for (int j = 0; j < bnum - 1; ++j) {
                blocks[i][j + 1] = blocks[i][j] + popCount(bit[i * bnum + j]);
            }
            chunk[i + 1] = chunk[i] + blocks[i][bnum - 1] + popCount(bit[(i + 1) * bnum - 1]);
        }
    }

    // [0, pos)にあるkindの数を返す
    int rank(int pos, int kind) const {
        // assert(kind <= 1);
        if (kind == 0) {
            return pos - rank1(pos);
        } else {
            return rank1(pos);
        }
    }

    // [0, pos)にある1の数を返す
    int rank1(int pos) const {
        int cpos = pos / cw;
        int bpos = pos % cw / bw;
        int offset = pos % bw;

        uint masked = (bit[cpos * bnum + bpos]) & ((1 << offset) - 1);
        return chunk[cpos] + blocks[cpos][bpos] + popCount(masked);
    }

    // rank(idx, kind)=numなる最小のidxを返す
    // そもそもkindがnum個なかったら-1を返す
    int select(int num, int kind) const {
        if (num == 0) return 0;
        if (rank(length, kind) < num) return -1;

        int ok = length, ng = 0;
        while (ok - ng > 1) {
            int mid = (ok + ng) / 2;
            if (rank(mid, kind) >= num) {
                ok = num;
            } else {
                ng = num;
            }
        }

        return ok;
    }
};

int bitVector::cw = 256;
int bitVector::bw = 32;

#include <iostream>
#include <string>

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

    bitVector bv(N);

    for (int i = 0; i < N; ++i) {
        bv.set(i, S[i] == 'W' ? 1 : 0);
    }

    bv.build();
    int ans = N;

    for (int i = 1; i <= N; ++i) {
        int turn = bv.rank(i - 1, 1) + (bv.rank(N, 0) - bv.rank(i, 0));
        ans = min(ans, turn);
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N;
v_ll A;
int main(){
  cin >> N;
  A.assign(N+10,0);
  ll sum=0;
  ll abssum=0;
  for (ll i=1;i<=N;i++){
    cin >> A[i];
    sum+=A[i];
    abssum+=abs(A[i]);
  }
  sort(A.begin()+1,A.begin()+1+N);
  ll hoge = N+1;
  for (ll i=1;i<=N;i++){
    if (A[i]>=0){hoge=i;break;}
  }
  if (hoge==1){
    cout << sum-A[1]*2 << endl;
    ll x=A[1],y=A[1];
    for (ll i=2;i<=N-1;i++){
      y=A[i];
      cout << x << " " << y << endl;
      x=x-y;
    }
    y=x;
    x=A[N];
    cout << x << " " << y << endl;
    return 0;
  }else if (hoge==N+1){
    cout << A[N]*2-sum << endl;
    ll x=A[N],y=A[1];
    for (ll i=1;i<=N-1;i++){
      y=A[i];
      cout << x << " " << y << endl;
      x=x-y;
    }
    return 0;
  }else{
    cout << abssum << endl;
    ll X,Y;
    ll x=A[hoge],y=A[1];
    for (ll i=2;i<=hoge-1;i++){
      y=A[i];
      cout << x << " " << y << endl;
      x=x-y;
    }
    X=x;
    x=A[1];
    for (ll i=hoge+1;i<=N;i++){
      y=A[i];
      cout << x << " " << y << endl;
      x=x-y;
    }
    Y=x;
    cout << X << " " << Y << endl;
  }
}


Measured memory_bytes: 2688
q,h,c,d=map(int,input().split())
n=int(input())
c=min(4*q,2*h,c)
if d<2*c:
    if n%2==0:
        print(d*(n//2))
    else:
        print(d*(n//2)+c)
else:
    print(n*c)


Measured memory_bytes: 2940