akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
    
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int F = 1;
    for(int i = 0; i < N; i++){
      F = Math.min(F+K, F*2);
    }
    System.out.println(F);
  }
}


Measured memory_bytes: 23636
n, m = gets.chomp.split(' ').map(&:to_i)
list = n.times.map do
  l = gets.chomp.split(' ').map(&:to_i)
  l.shift # k
  l
end

all_likes = Array.new(m + 1) { true }
all_likes[0] = false

list.each do |l|
  1.upto(m + 1).each do |i|
    next unless all_likes[i]
    unless l.include?(i)
      all_likes[i] = false
    end
  end
end

puts all_likes.count { |t| t }


Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll k,s;
	scanf("%lld%lld",&k,&s);
	ll ans=0;
	rep(x,0,k+1)rep(y,0,k+1){
		ll z=s-x-y;
		if(0<=z&&z<=k)ans++;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int t1=0, t2=0;
	cin >> s;
	for (int i=0; i<s.size(); i++)
	{
		if (s[i]=='0') t1++;
		else t2++;
	}
	cout << min(t1, t2)*2 << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] a = new int[N];
        HashMap<Integer, Integer> map = new HashMap<>();

        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
            if(map.containsKey(a[i])){
                map.put(a[i], map.get(a[i]) + 1);
            }
            else{
                map.put(a[i], 1);
            }
        }
        long ans = 0L;
        for(int key : map.keySet()){
            if(key>map.get(key)){
                ans += map.get(key);
            }
            else if(key<map.get(key)){
                ans += map.get(key) - key;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 62796
import java.util.Scanner;

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

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                grid[i][j] = sc.nextInt();
            }
        }

        // 横方向を見る
        for (int i = 0; i < 2; i++) {
            int a = (grid[i][0] - grid[i+1][0]);
            int b = (grid[i][1] - grid[i+1][1]);
            int c = (grid[i][2] - grid[i+1][2]);
            if (a != b || b != c) { System.out.println("No"); return; }
        }

        // 横方向を見る
        for (int i = 0; i < 2; i++) {
            int a = (grid[0][i] - grid[0][i+1]);
            int b = (grid[1][i] - grid[1][i+1]);
            int c = (grid[2][i] - grid[2][i+1]);
            if (a != b || b != c) { System.out.println("No"); return; }
        }

        System.out.println("Yes");
    }
}


Measured memory_bytes: 23508
// 使ってみるテスト
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>

#include <set>
#include <list>
#include <unordered_map>
#include <vector>
#include <stack>
#include <queue>

#include <algorithm>
#include <utility>

using namespace std;

// C++11系の標準関数でのg++のバグ対策と
// split系の関数を作成
namespace patch
{
    template <typename T>
    string to_string(const T& n)
    {
        ostringstream stm;
        stm << n;
        return stm.str();
    }
    int stoi(const string &str)
    {
        int ret;
        istringstream stm(str);
        stm >> ret;
        if (stm.fail())
        {
            throw -1;
        }
        return ret; 
    }
    vector<string> split(const string &str)
    {
        istringstream stm(str);
        vector<string> ret;
        copy(istream_iterator<string>(stm),
            istream_iterator<string>(),
            back_inserter(ret));
        return ret;
    }
    vector<string> split(const string &str, char delim)
    {
        istringstream stm(str);
        vector<string> ret;
        string buf;
        while (getline(stm, buf, delim))
        {
            ret.push_back(buf);
        }
        return ret;
    }
}

int bubbleSort(vector<int> &vs)
{
    int end = vs.size();
    if (end == 1)
    {
        return 0;
    }
    int cnt = 0;
    for (int j = 0; j < end - 1; ++j)
    {
        for (int i = 0; i < end - j - 1; ++i)
        {
            if (vs[i] > vs[i+1])
            {
                swap(vs[i], vs[i+1]);
                ++cnt;
            }
        }
    } 
    return cnt;
}

// bubble sort
int main()
{
    ios::sync_with_stdio(false);

    // --- 標準入力読込開始 ---
    // line 1
    string s1;
    getline(cin, s1);
    int n = patch::stoi(s1);

    // line 2
    vector<int> vs(n);
    vector<string> ss;
    string s2;
    getline(cin, s2);
    ss = patch::split(s2);
    for (int n = 0, sz = ss.size(); n < sz; ++n)
    {
        vs[n] = patch::stoi(ss[n]);
    }
    // --- 標準入力読込終了 ---

    // バブルソート実行
    int cnt = bubbleSort(vs);
    
    bool isFirst = true;  // 無駄なスペースがあるとダメらしいので
    for (int n : vs)
    {
        //cout << n << " ";   // ふぁっ？！ Presentation Error??!
        if (isFirst)          // こうやるしかないぽ
        {
            cout << n;
            isFirst = false;  // 仕方ねぇ
        }
        else
        {
            cout << " " << n;
        }
    }
    cout << "\n";
    cout << cnt << "\n";
    
    return 0;
}

