akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val (n, d) = readLine()!!.split(" ").map { it.toInt() }
    val res = n.toDouble() / (2 * d.toDouble() + 1)
    if (res > res.toInt()) println(res.toInt() + 1)
    else println(res.toInt())
}

Measured memory_bytes: 37932
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, k;
    cin >> n >> k;
    if (abs(n - k) >= n)
        cout << n << '\n';
    else
        cout << min(abs(n % k), abs(n % k - k)) << '\n';
  
    return 0;
}

Measured memory_bytes: 3628
import java.io.*;
import java.util.*;
import java.math.*;
     
public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
	    void solve(IO io, PrintWriter out)
	    {
           int i, j=0;
           	int h = io.nextInt();
          	int n = io.nextInt();
          	int sum=0;
          	for(i=0 ; i<n ; i++)
              	sum+=io.nextInt();
          	if(sum>=h)
              out.print("Yes");
          	else
              out.print("No");
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
}

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

using namespace std;

#define DB( x ) cout << #x << " = " << x << endl;
#define LEFT(n) (2 * (n))
#define RIGHT(n) (2 * (n) + 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> node;
//typedef vector <vector <ll>> matrix;

const ll INF = 1e9;
const double EPS = 1e-9;
const ll MOD = (ll)(1000000007);
const ll MAXV = (ll)(2e6 + 10);
const ll MAXE = (ll)(1e6 + 10);

ll cnt[MAXV];

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

	string s;

	cin >> s;

	vector<ll> pos_r;

	for(ll i = 0;i < s.size() - 1;i ++){
		if(s[i] == 'R' && s[i + 1] == 'L')
			pos_r.push_back(i + 1);
	}

	ll curr = 0, dif;
	for(ll i = 0;i < s.size();i ++){
		if(s[i] == 'R'){
			dif = pos_r[curr] - i;
			if(dif % 2LL == 0LL)
				cnt[pos_r[curr]] ++;
			else
				cnt[pos_r[curr] - 1] ++;
		}
		else{
			dif = i - pos_r[curr - 1];
			if(dif % 2LL == 0LL)
				cnt[pos_r[curr - 1]] ++;
			else
				cnt[pos_r[curr - 1] - 1] ++;
		}

		if(i == pos_r[curr] - 1)
			curr ++;
	}

	for(ll i = 0;i < s.size();i ++)
		cout << cnt[i] << " ";
	cout << "\n";

	return 0;
}


Measured memory_bytes: 1864
import bisect
n,*l=map(int,open(0).read().split())
l.sort()
a=0
for i in range(n):
    for j in range(i+1,n):
        k=l[i]+l[j]
        a+=max(0,bisect.bisect_left(l,k)-j-1)
print(a) 

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

