akhauriyash/Code-Regression huggingface dataset:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,K = map(int,input().split())
H = [int(input()) for _ in range(N)]

H.sort()

ans = 10**10
for i in range(N-K+1):
    ans = min(ans, H[i+K-1]-H[i])

print(ans)

Measured memory_bytes: 7488
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 505 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int n;
int S;
const int T = maxn * maxn;
int r[T]; //距离 
int p[T];
int f[T]; //有没有 
int q[T];
int fr, ed;
int main() {
	cin >> n;
	S = n * n;
	for (int i = 1; i <= S; i++)
		scanf("%d", &p[i]), f[i] = 1;
	int mx = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) {
			int mn = min(i, n + 1 - i);
			mn = min(mn, min(j, n + 1 - j));
			r[(i - 1) * n + j] = mn - 1;
		}
	int ans = 0;
	for (int i = 1; i <= S; i++) {
		int id = p[i];
		ans += r[id];
	//	cout << r[id] << endl;
		fr = ed = 0;
		q[ed++] = id;
		f[id] = 0;
		while (fr < ed) {
			int gm = q[fr++];
			
			int v, nans = r[gm] + f[gm];
		//	if (p[i] == 9) cout << gm << ' ' << r[10] << ' ' << nans << endl;
			if (gm % n != 1) {
				v = gm - 1;
				if (r[v] > nans) {
					r[v] = nans;
					q[ed++] = v;
				}
			}
			if (gm % n != 0) {
				v = gm + 1;
				if (r[v] > nans) {
					r[v] = nans;
					q[ed++] = v;
				}
			}
			if (gm > n) {
				v = gm - n;
				if (r[v] > nans) {
					r[v] = nans;
					q[ed++] = v;
				}
			}
			if (gm + n <= S) {
				v = gm + n;
				if (r[v] > nans) {
					r[v] = nans;
					q[ed++] = v;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7540
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	string x; cin >> x;
	
	int n = x.size();
	int a = 0, b = 0;
	
	rep(i, n){
		a += (x[i]=='S'?-1:1);
		b = max(a, b);
	}
	
	cout << 2 * b << endl;
	
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 N;
	cin >> N;
	vector<PLL> z(N);
	REP(i, N){
		cin >> z[i].fs >> z[i].sc;
		z[i].fs += z[i].sc;
	}
	sort(all(z));
	vector<vector<int64>> dp(N+1, vector<int64>(N+1, INF_LL));
	dp[0][0] = 0;
	int64 res = 0;
	REP(i, N){
		REP(j, N){
			chmin(dp[i+1][j], dp[i][j]);
			if(dp[i][j] <= z[i].fs-z[i].sc){
				chmin(dp[i+1][j+1], dp[i][j]+z[i].sc);
				res = max(res, (int64)j+1);
			}
		}
	}
	cout << res << endl;
}

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

using namespace std;

typedef long long llint;
const long long MOD = 1e9 + 7;

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

  llint ans = 1;
  vector<llint> used(26, 0);
  for (int i = 0; i < n; i++) {
    int d = s[i] - 'a';
    used[d]++;
  }
  for (int i = 0; i < 26; i++) {
    if (used[i] == 0) continue;
    ans *= used[i] + 1;
    ans %= MOD;
  }

  cout << ans - 1 << endl;

  return 0;
}

Measured memory_bytes: 512
S = input()
ans = 0
tmp = S[0]
N = len(S)
if N == 1:
    print(0)
    exit()
for i in range(1, N):
    if i == N-1:
        ans += 1
    if S[i] != tmp:
        tmp = S[i]
        ans += 1
print(ans-1)

Measured memory_bytes: 70112
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ   
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        
        long min=1000000000;
        for(long i=1;i*i<=n;i++){
            if(n%i==0){
                long now=Math.max(String.valueOf(i).length(),String.valueOf(n/i).length());
                min=Math.min(min,now);
            }
        }
        System.out.println(min);
    }
}

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}



