akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(' ').map { it.toLong() }.sortedDescending()
    val que = LinkedList<Long>()
    que.add(A.first())
    var ans = 0L
    for (i in 1 until A.size) {
        val p = que.poll()
        ans += p
        que.add(A[i])
        que.add(A[i])
    }
    println(ans)
}

Measured memory_bytes: 74908
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

unordered_map<int,int> prime_factor(int n){
    unordered_map<int,int> ret;
    for(int i=2; i*i<=n; i++){
        while(n % i == 0){
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n]=1;
    return ret;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int ans=0;
    for(auto p:prime_factor(N)) {
        auto a=p;
        int pos=1;
        while(a.se-pos>=0) {
            a.se-=pos;
            ans++;
            pos++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

int main(){
  int N, K;
  int h[100005];
  cin >> N >> K;
  rep(i, N) cin >> h[i];

  ll cost[100005];
  for(int i = 0; i < 100005; i++) cost[i] = INT_MAX;
  cost[0] = 0;
  cost[1] = abs(h[0] - h[1]);
  for(int i = 0; i < N; i++){
    for(int k = 1; k <= min(N - i - 1, K); k++){
      cost[i + k] = min(cost[i + k], cost[i] + abs(h[i] - h[i + k]));
    }
  }
  cout << cost[N - 1] << endl;
}


Measured memory_bytes: 1408
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int d = saori.saori_hayami();
		int x = saori.saori_hayami();
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = saori.saori_hayami();
		}
		int ans = 0;
		int num = 1;
		boolean flg = true;
		for(int i = 0;i < n;i++){
			num = 1;
			flg = true;
			while(flg){
				num += a[i];
				if(num > d){
					flg = false;
					break;
				} else {
					ans++;
				}
			}

		}
		System.out.println(x+ans+n);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main(){
	int W,H;
	cin>>W>>H;
	int x,y,r;
	cin>>x>>y>>r;
	if(x-r >= 0 && x+r <=W && y-r >= 0 && y+r <= H)
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3084
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws Exception {
        BufferedReader br = 
                new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int num = Integer.parseInt(line);
        int sec = num % 60;
        int min = 0;
        int hour = 0;
        num = Math.round(num / 60);
        if (num > 0) {
            min = num % 60;
            num = Math.round(num / 60);
            if (num > 0) {
                hour = num % 60;
            }
        }

        System.out.println(String.format("%d:%d:%d", hour, min, sec));
    }
}

Measured memory_bytes: 24708
/* ****revpro**** */
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,x,d;
		cin>>n>>x>>d;
		if(d==0&&x==0) cout<<1;
		else if(d==0) {
			cout<<n+1;
		}
		else{
			map <ll,vector <pii>> m;
			rep(i,0,n+1)
				m[(i*x)%d].pb({(i*x)/d+i*(i-1)/2,(i*x)/d+i*n-i*(i+1)/2});
			ll ans=0;
			for(auto i:m){
				vector <pii> v=i.S;
				stack <pii> s;
				sort(all(v));
				s.push(v[0]);
				rep(j,1,sz(v)){
					if(v[j].F>s.top().S){
						s.push(v[j]);
					}
					else{
						pii p=s.top();
						s.pop();
						p.S=max(v[j].S,p.S);
						s.push(p);
					}
				}
				while(!s.empty()){
					pii p=s.top();
					s.pop();
					ans+=(p.S-p.F+1);
				}
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 22144
#include <stdio.h>
#include <algorithm>


int main()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 0; i <= n; ++ i) {
        for (int j = 0; j <= m; ++ j) {
            if (i * m + j * n - 2 * i * j == k)
                return puts("Yes"), 0;
        }
    }
    puts("No");
}

Measured memory_bytes: 128
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int N,K;
    cin>>N>>K;
    vector<int> vtbl(N,0);
    for(auto&& v:vtbl){
        cin>>v;
    }

    int ans=0;
    for(int t=min(K,N);t>=0;--t){
        for(int l=0;l<=t;++l){
            int r=t-l;
            vector<int> dt(t);
            copy(vtbl.begin(),vtbl.begin()+l,dt.begin());
            copy(vtbl.rbegin(),vtbl.rbegin()+r,dt.begin()+l);
            sort(dt.begin(),dt.end());
            int val=0;
            for(int i=0;i<dt.size();++i){
                if(dt[i]<0 && i<K-t){
                    //すてる
                } else{
					val += dt[i];
				}
            }
            ans=max(ans,val);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
main = do
    getLine
    hs <- fmap read. words <$> getLine
    print $ solve hs 0

solve hs count
    | all (0==) hs = count
    | otherwise = solve (uncurry g $ span (==0) hs) (count+1)
    where
        g a b = a ++ zipWith (-) b (f b)
        f [] = []
        f (x:xs)
            | x>0 = 1 : f xs
            | otherwise = 0 : fmap (const 0) xs

Measured memory_bytes: 3452
#include <algorithm>
#include <array>
#include <assert.h>
#include <chrono>
#include <bitset>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <random>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<pll> vpll;

#ifdef OLBOEB
mt19937 rnd(228 + 1488 + 238 + 24111997 % 322);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

void print_time() {
#ifdef OLBOEB
    cout.flush();
    cerr << "\ntime: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(x) ((ll)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class L, class R> ostream& operator<<(ostream& out, map<L, R> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }




int main() {
    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n;
    cin >> n;
    string s;
    cin >> s;

    ll ans = 1;
    for (ll i = 0; i + 1 < n; ++i) {
        if (s[i] != s[i + 1]) ++ans;
    }

    cout << ans << endl;

    print_time();
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
 
  
 
ll n,m,k,x,y;
ll dp[9999999];
ll a[999999];ll c[99];map<ll,ll>mp;
map<ll,ll>mpp;
ll b[9999999];ll p[9999999];
int main()
{
   ll n,k;    cin>>n;ll ans=0;
    for(int j=1;j<=n;j++){
       cin>>c[j];
       a[j]+=c[j]+a[j-1];
   }  for(int j=1;j<=n;j++){
       cin>>b[j];
       p[j]+=b[j]+p[j-1];
   }
  
      for(int j=1;j<=n;j++){
      ans=max(ans,a[j]+b[j]+p[n]-p[j]);
   }cout<<ans;
     
      
   

  
   }

Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>
using namespace std;

int main() {
    int n;
    cin >> n;
    int a[100010];
    a[0] = 0;
    a[n+1] = 0;
    for(int i=1;i<=n;i++) cin >> a[i];

    int memo[100010]={0};
    int result[100010]={0};
    int sum_result[100010]={0};
    for(int i=0;i<=n;i++){
        memo[i] = abs(a[i+1] - a[i]);
    }
    for(int i=1;i<=n+1;i++){
        sum_result[i] = memo[i-1] + sum_result[i-1];
    }


    for(int i=0;i<=n;i++){
        //for(int j=0;j<=n;j++){
        //    //cout << "i: " << i << " j: " << j << " memo[j]:" << memo[j] << endl;
        //    result[i] += memo[j];
        //}
        result[i] = sum_result[n+1];
        result[i] -= memo[i];
        result[i] -= memo[i+1];
        result[i] += abs(a[i+2] - a[i]);
    }

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

    return 0;
}

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

using namespace std;

int main()
{
    long long n  , sum=1e18;
    cin>>n;
    for(int i=1 ; i<=sqrt(n) ; i++)
    {
        if( n%i==0 )
        {
            sum=min( sum , ( ( i-1 )+ ( (n/i) -1 ) ) );
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int N,j_num=0,two_num=0,four_num=0;
	scanf("%d",&N);
	
	long long *a;
	a=(long long*)malloc(N*sizeof(long long));
	
	for(int i=0;i<N;i++)
	{
		scanf("%lld",&a[i]);
		
		if(a[i] & 1)
			j_num++;
		else if(!(a[i]%4))
			four_num++;
		else 
			two_num++;	
	}
	
	if(two_num==0 && j_num>(four_num+1))
		printf("No");
	else if(two_num && j_num>four_num)
		printf("No");
	else
		printf("Yes");
	
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1 << 30);
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, m;
  cin >> n >> m;
  ll sum = 0;
  for(ll i = 0; i < m; i++){
    ll a;
    cin >> a;
    sum += a;
  }
  cout << (n-sum<0?-1:n - sum) << endl;
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int L[4] = {}, R[4] = {};
	for (double l, r; cin >> l >> r;) {
		if (l >= 1.1)L[0]++;
		else if (l >= 0.6)L[1]++;
		else if (l >= 0.2)L[2]++;
		else if (l < 0.2)L[3]++;
		if (r >= 1.1)R[0]++;
		else if (r >= 0.6)R[1]++;
		else if (r >= 0.2)R[2]++;
		else if (r < 0.2)R[3]++;
	}
	rep(i, 0, 4) {
		cout << L[i] << " " << R[i] << endl;
	}
	return 0;
}

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

int64_t calc_expression(string &S, bitset<10> &plus)
{
  int64_t ans = 0;
  int64_t num = 0;
  for (int i = 0; i < S.size(); i++)
  {
    num *= 10;
    num += S.at(i) - '0';
    if (i < S.size() - 1 && plus.test(i))
    {
      ans += num;
      num = 0;
    }
  }
  return ans + num;
}

int main()
{
  string S;
  cin >> S;
  int64_t ans = 0;
  for (int tmp = 0; tmp < (1 << S.size() - 1); tmp++)
  {
    bitset<10> plus(tmp);
    ans += calc_expression(S, plus);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
K = int(input())
sum = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            gcd_1 = math.gcd(i,j)
            sum = sum + math.gcd(gcd_1,k)
print(sum)

Measured memory_bytes: 68900
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int rem=7;
    bool flag=false;
    int k;
    for(k=1;k<=1000000;k++)
    {
        if(rem%n==0)
        {
            flag=true;
            break;
        }
        else
        {
            rem=rem*10+7;
            rem=rem%n;
        }
        
    }
    if(flag==false)
        cout<<-1<<endl;
    else
    {
        cout<<k<<endl;
    }
    
}

Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;

int main(){
  int N;
  cin >> N;
  pair<int, char> a[2 * N];
  for(int i = 0; i < N; i++){
    int c; cin >> c;
    a[i] = pair<int, char>(c, 'a');
  }
  for(int i = N; i < 2 * N; i++){
    int c; cin >> c;
    a[i] = pair<int, char>(c, 'b');
  }

  sort(a, a + 2 * N);

  ll cnta = 0;
  ll cntb = 0;
  ll ans = 1;
  for(int i = 0; i < 2 * N; i++){
    if(a[i].second == 'a'){
      if(cntb == 0){
        cnta++;
      } else {
        ans *= cntb;
        cntb--;
      }
    }
    else{
      if(cnta == 0){
        cntb++;
      } else {
        ans *= cnta;
        cnta--;
      }
    }

    ans %= MOD;
  }

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
const int LG = 20;

#define rank tmp1

int rank[LG][N];
string s;
int n;
pair<pair<int, int>, int> tmp[N];

int lcp(int x, int y)
{
	if (x == y)
		return n - x;
	int ans = 0;
	for (int i=LG-1; i>=0; i--)
		if (rank[i][x] == rank[i][y])
		{
			ans |= 1 << i;
			x += 1 << i;
			y += 1 << i;
		}
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);

	cin >> s;
	n = s.length();
	for (int i=0; i<n; i++)
		rank[0][i] = s[i];
	for (int i=1; i<LG; i++)
	{
		for (int j=0; j<n; j++)
			if (j + (1 << (i-1)) < n)
				tmp[j] = {{rank[i-1][j], rank[i-1][j+(1<<(i-1))]}, j};
			else
				tmp[j] = {{rank[i-1][j], -1}, j};
		sort(tmp, tmp+n);
		for (int j=0; j<n; j++)
			if (j > 0 && tmp[j].first == tmp[j-1].first)
				rank[i][tmp[j].second] = rank[i][tmp[j-1].second];
			else
				rank[i][tmp[j].second] = j;
	}
	int l = 0, r = n;
	while (r - l > 1)
	{
		int mid = (l + r) / 2;
		int prv = -1;
		int mx = 0;
		for (int i=0; i<n; i++)
			if (tmp[i].second + mid <= n)
			{
				if (prv != -1)
					mx = max(mx, lcp(prv, tmp[i].second));
				prv = tmp[i].second;
			}
		if (mx < mid)
			r = mid;
		else
			l = mid;
	}
	cout << n - r + 1 << "\n";
	return 0;
}

Measured memory_bytes: 9552
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n;
	cin >> n;
	int p[n];
	REP(i, n) cin >> p[i];
	int ans = 0;
	REP(i, n-1){
		if(i + 1 == p[i]){
			int t = p[i+1];
			p[i+1] = p[i];
			p[i] = t;
			ans++;
		}
	}
	if(p[n-1] == n) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

ll dp[101010];

int main(){

    dp[0] = 1;
    for(ll i = 0; i <= 100000; i++){
        if(dp[i] == 0)continue;
        for(ll j = 100; j <= 105; j++)dp[i + j] = 1;
    }
    ll X;
    cin >> X;
    cout << dp[X] << endl;

    return 0;
}

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

bool A,B;

int main()
{
    char C;
    scanf("%c",&C);
    if(C == 'H')A = 1;
    else A = 0;
    scanf(" %c",&C);
    if(C == 'H')B = 1;
    else B = 0;
    if(A ^ B)printf("D\n");
    else printf("H\n");
    return 0;
}


Measured memory_bytes: 256
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os") 

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define mp make_pair

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e5+10, lg=64, mod=1e9+7, inf=1e18;

ll n,k,a[maxn];
ll l[maxn],r[maxn],ps[maxn];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		ps[i]=ps[i-1]+a[i];
		l[i]=l[i-1]+max(0ll,a[i]);
	}
	for(int i=n;i>=1;i--) r[i]=r[i+1]+max(0ll,a[i]);
	ll ans=0;
	for(int i=0;i<=n-k;i++) ans=max(ans,l[i]+r[i+k+1]+max(0ll,ps[i+k]-ps[i]));
	cout<<ans<<endl;

	return 0;
}







 







Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=n-1;i>=0;i--){
    if(i!=n-1){
      if(a[i]==a[i+1]+1) a[i]--;
      else if(a[i]>a[i+1]+1){
        cout<<"No";return 0;
      }
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))
int main(void){
	int n,k;
	scanf("%d%d",&n,&k);
	double p=1.0/n;
	double sum=0;
	for(int i=1;i<=n;i++){
		int score=i;
		double tmp=p;
		for(int j=0;j<k;j++){
			if(score>=k)break;
			score*=2;
			tmp*=0.5;
		}
		sum+=tmp;
	}
	printf("%.10lf",sum);
	
	return 0;
}

Measured memory_bytes: 128
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
int a[106];
int main(){
    string s ; cin >> s ;
    string t = s ;
    reverse(t.begin() , t.end());
    if(t==s)
    cout << "Yes";
    else cout << "No";
}



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

public class Main {

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

	    long x=gl();
	    long c=Math.floorDiv(x, 11);
	    long a=x%11;

	    //System.out.println(m);
	    if(a==0) {
	        System.out.println(c*2);
	    } else if(a<=6){
	    	System.out.println(c*2+1);
	    } else {
	    	System.out.println(c*2+2);
	    }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35868
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll x;cin>>x;

  int i = x;
  while(i<x+1000){
    int j = sqrt(i);
    bool b = false;
    while(j>1){
      if(i%j==0){
        b = true;
        break;
      }
      j--;
    }
    if(b == false){
      cout<<i<<endl;
      return 0;
    }
    i++;
  }
 

  return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int x=sc.nextInt(),y=sc.nextInt();
		boolean ok=false;
		for(int i=0;i<=x;i++) {
			int j=x-i;
			ok|=(4*i+2*j==y);
			
		}
		
				System.out.println(ok?"Yes":"No");
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

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

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

		boolean ready() throws IOException {
			return br.ready();
		}

		int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 32792
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long long int (i) = 0; (i) < (int) (n); (i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;
int main(int argc, char const *argv[])
{
    int n;
    string a,b,c;
    cin >> n >> a >> b >> c;
    int cc = 0;
    rep(i, n) {
        if (a[i] == b[i]) {
            if(b[i] == c[i]) {

            }else{
                cc++;
            }
        } else {
            if(a[i] == c[i] || b[i] == c[i]) {
                cc++;
            } else {
                cc += 2;
            }
        }
    }
    cout << cc << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int MOD = 1e9+7;
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define ar array
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

	int A,B;
	string op;
	cin >> A >> op >> B;

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


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

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll dp[n][n+1];
    dp[n-1][1] = s[n-2] == '<';
    dp[n-1][2] = s[n-2] == '>';
    for(int i = n-2; i >= 1; i--) {
        if(s[i-1] == '<') {
            dp[i][n-i+1] = 0;
            for(int k = n-i; k >= 1; k--)
                dp[i][k] = (dp[i][k+1] + dp[i+1][k])%mod;
        }
        else {
            dp[i][1] = 0;
            for(int k = 2; k <= n-i+1; k++)
                dp[i][k] = (dp[i][k-1] + dp[i+1][k-1]) % mod;
        }
    }
    ll ans = 0;
    for(int j = 1; j <= n; ++j)
        ans = (ans + dp[1][j]) % mod;
    cout << (ans+mod) % mod;
    return 0;
}


Measured memory_bytes: 70272
n=int(input())
p=input().split()
#https://note.nkmk.me/python-list-str-num-conversion/
#せっかくだからnを使おう
a=0
for i in range(n):
  p[i]=int(p[i])
  if p[i]!=(i+1):
    a+=1
if a<=2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a>c){
             System.out.println("No");
             }else if(c>b){
             System.out.println("No");
             }else{
             System.out.println("Yes");
             }
}
}

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

A = int(N / 4)
B = int(N / 7)

jug = False

for i in range(0, (A + 1)* 4, 4):
    if jug == True:
        break
    for j in range(0, (B + 1) * 7, 7):
        if i + j == N:
            print("Yes")
            jug = True
            break

if jug == False:
    print("No")


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=1005;
const int MOD=1000000007;
const int inf=1000000000;

int n,m,cnt,last[N],fa[N],dep[N],val[N],f[N];
struct edge{int to,next,w;}e[N*2];
struct data{int x,y,w,tag;}a[N*2];
LL X;

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int find(int x)
{
	if (f[x]==x) return x;
	else return f[x]=find(f[x]);
}

bool cmp(data a,data b)
{
	return a.w<b.w;
}

int ksm(int x,int y)
{
	int ans=1;
	while (y)
	{
		if (y&1) ans=(LL)ans*x%MOD;
		x=(LL)x*x%MOD;y>>=1;
	}
	return ans;
}

void addedge(int u,int v,int w)
{
	e[++cnt].to=v;e[cnt].w=w;e[cnt].next=last[u];last[u]=cnt;
	e[++cnt].to=u;e[cnt].w=w;e[cnt].next=last[v];last[v]=cnt;
}

void dfs(int x)
{
	dep[x]=dep[fa[x]]+1;
	for (int i=last[x];i;i=e[i].next)
	{
		if (e[i].to==fa[x]) continue;
		val[e[i].to]=e[i].w;
		fa[e[i].to]=x;
		dfs(e[i].to);
	}
}

int get_mx(int x,int y)
{
	int mx=0;
	if (dep[x]<dep[y]) swap(x,y);
	while (dep[x]>dep[y]) mx=max(mx,val[x]),x=fa[x];
	while (x!=y) mx=max(mx,max(val[x],val[y])),x=fa[x],y=fa[y];
	return mx;
}

int main()
{
	n=read();m=read();scanf("%lld",&X);
	for (int i=1;i<=m;i++) a[i].x=read(),a[i].y=read(),a[i].w=read();
	for (int i=1;i<=n;i++) f[i]=i;
	sort(a+1,a+m+1,cmp);
	LL tot=0;
	for (int i=1;i<=m;i++)
	{
		int x=find(a[i].x),y=find(a[i].y);
		if (x!=y) f[x]=y,addedge(a[i].x,a[i].y,a[i].w),tot+=a[i].w;
	}
	dfs(1);
	int s1=0,s2=1;
	for (int i=2;i<=m;i++)
	{
		int mx=get_mx(a[i].x,a[i].y);
		if (tot-mx+a[i].w==X) s1++;
		else if (tot-mx+a[i].w>X) s2++;
	}
	printf("%d",(LL)(ksm(2,s1)-1)*ksm(2,s2)%MOD);
	return 0;
}

Measured memory_bytes: 384
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()
  val k = sc.nextInt()


  val min = Math.min(a, b)
  val list = mutableListOf<Int>()
  for (i in 1..min) {
    if (a % i == 0 && b % i == 0) {
      list.add(i)
    }
  }

  list.reverse()
  println(list.get(k-1))

}


Measured memory_bytes: 36776
#!/usr/bin/env python3
import sys
INF = float("inf")


def eratosthenes_sieve(n):
    table = [0] * (n + 1)
    prime_list = []

    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1

    return prime_list


def solve(N: int):
    primes = eratosthenes_sieve(55555)

    # 5で割って余り1を集める
    myprimes = [p for p in primes if p % 10 == 1]

    print(*myprimes[:N], sep=" ")

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N + 1);
    for (ll i = 1; i <= N; i++) {
        cin >> A[i];
    }
    A[0] = -9999;

    ll KR = K;
    ll movenum = 0;
    map<ll, ll> used;
    ll city = 1;
    while (KR > 0) {
        if (used.count(city)) {
            break;
        }
        used[city] = movenum;
        city = A[city];
        movenum++;
        KR--;
    }
    if (KR == 0) {
        print(city);
        return 0;
    }
    ll loop = movenum - used[city];
    //print(movenum, city, loop);
    // ll KR = K - movenum;
    ll loopnum = max(0L, KR / loop - 2);
    KR = KR - (loop * loopnum);

    while (KR > 0) {
        city = A[city];
        KR--;
    }
    print(city);
}


Measured memory_bytes: 14788
#include<cstdio>
#include<iostream>
using namespace std;
string S;
char a[27] = {0};
int main()
{
    cin>>S;
    for (int i = 0; i < S.size(); i++)
        a[S[i] - 'a'] = 1;
    for (int i = 0; i < 26; i++)
        if(!a[i])
        {
            printf("%c\n",i+'a');
            return 0;
        }
    cout<<"None"<<endl;
    return 0;
}



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

int main() {
  int N; cin >> N;
  vector<int> a(N), b(N);
  rep(i, N) cin >> a[i];
  rep(i, N) cin >> b[i];
  
  int ans = 0;
  rep(i, N) {
    int k = 0;
    rep(j, i+1) k += a[j];
    rep(j, N-i) k += b[i+j];
    ans = max(k, ans);
  }
  
  cout << ans << endl;
  

}


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

L = list(range(0,102))
if y != 0:
    L2 = list(map(int,input().split()))
    
    #print(L)
    for i in range(len(L2)):
        L.remove(L2[i])
        
#print(L)
#L = sorted(L)

#print(L)

t = len(L)//2

for j in range(len(L)):
#    print(t,L[t])
    if L[t] >= x:
#        print("L[t] >= x")
        if t == 0:
            print(L[t])
            break
        elif L[t-1] <= x:
            if abs(L[t]-x) < abs(L[t-1]-x):
                print(L[t])
                break
            else:
                print(L[t-1])
                break
        
        t = t//2
    else:
        if t == y-1:
            print(L[t])
            break
        elif L[t+1] >= x:
            if abs(L[t]-x) > abs(L[t+1]-x):
                print(L[t+1])
                break
            else:
                print(L[t])
                break
        t = t + (len(L)-t)//2
        
    

Measured memory_bytes: 9248
N = int(input())
f = []
for i in range(N):
    F = map(str, input().split())
    f.append("0B" + ''.join(F))
P = [list(map(int, input().split())) for i in range(N)]

ans = -float("inf")
for bit in range(1, 2 ** 10):
    profit = 0  
    for i in range(N):    
        c = bin( bit & int(f[i], 0) )
        index = c.count('1')
        profit += P[i][index]
    ans= max(ans, profit)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);
//桁数に注意 long long　にする

int main() {
  int n,m;
  cin >> n >> m;
  
  vector<int> p(m);
  
  rep(i,m) {
  cin >> p[i];
  n-=p[i];
  }
  
  cout << max(-1,n) << endl;
  
}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	L := sc.nextIntSlice(N)
	sort.Ints(L)
	count := 0
	for i := 0; i < N-2; i++ {
		for j := i + 1; j < N-1; j++ {
			// lower <= x < upper
			lower := j + 1
			upper := sort.Search(len(L), func(index int) bool {
				return L[index] >= L[i]+L[j]
			})
			if lower < upper {
				count += upper - lower
			}
		}
	}
	fmt.Println(count)
}


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 410;
ve<pii> a[N];
bool bad[N];
bool is[N][N];