Measured memory_bytes: 1244
import heapq

class PriorytyQueue(object):

    def __init__(self, arr, target='min'):
        self.arr = arr
        self.target = target
        self._heapify()
    
    def _heapify(self):
        if self.target == 'max':
            self.arr = list(map(lambda x:x*(-1), self.arr))
        heapq.heapify(self.arr)
    
    def push(self, x):
        if self.target == 'max':
            x *= -1
        heapq.heappush(self.arr, x)

    def pop(self):
        res = heapq.heappop(self.arr)
        if self.target == 'max':
            return res*(-1)
        else:
            return res
    
    def get_arr(self):
        if self.target == 'max':
            return list(map(lambda x:x*(-1), self.arr))
        else:
            return self.arr

N, M = map(int, input().split())
A = list(map(int, input().split()))

A = PriorytyQueue(A, target='max')

for i in range(M):
    max_A = A.pop()
    A.push(max_A//2)

print(sum(A.get_arr()))

Measured memory_bytes: 14224
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> to(n), cost(n);
    rep(i, n-1) {
        int a, b, w;
        cin >> a >> b >> w;
        a--;
        b--;
        to[a].push_back(b);
        cost[a].push_back(w);
        to[b].push_back(a);
        cost[b].push_back(w);
    }

    vector<int> ans(n, -1);
    queue<int> q;
    ans[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        rep(i, to[v].size()) {
            int u = to[v][i];
            int w = cost[v][i];
            if(ans[u] != -1) {
                continue;
            }
            ans[u] = (ans[v]+w)%2;
            q.push(u);
        }
    }

    rep(i, n) {
        cout << ans[i] << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <vector>
#include <assert.h>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define each(i,n) for(auto &i : n)

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

	vector<int> p(n);
	rep(i, n) {
		cin >> p[i];
		p[i]--;
	}

	vector<int> a(n), b(n);

	int cnt = 0;
	each(i, p) {
		a[i] = +i * n + (n - 1) * n + 1 + cnt;
		b[i] = -i * n + (n - 1) * n + 1;
		cnt++;
	}

	rep(i, n-1) {
		assert(a[i] < a[i + 1]);
		assert(b[i] > b[i + 1]);
		assert(a[i] >= 1);
		assert(b[i] >= 1);
		assert(a[i] <= 1e9);
		assert(b[i] <= 1e9);
	}

	rep(i, n) {
		if (i == n - 1)cout << a[i] << endl;
		else cout << a[i] << " ";
	}
	rep(i, n) {
		if (i == n - 1)cout << b[i] << endl;
		else cout << b[i] << " ";
	}


	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=1;i<=n;++i)
#define mp make_pair
#define F first
#define S second
#define init(x) memset(x,0,sizeof(x))
int a,b,c,n=0;
int main()
{
 	cin>>a>>b>>c;
 	if (a<b) swap(a,b);
 	if (a<c) swap(a,c);
 	if (b<c) swap(b,c);
 	while(a>b){
 		++n;
 		++b;++c;
 	}
 	if (b!=c){
 		while(b-c>1){
 			c+=2;++n;
 		}
 		if (b!=c) n+=2;
 	}
 	cout<<n;
 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> p(m);
    vector<int> y(m);
    rep(i,m) cin >> p[i] >> y[i];

    vector<priority_queue<int, vector<int>, greater<int>>> x(n);
    vector<unordered_map<int,int>> yx(n);

    rep(i,m)
    {
        x[p[i]-1].push(y[i]);
    }

    rep(i,n)
    {
        int id = 1;
        while(!x[i].empty())
        {
            yx[i].insert({x[i].top(),id});
            x[i].pop();
            ++id;
        }
    }

    rep(i,m)
    {
        printf("%06d%06d\n", p[i], yx[p[i]-1][y[i]]);
    }

    return 0;
}

Measured memory_bytes: 20224
n,k = map(int,input().split())
import math

def succ(m): #サイコロの目がmの時、kを超えるようにコインの表を出し続ける最小の回数
  res = 0
  while True:
    if m < k:
      res += 1
      m *= 2
    if m >= k:
      return res

def pos():
  res = 0
  for i in range (1, n+1):
    m = n*2**succ(i)
    res += 1/m
  return res

print(pos())

Measured memory_bytes: 3060
import static java.lang.Math.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 50;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		long[] a;
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			a = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextLong() - (i+1);
			}

			long left = -(long)pow(10, 9);
			long right = (long)pow(10, 9);

			for (int i = 0; i < 100; i++) {
				long c1 = (left * 2L + right) / 3;
				long c2 = (left + right * 2L) / 3;

				if (func(c1) < func(c2)) {
					right = c2;
				} else {
					left = c1;
				}
			}

			long ans = LINF;

			for (long b = left; b <= right; b++) {
				ans = min(ans, func(b));
			}

			out.println(ans);

		}

		long func(long b) {
			long ret = 0;
			for (long l : a) {
				ret += Math.abs(l - b);
			}
			return ret;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 47884
N, M = gets.split.map(&:to_i)

gate = M.times.map { gets.split.map(&:to_i) }

counter = Array.new(N + 2, 0)

gate.each do |l, r|
  counter[l] += 1
  counter[r + 1] -= 1
end

ans = 0

cnt = 0

(1..N).each do |i|
  cnt += counter[i]

  if cnt == M
    ans += 1
  end
end

puts ans


Measured memory_bytes: 10364
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
int n, a[N], x;
int dp[N];
void solve(){
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i]; 
    
    dp[2] = abs(a[2] - a[1]); 

    for(int i = 3; i <= n; ++i)
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));


    cout << dp[n];  

}   
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	cin>>n;

    bool check=false;
    for(int i=0;i<=25;i++){
        for(int j=0;j<=14;j++){
            if(n==4*i+7*j){
                check=true;
                break;
            }
        }
    }
    
	
    cout<<(check?"Yes":"No")<<endl;

	return 0;
}