signed main(void){
    int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
    priority_queue<int> p,q,r;
    rep(i,a){
        int a;cin>>a;
        p.push(a);
    }
    rep(i,b){
        int b;cin>>b;
        q.push(b);
    }
    rep(i,c){
        int c;cin>>c;
        r.push(c);
    }
    rep(i,x){
        r.push(p.top());
        p.pop();
    }
    rep(i,y){
        r.push(q.top());
        q.pop();
    }
    int ans=0;
    rep(i,x+y){
        ans+=r.top();
        r.pop();
    }

    cout << ans << endl;




    return 0;
}


Measured memory_bytes: 8048
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n = ni()
a = [ni() for _ in range(n)]

cnt = Counter(a)

ans = 0
for ci in cnt.values():
    if ci % 2 == 1:
        ans += 1
        
print(ans)

Measured memory_bytes: 16636
#include <bits/stdc++.h>
using namespace std;
#define LL long int

int main(){
    int n;
    cin >> n;
    int ans = -1,count = 0,before;
    cin >> before;
    for(int i = 0; i < n - 1; ++i){
        int h;
        cin >> h;
        if(h <= before){
            count++;
        }else{
            if(ans < count){
                ans = count;
            }
            count = 0;
        }
        before = h;
    }

    if(ans < count){
        ans = count;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    double df = 1e9;
    double n, t, a;
    int ans;
    cin >> n >> t >> a;
    for(int i=0; i<n; i++){
        double h;
        cin >> h;
        if(df > abs(a - (t - h * 0.006))){
            ans = i+1;
            df = abs(a - (t - h * 0.006));
            }
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------
vector<long long> factor_array(long long n){
    vector<long long> res ;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i) ;
            if(i*i!=n){
                res.push_back(n/i) ;
            }
        }
    }
    sort(res.begin(),res.end()) ;
    return res ;
}
//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll n;
    cin >> n;
    vll a(n);
    REP(i,n){
        cin >> a[i];
    }
    vll k = factor_array(a[0]);
    vll g = factor_array(a[1]);
    REP(i,SZ(g)){
        k.PB(g[i]);
    }

    sort(ALL(k));



    ll ans = -1;
  	ll m = SZ(k);
    REP(i,m){
        //cout << k[i] <<endl;
        ll tmp = 0;
        REP(j,n){
            if(a[j]%k[m-1-i]==0){
                tmp++;
            }
        }
        if(tmp>=n-1){
            cout << k[m-1-i];
          	return 0;
        }
    }




    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}


Measured memory_bytes: 3972
import math
X = []
Y = []

def area(a,b,c):
    p = math.sqrt((X [a] - X [b]) ** 2 + (Y [a] - Y [b]) ** 2)
    q = math.sqrt((X [b] - X [c]) ** 2 + (Y [b] - Y [c]) ** 2)
    r = math.sqrt((X [c] - X [a]) ** 2 + (Y [c] - Y [a]) ** 2)
    z = (p + q + r) / 2
    return math.sqrt(z * (z - p) * (z - q) * (z - r))

while True:
    try:
        a,b = map(float,input().split(','))
        X.append(a)
        Y.append(b)
    except EOFError:
        break

ans = 0.0
for i in range(1,len(X) - 1):
    ans += area(0,i,i + 1)
print(ans)

Measured memory_bytes: 7652
#include <cctype>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cmath>
#define pk putchar(' ')
#define ph puts("")
typedef long long ll;
using namespace std;
template <class T>
void rd(T &x)
{
    x = 0;
    int f = 1;
    char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
    while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    x *= f;
}
template <class T>
void pt(T x)
{
    if (x < 0)
        putchar('-'), x = (~x) + 1;
    if (x > 9)
        pt(x / 10);
    putchar(x % 10 ^ 48);
}
const int N = 55;
int a[N], b[N], c[N], n, m ,q, ans, tmp[N], d[N];
int check()
{
	int res = 0;
	for (int i = 1; i <= q; i++)
		if (tmp[b[i]] - tmp[a[i]] == c[i])
			res += d[i];
	return res;
}
void dfs(int maxx, int x)
{
	if (x > n)
	{
		ans = max(ans, check());
		return;
	}
	for (int i = maxx; i <= m; i++)
	{
		tmp[x] = i;
		dfs(i, x + 1);
	}
}
int main() 
{
	rd(n), rd(m), rd(q);
	for (int i = 1; i <= q; i++)
		rd(a[i]), rd(b[i]), rd(c[i]), rd(d[i]);
	dfs(1, 1);
	pt(ans);
    return 0;
}

