akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

unsigned long long modpow(unsigned long long n, unsigned long long k, unsigned long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    string s,t;
    cin >> s >> t;
    vector<vector<int>>dp(3010,vector<int>(3010,0));
    for(int i = 0;i<s.size();i++) dp[i][0] = 0;
    for(int i = 0;i<t.size();i++) dp[0][i] = 0;

    for(int i = 1;i<=s.size();i++){
        for(int j = 1;j<=t.size();j++){
            if(s[i-1]==t[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    int i = s.size();int j = t.size();
    vector<char>ans;
    while(i>0&&j>0){
        if(s[i-1]==t[j-1]){
            ans.push_back(s[i-1]);
            i--;j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    }
    for(int i = ans.size()-1;i>=0;i--){
        cout << ans[i];
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif
	
	ll n;
	int m;
	
	cin>>n>>m;
	
	while(m--)
	{
	    ll a;
	    cin>>a;
	    n-=a;
	}
	
	if(n<0LL) cout << -1 << endl;
	else cout << n << endl;
}

Measured memory_bytes: 3644
// Problem : C - Many Requirements
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

struct Query {
	int a, b, c, d;
};

int n, m, qq, ans = 0;
vector<Query> queries;
vi seq;

void backtrack(int pos, int val) {
	//cout << pos << " " << val << endl;
	if (pos == n) {
		int tmp = 0;
		for (auto q: queries) {
			if (seq[q.b - 1] - seq[q.a - 1] == q.c) {
				tmp += q.d;
			}
		}
		ans = max(ans, tmp);
		return;
	}
	FOR(i, val, m) {
		seq.pb(i);
		backtrack(pos + 1, i);
		seq.pop_back();
	}
}

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m >> qq;
	REP(_, qq) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		queries.pb({a, b, c, d});
	}
	backtrack(0, 1);
	cout << ans << endl;
	return 0;
}
 


Measured memory_bytes: 3612
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    if A == B:
        ret = C
    elif B == C:
        ret = A
    else:
        ret = B
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


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

int main() {
	int health, moves;
	cin >> health >> moves;
	
	int totalMoves = 0;
	for(int i = 0; i < moves; i++){
		int x;
		cin >> x;
		totalMoves += x;
	}
	
	cout << (totalMoves >= health ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define inf 10000000000000
typedef long long ll;
using namespace std;
const int maxN = 55;
const int maxM = 1e6;
int siz[maxN], p[maxN];
ll m[maxN], N, X, D, dp[maxN * maxN * maxN];
bool ok[maxN][maxN], in[maxN];
//ll dp[2][maxM];
struct node{
	ll m; int siz; int idx; ll num, d;
}a[maxN], t[maxN];
bool cmp(const node& e1, const node& e2) {
	if(e1.siz * e2.m == e2.siz * e1.m) return e1.siz < e2.siz;
	return e1.siz * e2.m > e2.siz * e1.m;
}
void dfs(int u) {
	a[u].siz = 1;
	for(int i = 1; i <= N; ++i) {
		if(ok[u][i]) {
			dfs(i); a[u].siz += a[i].siz; a[u].m += a[i].m;
		}
	}
	//cout << u << ' ' << a[u].siz << ' ' << a[u].m << endl;
}

int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%lld%lld%lld", &N, &X, &D);
	//cout << D << "&&&&&&&&&&&&&&&&" << endl;
	scanf("%lld", &a[1].m);  a[1].d = inf;
	for(int i = 2; i <= N; ++i) a[i].d = D, a[i].idx = i, scanf("%lld%d", &a[i].m, &p[i]), ok[p[i]][i] = 1, a[i].num = max(0ll, D - 50);
	a[1].num = inf;
	dfs(1);
	for(int i = 1; i <= 2500 * 50; ++i) dp[i] = inf;
	for(int i = 1; i <= N; ++i) {
			for(int j = 1; j <= min(50ll, D); j++) {
				for(int k = 2500 * 50; k >= 0; --k) {
						if(k - a[i].siz >= 0) dp[k] = min(dp[k], dp[k - a[i].siz] + a[i].m);
				}
			}
	}
	sort(a + 1, a + 1 + N, cmp);
	ll ans = 0;
	for(int i = 0; i <= 2500 * 50; ++i) {
		if(dp[i] > X) continue;
		ll x = X - dp[i]; ll cnt = i; 
		for(int j = 1; j <= N; ++j) {
			ll tmp = min(x / a[j].m, a[j].num);
			x -= tmp * a[j].m; cnt += tmp * a[j].siz;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, S: str):
    counter = 0
    for i, s in enumerate(S):
        if i > 0:
            if s == 'L' and S[i-1] == 'L':
                counter += 1
        if i < N-1:
            if s == 'R' and S[i+1] == 'R':
                counter += 1
    n = N - counter
    print(N - max(1, n - 2 * K))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.io.*;

/**
 * Created by Ayushi on 21 Jun 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        //StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n = Long.parseLong(br.readLine());
        br.close();
        long l; //, r;
        l = 0;
        long c;
        int t;
        for (t = 1; t <= 13; t++) {
            c = (long) (l + (Math.pow(26, t)));
            if (n <= c) {
                //r = c;
                break;
            }
            else l = c;
        }
        long d = (n - l) -1;
        long[] a = new long[t];
        for (int i = t-1; i >= 0; i--) {
            a[i] = Math.max((d%26) + 97, 97);
            d = d/26;
        }
        for (int j = 0; j < t; j++) {
            System.out.print((char)a[j]);
            //System.out.println(a[j]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 32628
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << 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()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    char a;
    in(a);

    if (tolower(a) == a)
    {
        outl("a");
    }
    else
    {
        outl("A");
    }
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int N;
  cin >> N;
  if(N%10 == N/100) cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
char city[100][100];
bool done[100][100];
int keiro[100][100];
int dist[100][100];
int h,w;

int bfs(int x, int y){
    //if(x < 0 || x >= w || y < 0 || y >= h || city[y][x] == '#') return;
    queue<P> que;
    //int dist[h][w];
    int distance = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            done[i][j] = false;
        }
    }

    // 初期条件 (頂点 0 を初期ノードとする)
    P hoge;
    hoge.first = x;
    hoge.second = y;
    que.push(hoge); // 0 を橙色頂点にする
    dist[x][y] = 0;
    done[x][y] = true;
    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        //dist++;
        P v = que.front(); // キューから先頭頂点を取り出す
        que.pop();
        if(v.first+1 < h && v.first+1 >= 0 && v.second < w && v.second >= 0 && !done[v.first+1][v.second] && city[v.first+1][v.second] != '#'){
            hoge.first = v.first+1;
            hoge.second = v.second;
            que.push(hoge);
            dist[hoge.first][hoge.second] = dist[v.first][v.second]+1;
            distance = max(distance,dist[hoge.first][hoge.second]);
            done[hoge.first][hoge.second] = true;
        }
        if (v.first-1 < h && v.first-1 >= 0 && v.second < w && v.second >= 0 && !done[v.first-1][v.second]&& city[v.first-1][v.second] != '#'){
            hoge.first = v.first-1;
            hoge.second = v.second;
            que.push(hoge);
            dist[hoge.first][hoge.second] = dist[v.first][v.second]+1;
            distance = max(distance,dist[hoge.first][hoge.second]);
            done[hoge.first][hoge.second] = true;
        }
        if(v.first < h && v.first >= 0 && v.second+1 < w && v.second+1 >= 0 && !done[v.first][v.second+1]&& city[v.first][v.second+1] != '#'){
            hoge.first = v.first;
            hoge.second = v.second+1;
            que.push(hoge);
            dist[hoge.first][hoge.second] = dist[v.first][v.second]+1;
            distance = max(distance,dist[hoge.first][hoge.second]);
            done[hoge.first][hoge.second] = true;
        }
        if(v.first < h && v.first >= 0 && v.second-1 < w && v.second-1 >= 0 && !done[v.first][v.second-1]&& city[v.first][v.second-1] != '#'){
            hoge.first = v.first;
            hoge.second = v.second-1;
            que.push(hoge);
            dist[hoge.first][hoge.second] = dist[v.first][v.second]+1;
            distance = max(distance,dist[hoge.first][hoge.second]);
            done[hoge.first][hoge.second] = true;
        }
    }
    return distance;
}

int main(){
    cin >> h >> w;
    char temp;
    bool judge = false;
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> temp;
            city[i][j] = temp;
            done[i][j] = false;
        }
    }

    //dfs(startx,starty);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(city[i][j] != '#'){
                ans = max(ans,bfs(i,j));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#include <cstring>
using namespace std;
int dp[100000];
int n,a[100000],k;

int topdown()
{
	dp[n-1]=0;

	for(int i=n-2;i>=0;i--)
	{
		dp[i]=1e9;
		for(int j=1;j<=k;j++)
		{
          	if(i+j<n)
				dp[i]=min(dp[i] , abs(a[i]-a[i+j])+dp[i+j]);
		}
	}
	return dp[0];
}

int main()
{
  	ios_base::sync_with_stdio(0);            //fast input and output
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];

	cout<<topdown();

	return 0;
}


Measured memory_bytes: 4424
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}
ll n;
void solve(char a,ll k,ll c,string s){
    if (k==n-1){
        cout << s << endl;
    }else{
        s+=a;
        if (c>a-'a'){
            for (ll i=0;i<=c;i++){
                s[k+1]='a'+i;
                solve('a'+i,k+1,c,s);
            }
        }else{
            for (ll i=0;i<=c+1;i++){
                s[k+1]='a'+i;
                solve('a'+i,k+1,c+1,s);
            }
        }
    }
}

int main(){
    cin >> n;
    string s;
    s='a';
    solve('a',0,1,s);
    return 0;
}



Measured memory_bytes: 1536
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, c = 0, h, k;
    cin >> n >> k;
    for (ll i = 0; i < n; i++)
        cin >> h, c += h >= k;
    cout << c;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
# print(N, M)
# print(ks)
# print(p)

ans = 0

import itertools
for i in itertools.product([0,1], repeat=N):
  righted = 0
  for iter, j in enumerate(ks):
  #  print(iter, j )
    cnt = 0
    for k in range(1,len(j)):
      cnt += i[j[k]-1]
    if cnt % 2 == p[iter]:
      righted += 1
  if len(ks) == righted:
    ans += 1
    
print(ans)


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

vector<pair<int,bool> > vec;
int n,t;
int main()
{
    cin >>n >>t;
    int l,r;
    while(n--)
    {
        cin >>l >> r;
        vec.push_back(pair<int,bool>(l,true));
        vec.push_back(pair<int,bool>(r,false));
    }
    sort(vec.begin(),vec.end());

    int maxim=0;
    int result=0;
    int size=vec.size();
    for (int i= 0; i < size; i++)
    {
        result+=vec[i].second?1:-1;
        while (i+1<size && vec[i].first==vec[i+1].first)
        {
            result+=vec[i+1].second?1:-1;
            i++;
        }
        maxim=result>maxim?result:maxim;
    }

    cout<< maxim << endl;
    return 0;
}




Measured memory_bytes: 4928
#include<iostream>
#include<deque>
#include<algorithm>
#include<vector>
#include<cassert>
#include<climits>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX (2*1000000+2)

using namespace std;

int a[MAX];

int main(){
  int N;
  cin >> N;
  rep(i,N)cin >> a[i];

  deque<int> deq;

  int ans = 0;
  rep(i,N){
    /*
    cout << endl << i << " deq - state " << a[i] << " ans = " << ans << endl;
    rep(j,deq.size()){
      cout << deq[j] << " ";
    } cout << endl;
    */
    if(deq.empty() || ( !deq.empty() && deq.front() < a[i] ) ){
      deq.push_front(a[i]);
      ans++;
      continue;
    }

    int tmp;
    while(!deq.empty() && deq.front() > a[i]){
      tmp = deq.front();
      deq.pop_front();
    }


    if( !deq.empty() && deq.front() == a[i] )continue;
    deq.push_front(a[i]);
    ans++;

    if( !deq.empty() && deq.front() < a[i] ){
      deq.push_front(tmp);
    }

  }
  /*
    cout << endl <<  " deq - state last" << endl;
    rep(j,deq.size()){
      cout << deq[j] << " ";
    } cout << endl;
  */
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2820
from collections import deque
import sys, copy, itertools,heapq
input = sys.stdin.readline

n = int(input())
D = [list(map(int, input().split())) for i in range(n)]

count = 0
ans = 'No'

for i in range(n):
  if D[i][0] == D[i][1]:
    count += 1
  else:
    count = 0
  if count == 3:
    ans = 'Yes'
    break

print(ans)

Measured memory_bytes: 68632
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.min;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void sort(int a[], int n) {
		if (n == 0) {
			return;
		}
		for (int i = 1; i < n; i++) {
			int j = i;
			int ca = a[i];
			do {
				int nj = (j - 1) >> 1;
				int na = a[nj];
				if (ca <= na) {
					break;
				}
				a[j] = na;
				j = nj;
			} while (j != 0);
			a[j] = ca;
		}
		int ca = a[0];
		for (int i = n - 1; i > 0; i--) {
			int j = 0;
			while ((j << 1) + 2 + Integer.MIN_VALUE < i + Integer.MIN_VALUE) {
				j <<= 1;
				j += (a[j + 2] > a[j + 1]) ? 2 : 1;
			}
			if ((j << 1) + 2 == i) {
				j = (j << 1) + 1;
			}
			int na = a[i];
			a[i] = ca;
			ca = na;
			while (j != 0 && a[j] < ca) {
				j = (j - 1) >> 1;
			}
			while (j != 0) {
				na = a[j];
				a[j] = ca;
				ca = na;
				j = (j - 1) >> 1;
			}
		}
		a[0] = ca;
	}

	static void solve() throws Exception {
		int n = scanInt(), m = scanInt(), v = scanInt(), p = scanInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanInt();
		}
		sort(a, n);
		int l = -1, r = n - p;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (a[mid] + m < a[n - p]) {
				l = mid;
				continue;
			}
			if (v <= p) {
				r = mid;
				continue;
			}
			long have = (long) m * (v - p);
			int cutoff = a[mid] + m;
			for (int i = 0; i < n - p + (mid < n - p ? 1 : 0); i++) {
				if (i != mid) {
					have -= min(min(cutoff - a[i], m), have);
				}
			}
			if (have == 0) {
				r = mid;
			} else {
				l = mid;
			}
		}
		out.print(n - r);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 37760
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;

int main(){

        int n;
        cin >> n;

    int  a = n%10;

        if(a==2||a==4||a==5||a==7||a==9)cout << "hon" << endl;
        else if(a==0||a==1||a==6||a==8)cout << "pon" << endl;
        else cout << "bon" << endl;

}

Measured memory_bytes: 3624
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
   T : Integer;
begin
   Get (A);
   Get (B);
   Get (T);
   Put_Line (Integer'Image (T/A*B));
end Solve;

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
       

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

  ll ans = 0;
  for (int i = 0; i < n + 1; ++i) {
    ans += (a[i] * (a[i] - 1)) / 2;
  }
  
  for (int i = 0; i < n; ++i) {
    cout << ans - (a[b[i]] - 1) << endl;
  }
}


Measured memory_bytes: 5760
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
   SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD SYSIN.
   01 INDATA  PIC X(60000).
WORKING-STORAGE SECTION.
01 ln         PIC X(400).
01 maxlen     PIC 9(10) VALUE 100 COMP.
01 cur        PIC 9(10) VALUE 1 COMP.
01 i          PIC 9(10) VALUE 1 COMP.
01 j          PIC 9(10) COMP.
01 len        PIC 9(10) COMP.
01 accum      PIC 9(10) VALUE ZERO COMP.
01 ans        PIC 9(10).
01 zs         PIC Z(9)9.
01 N          PIC 9(10).
01 M          PIC 9(10).
01 A          PIC 9(10).

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO N M.
  MOVE M TO maxlen.
  OPEN INPUT SYSIN.
  READ SYSIN INTO INDATA.
  CLOSE SYSIN.
  PERFORM maxlen TIMES
    PERFORM VARYING j FROM cur BY 1 UNTIL INDATA(j:1) = SPACE
    END-PERFORM
    COMPUTE len = j - cur
    MOVE INDATA(cur:len) TO A
    ADD A TO accum
    COMPUTE cur = j + 1
    ADD 1 TO i
  END-PERFORM.
  IF N < accum THEN
    DISPLAY -1
  ELSE
    COMPUTE ans = N - accum
    MOVE ans TO zs
    DISPLAY FUNCTION TRIM(zs)
  END-IF.
  STOP RUN.


Measured memory_bytes: 3880
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 200010;
const int MOD = 1000000007;
const int INF = 1000000010;

int n, m;
int x[MAXN], y[MAXN];

unordered_map<int, int> v;

void add(int x, int p)
{
	for (; x <= INF; x += x&-x)
	{
		v[x] += p;
		if (v[x] >= MOD) v[x] -= MOD;
	}
}

int get(int x)
{
	int p = 0;
	for (; x; x -= x&-x)
	{
		p += v[x];
		if (p >= MOD) p -= MOD;
	}
	return p;
}

int main()
{
	
	n = inp();
	m = inp();
	for (int i = 1; i <= n; ++ i)
		x[i] = inp();
	for (int i = 1; i <= m; ++ i)
		y[i] = inp();
	vector<pii> p;
	for (int i = 1; i <= n; ++ i)
	{
		int k = lower_bound(y+1, y+m+1, x[i])-y;
		if (k <= m && k >= 2)
			p.emplace_back(x[i]-y[k-1], y[k]-x[i]);
	}
	sort(p.begin(), p.end(), [](const pii &a, const pii &b)
	{
		return a.X == b.X ? a.Y > b.Y : a.X < b.X;
	});
	p.erase(unique(p.begin(), p.end()), p.end());
	add(0+1, 1);
	for (auto e : p)
	{
		int a, b;
		tie(a, b) = e;
		add(b+1, get(b));
	}
	cout << get(1000000001) << endl;
	
	return 0;
}


Measured memory_bytes: 60384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int Y=stdIn.nextInt();
		int z=0,y=0,fin=0;
		while(z<N+1){
			while(y<N+1){
				if(z+y>N)
					break;
				if(z*10000+y*5000+(N-y-z)*1000==Y){
					fin=1;
					break;
				}
				y++;
			}
			if(fin==1)
				break;
			z++;y=0;
		}
		if(fin==1)
			System.out.println(z+" "+y+" "+(N-y-z));
		else
			System.out.println("-1 -1 -1");
	}

}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int flag[200010];

signed main()
{
    int N,M; cin>>N>>M;
    REP(i,M){
        int a,b; cin>>a>>b;
        if(a==1) flag[b]|=1;
        if(b==N) flag[a]|=2;
    }
    for(int i=2;i<=N-1;i++){
        if(flag[i]==3){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
 
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#define ll long long
#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define sz(a) int((a).size())
#define shit while(t--)
#define fr for(int i=0;i<n;i++)
int maxo=1e9+7;
using namespace std;
int arr[95];
ll dp[20001];
const int mod= 1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,x;
    string s;
    cin>>n>>s;
    if(n%2==0)
    {
        string a="";
        string b="";
        for(int i=0; i<n/2; i++)
        {
            a+=s[i];
        }
        for(int j=n/2; j<n; j++)
        {
            b+=s[j];
        }
        if(a==b)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3640
using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
#include <stdio.h>
int main()
{
	int n;
	while(cin>>n&&n){
		int num[10]={},tmp;
		while(n--){cin>>tmp;num[tmp]++;}
		for(int i=0;i<10;i++){
			if(num[i])for(int j=0;j<num[i];j++)printf("*");
			else printf("-");
			printf("\n");
		}
	}
    return 0;
}

Measured memory_bytes: 1112
use std::cmp::min;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let k: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut hv = vec![0i64; n];
    for i in 0..n {
        hv[i] = read(&mut stdin_lock, &mut buf, b'\n');
    }

    hv.sort();
    let mut ans = 1_000_000_000;
    for i in 0..n - k + 1 {
        ans = min(ans, hv[i + k - 1] - hv[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, m;
int h[100000];
vector<int> et[100000];

signed main() {
	int i, j;
	
	cin >> n >> m;
	rep(i, n) cin >> h[i];
	
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		et[a].push_back(b);
		et[b].push_back(a);
	}
	
	int ans = 0;
	rep(i, n) {
		rep(j, et[i].size()) {
			int nv = et[i][j];
			if (h[nv] >= h[i]) break;
		}
		if (j >= et[i].size()) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    ll n,k;
    std::cin >> n>>k;
    ll cntww = 0;
    ll cntbb = 0;
    vector<vector<ll>> cntw(2*k,vector<ll>(2*k,0)),cntb(2*k,vector<ll>(2*k,0));
    for (int i = 0; i < n; i++) {
        ll x,y;
        char c;
        std::cin >> x>>y>>c;
        x %= 2*k;
        y %= 2*k;
        if(c=='W'){
            cntw[x][y]++;
            cntww++;
        }else{
            cntb[x][y]++;
            cntbb++;
        }
    }
    vector<vector<ll>> dpw(2*k+1,vector<ll>(2*k+1,0)),dpb(2*k+1,vector<ll>(2*k+1,0));
    
    for (int i = 0; i < 2*k; i++) {
        for (int j = 0; j < 2*k; j++) {
            dpw[i+1][j+1] = dpw[i+1][j]+dpw[i][j+1]-dpw[i][j]+cntw[i][j];
            dpb[i+1][j+1] = dpb[i+1][j]+dpb[i][j+1]-dpb[i][j]+cntb[i][j];
        }
    }
    ll ans = 0;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < k; j++) {
            ll cb = 0;
            ll cw = 0;
            
            cb = 
            dpb[i+k][j+k]-dpb[i+k][j]-dpb[i][j+k]+dpb[i][j]*2+
            dpb[i][2*k]-dpb[i][j+k]+
            dpb[2*k][j]-dpb[i+k][j]+
            dpb[2*k][2*k]-dpb[2*k][j+k]-dpb[i+k][2*k]+dpb[i+k][j+k];
            cw = 
            dpw[i+k][j+k]-dpw[i+k][j]-dpw[i][j+k]+dpw[i][j]*2+
            dpw[i][2*k]-dpw[i][j+k]+
            dpw[2*k][j]-dpw[i+k][j]+
            dpw[2*k][2*k]-dpw[2*k][j+k]-dpw[i+k][2*k]+dpw[i+k][j+k];

            // std::cout << cb<<" "<<cntww-cw<<" "<<cw<<" "<<cntbb-cb << std::endl;
            ans = max(ans, max(cb+cntww-cw, cw+cntbb-cb));
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 128652
import sys
input = sys.stdin.readline
n = int(input())
chk = []
res = []
for i in range(n):
  s = input().strip()
  m = 0
  e = 0
  for i in s:
    if i == ')':
      e -= 1
      m = min(m,e)
    else:
      e += 1
  if e >= 0:
    chk.append((m,e))
  else:
    res.append((-1*e+m,-1*e))
  
from operator import itemgetter
res.sort(key=itemgetter(0),reverse=True)
chk.sort(key=itemgetter(0),reverse=True)
ans = 'Yes'
st = 0
for i,j in chk:
  if i+st < 0:
    ans = 'No'
    break
  st += j
  
sr = 0
for i,j in res:
  if i+sr < 0:
    ans = 'No'
    break
  sr += j
  
if st != sr:
  ans = 'No'

print(ans)

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

char t[] = "XYZABCDEFGHIJKLMNOPQRSTUVW";
char a[1001];

int main() {
	cin>>a;
	for(int i=0;i<strlen(a);i++)a[i]=t[a[i]-'A'];
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 1140
from math import sqrt
n,d=map(int,input().split())
a=[]
for w in range(n):
    a.append([int(i) for i in input().split()])
c=0
for i in range(n-1):
    for j in range(i+1,n):
        s=0
        for k in range(d):
            s+=(a[i][k]-a[j][k])**2
        if sqrt(s)%1==0:
            c+=1
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;


int n;
int ans;


int main()
{
    cin >> n;
    n = n/5;
    n = n*5;
    ans = n/500*1000;
    ans += n%500;
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1];
	a[0]=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int count=0;
	for(int i=1;i<=n;i+=2){
		if(a[i]%2!=0){
			count++;
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define scan(arr,n) for(int i=0;i<n;i++) cin>>arr[i]
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

signed main()
{
	ios_base::sync_with_stdio(false);   
    cin.tie(NULL);

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	string str;
    	cin>>str;
    	if(str=="ABC")
    		cout<<"ARC"<<endl;
    	else
    		cout<<"ABC"<<endl;
    	
    	
    }
    return 0;
}

Measured memory_bytes: 3656
/* 十 聖イシドールスよ、迷えるプログラマを導き給え！ 十 */
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <deque>

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

//const long long INF = 1LL << 60;
const int INF = 1e9;

//               {up, left, right, down} 
const int di[] = {-1, 0, 1, 0};
const int dj[] = { 0,-1, 0, 1};

// dequeを使って、コストの低いものは前に、コストの高いものは後に回せば良い。
// ワープの実装は、左上(-2, -2)から右下(2, 2)まで全探索する 
int main()
{
	int H, W;
	std::cin >> H >> W;

	int Ch, Cw;
	std::cin >> Ch >> Cw;
	int Dh, Dw;
	std::cin >> Dh >> Dw;
	Ch--; Cw--; Dh--; Dw--;

	std::vector<std::string> S(H);
	rep( i, H )
	{
		std::cin >> S[i];
	}

	std::vector<std::vector<int>> dist( H, std::vector<int>( W, INF ) );	// コスト(条件判定上-1だとまずい)  
	std::deque<std::pair<int, int>> q;	// 座標を記録する 
	// コスト0の座標[でっく-------でっく]コスト1の座標
	// ⇑のように追加することで、距離順に探索することが出来る
	
	// 最初の1マスを入れる
	dist[Ch][Cw] = 0;
	q.emplace_back( Ch, Cw );

	// bfsをする 
	while ( !q.empty() )
	{
		int i = q.front().first;
		int j = q.front().second;
		int d = dist[i][j];
		q.pop_front();

		// 縦横にいけるかどうか
		rep( v, 4 )
		{
			int ni = i + di[v];
			int nj = j + dj[v];
			//printf( "[%d:%d]", ni, nj );
			// マップの外に出た 
			if( ni < 0 || ni >= H || nj < 0 || nj >= W )
			{
				//printf( "-c01\n" );
				continue;
			}
			// 壁 	
			else if( S[ni][nj] == '#' )
			{
				//printf( "-c02\n" );
				continue;
			}
			// より短く来ることが出来る 
			else if( dist[ni][nj] <= d )
			{
				//printf( "-c03\n" );
				continue;
			}
			// それ以外 
			else
			{
				dist[ni][nj] = d;
				q.emplace_front( ni, nj );	// コスト0は前側に 
			}
		}
		// ワープ出来るかどうか 
		for( int ei = -2; ei <= 2; ei++ )
		{
			//printf( " execute warp1" );
			for( int ej = -2; ej <= 2; ej++ )
			{
				//printf( " execute warp2" );
				int ni = i + ei;
				int nj = j + ej;
				// マップの外に出た 
				if( ni < 0 || ni >= H || nj < 0 || nj >= W )
				{
					continue;
					//printf( "-c11\n" );
				}
				// 壁 	
				else if( S[ni][nj] == '#' )
				{
					continue;
					//printf( "-c12\n" );
				}
				// ワープせずに来ることが出来る 
				else if( dist[ni][nj] <= d + 1 )
				{
					continue;
					//printf( "-c13\n" );
				}
				// それ以外 
				else
				{
					dist[ni][nj] = d + 1;
					q.emplace_back( ni, nj );	// コスト+1は後側に 
				}
			}
		}
		//printf( "\n" );
	}

	rep( i, H )
	{
		rep( j, W )
		{
			//printf( "[%d:%d]%d", i, j, dist[i][j] );
		}
		//printf( "\n" );
	}

	int ans = dist[Dh][Dw];
	if( ans == INF )
	{
		ans = -1;
	}
	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 9496
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int k;
    cin >> k;
    vector<ll> lunlun;
    rep(i, 9) {
        lunlun.push_back(i+1);
    }
    int temp = 0;
    while (lunlun.size()<=k) {
        ll now = lunlun[temp];
        ll tail = now%10;
        now *= 10;
        rep(i, 3) {
            ll next = tail+i-1;
            if (next<=9 && next>=0) {
                lunlun.push_back(now+next);
            }
        }
        temp++;
    }
    ll ans = lunlun[k-1];
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include<cstdio>
#include<algorithm>
using namespace std;
int a[200005],b[1000005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		for(int j=a[i];j<=a[n];j+=a[i])
		{
			b[j]++;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(b[a[i]]==1)
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6404
s = list(input())
t = list(input())
s.sort()
t.sort()
t.reverse()

ss = "".join(s)
tt = "".join(t)

st = [ss,tt]
sst = [ss, tt]
sst.sort()

if ss == tt:
    print("No")
elif st == sst:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).

#define in input_int()
#define ins input_string()
int input_int(){int a;cin>>a;return a;}
string input_string(){string s;cin>>s;return s;}
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};



int n,m,k,a,b,c,d,x,y,arr[N];
string s;
void solve()
{
    
    cin>>x>>k>>d;
    int ans=abs(x);
    
    int need=abs(x)/d;
    if(k<need)
    {
        need=k;
        k=0;
    }
    else
    {
        k-=need;
    }


    if(x<0)
    {
        x+=d*need;

        if(k%2)
        {
            x+=d;
        }

    }
    else
    {
        x-=d*need;

        if(k%2)
        {
            x-=d;
        }
    }


    cout<<abs(x);





}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}
//       clang++ c.cpp ; ./a.out < a.txt ;  

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
ll N;
const ll MAX_N=1e5;
string S[MAX_N];
ll ABC[3];
char ope[MAX_N+1];
ll ctoi(char c){
	return c-'A';
}
bool dfs(ll i){
	if(i==N){
		return true;
	}
	if(ABC[ctoi(S[i][0])]>0){
		
		ABC[ctoi(S[i][0])]--;
		ABC[ctoi(S[i][1])]++;
		ope[i]=S[i][1];
		if(dfs(i+1)){
			return true;
		}
		ABC[ctoi(S[i][0])]++;
		ABC[ctoi(S[i][1])]--;
		

	}
	if(ABC[ctoi(S[i][1])]>0){
		
		ABC[ctoi(S[i][1])]--;
		ABC[ctoi(S[i][0])]++;
		ope[i]=S[i][0];
		if(dfs(i+1)){
			return true;
		}
		ABC[ctoi(S[i][1])]++;
		ABC[ctoi(S[i][0])]--;
		
		
	}
	return false;
}

int main(){
	cin.tie(0);
	cin.sync_with_stdio(false);
	cin>>N;
	REP(i,3)cin>>ABC[i];
	REP(i,N)cin>>S[i];
	if(dfs(0)){
		cout<<"Yes"<<endl;
		REP(i,N){
			cout<<ope[i]<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 10008
#include <cstdio>
using namespace std;

int main ()
{
  int a, b, c;
  int count = 0;

  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);

  for (int i = a; i <= b; i++) {
    if (c % i == 0) {
      count++;
    }
  }
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,t,m,n,a)vector<vector<t> > name(m,vector<t> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int n;
	std::cin >> n;
	bool han=1;
	rep(l,n){
		int tt=0,xx=0,yy=0;
		int t,x,y;
		std::cin >>t>>x>>y ;
		if(abs(x-xx)+abs(y-yy)>t-tt)han=0;
		if((abs(x-xx)+abs(y-yy))%2!=(t-tt)%2)han=0;
		tt=t;yy=y;xx=x;
		
	}
	if(han)std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  char S[99];
  int N,count,i;
  N=0;
  count=1;
  scanf("%s",S);
  
  while(S[N]!='\0') N++;
  if(N%2==0) count=-1;
  
  for(i=0;i<N/2;i++){
    if(S[i]!=S[N-i-1]){
      count=-1;
      break;
    }
  }
  for(i=0;i<N/4;i++){
    if(S[i]!=S[(N-1)/2-i-1] || S[(N+3)/2+i-1]!=S[N-i-1]){
      count=-1;
      break;
    }
  }
  
  if(count==-1) printf("No");
  else printf("Yes");
  
  return 0;
}

Measured memory_bytes: 128
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
using namespace std;

int main() {
	int n;
	string A,B;
	int T=0,H=0;
	cin>>n;

	for(int i=0;i<n;i++){
		cin>>A>>B;
		if(A>B)T+=3;
		else if(A<B)H+=3;
		else{
			T+=1,H+=1;
		}
	}
	cout<<T<<" "<<H<<endl;
	return 0;
}

Measured memory_bytes: 3160
def main():
    n = int(input())
    s = input()
    ans = 0
    L, R = 0, n-1
    while L < R:
        if s[L] != "W":
            L += 1
        elif s[R] != "R":
            R -= 1
        else:
            ans += 1
            L += 1
            R -= 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9484
#include <cstdio>
#include <queue>
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 1e5 + 1;
typedef unsigned long long ull;
const ll INF = 1ll<<60;
int m,n,t;
int main()
{
    string s;
    cin >> s;
    int len = s.size();
    while (len--)
        printf("x");
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		
		for(int i=0;i<=x;i++) {
			int turu = x - i;
			if(2 * turu + 4 * i == y) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");

	}

}


Measured memory_bytes: 35860
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int Knapsack(int N,int W, vector<int> v, vector<int> w)
{
	vector< vector<int> > V(N+1,vector<int>(W+1));
	for(int i=0;i<=N;++i)
		for (int j = 0; j <= W; ++j) {
			if (i == 0 || j == 0) V[i][j] = 0;
			else if (j >= w[i - 1]) V[i][j] = max(v[i - 1] + V[i - 1][j - w[i - 1]], V[i - 1][j]);
			else V[i][j] = V[i - 1][j];
		}
	return V[N][W];
}
int main()
{
	int N, W,vv,ww;
	vector<int> v, w;
	cin >> N >> W;
	for (int variable = 0; variable < N; ++variable) {
		cin >> vv >> ww;
		v.push_back(vv);
		w.push_back(ww);
	}
	cout << Knapsack(N, W, v, w) << endl;
}

Measured memory_bytes: 4964
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_176
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            string n = Read();
            int sum = 0;
            for(int i = 0; i < n.Length; i++)
            {
                sum += n[i] - '0';
            }

            WriteLine(sum % 9 == 0 ? "Yes" : "No");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 26428