akhauriyash/Code-Regression huggingface dataset:
/*
 * ALDS1_10_C.cpp
 *
 *  Created on: May 5, 2018
 *      Author: 13743
 */

#include<cstdio>
#include<cstring>
#include<algorithm>

int dp[1001][1001];
bool dpR[1001][1001];

int lcm(char* X, char* Y, int nx, int ny) {
	dp[1][1] = (X[0] == Y[0]);
	for(int i=1; i<=nx; i++) {
		for(int j=1; j<=ny; j++) {
			dp[i][j] = (X[i-1]==Y[j-1]) + dp[i-1][j-1];
			dp[i][j] = std::max(dp[i-1][j], dp[i][j]);
			dp[i][j] = std::max(dp[i][j-1], dp[i][j]);
		}
	}
	return dp[nx][ny];
}

int lcmRec(char* X, char* Y, int nx, int ny) {
	if(nx <=0 || ny <= 0) return 0;
	if(!dpR[nx][ny]) {
		dpR[nx][ny] = 1;
		dp[nx][ny] = lcmRec(X, Y, nx-1, ny-1) + (X[nx-1]==Y[ny-1]);
		dp[nx][ny] = std::max(lcmRec(X, Y, nx-1, ny), dp[nx][ny]);
		dp[nx][ny] = std::max(lcmRec(X, Y, nx, ny-1), dp[nx][ny]);
	}
	return dp[nx][ny];
}

int main() {
	int q;
	scanf("%d", &q);
	char X[1001];
	char Y[1001];
	while(q--) {
		for(int i=0; i<1001; i++) {
			for(int j=0; j<1001; j++) {
				dpR[i][j] = dp[i][j] = 0;
			}
		}
		scanf("%s", X);
		scanf("%s", Y);
		int nx = (int)strlen(X);
		int ny = (int)strlen(Y);
		printf("%d\n", lcm(X, Y, nx, ny));
		//printf("%d\n", lcmRec(X, Y, nx, ny));
	}
}





Measured memory_bytes: 7620
#include <iostream>
int main(){
int w,n,b[30],a,c,d,i,f,h;
char g;
std::cin>>w>>n;
for(a=1;a<=w;++a){
    b[a]=a;
    }
for(i=0;i<n;++i){
      std::cin>>c>>g>>d;
       f=b[c];
      b[c]=b[d];
     b[d]=f;
}
for(h=1;h<=w;++h){
  std::cout<<b[h]<<std::endl;
  }
return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

#define MAX 45

int fibonacci(int);
int F[MAX];

int main(){

  int n;

  scanf("%d",&n);

  printf("%d\n",fibonacci(n));

  return 0;
}

int fibonacci(int n){

  if(n == 0 || n == 1) return F[n] = 1;
  else if(F[n] > 0) return F[n];
  else return F[n] = fibonacci(n-2) + fibonacci(n-1);
}
	

Measured memory_bytes: 596
fn main() {
    let a = read::<usize>();
    let b = read::<usize>();

    let ret: usize;
    if a == 1 && b == 2 {
        ret = 3;
    } else if a == 1 && b == 3 {
        ret = 2;
    } else if a == 2 && b == 1 {
        ret = 3;
    } else if a == 2 && b == 3 {
        ret = 1;
    } else if a == 3 && b == 1 {
        ret = 2;
    } else {
        ret = 1;
    }

    println!("{}", ret);
}

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()
}

Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 998244353
#define Mod1(x) (x>=mod?x-mod:x)
#define Mod2(x) (x<0?x+mod:x)
#define maxn 3000010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
ll fac[maxn],inv[maxn];
int n,m;
inline ll power(ll a,ll b)
{
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ans=ans*a%mod;
	return ans;
}
inline ll C(int n,int m){return fac[n]*inv[m]%mod*inv[n-m]%mod;}
inline ll calc(int n,int m,int k)
{
	ll sum=0;
	for(int i=0;i<=n&&i<=k;i++)
		if(!((m-i)&1)&&m>=i)sum=(sum+C(n,i)*C((m-i)/2+n-1,n-1))%mod;
	// writeln(sum);
	return sum;
}
int main()
{
	n=read(); m=read();
	fac[0]=inv[0]=1;
	for(int i=1;i<=n+3*m;i++){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=power(fac[i],mod-2);
	}
	ll ans=(calc(n,3*m,m)-n*calc(n,m-1,m))%mod;
	writeln(Mod2(ans));
	return 0;
}

Measured memory_bytes: 41088
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import math
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#############
# Main Code #
#############

S = str(input())


if S == "AAA" or S == "BBB":
  print("No")

