akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    int n,i,j,k,max=0,a;

    scanf("%d",&n);
    if(n>=1 && n<=100)
    {



    for(i=1;i<=n;i++)
    {      k=1;
           j=i;
           while(j%2==0)
           {
                k=k+1;
                j=j/2;

           }
           if(k>max)
           {
               max=k;
                a=i;
           }
    }




    printf("%d\n",a);
    }
    return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

vector<vector<char>> v(26);
vector<vector<char>> vv(26);

int main(){
	
	string a,b;cin >> a >> b;
	REP(i,a.size()){
		v[b[i]-'a'].PB(a[i]);
		vv[a[i]-'a'].PB(b[i]);
	}
	
	REP(i,26){
		set<char> s;
		REP(j,v[i].size())s.insert(v[i][j]);
		if(s.size() > 1){
			cout << "No" << endl;
			return 0;
		}
	}
	
	REP(i,26){
		set<char> s;
		REP(j,vv[i].size())s.insert(vv[i][j]);
		if(s.size() > 1){
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
		
	
	return 0;
}

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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

signed main(){
    
    int n;
    cin >> n;
    
    vector<string> s;
    REP(i,n){
        string a;
        cin >> a;
        s.push_back(a);
    }
    int ans = 1;

    REP(i,n-1){
        if(s[i][s[i].size()-1] != s[i+1][0] )ans = 0;
    }
    REP(i,n){
        REP(j,n){
            if(i != j){
                if(s[i] == s[j])ans = 0;

            }
        }
    }

    if(ans == 1)cout << "Yes";
    else cout << "No";
    

    
    return 0;
}
//g++ -std=c++14 code1.cpp


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    ab = [[int(i) for i in input().split()] for _ in range(M)]
    ab = sorted(ab, key=lambda x: x[1])
    last = ab[0][1] - 1
    ans = 1
    for a, b in ab[1:]:
        if last >= a:
            continue
        ans += 1
        last = b - 1
    print(ans)


main()


Measured memory_bytes: 23592
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
const int maxn = 2e5+5;
const int ff = 0x3f3f3f3f;

int main()
{
	int n;
	cin>>n;
	int flag = 0;
	while(n)
	{
		if(n%10 == 9)
		{
			flag = 1;
			break;
		}
		n/= 10;
	}
	if(flag)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import sys

n, x, y = map(int, input().split())

res = {}

for i in range(1, n + 1):
	for j in range(i + 1, n + 1):
		d = min(abs(i - j), min(abs(i - x) + 1 + abs(j - y), abs(i - y) + 1 + abs(j - x)))

		#print(i, j, d)

		if d in res:
			res[d] += 1
		else:
			res[d] = 1

for k in range(1, n):
	if k in res:
		print(res[k])
	else:
		print(0)



Measured memory_bytes: 52188
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,s,f=0,op[10050],i,k=0;
	double x;
	for(i=0;i<=1050;i++)
	op[i]=i*i; 
 	scanf("%d%d",&a,&b);
 	c=b;
 	while(c)
 	{
	 	c/=10;
	 	f++;
 	}
 	//printf("%d\n",f);
 	if(f==1)
 	s=a*10+b;
 	else if(f==2)
 	s=a*100+b;
 	else if(f==3)
 	s=a*1000+b;
 	//printf("%d\n",s);
 	for(i=0;i<=1050;i++)
 	{
	 	if(op[i]==s)
	 	{
	 		k=1;break;
	 	}
 	}
 	if(k)
 	printf("Yes\n");
 	else
 	printf("No\n");
} 

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

s=list(input())

count_w = 0

w_list = []

r_list = []
for i in range(n):
    if s[i] == 'W':
        count_w += 1
        w_list.append(i)
    else:
        r_list.append(i)
w_list.reverse()

chage_count = 0
while len(w_list) > 0 and len(r_list) > 0 and r_list[-1] > w_list[-1]:
    r_list.pop()
    w_list.pop()
    chage_count += 1

print(min(chage_count, count_w))

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

using namespace std;

int calc(int n, int m) { return (1900 * m + 100 * (n - m)) * (1 << m); }

int main() {
  int n, m;
  std::cin >> n >> m;
  std::cout << calc(n, m) << std::endl;
  return 0;
}


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

using namespace std;

int cnt[100000];
int main()
{
    //freopen("input.txt", "r", stdin);

    int n;
    scanf("%d", &n);

    int t;
    long long int sum = 0;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &t);
        cnt[t]++;
        sum += t;
    }

    int q, b, c;
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d %d", &b, &c);
        cnt[c] += cnt[b];
        sum += (-cnt[b] * b + cnt[b] * c);
        cnt[b] = 0;

        printf("%lld\n", sum);
    }

    return 0;
}

