akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<ll> a, b;
    ll ans;

    rep(i, N)
    {
        ll t_a, t_b;
        cin >> t_a >> t_b;
        a.push_back(t_a);
        b.push_back(t_b);
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater<ll>());

    if (N % 2 == 1)
    {
        int tmp = N / 2;
        ans = b[tmp] - a[tmp] + 1;
    }
    else
    {
        int tmp = (N - 1) / 2;
        double tmp_b = (b[tmp] + b[tmp + 1]) / 2.0;
        double tmp_a = (a[tmp] + a[tmp + 1]) / 2.0;
        // ll tmp_min = ll((b[tmp] + a[tmp + 1]) / 2);
        ans = ll((tmp_b - tmp_a) * 2 + 0.1) + 1;
        // ans = (b[tmp] - a[tmp + 1]) - (b[tmp + 1] - a[tmp]);
        // cout << tmp_a << " " << tmp_b << endl;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{

    int n;
    cin >> n;

    int ans = 0;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;

        while(a % 2 == 0)
            a /= 2, ans++;
    }

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


Measured memory_bytes: 3640
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

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

  ll n, m;
  cin >> n >> m;
  vvll eds(n);
  vll par(n, -1);
  vll ideg(n, 0);
  rep(i, n + m - 1) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    eds[a].push_back(b);
    ideg[b]++;
  }
  ll rt = -1;
  rep(i, n) {
    if (ideg[i] == 0) {
      rt = i;
      break;
    }
  }
  assert(rt != -1);

  queue<ll> que;
  que.push(rt);
  while(!que.empty()){
    ll u = que.front();
    que.pop();
    for(ll v : eds[u]){
      if(ideg[v] == 1){
        par[v] = u;
        que.push(v);
      } 
      ideg[v]--;
    }
  }

  rep(i, n) cout << par[i] + 1 << endl;

  return 0;
}


Measured memory_bytes: 7808
#include <stdio.h>

