akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;

ll pow(ll x, ll n, ll M){
	ll res=1;
  	if(n>0){
      res=pow(x,n/2,M);
      if(n%2==0){
      	res=(res*res)%M;
      }
      else{res=(((res*res)%M)*x)%M;}
    } 
      return res;
    }

ll COMBI(ll n, ll x) {
    // nCx
    ll p=1,q=1,res=1;
    for(long int i=0; i<x;i++) {
     	p=p*(n-i)%1000000007;
      	q=q*(i+1)%1000000007;     	
    }  
  
    return p*pow(q,1000000005,1000000007) % 1000000007;
}
int main() {
    
  
	ll n,a,b;
    cin >>n>>a>>b;
    long long int ans;
    ans=pow(2,n,1000000007)-1;
  	ans=ans+1000000007*2;
  	ans=ans-COMBI(n,a)-COMBI(n,b);
  	ans=ans%1000000007;
  	cout<<ans;
}
 
 



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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

const int N=100010,M=2,inf=1e9;
int n;
int a[N],dp[N];

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	cin>>n;
	for(int i=0;i<n;++i)cin>>a[i];
	for(int i=0;i<n;++i)dp[i]=inf;
	dp[0]=0;
	for(int i=0;i<n;++i)
		for(int j=1;j<=M;++j)
			dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 4392
#include <bits/stdc++.h> 
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb push_back 
#define mk make_pair 
#define fr first 
#define sc second 
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii; 
typedef vector<int> vi; 
vi g[100010];
int main(){
    int N;
    cin >> N;
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        --a;--b;
        g[a].pb(b);
        g[b].pb(a);
    }

    priority_queue < pair<int,int> > Q;
    int K;
    vi ini(100010,-INF);
    cin >> K;
    rep(i,K){
        int a,b;
        cin >> a >> b;
        --a;
        ini[a] = b;
        Q.push(mk(b,a));
    }
    bool errorFlg = false;
    while(!Q.empty()){
        pair<int,int> e = Q.top();
        Q.pop();
        bool flg = false;
        rep(i,g[e.sc].size()){
            int s = g[e.sc][i];
            if(abs(ini[s] - ini[e.sc]) == 1)continue;
            if(ini[s] != -INF){
                flg = true;
                break;
            } 
            ini[s] = ini[e.sc] - 1;
            Q.push(mk(ini[s],s));
        } 
        if(flg){
            puts("No");
            errorFlg = true;
            break;
        }
    }
    if(!errorFlg){
        puts("Yes");
        rep(i,N){
            cout << ini[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 7924
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll, ll>;
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	vector<ll> x(N);
	vector<ll> y(N);
	set<P> st;
	for (int i = 0;i < N;i++) {
		cin >> x[i] >> y[i];
		st.insert(P(x[i], y[i]));
	}
	ll ans = INF;
	for (int i = 0;i < N;i++) {
		for (int j = i + 1;j < N;j++) {
			ll p = x[j] - x[i];
			ll q = y[j] - y[i];
			ll now = 0;
			for (int k = 0;k < N;k++) {
				if (st.find(P(x[k] - p, y[k] - q)) == st.end())
					now++;
			}
			ans = min(ans, now);
		}
	}
	if (N == 1)
		cout << 1 << endl;
	else
		cout << ans << endl;
	return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
	char A, B;
	cin >>A >> B;
	if (A != B)
		cout << 'D';
	else
		cout << 'H';
}

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

int main() {
  int A,B;
  char op;
  cin >> A >> op >> B;

    if (op == '+') {
      cout << A + B << endl;
    }
    else if (op == '-') {
      cout << A - B << endl;
    }
      
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,k,sum=0;
int main()
{
 cin>>a>>b>>c>>k;
 
 sum+=min(a,k);
 
 k=k-a;
 
 if(k>0)
 {
    k=k-b;
 }
 if(k>0)
 {
 sum=sum-min(k,c);
 }
 
 cout<<sum<<endl;
 
return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void)
{
	int h[10];
	int i, j;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &h[i]);
	}
	
	for (i = 0; i < 9; i++){
		for (j = 0; j < 9 - i; j++){
			if (h[j] < h[j + 1]){
				h[j] += h[j + 1];
				h[j + 1] = h[j] - h[j + 1];
				h[j] -= h[j + 1];
			}
		}
	}
	
	for (i = 0; i < 3; i++){
		printf("%d\n", h[i]);
	}
	
	return (0);
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
#include <map>
using namespace std;
// 1 2 3 4 5 6
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, d; cin >> n >> d;
	int l = d * 2 + 1;
	cout << n / l + ((n % l) ? 1 : 0) << '\n';





}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
    static Node [] N;
    static boolean [] seen;
    static int [] d;


    static public class Node{
        int id;
        ArrayList<Integer> edges = new ArrayList<>();
        public Node(int id) {
            this.id = id;
        }
        public void add(int e){
            edges.add(e);
        }
    }

    static public void bfs(int i, int counter) {
        if(d[i] == 0 || d[i] > counter ) {
            d[i] = counter;
            counter++;
            if (N[i].edges.isEmpty()) {

            } else {
                for (int j : N[i].edges) {
                    bfs(j - 1, counter);
                }
            }
        }
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        N = new Node[n];
        seen = new boolean[n];
        d = new int[n];
        for(int x = 0; x < n; x++){
            int id = scan.nextInt();
            N[x] = new Node(id);
            int ed = scan.nextInt();
            for(int y = 0; y < ed; y++){
                int check = scan.nextInt();
                N[x].add(check);
            }
        }
        bfs(0, 0);
        for(int x = 0; x < n; x++){
            if(x == 0){
                System.out.println(N[x].id +" 0");
            }
            else if(d[x] != 0) {
                System.out.println(N[x].id + " " + d[x]);
            }
            else{
                System.out.println(N[x].id +" -1");
            }
        }
    }

}