int main(){
    ll n,p;
    cin>>n>>p;
    if(n==1){cout<<p<<endl; return 0;}
    int ans=0;
    for(int i=1; i<1000100; ++i){
        if(pow(i,n)>p)break;
        if(p%(ll)pow(i,n)==0)ans=i;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int a,b, h;
    cin >> a >> b >> h;
    cout << (a+b)*h / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << ( A + B >= C ? "Yes" : "No" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool c7(int n) {
    int k;
    while (n > 0) {
        k = n % 10;
        if (k == 7)return 1;
        n /= 10;
    }
    return 0;
}
int main()
{
    int n;
    cin >> n;
    cout << (c7(n)?"Yes":"No");
}

Measured memory_bytes: 3560
import string
List = [chr(i) for i in range(65,65+26)]
N = int(input())
s = list(input())
ans = ''
for i in range(len(s)):
  Next_index = List.index(s[i])+N
  if Next_index>25:
    Next_index = abs(26-Next_index)
  ans += List[Next_index]
print(ans)

Measured memory_bytes: 3772
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long 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;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
double PI = 3.141592653589793238;
vector<vector<int>>G(100030);
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int susum[100030] = {};
	queue<int>q;
	q.push(1);
	while (q.size()) {
		int a = q.front();
		q.pop();
		for (auto i : G[a]) {
			if (susum[i] == 0) {
				q.push(i);
				susum[i] = a;
			}
		}
	}
	cout << "Yes" << endl;
	for (int i = 2; i <= n; i++) {
		cout << susum[i] << endl;
	}
}

Measured memory_bytes: 10040
#include<stdio.h>
#define N 1000

int main(void){
	int n;
	scanf("%d", &n);
	double a[n];
	double b[n+1];
	double c[n+1][n+1];
	double d[n+1];
	
	for(int i = 0; i < n; i++){
		scanf("%lf", &a[i]);
	}
	
	for(int i = 0; i <= n; i++){
		scanf("%lf", &b[i]);
	}
	
	c[0][0] = b[0];
	d[0] = a[0] + b[0];
	
	for(int i = 1; i <= n; i++){
		c[i][i] = b[i];
		c[i-1][i] = a[i-1] + (b[i-1] + b[i]) * 2;
		d[i] = d[i-1] + a[i] + b[i];
	}
	
	double x, y;
	
	for(int i = 1; i < n; i++){
		for(int j = 0; j < n-i; j++){
			x = c[j][j] + c[j+1][i+j+1];
			for(int k = j; k < i+j; k++){
				y = c[j][k+1] + c[k+2][i+j+1];
				if(x > y){
					x = y;
				}
			}
			c[j][i+j+1] = x + d[i+j] - d[j-1] + b[i+j+1];
		}
	}
	printf("%lf\n", c[0][n]);
	
	return 0;
}


Measured memory_bytes: 3740
n,m = map(int,input().split())
l_rng = []
for i in range(m):
    l_rng.append( list(map(int,input().split()) ) )
l_rng.sort(key=lambda x:x[1])    
#初期
r_isl = l_rng[0][1]
cnt = 1

for i in l_rng:
  if  r_isl <= i[0]:
    r_isl = i[1] 
    cnt = cnt + 1
print(cnt)    

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

using namespace std;

typedef long long ll;

ll min(ll a, ll b) {
  return a > b ? b : a;
}

ll max(ll a, ll b) {
  return a < b ? b : a;
}

int main() {
  int N;
  
  ll maxZ = -9223372036854775807l, minZ = 9223372036854775807l,
     maxW = -9223372036854775807l, minW = 9223372036854775807l;
  
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    ll in_x, in_y;
    
    cin >> in_x >> in_y;
    
    minZ = min(minZ, in_x + in_y);
    maxZ = max(maxZ, in_x + in_y);
    minW = min(minW, in_x - in_y);
    maxW = max(maxW, in_x - in_y);
  }
  
  cout << max(maxZ - minZ, maxW - minW) << endl;
  
  return 0;
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	map<int,int> m;
	int n,x;cin>>x>>n; int a; repi(i,n) {cin>>a;m[a]=1;}
	int ans=0,mi=200;
	for(int i=0;i<100;++i)
	{
		if(m[x-i]==0) {ans= x-i;break;}
		if(m[x+i]==0) {ans= x+i;break;}
		
	}
	db(ans);
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 3648
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt() , k = sc.nextInt();
        Integer [] h = sc.nextIntegerArray(n);
        Arrays.sort(h);
        long ans = 0;
        for (int i = n-1-k ; i>=0 ; i--)
            ans  += h[i];
        out.println(ans);
        out.flush();
        out.close();
    }


    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

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


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

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

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

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

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }


        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }

}

Measured memory_bytes: 54100
class Main {
    public static void main(String[] args) {
    	
    	for(int i = 1; i <= 9; i++) {
    		for(int j = 1; j <= 9; j++) {
    			System.out.println(i + "x" + j + "=" + i * j);
    		}
    	}
    	
   }
}

Measured memory_bytes: 9068
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#define INF 10e10

using namespace std;

//  #define y cout << "yes"<< endl
  #define Y cout << "YES" << endl
  #define y cout << "Yes" << endl
//  #define n cout << "no"<< endl
  #define N cout << "NO" << endl
  #define n cout << "No" << endl
  #define pu(q) cout << q ;
  #define put(q) cout << q << " ";
  #define puts(q) cout << q << endl;
  
  
	int a,b,c,d,e,f,g,h,ans,res;
//	char a,b,c,d,e,f,g,h,ans,res;
//	string a,b,c,d,e,f,g,h,ans,res;
//	double a,b,c,d,e,f,g,h,ans,res;
	
void take(int x);
  
