akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a,b,c;
	long long resa=0,resb=0,resc=0,tempa,tempb,tempc;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		if(resb>resc){
			tempa=resb+a;
		}else{
			tempa=resc+a;
		}
		if(resa>resc){
			tempb=resa+b;
		}else{
			tempb=resc+b;
		}
		if(resb>resa){
			tempc=resb+c;
		}else{
			tempc=resa+c;
		}
		resa=tempa;
		resb=tempb;
		resc=tempc;
	}
	long long res=resa;
	if(resb>res)res=resb;
	if(resc>res)res=resc;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B)cout << C << endl;
    else if(B == C)cout << A << endl;
    else cout << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
    #define pp(x) cerr<<#x<<" = ("<<x.F<<" , "<<x.S<<")"<<endl;
    #define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl;
    #define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl;
#else
    #define p(x)
    #define p2(x,y)
    #define pp(x)
    #define pv(x)
    #define ppv(x)
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int maxp = 22;
const ld EPS = 1e-18;
const ll INF = 1e18;
const int MOD = 1e9+7;
const int N = 2e5+1;


int main(){
fastio

int n;
cin>>n;

string s = "ACL";

int i;
string ans = "";

for(i=0;i<n;i++)ans += s;

cout<<ans<<endl;



}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 9;

char s[N];
int f[N], n, t, lim;
using ll = long long;
ll l, r, c[120][26], ans[26], fib[N];

void Solve (ll x, int t) {
	ll bs = x / ::t, b2 = x % ::t;
	bs *= t;
	for (int i = 0; i < ::t; ++i) {
		ans[s[i] - 'a'] += bs;
		if (i < b2) ans[s[i] - 'a'] += t;
	}
}

void Solve2 (ll x, int t) {
	int now = lim + 1;
	while (now-- > 0) {
		if (x >= fib[now]) {
			for (int i = 0; i < 26; ++i) ans[i] += c[now][i] * t;
			x -= fib[now], --now;
		}
	}
	for (int i = 0; i < x; ++i) ans[s[i] - 'a'] += t;
}

