akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}


int main(void){
  ll N, A, B, W, H, C, D, Q, X, Y;
  ll ans = 0;
  string S, T;
  cin >> A >> B;
  
  rep_s(i, A, B+1){
    S = to_string(i);
    if (S[0] == S[4] && S[1] == S[3]) ans++;
  }

  cout << ans << endl;

}


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


typedef struct point_{
	double x,y;
	struct point_ operator-(const struct point_ & r) const{
		return {x-r.x,y-r.y};
	}
	struct point_ operator+(const struct point_ & r) const{
		return {x+r.x,y+r.y};
	}
	double norm2(){
		return x*x+y*y;
	}
} Point;

double dot(Point p1,Point p2) {
	return p1.x * p2.x + p1.y * p2.y;
}
Point c_mul(double c,Point p){
	return {c*p.x,c*p.y};
}

int main(){
	Point p1,p2,p;
	int q;
	scanf("%lf%lf%lf%lf%d",&p1.x,&p1.y,&p2.x,&p2.y,&q);
	for(int i = 0; i < q; i++){
		scanf("%lf%lf",&p.x,&p.y);
		Point v = p - p1;
		Point u = p2 - p1;
		Point p1h = c_mul(dot(u,v)/u.norm2(),u);
		Point p1q = c_mul(2,p1h) - v;
		Point ans = p1 + p1q;
		printf("%.10f %.10f\n",ans.x,ans.y);
	}
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  std::vector<int> vec(n);
  rep(i,n) cin >> vec.at(i);
  int ans = 100;
  for (int i = 1; i < n; i++) {
    std::vector<int> l = std::vector(vec.begin(), vec.begin() + i);
    std::vector<int> r = std::vector(vec.begin() + i, vec.end());
    int tmp1 = accumulate(l.begin(), l.end(), 0);
    int tmp2 = accumulate(r.begin(), r.end(), 0);
    ans = min(ans,abs(tmp1 - tmp2));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
//typedef long long ll;
//typedef long double ld;
//typedef unsigned long long ull;
//typedef unsigned long double uld;
typedef pair<int,int> P;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    vector<char> check(2*n);
    rep(i,2*n){
        check[i] = s[i%n];
    }
    bool ans = false;
    rep(i,n){
        bool res = true;
        rep(j,n){
            if(t[j] != check[i+j]) res = false;
        }
        if(res) ans = true;
    }
    cout << (ans ? "Yes" : "No") << endl;
}
/*



*/

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

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

    int N;
    cin >> N;
    map<string, int> mp;
    for (int i = 0; i < N; ++i) {
        string S;
        cin >> S;
        mp[S]++;
    }
    cout << mp.size() << endl;

    return 0;
}

Measured memory_bytes: 19172
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>

using namespace std;


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;
int main(void) {
  double a, b;
  lld amin, amax, bmin, bmax;
  cin >> a >> b;
  amin = (lld)ceil(a / 0.08);
  amax = (lld)ceil((a + 1.0) / 0.08) - 1;
  bmin = (lld)ceil(b / 0.1);
  bmax = (lld)ceil((b + 1.0) / 0.1) - 1;
  if (amax < bmin || bmax < amin) {
    cout << -1 << "\n";
  } else if (amin < bmin) {
    cout << bmin << "\n";
  } else {
    cout << amin << "\n";
  }
}

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