Measured memory_bytes: 256
import itertools
import bisect
n,m,k=map(int,input().split())
aa=list(map(int,input().split()))
bb=list(map(int,input().split()))
count=0
book=0
rest=0
ans=[]
aaa=list(itertools.accumulate(aa))
bbb=list(itertools.accumulate(bb))
bs=bisect.bisect(bbb,k)
ap=bisect.bisect(aaa,k)
ans.append(ap)
for i in range(bs+1):
  ii=bs-i
  rest=k-bbb[ii-1]
  goal=bisect.bisect(aaa,rest)
  ans.append(ii+goal)
  #print(ii,goal,rest)

print(max(ans))  
  

Measured memory_bytes: 49840
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int A,B,X; cin >> A >> B >> X;
    int S=A+B;
    if(S<X || A>X) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 3652
(defun split (str delim)
  (let ((res (make-array 1 :element-type 'string
                           :fill-pointer 0
                           :adjustable t)))
    (loop for i from 0 below (length str)
          with start = 0
          when (eq (char str i) delim)
          do (vector-push-extend (subseq str start i) res)
             (setf start (1+ i))
          finally (let ((tail (subseq str start)))
                    (when tail
                      (vector-push-extend tail res))))
    res))

(let* ((n (parse-integer (read-line)))
       (a (map 'vector #'parse-integer (split (read-line) #\Space)))
       (pos (make-array n :initial-element 0)))
  (loop for i from 0 below n
        for p = (aref a i)
        do (incf (aref pos p)))
  (if (or (and (evenp n)
               (/= (aref pos 0) 0))
          (and (oddp n)
               (/= (aref pos 0) 1)))
      (format t "0~%")
      (if (and (> n 1)
               (loop for i from 1 below n
                     for p = (aref pos i)
                     when (not (integerp (/ p 2)))
                     do (return t)
                     finally (return nil)))
          (format t "0~%")
          (format t "~A~%"
                  (mod (expt 2 (/ (if (oddp n)
                                      (1- n)
                                      n)
                                  2))
                       1000000007)))))

Measured memory_bytes: 18276
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  map<string, bool> mp;
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  mp[s[0]] = true;
  for(int i = 1; i < n; i++){
    if(mp[s[i]] || s[i-1][s[i-1].size()-1] != s[i][0]){
      cout << "No" << endl;
      return 0;
    }
    mp[s[i]] = true;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
long long mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////
int n, q; 
vector<vector<int>> v;
vector<long long> ans;
vector<int> c;
vector<bool> vis;

void func(int pos, int tmp) {
    vis[pos] = true;
    cerr << pos << " " << tmp << endl;
    int sum = tmp + c[pos];
    ans[pos] += sum;
    for(int i=0; i<v[pos].size(); i++) {
        if(vis[v[pos][i]]) continue;
        func(v[pos][i], sum);
    }
}

int main() {
    cin >> n >> q; 
    ans.resize(n, 0);
    v.resize(n);
    vis.resize(n, false);
    int a, b;
    for(int i=0; i<n-1; i++) {
        cin >> a >> b;
        a--; b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    c.resize(n, 0);
    int p, x;
    for(int i=0; i<q; i++) {
        cin >> p >> x;
        c[p-1] += x;
    }

    func(0, 0);
    for(int i=0; i<n; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}




// EOF


Measured memory_bytes: 25088
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int h, a;
  cin >> h >> a;

  cout << (h + a - 1) / a;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int k ,s;
	cin >> k >> s;
	int ans = 0;
	for (int x = 0; x <= k; x++)
	{
		for (int y = 0; y <= k; y++)
		{
			if (0 <= (s - (x + y)) &&  (s - (x + y)) <= k)
			{
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = unsigned long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

namespace mp = boost::multiprecision;

mp::cpp_dec_float_50 A;
mp::cpp_dec_float_50 B;

int main()
{
  std::cin >> A >> B;

  mp::cpp_dec_float_50 C = (A*B);

  mp::cpp_int n{mp::cpp_dec_float_50(mp::floor(C)).str()};

  std::cout << n << std::endl;

  return 0;
}

Measured memory_bytes: 3360
#include <stdio.h>

int main(void){
  int s;
  double w;
  double h;
  double bmi;
  while(scanf("%d,%lf,%lf",&s,&w,&h)!=EOF){
    bmi=w/(h*h);
    if(bmi>=25){
      printf("%d\n",s);
    }
  }
  return 0;
}



Measured memory_bytes: 1988
#include <bits/stdc++.h>
using namespace std;
constexpr int M = 1e9 + 7;

int solve(const int s) {
    if (s < 3) return 0;

    // number of sequences [whose sum is i]
    vector<int> dp(s + 1, 0);
    dp[0] = 1;
    dp[3] = 1;

    for (int i = 4; i <= s; ++i) {
        for (int j = 3; j <= s; ++j) {
            if (i - j >= 0) {
                dp[i] += dp[i - j];
                dp[i] %= M;
            }
        }
    }

    return dp[s];
}

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

    int s;
    cin >> s;
    cout << solve(s) << '\n';

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
using db = double;
const int maxn = 200000;
int n;
int dp[3][maxn];
int v[3][maxn];
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i = 1;i <= n;++i)for(int j = 0;j < 3;++j)cin >> v[j][i];
	for(int i = 1;i <= n;++i)for(int j = 0;j < 3;++j)for(int k = 0;k < 3;++k)dp[j][i] = max(dp[j][i], j == k ? 0 : dp[k][i-1] + v[j][i]);
	cout << max({dp[0][n], dp[1][n], dp[2][n]}) << '\n';
}

Measured memory_bytes: 3712
from operator import mul
from functools import reduce

X,Y = map(int,input().split()[:2])

if (X + Y) % 3 or not (X <= 2*Y and Y <= 2*X):
    print(0)
    exit()

x_tmp=X+1
y_tmp=Y+2

x_count=0
y_count=0

while x_tmp*2 != y_tmp:
    x_tmp-=2
    y_tmp-=1
    x_count+=1

y_count = y_tmp//2 - 1

sum = x_count + y_count

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, sum + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ret = cmb(sum,x_count,mod)
print(ret)


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

struct node{int l,r;}c[2010];
int n,a[2010],b[2010],l[2010],r[2010],L[2010],ans;
char ch[2010];

bool cmp(node x,node y){return x.r<y.r;}

void work()
{
	scanf("%s",ch),n=strlen(ch),ans=2*n;
	for (int i=0; i<n; i++)  a[i]=(ch[i]=='1'),a[n]+=a[i];
	scanf("%s",ch);
	for (int i=0; i<n; i++)  b[i]=(ch[i]=='1'),b[n]+=b[i];
	if (!b[n])  puts(a[n]?"-1":"0"),exit(0);
	a[n]=b[n]=0;
	for (int i=1; i<n; i++)  l[i]=(b[i]?i:l[i-1]);
	for (int i=n-2; ~i; i--)  r[i]=(b[i]?i:r[i+1]);
	l[0]=(b[0]?0:l[n-1]),r[n-1]=(b[n-1]?n-1:r[0]);
	for (int i=1; i<n; i++)  l[i]=(b[i]?i:l[i-1]);
	for (int i=n-2; ~i; i--)  r[i]=(b[i]?i:r[i+1]);
	for (int i=0; i<n; i++)  l[i]=(i-l[i]+n)%n,r[i]=(r[i]-i+n)%n;
	for (int d=-n,m; d<=n; d++)
		{
			if (d<0)  c[m=1]=(node){-d,n},L[m]=-d;
			else  if (d>0)  c[m=1]=(node){n,d},L[m]=n;
			else  c[m=1]=(node){0,0},L[m]=0;
			for (int i=0; i<n; i++)
				if (a[i]!=b[(i+d+n)%n])
					c[++m]=(node){l[i],r[i]},L[m]=l[i];
			sort(c+1,c+m+1,cmp),sort(L+1,L+m+1);
			for (int i=0,j=m; i<=m&&c[j].r>=d; i++)
				{
					while ((j)&&(c[j].l<=L[i]))  j--;
					if (c[j].r>=d)  ans=min(ans,m-1+2*L[i]+2*c[j].r-abs(d));
				}
		}
	printf("%d",ans);
}

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


Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
s = [list(input()) for _ in range(h)]

Ch, Cw = Ch - 1, Cw - 1
Dh, Dw = Dh - 1, Dw - 1
d = [[-1] * w for _ in range(h)]
d[Ch][Cw] = 0
walk = [[0, 1], [0, -1], [1, 0], [-1, 0]]
warp = [[2, 2], [2, 1], [2, 0], [2, -1], [2, -2], [1, 2], [1, 1], [1, -1], [1, -2], [0, 2], [0, -2], [-1, 2], [-1, 1],
        [-1, -1], [-1, -2], [-2, 2], [-2, 1], [-2, 0], [-2, -1], [-2, -2]]

que = deque([[0, Ch, Cw]])
while que:
    count, y, x = que.popleft()
    if d[y][x] < count:
        continue
    for NY, NX in walk:
        if 0 <= y + NY < h and 0 <= x + NX < w and s[y + NY][x + NX] != '#':
            if d[y + NY][x + NX] == -1 or d[y + NY][x + NX] > count:
                d[y + NY][x + NX] = count
                que.appendleft([count, y + NY, x + NX])
    for NY, NX in warp:
        if 0 <= y + NY < h and 0 <= x + NX < w and s[y + NY][x + NX] != '#':
            if d[y + NY][x + NX] == -1 or d[y + NY][x + NX] > count + 1:
                d[y + NY][x + NX] = count + 1
                que.append([count + 1, y + NY, x + NX])

print(d[Dh][Dw])


Measured memory_bytes: 155604
abc = sorted([int(x) for x in input().split()])
eo = [x%2 == 0 for x in abc]
n = eo.count(True)
cnt = 0
if n == 1:
  for i in range(3):
    if not eo[i]:
      abc[i] += 1
  cnt += 1
elif n == 2:
  for i in range(3):
    if eo[i]:
      abc[i] += 1
  cnt += 1
cnt += (abc[2]*2 - abc[0] - abc[1])//2
print(cnt)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		int[]A = new int[N];
		for(var i=0;i<K;i++){
			int D = int.Parse(Console.ReadLine());
			string[] str2 = Console.ReadLine().Split();
			for(var j=0;j<D;j++){
				A[int.Parse(str2[j])-1]++;
			}
		}
		int ans = 0;
		for(var i=0;i<N;i++){
			if(A[i]==0){
				ans++;
			}
		}
		Console.WriteLine(ans);
	}
}

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

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

	vector<string> vec(7);
	
	vec = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int i=0;
	for (i = 0; i < 7; i++) {
		if (S == vec.at(i)) {
			break;
		}
	}

	cout << 7 - i << endl;


}

Measured memory_bytes: 256
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
#include <cstdio>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;


int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    double a;
    while (cin >> a)
    {
        double b = a / 3;
        cout << fixed << setprecision(12)<< b * b * b << '\n';
    }

}



Measured memory_bytes: 256
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

k = int(input())
ans = -1
d = 7 % k
for i in range(1, k+10):
    if d == 0:
        ans = i
        break
    d = (10*d + 7) % k
print(ans)

Measured memory_bytes: 68096
#include<iostream>
#include<cstring>
#define ll long long
#define ld long double
using namespace std;
ll n;
ll ans=0;
ll a[100001][3];
ll dp[100001][3];
// try to find the max possible answer if a,b,c is done on nth day ,use dp;
// dp[n][0] = a[n]+max(dp[n-1][1],dp[n-1][2]); // write for each 0,1,2 states and find max;
void solve()
{
	dp[1][0]=a[1][0];
	dp[1][1]=a[1][1];
	dp[1][2]=a[1][2];
	for(ll i=2;i<=n;i++)
	{
	dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);	
	dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
	dp[i][2] = a[i][2] + max(dp[i-1][1],dp[i-1][0]);	
	}
	//cout<<a[n][0]<<" "<<a[n][1]<<" "<<a[n][2]<<endl;
	ans= max(max(dp[n][0],dp[n][1]) , dp[n][2] );	
}

int main()
{

cin>>n;
memset(dp,-1,sizeof(dp));
// ith point on ith day;
for(ll i=1;i<=n;i++)
{
// three type input;
	cin>>a[i][0]>>a[i][1]>>a[i][2];
}
ans=0;
solve();
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define mod 1000000007
#define endl '\n'
typedef long long int ll ;
using namespace std;
int main()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    int idx=-1; char ch;
    
    ll cnt=0;
    for(int i=0;i<n;i++){
        // cout<<cnt<<endl;
        if(idx==-1 ){
            ch=s[i];
            cnt++;
            idx=1;
            continue;
        }
        if(idx!=-1 && s[i]==ch) continue;
        else{
            ch=s[i];
            cnt++;
        }
        
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 512
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	int n;
	public void run() {
		n=sc.nextInt();
		while(n--!=0){
			int a1=0,a2=0;
			boolean ok=true;

			int[] vals=new int[10];
			for(int i=0;i<vals.length;i++){
				vals[i]=sc.nextInt();
			}
			for(int i=0;i<10;i++){
				int ball=vals[i];
				if(a1<ball){
					a1=ball;
				}else if(a2<ball){
					a2=ball;
				}else{
					ok=false;
					break;
				}
			}
			ln(ok?"YES":"NO");
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
n, a, b = map(int, input().split())
ans = set()
if a > b or not a == b and n <= 1:
  print(0)
elif a == b:
  print(1)
else:
  max = (n - 2) * b + a + b
  min = (n - 2) * a + a + b
  print(max - min + 1)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace Atcoder
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            string s = ReadText();
            string t = ReadText();

            if (s.Length > 10)
            {
                return "No";
            }
            else if (t.Length != s.Length + 1)
            {
                return "No";
            }
            else if (s != t.Substring(0, t.Length-1))
            {
                return "No";
            }

            return "Yes";
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }

        #endregion
    }

    public static class CastExtention
    {
        public static long ToLong(this string a) { return long.Parse(a); }
        public static int ToInt(this string a) { return int.Parse(a); }
    }
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	string s; cin >> s;
	int N = SZ(s);
	FOR(state, 0, 1 << (N - 1)) {
		LL ret = 0;
		LL sub = 0;
		FOR(i, 0, N - 1) {
			if (state & 1 << i) { //iのあとに'+'
				sub *= 10;
				sub += s[i] - '0';
				ret += sub;
				sub = 0;
			}
			else {
				sub *= 10;
				sub += s[i] - '0';
			}
		}
		sub *= 10;
		sub += s.back() - '0';
		ret += sub;
		ans += ret;
	}


	cout << ans << "\n";

	return 0;
}

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

#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i > b; --i)
#define REP(i, n)    for(uint i = 0; i < n; ++i)

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int abs(int x){
    return x > 0? x : -x;
}

int main(){
    int n; cin >> n;
    int A[n + 1];
    A[0] = 0;

    
    REP(i, n){
        cin >> A[i + 1];
    }
        int ans = 0;
        int now = 0;

        while(true){
            if(ans > 0 && now == 0){
                break;
            }
            ans += abs(A[now] - A[(now + 1) % (n + 1)]);
            now = (now + 1) % (n + 1);
        }

        INC(i, 1, n + 1){
            int out = ans;
            out += abs(A[i - 1] - A[(i + 1) % (n + 1)]) - abs(A[i] - A[(i + 1) % (n + 1)]) - abs(A[i - 1] - A[i]);
            cout << out << endl;
        }
    return 0;
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
static class Program{
	const int mod=(int)1e9+7;
	static List<int>[] li;
	static bool[] b;
	static int[] h,c,ans;
	static int n,g=1;
	static void Main(){
		Sc sc=new Sc();
		n=sc.I;
		li=new List<int>[n+1];
		b=new bool[n+1];
		ans=new int[n];
		for(int i=1;i<=n;i++){li[i]=new List<int>();}
		for(int i=1;i<n;i++){
			int[] e=sc.Ia;
			li[e[0]].Add(e[1]);
			li[e[1]].Add(e[0]);
		}
		c=sc.Ia;
		Array.Sort(c,(u,v)=>v-u);

		Fu(1);
		h=new int[n];
		ans[0]=c[0];
		Console.WriteLine("{0}",c.Sum()-c[0]);
		Console.WriteLine("{0}",String.Join(" ",ans));
	}
	static void Fu(int a){
		b[a]=true;
		for(int i=0;i<li[a].Count;i++){
			if(!b[li[a][i]]){
				ans[li[a][i]-1]=c[g];
				g++;
				Fu(li[a][i]);
			}
		}
	}
}


public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public string Sz{get{return Console.ReadLine();}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2(int b){return Array.ConvertAll((((b&1)!=0?"0 ":"")+Console.ReadLine()+((b&2)!=0?" 0":"")).Split(),int.Parse);}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return (Console.ReadLine()+" 0").Split();}}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 22076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dp[18][2];//dp[上から何桁][未満フラグ]
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    rep(i,18)rep(j,2)dp[i][j] = 0;
    rep(i,n)rep(j,2){
        int x = s[i] - '0';
        if( i == 0 && j == 1)continue;
        rep(d,10){
            int ni = i+1,nj = 0;
            
            if(j== 0 && d >x)continue;
            if(j || d < x)nj = 1;
            dp[ni][nj] = max(dp[ni][nj],dp[i][j]+d);

        }
        
    }
    
    cout << max(dp[n][1],dp[n][0]) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		int N = nextInt();
		int[] p = new int[N+1];
		for(int i=2;i<=N;i++) {
			TreeMap<Long,Long> map = primeFactorize(i);
			for(long key:map.keySet()) {
				if(key==1) {
					continue;
				}
				long val=map.get(key);
				p[(int)key]+=val;
			}
		}
		long ans = 1;
		for(int i=0;i<=N;i++) {
			if(p[i]!=0) {
				ans*=(p[i]+1);
				ans%=MOD;

			}
		}
		pw.println(ans);

	}

	public static TreeMap<Long, Long> primeFactorize(long N) {
		TreeMap<Long, Long> map = new TreeMap<>();
		for (long i = 2; i * i <= N; i++) {
			long k = 0;
			while (N % i == 0) {
				k++;
				N /= i;
			}
			if(k!=0) {
				map.put(i, k);
			}
		}
		map.put(N, 1L);
		return map;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



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


int main(){
  long long int N;
  vector<long long int> A(5);
  cin >> N;
  for(auto& a : A){
    cin >> a;
  }
  long long int min_occupy = *min_element(A.begin(), A.end());
  cout << 4 + N / min_occupy + (N % min_occupy == 0 ? 0 : 1) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from heapq import heappop
import heapq
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, K = MAP()
V = LIST()
V = deque(V)
 
# R = A + B
max_R = min(N, K)
# A, B 全探索
ans = 0
for R in range(1, max_R+1):
    for i in range(0, R+1):
        minus_count = 0
 
        v = deepcopy(V)
        pocket = []
        heapq.heapify(pocket)
        A = i
        B = R - i
        for a in range(A):
            a_pop = v.popleft()
            if a_pop < 0:
                minus_count += 1
            heappush(pocket, a_pop)
        for b in range(B):
            b_pop = v.pop()
            if b_pop < 0:
                minus_count += 1
            heappush(pocket, b_pop)
        dump = K - R
        dump_time = min(minus_count, dump)

        if dump_time > 0:
            for d in range(dump_time):
                x = heappop(pocket) 
 
        wa = sum(pocket)
        if ans <= wa:
            ans = wa
print(ans)
        

Measured memory_bytes: 5332
#include<bits/stdc++.h>
#define rep(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define drep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define MAGICLINE ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define se second
#define fs first
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, pair<int, int> > PII;
typedef priority_queue<PII,
                       vector<PII>,
                       greater<PII> > dijQ;

int Abs(int a){
    return a < 0 ? -a : a;
}

const int MN = 100002;
int T[MN], dist[MN];

int main(){
    int n; cin >> n;
    rep(i, 0, n) cin >> T[i];
    if(n == 2){
        cout << Abs(T[0] - T[1]);
        return 0;
    }

    dist[1] = Abs(T[0] - T[1]);
    rep(i, 2, n){
        dist[i] = min(dist[i-1]+Abs(T[i-1] - T[i]), dist[i-2]+Abs(T[i-2] - T[i]));
    }
    cout << dist[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;
typedef long long ll;

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


struct edge {
    ll to;
    ll cap;
    ll rev;
};

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

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(ll from,ll to,ll cap) {
    G[from].push_back((edge){to,cap,(ll)G[to].size()});
    G[to].push_back((edge){from,0,(ll)G[from].size() - 1});
}

ll dfs(ll v,ll t,ll f) {
    if(v == t)return f;
    used[v] = true;
    for(auto &e : G[v]) {
        if(!used[e.to] && e.cap>0) {
            ll d = dfs(e.to,t,min(f,e.cap));
            if(d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

ll max_flow(ll s,ll t) {
    ll flow = 0;
    for(;;) {
        fill(used,used+MAX_V,false);
        ll f = dfs(s,t,1e18);
        if(f == 0)break;
        flow += f;
    }
    return flow;
}
ll h,w;
char S[200][200];

ll id(ll i,ll j) {
    return i * w + j;
}
 
int main() {
    cin >> h >> w;
    rep(i,h)cin >> S[i];
    rep(i,h)rep(j,w) {
        rep(k,4) {
            ll y = dy[k] + i;
            ll x = dx[k] + j;

            if(y >= 0 && y < h && x >= 0 && x < w) {
                add_edge(id(i,j) + h * w,id(y,x),1e18);
            }
        }
    }

    ll s = h * w * 2;
    ll t = h * w * 2 + 1;

    rep(i,h)rep(j,w) {
        if(S[i][j] == 'X') {
            add_edge(s,id(i,j),1e18);
            add_edge(id(i,j),id(i,j) + h * w,1e18);
        }else {
            add_edge(id(i,j),id(i,j) + h * w,1);
        }
    }

    rep(i,h)rep(j,w) {
        if(i == 0 || i == h - 1 || j == 0 || j == w - 1) {
            if(S[i][j] == 'X') {
                cout << -1 << endl;
                return 0;
            }
            add_edge(id(i,j) + h * w,t,1e18);
        }
    }

    cout << max_flow(s,t) << endl;
}

Measured memory_bytes: 5760
def solve(dx, dy):
    a = 'U'*dy+'R'*dx
    b = 'D'*dy+'L'*dx
    c = 'L'+'U'*(dy+1)+'R'*(dx+1)+'D'
    d = 'R'+'D'*(dy+1)+'L'*(dx+1)+'U'
    return a+b+c+d


if __name__ == '__main__':
    sx, sy, tx, ty = map(int, input().split())
    dx = abs(tx-sx)
    dy = abs(ty-sy)
    print(solve(dx, dy))


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  string s[3];
  REP(i, 3){
    cin >> s[i];
  }
  cout << "A" << s[1][0] << "C" << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	string s;
	cin>>s;
	
	string t = "";
	
	for(int i=0;i<s.size();i++){
		if(s[i]!='x'){
			t += s[i];
		}
	}
	
	string tr = t;
	reverse(tr.begin(),tr.end());
	
	if(tr!=t){
		cout<<-1<<endl;
		return 0;
	}
	
	vector<int> cnt(1,0);
	
	for(int i=0;i<s.size();i++){
		if(s[i]=='x'){
			cnt.back()++;
		}
		else{
			cnt.push_back(0);
		}
	}
	
	int ans = 0;
	
	for(int i=0;i<cnt.size();i++){
		int m = max(cnt[i],cnt[cnt.size()-1-i]);
		ans += m-cnt[i];
		ans += m-cnt[cnt.size()-1-i];
		cnt[i] = m;
		cnt[cnt.size()-1-i] = m;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if (r <= x && x <= W-r && r <= y && y <= H-r) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}


Measured memory_bytes: 3160
#include<stdio.h>
int main (void)
{
  int n;
  scanf("%d",&n);
  int a[n];
  double sum=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum+=(double)1.0/a[i];
  }
  printf("%f",(double)1.0/sum);
  return 0;
}


Measured memory_bytes: 128