akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

#define group first
#define power second

using namespace std;

const int MAX = 33;
const int NONE = -1;

int h, w, s;
int total_demand;
vector<vector<int>> town;
vector<vector<int>> sum;
pair<int, int> memo[MAX][MAX][MAX][MAX]; //<??°???????????°, ?????????>


int calc(int x1, int x2, int y1, int y2) {
	// ??¨?????¢????????????????±???????
	return sum[y2][x2] - sum[y2][x1] - sum[y1][x2] + sum[y1][x1];
}

pair<int, int> update(pair<int, int> a, pair<int, int> b, pair<int, int> res) {
	pair<int, int> tmp = {a.group + b.group, min(a.power, b.power)};
	return max(res, tmp);
}

pair<int, int> dfs(int sx, int ex, int sy, int ey) {
	if(memo[sx][ex][sy][ey].group != NONE) return memo[sx][ex][sy][ey];
	int demand = calc(sx, ex, sy, ey);
	if(total_demand - demand > s) {
		memo[sx][ex][sy][ey] = {0, 0};
		return memo[sx][ex][sy][ey];
	}
	pair<int, int> res = make_pair(1, s - (total_demand - demand));
	for(int x = sx+1; x < ex; ++x) {
		//?????????
		pair<int, int> a = dfs(x, ex, sy, ey), b = dfs(sx, x, sy, ey);
		if(a.group == 0 || b.group == 0) continue;
		res = update(a, b, res);
	}
	
	for(int y = sy+1; y < ey; ++y) {
		//?¨???????
		pair<int, int> a = dfs(sx, ex, sy, y), b = dfs(sx, ex, y, ey);
		if(a.group == 0 || b.group == 0) continue;
		res = update(a, b, res);
	}
	
	memo[sx][ex][sy][ey] = res;
	return res;
}

int main() {
	while(cin >> h >> w >> s, h) {
		town.assign(h, vector<int>(w, 0));
		sum.assign(h+1, vector<int>(w+1, 0));	
		total_demand = 0;
		rep(y, h) {
			rep(x, w) {
				cin >> town[y][x];
				total_demand += town[y][x];
			}
		}
		fill_n((pair<int, int>*)memo, MAX*MAX*MAX*MAX, make_pair(NONE, NONE));

		for(int y = 1; y <= h; ++y) {
			for(int x = 1; x <= w; ++x) {
				sum[y][x] = sum[y][x-1] + sum[y-1][x] - sum[y-1][x-1] + town[y-1][x-1];
			}
		}

		pair<int, int> ans = dfs(0, w, 0, h);
		cout << ans.group << " " << ans.power << endl;
	}

	return 0;
}

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

using namespace std;

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

	int n;
	cin >> n;
	int ans = 0;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; j++) {
			ans = max(ans, abs(a[i] - a[j]));
		}
	}
	cout << ans;
	return 0;
}


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

using namespace std;

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

	int ans = 0;
	for(int i = 0; i < (int)s.size() / 2; i++) {
		ans += s[i] != s[s.size() - 1 - i];
	}
	cout << ans << endl;
}


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

void shuffle(Int ary[],int size)
{
    for(int i=0;i<size;i++)
    {
        int j = rand()%size;
        Int t = ary[i];
        ary[i] = ary[j];
        ary[j] = t;
    }
}

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

    int n; cin>>n; Int p[n]; for (int i = 0; i < n; i++) cin>>p[i]; bool ans1=true,ans2=true;
    shuffle(p,n);

    for (int i = 0; i < n-2; i++){
        Int *key=find(p+i+2,p+n,p[i]^p[i+1]);
        if(key==p+n){
            ans1=false;break;
        }else{
            swap(p[distance(p,key)],p[i+2]);
        }
    }
    if(!(p[n-2]^p[n-1]==p[0]&&p[n-1]^p[0]==p[1]))ans1=false;
    for (int i = n-1; i >=2; i--){
        Int *key=find(p,p+i-1,p[i]^p[i-1]);
        if(key==p+i-1){
            ans2=false;break;
        }else{
            swap(p[distance(p,key)],p[i-2]);
        }
    }
    if(!(p[1]^p[0]==p[n-1]&&p[0]^p[n-1]==p[n-2]))ans2=false;
    std::cout<<((ans1||ans2)?"Yes":"No")<<endl;
}

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