int main()
{
    int i,j,a,n,tmp;
    int A[N],B[N];

    scanf("%d",&n);
    if(n < 1 || n > N)exit(1);

    for(i = 0 ; i < n ; i++){
        scanf("%d",&A[i]);
        if(A[i] < 0 || A[i] > N)exit(1);
    }
    i = -1;
    a = A[n-1];
    for(j = 0 ; j < n-1 ; j++){
        if(A[j] <= a){
            i++;
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
        }
    tmp = A[i+1];
    A[i+1] = A[n-1];
    A[n-1] = tmp;

    for(j = 0 ; j < n ; j++){
        if(j)printf(" ");
        if(j == i + 1)printf("[%d]",A[j]);
        else printf("%d",A[j]);
    }
    printf("\n");
    return 0;
}



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

using namespace std;

vector<string> W;
int N;

bool check(){
    for(int i=0; i<N-1; i++){
        if(find(W.begin(), W.begin()+i+1, W[i+1])!=W.begin()+i+1) return false;
        if(W[i+1][0] != W[i][W[i].size()-1]) return false;
    }

    return true;
}


int main() {
    cin >> N;
    W.resize(N);
    for(string &w:W) cin >> w;

    if(check()) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func stringsToInts(s, sep string) []int {
	ss := strings.Split(s, sep)
	ints := make([]int, 0)
	for _, c := range ss {
		i, _ := strconv.Atoi(c)
		ints = append(ints, i)
	}
	return ints
}

func sum(tree []int, targetL, targetR, currentL, currentR, idx int) int {
	if targetL <= currentL && currentR <= targetR {
		return tree[idx]
	}

	if (targetR < currentL) || (currentR < targetL) {
		return 0
	}

	sum := sum(tree, targetL, targetR, currentL, (currentL+currentR)/2, idx*2+1) + sum(tree, targetL, targetR, (currentL+currentR)/2+1, currentR, idx*2+2)
	return sum
}

func compute(tree []int, com, x, y, size int) {
	switch com {
	case 0: // add(x, y)
		x = x - 1
		treeidx := size + x - 1
		tree[treeidx] += y
		for treeidx != 0 {
			treeidx = (treeidx - 1) / 2
			tree[treeidx] += y
		}
	case 1: // getSum(x,y)
		sum := sum(tree, x-1, y-1, 0, size-1, 0)
		fmt.Println(sum)
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	line := scanner.Text()
	ints := stringsToInts(line, " ")
	n, q := ints[0], ints[1]

	pow := math.Ceil(math.Log2(float64(n)))
	leafSize := int(math.Pow(2, pow))
	binaryTree := make([]int, int(math.Pow(2, pow+1)-1))

	for i := 0; i < q; i++ {
		scanner.Scan()
		line := scanner.Text()
		ints := stringsToInts(line, " ")
		com, x, y := ints[0], ints[1], ints[2]
		compute(binaryTree, com, x, y, leafSize)
	}
}


Measured memory_bytes: 5856
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())
    print("YES" if abs(a-b) <= (v-w)*t else "NO")
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 38992
#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(int a,int b)
{
	return a>b;
}	
int main()
{
	int i,n,k,x,f=0;
	cin>>n>>k;
	int a[200000+5]={0};
	for(i=0;i<n;i++) 
	{
	cin>>x;
	a[x]++;
    }
    sort(a,a+200000,cmp);
    for(i=k;i<=200000;i++)
    f+=a[i];
    cout<<f<<endl;
    return 0;
}

Measured memory_bytes: 1024
def main():
    N, M, K = (int(i) for i in input().split())
    for i in range(N+1):
        for j in range(M+1):
            cur = i*j + (N-i)*(M-j)
            if cur == K:
                return print("Yes")
    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    
    int n;
    cin >> n;
    vector<int> a;
    
    for(int i=0;i<n;i++){
        int m;
        cin >> m;
        a.push_back(m);
    }
    
    sort(a.begin(),a.end());
    
    int result = 0;
    for(int i = 0;i<n;i++){
        if(i%2==0){
            result+=a.back();
        }
        else{
            result-=a.back();
        }
        a.pop_back();
    }
    
    cout << result << endl;
    
}


Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	long long N, K;
	cin >> N >> K;
	N %= K;
	cout << min(N, K - N) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    
    long long a,b,c,d,e,n,diff;
    a = b = c = d = e = LLONG_MAX;
    
    long long x,y;
    cin >> x >> y;
    
    diff = abs(abs(y) - abs(x));
    
    n = x;
    
    
    n += diff;
    
    if ( y == n ) { a = diff; }
    
    n = -n;
    
    if ( y == n ) { b = diff+1; }
    
    
    
    n = -x;
    
    if ( y == n ) { c = diff+1; }
    
    n += diff;
    
    if ( y == n ) { d = diff+1; }
    
    n = -n;
    
    if ( y == n ) { e = diff+2; }
    
    cout << min(min(a,b),min(c,min(d,e))) << endl;
    
    return 0;
}

