akhauriyash/Code-Regression huggingface dataset:
// Problem : C - Tsundoku
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n,m,t;
    cin>>n>>m>>t;
    vi a(n),b(m);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<m;i++) cin>>b[i];
    for(int i=1;i<n;i++) a[i] += a[i-1];
    for(int i=1;i<m;i++) b[i] += b[i-1];
    int ans = 0;
    for(int i=0;i<n;i++){
        if(a[i] > t) break;
        int rem = t-a[i];
        int j = upper_bound(all(b),rem) - b.begin();
        j--;
        ans = max(ans,i+j+2);
    }
    for(int i=0;i<m;i++){
        if(b[i] > t) break;
        int rem = t-b[i];
        int j = upper_bound(all(a),rem) - a.begin();
        j--;
        ans = max(ans,i+j+2);
    }
    cout<<ans<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6344
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    
    while((a>0) && (c>0)){
      a -= d;
      c -= b;
    }
    
    if(c>0){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    }
  }
}
    

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    long long int num=0;
    unsigned long long int sum=0;
    vector<long long int> te(0);
    vector<vector<long long int>> vecvec;
    vecvec.push_back(te);
    long long int ab=0;
    while(num<pow(2,s.size())){
        vector<long long int> vec;
        bitset<11> bit(num);
        long long int tes=0;
        for(int i=0;i<s.size();++i){
            if(bit[i]){
                vec.push_back(atoll(s.substr(tes,i-tes+1).c_str()));
                tes=i+1;
            }
        }
        if(!bit[s.size()-1])vec.push_back(atoll(s.substr(tes).c_str()));
        if(find(vecvec.begin(),vecvec.end(),vec)==vecvec.end()){
            sum+=std::accumulate(vec.begin(),vec.end(),0LL);
       //     for(auto&m:vec)cout<<m<<" ";cout<<sum<<endl;ab++;
            vecvec.pop_back();
            vecvec.push_back(vec);
            vecvec.push_back(te);
        }
        ++num;

    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer points[] = new Integer[n+1];
        for(int i=0; i<n+1; i++){
            points[i] = sc.nextInt();
        }
        Arrays.sort(points, Collections.reverseOrder());
        int intervals[] = new int[n];
        for(int i=1; i<n+1; i++){
            intervals[i-1] = points[i-1] - points[i];
        }
        int ans = gcd(intervals);
        System.out.println(ans);
    }

    public static int gcd(int a, int b){
        if(a < b){
            int swap = a;
            a = b;
            b = swap;
        }
        int r;
        while((r = a % b) != 0){
            a = b;
            b = r;
        }
        return b;
    }

    public static int gcd(int array[]){
        int g = array[0];
        for(int value : array){
            g = gcd(g, value);
        }
        return g;
    }
}

Measured memory_bytes: 61960
#ifndef CLASS_MODINT
#define CLASS_MODINT

#include <cstdint>

template<std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::int64_t n_) : n((n_ >= 0 ? n_ : mod - (-n_) % mod) % mod) {};
	static constexpr std::uint32_t get_mod() { return mod; }
	std::uint32_t get() const { return n; }
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint inv() const { return (*this).pow(mod - 2); }
	modint pow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
};

#endif // CLASS_MODINT

#include <vector>
#include <iostream>
#include <functional>
using namespace std;
using modulo = modint<1000000007>;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	vector<modulo> harmony(N + 1);
	for (int i = 1; i <= N; ++i) harmony[i] = harmony[i - 1] + modulo(i).inv();
	modulo ans = 0;
	for (int i = 0; i < N; ++i) {
		ans += (harmony[i + 1] + harmony[N - i] - 1) * A[i];
	}
	for (int i = 1; i <= N; ++i) ans *= i;
	cout << ans.get() << endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] nq = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nq[0];
        var q = nq[1];

        var list = new List<List<int>>();
        for (int i = 0; i < n; i++)
        {
            list.Add(new List<int>());
        }

        for (int i = 0; i < n - 1; i++)
        {
            int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            list[tmp[0] - 1].Add(tmp[1] - 1);
            list[tmp[1] - 1].Add(tmp[0] - 1);
        }

        int[] p = new int[q];
        int[] x = new int[q];
        for (int i = 0; i < q; i++)
        {
            int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            p[i] = tmp[0];
            x[i] = tmp[1];
        }

        bool[] visited = new bool[n];
        long[] ans = new long[n];
        for (int i = 0; i < q; i++)
        {
            ans[p[i] - 1] += x[i];
        }

        var que = new Queue<int>();
        que.Enqueue(0);
        while (que.Count > 0)
        {
            var c = que.Dequeue();
            visited[c] = true;
            for (int k = 0; k < list[c].Count; k++)
            {
                if (!visited[list[c][k]])
                {
                    que.Enqueue(list[c][k]);
                    ans[list[c][k]] += ans[c];
                }
            }
        }


        // 出力
        foreach (var item in ans)
        {
            Console.Write(item + " ");
        }
    }
}