Measured memory_bytes: 4176
#include <iostream>
#include <algorithm>
#define int long long
#define mod 1000000007
using namespace std;
int a[500005],dp[500005],cf[500005],st[500005][20],LOG[500005];
inline int mn(int l,int r)
{
	if(l>r) return 5e18;
	int i=LOG[r-l+1];
	return min(st[l][i],st[r-(1<<i)+1][i]);
}
signed main(int argc, char** argv) {
	int n,x,y;
	cin >> n >> x >> y;
	if(x>y) swap(x,y);
	a[0]=-2e18;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		st[i][0]=a[i]-a[i-1];
		if(i-1&&a[i]-a[i-2]<x)
		{
			puts("0");
			return 0;
		}
	}
	a[n+1]=2e18;
	for(int i=2;i<=n;i++)
		LOG[i]=LOG[i>>1]+1;
	for(int j=1;j<=18;j++)
		for(int i=1;i+(1<<j)-1<=n;i++)
			st[i][j]=min(st[i][j-1],st[i+(1<<j-1)][j-1]);
	dp[0]=1;
	for(int i=0;i<=n;i++)
	{
		cf[i]+=cf[i-1];
		dp[i]+=cf[i];
		dp[i]%=mod,cf[i]%=mod;
		int L=n+2,R=n+1;
		int l=i+1,r=n+1;
		while(l<=r)
		{
			int mid=(l+r)/2;
			if(a[mid]-a[i]>=y)
				L=mid,r=mid-1;
			else
				l=mid+1;
		}
		l=i+1,r=n+1;
		while(l<=r)
		{
			int mid=(l+r)/2;
			if(mn(i+2,mid-1)>=x)
				R=mid,l=mid+1;
			else	
				r=mid-1;
		}
		if(L<=R)
		cf[L]+=dp[i],cf[R+1]-=dp[i],cf[L]%=mod,cf[R+1]%=mod;
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		if(mn(i+2,n)>=x)
		{
			//cout << dp[i] << endl;
			ans+=dp[i],ans%=mod;
		}
	}
	cout << (ans+mod)%mod;
	return 0;
}
//dp[i]表示上一个在y里的是a[i] 

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

class Rolling_Hash{
private:
  ll n;
  static constexpr ll base1=1007,base2=2009;
  static constexpr ll mod1=(1e9+7),mod2=(1e9+9);
  vector<ll> hash1,hash2,mpow1,mpow2;
public:
  Rolling_Hash(const string& s){
    n=s.size();
    hash1.assign(n+1,0);
    hash2.assign(n+1,0);
    mpow1.assign(n+1,1);
    mpow2.assign(n+1,1);
    for(ll i=0;i<n;++i){
      hash1[i+1] = (hash1[i]*base1+s[i])%mod1;
      hash2[i+1] = (hash2[i]*base2+s[i])%mod2;
      mpow1[i+1] = (mpow1[i]*base1)%mod1;
      mpow2[i+1] = (mpow2[i]*base2)%mod2;
    }
  }
  inline auto get(ll l,ll r){
    ll lefval = hash1[r]-hash1[l]*mpow1[r-l]%mod1;
    ll rigval = hash2[r]-hash2[l]*mpow2[r-l]%mod2;
    if(lefval<0)lefval+=mod1;
    if(rigval<0)rigval+=mod2;
    return make_pair(lefval,rigval);
  }
  inline auto get_LCP(ll a,ll b){
    ll len = min( n-a+1,n-b+1 );
    ll low=0,high=len;
    while( high-low>1 ){
      ll mid=(high+low)/2;
      if(get(a,a+mid)!=get(b,b+mid))high=mid;
      else low=mid;
    }
    return low;
  }
};

main(){

  ll n;
  string s;
  cin>>n>>s;

  Rolling_Hash rh(s);
  ll ans=0;
  rep(i,n){
    for(ll j=i+1;j<n;++j){
      ll lcp=rh.get_LCP(i,j);
      ans=max(ans,min(lcp,j-i));
    }
  }
  cout<<(ans)<<endl;

}


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