Measured memory_bytes: 256
class State private constructor(val direction: Int, val state: Int, val score: Int) {
    constructor():this(0, 0, 0)
    fun move(command: Char): State {
        val diff = when(command){
            'R' -> 1
            'L' -> -1
            else -> TODO()
        }
        val newDirection = (direction + diff + 4) % 4
        return when {
            diff == 1 && newDirection == 0 && state == (1 shl 4) - 1 -> State(0, 0, score + 1)
            diff == 1 && newDirection == 1 -> State(1, 3, score)
            newDirection == 0 -> State(0, 0, score)
            else -> State(newDirection, state or (1 shl newDirection), score)
        }
    }

    override fun toString(): String {
        return "State(direction = $direction, state = $state, score = $score)"
    }
}
fun main(args: Array<String>?): Unit {
    println(
            readLine()!!.trim().fold(State()){s, c ->
                s.move(c)
            }.score
    )
}


Measured memory_bytes: 30688
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][] a = new int[N][26];

        for(int i = 0; i<N; i++) {
            String str = sc.next();
            for(int c = 0; c<str.length(); c++) {
                a[i][(int)(str.charAt(c)-'a')]++;
            }
        }
        StringBuilder builder = new StringBuilder();
        for(int i = 0; i<26; i++) {
            int min = Integer.MAX_VALUE;
            for(int j = 0; j<N; j++) {
                min = Math.min(a[j][i], min);
            }
            while(min!=0) {
                builder.append(((char)('a'+i)));
                min--;
            }
        }
        System.out.println(builder.toString());

    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    rep(n,0,N) cin>>A.at(n);
    sort(ToEnd(A));

    int ans=0;
    bool AliceTurn=true;
    _rep(a,A.size()-1,0){
        if(AliceTurn) ans+=A.at(a);
        else ans-=A.at(a);
        AliceTurn=!AliceTurn;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
h = Hash.new(0)


alpha = [*'a'..'z']

def min(a, b)
  a < b ? a : b
end

n.times do |i|
  s = gets.chomp

  if i == 0
    s.each_char do |c|
      h[c] += 1
    end
    next
  end

  alpha.each do |char|
    h[char] = min(h[char], s.count(char))
  end
end

ans = ''
h.sort.each do |k,v|
  next if v == 0

  ans += k * v
end

puts ans




Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	input(a);
	ll ans = 0;
	sort(all(a));

	for (int i = 0; i < n - k; i++)
		ans += a[i];
	cout << ans;

}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();

}

Measured memory_bytes: 1792
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;
 
bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}
 
ll gcd(ll a,ll b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
const int MAX = 510000;
const int MOD = 1000000007;
 
int main(){
    int N;
    int HList[100001] = {0};
    int dp[100001] = {1145141919};
 
    for(int i = 0; i < 100001;i++){
        dp[i] = 1145141919;
    }
    cin >>N;
 
    dp[0] = 0;
 
    for(int i = 0;i < N;i++){
        cin >>HList[i];
    }
 
    for(int i = 0; i <= N-1;i++){
        dp[i+1] = min(dp[i+1],dp[i] + abs(HList[i+1] - HList[i]));
        dp[i+2] = min(dp[i+2],dp[i] + abs(HList[i+2] - HList[i]));
    }
 
    cout <<dp[N-1]<<endl;
    return 0;
}
 
/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;
 
      for(ll s = 1;s < 50000000;s++){
 
        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }
 
//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;
 
*/

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

bool flg[1000010];
int cnt[1000010];

int main() {
	int n; cin >> n;
	int a[n];
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		++cnt[a[i]];
	}
	sort(a, a + n);
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		if(flg[a[i]]) continue;
		if(cnt[a[i]] < 2) ++ans;
		for(int j = a[i]; j < 1000010; j += a[i]) {
			flg[j] |= true;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 9120
n,m = gets.split.map &:to_i

k = []
a = []
b = {}
n.times do |i|
    k,*a[i] = gets.split.map &:to_i
    a[i].each do |ai|
        b[ai] ||= 0
        b[ai] += 1
    end
end

puts b.count{|k,bi|bi == n}


Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    int n = Integer.parseInt(br.readLine());
	    String line = br.readLine();

	    String[] input = line.split(" ");
	    String[] output = new String[input.length];

	    int len = input.length - 1;
	    for (int i = 0; i < n; i++) {
	    	output[i] = input[len--];
	    }

	    System.out.println(String.join(" ", output));

	}
}

