akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
#define nrep(i,a,b) for(int i=int(a);i>=int(b);--i)
#define trv(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define watch(x) cout<<"\n"<<#x<<" is "<<x<<"\n"
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ZERO(box) memset(box, 0, sizeof(box));
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define chkbit(s, b) (s & (1<<b))
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
const int mod=1e9+7;

ll sq(ll a){ return a*a;}

void solve(){
	int n,A;
	cin>>n>>A;
	vi x(n+1,0);
	vvi dp(51,vi(2501,0));
	
	dp[0][0]=1;
	rep(i,1,n){
		cin>>x[i];
	}
	// dp[i][j] denotes the number of ways to achive sum j, using i cards;
	ll tot=0;
	rep(i,1,n){
		nrep(posi,i-1,0){
			rep(j,0,tot){
				dp[posi+1][j+x[i]] += dp[posi][j];
			}
		}
		tot += x[i];
	}
	ll ways=0;
	rep(i,1,n){
		ways += dp[i][A*i];
	}
	cout<<ways<<"\n";
	
}


int main(){
	int t=1;
	//cin>>t;
	while(t--){
		solve();	
	}	
}
/*input
4 8
7 9 8 9
*/

Measured memory_bytes: 1280
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char S[1001];

    scanf("%s", S);

    int len = strlen(S);

    if(S[len-1] == 's'){
        printf("%ses\n", S);
    }else{
        printf("%ss\n", S);
    }

    return 0;
}

Measured memory_bytes: 1728
from collections import deque
N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    E[a-1].append(b)
    E[b-1].append(a)
print("POSSIBLE")if any(N in E[v-1] for v in E[0]) else print("IMPOSSIBLE")

Measured memory_bytes: 38720
from itertools import chain


def solve():
    N, M, K = map(int, input().split())

    A = map(int, input().split())
    B = list(map(int, input().split()))

    answer = 0

    sum_b = sum(B)
    idx_b = M
    remain = K

    for i, a in enumerate(chain([0], A)):
        remain -= a
        if remain < 0:
            break

        while sum_b > remain:
            if idx_b < 0:
                break
            idx_b -= 1
            b = B[idx_b]
            sum_b -= b

        answer = max(answer, i + idx_b)

    return answer


def main():
    print(solve())


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int m, f, b;
    cin >> m >> f >> b;
    if (m + f < b) {
        cout << "NA" << '\n';
    } else {
        cout << max(b - m, 0) << '\n';
    }
    return 0;
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}

string str;



void hawawa()
{
	cin >> str;
	long long ans = 0, cnt = 0, ans_c;
	ans_c = ans;
	cnt = 0;
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'B') {
			cnt++;
		}
		else {
			str[i] = 'B';
			str[i - cnt] = 'W';
			ans += cnt;
		}
	}
	
	cout << ans << "\n";
}

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


Measured memory_bytes: 720
N = int(input())
a_list = list(map(int, input().split()))
a_list.sort()

from collections import deque

deq = deque(a_list)
res = []
while len(deq) > 2:
    min_num = deq.popleft()
    max_num = deq.pop()
    if min_num < 0 and max_num > 0:
        ne = deq.pop()
        if ne >= 0:
            res.append((min_num, ne))
            min_num -= ne
            deq.appendleft(min_num)
            deq.append(max_num)
        else:
            res.append((max_num, ne))
            max_num -= ne
            deq.append(max_num)
            deq.appendleft(min_num)
    else:
        if max_num <= 0:
            res.append((max_num, min_num))
            max_num = max_num - min_num
            deq.append(max_num)
        else:
            res.append((min_num, max_num))
            min_num = min_num - max_num
            deq.appendleft(min_num)

tmp1 = deq[0]
tmp2 = deq[1]
res.append((max(tmp1, tmp2), min(tmp2, tmp1)))
ans = max(tmp1, tmp2) - min(tmp2, tmp1)
print(ans)
for x,y in res:
    print(x, y)


Measured memory_bytes: 64668
main :: IO ()
main = do
  s <- getLine
  putStrLn . show . solve $ s

solve :: String -> Int
solve = solve2. solve1

solve1 :: String -> [Int]
solve1 [] = []
solve1 (_:[]) = []
solve1 (_:_:[]) = []
solve1 (x:y:z:xs) = (read (x:y:z:[])) : solve1 (y:z:xs)