int main() {
    int x, n, tmp, min1 = 0, min2 = 101;
    vector<int> v(100);
    cin >> x >> n;
    if (n != 0) {
        for (int i = 0; i < n; i++) {
            cin >> tmp;
            v[tmp - 1] ++;
        }
        for (int i = x - 1; i >= 0; i--) {
            if (v[i] == 0) {
                min1 = i + 1;
                break;
            }
            if (i == 0) {
                min1 = 0;
            }
        }
        for (int i = x; i < 100; i++) {
            if (v[i] == 0) {
                min2 = i + 1;
                break;
            }
        }
        //cout << min1 << endl;
        //cout << min2 << endl;
        if (abs(min1 - x) == abs(min2 - x)) {
            cout << min1 << endl;
        }
        else if (abs(min1 - x) > abs(min2 - x)) {
            cout << min2 << endl;
        }
        else
        {
            cout << min1 << endl;
        }
    }
    else {
        string buf;
        getline(cin, buf);
        if (buf.empty()) cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
using namespace std;
int beg[200100],nex[501000],tto[500100],e;
int cnt1[200100],cnt2[200100];
void putin(int s,int t){
	tto[++e]=t;
	nex[e]=beg[s];
	beg[s]=e;
}
bool vis[200100];
void dfs(int u){
	if(vis[u]) return;
	vis[u]=1;
	for(int i=beg[u];i;i=nex[i])
		dfs(tto[i]);
}
int main(){
//	freopen("E.in","r",stdin);
	int n,h;
	scanf("%d%d",&n,&h);
	int A,B,C,D;
	for(int i=1;i<=n;i++){
		scanf("%d%d%d%d",&A,&B,&C,&D);
		if(C>0){
			putin(n+C,i);
			putin(i,n+C);
			cnt1[n+C]++;
		}
		else{
			putin(n+h+A,i);
			putin(i,n+h+A);
			cnt2[n+A+h]++;
		}
		if(D>0){
			putin(n+D+h,i);
			putin(i,n+D+h);
			cnt1[n+D+h]++;
		}
		else{
			putin(n+B,i);
			putin(i,n+B);
			cnt2[n+B]++;
		}
	}
	for(int i=1;i<=h+h;i++){
		if(cnt1[n+i]>cnt2[n+i]){
			printf("NO\n");
			return 0;
		}
	}
	for(int i=1;i<=h+h;i++)
		if(cnt2[n+i]>cnt1[n+i])
			dfs(n+i);
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>

int main(void)
{
  int num = 100000;
  int  n,i;
  double numd;

  scanf("%d", &n);

  if(n <= 100 || n > 0){
    for(i=1; i<=n; i++){
      num = num * 1.05;

    numd = (double)num / 1000;
    numd = numd + 0.999;
    num = (int)numd * 1000;
    }

    printf("%d\n", num);
  }

  return 0;
}

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

int main(){
    
    int n; cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());    
    long long r = 0, c = 0;
    set<long long> st;

    for(int i = 0; i < n; i++){
        if(st.find(a[i]) != st.end()){
            if(r == 0){ 
                r = a[i];
                st.erase(a[i]);
            }
            else{
                c = a[i];
                break;
            }
        }else st.insert(a[i]);
    }

    cout << r * c << endl;
    
    return 0;
}

Measured memory_bytes: 4992
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}



const ll N=2e5+5;


int main()
{ 

IOS;

ll k;cin>>k;

ll s=0;

for(int i=0;i<=1e6;i++){
//ll temp=7*powM(10,i,k)%k;
//(s+=temp)%=k;
  s*=10;
  s%=k;
  s=(s+7)%k;
  if(!s){
    cout<<i+1;
    return 0;
  }
}

cout<<-1;


//end_routine();

return 0;
 
 }


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#ifndef d
#define d(...)
#endif
#define st first
#define nd second
#define pb push_back
#define siz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
typedef long long LL;
typedef long double LD;
constexpr int INF=1e9+7;
constexpr LL INFL=1e18;
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag,
         tree_order_statistics_node_update>;
*/

constexpr int maxn = 100005;

int n, m, deg[maxn];
vector<pair<int, int>> G[maxn], Q[maxn];
bool used[maxn], on_stack[maxn];

vector<int> euler;
void dfs(int a) {
	while(not G[a].empty()) {
		int v, i;
		tie(v, i) = G[a].back();
		G[a].pop_back();
		if(used[i]) continue;
		used[i] = true;
		dfs(v);
		euler.push_back(a);
	}
}


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

	cin >> n >> m;
	for(int i=0; i<m; i++) {
		int a, b;
		cin >> a >> b;
		assert(a != b);
		Q[a].emplace_back(b, i);
		Q[b].emplace_back(a, i);
		deg[a]++, deg[b]++;
	}
	
	for(int i=1; i<=n; i++)
		if(deg[i] % 2 == 1) {
			cout << "No\n";
			exit(0);
		}
	
	mt19937 rng(time(0));
	for(int _=0; _<90; _++) {
		for(int i=1; i<=n; i++) {
			G[i] = Q[i];
			shuffle(all(G[i]), rng);
		}
		fill_n(used, m, false);
		fill_n(on_stack, n+1, false);
		euler.clear();
		int root = rng() % n + 1;
		//int root = 1;
		dfs(root);
		
		stack<int> S;
		int cnt = 1;
		for(int x:euler) {
			if(on_stack[x]) {
				cnt++;
				while(on_stack[x]) {
					auto y = S.top();
					S.pop();
					on_stack[y] = false;
				}
			}
			on_stack[x] = true;
			S.push(x);
		}
		
		if(cnt >= 3) {
			cout << "Yes\n";
			exit(0);
		}
	}
	cout << "No\n";
}