else:
  print("Yes")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  ModInt() : v(0) {}
  ModInt(auto x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
  constexpr ModInt(unsigned v, int) : v(v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool)*this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t)v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  M pow(auto n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  friend M operator*(auto l, M r) { return M(l) *= r; }
  friend M operator/(auto l, M r) { return M(l) /= r; }
  friend M operator+(auto l, M r) { return M(l) += r; }
  friend M operator-(auto l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { lint x; is >> x; r = x; return is; }
  friend bool operator==(auto l, M r) { return M(l) == r; }
  friend bool operator!=(auto l, M r) { return !(l == r); }
};
using Mint = ModInt<(unsigned)1e9 + 7>;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  V<Mint> dp(13);
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    V<Mint> ndp(13);
    for (int r = 0; r < 13; ++r) {
      for (int d = 0; d < 10; ++d) {
        if (s[i] == '?' or s[i] == '0' + d) {
          ndp[(10 * r + d) % 13] += dp[r];
        }
      }
    }
    swap(dp, ndp);
  }
  cout << dp[5] << '\n';
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

total = sum(a)

a.sort()
a = a[::-1]

a_m = a[m - 1]

if a_m * 4 * m >= total:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#https://atcoder.jp/contests/abc161/tasks/abc161_b
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort(reverse = True)
    s = sum(a)
    for i in range(m-1,-1, -1):
        if a[i]*4*m < s:
            print("No")
            return
    print("Yes")
if __name__ == "__main__":
    main()



Measured memory_bytes: 38256
#include <iostream>
#include <string>