int main(void){
	take(3);//数
	
	
	
	if(a*b>c){
		puts(c);
		
	//	y;	//Yes
	//	Y;	//YES
	//	n;	//No
	//	N;	//NO
	}/*
	
	else if(){
		
		
	//	y;
	//	Y;
	//	n;
	//	N;
		
	}
	else if(){
		
		
	//	y;
	//	Y;
	//	n;
	//	N;
		
	}
	else if(){
		
		
	//	y;
	//	Y;
	//	n;
	//	N;
		
	}
	*/
	else{
		
	puts(a*b);	
	//	y;
	//	Y;
	//	n;
	//	N;
		
	}
//	cout << ans << endl;
	
	return 0;
}
void take(int x){
	if(x==1)
		cin >> a;
	else if(x==2)
		cin >> a >> b;
	else if(x==3)
		cin >> a >> b >> c;
	else if(x==4)
		cin >> a >> b >> c >> d;
	else if(x==5)
		cin >> a >> b >> c >> d >> e;
	else if(x==6)
		cin >> a >> b >> c >> d >> e >> f;
	else if(x==7)
		cin >> a >> b >> c >> d >> e >> f >> g;
	else if(x==8)
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
	return ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
//using namespace __gnu_pbds;
//typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
//ordered_set;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
#define X first
#define Y second
//#define int long long int 
const int MAXN = (int)2e5 + 10;
const int MOD = (int) 1e9;

void solve(){
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for(int i = 0; i < m; ++i){
        int x; cin >> x;
        sum += x;
    }
    if(sum > n){
        cout << -1 << '\n';
    } else {
        cout << n - sum << '\n';
    }

}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}
/*
Sample inp
*/


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long
#define pi pair<ll,ll>
ll a[800001],  b[500009], lastcall[800000], value[500000];
string s;
vector<ll>v;
int main()
{
    IO;
    ll j=0, n, m, k, kk=1, m1=0, a1=8, grtr=0, a2=20, l, t, ds,r,mx=0, cnt=0, mn=INT_MAX, h=0, mod=1e9+7, i; char ch;
    cin>>n>>k;
    for(i=1; i<=n; i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(i=1; i<=k; i++) cnt+=a[i];
    cout<<cnt<<endl;
    return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  
  int result = 0;
  for(int i=0; i < s.size(); i++) {
    if(s[i] == t[i]) result++;
  }
  cout << result << endl;
}


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

using namespace std;

#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef complex<ld> point;
typedef vector<int> vi;

inline void fileIO(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}

template <class T, class S>
inline bool smin(T &a, S b) {
  return (T)b < a ? a = b, 1 : 0;
}
template <class T, class S>
inline bool smax(T &a, S b) {
  return a < (T)b ? a = b, 1 : 0;
}

constexpr int MOD = 1e9 + 7;  // 924844033;
constexpr int N = 1e5 + 10;

template <typename T>
inline T mod(T &v) {
  return v = (v % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S &l, T r) {
  return mod(l += r);
}
ll po(ll v, ll u) {
  return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1;
}

int n;
ll T, E, x[N], dp[N], seg[N << 1];

inline void segAssign(int id, ll val) {
  for (seg[id += n] = val; id > 1; id >>= 1)
    seg[id >> 1] = min(seg[id], seg[id ^ 1]);
}

inline ll segGet(int l, int r) {
  ll res = 1e18;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) smin(res, seg[l++]);
    if (r & 1) smin(res, seg[--r]);
  }
  return res;
}

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

#ifndef LOCAL
  // fileIO("superposition");
#endif

  cin >> n >> E >> T;
  n++;
  rep(i, 1, n) cin >> x[i];

  int ptr = 0;
  dp[0] = 0;
  segAssign(0, dp[0] + T);
  rep(i, 1, n) {
    while (2 * (x[i] - x[ptr + 1]) >= T) {
      segAssign(ptr, dp[ptr] - 2 * x[ptr + 1]);
      ptr++;
    }
    dp[i] = min(segGet(0, ptr) + 2 * x[i], segGet(ptr, i));
    segAssign(i, dp[i] + T);
  }

  cout << E + dp[n - 1] << endl;

  return 0;
}

// 1 2 0 1 2

Measured memory_bytes: 3328
# -*- coding: utf-8 -*-

N, M = map(int,input().split())

street = [0 for i in range(N)]

for i in range(M):
    a, b = map(int,input().split())
    street[a-1] += 1
    street[b-1] += 1

for s in street:
    print(s)

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
typedef long long int ll;