solve2 :: [Int] -> Int
solve2 xs = minimum $ (map (\x -> abs (x - 753))) xs


Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define inputLongArray2(a,b,N) long a[N]; long b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)

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()
{
  //input
  inputInt2(N,W);
  inputLongArray2(w,v,N);
  
  //main
  int INF = 1e9;
  long long memo[N+2][W+2] = {-INF};//添え字 0~N * 0~W
  fN(j,W+2) memo[0][j] = 0; //0番目の物まで見た時、重さの和がi以下となる時の価値の最大値→0番目の物まで見た時、価値は常に0。
  
  for(int obj=0; obj<N+1; obj++){
     for(int sum_w=0; sum_w<W+1; sum_w++) {
       if(sum_w-w[obj]>=0) memo[obj+1][sum_w] = max(memo[obj+1][sum_w], memo[obj][sum_w-w[obj]]+v[obj]); //i+1番目の物を選べる時
       memo[obj+1][sum_w] = max(memo[obj+1][sum_w],memo[obj][sum_w]);
     }
  }
  
  // 出力
  output(memo[N][W]);
    
  return 0;
}

Measured memory_bytes: 79872
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    pair<int, int> a[n];
    rep(i, 0, n) {
        int x, l;
        cin >> x >> l;
        a[i] = {x - l, x + l};
    }
    sort(a, a + n);
    multiset<int> cur;
    rep(i, 0, n) {
        if (sz(cur) == 0 || a[i].fi >= *(--cur.end())) {
            cur.insert(a[i].se);
        } else {
            if (a[i].se < *(--cur.end())) {
                cur.erase(--cur.end());
                cur.insert(a[i].se);
            }
        }
    }
    cout << sz(cur) << "\n";
    return 0;
}

Measured memory_bytes: 5760
l,r = map(int,input().split())
minimum = 2019

if r-l>=2018:
    print(0)

else:
    l %= 2019
    r %= 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            i %= 2019
            j %= 2019
            answer = (i*j)%2019
            minimum = min(answer, minimum)
    print(minimum)

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn = 55;

int check(int x)
{
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0) return 0;
	}
	return 1;
}