Measured memory_bytes: 45088
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = Integer.parseInt(scanner.next());
        int B = Integer.parseInt(scanner.next());
        scanner.close();

        int price = 0;
        if (A >= 13) {
            price = B;
        } else if (A >= 6) {
            price = B /2;
        }

        System.out.println(price);
    }
}


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

int main(){
    int64_t N,A,B;
    cin >> N >> A >> B;
    int64_t total = 0;
    for(int i = 0;i < N/(A+B);i++){
        total += A;
    }
    if(N%(A+B) >=A){
        total += A;
    }
    else {
        total += N%(A+B);
    }
    cout << total << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;

int n;
int a[MAXN];
vector<int> gph[MAXN];
int par[MAXN];

int DOWN(int x, int thr, int c){
	while(x > 1 && c){
		x = (x + thr - 1) / thr;
		c--;
	}
	return x;
}

int dfs(int x, int thr){
	vector<pi> v;
	if(gph[x].empty()) v.emplace_back(0, 1);
	for(auto &i : gph[x]) v.emplace_back(a[i] - a[x], dfs(i, thr));
	int prv = 2e9;
	int cursum = 0;
	for(int i=0; i<v.size(); ){
		int e = i;
		while(e < v.size() && v[i].first == v[e].first) e++;
		cursum = DOWN(cursum, thr, prv - v[i].first);
		prv = v[i].first;
		for(int j=i; j<e; j++){
			cursum += v[j].second;
		}
		i = e;
	}
	return DOWN(cursum, thr, v.back().first);
}

bool trial(int m){
	if(m == 1){
		for(int i=1; i<n; i++){
			if(a[i] >= a[i+1]) return 0;
		}
		return 1;
	}
	vector<pi> stk;
	stk.emplace_back(0, 0);
	for(int i=1; i<=n; i++){
		int cnt = 0;
		while(!stk.empty() && stk.back().first >= a[i]){
			stk.pop_back();
		}
		par[i] = stk.back().second;
		stk.push_back(pi(a[i], i));
	}
	for(int i=0; i<=n; i++) gph[i].clear();
	for(int i=1; i<=n; i++){
		gph[par[i]].push_back(i);
	}
	return dfs(0, m) <= 1;
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d", &a[i]);
	int s = 1, e = n;
	while(s != e){
		int m = (s+e)/2;
		if(trial(m)) e = m;
		else s = m + 1;
	}
	cout << s << endl;
}


Measured memory_bytes: 41404
#include<iostream>
#include<cmath>
#include <vector>
using namespace std;

int main(){

  int a = 0;
  int b = 0;
  cin >> a >> b;

  int as = 0;
  int bs = 0;

  for (int i = 0; i < b; i++) {
    as += a * pow(10, i);
  }

  for (int i = 0; i < a; i++) {
    bs += b * pow(10, i);
  }

  if (as > bs) {
    cout << as << endl;
  } else {
    cout << bs << endl;
  }

  return 0;
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;

int N, U, V, M;
struct bingo {
	map<int, int>wmp;
	map<int, int>hmp;
	set<int>slant00mp;
	set<int>slant0nmp;
	vector<int>wnum;
	vector<int>hnum;
	int slant00num;
	int slant0nnum;
	int ans;
	int need;
	bingo(int n,int need_):wnum(n),hnum(n){
		need = need_;
		slant00num = 0;
		slant0nnum=0;
		ans = 0;
	}
	bool fill(int a) {
		if (wmp.count(a)) {
			wnum[wmp[a]]++;
			if (wnum[wmp[a]] == N)ans++;
		}
		if (hmp.count(a)) {
			hnum[hmp[a]]++;
			if (hnum[hmp[a]] == N)ans++;
		}
		if (slant00mp.count(a)) {
			slant00num++;
			if (slant00num == N)ans++;
		}
		if (slant0nmp.count(a)) {
			slant0nnum++;
			if (slant0nnum == N)ans++;
		}
		if (N == 1)ans = min(ans, 1);
		return need <= ans;
	}
};
int main() {cin >> N >> U >> V >> M;
	vector<bingo>bingos;
	bingos.push_back(bingo(N, U));
	bingos.push_back(bingo(N, V));
	for (int k = 0; k < 2; ++k) {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				int a; cin >> a;
				bingos[k].wmp[a] = i;
				bingos[k].hmp[a] = j;
				if (i == j)bingos[k].slant00mp.emplace(a);
				if (i + j == N - 1)bingos[k].slant0nmp.emplace(a);
			}
		}
	}
	while (M--) {
		int a; cin >> a;
		if (bingos[0].fill(a)) {
			if (bingos[1].fill(a)) {
				cout << "DRAW" << endl;
				return 0;
			}
			else {
				cout << "USAGI" << endl;
				return 0;
			}
		}
		else {
			if (bingos[1].fill(a)) {
				cout << "NEKO" << endl;
				return 0;
			}
			else {
				
			}
		}
	}
	cout << "DRAW" << endl;
	return 0;
}

