akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#ifdef RUBICK
#include "dbg.h"
#endif

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;

const ll MOD = 1e9 + 7;

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

    string row[2];
    cin >> row[0];
    cin >> row[1];

    const auto get_type = [&](int i) {
        if (row[0][i] == row[1][i])
            return 1;
        else
            return 2;
    };

    int i = 0;
    int ptype = -1;
    ll ans = 1;
    while (i < n) {
        int ctype = get_type(i);
        if (ptype == -1) {
            if (ctype == 1)
                ans = 3;
            else
                ans = 6;
        } else {
            if (ptype == 1 && ctype == 1) {
                ans = (ans * 2) % MOD;
            } else if (ptype == 1 && ctype == 2) {
                ans = (ans * 2) % MOD;
            } else if (ptype == 2 && ctype == 1) {
                ans = (ans * 1) % MOD;
            } else {
                ans = (ans * 3) % MOD;
            }
        }

        ptype = ctype;

        if (ctype == 1)
            i += 1;
        else
            i += 2;
    }

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


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

ll mod_pow(ll a,ll b,ll p){ //(a^b)%p
	ll res=1;
	a%=p;

	while(b>0){
		if(b&1==1) res=((res%p)*(a%p))%p;
		a=(a%p*a%p)%p;
		b>>=1;
	}
	return res;
}

//mod_inv=mod_pow(denominator,MOD-2,MOD);
int fac[MAXSIZE+6];
int inv[MAXSIZE+6];

void pre(){
	fac[0] = 1;
	for(int i=1;i<=MAXSIZE;i++){
		fac[i] = fac[i-1] * (i);
		fac[i]%=mod;
	}
	inv[MAXSIZE] = mod_pow(fac[MAXSIZE],mod-2,mod);
	for(int i=MAXSIZE-1;i>=0;i--){
		inv[i] = (i+1) * inv[i+1];
		inv[i]%=mod;
	}
}

int nCr(int n, int r){
	if(r>n) return 0;
	int ans = fac[n];
	ans%=mod;
	ans = ans * inv[r];
	ans%=mod;
	ans = ans * inv[n-r];
	ans%=mod;
	return ans;
}

int a[maxn];
int32_t main(){
	fastio();
	int n , k ;
	cin >> n >> k;
	forr(i,n) cin >> a[i];
	sort(a,a+n);
	pre();
	int sum = 0;
	int ans = 0;
	if( k == 1) {
		cout << 0;
		return 0;
	}
	int r = k-2;
	for(int i = k-1; i < n; i++){
		sum += nCr(r,k-2);
		r++;
		ans += (sum % mod ) * (a[i]%mod);
		ans %= mod;
	}
	r = k - 2;
	sum = 0;
	for(int i = n-k; i >= 0; i--){
		sum += nCr(r,k-2);
		r++;
		ans -=(sum%mod) * (a[i]);
		ans = (ans + mod) %mod;
	}
	cout << ans;
}

Measured memory_bytes: 20072
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll pow(ll a,ll b){
  if(b==0) return 1;
  ll ret=pow(a,b/2);
  ret*=ret;
  ret%=mod;
  if(b%2==1) ret*=a;
  ret%=mod;
  return ret;
}
struct nCr{
private:
  vector<ll> vecs,vecm,vec;
  ll n;
public:
  nCr(ll a){
    vecs.resize(a+1,0);
    n=a;
    vecs[0]=1;
    for(ll i=1;i<=n;i++){
      vecs[i]=vecs[i-1]*(a-i+1);
      vecs[i]%=mod;
    }
    for(ll i=0;i<=n;i++) vecs[i]%=mod;

  //  cout<<pow(vecs[n],mod-2)<<endl;
    vecm.resize(n+1,0);
    vecm[n]=pow(vecs[n],mod-2)%mod;
    for(int i=n-1;i>=0;i--){
      vecm[i]=(vecm[i+1]*(i+1))%mod;
    }

    vec.resize(n+1,0);
    for(int i=0;i<=n;i++) vec[i]=(vecs[i]*vecm[i])%mod;
  }
  ll comb(ll p){
    if(p>n||p<0) return 0;
    return vec[p];
  }
  void debug(){
    for(ll i=0;i<=n;i++) cout<<vecs[i]<<" ";
    cout<<endl;
    for(ll i=0;i<=n;i++) cout<<vecm[i]<<" ";
    cout<<endl;
    for(ll i=0;i<=n;i++) cout<<vec[i]<<" ";
    cout<<endl;
  }
};
int main(){
  ll n;
  cin>>n;
  vector<ll> used(n+1,0);
  vector<ll> v;
  ll d;
  for(ll i=0;i<=n;i++){
    ll a;
    cin>>a;
    v.push_back(a);
    if(used[a]==1) d=a;
    used[a]=1;
  }
  if(n==1) {
    cout<<1<<endl<<1<<endl;
    return 0;
  }
  ll l;
  for(ll i=0;i<=n;i++){
    if(v[i]==d){
      l=i;
      break;
    }
  }
  ll right;
  for(ll i=n;i>=0;i--){
    if(v[i]==d){
      right=i;
      break;
    }
  }
  //cout<<l<<" "<<right<<endl;
  ll p=l,q=right-l-1,r=n-right;
  ll pr=p+r;
//  cout<<"a"<<endl;
  nCr n1comb=nCr(n-1),prcomb=nCr(pr);
  //n1comb.debug();
//  cout<<"b"<<endl;
  ll a=390205642,b=542308465;
//  cout<<(a*b)%mod<<"do"<<endl;
  for(ll i=1;i<=n+1;i++){
    ll ans=n1comb.comb(i)+2*n1comb.comb(i-1)+n1comb.comb(i-2)-prcomb.comb(i-1);
    while(ans<0) ans+=mod;
    ans%=mod;
    cout<<ans<<endl;
  }
}


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