Measured memory_bytes: 24424
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
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(); }

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n, h; cin >> n >> h;

	vector<int> a(n);
	vector<int> b(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

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

	int amax = a[0];


	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (b[i] > a[0]) {
			
			if (h - b[i] > 0) {
				cnt++;
				h -= b[i];
			}
			else {
				cnt++;
				cout << cnt << endl;
				return 0;
			}

		}
		else {
			break;
		}
	}

	cnt += (h + amax - 1) / amax;

	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Map = vector<vector<char>>;
using pr = pair<int, int>;

int H, W, ans = 0;
Map S;
vector<vector<int>> dist;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int bfs(pr c)
{
    dist.assign(H, vector<int>(W, -1));
    queue<pr> Q;
    Q.push(c);
    dist[c.first][c.second] = 0;
    int max_dist = 0;

    while (!Q.empty())
    {
        pr p = Q.front();
        int x = p.first, y = p.second;
        Q.pop();

        for (int dir = 0; dir < 4; dir++)
        {
            int nx = x + dx[dir], ny = y + dy[dir];

            if (nx < 0 || nx >= H || ny < 0 || ny >= W)
            {
                continue;
            }

            if (dist[nx][ny] != -1)
            {
                continue;
            }

            if (S[nx][ny] == '#')
            {
                continue;
            }

            Q.push(make_pair(nx, ny));
            dist[nx][ny] = dist[x][y] + 1;
            max_dist = max(max_dist, dist[nx][ny]);
        }
    }

    return max_dist;
}

