akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;

#define NMAX 5002

short L[NMAX][NMAX], LL[NMAX], R[NMAX][NMAX], RR[NMAX], S[NMAX][NMAX];
int v[NMAX];

void build_left(const int n, const int K) {
    L[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= K; j++) {
            L[i][j] = L[i - 1][j];
        }
        for (int j = 0; j <= K && j + v[i] <= K; j++) {
            if (L[i - 1][j]) {
                L[i][j + v[i]] = 1;
            }
        }
    }
    for (int i = 0; i <= n; i++) {
        LL[i] = -1;
        for (int j = K - 1; j >= 0; j--) {
            if (L[i][j]) {
                LL[i] = j;
                break;
            }
        }
    }
}

void build_right(const int n, const int K) {
    R[n + 1][0] = 1;
    for (int i = n; i >= 1; i--) {
        for (int j = 0; j <= K; j++) {
            R[i][j] = R[i + 1][j];
        }
        for (int j = 0; j <= K && j + v[i] <= K; j++) {
            if (R[i + 1][j]) {
                R[i][j + v[i]] = 1;
            }
        }
    }
    for (int i = 1; i <= n + 1; i++) {
        RR[i] = -1;
        for (int j = K - 1; j >= 0; j--) {
            if (R[i][j]) {
                RR[i] = j;
                break;
            }
        }
    }
    for (int i = 1; i <= n + 1; i++) {
        S[i][0] = R[i][0];
        for (int j = 1; j <= K; j++) {
            S[i][j] = S[i][j - 1] + R[i][j];
        }
    }
}

int get_sum(const int poz, const int st, const int dr) {
    if (st > dr)
        return 0;
    if (st == 0)
        return S[poz][dr];
    return S[poz][dr] - S[poz][st - 1];
}

bool good(const int poz, const int K, const int n) {
    const int st = K - v[poz];
    if (poz > 1 && LL[poz - 1] >= st) {
        return true;
    }
    if (poz < n && RR[poz + 1] >= st) {
        return true;
    }
    if (poz == 1 || poz == n) {
        return false;
    }
    for (int i = 1; i <= K; i++) {
        if (L[poz - 1][i] == 0) {
            continue;
        }
        int x = max(st - i, 0);
        int y = K - i - 1;
        if (x > y || y <= 0) {
            continue;
        }
        if (get_sum(poz + 1, x, y) >= 1) {
            return true;
        }
    }
    return false;
}

int main()
{
    ios_base::sync_with_stdio(false);

    int n, K, k = 0;
    // ifstream cin("code.in");
    cin >> n >> K;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x < K) {
            v[++k] = x;
        }
    }
    n = k;

    build_left(n, K);
    build_right(n, K);

    int sol = n;
    for (int i = 1; i <= n; i++) {
        if (good(i, K, n)) {
            sol--;
        }
    }

    cout << sol << '\n';
    return 0;
}


Measured memory_bytes: 146944
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

