akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
void solve()
{
	int x;
	cin>>x;
	ll utility=0;
	ll ax=x/500;
	ll rest=x-ax*500;
	ll bx=rest/5;
	utility=ax*1000;
	utility+=bx*5;
	cout<<utility<<endl;
	
}

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


Measured memory_bytes: 384
n,k = map(int,input().split())
h = sorted([int(input()) for _ in range(n)],reverse=True)
mn = max(h)
for i in range(n-k+1):
    mn1 = h[i] - h[i+k-1]
    if mn1 < mn:
        mn = mn1
print(mn)

Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

bool sor(const int &a, const int &b){
    return a>b;
}
int main(){
    int me[5];
    int ma = 10;
    int count = 0;
    rep(i,5)cin >> me[i];
    rep(i,5){
        if(me[i]%10==0){
            count+=me[i];
        }else{
            if(me[i]>100){
                count+=((me[i]/10)+1)*10;
            }else if(me[i]>10){
                count+=((me[i]/10)+1)*10;
            }else {
                count+=10;
            }
        }
        
        if(me[i]>=100){
            if(me[i]%10!= 0 && (me[i]%10) < ma){
                ma = me[i]%10;
            }
        }else if(me[i]>=10){
            if(me[i]%10 != 0 && (me[i]%10) < ma){
                ma = me[i]%10;
            }
        }else if(me[i]<ma){
            ma = me[i];
        }
    } 

    cout << count-(10-ma) << endl;
    return 0;
}

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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int nr = 0, nw = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') nw++;
		else nr++;
	}
	int a = 0, b = nr;
	for (int i = 0; i < n && a != b; i++) {
		if (s[i] == 'W') a++;
		else b--;
	}
	int ans = a;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3416
#include <stdio.h>