int main()
{
    cin >> H >> W;
    S.resize(H, vector<char>(W));

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> S[i][j];
        }
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (S[i][j] == '#')
            {
                continue;
            }

            ans = max(ans, bfs(make_pair(i, j)));
        }
    }

    cout << ans << endl;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    vector<ll>sum(n+1,0);
    vector<bool>ch(n+1,false);
    ll s=0;
    for (int i = 1; i <=n; ++i) {
        s+=i;
        sum[i]=s;
    }
    ll x=n;
    ll k;
    while(1) {
        k = lower_bound(all(sum), x) - sum.begin();
//        cout <<sum[k]<<" "<<x<<endl;
        for (int i = 1; i <=k; ++i) {
            if(ch[i])ch[i]=false;
            else if(!ch[i])ch[i]=true;
        }
        x=sum[k]-x;
        if(!x)break;
    }
    for (int i = 1; i <=n; ++i) {
        if(ch[i])cout <<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 82696
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;

struct RollingHash {
    static const ll base1 = 1009;
    static const ll base2 = 2009;
    static const ll mod1 = 1000000007;
    static const ll mod2 = 1000000009;
    vector<ll> hash1, hash2, pow1, pow2;

    RollingHash(const string &S) {
        int n = (int) S.size();
        hash1.assign(n + 1, 0);
        hash2.assign(n + 1, 0);
        pow1.assign(n + 1, 1);
        pow2.assign(n + 1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
            pow1[i + 1] = (pow1[i] * base1) % mod1;
            pow2[i + 1] = (pow2[i] * base2) % mod2;
        }
    }

    inline pair<ll, ll> get(int l, int r) const {
        ll res1 = hash1[r] - hash1[l] * pow1[r - l] % mod1;
        if (res1 < 0) res1 += mod1;
        ll res2 = hash2[r] - hash2[l] * pow2[r - l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    inline int getLCP(int a, int b) const {
        int len = min((int) hash1.size() - a, (int) hash1.size() - b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a + mid) != get(b, b + mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};

int main() {
    int N;
    string S;
    cin >> N >> S;
    RollingHash rollingHash(S);

    int res = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            int lcp = rollingHash.getLCP(i, j);
            lcp = min(lcp, j - i);
            res = max(res, lcp);
        }
    }

    cout << res << endl;
}


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

int main()
{
  ll w, a, b, ans;
  cin >> w >> a >> b;

  if (b > a + w)
  {
    ans = b - (a + w);
  }
  else if (a > b + w)
  {
    ans = a - (b + w);
  }
  else
  {
    cout << 0 << endl;
    return 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;


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

    int sum = 0;
    int arr[3];
    for(int bit=0; bit<(1<<3); bit++){
        sum = s.at(0)-'0';
        for(int i=0; i<3; i++){
            if(bit & (1<<i)){
                arr[i] = 1;
                sum -= s.at(i+1)-'0';
            }else{
                arr[i] = 0;
                sum += s.at(i+1)-'0';
            }
        }
        if(sum==7){
            break;
        }
    }

    cout << s.at(0);
    for(int i=0; i<3; i++){
        cout << ((arr[i]==1)? '-' : '+') << s.at(i+1);
    }
    cout << "=7" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}
        int n=sc.nextInt();
        int m=sc.nextInt();
        int r[] = new int[n];
        ArrayList<Integer> from[]=new ArrayList[n];

        for(int i=0; i<n; i++) {
            from[i] = new ArrayList<Integer>();
        }
        for(int i=0; i<m; i++) {
            int a=sc.nextInt()-1,
                b=sc.nextInt()-1;
            from[b].add(a);
            r[b]++;
        }   

        int pre=-1,ans=0;
        for(int i=0; i<n; i++) {
            if(r[i]>0){
                for(int t=0; t<from[i].size(); t++) {
                    if(pre<=from[i].get(t)){ans++; pre=i;break;}
                }
            }
        }

        out.println(ans);
        out.flush();
    }
    
    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
     
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
    
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class P implements Comparable<P>{
        int id, d;
        P(int  id, int d) {
            this.id=id;
            this.d=d;
        } 
          
        public int compareTo(P p){
            return d-p.d; //descend
        }
    }

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 54384
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[55][55][5000];
signed main() {
    int X;
    cin >> X;
    cout << 360LL/__gcd(360LL,X)*X/X << endl;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[200010];
signed main()
{
	int n,i,ans=0;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=2;i<=n;i++)
	{
		ans+=max(0ll,a[i-1]-a[i]);
		a[i]=max(a[i],a[i-1]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5180
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
	  Set<String> set = new HashSet<>();
      for(int i = 0; i < n; i++)
        	set.add(sc.next());
      System.out.println(set.size() == 4 ? "Four" : "Three");
  }
}


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

n = int(input())
sp = ["" for _ in range(n)]

for i in range(n):
    a, b = map(str, input().split())
    sp[i] = [a, int(b)]
    sp[i].insert(2, i+1)
#print(sp)

sp2 = sorted(sp, key=lambda x:x[1], reverse=True)
#print(sp2)

sp3 = sorted(sp2, key=lambda x:x[0], reverse=False)
#print(sp3)

for i in range(len(sp3)):
    print(sp3[i][2])

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

signed main(void)
{
	string s, t;
	int m;

	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.rbegin(),t.rend());
	if (s < t)
		cout << "Yes"<< endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
N, M, X, Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
MAX_x = max(x)
MIN_y = min(y)
MAX_x = max(MAX_x, X)
MIN_y = min(MIN_y, Y)
if MAX_x < MIN_y:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include <stdio.h>
int main(void)
{
    int i,n,debt=100000;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        debt=debt*1.05;
        if(debt%1000!=0)
            debt=debt-debt%1000+1000;
    }
    printf("%d\n",debt);
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;






int main() {
	vector<string> s(3, "");
	string ans;
	while (1) {
		cin >> s[0] >> s[1] >> s[2];
		if (cin.eof())break;
		ans = "NA";
		for (int i = 0; i < 3; i++) {
			if ((s[i][0] != '+'&&s[i][0] == s[i][1] && s[i][1] == s[i][2])) {
				ans = s[i][0];
				break;
			}
			if ((s[0][i] != '+'&&s[0][i] == s[1][i] && s[1][i] == s[2][i])) {
				ans = s[0][i];
				break;
			}
		}
		if (s[1][1] != '+') {
			if ((s[1][1] == s[0][2] && s[1][1] == s[2][0]) || (s[1][1] == s[0][0] && s[1][1] == s[2][2])) {
				ans = s[1][1];
			}
		}
		cout << ans << endl;
	}
}

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

int main() {
int n,k,q;
cin >> n >> k >>q;
vector<long long >a(q);
vector<int>hito(n,k-q);
for(int  i =0;i<q;i++){
    cin >> a.at(i);
    hito.at(a.at(i)-1)++;
}
for(int i=0;i<n;i++){
    if(hito.at(i)>0)cout <<"Yes"<<endl;
    else{
        cout <<"No"<<endl;
    }
}
}





Measured memory_bytes: 1792
def dijkstra_back(s,t,n,w,cost):
    import heapq
    #sからtへの最短経路の経路復元
    prev = [s] * n #最短経路の直前の頂点
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    q=[]
    heapq.heapify(q)
    heapq.heappush(q,(0,s))
    while q:
        c,v=heapq.heappop(q)
        if d[v]<c:
            continue

        for i in range(len(to[v])):
            k=to[v][i]
            if d[k]>d[v]+cost[v][k]:
                d[k]=d[v]+cost[v][k]
                heapq.heappush(q,(d[k],k))
                prev[k]=v

    path = [t]
    while prev[t] != s:
        path.append(prev[t])
        prev[t] = prev[prev[t]]
    path.append(s)
    path = path[::-1]
    return path



N,M=map(int,input().split())
fr={i:set([]) for i in range(1,N+1)}
to={i:set([]) for i in range(1,N+1)}
for i in range(0,M):
    a,b=map(int,input().split())
    fr[b].add(a)
    to[a].add(b)

delete=set([])
flag=1
while flag==1:
    flag=0
    for i in range(1,N+1):
        if (not i in delete) and (delete>=fr[i] or delete>=to[i]):
            delete.add(i)
            flag=1

node=[i for i in range(1,N+1)]
save=set(node)-delete
if save:
    hen=[]
    for i in save:
        fr[i]=fr[i]&save
        to[i]=to[i]&save
        fr[i]=list(fr[i])
        to[i]=list(to[i])

    for i in save:
        for j in fr[i]:
            hen.append((j,i))

    save=list(save)

    cost=[[float('inf') for i in range(0,N+1)] for i in range(0,N+1)]
    for i in range(0,len(hen)):
        a,b=hen[i]
        cost[a][b]=1

    ansc=10**10
    ans=[]
    for i in range(len(save)):
        for j in fr[save[i]]:
            test=dijkstra_back(save[i],j,N+1,len(hen),cost)
            if len(test)<ansc:
                ansc=len(test)
                ans=test

    print(ansc)
    for i in range(0,ansc):
        print(ans[i])

else:
    print(-1)

Measured memory_bytes: 123612
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#define unsigned long long 
#define rep(i,a,b) for(ull (i)=(a);(i)<(b);i++)
using namespace std;
int n, p, man[60], wan;


int main(void){
	while (true){
		memset(man, 0, sizeof(man));
		cin >> n >> p;
		if (n == 0)return(0);
		wan = p;
		int i = 0;
		while (true){
			if (wan > 0){
				man[i]++;
				wan--;
				if (man[i] == p)break;
			}
			else
			{
				wan = man[i];
				man[i] = 0;
			}

			i = (i + 1) % n;
		}
		cout << i << endl;



	}



}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
using namespace std;
int main(){
  char a,b;
  cin>>a>>b;
  if(a == 'H'){
    if(b == 'H'){
      cout<<"H"<<endl;
      return 0;
    } else{
      cout<<"D"<<endl;
      return 0;
    } 
  }else {
      if(b =='H'){
        cout<<"D"<<endl;
        return 0;
      } else{
        cout <<"H"<<endl;
        return 0;
      }
    }
  
}
    

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

int main(){
	int N;
	cin>>N;
	int a[N];
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	int ans=0;
	for(int i=0;i<N;i++){
		while(true){
			if(a[i]%2==0){
				a[i]=a[i]/2;
				ans=ans+1;
			}else{
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] a = new int[n][m];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                a[i][j] = sc.nextInt();
            }
        }
        int[] b = new int[m];
        for(int i = 0; i < m; i++){
            b[i] =sc.nextInt();
        }
        for(int i = 0; i < n; i++){
            int sum =0;
            for(int j = 0; j < m; j++){
                int total = a[i][j] * b[j];
                sum += total;
            }
            System.out.println(sum);
        }
    }
}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

enum{FRONT,BACK,RIGHT,LEFT,TOP,BOTTOM};
struct Die{
	int face[6]; // front,back,right,left,top,bottom
	Die():face{2,5,3,4,1,6}{}
	void Rotate(int a,int b,int c,int d){
		tie(face[a],face[b],face[c],face[d])=mt(face[b],face[c],face[d],face[a]);
	}
	void TurnF(){Rotate(2,4,3,5);}
	void TurnR(){Rotate(0,5,1,4);}
	void TurnU(){Rotate(0,2,1,3);}
};

typedef vector<vector<vector<Die>>> Cube;

bool ok(Cube cube,int x,int y,int z,const vvi& ts,const vvi& fs)
{
	if(x>0 && cube[x][y][z].face[BACK]+cube[x-1][y][z].face[FRONT]!=7) return false;
	if(y>0 && cube[x][y][z].face[LEFT]+cube[x][y-1][z].face[RIGHT]!=7) return false;
	if(z>0 && cube[x][y][z].face[BOTTOM]+cube[x][y][z-1].face[TOP]!=7) return false;
	if(z==2 && cube[x][y][z].face[TOP]!=ts[x][y] && ts[x][y]) return false;
	if(x==2 && cube[x][y][z].face[FRONT]!=fs[2-z][y] && fs[2-z][y]) return false;
	return true;
}

void dfs(Cube& cube,int x,int y,int z,const vvi& ts,const vvi& fs,vi& res)
{
	if(x==3) x=0,y++;
	if(y==3) y=0,z++;
	if(z==3){
		int sum=0;
		rep(i,3) rep(j,3)
			sum+=cube[i][2][j].face[RIGHT];
		res.push_back(sum);
		return;
	}
	
	Die d;
	rep(i,6){
		rep(j,4){
			cube[x][y][z]=d;
			if(ok(cube,x,y,z,ts,fs))
				dfs(cube,x+1,y,z,ts,fs,res);
			d.TurnU();
		}
		i&1?d.TurnF():d.TurnR();
	}
}

void solve(const vvi& ts,const vvi& fs)
{
	Cube cube(3,vector<vector<Die>>(3,vector<Die>(3)));
	vi res;
	dfs(cube,0,0,0,ts,fs,res);
	sort(all(res));
	res.erase(unique(all(res)),end(res));
	if(res.empty())
		cout<<0<<endl;
	else{
		rep(i,res.size())
			cout<<(i?" ":"")<<res[i];
		cout<<endl;
	}
}

int main()
{
	int tc; cin>>tc;
	rep(_,tc){
		vvi ts(3,vi(3)),fs(3,vi(3));
		rep(i,3) rep(j,3) cin>>ts[i][j];
		rep(i,3) rep(j,3) cin>>fs[i][j];
		solve(ts,fs);
	}
}

Measured memory_bytes: 1360
#include<stdio.h>

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	
	if (a < b) {
		printf("a < b\n");
	}
	else if (a > b) {
		printf("a > b\n");
	}
	else {
		printf("a == b\n");
	}
	return 0;
}

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

public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int T = in.nextInt();
		int[] t = new int[n+1];	
		for(int i =0;i<n;i++){
			t[i] = in.nextInt();
		}
		t[n] = Integer.MAX_VALUE;
		long ontime=0;
		for(int i=1;i<=n;i++){
			
			ontime+=Math.min(T,t[i]-t[i-1]);

		}
		out.println(ontime);
		out.flush();
		out.close();  
	}

}





