akhauriyash/Code-Regression huggingface dataset:
nums = list(map(int, input().split()))
s=input()
#print(nums[0], nums[1], nums[2])
#print(s)
N=nums[0]
A=nums[1]
B=nums[2]
cA=0
cB=0
for i in range(N):
	if(s[i:i+1] == "a"):
#		print(s[i:i+1])
		if((cA+cB)<(A+B)):
			print("Yes")
			cA+=1
		else:
			print("No")
	elif(s[i:i+1]=="b"):
#		print(s[i:i+1])
		if((cA+cB)<(A+B)):
			if(cB<B):
				print("Yes")
				cB+=1
			else:
				print("No")
		else:
			print("No")	
		
	elif(s[i:i+1]=="c"):
		print("No")


Measured memory_bytes: 4040
import math
while True:
    l,w,h=map(int,raw_input().split())
    if l==w==h==0:
        break
    n=input()
    for i in range(n):
        r=input()
        leng=math.sqrt(pow(w,2)+pow(h,2))/2
        if r>leng:
            print "OK"
        else:
            print "NA"

Measured memory_bytes: 4380
<?php
list($n,$k)=explode(" ",trim(fgets(STDIN)));
if($k==1){
  echo 1;
}else{
  $i=1;
  $ans=0;
  while($i<=$n){
    $omote=0;
    while($i*pow(2,$omote)<$k){
      ++$omote;
    }
    $per=sprintf("%.15f",(1/$n)*(1/pow(2,$omote)));
    $ans+=$per;
    ++$i;
  }
  echo $ans;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
  int N, C;
  cin >> N >> C;
  
  vector<vector<int>> imos(100002, vector<int>(C));
  for (int i = 0; i < N; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    c--;
    imos[s][c]++;
    imos[t + 1][c]--; 
  }

  for (int i = 0; i < C; i++) {
    int sum = 0;
    for (int j = 0; j < 100002; j++) {
      sum += imos[j][i];
      imos[j][i] = sum;
    }
  }
/*
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < 30; j++) {
      cout << imos[j][i] << " ";
    }
    cout << endl;
  }
*/
  int ans = 0;
  for (int j = 0; j < 100002; j++) {
    int sum = 0;
    for (int i = 0; i < C; i++) {
      sum += imos[j][i] >= 1 ? 1 : 0;
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=int(a); i<int(b); ++i)
#define FORD(i,a,b) for(int i=int(a); i<int(b); --i)
#define REP(i,N) for(int i=0; i<int(N); ++i)
#define REPD(i,N) for(int i=0; i<int(N); --i)
#define PB push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //配列の最大のrenge

int main() {
    int N; cin >> N;
    ll res = 1;
    REP(i,N){
        res = res*(i+1) % MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		String message = "delicious";
		if(a + x < b) {
			message = "dangerous";
		} else if(a < b) {
			message = "safe";
		}
		System.out.println(message);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<iomanip>
using namespace std;
typedef long long ll;
#define N 110
#define M 1010
namespace uf{
  ll p[N];
  void init(){
      for(int i=0;i<N;i++)p[i]=i;
  }  
  ll par(ll x){return p[x]=(x==p[x]?x:par(p[x]));}
  void unite(ll a,ll b){p[par(a)]=par(b);}
  bool same(ll a,ll b){return par(a)==par(b);}
};
struct pnt{
  ll x,y,id;
  bool operator<(const pnt&key)const{
      if(this->x==key.x){
	  return this->y<key.y;
      }
      return this->x<key.x;
  }  
};
struct edge{
  ll a,b; double c;
  bool operator<(const edge&key)const{
      return this->c<key.c;
  }  
};
double dis(pnt a,pnt b){
    double dx=a.x-b.x;
    double dy=a.y-b.y;
    double c=(double)sqrt((double)(dx*dx+dy*dy));
    return c;
}

double ans=0;
void add(pnt a,pnt b,bool t){
    if(t==1)ans+=dis(a,b);
    if(uf::same(a.id,b.id))return;
    if(t==0)ans+=dis(a,b);
    //cout<<"#"<<a.id<<" "<<b.id<<" "<<dis(a,b)<<endl;
    uf::unite(a.id,b.id);
}

ll n,m;
pnt p[N];
edge e[M];
class cvh{
    public:
    vector<ll> v;
    bool check(pnt a,pnt b,pnt c){
	double vl=(a.y-b.y)*(a.x-c.x);
	double vr=(a.x-b.x)*(a.y-c.y);
	return vl>=vr;
    }
    void main(){
	for(int i=0;i<n;i++){
	    while(v.size()>=2){
		if(check(p[v[v.size()-2]],p[v.back()],p[i]))break;
		v.pop_back();
	    }
	    v.push_back(i);
	}
    }
};cvh uc,vc;
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
	cin>>p[i].x>>p[i].y;
	p[i].id=i+1;
    }
    for(int i=0;i<m;i++){
	ll a,b;cin>>a>>b;
	double c=dis(p[a-1],p[b-1]);
	e[i].a=a,e[i].b=b,e[i].c=c;
    }
    sort(p,p+n); uc.main();
    uf::init();
    for(int i=0;i<uc.v.size()-1;i++){
	add(p[uc.v[i]],p[uc.v[i+1]],1);
    }
    for(int i=0;i<n/2;i++)swap(p[i],p[n-1-i]);
    vc.main();
    for(int i=0;i<vc.v.size()-1;i++){
	add(p[vc.v[i]],p[vc.v[i+1]],1);
    }
    sort(e,e+m);
    for(int i=0;i<m;i++){
	ll aa; for(int j=0;j<n;j++)if(p[j].id==e[i].a)aa=j;
	ll bb; for(int j=0;j<n;j++)if(p[j].id==e[i].b)bb=j;
	add(p[aa],p[bb],0);
    }
    cout<<fixed<<setprecision(9)<<ans<<endl;
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    sort(s.begin(),s.end());
    vector<int> cnt(n);
    int num=0;
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            num++;
            if(i==n-2) cnt[i+1]=num;
        }else{
            cnt[i]=num;
            num=0;
        }
    }
    int id=0;
    for(int i=0;i<n;i++){
        id=max(id,cnt[i]);
    }
    for(int i=0;i<n;i++){
        if(cnt[i]==id){
            cout << s[i] << endl;
        }
    }
}