int main(void) {
	int a[4][3][10] = {0},n, i,c,k;
	
	scanf("%d", &n);
	for(i = 0; n> i; i++){
		int b,f,r,v;
		scanf("%d%d%d%d",&b,&f,&r,&v);
		a[b-1][f-1][r-1] += v;
	}
	for(i = 0; 4 > i; i++){
		for(c = 0; 3 > c; c++){
			for(k = 0; 10 > k; k++){
				printf(" %d", a[i][c][k]);
			}
			printf("\n");
		}
		if(i == 3) break;
		for(k = 0; 20 > k; k++){
				printf("#");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;


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

Measured memory_bytes: 26032
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            out.println((int) Math.pow(in.nextInt(), 2) - in.nextInt());
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using namespace std;

const ll mod = 1e9 + 7;

struct ModComb {
    vector<long long> fact, rfact;
    long long max, mod;
    ModComb(long long ma, long long mod) :fact(ma, 0), rfact(ma, 0), max(ma), mod(mod) {
        fact[0] = 1;
        for (long long i=1; i<max; ++i) {
            fact[i] = fact[i-1]*i;
            fact[i] %= mod;
        }
        rfact[max-1] = mod_inverse(fact[max-1], mod);
        for (long long i=max-2; i>=0; --i) {
            rfact[i] = rfact[i+1]*(i+1);
            rfact[i] %= mod;
        }
    }
    long long mod_pow(long long x, long long n, long long mod) {
        long long a = 1LL;
        while (n) {
            if (n%2) a = ((a%mod)*(x%mod))%mod;
            x = ((x%mod)*(x%mod))%mod;
            n /= 2LL;
        }
        return a;
    }

    long long mod_inverse(long long a, long long m) {
        return mod_pow(a, m-2, m);
    }

    long long operator()(long long n, long long r) {
        if (n < r) return 0;
        return (((fact[n] * rfact[r]) % mod) * rfact[n - r]) % mod;
    }
};

int main() {
    ll x, y;
    cin >> x >> y;

    ModComb mb(1000000, mod);

    if ((x+y)%3 == 0) {
        if (x == y) {
            cout << mb(x/3+1+x/3-1, x/3) << endl;
        }
        else {
            ll a = max(x, y), b = min(x, y);
            ll tmp = a - b;
            if (b - tmp == a - tmp*2) {
                cout << mb((b-tmp)/3+1+(b-tmp)/3+tmp-1, (b-tmp)/3+tmp) << endl;
            }
            else {
                cout << 0 << endl;
            }
        }
    }
    else {
        cout << 0 << endl;
    }

}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100005;

ll S[maxn];
int n,q;

int main() {
	cin>>n>>q;
	for (int i=0;i<q;i++) {
		bool op; cin>>op;
		if (op) {
			int k; cin>>k;
			int ans=0;
			for (int i=k;i>0;i-=i&-i)
				ans+=S[i];
			cout<<ans<<'\n';
		}
		else {
			int s,t,x; cin>>s>>t>>x;
			for (int i=s;i<=n;i+=i&-i)
				S[i]+=x;
			for (int i=t+1;i<=n;i+=i&-i)
				S[i]+=-x;
		}
	}
}


Measured memory_bytes: 3876
#include <bits/stdc++.h>
#define N 500
#define M 50
using namespace std;

int main(){
  int n,m;
  double sx[N],sy[N],sz[N],tx[M],ty[M],tz[M],r[M];
  bool ans[N];
  while(1){
    cin>>n;
    if(!n) break;
    for(int i=0;i<n;i++) cin>>sx[i]>>sy[i]>>sz[i],ans[i]=false;
    cin>>m;
    for(int i=0;i<m;i++) cin>>tx[i]>>ty[i]>>tz[i]>>r[i];
    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
	double d1=sqrt(sx[j]*sx[j]+sy[j]*sy[j]+sz[j]*sz[j]);
	double X=sqrt(tx[i]*tx[i]+ty[i]*ty[i]+tz[i]*tz[i]);
	double Y=X*tan(r[i]);
	double t=(tx[i]*sx[j]+ty[i]*sy[j]+tz[i]*sz[j])/(X*d1);
	if(/*d1<=Y&&*/acos(t)<=r[i]) ans[j]=true;
      }
    }
    int cnt=0;
    for(int i=0;i<n;i++)
      if(ans[i]) cnt++;
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1312
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
#include <set>
typedef long long ll;
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; }
// const int MOD = 1000000007;
// const ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}

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

    vector<vector<int> > honest(n), unkind(n);
    for(int i=0; i<n; i++){
        int a;
        cin >> a;

        for(int j=0; j<a; j++){
            int x, y;
            cin >> x >> y;
            x -= 1;
            if(y == 1) honest[i].push_back(x);
            if(y == 0) unkind[i].push_back(x);
        }
    }

    int ans = 0;
    for(int bit=1; bit<(1<<n); bit++){
        set<int> people;
        for(int i=0; i<n; i++){
            if((bit>>i) & 1){
                people.insert(i);
      
            }
        }

        bool flag = true;
        for(int i=0; i<n; i++){
            if(people.find(i) != people.end()){
                for(int h : honest[i]) if(people.find(h) == people.end()) flag = false;
                for(int u : unkind[i]) if(people.find(u) != people.end()) flag = false;
            }
        }
        if(flag == true) ans = max(ans, (int)people.size());
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//
//  pcpp.cpp
//  Practice
//
//  Created by 今井咲良 on 19.10.19.
//  Copyright © 2019 今井咲良. All rights reserved.
//

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

int main(void){
    int N;
    int count = 0;
    std::cin >> N;
    //std::cout << N << "\n";
    std::vector<int> L(N, 0);

    for(int i=0; i<N; i++){
        std::cin >> L[i];
    }
    std::sort(L.begin(), L.end());
    std::reverse(L.begin(), L.end());

    /*for(int i=0; i<N; i++){
        std::cout << L[i] << ' ';
    }*/

    for(int i=0; i<N-2; i++){
        /*if(L[i] > L[i+2]+L[i+1]){
            count ++;
        }*/
        for(int j=i+1; j<N-1; j++){
            /*if(L[i] > L[j]+L[i+1]){
                count++;
            }*/
            for(int k=j+1; k<N; k++){
                if(L[i] < L[j]+L[k]){
                    count++;
                }
            }
        }
    }
    std::cout << count << std::endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
 
static const int MAX = 100;

int main(){
   
  int M[MAX][MAX];
  int n, u, k, v; 
  int i, j;
 
  scanf("%d", &n);
   
  for (i = 0; i < n; i++){
    for (j = 0; j < n; j++) {
      M[i][j] = 0;
    }
  }
   
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
     
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      M[u-1][v-1] = 1;
    }
  }
   
  for (i = 0; i < n; i++ ){
    for (j = 0; j < n; j++ ){
      if (j) printf(" ");
      printf("%d",M[i][j]);
      if(j == n-1){
    printf("\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def>pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf=1000000019;
int main(){
	double a,b;
	cin>>a>>b;
	cout<<shosu(10)<<b*b*b*acos(-1)*4/3<<endl;
}







Measured memory_bytes: 3272
use std::io;
use std::cmp;


fn main() {
    let (n, m, k) = {
        let i = read::<usize>();
        (i[0], i[1], i[2])
    };
    let an = read::<usize>();
    let bm = read::<usize>();

    let mut an_sum = vec![0usize];
    let mut bm_sum = vec![0usize];

    for i in 0..n { an_sum.push(an_sum[i] + an[i]); }
    for i in 0..m { bm_sum.push(bm_sum[i] + bm[i]); }

    let mut ans: usize = 0;
    let mut j = m;

    for i in 0..=n {
        if an_sum[i] > k { break; }
        while bm_sum[j] > k - an_sum[i] { j -= 1; }
        ans = cmp::max(ans, i + j);
    }

    println!("{}", ans);
}


#[allow(unused)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}


#[allow(unused)]
fn read_one<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


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

using namespace std;

void show_vec(vector<string> &vec){
	int N = vec.size();
	for(int i=0; i<N; ++i){
		cout << vec[i];
		if(i < N-1){
			cout << " ";
		}
	}	
	cout << endl;
}

int main(){
	string temp; 
	int N;
	cin >> N;
	vector <string> data1(N), data2(N); 
	vector<int> keep_num;
	
	// Input
	for(int i=0; i<N; ++i){
		cin >> data1[i];
		data2[i] = data1[i];
	}

	// Bubble Sort
	for(int i=0; i<N; ++i){
		for(int j=N-1; i+1<=j; --j){
			if(data1[j][1] < data1[j-1][1]){
				temp = data1[j];
				data1[j] = data1[j-1]; 
				data1[j-1] = temp;
			}
		}
	}

	// Selection Sort
	int minj;
	for(int i=0; i<N; ++i){
		minj = i;
		for(int j=i; j<N; ++j){
			if(data2[j][1] < data2[minj][1]){
				minj = j;
			}
		}

		temp = data2[i];
		data2[i] = data2[minj];
		data2[minj] = temp;
	}

	// Judge
	show_vec(data1);	
	cout << "Stable" << endl; //bubble sort is stable
	show_vec(data2);

	for(int i=0; i<N; ++i){
		if(data1[i][0] != data2[i][0]){
			cout << "Not stable" << endl;
			return 0;
		}
	}
	cout << "Stable" << endl;
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define INF 1000000001
#define ll long long
using namespace std;


//=============is_prime============================
bool is_prime(ll N)
{
  if (N == 1)
  {
    return false;
  }
  for (ll i = 2; i * i <= N; ++i)
  {
    if (N % i == 0)
    {
      return false;
    }
  }
  return true;
}
//=================================================


int main()
{
  ll X;
  cin >> X;
  while (true)
  {
    if (is_prime(X))
    {
      cout << X << endl;
      return 0;
    }
    X += 1;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=505;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int a[MAXN][MAXN],n;ll Sum[2][MAXN][MAXN],F[MAXN][MAXN];
inline ll Get(int opt,int lx,int rx,int ly,int ry){return Sum[opt][rx][ry]-Sum[opt][lx-1][ry]-Sum[opt][rx][ly-1]+Sum[opt][lx-1][ly-1];}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();
	Rep(i,1,n)Rep(j,1,n)if(j!=i)a[i][j]=read();
	Rep(i,1,n)Rep(j,1,n){
		if(i<j)Sum[0][i][j]=a[i][j];if(i>j)Sum[1][i][j]=a[i][j];
		Sum[0][i][j]+=Sum[0][i-1][j]+Sum[0][i][j-1]-Sum[0][i-1][j-1];
		Sum[1][i][j]+=Sum[1][i-1][j]+Sum[1][i][j-1]-Sum[1][i-1][j-1];
	}memset(F,0x3f,sizeof(F)),F[0][0]=0;
	Rep(i,0,n)Rep(j,0,max(i-1,0))Rep(k,i+1,n)F[k][i]=min(F[k][i],F[i][j]+Get(1,k+1,n,j+1,i)+Get(0,i+1,k,i+1,k));
	ll ans=1e18;Rep(j,0,n)ans=min(ans,F[n][j]);cout<<ans<<"\n";
	return 0;
}




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

ll n;
char s[4444];
ll ans = 0;

int main(){
	scanf("%lld%s", &n, s);
	rep(i, n){
		ll delta = 0;
		ll cnt[3], cnt2[3];
		cnt[0] = cnt[1] = cnt[2] = 0;
		cnt2[0] = cnt2[1] = cnt2[2] = 0;
		for(int len = 1; len < n; len++){
			if(i-len >= 0 && i+len < n){
				if(s[i-len] != s[i] && s[i+len] != s[i] && s[i-len] != s[i+len]) delta--;
			}
			if(i-len >= 0 && s[i-len] != s[i]){
				if(s[i-len] == 'R') cnt[0]++;
				if(s[i-len] == 'G') cnt[1]++;
				if(s[i-len] == 'B') cnt[2]++;
			}
			if(i+len < n && s[i+len] != s[i]){
				if(s[i+len] == 'R') cnt2[0]++;
				if(s[i+len] == 'G') cnt2[1]++;
				if(s[i+len] == 'B') cnt2[2]++;
			}
		}
		delta += (cnt[0]*cnt2[1] + cnt[0]*cnt2[2] + cnt[1]*cnt2[0] + cnt[1]*cnt2[2] + cnt[2]*cnt2[0] + cnt[2]*cnt2[1]);
		ans += delta;
	}
	cout << ans << endl;
	return 0;
}

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

#ifdef LOCAL 
#include "/home/gokul/Codes/lib/prettyprint.hpp"
#else
#define debug(...) 2
#endif

template <int MOD=1000000007>
struct Modular {
  int value;
  static const int MOD_value = MOD;

  Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
  Modular(long long a, long long b) : value(0){ *this += a; *this /= b;}

  Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD) value -= MOD; return *this;}
  Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD;return *this;}
  Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}

  friend Modular mexp(Modular a, long long e) {
    Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
    return res;
  }
  friend Modular inverse(Modular a) { return mexp(a, MOD - 2); }

  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
  friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
  friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;

  Modular<> dp[n + 1][n + 1], fact[n + 1], inv[n + 1];
  memset(dp, 0, sizeof dp);
  inv[0] = fact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = i * fact[i - 1];
    inv[i] = 1 / fact[i];
  }

  auto ncr = [&](int nn, int rr) {
    return fact[nn] * inv[nn - rr] * inv[rr];
  };

  auto groups = [&](int nn, int g) {
    return fact[nn] * mexp(inv[g], nn/g) * inv[nn/g];
  }; 

  dp[0][a-1] = 1;
  for (int i = a; i <= b; ++i) {

    for (int used = 0; used <= n; ++used) {
      dp[used][i] += dp[used][i-1];
    } 

    for (int j = i * c; j <= i * d; j += i) {
      for (int used = n; used >= 0; --used) {
        if (j + used <= n) {
          dp[j + used][i] += dp[used][i - 1] * ncr(n - used, j) * groups(j, i);  
        }
      }         
    }
    
  } 

  cout << dp[n][b] << '\n';
}

Measured memory_bytes: 4224
n = int(input())
a = list(map(int, input().split()))
L = sum(a)
cnt = 0
cnt_2 = 0

for i in range(n):
    cnt += a[i]
    cnt_2 = cnt - a[i]
    if cnt >= L / 2:
        break

if cnt == L / 2 or cnt_2 == L / 2:
    ans = 0
    ans_2 = 0
else:
    ans = abs(L - cnt * 2)
    ans_2 = abs(L - cnt_2 * 2)

print(min(ans, ans_2))


Measured memory_bytes: 26220
fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_line(&mut buf).ok();
    let n: usize = buf.trim().parse().unwrap();
    let mut mats = vec![vec![(0,0,0); n]; n];
    for i in 0..n {
        let mut buf = String::new();
        let _ = std::io::stdin().read_line(&mut buf).ok();
        let mut buf = buf.split_whitespace();
        mats[i][i].1 = buf.next().unwrap().parse().unwrap();
        mats[i][i].2 = buf.next().unwrap().parse().unwrap();
    }
    for j in 1..n {
        for i in 0..n-j {
            let mut res = Vec::new();
            for k in 0..j {
                res.push(mats[i][i+k].0+mats[i+k+1][i+j].0+mats[i][i+k].1*mats[i][i+k].2*mats[i+k+1][i+j].2);
            }
            mats[i][i+j].0 = *res.iter().min().unwrap();
            mats[i][i+j].1 = mats[i][i].1;
            mats[i][i+j].2 = mats[i+j][i+j].2;
        }
    }
    println!("{}", mats[0][n-1].0);
}



Measured memory_bytes: 5052
#include <stdio.h>

int main(void)
{
	float v;
	float N;
	
	while (scanf("%f", &v) != EOF){
		N = v * v / 19.6;
		N = (N + 5) / 5 + 0.5;
		printf("%.0f\n", N);
	}
	
	return (0);
}

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

int main(){
	int m[3];
	int ans=0;
	for(int i=0;i<3;i++){
		cin >> m[i];
	}
	sort(m,m+3);
	bool flag=false;
	if((m[1]-m[0])%2==1) flag=true;
	for(int i=0;i<m[2]-m[1];i++) ans++;
	ans+=(m[2]-(m[0]+ans))/2;
	if(flag) ans+=2;
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
MIN = -10**18

n,k = map(int,input().split())
a = list(map(int,input().split()))
print(math.ceil((n-1)/(k-1)))

Measured memory_bytes: 14172
#include <iostream>

using namespace std;

int main(){

    int n;
    int next = 1;
    int ans = 0;

    cin >> n;

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(a == next){
            next++;
        }
        else{
            ans++;
        }
    }

    if(next == 1){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
ll INF = 1LL<<40;

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

    int A, B, C, D;
    string s;
    cin >> s;
    A = stoi(s.substr(0,1));
    B = stoi(s.substr(1,1));
    C = stoi(s.substr(2,1));
    D = stoi(s.substr(3,1));

    if(A+B+C+D == 7){ cout << A << "+" << B << "+" << C << "+" << D; }
    else if(A+B+C-D == 7){ cout << A << "+" << B << "+" << C << "-" << D; }
    else if(A+B-C+D == 7){ cout << A << "+" << B << "-" << C << "+" << D; }
    else if(A-B+C+D == 7){ cout << A << "-" << B << "+" << C << "+" << D; }
    else if(A-B-C+D == 7){ cout << A << "-" << B << "-" << C << "+" << D; }
    else if(A-B+C-D == 7){ cout << A << "-" << B << "+" << C << "-" << D; }
    else if(A+B-C-D == 7){ cout << A << "+" << B << "-" << C << "-" << D; }
    else if(A-B-C-D == 7){ cout << A << "-" << B << "-" << C << "-" << D; }
    cout << "=7" << endl;
    return 0;
}


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

struct UFTree(T)
{
    struct Node
    {
        T parent;
        T rank = 1;
    }

    ///
    this(T n)
    {
        nodes.length = n;
        sizes.length = n;
        foreach (i, ref node; nodes) {
            node = Node(i.to!T);
            sizes[i] = 1;
        }
    }

    ///
    bool unite(T a, T b)
    {
        a = root(a);
        b = root(b);

        if (a == b) return false;

        if (nodes[a].rank < nodes[b].rank) {
            sizes[nodes[a].parent] += sizes[nodes[b].parent];
            nodes[b].parent = nodes[a].parent;
        } else {
            sizes[nodes[b].parent] += sizes[nodes[a].parent];
            nodes[a].parent = nodes[b].parent;
            if (nodes[a].rank == nodes[b].rank) nodes[a].rank += 1;
        }

        return true;
    }

    ///
    bool is_same(T a, T b)
    {
        return root(a) == root(b);
    }

    ///
    T size(T i)
    {
        return sizes[root(i)];
    }

private:
    Node[] nodes;
    T[] sizes;

    T root(T i)
    {
        if (nodes[i].parent == i) return i;

        return nodes[i].parent = root(nodes[i].parent);
    }
}

///
UFTree!T uftree(T)(T n)
{
    return UFTree!T(n);
}

void main()
{
    auto nq = readln.split.to!(int[]);
    auto N = nq[0];
    auto Q = nq[1];
    auto uft = uftree(N);
    foreach (_; 0..Q) {
        auto cxy = readln.split.to!(int[]);
        if (cxy[0] == 0) {
            uft.unite(cxy[1], cxy[2]);
        } else {
            writeln(uft.is_same(cxy[1], cxy[2])+0);
        }
    }
}


Measured memory_bytes: 4000
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int h1, m1, h2, m2, k;
   cin >> h1 >> m1 >> h2 >> m2 >> k;
   int ans = 0;
   ans = h2 * 60 + m2 - h1 * 60 - m1 - k;
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include <cstdint>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
#define ll long long int
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for(ll i=0;i<x;i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k"<<endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

int main() {
	ll N;
	string S, T;
	cin >> N;
	cin >> S >> T;
	string A;
	rep(N) {
		A.push_back(S[i]);
		A.push_back(T[i]);
	}
	cout << A;
}

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

int main() {
    int n,lin;
    vector<int> l;
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> lin;
        l.push_back(lin);
    }
    sort(l.begin(),l.end());
    int ans=0;
    for (int i=0;i<n;i++) {
        for (int j=i+1;j<n;j++) {
            auto right = lower_bound(l.begin(),l.end(),l.at(j)+l.at(i));
            ans += right-l.begin()-j-1;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int> PI;
#define MAX 99999999
vvi v(60,vi(60,0));
int w,h;
int mx[]={-1,0,1};
int my[]={-1,0,1};
void dfs(int y,int x){
        if (!v[y][x])return;
        if(v[y][x]){
            v[y][x]=0;
            rep(p,3)rep(q,3){
                int tx=x+mx[p]; int ty=y+my[q];
                if(0<=tx&&tx<w&&0<=ty&&ty<h&&v[ty][tx]!=0){
                    dfs(ty,tx);
                }
            }
        }
    }
int main(){
    while(cin>>w>>h,w+h){
        rep(i,h)rep(j,w)cin>>v[i][j];
        int ans=0;
        rep(i,h)rep(j,w){
            if(v[i][j]){dfs(i,j);
            ans++;
            }
        }
        cout<<ans<<endl;
        rep(i,60)rep(j,60)v[i][j]=0;
    }
}

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

int main() {
    char c;
    while (true) {
        scanf("%c", &c);
        if (c == '\n') {
            cout << endl;
            break;
        }

        if (!isalpha(c)) {
            cout << c;
        } else if (islower(c)) {
            cout << (char) toupper(c);
        } else {
            cout << (char) tolower(c);
        }
    }
}

Measured memory_bytes: 1144
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define INF 10000000
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, i, j, k, x;
	cin >> n;

	vector<int> dp(n + 1, INF);
	dp[0] = 0;
	for (i = 0; i < n; i++) {
		dp[i + 1] = min(dp[i + 1], dp[i] + 1);
		for (x = 6; i + x <= n; x *= 6) dp[i + x] = min(dp[i + x], dp[i] + 1);
		for (x = 9; i + x <= n; x *= 9) dp[i + x] = min(dp[i + x], dp[i] + 1);
	}

	cout << dp[n] << "\n";

	return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, H;
    cin >> N >> H;
    int ma_a = 0;
    priority_queue<int> Q;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        ma_a = max(ma_a, a);
        Q.push(b);
    }

    int ans = 0;
    while(!Q.empty() && Q.top() > ma_a && H > 0) {
        H -= Q.top(); Q.pop();
        ans++;
    }
    if (H > 0) {
        ans += (H + ma_a - 1) / ma_a;
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    double ans = 0;
    for(int i = 0; i < N; i++) {
        double x; string u;
        cin >> x >> u;
        ans += (u=="BTC" ? x*380000.0 : x);
    }
    cout << fixed << setprecision(5) << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,p;
  cin >> a >> b >> c >> d >> p;
  a = a*p;
  if(p>c) b += (p-c)*d;

  if(a<b){
    cout << a << endl;
  }
  else{
    cout << b << endl;
  }
  return 0;
}



Measured memory_bytes: 3076
#pragma gcc optimize("Ofast")
#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 ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,x);
  Vi V(n);
  VIN(V)
  int last = 0;
  FOR(i,1,n){
    if(last + x >= V[i]){
      z += V[i] - last;
    } else {
      z += x;
    }
    last = V[i];
  }
  OUT(z+x);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;

int main() {
    int a = int(5);
    int n, q;
    cin >> n >> q;
    dsu d(n);
    for (ll i = 0;i < q;++i) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            d.merge(u, v);
        }
        else if (t == 1) {
            cout << d.same(u, v) << endl;
        }
        else cout << "WA";
    }
}


Measured memory_bytes: 3992
#include<iostream>
#include<string>
#include<cmath>
#include<vector>

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

	if( n%10 ==2 ||
	    n%10 ==4 ||
	    n%10 ==5 ||
	    n%10 ==7 ||
	    n%10 ==9 )
	    std::cout<<"hon"<<std::endl;
	else if(n%10 ==0 ||
			n%10 ==1 ||
			n%10 ==6 ||
			n%10 ==8 )
		std::cout<<"pon"<<std::endl;
	else
		std::cout<<"bon"<<std::endl;

	return 0;	

}

Measured memory_bytes: 3636
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int dp[100001];
int p[11];
vector<char> d;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  reps(i,n){
    if(i % 2 == 0) continue;
    int sum = 0;
    reps(j,i){
      if(i%j == 0) sum++;
    }
    if(sum == 8) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	LL n;
	cin >> n;
	LL a[5];
	REP(i, 5)cin >> a[i];
	LL x = 1e18;
	REP(i, 5)x = min(x, a[i]);
	cout << (n - 1)/ x + 5 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int x,y,tmp,r;

  scanf("%d%d",&x,&y);
  
  if(x < y){
  
    tmp = x;
    x = y; 
    y = tmp;
   
  }

  r = x % y; 
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }

  printf("%d\n",y);
 
  return 0;
}

Measured memory_bytes: 592
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

bool isSymmetry(string str){
  // x := i w ""
  // "i" x "i"
  // "w" x "w"
  // "(" x ")"
  // ")" x "("
  // "{" x "}"
  // "}" x "{"
  // "[" x "]"
  // "]" x "["
  for(int i=0,j=str.size()-1;i<str.size() && i <= j;i++,j--){
    if(str[i] == 'i' && str[j] != 'i') return false;
    else if(str[i] == 'w' && str[j] != 'w') return false;
    else if(str[i] == '(' && str[j] != ')') return false;
    else if(str[i] == ')' && str[j] != '(') return false;
    else if(str[i] == '{' && str[j] != '}') return false;
    else if(str[i] == '}' && str[j] != '{') return false;
    else if(str[i] == '[' && str[j] != ']') return false;
    else if(str[i] == ']' && str[j] != '[') return false;
  }
  return true;
}

bool has_iwi(string str){

  int iwi_num = 0;
  for(int i=0;i+2<str.size();i++){
    if(str[i] == 'i'
       && str[i+1] == 'w'
       && str[i+2] == 'i'){
      iwi_num++;
    }
  }
  if(iwi_num != 1) return false;

  int i_num=0;
  int w_num=0;
  for(int i=0;i<str.size();i++){
    if(str[i] == 'i') i_num++;
    if(str[i] == 'w') w_num++;
  }

  if(i_num != iwi_num*2) return false;
  if(w_num != iwi_num) return false;

  return true;
}

int main(){
  char buf[16];

  while(~scanf("%s",buf)){
    int res = 0;
    for(int S=0;S<=(1<<strlen(buf)) -1; S++){
      string str = "";
      for(int i=0;i<strlen(buf);i++){
	if(S & (1<<i)) str.push_back(buf[i]);
      }
      if(!has_iwi(str)) continue;
      if(isSymmetry(str)) res = max(res,(int)str.size());
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

int n;
double dp[3002][3002];


signed main() {
    cin >> n;
    vector<double> p(n);
    rep(i,n) cin>>p[i];

    // rep(i,3002) rep(j,3002) dp[i][j] = 0.0;
    dp[0][0] = 1 - p[0];
    dp[0][1] = p[0];

    FOR(i,1,n){
        dp[i][0] = (1-p[i]) * dp[i-1][0];
        FOR(j,1,i+2) dp[i][j] = p[i] * dp[i-1][j-1] + (1-p[i]) * dp[i-1][j];
        // rep(j,n+1) cerr << dp[i][j] << ' ';
        // cerr << endl;
    }
    double ans = 0.0;
    FOR(i,n/2+1,n+1) {
        ans += dp[n-1][i];
        // cerr << dp[n-1][i] << endl;
    }
    printf("%.16f\n", ans);

    return 0;
}

Measured memory_bytes: 68992
#include <iostream>

int main(void) {
    int k, a, b;

    std::cin >> k;
    std::cin >> a >> b;

    bool achieved = false;

    for (int i = a; i <= b; ++i) {
        if (i % k == 0) {
            achieved = true;
            break;
        }
    }

    if (achieved) {
        std::cout << "OK\n";
    } else {
        std::cout << "NG\n";
    }
}

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

int main() {
  int s; cin >> s;
  
  vector<int> ai;
  ai.push_back(s);
  while (true) {
    int n = ai.back();
    int nn = 0;
    if (n%2 == 0) nn = n/2;
    else nn = 3*n+1;
    if (find(ai.begin(), ai.end(), nn) != ai.end()) {
      cout << ai.size()+1 << endl;
      break;
    } else ai.push_back(nn);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
#define int long long
int contor[100005], n, q, x, y, sum;
int32_t main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        sum += x;
        ++contor[x];
    }
    cin >> q;
    while (q--) {
        cin >> x >> y;
        sum += (y - x) * contor[x];
        contor[y] += contor[x];
        contor[x] = 0;
        cout << sum << '\n';
    }
    PLEC
}


Measured memory_bytes: 4432
import sys

input = sys.stdin.readline

h, w, k = map(int, input().split())
s = [input() for _ in range(h)]

cs = [[0] * (w + 1) for _ in range(h + 1)]
for i in range(h):
    for j in range(w):
        cs[i + 1][j +
                  1] = cs[i][j + 1] + cs[i + 1][j] - cs[i][j] + int(s[i][j])


def f(i1, j1, i2, j2):
    return cs[i1][j1] - cs[i1][j2] - cs[i2][j1] + cs[i2][j2]


ans = h + w
for bit in range(1 << (h - 1)):
    border = [0]
    cand = 0
    for i in range(h):
        if (bit >> i) & 1:
            border.append(i + 1)
            cand += 1
    border.append(h)

    # 貪欲に縦の線に沿って折る
    j0 = 0
    for j in range(w):
        for i in range(len(border) - 1):
            if f(border[i + 1], j + 1, border[i], j0) > k:
                cand += 1
                j0 = j
                break

    # 最後に残ったピースたちがk以下かチェック
    is_possible = True
    for i in range(len(border) - 1):
        if f(border[i + 1], w, border[i], j0) > k:
            is_possible = False
            break

    if is_possible:
        ans = min(ans, cand)
print(ans)


Measured memory_bytes: 44124
#include "limits.h"
#include <cstring>
#include <iostream>
using namespace std;
#define Maxvernum 100000
#define Maxarcnum 500000
typedef struct arcs
{
	int start;
	int to;
	int cost;
};
arcs input[Maxarcnum];
int dist[Maxvernum];
int visited[Maxvernum];
int V, E, r;
void BellmanFord(int r)
{
	while(1)
	{
		int flag = 0;
		for (int i=0; i<E; i++)
		{
			if (dist[input[i].start] != INT_MAX && dist[input[i].start] + input[i].cost < dist[input[i].to])
			{
				dist[input[i].to] = dist[input[i].start] + input[i].cost;
				flag = 1;
			}
		}
		if (flag == 0)
			break;
	}
}
int main()
{
	cin>>V>>E>>r;
	for (int i=0; i<Maxvernum; i++)
		dist[i] = INT_MAX;
	memset(visited, 0, sizeof(visited));
	for (int i=0; i<E; i++)
	{
		cin>>input[i].start>>input[i].to>>input[i].cost;
		if (input[i].start == r)
			dist[input[i].to] = input[i].cost;
	}
	dist[r] = 0;
	visited[r] = 1;
	BellmanFord(r);
	for (int i=0; i<V; i++)
		if (dist[i] != INT_MAX)
			cout<<dist[i]<<endl;
		else
			cout<<"INF"<<endl;
	return 0;
}

Measured memory_bytes: 9512
#include<cstdio>
#include<cstring>
#define MN 300
char s[MN+5];
int ls[MN+5][26],f[MN+5][MN+5][MN+5];
inline void rw(int&a,int b){if(b>a)a=b;}
int main()
{
	int n,m,i,j,k,ans=0;
	scanf("%s%d",s+1,&m);n=strlen(s+1);
	for(i=1;i<=n;++i)
	{
		for(j=0;j<26;++j)ls[i][j]=ls[i-1][j];
		ls[i][s[i]-'a']=i;
	}
	for(i=1;i<=n;++i)for(j=n;j>=i;--j)for(k=0;k<=m;++k)
	{
		rw(f[i+1][j][k],f[i][j][k]);
		if(ls[j][s[i]-'a']>i)rw(f[i+1][ls[j][s[i]-'a']-1][k],f[i][j][k]+2),rw(ans,f[i][j][k]+2);
		rw(ans,f[i][j][k]+1);
		if(i<j&&k<m)rw(f[i+1][j-1][k+1],f[i][j][k]+2),rw(ans,f[i][j][k]+2);
	}
	printf("%d",ans);
}

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

int main () {
	ll int n,ans=1;

	cin >> n;

	for(ll int i=1;i<=n;i++){
		ans *= i;
		ans = ans%1000000007;
	}


	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256