akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);

	if(a + b + c >= 22) printf("bust\n");
	else printf("win\n");
	return 0;
}


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

int main(){
  int card1[200],card2[200];
  int n,m;
  cin>> n>> m;
  int n2=n*2;
  for(int i=0;i<n2;i++){
    card1[i]=i+1;
  }
  for(int i=0;i<m;i++){
    int k;
    cin>> k;
    if(k==0){
      for(int j=0;j<n2;j++){
	card2[j]=card1[j];
      }
      for(int j=0;j<n;j++){
	card1[j*2]=card2[j];
      }
      for(int j=0;j<n;j++){
	card1[j*2+1]=card2[j+n];
      }
    }
    else{
      for(int j=0;j<n2;j++){
	card2[j]=card1[j];
      }
      for(int j=0;j<n2-k;j++){
	card1[j]=card2[k+j];
      }
      for(int j=0;j<k;j++){
	card1[j+n2-k]=card2[j];
      }
    }
  }

  for(int i=0;i<n2;i++){
    cout<< card1[i]<< endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int h,w;
    cin>>h>>w;
    string m[50];
    rep(i,h){
        cin>>m[i];
    }
    char ans[h][w];
    rep(i,h){
        rep(j,w){
            if(m[i][j]=='#'){
                ans[i][j]='#';
                continue;
            }
            int count=0;
            for(int k=-1;k<2;k++){
                for(int l=-1;l<2;l++){
                    if(k==0&&l==0) continue;
                    if((i+k<0)||(i+k>=h)||(j+l<0)||(j+l>=w)) continue;
                    if(m[i+k][j+l]=='#') count++;
                }
            }
            ans[i][j]='0'+count;
        }
    }
    rep(i,h){rep(j,w){cout<<ans[i][j];}cout<<endl;}
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        mut A: i64,
        mut B: i64,
        K: usize,
    }

    // どうせ100回以下のループで済むので問題文の通りに追えばOK
    for _ in 0..K / 2 {
        if A % 2 == 1 {
            A -= 1;
        }
        A /= 2;
        B += A;

        if B % 2 == 1 {
            B -= 1;
        }

        B /= 2;
        A += B;
    }

    if K % 2 == 1 {
        if A % 2 == 1 {
            A -= 1;
        }
        A /= 2;
        B += A;
    }

    println!("{} {}", A, B);
}


Measured memory_bytes: 2168
N = int(input().strip())

sumA = 0
pair_sum = [0] * N
for i in range(N):
  A, B = map(int, input().split())
  pair_sum[i] = A + B
  sumA += A

pair_sum = sorted(pair_sum, reverse=True)
pair_sum_first = 0

for i in range(1, N, 2):
  pair_sum_first += pair_sum[i]
print("%d" % (sumA - pair_sum_first))

Measured memory_bytes: 9112
s = gets.chomp*2
t = gets.chomp
g = s.length / 2

c = 0
w = -1
t.chars do |ti|
  u = s.index(ti, w+1)
  if u == nil
    puts "-1"
    exit
  else
    c += u - w
    w = u % g
  end
end
puts c


Measured memory_bytes: 4348
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	int x = fetch<int>();
	int y = fetch<int>();

	cout << (x < 10 && y < 10 ? x * y : -1) << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

using namespace std;

void solve()
{
	int r[101] = {0};
	int a, b;
	while(cin >> a >> b)
	{
		if(a == 0 && b == 0)
		{
			bool flag = false;
			if(r[1] % 2 == 0 && r[2] % 2 == 0)
			{
				flag = true;
			}
			for(int i = 3; i < 100; ++i)
			{
				if(r[i] % 2 == 1)
				{
					flag = true;
					break;
				}
			}
			flag ? cout << "NG" : cout << "OK";
			cout << endl;
			memset(r, 0, sizeof(r));
		}
		else
		{
			r[a]++;
			r[b]++;
		}
	}
}

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

Measured memory_bytes: 0
#include<stdio.h>

