akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    mint sum(0);
    vll a(n);
    REP(i,n){
        cin >> a[i];
        sum += mint(a[i]);
    }
    mint ans(0);
    REP(i,n){
        mint t = sum - mint(a[i]);
        ans += t * mint(a[i]);
    }
    ans /= mint(2);
    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 4780
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    ll x;
    cin >> x;

    ll a[51] = { 1 }, b[51] = { 1 };
    for (int i = 0; i < n; i++) {
        a[i + 1] = a[i] * 2 + 3;
        b[i + 1] = b[i] * 2 + 1;
    }

    ll r = 0;
    for (int i = n; i > 0; i--) {
        if (x < 1) {
            break;
        } else if (x < 1 + a[i - 1]) {
            x--;
        } else if (x < 1 + a[i - 1] + 1) {
            r += b[i - 1];
            break;
        } else if (x < a[i] - 1) {
            r += b[i - 1] + 1;
            x -= 1 + a[i - 1] + 1;
        } else {
            r += b[i];
            break;
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    c = [int(i) for i in input().split()]
    a.sort()
    b.sort()
    c.sort()

    cnt = 0
    for i in range(n):
        v = b[i]
        idx_a = bisect_left(a, v) 
        idx_b = bisect_right(c, v)
        cnt += idx_a * (n-idx_b)     
    print(cnt)
main()

Measured memory_bytes: 22592
# pypy
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

R, C, K = map(int, readline().split())
rcv = list(map(int, read().split()))
rc2v = {}
for rr, cc, vv in zip(rcv[::3], rcv[1::3], rcv[2::3]):
    rc2v[(rr, cc)] = vv

dp = [[0]*4 for c in range(C+1)]
for r in range(1, R+1):
  for c in range(1, C+1):
    v = rc2v[(r, c)] if (r, c) in rc2v else 0
    dp[c][0] = max(dp[c-1][0], max(dp[c]))
    dp[c][1] = max(dp[c-1][1], dp[c][0] + v)
    dp[c][2] = max(dp[c-1][2], dp[c-1][1] + v)
    dp[c][3] = max(dp[c-1][3], dp[c-1][2] + v)

print(max(dp[-1]))

Measured memory_bytes: 162464
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << std::setprecision(10) << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()

signed main() {
	int n;
	std::cin >> n;
	std::vector<double> v(n);
	rep(i,n) std::cin >> v[i];
	std::sort(all(v));
	double av = v[0];
	rep(i,n-1) {
		av = (av+v[i+1])/2;
	}
	print(av);

	return 0;
}


Measured memory_bytes: 256
/*
* @Author: Kabid
* @Date:   {{create_time}}
* @Last Modified by:   Kabid
* @Last Modified time: 2020-09-19 13:28:41
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');

int t;       //test cases
ll i, j;	 //iterators
ll n, k , p, q,  d, m, c, c1, c2, d1; //variables;
ll mx = LLONG_MIN, mn = LLONG_MAX;		// max min
string s, s1, s2;		// string
ll a [1000001], b [200001] , mox [200001];	// array
map <int, int > mp;
vector <vector<ll>> vc;
vector <ll> v;
set <ll> st;
bool r;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cin >> t; q = t;
	t = 1;
	while (t--) {


		/*cin >> s;
		n = s.size();
		for (i = n - 1; i > 0; i--) {
			for (j = i - 1; j >= 0; j--) {
				if (s[i] > s[j]) {
					swap(s[i], s[j]);
					cout << s << endl;
					break;
				}
			}
			if(j!=-1) break;
		}
		if (i == 0) {
			cout << "no answer" << endl;
		}*/
		cin >>n>> s;
		if(n%2){
			cout<<"No"<<endl;
		}
		else{
			for(i=0;i<n/2;i++){
				if(s[i]!=s[n/2+i]){
					cout<<"No"<<endl;
					break;
				}
			}
			if(i==n/2){
				cout<<"Yes"<<endl;
			}
		}
	}
	return 0;

}


