akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M;
ll cake[1010][3];
int main(){
    cin>>N>>M;
    for(ll i=0;i<N;i++){
        for(ll j=0;j<3;j++){
            cin>>cake[i][j];
        }
    }
    ll ans=0;
    for(ll state=0;state<8;state++){
        vector<ll> c(N);
        for(ll i=0;i<N;i++){
            for(ll j=0;j<3;j++){
                if(state&(1<<j)){
                    c[i]+=cake[i][j];
                }else{
                    c[i]-=cake[i][j];
                }
            }
        }
        sort(c.begin(),c.end());
        ll sum=0;
        for(ll i=N-1,cnt=0;cnt<M;i--,cnt++){
            sum+=c[i];
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long // for codeforces

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

  rep(i,t.size()) cout<<s[i]<<t[i];
  if(s.size()>t.size()) cout<<s[s.size()-1];
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[200009];
main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 1; i <= n; i++){
        int p;
        cin >> p;
        f[p] = i;
        v.push_back(p);
    }
    int cnt  = 1;
    int ans = 0;
    for(int i =  2; i <= n; i++){
        if(f[i]  > f[i-1]){
            cnt ++;
            continue;
        }
        else {
            ans = max(ans, cnt);
            cnt  = 1;
        }
    }
    ans = max(ans, cnt);
    cout << n - ans<< endl;

}


Measured memory_bytes: 2168
#include<cstdio>

int main()
{
    #ifdef LOCAL
    freopen("date.in", "r", stdin);
    freopen("date.out", "w", stdout);
    #endif
    int n, x, t;
    int ans;
    scanf("%d %d %d", &n, &x, &t);
    if(n%x!=0)
        ans = ((n / x) + 1) * t;
    else
        ans = (n / x) * t;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; i++) cin >> h[i];
	int dp[n];
	for (int i = 0; i < n; i++) dp[i] = INF;
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= 2; j++) {
			int k = i + j;
			if (k == n) break;
			dp[k] = min(dp[k], dp[i] + abs(h[k] - h[i]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
$num = inputs[0][0]
$prime_table = [2, 3, 5, 7, 11,	13, 17,	19, 23,	29, 31, 37, 41,	43, 47,	53, 59,	61, 67,	71, 73,	79, 83, 89, 97]
$candidates = [[75], [3, 25], [5, 15], [3, 5, 5]]

if $debugFlag
  p $num
  p $prime_table
end

factorize = []
$prime_table.each do |p_i|
  break if p_i > $num
  tmp = p_i
  tmp_cnt = 0
  while tmp <= $num
    tmp_cnt += ($num / tmp)
    tmp *= p_i
  end
  factorize << tmp_cnt
end

p factorize if $debugFlag

def dfs( res_src_list, res_tgt_list )
  return 1 if res_tgt_list == []
  sum = 0
  c_res_tgt_list = res_tgt_list.clone
  tgt = c_res_tgt_list.shift
  res_src_list.size.times do |i|
    if res_src_list[i] >= tgt - 1
      c_res_src_list = res_src_list.clone
      c_res_src_list.delete_at(i)
      if $debugFlag
        print "res_src_val: "
        p res_src_list[i]
        print "tgt: "
        p tgt
        p c_res_tgt_list
      end
      sum += dfs( c_res_src_list, c_res_tgt_list )
    end
  end
  return sum
end

res = 0
$candidates.each do |c_i|
  if $debugFlag
    print "c_i:"
    p c_i
  end
  addVal = dfs( factorize, c_i )
  addVal /= 2 if c_i == [3, 5, 5]
  res += addVal
end

puts res


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

int main(){
  string w,s;
  vector<int> count(26);
  cin >> w;
  s = "abcdefghijklmnopqrstuvwxyz";
  for(int i = 0;i < w.size();i++){
    for(int j = 0;j < 26;j++){
      if(w.at(i) == s.at(j)){
        count.at(j)++;
      }
    }
  }
  
  for(int i : count){
    if(i % 2 != 0){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;  
}


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

using namespace std;

using ll = long long;

constexpr char endl('\n');

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)

size_t smaller_count(size_t pos, vector<size_t> & v) {
    size_t k = v.at(pos);
    size_t ret = 0;
    FOR(i, pos + 1, v.size()) {
        if (k > v.at(i)) ++ret;
    }
    return ret;
}

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

    size_t n, m;
    cin >> n >> m;

    vector<size_t> v(n);
    REP(i, n) {
        v.at(i) = i + 1;
    }
    unordered_multimap<size_t, size_t> h;
    REP(i, m) {
        size_t a, b;
        cin >> a >> b;
        h.emplace(a, b);
        h.emplace(b, a);
    }
    size_t ret = 0;

    do {
        bool found = true;
        REP(i, n - 1) {
            auto p = h.equal_range(v.at(i));
            auto it = find_if(p.first, p.second, [&](auto pair) {return pair.second == v.at(i + 1); });
            if (it == p.second) {
                found = false;
                break;
            }
        }
        if (found) ++ret;
    } while (next_permutation(v.begin()+1, v.end()));
    cout << ret << ::endl;


    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int Knapsack_01_eco(int N,int W, vector<int> v,vector<int> w) {

    vector<int> dp(W+1, 0);

    REP(i, N) DEPS(j, W, w[i]) dp[j] = max(dp[j], dp[j-w[i]]+v[i]);

    return dp[W];
}


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

  int N, W;
  cin >> N >> W;
  vvint(v, w, N);

  cout << Knapsack_01_eco(N, W, v, w) << endl;

}

Measured memory_bytes: 3200
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

vvl T(10001);
vl Node(10001);
vl C(10001);
ll num;
ll ret;

void search(ll d, ll parent) {
	rep(i, T[d].size()) {
		if (T[d][i] == parent)continue;
		Node[T[d][i]] = C[num];
		num++;
	}

	rep(i, T[d].size()) {
		if (T[d][i] == parent)continue;
		search(T[d][i], d);
	}
}

void calc(ll d, ll parent) {
	rep(i, T[d].size()) {
		if (T[d][i] == parent)continue;
		ret += min(Node[d], Node[T[d][i]]);
		calc(T[d][i], d);
	}
}

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

	ll N;
	cin >> N;
	num = 0;
	ret = 0;

	vl A(N - 1), B(N - 1);

	rep(i, N - 1) {
		cin >> A[i] >> B[i];
	}
	rep(i, N) {
		cin >> C[i];
	}

	sort(C.begin(), C.end(), greater<ll>());

	rep(i, N - 1) {
		T[A[i]].push_back(B[i]);
		T[B[i]].push_back(A[i]);
	}

	Node[1] = C[num];
	num++;

	search(1, 0);

	calc(1, 0);



	cout << ret << endl;
	rep(i, N) {
		cout << Node[i + 1] << " ";
	}






	return 0;



	
}



Measured memory_bytes: 1664
N,K = map(int, input().split())
trees = [int(input()) for _ in range(N)]

def solve(N,K,trees):
    trees.sort()

    diffs = []
    for i,h in enumerate(trees[:N-K+1]):
        min_h = h
        max_h = trees[i+K-1]
        #print(min_h,max_h)
        diffs.append(max_h-min_h)

    print(min(diffs))
    return

solve(N,K,trees)

Measured memory_bytes: 12060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N,M; cin >> N >> M;
    vector<vector<ll>> G(N);
    for(int i = 0; i < M;i++){
        ll a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> dist(N,LINF);
    dist[0] = 0;
    queue<ll> q; q.push(0);
    while(q.size()){
        auto n = q.front(); q.pop();
        for(auto next:G[n]){
            if(dist[next] > dist[n] + 1){
                dist[next] = dist[n] + 1;
                q.push(next);
            }
        }
    }
    if(dist[N-1] == 2) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(2*n);
  for(int i= 0;i < 2*n;i++)cin >> a[i];
  sort(a.begin(),a.end());
  int ans = 0;
  for(int i = 0;i < 2*n;i+=2)ans += a[i];
  cout << ans;
 return 0; 
}

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

int main(){
  ll n,k;
  ll a[100009],b[100009];

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

  ll ans=0;
  for(int i=31;i>=0;i--){
    ll now=k,sum=0;
    if((k>>i)&1){
      int bits=0;
      for(int j=0;j<i;j++){
	bits+=(1<<j);
      }
      now=now|bits;
      now=now&(~(1<<i));
    }

    for(int j=0;j<n;j++){
      if((now|a[j])==now)sum+=b[j];
    }
    ans=max(ans,sum);
  }

  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

const int INF = 100000000;

int n, l;
int data[100002];
int memo[100002];

int func(int i){
  if(memo[i] != -1) return memo[i];
  int res = 0;
  if(data[i+1] > data[i]) res = max(res, func(i+1));
  if(data[i-1] > data[i]) res = max(res, func(i-1));
  return memo[i] = res + l - data[i];
}


main(){
  fill(memo, memo+100002, -1);
  cin >> n >> l;
  for(int i=1;i<=n;++i){
    cin >> data[i];
  }
  int ans = 0;
  for(int i=1;i<=n;++i){
    ans = max(ans, func(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1608
import java.util.Scanner;

public class Main {
    public static int from = 0;

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

        int steps = sc.nextInt();
        long[] dp = new long[steps + 1];

        int breaks = sc.nextInt();
        int[] br = new int[breaks];
        for (int i = 0; i < breaks; i++) {
            br[i] = sc.nextInt();
        }


        dp[0] = 1;
        if (isBroken(br, 1, from) ) {
            dp[1] = 0;
            from = 1;
        } else {
            dp[1] = 1;
        }

        int mod = 1000000007;
        for (int step = 2; step <= steps; step++) {
            dp[step] = 0;
            if (!isBroken(br, step, from)) {
                dp[step] = (dp[step - 1] + dp[step - 2]) % mod;
            }
        }

        System.out.println(dp[steps]);
    }

    public static boolean isBroken(int[] broken, int step, int from) {
        for (int i = from; i < broken.length; i++) {
            if (broken[i] == step) {
                Main.from = i;
                return true;
            }
        }
        return false;
    }
}

Measured memory_bytes: 46836
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    char c; cin >> c;

    char ans = 'A';
    if(c-'A' > 27) ans = 'a';
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int maxt=1<<20;
int n,m;
struct Inte
{
	int L,R;
	bool operator < (const Inte &t)const
	{
		if(L!=t.L)
			return L<t.L;
		return R>t.R;
	}
}a[maxn];
vector<int> chan;
int BIT[maxt],cn;
void ADD(int x)
{
	cn++;
	while(x<=m+1)
	{
		BIT[x]++;
		x+=x&-x;
	}
}
int sum(int x)
{
	int s=0;
	while(x>0)
	{
		s+=BIT[x];
		x-=x&-x;
	}
	return s;
}
void UPD(int &ans,int rr,int ll)
{
	int res=cn-sum(rr-1);
//	cout<<ll<<" "<<rr<<" "<<res<<" "<<cn<<endl;
	ans=max(ans,rr+res-ll);
}
int dat[maxt],mx[maxt],tag[maxt];
void retag(int x,int l,int r)
{
	if(l==r)return;
	tag[x*2]+=tag[x];
	tag[x*2+1]+=tag[x];
	
	mx[x*2]+=tag[x];
	mx[x*2+1]+=tag[x];
	
	tag[x]=0;
	mx[x]=max(mx[x*2],mx[x*2+1]);
}
void build(int x,int l,int r)
{
	if(l==r)
	{
		mx[x]=l;
		return;
	}
	int mid=(l+r)>>1;
	build(x*2,l,mid);
	build(x*2+1,mid+1,r);
	mx[x]=max(mx[x*2],mx[x*2+1]);
}
void Insert(int x,int l,int r,int tl,int tr)
{
	if(tr<l||tl>r)return;
	retag(x,l,r);
	if(tl<=l&&r<=tr)
	{
		tag[x]++;
		mx[x]++;
		return;
	}
	int mid=(l+r)>>1;
	Insert(x*2,l,mid,tl,tr);
	Insert(x*2+1,mid+1,r,tl,tr);
//	dat[x]=dat[x*2]+dat[x*2+1];
	mx[x]=max(mx[x*2],mx[x*2+1]);
}
int query(int x,int l,int r,int tl=0,int tr=m+1)
{
	if(tr<l||tl>r)return -maxt;
	if(tag[x])retag(x,l,r);
	if(tl<=l&&r<=tr)return mx[x];
	int mid=(l+r)>>1;
	return max(query(x*2,l,mid,tl,tr),query(x*2+1,mid+1,r,tl,tr));
	
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%d%d",&a[i].L,&a[i].R);
		
	sort(a,a+n);
	build(1,0,m+1);
	int AL,AR,AX;
	int ans=m+1;
	for(int i=0;i<n;)
	{
		AL=a[i].L;
		int j=i;
		while(j+1<n&&a[j+1].L==AL)j++;
		chan.clear();
		for(int k=i;k<=j;k++)
		{
			chan.push_back(a[k].R);
			ADD(a[k].R);
			Insert(1,0,m+1,0,a[k].R);
		//	cout<<"uf "<<a[k].R<<" "<<query(1,0,m+1)<<endl;
		}
		sort(chan.begin(),chan.end());
		chan.erase(unique(chan.begin(),chan.end()),chan.end());
		
		for(int k=0;k<chan.size();k++)
			UPD(ans,chan[k],AL);
			
		int MMMX=query(1,0,m+1);
	//	cout<<MMMX<<endl;
		ans=max(ans,MMMX-AL);
		i=j+1;
	}
	ans=max(ans-m-1,n-m);
	printf("%d\n",ans);
	return 0;
}

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

vector<vector<int>> g;
vector<pair<int, int>> e;
int t[111111], d[111111];
void f(int u, int x) {
	if (t[x]) return;
	t[x] = 1;
	int v = u ? u ^ e[x].first^e[x].second : 1;
	for (int y : g[v])
		if (y != x) f(v, y);
	if (!u) return;
	if (d[v]) cout << v << ' ' << u << '\n', d[v] = 0;
	else cout << u << ' ' << v << '\n', d[u] ^= 1;
}
int main() {
	int n, m;
	cin >> n >> m;
	if (m & 1) {
		cout << -1 << endl;
		return 0;
	}
	g.resize(n + 1);
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		e.emplace_back(a, b);
		g[a].push_back(i);
		g[b].push_back(i);
	}
	f(0, m);
	cout << flush;
	return 0;
}


Measured memory_bytes: 16244
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N, K;
  int res=0;
  cin >> N >> K;

  while(N>0){
    N /= K;
    res++;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
/*input
100000
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  10000005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
void solve()
{
	lld k;
	cin >> k; 
	lld cnt=0;
	priority_queue<lld> q;
	rep(i,1,10){
		q.push(-i);
	}
	while(!q.empty()){
		lld t=q.top();
		q.pop();
		cnt++;
		t*=-1;
		if(cnt==k){
			cout << t << endl;
			return;
		}
		lld lastdig=t%10;
		rep(i,lastdig-1,lastdig+2){
			if(i>=0 && i<=9){
				lld x=t*10+i;
				q.push(-x);
			}
		}
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int modi = 1e9+7;
void solve(){
	ll n;
	cin >> n;
	pair<ll,ll> coords[n];
	vi xy,x_y;
	for(ll i =0;i<n;i++){
		ll x,y;
		cin >> x >> y;
		coords[i] = {x,y};
		xy.pb(x+y);
		x_y.pb(x-y);
	}
	ll ans = 0;
	sort(xy.begin(),xy.end());
	sort(x_y.begin(),x_y.end());

	ans = max(xy[n-1]-xy[0],x_y[n-1] - x_y[0]);

	// pii a  = dfs(0,coords[0]);
	// pii b=  dfs(a.se, coords[a.se]);
	// sort(ru.begin(),ru.end());
	cout << ans << endl; 

}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 8248
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
signed main(){
	int n,ans=0;
	string s;
	cin>>n>>s;
	f(i,n-2){
		if(s.substr(i,3)=="ABC")ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::{stdin, stdout, stderr, Write, BufWriter, BufReader, BufRead};

macro_rules! read_from_line {
    ($inbuf:ident => $($name:ident : $ty:ty),* ) => {
        let mut buf = String::new();
        $inbuf.read_line(&mut buf).unwrap();
        buf.pop();
        let mut words = buf.split_whitespace();
        $(
            let $name:$ty = words.next().unwrap().parse().unwrap();
        )*
    };
}

macro_rules! read_many {
    ($inbuf:ident => $name:ident : $ty:ty) => {
        let $name: Vec<$ty> = strio::read_many_from_line(&mut $inbuf);
    };
}

fn main() {
    let cout = stdout();
    let mut cout = BufWriter::new(cout.lock());
    let cin = stdin();
    let mut cin = BufReader::new(cin.lock());

    //read_from_line!(cin => a:i32, b:String);
    //let xs: Vec<i32> = strio::read_many_from_line(&mut cin);
    
    read_from_line!(cin => _n:i32);
    read_many!(cin => xs:i64);

    writeln!(cout, "{}", xs.iter().max().unwrap() - xs.iter().min().unwrap()).unwrap();


}

mod strio {
    use std::str::FromStr;
    use std;

    pub fn read_from_line<T, R> (r: &mut R) -> T where
        T: FromStr,
        <T as std::str::FromStr>::Err : std::fmt::Debug,
        R: std::io::BufRead,
    {
        let mut buf = String::new();
        r.read_line(&mut buf).unwrap();
        buf.pop();
        buf.parse().unwrap()
    }

    pub fn read_many_from_line<T, R> (r: &mut R) -> Vec<T> where
        T: FromStr,
        <T as std::str::FromStr>::Err : std::fmt::Debug,
        R: std::io::BufRead,
    {
        let mut buf = String::new();
        r.read_line(&mut buf).unwrap();
        buf.pop();
        buf.split_whitespace().map(|x| x.parse().unwrap()).collect()
    }
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
S = list(str(input()))

tmp = []
for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
        tmp.append(1)
    else:
        tmp.append(0)

ans = 0
num = 0
for i in range(len(S)):
    if tmp[i] == 1:
        num += 1
    else:
        ans = max(ans, num)
        num = 0
ans = max(ans, num)
print(ans)


Measured memory_bytes: 3064
//! ----------------------------------------------
//! 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 query(k: usize, d: &mut Vec<i64>, mut n: usize, x: i64, m: i64) -> usize {
    for i in 0..d.len() {
        d[i] %= m;
    }

    n -= 1;

    let a_last = {
        let mut a = x;

        for i in 0..k {
            let mut t = n / k;
            if i < n % k {
                t += 1;
            }

            a += (t as i64) * d[i];
        }

        a
    };

    // a[j] mod m == a[j+1] mod m
    // <=> d[j] == 0
    let u = (0..k)
        .map(|i| {
            if d[i] != 0 {
                return 0;
            }

            let mut t = n / k;
            if i < n % k {
                t += 1;
            }

            t
        })
        .sum::<usize>();

    // a[j] mod m > a[j+1] mod m
    // となるのは a[j] を m で割った商が 1 増えるとき
    let v = (a_last / m - x / m) as usize;

    n - (u + v)
}

fn main() {
    let (k, q) = read!(usize, usize);
    let d = read![[i64]];
    let T = read![usize, i64, i64; q];

    let mut d_buf = d.clone();

    for (n, x, m) in T {
        d_buf.clear();
        d_buf.extend(d.iter().cloned());

        println!("{}", query(k, &mut d_buf, n, x, m));
    }
}


Measured memory_bytes: 4476
#include <stdio.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))
#define max(p,q)((p)>(q)?(p):(q))
#define INF 1000000000

//ワーシャルフロイド
//頂点数（と隣接行列）を引いて全点間最短距離を返す
//O(V^3)
//*
int cost[410][410];
int dddd[410][410];
void waasharuhuroido(int n){
	rep(i,0,n)rep(j,0,n)dddd[i][j]=cost[i][j];//辺が無いところはINFにする前処理が必要
	rep(k,0,n)rep(i,0,n)rep(j,0,n)dddd[i][j]=min(dddd[i][j],dddd[i][k]+dddd[k][j]);
}

int h,w;
char s[30][30];
int d4[]={0,1,0,-1,0};
#define in(p,q)(0<=(p)&&(p)<h&&0<=(q)&&(q)<w)
int main(){
	scanf("%d%d",&h,&w);
	rep(i,0,h)scanf("%s",s[i]);
	rep(i,0,h*w)rep(j,0,h*w)cost[i][j]=i==j?0:INF;
	rep(i,0,h)rep(j,0,w)if(s[i][j]=='.'){
		rep(k,0,4){
			int ii=i+d4[k];
			int jj=j+d4[k+1];
			if(in(ii,jj)&&s[ii][jj]=='.')cost[i*w+j][ii*w+jj]=1;
		}
	}
	waasharuhuroido(h*w);
	int ans=0;
	rep(i,0,h*w)rep(j,0,h*w)if(dddd[i][j]!=INF)ans=max(ans,dddd[i][j]);
	printf("%d",ans);
}

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

int main() {
  int x,n;
  
  cin >> x;
  
  if(400<=x&&x<600){
    n = 8;
  }else if(600<=x&&x<800){
    n = 7;
  }else if(800<=x&&x<1000){
    n = 6;
  }else if(1000<=x&&x<1200){
    n = 5;
  }else if(1200<=x&&x<1400){
    n = 4;
  }else if(1400<=x&&x<1600){
    n = 3;
  }else if(1600<=x&&x<1800){
    n = 2;
  }else if(1800<=x&&x<2000){
    n = 1;
  }
  
  cout << n << endl;
  
  return 0;
  
  
  
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong

signed main(){
    int n;
    cin >> n;
    int A[MAX];
    REP(i,n){
        cin >> A[i+1];
    }
    A[0] = 0;
    int res = 0;
    FOR(i,1,n+1){
        int tmp = (A[i])/2;
        res += tmp;
        A[i] -= 2 * tmp;
        if(A[i+1] !=0 and A[i] !=0) A[i+1] ++;
    }
    cout << res << endl;

}


Measured memory_bytes: 1024
// 5/22
// ANT2-5-1. 二部グラフ判定
// 類題
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LLP = pair<ll, ll>;

struct Edge {
    int to;
    int length;
    Edge(int t, int l) : to(t), length(l) { }
};
using Graph = vector<vector<Edge>>;

// 1か-1で塗り分ける。初期値は0。
vector<int> color;

void dfs(Graph &G, int v, int c = 0) {
    color[v] = c;

    for (auto nv : G[v]) {
        // まだ塗られていない場合
        if (color[nv.to] == -1) {
            if (nv.length % 2 == 0) dfs(G, nv.to, c);
            else dfs(G, nv.to, 1 - c);
        }
    }
}
 
int main() {
    int N;
    cin >> N;

    Graph G(N);
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }

    color.assign(N, -1);

    rep(i, N) {
        if (color[i] == -1) {
            dfs(G, i, 0);
        }
    }

    rep(i, N) {
        cout << color[i] << endl;
    }
}


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

int main(){
  string a,b,c; cin>>a >>b >>c;
  a[0] -= 'a'-'A';
  b[0] -= 'a'-'A';
  c[0] -= 'a'-'A';
  cout<<a[0]<<b[0]<<c[0]<<endl;
}

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


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

  vector<ll> a(n, 0);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  bool flag = true;
  int cnt = 0;
  while(1){
    for(int i = 0; i < n; i++){
      if(a[i] % 2 == 1){
        flag = false; break;
      }
      a[i] /= 2;
    }
    if(!flag) break;
    cnt++;
  }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;


public class Main {
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 
	public static boolean solve(long r, long g, long b, long w) {
		 if((r%2+g%2+b%2+w%2)>1)return false;
		 else return true;
	}
	public static void main(String[] args)throws IOException  {
		FastReader s=new FastReader();		
		
		int n = s.nextInt();
		int x = s.nextInt();
		int t = s.nextInt();
			int p = (int)Math.ceil((double)n/(double)x);
			System.out.println(p*t);
	}
	
}


Measured memory_bytes: 32664
let n, d, x = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let _ = Array.fold_left (fun c a -> c + (d - 1) / a + 1) 0 a_s |> (+) x |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

int main(void)
{
  std::string s;
  std::cin >> s;
  int a_cnt = std::count(s.begin(), s.end(), 'A');
  int b_cnt = std::count(s.begin(), s.end(), 'B');
  std::string result = (a_cnt && b_cnt) ? std::string("Yes") : std::string("No");
  std::cout << result << std::endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	s := make(map[string]int)
	for i := 0; i < n; i++ {
		s[Scan()]++
	}
	m := iScan()
	t := make(map[string]int)
	for i := 0; i < m; i++ {
		t[Scan()]++
	}
	ans := make([]int, 0)
	for k, v := range s {
		ans = append(ans, v-t[k])
	}
	fmt.Println(larger(0, max(ans)))
}


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

#define int long long
#define mp make_pair
#define fi first
#define se second

typedef pair<int,int> ii;
typedef pair<int,ii> edge;
typedef pair<ii,int> data;
const int N = 1e5 + 5;
int n;
data a[N];
priority_queue<edge, vector<edge>, greater<edge> > pq;
int par[N];
int anc(int u) { return u == par[u] ? u : par[u] = anc(par[u]); }
void join(int u,int v) { par[anc(v)] = anc(u); }
signed main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1;i <= n;++i) {
		cin >> a[i].fi.fi >> a[i].fi.se;
		a[i].se = i;
		par[i] = i; //////////////////
	}
	sort(a + 1, a + 1 + n);
	for (int i = 2;i <= n;++i) pq.push(edge(min(abs(a[i].fi.fi - a[i - 1].fi.fi), abs(a[i].fi.se - a[i - 1].fi.se)), ii(a[i].se, a[i - 1].se)));
	for (int i = 1;i <= n;++i) swap(a[i].fi.se, a[i].fi.fi);
	sort(a + 1, a + 1 + n);
	for (int i = 2;i <= n;++i) pq.push(edge(min(abs(a[i].fi.fi - a[i - 1].fi.fi), abs(a[i].fi.se - a[i - 1].fi.se)), ii(a[i].se, a[i - 1].se)));
	int need = n - 1;
	int res = 0;
	while (need) {
		edge cur = pq.top(); pq.pop();
		if (anc(cur.se.fi) == anc(cur.se.se)) continue;
		join(cur.se.fi, cur.se.se) ; res += cur.fi;need--;
	}
	cout << res;
}

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

int main() {
  double n; cin >> n;
  vector<int> x(n);
  for (int i=0; i < n; i++) cin >> x.at(i);
  int avg = round(accumulate(x.begin(), x.end(), 0) / n);
  ll ans = 0;
  for (int i=0; i < n; i++) {
    ans += (avg-x.at(i)) * (avg-x.at(i));
  }
  cout << ans << endl;
  return 0;
}

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

#define ll long long

int N, K, C;
string s;
int dp[400401];
int chk[200201];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> K >> C >> s;
	s = ' ' + s;
	for(int i=N; i>=1; i--)
	{
		if (s[i] == 'x')
		{
			dp[i] = dp[i+1];
			continue;
		}
		dp[i] = max(dp[i+1+C]+1, dp[i+1]);
	}

	memset(chk, -1, sizeof(chk));
	int n = 1, cnt = 0;
	while(n <= N)
	{
		if (s[n] == 'o')
		{
			chk[n] = cnt;
			cnt++;
			n += 1 + C;
		}
		else n++;
	}
	if (cnt > K) { return 0; }

	for(int i=1; i<=N; i++)
	{
		if (chk[i] == -1) continue;
		//printf("chk %d : %d + %d\n", i, chk[i], dp[i+1]);
		if (chk[i] + dp[i+1] == K); // 대안이 있는가?
		else cout << i << "\n";
	}
	return 0;
}

Measured memory_bytes: 3408
x = list(map(int, input().split()))

if x[0] == 0:
    print('1')

elif x[1] == 0:
    print('2')

elif x[2] == 0:
    print('3')

elif x[3] == 0:
    print('4')

elif x[4] == 0:
    print('5')
    

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int A = 0;
 string S,T;
 cin >> S >> T;
 if(S.at(0) == T.at(0)){
   A ++;
 }
 if(S.at(1) == T.at(1)){
   A ++;
 }
 if(S.at(2) == T.at(2)){
   A ++;
 }
 cout << A << endl;
}

Measured memory_bytes: 256
import heapq

k = int(input())
l = list(range(1,10))
heapq.heapify(l)
for _ in range(k):
    leftpop = heapq.heappop(l)
    fp = leftpop % 10
    if fp == 0:
        heapq.heappush(l,leftpop * 10)
        heapq.heappush(l,leftpop * 10 + 1)
    elif fp == 9:
        heapq.heappush(l,leftpop * 10 + 9 - 1)
        heapq.heappush(l,leftpop * 10 + 9)
    else:
        heapq.heappush(l,leftpop * 10 + fp - 1)
        heapq.heappush(l,leftpop * 10 + fp)
        heapq.heappush(l,leftpop * 10 + fp + 1)

print(leftpop)

Measured memory_bytes: 11652
#include "bits/stdc++.h"
using namespace std;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n;
	cin >> n;
	string s;
	string arfa = "abcdefghijklmnopqrstuvwxyz";
	map<char, int> c;
	for (int i = 0; i < arfa.size(); i++) {
		c[arfa[i]] = 100;
	}

	for (int i = 0; i < n; i++) {
		string k;
		cin >> k;
		map<char, int>ans;
		for (int j = 0; j < k.size(); j++) {
			ans[k[j]]++;
		}
		for (int j = 0; j < arfa.size(); j++) {
			if (c[arfa[j]] > ans[arfa[j]]) {
				c[arfa[j]] = ans[arfa[j]];
			}
		}
	}
	string kotae = "";
	for (int i = 0; i < arfa.size(); i++) {
		for (int j = 0; j < c[arfa[i]]; j++) {
			kotae = kotae + arfa[i];
		}
	}
	cout << kotae;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int nCr(ll N, ll M) {
    if (N == 3 && M != 0) {
        return 1;
    } else if (N < 3) {
        return 0;
    } else if (M == 0) {
        return 0;
    } else if (M == 1) {
        return 1;
    } else {
        ll q = 1;
        for (ll i = 0; i < M - 1; i++) {
            q *= N + M - 4 - i;
            q %= 1000000007;
        }
        for (int i = 0; i < M - 1; i++) {
            q /= 1 + i;
            q %= 1000000007;
        }
        return q;
    }
}
int main() {
   int N,X,T;
   cin>>N>>X>>T;
  if(N%X!=0){
      N+=X;
  }
  cout<<N/X*T<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=2e9;


int main()
{
    ios::sync_with_stdio(false);
    ll l,r,tem=2019;
    cin>>l>>r;

    if(!l||r-l>2019)
    {
        cout<<0<<endl;
        return 0;
    }

    l=l%2019;
    r=r%2019;

    int ans=2200;

    for(int i=l;i<=r;i++)
        for(int j=i+1;j<=r;j++)
        ans=min(ans,(i*j)%2019);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    const nm = input[0].split(' ');
    const n = parseInt(nm[0], 10);
    const m = parseInt(nm[1], 10);
    const xyz = readXYZ(input, n);
    
    const COEF = [
        {x: 1, y: 1, z: 1},
        {x: 1, y: 1, z: -1},
        {x: 1, y: -1, z: 1},
        {x: 1, y: -1, z: -1},
        {x: -1, y: 1, z: 1},
        {x: -1, y: 1, z: -1},
        {x: -1, y: -1, z: 1},
        {x: -1, y: -1, z: -1},
    ];
   
    let ans = 0;
    for (let i = 0; i < COEF.length; i++) {
        ans = Math.max(ans, calcMax(xyz, COEF[i], m));
    }

    console.log(ans);

    return 0;
}

function readXYZ(input, n) {

    let xyz = new Array(n);

    for (let i = 0; i < n; i++) {
        const xyzstr = input[1 + i].split(' ');
        xyz[i] = {
            x: parseInt(xyzstr[0], 10),
            y: parseInt(xyzstr[1], 10),
            z: parseInt(xyzstr[2], 10),
        };
    }

    return xyz;
}

function calcMax(xyz, coef, m) {

    let xyzwork = xyz.concat();

    xyzwork.sort(function(a, b) {
        const aval = coef.x * a.x + coef.y * a.y + coef.z * a.z;
        const bval = coef.x * b.x + coef.y * b.y + coef.z * b.z;
        if (aval > bval) {
            return -1;
        } else if (aval < bval) {
            return 1;
        } else {
            return 0;
        }
    });

    let ret = 0;
    for (let i = 0; i < m; i++) {
        ret += coef.x * xyzwork[i].x + coef.y * xyzwork[i].y + coef.z * xyzwork[i].z;
    }

    return ret;
}

Measured memory_bytes: 11948
#include<stdio.h>

int data[10];
int sp=0;
int top() {
    return data[sp-1];
}
void pop() {
    sp--;
}
void push(int n) {
    if(n>0) {
        data[sp] = n;
        sp++;
    }
}

int main() {
    int n;
    while(scanf("%d",&n) != EOF) {
        if(n==0) {
            printf("%d\n",top());
            pop();
        }else{
            push(n);
        }
    }
    return 0;
}

Measured memory_bytes: 1788
# -*- coding:utf-8 -*-
import sys
array = []
for i in sys.stdin:
    array.append(i)

for i in range(len(array)):
    data = array[i].split()
    a = int(data[0])
    op = str(data[1])
    b = int(data[2])
    if op == '?':
        break
    if op == '+':
        print(a+b)
    if op == '-':
        print(a-b)
    if op == '/':
        print(int(a/b))
    if op == '*':
        print(a*b)

Measured memory_bytes: 7640
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

int gcd(int x, int y)
{
	if (x < y)
	{
		swap(x, y);
	}
	while (y > 0)
	{
		int r = x % y;
		x = y;
		y = r;
	}
	return x;
}

int main()
{
	int x, y;
	cin >> x >> y;

	cout << gcd(x, y) << endl;

	return 0;
}

Measured memory_bytes: 1164
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      a: i64,
      b: i64,
      _c: i64,
      k: i64,
    }
    if k % 2 == 0 {
        println!("{}", a-b);
    } else {
        println!("{}", b-a);
    }
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main(){
    int A, B, C, X, count = 0;
    cin >> A >> B >> C >> X;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if(500 * i + 100 * j + 50 * k == X) count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int k1, k2;
    int ans;

    for ( k1 = 1; k1 <= 9; k1++ ){
        for ( k2 = 1; k2 <= 9; k2++ ){
            ans = k1*k2;
            printf("%dx%d=%d\n", k1, k2, ans);
        }
    }

    return 0;
}

Measured memory_bytes: 520
#include <stdio.h>

int search(int A[], int n, int key) {
	int i = 0;
	A[n] = key;
	while ( A[i] != key ) {
		i++;
	}
	return i != n;
}

int main() {
	int i, n, A[10001], q, key, sum = 0;

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

	scanf("%d", &q);
	for ( i = 0; i < q; i++) {
		scanf("%d", &key);
		if( search(A, n, key) ){
			sum++;
		}
	}
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 636
n = int(input())
s = input()
number_of_W_in_prefix = [0]
number_of_R_in_suffix = [0]
for i in range(n):
    number_of_W_in_prefix.append(number_of_W_in_prefix[i] + (s[i] == 'W'))
    number_of_R_in_suffix.append(number_of_R_in_suffix[i] + (s[n - i - 1] == 'R'))
result = n
for k in range(n + 1):
    result = min(result, max(number_of_W_in_prefix[k], number_of_R_in_suffix[n - k]))
print(result)


Measured memory_bytes: 95516