using namespace std;

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

    int cnt = 0;
    if (s[0] == '1') cnt++;
    if (s[1] == '1') cnt++;
    if (s[2] == '1') cnt++;

    cout << cnt << endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n;
	cin >> n;
	if(n%10==9||n/10==9){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

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

int main(void){
  int N, M, X; cin >> N >> M >> X;
  vector<int> A(M);
  for(auto& a: A){
    cin >> a;
  }
  int ans1 = 0;
  int ans2 = 0;
  int begin, end;
  begin = 0;
  end = X;
  for(int i = 0; i < (int)A.size(); i++){
    if(begin <= A[i] && A[i] <= end){
      ans1 += 1;
    }
  }
  begin = X;
  end = N;
  for(int i = 0; i < (int)A.size(); i++){
    if(begin <= A[i] && A[i] <= end){
      ans2 += 1;
    }
  }
  cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N; std::cin >> N;
  std::string S = std::to_string(N);
  int f = 0;
  for(auto&& s : S) f += s - '0';
  if ( N % f == 0 ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<string> vs;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

void printtext(vs &text,char c,int cur,int line,string buf)
{
	cerr<<"command: "<<c<<endl;
	cerr<<"cur: "<<cur<<", line: "<<line<<", buffer: "<<buf<<endl;
	rep(i,text.size())cerr<<text[i]<<endl;
}

int main()
{
	vs text;
	string tmp,buf;
	while(getline(cin,tmp),tmp!="END_OF_TEXT")text.pb(tmp);
	
	char c;
	int cur=0,line=0;
	while(cin>>c,c!='-')
	{
		if(c=='a')cur=0;
		else if(c=='e')cur=text[line].size();
		else if(c=='p')
		{
			cur=0;
			if(line>0)line--;
		}
		else if(c=='n')
		{
			cur=0;
			if(line<text.size()-1)line++;
		}
		else if(c=='f')
		{
			if(cur!=text[line].size())cur++;
			else if(line<text.size()-1)line++,cur=0;
		}
		else if(c=='b')
		{
			if(cur!=0)cur--;
			else if(line>0)line--,cur=text[line].size();
		}
		else if(c=='d')
		{
			if(cur<text[line].size())text[line].erase(text[line].begin()+cur);
			else if(cur==text[line].size()&&line<text.size()-1)
			{
				text[line]+=text[line+1];
				text.erase(text.begin()+(line+1));
			}
		}
		else if(c=='k')
		{
			if(cur<text[line].size())
			{
				buf=text[line].substr(cur);
				text[line].erase(text[line].begin()+cur,text[line].end());
			}
			else if(cur==text[line].size()&&line<text.size()-1)
			{
				text[line]+=text[line+1];
				text.erase(text.begin()+(line+1));
				buf="\n";
			}
		}
		else if(c=='y')
		{
			if(buf.empty())continue;
			if(buf=="\n")
			{
				text.insert(text.begin()+(line+1),text[line].substr(cur));
				text[line].erase(text[line].begin()+cur,text[line].end());
				cur=0; line++;
			}
			else
			{
				text[line].insert(text[line].begin()+cur,all(buf));
				cur+=buf.size();
			}
		}
		
		//printtext(text,c,cur,line,buf);
	}
	rep(i,text.size())cout<<text[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {

  public static String S;
  public static String[] arr;

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    S = sc.next();
    sc.close();
    String[] arr_ = S.split("");

    String result = "Bad";

    if (!arr_[0].equals(arr_[1])) {
      
      if (!arr_[1].equals(arr_[2]))  {

        if (!arr_[2].equals(arr_[3]))  {
          result = "Good";
        }

      }

    }

    System.out.println(result);

  }
  
}

Measured memory_bytes: 23632
import bisect


def main():
    n, k = map(lambda x: int(x), input().split())
    w = [int(input()) for _ in range(n)]

    cumulative_sum = [0]
    for weight in w:
        cumulative_sum.append(cumulative_sum[-1] + weight)
    p_min, p_max = max(w), cumulative_sum[-1]

    while p_min != p_max:
        p_mid = (p_min + p_max) // 2
        left_track = k
        index = 1
        while left_track > 0:
            left_track -= 1
            index = bisect.bisect_right(cumulative_sum, cumulative_sum[index-1] + p_mid)
            if index == len(cumulative_sum):
                break
        else:
            p_min = p_mid+1
            continue
        p_max = p_mid

    print(p_min)


if __name__ == '__main__':
    main()



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

class Node{
public:
  Node* prev;
  Node* next;
  int data;
  Node(){
    prev = 0;
    next = 0;
    data = 0;
  }
};

class List{
private:
  Node head;
public:
  List(){head.prev = &head; head.next = &head;}
  int insert(int x);
  int del(int x);
  int deleteFirst();
  int deleteLast();
  void print();
};

int List::insert(int x){
  Node* p = new Node();

  if(p==0)
   return -1;

  Node* q = &head;
  Node* r = head.next;

  p->prev = q;
  p->next = r;
  p->data = x;

  q->next = p;
  r->prev = p;

  return 0;
}

int List::del(int x){
  Node* p;

  for(p=head.next;p!=&head;p=p->next){
    if(p->data==x)
     break;
  }

  if(p==&head)
    return -2;

  Node* q = p->prev;
  Node* r = p->next;

  q->next = r;
  r->prev = q;

  delete p;

  return 0;
}

int List::deleteFirst(){
  Node* p = head.next;

  if(p==&head)
    return -2;

  Node* q = p->prev;
  Node* r = p->next;

  q->next = r;
  r->prev = q;

  delete p;

  return 0;
}

int List::deleteLast(){
  Node* p = head.prev;

  if(p==&head)
    return -2;

  Node* q = p->prev;
  Node* r = p->next;

  q->next = r;
  r->prev = q;

  delete p;

  return 0;
}

void List::print(){
  for(Node* p=head.next; p!=&head; p=p->next){
    cout << p->data;

    if(p->next!=&head){
      cout << ' ';
    }
    else{
      cout << endl;
    }
  }
}

int main(){
  List L;

  int n;
  cin >> n;

  for(int i=0; i<n; i++){
    char com[20];
    cin >> com;

    if(com[0]=='i'){
      int x;
      cin >> x;

      L.insert(x);
    }
    else if(com[6]=='F'){
      L.deleteFirst();
    }
    else if(com[6]=='L'){
      L.deleteLast();
    }
    else{
      int x;
      cin >> x;

      L.del(x);
    }
  }
  L.print();
  return 0;
}



Measured memory_bytes: 34316
import sys
from bisect import bisect_left

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, Q = map(int, readline().split())
    S = [int(readline()) for _ in range(A)]
    T = [int(readline()) for _ in range(B)]
    X = [int(readline()) for _ in range(Q)]

    ans = [0] * Q
    vs = [0] * 2
    vt = [0] * 2
    for i, x in enumerate(X):
        idx_s = bisect_left(S, x)
        idx_t = bisect_left(T, x)

        vs[0] = S[idx_s - 1] if idx_s > 0 else -INF
        vt[0] = T[idx_t - 1] if idx_t > 0 else -INF
        vs[1] = S[idx_s] if idx_s < A else INF
        vt[1] = T[idx_t] if idx_t < B else INF

        ans[i] = min(
            abs(x - vs[0]) + abs(vs[0] - vt[0]),
            abs(x - vt[0]) + abs(vt[0] - vs[0]),
            abs(x - vs[0]) + abs(vs[0] - vt[1]),
            abs(x - vt[0]) + abs(vt[0] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[1]),
            abs(x - vt[1]) + abs(vt[1] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[0]),
            abs(x - vt[1]) + abs(vt[1] - vs[0]),
        )

    print('\n'.join(map(str, ans)))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 34652
N=int(input())
S=""
if N==0:
    print(0)
    exit()
while(True):
    if N==1:
        S="1"+S
        break
    if N%2==1:
        S="1"+S
    else:
        S="0"+S
    N-=N%2
    N=N//(-2)
print(S)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
    int H, W;
    cin >> H >> W;
    int Ch, Cw;
    cin >> Ch >> Cw;
    --Ch; --Cw;
    int Dh, Dw;
    cin >> Dh >> Dw;
    --Dh; --Dw;
    vector<string> S(H);
    rep(i, H) {
        string s;
        cin >> s;
        S[i] = s;
    }
    vector<vector<int>> dist(H, vector<int> (W, INF));
    deque<tuple<int, int, int>> que;
    auto update = [&] (int i, int j, int d, bool warp) {
        if (i < 0 || i >= H || j < 0 || j >= W) return;
        if (S[i][j] == '#' || dist[i][j] <= d) return;
        dist[i][j] = d;
        if (!warp) que.emplace_front(i, j, d);
        else que.emplace_back(i, j, d);
    };
    update(Ch, Cw, 0, 0);
    while (!que.empty()) {
        int ci = get<0>(que.front());
        int cj = get<1>(que.front());
        int cd = get<2>(que.front());
        que.pop_front();
        if (dist[ci][cj] < cd) continue;
        rep(dir, 4) {
            int ni = ci + dx[dir];
            int nj = cj + dy[dir];
            update(ni, nj, dist[ci][cj], 0);
        }
        // warp
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int ni = ci + i;
                int nj = cj + j;
                update(ni, nj, dist[ci][cj] + 1, 1);
            }            
        }
    }
    int ans = dist[Dh][Dw];
    cout << (ans != INF ? ans : -1) << '\n';
    return 0;
}

Measured memory_bytes: 8712
#include <iostream>
#include <cmath>

using namespace std;

void solve()
{
	int e;
	while(cin >> e, e)
	{
		int x = 0;
		int y = 0;
		int z = 0;
		while(pow((double)z, 3) < e)
		{
			++z;
		}
		int zbuf = 0;
		if(pow((double)z, 3) > e)
		{
			zbuf = z - 1;
		}
		else
		{
			zbuf = z;
		}
		int min = 100000000;
		int m = 0;
		for(int i = 0; i <= zbuf; ++i)
		{
			x = 0;
			y = 0;
			int ebuf = e;
			ebuf -= pow((double)i, 3);
			z = i;
			while(pow((double)y, 2) < ebuf)
			{
				++y;
			}
			if(pow((double)y, 2) > ebuf)
			{
				--y;
			}
			ebuf -= pow((double)y, 2);
			x = ebuf;
			if(min > x + y + z)
			{
				min = x + y + z;
			}
		}
		cout << min << endl;
	}
}

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

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

typedef long long ll;
typedef int i;
typedef string s;
typedef double d;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (abs(a*b)/gcd(a,b))
#define sqr(a) (a*a)

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)
#define be(a) a.begin(),a.end()
#define sz(x) x.size()
#define nl cout<<"\n";
#define sp cout<<" ";