ll func(ll num){
    ll ret = pow(10,13);
    for(ll i=1;i*i<=num;++i){
        if(num%i == 0){
            ret = min(ret,i + num/i-2);
        } 
    }
    return ret;
}

int main() {
    ll N;
    cin >> N;
    cout << func(N) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 350000;
const int K = 19;
int n, q;
int mod =  1e9 + 7;
int s1[N], s2[N], a[N], ans[N], f[N], invf[N];
string t[N], d[N], s;
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int c(int n, int k){
    if (k < 0) return 0;
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
int check (int x){
    for (int i = 1; i <= q; i++){
        if (s[x - 1] == t[i][0]){
            if (d[i] == "L"){
                if (x == 1) return -1;
                x--;
            } else{
                if (x == n) return 1;
                x++;
            }
        }
    }
    return 0;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n >> q;
    cin >> s;
    for (int i = 1; i <= q; i++){
        cin >> t[i];
        cin >> d[i];
    }
    if (check(1) == -1 && check(n) == -1){
        cout << 0;
        return 0;
    }
    if (check(1) == 1 && check(n) == 1){
        cout << 0;
        return 0;
    }
    int ans = 0;
    if (check(1) != 0){
        int l = 1;
        int r = n;
        while(r - l > 1){
            int mid = (r + l) / 2;
            if (check(mid) == -1) l = mid; else r = mid;
        }
        ans += l;
    }
    if (check(n) != 0){
        int r = n;
        int l = 1;
        while(r - l > 1){
            int mid = (r + l) / 2;
            if (check(mid) == 1) r = mid; else l = mid;
        }
        ans += (n - r + 1);
    }
    cout << n - ans;
}


Measured memory_bytes: 25424
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
using Graph = vector<vector<bool>>;

vector<bool> visited;
ll N;

void dfs(Graph &G, ll v) {
  if (visited[v]) return;
  visited[v] = true;
  for (int i = 0; i < N; i++) {
    if (G[v][i]) {
      dfs(G, i);
    }
  }
}

int main() {
  ll M;
  cin >> N >> M;
  Graph node(N, vector<bool>(N, false));
  ll a, b;
  vector<pair<ll, ll>> es;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    a--;
    b--;
    node[a][b] = true;
    node[b][a] = true;
    es.push_back({a, b});
  }
  ll ans = 0;
  for (auto p : es) {
    a = p.first;
    b = p.second;
    node[a][b] = false;
    node[b][a] = false;
    visited.assign(N, false);
    dfs(node, 0);
    bool connected = true;
    for (int i = 0; i < N; i++) {
      if (!visited[i]) {
        connected = false;
      }
    }
    if (!connected) ans++;
    node[a][b] = true;
    node[b][a] = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
typedef pair<pi,int> pii;
#define p(x,y,z) pii(pi(x,y),z)

int taken[21];
int upto;
vector <pii> ans; 
int L;

int32_t main() {
	FAST
	cin >> L;
	
	for (int x = 0;x<21;x++) {
		if ((1 << x) > L) {
			upto = x-1;
			break;
		}
	}

	for (int x = 0;x<upto;x++) {
		ans.push_back(p(x,x+1,(1<<x)));
		ans.push_back(p(x,x+1,0));
	}
	
	int curv = (1 << upto);
	for (int x=0;x<upto;x++) {
		if ((1<< x) & L) {
			ans.push_back(p(x,upto,curv));
			curv += (1 << x);
		}
	}
	
	cout << upto+1 << " " << ans.size() << "\n";
	for (auto cur: ans) {
		cout << cur.f.f+1 << " " << cur.f.s+1 << " " << cur.s << "\n";
	}
	
	
	
}








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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

ll A, B;

vi get(ll x)
{
	vi res;
	while (x > 0) {
		res.pb(x & 1);
		x /= 2;
	}
	return res;
}

vector<pair<ll, ll>> cand;

int main() {
	cin >> A >> B;

	if (A == B) {
		puts("1");
		return 0;
	}

	vi va = get(A);
	vi vb = get(B);

	while (va.size() < vb.size()) {
		va.pb(0);
	}

	ll com = 0;
	int lp = -1;

	int sz = va.size();
	for (int i = sz - 1; i >= 0; --i) {
		if (va[i] != vb[i]) {
			lp = i;
			break;
		}
		com += ((ll)va[i] << i);
	}

	sz = lp + 1;

	cand.eb(A - com, (1LL << lp) - 1);
	cand.eb(A - com + (1LL << lp), (1LL << (lp + 1)) - 1);

	int pz = -1;
	for (int i = sz - 2; i >= 0; --i) {
		if (vb[i]) {
			pz = i;
			break;
		}
	}

	ll lo = (1LL << lp);
	ll hi = (1LL << lp);

	if (pz != -1) {
		hi += (1LL << (pz + 1)) - 1;
	}

	cand.eb(lo, hi);

	sort(ALL(cand));
	ll ret = 0;
	ll la = -1, hd = -1;

	rep(i, cand.size()) {
		if (la == -1) {
			hd = cand[i].fi, la = cand[i].se;
		} else {
			if (la >= cand[i].fi) {
				la = max(cand[i].se, la);
			} else {
				ret += la - hd + 1;
				hd = cand[i].fi, la = cand[i].se;
			}
		}
	}

	ret += la - hd + 1;
	cout << ret << endl;

	return 0;
}

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

int L, R;
int a[2019];

int main () {
  cin >> L >> R;

  for(int i = L; i <= min(R, L+2018); i++) {
    a[i%2019] = 1;
  }

  int ans = 2018;
  for(int i = 0; i < 2019; i++) {
    if(!a[i]) continue;

    for(int j = i + 1; j < 2019; j++) {
      if(!a[j]) continue;

      ans = min(ans, (i*j) % 2019);
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;


int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int f = min(n, k);
    int s = n - f;
    cout << x * f + y * s;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i))
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i))
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  cin>>s; n=s.size(); if(n&1)reverse(ALL(s));
  pri(s);
}


Measured memory_bytes: 3632
fun main(args: Array<String>) {
    abc148d()
}

private const val MAX = Long.MAX_VALUE / 3

fun abc148d() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }.toLongArray()

    var answer = MAX

    val indexOfFirst1 = aList.indexOfFirst { it == 1L }

    if (indexOfFirst1 == -1) return println(-1)

    var curr = 0L
    var value = 2L
    for (j in indexOfFirst1..aList.lastIndex) {
        if (aList[j] == value) {
            curr++
            value++
        }
    }

    answer = Math.min(answer, n - curr - 1)

    if (answer == MAX) answer = -1

    println(answer)
}