int main(){
	int k, n;
	int a[200005] = {0};
	int min;
	int i;

	scanf("%d %d", &k, &n);
	for(i=0; i<n; i++){
		scanf("%d", a+i);
	}

	min = k - (k - a[n-1]) - a[0];
	for(i=1; i<n; i++){
		if(k - (a[i]- a[i-1]) < min){
			min = k - (a[i] - a[i-1]);
		}
	}

	printf("%d", min);

	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef deque<int> di;
typedef pair<int,int> pi;
#define pb push_back
#define mp make_pair
#define mh make_heap
#define s second
#define f first
#define pf push_front
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define FOR(i,a,b) for(ll i=a;i<b;i++)

int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    int n,c1=0,c2=0,c3=0,c4=0;
    cin>>n;
    string s1;
    FOR(i,0,n)
    {
        cin>>s1;
        if(s1=="AC")
            c1++;
        if(s1=="WA")
            c2++;
        if(s1=="TLE")
            c3++;
        if(s1=="RE")
            c4++;
    }
    cout<<"AC x "<<c1<<endl;
    cout<<"WA x "<<c2<<endl;
    cout<<"TLE x "<<c3<<endl;
    cout<<"RE x "<<c4<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
int main(void)
{   // Your code here!
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    if(a < b)
     printf("a < b\n");
    else if(a > b)
     printf("a > b\n");
    else if(a == b)
     printf("a == b\n");
     
     return 0;
}




Measured memory_bytes: 2044
n, m, l = map(int, input().split())
A = []
B = []
for _ in range(n):
    A.append(list(map(int, input().split())))
for _ in range(m):
    B.append(list(map(int, input().split())))

for i in range(n):
    for j in range(l):
        s = 0
        for k in range(m):
            s += A[i][k] * B[k][j]
        print(s, end='')
        if j != l-1:
            print(' ', end='')
    print()

Measured memory_bytes: 8640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    set<int> check;
    check.insert(3);
    {
        int count = 3;
        while (*check.rbegin() <= 1e5) {
            check.insert(*check.rbegin() + count++);
        }
    }
    if (N == 1) {
        cout << "Yes" << endl;
        cout << 2 << endl;
        cout << "1 1" << endl;
        cout << "1 1" << endl;
        return 0;
    }
    if (check.find(N) == check.end()) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    vector<set<int>> ans;
    {
        // init
        vector<int> temp = {1, 2, 3};
        for (int i = 0; i < 3; i++) {
            set<int> s;
            s.insert(temp[i]);
            s.insert(temp[(i + 1) % 3]);
            ans.push_back(s);
        }
    }
    set<int> temp;
    int base = 3;
    for (int i = 4; i <= N; i++) {
        ans[i - base - 1].insert(i);
        temp.insert(i);
        if ((i - base) == ans.size()) {
            ans.push_back(temp);
            temp = set<int>();
            base = i;
        }
    }
    cout << ans.size() << endl;
    for (auto & an : ans) {
        cout << an.size() << " ";
        for (auto itr = an.begin(); itr != an.end(); itr++) {
            cout << *itr << (next(itr, 1) == an.end() ? '\n' : ' ');
        }
    }
}


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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);
 

void solve() {
    int X, t;
    cin >> X >> t;
    int ans = max(0, X - t);
    cout << ans << endl;
}
 
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
from collections import deque

S = input()
S = deque(S)
Q = int(input())
Query1 = 0
flag = False
for i in range(Q):
    Queryi = input().split()
    if Queryi[0] == '1':
        Query1 += 1
        flag = not flag
    else:
        if (Queryi[1] == '1') ^ flag:
            S.appendleft(Queryi[2])
        else:
            S.append(Queryi[2])

if Query1 % 2 != 0:
    S.reverse()

ans = ''.join(S)
print(ans)