Measured memory_bytes: 30084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int H, W;
  cin >> H >> W;
  
  //1行目
  for (int i = 0; i < W+2; i++){
    cout << "#" ;
  }
  cout << endl;
  
  //最後の手前まで
  for (int i = 0; i < H; i++){
    string mozi;
    cin >> mozi;
    cout << "#" << mozi << "#" << endl;
  }
  
  //最後
  for (int i = 0; i < W+2; i++){
    cout << "#" ;
  }
  cout << endl;
}


Measured memory_bytes: 256
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def main():
    X=int(input())
    while True:
        if is_prime(X):
            print(X)
            return
        else:
            X+=1
        

main()


Measured memory_bytes: 3060
def int_raw():
    return int(input())


def ss_raw():
    return raw_input().split()


def ints_raw():
    return list(map(int, ss_raw()))


N, K = ints_raw()
S = [int(s) for s in raw_input()]
current = S[0]
count = 0
stand_array = []
reverse_array = []
if current == 0:
    reverse_array.append(0)
for s in S:
    if s == current:
        count += 1
    else:
        if current == 1:
            reverse_array.append(count)
        else:
            stand_array.append(count)
        count = 1
        current = 1 - current
if current == 1:
    reverse_array.append(count)
else:
    stand_array.append(count)
if current == 0:
    reverse_array.append(0)

if len(stand_array) <= K:
    print(N)
else:
    max_score = 0
    score = 0
    for i in range(K):
        score += stand_array[i]
        score += reverse_array[i]
    score += reverse_array[K]
    max_score = score
    for i in range(len(stand_array) - K):
        score -= stand_array[i]
        score -= reverse_array[i]
        score += stand_array[i + K]
        score += reverse_array[i + K + 1]
        max_score = max(score, max_score)
    print(max_score)


Measured memory_bytes: 5828
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

    int count = 0;
    for (const char c: S) if (c == 'x') count++;

    if (count < 8) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n; std::cin >> n;
	std::vector<std::vector<std::pair<int, int>>> testinomial(n);
	for (auto& t : testinomial) {
		int a; std::cin >> a;
		t.resize(a);
		for (auto& p : t) {
			std::cin >> p.first >> p.second;
			--p.first;
		}
	}
	int max_count = 0;
	for (auto pattern = 0; pattern < (1 << n); ++pattern) {
		bool is_possible = true;
		for (auto i = 0; i < n && is_possible; ++i) if ((pattern & (1 << i)) != 0) {
			for (auto& p : testinomial[i]) {
				switch (p.second) {
				case 0: 
					if ((pattern & (1 << p.first)) != 0) {
						is_possible = false;
					}
					break;
				case 1:
					if ((pattern & (1 << p.first)) == 0) {
						is_possible = false;
					}
					break;
				default: throw 0;
				}
			}
		}
		if (is_possible) {
			int count = 0;
			for (auto i = 0; i < n; ++i) if ((pattern & (1 << i)) != 0) {
				++count;
			}
			max_count = std::max(max_count, count);
		}
	}
	std::cout << max_count << std::endl;
}