Measured memory_bytes: 3592
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll n;cin>>n;
    string s;cin>>s;
    ll cnt=0;
    ll i=0;
    while(i<n)
    {
        ll j=i;
        while(j<n and s[j]==s[i])j++;
        cnt++;
        i=j;
    }
    cout<<cnt<<endl;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<string> s(N);
  for(int i = 0; i < N; i++){cin >> s.at(i);}
  int M;
  cin >> M;
  vector<string> t(M);
  for(int i = 0; i < M; i++){cin >> t.at(i);}

  vector<int> X(N + M);
  int v = 0; // v個目の文字列について
  string u;// 文字列uの存在する数を考える
  for(int i = 0; i < N; i++)
  {
    u = s.at(i);
    for(int j = 0; j < N; j++)
    {
      if(s.at(j) == u){X.at(v)++;}
    }
    for(int j = 0; j < M; j++)
    {
      if(t.at(j) == u){X.at(v)--;}
    }
    v++;
  }
  sort(X.rbegin(), X.rend());
  if(X.at(0) < 0){cout << '0' << endl;}
  else{cout << X.at(0) << endl;}
}

Measured memory_bytes: 3572
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if ((A + B) % 3 == 0 || A % 3 == 0 || B % 3 == 0) {
            System.out.println("Possible");
        } else {
            System.out.println("Impossible");
        }
    }
}

Measured memory_bytes: 23124
def examA():
    R = I()
    ans = R*2*3.141592
    print(ans)
    return

def examB():
    N, M = LI()
    A = LI()
    S = sum(A)
    if N>=S:
        ans = N-S
    else:
        ans = -1
    print(ans)
    return

def examC():
    N = I()
    A = LI()
    ans = [0]*N
    for i in range(N-2,-1,-1):
        ans[A[i]-1] +=1
    for v in ans:
        print(v)
    return

def examD():
    N, K = LI()
    S = [0]*(N+2)
    for i in range(1,N+1):
        S[i+1] = S[i] + i
    #print(S)
    ans = 0
    for i in range(K,N+2):
        cur = (S[N+1] - S[N-i+1]) - (S[i] - S[0]) +1
        ans += cur
        ans %= mod
        #print(cur)

    print(ans)
    return

def examE():
    N = I()
    A = LI()

    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 10108
// g++ -std=c++11 -O2 -Wall -Wl,--stack=268435456

#include <bits/stdc++.h>
using namespace std;

typedef vector<int>        vi;
typedef vector< vi >       vvi;
typedef pair<int, int>     pi;
typedef vector< pi >       vpi;

typedef long long          ll;
typedef vector<ll>         vl;
typedef vector< vl >      vvl;

typedef pair<ll, ll>       pl;
typedef vector< pl >       vpl;
typedef vector< vpl >      vvpl;

const int LARGE_INT = 1000000007;
const ll LARGE_LONG = 1L << 60;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = (int)(a); i < (int)(b); i++)

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, lb, up, i;
    ll m, v, p;
    cin >> n >> m >> v >> p;
    vl a(n);
    REP(i, 0, n) { cin >> a[i]; }
    sort(a.rbegin(), a.rend());
    
    lb = p-1;  up = n-1;  // lb <= index of the last feasible problem <= up, lb known feasible
    while (lb < up) {
        int t = (lb+up+1)/2;
        ll total = (n-v) * m;
        //cout << lb << "," << up << "," << total << "," << t << "," << a[t] << endl;
        for(i=p-1; i<t; i++) { // whether a[p-1] to a[t-2] can be made equal to a[t-1]+m
            if (a[i] - a[t] > m)    break;    // don't work
            total -= a[i] - a[t];
            if (total < 0)        break;
        }
        if (i == t)   lb = t;
        else          up = t - 1;
    }
    cout << lb+1 << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> B(N, 0);
    for(int i = 0; i < N - 1; i++) {
        int j;
        cin >> j;
        B[j-1]++;
    }

    for(auto x: B) {
        cout << x << endl;
    }
}


Measured memory_bytes: 3996
lmap = lambda f, s: list(map(f, s))
n, m = map(int, input().split())
a = [lmap(int, input().split()) for i in range(n)]
a = lmap(lambda xs: xs + [sum(xs)], a)
a.append(lmap(sum, zip(*a)))
for xs in a: print(*xs)


Measured memory_bytes: 6248
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;

namespace ProjectContest
{
    class Test
    {
        static void Main()
        {
            var abcd = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt64);
            long a = abcd[0], b = abcd[1], c = abcd[2], d = abcd[3];
            long kq = b-a+1;
            long t1 = b / c - (a % c == 0 ? a / c : a / c + 1) + 1;
            long t2 = b / d - (a % d == 0 ? a / d : a / d + 1) + 1;
            long cd = BCNN(c, d);
            long t3= b / cd - (a % cd == 0 ? a / cd : a / cd + 1) + 1;
            Console.WriteLine(kq - t1 - t2 + t3);
        }