int main()
{
	int p=0;
	int v=1;
	int n;
	cin>>n;
	for(int i=2;i<=55555;i++){
		if(check(i)&&i%10==1){
			printf("%d",i);
			p++;
			printf("%c",p==n?'\n':' ');
			if(p==n) break;
		}
	}


	return 0;
}


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

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

    ll a[n];
    ll count = 0;
    rep(i, n){
        cin >> a[i];
        while(a[i] % 2 == 0){
            count++;
            a[i] = a[i] / 2;
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 384
/*
 * @Author: Kaizyn
 * @Date: 2020-08-22 21:20:15
 * @LastEditTime: 2020-08-22 21:21:10
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;

string s;

inline void solve() {
  cin >> s;
  int sum = 0;
  for (const char &c : s) {
    sum += c-'0';
  }
  cout << (sum%9 == 0 ? "Yes" : "No") << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	int N; 
	long long int W; 
	long long int w[110] = {}; 
	long long int v[110] = {}; 
	cin >> N >> W; 
 	for(int i = 1; i <= N; i++){
		cin >> w[i] >> v[i]; 
	}
	long long int dp[110][100010] = {}; // dp[i番目まで][価値j] = 重さのmin
    for(int i = 0; i < 110; i++){
      	for(int j = 0; j < 100010; j++){
           dp[i][j] = 1e18;        
        }
    }
    dp[0][0] = 0; 
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= 1000 * i; j++){
			if(j >= v[i]){
				dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]); 
			}
			else{
				dp[i][j] = dp[i-1][j]; 
			}
		}
	}
	for(int j = 100009; j >= 0; j--){
		if(dp[N][j] <= W){
			cout << j << endl; 
			break; 
		}
	}	
}

Measured memory_bytes: 86272
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int n;
    cin >> n;
    int x = 800 * n;
    int y = (n / 15) * 200;
    cout << x - y << endl;
}

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

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

    vector<int> a(N);

    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }

    sort(a.begin(),a.end());

    vector<int> b((a.at(N-1)+2),0);

    for(int i=0;i<N;i++){
        if(a.at(i)!=0) {
            b.at(a.at(i) - 1)++;
        }

        b.at(a.at(i))++;
        b.at(a.at(i) + 1)++;
    }

    sort(b.begin(),b.end(),greater<int>());
    int max = b.at(0);

    cout<<max<<endl;




    return 0;



}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int Max_n = 100003;
int cs[33][Max_n];
int active[33];

// 1901 - 19:18
int main(){
    int N, C, s, t ,c, ans=0;
    cin >> N >> C;

    for(int i =1; i <= N; i++){
        cin >> s >> t >> c;
        for(int j=s; j <=t; j++){
            cs[c][j] =1;
        }
    }

    for(int i =1; i < Max_n; i++){
        int temp=0;
        for(int j=1; j <=C; j++){
            if(cs[j][i] ==1) temp++;
        }
        ans = max(ans, temp);
    }


    cout << ans << endl;
  
   

    return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

string s;
ll k;

void input(){
    cin >> s;
    cin >> k;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    string ans;
    if(k <= (ll)s.size()){
        for(int i=0;i<k;i++){
            if (s.at(i) != '1'){
                cout << s.at(i) << endl;
                return 0;
            }
        }
    }else{
        for(int i=0;i<s.size();i++){
            if (s.at(i) != '1'){
                cout << s.at(i) << endl;
                return 0;                
            }
        }
    }
    cout << '1' << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
nums = [int(input()) for i in range(n)]
n_max = max(nums)
ex_nums = [i for i in nums]
ex_nums.remove(n_max)
n_semi_max = max(ex_nums)
for i in nums:
    if i == n_max:
        print(n_semi_max)
    else:
        print(n_max)

Measured memory_bytes: 14168
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;


void solve(){
    int x;
    cin >> x;
    cout << (x^1ll) << endl;   
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <string>
#include <list>
#include<vector>
#include <sstream>
#include <stdio.h>
#include <utility>
#include <unordered_set>
#include <valarray>
#include <iomanip>
using namespace std;


int main(void)
{
	int A, B = 0;
	int ItemCount = 0;

	cin >> A >> B;
	
	std::unordered_set<int> Counter;
	int Tmp = 0;
	for (int i=0;i<B;i++)
	{
		cin >> ItemCount;
		for (int z=0;z<ItemCount;z++)
		{
			cin >> Tmp;
			Counter.emplace(Tmp);
		}
	}

	cout << (A-Counter.size()) << endl;

	return 0;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
/* snukeくんの解説動画最後10分弱くらい */

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int ans;


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

    vector<vector<int> > ds(n);

    REP(i, n) {
        int t, d;
        cin >> t >> d;
        t--;
        ds[t].push_back(d);
    }

    /* y1: 全種類で一番おいしいもの1個ずつおいしい順に並べたもの */
    /* y0: それ以外をおいしい順に並べたもの */
    vector<int> y0, y1;
    REP(i, n) {
        if(ds[i].size() == 0) continue;

        sort(ds[i].begin(), ds[i].end());
        y1.push_back(ds[i].back());
        ds[i].pop_back();
        y0.insert(y0.end(), ds[i].begin(), ds[i].end());
    }

    sort(y0.rbegin(), y0.rend());
    sort(y1.rbegin(), y1.rend());

    ll ans = 0;

    int Y = max(0, k - int(y0.size())); /* 種類が増えうる要素（y1)から最低何個取るか */
    ll X = 0;
    REP(i, Y) X += y1[i];
    REP(i, k-Y) X += y0[i];

    while(1) {
        ans = max(ans, X + (long long)Y*Y);

        /* maxまで行ったら終わり */
        if(Y >= k || Y >= y1.size()) break;

        /* 種類一個増やす */
        X += y1[Y];
        X -= y0[k-Y-1];    
        Y++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
#define F(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RF(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
int dp[N][3],vals[N][3];

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    int n;
    cin>>n;

    F(i, 0, n) {
    	F(j, 0, 3) {
    		cin>>vals[i][j];
    	}
    }
    memset(dp, -1, sizeof(dp));
    F(i, 0, 3) {
    	dp[0][i]=vals[0][i];
    }

    F(i, 1, n) {
    	F(j, 0, 3) {
    		int maxm = -1;
    		F(k, 0, 3) {
    			if(k == j) continue;
    			maxm = max(maxm, dp[i-1][k]);
    		}
    		dp[i][j]=maxm + vals[i][j];
    	}
    }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));

    return 0;
}/*

*/