#define op() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    op();
    i n,m,a,sum=0;
    cin>>n>>m;
    while(m--)
    {
       cin>>a;
       sum+=a;
    }
    if(n>=sum)
        cout<<n-sum;
    else
        cout<<-1;
    nl;
    return 0;
}



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

typedef long long ll;

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

    int n; cin >> n;
    char s;
    int cnt[26] = {0};
    for(int i=0;i<n;i++){
        cin >> s;
        cnt[s-'A']++;
    }
    int arare = 0;
    for(int i=0;i<26;i++){
        if(cnt[i]>=1) arare++;
    }
    if(arare==3) cout << "Three" << endl;
    else cout << "Four" << endl;
    return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env ruby
$m = 1046527
n = STDIN.gets.chomp.to_i
$t = []
class String
	def key
		sum, p = 0, 1
		self.each_char do |ch|
			num = nil
			case ch
			when 'A'
				num = 1
			when 'C'
				num = 2
			when 'G'
				num = 3
			when 'T'
				num = 4
			end
			sum += p * num
			p *= 4
		end
		sum
	end
end
def calc_hash data, i
	((data.key % $m) + i * (1 + (data.key % ($m - 1)))) % $m
end
def insert data
	i = 0
	hash = nil
	while i < $m
		hash = calc_hash(data, i)
		if $t[hash] == data
			return
		elsif $t[hash] == nil
			$t[hash] = data
			return
		end
		i += 1
	end
	raise 'omg'
end
def search data
	i = 0
	while i < $m
		hash = calc_hash(data, i)
		if $t[hash] == data
			return true
		elsif $t[hash] == nil
			return false
		else
			i += 1
		end
	end
	return false
end
output = []
n.times do
	commandline = STDIN.gets.chomp.split(' ')
	command = commandline[0]
	arg = commandline[1]
	case command
	when 'insert'
		insert arg
	when 'find'
		output << (search(arg) ? 'yes' : 'no')
	end