Measured memory_bytes: 83068
#include<cstdio>
#include<cmath>
#define ll long long
ll gcd(ll a,ll b)
{
	if(!b)return a;
	return gcd(b,a%b);
}
ll a,b,k,ans,x;
int main()
{
	scanf("%lld%lld",&a,&b);
	if(a<b)k=a,a=b,b=k;
	ll g=gcd(a,b);
	if(g%2==0)ans++;
	while(g%2==0)g/=2;
	x=sqrt(g);
	for(int i=3;i<=x;i+=2)
		if(g%i==0)
		{
			ans++;
			while(g%i==0)g/=i;
			x=sqrt(g);
		}
	if(g>1)ans++;
	printf("%lld",ans+1);
}

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

using namespace std;

int main() {
    size_t n, r;
    cin >> n >> r;
    if (n >= 10)
        cout << r << endl;
    else
        cout << r + 100 * (10 - n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

int f(int x, int y) {
    if (x % y == 0)
        return x / y;
    else
        return x / y + 1;
}

signed main() {
    int n;
    cin >> n;
    int t, a, pt, pa;
    int x = 1, y = 1;
    int ans;
    while (n--) {
        cin >> t >> a;
        int m = max(f(x, t), f(y, a));
        x = m * t;
        y = m * a;
        ans = x + y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 15;
const int mod = 1000000007;

int a[maxn][maxn];
int c[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m, X;
  cin>>n>>m>>X;
  int ret = -1;
  for(int i=0;i<n;i++){
    cin>>c[i];
    for(int j=0;j<m;j++)cin>>a[i][j];
  }
  for(int i=1;i<(1<<n);i++){
    vector<int>tt=vector<int>(m, 0);
    int ans = 0;
    for(int j=0;j<n;j++){
      if(i&(1<<j)){
        ans +=c[j];
        for(int k=0;k<m;k++)tt[k]+=a[j][k];
      }
    }
    bool sign = 0;
    for(int j=0;j<m;j++)if(tt[j]<X){
      sign=1;
        break;
    }
    if(!sign){
      if(ret==-1||ret>ans)ret=ans;
    }
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()

def main():
    N=ii()

    k = N
    ans = []
    a_ord = ord('a')

    def mod(n):
        return n%26 if n % 26 > 0 else 26


    while k > 0:
        # print(k%26)
        ans.append(chr(a_ord+mod(k)-1))
        if k % 26 > 0:
            k //= 26
        else:
            k -= 1
            k //= 26

    # if N % 26 == 0:
    #     print("".join(ans[::-2]))
    # else:
    print("".join(ans[::-1]))


if __name__ == "__main__":
  main()

Measured memory_bytes: 61964
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li      int64_t
#define ld      double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define repir(i,v)  for(i=v.rbegin();i!=v.rend();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl          cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define rtr reverse_iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

li n,a[205];

void solve(){
  li i;cin>>n;
  rep(i,0,2*n) cin>>a[i];
  sort(a,a+2*n);
  li ans=0;
  for(i=0;i<2*n;i+=2){
    ans+=min(a[i],a[i+1]);
  }
  cout<<ans;
}

int main(){
  opt
  #ifndef ONLINE_JUDGE
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  #endif
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
	int n;
	cin >> n;
	vector<string> A, B;
	REP(i, n) {
		string c;
		cin >> c;
		string d = c;
		REP(i, c.length()) {
			if (c[i] == '?') {
				c[i] = 'a';
				d[i] = 'z';
			}
		}
		A.push_back(c);
		B.push_back(d);
	}
	string c;
	cin >> c;
	A.push_back(c);
	B.push_back(c);
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	int bot = 0, top = 0;
	for (int i = 0; i < A.size(); ++i) {
		if (B[i] == c) {
			bot = i;
			break;
		}
	}
	for (int i = B.size() - 1; i >= 0; --i) {
		if (A[i] == c) {
			top = i;
			break;
		}
	}
	for (int i = bot; i <= top; ++i) {
		if (i != bot) cout << " ";
		cout << i + 1;
	}
	cout << endl;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 2100;
int n;
string s;
vi e[maxn];

struct TRes {
    int s0, sd, mm;

    TRes mv() const {
        TRes r = *this;
        r.sd += r.s0;
        return r;
    }

    TRes operator+(TRes r) {
        TRes res = {s0 + r.s0, sd + r.sd, mm + r.mm};
        int S = min(sd, r.sd);
        res.mm = S + min((sd - S) / 2, mm) + min((r.sd - S) / 2, r.mm);
        if (S) uax(res.mm, S - 1 + min((sd - S + 1) / 2, mm) + min((r.sd - S + 1) / 2, r.mm));
        return res;
    }
};

pii mv(pii p) {
    return {p.fi, p.fi + p.se};
}

pii operator+(pii a, pii b) {
    return {a.fi + b.fi, a.se + b.se};
}

TRes dfs(int v, int p) {
    TRes res = {s[v] - '0', 0, 0};
    for (int u: e[v]) {
        if (u == p) continue;
        res = res + dfs(u, v).mv();
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    cin >> n >> s;
    forn(i, n - 1) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        e[u].pb(v);
        e[v].pb(u);
    }

    i64 ans = 1e18;
    forn(v, n) {
        vector<TRes> ds;
        for (int u: e[v]) ds.pb(dfs(u, v).mv());
        sort(all(ds), [](TRes a, TRes b){return a.sd > b.sd;});
        i64 T = 0;
        for (auto w: ds) T += w.sd;
        if (T % 2) continue;
        if (ds[0].sd - 2 * ds[0].mm > T - ds[0].sd) continue;
//        if (ds[0].sd > T / 2) continue;
        uin(ans, T / 2);
//        cerr << v << ' ' << T / 2 << ' ' << ds[0].sd << ' ' << ds[0].mm << '\n';
    }
    if (ans > 1e17) ans = -1;
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

int main(){
    ll n;
    cin >> n;
    ll i = 1;
    int skip = -1;
    while(1){
        if(i*(i+1) / 2 > n){
            skip = i*(i+1) / 2 - n;
            //printf("skip = %d\n", skip);
            break;
        } else if(i*(i+1) / 2 == n){
            break;
        }
        i++;
    }
    for(int j = 1; j <= i; j++){
        if(j == skip) continue;
        cout << j << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
a,b = gets.chomp.split(" ").map(&:to_i)
postal = gets.chomp.split('-')
result = false
# print("a: #{a}, b: #{b}, postal:#{postal}")

if postal.size == 2 && !postal.empty?
  first = postal[0].length
  second = postal[1].length
  result = (first == a) && (second == b)
end


print("#{result ? "Yes" : "No"}")

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int k,n,m;
char a[1001];
int main()
{gets(a);
 for(int i=0;i<=strlen(a);i++)
 {
  if(a[i]=='C'&&m==0){k++;m=1;}
  else if(a[i]=='F'&&m==1) n++;
  }
  if(k>0&&n>0) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 200000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N, T;
int t[MAX_N];

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> T;
  REP(i, N) cin >> t[i];

  sort(t, t + N);

  ll ans = 0;
  int start = inf, end = inf;
  for (int i = 0; i < N; i++) {
    ans += T;
    if (end != inf && end > t[i]) {
      ans -= end - t[i];
    }
    end = t[i] + T;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String s = sc.next();
    
    if(a >= 3200){
      System.out.println(s);
    }else{
      System.out.println("red");
    }
  }
}

Measured memory_bytes: 21844
import java.util.*;
import java.util.stream.IntStream;

class Dice {
	int[] surfaces = new int[6];

	Dice(int[] diceNumArr) {surfaces = diceNumArr;}

	public int getTopNumber() {return surfaces[0];}

	public void move(String str) {
		for (char d : str.toCharArray()) {
			if (d == 'E') {roll(true, false, false);}
			else if (d == 'W') {IntStream.range(0, 3).forEach(e -> roll(true, false, false));}
			else if (d == 'S') {IntStream.range(0, 3).forEach(e -> roll(false, true, false));}
			else if (d == 'N') {roll(false, true, false);}
		}
	}

	private void roll(boolean x, boolean y, boolean z) {
		if (x && !y && !z) {roll(0, 3, 5, 2);}
		else if (!x && y && !z) {roll(0, 1, 5, 4);}
		else if (!x && !y && z) {roll(1, 2, 4, 3);}
	}

	private void roll(int w, int x, int y, int z) {
			int tmp = surfaces[w];
			surfaces[w] = surfaces[x];
			surfaces[x] = surfaces[y];
			surfaces[y] = surfaces[z];
			surfaces[z] = tmp;
	}

	public void setTopAndFront(int top, int front) {
		isSame(top, front, -1);
	}

	private boolean isSame(int... srf) {
		for (int xy = 0; xy < 6; xy++) {
			for (int z = 0; z < 4; z++) {
				if (surfaces[0] == srf[0] && surfaces[1] == srf[1] && srf[2] < 0) return false;
				int[] a = Arrays.copyOfRange(surfaces, 2, surfaces.length);
				int[] b = Arrays.copyOfRange(srf, 2, srf.length);
				if (Arrays.equals(a, b)) return true;
				roll(false, false, true);
			}
			if (xy % 2 == 0) {roll(true, false, false);}
			else {roll(false, true, false);}
		}
		return false;
	}

	@Override
	public boolean equals(Object obj) {
		Dice other = (Dice) obj;
		return isSame(other.surfaces);
	}
}

public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int[] diceNumArr = { sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt() };
			Dice dice = new Dice(diceNumArr);
			int cnt = sc.nextInt();

			for (int i = 0; i< cnt; i++ ) {
				dice.setTopAndFront(sc.nextInt(), sc.nextInt());
				System.out.println(dice.surfaces[2]);
			}
		}
	}
}


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




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


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,j,flag=0;
  cin>>n;
  vector<int> a(n);
  stack<int> b;
  for(i=0;i<n;i++) cin>>a[i];
  
  while(!a.empty())
  {
    flag=0;
   for(j=a.size()-1;j>=0;j--)
   {
     if(a[j]==j+1)  
     {
       flag=1;
       b.push(a[j]);
       a.erase(a.begin()+j);
       break;
     }
     
   }
    if(flag==0) 
    {
      cout<<-1;return 0;
    }
  }
  
while(!b.empty())
{
    cout<<b.top()<<endl;
    b.pop();
}
  return 0;
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;

template<class T> bool uin(T &a, T b){ return (a > b ? a = b, true : false); }
template<class T> bool uax(T &a, T b){ return (a < b ? a = b, true : false); }

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

int const MAXN = 141;

int n, a[MAXN], b[MAXN], c[MAXN], d[MAXN];

vi e[MAXN];
int lp[MAXN], u[MAXN];
bool f[MAXN];

bool dfs(int x) {
	u[x] = 1;
	for(int y : e[x]) {
		if (lp[y] == -1 || (!u[lp[y]] && dfs(lp[y]))) {
			lp[y] = x;
			return true;
		}
	}
	return false;
}

void solve() {
	fi(1, n) {
		fj(1, n) {
			if (a[i] < c[j] && b[i] < d[j]) {
				e[i].pb(j);
			}
		}
	}	
	memset(lp, 255, sizeof(lp));
	fi(1, n) {
		memset(u, 0, sizeof(u));
		dfs(i);
	}
	fi(1, n) {
		if (lp[i] != -1) {
			f[lp[i]] = 1;
		}
	}
	int ans = 0;
	fi(1, n) {
		ans += f[i];
	}
	printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d", &n);
	fi(1, n) {
		scanf("%d %d", &a[i], &b[i]);
	}
	fi(1, n) {
		scanf("%d %d", &c[i], &d[i]);
	}
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;

/**
 * Created on 2016/08/13.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        for(int i=0; i<N; i++){
            int tmp = sc.nextInt();
            if(map.containsKey(tmp)){
                int val = map.get(tmp);
                val++;
                map.put(tmp, val);
            }else{
                map.put(tmp, 1);
            }
        }

        Set<Integer> keys = map.keySet();

        int tmpCost = Integer.MAX_VALUE;
        int ans = -1;

        for(int key=-101; key<101; key++){
            int cost = 0;
            for(int key2: keys){
                int cnt = map.get(key2);
                cost += ((key - key2) * (key - key2)) * cnt;
            }
            if(cost < tmpCost){
                tmpCost = cost;
                ans = key;
            }
        }

        System.out.println(tmpCost);
    }
}


Measured memory_bytes: 9940
#include <iostream>
#include <cstdlib>
//n個の数値の入力に対して,素数の数を出力する問題
using namespace std;
bool isPrime(int x);

int main(){
	int n, num, ans = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> num;
		if(isPrime(num)) ans++;
	}
	cout << ans << endl;
	return EXIT_SUCCESS; 
}

//素数判定
//合成数xはx <= √pを満たす素因子pを持つ
bool isPrime(int x){
	if(x == 2) return true;
	if(x < 2 || x % 2 == 0) return false;
	int i = 3;
	while(i * i <= x){
		if(x % i == 0) return false;
		i += 2;
	}
	return true;
}




Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
std::vector<int> a(3);
int even=0 , ans=0 ;
int main(){
  for (size_t i = 0; i < 3; i++) {
    cin >> a[i];
    if(a[i]%2==0)even++;
  }

  if(even == 1){ //偶数の数字が一番少ないとき、偶数に揃える
    for (size_t i = 0; i < 3; i++) {
      if(a[i]%2 == 1){
        a[i]++;
      }
    }
    ans++;
  }

  if(even == 2){ //奇数の数字が一番少ないとき、奇数に揃える
    for (size_t i = 0; i < 3; i++) {
      if(a[i]%2 == 0){
        a[i]++;
      }
    }
    ans++;
  }
  sort(a.begin(),a.end());
  for (size_t i = 0; i < 2; i++) {
    ans += (a[2]-a[i])/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int x1,x2,x3,x4,x5;
      cin >> x1 >> x2 >> x3 >> x4 >>x5;
     
      if (x1 < 1) {
        cout << 1 << endl;
      }
      else if (x2 < 1) {
        cout << 2 << endl;
      }
      else if (x3 < 1) {
        cout << 3 << endl;
      }
      else if (x4 < 1) {
        cout << 4 << endl;
      }
      else {
        cout << 5 << endl;
      }
    }


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  ll ans = 0;
  long double up = (-1.0 + sqrt(1.0 + 4.0*N))/2.0;
  for(ll i=1;i<up;i++){
    if(N%i==0){
      if(N/i-1>i)ans += N/i-1;
    }
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        int min=Integer.MAX_VALUE;
        for(int i=0;i+2<s.length();i++){
            min=Math.min(min,Math.abs(753-Integer.parseInt(s.substring(i,i+3))));
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 21716
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: August 27 2019
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(i,x) for(auto i=0 ; i<(x); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;

auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 
    ivv(n);
    cout<<3 * n * n<<'\n';
    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
a=list(map(int,input().split()))
def idou(a,b):
    if a<=0<=b:
        return 2*min(abs(a),abs(b))+max(abs(a),abs(b))
    else:
        return max(abs(a),abs(b))

print(min([idou(a[i],a[i+K-1]) for i in range(N-K+1)]))

Measured memory_bytes: 14224
n=int(input())
A=list(map(int,input().split()))
q=int(input())
M=list(map(int,input().split()))
dp = [[None for i in range(2001)] for i in range(21)]

def solve(i,m):
  if dp[i][m] != None:
    return dp[i][m]
  if m == 0:
    dp[i][m] == True
    return True
  elif i >= n:
    dp[i][m] == False
    return False
  dp[i][m] = solve(i+1,m) or solve(i+1,m-A[i])   
  return dp[i][m]

for m in M:
  if solve(0,m):
    print("yes")
  else:
    print("no")


Measured memory_bytes: 5976
N=int(input())
A=[int(i) for i in input().split()]
m2=0
m1=0
m0=0
for a in A:
  if a%4==0:
    m2+=1
  elif a%2==0:
    m1+=1
  else:
    m0+=1
if m1==0:
  if m2-m0>=-1:
    print("Yes")
  else:
    print("No")
if m1!=0:
  if m2-m0>=0:
    print("Yes")
  else:
    print("No")


Measured memory_bytes: 63216
//
// Created on 2020/04/04.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {

    int cnt = 9;
    int k;
    cin>>k;

    if(k<=9){
        cout<<k<<endl;
        return 0;
    }

    queue<string>q;

    for (int l = 1; l <= 9; ++l) {
        q.push(to_string(l));
    }

    string temp;

    while(!(q.empty())) {


        temp = q.front();
        q.pop();

        for (int i = max((temp[temp.size()-1] - '0') - 1, 0); i <= min((temp[temp.size()-1] - '0') + 1, 9); ++i) {
            string temp2 =  temp + to_string(i);

            cnt++;

            if (cnt == k) {

                cout << temp2 << endl;
                return 0;
            }
            q.push(temp2);

        }
    }



}


Measured memory_bytes: 3840
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
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 (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int r; cin >> r;
    double ans = r*2*3.14159;
    ct(ans);
}



Measured memory_bytes: 3788
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	char alpha;
	cin >> alpha;
	if(0x41<=alpha and alpha<=0x5a){
		cout << 'A';
	}else{
		cout << 'a';
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3620
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;




int main(void) {

    int X,Y; cin>>X>>Y;
    ll ans=0;
    if(X==1){
        ans = 300000;
    }else if(X==2){
        ans = 200000;
    }else if(X==3){
        ans = 100000;
    }
    if(Y==1){
        ans += 300000;
    }else if(Y==2){
        ans += 200000;
    }else if(Y==3){
        ans += 100000;
    }
    if(X==1 && Y==1){
        ans += 400000;
    }
    cout<<ans<<endl;


    return 0;
}


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

using namespace std;

int main()
{
  int a,b,c;
  int count=0;
  int i;
  cin >> a >> b >> c;
  for(i=a;i<=b;i++){
  	if(i%c==0){
    	count++;
    }
  
  
  }
cout << count << endl;
  
  
  
  
  
  
  
  
  

}

Measured memory_bytes: 3628
void main() {
    long m = readln.chomp.to!long;

    long x, y;
    foreach (i; 0 .. m) {
        long[] tmp = readln.split.to!(long[]);
        long d = tmp[0], c = tmp[1];
        x += c, y += d * c;
    }

    writeln(x - 1 + (y - 1) / 9);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int ans = 0;
		for(int i = 0; i < 3; i++) {
			if(s.charAt(i) == t.charAt(i))
				ans++;
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main(){
	int n,maxv,enu,sii;
	long num = 1;
	int minv;
    double memo;
	maxv = -100;
	minv = 1000000000;
	memo = 1000000000.0;
	cin >> n;
	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (maxv < a[i]) maxv = a[i];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] == maxv) continue;

		if ( ((double)maxv / 2.0 - a[i]) < 0) {
			if ((((double)maxv / 2.0 - a[i])* -1) < memo) {
				minv = a[i];
				memo = (((double)maxv / 2.0 - a[i])* -1);
			}
		}
		else{
			if ( ((double)maxv / 2.0 - a[i]) < memo) {
				minv = a[i];
				memo = ((double)maxv / 2.0 - a[i]);
			}

		}
	}

	cout << maxv << " " << minv << endl;

	return 0;
}


Measured memory_bytes: 3712
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define MODk 998244353
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
ll gcd(ll a,ll b);
ll lcm(ll a,ll b);
ll modularExponentiation(ll x,ll n,ll M);
void dsp(vector<ll> &V);
void dsp2(vector<pair<ll,ll>>&V);
void dsp3(map<ll,ll>&M);
double fact(double n);
ll nPr(ll n,ll r);
ll nCr(ll n,ll r);
ll mx;
bool isPalindrome(string k) 
{ 
    // Start from leftmost and rightmost corners of str 
    ll l = 0; 
    ll h = sz(k) - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (k[l++] != k[h--]) 
        { 
            return false; 
        } 
    } 
    return true; 
} 
void solve()
{
   ll k,n,i;cin>>k>>n;
   vi V(n,0);
   vi D(n,0);
   fo(i,0,n)cin>>V[i];
   
   fo(i,1,n)
   D[i]=V[i]-V[i-1];
   D[0]=V[0]+k-V[n-1];
   
   sort(all(D));
   cout<<k-D[sz(D)-1]<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
ll gcd(ll a,ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
          
} 
ll lcm(ll a,ll b)  
{  
    return (a*b)/gcd(a, b);  
}  
ll modularExponentiation(ll x,ll n,ll M)
{   
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
        result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
        return result;
}
void dsp(vector<ll> &V)
{
    ull j;
    for(j=0;j<V.size();j++)
    {
        cout<<V[j]<<" ";
    }
    cout<<endl;
}
void dsp2(vector<pair<ll,ll>>&V)
{
    ull j;
    for(j=0;j<V.size();j++)
    {
        cout<<V[j].first<<" "<<V[j].second<<" ";
    }
    cout<<endl;
}
void dsp3(map<ll,ll>&M)
{
      map<ll,ll>::iterator it=M.begin();
      while(it!=M.end())
      {
        cout<<it->first<<" "<<it->second<<endl;
        it++;
      }
}
double fact(double n)
{
    double i=1;
    double res=1;
    
    if(n==0)
        return 1.00;
    
    while(i<=n)
    {
        res*=i;
        i++;
    }
    
    return res;
}
ll nPr(ll n,ll r)
{
    return (fact(n)/fact(n-r));
}
ll nCr(ll n,ll r)
{
    return (fact(n)/(fact(r)*fact(n-r)));
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>

Measured memory_bytes: 3328