Measured memory_bytes: 73944
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(i) cout<<i<<endl;
const int mod=1e9 +7;
int main(){
IOS;
int n,i,x;
cin>>n;
int d[100002];
memset(d,0,sizeof(d));
for(i=0;i<n;i++){
    cin>>x;
    d[x]++;
}
int aux[100002];
memset(aux,0,sizeof(aux));
for(i=1;i<=100001;i++){
    aux[i]+=aux[i-1]+d[i-1];
}
int count=0;
for(i=1;i<=100001;i++){
    if(aux[i]*2==n)
        count++;
}
cout<<count<<endl;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL mod_pow_fast(LL a,LL n, LL MOD){
    LL p = a;
    LL ret = 1;
    while(n){
        if(n & 1) ret = (ret * p) % MOD;
        n = n >> 1;
        p = (p * p) % MOD;
    }
    return ret;
}

LL mod_val[200005][10] = {{0}};
LL dp[10000] = {0};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,p;
    cin>>n>>p;
    string s;
    cin>>s;

    if(p == 2 || p == 5){
        LL ans = 0;
        REP(i,n){
            LL x = s[i] - '0';
            if(x % p == 0){
                ans += i + 1;
            }
        }
        PUTS(ans);
        return 0;
    }
    // (100x + 10y + z) mod p
    // (100x % p + 10y % p + z % p) mod p
    // x * 10^100000 % p
    // mod_val[i][j] == j * 10^i mod p
    REP(i,n){
        REP(j,10){
            mod_val[i][j] = (mod_pow_fast(10, i, p) * j) % p;
        }
    }

    reverse(ALL(s));
    LL ans = 0;
    LL m = 0;
    dp[0] = 1;
    REP(i,n){
        LL x = s[i] - '0';
        m += mod_val[i][x];
        m %= p;
        ans += dp[m];
        dp[m]++;
    }

    PUTS(ans);
}

Measured memory_bytes: 16276
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while (k--)
	{
		if (b <= a)
		{
			b *= 2;
		}
		else if (c <= b)
		{
			c *= 2;
		}
	}
	if (c > b && b > a)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


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

class Main{
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a > b){
            System.out.println("a > b");
        }else if (a == b){
            System.out.println("a == b");
        }else{
            System.out.println("a < b");
        }    
    }
}

Measured memory_bytes: 17156
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int n, k, a[50];
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n, greater<int>());
	cout << accumulate(a, a + k, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define output(x) cout<<x<<endl;
typedef long long int ll;



int main()
{
	ll  i, j, k, l, m, sum, flag,ans,N;
	sum = 0;
	flag = 0;
	cin >> N;
	ans = 0;
	vector<ll>A(N);
	vector<ll>B(N);
	REP(i, 0, N) {
		cin >> A[i];
		ans += A[i] / 2;
		if (A[i] != 0) {
			if (A[i] % 2 == 1) {
				B[i] = 1;
			}
			else
				B[i] = 0;
		}
		else
			B[i] = -1;
	}
	REP(i, 0, N) {
		if (B[i] != -1) {
			sum += B[i];

		}
		else {
			ans += sum / 2;
			sum = 0;
		}
	}
	ans += sum / 2;
	output(ans);


	return 0;
}



Measured memory_bytes: 1792
def main():
    n, m, q = map(int, input().split())
    abcd = [list(map(int, input().split())) for _ in [0]*q]

    que = [[1]]
    for _ in range(n):
        que2 = []
        for qq in que:
            i = qq[-1]
            for j in range(i, m+1):
                que2.append(qq+[j])
        que = que2

    ans = 0
    for q in que:
        temp = 0
        for a, b, c, d in abcd:
            if q[b]-q[a] == c:
                temp += d
        ans = max(ans, temp)
    print(ans)


main()

Measured memory_bytes: 114420
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int cnt;

void insertionSort(vector<int> &mat,int g){
    for(int i=g;i<mat.size();i++){
        int v = mat[i];
        int j = i - g;
        while(j>=0 && mat[j]>v){
            mat[j+g] = mat[j];
            j = j - g;
            cnt++;
            mat[j+g] = v;
        }
    }
}

void shellSort(vector<int> &mat){
    vector<int>g;
    cnt = 0;
    for(int h=1;h<=mat.size();h=3*h+1)g.push_back(h);
    reverse(g.begin(),g.end());
    int m = g.size();
    cout << m << endl;
    for(int i=0;i<g.size();i++){
        if(i<g.size()-1) cout << g[i] << " ";
        else cout << g[i] << endl;
    }
    for(int i=0;i<m;i++)insertionSort(mat,g[i]);
}

int main(){
    vector<int> mat;
    int n,x;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x;
        mat.push_back(x);
    }
    shellSort(mat);
    cout << cnt << endl;
    for(int i=0;i<n;i++) cout << mat[i] << endl;
    return 0;
}

Measured memory_bytes: 6992
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}