Measured memory_bytes: 43984
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {

    int N;
    cin >> N;
    string ans;
    if (N == 0)ans = '0';
    while (N!=0) {
        if (N % 2 == 0)ans += '0';
        else {
            ans += '1';
            N -= 1;
        }
        N /= -2;
    }
    reverse(ans.begin(), ans.end());

    cout << ans << endl;

    return 0;
}

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

s = input()

s_list = list(s)
operator_box = list(range(len(s_list) - 1))
operators = dict(zip(operator_box, list(map(lambda x: False, operator_box))))

result = 0

# あるオペレータの組み合わせにおける数の和を出す
def calc(nums, operators):
    sums = 0
    _index = 0
    for index, operator in operators.items():
        if operator:
            if _index == index:
                chars = [nums[_index]]
            else:
                chars = nums[_index: int(index) + 1]

            _index = int(index) + 1
            number = ''.join(chars)
            sums += int(number)

    chars = nums[_index:]
    sums += int(''.join(chars))
    return sums

length = len(operators)

for i in range(2 ** length):
    _operators = operators
    for j in range(length):
        if ((i >> j) & 1):
            _operators[length - 1 - j] = True
        else: 
            _operators[length - 1 - j] = False

    result += calc(s_list, _operators)

print(result)



Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var c string
	chars := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	fmt.Scan(&c)
	res := "a"
	for i := 0; i < len(chars); i++ {
		if chars[i] == c {
			res = chars[i+1]
			break
		}
	}

	fmt.Println(res)
}


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