        private static long BCNN(long c, long d)
        {
            long x = c, y = d;
            while (c * d != 0)
            {
                if (c >= d) c %= d;
                else d %= c;
            }
            return x * y / (c + d);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_N=1e5+5;
const int MOD=1000000007;

int n;
vector<int> G[MAX_N];
priority_queue<pii,vector<pii>,less<pii>> pq;
int fa[MAX_N];
ll dp[MAX_N][2];

void dfs(int now, int pa, int d)
{
	fa[now]=pa;
	auto it=find(G[now].begin(),G[now].end(),pa);
	if(it!=G[now].end()) G[now].erase(it);
	if(!G[now].empty()) pq.push({d,now});
	for(auto &i:G[now])
		dfs(i,now,d+1);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) dp[i][0]=dp[i][1]=1;
	for(int i=0,t1,t2;i<n-1;i++)
	{
		scanf("%d%d",&t1,&t2);
		G[t1].emplace_back(t2);
		G[t2].emplace_back(t1);
	}
	dfs(1,-1,0);
	while(!pq.empty())
	{
		int id=pq.top().S;
		pq.pop();
		for(auto &i:G[id])
		{
			dp[id][0]=(dp[id][0]*(dp[i][0]+dp[i][1]))%MOD;
			dp[id][1]=(dp[id][1]*dp[i][0])%MOD;
		}
	}
	printf("%lld\n",(dp[1][0]+dp[1][1])%MOD);
	return 0;
}



Measured memory_bytes: 14196
#include<iostream>
#include<string>
using namespace std;
int solve(int arr[],int n,int x)
{
	int tmp=0;
	for(int i=0;i<n;i++)
	{
		tmp+=x%arr[i];
	}
	return tmp;
}
int main()
{
	int n;
	cin>>n;
	int arr[n];
	long int ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		ans+=arr[i]-1;
	}
	cout<<ans<<"\n";
	
}

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

using namespace std;
const int N = 100 + 5;

char mat[N][N];