void solve(void)
{
  int N;
  cin>>N;
  int A,B,C,D,E;
  cin>>A>>B>>C>>D>>E;
  int M =min(A,min(B,min(C,min(D,E))));

  cout<<4+N/M+(int)(N%M > 0)<<endl;
  
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
 
int main()
{
    int n;
    cin >> n;

    int m,ans = INT32_MIN;
    cin >> m;
    int minv = m;
    FOR(i, 1, n){
        cin >> m;
        ans = max(ans, m-minv);
        minv = min(minv, m);
    }

    print(ans);
    return 0;
}


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

int main()
{
    int n;
    cin>>n;
    long long int x;
    cin>>x;
    vector<int>arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    long long int cost=0;
    for(int i=0;i<n;i++)
    {
        if(arr[i]>=x)
        {
            cost+=arr[i]-x;
            arr[i]=x;
        }
    }
    
 /*
for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    cout<<endl;
*/
    for(int i=1;i<n;i++)
    {
        if(arr[i]+arr[i-1]>x)
        {
            cost+=(arr[i]-(x-arr[i-1]));
            arr[i]=(x-arr[i-1]);
        }
    }
/*
for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    cout<<endl;
*/
    cout<<cost<<endl;
    
    return 0;
}

Measured memory_bytes: 640
/*  /$$                                     /$$
      | $$                                    | $$
  /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$
 /$$__  $$ /$$__  $$ /$$_____/ /$$__  $$ /$$__  $$ /$$__  $$ /$$__  $$
| $$  | $$| $$$$$$$$| $$      | $$  \ $$| $$  | $$| $$$$$$$$| $$  \__/
| $$  | $$| $$_____/| $$      | $$  | $$| $$  | $$| $$_____/| $$
|  $$$$$$$|  $$$$$$$|  $$$$$$$|  $$$$$$/|  $$$$$$$|  $$$$$$$| $$
 \_______/ \_______/ \_______/ \______/  \_______/ \_______/|__//$$$$$$ /$$$$$$
                                                               |______/|______/

*/
#include <bits/stdc++.h>
#define fastio        ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ln            cout << endl;
#define vi            vector<int>
#define vll           vector<long long>
#define sortl(vec)    sort(vec.begin(), vec.end());
#define sortr(vec)    sort(vec.rbegin(), vec.rend());
#define forn(i, x, n) for(long long i = x; i < n; i++)
#define revn(i, n, x) for(long long i = n; i >= x; i--)
#define in(vec)       for(auto &it : vec) cin >> it;
#define loop(vec)     for(auto &it : vec)
#define	out(vec)      for(auto &it : vec) cout << it << " "; ln
#define ll            long long
#define mod           1000000007
#define debug(x)      cout << x << endl;
#define pb            emplace_back
#define mp            make_pair
#define um            unordered_map
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define f             first
#define s             second
#define pi            3.14159265359
#define CLOCK         cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
using namespace std;

void primeFactors(ll n) {
	while (n % 2 == 0) {
		//cout << 2 << " ";
		n = n / 2;
	}

	for (ll i = 3; i <= sqrt(n); i += 2) {
		while (n % i == 0) {
			//cout << i << " ";
			n = n / i;
		}
	}

	if (n > 2)
		cout << n << " ";
}

ll power(ll x, ll y, ll p) {
	ll res = 1;
	x = x % p;

	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;

		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

ll modulo(ll a, ll b) {
	ll c = a % b;
	return (c < 0) ? c + b : c;
}

int main() {
// in(vec) works for size-defined type vectors

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif

	fastio
	ll t = 1;
	while (t--) {
		ll k;
		string str;
		cin >> k;
		cin >> str;

		if (str.size() <= k)
			cout << str << endl;
		else
			cout << str.substr(0, k) << "..." << endl;



	}
	CLOCK
	return 0;
}



Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    string n;
    cin >> n;
    string ans = "No";
    rep(i, 3) {
        if (n[i]-'0'==7) ans = "Yes";
    }
    
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>

using namespace std;

long dp[3000][3000];


int main(){
    int N;
    long a[3000];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < N; i++){
        if(N%2 == 0) dp[i][i] = -a[i];
        else dp[i][i] = a[i];
    }
    for(int i = 1; i < N; i++){
        for(int j = 0; j+i < N; j++){
            if((N-(i+1))%2 == 0){
                dp[j][j+i] = max(dp[j+1][j+i]+a[j], dp[j][j+i-1]+a[j+i]);
            }else{
                dp[j][j+i] = min(dp[j+1][j+i]-a[j], dp[j][j+i-1]-a[j+i]);
            }
        }
    }
    cout << dp[0][N-1] << endl;
}

Measured memory_bytes: 70016
//再帰
#include<bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

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

template<typename T,typename U>
void Printarray(T f,U n){for(U i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i]<<endl;}

int flog(vector<int> &dp,const vector<int> &h,int i) {

  // DP の値が更新されていたらそのままリターン
  if(dp[i]<1e9) return dp[i];
  // 足場 0 のコストは 0
  if(i==0) return 0;

  // i-1, i-2 それぞれ試す
  int res = 1e9;
  // 足場 i-1 から来た場合
  chmin(res, flog(dp,h,i-1) + abs(h[i] - h[i - 1]));
  // 足場 i-2 から来た場合
  if (i > 1) chmin(res, flog(dp,h,i-2) + abs(h[i] - h[i - 2]));

  // 結果をメモしながら、返す
  return dp[i] = res;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  vector<int> h(n);rep(i,n)cin>>h[i];
  vector<int> dp(n);

  dp.assign(n,1e9);

  //Printarray(dp,n);

  cout<<flog(dp,h,n-1)<<endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
const unsigned int M = 1000000007;
#define ll long long
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b;
    while(cin>>a>>b){
        a<=9&&b<=9?cout<<a*b<<endl:cout<<"-1"<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    List<Statement>[] statements = new List[N];
    for (int i = 0; i < N; i++) {
      statements[i] = new ArrayList<>();
      int a = scanner.nextInt();
      for (int j = 0; j < a; j++) {
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        statements[i].add(new Statement(x - 1, y == 1));
      }
    }

    int max = 0;
    loop:
    for (int i = 0; i < (1 << N); i++) {
      for (int j = 0; j < N; j++) {
        if ((1 & i>>j) == 1) {
          for (Statement s : statements[j]) {
            if (((1 << s.who) & i) == 0 && s.honest) continue loop;
            if (((1 << s.who) & i) != 0 && !s.honest) continue loop;
          }
        }
      }
      max = Math.max(max, Integer.bitCount(i));
    }
    System.out.println(max);
  }

  private static class Statement {
    final int who;
    final boolean honest;

    private Statement(int who, boolean honest) {
      this.who = who;
      this.honest = honest;
    }
  }
}


Measured memory_bytes: 27092
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,a;
  map<int,int> b;
  for (cin >> N; N; b[a]++, N--) {
    cin >> a;
  }
  a = 0;
  for (auto p : b) {
    if (p.second >= p.first) {
      a += p.second-p.first;
    } else {
      a += p.second;
    }
  }
  cout << a;
}