Measured memory_bytes: 2560
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>


using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) sort(a.rbegin(),a.rend())
#define Sort(a) sort(a.begin(),a.end())
#define Sum(a)  accumulate(a.begin(), a.end(), 0)
#define REP(i, n) for(UI i = 0;i < n;i++)
#define REPR(i, n) for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) for(UI i = m;i < n;i++)

LL N, K, s[60], dp[60][2];

int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> K;
	REP(i, N) {
		LL a; cin >> a;
		REP(j, 50) if (a & (1ll << j))s[j]++;
	}
	reverse(s, s + 50);
	REP(i, 50) {
		if (K & (1ll << 50 - i - 1)) {
			dp[i + 1][0] = dp[i][0] * 2 + N - s[i];
			dp[i + 1][1] = dp[i][0] * 2 + s[i];
		}
		else dp[i + 1][0] = dp[i][0] * 2 + s[i];
		if(dp[i][1] > 0)dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] * 2 + max(N - s[i], s[i]));
	}
	cout << max(dp[50][0], dp[50][1]) << endl;

	return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a, b, c;
int main() {
	scanf("%d%d%d", &a, &b, &c);
	if(a == b)printf("%d\n", c);
	else if(a == c)printf("%d\n", b);
	else if(b == c)printf("%d\n", a);
	return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    map<i64, i64> cnt;
    i64 sum = 0;
    for (i64 i = 0; i < n; i++) {
        i64 a;
        cin >> a;
        cnt[a]++;
        sum += a;
    }
    i64 q;
    cin >> q;

    for (i64 i = 0; i < q; i++) {
        i64 b, c;
        cin >> b >> c;
        sum -= cnt[b] * b;
        sum += cnt[b] * c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 9564
import java.io.*;  

public class Main {
    public static void main(String[] args) throws IOException {
	int height;                                         // ?????°?????£?¨??????????
	int width;                                          // ?????°?????£?¨?????¨????
	int area;                                           // ?????°?????£?¨??????¢??????
        int l;
	/* ??\???????????? */
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String buf = br.readLine();
        String[] x = buf.split(" ",0);
    	
    	
    	height=Integer.parseInt(x[0]);
    	width=Integer.parseInt(x[1]);
	    area = height*width;
	    l = height + width+height + width;
	    System.out.println(area +" "+ l );
    
	
    }
    
}

Measured memory_bytes: 24152
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    tmp0 = input[0].split(" ");
    　s = tmp0[0].trim(); //'abcdef'
      var len=s.length-3;cnt=0;wa=0;

      if(s.substr(0,1)=='A'){
               for(i=2;i<=s.length-2;i++){
                 if(s.substr(i,1)=='C'){cnt+=1;
                                        if(cnt==2){break;}}
                                      
                    }
                  }else{var cnt=2;}
 // console.log(cnt);
      if(cnt==2||cnt==0){console.log('WA')}
       else{
      var c=0;
    for(l=0;l<s.length;l++){ 
     const STR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
       for (i = 0; i < STR.length; i++) {if (s.substr(l,1) == STR[i]) {c+=1;}}
                  }
      
             if(c==2){console.log('AC');}
                else{console.log("WA");}
                }
                }
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'

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

    reverse(all(s));
    int n = s.size();
    vll dp(n + 1, vl(13));
    
    dp[0][0] = 1;
    ll now = 1;
    rep(i,n){
        rep(j,13){
            if(s[i] != '?'){
                int x = s[i] - '0'; // 文字列を数値に変換
                int nj = (j + x * now % 13) % 13;
                dp[i + 1][nj] += dp[i][j];
                dp[i + 1][nj] %= MOD;
            }
            else{
                rep(k,10){
                    int nj = (j + k * now % 13) % 13;
                    dp[i + 1][nj] += dp[i][j];
                    dp[i + 1][nj] %= MOD;
                }
            }
        }
        now *= 10;
        now %= 13;
    }

    cout << dp[n][5] << endl;
    return 0;
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int; //任意長整数 
using Real32 = mp::number<mp::cpp_dec_float<32>>;
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
using Rat = boost::rational<Bint>;//有理数*/
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);


