akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl '\n'
#define maxl __LONG_LONG_MAX__
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define rep(i, n) for(int i = 0; i < n; i++)
#define rev(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i=1; i < n; i++)
#define rev1(i, n) for(int i=n ; i > 0; i--)
#define FOR(i, a, b) for(int i=a ; i < b; i++)
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define n_ones(x) __builtin_popcountll(x)
#define n_trailzero(x) __builtin_ctzll(x)
#define n_leadingzero(x) __builtin_clz(x)
#define sz(a) (ll)(a.size())

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vector<ll>> vvll;
typedef stack<ll> stk;
typedef queue<ll> que;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_setll;
typedef tree<char,null_type,less<char>,rb_tree_tag,
tree_order_statistics_node_update> indexed_setc;

ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}

ll mod = 1e9 + 7;

void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	rep(i, n)
		cin>>a[i];
	ll dp[n][n] = {0};
	//dp[i][j] -> value of X - Y when left and right pointers are at i and j
	for(ll i = n-1 ; i >= 0; i--)
	{
		for(ll j = i; j < n; j++)
		{
			if(i == j)
				dp[i][j] = a[i];
			else
				dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
		}	
	} 
	cout<<dp[0][n-1]<<endl;
	return;
}

int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
	ll t = 1;
	//cin>>t;
	rep(i, t)
		solve();
	return 0;
	
}

Measured memory_bytes: 70656
fn main() {
    let n: i64 = read();
    let mut rtnc: i64 = ((n as f64).sqrt()) as i64;

    loop {
        if n % rtnc == 0 {
            let ans = rtnc - 1 + n / rtnc - 1;
            println!("{}", ans);
            break;
        }
        rtnc -= 1
    }
}





//**********************************************************************************************************************************************//

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: u64) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

ll gcd (ll a, ll b){
    ll k = a % b;
    while (k > 0){
        a = b;
        b = k;
        k = a % b;
    }
    return b;
}