int n, k;

double solve(){
    double ans = 0;
    double t;
    for(int i = 1; i <= n; i++){
        t = 1.0 / n;
        int a = i;
        while(a < k){
            a *= 2;
            t = t / 2;
        }

        ans += t;
    }

    return ans;
}

int main(){
    scanf("%d %d", &n, &k);

    printf("%.12lf\n", solve());

    return 0;
}

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

using namespace std;

int idconv(string s) {
	int res = 0;
	for (int i = 0; i < 3; i++) {
		res += (s[i] - '0');
	}
	return res;
}

int timeconv(string s) {
	int res = 0;
	res += ((s[0] - '0') * 10 + (s[1] - '0'));
	res *= 60;
	res += ((s[3] - '0') * 10 + (s[4] - '0'));
	return res;
}

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

	int n;
	while (true) {
		cin >> n;
		if (n == 0) break;
		vector<int> sum(1000, 0);
		bool exist = false;
		vector<int> intime(1000, -1);
		for (int i = 0; i < n; i++) {
			string md, hm, e, p;
			cin >> md >> hm >> e >> p;
			int time = timeconv(hm), id = idconv(p);
			if (id == 0) {
				if (e == "I") {
					exist = true;
					for (int j = 1; j < 1000; j++) {
						if (intime[j] > 0) intime[j] = time;
					}
				}
				else {
					exist = false;
					for (int j = 1; j < 1000; j++) {
						if (intime[j] > 0) {
							sum[j] += (time - intime[j]);
						}
					}
				}
			}
			else {
				if (e == "I") {
					if (exist) {
						intime[id] = time;
					}
					else {
						intime[id] = time;
					}
				}
				else {
					if (exist) {
						sum[id] += time - intime[id];
					}
					else {

					}
                    intime[id]=-1;
				}
			}
		}
		int ma = -1;
		for (int i = 1; i < 1000; i++) {
			if (sum[i] > ma) {
				ma = sum[i];
			}
		}
		cout << ma << endl;
	}
}

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

def max_positive_num(L):
    val = 0
    for i in range(L):
        if i % 2 == 0:
            val = val + 2 ** i
    return val


def min_negative_num(L):
    val = 0
    for i in range(L):
        if i % 2 == 1:
            val = val - 2 ** i
    return val


# 与えた数字に対して最大のビット数を返す
def maxbit(num):
    count = 0
    while not (min_negative_num(count) <= num <= max_positive_num(count)):
        count = count + 1
    return count

bitlist = [0]*maxbit(N)

if N == 0:
    print("0")
else:
    rest = N
    for i in range(maxbit(N), 0, -1):
        if i % 2 == 0:
            if (min_negative_num(i) <= rest < min_negative_num(i-1)):
                bitlist[i-1] = 1
                rest = rest - pow(-2,(i-1))
        else:
            if (max_positive_num(i-1) < rest <= max_positive_num(i)):
                bitlist[i-1] = 1
                rest = rest - pow(-2,(i-1))
    ans = ''.join(map(str, bitlist))
    print(ans[::-1])

Measured memory_bytes: 3064