Measured memory_bytes: 1492
#include <iostream>
using namespace std;
 
bool overlap(int a, int b, int c, int d){
  if ( d <= a ) return false;
  if ( b <= c ) return false;
  return true;
}
 
int main(void){
  int a, b, s, f, n;
  cin >> a >> b >> n;
  for ( int i = 0; i < n; i++ ){
    cin >> s >> f;
    if ( overlap(a, b, s, f) ){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3104
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn :: IO Int
  xs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print ((recip $ sum $ map (recip . fromIntegral) xs) :: Double)


Measured memory_bytes: 508
#include <stdio.h>

int main(void){
    char alpha;
    int i, flag[3];
    for(i = 0; i < 3; i++)
        flag[i] = 0;
    for(i = 0; i < 3; i++){
        alpha = getchar();
        switch (alpha) {
            case 'a':
                if(flag[0] > 0){
                    printf("No\n");
                    return 0;
                }
                else
                    flag[0]++;
                break;
            case 'b':
                if(flag[1] > 0){
                    printf("No\n");
                    return 0;
                }
                else
                    flag[1]++;
                break;
            case 'c':
                if(flag[2] > 0){
                    printf("No\n");
                    return 0;
                }
                else
                    flag[2]++;
                break;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

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

        String s = sc.next();

        System.out.println(solve(s));

        sc.close();
    }

    static String solve(String s) {
        return s.replace(',', ' ');
    }
}

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

using namespace std;

typedef long long ll;
const double eps=1e-6,pi=acos(-1);
const int N=1e5+5,M=1e9+7,SEGM=4*N,OO=0x3f3f3f3f;
int n,m,a[N],b[N],c[N];
int mem[N];

int solve(int i=0){
    if(i>=n) return 1e9;
    if(i==n-1) return 0;
    int &ret=mem[i];
    if(~ret) return ret;
    ret=1e9;
    for(int j=1;j<=m;++j)
        ret=min(ret,solve(i+j)+abs(a[i]-a[i+j]));
    return ret;
}

int main(){
    //freopen("myfile.txt","w",stdout);
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i)
        scanf("%d",a+i);
    memset(mem,-1,sizeof mem);
    printf("%d",solve());
    return 0;
}


Measured memory_bytes: 10776
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    int n=0;
    cin >> a >> b >> c;
   
   for(;a<=b;a=a+1){
       if(c%a==0){
           n=n+1;
       }
       
       
   }
   
    cout << n <<endl;
}



Measured memory_bytes: 3092
# import itertools
# import math


def solve(X, A):
    return 10 if X >= A else 0


# N = int(input())
# S = input()
X, A = map(int, input().split())
# A = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(X, A))


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

int main(){
  ll X; int K; cin>>X>>K;
  set<pair<ll,ll> > st;
  rep(i,K){
    ll t; cin>>t;
    st.insert(make_pair(t,-1));
  }
  int Q; cin>>Q;
  rep(i,Q){
    ll t,a; cin>>t>>a;
    st.insert(make_pair(t,a));
  }
  bool inc=0;
  ll pre=0, a=0,b=X,c=0;
  for(auto s:st){
    ll t=s.first, x=s.second;
    ll dt=t-pre;
    if(inc){
      c+=dt;
      if(b+c>X) b=X-c;
      if(a>b) a=b;
    }else{
      c-=dt;
      if(a+c<0) a=-c;
      if(a>b) b=a;
    }
    if(x==-1) inc=!inc;
    else cout<<max(a,min(b,x))+c<<endl;
    pre=t;
  }
  return 0;
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
 
 
#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;
 
ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;
 
int main(){
    int a, b;
    cin >> a >> b;
    if(a == b) cout << a * 2 << endl;
    else cout << max(a, b) * 2 - 1 << endl;
    return 0;
}




Measured memory_bytes: 384
# https://atcoder.jp/contests/abc129/tasks/abc129_e
# 問題文
# 正整数 L が二進数表記で与えられます。 
# 以下の条件を満たす非負整数 a,b の組 (a,b) がいくつ存在するか求めてください
# a+b≤L
# a+b=a XOR b
# ただし、この値は非常に大きくなることがあるので、
# 109+7 で割った余りを出力してください。
# XOR とは制約Lは二進数表記で与えられ、
# 先頭文字は必ず 1 である
# 1≤L<2**100001

# 1111111111111111111
# 162261460

MOD = (10**9) + 7

L = gets.chomp
dp = Array.new(2) {[]}
dp[0][0] = 1
dp[1][0] = 0

one = '1'
counter = 0
L.chars do |c|
  if c == one
    dp[0][counter+1] = (dp[0][counter] * 2)%MOD
    dp[1][counter+1] = (dp[0][counter] + (dp[1][counter] * 3)%MOD)%MOD
  else
    dp[0][counter+1] = dp[0][counter]
    dp[1][counter+1] = (dp[1][counter] * 3)%MOD
  end
  counter += 1
end

puts (dp[0].last + dp[1].last)%MOD

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

int main(){
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    int na = sa.size(), nb = sb.size(), nc = sc.size();
    int i = 1, j = 0, k = 0;
    char next = sa[0];
    while(true){
        if(next == 'a')
        {
            if(i == na)
            {
                cout << "A\n";
                return 0;
            }
            next = sa[i++];
        }
        else if(next == 'b')
        {
            if(j == nb)
            {
                cout << "B\n";
                return 0;
            }
            next = sb[j++];
        }
        else
        {
            if(k == nc)
            {
                cout << "C\n";
                return 0;
            }
            next = sc[k++];
        }
    }
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int count_0 = 0;
        int count_1 = 0;
        
        for (int i = 0; i < str.length(); i++) {
            char chr = str.charAt(i);
            
            if (chr == '0') {
                count_0++;
            } else {
                count_1++;
            }
        }
        
        int answer = Math.min(count_0, count_1) * 2;
        System.out.println(answer);
    }
}

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

int main() {
  int a, b, c, d;
  string reply;

  cin >> a >> b >> c >> d;

  a += b;
  c += d;

  if (a > c) {
    reply = "Left";
  } else if (a == c) {
    reply = "Balanced";
  } else {
    reply = "Right";
  }
  cout << reply << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  ll N,T;
  cin>>N>>T;
  vector<ll> t(N);
  for(int i=0;i<N;i++){
    cin>>t[i];
  }
  ll ans=T;
  for(int i=1;i<N;i++){
    ans+=T;
    if(t[i]-t[i-1]<T){
      ans-=(T-(t[i]-t[i-1]));
    }
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
struct mmp{
	int x,z;
}n[25];
int main(){
	int a,b,c,d,i,j,k,l;
	while(~scanf("%d",&a))
	{
		for(i=0;i<a;i++)
		{
			scanf("%d",&n[i].x);
			n[i].z=0;
		}
		b=0;
		for(j=1;j<a-1;j++)
		{
			if(n[j].x>n[j-1].x&&n[j].x<n[j+1].x)
			b+=1;
			else if(n[j].x<n[j-1].x&&n[j].x>n[j+1].x)
			b+=1;
		}
		printf("%d\n",b);
	}
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);

    rep(i, n) cin >> q.at(i);
    rep(i, n) cin >> p.at(i);
    map<vector<int>, int> mp;

    vector<int> a(n);
    rep(i, n) a.at(i) = i+1;


    do {
        mp[a] = mp.size();
    } while (next_permutation(a.begin(), a.end()));

    int res = abs(mp[p] - mp[q]);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, l;
    cin >> n >> l;
    ll L = l + n - 1;
    ll sum = (l + L) * n / 2;
    if(l >= 0) cout << (sum - l);
    else if(L <= 0) cout << (sum - L);
    else cout << sum;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var M = cin.ReadInt;

            var arrayA = new int[N];
            var sumA = 0;

            for (int i = 0; i < N; i++)
            {
                arrayA[i] = cin.ReadInt;
                sumA += arrayA[i];
            }

            var count = 0;
            double checkA = (double)sumA / (4.0 * (double)M);
            var ans = false;

            foreach (var item in arrayA)
            {
                if((double)item >= checkA) 
                {
                    count++;
                }
                if (count >= M) 
                {
                    ans = true;
                    break;
                }
            }

            WriteLine(ans ? "Yes" : "No");
        }

    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }


        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

typedef long long ll;

const int Maxn = 52;

int n, p;
int a[Maxn];

int main()
{
	scanf("%d %d", &n, &p);
	bool wasodd = false, waseven = false;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] % 2) wasodd = true;
		else waseven = true;
	}
	if (wasodd) cout << (1ll << ll(n - 1)) << endl;
	else if (p == 1) cout << 0 << endl;
	else cout << (1ll << ll(n)) << endl;
	return 0;
}

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