int main() {
	int a, b, cnta = 1, cntb = 1;

	cin >> a >> b;
	for (int i = 0; i < 100; i++)
		for (int j = 0; j < 100; j++)
			if (j < 50) mat[i][j] = '.';
			else mat[i][j] = '#';

			for (int i = 0; i < 100; i += 2)
				for (int j = 0; j < 48; j += 2) {
					if (cntb == b) break;
					mat[i][j] = '#'; cntb++;
				}
			for (int i = 0; i < 100; i += 2)
				for (int j = 51; j < 98; j += 2) {
					if (cnta == a) break;
					mat[i][j] = '.'; cnta++;

				}
			printf("100 100\n");
			for (int i = 0; i < 100; i++) {
				for (int j = 0; j < 100; j++) {
					printf("%c", mat[i][j]);
				}
				printf("\n");
			}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    int n;
    double dp[301][301][301];
    double sol(int zero,int one,int two,int three)
    {
        if (one+two+three==0)
            return 0;
        if (dp[one][two][three]>-0.5)
            return dp[one][two][three];
        double &ret = dp[one][two][three];
        /*ret=0;
        // Pick 0, p=zero/n
        // dp[one][two][three] += p*dp[one][two][three]+p
        // dp[one][two][three] += p/(1-p)
        double p = ((double)zero)/n;
        ret+=p/(1-p);
        */
        double x = 0;
        double tot = one+two+three;
        double p;
        // Pick 1, p=one/tot
        // dp[one][two][three] += p*dp[one-1][two][three] + p
        if (one) {
            p = ((double)one)/n;
            x += p*sol(zero+1,one-1,two,three);
        }

        // Pick 2, p=two/tot
        // dp[one][two][three] += p*dp[one+1][two-1][three] + p
        if (two) {
            p = ((double)two)/n;
            x += p*sol(zero,one+1,two-1,three);
        }

        // Pick 3, p=three/tot
        // dp[one][two][three] += p*dp[one][two+1][three-1] + p
        if (three) {
            p = ((double)three)/n;
            x += p*sol(zero,one,two+1,three-1);
        }
        x+=1;
        ret = x*n/tot;
        return ret;
    }
    int main()
    {
        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        cin>>n;
        int cnt[5]={0};
        for (int i=0;i<n;i++)
        {
            int x;
            cin>>x;
            cnt[x]++;
        }
        for (int i=0;i<=n;i++)
            for (int j=0;j<=n;j++)
                for (int k=0;k<=n;k++)
                    dp[i][j][k]=-2;
        cout<<setprecision(10)<<fixed<<sol(cnt[0],cnt[1],cnt[2],cnt[3])<<endl;
    }


Measured memory_bytes: 213376
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;

int n, m, d;

signed main() {
	cin >> n >> m >> d;
	
	double ans = (m - 1) * 2 * (n - d) / (double)(n * n);
	if (d == 0) ans /= 2;
	
	printf("%.14f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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




int sh, sm, eh, em, k;

int main() {

	cin >> sh >> sm >> eh >> em >> k;

	em -= k;

	if (em < 0) {
		eh--;
		em += 60;
	}

	cout << (eh - sh) * 60 + (em - sm) << endl;

}


Measured memory_bytes: 3636
//gauravsinghh
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 1000000000
#define lim 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
int main(){
    IOS
    //io_set();
 	ll r;
 	cin >> r;
 	cout << r * r << endl;	   
    return 0;
} 


Measured memory_bytes: 256
using System;
class Tenka1_2019_B
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();
        int K = int.Parse(Console.ReadLine());


        char c = S[K - 1];

        char[] ans = new char[N];

        for (int i = 0; i < S.Length; i++)
        {
            ans[i] = (S[i] == c) ? c : '*';
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
import sys

read = sys.stdin.buffer.read


def main():
    N, T, *AB = map(int, read().split())
    D = [(a, b) for a, b in zip(*[iter(AB)] * 2)]

    D.sort()

    dp = [0] * T
    ans = 0
    for i, (a, b) in enumerate(D[:-1]):
        for t in range(T - 1, -1, -1):
            if t >= a and dp[t] < dp[t - a] + b:
                dp[t] = dp[t - a] + b

        if ans < dp[T - 1] + D[i + 1][1]:
            ans = dp[T - 1] + D[i + 1][1]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 73944
import math
R,G,B,N = map(int,input().split())
ans = 0
r,g,b = 0,0,0
for i in range(math.floor(N/R)+1):
    for j in range(math.floor((N-i*R)/G)+1):
        if (N-R*i-G*j)%B == 0:
            ans += 1
print(ans)

Measured memory_bytes: 3060
K,N = map(int,input().split())
A = list(map(int,input().split()))
c = 0
for i in range(0,len(A)-1):
    c = max(c,(A[i+1]-A[i]))
if c >= (K - A[-1]+A[0]):
    print(K-c)
else:
    print(A[-1]-A[0])

Measured memory_bytes: 26420
#include<cstdio>
#include<queue>

using namespace std;

int main()
{
	int ap, bp, turnnum, acard, bcard;
	ap = bp = 0;
	queue<int>adeck, bdeck;
	while (1)
	{
		scanf("%d", &turnnum);
		if (turnnum == 0)break;

		for (int i = 0; i < turnnum; i++)
		{
			scanf("%d %d", &acard, &bcard);
			adeck.push(acard);
			bdeck.push(bcard);
		}
		while (adeck.empty() == false)
		{
			if (adeck.front()>bdeck.front())
			{
				ap += adeck.front() + bdeck.front();
				adeck.pop();
				bdeck.pop();
			}
			else if(adeck.front() < bdeck.front())
			{
				bp += adeck.front() + bdeck.front();
				adeck.pop();
				bdeck.pop();
			}
			else
			{
				ap += adeck.front();
				bp += bdeck.front();
				adeck.pop();
				bdeck.pop();
			}
		}
		printf("%d %d\n", ap, bp);
                ap=0;bp=0;
	}

}

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

char s[8][9];
int main() {
	rep(i, 8)scanf("%s", s[i]);
	puts("90");
	rep(i, 8) {
		for (int j = 7; j >= 0; j--)cout << s[j][i];
		cout << endl;
	}
	puts("180");
	for (int i = 7; i >= 0; i--) {
		for (int j = 7; j >= 0; j--)cout << s[i][j];
		cout << endl;
	}
	puts("270");
	for (int i = 7; i >= 0; i--) {
		rep(j, 8)cout << s[j][i];
		cout << endl;
	}
}

Measured memory_bytes: 3140
H,W,K = map(int,input().split())
cake = []
ls = []
zeroh = [0]*H
for i in range(H):
    c = input()
    tmp = c.rfind("#")
    if tmp == -1:
        zeroh[i] = 1
        tmp = W-1
    ls.append(tmp)
    cake.append(list(c))
ans = []
num = 1
split = [0]*W
for i in range(H):
    if zeroh[i]:
        ans.append(split)
    if not zeroh[i]:
        split = []
        for j in range(W):
            split.append(num)
            if cake[i][j] == "#" and j<ls[i]:
                num += 1
        num += 1
        ans.append(split)

notzeropoint = 0
for i in range(H):
    if ans[i][0] != 0:
        notzeropoint = i
        break

for i in range(notzeropoint):
    for j in range(W):
        ans[i][j] = ans[notzeropoint][j]


for i in range(H):
    print(*ans[i])

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

int main(){
    int n;
    int taroP = 0;
    int hanakoP = 0;
    string taroC,hanakoC;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> taroC >> hanakoC;
        if(taroC < hanakoC){
            hanakoP += 3;
        }else if(taroC > hanakoC){
            taroP += 3;
        }else{
            taroP++; hanakoP++;
        }
    }
    cout << taroP << " " << hanakoP << endl;
}

Measured memory_bytes: 3156
#include <cstdio>
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <string> 
#include <sstream>  
#include <vector> 
#include <time.h>
#include <algorithm>
using namespace std;
int cc(string c,int index,int ans = 0){
    if(index < 0)return -1;
    return c.at(index) == 'c' ? ans : cc(c,index-1,ans+1);
}
int main(void){
    int H,W;
    cin >> H >> W;
    string c,ans = "";
    for(int i = 0;i < H;i++){
        cin >> c;  
        stringstream ss;
        for (int i2 = 0; i2 < W; i2++){  
            i2 == 0 ? ss << cc(c,i2) : ss << " " << cc(c,i2); ;
        }
        ans += ss.str();
        if(i < H - 1)ans += "\n";
    }
    cout << ans << endl;
}

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

#define ll long long
#define pb push_back
#define st first
#define sc second
#define mp make_pair

using namespace std;

const int e = 2*1e6 + 69;

ll a[e];
ll kt[e];

int main()
{
    int n;
    cin >>n ;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        kt[a[i]] ++;
    }
    ll dem =0;
    for(int i=1; i<=n; i++){
        ll ans = 0;
        for(int j=1; j*j<=a[i]; j++){
            if(a[i] % j == 0){
                ans += kt[j];
                if(j != a[i]/j){
                    ans += kt[a[i]/j];
                }
            }
        }
        if(ans == 1) dem ++;
    }
    cout << dem;
}



Measured memory_bytes: 13000
#include <iostream>

using namespace std;

int main(){
    int x, y;
    while(true){
        cin >> x >> y;
        if(x==0 && y==0)
            break;
        if(x>y)
            cout << y << ' ' << x << endl;
        if(x<y)
            cout << x << ' ' << y << endl;
        if(x==y)
            cout << x << ' ' << y << endl;
    }
    return 0;
}

Measured memory_bytes: 2992
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map(String::toInt)

    for (i in 1..10000) {
        if ((i * 0.08).toInt() == a && (i * 0.1).toInt() == b) {
            println(i)
            return
        }
    }
    println(-1)
}

Measured memory_bytes: 39904
n = int(input())

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= int(i)
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(n)
  return table

a = [1]*(n+1)
for i in range(3,n+1,2):
    il = prime_decomposition(i)
    il_unique = list(set(il))
    ans = 1
    for j in il_unique:
        ans *= (il.count(j)+1)
    a[i] = max(a[i],ans)


print(a.count(8))

Measured memory_bytes: 3188
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
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> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,x,t;cin>>n>>x>>t;
  cout<<(n+x-1)/x*t<<endl;
  return 0;
}