Measured memory_bytes: 8144
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string s,t;
int main(){
    cin>>s>>t;
    ll ans=0;
    for(ll i=0;i<s.length();i++){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3844
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

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

long long stoi(string str) {
	long long ret;
	stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve() {
	int n;
	cin >> n;
	map<int, int> m;
	rep(i, n) {
		int a;
		cin >> a;
		m[a]++;
		if (m[a] >= 3) {
			P(0);
			return;
		}
	}
	if (n % 2 == 0) {
		for (int i = 1; i < n; i += 2) {
			if (m[i] != 2) {
				P(0);
				return;
			}
		}
	}
	else {
		if (m[0] != 1) {
			P(0);
			return;
		}
		for (int i = 2; i < n; i += 2) {
			if (m[i] != 2) {
				P(0);
				return;
			}
		}
	}
	ll ans = 1;
	for (int i = 0; i < n / 2; i++) {
		ans = (ans * 2) % MOD;
	}
	cout << ans << endl;
}

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


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

int main() {
  int k, t;
  cin >> k >> t;

  vector<int> a(t);
  for (int i = 0; i < t; ++i)
    cin >> a[i];

  sort(a.rbegin(), a.rend());

  int diff = a[0];
  for (int i = 1; i < t; ++i)
    diff = abs(diff - a[i]);
  int ans = max(0, diff - 1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	vector<int> primeList;
	bool used[50002];
	
	memset(used, true, sizeof(used));

	for(int i = 2; i <= sqrt(50000); i++)
	{
		if(used[i] == false)
		{
			continue;
		}
		for(int j = i*2; j <= 50000; j += i)
		{
			used[j] = false;
		}
	}
	for(int i = 2; i < 50000; i++)
	{
		if(used[i] == true)
		{
			primeList.push_back(i);
		}
	}
	int num, ans;
	while(cin >> num)
	{
		if(num == 0)
		{
			break;
		}
		ans = 0;

		for(int i = 0; i < primeList.size() && primeList[i] <= (num/2); i++)
		{
			if(used[num - primeList[i]] == true)
			{
				ans++;
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 1324
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSimplifiedMahjong solver = new BSimplifiedMahjong();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSimplifiedMahjong {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int[] a = in.ints(n);
            long ans = 0;
            for (int i = 0; i < n - 1; i++) {
                if (a[i] % 2 == 1 && a[i + 1] > 0) {
                    a[i]--;
                    a[i + 1]--;
                    ans += 1;
                }
            }
            //System.out.println(Arrays.toString(a));
            for (int i = 0; i < n; i++) {
                ans += a[i] / 2;
            }
            out.println(ans);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }
}



Measured memory_bytes: 37704
N, M = map(int,input().split())
L = []
id = []

for i in range(M):
    tmp = []
    tmp = list(map(int,input().split()))
    tmp.append(i)
    L.append(tmp)

LL = sorted(L)
num = []

for i in range(len(LL)):
    if i == 0:
        cnt = 1
    else:
        if (LL[i][0] == LL[i-1][0]):
            cnt += 1
        else:
            cnt = 1
    id.append(LL[i][2])
    num.append(str(LL[i][0]).zfill(6) + str(cnt).zfill(6))

numnum = [x for _ , x in sorted(zip(id,num))]

for x in numnum:
    print(x)

Measured memory_bytes: 48304
n,m = map(int,input().split())
h = list(map(int,input().split()))
l = list({i} for i in range(n+1))
for i in range(m):
    a,b = map(int,input().split())
    l[a].add(b)
    l[b].add(a)
    
for i in range(len(l)):
    l[i] = list(l[i])
good = set()
for i in range(1,len(l)):
    l[i].remove(i)
    for j in range(len(l[i])):
        if h[l[i][j]-1] >= h[i-1]:
            break
    else:
        good.add(i)
print(len(good))

Measured memory_bytes: 56272
#include <stdio.h>

#define intersect(x1, y1, x2, y2) \
    (((x1 - x2) * (yp - y1) + (y1 - y2) * (x1 - xp)) * \
     ((x1 - x2) * (yc - y1) + (y1 - y2) * (x1 - xc)) < 0)

int main(void)
{
    double x1, y1, x2, y2, x3, y3, xp, yp;

    while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
                &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF) {
        double xc, yc;

        xc = (x1 + x2 + x3) / 3;
        yc = (y1 + y2 + y3) / 3;

        if (intersect(x1, y1, x2, y2) || intersect(x2, y2, x3, y3) || intersect(x3, y3, x1, y1))
            printf("NO\n");
        else
            printf("YES\n");

    }

    return 0;
}

// refered to #513648 by ytetsuwo

Measured memory_bytes: 612
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 1000003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define sumall(v) accumulate(all(v),(ll)0)
#define suma accumulate
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
#define sp " "
#define zero (ll)0
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"\n" ;}
double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
ll n,m,k,x,y;
bool ok = false;
int main()
{
    FastIO ;
    PRECISION(10) ;
    ll a,b,c,d,i,j,t;//,x,y,z;//,x1,y1,z1,e,f;
    ll p,q,r,u,w ;
    char ch,chr ;
    string str,st,str1,str2,str3,str4;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    //Stay Motivated!!
    //Never use i for two or more nested loops!!
    //Range Query + Constructive + DSU  +  Graph Theory + Math + DP + Bitmasks + Geometry + Brute Force + Implementation + Binary Search
    cin>>n;
    vll v;
    for(i=0 ; i<n ; i++)
    {
        cin>>a;
        v.pb(a);
    }
    map<ll,ll>mp;
    for(i=0 ; i<n ; i++)
    {
        a = -v[i] - i - 1;
        mp[a]++;
    }
    c = 0;
    for(i=0 ; i<n ; i++)
    {
        a = v[i] - i - 1;
        x = mp[a];
        c+=x;
    }
    cout<<c;
}

Measured memory_bytes: 27352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int mod_pow(Int x, Int a, Int m = MOD){
    if(a == 0)return 1;
    Int res = mod_pow(x, a / 2, m);
    res = res * res % m;
    if(a % 2)res *= x;
    return res % m;
}

Int inv(Int x, Int m = MOD){
    return mod_pow(x, m-2, m);
}

Int fact[1080000];
Int revfact[1080000];
Int rev[1080000];

void init(){
    Int m = MOD;
    fact[0] = 1;
    revfact[0] = 1;
    rev[0] = 0;
    rev[1] = 1;
    for(int i = 1;i < 1080000;i++){
        fact[i] = fact[i-1] * i % m;
        if(i>1)rev[i] = MOD / i * (MOD-rev[MOD % i]) % MOD;
        revfact[i] = revfact[i-1] * rev[i] % MOD;
    }
}

Int nCk(Int n, Int k){
    if(n < k)return 0;
    return fact[n] * revfact[n-k] % MOD * revfact[k] % MOD;
}



Int B[1100];

void init_B(){
    init();
    B[0] = 1;
    for(int i = 1;i < 1100;i++){
        Int sgn = 1;
        if(i%2)sgn *= -1;
        for(int j = 0;j < i;j++){
            B[i] += sgn * nCk(i+1, j) * B[j] % MOD;
            B[i] %= MOD;
            sgn *= -1;
        }
        B[i] *= -sgn * inv(nCk(i+1,i));
        B[i] %= MOD;
        if(B[i] < 0)B[i] += MOD;
    }
}

Int S(int k, int n){
    Int res = 0;
    Int pown = n;
    for(int j = 0;j <= k;j++){
        res += nCk(k+1, k-j) * B[k-j] % MOD * pown % MOD;
        res %= MOD;
        pown = pown * n % MOD;
    }
    res = res * inv(k + 1) % MOD;
    res %= MOD;
    if(res < 0)res += MOD;
    return res;

}

Int calc(Int k, Int n){
    if(n % 2 == 0)return S(k, n/2) * mod_pow(2, k) % MOD;
    else return (S(k, n) - calc(k, n-1)) % MOD;
}

Int n, s, k;
int main(){
    init_B();    
    cin >> n >> s;    
    Int ans = 0;
    ans += s * (s+1) %MOD  * inv(2) %MOD* mod_pow(s+1, n-2) %MOD;
    int odds = (s - 1) / 2;
    ans += calc(n-1, s); ans %= MOD;
    ans -= calc(n-1, s-1); ans %= MOD;
    if(ans < 0)ans += MOD;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 28440
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    vector<string> ans;
    for (int i = 1; i <= min(n, k); i++)
    {
        for (int j = 0; j < n - i + 1; j++)
        {
            ans.push_back(s.substr(j, i));
        }
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    cout << ans[k-1] << endl;
}

Measured memory_bytes: 1660
def prime_list():
  p_lis = [True] * (2 * 10**5 + 1)
  p_lis[0], p_lis[1] = False, False
  for i in range(2, 2 * 10**5 + 1):
    if p_lis[i]:
      j = 2
      while j * i <= 2 * 10**5:
        p_lis[j*i] = False
        j += 1
  return p_lis

x = int(input())
p_lis = prime_list()
j = 0
while True:
  if p_lis[x+j]:
    print(x+j)
    break
  j += 1



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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector< vector<int> > a(2, vector<int>(n));
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];
    vector< vector<int> > dp(2, vector<int>(n, 0));
    dp[0][0] = a[0][0];
    for (int i = 0; i < 2; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (i - 1 >= 0)
                dp[i][j] = max(dp[i][j], dp[i - 1][j] + a[i][j]);
            if (j - 1 >= 0)
                dp[i][j] = max(dp[i][j], dp[i][j - 1] + a[i][j]);
        }
    }
    cout << dp[1][n - 1];
    return 0;
}


Measured memory_bytes: 256
import sys
for line in sys.stdin:
    try:
        p = list(map(float, line.split(',')))
    except:
        break
    v = [p[i] - p[(i + 2) % 8] for i in range(8)]
    ip = [v[j] * v[(j + 3) % 8] - v[j + 1] * v[(j + 2) % 8] > 0 for j in range(0,8,2)]
    if sum(ip) == 0 or sum(ip) == 4:
        print('YES')
    else:
        print('NO')

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

int main(){
    int H, W, i, j;
    while(1){
    cin >> H >> W ;
    if(H==0 && W==0) break;
    for(i=0; i < H; i++){
        for(j=0; j<W; j++){
            if( i%2 == 1 && j%2 == 1 || i%2 == 0 && j%2 == 0 ) cout << '#';
            else cout << '.';
        }
        cout << endl;
    }
    cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3072
import java.util.Scanner;

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


	int N;
	int Y;
	public void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		Y = sc.nextInt();
		int a=-1;
		int b=-1;
		int c=-1;
		boolean hit = false;
		for(int i=0; i<=N; i++) {
			for(int j=0; j<=N-i; j++) {
				if(1000*i + 5000*j + 10000*(N-i-j) == Y) {
					a=i;
					b=j;
					c=N-i-j;
					hit = true;
				}
			}
			if(hit)break;
		}
		System.out.println(c+" "+b+ " "+a);
		sc.close();
	}


}

Measured memory_bytes: 23124
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    rep(0, i, N)
    {
        char a;
        cin >> a;
        if (a == 'Y')
        {
            cout << "Four" << endl;
            return 0;
        }
    }

    cout << "Three" << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
inline char nchar() {
	static const int bufl=1<<20;
	static char buf[bufl],*a=NULL,*b=NULL;
	return a==b && (b=(a=buf)+fread(buf,1,bufl,stdin),a==b)?EOF:*a++;
}
inline int read() {
	int x=0,f=1;
	char c=nchar();
	for (;!isdigit(c);c=nchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=nchar()) x=x*10+c-'0';
	return x*f;
}
const int maxn=2e3+1;
const int maxl=4e6+1;
typedef bitset<maxl> bit;
bit f;
int n,sum=0;
int main() {
	f[0]=true;
	n=read();
	for (int i=1;i<=n;++i) {
		int x=read();
		sum+=x;
		f|=f<<x;
	}
	for (int i=(sum+1)/2;i<=sum;++i) if (f[i]) {
		printf("%d\n",i);
		break;
	}
	return 0;
}


Measured memory_bytes: 1664
// In the name of Allah the Lord of the Worlds.

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

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

    double tot = 0;
    int n , k;
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        double now = i , pro = 1.00/n;
        while(now<k){
            now*=2;
            pro*=0.5;
        }
        tot+=pro;
    }
    cout << setprecision(14) << fixed << tot << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int gcd(int a,int b)
{
    if(a==0)
    return b;
    else
        return gcd(b%a,a);
}
int main()
{
    ll n;
    cin>>n;
    vector<ll> arr;
    int t;
    for(int x=0;x<n;x++)
    {   cin>>t;
        arr.push_back(t);
    }
    ll g=arr[0];
   for(int x=0;x<n;x++)
   {
       g=gcd(g,arr[x]);
   }
   cout<<g;
}


Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int[] c = new int[26];
		for(int i = 0; i < 26; i++) {
			c[i] = sc.nextInt();
		}
		int[][] s = new int[d][26];
		for(int i = 0; i < d; i++) {
			for(int j = 0; j < 26; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		int[] lastDay = new int[26];
		for(int i = 0; i < 26; i++) {
			lastDay[i] = 0;
		}
		long result = 0;
		for(int i = 1; i <= d; i++) {
			long max = result;
			int check = 0;
			for(int j = 0; j < 26; j++) {
				long temp = 0;
				temp += s[i-1][j];
				for(int k = 0; k < 26; k++) {
					if(k != j&&i!=d) {
						temp -= c[k]*(i-lastDay[k]);
					}
				}
				if(max < temp+result) {
					max = temp+result;
					check = j;
				}
			}
			lastDay[check] = i;
			System.out.println(check+1);
		}
	}
}


Measured memory_bytes: 46176