const int N = 2 * 100 * 1000 + 20;
int n, k, a[N], ans;

int main() {
	cin >> k >> n;
  	for (int i = 0; i < n; i++)
		cin >> a[i];
  	for (int i = 1; i < n; i++)
    	ans = max(ans, a[i] - a[i - 1]);
  	ans = max(ans, a[0] + k - a[n - 1]);
  	return cout << k - ans << "\n", 0;
}


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

int main(){
  string s;
  cin >> s;
  int n = s.size(),m = 1;
  int nn = (n-1)/2;
  vector<char> t(n),ss(nn),tt(nn);
  
  for(int i=0;i<n;i++){
    t.at(i) = s.at(n-1-i);
  }
  for(int i=0;i<nn;i++){
    ss.at(i) = s.at(i);
    tt.at(i) = s.at(n-1-i);
  }
  
  for(int i=0;i<n;i++){
    if(s.at(i) != t.at(i)){
      m = -1;
      break;
    }
  }
  for(int i=0;i<nn;i++){
    if(ss.at(i) != ss.at(nn-1-i)){
      m = -1;
      break;
    }
  }
  for(int i=0;i<nn;i++){
    if(tt.at(i) != tt.at(nn-1-i)){
      m = -1;
      break;
    }
  }
  
  if(m >0) cout << "Yes" << endl;
  else cout <<  "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void){

  char c;
  cin>>c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') cout<<"vowel"<<endl;
  else cout<<"consonant"<<endl;

  return 0;
}

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