int main() {
	int n, t, a;
	cin >> n >> t >> a;
	int h[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	double min = 1e8;
	double tmp;
	int ans;
	for (int i = 0; i < n; i++) {
		tmp = abs (a - (t-h[i]*0.006));
		if (tmp < min) {
			min = tmp;
			ans = i+1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

string str;

ll stringToInt(string strInt){
	ll ret = 0;

	for(int i = 0;i < strInt.size();i++){
		ret *= 10;
		ret += strInt[i] - '0';
	}

	return ret;
}

ll saiki(int now, string stackStr, int sum){
	ll ret = 0;
	if(now == str.size()){
		ll plus = stringToInt(stackStr);
		return sum + plus;
	}


	if(stackStr.size() != 0){
		ll plus = stringToInt(stackStr);
		string next1 = "";
		next1 += str[now];
		ret += saiki(now + 1, next1, sum + plus);
	}

	string next2 = stackStr + str[now];
	ret += saiki(now + 1, next2, sum);

	return ret;
}

int main() {
	cin >> str;
	cout << saiki(0, "", 0) << endl;
	return 0;
}

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

const int maxn = 110;
char str[maxn];

int main()
{
    //freopen("D.in","r",stdin);
    int n;
    scanf("%d",&n);
    scanf("%s",str+1);
    int leftb = 0, rightb = 0;
    int ans = 0;
    for (int i=1;i<=n;i++)
    {
        if (str[i] == '(') leftb++;
        else rightb++;
        if (leftb >= rightb) continue;
        ans += rightb - leftb;
        leftb = rightb;
    }
    for (int i=1;i<=ans;i++) printf("(");
    for (int i=1;i<=n;i++) printf("%c",str[i]);
    for (int i=1;i<=leftb-rightb;i++) printf(")");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
#define MOD (ll)(1e9+7)
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;


signed main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    ll sum[n] = {};
    rep(i,0,n){
        cin >> a[i];
        if(i > 0) sum[i] += sum[i-1];
        sum[i] += a[i]; 
    }

    ll ans = LINF;
    rep(i,0,n-1){
        ans = min(ans,abs(sum[i] - (sum[n-1] - sum[i])));
    }

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


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int n;
vector<vector<P>> v;

bool judge(int bit){

  for(int i= 0; i< n; i++){

    if(!(bit & (1<<i) )) continue;

    for(P xy: v[i]){
      int x = xy.first;
      int y = xy.second;

      if(y == 1 && !(bit & (1 << x))) return false;
      if(y == 0 &&  (bit & (1 << x))) return false;
    }
  }

  return true;
}

int main(){
  cin >> n;
  v.resize(n);

  rep(i,n){
    int a; cin >> a;
    v[i].resize(a);

    rep(j,a){
      int x, y;
      cin >> v[i][j].first >> v[i][j].second;
      v[i][j].first--;
    }

  }

  int ans = 0;

  for(int bit = 0; bit < (1 << n); bit++){

    if(judge (bit) ){

      int cnt = 0;
      rep(i,n) if(bit & (1 << i)) cnt ++;

      ans = max(ans, cnt);
    }
  }

  dunk(ans);
}

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,c=INTM()
    if a==b:
        print(c)
    elif a==c:
        print(b)
    else:
        print(a)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#include<numeric>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_ll = pair<ll, ll>;
int main() {
	int A, B;
	cin >> A >> B;
	if (B != A)cout << 2 * max(A,B) - 1 << endl;
	else cout << 2 * A << endl;
	cin >> A;
}

Measured memory_bytes: 384
import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int max = 0;
        int[] list = new int[a];
        for (int i = 0; i < a; i++) {
            list[i] = sc.nextInt();
            if(list[i] > max) {
                max = list[i];
            }
        }
        int ans = 0;
        for(int i = 0;i < max;i++){
            boolean flg = false;
            for(int j = 0; j < a; j++){
                if(list[j] > i && !flg){
                    ans++;
                    flg = true;
                } else if(list[j] <= i) {
                    flg = false;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

string S;
string T;
string finalAns;
int cnt = 0;
int isPossible;
int ans;
int pos = -1;

int main()
{
	cin >> S;
	cin >> T;

	for(int i = 0; i < S.size() - T.size() + 1; i++)
	{
		isPossible = 1;
		for(int j = 0; j < T.size(); j++)
		{
			if(S[i + j] == '?')
			{
				continue;
			}
			else if(S[i + j] != T[j])
			{
				isPossible = 0;
			}
		}
			// cout << isPossible;
		if(isPossible)
		{
			pos = i;
		}
	}
	if(pos >= 0)
	{
		for(int i = 0; i < T.size(); i++)
		{
		
			S[pos + i] = T[i];

		}
		for(int i = 0; i < S.size(); i++)
		{
			if(S[i] == '?')
			{
				S[i] = 'a';
			}
		}
		cout << S;
	}
	else
	{
		cout << "UNRESTORABLE";
	}

	return 0;
}


/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
n,m = map(int,input().split())
if(m==1):
    print(1)
    exit()

mod = 10**9+7

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5//1)+1 ):
        if(temp%i == 0):
            count=0
            while( temp%i == 0):
                count += 1
                temp = temp // i
            arr.append([i, count])

    if(temp != 1):
        arr.append([temp, 1])

    if(arr == []):
        arr.append([n, 1])

    return arr

max_n = 2 * 10**5
fac, finv, inv = [0]*max_n, [0]*max_n, [0]*max_n

def comInit(max_n):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max_n):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max_n)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( (n<0) | (k < 0)):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

arr = factorization(m)

ans = 1
for _,k in arr:
    ans *= com(n+k-1, k)
    ans %= mod

print(ans)

Measured memory_bytes: 70076
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define H_MAX 50
#define W_MAX 50

int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int H,W;

namespace patch {
  template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
}

int main() {

	string s,t;
	cin >> s >> t;

	vector<int> vec;
	rep(i,s.size()) {
		int k = i;
		rep(j,t.size()) {
			if(s[k] == t[j] || s[k] == '?') {
				if(j == t.size()-1) {
					vec.pb(i);
				}
				else {
					k++;
					continue;
				}
			}
			else
				break;
		}
	}
	if(vec.size() == 0) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	vector<int>::iterator iter = vec.begin();
	vector<string> ans;
	while(iter != vec.end()) {
		string acc = s;
		rep(i,t.size()) {
			acc[*iter + i] = t[i];
		}
		rep(i,s.size()) {
			if(acc[i] == '?')
				acc[i] = 'a';
		}
		ans.pb(acc);
		iter++;
	}

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

	cout << *(ans.begin()) << endl;
  return 0;
}
 


Measured memory_bytes: 256
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
import itertools
seq=tuple([i+1 for i in range(n)])
i=0
for j in itertools.permutations(seq):
  if p==j:
    x=i
  if q==j:
    y=i
  i+=1
print(abs(x-y))


Measured memory_bytes: 39152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt(),m=s.nextInt();
        System.out.println(n==m?"Yes":"No");
    }
}



class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25348
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <iomanip>
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=j;i>=k;i--)
#define LL long long
using namespace std ;

inline LL read() {
	LL x = 0 , f = 1 ;
	char ch = getchar() ;
	while(ch<'0'||ch>'9') { if(ch=='-') f = -1 ; ch = getchar() ; }
	while(ch>='0'&&ch<='9') { x = x * 10+ch-48 ; ch = getchar() ; }
	return x * f ;
}

const int N = 2e5+11;
int n,m;
int vis_1[N],vis_2[N];


int main() {
	n=read();m=read();
	vis_1[1]=1; vis_2[n]=1;
	For(i, 1, m) {
		int x=read(),y=read();
		if(x==1) vis_1[y]=1;
		if(y==n) vis_2[x]=1;
	}
	For(i, 1, n) 
		if(vis_1[i] && vis_2[i]) {
			puts("POSSIBLE");
			return 0;
		}
	puts("IMPOSSIBLE");
}









Measured memory_bytes: 1792
#include<stdio.h>
#define GRAY 1    //visited
#define WHITE 0   //non-visited

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum;

  scanf("%d", &n);   

  int M[n][n], p[n]; 
  int visited[n], cost[n], pi[n]; 

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;  //隣接行列M
    }
  }
  
  for ( i = 0; i < n; i++ ){
    visited[i] = WHITE;
    cost[i] = INFTY;
  }

  cost[0] = 0;
  pi[0] = -1;

  while(1){
    int mincost = INFTY;
    int u;

    for(i = 0; i < n; i++){  //costが最小のノードuを選択
      if(!visited[i]==GRAY && cost[i]<mincost){
	mincost = cost[i];
	u = i;
      }
    }

    if( mincost == INFTY ) break;

    visited[u] = GRAY;

    int v;

    for(v = 0; v < n; v++){
      if(visited[v]==GRAY || M[u][v]==INFTY) continue;
      if(M[u][v] < cost[v]){
	cost[v] = M[u][v];
	pi[v] = u;
      }
    }
    
  }

  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( pi[i] != -1 ) sum += M[i][pi[i]];
  }

  printf("%d\n", sum);

  return 0;
}