int main() {
    ll n, m, k; cin >> n >> m >> k;
    vector<ll> rui(n+1,0LL);
    vector<ll> lui(m+1,0LL);
    rep(i,n){
        ll a; cin >> a;
        rui[i+1] = rui[i] + a;
    }
    rep(i,m){
        ll a; cin >> a;
        lui[i+1] = lui[i] + a;
    }
    ll ans = 0LL;
    int cl = m;
    //printvec(rui);
    //printvec(lui);
    rep(i,n+1){
        ll ima = i;
        ll le = k - rui[i];
        if (le < 0){
            break;
        }
        if (le >= lui[m]){
            ima += m;
            ans = max(ans,ima);
            continue;
        }
        while (lui[cl] > le){
            cl--;
        }
        ans = max(ans,ima+cl);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6416
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define pue <<" "<<
using namespace std;
using LL = long long;
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 INF = 1e9;
const LL LLINF = 1e16;

int dp[1<<20][20];

int main(){
    fastcin();
    int n;
    cin >>n;
    vector<pair<int, int>> a(n);
    rep(i, n) cin >> a[i].first;
    rep(i, n) cin >> a[i].second;
    rep(i, 1<<20)rep(j, 20) dp[i][j] = INF;
    rep(i, n) dp[0][i] = 0;

    rep(i, 1<<n){
        int ct = __builtin_popcount(i);
        rep(j, n)if(i==0||i&(1<<j)){
            int cost = 0;
            rep(k, n)if(!(i&(1<<k))){
                int now = (abs(j-ct-1)%2) ? a[j].second:a[j].first;
                int nxt = (abs(k-ct)%2) ? a[k].second:a[k].first; 
                if(i==0) now = -1;
                if(now <= nxt){
                    // cout << bitset<3>(i|(1<<k)) pue now pue nxt pue endl;
                    chmin(dp[i|(1<<k)][k], dp[i][j]+cost);
                }
                cost++;
            }
        }
    }
    int ans = INF;
    rep(i, n) chmin(ans, dp[(1<<n)-1][i]);
    if(ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 82304
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/

int main() {
	ll N; cin >> N;
	int max = 0;
	int ans = 0;
	bool okl = false;
	bool okr = false;
	string S; cin>>S;
	for (int t = 1;t < S.size();t++) {
		max = 0;
		for (int i = 0;i < t;i++) {
			okr = false;
			okl = true;
			for (int r = t;r < S.size();r++) {
				if (S[i] == S[r]) {
					okr = true;
					break;
				}
			}
			for (int l = i - 1;l >= 0;l--) {
				if (S[i] == S[l]) {
					okl = false;
					break;
				}
			}
			if (okr && okl) max++;
		}
		if (max > ans) ans = max;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


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

    if (a <= c && c <= b) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
    scanf("%d%d%d",&a,&b,&c);
    if (a+b>=c) printf("%d\n",b+c);
    else printf("%d\n",2*b+min(c-b,a+1));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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 keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a.begin(), a.end());

    ll now = a[0];
    ll count = 1;
    ll ans = 0;
    for(ll i=1;i<n;++i){
        if(now == a[i]){
            count++;
        }else{
            if(now > count){
                ans += count;
            }else if(now < count){
                ans += count - now;
            }
            now = a[i];
            count = 1;
        }
    }
    if(now > count){
        ans += count;
    }else if(now < count){
        ans += count - now;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n, s[1000], count;
	double m, dispersed;

	while (1)
	{
		scanf("%d", &n);

		if (n == 0)
			break;

		for (count = 0, m = 0; count < n; count++)
		{
			scanf("%d", &s[count]);
			m = m + s[count];
		}

		m = m / n;

		for (count = 0, dispersed = 0; count < n; count++)
		{
			dispersed = dispersed + pow((s[count] - m), 2.0000);
		}

		dispersed = dispersed / n;

		printf("%.8f\n", (double)sqrt(dispersed));

	}
	return 0;
}


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

#define ll long long

int main()
{
    ll n,i,j,k,l;
    cin>>n;
    if(n==1)
        cout<<"Hello World"<<endl;
    else
    {
        cin>>k>>l;
        cout<<k+l<<endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}
ll gcd(ll a, ll b) {
	if (a < b)return gcd(b, a);
	if (b == 0)return a;
	return gcd(b, a%b);
}
ll gcd3(ll a, ll b, ll c) {
	return gcd(gcd(a, b), c);
}



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

	int k;
	cin >> k;
	ll ans = 0;
	REPS(i, k) {
		FOR(j, i, k + 1) {
			FOR(l, j, k + 1) {
				int cnt = 0;
				ll res = gcd3(i, j, l);
				if (i == j)cnt++;
				if (j == l)cnt++;
				if (cnt == 2)ans += res;
				if (cnt == 1)ans += res * 3;
				if (cnt == 0)ans += res * 6;
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

#define FAST_IO ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define maxn 3005
#define endl "\n"
typedef long long ll;

double p[maxn];
double dp[maxn][maxn];
 
int main(){ 
	
	FAST_IO;

   
	int n;
	cin>>n;
	
	for(int i=1; i<=n; i++)
		cin>>p[i];

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

	dp[1][0] = 1-p[1];
	dp[1][1] = p[1];

	for(int i=2; i<=n; i++){
		dp[i][0] = dp[i-1][0]*(1-p[i]);
		dp[i][i] = dp[i-1][i-1]*p[i];

		for(int j=1; j<i; j++){
			dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
		}
	}

	double ans = 0;
	for(int i=n/2+1; i<=n; i++){
		ans += dp[n][i];
	}

	printf("%.15lf\n",ans);


}
 

Measured memory_bytes: 70784
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 100005;

int c[N];
int l[N];

int main(){
    fill(c,c+N,1);
    l[1] = 1;
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        --c[x];
        ++c[y];
        if(l[x]==1){
            l[y] = 1;
            if(c[x]==0){
                l[x] = 0;
            }
        }
    }
    int a = 0;
    for(int i=1;i<=n;i++){
        if(l[i]==1){
            ++a;    
        }
    }
    printf("%d\n",a);
    return 0;   
}

Measured memory_bytes: 896
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S;

LL ans = INF;

void solve(){
    //解法：
    //A - N = B となるようなA,Bを決めて、
    //Aの各桁を足した数＋Bの各桁を足した数
    //の最小値を求める
    //Aを決めれば自動的にBも決まる

    //Aの桁数＝Sの桁数+1となる場合があるのでそれを考慮して
    //入力された数の頭の桁に0を追加しておく
    S='0'+S;
    reverse(S.begin(),S.end());//文字列Sを反転
    int n = S.size();//Sが何桁の数なのかを保管
    //下からi桁目まで見て、繰り下がりがj(0 or 1)のときの
    //使う紙幣の枚数の最小値をdp[i][j]とおく
    vector<vector<LL>> dp(n+1,vector<LL>(2,INF));
    //0桁決めた状態では繰り下がりは0
    dp[0][0] = 0;
    //下からi桁目を見る
    //配るイメージのDP
    for(int i=0;i<n;i++){
        //j=0なら繰り下がりなし
        //j=1なら繰り下がりあり
        for(int j=0;j<2;j++){
            int x = S[i] - '0';//今見ている数
            x += j;//jくりさがる
            for(int a=0;a<10;a++){//aをAのi桁目であると仮定する
                int nj=0;//繰り下がりがあるなら1にする
                int b = a-x;//これが負＝くり下がりが発生
                if(b<0){
                    nj = 1;
                    b += 10;
                }
                dp[i+1][nj] = min(dp[i+1][nj],dp[i][j]+a+b);
            }
        }
    }
    ans = dp[n][0];
}
 
int main(){
	cin >> S;
 
	solve();

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

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

int main() {
  vector<int>a(5);
  for (int i = 0; i < 5; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < 5; i++) {
    if (a.at(i) == 0) {
      cout << i+1 << endl;
    }
  }
}  




Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

vector<long long> x(8);
vector<long long> y(8);

ll perm2[8];
double res = 0;
void permutation2(int n) {
	for (int i = 0; i < n; i++) {
		perm2[i] = i;
	}
	do {
		for (int i = 0; i < n-1; i++) {
			res += sqrt((x[perm2[i]]-x[perm2[i+1]])*(x[perm2[i]]-x[perm2[i+1]])+(y[perm2[i]]-y[perm2[i+1]])*(y[perm2[i]]-y[perm2[i+1]]));
		}
	} while (next_permutation(perm2, perm2 + n));
	return ;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&x[i]);
		scanf("%lld",&y[i]);
	}
	permutation2(N);
	repn(i, N) {
		res /= i;
	}
	printf("%.16f\n", res);
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    sc.nextLine();
    List<Long> A = Arrays.stream(sc.nextLine().split(" "))
      .map(Long::parseLong)
      .collect(Collectors.toList());
    if (A.contains(0L)) {
      System.out.println(0);
      return;
    }
    BigDecimal ans = BigDecimal.valueOf(1);
    for (int i = 0; i < N; i++) {
      ans = ans.multiply(BigDecimal.valueOf(A.get(i)));
      if (ans.compareTo(BigDecimal.valueOf(1).scaleByPowerOfTen(18)) > 0) {
        ans = BigDecimal.valueOf(-1);
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 61444
n = gets.chomp.to_i

ans = 0
if n < 10
  ans = n
elsif n < 100
  ans = 9
elsif n < 1000
  ans = n - 90
elsif n < 10000
  ans = 909
elsif n < 100000
  ans = n - 9090
else
  ans = 90909
end

puts(ans)

Measured memory_bytes: 1788
import java.text.NumberFormat;
import java.util.Scanner;

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

        int n = sc.nextInt();

        long numbers[] = new long[n];

        for(int i = 0; i < n; i++) {
            numbers[i] = sc.nextLong();
            if(numbers[i] == 0){
                System.out.println(0);
                return;
            }
        }

        double ans = 0;
        for(int i = 0; i < n;i++){
            double d = Math.log10(numbers[i]);
            ans += d;
        }

        if(ans > 18){
            System.out.println(-1);
            return;
        }else{
            long answer = 1;
            for(int i = 0;i < n;i++){
                answer *= numbers[i];

                if(answer > (long)1e18){
                    System.out.println(-1);
                    return;
                }
            }

            System.out.println(answer);

        }

//        long ans = 1;
//        for(int i = 0;i < n;i++){
//            ans *= numbers[i];
//
//            if(ans > (long)1e18){
//                System.out.println(-1);
//                return;
//            }
//        }
//
//        System.out.println(ans);



//        NumberFormat nm = NumberFormat.getNumberInstance();
//        System.out.println(nm.format(l));


    }
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 2010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m,Q;

char st[maxn][maxn];

int sm1[maxn][maxn],sm2[maxn][maxn],sm3[maxn][maxn];

void Work(){
	while(Q--){
		int x1,y1,x2,y2;
		read(x1,y1,x2,y2);
		int V=sm1[x2][y2]-sm1[x1-1][y2]-sm1[x2][y1-1]+sm1[x1-1][y1-1];
		int E=sm2[x2][y2]-sm2[x1-1][y2]-sm2[x2][y1]+sm2[x1-1][y1]
			 +sm3[x2][y2]-sm3[x1][y2]-sm3[x2][y1-1]+sm3[x1][y1-1];
		printf("%d\n",V-E);
	}
}

void Init(){
	read(n,m,Q);
	REP(i,1,n)scanf("%s",st[i]+1);
	REP(i,1,n)REP(j,1,m)sm1[i][j]=sm1[i-1][j]+sm1[i][j-1]-sm1[i-1][j-1]+(st[i][j]-'0');
	REP(i,1,n)REP(j,1,m)sm2[i][j]=sm2[i-1][j]+sm2[i][j-1]-sm2[i-1][j-1]+((st[i][j]=='1')&&(st[i][j-1]=='1'));
	REP(i,1,n)REP(j,1,m)sm3[i][j]=sm3[i-1][j]+sm3[i][j-1]-sm3[i-1][j-1]+((st[i][j]=='1')&&(st[i-1][j]=='1'));
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 53120
#include <stdio.h>
#define N 505
int A[N],B[N],g[N][N],n,k,mt[N],used[N];
int inline gcd(int a, int b) {while (b) {int c=a%b;a=b,b=c;} return a;}
int kuhn(int v) {if (used[v]) return 0;used[v]=1;for (int i=g[v][0]-1;i;i--) {int to=g[v][i];if (mt[to]==-1 || kuhn(mt[to])) {mt[to]=v;return 1;}}return 0;}
int main() {
	int i,j;while (scanf("%d %d",&n,&k)!=EOF && (n || k)) {
		for (i=0;i<k;mt[i++]=-1);
		for (i=0;i<n;g[i][0]=1,scanf("%d",&A[i++]));for (i=0;i<k;scanf("%d",&B[i++]));
		for (i=0;i<n;i++) for (j=0;j<k;j++) if (gcd(A[i],B[j])>1) g[i][g[i][0]++]=j;
		for (i=0;i<n;i++) {for (j=0;j<n;used[j++]=0);kuhn(i);}
		for (i=0,j=0;i<k;j+=(mt[i]!=-1),i++);printf("%d\n",j);
	}
	return 0;
}

Measured memory_bytes: 2044
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int H,N,W,a,b,c,d,i,j;
    cin>>H>>W>>N;
    vector<vector<int> > data(H,vector<int>(W));
a=data.at(0).size();
b=data.size();
if(a>b){
    if(N%a==0){
c=N/a;
    }
    else{
c=(N/a)+1;
    }  
}
else{
    if(N%b==0){
        c=N/b;
    }
    else{
c=(N/b)+1;
    }
}
    
    cout<<c<<endl;
    return 0;
}

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

public class Main {
	
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		solver.solve(1, scan, out);
		out.close();
	}
	
	static class Task {
		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			int a = scan.nextInt(), b = scan.nextInt();
			out.println(Math.max(Math.max(a+b, a*b), a-b));
		}
	}
	
	

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 23380
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DIHateFactorization {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int X;
        cin >> X;

        vector<int> fact(100005);
        map<int, int> m;
        FOR(i, 0, 1000) {
            fact[i] = 1;
            REP(j, 5) {
                fact[i] *= i;
            }
            m[fact[i]] = i;
        }
        FOR(i, 1, 100000) {
            int a5 = fact[i];
            int b5 = a5 - X;
            int sign = 1;
            if (b5 < 0) {
                b5 *= -1;
                sign = -1;
            }
            if (m.count(b5)) {
                cout << i << " " << sign * m[b5] << endl;
                return;
            }
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DIHateFactorization solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3992
import java.util.*;

class Main{
    Scanner sc = new Scanner(System.in);
    
    Main(){
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if ( H == 0 && W == 0 ) break;
            for ( int row = 0; row < H; row++){
                for ( int col = 0; col < W; col++){
                    if ( row == 0 || row == (H - 1) || col == 0 || col == (W - 1) ) {
                        System.out.print("#");
                    }else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
    public static void main(String[] args){
        new Main();
    }
}
                    


Measured memory_bytes: 36480
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final int k = sc.nextInt();

        double sum = 0;
        final double base = 0.5;
        final double base2 = 1/(double)n;
        for (int deme = 1;deme <= n;++deme)
        {
            int nn = 0;
            int s = deme;
            while (s < k)
            {
                s *= 2;
                ++nn;
            }
            sum += base2*Math.pow(base,nn);
        }
        System.out.println(sum);
        sc.close();
    }
}

Measured memory_bytes: 21076
l = list(map(int, input().split()))
l.sort(reverse=True)
x = l[0] - l[1]
y = l[0] - l[2]
count = 0

if x % 2 == 0 and y % 2 == 1:
    x += 1
    count += 1
if y % 2 == 0 and x % 2 == 1:
    y += 1
    count += 1

if x % 2 == 1 and y % 2 == 1:
    count += (x+1)//2
    count += (y-1)//2
    print(count)
elif x % 2 == 0 and y % 2 == 0:
    print((x+y)//2)


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

int main() {
  	string s;
	int i,n;
  
  	cin >> s;
  
  	n=0;
  	for (i=0;i<3;++i)
    {
	 	if (s[i]=='1' )
	      n+=1;
    }
  	cout << n << endl;
}

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

if x == 0:
    if k % 2 == 1:
        x = d

elif x > 0:
    if x >= k*d:
        x -= k*d
    else:
        n = x//d
        x -= n*d
        k -= n

        if k%2 ==1:
            x -= d
else:
    if x <= -(k*d):
        x += k*d

    else:
        n = abs(x)//d
        x += n*d
        k -= n
        if k%2 ==1:
            x += d

print(abs(x))

Measured memory_bytes: 9172
import Text.Printf

dist [x1,y1,x2,y2] = sqrt $ (x2-x1)**2 + (y2-y1)**2

main1 = do
  points <- fmap (map read . words) getLine :: IO [Double]
  printf "%.8f\n" (dist points)

degreeToRadian deg = pi * deg / 180

cosine a b rad = sqrt $ (a**2) + (b**2) - (2*a*b*(cos rad))

solve2 [a,b,deg] = (s,l,h)
  where
    rad = degreeToRadian deg
    h = b * (sin rad)
    s = a * h / 2
    l = a + b + (cosine a b rad)

main = do
  abc <- fmap (map read . words) getLine :: IO [Double]
  let (s,l,h) = solve2 abc
  printf "%.8f\n" s
  printf "%.8f\n" l
  printf "%.8f\n" h



Measured memory_bytes: 4276
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX_M = 10;
const int MAX_N = 45;
const int INF = 100000000;

//input
int N;
int d[MAX_M][MAX_M];

int maxIndex;
int sum[MAX_M];

void solve(){
	for(int k = 0; k <= maxIndex; k ++){
		for(int i = 0; i <= maxIndex; i ++){
			for(int j = 0; j <= maxIndex; j ++){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	int index, ans = INF;
	for(int i = 0; i <= maxIndex; i ++){
		sum[i] = 0;
		for(int j = 0; j <= maxIndex; j ++){
			sum[i] += d[i][j];
		}
		if(ans > sum[i]){
			index = i;
			ans = sum[i];
		}
	}
	printf("%d %d\n", index, ans);
}

int main(int argc, char const *argv[]){

	while(scanf("%d", &N) && N != 0){
		//init
		for(int i = 0; i < MAX_M; i ++){
			fill(d[i], d[i] + MAX_M, INF);
			d[i][i] = 0;
		}
		maxIndex = 0;
		//input
		for(int i = 0; i < N; i ++){
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);
			d[a][b] = c;
			d[b][a] = c;
			maxIndex = max(maxIndex, a);
			maxIndex = max(maxIndex, b);
		}
		solve();
	}

	return 0;
}

Measured memory_bytes: 1184
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <map>
#include <string>
#include <vector>

using namespace std;

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

  long long sum = 0;
  map<int, int> M;
  // vector<int> A(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    // A[i] = a;
    if (M.find(a) == M.end()) {
      M[a] = 1;
    } else {
      M[a]++;
    }
    sum += a;
  }

  int Q;
  cin >> Q;

  string result;
  for (int i = 0; i < Q; i++)  {
    int B, C;
    cin >> B >> C;

    long long r = sum;
    if (M.find(B) != M.end()) {
      int n = M[B];
      if (M.find(C) != M.end()) {
        M[C] += M[B];
        M[B] = 0;
      } else {
        M[C] = M[B];
        M[B] = 0;
      }
      r += (C * n) - (B * n);
    }

    
    // for (auto& it : M) {
    //   r += it.first * it.second;
    // }
    result += to_string(r) + "\n";
    sum = r;
  }
  cout << result;

  return 0;
}


Measured memory_bytes: 7964
/*input
4 5
1 2
1 3
3 2
2 4
3 4
*/
#include<bits/stdc++.h>
using namespace std;

void dfs(int u,vector<int> &vis,vector<int> &dp,vector<vector<int>> &g)
{
	// cout<<u<<"\n";
	vis[u]=1;
	dp[u]=0;
	for(int i=0;i<g[u].size();i++)
	{
		if(vis[g[u][i]]==0) dfs(g[u][i],vis,dp,g); 
		dp[u]=max(dp[u],1+dp[g[u][i]]);
	} 
	return ;	
}

int main()
{
	int n,m;cin>>n>>m;
	vector<vector<int>> g(n,vector<int> ());
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		x--,y--;
		g[x].push_back(y);
	}


	vector<int> dp(n,0);
	vector<int> vis(n,0);

	for(int i=0;i<n;i++) if(vis[i]==0) dfs(i,vis,dp,g);
	// for(int i=0;i<n;i++) cout<<dp[i]<<" ";
	cout<<*max_element(dp.begin(), dp.end());
	return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    string s;
    cin >> s;
    string sx(s.size(), 'x');
    cout << sx << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans=1<<30;
main()
{
    string s,t;
    cin>>s;
    cin>>t;
    for(int i=0;i<=s.size()-t.size();++i)
    {
        int c=0;
        for(int j=0;j<t.size();++j){
            c+=s[j+i]!=t[j];
        }
        ans=min(ans,c);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
n = gets.to_i
input = gets.split.map(&:to_i)
a = 0
n.times{|t|
a += input[t]*((-1)**t)
}

print a," "
(n-1).times{|t|
  print input[t]*2 - a," "
  a = input[t]*2 - a 
}

Measured memory_bytes: 12292
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <cstdlib>
using namespace std;
bool is_digit(const string& str) {
    return str.length() > 0 && str[0] != '+' && str[0] != '-' && str[0] != '*';
}

inline int compute(const char oprt, int a, int b) {
    if (oprt == '+') {
        return a + b;
    } else if (oprt == '-') {
        return a - b;
    } else {
        return a * b;
    }   
}

int main() {
    stack<int> operands;
    vector<string> inputs;
    string cur;
    while (cin >> cur) {
        inputs.push_back(cur);
    }   

    for (int i = 0; i < (int) inputs.size(); ++i) {
        string cur = inputs[i];
        if (is_digit(cur)) {
            operands.push(atoi(cur.c_str()));
        } else {
            int operand_1 = operands.top();
            operands.pop();
            int operand_2 = operands.top();
            operands.pop();
            char oprt = cur[0];
            operands.push(compute(oprt, operand_2, operand_1));
        }   
    }   

    cout << operands.top() << endl;

    return 0;
}

Measured memory_bytes: 3208
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, b;
  cin >> n >> b;
  int ret = 0;
  for (; n; n /= b) ret++;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  char ch;
  string str;
  int ans = 0;
  while(cin >> str){

    int f = 1;

    for(int i = 0; i <= (int)str.size()/2 ; i++){

      if(str[i] != str[str.size()-1 - i])f = 0;

    }
    if(f)ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1184
//AUTHOR: *Akash Shrivastva*
//Birla Institute of Technology,Mesra,India
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define M 1000000007
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll vector< pair <ll,ll> >
#define F first
#define S second
#define PII pair <ll,ll>

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


    ll n,k;cin>>n>>k;
    ll a[n],i,j;
    for (i=0;i<n;i++)	cin>>a[i];
    ll x=0,c=0;
	for (i=40;i>=0;i--)
	{
		c=0;
		for (j=0;j<n;j++)
		{
			if ((a[j]>>i)&1)	
				c++;
		}
		if (c*2<=n and (x+(1LL<<i))<=k)
			x+=1LL<<i;
	}
	ll ans=0;
	for (i=0;i<n;i++)	ans+=x^a[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



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

  vector<int> t(n+1), x(n+1), y(n+1);
  t[0] = 0, x[0] = 0, y[0] = 0;
  rep(i, n) {
    cin >> t[i+1] >> x[i+1] >> y[i+1];
  }

  rep(i, n) {
    int d = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if(d > (t[i+1]-t[i])) {
      cout << "No" << endl;
      return 0;
    }
    if( (t[i+1]-t[i]-d) % 2 == 1 ) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

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

using namespace std ;
typedef long long ll;
typedef string str;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<int, int> pii;
typedef vector<pii> vpii ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
ll ceif(ll a, ll b){
    return (a+b-1)/b ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, a, b, c, d , e ;
  cin >> n >> a >> b >> c >> d >> e ;
  ll f = min({a,b,c,d,e}) ;
  cout << 4+ceif(n,f) <<endl ;
  return 0 ;
}


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


#define loop(i,n) for(int lc=i;lc<=n;lc++)
#define tloop(tn) for(int tlc=1;tlc<=tn;tlc++)
#define loop2(i2,n2) for(int lc2=i2;lc2<=n2;lc2++)
#define bloop(n,bn) for(int blc=n;blc>=bn;blc--)
#define il() while(true)
#define pi acos(-1)
#define rad_to_deg(angl) ((180*angl)/pi)
#define ll long long
#define caseno printf("Case %d: ",tlc);

#define sfi(def_var) scanf("%d",&def_var)
#define sfii(def_var,def_var2) scanf("%d %d",&def_var,&def_var2)
#define sfll(def_var,def_var2) scanf("%lld %lld",&def_var,&def_var2)

#define sfl(def_var) scanf("%lld",&def_var)
#define sfd(def_var) scanf("%lf",&def_var)
#define sfs(def_var) scanf("%s",&def_var)

#define pfie(def_var) printf("%d\n",def_var)
#define pfi(def_var) printf("%d",def_var)
#define pfl(def_var) printf("%lld",def_var)
#define pfd(def_var) printf("%lf",def_var)
#define nl printf("\n");

string s,t;
int dp[3001][3001];
int find_ans(int i,int j)
{
    if(i==s.size() || j==t.size()) return 0;
    if(dp[i][j]!=-1) return dp[i][j];

    if(s[i]==t[j])
    {
        dp[i][j]=find_ans(i+1,j+1)+1;
        return dp[i][j];
    }
    dp[i][j]=max( find_ans(i+1,j),find_ans(i,j+1)  );
    return dp[i][j];
}



void print(int i,int j,int l)
{
    //cout << "\ncall : " << i << ' ' << j << endl;
    if(i==s.size() || j==t.size()) return;

    if(s[i]==t[j])
    {
        cout << s[i];
        print(i+1,j+1,l-1);
        return;
    }
    if(dp[i+1][j]>=dp[i][j+1]) print(i+1,j,l);
    else print(i,j+1,l);
    //cout << "return to : " << i << ' ' << j << endl;
}


int main()
{
    cin >> s >> t;
    for(int i=0;i<=s.size();i++)
    {
        for(int j=0;j<=t.size();j++) dp[i][j]=-1;
    }


    //nl;nl;
    find_ans(0,0);
//    for(int i=0;i<s.size();i++)
//    {
//        for(int j=0;j<t.size();j++)
//        {
//            if(dp[i][j]==-1) cout << '-' << ' ';
//            else cout << dp[i][j] << ' ';
//        }
//        nl;
//    }
//    nl; nl;
    print(0,0,dp[0][0]);
}


Measured memory_bytes: 35840
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        bool flag=false;
        int four=0,one=0,two=0;
        for(int i=1;i<=n;++i)
        {
            scanf("%d",&a[i]);
            {
                if(a[i]%4==0) four++;
                else if(a[i]%2==0) two++;
                else one++;
            }
        }
        if(one>four+1||(one==four+1&&two!=0)) printf("No\n");
        else printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int m;
    cin >> m;
    cout << 24 + (24 - m) << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
from networkx import*
H,*S=open(0)
H,W=map(int,H.split())
g=Graph()
a=g.add_edges_from
for i in range(m:=H*W):
  a([[m*2,h:=i//W],[m*2,w:=i%W+m]]*((c:=S[h][w-m])=='S')+[[h,I:=m*3],[w,I]]*(c=='T'),capacity=I)
  a([[h,w],[w,h]]*(c>'T'),capacity=1)
print([-1,f:=minimum_cut(g,m*2,I)[0]][f<I])

Measured memory_bytes: 64056
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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 vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	vi prime(300000, 1);
	prime[0] = false;
	prime[1] = false;

	FOR(i, 2, 300000) {
		if(prime[i]) {
			for(int j = 2*i; j < 300000; j += i) {
				prime[j] = 0;
			}
		}
	}

	int n;
	while(cin >> n, n) {
		int num = 0;
		for(int i = n+1; i <= 2*n; i++) {
			if(prime[i]) {
				num++;
			}
		}

		cout << num << endl;
	}

}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  int x1, y1 , x2 , y2 ;

  scanf("%d %d %d %d", &x1 ,&y1, &x2 , &y2) ;

  int diffx = x2 - x1 ;
  int diffy = y2 - y1 ;

  for(int i =1  ;i<=diffy ; i++)
    printf("U") ;
  for(int i = 1 ;i<=diffx ; i++)
    printf("R") ;
  for(int i = 1 ; i<=diffy ;i++)
    printf("D") ;
  for(int i = 1; i<=diffx; i++)
    printf("L") ;
  printf("L") ;
  for(int i = 1 ;i<=diffy+1 ;i++)
    printf("U") ;
  for(int i = 1 ;i<=diffx+1 ; i++)
    printf("R") ;
  printf("DR") ;
  for(int i = 1 ;i<=diffy+1;i++)
    printf("D") ;
  for(int i = 1 ; i<=diffx+1 ;i++)
    printf("L") ;
  printf("U") ;
  
    
	
  return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans=0;
int n,a[200100],cnt[200100];
inline long long cal(int x){return 1ll*x*(x-1)/2;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i),cnt[a[i]]++;
	for(int i=1;i<=n;i++) ans+=cal(cnt[i]);
	for(int i=1;i<=n;i++) printf("%lld\n",ans-cal(cnt[a[i]])+cal(cnt[a[i]]-1));
	return 0;
}

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


int main() {
	::std::string s;
	long long k;
	::std::cin >> s >> k;

	int cnt = 0;
	char next = '1';
	for (const auto c : s) {
		if (c == '1') { ++cnt; }
		else { next = c;break; }
	}
	::std::cout << (k <= cnt ? '1' : next) << ::std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 998244353
using namespace std;
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;}

ull node[100100];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ull N; cin >> N;
  rep(i,N) {
    ull tmp;
    cin >> tmp;
    if(i==0 && tmp!=0) {
      cout << 0 << endl;
      return 0;
    }
    node[tmp] += 1;
  }
  ull ans = 0;
  ull i;
  if(node[0] == 1) {
    ans = 1;
    for(i=2; i<100100; ++i) {
      if(node[i] == 0) break;
      for(ull j=1; j<=node[i]; ++j) {
        ans *= node[i-1];
        ans %= MOD;
      }
    }
    for(int n=i; n<100100; ++n) {
      if(node[n] != 0) {
        ans = 0;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
  int a[4]={},b[4]={};
  int hit,blow;

  while(scanf("%d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
      hit=0; blow=0;
      for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
          if(a[i]==b[j]){
            if(i==j) hit++;
            else blow++;
          }
        }
      }
      printf("%d %d\n",hit,blow);
  }
  //for(int i=0;i<4;i++){
  //  printf("a[%d]=%d   b[%d]=%d\n",i,a[i],i,b[i]); }

  return 0;
}


Measured memory_bytes: 2056