void swap(int *x,int *y){
  int temp;
  temp=*x;
  *x=*y;
  *y=temp;
}

int main(void){
  int A[100];
  int i,j,N,C,mini;
  int p,q;
  C=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<N;i++){
    mini=i;
    for(j=i;j<N;j++){
      if(A[j]<A[mini]){
        mini=j;
      }
    }
    p=A[i];
    q=A[mini];
    if (p>q)C++;
    swap(&p,&q);
    A[i]=p;
    A[mini]=q;
  }
  for(i=0;i<N;i++){
    if(i!=0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",C);
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
//#define MAX 2001

void rec(int p,int q);
int s[2000],t[2000],n;

int main(){
	
	int i,m,a;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	rec(0,0);
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d",&a);
		if(t[a]) printf("yes\n");
		else printf("no\n");
	}
	
	return 0;
}

void rec(int sum,int q){
	
	if(q==n){
		t[sum]=1;
		return;
	}
	rec(sum,q+1);
	if(sum+s[q]<=2000) rec(sum+s[q],q+1);
		
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  string S;
  cin >> S;
  if (S.back() == 's')
    S += "es";
  else
    S += "s";
  cout << S << '\n';
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

char getResult(char x,string sa, string sb, string sc){
    if(x=='a' && sa.empty()) return 'A';
    if(x=='b' && sb.empty()) return 'B';
    if(x=='c' && sc.empty()) return 'C';
    if(x=='a') {
        x = sa.back();
        sa.pop_back();
        return getResult(x, sa, sb, sc);
    }
    if(x=='b') {
        x = sb.back();
        sb.pop_back();
        return getResult(x, sa, sb, sc);
    }
    if(x=='c') {
        x = sc.back();
        sc.pop_back();
        return getResult(x, sa, sb, sc);
    }
    return 0;
}
int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    reverse(sa.begin(), sa.end());
    reverse(sb.begin(), sb.end());
    reverse(sc.begin(), sc.end());
    cout << getResult('a',sa,sb,sc) << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  
  int n;
  cin>>n;
  char s[n],t[n];
  cin>>s;
  cin>>t;
  char res[2*n];
  int l=0;
  for(int i=0;i<n;i++)
  {
    res[l++]=s[i];
    res[l++]=t[i];
  }
  for(int i=0;i<2*n;i++)
  {
  cout<<res[i];}
  return 0;
}

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

using namespace std;
typedef long long ll;

ll H,W;
string s[1000];
ll m[1000][1000];
ll MOD = 1e9+7;

int main(){
    cin >> H >> W;
    for(int i=0;i<H;i++) cin >> s[i];
    m[0][0] = 1;
    for(int i=1;i<H;i++){
        if(s[i][0] == '.') m[i][0] = m[i-1][0];
        else m[i][0] = 0;
    }
    for(int i=1;i<W;i++){
        if(s[0][i] == '.') m[0][i] = m[0][i-1];
        else m[0][i] = 0;
    }
    for(int i=1;i<H;i++){
        for(int j=1;j<W;j++){
            if(s[i][j] == '#'){
                m[i][j] = 0;
                continue;
            }
            m[i][j] = m[i-1][j] + m[i][j-1];
            m[i][j] %= MOD;
        }
    }
    cout << m[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    int mini = 10000, maxi = -1;
    REP(i,0,n) {
        if (a[i] < mini) mini = a[i];
        if (a[i] > maxi) maxi = a[i];
    }
    cout << maxi - mini << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        while(true){
            int n = sc.nextInt();
            if(n == 0) break;

            Team[] t = new Team[n];
            //ArrayList<Team> al = new ArrayList<Team>();

            for(int i = 0; i < n; i++){
                int id = sc.nextInt();
                int[] m = new int[4];
                int[] s = new int[4];

                for(int j = 0; j < 4; j++){
                    m[j] = sc.nextInt();
                    s[j] = sc.nextInt();
                }

                t[i] = new Team(id, m, s);
            }

            Arrays.sort(t);

            System.out.println(t[0].id);
            System.out.println(t[1].id);
            System.out.println(t[n - 2].id);
        }
    }
}

class Team implements Comparable<Team>{
    int id, score;

    Team(int id, int[] m, int[] s){
        this.id = id;
        this.score = 0;

        for(int i = 0; i < 4; i++){
            this.score += m[i] * 60 + s[i];
        }
    }

    public int compareTo(Team t){
        return this.score - t.score;
    }
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
	string a,b,d;
	cin>>a>>b;
	int c=a.sz;
	d=a;
	int e=0;
	fo(i,c){
		fo(j,c){
			d[j]=a[(j+i)%c];
		}
		if(d==b){
			e=1;
			break;
		}
	}
	if(e)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{	
	public static void main(String[] args)
	{
		Stack<String> stack = new Stack<String>();
		ArrayList<String> list = new ArrayList<String>();
		ArrayList<String> operators = new ArrayList<String>();
		operators.add("*"); 
		operators.add("/"); 
		operators.add("-"); 
		operators.add("+");
		//////////////////////////////////////// apparently there's a Scanner bug and having 2 scanners fixes it
		Scanner in = new Scanner(System.in);
		String bug = in.nextLine();
		Scanner real = new Scanner(bug);
		////////////////////////////////////////
		while(real.hasNext())
		{
			list.add(real.next());
		}
		in.close();
		real.close();
		////////////////////////////////////////
		for(int i =0;i<list.size();i++)
		{
			if(!operators.contains(list.get(i)))
			{
				stack.push(list.get(i));
			}
			else
			{
				//sets the values for the numbers that are to be computed
				int n2 = Integer.valueOf(stack.pop());
				int n1 = Integer.valueOf(stack.pop());
				//checks what the next operator is
				if(list.get(i).equals(operators.get(0)))
				{
					stack.push(String.valueOf(n1*n2));
				}
				else if(list.get(i).equals(operators.get(1)))
				{
					stack.push(String.valueOf(n1/n2));
				}
				else if(list.get(i).equals(operators.get(2)))
				{
					stack.push(String.valueOf(n1-n2));
				}
				else
				{
					stack.push(String.valueOf(n1+n2));
				}
			}
		}
		System.out.println(stack.pop());
	}
}


Measured memory_bytes: 26192
#include<iostream>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int get() { int r; cin >> r; return r; }
signed main() {
	double x1, x2, y1, y2, x3, y3, a, b, c, d;
	cin >> x1 >> y1 >> x2 >> y2;
	a = x1 - x2; b = y1 - y2;
	c = b; d = a;
	if (d < 0)d *= -1;
	else c *= -1;
	int q = get();
	for1(i, q) {
		cin >> x3 >> y3;
		double k1 = -100000, k2 = 100000;
		while (k2 - k1 >= 0.0000000000001) {
			double mid = (k1 + k2) / 2;
			if ((a * (y3 + k1 * d - y1) - b * (x3 + k1 * c - x1)) * ((a * (y3 + mid * d - y1) - b * (x3 + mid * c - x1))) > 0) {
				k1 = mid;
			}
			else k2 = mid;
		}
		double k = (k1 + k2) / 2;
		printf("%.20f %.20f\n", x3 + k * c, y3 + k * d);
	}
}


Measured memory_bytes: 3296
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int calc(int x) {
    if(x <= 0) return 0;
    return (x - 1) / 2 + 1;
}
int main() {
    int A, B, C, X, Y;
    scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);
    X *= 2, Y *= 2;
    int ans = 2e9;
    for(int i = 0; i <= X || i <= Y; i++) {
        ans = min(ans, i * C + A * calc(X - i) + B * calc(Y - i));
    }
                  printf("%d\n", ans);
                  return 0;
}

Measured memory_bytes: 128
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
from collections import defaultdict
from collections import Counter
H,W,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

dic = defaultdict(int)
for a,b in AB:
    for dh in range(3):
        for dw in range(3):
            if 0 < a-dh <= H-2 and 0 < b-dw <= W-2:
                dic[(a-dh,b-dw)] += 1

Ans = Counter(dic.values())
Ans[0] = (H-2)*(W-2) - sum(Ans.values())

for i in range(10):
    print(Ans[i])

Measured memory_bytes: 191208
#include<stdio.h>
int main() {
    int i, n, a, ans = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &a);
        while (a % 2 == 0) {
            ans++;
            a = a / 2;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define abs(a) (((a) < 0) ? -(a) : (a))

#define FOR(var, to)          for (register int var = 0; var < to; var++)
#define FROMTO(var, from, to) for (register int var = from; var <= to; var++)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

static inline s64 rs64() {
	s64 a;
	scanf("%" SCNd64, &a);
	return a;
}

static inline void wi(int a) {
	printf("%d", a);
}

static inline void wu64(u64 a) {
	printf("%" PRIu64, a);
}

int int_comp(const void* a,const void* b) {
	return (*((int*)b) - *((int*)a));
}

int main() {
	int n = ri();
	int h = ri();
	int a[n];
	int b[n];
	FOR(i,n) {
		a[i] = ri();
		b[i] = ri();
	}
	
	int a_max = -1;
	FOR(i,n) {
		a_max = max(a_max, a[i]);
	}
	
	int res = 0;
	int high[n];
	int highs = 0;
	FOR(i,n) high[i] = -1;
	
	FOR(i,n) {
		if (b[i] > a_max) high[highs] = b[i], highs++;
	}
	
	qsort(high, highs, sizeof(int), int_comp);
	FOR(i,highs) {
		res++;
		h -= high[i];
		if (h <= 0) break;
	}
	
	if (h > 0) res += ((h-1)/a_max + 1);
	
	printf("%d", res);
	
	return 0;
}


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

int main(void){
    int n, k;
    cin >> n >> k;

    cout << n - k + 1 << endl;
}

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

using namespace std;

int main()
{
unsigned long long int n;
cin>>n;
--n;
string s="";
while(n >= 26) {
    s+=char((n%26) + 'a');
    n/=26;
   --n;
}
s+=char(n+'a');
reverse(s.begin(),s.end());
cout<<s;
return 0;
}


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

typedef long long ll;
using namespace std;

int fis[100001];

int main(void) {
  int n, k;
  cin >> n >> k;
  long double div = 0;
  int maxfi = 0;
  for (int i = 1; i <= n; i++) {
    int fi = 0;
    int t = i;
    while(t < k) {
      t <<= 1; fi++;
    }
    div += (1.0 / (1 << fi));
  }

  cout << setprecision(20) << div / n << endl; 

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int[] a = new int[n+2];
        for(int i=0;i<n;++i)a[i+1]=scan.nextInt();
        a[0]=0;
        a[n+1]=0;

        int sum = 0;
        for(int i=1;i<n+2;++i)sum += Math.abs(a[i] - a[i-1]);
        for(int i=1;i<n+1;++i){
            //iをやめたとき
            if((a[i]-a[i-1])*(a[i+1]-a[i])>=0){
                System.out.println(sum);
            }else{
                if(Math.abs(a[i]-a[i-1])<Math.abs(a[i]-a[i+1]))System.out.println(sum - Math.abs(a[i-1]-a[i])*2);
                else System.out.println(sum - Math.abs(a[i+1]-a[i])*2);
            }
        }




    }
}

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


int main() {
	string s;
	int n;
	cin >> s;
	cin >> n;
	int cnt = 0;
	for(int i = 0; i < s.size(); ++i) {
		if(cnt % n == 0) cout << s[i], cnt = 0;
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      int a = Integer.parseInt(sc.next());
      String s = sc.next();
      if (a >= 3200) {
        System.out.println(s);
      } else {
        System.out.println("red");
      }
    }
}

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

int func(int n){
  int ans = 0;
  for(int x = 1; x <= sqrt(n); x++){
    for(int y = 1; y <= sqrt(n); y++){
      for(int z = 1; z <= sqrt(n); z++){
        ll tmp = x*x + y*y + z*z + x*y + y*z + z*x;
        if(tmp>n) break;
        if(tmp==n) ans++;
      }
    }   
  }

  return ans;
}

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

  rep(i,n) cout << func(i+1) << endl;

  return 0;
}

Measured memory_bytes: 3648
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    A = []
    C = []
    for i in range(M):
        a, _ = LI()
        bit = 0
        A.append(a)
        c = LI()
        for ix in c:
            bit = bit | 1 << (ix-1)
        C.append(bit)
    dp = [[inf for _ in range(1 << N)] for __ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for j in range(1 << N):
            # use i-th key
            dp[i+1][j | C[i]] = min(dp[i+1][j | C[i]], dp[i][j] + A[i])
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    ans = dp[M][(1 << N) - 1]
    if ans == inf:
        print(-1)
        return
    print(ans)
    return

main()



Measured memory_bytes: 118452
N, M, X, Y = map(int, input().split())
X_list = list(map(int, input().split()))
X_list.append(X)
Y_list = list(map(int, input().split()))
Y_list.append(Y)
if max(X_list) < min(Y_list):
    print('No War')
    exit(0)
print('War')

Measured memory_bytes: 3060