Measured memory_bytes: 15668
#include <iostream>
using namespace std;
int main() {
    int A;
    cin >> A;
    string s;
    cin >> s;
    int count = s.length();
    if(count % 2 != 0){
        cout << "No" << endl;
    }else{
        bool judge = true;
        for(int i = 0; i < count / 2; i++){
            if(s[i] != s[i + count / 2]){
                judge = false;
            }
        }
        if(judge){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        string S;
        cin >> S;
        bool ok = false;
        int num;
        if (S[0] == 'A')
        {
                for (int i = 2; i < S.size() - 1; i++)
                {
                        if (S[i] == 'C')
                        {
                                num = i;
                                ok = true;
                        }
                }
        }

        if (ok)
        {
                for (int i = 1; i < S.size(); i++)
                {
                        if (i == num)
                        {
                                continue;
                        }
                        if (S[i] - 'a' < 0)
                        {
                                cout << "WA" << endl;
                                return 0;
                        }
                }
                cout << "AC" << endl;
        }
        else
        {
                cout << "WA" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,a[15][15],b[15];
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
		    cin>>a[i][j];
	cin>>n;
	for(int i=1;i<=n;i++)
	    cin>>b[i];
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			for(int k=1;k<=n;k++)
			{
				if(a[i][j]==b[k])
				{
					a[i][j]=0;
					break;
				}
			}
		}
	}
	int i,j,flag=0;
	if(a[1][1]==0&&a[2][2]==0&&a[3][3]==0)
	    flag=1;
	else if(a[1][3]==0&&a[2][2]==0&&a[3][1]==0)
	    flag=1;
	for(i=1;i<=3;i++)
	{
		if(a[i][1]==0&&a[i][2]==0&&a[i][3]==0)
		    flag=1;
		else if(a[1][i]==0&&a[2][i]==0&&a[3][i]==0)
		    flag=1;
	}
	if(flag==1)
	    cout<<"Yes"<<endl;
	else
	    cout<<"No"<<endl;
	return 0;
}

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

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

long long MOD = 1000000000 + 7;
long long MAX = 1000000000000000000;

int main(){
  cout << setprecision(10);
  int H,W;
  cin >> H >> W;
  ll dp[10][10];
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> dp[i][j];
    }
  }

  for(int k = 0; k < 10; k++){
    for(int i = 0; i < 10; i++){
      for(int j = 0; j < 10; j++){
        dp[i][j] = min(dp[i][j], dp[i][k]+ dp[k][j]);
      }
    }
  }

  ll cost = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int tmp;
      cin >> tmp;
      if(tmp == -1) continue;

      cost += dp[tmp][1];
    }
  }
  cout << cost << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define LOOP while (true)
using namespace std;
typedef long long ll;

int main()
{
  ll K;
  cin >> K;

  if (K <= 10)
  {
    cout << K << endl;
    return 0;
  }

  vector<string> xs = {"1", "2", "3", "4", "5", "6", "7", "8", "9"};
  ll cnt = 9;
  LOOP
  {
    vector<string> ys;

    for (string x : xs)
    {
      ll h = x[x.length() - 1] - '0';
      FOR(i, h - 1, h + 1)
      {
        if (i < 0 || 9 < i)
          continue;

        string y = x + to_string(i);
        ys.push_back(y);
        cnt++;
        if (cnt == K)
        {
          cout << y << endl;
          return 0;
        }
      }
    }

    xs = ys;
  }

  return 0;
}

Measured memory_bytes: 6740
#include<iostream>
#include<vector>
#include<numeric>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  for (auto &i : m) cin >> i;
  
  int res = X - accumulate(m.begin(), m.end(), 0);
  
  sort(m.begin(), m.end());
  int NUM = res / m[0];
  
  cout << N + NUM << endl;
}

