akhauriyash/Code-Regression huggingface dataset:
import numpy as np
i8 = np.int64

def factorial(N, MOD):
    fac = np.empty(N + 1, i8)
    inv = np.empty(N + 1, i8)
    finv = np.empty(N + 1, i8)
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, N + 1):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD
    return fac, finv

def com(n, k, fac, finv):
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

MOD = 1000000007  # type: int
N, K = map(int, input().split())
A = np.fromstring(input(), dtype=i8, sep=' ')
A = np.sort(A)

fac, finv = factorial(100000, MOD)
ans = 0
for i in range(N - K + 1):
    ans = (ans + (A[N - i - 1] - A[i]) * com(N - i - 1, K - 1, fac, finv)) % MOD
print(ans)

Measured memory_bytes: 16332
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      if x == 500 * i + 100 * j + 50 * k:
        count += 1
        
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

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

typedef long long ll;

int main() {
	/*string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 3)if (s[i] == t[i])ans++;
	cout << ans;*/


	/*int a, b;
	cin >> a >> b;
	int ans = 0;
	while (ans * a - (ans - 1) < b) {
		ans++;
	}
	cout << ans;*/


	int n;
	cin >> n;
	int ans = 0;
	int h;
	int pre = -1;
	int k = 0;
	rep(i, n) {
		cin >> h;
		if (h <= pre) { k++; }
		else { ans = max(ans, k); k = 0; }
		pre = h;
	}
	ans = max(ans, k);
	cout << ans;

	return 0;
}

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

using namespace std;

int main()
{
    int A, B, K;
    cin >> A >> B >> K;

    vector<int> v;
    for (int i = 1; i <= min(A, B); i++)
    {
        if (A % i == 0 && B % i == 0)
        {
            v.push_back(i);
        }
    }

    sort(v.begin(), v.end(), greater<int>());
    cout << v[K - 1] << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <iostream>

using namespace std;


int MAXN = 2e5 + 1;
vector<long long> st;

void update_tree( int pos, long long value, int root, int tleft, int tright) {
  if (pos < tleft || pos > tright || tleft > tright) return;

  if (tleft == tright) {
    st[root] = value;
    return;
  } 

  int mid = (tleft + tright) / 2;
  
  update_tree(pos, value, root*2, tleft, mid);
  update_tree(pos, value, root*2+1, mid+1, tright);
  
  st[root] = max(st[root], value);
}

long long query( int qleft, int qright, int root, int tleft, int tright) {
    if (  qleft > qright ) return -1;
    if ( tleft == qleft && tright == qright) return st[root];

    int mid = (tleft + tright)/2;

    return max(
      query(qleft, min(qright, mid), root*2, tleft, mid),
      query(max(mid+1, qleft), qright, root*2+1, mid+1, tright)
    );
}


// https://atcoder.jp/contests/dp/tasks/dp_q
int main() {
  int N;
  cin >> N;

  vector<int> H(N+1);
  vector<int> A(N+1);

  st.assign(N*4 + 10, -1);

  // input H
  for(auto i=1; i<=N; i++) cin >> H.at(i);
  // input A
  for(auto i=1; i<=N; i++) cin >> A.at(i);
    
  vector<long long> F(N+1, 0);

  long long myres = -1;
  for (auto i = 1; i <= N; i++) {
      auto res = query(1, H.at(i)-1, 1, 1, N);
      F.at(i) = (  (res==-1)?(0):(res) ) + A.at(i);
      myres = max(myres, F.at(i));
      update_tree(  H.at(i), F.at(i), 1, 1, N);
  }
  cout << myres << endl;
  return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    long long N, A, B;
    cin >> N >> A >> B;

    long long sum = A + B;
    long long r = N % sum;
    long long ans = A * (N / sum) + min(A, r);

    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll w,h,n;

P from[1003],to[1003];
ll field[2002][2002];

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
    cin >> w >> h >> n;
    if(w == 0) break;
    set<ll> num_x,num_y;
    map<ll,ll> mp_x,mp_y;

    num_x.insert(0);
    num_y.insert(0);
    num_x.insert(w);
    num_y.insert(h);

    for (int i = 0;i < n;i++){
        cin >> from[i].first >> from[i].second >> to[i].first >> to[i].second;
        num_x.insert(from[i].first);
        num_y.insert(from[i].second);
        num_x.insert(to[i].first);
        num_y.insert(to[i].second);
    }
    ll cnt = 0;
    for(auto&& i:num_x){
        mp_x[i] = cnt;
        cnt += 2;
    }
    cnt = 0;
    for(auto&& i:num_y){
        mp_y[i] = cnt;
        cnt += 2;
    }

    memset(field,0,sizeof(field));

    for (int i = 0;i < n;i++){
        ll st_x = mp_x[from[i].first]; 
        ll st_y = mp_y[from[i].second]; 
        ll g_x  = mp_x[to[i].first];
        ll g_y  = mp_y[to[i].second];
        for (int j = st_y;j <= g_y;j++){
            field[j][st_x]++;
            field[j][g_x]--;
        }
    }

    for (int i = 0;i < mp_y[h];i++){
        for (int j = 0;j < mp_x[w];j++){
            field[i][j+1] += field[i][j];
        }
    }

    ll ans = 0;
    for (int i = 0;i < mp_y[h];i++){
        for (int j = 0;j < mp_x[w];j++){
            if(field[i][j] != 0) continue;
            queue<P> que;
            que.push(P(j,i));
            field[i][j] = -1;
            //cout << i << " " << j << endl;
            while(que.size()){
                P p = que.front(); que.pop();
                ll fx = p.first;
                ll fy = p.second;
                //cout << field[fx][fy] << endl;
                for (int k = 0;k < 4;k++){
                    ll tx = fx+dx[k];
                    ll ty = fy+dy[k];
                    if(tx < 0 || ty < 0 || tx >= mp_x[w] || ty >= mp_y[h] || field[ty][tx] != 0) continue;
                    field[ty][tx] = -1;
                    que.push(P(tx,ty));
                }
            }
            ans++;
        }
    }

    cout << ans << endl;
    }

    return 0;

}