Measured memory_bytes: 888
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    bool[][] G;
    G.length = N;
    foreach (i; 0..N) {
        G[i].length = N;
        foreach (j, x; readln.chomp) {
            if (x == '1') G[i][j] = true;
        }
    }

    auto S = new int[](N);
    bool check(int i, int p, int s) {
        if (S[i]) return S[i] == s;
        S[i] = s;
        foreach (j, n; G[i]) if (n && i != j && j != p) {
            if (check(j.to!int, i, s%2+1) == false) return false;
        }
        return true;
    }
    if (check(0, -1, 1) == false) {
        writeln(-1);
        return;
    }

    auto M = new int[][](N, N);
    foreach (i; 0..N) {
        foreach (j, c; G[i]) {
            if (i == j) continue;
            if (c) {
                M[i][j] = 1;
                M[j][i] = 1;
            } else {
                M[i][j] = int.max / 3;
                M[j][i] = int.max / 3;
            }
        }
    }
    foreach (k; 0..N) {
        foreach (i; 0..N) {
            foreach (j; 0..N) {
                if (M[i][j] > M[i][k] + M[k][j]) {
                    M[i][j] = M[i][k] + M[k][j];
                }
            }
        }
    }
    int r;
    foreach (i; 0..N) foreach (j; 0..N) r = max(r, M[i][j]);
    writeln(r+1);
}

Measured memory_bytes: 636
o[256],z[257];main(N,S,A,C,s,a,c,r,i){for(;scanf("%d",&N),N;printf("%d %d %d\n",S,A,C)){
	double H=99999,h,n=N;
	for(i=1;i<=N;i++)scanf("%d",z+i);
	for(s=0;s<16;s++)for(a=0;a<16;a++)for(c=0;c<16;c++){
		for(r=s,h=0,i=1;i<=N;i++)o[(z[i]+(r=(a*r+c)%256))%256]++;
		for(i=0;i<256;i++)if(o[i])h-=o[i]/n*log(o[i]/n),o[i]=0;
		if(h+1e-9<H)H=h,S=s,A=a,C=c;
	}
}exit(0);}

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

using namespace std;

int main()
{
    int N;
    cin>>N;
    long long arr[N][3],ans[N][3];
    for(int i=0;i<N;i++)
    {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    ans[0][0] = arr[0][0],ans[0][1]=arr[0][1],ans[0][2]=arr[0][2];
    for(int i=1;i<N;i++)
    {
        ans[i][0] = max(ans[i-1][1],ans[i-1][2]) + arr[i][0];
        ans[i][1] = max(ans[i-1][0],ans[i-1][2]) + arr[i][1];
        ans[i][2] = max(ans[i-1][0],ans[i-1][1]) + arr[i][2];
    }
    cout<<max(max(ans[N-1][0],ans[N-1][1]),ans[N-1][2]);
  return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define INF 1e9
typedef long long LL;

int main() {
  LL W, H, x, y;
  cin >> W >> H >> x >> y;
  int answer = 0;
  if (2*x==W && 2*y == H) answer = 1;
  
  cout << double(W*H)/2 << ' ' << answer << endl;
  
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n; cin >> n;
    printf("%lld:",n);

    for (ll i = 2; i < 100100; i++) {
        if(n%i == 0){
            printf(" %lld", i);
            n/=i;
            i=1;
        }
        if(i==100099&&n!=1) cout<<" "<<n;
    }
 
    cout<<endl;

    return 0;
}


Measured memory_bytes: 3216
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		Integer[] A = new Integer[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}
		sc.close();
		if(N<=K) {
			System.out.println(0);
			return;
		}
		Arrays.sort(A,  Collections.reverseOrder());
		long s = 0;
		for(int i=K; i<N; i++) {
				s += A[i];
		}
		System.out.println(s);
	}

}

Measured memory_bytes: 92520
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int t,p,r;
	while(cin>>t>>p>>r){
		if(t==0&&p==0&&r==0) break;
		int tid,pid,time,wa[t+1][p+1],ac[t+1],pen[t+1];
		for(int i=0;i<=t;i++){
			pen[i]=0;
			ac[i]=0;
			for(int j=0;j<=p;j++){
				wa[i][j]=0;
			}
		}
		string m;
		for(int i=0;i<r;i++){
			cin>>tid>>pid>>time>>m;
			if(m=="WRONG"){
				wa[tid][pid]++;
			}
			else if(m=="CORRECT"){
				ac[tid]++;
				pen[tid]=pen[tid]+wa[tid][pid]*1200+time;
				wa[tid][pid]=0;
			}
		}
		for(int n=1;n<=t;n++){
			int acmax=-1,penmin,maxteam=0;
			for(int i=1;i<=t;i++){
				if(acmax<ac[i]){
					maxteam=i;
					acmax=ac[i];
					penmin=pen[i];
				}
				else if(acmax==ac[i]&&pen[i]<penmin){
					maxteam=i;
					penmin=pen[i];
				}
			}
			cout<<maxteam<<" "<<ac[maxteam]<<" "<<pen[maxteam]<<endl;
			ac[maxteam]=-2;
		}
	}
    return 0;
}