Measured memory_bytes: 256
import std;
import core.bitop;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "B", long, "W");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, m;
    scan(n, m);
    auto ary = aryread.sort!"a<b"().array();
    auto dif = iota(m - 1).map!(x => ary[x + 1] - ary[x]).array().sort!"a<b"().array();
    // dif.writeln();
    dif.take(max(m - n, 0)).sum().writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 7588
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var a = input[0];
        var b = input[1];
        var c = input[2];
        var list = new List<int>();
        list.Add(a * 10 + b + c);
        list.Add(b * 10 + a + c);
        list.Add(c * 10 + a + b);
        Console.WriteLine(list.Max());
    }
}


Measured memory_bytes: 13396
def main():
    N, M, X = map(int, input().split())
    A = map(int, input().split())

    costs = [0] * (N+1)
    for a in A:
        costs[a] = 1

    ans = min(sum(costs[0:X+1]), sum(costs[X:]))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pii Dir[8] = { //?§????
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};
class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
};

class BiDGraph : public Graph {//??????
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};
class DGraph : public Graph {//??????
public:
	DGraph(int n) : Graph(n) {}
	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		sumcost++;
	}
};

void SCC(DGraph& g, vector<int>& scc) {
	vector<int> lowlink(g.vn, -1), orb(g.vn, -1);
	scc.resize(g.vn, -1);
	int cc = 0;
	int k = 0;
	vector<bool> used(g.vn);
	stack<int> st;
	function<void(int)> dfs = [&](int cur) {
		int nex = 0;
		lowlink[cur] = orb[cur] = ++k;
		st.push(cur);
		used[cur] = 1;
		for (auto itr : g.g[cur]) {
			if (orb[itr.first] == -1) {
				dfs(itr.first);
				lowlink[cur] = min(lowlink[cur], lowlink[itr.first]);
			}
			else if(used[itr.first]){
				lowlink[cur] = min(lowlink[cur], orb[itr.first]);
			}
		}
		if (lowlink[cur] == orb[cur]) {
			while (1) {
				int cp = st.top(); st.pop();
				used[cp] = 0;
				scc[cp] = cc;
				if (cp == cur)
					break;
			}
			cc++;
		}
	};
	REP(i, g.vn) {
		if (orb[i] < 0) {
			dfs(i);
		}
	}
	return;
}

signed main() {
	int v, e;
	scnaf("%d %d", &v, &e);
	DGraph g(v);
	REP(i, e) {
		int a, b;
		scanf("%d %d", &a, &b);
		g.con(a, b);
	}
	vector<int> scc;
	SCC(g, scc);

	int q;
	scanf("%d", &q);

	REP(i, q) {
		int a, b;
		scanf("%d %d", &a, &b);

		printf("%d\n", scc[a] == scc[b]);
	}

	return 0;
}

Measured memory_bytes: 4784
long d[1<<18]={0,0,1,6,19,65},M=998244353,m;b,c,N,s[4];
main(f){
	for(m=M-3;read(0,&c,1),c-10;s[c-97]++,f&=b!=c,b=c)
		m=!N|N++%3?m:(m+m)%M,
		d[N+5]=(5*d[N+4]-6*d[N+3]+2*d[N+2]-10*d[N+1]+12*d[N])%M;
	printf("%d\n",!*s+!s[1]+!s[2]>1?:(d[N]+(N%3|*s%3-s[2]%3?f:N>3?m+f:m)+M)%M);
}

Measured memory_bytes: 1664
#include <climits>
#include <iostream>
#include <unistd.h>
#include <vector>
using namespace std;

ostream &operator<<(ostream &os, const pair<int, int> &p) {
  os << '[' << p.first << ',' << p.second << ')';
  return os;
}
enum comm { UPDATE = 0, FIND = 1, DUMP = 2 };

int get_left(int i, int n) {
  while (i < n)
    i <<= 1;
  return i - n;
}

int get_right(int i, int n) {
  i++;
  while (i <= n)
    i <<= 1;
  return i - n;
}

pair<int, int> get_range(int i, int n) {
  int fst = i;
  int snd = i + 1;
  while (fst < n)
    fst <<= 1;
  while (snd <= n)
    snd <<= 1;
  return make_pair(fst - n, snd - n);
}

void dump(vector<int> &st) {
  const int nn = st.size();
  int i, split = 1;

  for (i = 1; i < nn; i++) {
    if (i == (1 << split)) {
      cout << endl;
      split++;
    }
    cout << (st[i] == INT_MAX ? "inf" : to_string(st[i]));
    for (int j = 0; j < (nn >> split); j++) {
      cout << '\t';
    }
  }
  cout << endl;
}