Measured memory_bytes: 29036
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    vector<ll> l(n); for(int i= 1; i<= n-1; i++) l[i] = max(l[i-1], a[i-1]);
    vector<ll> r(n); for(int i= n-2; i>= 0; i--) r[i] = max(r[i+1], a[i+1]);

    rep(i,n){
        cout << max(l[i], r[i]) << endl;
    }
}



Measured memory_bytes: 6272
#define scanf_s scanf
#include <string>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 500000
#define MAX_  2000000000
struct tree
{
	long long int key = MAX_ + 1;
	tree *left = NULL, *right = NULL, *p = NULL;
};
void insert(tree &T,tree &z)
{
	tree *y = NULL , *x = &T;
	while (x->key != MAX_ + 1) {
		y = x;
		if (z.key < x->key) { x = x->left; }
		else { x = x->right; }
		if (x == NULL) break;
	}
	z.p = y;
	if (y == NULL) { 
		T = z; 
	}
	else if (z.key < y->key) { 
		y->left = &z; 
	}
	else { 
		y->right = &z; 
	}
}
void print_1(tree *T) {
	if (T != NULL) {
		printf(" %lld", T->key);
		print_1(T->left);
		print_1(T->right);
	}
}
void print_2(tree *T) {
	if (T != NULL) {
		print_2(T->left);
		printf(" %lld", T->key);
		print_2(T->right);
	}
}
int find_(tree *T,long long int n){
	if (T == NULL) { return 0; }
	if (T->key == n) { return 1; }

	if (T->key < n) {
		return (find_(T->right, n));
	}
	else {
		return (find_(T->left, n));
	}
}
int main() {
	int m, cou = 0;
	long long int k;
	string s;
	tree t, id[MAX];
	scanf_s("%d", &m);
	for (int i = 0; i < m; ++i) {
		cin >> s;
		if (s == "insert") {
			scanf_s("%lld", &id[cou].key);
			insert(t, id[cou]);
			++cou;
		}
		else if(s == "print"){
			print_2(&t);
			printf("\n");
			print_1(&t);
			printf("\n");
		}
		else {
			scanf_s("%lld", &k);
			if (find_(&t, k)) printf("yes\n");
			else printf("no\n");
		}
	}
	return 0;
}

Measured memory_bytes: 34600
import numpy as np

N, M, X = map(int, input().split())
books = [list(map(int, input().split())) for n in range(N)]
npbooks = np.array(books)

def can_achieve(points, target):
    return all(points >= target)

def make_subsets(whole_list):
    subsets = []
    for i in range(1 << len(whole_list)):
        output = []
        for j in range(len(whole_list)):
            if ((i >> j) & 1) == 1:
                output.append(whole_list[j])
        subsets.append(output)
    return subsets[1:]

subsets = make_subsets([i for i in range(N)])
values = []
for subset in subsets:
    total = np.array([0 for _ in range(M+1)])
    for idx in subset:
        total += books[idx]
    if can_achieve(total[1:], X):
        values.append(total[0])
if values == []:
    print(-1)
else:
    print(min(values))

Measured memory_bytes: 27620
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    long long int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k)
    {
        cout<<k;
    }
    else if(a+b>=k)
    {
        cout<<a;
    }
    else
    {
        cout<<a-(k-a-b);
    }
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll n,m,a[100010],ans=0;
pair<ll,ll> q[100010];

void init(){
	cin>>n>>m;
	rep(i,n)cin>>a[i];
	rep(i,m){
		ll b,c;
		cin>>b>>c;
		q[i]={c,b};
	}
	sort(a,a+n);
	sort(q,q+m);
}