int main () {
	scanf("%s", s);
	n = strlen(s);
	n >>= 1;
	s[n] = '\0';
	scanf("%lld%lld", &l, &r);
	for (int i = 1, j; i < n; ++i) {
		j = f[i];
		while (j && s[j] != s[i]) j = f[j];
		f[i + 1] = s[i] == s[j] ? j + 1 : 0;
	}
	t = n - f[n];
	if (n % t == 0) {
		Solve(r, 1); Solve(l - 1, -1);
	} else {
		for (int i = 0; i < t; ++i) ++c[0][s[i] - 'a'];
		for (int i = 0; i < n; ++i) ++c[1][s[i] - 'a'];
		fib[0] = t; fib[1] = n;
		for (lim = 2; ; ++lim) {
			for (int j = 0; j < 26; ++j) c[lim][j] = c[lim - 1][j] + c[lim - 2][j];
			if ((fib[lim] = fib[lim - 1] + fib[lim - 2]) >= 1e18) break;
		}
		Solve2(r, 1); Solve2(l - 1, -1);
	}
	ll sum = 0;
	for (int i = 0; i < 26; ++i) printf("%lld ", ans[i]), sum += ans[i];
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
using namespace std;
int D,N;
int memo[101][101];
int a[100],e[100],r[100];
int f(int d,int E)
{
	if(memo[d][E]>=0)return memo[d][E];
	if(E==100)
	{
		int ans=1e9;
		for(int i=0;i<N;i++)if(a[i])ans=min(ans,(d-1)/a[i]+1);
		return memo[d][E]=ans;
	}
	int ans=1e9;
	for(int i=0;i<N;i++)
	{
		if(E<r[i])continue;
		if(d<=a[i])
		{
			ans=1;
			break;
		}
		if(a[i]||e[i])ans=min(ans,1+f(d-a[i],min(100,E+e[i])));
	}
	return memo[d][E]=ans;
}
main()
{
	while(cin>>D>>N,D)
	{
		for(int i=0;i<N;i++)cin>>a[i]>>e[i]>>r[i];
		for(int i=0;i<=D;i++)for(int j=0;j<=100;j++)memo[i][j]=-1;
		int ans=f(D,0);
		if(ans==1e9)cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
}



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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll n, m; cin >> n >> m;
	vector<ll> a(n), b(n);
	REP(i, n) cin >> a[i] >> b[i];

	map<ll, vector<ll>> ma;
	REP(i, n)
		ma[m-a[i]].emplace_back(b[i]);

	ll res{0};
	priority_queue<ll> que;
	for (ll i = m-1; i >= 0; --i)
	{
		for (auto &e : ma[i]) que.push(e);
		if (que.size())
		{
			res += que.top();
			que.pop();
		}
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 12416
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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


    int N, M; cin >> N >> M;
    vi L(M), R(M); REP(i, M) cin >> L[i] >> R[i];

    vi x(N + MGN, 0);
    REP(i,M) {
        x[L[i]]++;
        x[R[i] + 1]--;
    }

    REP(i,N+1) {
        x[i + 1] += x[i];
    }

    int ans = 0;
    REP(i,N+1) {
        if (x[i] == M) ans++;
    }

    cout <<  ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
    int N, tmp, f=0;
    long long ans=1;
    int A[200000];
    int B[200000];
    int C[200000];

    scanf("%d",&N);
    for(int i=0; i<N; i++){
        scanf("%d",&A[i]);
        B[i]=0;
        C[i]=0;
    }

    for(int i=0; i<N; i++){
        tmp = A[i];
        B[tmp]++;
    }

    
    if(N%2 == 1) {
        C[0] = 1;
        for(int i=2; i<=N-1; i+=2) C[i] = 2;
    } else {
        for(int i=1; i<=N-1; i+=2) C[i] = 2;
    }

    for(int i=0; i<N; i++){
        //printf("B[%d] = %d\n",i,B[i]);
        //printf("C[%d] = %d\n",i,C[i]);
        if(B[i] != C[i]) f=1;
    }

    if(f == 1){
        printf("0\n");
        return 0;
    }

    for(int i=0; i<N/2; i++){
        ans *= 2;
        ans%=1000000007;
    }

    printf("%lld\n",ans%1000000007);

    return 0;
}

Measured memory_bytes: 2904
for i in range(5):
	n = int(input())
	if n == 0: break
	bcnt = acnt = 0
	for j in range(n):
		a, b = map(int, input().split())
		if a > b: acnt += a + b
		elif a < b:bcnt += a + b
		else:
			acnt += a
			bcnt += b
	print(acnt, bcnt)

Measured memory_bytes: 7580
# ABC 084
def getIntList(): return [int(x) for x in input().split()]
def db(x): 
    global debug
    if debug: print(x)
debug = False
A,B = getIntList()
S = input()
db((A,B,S))
number = [chr(ord('0')+i) for i in range(10)]
db(number)
if S[A]=='-':
    for i in range(A):
        if not(S[i] in number):
            print('No');break
    else:
        for i in range(A+2,A+B+1):
            if not(S[i] in number):
                print('No');break
        else:
            print('Yes')  
else: 
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N, T;
vector<ll> A, B;
vector<vector<ll>> DP1, DP2;

int main() {
	cin >> N >> T;
	A.resize(N + 1);
	B.resize(N + 1);
	for (ll n = 1; n <= N; n++)cin >> A[n] >> B[n];
	DP1.resize(N + 2, vector<ll>(T + 1,0));
	DP2.resize(N + 2, vector<ll>(T + 1,0));
	for (ll n = 1; n <= N; n++) {
		for (ll t = 0; t <= T; t++) {
			DP1[n][t] = DP1[n - 1][t];
			if (t >= A[n])DP1[n][t] = max(DP1[n][t], DP1[n - 1][t - A[n]] + B[n]);
		}
	}
	for (ll n = N; n >= 1; n--) {
		for (ll t = 0; t <= T; t++) {
			DP2[n][t] = DP2[n + 1][t];
			if (t >= A[n])DP2[n][t] = max(DP2[n][t], DP2[n + 1][t - A[n]] + B[n]);
		}
	}
	ll ans = DP1[N][T - 1];
	for (ll n = 1; n <= N; n++) {
		ll temp = 0;
		for (ll t = 0; t <= T - 1; t++) {
			temp = max(temp, DP1[n - 1][t] + DP2[n + 1][T - 1 - t]);
		}
		temp += B[n];
		ans = max(ans, temp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 141312
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const double PI = acos(-1);
const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll x,k,d;
    cin >> x >> k >> d;
    string sk = to_string(k);
    string sd = to_string(d);
    x = abs(x);
    if(sz(sk) + sz(sd) <= 17){
        if(x >= k * d) {
            print(x - k * d);
            return 0;
        } else {
            ll tmp = x % d;
            ll tmp2 = x / d;
            if((k % 2 == 0 && tmp2 % 2 == 0) || (k % 2 != 0 && tmp2 % 2 != 0)){
                print(tmp);
            } else {
                print(min(abs(tmp + d), abs(tmp - d)));
            }
        }
    } else {
            ll tmp = x % d;
            ll tmp2 = x / d;
            if((k % 2 == 0 && tmp2 % 2 == 0) || (k % 2 != 0 && tmp2 % 2 != 0)){
                print(tmp);
            } else {
                print(min(abs(tmp + d), abs(tmp - d)));
            }
    }
    

}



Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	
	if(((n+1)/2) >= k){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const inf = 100

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	s := getString()
	N := len(s)
	s += "@@@@@"

	dp := make([][3]int, N+10)
	for i := 0; i < N+1; i++ {
		for j := 0; j < 3; j++ {
			dp[i][j] = -inf
		}
	}
	dp[0][0] = 0

	for i := 0; i < N; i++ {
		for j := 0; j < 3; j++ {
			for k := 1; k < 3; k++ {
				if dp[i][j] >= 0 {
					if j == k {
						if k == 1 {
							if s[i-1] == s[i] {
								continue
							}
						} else {
							if s[i-2] == s[i] && s[i-1] == s[i+1] {
								continue
							}
						}
					}
					dp[i+k][k] = max(dp[i+k][k], dp[i][j]+1)
				}
			}
		}

	}

	out(max(dp[N][1], dp[N][2]))
}


Measured memory_bytes: 7580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    ll n; cin >> n;
    ll ans = 0, doub = 0;
    for(ll a=1; a<=(n-1); a++){
        // cout << a << endl;
        ans += (n-1)/a;
        // cout << ans << endl;
        // if(a*a <= (n-1)) doub++;
    }
    // cout << doub << endl;
    cout << ans << endl;
    // cout << ans - doub << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define dbl double
#define forn(i,n,k) for(int i=0;i<n;i=i+k)
#define forpn(p,n,k) for(int i=p;i<n;i+=k)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
using namespace std;

int main()
{   ios::sync_with_stdio(0);
    
    
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int>v(n);
    for0(i,n) cin>>v[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<n;i++){
        if(dp[i-2]+abs(v[i-2]-v[i])<dp[i-1]+abs(v[i-1]-v[i]))
            dp[i]=dp[i-2]+abs(v[i-2]-v[i]);
        else dp[i]=dp[i-1]+abs(v[i-1]-v[i]);
    }
    cout<<dp[n-1];
      
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 1'000'000'007;

int main() {
    int N;
    cin >> N;
    vector<double> v(N);
    for(int i = 0; i < N; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double rez = (v[0] + v[1]) / 2;
    for(int i = 2; i < N; i++) {
        rez = (rez + v[i]) / 2;
    }
    cout << fixed << setprecision(10) << rez;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    string s;
    cin>>s;
    bool ok=0;
    f(i,0,s.size()){if(s[i]=='7'){ok=1;break;}}
    cout<<(ok?"Yes":"No");
    return 0;  
} 





Measured memory_bytes: 3640
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

bool check(int n) {
  int pr = n % 10;
  while (n) {
    int p = n % 10;
    if (abs(pr - p) > 1) return false;
    pr = p;
    n /= 10;
  }
  return true;
}

int next(int n, int place) {
  string str = to_string(n);
  int p = str.length();
  char ch = str[p - place];
  if (ch == '9' and p != place) return 14;
  ch++;
  if (place == p and str[0] == '9') {
    str.pb('0');
    p++, place++;
    ch = '1';
  }
  for (int i = p - place; i < p; i++) {
    str[i] = ch;
    if (ch != '0')
      ch--;
  }
  return stoll(str);
}

int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int k;
  cin >> k;
  int c = 0;
  for (int i = 0; i < k; i++) {
    int pos = 1;
    while (1) {
      int p = next(c, pos);
      if (check(p)) {
        c = p;
        break;
      }
      pos++;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  for (auto it = vc.begin(); it != vc.end(); ++it)
  {
    if (std::next(it) == vc.end())
      os << *it;
    else
      os << *it << ' ';
  }
  return os;
}

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  using std::cout;
  ui H{}, W{}; cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  typedef pair<ll, ll> mPair;
  typedef pair<mPair, ui> Pair;
  std::queue<Pair> queue;
  rep(0, H)
  {
    string s{}; cin >> s;
    rep_uj(0, W)
    {
      A[i][j] = s[j];
      if(A[i][j] == '#') queue.push({{i, j}, 0});
    }
  }

  ull ans{};  
  while (!queue.empty())
  {
    Pair p = queue.front();
    queue.pop();
    ++p.second;
    mPair p0 = {p.first.first    ,p.first.second - 1 };
    mPair p1 = {p.first.first    ,p.first.second + 1 };
    mPair p2 = {p.first.first - 1,p.first.second };
    mPair p3 = {p.first.first + 1,p.first.second };
    if(p0.second >= 0
    && A[p0.first][p0.second] == '.')
    {
      A[p0.first][p0.second] = '#';
      queue.push({p0, p.second});
      ans = p.second;
    }
    if(p1.second < W
    && A[p1.first][p1.second] == '.')
    {
      A[p1.first][p1.second] = '#';
      queue.push({p1, p.second});
      ans = p.second;
    }
    if(p2.first >= 0
    && A[p2.first][p2.second] == '.')
    {
      A[p2.first][p2.second] = '#';
      queue.push({p2, p.second});
      ans = p.second;
    }
    if(p3.first < H
    && A[p3.first][p3.second] == '.')
    {
      A[p3.first][p3.second] = '#';
      queue.push({p3, p.second});
      ans = p.second;
    }
  }

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

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

  solve();

  return 0;
}


Measured memory_bytes: 25524
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
const int Maxn = 1e9 + 10;
const int N = 1e5 + 10;
const int INF=(0x7fffffff)/2;
const int MOD = 1000000007;
ll dp[55][2555];

int main(){
	int n, a;
	scanf("%d %d", &n, &a);
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		int x;
		scanf("%d\n", &x);
		for(int j = i - 1; j >= 0; j--){
			for(int k = 0; k <= 55 * j; k++){
				dp[j + 1][k + x] = dp[j + 1][k + x] + dp[j][k]; //i表示相加的个数，j表示加起来后的值
			}
		}
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		ans = ans + dp[i][i * a];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		Stack<Long> stack = new Stack<>();
		while (s.hasNext()) {
			String in = s.next();
			try {
				stack.push(Long.parseLong(in));
			} catch (Exception e) {
				switch (in) {
					case "+":
						stack.push(stack.pop() + stack.pop());
						break;
					case "-":
						long x1 = stack.pop();
						long x2 = stack.pop();
						stack.push(x2 - x1);
						break;
					case "/":
						long x11 = stack.pop();
						long x22 = stack.pop();
						stack.push(x22 / x11);
						break;
					case "*":
						stack.push(stack.pop() * stack.pop());
						break;
				}
			}
		}
		System.out.println(stack.pop());
	}
}



Measured memory_bytes: 26492
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,n;
	cin>>a>>b>>n;
	long long ans=0;
	if(b==1){
		ans=0;
	}else if(n==1){
		ans=a/b;
	}
	else if(n>=b){
		 ans=(a*(b-1))/b;	
	}else if(n<b){
			ans=(a*n)/b;
	}
	cout<<ans<<endl;
	
	return 0;
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2], freq[N];


void solve()
{
	cin >> n;
	map<int, int> mp;
	lop(i, 0, n)
	{
		int x; cin >> x;
		mp[x]++;
	}

	vector<pii> vec;
	for (auto &i : mp) vec.pb(i);

	int sz = vec.size();
	int ans = 0;
	lop(i, 0, sz)
	{
		if ( vec[i].ss == 1 and freq[ vec[i].ff ] == 0 ) ans++;
		for (int j = vec[i].ff; j <= ((int)1e6) + 7; j += vec[i].ff ) freq[j] += vec[i].ss;
	}

	cout << ans << endl;


}

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

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


}





















Measured memory_bytes: 26572
#include <cstdio>
int min(int a,int b){
	return a<b?a:b;
}
int max(int a,int b){
	return a>b?a:b;
}
const int Maxn=200000;
const int Inf=0x3f3f3f3f;
int h,w;
int a[Maxn+5],b[Maxn+5];
struct Segment_Node{
	int val;
	int lazy;
	int left,right;
}seg[Maxn<<2|5];
void build(int root=1,int left=1,int right=w){
	seg[root].left=left;
	seg[root].right=right;
	seg[root].val=seg[root].lazy=0;
	if(left==right){
		return;
	}
	int mid=(left+right)>>1;
	build(root<<1,left,mid);
	build(root<<1|1,mid+1,right);
}
void update_tag(int x,int root,int left,int right){
	if(x<=seg[root].lazy){
		return;
	}
	if(x<=w){
		seg[root].val=x-right;
	}
	else{
		seg[root].val=Inf;
	}
	seg[root].lazy=x;
	seg[root].left=seg[root].right=x;
}
bool DDD;
void push_down(int root,int left,int right){
	if(seg[root].lazy){
		int mid=(left+right)>>1;
		update_tag(seg[root].lazy,root<<1,left,mid);
		update_tag(seg[root].lazy,root<<1|1,mid+1,right);
		seg[root].lazy=0;
	}
}
void update(int l,int r,int root=1,int left=1,int right=w){
	if(l>seg[root].right||r<seg[root].left){
		return;
	}
	if(l<=seg[root].left&&r>=seg[root].right){
		update_tag(r+1,root,left,right);
		return;
	}
	if(root==1){
		DDD=1;
	}
	push_down(root,left,right);
	int mid=(left+right)>>1;
	update(l,r,root<<1,left,mid);
	update(l,r,root<<1|1,mid+1,right);
	seg[root].val=min(seg[root<<1].val,seg[root<<1|1].val);
	seg[root].left=min(seg[root<<1].left,seg[root<<1|1].left);
	seg[root].right=max(seg[root<<1].right,seg[root<<1|1].right);
}
void print(int root=1,int left=1,int right=w){
	if(left==right){
		printf("%d ",seg[root].left);
		return;
	}
	push_down(root,left,right);
	int mid=(left+right)>>1;
	print(root<<1,left,mid);
	print(root<<1|1,mid+1,right);
}
int ans[Maxn+5];
int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	build();
	for(int i=1;i<=h;i++){
		update(a[i],b[i]);
		ans[i]=i+seg[1].val;
	}
	for(int i=1;i<=h;i++){
		printf("%d\n",ans[i]>h+w?-1:ans[i]);
	}
	return 0;
}


Measured memory_bytes: 13724
#include <stdio.h>
long long int memo[87]={};
long long int ru(int a)
{
    if(a==0)return 2;
    if(a==1)return 1;
    if(memo[a]!=0)return memo[a];
    return memo[a]=ru(a-1)+ru(a-2);
}

int main(void)
{
    int n;
    scanf("%d",&n);
    long long int ans=ru(n);
    printf("%lld",ans);
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int w,n;
	int i,temp;
	int a,b,c[31];
	
	scanf("%d",&w);
	scanf("%d",&n);
	for(i=1;i<=w;i++){
		c[i]=i;
	}
	for(i=1;i<=n;i++){
		scanf("%d,%d",&a,&b);
		temp=c[a];
		c[a]=c[b];
		c[b]=temp;
	}
	for(i=1;i<=w;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = max(-1000000000000000009LL, a * c);
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans << endl;
}


Measured memory_bytes: 3632
package main
 
import (
  "fmt"
  "strconv"
)

func main() {
  
  //入力値を分割
  var str string
  fmt.Scan(&str)
  var a,b,c,d int
  a,_ = strconv.Atoi(string(str[0]))
  b,_ = strconv.Atoi(string(str[1]))
  c,_ = strconv.Atoi(string(str[2]))
  d,_ = strconv.Atoi(string(str[3]))
  
  //+,-を格納
  var sa,sb,sc string

  //計算結果
  var ans int
  
  //全パターン試して正解を見つけたら終了(bit演算を使わない方法)
  fin:
  	for i := 0; i < 2; i++ {
      for j := 0; j < 2; j++ {
        for k := 0; k < 2; k++ {
          ans = a
          if i == 0 {
            ans -= b
            sa = "-"
          } else {
            ans += b
            sa = "+"
          }
          if j == 0 {
            ans -= c
            sb = "-"
          } else {
            ans += c
            sb = "+"
          }
          if k == 0 {
            ans -= d
          sc = "-"
          } else {
            ans += d
            sc = "+"
          }
          if ans == 7 { 
            fmt.Printf("%d%s%d%s%d%s%d=7",a,sa,b,sb,c,sc,d)
            break fin
          }
        }
      }
    }
}


Measured memory_bytes: 512
import itertools
n,y = map(int,input().split())
z = y//1000

list = list(range(n+1))
for a,b in itertools.product(list,list):
    c = n - a - b
    if c>=0:
        v = 10*a + 5*b + c
        w = a + b + c
        if v == z and w == n:
            break
else:
    a = -1
    b = -1
    c = -1

print(str(a),str(b),str(c))


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    ll N; cin >> N;
    vector<ll> a(N); REP(i,N) cin >> a[i];
    ll ans = 0;
    SORT(a);
    while(a[N-1]>N-1){
        ll S = 0; REP(i,N) S += a[i]/N;
        REP(i,N){
            ll d = a[i]/N;
            ans += d;
            a[i] -= d*N;
            a[i] += S-d;
        }
        SORT(a);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int SIZE = 181 + 1;
const int MAX = 1000000;

int T[SIZE];
int cost1[MAX], cost2[MAX];

int main( void )
{	
	for(int i=0; i < SIZE; ++i) T[i] = i * (i + 1) * (i + 2) / 6;

	fill(cost1, cost1+MAX, MAX);
	fill(cost2, cost2+MAX, MAX + MAX);
	cost1[0] = cost2[0] = 0;
	for(int i=0; i < MAX; ++i) {
		//if(cost1[i] < 6) {
			for(int j=0; j < SIZE; ++j) {
				if(i + T[j] < MAX && cost1[i] < 5)
					cost1[i + T[j]] = min(cost1[i + T[j]], cost1[i] + 1);
				if(T[j] & 1) {
					if(i + T[j] < MAX)
						cost2[i + T[j]] = min(cost2[i + T[j]], cost2[i] + 1);
				}
			}
	}
	int n;
	while(cin >> n, n) {
		cout << cost1[n] << ' ' << cost2[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 8564
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100100;

    void solve() {
        ll n, cnt = 0;
        cin >> n;
        ll a[n]; map<ll, ll> mp;
        rep(i, n) cin >> a[i], mp[a[i]]++;
        trav(i, mp) {
            if(i.fst < i.snd) cnt+=(i.snd - i.fst);
            else if(i.fst > i.snd) cnt+=i.snd;
        }
        cout << cnt << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
     /*
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
      */
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
//int mod = 1e9 + 7;
int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	int n;
	cin >> n;
	int xr = 0;
	int a[n];
	for (int i = 0; i < n; i++)
		cin >> a[i], xr ^= a[i];
	for (int i = 0; i < n; i++)
	{
		a[i] ^= xr;
		cout << a[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 5132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int n; cin >> n;
	bool ans = false;
	for (int i = 0; i < 20; ++i)
	{
		for (int j = 0; j < 20; ++j)
		{
			if(4*i + 7*j == n) ans = true;
		}
	}

	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 2e5 + 20;
const int MOD = 998244353;
vector<int> unq;
vector<pii> srt;
int x[MAXN], d[MAXN], dp[MAXN][2], n;
struct SegmentTree {
	#define lson (root << 1)
	#define rson (root << 1 | 1) 
	int val[1 << 19];
	inline void modify(int p, int v, int root = 1, int stdl = 1, int stdr = n) {
		if (stdl == stdr) {
			val[root] = v;
			return;
		}
		int mid = (stdl + stdr) >> 1;
		if (p <= mid) {
			modify(p, v, lson, stdl, mid);
		} else {
			modify(p, v, rson, mid + 1, stdr);
		}
		val[root] = max(val[lson], val[rson]);
	}
	inline int query(int l, int r, int root = 1, int stdl = 1, int stdr = n) {
		if (l <= stdl && stdr <= r) return val[root];
		int res = 0, mid = (stdl + stdr) >> 1;
		if (l <= mid) res = query(l, r, lson, stdl, mid);
		if (r > mid) res = max(res, query(l, r, rson, mid + 1, stdr)); 
		return res;
	}
}	tr;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> n;
	rep (i, 1, n) {
		cin >> x[i] >> d[i];
		unq.emplace_back(x[i]);
		srt.emplace_back(x[i], d[i]);
	}
	sort(all(unq));
	sort(all(srt));
	rep (i, 0, n - 1) {
		x[i + 1] = srt[i].fst;
		d[i + 1] = srt[i].sed;
	}
	dp[n + 1][0] = 1;
	dp[n][0] = dp[n][1] = 1;
	tr.modify(n, n);
	per (i, n - 1, 1) {
		dp[i][0] = (dp[i + 1][0] + dp[i + 1][1]) % MOD;
		int pos = upper_bound(all(unq), x[i] + d[i] - 1) - unq.begin();
		int far = max(i, tr.query(i, pos)); tr.modify(i, far);
		dp[i][1] = (dp[far + 1][0] + dp[far + 1][1]) % MOD;
	}
	cout << (dp[1][0] + dp[1][1]) % MOD << endl;
	return 0;
}

Measured memory_bytes: 8040
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll k,a,b,i,j,p=100,c=0;
    cin>>k;
    double x=1.01;

    while(p<k)
    {
        p=p*x;
        c++;
    }
    cout<<c<<endl;



    return 0;
}


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

int max(int n){
  while(n>=10){
    n /= 10;
  }
  return n;
}

int main(){
  int n,i,j;
  cin >> n;
  vector<vector<int>> a(10,vector<int>(10,0));
  for(i=1;i<=n;i++){
    a.at(max(i)).at(i%10)++;
  }
  
  int s=0;
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      s += a.at(i).at(j)*a.at(j).at(i);
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define si second
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define AS 200001
#define mod 1000000007
struct activity
{
	int A, B, C;
};
int solve(vector<activity>ar, int n) {
	int dp[n + 1][3];
	dp[1][0] = ar[1].A;
	dp[1][1] = ar[1].B;
	dp[1][2] = ar[1].C;
	for (int i = 2; i <= n; i++) {
		dp[i][0] = ar[i].A + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = ar[i].B + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = ar[i].C + max(dp[i - 1][0], dp[i - 1][1]);
	}
	return max({dp[n][0], dp[n][1], dp[n][2]});
}
int main() {
	fastIO
	int n;
	cin >> n;
	vector<activity>ar;
	ar.resize(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> ar[i].A;
		cin >> ar[i].B;
		cin >> ar[i].C;
	}
	cout << solve(ar, n);
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    int p[n];
    for(int i=0; i<n; i++){
        cin>>p[i];
    }
    sort(p, p+n);
    int sum=0;
    for(int i=0; i<k; i++){
        sum+=p[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

string s;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    if ('A' <= s[0] && s[0] <= 'Z') cout << 'A' << E;
    else cout << 'a' << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h> 
using namespace std;
#define pb push_back
#define ll long long int
#define vi vector<int>
#define ii pair<int,int>
#define vli vector<ll>
#define graph vector<vector< int > >
#define vpi vector<pair<int ,int> >
#define vpli vector<pair<ll ,ll> >
#define mp make_pair
#define F first
#define S second
#define mod 37
#define INF (ll)1e18
#define wh(a) cout<<#a<<"  is  "<<a<<endl;
#define INI(a) memset(a,0,sizeof(a))
#define LIMIT 400000
#define PI 3.14159265358

void solve(){
    int n,m;
    cin>>n>>m;
    graph g(n+1);
    for(int i=0;i<m;++i){
        int u,v;
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    int par[n+1];
    int mark[n+1];
    INI(mark);
    //bfs
    queue<int> q;
    q.push(1);
    mark[1]=1;
    int count=1;
    while(!q.empty()){
        int cur= q.front();
        q.pop();
        for(auto x:g[cur]){
            if(mark[x]==0){
                q.push(x);
                mark[x]=1;
                par[x]=cur;
                count++;
            }
        }
    }
    if(count==n){
        cout<<"Yes"<<endl;
        for(int i=2;i<=n;++i){
            cout<<par[i]<<endl;
        }
    }
    else{
        cout<<"No"<<endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // #endif
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 10576
#define DEBUG 0
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2019/8/18 21:01:15
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using ll = long long;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a)
  {
    mint b{a};
    return *this *= b.power(MOD - 2);
  }
  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 operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
class combination
{
public:
  vector<mint> inv, fact, factinv;
  static int MAX_SIZE;
  combination() : inv(MAX_SIZE), fact(MAX_SIZE), factinv(MAX_SIZE)
  {
    inv[1] = 1;
    for (auto i = 2; i < MAX_SIZE; i++)
    {
      inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
    }
    fact[0] = factinv[0] = 1;
    for (auto i = 1; i < MAX_SIZE; i++)
    {
      fact[i] = mint(i) * fact[i - 1];
      factinv[i] = inv[i] * factinv[i - 1];
    }
  }
  mint operator()(int n, int k)
  {
    if (n >= 0 && k >= 0 && n - k >= 0)
    {
      return fact[n] * factinv[k] * factinv[n - k];
    }
    return 0;
  }
};
int combination::MAX_SIZE = 3000010;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// constexpr double epsilon = 1e-10;
// constexpr ll infty = 1000000000000000LL;
// constexpr int dx[4] = {1, 0, -1, 0};
// constexpr int dy[4] = {0, 1, 0, -1};
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}

int main()
{
  int N;
  cin >> N;
  vector<double> A(N);
  for (auto i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  double X{0.0};
  for (auto i = 0; i < N; i++)
  {
    X += 1 / A[i];
  }
  cout << fixed << setprecision(12) << 1 / X << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long T = sc.nextLong();
		
		long start = sc.nextLong();
		long[] ruiseki = new long[N-1];
		for (int i = 1; i < N; i++) {
			long ti = sc.nextLong();
			ruiseki[i-1] = ti - start;
			
			start = ti;
		}
		
		long ans = T;
		for (int i = 0; i < ruiseki.length; i++) {
			ans += Math.min(T, ruiseki[i]);
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 88448