Measured memory_bytes: 3652
package main

import (
	"fmt"
)

func main() {
	var n, x, m int
	var s string
	fmt.Scan(&n, &s)
	for _, c := range s {
		// fmt.Println(c)
		if c == 'I' {
			x++
			if x > m {
				m = x
			}
		} else {
			x--
		}
	}
	fmt.Println(m)
}


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

int main(){
    ll n; cin >> n;
    ll ans = 0;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    rep(i,n-1){
        ans += (a[(i+1)/2]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    for(int i=2;i<N;i++){
        if(S[i-2] == 'A' && S[i-1] == 'B' && S[i] == 'C')
            ans++;
    }

    cout << ans << endl;

}

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

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

    int N; cin >> N;
    string S; cin >> S;

    int ans = 0;
    char prev = 'A';
    for (int i = 0; i < N; ++i) {
        if (S[i] != prev) ans++;
        prev = S[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
using System;
using System.Linq;

namespace arc089_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] now = new int[] { 0,0 }; int time = 0;
            bool ret = true;
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int move = Math.Abs(now[0] - x[1]) + Math.Abs(now[1] - x[2]);
                if (move <= x[0] - time && (move - (x[0] - time)) % 2 == 0)
                {
                    now[0] = x[1]; now[1] = x[2];
                    time = x[0];
                }
                else
                {
                    ret = false;
                }
            }
            Console.WriteLine(ret ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 17456
import sys
input = lambda: sys.stdin.readline().rstrip()

mod = 10**9 + 7


class Mod:
    """
    comb = Mod(1000000)
    print(comb(5, 3))  # 5C3
    """

    def __init__(self, n_max, mod=10**9 + 7):
        self.mod = mod
        self.modinv = self.__make_modinv_list(n_max)
        self.fac, self.facinv = self.__make_factorial_list(n_max)

    def comb(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def factorial(self, n):
        return self.fac[n]

    def factorial_inv(self, n):
        return self.facinv[n]

    def __make_factorial_list(self, n):
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def __make_modinv_list(self, n):
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
        return modinv


def solve():

    n, k = map(int, input().split())
    k = min(n - 1, k)
    m = Mod(n)

    ans = 0
    for i in range(k + 1):
        ans += m.comb(n - 1, n - 1 - i) * m.comb(n, i)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    solve()


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

ll gcd(ll a,ll b){
    ll c,d,e;
    c=max(a,b);
    d=min(a,b);
    while(1){
        c=c%d;
        if(c==0){
            break;
        }
        e=d;
        d=c;
        c=e;
    }
    return d;
}

int main(){
    ll n,k;
    cin >> n >> k;
    ll a,g,ma=0;

    rep(i,n){
        cin >> a;
        if(i==0){
            g=a;
            ma=a;
        }
        else{
            g=gcd(g,a);
            ma=max(ma,a);
        }
    }

    if(k%g==0 and k<=ma){
        cout << "POSSIBLE" << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
    


    

    return 0;
}

Measured memory_bytes: 3592
#include<iostream>

using namespace std;

int p, q, a, n;


int dfs(int nume, int deno, int divide_num, int now_deno)
{
    if(p * deno == q * nume)return 1;
    if(p * deno  < q * nume)return 0;
    if(divide_num == n)return 0;

    int ret = 0;

    for(int i = now_deno; deno * i <= a; ++i)
    {
        //i????¬?????¶?????????°?????????(?????????1??§??????)
        //deno???????????????
        //nume * i + deno ??? ????????????????????°????£?????¶???????????????????
        //deno * i        ??? ????????????????????°????£?????¶???????????????????
        //?´?????????????????????????
        ret += dfs(nume * i + deno, deno * i, divide_num + 1, i);
    }

    return ret;
}

int main()
{
    while(cin >> p >> q >> a >> n, p)
        cout<< dfs(0, 1, 0, 1) << endl;
}

Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    int r, d, x;
    cin >> r >> d >> x;
    
    int xi = x;
    for (int i = 1; i <= 10; ++i) {
        xi = r*xi - d;
        cout << xi << endl;
    }
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a < 0){
        if(b >= 0){
            cout << "Zero" << endl;
        } else{
            if((b - a + 1) % 2 == 0 ){
                cout << "Positive" << endl;
            } else {
                cout << "Negative" << endl;
            }
        }
    } else if( a == 0){
        cout << "Zero" << endl;
    } else{
        cout << "Positive" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cWeightEdges=vector<vector<pair<int,int>>>;
using cEdges=vector<vector<int>>;

int main() {
	int n,q;
	cin>>n>>q;
	long long ini=0;
	vector<long long> a(n,ini);
	int backet=sqrt(n);
	vector<long long> b(n/backet+1,ini);
	

	while(q>0){
		--q;
		int Q,x,y;
		cin>>Q>>x>>y;
		if(Q==0){
			--x;
			a[x]+=y;
			b[x/backet]+=y;
		}
		else{
			--x,--y;
			long long ans=0;
			if(y-x+1>=2*backet){
				int i=x;
				if(x%backet){
					for(i=x;i<(x/backet)*backet+backet;++i){
						ans+=a[i];
					}
				}
				for(int j=i/backet;j<y/backet;++j){
					ans+=b[j];
				}
				if(y%backet==backet-1){
					ans+=b[y/backet];
				}
				else{
					for(int j=(y/backet)*backet;j<=y;++j){
						ans+=a[j];
					}
				}
			}
			else{
				for(int i=x;i<=y;++i){
					ans+=a[i];
				}
			}
			cout<<ans<<"\n";
		}
	}
	
	//system("pause");
	return 0;
}

Measured memory_bytes: 3536
// inputに入力データ全体が入る
function Main(input) {

var counter = function(str,seq){
    return str.split(seq).length - 1;
};
	lines = input.split("\n"); // 1行目がinput[0], 2行目がinput[1], …に入る
	var s = lines[0];
	var bw = counter(s,"BW");
	var wb = counter(s,"WB");
	console.log(bw+wb);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 23520
#include<iostream>
#include<stdio.h>
#include<cstring>

using namespace std;
int main()
{
  char s[500];
  cin>>s;
  char t[500];
  cin>>t;
  int n,m;
  n=strlen(s);
  m=strlen(t);
  if(n>=m)
  {
    cout<<t<<s<<endl;
  }
  if(n<m)
  {
    cout<<s<<t<<endl;
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int ans = 0;
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  for (int i = 0; i < N; i += 2){
    if (A[i] % 2 == 1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include<cstdio>
using namespace std;
int a,b;
int PD(int x)
{
	int c[15];
	int n=0;
	int ans=0;
	while(x>0)
	{
		c[++n]=(x%10);
		x/=10;
	}
	//for(int i=1;i<=n-1;i++)
	//printf("%d ",c[i]);
	//printf("%d\n",c[n]);
	for(int i=1;i<=n;i++)
	{
		if(c[i]==c[n-i+1])ans++;
	}
	if(ans==n) return 1;
	return 0;
}
int main()
{
	int cnt=0;
	scanf("%d %d",&a,&b);
	for(int i=a;i<=b;i++)
	{
		if(PD(i)) cnt++;
	}
	printf("%d",cnt);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, k;
int a[N], cache[N];

int dp(int idx)
{
	if(idx>n)
		return 1e10;
	if(idx==n)
		return 0;
	int &ans=cache[idx];
	if(ans!=-1)
		return ans;
	ans=1e10;
	for(int i=1;i<=k && i+idx<=n;i++)
		ans=min(ans, abs(a[idx]-a[idx+i])+dp(idx+i));
	return ans;
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int ans=dp(1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6528
def solve():
    a, b, c = read()
    result = think(a, b, c)
    write(result)


def read():
    n = read_int(1)[0]
    a = read_int(n)
    b = read_int(n)
    c = read_int(n - 1)
    return a, b, c


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b, c):
    satisfaction = 0
    prev = -1
    for e in a:
        satisfaction += b[e - 1]
        if prev == e - 1:
            satisfaction += c[prev - 1]
        prev = e
    return satisfaction


def write(result):
    print(result)


if __name__ == '__main__':
    # import doctest
    # doctest.testmod()
    # import sys
    # sys.setrecursionlimit(10000)
    solve()

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)

long long int n,cnt=0,ans=0,a[100000],b,c,cmp=0;
string s,w;

int main(void){
      cin >> n;
      rep(i,n){
          cin >> a[i];
          cmp+=a[i];
      }
      
      sort(a,a+n);
      
     if(cmp%10==0){
     rep(i,n){
         if(a[i]%10!=0){
             cmp-=a[i];
             break;
         }
     }
     }
     if(cmp%10==0){
         cmp=0;
     }
      
      cout << cmp << endl;
      
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n,T;
    cin >>n >>T;
    vector<int> t(n);
    rep(i,n) cin >>t[i];

    ll ans=T;
    for(int i=1; i<n; ++i)
    {
        if(t[i]-t[i-1]>T) ans+=T;
        else ans+=t[i]-t[i-1];
    }

    cout << ans << endl;
    return 0;
}


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


int main()
{
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; i++) {
		int t = i % 10;
		int s = i / 10000;
		int x = (i / 10) % 10;
		int y = (i / 1000) % 10;
		if (t == s && x == y) {
			ans++;
		}
	}

	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);
        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            StringBuffer sb = new StringBuffer();
            if(h == 0 && w == 0){
                break;
            }
            for(int i =0;i<w;i++){
                sb.append("#");
            }
            for(int j=0;j<h;j++){
                System.out.println(sb.toString());
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 27380
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == '-') f ^= 1;
	for (; isdigit(c);c = getchar()) x = x * 10 + c - '0';
	return f ? x : -x;
}

int dp[1<<12];

int main() {
	int n = read(), m = read();
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	rep(i, m) {
		int a = read(), b = read();
		int nm = 0;
		rep(i, b) nm |= 1<<(read() - 1);
		rep(msk, 1<<n) {
			dp[msk | nm] = min(dp[msk | nm], dp[msk] + a);
		}
	}
	printf("%d\n", dp[(1<<n) - 1] == inf ? -1 : dp[(1<<n) - 1]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;

int main(){
  string s;
  cin >> s;
  ll len = s.length();
  ll cnt = 0;
  for(ll i = 0; i < len - 1; i++){
    if(s[i] != s[i + 1])
      cnt++;
  }
    
  cout << cnt << endl;
}


Measured memory_bytes: 1020
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var a = Read();
            var b = Read();
            var c = Read();
            var x = Read();
            long ans = 0;
            for (int i = 0; i <=a; i++)
            {
                for (int j = 0; j <= b; j++)
                {
                    for (int k = 0; k <= c; k++)
                    {
                        if (i * 500 + j * 100 + k * 50 == x) ans++;
                    }
                }
            }
            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}




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

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

    if(s=="SUN") cout << 7 << endl;
    else if(s=="MON") cout << 6 << endl;
    else if(s=="TUE") cout << 5 << endl;
    else if(s=="WED") cout << 4 << endl;
    else if(s=="THU") cout << 3 << endl;
    else if(s=="FRI") cout << 2 << endl;
    else if(s=="SAT") cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 struct stu
 {
   int x;
   int y;       
 };
 
 stu f;
 
 int dir_x[2]={1,0};
 int dir_y[2]={0,1};
 int start_x,start_y;
 
 int n,m;
 int mapKK[16][16];
 
 int bfs()
 {
   queue<stu> que;
   int count=0;
   f.x=start_x;
   f.y=start_y;
   que.push(f);
   while(que.size())
   {
     stu p=que.front();
     que.pop();
     if(p.x==n-1&&p.y==m-1)
     {
       count++;
     }
     for(int i=0;i<2;i++)
     {
       stu q;
       q.x=p.x+dir_x[i];
       q.y=p.y+dir_y[i];
       if((q.x<n)&&(q.y<m)&&(mapKK[q.x][q.y]!=1)) 
       {
         que.push(q);                                              
       }
     }        
   }      
   return count;
 }
  
 int main()
 {
   //count=0;
   //int map[16][16];
   start_x=start_y=0;
   while(cin>>n>>m&&(m!=0||n!=0))
   {
     for(int i=0;i<n;i++) for(int j=0;j<m;j++) mapKK[i][j]=0;
     int obj;
     cin>>obj;
     while(obj--) 
     {
       int x,y;
       cin>>x>>y;
       mapKK[x-1][y-1]=1;             
     }
     int count=bfs();
     cout<<count<<endl;
   }
   //while(1);      
   return 0;    
 }
 

Measured memory_bytes: 9224
n,m=list(map(int,input().split()))
a=sorted([list(map(int,input().split())) for i in range(n)])
cnt,ans,j=0,0,0
while cnt<m:
  cnt+=a[j][1]
  ans+=a[j][0]*a[j][1]
  j+=1
print(ans-(cnt-m)*a[j-1][0])


Measured memory_bytes: 28648
nm = input().split(' ')
a = input().split(' ')
total = 0
count = 0

for n in a:
    total += int(n)

for n in a:
    if int(n) >= total / (4 * int(nm[1])):
        count += 1

if count >= int(nm[1]):
    print("Yes")
else:
    print("No")

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

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

    vector<int> sum_b(N + 1);
    vector<int> sum_w(N + 1);
    for(int i = 0; i < N; i++) {
        sum_b[i + 1] = sum_b[i];
        sum_w[i + 1] = sum_w[i];
        if(S[i] == '#') {
            sum_b[i + 1]++;
        } else {
            sum_w[i + 1]++;
        }
    }

    IFD for(int i = 0; i < N + 1; i++) {
        cout << sum_w[i] << endl;
    }
    IFD cout << "sum_w[N]: " << sum_w[N] << endl;

    int ans = N + 1;
    for(int i = 0; i < N + 1; i++) {
        IFD cout << "i: " << i << " b[i]: " << sum_b[i] << " w[i]: " << sum_w[i] << endl;
        ans = min(ans, sum_b[i] + (sum_w[N] - sum_w[i]));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2180