Measured memory_bytes: 15104
a = input()
b = input()
if(len(a) > len(b)):
    print("GREATER")
elif(len(a) < len(b)):
    print("LESS")
else:
    flag = True
    for i in range(len(a)):
        if(int(a[i]) > int(b[i])):
            flag = False
            print("GREATER")
            break
        elif(int(a[i]) < int(b[i])):
            flag = False
            print("LESS")
            break
    if(flag):
        print("EQUAL")


Measured memory_bytes: 3064
// Own template

#include<bits/stdc++.h>

using namespace std;

#define fo(i,n) for(int i=0;i<n;i++);
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define ll long long
#define N 100001
#define MX 1000000001


int main()
{
    int a;
    cin>>a;
    cout<<(a+(a*a)+(a*a*a))<<endl;

    return 0;
}
// Happy Coding  (:


Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
ll gcd(ll a,ll b)
{
    if(b!=0) return gcd(b,a%b);
    else return a;
}
ll n;
int main()
{
    scanf("%lld",&n);
    printf("%lld\n",2*n/gcd(2,n));
}


Measured memory_bytes: 128
H, W, N = map(int, input().split())

X = []
for _ in range(N):
    a, b = map(int, input().split())
    for i in range(0, 3):
        for j in range(0, 3):
            if a-i >= 1 and a-i <= H-2 and b-j >= 1 and b-j <= W-2:
                X.append((a-i, b-j))

X = sorted(X, key = lambda x: x[1]*10**9+x[0]) + [(H+1, W+1)]
# print(X)
ANS = [0] * 10

pre = (-1, -1)
c = -1
for x in X:
    if x == pre:
        c += 1
        
    else:
        if c >= 0:
            c += 1
            ANS[c] += 1
            
        c = 0
        pre = x

ANS[0] = (H-2)*(W-2) - sum(ANS)