Measured memory_bytes: 1216
//BROWNIE TK

#include <bits/stdc++.h>

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define forzm(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

using namespace std;

/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{
    return a * b / gcd(a, b);
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
/*CODE BEGINS*/
int main()
{
    kira;
    ldb l;
    cin>>l;
    ldb x=l/ldb(3);
    cout<<deci(10)<<pow(x,ldb(3));
    return 0;
}

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

int p(int a){
    if(a<0){
        a=-a;
    }
    return a;
}

int main()
{
    int n,check=0,oldx=0,oldy=0,oldt=0;
    int x[100000],y[100000],t[100000];
    cin >> n;
    for(int i=0;i<n;i++){
        if(i!=0){
            oldx=x[i-1];
            oldy=y[i-1];
            oldt=t[i-1];
        }
        cin >> t[i] >> x[i] >> y[i];
        if((t[i]-oldt)<((p(x[i]-oldx)+(p(y[i]-oldy))))){
            check=1;
        }else{
            if((t[i]-oldt)%2){
                if((p(x[i]-oldx)+p(y[i]-oldy))%2==0){
                    check=1;
                }
            }else{
                if((p(x[i]-oldx)+p(y[i]-oldy))%2){
                    check=1;
                }
            }
        }

    }
    if(check){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  LL vmin = 1e18;
  LL sum = 0;
  int neg_cnt = 0;
  for (int i = 0; i < N; ++i) {
    LL a; cin >> a;
    if (a < 0) {
      ++neg_cnt;
      a = -a;
    }
    vmin = min(vmin, a);
    sum += a;
  }

  if (neg_cnt % 2 == 1) {
    sum -= 2 * vmin;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3604
import java.io.*;
import java.util.*;
public class Main {
    private static MyScanner scanner;
    private List<Integer> T;

    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }

    private void solve() {
        try {
            int N = scanner.nextInt();
            int C = scanner.nextInt();
            int K = scanner.nextInt();
            T = new ArrayList<Integer>();
            for (int i = 0; i < N; i++) {
                T.add(scanner.nextInt());
            }
            Collections.sort(T);
            int count = 0;
            while (T.size() > 0) {
                int max = T.get(0) + K;
                int index = 0;
                while (index < T.size() && T.get(index) <= max) {
                    index++;
                }
                //System.out.println(index + " " + T.size());
                if (index < C) {
                    for (int i = 0; i < index; i++) {
                        T.remove(0);
                    }
                } else {
                    for (int i = 0; i < C; i++) {
                        T.remove(0);
                    }
                }
                count++;
            }
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 41396
h,w = map(int,input().split())
a = [list(input()) for nesya in range(h)]
c = 0
for i in range(h):
  for j in range(w):
    if a[i][j] == '#':
      c += 1

if c == h+w-1:
  print('Possible')
else:
  print('Impossible')

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"os"
	"sort"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)

	count := map[int]int{}
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scanf("%d %d", &a, &b)
		count[a] += b
	}

	nums := []int{}
	for i, _ := range count {
		nums = append(nums, i)
	}

	sort.Ints(nums)

	sum := 0
	for _, i := range nums {
		sum += count[i]
		if sum >= k {
			fmt.Printf("%d\n", i)
			os.Exit(0)
		}
	}
}


Measured memory_bytes: 9004
#include  <iostream>
#include  <cstdlib>
#include  <algorithm>

using namespace std;

int main()
{
	int n;
	int w[100];

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> w[i];

	int aw[100] = { 0 };
	for (int t = 0; t < n - 1; t++) {
		int s1 = 0;
		int s2 = 0;
		for (int k = 0; k <= t; k++) 
			s1 += w[k];
		for (int k = n - 1; k > t; k--)
			s2 += w[k];

		aw[t] = abs(s1 - s2);
	}

	int ans = aw[0];
	for (int i = 1; i < n - 1; i++) {
		ans = min(ans, aw[i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  string s;
  cin >> s;
  ll n = s.size();

  for (ll i = 0; i < n / 2; i++) {
    s.pop_back();
    s.pop_back();
    for (ll j = 0; j < s.size() / 2; j++) {
      if (s[j] != s[j + s.size() / 2]) break;
      if (j == s.size() / 2 - 1) {
        cout << s.size() << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;


//ここから

void solve(){
  int n,k;
  cin>>n>>k;
  k--;
  string s;
  cin>>s;
  s[k]+=32;
  cout<<s;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func calc(numA int, numB int, op rune) (ans int) {
	switch op {
	case '+':
		ans = numA + numB
	case '-':
		ans = numA - numB
	case '*':
		ans = numA * numB
	case '/':
		ans = numA / numB
	}
	return
}
func main() {
	var numA, numB int
	var op rune

	for {
		fmt.Scanf("%d %c %d\n", &numA, &op, &numB)
		if op == '?' {
			break
		}
		fmt.Println(calc(numA, numB, op))
	}
}



Measured memory_bytes: 1120
#include<cstdio>
#include<cctype>
 
int main(){
 char ch;
  
 while(1){
 scanf("%c", &ch);
 if ( isalpha(ch) ){
  if ( islower(ch) ) printf("%c", toupper(ch));
  else printf("%c", tolower(ch));
 } else printf("%c", ch);
  
  if( ch == '\n' ) break;
}
 
return 0;
}


Measured memory_bytes: 2572
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int A = max(a, max(b, c));
	int C = min(a, min(b, c));
	int B = a + b + c - A - C;
	cout << A * 10 + B + C << endl;
}


Measured memory_bytes: 256
//omajinai
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
//omajinai

signed main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int x;
    cin >> x;

    int a,b;
    a = x / 100;
    b = x % 100;

    if(x < 100){
        cout << 0 << endl;
        return 0;
    }

    if(a * 5 >= b){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

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

using namespace std;

int main() {
  string a, b, c; cin >> a >> b >> c;
  if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/agc007/tasks/agc007_a
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_ints(): return list(map(int, read().split()))


def read_map_as(H, replace={'#': 1, '.': 0}, pad=None):
    '''
    文字列のmapを置換して読み込み。デフォでは#→1,.→0
    '''
    if pad is None:
        ret = []
        for _ in range(H):
            ret.append([replace[s] for s in read()[:-1]])
            # 内包表記はpypyでは若干遅いことに注意
            # #numpy使うだろうからこれを残しておくけど
    else:  # paddingする
        ret = [[pad] * (W + 2)]  # Wはどっかで定義しておくことに注意
        for _ in range(H):
            ret.append([pad] + [replace[s] for s in read()[:-1]] + [pad])
        ret.append([pad] * (W + 2))

    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

# 常に右、下に動いていたなら、経路は一つに決まる。
# →#をたどってそれ以外に#があるかを判別すれば良い
H, W = read_ints()
A = read_map_as(H)
i, j = 0, 0
A[i][j] = 0
while i != H - 1 or j != W - 1:
    if i + 1 < H and j + 1 < W and A[i + 1][j] and A[i][j + 1]:
        print('Impossible')
        exit()
    ni = i
    nj = j
    if i + 1 < H and A[i + 1][j]:
        ni = i + 1
    if j + 1 < W and A[i][j + 1]:
        nj = j + 1
    if ni == i and nj == j:
        print('Impossible')
        exit()
    A[ni][nj] = 0  # 簡単のために0を埋めておく
    i, j = ni, nj

res = reduce(add, reduce(add, A))
# print(*A, sep='\n')
# print(res)
print('Possible' if res == 0 else 'Impossible')


Measured memory_bytes: 68688
#include<bits/stdc++.h>
using ll= long long;
using  INT = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*........................................DEFINE FUNCTIONS.........................................*/


/*....................................DEFINE GLOBAL VARIABLES .....................................*/



/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);


	int N;
	cin>>N;
	int ans=0;

	REP(i,N){
		int a;
		cin>>a;
		while(a%2==0){
			a/=2;
			ans++;
		}
	}

	cout<<ans<<endl;









		

		return 0;
}













Measured memory_bytes: 3604
n, x = map(int, input().split())

ans = n

wall_side = n - x
light_length = n - (n - x)
while True:
    if wall_side % light_length == 0:
        ans += (2 * (wall_side // light_length - 1) + 1) * light_length
        break
    else:
        ans += 2 * (wall_side // light_length) * light_length
        wall_side, light_length = light_length, wall_side % light_length
        

print(ans)



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

int main(){
   bool flag=false;
   int n;
   scanf("%d",&n);
   while(n){
    if(n%10==7){
        flag=true;
        break;
    }
    n/=10;
   }
   printf("%s",flag?"Yes":"No");
   return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
//#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
#define MAXN 200100
using namespace std;
typedef vector<int> vi;
typedef set<int> se;
typedef pair<int,int> pii;
inline int mod(int n, int m){
int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}



int pre[MAXN];
int suf[MAXN];
int ans[MAXN];

int32_t main(){
	fastio;
 	string s;
 	cin>>s;
 	pre[0]=1;
 	int n = s.size();
	for(int i=0;i<n;i++){
		pre[i+1]=pre[i];
		if(s[i]=='R')pre[i+1]=i+1;
	}
 	suf[n+1]=n;
 	for(int i=n;i>=1;i--){
		 suf[i]=suf[i+1];
		 if(s[i-1]=='L')suf[i]=i;
	 }
 
 	 for(int i=1;i<=n;i++){
	   if(s[i-1]=='L'){
		   int pos = pre[i];
		   int dist = i-pos;
		   if(dist&1){
			   ans[pos+1]++;
		   }else ans[pos]++;
	   }else{
		   int pos = suf[i];
		   int dist = pos-i;
		   if(dist&1){
			   ans[pos-1]++;
		   }else ans[pos]++;
	   }		 	  
	}
 	for(int i=1;i<=n;i++)cout<<ans[i]<<" ";
 		cout<<endl;
}

Measured memory_bytes: 1872
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define DEBUG

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
int main(){
    ll N,M;
    cin>>N>>M;
    
    int max=0,min=INF;
    REP(i,M){
        int a,z;
        cin>>a>>z;
        if(max<a)max=a;
        if(min>z)min=z;
        //cout<<max<<min<<endl;
    }
    if(min-max+1<=0)cout<<0;
    else cout<<min-max+1;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 2019;

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

    int L, R;
    cin >> L >> R;

    int diff = R - L;
    L %= 2019;
    R %= 2019;

    if (L == 0 || L + diff >= 2019) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 2019;
    rep(i, L, R) {
        rep(j, i + 1, R + 1) { ans = min(ans, (i * j) % 2019); }
    }
    cout << ans << endl;

    return 0;
}

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

vector<vector<string>> ptn = {
{
  ".###",
  ".#.#",
  ".#.#",
  ".#.#",
  ".###",
},
{
  "..#.",
  ".##.",
  "..#.",
  "..#.",
  ".###",
},
{
  ".###",
  "...#",
  ".###",
  ".#..",
  ".###",
},
{
  ".###",
  "...#",
  ".###",
  "...#",
  ".###",
},
{
  ".#.#",
  ".#.#",
  ".###",
  "...#",
  "...#",
},
{
  ".###",
  ".#..",
  ".###",
  "...#",
  ".###",
},
{
  ".###",
  ".#..",
  ".###",
  ".#.#",
  ".###",
},
{
  ".###",
  "...#",
  "...#",
  "...#",
  "...#",
},
{
  ".###",
  ".#.#",
  ".###",
  ".#.#",
  ".###",
},
{
  ".###",
  ".#.#",
  ".###",
  "...#",
  ".###", 
}
};

int main(){

  int64_t n;
  cin>>n;

  int64_t min_wk=1000000000000001;
  for(int i=0;i<5;i++){
    int64_t wk;
    cin>>wk;
    min_wk=min(min_wk,wk);
  }


  cout << std::fixed << std::setprecision(0)<<5+ceil((long double)n/(long double)min_wk-1)<<endl;

  return 0;

}


Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int K = Integer.parseInt(st.nextToken());
         String input = infile.readLine();
         char[] arr = input.toCharArray();
         int res = 0;
         for(int i=1; i < N-1; i++)
         {
            if(arr[i] == 'L' && arr[i-1] == 'L') 
               res++;
            else if(arr[i] == 'R' && arr[i+1] == 'R') 
               res++;
         }
         if(N >= 2)
         {
            if(arr[0] == 'R' && arr[1] == 'R')
               res++;
            if(arr[N-1] == 'L' && arr[N-2] == 'L')
               res++;
         }
         ArrayList<Character> ls = new ArrayList<Character>();
         char curr = arr[0];
         for(int i=1; i < N; i++)
            if(curr != arr[i])
            {
               ls.add(curr);
               curr = arr[i];
            } 
         ls.add(curr);
         for(int i=1; i < ls.size()-1; i+=2)
         {
            if(K == 0)
               break;
            res += 2;
            K--;
         }
         if(K > 0 && ls.get(0) != ls.get(ls.size()-1))
            res++;
         System.out.println(res);
      }
   }

Measured memory_bytes: 27092
package main
import "fmt"

func main() {
	var a int
  	fmt.Scan(&a)
  	if a % 2 == 0 {
      fmt.Println((a/2) * (a/2))
    } else {
      fmt.Println((a-1)/2 * ((a-1)/2 + 1))
    }
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
  int n;
  int a,b,c,d;
  while(cin >> n){
    int ans = 0;
    for(a=0; a<10; a++){
      for(b=0; b<10; b++){
	for(c=0; c<10; c++){
	  for(d=0; d<10; d++){
	    if((a+b+c+d) == n) ans++;
	  }
	}
      }
    }
  cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
using namespace std;

int main(){
	ll h,w;
	cin >> h >> w;
	char grid[h+1][w+1];
	ll dp[h+1][w+1];
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin >> grid[i][j];
			dp[i][j]=0;
		}
	}
	for(int i=1;i<=w;i++){
		if(grid[1][i]=='.'){
			dp[1][i]=1;
		}
		else{
			break;
		}
	}
	for(int i=1;i<=h;i++){
		if(grid[i][1]=='.'){
			dp[i][1]=1;
		}
		else{
			break;
		}
	}
	for(int i=2;i<=h;i++){
		for(int j=2;j<=w;j++){
			if(grid[i][j]=='.'){
				dp[i][j] = ((dp[i-1][j])%MOD + (dp[i][j-1])%MOD)%MOD;
			}
			else{
				dp[i][j] = 0;
			}
		}
	}
	cout << dp[h][w] << endl;
}

Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<int> list = (Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList());
            list.Reverse();
            string s = "";
            foreach (int i in list)
            {
                s += " " + i.ToString();
            }
            s = s.Remove(0, 1);
            Console.WriteLine(s);
        }
    }
}


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

int main(){
    int A,B,K;
    cin >> A >> B >> K;
    int i = 1;
    int C = min(A , B);
    while (i <= K && C >= 0){
        if (A % C == 0 && B % C == 0){
            i++;
            C--;
        }
        else{
            C--;
        }
    }
    cout << C + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define INF 1ll<<60
using namespace std;
signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  string a;
  cin>>a;
  bool hard=false;
  for(int i=0;i<a.size()-1;i++){
    if(a[i]==a[i+1])
      hard=true;
  }
  if(hard)
    cout<<"Bad"<<endl;
  else
    cout<<"Good"<<endl;
  return 0;
}


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

#define ll long long int
#define absdiff(a,b) (a>b)?a-b:b-a
#define mp make_pair 
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"
const ll ll_MAX = 19223372036859;
const ll MOD = 1e9 + 7;
ll fast_expo(ll x,ll p){if(p==0) return 1;
    else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} 
    else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  
    else return gcd(b%a,a); }

ll dp[10001][101][2];
string str;
ll d, ans = 0;

ll find(ll pos, bool f, ll sum){
    if(dp[pos][sum][f] != -1) 
        return dp[pos][sum][f];

    if(pos == str.size()){
        if(sum % d == 0)
            return 1;
        return 0;
    }

    dp[pos][sum][f] = 0;   
    if(f){
        ll val = str[pos] - '0';
        for(ll i = 0; i < val; ++i){
            dp[pos][sum][f] += find(pos+1, false, (sum-i+10*d)%d);
            dp[pos][sum][f] %= MOD;
        }
        dp[pos][sum][f] += find(pos+1, true, (sum-val+d)%d);
        dp[pos][sum][f] %= MOD;
    } else {
        for(ll i = 0; i < 10; ++i){
            dp[pos][sum][f] += find(pos+1, false, (sum-i+10*d)%d);
            dp[pos][sum][f] %= MOD;
        }
    }
    return dp[pos][sum][f];
}

int main()
{
    // fast
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ll t_c; t_c = 1;
    // cin >> t_c;
    for(ll t_i=0; t_i<t_c; ++t_i){
        memset(dp, -1, sizeof(dp));
        cin >> str;
        cin >> d;
            
        cout << (find(0, true, 0)-1+MOD)%MOD;     
    }  
    return 0;
}

Measured memory_bytes: 17024