int main(){
    int n = 0;
    map<int,int> p[2];
    string s;
    while(getline(cin, s)){
        if(s == ""){ n++; continue; }
        int a,b;
        sscanf(s.c_str(), "%d,%d", &a, &b);
        p[n][a]++;
    }
    FOREACH(it, p[0]){
        if(p[1][it->first] > 0){
            cout << it->first << " " << it->second + p[1][it->first] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1240
// https://atcoder.jp/contests/abc115/tasks/abc115_a

#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::{HashSet, VecDeque};
use std::io;
use std::io::{BufRead, Read, Write};
use std::str::FromStr;

#[allow(unused, non_snake_case)]
pub fn solve<R: BufRead, W: Write>(mut io: Io<R, W>) {
    let D: usize = io.next();

    let res = match D {
        22 => "Christmas Eve Eve Eve",
        23 => "Christmas Eve Eve",
        24 => "Christmas Eve",
        25 => "Christmas",
        _ => "",
    };

    io.println(res);
}

#[allow(dead_code)]
fn main() {
    let stdin = io::stdin();
    let stdin_lock = stdin.lock();
    let stdout = io::stdout();
    let stdout_lock = stdout.lock();

    let io = Io {
        reader: stdin_lock,
        writer: stdout_lock,
    };

    solve(io);
}

/* IO helpers */

pub struct Io<R, W>
where
    R: BufRead,
    W: Write,
{
    pub reader: R,
    pub writer: W,
}

#[allow(dead_code)]
impl<R, W> Io<R, W>
where
    R: BufRead,
    W: Write,
{
    fn println<T: std::fmt::Display>(&mut self, value: T) {
        writeln!(&mut self.writer, "{}", value).expect("Unable to write");
    }

    fn debug<T: std::fmt::Debug>(&mut self, value: T) {
        writeln!(&mut self.writer, "{:?}", value).expect("Unable to write");
    }

    fn print<T: std::fmt::Display>(&mut self, value: T) {
        write!(&mut self.writer, "{}", value).expect("Unable to write");
    }

    fn next<T: FromStr>(&mut self) -> T {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok().expect("Unable to parse")
    }

    fn nexts<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next::<T>()).collect::<Vec<T>>()
    }
}

/* Structure helpers */

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	while(1){
	int n,m,p,q=0,r=0,l=0,s=0,e=0,ans=0;
	cin>>n>>m;
		if(n==0 && m==0)
			break;
	vector<int> a,x;
	a.push_back(0);
	for(int i=0;i<n;i++){
		cin>>p;
		a.push_back(p);
	}
	q=n+1;
	//cout<<q<<endl;
	for(int i=0;i<q;i++){
		for(int j=0;j<q;j++){
			x.push_back(a[i]+a[j]);
		}
	}
	sort(x.begin(),x.end());
	//for(int i=0;i<q*q;i++)
	//cout<<x[i]<<' ';
	//cout<<endl;
	for(int i=0;i<x.size();i++){
		r=m-x[i];
		//cout<<r<<"を探します"<<endl;
		if(r>=0){
			s=0;
			e=q*q;
			l=(s+e)/2;
			while(s<e){
				//cout<<"l="<<l<<endl;
				l=(s+e)/2;
				if(x[l]==r)break;
				if(x[l]>r){
					e=l-1;
				}else{
					s=l+1;
				}
			}
			while(x[l]>r&&p>0)
			l--;
			while(1){
				if(l+1==q*q)break;
				if(x[l+1]<=r)l++;
				else break;
			}
		ans=max(ans,x[i]+x[l]);
		}
	}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 9196
def get_subs(l, c, n):
    # print('c = ' + str(c))
    canl = []
    for index, val in enumerate(l):
        if val == c:
            candidate = ''
            for i in range(n):
                if index + i < len(l):
                    candidate += l[index + i]
            canl.append(candidate)
    res = list(set(canl))
    # print(res)
    return res


s = input()
K = int(input())

cand = sorted(list(set(list(s))))
cand.reverse()
# print(cand)


subl = []
while len(subl) < K:
    c = cand.pop()
    n = 1
    while n <= K:
        canl = get_subs(list(s), c, n)
        subl.extend(canl)
        subl = list(set(subl))
        n += 1

subl = sorted(subl)
# print(subl)
print(subl[K-1])


Measured memory_bytes: 3360
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    long long n,i,j=0,k=0;
    cin>>s;
    n=s.size();
    for(i=(((n-1)/2)+2)-1;i<=(n-1);i++)
     {
         if(s[j]==s[i])
         {
             k++;
         }
         j++;      
     }
     if(k==((n-1)/2))
     {
         cout<<"Yes"<<endl;
     }
     else
     {
         cout<<"No"<<endl;
     }
     return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, a: "List[int]"):

    # 石k個で勝利するプレイヤー0 or 1
    dp = [1]*(K+1)
    dp[0] = 1
    for k in range(1, K+1):
        dp[k] = 1
        for i in range(N):
            if k-a[i] >= 0 and dp[k-a[i]] == 1:
                dp[k] = 0
    print("First" if dp[K] == 0 else "Second")

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		String line = scan.nextLine();
		//int N = Integer.parseInt(line);
		
		float[] A = new float[2];
		float[] B = new float[2];
		float[] C = new float[2];
		float[] D = new float[2];
		
		List<Boolean> L = new ArrayList<Boolean>();
		
		while(scan.hasNext()){
			line = scan.nextLine();
			String[] s = line.split(" +");
			A[0] = Float.parseFloat(s[0]);
			A[1] = Float.parseFloat(s[1]);
			
			B[0] = Float.parseFloat(s[2]);
			B[1] = Float.parseFloat(s[3]);
			
			C[0] = Float.parseFloat(s[4]);
			C[1] = Float.parseFloat(s[5]);
			
			D[0] = Float.parseFloat(s[6]);
			D[1] = Float.parseFloat(s[7]);
			
			float AB = (B[1] - A[1])/(B[0] - A[0]);
			float CD = (D[1] - C[1])/(D[0] - C[0]);;
		    L.add(AB == CD);
		}

		for(Boolean Li : L) {
			System.out.println(Li?"YES":"NO");
		}
		
		scan.close();
	}
}


Measured memory_bytes: 26136
N=int(input())
yakusuu=[]