signed main(){
    int n,m,q;
    cin>>n>>m>>q;
    vector<vector<int>> v(n+1,vector<int>(n+1,0));
    for(int i=0;i < m;i++)
    {
        int l,r;
        cin>>l>>r;
        v.at(l).at(r)++;
    }

    for(int i=0;i < n+1;i++)
    {
        for(int j=1;j < n+1;j++)
        {
            v.at(i).at(j)+=v.at(i).at(j-1);
        }
    }
    
    for(int i=1;i < n+1;i++)
    {
        for(int j=0;j < n+1;j++)
        {
            v.at(i).at(j)+=v.at(i-1).at(j);
        }
    }
    for(int i=0;i < q;i++)
    {
        int l,r,ans=0;
        cin>>l>>r;
        ans=v.at(r).at(r)-v.at(l-1).at(r)-v.at(r).at(l-1)+v.at(l-1).at(l-1);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    LL(n,m);
    ll ans=1,Msqrt=sqrt(m);
    for(ll i=1;i<=Msqrt;i++){
        if(m%i==0){
            if(i*n<=m)ans=max(ans,i);
            if((m/i)*n<=m)ans=max(ans,m/i);
        }
    }
    out(ans);
}

Measured memory_bytes: 3812
local a, b = io.read("*n", "*n")
local c, d = io.read("*n", "*n")
a = c - a
b = d - b
for i = 1, a do
  io.write("R")
end
for i = 1, b do
  io.write("U")
end
for i = 1, a do
  io.write("L")
end
for i = 1, b do
  io.write("D")
end
io.write("D")
for i = 1, a + 1 do
  io.write("R")
end
for i = 1, b + 1 do
  io.write("U")
end
io.write("LU")
for i = 1, a + 1 do
  io.write("L")
end
for i = 1, b + 1 do
  io.write("D")
end
print("R")


Measured memory_bytes: 760
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;	}


//Variables Declaration


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

 	float tab[1001];
 	int  N,M;
 	float total=0;
 	cin>>N>>M;
    for(int i =0 ; i<N ;++i){
    	cin>>tab[i];
    	total+=tab[i];
    }
    sort(tab,tab+N,greater<int>());
    total/=(4*M);
for(int i =0 ; i<M ;++i){
    	if(tab[i]<total) {cout<< "No"<<endl;return 0;}
    }
    cout<<"Yes";




	return 0;
}


Measured memory_bytes: 384
using System; 
using System.Text;
using System.Collections.Generic; 
using System.Linq; 
using E = System.Linq.Enumerable; 


class Program {
    static void Main(string[] args) {
        
        var NW = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var N = NW[0];
        var W = NW[1];
        
        Console.WriteLine((N+W)%24);
     }
}


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

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

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

//////////////////////////////////////////////

string str;

bool solve(){
	FOR(i,str.length()){
		if(i % 2 == 0){
			if(str[i] == 'L') return false;
		}
		else{
			if(str[i] == 'R') return false;
		}
	}
	return true;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> str;
	if(solve()) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

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

    int N = scanner.nextInt();
    Task[] tasks = new Task[N];
    for (int i = 0; i < N; i++) tasks[i] = new Task(scanner.nextInt(), scanner.nextInt());

    Arrays.sort(tasks, Comparator.comparingInt(t -> t.b));
    long sum = 0;
    for (Task t : tasks) {
      sum += t.a;
      if (sum > t.b) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }

  private static class Task {
    final int a;
    final int b;

    private Task(int a, int b) {
      this.a = a;
      this.b = b;
    }
  }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int h,w;cin>>h>>w;
    char res='A';
    vector<vector<string>> s(h,vector<string>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
            if(s[i][j]=="snuke"){
                res += j;
                cout<<res<<i+1<<endl;
                return 0;
            } 
        }
    }
}


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

#define ll long long
#define pii pair<int,int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(int i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

void kekek()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef EBUCHKA
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
}

vector<vector<int>> gr(100228);
vector<bool> used(100228);
vector<int> dp(100228);
vector<int> topsort;

void dfs(int st) {
	used[st] = true;
	for (auto it: gr[st]) {
		if(!used[it])
			dfs(it);
	}
	topsort.push_back(st);
}



int main() {
	kekek();
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--;v--;
		gr[u].push_back(v);
		//gr[v].push_back(u);
	}
	for (int i = 0; i < n; i++) {
		if (!used[i])
			dfs(i);
	}
	// cout << "TOPSOR:" << endl;
	// for (auto it: topsort) {
	// 	cout << it + 1 << ' ';
	// }
	// cout << endl;
	for (auto it: topsort) {
		for (auto cp: gr[it]) {
			dp[it] = max(dp[it], dp[cp] + 1);
		}
	}
	int ans = -1;
	for (int i = 0; i < n; i++) {
		ans = max(ans, dp[i]);
		//cout << dp[i] << ' ';
	}
	cout << ans;
}

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