bool dfs(int v, int l, int st) {
	is[st][v] = 1;
	forn(i, sz(a[v])) {
		int to = a[v][i].sc;
		if (a[v][i].fs >= l)
			break;
		if (is[st][to]) {
			bad[st] = 1;
			return false;
		}
		if (!dfs(to, a[v][i].fs, st))
			return 0;
	}
	return 1;
}

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	memset(bad, 0, sizeof(bad));
	memset(is, 0, sizeof(is));
	int n, m;
	cin >> n >> m;
	forn(i, m) {
		int u, v;
		scanf("%d%d", &u, &v);
		u--, v--;
		a[u].pb(mp(i, v));
		a[v].pb(mp(i, u));	
	}	
	forn(i, n)
		sort(all(a[i]));
	forn(i, n) {
		dfs(i, 1e9, i);
	}
	int ans = 0;
	forn(i, n) {
		forn(j, i) {
			bool ok = 0;
			if (bad[i] || bad[j])
				continue;
			forn(k, n) {
				ok |= (is[i][k] && is[j][k]);
			}
			if (!ok) {
				ans++;
			}
		}	
	}
	cout << ans << endl;
	return 0;
}


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

int main(int argc, char const *argv[])
{
    int h,w;
    cin >>h>>w;
    vector<string> vec_s(h);
    string s;
    for(int i=0;i<h;++i)cin >> vec_s[i];
    for(int i=0;i<2*h;++i)cout << vec_s[i/2] << endl;
    return 0;
}


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