for i in range(1,int(N**0.5)+1):
    if N%i==0:
        yakusuu.append(i-1)
        yakusuu.append(N//i -1)
retval=0
for y in yakusuu:
    if y==0:
        continue
    if N//y==N%y:
        retval+=y

print(retval)


Measured memory_bytes: 3188
N, K = map(int, input().split())
hs = list(map(int, input().split()))

total_cost = [1e15 for i in range(N)]

total_cost[0] = 0
total_cost[1] = abs(hs[1] - hs[0])

for i in range(2, N):
  for k in range(1, K+1):
    if total_cost[i] == -1:
      total_cost[i] = total_cost[i-k] + abs(hs[i] - hs[i-k])
    else:
      total_cost[i] = min(total_cost[i], total_cost[i-k] + abs(hs[i] - hs[i-k]))
    if i == k:
      break

print(total_cost[N-1])


Measured memory_bytes: 58848
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(){
    int n,k; cin>>n>>k;
    vector<int> a(n),sum1(n+1,0),sum2(n+1,0);
    int Sum1=0,Sum2=0;
    rep(i,n){
        cin>>a.at(i);
        Sum1+=a.at(i);
        if(a.at(i)>0)Sum2+=a.at(i);
        sum1.at(i+1)=Sum1;
        sum2.at(i+1)=Sum2;
    }
    int ans=-INF;
    for(int i=0; i+k<=n; i++){
        chmax(ans, max<int>(0,sum1.at(i+k)-sum1.at(i))+sum2.back()-sum2.at(i+k)+sum2.at(i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
z,v,a=input,range,print
h,w,k=map(int,z().split())
r,s,t,u=map(lambda x:int(x)-1,z().split())
b=[z()for _ in v(h)]
l=[[-1]*w for _ in v(h)]
l[r][s]=0
from collections import*
d=deque([(r,s)])
while d:
  x,y=d.popleft()
  if(x==t)&(y==u):exit(a(l[x][y]))
  for e,f in[[1,0],[-1,0],[0,-1],[0,1]]:
    for i in v(1,k+1):
      p,q=x+e*i,y+f*i
      if not((0<=p<h)&(0<=q<w))or b[p][q]=="@" or 0<=l[p][q]<=l[x][y]:break
      if l[p][q]==-1:d+=[(p,q)];l[p][q]=l[x][y]+1
a(-1)

Measured memory_bytes: 93772
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld\n",x)
#define print2(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 222222

ll gcd(ll x, ll y) {
  if (x < y) swap(x, y);
  return y ? gcd(y, x%y) : x;
}

int main(void) {
  string t;
  cin >> n >> m;
  cin >> s;
  cin >> t;
  ok = true;
  ll g = gcd(n, m);
  ll x = n / g, y = m / g;
  rep(i, g) {
	if (s[i*x] != t[i*y]) ok = false;
  }
  if (ok) cout << n * y << endl;
  else cout << "-1" << endl;


  return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
  int L, A, B, C, D; cin >>L >>A >>B >>C >>D;
  cout <<L - max(A / C + (A % C ? 1 : 0), B / D + (B % D ? 1 : 0)) <<endl;
  return 0;
}

Measured memory_bytes: 1164
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
import Data.IORef
import Control.Monad.ST
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
applyBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
applyBin op f g x = op (f x) $ g x
applyUni :: (a -> b -> c) -> (a -> b) -> a -> c
applyUni op f x = op x $ f x
applyTuple :: (a -> b, a -> c) -> a -> (b, c)
applyTuple (f,g) a = (f a, g a)
-- end of templete

fact :: Int -> Integer
fact n = runST $ do
    ref <- newSTRef 1 :: ST s (STRef s Integer)
    forM_ [1..n] $ modifySTRef ref . (*) . toInteger
    readSTRef ref


main = getInt >>= print . fact

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

using namespace std;

const int N = 2005;
const long long inf = 1e18;

int a[N][2], n;
long long dp[N][N][2][2]; // pertama, kedua

long long dfs(int i, int j, int p, int move) {
  if (dp[i][j][p][move] != -1) return dp[i][j][p][move];
  if (i == n || j == n) return abs(a[i][0] - a[j][1]);
  long long& ret = dp[i][j][p][move];
  int pol = max(i, j);
  if (p == 0) {
    ret = dfs(pol + 1, j, p, 1);
    if (move) ret = max(ret, dfs(i, j, p ^ 1, 0));
  } else {
    ret = dfs(i, pol + 1, p, 1);
    if (move) ret = min(ret, dfs(i, j, p ^ 1, 0));
  }
  return ret;
  
}

int main() {
  scanf("%d %d %d", &n, &a[0][0], &a[0][1]);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i][0]), a[i][1] = a[i][0];
  memset(dp, -1, sizeof(dp));
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}


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

int find(int cur,int a[],int n){
    int memo[n];
    memo[0]=0;
    for(int i=1;i<n;i++)
    {
        if(i==1)
        memo[i]=abs(a[i-1]-a[i])+memo[i-1];
        else
        memo[i]=min(abs(a[i-1]-a[i])+memo[i-1],abs(a[i-2]-a[i])+memo[i-2]);
    }
    return memo[n-1];   
}

int main() {
    int n;cin>>n;
    int a[n];
    // memset(memo,0,sizeof(int)*100005);
    for(int i=0;i<n;i++)
        cin>>a[i];
    cout<<find(0,a,n);
    // for(int i=0;i<n;i++)
    // cout<<memo[i]<<" ";
    
    
}

Measured memory_bytes: 1024
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    double A, V, B, W, T; cin >> A >> V >> B >> W >> T;
    V > W && abs(A - B) / (V - W)<=T ? puts("YES") : puts("NO");
}






Measured memory_bytes: 3708
def area(p,q,r):
    a = [x-y for x,y in zip(r,p)]
    b = [x-y for x,y in zip(q,p)]
    return (a[0]*b[1]-a[1]*b[0]) / 2

S = []

while True:
    string = input()
    if string == '':
        continue
    elif int(string) == 0:
        break
    else:
        n = int(string)
        v = []
        for _ in range(n):
            v.append([int(x) for x in input().split()])
        s = 0
        for i in range(1,n-1):
            s += area(v[0],v[i],v[i+1])
        S.append(round(s,1))

for i,x in enumerate(S):
    print(i+1, x)


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

using namespace std;

typedef long long ll;

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

	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if(s < t){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
k = int(input())


def gcd(a, b):
    if a > b:
        a, b = b, a
    while a != 0:
        a, b = b % a, a
    return b


ans = 0
for p in range(1, k + 1):
    for q in range(1, k + 1):
        for r in range(1, k + 1):
            ans += gcd(gcd(p, q), r)
print(ans)

Measured memory_bytes: 68724
import java.util.Scanner;

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

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();

      if (B % A == 0) {
        System.out.println(A + B);
      } else {
        System.out.println(B - A);
      }
    }
  }
}

Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;
#define M_PIl        3.141592653589793238462643383279502884
typedef long long ll;
typedef long double ld;