int main(){
	int h, n;
  	cin >> h >> n;
  	vector<int> a(n), b(n);
  	rep(i, n) cin >> a[i] >> b[i];
  	vector<int> dp(h+1, 1e9);
  	dp[0] = 0;
  	
	rep(i, n){
    	rep(j, h){
          	int nj = min(j+a[i], h);
        	dp[nj] = min(dp[nj], dp[j]+b[i]);
        }
    }
	
  	cout << dp[h] << endl;
}

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

int top, S[1000];

void push(int x) {
    top++;
    S[top] = x;
}

int pop() {
    top--;
    return S[top + 1];
}

int main() {
    int x, a, b;
    top = 0;
    char s[100];

    while(scanf("%s", s) != EOF) {
        if(s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        } else if(s[0] == '-') {
            a = pop();
            b = pop();
            push(b - a);
        } else if(s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        } else {
            x = atoi(s);
            push(x);
        }
    }
    x = pop();
    cout << x << endl;
}


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


int main(){
    while(1){
    
    int H,W;
    cin>>H>>W;
    if(H == 0 && W == 0) break;
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if((i+j)%2 == 0) cout<<"#";
            else cout<<".";
        }
    cout<<endl;
}
        cout<<endl;
    }
  return 0;
}



Measured memory_bytes: 3116
X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  flag=False
  i=0
  while flag==False:
    if (X-i in p)==False:
      flag==True
      print(X-i)
      break
    if (X-i in p)==True and (X+i in p)==False:
      flag==True
      print(X+i)
      break
    i+=1

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

using namespace std;