int main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;

  ll mods = 1000000007;
  vector<ll> primes
      {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107,
       109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
       233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359,
       367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491,
       499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641,
       643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787,
       797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
       947, 953, 967, 971, 977, 983, 991, 997};

  vector<ll> yaku(1001, 0);
  for (int i = 2; i <= n; ++i) {
    for (int j = 0; j < primes.size(); ++j) {
      ll ii = i;
      bool flags = true;
      while (flags) {
        flags = false;
        if (ii % primes.at(j) == 0) {
          flags = true;
          ii /= primes.at(j);
          ++yaku.at(primes.at(j));
        }
      }
    }
  }
  ll ans = 1;
  for (const auto &i : yaku) {
    if (i != 0) ans = ans * (i + 1) % mods;

  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,a,n) for(int i = a; i < n; i++)
#define s(n) cin >> n
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rsz(x,n) x.clear(); x.resize(n)
#define rrsz(x,a,n) x.clear(); x.resize(n,a)
#define wt while(true)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ls(x) ((2*(x)) + 1)
#define rs(x) ((ls(x)) + 1)
#define md(a,b) (((a) + (b))/2)
#define INF (1e9 + 7)
using namespace std;

int main()
{
    lli n,k;
    s(n);s(k);
    vector<int>a(n);
    for(int& x : a)
    s(x);
    vector<bool> dp(k + 1);
    for(int stones = 0; stones <= k; ++stones) {
        for(int x : a) {
            if(stones >= x && !dp[stones-x]) {
                dp[stones] = true;
            }
        }
    }

    puts(dp[k] ? "First" : "Second");
    
    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn check(v: &Vec<i32>, n: i32, a0: i32, a1: i32) -> Option<Vec<i32>> {
    let mut a: Vec<i32> = vec![];
    a.push(a0);
    a.push(a1);
    for i in 0..n {
        let tmp1 = a[i as usize];
        let tmp2 = a[(i + 1) as usize];
        let tmp = tmp1 * tmp2 * v[((i + 1) % n) as usize];
        a.push(tmp);
    }

    if a0 == a[n as usize] && a1 == a[(n + 1) as usize] {
        Some(a.clone())
    } else {
        None
    }
}

fn main() {
    let n: i32 = read();
    let s: String = read();
    let v: Vec<i32> = s.chars().map(|e| if e == 'o' { 1 } else { -1 }).collect();

    if let Some(a) = check(&v, n, 1, 1) {
        for i in 0..n {
            if a[i as usize] == 1 {
                print!("S");
            } else {
                print!("W");
            }
        }
    } else if let Some(a) = check(&v, n, 1, -1) {
        for i in 0..n {
            if a[i as usize] == 1 {
                print!("S");
            } else {
                print!("W");
            }
        }
    } else if let Some(a) = check(&v, n, -1, 1) {
        for i in 0..n {
            if a[i as usize] == 1 {
                print!("S");
            } else {
                print!("W");
            }
        }
    } else if let Some(a) = check(&v, n, -1, -1) {
        for i in 0..n {
            if a[i as usize] == 1 {
                print!("S");
            } else {
                print!("W");
            }
        }
    } else {
        print!("-1");
    }
    println!("");
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>

int seiza[200][2],star[1000][2],n,m,i,j,k,x,y,flag;

int main(){
	while(~scanf("%d",&m)){
		if(m==0)break;
		
		for(i=0;i<m;i++){
			scanf("%d%d",&seiza[i][0],&seiza[i][1]);
		}
		
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d%d",&star[i][0],&star[i][1]);
		}
		
		for(i=0;i<n;i++){
			x=-seiza[0][0]+star[i][0];
			y=-seiza[0][1]+star[i][1];
			flag=0;
			for(j=1;j<m;j++){
				flag=1;
				for(k=0;k<n;k++){
					if(-x+star[k][0]==seiza[j][0] && -y+star[k][1]==seiza[j][1])flag=0;
				}
				if(flag==1)break;
			}
			if(flag==0)break;
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
long long n,a,ok;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>n;
long long minn=100000000;
for(int i=0;i<n;i++){
	 cin>>a;
	 if(a<minn){
	 	 ok++;
	 }
	 minn=min(a,minn);
}
cout<<ok;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll K, A, B;
	std::cin >> K >> A >> B;
	repeq(i, A, B) {
		if (i % K == 0) {
			std::cout << "OK" << endl;
			return 0;
		}
	}
	std::cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3592
n, k = map(int, input().split())
hs = list(map(int, input().split()))
dp=[0]*n
dp[0]=0
for i, hi in enumerate(hs):
    if i == 0:
        continue
    s = max(0, i-k)
    dp[i] = min([ml + abs(hl - hi) for ml, hl in zip(dp[s:i], hs[s:i])])
print(dp[-1])

Measured memory_bytes: 13980
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e30
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,X,Y;
ll ans;
ll a[1000000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}

int main() {
	cin>>X>>Y;
	if(abs(X-Y)<=1)cout<<"Brown"<<endl;
	else cout<<"Alice"<<endl;
	return 0;
}

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

const long long INF = 1e5 + 6;

int main()
{

	int n;
	cin >> n;
	int vac[n+1][3];
	for(int i = 1;i<=n;i++){
		cin >> vac[i][0] >> vac[i][1] >> vac[i][2];
	}

	long long int dp[n+1][3];
	dp[1][0] = vac[1][0];
	dp[1][1] = vac[1][1];
	dp[1][2] = vac[1][2];
	for(int i = 2;i<=n;i++){
		for(int j = 0;j<3;j++){
			dp[i][j] = max(dp[i-1][(j+1)%3]+vac[i][j],dp[i-1][(j+2)%3]+vac[i][j]);
		}
	}


	long long ans = max(dp[n][0],max(dp[n][1],dp[n][2]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;


namespace ABC136
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            int cnt = 0;

            for (int i = 1; i <= n; i++)
            {
                if (i<10)
                {
                    cnt++;
                }
                else if (100 <= i && i < 1000)
                {
                    cnt++;
                }
                else if (10000 <= i && i < 100000)
                {
                    cnt++;
                }
                else if (1000000 <= i && i < 10000000)
                {
                    cnt++;
                }

            }

            WriteLine("{0}", cnt);
            Read();
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<set>
using namespace std;
int n , m , a , b;

signed main() {
    cin >> n >> m >> a >> b;
    for( int i = 1 ; i <= b ; ++ i ) {
        for( int j = 1 ; j <= a ; ++ j ) putchar( '1' );
        for( int j = 1 ; j <= m - a ; ++ j ) putchar( '0' );
        puts("");
    }
    for( int i = 1 ; i <= n - b ; ++ i ) {
        for( int j = 1 ; j <= a ; ++ j ) putchar( '0' );
        for( int j = 1 ; j <= m - a ; ++ j ) putchar( '1' );
        puts("");
    }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long int
#define INF 10000000000000
#define MK2DV(v,row,col,val) vector<vector<ll>> v(row, vector<ll>(col,val))
using namespace std;
ll findmin(ll a, ll b)
{
    if(a < b) return a;
    return b;
}
ll fuc(ll i, ll have, ll *give, ll *cost, ll m, ll n, vector<vector<ll> > &dp)
{
    if(have == n)
    {
        return 0;
    }
    if(i == m)
    {
        return INF;
    }
    if(dp[i][have] != -1)
    {
        return dp[i][have];
    }
    ll ans = findmin(fuc(i+1,have,give,cost,m,n,dp), fuc(i+1,(have|give[i]),give,cost,m,n,dp)+cost[i]);
    dp[i][have] = ans;
    return ans;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    ll give[m];
    ll cost[m];
    ll netreq = (1LL << n) - 1;
    MK2DV(dp,m+5,netreq+5,-1);
    for(ll i = 0; i < m; i++)
    {
        give[i] = 0;
        ll a, b;
        cin >> a >> b;
        cost[i] = a;
        for(ll j = 0; j < b; j++)
        {
            ll key;
            cin >> key;
            key--;
            ll mask = (1LL << key); 
            give[i] = (give[i] | mask );
        }
    }
    ll ans = fuc(0,0,give,cost,m,netreq,dp);
    if(ans >= INF)
        ans = -1;
    cout << ans << '\n';
    return 0;
 }


Measured memory_bytes: 32640
#include <vector>
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
using namespace std;

// 累積演算 (0-indexed・prefix, suffix, 任意連続部分列)
// 任意連続部分列は逆演算があるときのみできる？

template <typename MonoidType>
struct Accumulation {
    int n;
    vector<MonoidType> pre, suf;
    MonoidType E;
    
    using MMtoM = function< MonoidType(MonoidType, MonoidType) >;
    MMtoM op, rop;

    void build(int m, vector<MonoidType> vec) {
        pre = suf = vector<MonoidType>(m+1, E);
        for(int i=0; i<m; i++) {
            pre[i+1] = op(pre[i], vec[i]);
        }
        for(int i=m-1; i>=0; i--) {
            suf[i] = op(suf[i+1], vec[i]);
        }
    }

    Accumulation() {}
    Accumulation(vector<MonoidType> val_array, MonoidType E_,
                 MMtoM op_, MMtoM rop_ = MMtoM()) :
        E(E_), op(op_), rop(rop_) {
        n = val_array.size();
        build(n, val_array);
    }

    // [0, k)
    inline MonoidType get_prefix(int k) { return pre[k]; }
    // [k, n)
    inline MonoidType get_suffix(int k) { return suf[k]; }
    // [l, r) (rop が定義されてるときのみ)
    inline MonoidType get_subseq(int l, int r) {
        return rop(pre[r], pre[l]);
    }
};


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

// Verified on Apr 28, 2019 (prefix, suffix のみ)
// Judge: https://atcoder.jp/contests/abc125/tasks/abc125_c
void ABC125_C() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    
    Accumulation<int> acc(A, 0,
                          [](int a, int b) { return gcd(a, b); });

    int ans = 0;
    for(int i=0; i<N; i++) {
        int vl = acc.get_prefix(i), vr = acc.get_suffix(i+1);
        ans = max(ans, gcd(vl, vr));
    }
    cout << ans << endl;
}

void ABC122_C() {
    int N, Q; cin >> N >> Q;
    string s; cin >> s;

    vector<int> A(N);
    for(int i=1; i<N; i++) {
        A[i] = (s[i-1] == 'A' and s[i] == 'C');
        // fprintf(stderr, "%lld ", A[i]);
    }
    // fprintf(stderr, "\n");

    Accumulation<int> acc(A, 0,
                          [](int a, int b) { return a + b; },
                          [](int a, int b) { return a - b; });

    for(int i=0; i<Q; i++) {
        int l, r; cin >> l >> r;
        cout << acc.get_subseq(l, r) << endl;
    }
}

int main() {
    // ABC125_C();
    ABC122_C();
    return 0;
}


Measured memory_bytes: 2432
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
typedef long long ll;
typedef unsigned un;
typedef std::string str;
typedef std::pair<ll,ll> pll;
typedef std::pair<int,int> pii;
typedef std::pair<double,double> pd;
ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return f*x;}
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
void umax(int& a,int t){if(t>a)a=t;}
bool umin(ll& a,ll t){if(t<a)return a=t,1;return 0;}
#define MAXN 1000011
struct Trie
{
    int t[MAXN][26],status[MAXN][26];
    int cnt,tmp[26];
    Trie(){cnt=1;}
    void clear(){memset(t,0,sizeof t),memset(status,0,sizeof status),cnt=1;}
    void insert(char* s,int begin,int end)
    {
        for(int i=begin;i<=end;++i)++tmp[s[i]-'a'];
        int u=1;
        for(int c=0;c<26;++c)status[1][c]+=!!tmp[c];
        for(int i=end;i>=begin;--i)
        {
            int& v=t[u][s[i]-'a'];
            if(!v)v=++cnt;
            u=v;
            --tmp[s[i]-'a'];
            for(int c=0;c<26;++c)
                status[u][c]+=!!tmp[c];
        }
    }
    int Query(char* s,int begin,int end)
    {
        int u=1;
        for(int i=end;i>begin;--i)
        {
            u=t[u][s[i]-'a'];
            if(!u)return 0;
        }
        return status[u][s[begin]-'a'];
    }
}t;
char s[MAXN];
int len[MAXN];
int main()
{
    int n=read();
    ll ans=0;
    for(int i=1;i<=n;++i)
    {
        scanf("%s",s+len[i-1]+1);
        len[i]=len[i-1]+strlen(s+len[i-1]+1);
        ans+=t.Query(s,len[i-1]+1,len[i]);
        t.insert(s,len[i-1]+1,len[i]);
    }
    t.clear();
    for(int i=n;i;--i)
    {
        ans+=t.Query(s,len[i-1]+1,len[i]);
        t.insert(s,len[i-1]+1,len[i]);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 208464
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


vector<int> solve(const vector<int>& preorder0, const vector<int>& inorder0) {
    if (preorder0.size() <= 1) {
        return preorder0;
    }
    const int root = preorder0[0];
    auto boundary = find(inorder0.begin(), inorder0.end(), root);

    vector<int> inorderL;
    for (auto i = inorder0.begin(); i != boundary; ++i) {
        inorderL.push_back(*i);
    }
    vector<int> inorderR;
    auto tmp = boundary;
    ++tmp;
    for (auto i = tmp; i != inorder0.end(); ++i) {
        inorderR.push_back(*i);
    }

    vector<int> preorderL;
    auto tmp2 = preorder0.begin();
    ++tmp2;
    for (int i = 0; i < inorderL.size(); ++i) {
        preorderL.push_back(*tmp2);
        ++tmp2;
    }
    vector<int> preorderR;
    for (int i = 0; i < inorderR.size(); ++i) {
        preorderR.push_back(*tmp2);
        ++tmp2;
    }

    vector<int> postorderTreeWalk = solve(preorderL, inorderL);
    vector<int> rightSubtree = solve(preorderR, inorderR);
    for (auto item : rightSubtree) {
        postorderTreeWalk.push_back(item);
    }
    postorderTreeWalk.push_back(root);

    return postorderTreeWalk;
}

int main()
{
    int n;
    cin >> n;
    vector<int> preorderTreeWalk;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        preorderTreeWalk.push_back(x);
    }

    vector<int> inorderTreeWalk;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        inorderTreeWalk.push_back(x);
    }

    vector<int> postorderTreeWalk = solve(preorderTreeWalk, inorderTreeWalk);

    std::cout << postorderTreeWalk[0];
    for (int i = 1; i < postorderTreeWalk.size(); ++i) {
        std::cout << " " << postorderTreeWalk[i];
    }
    cout << endl;
}



Measured memory_bytes: 3156
#include<stdio.h>
using namespace std;

int main(void){
	int n, x;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		x = i;
		if(x % 3 == 0){
			printf(" %d", i);
		} else {
			do{
				if(x % 10 == 3){
					printf(" %d", i);
					break;
				}
				x = x / 10;
			} while(x);
		}
	}
	printf("\n");
	return 0;
}

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

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

  if (S.at(5) == '0' && S.at(6) == '1') {
    cout << "Heisei" << endl;
  }  
  else if (S.at(5) == '0' && S.at(6) == '2') {
    cout << "Heisei" << endl;
  }
  else if (S.at(5) == '0' && S.at(6) == '3') {
    cout << "Heisei" << endl;
    }
  else if (S.at(5) == '0' && S.at(6) == '4') {
    cout << "Heisei" << endl;
      }
  else {
    cout << "TBD" << endl;
  }
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> imos(n + 1);

    rep(_, min(k, 100)) {
        imos.assign(n + 1, 0);
        rep(i, n) {
            if (i - a[i] <= 0)
                imos[0]++;
            else
                imos[i - a[i]]++;

            if (i + a[i] + 1 <= n)
                imos[i + a[i] + 1]--;
            else
                imos[n]--;
        }

        rep(i, n) {
            imos[i + 1] += imos[i];
        }

        rep(i, n) a[i] = imos[i];
    }
    rep(i, n) cout << imos[i] << " ";

    return 0;
}

Measured memory_bytes: 6436
n = int(input())
sqrt_n = int(n ** 0.5)
count = 0
com = []
for i in range(sqrt_n):
    if n % (i+1) == 0:
        a, b = i+1, int(n/(i+1))
        if b-a >= 2:
            com.append([a,b])
for i in range(len(com)):
    count += (com[i][1]-1)
print(count)

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll>vec,vec2;
int main()
{
    ll a,b,c,d,e,i,j,k,l,n,m,x,y,t,p;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld%lld",&x,&y);
        vec.push_back(x+y);
        vec2.push_back(x-y);
    }
    sort(vec.begin(),vec.end());
    sort(vec2.begin(),vec2.end());
    ll ans=max(vec[n-1]-vec[0],vec2[n-1]-vec2[0]);
    cout<<ans<<endl;
}


Measured memory_bytes: 6648
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}
	else if(a>b){
		cout<<"a > b"<<endl;
	}
	else cout<<"a == b"<<endl;
}



Measured memory_bytes: 3108
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var num = Input.num;
        var ar = Input.ar;
        var dp = new long[num + 1, 4];
        for (var i = 0; i <= num; i++)
            for (var j = 0; j < 4; j++)
                dp[i, j] = int.MaxValue;

        for (var j = 0; j < 4; j++)
            dp[0, j] = j;
        for (var i = 1; i < num; i++)
            for (var j = 0; j < 4; j++)
                for (var h = 3; h >= 0 && j + h >= ar[i - 1]; h--)
                    dp[i, j] = Min(dp[i, j], dp[i - 1, h] + 2 * j);
        for (var j = 0; j < 4; j++)
            for (var i = 3; i >= 0 && i + j >= ar[num - 1]; i--)
                dp[num, j] = Min(dp[num, j], j + dp[num - 1, i]);
        var min = long.MaxValue;
        for (var i = 0; i < 4; i++)
            min = Min(min, dp[num, i]);
        WriteLine(min);
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}