ll expo(ll a, ll b) {
  if (b <= 0) return 1;
  if (a == 1) return 1;
  if (a == 0) return 0;
  ll ans = 1, base = a;
  for (; b; base*=base, b >>= 1) {
    if (b&1) ans *= base;
  }
  return ans; 
}

int main(){
  ld a,b,h,m;
  cin >> a >> b >> h >> m;
  ld temp = ((h-(m/5))*30)+(30*(m/60));
  cout << setprecision(15) << sqrt(expo(a,2)+expo(b,2)-((2*a*b)*cos(temp*M_PIl/180))) << endl;
  
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
    int D;
    cin >> D;
    vector<ll> c(26);
    for (int i = 0; i < 26; i++) cin >> c.at(i);
    vector<vector<ll>> s(D, vector<ll>(26));
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) cin >> s.at(i).at(j);
    }
    vector<int> t(D, 1);
    //for (int i = 0; i < D; i++) cin >> t.at(i);
    vector<int> dp(26, 0);
    ll ans = 0;
    int ans_c = 0;

    for (int i = 0; i < D; i++) {
        ll ans_pre = ans;
        ans = -10000000000;
        for (int j = 0; j < 26; j++) {
            ll tmp = s.at(i).at(j);
            for (int k = 0; k < 26; k++) {
                if (k != j) tmp -= c.at(k) * (ll)(i + 1 - dp.at(k));
            }
            //if (i == 4 && j == 12) cout << "13: " << tmp << endl;
            if (tmp > ans) {
                ans = tmp;
                ans_c = j;
            }
        }
        //cout << ans << endl;
        dp.at(ans_c) = i + 1;
        //cout << "ans_c: " << ans_c << ", dp.at(ans_c): " << dp.at(ans_c) << endl;
        t.at(i) = ans_c + 1;
        ans += ans_pre;
        cout << t.at(i) << endl;
    }

    //for (int i = 0; i < D; i++) {
        //cout << t.at(i) << endl;
        //if (i < D - 1) cout << " ";
    //}
    //cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3660
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <limits>
using namespace std;
typedef long long ll;

int n, m;
int book[110];

bool can(int W){
	int cnt = 1;
	int w = 0;

	for(int i=0;i<n;i++){
		if(w + book[i] <= W){
			w += book[i];
		} else {
			++cnt;
			w = book[i];
		}
	}

	return (cnt <= m);
}