for ans in ANS:
    print(ans)
    

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int real_b;
  for(int i = 0; i < b - a; i++) {
    real_b += i + 1;
  }
  
  cout << real_b - b << endl;
}

Measured memory_bytes: 256
x,y,a,b,c=gets.split.map(&:to_i)
p=gets.split.map(&:to_i).sort.reverse.slice(0..(x-1))
q=gets.split.map(&:to_i).sort.reverse.slice(0..(y-1))
r=gets.split.map(&:to_i).sort.reverse
s=0

arr=[]
p.each{|i| arr<<[i,:red]}
q.each{|i| arr<<[i,:green]}
#r.each{|i| arr+=[i,:clear]}
arr.sort!{|v, w| v[0] <=> w[0] }

rn=0
gn=0
i=0
j=0
while r[i] > arr[j][0]
    case arr[j][1]
    when :red
      if rn==x
        j+=1
      else
        arr[j][0]=0
        rn+=1
        i+=1
        j+=1
      end
    when :green
      if gn==y
        j+=1
      else
        arr[j][0]=0
        gn+=1
        i+=1
        j+=1
      end
    end
  break if i==r.size
end

s+=arr.map{|item| item[0]}.inject(:+)
0.upto(i-1){|k| s+=r[k]}
puts s

Measured memory_bytes: 33840
#include <stdio.h>

int main(void)
{
	int n;
	
	while (scanf("%d", &n) != EOF){
		if (n > 39){
			while (1){
				n = n - 39;
				if (n < 39 && n == 0){
					n = 39;
					printf("3C%d\n", n);
					break;
				}
				else if(n < 39 && n < 9){
					printf("3C0%d\n", n);
					break;
				}
				else if(n < 39){
					printf("3C%d\n", n);
					break;
				}
			}
		}
		else if (n < 9){
			printf("3C0%d\n", n);
		}
		else {
			printf("3C%d\n", n);
		}
	}
	return (0);
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define o(s) cout<< s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    string s="",s1;
    cin >> s;
    
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
        o("Yes");
    }else{
        o("No");
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str0[105];
char str1[105];

void solve()
{
    scanf("%s%s", str0, str1);
    int len0 = strlen(str0), len1 = strlen(str1);
    if (len0 < len1) {
        printf("LESS\n");
    }
    else if (len0 > len1) {
        printf("GREATER\n");
    }
    else {
        if (string(str0) < string(str1)) {
            printf("LESS\n");
        }
        else if (string(str0) > string(str1)) {
            printf("GREATER\n");
        }
        else {
            printf("EQUAL\n");
        }
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#define lli long long int
#define mod 998244353
using namespace std;
int main(){
int k;
char s[101];
cin>>k;
cin>>s;
int len=strlen(s);
if(len<=k){
	cout<<s<<endl;
}
else{
	for(int i=0;i<k;i++)
	cout<<s[i];
	cout<<"..."<<endl;
}
}


Measured memory_bytes: 3596
#input 数列の要素数N、並び替えた数列p
#output pの要素を一組並べ替えて昇順にすることができるか "Yes" or "No"

N = int(input())
plist = tuple(map(int,input().split()))
answer_p = list(plist)
answer_p.sort()
able = False

for i in range(N-1):
    if able == True:
        break
    p = list(plist)
    j = i + 1
    for j in range(N):
        if able == True:
            break
        p = list(plist)
        p[i] = plist[j]
        p[j] = plist[i]
        if p == answer_p:
            print('YES')
            able = True

if able == False:
    print('NO')

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(300000)
from math import isinf
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, M, X = MI()
C = [0] * N
A = [list() for _ in range(N)]
for i in range(N):
    C[i], *A[i] = MI()

ans = INF
for bits in range(2 ** N):
    rikai = [0] * M
    cost = 0
    for i in range(N):
        if (bits >> i) & 1:
            cost += C[i]
            for j, a in enumerate(A[i]):
                rikai[j] += a
    if all(r >= X for r in rikai):
        ans = min(ans, cost)
if isinf(ans):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 68852
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int n = sc.nextInt();
		int values[] = new int[n];

		for(int i = 0; i < n; i++){
			values[i] = sc.nextInt(); // 入力値取得
		}

		// 操作が可能な限り実行する。
		int minNum = NumberOfDevision(values);

		// 出力
		System.out.println(minNum);
	}

	// 偶数かどうかを判定
	static boolean isEven(int n){
		if(n%2 == 0){
			return true;
		}else{
			return false;
		}
	}

	// 2で割り切れる回数を取得
	static int NumberOfDevision(int[] values){
		for(int i = 0; i < values.length; i++){
			if(isEven(values[i])){
				values[i] = values[i]/2;
			}else{
				return 0;
			}
		}
		return 1 + NumberOfDevision(values);
	}
}




Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int A, B, C; 
  cin >> A >> B >> C;

  int MAX = max(A, max(B, C));
  int MIN = min(A, min(B, C));

  cout << MIN*(A+B+C-MIN-MAX)/2 << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String a = sc.next();
      	String b = sc.next();
      	int ab = Integer.parseInt(a + b);
      	String ans = "No";
      	for(int i = 1; i <= 320; i++){
        	if(i*i == ab){
            	ans = "Yes";
              	break;
            }
        }
      	System.out.println(ans);
    }
}