//http://algorithms.blog55.fc2.com/blog-entry-36.html

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない



int main() {
	
	int n;
	int x[100], y[100], h[100];
	ll cx, cy, H;
	int p = 0;

	cin >> n;

	rep(i, 0, n) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] > 0)p = i;
	}

	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			H = h[p] + abs(x[p] - i) + abs(y[p] - j);
			rep(l, 0, n) {
				ll sh = 0;
				if (h[l] > 0) {
					sh = h[l] + abs(x[l] - i) + abs(y[l] - j);
					if (sh != H)break;
				}
				else {
					if (H - abs(x[l] - i) - abs(y[l] - j) > 0)break;
				}

				if (l == n - 1) {
					cout << i <<' '<< j <<' '<< H << endl;
				}
				
			}
		}
	}

	return 0;
}


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

using namespace std;

#define MOD 1000000007

const int INF = 1e9;

typedef long long ll;
typedef pair<int, int> pii;
int n,h;
int dp[(ll)1e3+1][(ll)1e4+1];
int a[(ll)1e3+1];
int b[(ll)1e3+1];

int f(int i , int health) {
    if(health <= 0) return 0;
    if(i >= n) return INF;
    int &ret = dp[i][health];
    if(ret != -1) return ret;
    
    ret = min(b[i] + f(i+1, health - a[i]), b[i] + f(i, health - a[i]));
    ret = min(ret, f(i+1, health));

    return ret;

}
int main() {
    // oh hi mark
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h >> n;
    for(int i = 0; i < n; i++) {
        int x; cin >> x;
        h -= x;
    }
    if(h <= 0) {
        cout << "Yes\n";
    }else cout << "No\n";
    
    return 0;
}


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

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