int main(void){
	init();
	ll t=0;
	irep(i,m){
		if(t>=n)break;
		reg(j,t,min(t+q[i].second-1,n-1)){
			a[j]=max(a[j],q[i].first);
		}
		t=t+q[i].second;
	}
	rep(i,n)ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int bub(int a[],int n){
    int count=0;
    bool f=1;
    for(int i=0;f;i++){
        f=0;
        for(int k=n-1;k>=i+1;k--){
            if(a[k]<a[k-1]){
                swap(a[k],a[k-1]);
                f=1;
                count++;
            }
        }
    }
    return count;
}
int main(){
    int i,k,n,count;
    int a[100];
    
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];

    count=bub(a,n);
    
    for(int i=0;i<n;i++){
        if(i>0)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<count<<endl;
    
    return 0;
        
}
    




Measured memory_bytes: 3104
#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;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i, ans = LLONG_MAX, bsum = -1;
    ll l;
    cin >> n >> l;
    ll sum = n * (2 * l + (n - 1)) / 2;
    for(i = l; i <= l + n - 1; i++)
    {
        if(abs(i) < ans)
            bsum = sum - i, ans = abs(i);
    }
    cout << bsum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <bitset>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

int main(){

    ll N;
    cin >> N;

    vector< ll > v(N);
    for(ll i = 0; i < N; i++) cin >> v[i];

    sort(all(v));
    vector<ll> used;
    used.push_back(v[0]);
    for(int i = 0; i < N - 1; i++){
        if(v[i] != v[i + 1]) used.push_back(v[i+1]);
    }

    if(used.size() > 3){
        cout << "No" << endl;
        return 0;
    }

    if(used.size() == 1 && used[0] == 0){
        cout << "Yes" << endl;
        return 0;
    }

    if(N % 3 != 0){
        cout << "No" << endl;
        return 0;
    }

  
    if(used.size() == 2){

        // 多い方
        ll cnt = 0;
        ll no_cnt = 0;
        for(int i = 0; i < N; i++){
            if(v[i] == v[0]) cnt ++;
            else no_cnt ++;
        }
 
        if(cnt != N / 3 && cnt != N / 3 * 2){
            cout << "No" << endl;
            return 0;
        }

        bitset<30> bs1, bs2, bs3;

        if(cnt > no_cnt){
            bs1 = bitset<30>(used[0]);
            bs2 = bitset<30>(used[0]);
            bs3 = bitset<30>(used[1]);
        }
        else{
            bs1 = bitset<30>(used[0]);
            bs2 = bitset<30>(used[1]);
            bs3 = bitset<30>(used[1]);
        }

        if(bs1 == (bs2 ^ bs3) ){
            if(bs2 == (bs1 ^ bs3)){
                if(bs3 == (bs1 ^ bs2)){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }

        cout << "No" << endl;
        return 0;



    }



    bitset<30> bs1, bs2, bs3;
    bs1 = bitset<30>(used[0]);
    bs2 = bitset<30>(used[1]);
    bs3 = bitset<30>(used[2]);

    ll cnt0 = 0;
    ll cnt1 = 0;
    ll cnt2 = 0;
    for(int i = 0; i < N; i++){
        if(v[i] == used[0]) cnt0 ++ ;
        if(v[i] == used[1]) cnt1 ++ ;
        if(v[i] == used[2]) cnt2 ++ ;
    }

    if(cnt0 != cnt1 || cnt0 != cnt2 || cnt1 != cnt2){

        cout << "No" << endl;
        return 0;

    }

    if(bs1 == (bs2 ^ bs3) ){
        if(bs2 == (bs1 ^ bs3)){
            if(bs3 == (bs1 ^ bs2)){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

        cout << "No" << endl;
        return 0;


}

Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
typedef long long ll;
vector<ll> a(51,0);

ll ttl(ll n){
    if(n==0) a.at(n)=1;
    else a.at(n)=3+2*ttl(n-1);
    return a.at(n);
}

ll dfs(int n,ll i){
    if(!n) return 1;

    if(i==1) return 0;
    if(2<=i && i<=1+a.at(n-1)) return dfs(n-1,i-1);
    if(i==2+a.at(n-1)) return dfs(n-1,a.at(n-1))+1;
    if(3+a.at(n-1)<=i && i<=2+2*a.at(n-1)) return dfs(n-1,a.at(n-1))+1+dfs(n-1,i-2-a.at(n-1));
    else return 1+2*dfs(n-1,a.at(n-1));
}

int main(){
  ll n,x;cin>>n>>x;
  ttl(n);

  cout<<dfs(n,x);
}

Measured memory_bytes: 256
#d

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

A = [201] + A + [99]

money = 1000
stock = 0

sell_point = [0]*len(A)
buy_point = [0]*len(A)

position = "buy"

for i in range(len(A)-1):
    if position=="buy":
        if A[i] < A[i+1]:
            buy_point[i] = 1
            position ="sell"
            #print("buy", A[i])
            ba = money//A[i]
            #print("buy_amount", ba)
            money -= ba*A[i]
            stock += ba
            
    elif position=="sell":
        if A[i] > A[i+1]:
            sell_point[i] = 1
            position = "buy"
            #print("sell", A[i])
            sa = stock
            #print("sell_amount", sa)
            money += sa*A[i]
            stock = 0
print(money)

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

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto H = RDA;

	long ans, cnt;
	foreach (i; 1..N)
	{
		if (H[i] <= H[i-1])
		{
			++cnt;
		}
		else
		{
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);

	writeln(ans);
	stdout.flush();
	debug readln();
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  int a,b;
  cin >> a >> b;
  rep(i,3){
    if(a*b*(i+1)%2!=0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
int main()
{
	int m,n,i,t,j,k;
	int a[4][4],b[5][5];
	
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	for(i=1;i<=3;i++)
	for(j=1;j<=3;j++)
	{
		scanf("%d",&a[i][j]);
	}
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&m);
		int flag=0;
		for(i=1;i<=3;i++)
	    {
	    	for(j=1;j<=3;j++)
	       {
	    	if(a[i][j]==m)
	    	{
	    		flag=1;break;
			}
		   }
		   if(flag==1) break;
		}
		if(flag==1)
		{
			//printf("!%d %d\n",i,j);
			b[i][0]++;
			b[0][j]++;
			if(i==j)
			{
				b[0][0]++;
			}
			if(i+j==4)
			{
				b[4][4]++;
			}
		}
	}
	int flag=0;
	for(i=1;i<=3;i++)
	{
		if(b[i][0]==3) flag=1;
	}
	for(j=1;j<=3;j++)
	{
		if(b[0][j]==3) flag=1;
	}
	if(b[0][0]==3||b[4][4]==3) flag=1;
	
	if(flag==1) printf("Yes");
	else printf("No");
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
using namespace std;

int main() {
	// your code goes here
	
	
	int n,queries;
	cin>>n>>queries;
	
	vector<int>adj[n+1];
	bool vis[n+1];
	int cnt[n+1];
	
	
	memset(vis,false,sizeof(vis));
	memset(cnt,0,sizeof(cnt));
	
	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		
		adj[b].push_back(a);
		adj[a].push_back(b);
	
	}
	
	
		
	while(queries--){
		
		int p,x;
		cin>>p>>x;
		cnt[p]+=x;
		
	}
	
	
	queue< pair<int,int> > q;
	q.push( {1,cnt[1]} );
	vis[1]=true;
	int ans[n+1];
	memset(ans,0,sizeof(ans));
	while(q.empty()==false){
		
		int node=q.front().first;
		int cnt_node = q.front().second;
		ans[node]=cnt_node;
		q.pop();
		
		for(auto child:adj[node]){
			
			if( !vis[child] ){
				vis[child] = true;
				
				q.push({ child , cnt[child] + cnt_node } );
			}
		}
	}
	
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<" ";	
	}
	
	return 0;
}

Measured memory_bytes: 17268
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    w_list = li()
    min_diff = 10000
    for i in range(n):
        left_sum = sum(w_list[:i])
        right_sum = sum(w_list[i:])
        if abs(left_sum - right_sum) < min_diff:
            min_diff = abs(left_sum - right_sum)
    print(min_diff)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9;

int main(){
  ll S;
  cin>>S;
  int y=(S+mod-1)/mod;
  int x=-1*S+mod*y;
  cout<<"0 0 1000000000 1 "<<x<<" "<<y<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

const int mo=1000000007;
int a[2000],f[2000];

int ksm(int x,int y){
	int i=1;
	for (;y;y>>=1,x=1ll*x*x%mo)
		if (y&1) i=1ll*i*x%mo;
	return i;
}

int main(){
	int n,k,m=0,ans=0;
	scanf("%d%d\n",&n,&k);
	for (int i=1;i*i<=n;i++)
		if (n%i==0) a[++m]=i;
	for (int i=m;i;i--)
		if (a[i]*a[i]!=n) a[++m]=n/a[i];
	for (int i=1;i<=m;i++){
		f[i]=ksm(k,(a[i]+1)/2);
		for (int j=1;j<i;j++)
			if (a[i]%a[j]==0) (f[i]-=f[j])%=mo;
		ans=(ans+1ll*f[i]*(a[i]&1?a[i]:a[i]/2))%mo;
	}
	printf("%d\n",(ans+mo)%mo);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main(){
    int N;
    int a[60],b[60],c[60];
    cin >> N;
    for(int i = 0;i < N;i++) cin >> a[i];
    for(int i = 0;i < N;i++) cin >> b[i];
    for(int i = 0;i < N-1;i++) cin >> c[i];
    int count = 0;
    for(int i = 0;i < N;i++){
        count += b[a[i] - 1];

    }
    for(int i = 0;i < N-1;i++){
        if(a[i+1] - a[i]==1){
            count += c[a[i+1]-2];
        }
    }
    cout << count << endl;
}

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> x(n);
  for(Int i=0;i<n;i++) cin>>x[i];
  Int ans=(x[n-1]-x[0])*2;
  for(Int i=0;i+k<=n;i++){
    Int j=i+k-1;
    if(x[i]<0&&x[j]>0) chmin(ans,abs(x[i])+abs(x[j])+min(abs(x[i]),abs(x[j])));
    else chmin(ans,max(abs(x[i]),abs(x[j])));
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  int x = A+B;
  int y = A-B;
  int z = A*B;
  if(x >= y && x >= z){
    cout << x << endl;
  }
  else if(y >= z){
    cout << y << endl;
  }
  else{
    cout << z << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
long long int a,b,c,d,B,C,D,E,max;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
B=a*c;
C=a*d;
D=b*c;
E=b*d;
  max = B;

  if(max < C) max = C;
  if(max < D) max = D;
  if(max < E) max = E;
  printf("%lld",max);
return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int m,k,i;
cin>>m>>k;
if(k>(1<<m)-1){
    cout<<-1<<endl;
    return 0;
}
if(m==1&&k==0){
    cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;
    return 0;
}
else if(m==1&&k==1){
    cout<<-1<<endl;
    return 0;
}
for(i=0;i<(1<<m);i++){
    if(i!=k)
    cout<<i<<" ";
}
cout<<k<<" ";
for(i=(1<<m)-1;i>=0;i--){
    if(i!=k)
    cout<<i<<" ";
}
cout<<k<<" ";
cout<<endl;
}


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

using namespace std;

int n, q;
vector<int> A(n);
vector<bool> isE(2001);

void solve( const int p, int t )
{
	isE.at( t ) = true;
	if( p < n ) {
		solve( p+1, t - A.at( p ) );
		solve( p+1, t );
	}
	return;
}

int main()
{
	cin>>n;
	int num, sum;
	sum = 0;
	for( int i=0; i<n; i++ ) {
		cin>>num;
		A.push_back( num );
		sum += num;
	}
	solve( 0, sum );
	cin>>q;
	for( int i=0; i<q; i++ ) {
		cin>>num;
		if( isE.at( num ) ) {
			cout<<"yes"<<'\n';			
		} else {
			cout<<"no"<<'\n';
		}
	}
    return 0;
}	

Measured memory_bytes: 1180
#coding:UTF-8
def BS(n,S,q,T):
    count=0
    for i in range(q):
        left=0
        right=n
        while left < right:
            mid=int((left+right)/2)
            if S[mid]==T[i]:
                count+=1
                break
            elif T[i]<S[mid]:
                right=mid
            else:
                left=mid+1
        
    print(count)
  
if __name__=="__main__":
    n=int(input())
    S=input().split(" ")
    for i in range(n):
        S[i]=int(S[i])
    q=int(input())
    T=input().split(" ")
    for i in range(q):
        T[i]=int(T[i])
    BS(n,S,q,T)

Measured memory_bytes: 15660
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
    double x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    cout<<fixed<<setprecision(8)<<sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))<<endl;
    return 0;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,m;
	map<int,int> mp;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		mp[a]++;
	}
	cin >> m;
	for(int i = 0;i < m;i++){
		int a;
		cin >> a;
		if(!mp[a]){
			NO();
			return 0;
		}
		mp[a]--;
	}
	YES();
	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::map<std::string, int> mp;
    for (int i = 0; i < n; i++) {
        std::string s; std::cin >> s;
        mp[s]++;
    }
    int ma = 0;
    for (auto &p : mp) ma = std::max(ma, p.second);
    for (auto &p : mp) {
        if (ma == p.second) std::cout << p.first << std::endl;
    }
    return 0;
}


Measured memory_bytes: 25216
n = int(input())

slist = []
for h in range(n):
  slist.append(input())

newlist = []
word=[]
wordy = ""
for i in range(n):
  word = list(slist[i])
  word.sort()
  for jk in range(len(word)):
	  wordy = wordy+word.pop()
  newlist.append(wordy)
  wordy=""

resdic = {}
count = 0
for item in newlist:
  if not item in resdic:
    resdic[item] = 1
  else:
    count += resdic[item]
    resdic[item] += 1
    
print(count)


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

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

  int a = 754;
  for (int i = 0; i < s.size()-2; i++) {
    int aa = (s[i]-'0') * 100 + (s[i + 1]-'0') * 10 + (s[i + 2]-'0');
    if (abs(aa - 753) < a) a = abs(aa-753);
  }

  cout << a << endl;

}


Measured memory_bytes: 256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
vector<pair<ll,ll>> adj[2501];
ll n , m , p ;
void solve(){
	vector<ll> dist(n,-inf);
	dist[0]=0;
	for(ll i=0;i<2*n ; i++){
		for(ll j=0;j<n ;j++){
			if(dist[j]==-inf)continue;
			for(auto x: adj[j]){
				if(i<n) dist[x.f]=max(dist[x.f],dist[j]+x.s);
				else if(dist[x.f]<dist[j]+x.s)dist[x.f]=inf;
			}
		}
	}
	// for(ll i=0;i<n ;i++)cerr<<dist[i]<<" ";
	if(dist[n-1]==inf)cout<<-1<<endl;
	else{
		cout<<max(0LL , dist[n-1]);
	}

}
int main(){
	//mahakal(),fast;
	cin>> n >> m >> p ; 
	for(ll i=0,a,b,c ;i<m ;i++){
		cin>>a>>b>>c;--a;--b;c-=p;
		adj[a].pb({b,c});
	}
	solve();
	return 0;
}

Measured memory_bytes: 512
n, m = gets.split.map(&:to_i)

ss = m.times.with_object([]) do |_, arr|
  _, *s = gets.split.map(&:to_i)
  arr.push(s)
end
ps = gets.split.map(&:to_i)

ans = 0

(1 << n).times do |bit|
  valid = true

  m.times do |i|
    count = ss[i].count { |s| bit[s - 1] == 1 }

    if count % 2 != ps[i]
      valid = false
      break
    end
  end

  ans += 1 if valid
end

puts ans


Measured memory_bytes: 1788
#include<cstdio>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;

typedef pair<int,int> P;

int main(){
  int c,n,m,s,g,a,b,f;
  int cost[101][101];
  int d[11][101];

  while(1){
    scanf("%d %d %d %d %d",&c,&n,&m,&s,&g);
    if(!c && !n && !m && !s && !g)break;

    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
	if(i-j)cost[i][j] = 1<<29;
	else cost[i][j] = 0;
      }
    }

    for(int i=0;i<m;i++){
      scanf("%d %d %d",&a,&b,&f);
      cost[a][b] = f;
      cost[b][a] = f;
    }

    priority_queue<P,vector<P>,greater<P> > q;
    fill(d[0],d[0]+n+1,1<<29);
    d[0][s] = 0;
    q.push(P(0,s));

    while(q.size()){
      P p=q.top();
      q.pop();
      int v = p.second;
      if(d[0][v] < p.first)continue;
      for(int i=1;i<=n;i++){
	if(d[0][i] > d[0][v] + cost[v][i]){
	  d[0][i] = d[0][v] + cost[v][i];
	  q.push(P(d[0][i],i));
	}
      }
    }

    for(int i=1;i<=c;i++){
      fill(d[i],d[i]+n+1,1<<29);
      d[i][s] = 0;
      q.push(P(0,s));

      while(q.size()){
	P p=q.top();
	q.pop();
	int v = p.second;
	if(d[i][v] < p.first)continue;
	for(int j=1;j<=n;j++){
	  if(d[i][j] > d[i][v] + cost[v][j]){
	    d[i][j] = d[i][v] + cost[v][j];
	    q.push(P(d[i][j],j));
	  }
	  if(d[i][j] > d[i-1][v] + cost[v][j]/2){
	    d[i][j] = d[i-1][v] + cost[v][j]/2;
	    q.push(P(d[i][j],j));
	  }
	}
      }
    }

    printf("%d\n",d[c][g]);
  }
}

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

#define mem(a,n) memset(a,n,sizeof(a))
#define memc(a,b) memcpy(a,b,sizeof(b))
#define rep(i,a,n) for(int i=a;i<n;i++) ///[a,n)
#define pb push_back
#define IO ios::sync_with_stdio(false)
#define fre freopen("in.txt","r",stdin)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
typedef unsigned long long ull;
const double PI=acos(-1.0);
const double E=2.718281828459045;
const double eps=1e-3;
const int INF=0x3f3f3f3f;
const int MOD=1e8+7;
const int N=1e4+5;
const ll maxn=1e6+5;
const int dir[4][2]= {-1,0,1,0,0,-1,0,1};
int main()
{
    ll n,m;
    while(cin>>n>>m)
    {
        ll ans=(n-2)*(m-2);
        cout<<abs(ans)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
'use strict'

function main(inp) {
  inp = inp.trim().split('\n')
  inp[0] = inp[0].split(' ').map(n => Number(n));
  const A = inp[1].split(' ').map(n => Number(n));
  const H = inp[0][0]
  
  let sum = 0
  A.forEach(n => sum += n);
  console.log(sum >= H ? 'Yes' : 'No')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21956
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

void solve(){
}

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

  while(T--){
    int x = 0, y = 0;
    int tx,ty;
    int ansX,ansY;
    double ans = 0;

    while(cin>>tx>>ty,tx||ty){
      x += tx;
      y += ty;
      int dist = x*x + y*y;
      if(dist > ans || ans == dist && ansX < x){
        ans = dist;
        ansX = x;
        ansY = y;
      }
    }

    cout<<ansX<<" "<<ansY<<endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int c=0;
    for(int i=0;i<s1.size();i++)
    {
        if(s1[i]!=s2[i])
            c++;
    }
    cout<<c<<endl;
    return 0;
}


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

#define F first
#define S second
#define pb push_back 
#define mp make_pair

#define ll long long 
#define ld long double 

#define vi vector <int>
#define vb vector <bool>
#define vc vector <char>
#define vll vector <ll>
#define vs vector <string>

#define pll pair < ll , ll >
#define pld pair < ld , ld >
#define pii pair < int , int >

#define vpld vector < pld >
#define vpii vector < pii >
#define vpll vector < pll >

#define vvi vector < vector < int > >
#define vvll vector < vector < ll > >
#define vvld vector < vector < ld > >
#define vvb vector < vector < bool > >
#define vvpii vector < vector < pii > >
//vector<vector<int>> v(n, vector<int>(n));

#define all(v) (v).begin() , (v).end()
#define allrev(v) (v).rbegin() , (v).rend()

#define dist(x1 , y1 , x2 , y2) sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))

const int MOD = 1e9 + 7 ;

bool isprime (ll num) {
    for (ll i = 2 ; i * i <= num ; ++i) {
		if (num % i == 0) return false ;
	}
    return true;
}
 
ll gcd (ll a, ll b) {
    if (b == 0) return a ;
	else return gcd (b , a % b) ;
}
 
ll lcm (ll a, ll b) {
    return ((a / gcd(a , b)) * b) ;
}
 
ll cel (ll x1, ll y1) {
    if ((x1) <= 0) return (x1) / (y1) ;
    return (((x1) / (y1)) + (((x1) % (y1)) != 0)) ;
}

int power(int x, unsigned int y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y%2 == 0) 
        return power(x, y/2)*power(x, y/2); 
    else
        return x*power(x, y/2)*power(x, y/2); 
} 

void solve (int test_case) {
	ll int n,count=0;
	cin>>n;
	for(ll int i=1;i<=n;i++)
	{
	    for(ll int j=1;j<=n;j++)
	    {
	        ll int k=n-(i*j);
	        if(k>n||k<=0) break;
	        else count++;//cout<<i<<' '<<j<<' '<<' '<<k<<endl;
	    }
	}
	cout<<count;
}
int main() {
	ios_base :: sync_with_stdio (false) ;
	cin.tie(0) ;
	cout.tie(0) ;
	int tc = 1 ;
	//cin >> tc ;
	while (tc--) {
		solve (tc) ;
	}
	return 0 ;
}


Measured memory_bytes: 3636
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define vcin(V) for (int i = 0; i < (V).size(); i++) { cin >> (V).at(i); }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define nn int n=0
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool; 
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
//BEGIN OF CODE.
int c = 0, cnt = 0, ans = 0;
string s, t;
int main(void){
	llint a, b;
	cin >> a >> b;
	cout << LCM(a,b) << rt;
	please AC;
}
//THE END.

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <math.h>

using namespace std;

void C_123()
{
  long long N;
  cin >> N;

  long long max_numTimes = 0;
  for (int i = 0; i < 5; ++i)
  {
    long long capa;
    cin >> capa;

    long long times = N % capa == 0 ? N / capa : N / capa + 1;
    if (max_numTimes < times) max_numTimes = times;
  }

  cout << 5 + max_numTimes-1 << endl;
}

int main()
{
  //C_120();
  //C_121();
  //C_122();
  C_123();
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define ll              long long

#define vi              vector<int>
#define pb              push_back
#define mp              make_pair

#define ff              first
#define ss              second

#define fast_in_out     ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
bool arr[11];
int main()
{
    fast_in_out
    vi con,rem;
    //freopen ("myfile.txt","w",stdout);
    int n,k,x;cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>x;
        con.pb(x);
    }
    int t;

    while(1){
        t=n;
        int i=0;

        while(t/10){
            rem.pb(t%10);
            t/=10;
        }
        rem.pb(t);
        //for(auto it1=rem.begin();it1!=rem.end();it1++)cout<<*it1<<'\t';
        //break;
        bool chosen=true;
        for(auto it1=rem.begin();it1!=rem.end();it1++){
            for(auto it2=con.begin();it2!=con.end();it2++){
                if(*it1==*it2){
                    chosen=false;
                    break;
                }
            }
            if(!chosen)break;

        }
        if(chosen){
            cout<<n<<'\n';
            return 0;
        }
        //cout<<n<<'\t';
        n++;
        while(!rem.empty())rem.pop_back();
        //while(!con.empty())con.pop_back();
    }
    return 0;
}


Measured memory_bytes: 3652
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define mod 1000000007
using namespace std;
#define ll long long int
#define mod 1000000007
ll power(ll a,ll n)
{
	ll res=1;
	while(n)
	{
		if(n%2)
		res=(res*a)%mod,n--;
		else
		a=(a*a)%mod,n/=2;
	}
	return res;
}
int main()
{
  	ll n; 	
  	cin>>n;
  	if(n==1)
  	{
  		cout<<0<<endl;
  	}
  	else if(n==2)
  	{
  		cout<<2<<endl;
  	}
  	else
  	{
  		ll a = power(10, n), b = 2*power(9,n)%mod, c=power(8, n);
  		cout <<((a-b+mod)%mod+c)%mod;
  	}		
  }

Measured memory_bytes: 3552
#include <iostream>

int main()
{
    int x, y, z;
    std::cin >> x >> y >> z;

    auto swap = [](auto& x, auto& y)
    {
        auto tmp = x;
        x = y;
        y = tmp;
    };

    swap(x, y);
    swap(x, z);

    std::cout << x << " " << y << " " << z;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  int64_t x,y;
  cin>>x>>y;
  cout<<(abs(x-y)<=1?"Brown":"Alice")<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

const int N=2040,p=924844033;
int f[N+N][N][2];
bool end[N+N];
int n,k,Ans,fac[N];

inline int qm(int x){return x<p?x:x-p;}

int main(){
	scanf("%d%d",&n,&k);fac[0]=1;
	for(int i=1;i<=n;++i)fac[i]=1ll*fac[i-1]*i%p;
	for(int i=1,tt=0,d;i<=k;++i){
		d=(n-i)/k+1;
		tt+=d,end[tt]=true;
		tt+=d,end[tt]=true;
	}
	f[1][0][0]=1;
	for(int i=1;i<=n+n;++i)
	for(int j=0;j<=n;++j){
		f[i+1][j][0]=qm(f[i][j][0]+f[i][j][1]);
		if(!end[i])f[i+1][j+1][1]=f[i][j][0];
	}
	for(int i=0,t;i<=n;++i){
		t=1ll*fac[n-i]*qm(f[n+n][i][0]+f[n+n][i][1])%p;
		if(i&1)Ans=qm(Ans-t+p);
		else Ans=qm(Ans+t);
	}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 63872
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int count=0;
    for(int i=a;i<=b;i++){
        if(c%i==0)count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3096
from sys import stdin
input = stdin.readline

n, m, q = map(int, input().split())

a = []
b = []
c = []
d = []

for i in range(q):
    tmp = list(map(int, input().split()))
    a.append(tmp[0])
    b.append(tmp[1])
    c.append(tmp[2])
    d.append(tmp[3])

def s(A):
    if A[len(A) - 1] > m or len(A) > n:
        return 0
    elif len(A) == n:
        ans = 0
        for i in range(q):
            if (A[b[i] - 1] - A[a[i] - 1] == c[i]):
                ans += d[i]
        #print(A)
        #print(ans)
        return ans
    else:
        max_ans = 0
        for i in range(A[len(A) - 1], m + 1):
            tA = list(A)
            tA.append(i)
            max_ans = max(max_ans, s(tA))
        return max_ans

T = [1]
print(s(T))


Measured memory_bytes: 9268
coin = [500,100,50,10,5,1]

data = []
while (input = $stdin.gets.to_i) > 0 do
  data << input
end

data.each do |n|
  count = 0
  i = 0
  total = 1000 - n
  while total > 0 do
    if total - coin[i] >= 0
      total -= coin[i]
      count += 1
    else
      i += 1
    end
  end
  puts count
end

Measured memory_bytes: 6084
from functools import reduce
import fractions


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n = int(input())
a = list(map(int, input().split()))
l = lcm_list(a)
ans = sum([l // x for x in a]) % int(1e9+7)
print(ans)
# print(l)
# print(a)


Measured memory_bytes: 264668
# D - Teleporter

N, K = map(int, input().split())
A = list(int(x) for x in input().split())

done = set()
path = []
now = 0
while True:
    if now in done:
        break
    else:
        path.append(now)
        done.add(now)
        now = A[now] - 1

start = path.index(now)
loop = len(path) - start
if K < start:
    steps = K
else:
    steps = (K - start)%loop + start

#print(start, loop, steps, path)
print(path[steps]+1)

Measured memory_bytes: 128592
N = int(input())

l = list(range(N))

for n in range(N):
    l[n] = int(input())

# print(l)

count_l = []
ind_list = [0] * N

for i, k in enumerate(l):
    ind_list[k-1] = i

count = 1
for i in range(N):
    if i == N - 1:
        count_l.append(count)
    else:
        if ind_list[i] < ind_list[i+1]:
            count += 1
        else:
            count_l.append(count)
            count = 1

print(N - max(count_l))

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
int main() {
    int x;
    cin >> x;
    if (x == 1) {
        cout << 0 << endl;
    }
    else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
import Control.Monad

-- data YesNo = Yes | No deriving(Show)

solver :: String -> String
solver xs =
    let y = (read :: String -> Int) xs
        z = foldr (+) 0 (map (read . return) xs :: [Int])
    in if (y `mod` z) == 0 then "Yes" else "No"

main :: IO()
main = do
    line <- getLine
    putStrLn $ solver line


Measured memory_bytes: 508
//given n integers and an integer m such that n>m then there exits a pair
//(a-b) such that (a-b)%m==0


#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
const ll M=1000000007;

void solve(){
 string s;
 cin>>s;
 int c=0,ans=0;
 for(int i=0;i<s.size();i++){
    if(s[i]=='R')c++;
    else ans=max(ans,c),c=0;
 }
 cout<<max(ans,c);
}

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


Measured memory_bytes: 3612
n, m = map(int, input().split())
list1 = list(map(int, input().split()))
list2 = [1] * n
for _ in range(m):
    a, b = map(int, input().split())
    if list1[a - 1] <= list1[b - 1]:
        list2[a - 1] = 0
    if list1[a - 1] >= list1[b - 1]:
        list2[b - 1] = 0
print(list2.count(1))

Measured memory_bytes: 20104
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1000000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll P,Q,R;
    cin >> P >> Q >> R;
    cout << P+Q+R - max({P,Q,R}) << endl;
}


Measured memory_bytes: 256
n,k = map(int, input().split())

d = input().split()

while True:
    n_list = list(set(list(str(n))))

    flag = 0
    for n_data in n_list:
        if n_data in d:
            flag = 1
            break


    if flag == 0:
        print(str(n))
        exit(0)
    else:
        n += 1

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

Measured memory_bytes: 3624