Measured memory_bytes: 39228
#include <iostream>
#include <string>

int main()
{
  std::string S;
  std::cin >> S;
  int l = S.length();
  int cnt = 0;
  for (int i=0; i<l/2; i++) {
    if (S[i] != S[l-1-i]) cnt++;
  }
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

int N; 

int a, d;
map<int, int>mp;
int get(int place) {
	if (mp.find(place) == mp.end()) {
		return mp[place] = a + d*(place - 1);
	}
	else {
		return mp[place];
	}
}
int main() {
	cin >> N; 
	cin >> a >> d;
	int M; cin >> M;
	while (M--) {
		int x, y, z; cin >> x >> y >> z;
		if (x == 0) {
			int l = get(y);
			int r = get(z);
			mp[z] = l;
			mp[y] = r;
		}
		else {
			int l = get(y);
			int r = get(z);
			mp[y] = r;
		}
	}
	int K; cin >> K;
	int ans = get(K);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int n;
vector<int> v;
vector<int> c;

//inputします
void input() {
    cin >> n;
    v.resize(n);
    c.resize(n);
    ff(i, 0, n) {
        cin >> v[i];
    }
    ff(i, 0, n) {
        cin >> c[i];
    }
}

//ライブラリ置き場


//main
int main() {
    input();
    int ans = 0;
    ff(i, 0, n) {
        if (v[i] - c[i] > 0)ans += v[i] - c[i];
    }
    cout << ans << endl;
	return 0;
}

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

char name[32];
char sign[128];

bool rec(int,int,int);

int main(){
    
    int n;
    cin >> n;
    cin >> name;
    int count = 0;
    for(int i = 0; i < n; i++){
        cin >> sign;
        for(int i2 = 0; i2 < strlen(sign); i2++){
            if(name[0] == sign[i2]){
                if(rec(0+1, i2, 0)){ count++; break; }
            }
        }
    }
    cout << count << endl;
}

bool rec(int j,int i2,int interval){

    if(interval == 0){
        for(int i = i2+1; i < strlen(sign); i++){
            if(name[j] == sign[i]){
                if(rec(j+1, i, i - i2)){ return true; }
            }
        }
        return false;
    }
    else{
        if(name[j] == '\0'){ return true; }
        if(i2 + interval > strlen(sign)){ return false; }
	if(name[j] == sign[i2 + interval]){
            if(rec(j+1, i2+interval, interval)){ return true; }
            else{ return false; }
        }
        else{ return false; }
    }
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<utility>
using namespace std;
#define ll long long;
long long mod=1000000007;





bool isPrime(long long n)
{

    if (n <= 1)
        return false;


    for (long long i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}






bool isPalindrome(string s)
{

    int l = 0;
    int h = s.size()-1;


    while (h > l)
    {
        if (s[l++] != s[h--])
        {

            return false;
        }
    }
   return true;
}







int ternarySearch(int l, int r, int key, int ar[])

{
    while (r >= l) {

        // Find the mid1 and mid2
        int mid1 = l + (r - l) / 3;
        int mid2 = r - (r - l) / 3;

        // Check if key is present at any mid
        if (ar[mid1] == key) {
            return mid1;
        }
        if (ar[mid2] == key) {
            return mid2;
        }

        // Since key is not present at mid,
        // check in which region it is present
        // then repeat the Search operation
        // in that region

        if (key < ar[mid1]) {

            // The key lies in between l and mid1
            r = mid1 - 1;
        }
        else if (key > ar[mid2]) {

            // The key lies in between mid2 and r
            l = mid2 + 1;
        }
        else {

            // The key lies in between mid1 and mid2
            l = mid1 + 1;
            r = mid2 - 1;
        }
    }

    // Key not found
    return -1;
}






  int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;

        // Check if x is present at mid
        if (arr[m] == x)
            return m;

        // If x greater, ignore left half
        if (arr[m] < x)
            l = m + 1;

        // If x is smaller, ignore right half
        else
            r = m - 1;
    }

    // if we reach here, then element was
    // not present
    return -1;
}





int main(){
ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
int n;
double d;
cin>>n>>d;
int c=0;

for(int i=0;i<n;i++){
   int x,y;
   cin>>x>>y;
   long long a=pow(x,2)+pow(y,2);
   double ab=pow(a,0.5);
   if(ab<=d){
      c++;
   }
}
cout<<c<<endl;
 return 0;   
}

Measured memory_bytes: 4368
using System;

class Program {

    private static int Main() {
        var input = Console.ReadLine();
        var values = input.Split( ' ' );

        int r = int.Parse( values[ 0 ] );
        int c = int.Parse( values[ 1 ] );

        int[ , ] data = new int[ r + 1, c + 1 ];

        for( int i = 0; i < r; ++i ) {
            input = Console.ReadLine();
            values = input.Split( ' ' );

            int sum = 0;
            for( int j = 0; j < c; ++j ) {
                var value = int.Parse( values[ j ] );
                data[ i, j ] = value;
                data[ r, j ] += value;
                sum += value;
            }
            data[ i, c ] = sum;
            data[ r, c ] += sum;
        }

        for( int i = 0; i < r + 1; ++i ) {
            for( int j = 0; j < c + 1; ++j ) {
                var output = string.Format( "{0}{1}", data[ i, j ], ( j != c ) ? " " : string.Empty );
                Console.Write( output );
            }
            Console.WriteLine();
        }

        return 0;
    }

}

Measured memory_bytes: 11988
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let X = read![i64; 5];
    let K = read!(i64);

    let ok = X[4] - X[0] <= K;

    println!("{}", if ok { "Yay!" } else { ":(" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b;
	char c[9];
	cin>>n;
	while(n--){
		cin>>c;
		sort(c,c+8);
		a=atoi(c);
		sort(c,c+8,greater<int>());
		b=atoi(c);
		cout<<b-a<<endl;
	}
}

Measured memory_bytes: 3072
#include<iostream>
using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
    int N;
    cin >> N;
    int nx=0,ny=0,dir=1;
    int tmp;
    int result[H][W];
    for (int i=1;i<=N;i++){
        cin >> tmp;
        for(int c=0;c<tmp;c++){
            result[ny][nx] = i;
            if(dir==1 && ny==H-1){dir = -1; nx++;}
            else if(dir==-1 && ny==0){dir = 1; nx++;}
            else{ny += dir;}
        }
    }
    for (int i=0;i<H;i++){
        for (int j=0;j<W-1;j++){
            cout << result[i][j] << ' ';
        }
        cout << result[i][W-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 384
s = [i for i in input()]
ans = 0
tmp = 0
acgt = ['A', 'C', 'G', 'T']
while s:
  if s.pop(0) in acgt:
    tmp += 1
  else:
    ans = max([ans, tmp])
    tmp = 0

ans = max([ans, tmp])
print(ans)

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

int a[2][100];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,k;
    cin >> n;
    rep(i,2) {
        rep(j,n) {
            cin >> a[i][j];
        }
    }
    m=a[0][0];
    rep(i,n) {
        m+=a[1][i];
    }
    k=m;
    rep(i,n-1) {
        k=k-a[1][i]+a[0][i+1];
        m=max(m,k);
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = []
    for _ in range(n):
        t = deque(list((map(lambda x: int(x) - 1, input().split()))))
        A.append(t)

    que = deque(list(range(n)))
    res = 0
    emp = [False] * n
    while que:
        next_que = deque([])
        check = set()
        while que:
            i = que.popleft()
            if A[i]:
                idx = A[i][0]
                if i not in check and idx not in check and A[idx][0] == i:
                    A[i].popleft()
                    A[idx].popleft()
                    next_que.append(i)
                    next_que.append(idx)
                    check.add(i)
                    check.add(idx)
            else:
                emp[i] = True
        que = next_que
        if que:
            res += 1
    else:
        print(res if all(emp) else -1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 41808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int x; cin >> x;
	cout << (x < 1) << '\n';
	return 0;
}


Measured memory_bytes: 3616
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ

int main(){
	init_C(1100000);
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	for(int i=0;i<=d;i++){
		for(int x=0;x<2;x++){
			for(int y=0;y<=a-b;y++){
				if(d-(long long)b*i-x*b-(long long)y*i<0)break;
				long long ks=Comb(a,b);
				ks=ks*Comb(a-b,y)%mod;
				long long L=max(0LL,c-(long long)b*i-x*b-(long long)y*i);
				long long R=d-(long long)b*i-x*b-(long long)y*i;
				long long tmp=Comb(R+a,a);
				if(L)tmp=(tmp+mod-Comb(L-1+a,a))%mod;
				ks=ks*tmp%mod;
				if((x+y)%2==0)ret=(ret+ks)%mod;
				else ret=(ret+mod-ks)%mod;
	//			printf("%d %d %d: %lld\n",i,x,y,ks);
			}
		}
	//	printf("%d: %lld\n",i,ret);
	}
	long long sum=0;
	for(int i=c;i<=d;i++){
		sum=(sum+Comb(i+a-1,a-1))%mod;
	}
	ret=(sum+mod-ret)%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 34944
#include <iostream>
#include <unordered_map>
#include <queue>

int min[100000] = {0};
int min2[100000] = { 0 };
long long dp[100000] = {1, 0};
long long dp2[100000] = { 1, 0 };

int main() {
	int n, m, s, t;
	int len;
	std::cin >> n >> m >> s >> t;
	std::unordered_multimap<int, int> e;//from, to
	e.reserve(300000);
	for (int i = 0; i < m; i++) {
		int x, y;
		std::cin >> x >> y;
		e.insert(std::make_pair(x, y));
		e.insert(std::make_pair(y, x));
	}

	std::queue<std::pair<int, int>> q;
	q.push(std::make_pair(0, s));

	while (!q.empty()) {
		auto node = q.front(); q.pop();
		auto it = e.find(node.second);
		int count = e.count(node.second);
		for (int i = 0; i < count; i++, ++it) {
			auto next = node;
			next.first++;
			next.second = it->second;
			if (next.second == s || (min[next.second] > 0 && min[next.second] <= next.first)) {
				continue;
			}
			min[next.second] = next.first;
			dp[next.first]++;
			if (next.second == t) len = next.first;
			q.push(next);
		}
	}

	q.push(std::make_pair(0, t));
	while (!q.empty()) {
		auto node = q.front(); q.pop();
		auto it = e.find(node.second);
		int count = e.count(node.second);
		for (int i = 0; i < count; i++, ++it) {
			auto next = node;
			next.first++;
			next.second = it->second;
			if (next.second == t || (min2[next.second] > 0 && min2[next.second] <= next.first)) {
				continue;
			}
			min2[next.second] = next.first;
			dp2[next.first]++;
			q.push(next);
		}
	}

	long long count = 0;
	for (int i = 0; i <= len - 2; i++) {
			count += dp[i] * dp2[len - i - 2];
	}
	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 21860
///apigs property
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[555555],a[555555],k,l,m,n,o,p;
map<ll,ll>mp;
vector<ll>adj[555555];
const ll mod=1e9+7;
int main(){
    cin>>m>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    k=1e5;
    for(ll i=0;i<=101;i++){
        if(!mp[i]){
            if(abs(m-i)<k)k=abs(m-i),o=i;
        }
    }
    cout<<o;
}


Measured memory_bytes: 16672
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    stack <int> S;
    int a, b;
    string s;
    while (cin >> s) {
        if (s == "+") {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a + b);
        }
        else if (s == "-") {
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a - b);
        }
        else if (s == "*") {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a * b);
        }
        else if (s == "/") {
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a / b);
        }
        else {
            S.push(atoi(s.c_str()));
        }
    }
    cout << S.top() << endl;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,i,d,sum=0;
    cin>>a>>b>>c;
    for (i=1;i<=a;i++)
    {
        cin>>d;
        if (d<b||d>=c) sum++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    const int N = (int)1e5+1;
    vi p(N, true);
    p[0] = p[1] = false;

    rep(i, N){
        if(not p[i]) continue;
        for(int j = 2 * i; j < N; j += i){
            p[j] = false;
        }
    }

    vi sum(N);
    rep(i, 1, N){
        sum[i] = sum[i - 1];
        if(i % 2 == 1 and p[i] and p[(i + 1) / 2]){
            sum[i]++;
        }
    }

    int Q; cin >> Q;
    vi res(Q);
    rep(i, Q){
        int l, r; cin >> l >> r;
        res[i] = sum[r] - sum[l - 1];
    }
    for(auto& e : res){
        cout << e << endl;
    }

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;
int main() {
	int n;
	int ans = 0;
	int p[114514];
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> p[i];
	for (int i = 1; i <= n - 1; i++) {
		if (p[i] == i&&p[i + 1] == i + 1) {
			p[i] = 0;
			p[i + 1] = 0;
			ans++;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (p[i] == i) {
			p[i] = 0;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
#include <random>
#include <cassert>
#include <sstream>
using namespace std;
#define F first
#define S second
#define pb push_back
#define MP make_pair
#define ALL(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ln(i, n) " \n"[i == n]
typedef long long LL;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
//////////////////////
const long double eps = 1e-13;
const long double PI = acos(-1);
const int INF = (int)1e9;
const LL  INFF = (LL)1e15;
const int mod = 998244353;
const int MXN = (int)1e6 + 7;
LL a[MXN], b[MXN];
int id[MXN];
bool cmp(int &u, int &v){
	return a[u] + b[u] > a[v] + b[v];
}
int main(){
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld %lld", a + i, b + i);
		id[i] = i;
	}
	sort(id + 1, id + n + 1, cmp);
	LL v1 = 0;
	for (int i = 1; i <= n; i++) {
		if (i & 1) v1 += a[ id[i] ];
		else v1 -= b[ id[i] ];
	}
	printf("%lld\n", v1);
	return 0;
}


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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 10000

int main(){

    ll n;
    cin >> n;

    vector<ll> a;
    vector<ll> b;
    vector<ll> c;

    ll i,j,a1,b1,c1;

    for(i=0;i<n;i++){
        cin >> a1 >> b1 >> c1;
        a.push_back(a1);
        b.push_back(b1);
        c.push_back(c1);
    }

    ll dp[n][3];

    for(i=0;i<n;i++){
        for(j=0;j<3;j++){
            dp[i][j] = 0;
        }
    }

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(i=1;i<n;i++){
        dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][1],dp[i-1][0]);
    }

    ll ans = max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);

/*
    for(j=0;j<3;j++){
        for(i=0;i<n;i++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
*/
    cout << ans << endl;

}


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

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

const ll MAX=105;
const ll INF=0x3f3f3f3f3f3f3f;
const ll MOD=1e9+7;
ll dp[MAX][MAX][MAX*3],w[MAX],v[MAX],N,W;
bool chk[MAX][MAX][MAX*3];
ll make_dp(ll idx,ll cnt,ll add){
    if(cnt*w[0]+add>W) return -INF;
    if(idx==N) return 0;
    if(chk[idx][cnt][add]==0){
        chk[idx][cnt][add]=1;
        dp[idx][cnt][add]=max(make_dp(idx+1,cnt+1,add+w[idx]-w[0])+v[idx],make_dp(idx+1,cnt,add));
    }
    return dp[idx][cnt][add];
}
int main(){
    scanf("%lld%lld",&N,&W);
    for(ll i=0;i<N;i++){
        scanf("%lld%lld",&w[i],&v[i]);
    }
    printf("%lld\n",make_dp(0,0,0));
    return 0;
}


Measured memory_bytes: 28288
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	vector<int> a(3);
	for (int i = 0; i < 3; i++)cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
}


Measured memory_bytes: 3140
/*
	Nishant Singh
	nishant.ns19
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 

// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********

// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// ******** Using PBDS ********

using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;

// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********

inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}

inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}

inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}

ll gcd(ll a,ll b)
{
	if (b == 0) 
		return a; 
	return gcd(b, a % b);  
}

ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}

ll modinv(ll n)
{
	return modexp(n,mod-2);
}

// ******** GLOBAL VARIABLES ********

//ll n;
// ******** GLOBAL VARIABLES ********

void solve(){
	ll k;
	cin>>k;
	queue<string> q;
	REP(i,9)
	{
		q.push(to_string(i+1));
	}
	if(k<=9)
	{
		cout<<k;
		return;
	}
	ll cur=0;
	while(1)
	{
		string temp=q.front();
		q.pop();
		//cout<<temp<<ln;
		cur++;
		if(cur==k)
		{
			cout<<temp;
			return;
		}
		char last=(*temp.rbegin());
		if(last!='0')
		{
			temp.push_back(last-1);
			q.push(temp);
			temp.pop_back();
		}
		temp.push_back(last);
		q.push(temp);
		temp.pop_back();
		if(last!='9')
		{
			temp.push_back(last+1);
			q.push(temp);
		}	
	}
}  
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x, k, d;
    cin >> x >> k >> d;
    if (x == 0)
    {
        if (k % 2) {
            cout << x + d;
        }
        else
            cout << x;
        return 0;
    }
    if (x > 0)
    {
        long long dif = x;
        long long req = dif / d;
        if (req >= k) {
            cout << x - k*d;
        }
        else
        {
            x -= req * d;
            k -= req;
            if (1) {
                if (k % 2 == 0) {
                    cout << x;
                }
                else
                    cout << abs(x - d);
                return 0;
            }
        }
    }
    else
    {
        long long req = (abs(x)) / d;
        if (req >= k) {
            cout << abs(x + k * d);
        }
        else {
            x += req * d;
            k -= req;
            if (k % 2 == 0) {
                cout << abs(x);
            }
            else
                cout << x + d;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		
		int s1 = S % 10;
		int s2 = S / 10 % 10;
		int s3 = S / 100 % 10;
		
		System.out.println(s1 + s2 + s3);
		
	}
}


Measured memory_bytes: 21972
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

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

        final int n = sc.nextInt();
        final int m = sc.nextInt();

        final Integer[] a = new Integer[n];
        int points = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            points += a[i];
        }

        Arrays.sort(a, Comparator.reverseOrder());

        if (a[m-1] * 4 * m >= points) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 36012
c = 0
while True:
    try:
        if c % 2 == 0:
            A = [int(x) for x in input().split()]
        else:
            B = [int(x) for x in input().split()]
            hit = blow = 0
            for i in range(len(B)):
                if A[i] == B[i]:
                    hit += 1
                else:
                    if B[i] in A:
                        blow += 1
            print(hit,blow)
                
        c += 1    
    except EOFError:
        break

            
        
        


Measured memory_bytes: 5604
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

	double W, H,x, y;
	cin >>W>> H>>x>>y ;
	cout << W * H / 2<<" ";
	if (2 * x == W && 2 * y == H) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        long[] a = {1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692};
        System.out.println(a[k-1]);
    }
}

Measured memory_bytes: 35760