Measured memory_bytes: 18384
#include <bits/stdc++.h>
#define Rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
inline void nl(){std::cout<<std::endl;}
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

using ui = uint64_t;

//----------------library in this time--------------------------------
template <typename T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <typename T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <typename T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}
//------------------------main function-------------------------------
void Main(){
    ui n,m;
    cin >> n >> m;
    priority_queue<ui> a;
    Rep(i, n){
        ui ff;
        cin >> ff;
        a.push(ff);
    }
    Rep(i, m){
        ui ff = a.top();
        a.pop();
        a.push(ff/2);
    }
    ui ans = 0;
    while (!a.empty()) {
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;
    
}
//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    
    Main();
    return 0;
}



Measured memory_bytes: 1400
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9') f|=c=='-',c=getchar();
    while(c>='0'&&c<='9') x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

#define MAXN 5000
#define LL long long
int N,K;
char Min,Max,Ans[2*MAXN+5],str[2*MAXN+5];

char tmp[2*MAXN+5];
void Solve(char *S){
    int Now=N,len=0,k=K;
    while(Now>=1&&S[Now]==Min)
        Now--,len++;
    while(k&&len<=N-1)
        len<<=1,k--;
    if(len>=N){
        for(int i=1;i<=N;i++)
            Ans[i]=Min;
        puts(Ans+1);
        exit(0);
    }
    for(int i=1;i<=len;i++)
        tmp[i]=Min;
    for(int i=len+1;i<=N;i++)
        tmp[i]=S[Now--];
    /*
    for(int i=1;i<=N;i++){
        if(tmp[i]!=Ans[i]){
            if(tmp[i]<Ans[i])
                memcpy(Ans,tmp,sizeof tmp);
            return;
        }
    }
    */
    for(int i=1;i<=N;i++)
        if(tmp[i]<Ans[i]){
            for(int j=1;j<=N;j++)
                Ans[j]=tmp[j];
            return;
        }
        else
            if(tmp[i]>Ans[i])
                return;
}