Measured memory_bytes: 34640
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;

ll go(ll t,ll k){
	int cnt=0;
	while(t<k)cnt++,t<<=1;
	return cnt;
}


int main(){	
	cout<<fixed<<setprecision(10);
	ll n,k;cin>>n>>k;	
	ld ans=0;
	For(i,1,n+1)
		ans+=(1.0L/n)*pow(0.5,go(i,k));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>){
  val n = readLine()!!.toInt()
  val dStr = readLine()!!.split(" ")
  val d = Array(n){ dStr[it].toInt() }

  var result = 0
  for( (i, di) in d.withIndex() )
    for( j in i+1 until n )
      result += di * d[j]

  println(result)
}


Measured memory_bytes: 36032
#include<stdio.h>
#include<string.h>
int main(void) {
	int a;
	char str[20];
	scanf("%s", &str);
	a = strlen(str);
	for (int i = a-1; i >=0 ; i--)
	{
		printf("%c", str[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 928
#include<stdio.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;
P Q[LEN+1];
int head, tail, n;

void enqueue(P);
P dequeue(void);


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  
  head=1,tail=n+1;

  while(head!=tail){
    u=dequeue();
 
    if(q>u.t){
      c=u.t;
    }else{
      c=q;
    }
    u.t-=c;
    elaps+=c;
    if(u.t>0){
      enqueue(u);
    }else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


void enqueue(P x){
  Q[tail]=x;
  /*tail++;*/
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  /*head++;*/
  head=(head+1)%LEN;
  return x;
}




Measured memory_bytes: 11864
import sys
sys.setrecursionlimit(10**8)

n = int(input())
x = list(input())
bit_cnt = x.count('1')

# bitを一つ増やす場合
pos = [0] * n
pos_total = 0

# bitを一つ減らす場合
neg = [0] * n
neg_total = 0

base = 1
for i in range(n):
    pos[-i-1] = base%(bit_cnt+1)
    if x[-i-1] == '1':
        # 同時にmod(bit_cnt+1)の法でトータルを作成
        pos_total = (pos_total + base) % (bit_cnt+1)
    base = (base*2) % (bit_cnt+1)

base = 1
if bit_cnt == 1:
    # mod取れない
    pass
else:
    for i in range(n):
        neg[-i-1] = base%(bit_cnt-1)
        if x[-i-1] == '1':
            # 同時にmod(bit_cnt-1)の法でトータルを作成
            neg_total = (neg_total + base) % (bit_cnt-1)
        base = (base*2) % (bit_cnt-1)

def popcount(n):
    s = list(bin(n)[2:])
    return s.count('1')

memo = {}
memo[0] = 0
def dfs(n, depth=0):
    if n in memo:
        return depth + memo[n]
    else:
        ret = dfs(n%popcount(n), depth+1)
        # memo[n] = ret
        return ret

ans = []
for i in range(n):
    if x[i] == '0':
        st = (pos_total + pos[i]) % (bit_cnt+1)
        print(dfs(st, depth=1))
    elif bit_cnt == 1:
        # コーナーケース：すべてのbitが0となる
        print(0)
    else:
        st = (neg_total - neg[i]) % (bit_cnt-1)
        print(dfs(st, depth=1))


Measured memory_bytes: 26284
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    a = na()
    a = [ai - 1 for ai in a]

    junkan_point = 0
    visited = [0, a[0]]
    next = a[0]

    visited_set = set(visited)

    for _ in range(n+5):
        if a[next] in visited_set:
            junkan_point = a[next]
            break
        else:
            visited.append(a[next])
            visited_set.add(a[next])
            next = a[next]

    tmp_idx = visited.index(junkan_point)
    junkan_visited = visited[tmp_idx:]

    tmp = len(visited) - len(junkan_visited)
    if k < tmp:
        print(visited[k]+1)
    else:
        idx = (k - tmp) % len(junkan_visited)
        print(junkan_visited[idx] + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 148720
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;
#define MAX 100
typedef pair<int,int> pii;
typedef pair<double,pii> pp;

struct union_find {
    int rnk[MAX], par[MAX];

    union_find(int n) { for(int i = 0; i < n; i++) rnk[i] = 1, par[i] = i; }

    int find(int x) {
        if(x == par[x]) return x;
        else return par[x] = find(par[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(rnk[x] > rnk[y]) par[y] = x;
        else{
            par[x] = y;
            if(rnk[x] == rnk[y]) rnk[y]++;
        }
        return true;
    }
};

inline double cor(vector<double> a, vector<double> b) {
    double ret = sqrt((a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1]) + (a[2]-b[2])*(a[2]-b[2]));
    ret -= a[3]+b[3];
    if (ret <= 0) return 0;
    else return ret;
}

int main(void) {
    int n;
    while (cin>>n && n) {
        vector<vector<double> > v(n, vector<double>(4));
        for (int i = 0; i < n; i++) cin >> v[i][0] >> v[i][1] >> v[i][2] >> v[i][3];
        
        vector<vector<double> > l(n, vector<double>(n));
        priority_queue<pp, vector<pp>, greater<pp> > que;
        union_find uf(n);
        for (int i = 0; i < n-1; i++) {
            for (int j = i+1; j < n; j++) {
                pp t = make_pair(cor(v[i],v[j]), make_pair(i,j));
                que.push(t);
            }
        }
        double ans = 0;
        while (!que.empty()) {
            pp t = que.top();
            que.pop();
            if (uf.unite(t.second.first, t.second.second)) ans += t.first;
        }
        printf("%.3lf\n", ans);
    }
}

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,s[100003],p,a[100003],jie[100003],ans;
const int mod=1e9+7;
int poww(int x,int p)
{
	if(p==0)
		return 1;
	int tmp=poww(x,p/2)%mod;
	tmp=(tmp*tmp)%mod;
	if(p%2==1)
		tmp=(tmp*x)%mod;
	return tmp;
}
int aa(int n,int m)
{
	return jie[n]*poww(jie[n-m],mod-2)%mod;
}
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		s[i]=s[i-1]+a[i],s[i]%=mod;
	}
	jie[1]=1,jie[0]=1;
	for(int i=2;i<=100000;i++)
		jie[i]=jie[i-1]*i%mod;
	for(int i=2;i<=n-1;i++)
	{
		p=aa(i-2,i-2)%mod*aa(n-1,n-1-i)%mod;
		ans=(ans+p*((s[n-1]-s[i-1]-(s[n-i]-s[0])+2*mod)%mod))%mod;
	}
	for(int i=n;i<=n;i++)
	{
		for(int j=1;j<=i-1;j++)
		{
			if(i==n)
				ans=(ans+(a[i]-a[j])%mod*aa(i-j-1,i-j-1)%mod*aa(n-1,n-(i-j+1)))%mod;
			else
				ans=(ans+(a[i]-a[j])%mod*aa(i-j-1,i-j-1)%mod*aa(n-1,n-1-(i-j+1)))%mod;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, T;
    cin >> N;
    cin >> T;
    vector <int> cost;
    int a, b;
    bool flag = false;
    while(N--){
        cin >> a >> b;
        if(b <= T){
            cost.push_back(a);
            flag = true;
        }
    }
    if(flag){
        sort(cost.begin(), cost.end());
        cout << cost[0] << endl;
    }
    else
        cout << "TLE\n"; 
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iomanip>
using ll = long long;
using namespace std;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r) { return l.second < r.second; }
bool greaterPair(const ipair& l, const ipair& r) { return l.second > r.second; }

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define irep(i, n) for (int i = 0; i <= (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rirep(i, n) for (int i = n; i >= 0; --i)
int factorical(int n) {
	int sum = 1;
	for (int i = 1; i <= n; ++i)
	{
		sum *= i;
	}
	return sum;
}

vector<int> divisors(int n) {
	vector<int> res;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}
vector<ll> divisors_ll(ll n) {
	vector<ll> res;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}


void printVector(const vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}

bool pal(string s) {
	int n = s.length() / 2;
			rep(i, n) {
			if (s[i] != s[s.length() - 1 - i]) return false;
		}
			return true;
}

int euclidean_gcd(int a, int b) {
	if (a < b) return euclidean_gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

vector <string> vec_sort_and_del(vector<string> s) {
	std::sort(s.begin(), s.end());
	s.erase(std::unique(s.begin(), s.end()), s.end());
	return s;
}

int GetDigit(int num) {
	int digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

int main() {
	int k, n;
	double std;
	cin >> k >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	};
	vector<int> max_v(n);
	rep(i, n-1) {
		max_v[i] = a[i + 1] - a[i];
	};
	max_v[n-1] = k - a[n-1] + a[0];

	int max;
	max = *max_element(max_v.begin(), max_v.end());

	cout << k - max;

	return 0;
}




Measured memory_bytes: 1792
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    _ = int(input())
    S = input()

    T = []
    cnt = 0
    for s in S:
        if s == ')' and cnt == 0:
            T = ['('] + T + [')']
        elif s == ')' and cnt > 0:
            T = T + [')']
            cnt -= 1
        else:
            T = T + ['(']
            cnt += 1

    T = ['(' if t == ')' else ')' for t in T]
    new_S = T[::-1]

    T = []
    cnt = 0
    for s in new_S:
        if s == ')' and cnt == 0:
            T = ['('] + T + [')']
        elif s == ')' and cnt > 0:
            T = T + [')']
            cnt -= 1
        else:
            T = T + ['(']
            cnt += 1

    T = ['(' if t == ')' else ')' for t in T]
    T = T[::-1]
    print(''.join(T))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38508
#include<bits/stdc++.h>
using namespace std;
int n, a[100005];
int main ()
{
	scanf ("%d", &n);
	for (int i=1; i<=n; i++)
		scanf ("%d", &a[i]);
	sort (a + 1, a + n + 1);
	reverse (a + 1, a + n + 1);
	int x = 0;
	a[0] = a[1];
	while (a[x + 2] > x + 1 && x + 1 < n) x ++;
	int right=0,up=0,k=x;
	while (x<a[k] && k<=n)
		right++,k++;
	up=a[x+1]-x;
	right--;
	if (up%2==1 && right%2==1)
		printf ("Second\n");
	else 
		printf ("First\n");
	return 0;
}


Measured memory_bytes: 640
use proconio::input;

fn main() {
    input! {
        n: usize,
        c: usize,
        k: usize,
        mut t: [usize; n],
    };
    t.sort();

    let mut ans = 0;
    let mut i_l = 0;
    let mut i_r = 0;
    while i_l < n {
        while i_r + 1 < n && t[i_r + 1] <= t[i_l] + k {
            i_r += 1;
        }
        ans += 1;
        i_l += c;
        if i_l > i_r {
            i_l = i_r + 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4176
#include <stdio.h>

int main() {
	int i, N;
	long long int A[100], min = 9999999999, max = 0;

	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
		if (A[i] < min) min = A[i];
		if (A[i] > max) max = A[i];
	}

	printf("%lld\n", max - min);

	return 0;
}

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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c;
    if (a > b){
        k = a;
        a = b;
        b = k;
    }
    if (b > c){
        k = b;
        b = c;
        c = k;
    }
    if (a > b){
        k = a;
        a = b;
        b = k;
    }
    cout << c-a;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int A, B, C, D;
        private void Scan()
        {
            var sc = new Scanner();
            A = sc.NextInt();
            B = sc.NextInt();
            C = sc.NextInt();
            D = sc.NextInt();
        }

        public void Solve()
        {
            Scan();
            Console.WriteLine(Math.Min(A, B) + Math.Min(C, D));
        }


        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 11092
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = 0

for j in range(1, A[0][0] + 1):
    flag = True

    for i in range(1, N):
        if A[0][j] not in A[i][1:]:
            flag = False
            break

    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

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

        int nm = in.nextInt();
        int moves = in.nextInt();
        int health[] = new int[nm];
        long attacks = 0;

        for (int i = 0; i < health.length; i++)
            health[i] = in.nextInt();

        if (moves < nm) {
            Arrays.sort(health);

            for (int i = 0; i < nm - moves; i++)
                attacks += (long) health[i];
        }

        System.out.println(attacks);
        in.close();
    }
}

Measured memory_bytes: 64720
s=list(map(int,input().split()))
fivecon=0
sevencon=0
for i in range(3):
  if s[i]==5:
    fivecon+=1
  elif s[i]==7:
    sevencon+=1
    
if fivecon==2 and sevencon==1:
  print("YES")

else:
  print("NO")


Measured memory_bytes: 2940
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

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);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, M;
int h[2000], w[2000];
signed main() {
    while(cin >> N >> M, N || M) {
        map<int, int> ra, rb;

        rep(i,0,N) cin >> h[i+1];
        rep(i,0,M) cin >> w[i+1];
        rep(i,0,N) h[i+1] += h[i];
        rep(i,0,M) w[i+1] += w[i];

        rep(i,0,N) repq(j,i+1,N) {
            ra[ h[j] - h[i] ]++;
        }
        rep(i,0,M) repq(j,i+1,M) {
            rb[ w[j] - w[i] ]++;
        }

        int ans = 0;
        for(auto x : ra) {
            int val = x.first;
            ans += ra[val] * rb[val];
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main(){

    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<int> > map(501, vector<int>(501, 0)), city(501, vector<int>(501, 0));
    for(int i = 0; i < M; i++){
        int L, R;
        cin >> L >> R;
        map[L][R]++;
    }

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            city[i][j] = city[i][j - 1] + map[i][j];
        }
    }

    vector<pair<int, int> > problem(Q);
    for(int i = 0; i < Q; i++) cin >> problem[i].first >> problem[i].second;

    for(int i = 0; i < Q; i++){
        int ans = 0;
        for(int j = problem[i].first; j <= problem[i].second; j++){
            ans += city[j][problem[i].second] - city[j][problem[i].first - 1];
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3712
def resolve():
    a, b = map(int, input().split())
    count = 0
    for num in range(a, b+1):
        snum = str(num)
        if snum[0] != snum[4] or snum[1] != snum[3]:
            continue
        else:
            count += 1
    print(count)
resolve()

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=200010;
int n,m,nx[MAXN][27];
ll cnt,cur;
char c[MAXN],t[MAXN];
int main () {
	scanf("%s%s",c+1,t+1);
	n=strlen(c+1),m=strlen(t+1);
	for (int i=n+1;i<=2*n;i++) {c[i]=c[i-n];}
	for (int i=0;i<=25;i++) {nx[2*n][i]=2*n+1;}
	for (int i=2*n-1;i>=0;i--) {
		for (int j=0;j<=25;j++) {
			nx[i][j]=((c[i+1]=='a'+j)?i+1:nx[i+1][j]);
		}
	}
	for (int i=1;i<=m;i++) {
		if (nx[cur][t[i]-'a']==2*n+1) {printf("-1");return 0;}
		if (nx[cur][t[i]-'a']>n) {cnt++,cur=nx[cur][t[i]-'a']-n;}
		else {cur=nx[cur][t[i]-'a'];}
	}
	printf("%lld\n",cnt*n+cur);
	return 0;
}

Measured memory_bytes: 21632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sum;
int n,m;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		sum+=i;
		if(sum>=n){
			m=i;
			break;
		}
	}
	for(int i=1;i<=m;i++){
		if(i==sum-n)continue;
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
string S;

bool is_small(string S,int index){
    for(int i=0;i<S.size();i++){
        if(i!=0&&i!=index){
            if('a'<=S[i]&&S[i]<='z'){
            }
            else
            {
            return false;
            }
        }
    }
return true;
}

int main(int argc, char const *argv[])
{
    cin>>S;
bool flag_A=false;
bool flag_C=false;
bool flag_s=false;

flag_A=(S[0]=='A');
int count_c=0;
int index_c=0;
for(int i=2;i<S.size()-1;i++){
    if(S[i]=='C'){
        count_c++;
        if(count_c==1) index_c=i;
    }
}
flag_C=(count_c==1);

flag_s=is_small(S,index_c);

if(flag_A&&flag_C&&flag_s){
    cout<<"AC"<<endl;
}else{
    cout<<"WA"<<endl;
}

return 0;
}


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

int main() {
  int s,n = 0;
  cin >> s;
  if(s%2 ==1){
    n += 1;
  	s = (s-1)/10;
  }
  else {
    s = s/10;
  }
  if(s%2 ==1) {
    n += 1;
  	s = (s-1)/10;
  }
  else {
    s = s/10;
  }
  if(s%2 ==1) {
    n += 1;
  	s = (s-1)/10;
  }
  else {
    s = s/10;
  }
  cout << n << endl;
}

Measured memory_bytes: 256
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    string s;
    cin >> s;

    bool ans = true;
    for(int i = 0; i < s.size(); i++){
        if((i + 1) % 2 == 1){
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
                ans = false;
                break;
            }
        }
        else{
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
                cerr << i << "\n";
                ans = false;
                break;
            }
        }
    }

    cout << (ans ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    int Asum = 0;
    int Bsum = 0;
    for(int i = 0;i < N;i++){
        cin >> A.at(i);
    }
    for(int i = N - 1;0 < i;i--){
        for(int k = 0;k < i;k++){
            if(A.at(i) > A.at(k)){
                int s = 0;
                s = A.at(i);
                A.at(i) = A.at(k);
                A.at(k) = s;
            }
        }
    }
                for(int i = 0;i < N;i +=2){
                Asum += A.at(i);
                if(i + 1 < N){
                    Bsum += A.at(i + 1);
                }
                    else{
                        break;
                    }
            }
    cout << Asum - Bsum << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>

using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef long long  ll;

#define MOD 1000000007


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

    if(a>=3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, A, B;

int main() {
	cin >> A >> B >> N;
	long long T = A * min(N, B - 1LL) / B;
	cout << T << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
inline int fpow(int a,int b) {
	int ret=1;
	while (b) {
		if (b&1) ret*=a;
		b>>=1,a*=a;
	}
	return ret;
}
int main() {
	int n;
	scanf("%d",&n);
	printf("%d",fpow(n,3));
	return 0;
}

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

signed main(){
  int H,W;
  cin>>H>>W;
  string A[H];
  rep(i,H)cin>>A[i];
  rep(i,H)cout<<A[i]<<endl<<A[i]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    vector<int> a, b;
    while(1){
        int A, B; cin>>A>>B;
        if(A == 0 && B == 0) break;
        a.eb(A);
        b.eb(B);
    }

    for(int j=0; j<a.size(); j++){
        vector<int> ans;
        for(int i=a[j]; i<=b[j]; i++){
            if(i % 4 == 0){
                if(i % 100 == 0){
                    if(i % 400 == 0){
                        ans.eb(i);
                    }
                }
                else{
                    ans.eb(i);
                }
            }
        }

        if(ans.size() == 0){
            cout << "NA" << endl;
        }
        else{
            for(auto i:ans){
                cout << i << endl;
            }
        }

        if(j != a.size() - 1){
            cout << endl;
        }
    }
}


Measured memory_bytes: 3048
// Problem : C - Vacation
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 1e5 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent

struct Vacation {
	int Swim, bugs, homework;
};
int n;
vector<Vacation> v;
//int mem[N][4];
int dp[2][4];
/*int solve(int idx = 0, int prev = 0)
{
	if (idx == n)
		return 0;
	int& ret = mem[idx][prev];
	if (~ret)return ret;
	ret = 0;
	if (prev != 1)
		ret = max(ret, solve(idx + 1, 1) + v[idx].Swim);
	if (prev != 2)
		ret = max(ret, solve(idx + 1, 2) + v[idx].bugs);
	if (prev != 3)
		ret = max(ret, solve(idx + 1, 3) + v[idx].homework);

	return ret;
}*/
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	//clr(mem, -1);
	cin >> n;
	v = vector<Vacation>(n);
	for (int i = 0; i < n; i++)
		cin >> v[i].Swim >> v[i].bugs >> v[i].homework;
	//cout << solve() << endl;

	//baseCase
	dp[n%2][1] = dp[n%2][2] = dp[n%2][3] = 0;


	for (int idx = n-1; idx >=0; idx--) {
		int& ret1 = dp[idx%2][1];
		int& ret2 = dp[idx%2][2];
		int& ret3 = dp[idx%2][3];
		ret1 = ret2 = ret2 = 0;;

		ret1 = max(ret1, dp[(idx + 1)%2][2] + v[idx].Swim);
		ret1 = max(ret1, dp[(idx + 1)%2][3] + v[idx].Swim);
									
		ret2 = max(ret2, dp[(idx + 1)%2][1] + v[idx].bugs);
		ret2 = max(ret2, dp[(idx + 1)%2][3] + v[idx].bugs);
									
		ret3 = max(ret3, dp[(idx + 1)%2][1] + v[idx].homework);
		ret3 = max(ret3, dp[(idx + 1)%2][2] + v[idx].homework);

	}

	cout << max({ dp[0][1],dp[0][2],dp[0][3] }) << endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	unordered_map<int,int>m;
	int64_t ans=0;
	for(int i=1;i<=n;++i){
		int a; cin>>a;
		++m[a+i];
		ans+=m[i-a];
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 18332
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, k;

int main(){
	cin >> n >> k;
	
	double ans = 0;
	
	for(int i = 1; i <= n; i++){
		if(k <= i){
			ans += 1;
		}
		else{
			double cnt = 1.0;
			int j = i;
			while(j < k){
				j *= 2;
				cnt /= 2.0;
			}
			ans += cnt;
		}
	}
	
	printf("%.10f\n", ans/n);
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmpArray = br.readLine().split(" ");
		int numOfIsland = Integer.parseInt(tmpArray[0]);
		int numOfShip = Integer.parseInt(tmpArray[1]);
		
		ArrayList<Integer> shipFrom1 = new ArrayList<Integer>();
		ArrayList<Integer> shipToN = new ArrayList<Integer>();
		
		boolean result = false;
		
		for(int i = 0; i < numOfShip ; i++){
//			tmpArray = br.readLine().split(" ");
//			int a = Integer.parseInt(tmpArray[0]);
//			int b = Integer.parseInt(tmpArray[1]);
//			
			int a = 0;
			int b = 0;
			int num = 0;
			int tmp = br.read();
			int flag = 0;
			//a bの読み込み
			while(tmp != -1 && tmp != 10 && tmp != 13){
	            num = 0;
	            while(tmp >= '0' && tmp <= '9'){
	                num = num * 10 + (tmp - '0');
	                tmp = br.read();
	            }
	            if(tmp == -1){
	                break;
	            }
	            if(flag == 0){
	            	a = num;
	            	tmp = br.read();
	            }
	            else b = num;
//	            tmp = br.read();
	            flag++;
	        }
			
			//bの読み込み
//			num = 0;
//			tmp = br.read();
//			while(tmp != -1 && tmp != 32 && tmp != 10 && tmp != 13){
//	            num = 0;
//	            while(tmp >= '0' && tmp <= '9'){
//	                num = num * 10 + (tmp - '0');
//	                tmp = br.read();
//	            }
//	            if(tmp == -1){
//	                break;
//	            }
//	            b = num;
//	            tmp = br.read();
//	        }
//			
//			System.out.println(a + " " + b);
			
			if(a == 1){
				shipFrom1.add(b);
			}
			
			else if(b == numOfIsland){
				shipToN.add(a);
			}
		}
		
		//配列に変換
		Integer[] array1 = shipFrom1.toArray(new Integer[0]);
		Arrays.sort(array1);
		Integer[] array2 = shipToN.toArray(new Integer[0]);
		Arrays.sort(array2);

		if(array1.length <= array2.length){
			for(int i = 0; i < array1.length ; i++){
				if(Arrays.binarySearch(array2, array1[i]) >= 0){
					result = true;
					break;
				}
			}
		}
		else {
			for(int i = 0; i < array2.length ; i++){
				if(Arrays.binarySearch(array1, array2[i]) >= 0){
					result = true;
					break;
				}
			}
		}
		
//		
//		if(shipFrom1.size() <= shipToN.size()){
//			Iterator<Integer> it = shipFrom1.iterator();
//			for(int i = 0; i < shipFrom1.size() ; i++){
//				if(shipToN.contains(it.next())){
//					result = true;
//					break;
//				}
//			}
//		}
//		else {
//			Iterator<Integer> it = shipToN.iterator();
//			for(int i = 0; i < shipToN.size() ; i++){
//				if(shipFrom1.contains(it.next())){
//					result = true;
//					break;
//				}
//			}
//		}
//		
		if(result){
			System.out.println("POSSIBLE");
		}
		else {
			System.out.println("IMPOSSIBLE");
		}
	}

}


Measured memory_bytes: 33436
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
int main()
{
fast_io
string s;
cin>>s;
if(s[0]=='7'||s[1]=='7'||s[2]=='7')
cout<<"Yes";
else
cout<<"No";
  return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#define ll long long
int main(){
    ll h, n, i = 0, sum = 0;
    scanf("%lld%lld",&h,&n);
    ll a[n];
    for(; i < n; i++){
        scanf("%lld",&a[i]);
        sum += a[i];
    }
    if(sum >= h)
        puts("Yes");
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 896
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Majk
 */

#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first
#define y second
constexpr int MOD = 1000000007;

typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned int ui;

template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;

struct input {
	std::istream &cin;
	explicit input(std::istream &cin) :cin(cin){}
	template <typename T> operator T() { T t; cin >> t; return t; }
};
#define $ input{cin}

int logceil(ll x) {int b=0;while(x){x>>=1;++b;}return b;}

namespace std {
    template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector<vector<T>>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector<vector<T>>>(a,vector<vector<T>>(b,vector<T>(c,t))){}};

// #include "../l/mod.h"

class C {
public:
    void solve(istream& cin, ostream& cout) {
		int N, T; cin >> N >> T;
		vector<int> P(N); cin >> P;
		int ans = 0;
		for (int i = 1; i < N; ++i) {
			ans += min(T, P[i]-P[i-1]);
		}
		cout << ans + T << endl;
    }
};


int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	C solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}



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

long long gcd(long long a,long long b){
  long long c=max(a,b);
  long long d=min(a,b);
  long long e=c%d;
  if(e==0)return d;
  else{
    return gcd(d,e);
  }
}

int main() {
  int N;
  cin >>N;
  vector<long long> A(N);
  vector<long long> x(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
    if(i==0)x[0]=A[0];
    else{
    x[i]=gcd(A[i],x[i-1]);
    }
  }
  vector<long long> y(N);
  for(int i=N-1;i>=0;i--){
    if(i==N-1)y[i]=A[i];
    else{
      y[i]=gcd(A[i],y[i+1]);
    }
  }
  long long ans=0;
  for(int i=1;i<N-1;i++){
    ans=max(ans,gcd(x[i-1],y[i+1]));
  }
  ans=max(ans,max(x[N-2],y[1]));
  cout << ans;
  return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

map<long long,int> S;
multiset<pair<int,int>> M;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, D, A, X, H;
	long long ans=0, tot=0;
	for(cin>>N>>D>>A;N--;) {
		int X, H;
		cin>>X>>H;
		M.insert({X,H});
	}
	while(M.size()) {
		tie(X,H)=*M.begin();
		M.erase(M.begin());
		while(S.size() && S.begin()->first<X) {
			tot-=S.begin()->second;
			S.erase(S.begin());
		}
		if(H>A*tot) {
			S[X+2LL*D]+=(H-A*tot+A-1)/A;
			ans+=(H-A*tot+A-1)/A;
			tot+=(H-A*tot+A-1)/A;
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 11264
#include <cmath>
#include <iostream>
#define INF 1000000000
using namespace std;

int main(int argc, char *argv[]) {
  int n, maxv = -INF, minv, r;
  cin >> n;
  cin >> minv;

  for (int i = 1; i < n; ++i) {
    cin >> r;
    maxv = max(maxv, r - minv);
    minv = min(minv, r);
  }
  cout << maxv << endl;
  return 0;
}



Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890l
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define space " "
#define cbr cout << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll a, b, c;
int main()
{
	cin>>a>>b>>c;
	cout << min(b/a,c) << "\n";
}


Measured memory_bytes: 256
List=[int(i) for i in input().split()]
ans = 0

counter = 1

for i in range(20):
    if List[1] == 0:
      break
    if counter >= int(List[2]) + 0.5:
      break       
    if counter % int(List[0]) == 0:
      ans += int(List[1])
    
    counter += 1
print(ans)

Measured memory_bytes: 3060
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    int d, n;
    scanf("%d%d", &d, &n);
    int ans = 1;
    for (int i = 0; i < d; i++) {
        ans *= 100;
    }
    if (n < 100) {
        ans *= n;
    } else {
        ans *= 101;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define MAXN 100005
#define MOD (1000000007)
long long fac[MAXN];
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    fac[0]=fac[1]=1;
    for(int i=2;i<=max(n,m);i++)
    {
        fac[i]=fac[i-1]*i%MOD;
    }
    long long ans;
    if(n==m)
        ans=fac[n]*fac[m]%MOD*2%MOD;
    else if(abs(n-m)==1)
        ans=fac[n]*fac[m]%MOD;
    else
        ans=0;
    cout<<ans;
}


Measured memory_bytes: 1024
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = input().rstrip('\n')
    S = 0
    for n in N:
        S = (S + int(n))%9
    if S:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 68468