int main(){
	while(cin >> m >> n){
		if(n == 0 && m == 0)break;
		for(int i=0;i<n;i++)cin >> book[i];

		int sum = accumulate(book, book + n, 0);
		int maxi = *max_element(book, book + n);

		int low = maxi - 1, high = sum;

		while(high - low > 1){
			int mid = (high - low) / 2 + low;
			if(can(mid))high = mid; else low = mid;
		}

		cout << high << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    x = int(input())
    k = 1
    while ( x * k ) % 360:
        k += 1
    print(k)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 8932
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


const ll mx=4100;


int main(){
    ll n;
    cin>>n;
    vector<pair<pll,pll>> P(n);
    map<ll,ll> X;
    map<ll,ll> Y;
    /*
    map<ll,ll> RX;
    map<ll,ll> RY;
     */
    vector<ll> RX(mx,0);
    vector<ll> RY(mx,0);
    for(int i=0;i<n;i++){
        cin>>P[i].F.F>>P[i].F.S>>P[i].S.F>>P[i].S.S;
        X[P[i].F.F]=0;
        Y[P[i].F.S]=0;
        X[P[i].S.F]=0;
        Y[P[i].S.S]=0;
    }
    ll count=0;
    for(auto i=X.begin();i!=X.end();++i){
        i->second=count;
        RX[count++]=i->first;
    }
    count=0;
    for(auto i=Y.begin();i!=Y.end();++i){
        i->second=count;
        RY[count++]=i->first;
    }
    vector<vector<ll>> a(mx,vector<ll>(mx,0));
    for(int i=0;i<n;i++){
        a[X[P[i].F.F]][Y[P[i].F.S]]++;
        a[X[P[i].F.F]][Y[P[i].S.S]]--;
        a[X[P[i].S.F]][Y[P[i].F.S]]--;
        a[X[P[i].S.F]][Y[P[i].S.S]]++;
    }
    for(int i=0;i<mx;i++){
        for(int t=1;t<mx;t++){
            a[i][t]+=a[i][t-1];
        }
    }
    for(int i=0;i<mx;i++){
        for(int t=1;t<mx;t++){
            a[t][i]+=a[t-1][i];
        }
    }
    ll ans=0;
    for(int i=0;i<mx;i++){
        ll h=RX[i+1]-RX[i];
        for(int t=0;t<mx;t++){
            if(a[i][t]){
                ans+=h*(RY[t+1]-RY[t]);
            }
        }
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 135152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
	int N;
	string S;
	int res;
	cin >> N >> S;
	int sumw[N];
	int sume[N];
	sumw[0]=0;
	sume[0]=0;
	for(int i=0; i<N; i++){
		if(S[i]=='W'){
		    sumw[i+1] = sumw[i] + 1;
            sume[i+1] = sume[i];
		}else{
			sumw[i+1] = sumw[i];
			sume[i+1] = sume[i] + 1;
		}
	}
	res = N;
	for(int k=1; k<=N; k++){
		int temp = sumw[k-1]+sume[N]-sume[k];
		if(temp < res) res = temp;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 55
#define MAXM 55
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0;
int N,M;
vi A,B;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

void solve(){
    rep(k, M){
        UnionFind UF = UnionFind(N);

        rep(i, M){
            if(i==k) continue;
            UF.merge(A[i], B[i]);
            }

        if(UF.size(0) != N) ans++;
    }

    cout << ans << endl;
}

int main(){
    cin >> N >> M;
    A.resize(M), B.resize(M);

    rep(i, M) {
        cin >> A[i] >> B[i];
        --A[i], --B[i];
    }
    solve();
}


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

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

    int a, b, k;
    cin >> a >> b >> k;
    for (int i = 0; i < k; ++i) {
        if (a % 2 == 1) {
            a -= 1;
        }
        a /= 2;
        b += a;
        swap(a, b);
    }
    if (k % 2 == 1) swap(a, b);

    printf("%d %d", a, b);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;
#define MOD 1000000007LL

ll ncr(ll n, ll r){
  if(n < r) return 0;
  if(r > n-r) r = n-r;

  ll a = 1, b = 1;
  for(int i = 0; i < r; i++){
    a *= (n - i);
  }
  for(int i = 0; i < r; i++){
    b *= (i + 1);
  }
  return a/b;
}

int main(){
  int N;
  cin >> N;
  vi prime(100, 0);
  for(int i = 2; i <= N; i++){
    int NN = i;
    for(int j = 2; j*j <= NN; j++){
      int counter = 0;
      while(NN % j == 0){
        counter++;
        NN /= j;
      }
      prime.at(j) += counter;
    }
    if(NN != 1) prime.at(NN)++;
  }
  vi box(0);
  for(int i = 0; i < 100; i++){
    if(prime.at(i) != 0) box.push_back(prime.at(i));
  }
  sort(ALL(box));
  int ans = 0;
  //75 = 3 * 5 * 5 = 15 * 5 = 3 * 25 = 75
  int two = distance(lower_bound(ALL(box), 2), box.end());
  int four = distance(lower_bound(ALL(box), 4), box.end());
  int fourteen = distance(lower_bound(ALL(box), 14), box.end());
  int twefour = distance(lower_bound(ALL(box), 24), box.end());
  int sevfour = distance(lower_bound(ALL(box), 74), box.end());
  ans += ncr(four, 2) * ncr(two-2, 1);
  ans += fourteen * (four-1);
  ans += twefour * (two-1);
  ans += sevfour;
  cout << ans << endl;
}

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

    A = [B[0]]
    for i in range(1, len(B)):
        A.append(min([B[i], B[i-1]]))

    A.append(B[-1])
    print(sum(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int B[] = new int[N-1];
	
	sc.nextLine();
	for (int i=0; i<N-1; i++){
	  B[i] = sc.nextInt();
	}
	
	long SumA = B[0];
	
    for (int i=1; i<N-1; i++){
	  SumA += Math.min(B[i-1],B[i]);
	}
	
	SumA += B[N-2];
    
    System.out.println(SumA);
  }
}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

long long a[100005];

int main(void){
    int n;
    long long ans = 0;
    long long ans2 = 0;
    long long sum;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%lld", &a[i]);
    }

    if (a[0] <= 0){
        sum = 1;
        ans = llabs(1 - a[0]);
    }else{
        sum = a[0];
    }
    for (int i = 1; i < n; i++){
        if (sum+a[i] == 0){
            sum = (-1*llabs(sum)/sum);
            ans++;
        }else if (llabs(sum+a[i])/(sum+a[i]) == llabs(sum)/sum){
            ans += llabs(a[i] - ((-1*llabs(sum)/sum) - sum));
            sum = (-1*llabs(sum)/sum);
        }else{
            sum += a[i];
        }
    }
    if (a[0] >= 0){
        sum = -1;
        ans2 = llabs(-1 - a[0]);
    }else{
        sum = a[0];
    }
    for (int i = 1; i < n; i++){
        if (sum+a[i] == 0){
            sum = (-1*llabs(sum)/sum);
            ans2++;
        }else if (llabs(sum+a[i])/(sum+a[i]) == llabs(sum)/sum){
            ans2 += llabs(a[i] - ((-1*llabs(sum)/sum) - sum));
            sum = (-1*llabs(sum)/sum);
        }else{
            sum += a[i];
        }
    }
    

    printf("%lld\n", ans>ans2?ans2:ans);

    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 2e5+100;



int n;
string s;

int dp[maxn], dpc[maxn];
int nxt[maxn][26];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>s;
    n=s.length();

    for (int j=0;j<26;j++) {
	nxt[n][j]=n;
	for (int i=n-1; i>=0; i--) {
	    nxt[i][j]=nxt[i+1][j];
	    if (s[i]-'a' == j) {
		nxt[i][j] = i;
	    }
	}
    }


    dp[n+1] = 0;

    for (int i=n; i>=0; i--) {

	dp[i]=1e9;
	dpc[i]=-1;
	
	for (int j=0;j<26;j++) {
	    if (1+dp[nxt[i][j]+1] < dp[i]) {
		dp[i] = 1+dp[nxt[i][j]+1];
		dpc[i] = j;
	    }
	}
    }


    string res;

    for (int j=0; j<n; ) {
	res += char('a'+dpc[j]);
	j = nxt[j][dpc[j]]+1;
    }
    out(res);
    
  
    return 0;
}


Measured memory_bytes: 22420
var
  x, y : integer;
begin
	readln(x, y);
	if (x=y) then
	  writeln('Draw')
	else if (x=1) then
	  writeln('Alice')
	else if (y=1) then
	  writeln('Bob')
	else if (x>y) then
	  writeln('Alice')
	else if (x<y) then
	  writeln('Bob');
end.

Measured memory_bytes: 128
#include <stdio.h>

int roomToInt (int b,int f,int r) {
  int tmp;
  tmp = ((b-1) * 3 + f - 1) * 10 + r - 1;
  return tmp;
}

int main(void) {
  int i, tmp1, tmp2, n, b, f, r, v[120] = {};
  scanf("%d\n", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d %d %d\n", &b, &f, &r, &tmp1);
    tmp2 = roomToInt(b, f, r);
    v[tmp2] += tmp1; 
  }
  for (i = 0; i < 120 ; i++) {
    printf(" %d", v[i]);
    if ( (i + 1) % 10 == 0) printf("\n");
    if (i == 119) break;
    if ( (i + 1) % 30 == 0) printf("####################\n");
  }
  return 0;
}



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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	vector<int> a;

	cin >> N;
	for(int i=0; i<N; i++){
		long long tmp;
		cin >> tmp;
		a.push_back(tmp);
	}

	sort(a.begin(), a.end());

	long long ans = (1LL<<61);
	for(int i=a[0]-1; i<=a[N-1]+1; i++){
		long long c = 0;
		for(int j=0; j<N; j++){
			c += (a[j] - i) * (a[j] - i);
		}
		if(c < ans){ ans = c;}
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define MOD 998244353
typedef pair<long,long> pll;

class SegmentTree{
private:
	vector<long> a;
	int n, m, h;
public:
	SegmentTree(int _n): n(_n){
		m = 1; h = 1;
		while (m < n){
			m <<= 1;
			h++;
		}
		a.resize(2*m+1, 0);
	}
	void update(int idx){
		int i = m + idx - 1;
		for (int i=m+idx-1; i > 0; i=(i-1)/2){
			a[i]++;
		}
		a[0]++;
	}
	// [p,q)
	long get(int p, int q){
		return query(p, q, 0, 0, m);
	}
	long query(int p, int q, int k, int l, int r){
		if (r <= p || q <= l) return 0;
		if (p <= l && r <= q) return a[k];
		else{
			int vl = query(p, q, k*2+1, l, (l+r)/2);
			int vr = query(p, q, k*2+2, (l+r)/2, r);
			return vl+vr;
		}
	}
	void print(){
		for (int i = 0, j = 0; i < h; ++i){
			for (int k = 0; k < (1 << i); k++, j++){
				printf("%d ", a[j]);
			}
			printf("\n");
		}
	}
	void clear(){
		fill(a.begin(), a.end(), 0);
	}
};

long pow2(int n){
	if (n == 0) return 1;
	else if (n % 2 == 1) return (pow2(n-1)*2)%MOD;
	else{
		long t = pow2(n/2);
		return (t*t)%MOD;
	}
}

int n;
long x, y, ans, tmp;
vector<pll> xy;
vector<long> ur, ul, ll, lr, bin;

int main(){
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> x >> y;
		xy.emplace_back(x, y);
	}
	sort(xy.begin(), xy.end(), [](pll a, pll b){return a.second < b.second;});
	for (int i = 0; i < n; ++i) xy[i].second = i;
	sort(xy.begin(), xy.end(), [](pll a, pll b){return a.first < b.first;});

	SegmentTree tree(n);
	ur.resize(n);
	ul.resize(n);
	ll.resize(n);
	lr.resize(n);

	for (int i = 0; i < n; ++i){
		y = xy[i].second;
		ul[i] = tree.get(y+1, n);
		ll[i] = tree.get(0, y);
		tree.update(y);
	}
	tree.clear();
	for (int i = n-1; i >= 0; --i){
		y = xy[i].second;
		ur[i] = tree.get(y+1, n);
		lr[i] = tree.get(0, y);
		tree.update(y);
	}

	bin.resize(n); bin[0] = 1;
	for (int i = 0; i < n-1; ++i) bin[i+1] = (bin[i]*2) % MOD;

	ans = (bin[n-1] * n) % MOD;
	for (int i = 0; i < n; ++i){
		long bur = bin[ur[i]];
		long bul = bin[ul[i]];
		long blr = bin[lr[i]];
		long bll = bin[ll[i]];
		tmp = ((((((bur - 1)*(bll - 1)) % MOD)*bul) % MOD)*blr) % MOD;
		ans = (ans + tmp) % MOD;
		tmp = ((((((bul - 1)*(blr - 1)) % MOD)*bur) % MOD)*bll) % MOD;
		ans = (ans + tmp) % MOD;
		tmp = ((((((bur - 1)*(bll - 1)) % MOD)*(bul - 1)) % MOD)*(blr - 1)) % MOD;
		ans = (ans + (MOD - tmp)) % MOD;
	}
	cout << ans;
}

Measured memory_bytes: 16108
N = int(input())
# map(int,input().split())
A = list(map(int,input().split()))
# [list(map(int,input().split())) for i in range(N)]
sum = 1.0
bunbo = 0.0
for i in A:
    sum *= i

for j in A:
    bunbo += sum/j

print(sum/bunbo)


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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
using namespace std;
using ll = long long;
using lld = long long;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

ll gcd(ll a, ll b)
{
  if (a < b)
  {
    return gcd(b, a);
  }
  while (b != 0)
  {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  return a;
}

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

  ll mn;
  cin >> mn;
  loop(0, 4, i) {
    ll tmp;
    cin >> tmp;
    mn = min(mn, tmp);
  }

  ll bn;
  if (N % mn == 0) {
    bn = N/mn;
  } else {
    bn = N/mn + 1;
  }

  print(bn + 5 - 1);
}

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

int main(){
    int N;
    cin >> N;
    bool F[100][10];
    for(int i=0;i<N;i++){
        for(int j=0;j<10;j++){
            cin >> F[i][j];
        }
    }
    long long P[100][11];
    for(int i=0;i<N;i++){
        for(int j=0;j<=10;j++){
            cin >> P[i][j];
        }
    }

    long long maxP=-1000000001;
    for(int ij=1;ij<1024;ij++){
        long long pr=0;
        for(int i=0;i<N;i++){
            int c=0;
            for(int j=0;j<10;j++){
                if(F[i][j] && (ij&(1<<j))) c++;
            }
            pr+=P[i][c];
        }
        if(maxP<pr) maxP=pr;
    }

    cout << maxP << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using pdi = pair<double,int>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;


const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int H,N; cin >>H>>N;
    vector<P> vec(N);
    int maxa = 0;
    REP(i,N){
        int a,b; cin >> a >> b;
        maxa = max(maxa,a);
        vec[i] = P(a,b);
    }
    vvi dp(N + 1, vector<int>(H + maxa + 1, INF));
    dp[0][0] = 0;
    REP(i,N){
        REP(j,H+maxa){
            if(j >= vec[i].first){
                dp[i+1][j] = min(dp[i][j],dp[i + 1][j - vec[i].first] + vec[i].second);
            }
            else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    int ans = INF;
    for(int i = H; i < H + maxa; i++){
        ans = min(ans, dp[N][i]);
    }

    cout << ans << endl;

    

}

Measured memory_bytes: 46880
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let R2 T U = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U)
let R3 T U V = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V)
let R4 T U V W = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W)
let R5 T U V W X = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W),(c.[4]|>X)
[<EntryPoint>]
let main argv =
    let N=R int
    let cnt arr str = 
        arr
        |>Seq.sumBy(fun c-> if c=str then 1 else 0)
    let S=[|for i in [1..N] do yield (R string)|]
    printfn "AC x %d" (cnt S "AC")
    printfn "WA x %d" (cnt S "WA")
    printfn "TLE x %d" (cnt S "TLE")
    printfn "RE x %d" (cnt S "RE")
    0

Measured memory_bytes: 39240
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      auto A = new int[3];
      auto B = new int[3];
      foreach (i; 0 .. 3) {
        A[i] = readInt() - 1;
        B[i] = readInt() - 1;
      }
      
      auto deg = new int[4];
      foreach (i; 0 .. 3) {
        ++deg[A[i]];
        ++deg[B[i]];
      }
      bool ans = true;
      foreach (u; 0 .. 4) {
        ans = ans && (deg[u] <= 2);
      }
      writeln(ans ? "YES" : "NO");
    }
  } catch (EOFException e) {
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll lcm(ll n,ll m)
{
	return ((n*m)/(__gcd(n,m)));
}

int main()
{
	const double pi = 3.1415926535;
	cin.tie(0);
	cout.tie(0);
	ll n,m;
	cin>>n>>m;
	ll visited[n+1]={0},ans[n+1]={0};
	visited[1]=1;
	vector<ll> v[n+1];
	for(ll i=0;i<m;i++)
	{
		ll a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	queue<ll> q;
	q.push(1);
	while(!q.empty())
	{
		ll x=q.front();
		q.pop();
		for(ll i=0;i<v[x].size();i++)
		{
			if(visited[v[x][i]]==0)
			{
				ans[v[x][i]]=x;
				visited[v[x][i]]=1;
				q.push(v[x][i]);
			}
		}
	}
	int f=0;
	for(ll i=2;i<=n;i++)
	{
		if(ans[i]==0)
		{
			f=1;
			break;
		}
	}
	if(f==1)
	cout<<"No"<<endl;
	else
	{
		cout<<"Yes"<<endl;
		for(ll i=2;i<=n;i++)
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n;
  cin >> n;
  vector<pii> v(n);
  rep(i, n) cin >> v[i].S >> v[i].F;
  sort(all(v));
  ll sum = 0;
  rep(i, n) {
    sum += v[i].S;
    if (sum > v[i].F) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
  int n,a[10000],d,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  d=n-1;
  for(i=d;i>=0;i--){
    if (i>0)printf("%d ",a[i]);
    else printf("%d",a[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2048