void update(vector<int> &st, int i, int a) {
  const int nn = st.size();
  i += nn / 2;
  st[i] = a;

  for (;;) {
    i /= 2;
    st[i] = min(st[i * 2], st[i * 2 + 1]);
    if (i == 0)
      break;
  }
}

// return the mim in [l,r)
int find(vector<int> &st, int l, int r) {
  // assert(l<r);
  // cout << "find_min:" << make_pair(l, r) << endl;
  const int n = st.size() / 2;
  l += n;
  r += n;

  int current_min = INT_MAX;
  while (l < r) {
    while (1) {
      //  cout << get_range(l, n) << "\tl:" << l << endl;
      if (l & 1)
        break;
      l /= 2;
    }

    while (get_right(l, n) > r - n) {
      // cout << get_range(l, n) << endl;
      l <<= 1;
    }
    //  cout << get_range(l, n) << "\tl:" << l << endl;
    current_min = min(current_min, st[l]);
    l++;
    while (l <= n)
      l <<= 1;
  }
  return current_min;
}

int find2(vector<int> &st, int l, int r, int ll, int rr, int k) {
  // assert ( k > 0 );
  //cerr << make_pair(ll, rr) << endl;
  if (r <= ll || rr <= l || k < 1)
    return INT_MAX;

  if (l <= ll && rr <= r)
    return st[k];
  else {
    const int vr = find2(st, l, r, ll, (ll + rr) / 2, k * 2);
    const int vl = find2(st, l, r, (ll + rr) / 2, rr, k * 2 + 1);
    return min(vr, vl);
  }
}