int main(){
    int N;
    vector<int> vec(101);
    int i,j,t;
    int c1=0,c2=0;

    cin >> N;
    for(i=0;i<N;i++){
        cin >> vec.at(i);
    }
    for(i=0;i<N-1;i++){
        for(j=N-1;j>i;j--){
            if(vec.at(j-1)<vec.at(j)){
                t=vec.at(j-1);
                vec.at(j-1)=vec.at(j);
                vec.at(j)=t;
            }
        }
    }
    for(i=0;i<N;i++){
        if(i%2==0)
        c1+=vec.at(i);
        else 
        c2+=vec.at(i);
    }
   // cout << c1 << " " << c2 <<endl;
    cout << c1-c2 << endl;
}



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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	int n; cin>>n;

	 n %=10;

	 if(n ==3){
		 writeln("bon");
	 }else if (n==0 || n==1 || n==6 || n==8) {
		writeln("pon");
	}else {
		writeln("hon");
	}







}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int a1,a2,a3;

	scanf("%d %d %d" ,&a1, &a2, &a3);

	if(a1+a2+a3 >= 22){
		printf("bust");
	}

	else{
		printf("win");
	}


	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{

  string s;
  cin>>s;
  if(s=="SUN")cout<<"7"<<endl;
  if(s=="MON")cout<<"6"<<endl;
  if(s=="TUE")cout<<"5"<<endl;
  if(s=="WED")cout<<"4"<<endl;
  if(s=="THU")cout<<"3"<<endl;
  if(s=="FRI")cout<<"2"<<endl;
  if(s=="SAT")cout<<"1"<<endl;
}
  

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

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