end
output.each { |o| STDOUT.puts o }

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n;
    cin >> n;
    vector<int64_t> t(n),a(n);
    rep(i,0,n) cin >> t[i];
    rep(i,0,n) cin >> a[i];

    vector<int64_t> minit(n),maxit(n),minia(n),maxia(n);
    minit[0]=maxit[0]=t[0];
    rep(i,1,n){
        if(t[i]>t[i-1]) maxit[i]=minit[i]=t[i];
        else{
            maxit[i]=t[i];
            minit[i]=1;
        }
    }

    minia[n-1]=maxia[n-1]=a[n-1];
    for(int i=n-2; i>=0; --i){
        if(a[i]>a[i+1]) maxia[i]=minia[i]=a[i];
        else{
            maxia[i]=a[i];
            minia[i]=1;
        }
    }

    int64_t ans=1,mod=1e9+7;
    rep(i,0,n){
        if(maxit[i]<minia[i] or maxia[i]<minit[i]) ans=0;
        else ans=ans*(min(maxit[i],maxia[i])-max(minit[i],minia[i])+1)%mod;
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 4992
//ダイクストラ法
#include "bits/stdc++.h"
#include <queue>
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k;
const int N = 3e6;
vector<vector<pair<int, double>>> g;

using pairdi = pair<double, int>;
vector<double> leng(N,4503599627370496.0); //ある点を始点として、全体nodeへの最短距離
// 小さいほうが先頭にくるよう。ダイクストラ法などで使用を想定
// doubleは長さ、intはnodeidを意味している
auto compare = [](pairdi a, pairdi b) {
  return a.first > b.first;
};
priority_queue<pairdi,vector<pairdi>,decltype(compare) > que {compare};


//今見ている頂点から伸びる頂点をqueに溜める
void pushg(int nodeid){
  double len=leng[nodeid];
  for(auto to : g[nodeid]) {
    if (to.second==100.0){
      double dtmp=fmod(len,double(k));
      to.second=(double)k-dtmp;
    }
    que.emplace(len+to.second,to.first);//長さ,nodeid
  }
}

void djk(int first_node,int second_node){
  //初期値をプライオリティーキューにいれる
  que.emplace(0.0,first_node);
  que.emplace(0.0,second_node);
  //キューがなくなるまでやる
  int nodeid;
  double ddlen;
  while (!que.empty()) {
    nodeid=que.top().second;ddlen=que.top().first;
    if (leng[nodeid]>ddlen){
      leng[nodeid]=ddlen;
      pushg(nodeid);
    }
    que.pop();
  }
  return;
}



int main() {
  ll h,w;
  cin>>h>>w>>k;
  n=h*w;
  ll x1,y1,x2,y2;
  cin>>y1>>x1>>y2>>x2;
  x1--;y1--;x2--;y2--;
  vvi data(w, vi(h));  // N * M の2次元配列

  g.resize(n*2+1);

  for(ll i=0;i<h;i++){
    string s;
    cin>>s;
    for(ll j=0;j<w;j++){
      data[j][i]=(s[j]=='.');
    }
  }



  for(ll i=0;i<w;i++){
    for(ll j=0;j<h;j++){
      ll a=j*w+i;
      ll an=j*w+i+n;
      ll b=j*w+i;
      ll bn=j*w+i+n;
      if (i!=0){
        if (data[i-1][j]){
          g[a].emplace_back(a-1, 1.0);
          g[a].emplace_back(a+n-1, 100.0);
        }
      }

      if (i!=w-1){
        if (data[i+1][j]){
          g[a].emplace_back(a+1, 1.0);
          g[a].emplace_back(a+n+1, 100.0);
        }
      }

      if (j!=0){
        if (data[i][j-1]){
          g[a+n].emplace_back(a-w, 100.0);
          g[a+n].emplace_back(a+n-w, 1.0);
        }
      }

      if (j!=h-1){
        if (data[i][j+1]){
          g[a+n].emplace_back(a+w, 100.0);
          g[a+n].emplace_back(a+n+w, 1.0);
        }
      }

    }
  }


  djk(x1+y1*w,x1+y1*w+n);

  ll ans=min((ll)(leng[x2+y2*w]),(ll)(leng[x2+y2*w+n]));
  if (ans==4503599627370496LL){
    ans=-1;
  }else{
    ans=(ans-1)/k+1;
  }

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

Measured memory_bytes: 206164
using System;
using System.Collections.Generic;
using static System.Math;

public class Kura
{
	public int id { get; set; }
	public int d { get; set; }
	public int w { get; set; }
}

public class hello
{
	public static void Main()
	{
		var n = int.Parse(Console.ReadLine().Trim());
		var kuras = new Kura[n];
		for (int i = 0; i < n; i++)
		{
			string[] line = Console.ReadLine().Trim().Split(' ');
			var s = int.Parse(line[0]);
			var d = int.Parse(line[1]);
			var w = int.Parse(line[2]) * 20;
			kuras[i] = new Kura { id = s, d = d, w = w };
		}
		goDP(kuras, n);
	}
	static void print(double[,] dp, List<int>[,] via, int n, Kura[] kuras)
	{
		var imax = 1 << n;
		var mini = 0;
		var dpmin = dp[imax - 1, 0];
		for (int i = 1; i < n; i++)
			if (dp[imax - 1, i] < dpmin) { mini = i; dpmin = dp[imax - 1, i]; }
		Console.WriteLine(string.Join(" ", via[imax - 1, mini]));
	}
	static void goDP(Kura[] kuras, int n)
	{
		var imax = 1 << n;
		var tw = new int[imax];
		var via = new List<int>[imax, n];
		var dp = new double[imax, n];
		for (int i = 0; i < imax; i++)
			for (int j = 0; j < n; j++)
			{
				dp[i, j] = 99999999999999999d;
				via[i, j] = new List<int>();
			}
		for (int i = 0; i < n; i++)
		{
			var ti = 1 << (n - i - 1);
			dp[ti, i] = 0;
			tw[ti] = kuras[i].w;
			via[ti, i].Add(kuras[i].id);
		}
		for (int i = 0; i < imax; i++)
			for (int j = 0; j < n; j++)
			{
				if (((i >> (n - j - 1)) & 1) == 1)
				{
					for (int k = 0; k < n; k++)
						if (((i >> (n - k - 1)) & 1) == 0)
						{
							var nnow = i | (1 << (n - k - 1));
							var L = Abs(kuras[j].d - kuras[k].d);
							var nv = 2000d / (70d + tw[i]);
							var tt = L / nv;
							if (dp[i, j] + tt < dp[nnow, k])
							{
								dp[nnow, k] = dp[i, j] + tt;
								via[nnow, k].Clear();
								foreach (var x in via[i, j]) via[nnow, k].Add(x);
								via[nnow, k].Add(kuras[k].id);
							}
							tw[nnow] = tw[i] + kuras[k].w;
						}
				}
			}
		print(dp, via, n, kuras);
	}
}



Measured memory_bytes: 66236
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	cout << ((s.size()%2) ^ (s[0] != s.back()) ? "Second" : "First") << endl;
	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(){
	int S;
	int h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-h*3600-m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
h, w = map(int, input().split())
s = [input() for _ in range(h)]
leftbeam = [[0 for _ in range(w)] for _ in range(h)]
rightbeam = [[0 for _ in range(w)] for _ in range(h)]
downbeam = [[0 for _ in range(w)] for _ in range(h)]
upbeam = [[0 for _ in range(w)] for _ in range(h)]

def can_light(y, x):
    return (0 <= y < h) and (0 <= x < w) and s[y][x] == '.'

for y in range(h):
    beamlen = 0
    for x in range(w):
        if can_light(y, x):
            beamlen += 1
        else:
            beamlen = 0
        leftbeam[y][x] = beamlen

for y in range(h):
    beamlen = 0
    for x in range(w):
        if can_light(y, w - x - 1):
            beamlen += 1
        else:
            beamlen = 0
        rightbeam[y][w - x - 1] = beamlen


for x in range(w):
    beamlen = 0
    for y in range(h):
        if can_light(y, x):
            beamlen += 1
        else:
            beamlen = 0
        downbeam[y][x] = beamlen

for x in range(w):
    beamlen = 0
    for y in range(h):
        if can_light(h - y - 1, x):
            beamlen += 1
        else:
            beamlen = 0
        upbeam[h - y - 1][x] = beamlen

ans = 0
for y in range(h):
    for x in range(w):
        ans = max(ans, leftbeam[y][x] + rightbeam[y][x]
                     + downbeam[y][x] + upbeam[y][x] - 3)

print(ans)

Measured memory_bytes: 184836
n, m = map(int,input().split())
student_list = [list(map(int,input().split())) for _ in range(n)]

check_list = [list(map(int,input().split())) for _ in range(m)]

for s in student_list:
    tmp = []
    for c in check_list:
        tmp.append(abs(s[0]-c[0]) + abs(s[1]-c[1]))
    print(tmp.index(min(tmp))+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
#define SIZE 100005
#define M 1000000007
ll binomial[SIZE];
ll arr[SIZE];
ll power(ll a,ll b){
	if(b==0)
		return 1;
	ll p=power(a,b/2);
	p=(p*p)%M;
	if(b%2==0)
		return p;
	else
		return (p*a)%M;

}

ll inv(ll num){
	return power(num,M-2);
}
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll N,K;
	cin>>N>>K;
	for(ll i=0;i<N;++i){
		cin>>arr[i];
	}
	sort(arr,arr+N);
	binomial[0]=1;
	for(ll i=1;i<N;++i){
		binomial[i]=((binomial[i-1]*(K-2+i))%M*inv(i))%M;
	}
	for(ll i=1;i<N;++i){
		binomial[i]=(binomial[i]+binomial[i-1])%M;
		// cout<<binomial[i]<<" ";
	}
	ll ans=0;
	for(ll i=0;i<N;++i){
		ll start=i-K+1;
		ll end=N-i-K;
		// cout<<start<<" "<<end<<endl;
		if(start>=0){
			ans=(ans+(arr[i]*binomial[start])%M)%M;
		}
		if(end>=0){
			ans=(ans-(arr[i]*binomial[end])%M+M)%M;
		}
		// cout<<ans<<endl;
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=55559;
const int MOD=1e9+7;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int a,b;
    cin >>a >> b;
    ll ans=0;
    for(int i=1;i<=a-1;i++){
        for(int j=1;j<=31;j++){
            if(i==j)    ans++;
        }
    }
    
    for(int i=a;i<=a;i++){
        for(int j=1;j<=b;j++){
            if(i==j)    ans++;
        }
    }
    
    cout <<ans <<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


#define MAX_N 100005

ll fact[MAX_N];             // N!
ll fact_inv[MAX_N];         // N!の逆元

// O(log n)でx^n(modを法とする)
ll mod_pow(ll x,ll n,ll mod){
    ll res=1;
    while(n){
        if(n&1) res = (res*x)%mod;
        x = (x*x)%mod;
        n>>=1;
    }
    return res;
}

// O(log mod)で x^-1 を計算(法をmodとする)
ll invp(ll x,ll mod){
    return mod_pow(x,mod-2,mod);
}

// 法をmodとして組み合わせ nCrを計算(O(1))
ll nCr(ll n,ll r,ll mod){
    if(n < r)return 0;
    ll ret = fact[n];
    ret = (ret * fact_inv[r]) % mod;
    ret = (ret * fact_inv[n-r]) % mod;
    return ret;
}

// 初期化 O(MAX_N * log(mod)) くらいかなぁ
void init(const long long MOD){
    fact[0]=1;
    for(int i=1;i<MAX_N;i++) fact[i]=(fact[i-1]*i)%MOD;
    for(int i=0;i<MAX_N;i++) fact_inv[i]=invp(fact[i],MOD);
}


ll overlap(ll n,const vector<ll>& a){
    vector<int> used(n+5,0);
    rep(i,n+1){
        if(used[a[i]]) return a[i];
        used[a[i]] = 1;
    }
    return -1;
}

int main(){
    ll n; cin >> n;
    vector<ll> a(n+1); rep(i,n+1) cin >> a[i];
    init(mod);
    ll t = overlap(n,a);

    vector<int> ids;
    rep(i,n+1) if(a[i] == t) ids.push_back(i);

    int t1 = ids[0];
    int t3 = n-ids[1]; 

    for(int k=1;k<=n+1;k++){
        if(k == 1){
            cout << n << endl;
            continue;
        }
        ll tmp = nCr(n+1,k,mod);
        ll tmp2 = nCr(t1+t3,k-1,mod);

        tmp -= tmp2;
        tmp += mod;
        tmp %= mod;
        cout << tmp << endl;
    }
}


Measured memory_bytes: 3576
import sys
input = sys.stdin.readline

N = int(input())
edge = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

def dfs(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  white, black = [1]*N, [1]*N
  while stack:
    v = stack[-1]
    marker = 0
    for u in edge[v]:
      if u==parent[v]:
        continue
      if parent[u]==N: #子へ降ろす
        marker = 1
        parent[u]=v
        stack.append(u)
      else: #子から吸い上げる
        white[v] *= white[u]+black[u]
        white[v] %= mod
        black[v] *= white[u]
        black[v] %= mod
    if marker==0:
      stack.pop()
  ans = (black[0]+white[0])%mod
  return ans

mod = 10**9+7
ans = dfs(0)
print(ans)


Measured memory_bytes: 96264
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  vint A(n);
  int minus = 0;
  int zero = 0;
  int MIN = INF;
  int sum = 0;
  rep(i,n){
    cin >> A[i];
    if(A[i] < 0) minus++;
    if(A[i] == 0) zero++;
    MIN = min(MIN,abs(A[i]));
    sum += abs(A[i]);
  }
  if(minus % 2 == 1 && zero == 0){
    cout << sum - MIN*2 << endl;
  }
  else{
    cout << sum << endl;
  }
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
        
int main(){
    ll n,m=-1,k,w,sum=0,ans=0,Max=-1e9,Min=1e9+1;
    string s,t,u;
    bool count=false,ok=true;
    VL a(4);
    double v[4] = {0.25,0.5,1,2} ;
    rep(i,4){
        cin >> a[i];
    }
    cin >> n;
    while(n != 0){
        if(n>=2){
            rep(i,4){
                if(chmin(Min,((2/v[i])*a[i]))){
                    m = i;
                }
            }
            ans += (int)(n/v[m])*a[m];
            n -=(int)(n/v[m])*v[m];
            m = -1;
        }
        else{
            rep(i,3){
                if(chmin(Min,((1/v[i])*a[i]))){
                    m = i;
                }
            }
            ans += int(1/v[m])*a[m];
            n = 0;
        }
        Min = 1e9+1;
        m=-1;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    bool yes = true;
    int mx = h[0];
    for (int i = 1; i < n; i++) {
        if (h[i] + 1 < mx) {
            yes = false;
            break;
        }
        mx = max(mx, h[i]);
    }
    if (yes) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
    ll a,b,c,d; cin >> a >> b >> c >> d;
	cout << max({a*c , a*d , b*c , b*d}) << endl;

	return 0;
}

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

unsigned gcd(unsigned u, unsigned v) {
    while ( v != 0) {
        unsigned r = u % v;
        u = v;
        v = r;
    }
    return u;
}

int main()
{
    int k,n;
    cin >> n >> k;
    int i,j;
    int a[n];
    for(i = 0; i < n; i++) cin >> a[i];
    int maxi = a[0];
    int gcdr = a[0];
    for(i = 1; i < n; i++){
       gcdr = gcd(a[0],a[i]);
       maxi = (maxi < a[i])? a[i] : maxi;
    }
    if(maxi < k) cout << "IMPOSSIBLE" << "\n";
    else{
        if(k % gcdr == 0)cout << "POSSIBLE" <<"\n";
        else cout << "IMPOSSIBLE" << "\n";
    }
  return 0;
}


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

using namespace std;

int t, n;
vector<pair<int, int> > a, b;
int l, r, k;
long long ans;

std::priority_queue<int, vector<int>, greater<int> > q;

int main(){
	scanf("%d", &t);
	while(t--){
		scanf("%d", &n);
		a.clear(), b.clear(), ans = 0;
		for(int i = 1;i <= n;i++){
			scanf("%d%d%d", &k, &l, &r);
			if(l > r){
				ans += r;
				a.push_back({k, l - r});
			}else if(l < r && n - k){
				ans += l;
				b.push_back({n - k, r - l});
			}else{
				ans += l;
			}
		}
		sort(a.begin(), a.end());
		for(int i = 0;i < a.size();i++){
			if(q.size() < a[i].first){
				q.push(a[i].second);
			}else{
				if(q.top() < a[i].second){
					q.pop();
					q.push(a[i].second);
				}
			}
		}
		while(!q.empty()) ans += q.top(), q.pop();
		swap(a, b);
		sort(a.begin(), a.end());
		for(int i = 0;i < a.size();i++){
			if(q.size() < a[i].first){
				q.push(a[i].second);
			}else{
				if(q.top() < a[i].second){
					q.pop();
					q.push(a[i].second);
				}
			}
		}
		while(!q.empty()) ans += q.top(), q.pop();
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 5628
#include<stdio.h>
int main(){
int n,m,a[101],b[101],c[101],i,j,d=0,k;
for(i=0;i<100;i++){
c[i]=0;
}
scanf("%d\n%d\n",&n,&m);
for(i=0;i<m;i++){
scanf("%d ",&a[i]);
}
scanf("\n");
for(i=0;i<m;i++){
for(j=0;j<n;j++){
scanf("%d ",&b[j]);
if(b[j]==a[i]){
c[j]++;
d++;
}
}
scanf("\n");
for(k=0;k<n-d;k++){
c[a[i]-1]++;
}
d=0;
}
for(i=0;i<n;i++){
printf("%d\n",c[i]);
}
return 0;
}




Measured memory_bytes: 2048
import java.util.*;

public class Main {

    static int MOD = 1000000007;
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int k=sc.nextInt(),s=sc.nextInt();
        int ans=0;
        for(int i=0;i<k+1;i++)for(int j=0;j<k+1;j++){
            if(i+j<=s&&i+j+k>=s)ans++;
        }
        System.out.println(ans);

    }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define INF 1<<30

int main(){
	int n;
	cin >> n;
	pair<int, int> A[15][15];
	vector<int> B;
	for(int i = 0; i < n; i++){
		int a, x, y;
		cin >> a;
		B.push_back(a);
		for(int j = 0; j < a; j++){
			cin >> x >> y;
			x--;
			A[i][j] = make_pair(x, y);
		}
	}
	int ans = 0;
	for(int bit = 0; bit < (1<<n); bit++){
		int b = bit, i = 0;
		int T[15] = {0};
		int cnt = 0;
		while(b){
			if(b % 2 == 1) {
				T[i] = 1;
				cnt++;
			}
			b /= 2;
			i++;
		}
		int flag = 1;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < B[i]; j++){
				int x = A[i][j].fi , y = A[i][j].se;
				if(!T[i]) continue;
				if(T[x] != y) {
					flag = 0;
					break;
				}
			}
			if(!flag) break;
		}
		if(flag){
			ans = max(ans, cnt);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n/3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,i,j,k,a[100],v;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=1;i<n;i++){
    	printf("%d",a[0]);
    	for(k=1;k<n;k++){
    		printf(" %d",a[k]);
    		//if(k<=n-1) printf(" *");
    	}
    	printf("\n");
    	v=a[i];
    	j=i-1;
    	while(j>=0&&a[j]>v){
    		a[j+1]=a[j];
    		j--;
    	}
    	a[j+1]=v;
    	
    }
    printf("%d",a[0]);
    for(k=1;k<n;k++){
    		printf(" %d",a[k]);
    		//if(k<=n-1) printf(" *");
    	}
    	printf("\n");
    return 0;
}


Measured memory_bytes: 2016
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define lli long long int
#define ld long double
#define vec vector
#define forn(a) for(lli a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define presicion(x) cout<<fixed<<setprecision(x)
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main() {
    IOS;

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

    return 0;
}

Measured memory_bytes: 256