int main(int argc, char const *argv[]) {
  int n, q, nn, command, x, y;
  cin >> n >> q;
  for (nn = 1; nn < n; nn <<= 1)
    ;
  vector<int> seg_tree(nn * 2, INT_MAX);

  for (int i = 0; i < q; i++) {
    cin >> command;
    switch (command) {
    case UPDATE:
      cin >> x >> y;
      update(seg_tree, x, y);
      break;
    case FIND:
      cin >> x >> y;
      cout << find2(seg_tree, x, y + 1, 0, nn, 1) << endl;
      break;
    case DUMP:
      dump(seg_tree);
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 3852
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int maxh = 0, cnt = 0;
    for (int i=0; i<n; i++) {
        int h;
        cin >> h;
        if (h >= maxh) {
            maxh = h;
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jeel Vaishnav
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARoundOne solver = new ARoundOne();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARoundOne {
        public void solve(int testNumber, InputReader sc, PrintWriter out) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            out.println((6 - (a + b)));
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

using namespace std;
const int MOD = 1e9 + 7; 

int main() {
    int n;
    char a[55], b[55];
    while(scanf("%d", &n) != EOF) {
        getchar();
        scanf("%s", a);
        getchar();
        scanf("%s", b);
        int i = 0, p = 0;
        long long sum = 1;
        while(i < n) { // i 为当前摆放位置 
            if(i == 0) {
                if(a[i] == b[i]) { // X 
                    sum = (sum * 3) % MOD;
                    i ++;
                    p = 1;
                }
                else { // Y 
                    sum = (sum * 6) % MOD;
                    i += 2;
                    p = 2;
                }
            }
            else {
                if(a[i] == b[i]) { // 当前位置是 X
                    if(p == 1) sum = (sum * 2) % MOD; // 如果上一个位置是 X，即 X -> X 
                    else sum = (sum * 1) % MOD; // 如果上一个位置是 Y，即 Y -> X 
                    i ++;
                    p = 1;
                }
                else { // 当前位置是 Y
                    if(p == 1) sum = (sum * 2) % MOD; // 如果上一个位置是 X，即 X -> Y 
                    else sum = (sum * 3) % MOD; // 如果上一个位置是 Y，即 Y -> Y
                    i += 2;
                    p = 2;
                }
            }
        }
        printf("%lld\n", sum);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int A, P;
  cin >> A >> P;
  /*
  string s;
  int j, a;
  int O1, O2;
  */
  /*
  for(int i = 0; i < N; i++)
  {
    cin >> s;
    if(s == "SET")
    {
      cin >> j;
      if(j == 1)
      {
        cin >> O1;
      }
      else
      {
        cin >> O2;
      }
    }
    else if(s == "ADD")
    {
      cin >> a;
      O2 = O1 + a;
    }
    else
    {
      cin >> a;
      O2 = O1 - a;
    }
  }
  */
  cout << ((A*3)+P)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
int main()
{int a,b,c,d,e;
std::cin >> a >> b >> c >> d >> e;
 
 
if(a==0)
{std::cout << 1 << std::endl;}
 
if(b==0)
{std::cout << 2 << std::endl;}
  
if(c==0)
{std::cout << 3 << std::endl;}
 
if(d==0)
{std::cout << 4 << std::endl;}
 
 if(e==0)
{std::cout << 5 << std::endl;}
 
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  if (s[1] == 'B') s[1] = 'R'; else s[1] = 'B';
  cout << s << '\n';
}


Measured memory_bytes: 3572
import bisect
import sys
A, B, Q = map(int, input().split())
INF = 10 ** 13
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(sys.stdin.readline())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)


Measured memory_bytes: 78808
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int n, a[100000],c=1,x;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 1; i < n; i++) {
		c = a[c - 1];
		if (c == 2) { cout << i << endl; cin >> x; return 0; }
	}
	cout <<"-1" << endl;
	cin >> x;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





ll k, ans = 0;
vector<vector<ll>> g;

ll dfs(ll now, ll par){
    ll res = 0;
    for(auto &v : g[now]){
        res = max(res, dfs(v, now));
    }
    if(res >= k - 1 && par != 0){
        ans++;
        res = -1;
    }
    return res + 1;
}

int main() {
    ll n;
    cin >> n >> k;
    g.resize(n);
    REP(i, n){
        ll a;
        cin >> a;
        a--;
        if(i > 0){
            g[a].push_back(i);
        }
        else if(a != 0){
            ans++;
        }
    }
    dfs(0, 0);
    cout << ans << endl;
}


Measured memory_bytes: 10368
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

#define st first
#define nd second
#define int long long
const int N = 2e5+5, LOGN = 65;
int n, a[N], cnt = 0, u = 1, lg, in[N];
pair<int,int> par[LOGN][N];
long long k;
vector<int> v, cont[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        cont[a[i]].push_back(i);
    }
    for (int i = 1; i <= N; i++)
    {
        int m = cont[i].size();
        if (!m) continue;
        if (m == 1)
        {
            if (cont[i][0] == n)
                par[0][cont[i][0]] = {1,2};
            else
                par[0][cont[i][0]] = {cont[i][0]+1,1};
            continue;
        }
        for (int j = 0; j < m-1; j++)
        {
            if (cont[i][j+1] == n)
                par[0][cont[i][j]] = {1,1};
            else
                par[0][cont[i][j]] = {cont[i][j+1]+1,0};
        }
        par[0][cont[i][m-1]].st = cont[i][0]+1;
        par[0][cont[i][m-1]].nd = 1;
    }

    int lg = log2(n*k);
    for (int j = 1; j <= lg; j++)
    {
        for (int i = 1; i <= n; i++)
        {
            par[j][i].st = par[j-1][par[j-1][i].st].st;
            par[j][i].nd = par[j-1][i].nd + par[j-1][par[j-1][i].st].nd;
        }
    }

    for (int j = lg; j >= 0; j--)
    {
        if (!par[j][u].st || cnt+par[j][u].nd >= k) continue;
        //cout << j << ' ' << u << ' ' << par[j][u].st << endl;
        cnt += par[j][u].nd;
        u = par[j][u].st;
    }
    for (int i = u; i <= n; i++)
    {
        if (!in[a[i]])
        {
            v.push_back(a[i]);
            in[a[i]] = 1;
        }
        else
        {
            while(in[a[i]])
            {
                in[v.back()] = 0;
                v.pop_back();
            }
        }
    }
    for (int x: v)
        cout << x << ' ';

}


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

int main() {
  int n,k,sum,ans=1;
  cin >> n >> k;
  sum=k;
  while(sum<=n){
    sum*=k;
    ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
S=input()
T=input()
tbl = [0] * 26
tbl2 = [0] * 26
flag = True
for s,t in zip(S,T):
  c = ord(s)-ord('a')
  if tbl[c] == 0:
    tbl[c] = t
  elif tbl[c] == t:
    pass
  else:
    flag = False
    break
for s in tbl:
  if s == 0:
    continue
  c = ord(s)-ord('a')
  if 0 < tbl2[c]:
    flag = False
    break
  else:
    tbl2[c] = 1
print('Yes' if flag else 'No')


Measured memory_bytes: 3632
import java.util.*;
import java.io.*; 
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void solve(int TC) throws Exception{
        pn(ni()+1-ni());
    }
    //SOLUTION ENDS
    long mod = (int)1e9+9, IINF = (long)1e12;
    final int MAX = (int)1e5+1, INF = (int)1e9, root = 3;
    DecimalFormat df = new DecimalFormat("0.00000000");
    double PI = 3.141592653589793238462643383279502884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = true;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{    
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }   
            return str;
        }
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  LL N, T;
  cin>>N>>T;
  LL t[N];
  REP(i, N) cin>>t[i];
  if(N==1){
    cout<<T<<endl;
    return 0;
  }

  int ans=T;
  for(int i=1; i<N; ++i){
    ans += min(T, t[i]-t[i-1]);
  }

  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m; cin>>n>>m;
  int mx=INT_MIN, mn=INT_MAX;
  for(int i=0;i<m;i++){
    int l,r; cin>>l>>r;
    mx = max(mx, l);
    mn = min(mn,r);
  }
  cout<<max(0,mn-mx+1)<<"\n";
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

//-----------------------------------------------------------------------------

int n,k;
ll w[100000],d[100000];

bool check(ll dist) {
	ll cnt=0;
	REP(i,n) {
		if(w[i]>dist) continue;
		cnt+=(dist-w[i])/d[i]+1;
	}
	return cnt>=k;
}

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

	cin>>n>>k;
	REP(i,n) cin>>w[i]>>d[i];
	ll ub=2*LINF,lb=-1;
	while (ub-lb>1) {
		ll mid=(ub+lb)/2;
		if(check(mid)) ub=mid;
		else lb=mid;
	}
	cout<<ub<<endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

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

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	int n;
	string s, t, S;
	cin >> n >> s >> t;
	S = s;
	int j = 0;
	while (true) {
		if (S.substr(S.size() - n, n) == t) {
			cout << S.size() << endl;
			return 0;
		}
		S = s + t.substr(t.size() - j, j);
		j++;
	}
	}


Measured memory_bytes: 256
/* Author rumoisen */
/* created 2018/11/17 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no() { cout << "No" << endl;exit(0);}
void yes() { cout << "Yes" << endl;exit(0);}
void No() { cout << "NO" << endl;exit(0);}
void Yes() { cout << "YES" << endl;exit(0);}

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main()
{
    int n, m;
    vector<string> s(112);
    vector<string> t(112);
    cin >> n;
    for (int i = 0; i < n; i ++){
        cin >> s[i];
    }
    cin >> m;
    for (int i = 0; i < m; i++ ){
        cin >> t[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++ ){
        int sum = 0;
        string tmp = s[i];
        for (int j = 0; j < n; j++ ){
            if(s[j]==tmp){
                sum++;
            }
        }
        for (int k = 0; k < m; k++ ){
            if(t[k]==tmp){
                sum--;
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define int long long

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<vector<int> > f(n,vector<int>(10));
    for(int i = 0;i < n;i ++){
        for(int j = 0;j < 10;j ++){
            cin >> f.at(i).at(j);
        }
    }
    vector<vector<int> > p(n,vector<int>(11));
    for(int i = 0;i < n;i ++){
        for(int j = 0;j < 11;j ++){
            cin >> p.at(i).at(j);
        }
    }

    vector<int> c(n),count(10);
    count.at(9) = 1;

    int ans = -100000000000;

    for(int i = 0;i < 1023;i ++){

        for(int j = 0;j < n;j ++){
            c.at(j) = 0;
        }

        for(int j = 0;j < n;j ++){
            for(int k = 0;k < 10;k ++){
                if(f.at(j).at(k) == 1 && count.at(k) == 1){
                    c.at(j) ++;
                }
            }
        }

        int sum = 0;
        for(int j = 0;j < n;j ++){
            sum += p.at(j).at(c.at(j));
        }

        ans = max(ans,sum);

        count.at(9) ++;

        for(int j = 9;j > 0;j --){
            if(count.at(j) == 2){
                count.at(j) = 0;
                count.at(j-1) ++;
            }
        }
    }

    cout << ans << endl;

}

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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;
int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int const N = 100 * 1010;

/********************i**********************************/
vector<int> edge[N], total(N, 0), visited(N, 0);
void dfs(int a){
	for(int b : edge[a]){
		if(visited[b] == 1){
			total[a] = max(total[a], total[b] + 1);
		}
		else{
			dfs(b);
			total[a] = max(total[b] + 1, total[a]);
		}
	}
	visited[a] = 1;

}
void solve(){
	int n, m;
	cin >> n >> m;
	for(int x =0; x<m; x++){
		int u, v;
		cin >> u >> v;
		edge[u].pb(v);
	}
	for(int x =1; x<=n; x++){
		if(visited[x] == 0){
			dfs(x);
		}
	}
	cout << *max_element(ALL(total));
}


/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
}

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

using namespace std;

int main()
{
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3,y3,x4,y4;

    x3 = x2 - (y2 - y1);
    y3 = y2 - (x1 - x2);
    x4 = x1 - (y2 - y1);
    y4 = y1 - (x1 - x2);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}



Measured memory_bytes: 256