akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    string n;
    cin >> n;
    int dig = n.size();
    int fdig = n[0] - '0';
    int ldig = n.back() - '0';
    int num = 0;
    for(int i = 0; i < (int)n.size(); i++){
        num *= 10;
        num += n[i] - '0';
    }
    if(num < 10) {cout << n; return 0;}
    vector<vector<int>> nums(10, vector<int>(10));
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            int cur = 0;
            if(i == j){
                cur++;
            }
            int curdig = 2;
            while(curdig != dig){
                cur += pow(10, curdig - 2);
                curdig++;
            }
            if(i < fdig){
                cur += pow(10, curdig - 2);
            }else if(i == fdig){
                cur +=  (num - (i * pow(10, dig - 1) - 10 + j)) / 10;
            }
            nums[i][j] = cur;
        }
    }
    int sum = 0;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            sum += nums[i][j] * nums[j][i];
        }
    }
    cout << sum;
}

Measured memory_bytes: 256
import java.util.*;public class Main{Scanner sc = new Scanner(System.in);void run(){int[] d = new int[4];String[] s={"A","B","AB","O"};for(;sc.hasNextLine();){String a=sc.nextLine().split(",")[1];for(int i=0;i<4;i++)if(a.equals(s[i]))d[i]++;}for(int i=0;i<4;i++)System.out.println(d[i]);}public static void main(String[] args){Main m = new Main();m.run();}}

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

using namespace std;

int main(){
	int N;
	string S;
	cin>>N>>S;
	
	int current=0;
	int max=0;
	for(int i=0 ; i<S.size() ; i++){
		if(S.substr(i,1)=="I")current+=1;
		else current-=1;
		if(current>max)max=current;
	}
	cout<<max<<"\n";
	
	return 0;
}


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

int main() {
  int n;
  ll a,b;
  cin>>n>>a>>b;
  ll x[n];
  rep(i,n) cin>>x[i];
  ll ans=0;
  rep(i,n-1){
    ans+=min((x[i+1]-x[i])*a,b);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    a,b,c=MI()
    if (a==b and b!=c) or (a==c and b!=c) or (c==b and b!=a):
        print("Yes")
    else:
        print("No")

main()

Measured memory_bytes: 3064
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

A, B = map(int, input().split())
diff = B - A
left_idx = diff - 2

talls = []
t = 0
for i in range(999):
    t += (i + 1)
    talls.append(t)

t = talls[left_idx]
print(t - A)



Measured memory_bytes: 7116
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
using namespace std;

int main(){
  string W;
  int num = 0;
  cin >> W;
  transform(W.begin(),W.end(),W.begin() , ::tolower);
  string T = " ";
  while(true){
    cin >> T;
    if("END_OF_TEXT" == T) break;
    transform(T.begin(),T.end(),T.begin() , ::tolower);
    if(T == W) num++;
  }

  cout << num << endl;
  return 0;
}



Measured memory_bytes: 3152
#include <stdio.h>

int main(){
    double a,b,c,d,e,f,x,y;
	while (scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f) != EOF)
	{
		x = (c*e-f*b)/(a*e-d*b);
		y = (c-a*x)/b;
        if(x>-0.001 && x<0.001)x=0;
        if(y>-0.001 && y<0.001)y=0;
		printf("%1.3f %1.3f\n",x,y);
	}
    return 0;
}

Measured memory_bytes: 648
let () =
	let n = read_int () in (* n is not used *)
	let a =
		read_line ()
		|> Str.split (Str.regexp " ")
		|> List.map int_of_string
	in
	let count_odd lst =
		List.filter (fun i -> i mod 2 = 1) lst
		|> List.length
	in
	if count_odd a mod 2 = 0 then
		print_endline "YES"
	else
		print_endline "NO"


Measured memory_bytes: 16640
#include<stdio.h>

#define N 101

int main(){
  int n;
  int p[N];
  int m[N][N];
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);}

  for(int i=1;i<=n;i++)
    m[i][i]=0;

  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      /*2<<21*/
      m[i][j]=2097152;
      for(int k=i;k<=j-1;k++){
	/*さいしょう比較*/
	if(m[i][j]<m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
	
	  m[i][j]=m[i][j];
	else
	  m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      }
    }
  }
  printf("%d\n",m[1][n]);
  
  return 0;


  }



  



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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){

}

void solve(){
    ll x,y;
    cin>>x>>y;
    ll A,B,C;
    cin>>A>>B>>C;
    ll a[A+1];
    ll b[B+1];
    ll c[C+1];
    for(ll i=1;i<=A;i++)    
        cin>>a[i];
    for(ll i=1;i<=B;i++)
        cin>>b[i];
    for(ll i=1;i<=C;i++)
        cin>>c[i];
    
    sort(a+1,a+A+1,greater<ll>());
    sort(b+1,b+B+1,greater<ll>());
    sort(c+1,c+C+1,greater<ll>());

    vector<ll> res;
    for(ll i=1;i<=x;i++){
        res.pb(a[i]);
    }
    for(ll i=1;i<=y;i++){
        res.pb(b[i]);
    }
    for(ll i=1;i<=C;i++){
        res.pb(c[i]);
    }
    sort(res.begin(),res.end(),greater<ll>());

    ll sum=0;
    for(ll i=0;i<x+y;i++)
        sum += res[i];

    cout << sum << endl;
}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 8816
def solve():
    ret = -1
    diff = float('inf')
    for i in range(102):
        if i in p:
            continue
        if abs(X - i) < diff:
            ret = i
            diff = abs(X - i)
    print(ret)