int n, ck[100009];
string s;
vector<int> vec;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s;
	n = s.length();
	if (s[n - 1] == '1') cout << -1 << E;
	else if (s[0] == '0' || s[n - 2] == '0') cout << -1 << E;
	else {
		for (int i = 1; i < n - 2; i++) {
			int t1 = i + 1;
			int t2 = n - t1;
			if (s[i] == '0') {
				if (ck[t1] == 1 || ck[t2] == 1) {
					cout << -1 << E;
					return 0;
				}
				else {
					ck[t1] = -1;
					ck[t2] = -1;
				}
			}
			else {
				if (ck[t1] == -1 || ck[t2] == -1) {
					cout << -1 << E;
					return 0;
				}
				else {
					ck[t1] = 1;
					ck[t2] = 1;
				}
			}
		}
		cout << "1 2" << E;
		int cur = 2, cnt = 2;
		while (1) {
			if (cnt >= n) break;
			if (ck[cnt] == 1) {
				cout << cur << " " << cnt + 1 << E;
				cur = cnt + 1;
			}
			else {
				cout << cur << " " << cnt + 1 << E;
			}
			cnt++;
		}
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 2000
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		  Scanner  scan = new   Scanner (System.in);
		 String str1=scan.next();
		 String str2=scan.next();
		 char []c1=str1.toCharArray();
		 char[]c2=str2.toCharArray();
		 int count=0;
		 for(int i=0; i<c1.length;i++){
			 if(c1[i]==c2[i]){
				 count++;
			 }
		 }
		 System.out.println(count);
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <string.h>

int main(void) {
  char s[100],s1[50],s2[50];
  int l,i,p=0;
  gets(s);
  l=strlen(s);
  for(i=0;i<l/2;i++){
    s1[i]=s[i];
    s2[i]=s[i+l/2+1];
    if(s1[i]!=s2[i]){
      p=1;
    }
  }
  if(p==0){
    printf("Yes");
  }
  else printf("No");
}

Measured memory_bytes: 128
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;

typedef long long ll;

bool mark[105];

int arr[105];

int n, ans;

void solve() {                   
    scanf("%d", &n);    

    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);    
    }
    
    for (int i = 2; i <= n; ++i) {
        if (arr[i] == arr[i - 1] && !mark[i - 1]) {
            mark[i] = 1;
            ++ans;    
        }
    }

    printf("%d\n", ans);
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int x, y;
	cin >> x >> y;
	if(y%2 != 0){
		puts("No");
		return 0;
	}else{
		if(y >= 2*x && y<= 4*x){
			puts("Yes");
		}else puts("No");
	}
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

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

    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin>>a[i];

    int Q; cin>>Q;
    int ans=0;
    while(Q--){
        int x; cin>>x;
        int ng=-1,ok=N;
        while(ok-ng>1){
            int mid=(ok+ng)/2;
            if(a[mid]>=x) ok=mid;
            else ng=mid;
        }
        if(ok<N and a[ok]==x) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3236
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define EPS 1e-10
#define equals(a, b) (fabs(a - b) < EPS)

class Vector {
public:
  double x, y;
  Vector() {}
  Vector(double x, double y) : x(x), y(y) {}

  Vector operator+(Vector v) { return Vector(x + v.x, y + v.y); }
  Vector operator-(Vector v) { return Vector(x - v.x, y - v.y); }
  Vector operator*(double s) { return Vector(s * x, s * y); }
  double norm() { return x * x + y * y; }
  double abs() { return sqrt(norm()); }
};

// inner product
double dot(Vector v1, Vector v2) { return v1.x * v2.x + v1.y * v2.y; }

// cross product
double cross(Vector v1, Vector v2) { return v1.x * v2.y - v1.y * v2.x; }

class Line {
public:
  Vector v1, v2;
  Line() {}
  Line(Vector v1, Vector v2) : v1(v1), v2(v2) {}
};
class Segment {
public:
  Vector v1, v2;
  Segment() {}
  Segment(Vector v1, Vector v2) : v1(v1), v2(v2) {}
  operator Line() const { return Line(v1, v2); }
};

bool is_parrallel(Vector a, Vector b) { return equals(cross(a, b), 0); }
bool is_parrallel(Line a, Line b) {
  return is_parrallel(a.v1 - a.v2, b.v1 - b.v2);
}
bool is_parrallel(Segment a, Segment b) {
  return is_parrallel((Line)a, (Line)b);
}

bool is_orthogonal(Vector a, Vector b) { return equals(dot(a, b), 0); }
bool is_orthogonal(Line a, Line b) {
  return is_orthogonal(a.v1 - a.v2, b.v1 - b.v2);
}

Vector project(Line l, Vector v) {
  Vector a = v - l.v1;
  Vector b = l.v2 - l.v1;
  return l.v1 + b * (dot(a, b) / b.norm());
}

Vector reflect(Line l, Vector v) { return v + (project(l, v) - v) * 2.0; }

double distance(Line l, Vector v) { return (v - project(l, v)).abs(); }
double distance(Vector v1, Vector v2) { return (v1 - v2).abs(); }
bool in_segment(Segment s, Vector v) {
  return dot(s.v2 - s.v1, v - s.v1) > 0 && dot(s.v1 - s.v2, v - s.v2) > 0;
}
double distance(Segment s, Vector v) {
  auto m = project((Line)s, v);
  if (in_segment(s, m)) {
    return distance(m, v);
  } else
    return min(distance(s.v1, v), distance(s.v2, v));
}
bool opposite(Line l, Vector v1, Vector v2) {
  auto a = l.v2 - l.v1;
  auto b = v1 - l.v1;
  auto c = v2 - l.v1;
  return cross(a, b) * cross(a, c) < 0;
}
bool intersect(Segment s1, Segment s2) {
  if (is_parrallel(s1, s2)) {
    return equals(distance(s1, s2.v1), 0) || equals(distance(s1, s2.v2), 0);
  } else {
    return opposite((Line)s1, s2.v1, s2.v2) && opposite((Line)s2, s1.v1, s1.v2);
  }
}

double distance(Segment s1, Segment s2) {
  if (intersect(s1, s2)) {
    return 0;
  }
  return min({distance(s1, s2.v1), distance(s1, s2.v2), distance(s2, s1.v1),
              distance(s2, s1.v2)});
}

int main() {
  int nq;
  cin >> nq;
  for (int i = 0; i < nq; i++) {
    Segment seg[2];
    for (int j = 0; j < 2; j++) {
      int x0, y0, x1, y1;
      cin >> x0 >> y0 >> x1 >> y1;
      seg[j] = Segment(Vector(x0, y0), Vector(x1, y1));
    }
    printf("%.10f\n", distance(seg[0], seg[1]));
  }
}

Measured memory_bytes: 3208
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() throws IOException{
		while (true) {
			String input = br.readLine();
			if (input == null) break;

			String[] words = input.split(" ");
			boolean flag = false;
			int cip = 0;
			for (int i=0; !flag; i++) {
				cip = words[i].charAt(0) - 't';
				if (words[i].length() == 3) {
					char c1 = decipher(words[i].charAt(0)-cip);
					char c2 = decipher(words[i].charAt(1)-cip);
					char c3 = decipher(words[i].charAt(2)-cip);
					if (c1 == 't' && c2 == 'h' && c3 == 'e') {
						flag = true;
					}
				}else if (words[i].length() == 4) {
					char c1 = decipher(words[i].charAt(0)-cip);
					char c2 = decipher(words[i].charAt(1)-cip);
					char c3 = decipher(words[i].charAt(2)-cip);
					char c4 = decipher(words[i].charAt(3)-cip);
					if (c1 == 't' && c2 == 'h') {
						if ((c3 == 'i' && c4 == 's') || (c3 == 'a' && c4 == 't')){
							flag = true;
						}
					}
				}
			}

			char[] seq = input.toCharArray();
			StringBuilder sb = new StringBuilder();
			for (int i=0; i<seq.length; i++)
				sb.append((seq[i]==' ' || seq[i]=='.' || seq[i]=='\n' ? (char)seq[i] : decipher(seq[i]-cip)));
			out.println(sb);
		}
	}

	static char decipher(int x){
		x -= 'a';
		while (x < 0)
			x += 26;
		while (26 <= x)
			x -= 26;
		return (char)(x + 'a');
	}

	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		br.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

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

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

#define rep(i,n) for(long long i=0;i<(n);i++)
#define INT(n) int n;scanf("%d",&n);
#define LL(n) long long n;scanf("%lld",&n);
#define pint(n) printf("%d",n);
#define pll(n) printf("%lld",n);
#define psp printf(" ");
#define pln puts("");

int main(){
	INT(N);
	if(N>1){
		int a[100000] = {0};
		rep(i,N){
			INT(b);
			a[b]++;
			if(b>0){
				a[b-1]++;
			}
			if(b<N-1){
				a[b+1] ++;
			}
		}
		int max=0;
		rep(i,100000){
			max = (max<a[i])? a[i]:max;
		}
		pint(max)
		pln
	}
	if(N==1){
		INT(a)
		std::cout << 1 << "\n";
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
// #define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

using Int = __int128_t;
using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}


signed main() {

    int d, t, s;

    cin >> d >> t >> s;

    cout << ((double)d/s <= t ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 3644
#coding: Shift_JIS

def set_array(a,n):
	str=input()
	array=str.split()
	for i in range(n):
		a.append(int(array[i]))
	

n=int(input())
S=[]
set_array(S,n)
q=int(input())
T=[]
set_array(T,q)
C=0

def linear_search(S,x):
	S.append(x)
	l=len(S)
	i=0
	while(l>i):
		if S[i]==x:
			break
		i=i+1
	S.pop(-1)
	if i!=l-1:
		return 1;
	else:
		return 0;
for v in T:
	C+=linear_search(S,v)

print(C)


Measured memory_bytes: 6772
#include<bits/stdc++.h>
using namespace std;
const long long INFdesu=2E10;

long long abso(long long a){
    if(a<0) return -a;
    else return a;
}

int main(){
    int N,K;
    long long X[100010];
    cin >> N >> K;
    long long minV=INFdesu;
    int left=0;
    int i;
    for(i=0;i<N;i++) {
        cin >> X[i];
        if (X[i]<0) left=i+1;
    }

    int l,r;
    for(int i=0;i<=N-K;i++){
        l=i;
        r=i+K-1;
        minV=min(minV,abso(X[l])+abso(X[r]-X[l]));
        minV=min(minV,abso(X[r])+abso(X[r]-X[l]));
    }
    
    cout << minV << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (ll ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000
#define N 3000
#define md 1000000007
ll n,k,dp[N][N],i,j,fac[10010000];
void exgcd(ll a,ll b,ll &x,ll &y)
{
	if (b==0) {x=1,y=0;return ;}
	exgcd(b,a%b,x,y);
	ll t=x;
	x=y;
	y=t-(a/b)*y;
}
ll inv(ll a)
{
	ll x=0,y=0;
	exgcd(a,md,x,y);
	x=((x%md)+md)%md;
	return x;
}
ll C(ll n,ll m)
{
	return fac[n]*inv(fac[m])%md*inv(fac[n-m])%md;
}
int main()
{
	scanf("%lld %lld",&n,&k);
	if (k==1) {printf("1\n");return 0;}
	//pr(inv(1));
	fac[0]=1;for (i=1;i<=10000000;i++) fac[i]=(fac[i-1]*i)%md;
	/*for (i=0;i<=10;i++) 
	{
		for (j=0;j<=i;j++)
		printf("%lld ",C(i,j));
		cout<<endl;
	}*/
	dp[0][0]=1;
	for (i=0;i<=n;i++)	
	{
		for (j=i;j<=n;j++)
		{
			if (j==0) continue;
			if (i!=0) dp[i][j]=dp[i-1][j];
			if (i!=j) dp[i][j]=(dp[i][j]+C(j*(k-1)+i-1,k-2)*dp[i][j-1]%md)%md;
			//printf("dp[%d][%d]=%d\n",i,j,dp[i][j]);
		}
	}
	printf("%lld\n",dp[n][n]*fac[n]%md);
}

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

int main() {
  int T,R;
  cin >> T >> R;
  vector<int>data(T);
  for(int i=0;i<T;i++){
    cin >> data.at(i);
  }
  vector<bool>res(T,true);
  for(int i=0;i<R;i++){
    int a,b;
    cin >> a >> b;
    if(data.at(a-1)==data.at(b-1)){
      res.at(a-1)=false;
      res.at(b-1)=false;
    }else if(data.at(a-1)>data.at(b-1)){
      res.at(b-1)=false;
    }else{
      res.at(a-1)=false;
    }
  }
  int ans=0;
  for(int i=0;i<T;i++){
    if(res.at(i)) ans++;
  }
  cout << ans << endl;
}

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

int main()
{
	int n;
	scanf("%d", &n);
	getchar_unlocked();

	bool *d = new bool[10000000];

	while (n--) {
		int c = getchar_unlocked(), e, t = 1;
		while (getchar_unlocked() != ' ')
			;
		while ((e = getchar_unlocked()) != '\n') {
			t <<= 2;
			switch(e) {
			case 'A': t += 0; break;
			case 'C': t += 1; break;
			case 'G': t += 2; break;
			case 'T': t += 3; break;
			}
		}
		switch(c) {
		case 'i': d[t] = true; break;
		case 'f': puts(d[t] ? "yes" : "no");
		}
	}
}


Measured memory_bytes: 4000
import java.lang.Math.max
import java.lang.Math.min

fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val ret = Array(h){IntArray(w)}
    for(i in 0 until h){
        readLine()!!.forEachIndexed { j, c ->
            if(c == '#'){
                ret[i][j] = -100
                for(ii in max(0, i-1)..min(h-1, i+1)){
                    for(jj in max(0, j-1)..min(w-1, j+1)){
                        ret[ii][jj]++
                    }
                }
            }
        }
    }
    ret.forEachIndexed {i, it ->
        it.forEach {
            print(if(it < 0) '#' else it)
        }
        if(i < h-1) println()
    }

}

Measured memory_bytes: 38180
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<n; i++)

int solve(){
  long long a, b, c;  cin >> a >> b >> c;
  if(c-a-b>0 && 4*a*b<(c-a-b)*(c-a-b)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
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; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N, c=0, ans=0, f = 0;
    in >> N;
    vector<ll> H(N);
    in >> H[0];
    REP_AB(i, 1, N){
        in >> H[i];
        if(H[i-1]>=H[i]){
            c++;
            if(c > ans)ans = c;
        }else{
            //f = 1;
            c = 0;
        }
    }
    out << ans << endl;

}

Measured memory_bytes: 1024
while True:
    
    a, b, c = input().split()
    a = int(a)
    c = int(c)

    if b == "+": 
        print(a+c)
    elif b == "-":
        print(a-c)
    elif b == "*":
        print(a*c)
    elif b == "/":
        print(a//c)
    else:
        break



Measured memory_bytes: 5592
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;
int rev(int n){
	s = to_string(n) ;
	reverse(all(s)) ;
	return stoll(s)	;
}

void solve(){
	int k ;
	cin >> k ;
	queue<int> Q ;
	for(int i = 1 ; i <= 9 ; i++){
		Q.emplace(i) ;
	}
	int cnt = 0 ;
	while(!Q.empty()){
		int f = Q.front() ;
		if(++cnt == k) return cout << f << endl , void();
		Q.pop() ;
		if(f%10) Q.push(10*f+(f%10)-1) ;
		Q.push(10*f+(f%10)) ;
		if(f%10 != 9) Q.push(10*f+(f%10)+1) ;
	}
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	int cnt = 0;
	for( int i = 0; i < n-2; ++i ){
		if( s.substr(i, 3) == "ABC" ) ++cnt;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	swap(a, b);
	swap(a, c);
	printf("%d\n%d\n%d\n", a, b, c);

	Please AC;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
typedef long long ll;

int main(){
  ll a,b,k;
  cin >> a >> b >> k;
  if(a>=k)cout << a-k << " " << b << endl;
  else if(a+b>k)cout << "0" << " " << b-(k-a) << endl;
  else cout << "0" << " " << "0" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int K, X;
  scanf("%d %d", &K, &X);
  
  int i;
  for (i=0; i<2*K-1; i++) {
    int candidate = X-K+1+i;
    if (-1000000 <= candidate && candidate <= 1000000
) {
      printf("%d ", candidate);
    }
  }
}



Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const ll mod = 1000000007;
const ll INF = mod * mod;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa;cin>>nyaa;

void solve() {
	int n; cin >> n;
	vector<int> d(n);
	rep(i, n) {
		cin >> d[i];
	}
	int ans = 0;
	rep(i, n) {
		Rep(j, i + 1, n) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();

	//stop
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }
	return 0;
}



Measured memory_bytes: 2100
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N; cin>>N;
  vi A(N); REP(i,N) cin>>A[i];

  set<int> st;
  REP(i,N) st.insert(A[i]);

  string ans = st.size()==N ? "YES" : "NO";
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;

struct Edge{
    int to, id;
    Edge(int to, int id): to(to), id(id){} 
};

vector<Edge> edge[52];
//vector<int> a    :int要素を格納するまっさらな動的配列
//vector<int> a(5) :予め5個のint要素を確保した動的配列
//vector<int> a[5] :まっさらな動的配列を5つ確保している静的配列

bool fds(vector<int>& root, int now, int targ, int parent){
    if (targ == now){
        return true;
    }
    for (auto next : edge[now]){
        if (next.to == parent) continue;
        if (fds(root, next.to, targ, now)){
            root.push_back(next.id);
            return true;
        }
    }
    return false;
}

int main(){
    int n, m;
    cin >> n;
    
    rep(i, n-1){
        int tmpa, tmpb; cin >> tmpa >> tmpb;
        tmpa--; tmpb--;
        edge[tmpa].emplace_back(tmpb, i);
        edge[tmpb].emplace_back(tmpa, i);
    }    

    cin >> m;
    vector<ll> bitmap_range(m);
    rep(i, m){
        int tmpa, tmpb; cin >> tmpa >> tmpb;
        tmpa--; tmpb--;
        vector<int> root;
        fds(root, tmpa, tmpb, -1);
        // cout << i << ":";
        // show(root);
        // cout << endl;
        for(auto hen:root){
            bitmap_range[i] += 1ll << hen;            
        }
    }
    ll ans = 0;
    rep(i, 1<<m){
        ll score;
        ll sum_range = 0;
        rep(j, m){
            if (i>>j&1) sum_range |= bitmap_range[j];
        }
        score = 1ll<<(n-1-__builtin_popcountll(sum_range));
        if (__builtin_popcountll(i)%2 == 0){
            ans += score;
        } else {
            ans -= score;
        }
        //cout << score << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256