int main(){
    N=read(),K=read();
    scanf("%s",str+1);
    Min='z',Max='a';
    for(int i=1;i<=N;i++){
        Min=min(Min,str[i]);
        Max=max(Max,str[i]);
        str[2*N-i+1]=str[i];
        Ans[i]='z';
    }
    if(Min==Max)
        return puts(str+1),0;
    if(str[N]==Min)
        Solve(str);
    K--;
    for(int i=N+1;i<=2*N;i++)
        if(str[i]==Min)
            Solve(str+i-N);
    puts(Ans+1);
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;

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


Measured memory_bytes: 640
N, D, A = map(int, input().split())
XH = sorted([list(map(int, input().split())) for _ in range(N)])

bombloc = [-1]
bombdam = [ 0]
nbomb = 1
ibomb = 0 # leftmost active bomb
damage = 0
ans = 0
for x, h in XH:
    while ibomb<nbomb and bombloc[ibomb]+D<x:
        damage -= bombdam[ibomb]
        ibomb+=1
        
    h_remain = h-damage
    if h_remain<=0: continue

    n = (h_remain+A-1)//A
    bombloc.append(x+D)
    bombdam.append(n*A)
    nbomb += 1
    damage += n*A
    ans += n
    
print(ans)

Measured memory_bytes: 70136