int k,d[100010];

signed main(){
	cin >> k;
	for(int i = 0;i < k;i++) d[i] = INF;
	priority_queue<P,vector<P>,greater<P> > que;
	d[k] = 0;
	que.push(P(0,k));
	while(!que.empty()){
		P p = que.top();que.pop();
		int cost = p.first,v = p.second;
		if(cost > d[v]) continue;
		for(int i = 0;i < 10;i++){
			if(v == k && !i) continue;
			int to = (v * 10 + i) % k;
			if(d[to] > d[v] + i){
				d[to] = d[v] + i;
				que.push(P(d[to],to));
			}
		}
	}
	cout << d[0] << endl;
	return 0;
}

Measured memory_bytes: 6896
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    diff = 10 ** 10

    partA = 0
    partB = sum(A)

    for i in range(N):
        diff = min(diff, abs(partA-partB))
        partA += A[i]
        partB -= A[i]
    print(diff)
    return
resolve()

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int L = A + B;
  int R = C + D;
  
  if ( L > R ) {
    cout << "Left" << endl;
  }
  else if ( L < R ) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }  
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B; cin >> A >> B;
    if (B % A == 0) cout << A + B << endl;
    else

    cout << B - A << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.ABC._123
{
    class C
    {
        public static void Solve()
        {
            long n;
            long[] cap = new long[6];
            long minc = long.MaxValue;

            n = long.Parse(Console.ReadLine());

            for (int i = 0; i < 5; i++)
            {
                cap[i] = long.Parse(Console.ReadLine());
                if(cap[i] < minc)
                {
                    minc = cap[i];
                }
            }
            long mod = n % minc;
            long ans = 4;
            if (mod > 0)
                ans += n / minc + 1;
            else
                ans += n / minc;

            Console.WriteLine(ans);
        }
    }
  class Program
{
    static void Main(string[] args)
    {
        C.Solve();
    }
}

}


Measured memory_bytes: 13140