if __name__ == "__main__":
    X, N = map(int, input().split())
    p = set((map(int, input().split())))
    solve()

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 200005;
const int MOD = 10005;

int ten[N], t[N], cnt[MOD];

int main() {

    FAST;

    int n, p;
    cin >> n >> p;
    string a;
    cin >> a;
    a = " " + a;
    if (p == 2 || p == 5) {
        intt ans = 0;
        for (int i = 1; i <= n; i ++) {
            if ((int(a[i]) - '0') % p == 0) {
                ans += i;
            }
        }
        cout << ans << '\n';
    }
    else {
        ten[0] = 1;
        for (int i = 1; i <= n; i ++) {
            ten[i] = (ten[i - 1] * 10) % p;
        }
        t[n] = 0;
        for (int i = n - 1; i >= 0; i --) {
            t[i] = (t[i + 1] + ten[n - i - 1] * (int(a[i + 1]) - '0')) % p;
        }
        for (int i = 0; i <= n; i ++) {
            cnt[t[i]] ++;
        }
        intt ans = 0;
        for (int i = 0; i < p; i ++) {
            ans += 1LL * cnt[i] * (cnt[i] - 1) / 2;
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 2128
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = []
for i in range(M):
    xi = list(map(int, input().split()))
    c.append(a[xi[0]-1]+b[xi[1]-1]-xi[2])
print(min(min(a)+min(b), min(c)))


Measured memory_bytes: 18736
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
    int n;
	ll t; cin>>n>>t; t++;
	vector<ll> b1;
	vector<P> p2;
	for(int i=0; i<n; i++){
		ll a, b;
		cin>>a>>b;
		a++; b++;
		if(a==1) b1.push_back(b);
		else p2.push_back({a, b});
	}
	sort(p2.begin(), p2.end(), [&](P p, P q){ return p.second*(q.first-1)<q.second*(p.first-1);});
	ll dp[200020][31];
	int m2=p2.size();
	const ll INF=1e9+7;
	for(int i=0; i<=m2; i++) for(int j=0; j<=30; j++) dp[i][j]=INF;
	dp[0][0]=1;
	for(int i=0; i<m2; i++){
		ll a=p2[i].first, b=p2[i].second;
		for(int j=0; j<=30; j++){
			dp[i+1][j]=min(dp[i+1][j], dp[i][j]);
		}
		for(int j=0; j<30; j++){
			dp[i+1][j+1]=min(dp[i+1][j+1], a*dp[i][j]+b);
		}
	}
	sort(b1.begin(), b1.end());
	int m1=b1.size();
	vector<ll> s1(m1+1);
	s1[0]=0;
	for(int i=0; i<m1; i++) s1[i+1]=s1[i]+b1[i];
	int ans=0;
	for(int i=0; i<=30; i++){
		if(dp[m2][i]>=t+1) continue;
		int k=upper_bound(s1.begin(), s1.end(), t-dp[m2][i])-s1.begin();
		ans=max(ans, i+k-1);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  int a;
  cin >> a;
  int ans = a;
  ans += a*a;
  ans += a*a*a;
  cout << ans << endl;

  //int N, M;
  //cin >> N >> M ;
  //cout << N << endl;
  //cout << M << endl;

  /*int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }

  for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
struct UnionFind { vector<int> par,cnt;
    UnionFind(int NV){par.clear();cnt.resize(NV, 1);rep(i, 0, NV) par.push_back(i); } 
    int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
    void operator()(int x, int y) { x = operator[](x); y = operator[](y);
        if (x != y) par[x] = y, cnt[y] += cnt[x]; }};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, A[101010], B[101010];
//---------------------------------------------------------------------------------------------------
bool chk() {
    map<int, int> cnt;
    rep(i, 0, N + 1) cnt[A[i]]++;
    rep(i, 0, N + 1) { if (cnt[B[i]] == 0) return false; cnt[B[i]]--; }
    return true;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> B[i];

    A[N] = 0;
    rep(i, 0, N) A[N] ^= A[i];

    B[N] = 0;
    rep(i, 0, N) B[N] ^= B[i];

    if (!chk()) { printf("-1\n"); return; }

    int ans = 0;
    if (A[N] != B[N]) {
        ans++;
        rep(i, 0, N) if (A[i] != B[i] && B[i] == A[N]) {
            swap(A[i], A[N]);
            break;
        }
    }

    vector<int> dic;
    rep(i, 0, N) if (A[i] != B[i]) {
        ans++;
        dic.push_back(A[i]);
    }
    sort(dic.begin(), dic.end());
    dic.erase(unique(dic.begin(), dic.end()), dic.end());

    UnionFind uf(dic.size());
    rep(i, 0, N + 1) if (A[i] != B[i]) {
        int a = lower_bound(dic.begin(), dic.end(), A[i]) - dic.begin();
        int b = lower_bound(dic.begin(), dic.end(), B[i]) - dic.begin();
        uf(a, b);
    }

    rep(i, 0, dic.size()) if (uf[i] == i) ans++;
    rep(i, 0, N) if (A[i] != B[i] && B[i] == A[N]) {
        ans--;
        break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5760
# 因数分解して、入れ子で掛け算して、inで入ってるか見る

N = int(input())

nums = []
mul = []

for i in range(1, 9 + 1):
    if N % i == 0:
        nums.append(i)
    else:
        pass

# print(nums)


for i in nums:
    for j in nums:
        mul.append(i * j)

# print(mul)


if N in mul:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9076
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#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>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
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, M, C, A;
  cin >> N >> M >> C;
  vector<int> B(M);
  for(int i = 0; i < M; i++) cin >> B[i];
  int ans = 0;
  for(int i = 0; i < N; i++){
    int cnt = C;
    for(int j = 0; j < M; j++){
      cin >> A;
      cnt += A * B[j];
    }
    if(0 < cnt) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
    
int run_test(){
	int n;
	cin >> n;
	int arr[n];
	for(int i=0; i<n; i++){
		cin >> arr[i];
	}
	int ans = 0;
	sort(arr, arr + n);
	for(int i=0; i < n-2; i++){
		for(int j=i + 1; j<n-1; j++){
			int sum  = arr[i] + arr[j];
			int t = lower_bound(arr, arr + n, sum) - arr;
			if(t > j){
				ans += t - j - 1;
			}
		}
	}
	cout << ans ;
	return 0;
}
    
int main(){
   FAST;
    ll t;
    t = 1;
     
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    A -= K;
    B += min(A, 0ll);
    cout << max(A, 0ll) << " " << max(B, 0ll) << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
scale = 2 ** 30
while scale >= n:
  scale //= 2
#print('#',scale)
print(0)
z0 = input()
now = 0
while True:
  tmp = now + scale
  print(tmp%n)
  z1 = input()
  if z1 == 'Vacant':
    exit()
  if z1 == z0:
    now = tmp
  scale //= 2

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
struct Node{
	int from,to,dis;
	Node(int f=0,int t=9,int d=0):from(f),to(t),dis(d){}
}; 
int pow2[30]={1};
vector<Node> V;
inline int lowbit(int x)
{
	return (x & (-x));
}
int main()
{
	int L;
	for(int i=1;i<=20;i++)
		pow2[i] = pow2[i-1]<<1;
	while(scanf("%d",&L)!=EOF)
	{
		V.clear();
		for(int i=19;i>=2;i--)
		{
			V.push_back(Node(i,i+1,0));
			V.push_back(Node(i,i+1,pow2[19-i]));
		}
		int bit = floor(log2(L))+1; //二进制的位数
		//V.push_back(Node(1,22-bit,0)); 
		int x = L;
		while(x)
		{
			int y = lowbit(x);  
			bit = floor(log2(y))+1;
			x -= y;
			bitset<20> xx(x),yy(y);
			//cout<<"x = "<<xx<<"  y = "<<yy<<endl;
			if(bit==20) 
			{
				V.push_back(Node(1,2,0));
				V.push_back(Node(1,2,pow2[18]));
				break;
			}
			V.push_back(Node(1,21-bit,x)); 
		}
		int edge = V.size();
		printf("20 %d\n",edge);
		for(int i=0;i<edge;i++)
		{
			printf("%d %d %d\n",V[i].from,V[i].to,V[i].dis);
		}
		
	}
	
	
	
	
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll , ll > pll;
typedef vector < ll > vi;
#define INF (2e18)
#define eps (1e-6)
#define pb push_back
#define mp make_pair
#define modulo1e9 ((ll)1e9 + 7)

ll mn(ll a , ll b) {if (a < b) return a; return b;}
ll mx(ll a , ll b) {if (a > b) return a; return b;}

ll n , k;

ll bit[100];
ll sum = 0;
int main(){
	
	cin >> n >> k;
	
	for (ll i = 0 ; i < n ; i ++ ) {
		ll x; cin >> x;
		ll r = 0;
		while(x > 0){
			bit[r] += x%2;
			x >>= 1;
			r ++;
		}
	}
	ll p2 = 1;
	for (ll i = 1 ; i <= 40; i ++ ){
		p2 *= 2;
	}
	// pow 2 50
	
	for (ll i = 40 ; i >= 0 ; i --){

		if (k < p2){
			sum += (bit[i]) * p2;
			p2 /= 2;
			continue;
		}
		
		if (bit[i] < n - bit[i]){
			k-=p2;
			sum += (n-bit[i]) * p2;
			//cout << bit[i] << " " << i << " " << p2 << endl; 

		}else {
			sum += (bit[i]) * p2;
			//cout << bit[i] << " " << i << " " << p2 << endl; 
		}
		
		p2 /= 2;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,d,r;
    double f;
    scanf("%d%d",&a,&b);
    d=a/b;
    r=a%b;
    f=1.0*a/b;
    printf("%d %d %lf\n",d,r,f);
    return 0;
}


Measured memory_bytes: 2120
#include<iostream>
using namespace std;
int main()
{
       long long int t; 
  cin >> t ;
  long long int a[t], aaa=0;    
    for(long long int i=0; i<t; i++)
      
      
      
      
      
      
    {
         cin >> a[i] ;
      }
  for(long long int i=0; i<t; i++)
      
      
      
      
      
      
    {
         long long int zzz=abs(a[i]-a[i-1]);
         if(a[i]<a[i-1]&&(i!=0))
        {
               a[i]=a[i]+zzz;
                aaa=aaa+zzz;
         }
      }
  
         cout << aaa << "\n" ;
     
}

Measured memory_bytes: 5132
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int d[4][2] = { {0, 1}, {1, 0}, {-1, 0}, {0, -1} };

bool MAP[2000][2000];
vector<pair<int, int> > v;

int main(int argc, char *argv[])
{
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  sx += 1000;
  sy += 1000;
  tx += 1000;
  ty += 1000;

  int dx = tx-sx;
  int dy = ty-sy;

  for (int i = 0; i < dy; i++) printf("U");
  for (int i = 0; i < dx; i++) printf("R");
  for (int i = 0; i < dy; i++) printf("D");
  for (int i = 0; i < dx + 1; i++) printf("L");
  for (int i = 0; i < dy + 1; i++) printf("U");
  for (int i = 0; i < dx + 1; i++) printf("R");
  printf("DR");
  for (int i = 0; i < dy + 1; i++) printf("D");
  for (int i = 0; i < dx + 1; i++) printf("L");
  printf("U");

  puts("");
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();        
        long N = r.l();
      	long[] capa = r.ll(5);
        long time = 5 + (N-1)/min(capa);   
        print(time);
    }
    static void print(String s){
        System.out.println(s);
    }
    static void print(int i){
        System.out.println(i);
    }
    static void print(double d){
        System.out.println(d);
    }
    static void print(long l){
        System.out.println(l);
    }
    static int max(int[] ii){
        int max = ii[0];
        for(int i : ii){
            if(max < i){
                max = i;
            }
        }
        return max;
    }
    static int min(int[] ii){
        int min = ii[0];
        for(int i : ii){
            if(i < min){
                min = i;
            }
        }
        return min;
    }
    static long max(long[] ll){
        long max = ll[0];
        for(long l : ll){
            if(max < l){
                max = l;
            }
        }
        return max;
    }
    static long min(long[] ll){
        long min = ll[0];
        for(long l : ll){
            if(l < min){
                min = l;
            }
        }
        return min;
    }
    static double max(double[] dd){
        double max = dd[0];
        for(double d : dd){
            if(max < d){
                max = d;
            }
        }
        return max;
    }
    static double min(double[] dd){
        double min = dd[0];
        for(double d : dd){
            if(d < min){
                min = d;
            }
        }
        return min;
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return readLine().split(" ");
        }
        int i() throws IOException{
            return Integer.parseInt(readLine());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++){
                ii[j] = Integer.parseInt(ss[j]);
            }
            return ii;
        }
        int[] ii(int N) throws IOException{
            int[] ii = new int[N];
            for(int j = 0; j < N; j++){
                ii[j] = i();
            }
            return ii;
        }
        long l() throws IOException{
            return Long.parseLong(readLine());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++){
                ll[j] = Long.parseLong(ss[j]);
            }
            return ll;
        }
        long[] ll(int N) throws IOException{
            long[] ll = new long[N];
            for(int j = 0; j < N; j++){
                ll[j] = l();
            }
            return ll;
        }
    }
}

Measured memory_bytes: 22228
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<pair<int, int> , pair<int, int> > PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int N;
string s[100005];
map<char, int> mp;
char C[5] = {'M','A','R','C','H'};

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s[i];
        mp[s[i][0]]++;
    }
    int ans = 0;
    for(int i = 0; i < 5 - 2; i++){
        for(int j = i + 1; j < 5 - 1; j++){
            for(int k = j + 1; k < 5; k++){
                ans += mp[C[i]] * mp[C[j]] * mp[C[k]];
            }
        }
    }
    cout << ans << endl;

    return 0;
}
/*


*/


Measured memory_bytes: 6144
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int n; 
    cin >> n;
    vector<int> height(n);
    for (int i = 0; i < n; ++i)
    	cin >> height[i];
    std::vector<int> dp(n, 0);
    dp[0] = 0;
    dp[1] = abs(height[1]-height[0]);
    for (int j = 2; j < n; ++j) {
    	dp[j] = min (dp[j-1] + abs(height[j]-height[j-1]), 
    				 dp[j-2] + abs(height[j]-height[j-2]));
    }
    cout << dp[n-1] ;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  int result = K;
  //cout << K*pow(K-1,N-1) << endl;
  for(int i=1;i<N;i++){
    result *= K-1;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define maxn 100010
char s[maxn];
int n, ans[maxn], nxtL[maxn], preR[maxn];

int main()
{
	scanf("%s", s);
	n = strlen(s);
	int i;
	for (i = 1; i < n; ++i)
		if (s[i] == 'R')
			preR[i] = i;
		else preR[i] = preR[i - 1];
	for (i = n - 1; i >= 0; --i)
		if (s[i] == 'L')
			nxtL[i] = i;
		else nxtL[i] = nxtL[i + 1];
	int step;
	for (i = 0; i < n; ++i) {
		if (s[i] == 'R') {
			step = (nxtL[i] - i) & 1;
			++ans[nxtL[i] - step];
		} else {
			step = (i - preR[i]) & 1;
			++ans[preR[i] + step];
		}
	}
	for (i = 0; i < n; ++i)
		printf("%d ", ans[i]);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  string S; cin >> S;
  int flag1 = 0;
  for (int i = 1; i < S.size(); i+=2) {
    if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D') {
      // cout << S[i] << endl;
      // cout << 1 << i << endl;
      flag1 = 1;
      break;
    }
  }

  int flag2 = 0;
  for (int i = 0; i < S.size(); i+=2) {
    if (S[i] != 'R' && S[i] != 'U' && S[i] != 'D') {
      // cout << 0 << i << endl;
      flag2 = 1;
      break;
    }
  }
  if (flag1 == 0 && flag2 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No"  << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <iomanip>
#include <deque>
#include <list>
#include <cassert>
#include <complex>
#include <bitset>
#include <deque>


using namespace std;
typedef long long ll;
#define int ll
typedef long double ld;
typedef vector<int> vi;
typedef vector<ld> vld;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
#define mmin(a, b) a = min(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)(a).size())
#define watch(x) cout << (#x) << " = " << (x) << endl;


const int N = 1 << 17, oo = 1e9 + 10, A = 201, B = 100;
const ll M = 998244353, x = 137;


int my_get(const vi&cur)
{
	int ans = 0;
	for (int i = 1; i < SZ(cur); ++i)
		ans += abs(cur[i - 1] - cur[i]);

	return ans;
}


int my_get( vi&c, const vi&a, const vi&b)
{
	int ans = 0;

	do
	{
		for (int i = 0; i < SZ(c); ++i)
		{
			vi cur;
			for (int j = 0; j < i; ++j)
				cur.push_back(c[j]);

			vi cur2 = cur;

			for (int j = 0; j < SZ(a); ++j)
			{
				cur.push_back(a[j]);
				cur.push_back(b[j]);
				cur2.push_back(b[j]);
				cur2.push_back(a[j]);
			}

			for (int j = i; j < SZ(c); ++j)
			{
				cur.push_back(c[j]);
				cur2.push_back(c[j]);
			}


			ans = max(ans, my_get(cur));
			ans = max(ans, my_get(cur2));
		}
	} while (next_permutation(ALL(c)));

	return ans;
}


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

	int n;
	cin >> n;
	vi vl(n);

	for (int i = 0; i < n; ++i)
		cin >> vl[i];

	sort(ALL(vl));
	int ans = 0;

	for (int k = max(1LL, n / 2 - 1); k <= n / 2; ++k)
	{
		vi a, b, c;
		for (int i = 0; i < k; ++i)
		{
			a.push_back(vl[i]);
			b.push_back(vl[n - 1 - i]);
		}

		for (int i = k; i < n - k; ++i)
			c.push_back(vl[i]);
	
		sort(ALL(a));
		sort(ALL(b));
		sort(ALL(c));
		ans = max(ans, my_get(c, b, a));

		if (SZ(c) > 3)
			continue;
	}

	vi cur(n);

	for (int i = 0; i < min(n, 100LL); ++i)
	{
		cur[0] = vl[i];
		int ind = 1;

		int l = 0, r = n - 1;
		while (l < r)
		{
			if (l == i)
			{
				l++;
				continue;
			}

			if (r == i)
			{
				r--;
				continue;
			}

			cur[ind++] = vl[r--];
			cur[ind++] = vl[l++];
		}

		if (l == r && r != i)
			cur[ind++] = vl[r];


		ans = max(ans, my_get(cur));
	}


	for (int i = 0; i < min(n, 100LL); ++i)
	{
		cur[0] = vl[n - i - 1];
		int ind = 1;

		int l = 0, r = n - 1;
		while (l < r)
		{
			if (l == n - i - 1)
			{
				l++;
				continue;
			}

			if (r == n - i - 1)
			{
				r--;
				continue;
			}

			cur[ind++] = vl[l++];
			cur[ind++] = vl[r--];
		}

		if (l == r && r != n - i - 1)
			cur[ind++] = vl[r];


		ans = max(ans, my_get(cur));
	}

	cout << ans << '\n';
}


Measured memory_bytes: 4824
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] c = new int[m][2];
		for(int i = 0; i < m; i++){
		    c[i][0] = sc.nextInt();
		    c[i][1] = sc.nextInt();
		}
		
		// 計算
		int result = -1;
		for(int i = 0; i < 1000; i++){
		    boolean flg = true;
		    String s = String.valueOf(i);
		    if(s.length() != n) continue;
		    for(int j = 0; j < m; j++){
		        if(c[j][0] > s.length()){
		            flg = false;
		            break;
		        }
		        if(s.charAt(c[j][0]-1) - '0' != c[j][1]){
		            flg = false;
		            break;
		        }
		    }
		    if(flg){
		        result = i;
		        System.out.println(result);
		        return;
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  int N,sum=0;
  cin>>N;
  vector<int> W;
  for(int i=0; i<N; ++i){
    int Q;
    cin>>Q;
    sum+=Q;
    W.push_back(Q);
  }
  
  int mn=100000,SUM=0;
  for(int i=0; i<N; ++i){
    SUM+=2*W.at(i);
    mn=min(mn,abs(sum-SUM));
  }
  
  cout<<mn<<endl;
}


Measured memory_bytes: 256
from collections import Counter

n=int(input())
a=Counter(list(map(int,input().split())))
x=[0,0]
for i in a.keys():
    if a[i]>1:
        x.append(i)
    if a[i]>3:
        x.append(i)
x.sort()
print(x[-1]*x[-2])

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

using namespace std;

namespace program
{
	namespace IO
	{
		struct input_t
		{
			static const int BUF_SIZ = 500000;
			FILE *f;
			char Buf[BUF_SIZ], *p, *pend;
			input_t(FILE *_f) : f(_f), p(Buf), pend(Buf) { }
			~input_t() { fclose(f); }
			char getchar();
			template <typename T> T read();
		};

		char input_t::getchar()
		{
			if(p >= pend)
			{
				p = Buf;
				pend = Buf + fread(Buf, sizeof(char), BUF_SIZ, f);
				if(p >= pend)
					return EOF;
			}
			return *p++;
		}

		template <typename T>
		T input_t::read()
		{
			T s = 0;
			int fl = 0;
			char ch;
			while(!isdigit(ch = getchar()))
				fl ^= (ch == '-');
			do
				s = s * 10 + ch - '0';
			while(isdigit(ch = getchar()));
			return fl ? -s : s;
		}

		struct output_t
		{
			static const int BUF_SIZ = 500000;
			FILE *f;
			char Buf[BUF_SIZ], *p, *const pend;
			output_t(FILE *_f) : f(_f), p(Buf), pend(Buf + BUF_SIZ) { }
			~output_t() { fwrite(Buf, sizeof(char), p - Buf, f); fclose(f); }
			void putchar(char ch);
			template <typename T> void write(T x);
			void puts(const char *ch);
		};

		void output_t::putchar(char ch)
		{
			*p++ = ch;
			if(p >= pend)
			{
				fwrite(Buf, sizeof(char), p - Buf, f);
				p = Buf;
			}
		}

		template <typename T>
		void output_t::write(T x)
		{
			static char St[30];
			char *top = St;
			if(x < 0)
			{
				putchar('-');
				x = -x;
			}
			do
				*top++ = x % 10 + '0';
			while(x /= 10);
			while(top > St)
				putchar(*--top);
		}

		void output_t::puts(const char *ch)
		{
			while(*ch)
				putchar(*ch++);
			putchar('\n');
		}
	}

	IO::input_t input(stdin);
	IO::output_t output(stdout);

	typedef long long big;

	const int MAXN = 100000;

	template <typename T>
	vector<T> &operator *=(vector<T> &A, vector<int> B)
	{
		vector<T> C = A;
		for(int i = 0; i < A.size(); i++)
			A[i] = C[B[i]];
		return A;
	}

	template <typename T1, typename T2>
	void qpow(T1 &S, T2 X, big n)
	{
		while(n)
		{
			if(n & 1)
				S *= X;
			X *= X;
			n >>= 1;
		}
	}

	void work()
	{
		int n = input.read<int>(), m;
		big k;
		vector<big> X;
		vector<int> C;
		for(int i = 0; i < n; i++)
		{
			X.push_back(input.read<big>());
			C.push_back(i);
		}
		for(int i = n - 1; i > 0; i--)
			X[i] -= X[i - 1];
		m = input.read<int>();
		k = input.read<big>();
		while(m--)
		{
			int x = input.read<int>();
			swap(C[x - 1], C[x]);
		}
		qpow(X, C, k);
		for(int i = 1; i < n; i++)
			X[i] += X[i - 1];
		for(int i = 0; i < n; i++)
		{
			output.write(X[i]);
			output.puts(".0");
		}
	}
}

int main()
{
	program::work();
	return 0;
}


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

using namespace std;

#define int long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x;}
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x;}
inline int mul(int x, int y) { return ((x % mod) * (y % mod)) % mod;}
inline int power(int a, int b) {
    int x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a) { return power(a, mod - 2);}

#undef int
int main() {
#define int long long int
  
    int n,k; cin>>n>>k;
    int x=0,y=0;
    for(int i=1;i<=n;i++){
    	if(i%k==0) x++;
    	if(i%k==(k/2)) y++;
    }
    if(k&1) cout<<(x*x*x)<<endl;
    else cout<<(x*x*x + y*y*y)<<endl;
    
    return 0;
}




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

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  
  int sum1=0;
  for(int i=0;i<N;i+=2){
    sum1+=A.at(i);
  }
  
  int sum2=0;
  for(int i=1;i<N;i+=2){
    sum2+=A.at(i);
  }
  cout<<sum1-sum2<<endl;
}
  

Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    h = sorted([int(input()) for _ in range(n)])

    hd = h[k-1] - h[0]
    ans = hd
    for i in range(k, n):
        hd += (h[i] - h[i-1]) - (h[i-k+1] - h[i-k])
        ans = min(ans, hd)

    print(ans)


main()


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

int n,k;
string s,t;
ll h; 
map<ll,ll> m;

int main() {
  cin >> h;
  ll cnt=0;
  while(h>1) h/=2,cnt++;
  ll ans=1,a=1;
  rep(i,cnt) a*=2,ans+=a;
  cout << ans << endl;
}

Measured memory_bytes: 256
/*#include<utility>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<iostream>
#include<string.h>*/
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
using namespace std;
typedef long long LL;
int main(){
    int n;
    scanf("%d",&n);
    multiset<int> s;
    for(int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        s.insert(x);
    }
    vector<int> v;
    for(int i=0;i<31;i++)
    v.pb(1<<i);
  //  printf("%d\n",v.back());
    int ans=0;
    while(!s.empty()){
        int x=*s.rbegin();
        s.erase(s.find(x));
        int target=*upper_bound(v.begin(),v.end(),x);
        int need=target-x;
        if(s.find(need)!=s.end()){
            s.erase(s.find(need));
            ans++;
        }
    }
    printf("%d\n",ans);
}
/*
0 1 0
0 0 1
1 0 1
*/

Measured memory_bytes: 9600
#include <stdio.h>

int main(){
  int n,a,b,c=0,i,f;
  char s[100005];
  scanf("%d",&n);
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%s",&s);
  for(i=0;i<n;i++){
    if((a+b==0)|(s[i]=='c')){
      f=0;
    }else if(s[i]=='a'){
      f=1;
    }else if(b==c){
      f=0;
    }else{
      f=1;
      c++;
    }
    if(f){
      printf("Yes\n");
      a--;
    }else{
      printf("No\n");
    }
  }
  return(0);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;


int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	ll x;
	cin>>x;
	ll bal = 100;
	ll count = 0;
	while(x > bal)
	{
		bal += bal/100;
		count ++; 
	}
	cout<<count;

}

Measured memory_bytes: 3628
D, G = [int(n) for n in input().split()]

score_table = []
for i in range(1, D+1):
    p, c = [int(n) for n in input().split()]
    score_table.append([i*100, p, c])

min_count = sum([l[1] for l in score_table])
#print(min_count)

for bit in range(1<<D):
    score = 0
    count = 0

    for i in range(D):
        if bit & (1<<i):
            score += score_table[i][0] * score_table[i][1] + score_table[i][2]
            count += score_table[i][1]
    
    if score >= G:
        min_count = min(min_count, count)
    else:
        additional = []
        for j in range(D):
            if not bit & (1<<j):
                additional.append(score_table[j])
        
        additional_ = sorted(additional, key=lambda x:x[0], reverse=True)
        #print(additional_)
        
        # for i in additional_:
        #     if i[1] > 1:
        #         add_score = i
        #         break

        add_score = additional_[0]

        for k in range(add_score[1]-1):
            score += add_score[0]
            count += 1
            if score >= G:
                min_count = min(min_count, count)

print(min_count)

Measured memory_bytes: 9240
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		int m = sc.nextInt();

		int[] list = new int[m + 1];

		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				list[sc.nextInt()]++;
			}
		}

		int ans = 0;
		for(int i = 0; i < m; i++) {
			if(list[i + 1] == n) ans++;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>

#define maxn 205
#define maxm 10000005

using namespace std;

inline int getint()
{
	int num=0,flag=1;char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
	while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
	return num*flag;
}

int n;
long long F[3];

int main()
{
	n=getint();F[1]=F[2]=-1ll<<60;
	while(n--)
	{
		int x=getint();
		F[0]+=x,F[1]-=x,F[2]+=x;
		if(x<0)F[2]=max(F[2],F[1]),F[1]=max(F[1],F[0]);
		F[1]=max(F[1],F[2]),F[0]=max(F[0],F[1]);
	}
	printf("%lld\n",F[0]);
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	n := ReadInt()
	p := ReadInts(n)
	c := 0
	for i := 1; i < n-1; i++ {
		if p[i-1] > p[i] && p[i] >= p[i+1] {
			c++
		} else if p[i-1] <= p[i] && p[i] < p[i+1] {
			c++
		}
	}
	fmt.Println(c)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> A(n);
  for(int i=0; i<n; i++){
    cin >> A[i];
  }
  int f[n+1]={0};
  if(n<=1){
    cout << "0" << endl;
    return 0;
  }
  f[n]=INT_MAX;
  f[n-2]= abs(A[n-2]-A[n-1]);
  for(int i=n-3; i>=0; i--){
    ll min= INT_MAX;
    int j=1;
    while(j<=k && i+j<=n-1){
      ll cur= abs(A[i]-A[i+j])+f[i+j];
      if(cur < min)
        min= cur;
      j++;
    }
    f[i]= min;
    // f[i]= min(abs(A[i]-A[i+1])+f[i+1], abs(A[i]-A[i+2])+f[i+2]);
  }
  cout << f[0]<<endl;

  return 0;
}


Measured memory_bytes: 1408
N = int(input())
T = input().split()
M = int(input())

Drink = []
for D in range(M):
    Drink.append(input().split()) 
    
#print(Drink)

AnsTime = 0
for t in range(N):
    AnsTime += int(T[t]) 
#print(AnsTime)
#print(T[0])
#print(Drink[0][0])
#print(T[int(Drink[0][0])])
for Dec in range(M):
    DecreaseTime = AnsTime - (int(T[int(Drink[Dec][0])-1]) - int(Drink[Dec][1]) )
    print(DecreaseTime)

Measured memory_bytes: 3064
program sample
  implicit none
  integer :: a,b,c,d,abcd

  read(*,*) abcd
  a=abcd/1000
  b=abcd/100-10*a
  c=abcd/10-100*a-10*b
  d=abcd-1000*a-100*b-10*c

  if(a+b+c+d==7)then
     write(*,'(i1,"+",i1,"+",i1,"+",i1,"=7")') a,b,c,d
     stop
  else if(a-b+c+d==7)then
     write(*,'(i1,"-",i1,"+",i1,"+",i1,"=7")') a,b,c,d
     stop
  else if(a+b-c+d==7)then
     write(*,'(i1,"+",i1,"-",i1,"+",i1,"=7")') a,b,c,d
     stop
  else if(a+b+c-d==7)then
     write(*,'(i1,"+",i1,"+",i1,"-",i1,"=7")') a,b,c,d
     stop
  else if(a-b-c+d==7)then
     write(*,'(i1,"-",i1,"-",i1,"+",i1,"=7")') a,b,c,d
     stop
  else if(a-b+c-d==7)then
     write(*,'(i1,"-",i1,"+",i1,"-",i1,"=7")') a,b,c,d
     stop
  else if(a+b-c-d==7)then
     write(*,'(i1,"+",i1,"-",i1,"-",i1,"=7")') a,b,c,d
     stop
  else if(a-b-c-d==7)then
     write(*,'(i1,"-",i1,"-",i1,"-",i1,"=7")') a,b,c,d
     stop
  endif
  
  stop
  
end program sample

Measured memory_bytes: 2884
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
signed main(){
  string s;
  int ans=0,sum=0;
  cin>>s;
  if(s[0]=='R') sum++;
  for(int i=1;i<3;i++){
    if(s[i]=='R'&sum==0) sum++;
    if(s[i-1]==s[i]&&s[i]=='R') sum++;
    else ans=max(ans,sum),sum=0;
  }
  ans=max(ans,sum);
  cout<<ans<<"\n";
}

Measured memory_bytes: 3616
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}




signed main() {
	int x,a,A,B;
	cin >> x;
	for (int i = 1; i * i <= x; i++) {
		if (x % i != 0) {
			continue;
		}
		a = x / i;
		B = -200;
		A = B + i;
		while (B<0||jousu(A, 4) + jousu(A, 3) * B + A * A * B * B + B * B * B * A + B * B * B * B <= a) {
			
			if (A * A * A * A + A * A * A * B + A * A * B * B + B * B * B * A + B * B * B * B == a) {
				cout << A << " " << B << endl;
				return 0;
			}
			B++;
			A = B + i;
		}
	}
}



Measured memory_bytes: 3640
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        vector<int>ar(10);
        for(auto&e:ar){
                scanf("%d",&e);
        }
        sort(ar.begin(),ar.end());
        printf("%d\n%d\n%d\n",ar[9],ar[8],ar[7]);
        return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    int n = get<int>();

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (to_string(i).size() % 2 == 1)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    int n; cin >> n;
    string str; cin >> str;
    int Count = 0;
    int f = 0;
    int ls = n-1;
    while(f < ls)
    {
        for(int i = f; i <= ls; i++)
        {
            f = i;
            if(str[i] == 'W')
            {
                f = i;
                break;
            }
        }
        for(int i = ls; i >= f; i--)
        {
            ls = i;
            if(str[i] == 'R')
            {
                ls = i;
                break;
            }
        }
        if(f < ls)
        {
            Count++;
            str[f] = 'R';
            str[ls] = 'W';
            f++;
            ls--;
        }
    }
    cout << Count << endl;
}
int main()
{
    solve();
    return 0;
}


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

int main(int argc, const char * argv[]) {
    while(1){
        int n, p; cin >> n >> p;
        if(!n && !p) break;
        
        int now = p, id = 0;
        int man[50] = {0};
        while(1){
            if(now == 0){
                now = man[id];
                man[id] = 0;
            } else {
                man[id]++;
                now--;
                if(man[id] == p) break;
            }
            id = (id + 1) % n;
        }
        cout << id << endl;
    }
}

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

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

    vector<pair<int, int> > a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i + 1;
    }
    sort(a.begin(), a.end());

    for (int i = 0; i < n; i++) {
        cout << a[i].second;
        if (i != n - 1) cout << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1664
n = int(input())
h = list(map(int, input().split()))

c = 0
ans = 0
for x in range(n - 1):
    if h[x] >= h[x + 1]:
        c += 1
    else:
        ans = max(ans, c)
        c = 0

ans = max(ans, c)
print(ans)


Measured memory_bytes: 15020