int main(){
    int a,c;
    char b;
    while(true){
        cin >> a >> b >> c;
        if(b == '?'){break;}
        else if(b == '+'){
            cout << a+c << endl;
        }
        else if(b == '-'){
            cout << a-c << endl;
        }
        else if(b == '*'){
            cout << a*c << endl;
        }
        else {
            cout << a/c << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii unordered_map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef pair<pii,pii> ppp;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=4e18;
  const int N=2e5+25;
  const int M=1e6;

 void doit()
 { int n; cin>>n;
   vi a,ans; rep(i,1,10) { a.pb(i); ans.pb(i); }
   bool f=true;
   while(f){
     vi b;
     tr(i,a){
      int t=i%10;
       if(t==0)
       {
         b.pb(i*10+0); b.pb(i*10+1); 
       }
       else if(t==9){
         b.pb(i*10+8); b.pb(i*10+9);
       }
       else{
         b.pb(i*10+t-1); b.pb(i*10+t); b.pb(i*10+t+1);
       }
     }
     tr(i,b){
        ans.pb(i);
       if(Z(ans)>=n) {
         f=false; break;
       }
     }
     a=b;
   }
 //  prt(ans);
   cout<<ans[n-1];

 }

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


   int tc=1;                         
 //  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
    
   doit();
   if(i<tc)
   cout<<nl;
  }
  


 return 0; 
}

Measured memory_bytes: 3584
//////In the name of God:)
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long int
#define fast  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int MAXN = 1e5 + 10;
# define PI 3.14159265358979323846
int main(){
    double n;
    cin>>n;
    double ans = n * 2 * PI;
    cout<<fixed<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

typedef std::pair<int,int> P;

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

  std::vector<P> p(N);
  rep(i,N) std::cin >> p[i].first >> p[i].second;

  double S = 0.;
  for(int i=0; i<N; i++) for(int j=0; j<N; j++) {
    if ( i == j ) continue;
    double xd = p[i].first - p[j].first;
    double yd = p[i].second - p[j].second;
    S += std::sqrt(xd*xd+yd*yd);
  }
  std::cout << std::fixed << std::setprecision(10) << S / N << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	string s;
	cin>>s;
	n=s.size();
	if(s[n-1]=='s'){
		cout<<s<<"es"<<endl;
	}
	else{
		cout<<s<<"s"<<endl;
	}
	return 0;
} 

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 2 * N;

int n, k;
char s[N];
vector<int> seq;
LL sum[N];

int main()
{
	scanf("%d%d%s", &n, &k, s);
	
	seq.push_back(0);
	for (int i = 0; i < n; i ++ )
	{
		int j = i, cnt = 0;
		while (j < n && s[i] == s[j]) j ++ , cnt ++ ;
		seq.push_back(cnt);
		i = j - 1;
	}
	
	n = seq.size() - 1;
	
	for (int i = 1; i <= n; i ++ ) sum[i] = sum[i - 1] + seq[i];
	LL tot = sum[n];
	int res = 0, len = 2 * k + 1;
	for (int i = 1; i <= n; i ++ )
	{
		int j = min(i + len - 1, n);
		int part = sum[j] - sum[i - 1];
		int cnt = part - 1;
		cnt += tot - part - (n - (j - i + 1));
		res = max(res, cnt);
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1656
#include<stdio.h>

int main(void){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0) break; // '0 0'?????\???????????????break
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
        if(i==0||j==0||i==H-1||j==W-1) printf("#");
        else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;

}

Measured memory_bytes: 572
import java.util.Scanner;

public class Main {

	void run() {
		try (Scanner sc = new Scanner(System.in)) {
			int s = sc.nextInt();
			int w = sc.nextInt();
			System.out.println(w >= s ? "unsafe" : "safe");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}


Measured memory_bytes: 35812
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;

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

Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> p(n, k - q);
	for (int i = 0; i < q; i++) {
		int t;
		cin >> t;
		p.at(t - 1)++;
	}
	for (int i : p) {
		if (i <= 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
# input
n = int(input())
o = []
for i in range(n):
    o.append(list(map(int, input().split())))
o.sort(key=itemgetter(1))
# calc
t = 0
for j in range(n):
    t += o[j][0]
    if t > o[j][1]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 53720
a,b,c=map(int,input().split())
x=a
sum=0
if 1<=a<=10000 and 1<=b<=10000 and 1<=c<=10000 and a<=b:
    if c%x==0:
        sum+=1
    while x<b:
        x+=1
        if c%x==0:
            sum+=1
print(sum)



Measured memory_bytes: 5596
#include<iostream>
using namespace std;
int main(){
	for (int h = 0; h < 1000; h++){
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0){
			break;
		}
		for (int i = 0; i < a; i++){
			for (int j = 0; j < b; j++){
				if (j == 0 || j == b - 1 || i == 0 || i == a - 1){
					cout << "#";
				}
				else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_H = 2000000;
const int MAX_E2 = 1 << 22;

/* typedef */

template <typename T, const int MAX_E2>
struct SegTreeMax {
  int n, e2;
  T nodes[MAX_E2], is[MAX_E2];

  SegTreeMax() {}
  SegTreeMax(int _n) { init(_n); }

  void init(int _n) {
    n = _n;
    for (e2 = 1; e2 < n; e2 <<= 1);
    memset(nodes, -1, sizeof(nodes));
    memset(is, 0, sizeof(is));
  }

  int maxi() { return is[0]; }
  T getmax() { return nodes[0]; }
  T get(int i) { return nodes[e2 - 1 + i]; }

  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;
    is[j] = i;
    j = (j - 1) / 2;

    for (;;) {
      int j0 = j * 2 + 1, j1 = j0 + 1;
      if (nodes[j0] > nodes[j1])
	nodes[j] = nodes[j0], is[j] = is[j0];
      else
	nodes[j] = nodes[j1], is[j] = is[j1];
      if (j == 0) break;
      j = (j - 1) / 2;
    }
  }
};

/* global variables */

SegTreeMax<int,MAX_E2> st(MAX_H);

/* subroutines */

/* main */

int main() {
  int h = 0;

  for (;;) {
    char op[16];
    int tmp = scanf("%s", op);

    if (op[0] == 'i') {
      int x;
      tmp = scanf("%d", &x);

      st.set(h++, x);
    }
    else if (op[1] == 'x') {
      int x = st.getmax();
      st.set(st.maxi(), -1);
      
      printf("%d\n", x);
    }
    else break;
  }

  return 0;
}

Measured memory_bytes: 33972
#include <iostream>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;
	int a0 = a + a - 1;
	int a1 = b + b - 1;
	int a2 = a + b;
	int max = a0;
	if(max < a1)
		max = a1;
	if(max < a2)
		max = a2;
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256