int main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
        if(r <= x && (x+r) <= W && r <= y && (y+r) <= H) printf("Yes\n");
        
        else printf("No\n");
    
    return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int h = ri(), w = ri();
	int k = ri();
	std::vector<std::vector<bool> > a(h, std::vector<bool> (w));
	for (int i = 0; i < h; i++) {
		std::string s;
		std::cin >> s;
		for (int j = 0; j < w; j++) a[i][j] = s[j] == '#';
	}
	int res[h][w];
	int last = 0;
	int cnt = 1;
	for (int i = 0; i < h; i++) {
		std::vector<int> on;
		for (int j = 0; j < w; j++) if (a[i][j]) on.push_back(j);
		
		if (on.size()) {
			for (int j = 0; j < (int) on.size(); j++) {
				int start = j ? on[j - 1] + 1 : 0;
				int end = j + 1 == (int) on.size() ? w - 1 : on[j];
				for (int k = last; k <= i; k++) for (int l = start; l <= end; l++) res[k][l] = cnt;
				cnt++;
			}
			last = i + 1;
		}
	}
	if (last != h) {
		last--;
		for (int i = last + 1; i < h; i++) for (int j = 0; j < w; j++) res[i][j] = res[last][j];
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			std::cout << res[i][j] << " ";
		}
		std::cout << std::endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 1152
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N, W;
    cin >> N >> W;
    vector<int64_t> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];
    int64_t dp[N + 10][W + 10];
    rep(i, N + 10)
    {
        rep(j, W + 10)
        {
            dp[i][j] = 0;
        }
    }
    //深さをループで順に見ていく
    for (int i = 0; i < N; i++)
    {
        for (int sum_w = 0; sum_w <= W; sum_w++)
        {
            // i番目の品物を選ぶ場合
            if (sum_w - w[i] >= 0)
            {
                dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
            }
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 86144
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main() {
  ll N,i,ans=0,S=0,MOD=1e9+7;
  cin>>N;
  vector<ll> A(N);
  for (i=0;i<N;i++) {
    cin>>A[i];
    S+=A[i];
  }
  for (i=0;i<N;i++) {
    S-=A[i];
    ans += A[i]*(S%MOD)%MOD;
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}


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

long long T, N, ans, a[10000007];
vector<bool> v;

void outputprime(int n){ // vector is used
	v.push_back(false);
	v.push_back(false);
	for(int i = 2; i <= n; i++){
		v.push_back(true);
	}
	for(int i = 2; i*i <= n; i++){
		if (v[i] == false){
			continue;
		} else{
			for (int j = 2*i; j <= n; j+=i){
				v[j] = false;
			}
		}
	}
}

int main() {
	scanf("%d", &N);
	outputprime(N);
	a[1] = 1;
	for (int i = 2; i <= N; i++) {
		int temp = i;
		if (v[i]) {
			a[i] = 2;
			continue;
		}
		int cou = 0;
		for (int j = 2; ; j++) {
			if (v[j]) {
				while (temp % j == 0) {
					cou++;
					temp /= j;
				}
				if (cou > 0) {
					a[i] = (cou + 1) * a[temp];
					break;
				}
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		ans += i * a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 82728
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iostream>
typedef long long ll;
using namespace std;
const int maxn=101000;
int dis[maxn][35];
int n,l,q;
int num[maxn];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&num[i]);
    scanf("%d%d",&l,&q);
    for(int i=1;i<=n;i++){
        int idx=(int)(upper_bound(num+1,num+n+1,num[i]+l)-num);
        idx--;
        dis[i][0]=idx;
    }
    for(int j=1;j<=30;j++){
        for(int i=1;i<=n;i++){
            dis[i][j]=dis[dis[i][j-1]][j-1];
        }
    }
    while(q--){
        int a,b;
        scanf("%d%d",&a,&b);
        if(a==b){
            printf("0\n");
            continue;
        }
        if(a>b) swap(a,b);
        int ans=0,cur=a;
        for(int i=30;i>=0;i--){
            if(dis[cur][i]<b){
                ans+=(1<<i);
                cur=dis[cur][i];
            }
        }
        printf("%d\n",ans+1);
    }
    return 0;
}

Measured memory_bytes: 14848
#!/usr/bin/env python3
import sys

class UnionFind(object):
    def __init__(self, n=1):
        self.par  = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] =  self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self,x,y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

    

def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    uf = UnionFind(N)

    ans = [None] * M
    ans[M-1] = N * (N-1) // 2
    for i in range(M-1,0,-1):
        x,y = A[i] -1 , B[i] - 1
        if uf.is_same(x,y):
            ans[i-1] = ans[i]
        else:
            ans[i-1] = ans[i] - (uf.get_size(x) * uf.get_size(y))
        uf.union(x,y)
    for a in ans:
        print(a)



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]" 
    B = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19960
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,k) = get!(usize, usize);
    let h = get!([usize]);

    let mut count = 0usize;
    for e in h {
        if k<=e {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 8572
#include<stdio.h>

int main(void){

  int A,B,C,D,T_attack_num,A_attack_num;

  scanf("%d %d %d %d",&A,&B,&C,&D);
  if(C % B == 0) T_attack_num = C/B;
  else T_attack_num = (C/B)+1;

  if(A % D == 0) A_attack_num = A/D;
  else A_attack_num = (A/D)+1;

  if(T_attack_num <= A_attack_num) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 1648
program alphabet

 character::yomu*1

 read*,yomu

 if(yomu>='a' .and. yomu<='z') then
  print*,'a'
 end if

 if(yomu>='A' .and. yomu<='Z') then
  print*,'A'
 end if

 
end program alphabet

Measured memory_bytes: 2796
#include <stdio.h>
int main(){
  int A[100], N, i, j, swap, count = 0;
  scanf("%d", &N); 
  for(i = 0; i < N; i++){
    scanf("%d", &A[i]);
  }
  for(i = 0; i < N; i++){
    for(j = (N - 1); j > i; j--){
      if(A[j] < A[j - 1]){
	swap = A[j - 1];
	A[j - 1] = A[j];
	A[j] = swap;
	count++;
      } 
    }
  }
  for(i = 0; i < N; i++){
    printf("%d", A[i]);
    if(i < (N - 1))printf(" ");
  }
  printf("\n%d\n", count);

  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

ll fac[MAX], finv[MAX], inv[MAX];
void init_comb(){
  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;
  }
}

ll comb(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;
}

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

  int n, k;
  cin >> n >> k;

  init_comb();
  ll ans[n + 1];
  for(int i = 1; i <= k; i++){
    ans[i] = (((fac[k - 1] * finv[k - i]) % MOD) * finv[i - 1]) % MOD;
    int tmp = n - k - i + 1;
    if(tmp < 0) ans[i] = 0;
    else ans[i] = (ans[i] * ((((fac[tmp + i] * finv[tmp]) % MOD) * finv[i]) % MOD)) % MOD;
  }

  string buf;
  for(int i = 0; i < k; i++){
    buf += to_string(ans[i + 1]) + "\n";
  }

  cout << buf;

  return 0;
}


Measured memory_bytes: 2816
import sys
for e in sys.stdin:
 e=sorted(map(int,e.split(',')))
 print([['null','straight'][e[0]*10==e[1]or e[4]-e[0]==4],'one pair','two pair','three card','full house',0,'four card'][sum(e.count(s)for s in e)//2-2])


Measured memory_bytes: 5608
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll HMOD = (ll)1e9 + 7;
const ll LMOD = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
const long double EPS = 1e-10;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	int N; cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int A, B; cin >> A >> B;
		cout << A + B << endl;
	}
	return 0;
}



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

int main() {
  int n;
  int move_count = 0;
  int ans = 0;
  cin >> n;
  vector<int> height(n);
  rep (i, n) {
    cin >> height[i];
  }
  rep (i, n - 1) {
    if (height[i] >= height[i + 1]) {
      move_count++;
    }else{
      ans = max(ans, move_count);
      move_count = 0;
    }
  }
  ans = max(ans, move_count);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
using Int = long long;
#define rep(i, n) for (Int i = 0; i < Int(n); ++i)
#define rep1(i, n) for (Int i = 1; i <= Int(n); ++i)
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Int n;
    cin >> n;
    vector<pair<Int, Int>> x(n);
    rep(i, n) {
        Int v;
        cin >> v;
        x[i] = {v, i};
    }
    sort(begin(x), end(x));
    vector<Int> ord(n);
    rep(i, n) ord[x[i].second] = i;
    rep(i, n) cout << (ord[i] < n / 2 ? x[n / 2].first : x[n / 2 - 1].first)
                   << endl;
}


Measured memory_bytes: 6912
using System;

namespace atcoder {
    class Program {
        static void Main (string[] args)
        {
            ABC139.Tenki();
        }
    }

    class ABC139
    {
        public static void Tenki()
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            int cnt = 0;

            for(int i=0; i<3; i++)
            {
                if(s[i]==t[i])
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }   
    }
}

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

int main() {
  int D,N;
  cin >> D >> N;
  if(N < 100){
    if(D == 0) cout << N << endl;
    else if(D == 1) cout << N * 100 << endl;
    else cout << N * 10000 << endl;
  }else{
    if(D==0) cout << 101 << endl;
    else if(D == 1) cout << 10100 << endl;
    else cout << 1010000 << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
N = int(input())
used = [input()]
flag = 1
for i in range(N-1):
  now = input()
  if now not in used and used[-1][-1] == now[0]:
    used.append(now)
  else:
      flag = 0

if flag == 1:
  print("Yes")
else:
  print("No")


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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int L = S.length();
    cout << S[0] <<  L - 2 <<  S[L - 1] << endl;

    return 0;
}


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

using namespace std;

int main()
{
    char s[1024], s2[1024];
    
    scanf("%s", s);
    
    strcpy(s2, s);
    int len = strlen(s);
    for (int i = 0; i <= len - 8; i++){
        int ct[128] = {0};
        for (int j = i; j < i + 8; j++) ct[s[j]]++;
        if (ct['A'] == 2 && ct['I'] == 1 && ct['D'] == 1 && ct['U'] == 1 &&
            ct['N'] == 2 && ct['Y'] == 1){
            char tmp = s[i + 8];
            strcpy(s2 + i, "AIZUNYAN");
            s2[i + 8] = tmp;
        }
    }
    
    printf("%s\n", s2);
    
    return (0);
}

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

long long gcd(long long x, long long y)
{
    if (y == 0)
        return x;
    else
        return gcd(y, x % y);
}

int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    long long ans = b - b / c - b / d + b / (c * d / gcd(c, d));
    ans -= a - a / c - a / d + a / (c * d / gcd(c, d));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int A, B, M;
    scanf("%d %d %d", &A, &B, &M);
    vector<int> a, b;
    for (int i = 0; i < A; i++) {
        int tmp;
        scanf("%d", &tmp);
        a.push_back(tmp);
    }
    for (int i = 0; i < B; i++) {
        int tmp;
        scanf("%d", &tmp);
        b.push_back(tmp);
    }
    int ans = (int)1e9;
    for (int i = 0; i < M; i++) {
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);
        x--, y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ans = min(ans, a[0] + b[0]);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1400
from itertools import permutations
#from bisect import *                                                                 
n = int(input())
N = [i for i in range(1,n+1)]
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]

l = [list(i) for i in permutations(N)]
#print(l)                                                                             
P_idx = l.index(P)
Q_idx = l.index(Q)

print(abs(P_idx-Q_idx))




Measured memory_bytes: 46812
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1e9+7;
#define addm(x,y) (x+y>=MOD? (x+y-MOD):(x+y))
lli add(lli x,lli y)
{
	if(x+y>=MOD)
		return x+y-MOD;
	return x+y;
}
lli mult(lli x,lli y)
{
	return ( (x%MOD)*(y%MOD))%MOD;
}
int main()
{
		#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS
	
	// int t;
	// cin>>t;
	// for(int i=1;i<=t;i++)
	// {
	// 	cout<<"Case #"<<i<<": ";
	// 	solve();

	// }
	
	lli n;
	cin>>n;
	vector<lli>a(n);
	fr(i,n)
	cin>>a[i];
	lli pre[n]={0};
	pre[0]=a[0];
	for(lli i=1;i<n;i++)
		pre[i]=add(pre[i-1],a[i]);
	lli ans=0;
	fr(i,n-1)
	{
		lli p=(pre[n-1]-pre[i]+MOD)%MOD;
		ans=add(ans,mult(p,a[i]));

	}
cout<<ans<<endl;
	
	
	
}


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

#define ll long long

using namespace std;

const ll inf = 1e18 + 7;
const ll K = 2e9 + 7;
const ll N = 1e5 + 7;

ll sqr(ll n)
{
    ll l = 1, r = min(n, K);

    while (r - l > 1)
    {
        ll mid = (l + r) >> 1;

        if (mid * mid > n)
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }
    if (r * r <= n)
        l = r;

    return l;
}
ll easy(ll l, ll r)
{
    ll last = inf, cnt = 0, k;

        for (ll i = 1; i <= l * r; i++)
        {
            if (i == l)continue;
            ll j = (l * r) / i;
            k = j;
            if (j * i == l * r)
                j--;
            j = min(last - 1, j);
            if (j == r)
                j--;
            if (j > 0)
                cnt++;
            if (j <= 1)
            {
                break;
            }
            last = j;
        }
    return cnt;
}
main()
{
    int m;
    cin >> m;

    while (m--)
    {
        ll l, r, last = inf, ans = 0, mul, sq;

        scanf("%lld%lld", &l, &r);

        mul = (l * r);

//        if (mul < N)
//        {
//            cout << easy(l, r) << endl;
//            continue;
//        }

        sq = sqr(mul);

        ans = (min(l,r) - 1) * 2;

        if (l > r)
            swap(l,r);

        if (sq > l && sq < r) {
            if (sq * (sq + 1) < mul) {
                ans += (sq - min(l,r)) * 2;
                if(sq * 2 - l + 1 < r)
                    ans ++;
            }
            else if (sq * sq < mul) {
                ans += (sq - min(l,r) - 1) * 2 + 1;
                if(sq * 2 - l < r)
                    ans ++;
            }
            else if (sq * (sq - 1) < mul) {
                ans += (sq - min(l,r) - 1) * 2;
                if((sq - 1) * 2 - l + 1 < r)
                    ans ++;
            }
        }
        else if (sq == l && sq * (sq + 1) < mul){
            ans ++;
        }

        cout << ans << endl;
    }
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ABC061
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            var n = uint.Parse(s[0]);
            var k = ulong.Parse(s[1]);

            var arr = new SortedDictionary<uint, ulong>();

            for (var i = 0; i < n; i++)
            {
                s = Console.ReadLine().Split(' ');
                var a = uint.Parse(s[0]);
                var b = uint.Parse(s[1]);

                ulong v;
                arr.TryGetValue(a, out v);
                v += b;
                arr[a] = v;
            }

            ulong j = 0;
            foreach (var kvp in arr)
            {
                j += kvp.Value;
                if (j >= k)
                {
                    Console.WriteLine(kvp.Key);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 22968
n,k,q =map(int,input().split())
a_li = [int(input()) for _ in range(q)]
from collections import Counter
c = Counter(a_li)
for x in range(n):
    if q-k<0:
        print('Yes')
    else:
        if c[x+1]>q-k:
            print('Yes')
        else:
            print('No')

Measured memory_bytes: 11940
class Node:
  def __init__(self, num):
    self.key = num
    self.p = None
    self.left = None
    self.right = None

class BinarySearchTree:
  def __init__(self):
    self.root = None

  def insert(self, z):
    y = None
    x = self.root
    while x != None:
      y = x
      if z.key < x.key:
        x = x.left
      else:
        x = x.right
    z.p = y

    if y is None:
      self.root = z
    elif z.key < y.key:
      y.left = z
    else:
      y.right = z

  def find(self, key):
    node = self.root
    while node:
      if node.key == key: return node
      if key < node.key:
        node = node.left
      else:
        node = node.right
    return None

  def find_minimum(self, node):
    while node.left: node = node.left
    return node

  def delete(self, node):
    if node.left and node.right:
      m = self.find_minimum(node.right)
      node.key = m.key
      self.delete(m)
    elif node.left:
      self.update(node, node.left)
    elif node.right:
      self.update(node, node.right)
    else:
      self.update(node, None)

  def update(self, node, new_node):
    if node.key < node.p.key:
      node.p.left = new_node
    else:
      node.p.right = new_node
    if new_node:
      new_node.p = node.p

def print_inorder(node):
  if node is None: return
  print_inorder(node.left)
  print(" {}".format(node.key), end="")
  print_inorder(node.right)

def print_preorder(node):
  if node is None: return
  print(" {}".format(node.key), end="")
  print_preorder(node.left)
  print_preorder(node.right)

T = BinarySearchTree()
for i in range(int(input())):
  params = input().split()
  if params[0] == "insert":
    T.insert(Node(int(params[1])))
  elif params[0] == "find":
    if T.find(int(params[1])):
      print("yes")
    else:
      print("no")
  elif params[0] == "delete":
    node = T.find(int(params[1]))
    if node: T.delete(node)
  elif params[0] == "print":
    print_inorder(T.root)
    print("")
    print_preorder(T.root)
    print("")

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;
vector<P> edge[100001];
vector<bool> isUsed(100001, false);
vector<int> ans(100001);

/* 頂点vから塗っていく */
int dfs(int v) {
    isUsed[v] = true;
    REP(i, edge[v].size()) {
        if(!isUsed[edge[v][i].first]) {
            if(edge[v][i].second % 2 == 1) {
                /* ちがういろ */
                if(ans[v] == 1) ans[edge[v][i].first] = 0;
                else ans[edge[v][i].first] = 1;
                dfs(edge[v][i].first);
            } else {
                /* おなじいろ */
                if(ans[v] == 1) ans[edge[v][i].first] = 1;
                else ans[edge[v][i].first] = 0;
                dfs(edge[v][i].first);
            }
        }
    }

    return 0;
}

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

    REP(i, n-1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        edge[u].push_back(make_pair(v, w));
        edge[v].push_back(make_pair(u, w));
    }

    ans[0] = 1;
    dfs(0);

    REP(i, n) {
        cout << ans[i] << endl;
    }

    return 0;
}


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

Bxxx = 0
xxxA = 0
BxxA = 0
xABx = 0
for i in range(N):
    s = input()
    xABx += s.count("AB")
    if (s[0] == "B") and (s[-1] == "A"):
        BxxA += 1
    else:
        if s[0] == "B":
            Bxxx += 1
        if s[-1] == "A":
            xxxA += 1
#print("Bxxx={},xxxA={},BxxA={},xABx={}".format(Bxxx,xxxA,BxxA,xABx))

if BxxA == 0:
    print(xABx + min(Bxxx, xxxA))
elif Bxxx == xxxA == 0:
    print(xABx + BxxA - 1)
else:
    #set3 = min(BxxA, Bxxx, xxxA)
    #print(xABx + set3 * 2 + BxxA - set3 + min(Bxxx, xxxA) - set3)
    print(xABx + BxxA + min(Bxxx, xxxA))


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

int main() {
    int cnt = 0, ans = 0;
    string s;
    cin >> s;
    rep(i, s.size()) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
            ans = max(ans, cnt);
        } else {
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;

namespace AtCoder
{
    class Program
    {

        struct Point
        {
            public int left;
            public int right;

            public Point(int left, int right)
            {

                this.left = left;
                this.right = right;

            }

        }


        const int BiggestMod = 1000000007;

        public static void Main()
        {

            long ans = 0;
            var num = int.Parse(Console.ReadLine());

            if (num < 3)
            {

                Console.WriteLine(0);
                return;

            }

            var buf = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            Array.Sort(buf);
            Array.Reverse(buf);

            for (int i = 0; i + 2 < num; i++)
                for (int j = i + 1; j + 1 < num; j++)
                    if (buf[i] != buf[j])
                        for (int k = j + 1; k < num; k++)
                            if (buf[j] != buf[k])
                                if (buf[i] < buf[j] + buf[k])
                                    ans++;

            Console.WriteLine(ans);

        }

    }

}

Measured memory_bytes: 28164
#include <iostream>

long long solve(long long a, long long b, long long x) {
  if (a % x == 0) {
    return (b / x) - (a / x) + 1;
  } else {
    return (b / x) - (a / x);
  }
}

int main() {
  long long a, b, x;
  std::cin >> a >> b >> x;
  std::cout << solve(a, b, x) << std::endl;
  return 0;
}


Measured memory_bytes: 256
m,n = map(int, raw_input().split())
a = []
b = []
for i in range(m):
    a.append(map(int, raw_input().split()))
for i in range(n):
    b.append(input())
for i in range(m):
    ans = 0
    for j in range(n):
        ans += a[i][j] * b[j]
    print ans

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, n)cin >> v[i];
    rep(i, n)v[i]++;
    int mx = 0, s = 0;
    queue<int> q;
    rep(i, n){
        s += v[i];
        q.push(v[i]);
        if(q.size() > k){
            s -= q.front();
            q.pop();
        }
        if(q.size() == k){
            mx = max(mx, s);
        }
    }
    double ans = mx;
    ans /= 2;
    printf("%.10f\n", ans);
    system("pause");
}

Measured memory_bytes: 2048
import java.util.*;

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

        int W = sc.nextInt();
        int H = sc.nextInt();
        int N = sc.nextInt();

        int[][] a = new int[3][N];
        int min_x = 0;
        int max_x = W;
        int min_y = 0;
        int max_y = H;
        for(int i = 0; i < N; i++){
            a[0][i] = sc.nextInt();
            a[1][i] = sc.nextInt();
            a[2][i] = sc.nextInt();
        }
        sc.close();

        for(int i = 0; i < N; i++){
            if(a[2][i] == 1)
                min_x = Math.max(min_x, a[0][i]);
            if(a[2][i] == 2)
                max_x = Math.min(max_x, a[0][i]);
            if(a[2][i] == 3)
                min_y = Math.max(min_y, a[1][i]);
            if(a[2][i] == 4)
                max_y = Math.min(max_y, a[1][i]);
        }

        int x = max_x - min_x;
        int y = max_y - min_y;

        if(x <= 0 || y <= 0)
            System.out.println(0);
        else
            System.out.println(x*y);
    }
}

Measured memory_bytes: 23892
L, a, b, m = map(int, input().split())

k = 18

c = [0] * k

t = a + b * (L - 1)

p = 9
temp = 0
for i in range(k):
    if a <= p:
        c[i] = (min(p, t) - a) // b + 1 - temp
        temp += c[i]
    if t <= p:
        break
    p = (p + 1) * 10 - 1

def calc_mat(P, Q):
    ret = [[0,0,0],[0,0,0],[0,0,0]]
    for i in range(3):
        for j in range(3):
            for k in range(3):
                ret[i][j] += P[i][k] * Q[k][j]
            ret[i][j] %= m
    return ret


s = a
x = 0
for i in range(k):
    if c[i] == 0:
        continue
    mat = [[10 ** (i + 1), 0, 0], [1,1,0], [0,b,1]]
    temp_mat = [[1,0,0],[0,1,0],[0,0,1]]
    d = list(reversed(bin(c[i])[2:]))
    p = 1
    for z in d:
        if z == '1':
            temp_mat = calc_mat(temp_mat, mat)
        mat = calc_mat(mat, mat)
    #print(temp_mat)
    temp_x = (temp_mat[0][0] * x + temp_mat[1][0] * s + temp_mat[2][0]) % m
    s = (temp_mat[0][1] * x + temp_mat[1][1] * s + temp_mat[2][1]) % m
    x = temp_x
    #print(x, s)

print(x)

Measured memory_bytes: 3192
import java.util.Scanner;

public class Main 
{
	
	public static void main(String[] args)
	{
		
		int count = 0;
		int temp = 1000;
		int tempo = 0;
		int answer = 0;
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int[] p = new int[n];
		
		for(int i = 0; i < n; i++)
		{
			p[i] = sc.nextInt();
		}
		sc.close();
		
		while(count < k)
		{
			for(int i = 0; i < n; i++)
			{
				
				if(temp > p[i] && p[i] != 0)
				{
					temp = p[i];
					tempo = i;
				}
				if(i + 1 == n)
				{
					p[tempo] = 1000;
				}

			}
			
			answer += temp;
			temp = 1000;
			count++;

		}
		
		System.out.println(answer);
		
	}

}

Measured memory_bytes: 30476
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
    
    int n;
    int t,a,ans;
    double min=9999999.0;
    int h[1111];
    cin>>n>>t>>a;
    for(int i=0;i<n;i++){
        cin>>h[i];
        double k=abs((double)a-((double)t-(double)h[i]*0.006));
        if(min>k){
            min=k;
            ans=i+1;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
import sys

cin = sys.stdin
# cin = open("in.txt", "r")

def line2N():
    return map(int, cin.readline().split())


N, = line2N()
s = []
for i in range(N):
    si, = line2N()
    s.append(si)
total = sum(s)
if total % 10 == 0:
    s.sort()
    ot = total
    for si in s:
        if si % 10!=0:
            ot = si
            break

    print(total - ot)
else:
    print(total)

Measured memory_bytes: 3064
package main

import (
	"fmt"
  	"math"
)

func main() {
	var n,k float64
	fmt.Scan(&n,&k)
	
	for i := 0.0; i < n; i++ {
      if n == 1 {
        	fmt.Println(1)
        	return
      } else if n < math.Pow(k, i) {
			fmt.Println(i)
			return
		}
	}
}

Measured memory_bytes: 512
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 10 10:05:08 2019

@author: shinjisu
"""


# ARC 073 C
def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def dmp(x):
    global debug
    if debug:
        print(x)


def probC():
    N, T = getIntList()
    Ts = getIntList()
    dmp((N, T, Ts))
    total = Ts[0]
    for i in range(1, N):
        total += min(T, Ts[i]-Ts[i-1])
    return total+T


debug = False
print(probC())


Measured memory_bytes: 25836
import java.util.*;

class Main {
	public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();

            if(x == 0 && y == 0)    break;

            if(x <= y)  System.out.println(x+" "+y);
            else    System.out.println(y+" "+x);
        }
    }
}


Measured memory_bytes: 35716
while True:
    M,F,R = map(int,input().split())
    if M == -1 and F == -1 and R == -1:
        break
    if M == -1 or F == -1:
        print("F")
    elif M+F >= 80:
        print("A")
    elif M+F >= 65:
        print("B")
    elif M+F >= 50:
        print("C")
    elif M+F >= 30:
        if R >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")



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

using namespace std;

int main()
{
	int a, b;
	bool flag;

	cin >> a >> b;

	string str = to_string(a);
	string str2 = to_string(b);

	str += str2;

	int num = stoi(str);

	for (int i = 0; i < num / 2; i++) {
		if ((i * i) == num) {
			flag = true;
			break;
		}
		else {
			flag = false;
		}
	}

	if (flag == true) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

	return (0);
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int a, b, c;

signed main() {
  cin >> a >> b >> c;

  if (a + b >= c) {
    cout << b + c << endl;
  } else if (a + b < c) {
    cout << 2 * b + a + 1 << endl;
  }

  return 0;
}


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

int main()
{
    int N, A, B, ans = 0;
    cin >> N >> A >> B;
    for (int i = 1; i <= N; i++)
    {
        int k = i;
        int sum = 0;
        while (k > 0)
        {
            sum += k % 10;
            k /= 10;
        }
        if (sum >= A && B >= sum)
        {
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
z=[0]
s=r=0..9
gets.to_i.times{m=r.map{gets.split.map(&:to_i)+z}+[z*11]
puts ([[0,1].product(*[[0,1]]*9).find{|a|s=m.dup<<a+z
r.map{|i|s[i]=s[i][r].zip(e=s[i-1],s[i-2],e.rotate,e.rotate(-1)).map{|l|l.inject(:+)%2}+z}
s[9].all?{|j|j==0}}]+s[0,9]).map{|a|a[r]*" "}}

Measured memory_bytes: 6236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
int main(){
    speed;
    string s;
    cin>>s;
    if(s=="SUN")cout<<7;
    if(s=="MON")cout<<7-1;
    if(s=="TUE")cout<<7-2;
    if(s=="WED")cout<<7-3;
    if(s=="THU")cout<<7-4;
    if(s=="FRI")cout<<7-5;
    if(s=="SAT")cout<<7-6;
}

Measured memory_bytes: 256