akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int N, P, Q;
    auto C = new bool[99 * 60 + 59];
    auto D = new bool[99 * 60 + 59];
    bool input() {
        string p, q;
        readf("%d %s %s\n", &N, &p, &q);
        if (N == 0 && p == "0" && q == "0") return false;
        P = p[0 .. 2].to!int * 60 + p[2 .. 4].to!int;
        Q = q[0 .. 2].to!int * 60 + q[2 .. 4].to!int;
        C[P .. Q] = false;
        foreach (i; 0 .. N) {
            int K; scanf("%d\n", &K);
            auto pq = readln.chomp.split(" ").array;
            int s, t;
            D[] = true;
            for (int j = 0; j < K * 2; j += 2) {
                s = pq[j][0 .. 2].to!int * 60 + pq[j][2 .. 4].to!int;
                t = pq[j + 1][0 .. 2].to!int * 60 + pq[j + 1][2 .. 4].to!int;
                D[s .. t] = false;
            }
            foreach (j; P .. Q) {
                if (D[j]) {
                    C[j] = true;
                }
            }
        }
        return true;
    }

    void solve() {
        writeln( reduce!((a, xs) => max(a, xs.length))(
                0L,
                C[P .. Q].map!((a) => cast(char)(a.to!int + '0')).split("0")));
    }
    
    while (input) solve;
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
#include <algorithm>
#define PII pair<ll, ll>
#define F first
#define S second

using namespace std;
typedef long long ll;


ll n, n2, m;
ll ans;
ll a[100005];
PII b[100005];

int main()
{
    scanf("%lld%lld", &n, &m);
    n2 = n;
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    for(ll i = 0; i < m; i++)
    {
        scanf("%lld%lld", &b[i].S, &b[i].F);
    }
    sort(a, a + n);
    sort(b, b + m, greater<PII>());
    a[n] = 2e9;
    for(ll i = 0, j = 0; i < m; i++)
    {
        while(b[i].S--)
        {
            if(b[i].F > a[j]) a[j] = b[i].F;
            else
            {
                i = m;
                break;
            }
            j++;
        }
    }
    for(int i = 0; i < n; i++)
    {
        ans += a[i];
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 2688
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
#define rpd(i,s,e,d) for(int i=(s);i<(int)(e);i+=(d))

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

	int mx = 1000000;
	vector<int> D(mx+1, 0);
	rpd(i, 2, mx+1, 1)
		if(!D[i]) rpd(j, i, mx+1, i) D[j] = i;

	int N; cin>>N;
	int g = 0;
	bool not_pairwise = false;
	map<int, bool> past;
	rpd(i, 0, N, 1){
		int a; cin>>a;
		g = gcd(g, a);
		if(not_pairwise) continue;
		map<int, bool> now;
		while(a != 1){
			// 素数 D[a]: 今回は未済 & 過去は済
			if(( not_pairwise = !now[D[a]] && past[D[a]] )) break;
			now[D[a]] = past[D[a]] = true;
			a /= D[a];
		}
	}
	int t = not_pairwise + (g > 1);
	cout<< vector<string>{"pairwise","setwise","not"}[t] <<" coprime\n";
}


Measured memory_bytes: 10828
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int A, B;
	cin >> A >> B;
	for (int i = 1; i <= 3; ++i) {
		int res = A * B * i;
		if (res & 1) {
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	ll x, y; cin >> x >> y;
	if (abs(x - y) <= 1)printf("Brown");
	else printf("Alice");
	return 0;
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,m;
	cin >> n >> m;
	string s="";
	for(int i=0; i<n; i++)s+='.';
	bool ok=1;
	int p; char x;
	for(int i=0; i<m; i++){
		cin >> p >> x;
		p--;
		if(!ok)continue;
		if(s[p]=='.')s[p]=x;
		else if(s[p]!=x){
			ok=0;
		}
	}
	if(s[0]=='0'&&n>1)ok=0;
	if(ok){
		if(s[0]=='.')s[0]=(n==1?'0':'1');
		for(int i=1; i<n; i++){
			if(s[i]=='.')s[i]='0';
		}
		cout << s << '\n';
	}else cout << -1 << '\n';
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
bool is_in(const string& s, const string& t) {
    ll pos = 0;
    each(c, s) {
        if (pos >= t.size()) return true;
        if (c == t[pos]) ++pos;
    }
    if (pos >= t.size()) return true;
    return false;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s1, s2; cin >> s1 >> s2;
    string s[2] = {s1, s2};
    const ll n1 = s1.size(), n2 = s2.size();
    string odd = "", even = "";
    rep(i, n1) {
        if (i % 2) odd += s1[i];
        else even += s1[i];
    }
    if ((is_in(s1, odd) && is_in(s2, even)) || (is_in(s2, odd) && is_in(s1, even))) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

int n, lst[26], bc[200000];
pair<int, int> sg[800001], an[26];
char s[200001];

pair<int, int> operator +(pair<int, int> a, pair<int, int> b){
	if (a.first != b.first)return min(a, b);
	if (s[a.second] < s[b.second])return a;
	return b;
}

pair<int, int> toad;
void ad(int i, int l = 0, int r = n + 1, int id = 1){
	if (l + 1 == r) { sg[id] = toad; return; }
	int m = l + r >> 1, a = id << 1, b = a | 1;
	if (i < m)ad(i, l, m, a);
	else ad(i, m, r, b);
	sg[id] = sg[a] + sg[b];
}

pair<int, int> gt(int x, int y, int l = 0, int r = n + 1, int id = 1){
	if (x >= r || y <= l)return make_pair(1e9, 0);
	if (l >= x && r <= y)return sg[id];
	int m = l + r >> 1, a = id << 1, b = a | 1;
	return gt(x, y, l, m, a) + gt(x, y, m, r, b);
}

int main(){
	scanf("%s", s);
	n = strlen(s);
	f(i, 0, 26)lst[i] = n;
	toad = make_pair(0, n);
	ad(n);
	for (int i = n - 1; i >= 0; --i){
		pair<int, int> z = gt(i + 1, lst[s[i] - 'a'] + 1);
		bc[i] = z.second;
		toad = make_pair(z.first + 1, i);
		ad(i);
		lst[s[i] - 'a'] = i;
	}
	f(i, 0, 26){
		pair<int, int> z = gt(0, lst[i] + 1);
		an[i] = make_pair(z.first + 1, z.second);
	}
	pair<int, int> a(1e9, 0);
	f(i, 0, 26)if (an[i].first < a.first)a = make_pair(an[i].first, i);
	printf("%c", a.second + 'a');
	int i = an[a.second].second;
	while (i < n){
		printf("%c", s[i]);
		i = bc[i];
	}
	printf("\n");
}

Measured memory_bytes: 7168
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
void solve(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> grid(h, vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>grid[i][j];
        }
    }
    vector<vector<int>> dp(h, vector<int>(w, 1e9));
    dp[0][0]=(grid[0][0]=='#');
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i>0){
                dp[i][j]=min(dp[i][j], dp[i-1][j] + (grid[i-1][j]=='.' && grid[i][j]=='#'));
            }
            if(j>0){
                dp[i][j]=min(dp[i][j], dp[i][j-1] + (grid[i][j-1]=='.' && grid[i][j]=='#'));
            }
        }
    }
    cout<<dp[h-1][w-1]<<"\n";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>
#include <queue>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n,m;
    cin >> n >>m;
    vector<vector<int>> vec(n+1);
    for(int i = 0;i<m;i++){
        int x,y;
        cin >> x>> y;
        vec[x].push_back(y);
        vec[y].push_back(x);
    }
    vector<int> ans(n+1,0);
    vector<bool> visited(n+1, false);
    queue<int> q;
    q.push(1);
    visited[1] = true;
    
  
    while(q.size() != 0){
        int top = q.front();
        q.pop();
        for(int i = 0;i<vec[top].size();i++){
            if(visited[vec[top][i]] == false){
            q.push(vec[top][i]);
            visited[vec[top][i]] = true;
            ans[vec[top][i]] = top;
            }
        }
        
    }
    int min = *min_element(ans.begin()+2,ans.end());
    if(min == 0)
    cout << "No";
    else{
    cout << "Yes" << '\n';
    for(int i = 2;i<ans.size();i++){
        cout << ans[i] << '\n';
    }
    }
}









Measured memory_bytes: 10252
#include<cstdio>
#include<string>
#include<iostream>
#include<cmath>
#define MAXN 15
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	string c=a+b;
	int num=0;
	for(int i=0;i<c.size();i++)
		num=num*10+c[i]-'0';
	int l=floor(sqrt(num));
	int r=ceil(sqrt(num));
	if(r*r==num||l*l==num)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	int a,b,c; cin>>a>>b>>c;
	if(a>b)swap(a,b);
	if(a<c && c<b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B,C,D;
    cin >>A>>B>>C>>D;
    
    cout << max(A*B,C*D) << endl;


    return 0;
    

}

Measured memory_bytes: 3580
/// @file
/// @copyright 2018 thousand
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::min;

namespace {
int N, A, B;
}  // namespace

int main() {
  cin >> N >> A >> B;
  cout << min(A * N, B) << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
  public static void main(String[] args) {
 
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
 
    if (k%2 == 0) {
      System.out.println((k/2) * (k/2));
    } else {
      System.out.println((k/2+1) * (k/2));
    }
 
  }
}

Measured memory_bytes: 21844
# https://abc100.contest.atcoder.jp/tasks/abc100_c


def even_count(v):
    if v % 2 != 0:
        return 0
    else:
        r = 0
        while v % (2 ** 20) == 0:
            r += 20
            v //= (2 ** 20)

        while v % (2 ** 10) == 0:
            r += 10
            v //= (2 ** 10)

        while v % 2 == 0:
            r += 1
            v //= 2

    return r


N = int(input())

a = list(map(int, input().split()))

count = 0

for i in a:
    count += even_count(i)

print(count)


Measured memory_bytes: 4148
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  cout << s[0] << s.length() - 2 << s[s.length()-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
string s, t;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s >> t;

  ll ans = LLINF;
  REP(i, s.length() - t.length() + 1) {
    ll sum = 0;
    REP(j, t.length()) if(t[j] != s[i + j]) sum++;
    ans = min(ans, sum);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n, k; cin >> n >> k;
    map<ll, ll> s;
    rep(i, n) {
        ll a; cin >> a;
        s[a]++;
    }
    vector<pair<ll, ll>> v;
    for(auto x : s) v.push_back(make_pair(x.second, x.first));
    sort(all(v));
    ll ans = 0;
    ll a = s.size() - k;
    if(a < 0) a = 0;
    rep(i, a) ans += v[i].first;
    cout << ans << endl;
}

Measured memory_bytes: 19876
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
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);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    int n,m,k;cin >> n >> m >> k;
    rep(i, n+1) {
        rep(j, m+1) {
            if((n-i)*j+(m-j)*i==k) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3680
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bug() cout << "BUG" << endl ;
#define X first
#define Y second
#define per(how) cout << fixed << setprecision(how)
#define bit(a , b) (a >> b) & 1
#define all(v) v.begin() , v.end()
#define LB(x) (x & -x)
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 , MOD = 1e9 + 7 , SQRT = 350 ;
inline void smin(ll &x , ll y) { x = min(x , y) ; }
inline void smax(ll &x , ll y) { x = max(x , y) ; }




int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	ll n , k ;
	cin >> n >> k ; 
	ll a ;
	cin >> a;
	ll G = a;
	ll mx = a;
	n--;
	while(n--)
	{
		cin >> a;
		G = __gcd(a , G);
		smax(mx , a);
	}
	if(k <= mx && k % G == 0)	cout << "POSSIBLE";
	else	cout << "IMPOSSIBLE";
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
count = 0
check = 0

while check == 0:
    for i in range(N):
        if A[i]%2 == 1:
            check += 1
            break
        else:
            A[i] = A[i]/2
    count += 1


print(count-1)


Measured memory_bytes: 3060
#include <stdio.h>

int main(int argc, const char * argv[]) {
    char ch;
    int sum[26];
    for(int i=0; i<26; i++){
        sum[i] = 0;
    }
    while(scanf("%c", &ch) != EOF){
        if('a'<=ch && ch<='z'){
            sum[ch-'a']++;
        } else if('A'<=ch && ch<='Z'){
            sum[ch-'A']++;
        }
    }
    for(int i=0; i<26; i++){
        printf("%c : %d\n",'a'+i, sum[i]);
    }
    return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

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


Measured memory_bytes: 256
n = int(input())
h_list = [int(x) for x in input().split()]

ans = "Yes"
h_pre = h_list[0]
for h in h_list:
    if h > h_pre:
        h -= 1
    elif h < h_pre:
        ans = "No"
        break
    h_pre = h
print(ans)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
int main(){
  int N, Q;
  cin >> N >> Q;
  dsu G(N);
  for (int i = 0; i < Q; i++){
    int t, u, v;
    cin >> t >> u >> v;
    if (t == 0){
      G.merge(u, v);
    }
    if (t == 1){
      cout << G.same(u, v) << endl;
    }
  }
}

Measured memory_bytes: 3872
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

std::vector<std::vector<long long>>
warshall_floyd(std::vector<std::vector<long long>> dist) {
  const long long LINF = 1000000000000000018LL;
  int n = (int)dist.size();
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      if (dist[i][k] == LINF) {
        continue;
      }
      for (int j = 0; j < n; j++) {
        if (dist[k][j] == LINF) {
          continue;
        }
        dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  return dist;
}

int main() {
  const long long LINF = 1000000000000000018LL;
  int v, e;
  cin >> v >> e;
  std::vector<std::vector<long long>> mat(v, std::vector<long long>(v, LINF));
  for (int i = 0; i < v; i++) {
    for (int j = 0; j < v; j++) {
      mat[j][i] = (i == j ? 0 : LINF);
    }
  }
  while (e--) {
    int s, t, d;
    cin >> s >> t >> d;
    mat[s][t] = d;
  }

  std::vector<std::vector<long long>> dist = warshall_floyd(mat);
  for (int i = 0; i < v; i++) {
    if (dist[i][i] < 0) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }
  for (int i = 0; i < v; i++) {
    for (int j = 0; j < v; j++) {
      if (dist[i][j] != LINF) {
        cout << dist[i][j];
      } else {
        cout << "INF";
      }
      cout << (j == v - 1 ? "\n" : " ");
    }
  }
  return 0;
}


Measured memory_bytes: 3296
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    if(n==2){
        cout << abs(a[0]-a[1]) << endl;
        return 0;
    }
    sort(a.begin(),a.end());
    vector<int>b(n),c(n);
    rep(i,n){
        if(i==0){
            b[0] = 1;
            c[0] = -1;
        }else if(i < n-1){
            b[i] = i%2==1 ? -2:2;
            c[i] = i%2==0 ? -2:2;
        }else{
            b[n-1] = -b[n-2]/2;
            c[n-1] = -c[n-2]/2;
        }
    }
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll temp = 0;
    ll ans = 0;
    rep(i,n){
        // cerr << b[i] << endl;
        temp += a[i]*b[i]; 
    }
    ans = temp;
    temp = 0;
    rep(i,n){
        // cerr << c[i] << endl;
        temp += a[i]*c[i];
    }
    ans = max(ans, temp);
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>
#include <utility>
#include <map>
#include <functional>
#include <cstring>

using namespace std;

int N;
typedef pair<int,int> P;
P pairs[100010];
long long answers[100010];
int main() {
  memset(answers,0,sizeof(answers));
  scanf("%d", &N);
  for(int i=0;i<N;++i) {
    scanf("%d", &pairs[i].first);
    pairs[i].second = i;
  }
  sort(pairs, pairs+N, greater<P>());
  pairs[N].first=0;
  pairs[N].second=N;

  int minIndex=N;
  for(int i=0;i<N;++i) {
    minIndex = min(minIndex, pairs[i].second);
    if(pairs[i+1].first != pairs[i].first || i==N-1) {
      answers[minIndex] += 1ll * (i+1)*(pairs[i].first-pairs[i+1].first);
    }
  }

  for(int i=0;i<N;++i) {
    printf("%lld\n", answers[i]);
  }

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int dif,i,j,n,y,f=0,a=-1,d=0,b=-1,c=-1,q=10000,w=5000,r=1000;
    cin>>n>>y;

    for( i=0;i<=n;i++)
    {
        for( j=0;i+j<=n;j++)
        {
           d=n-i-j;


           if((i*q+j*w+d*r)==y) {
            a=i;
            b=j;
            c=d;
            f=1;
           }
        }
        if(f==1){break;}
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}





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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  for(int i = 0; i < N; ++i){
    if(A[i]%2){
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
}


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

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    string s, rs, prs, srs;
    int n;
    cin >> s;
    n = s.size();
    rs = s;
    reverse(rs.begin(), rs.end());
    prs = s.substr(0, (n - 1) / 2);
    string rprs = prs;
    reverse(rprs.begin(), rprs.end());
    srs = s.substr((n + 3) / 2 - 1);
    string rsrs = srs;
    reverse(rsrs.begin(), rsrs.end());

    bool flg = true;
    if (s != rs)flg = false;
    if (prs != rprs)flg = false;
    if (srs != rsrs)flg = false;

    if (flg) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 256
import itertools
import copy
h,w,k = map(int,input().split())
C = [list(input()) for i in range(h)]
ans = 0
for i in range(h+1):
  for j in range(w+1):
    for high in itertools.combinations(range(h),i):
      for width in itertools.combinations(range(w),j):
        C2 = copy.deepcopy(C)
        for hi in high:
          for l in range(w):
            C2[hi][l] = "."
        for wi in width:
          for m in range(h):
            C2[m][wi] = "."
        C2 = list(itertools.chain.from_iterable(C2))
        if C2.count("#") == k:
          ans += 1
print(ans)

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

struct Pyramid {
  int x,y,top=0,good=true;
  Pyramid(int x, int y): x(x),y(y) {}
};
ostream& operator<<(ostream& s, const Pyramid& x) {
  return s<< "(" << x.x << "," << x.y << ")";
}

struct Data {
  int x,y,h;
  Data(int x, int y, int h): x(x),y(y),h(h) {}
};
ostream& operator<<(ostream& s, const Data& x) {
  return s<< "(" << x.x << "," << x.y << "," << x.h << ")";
}
void p(const vector<Data>& xs) {
  cout<< xs.size() << ": ";
  for (const auto& x:xs) cout<< x <<",";
  cout<<endl;
}

int N;
vector<Pyramid> pyramids;
vector<Data> datas;
int main() {
  for(int y=0;y<=100;y++) for(int x=0;x<=100;x++) pyramids.push_back(Pyramid(x,y));
  scanf("%d", &N);
  Data t(-1,-1,-1);
  for(int n=0;n<N;n++) {
    int x,y,h; scanf("%d%d%d",&x,&y,&h); datas.push_back(Data(x,y,h));
    if(h>=1) t=datas.back();
  }
  for(auto& p:pyramids) {
    p.top = t.h + abs(p.x-t.x) + abs(p.y-t.y);
    for(const auto& data:datas) {
      const int h = max(p.top - abs(data.x - p.x)
                              - abs(data.y - p.y),
                        0);
      if (h != data.h) { p.good=false; break; }
    }
  }
  Pyramid p(-1, -1);
  for(const auto& x:pyramids) if(x.good) p=x;
  printf("%d %d %d\n", p.x, p.y, p.top);
}

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

#define rep3(i, s, n ,a) for (long i = (s); i < (long)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    long n;
    long k;
    cin >> n >> k;
    vector<long> a;
    rep(i, n){
        long A;
        cin >> A;
        a.push_back(A-1);
    }
    vector<long> check(n, 0);
    long point=0;
    long first=0, sec=0;
    rep(i, n){
        if(check[point]==0){
            first++;
            check[point]++;
            point = a[point];
        }else{
            break;
        }
    }

    if(k < first){
        point = 0;
        rep(i, k){
            point = a[point];
        }
        cout << point + 1 << endl;
    }else{
        k -= first;

    rep(i, n){
        if(check[point]!=2){
            sec++;
            check[point]++;
            point = a[point];
        }else{
            break;
        }
    }

    long x = k % sec;

    rep(i, x){
        point = a[point];
    }

    cout << point + 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 6416
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
    static List<int>[] G;
    static int N;
    static void Main()
    {
        var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
        N = NM[0];
        int M = NM[1];
        G = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            G[i] = new List<int>();
        }

        for (int i = 0; i < M; i++)
        {
            var r = Console.ReadLine().Split().Select(_ => int.Parse(_) - 1).ToArray();
            G[r[0]].Add(r[1]);
            G[r[1]].Add(r[0]);
        }

        int ans = Search(0, Enumerable.Repeat(false, N).ToArray());

        Console.WriteLine(ans);
    }
    static int Search(int now,bool[] frags)
    {
        int ans = 0;
        if (frags[now]) return 0;

        bool[] nfrags = new bool[N];
        Array.Copy(frags, nfrags, N);
        nfrags[now] = true;
        if (nfrags.All(_ => _)) return 1;
        foreach(int i in G[now])
        {
            ans += Search(i, nfrags);
        }

        return ans;
    }
}

Measured memory_bytes: 29032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template <class T>
struct Knapsack {
    vector<T> weight;
    vector<T> value;
    int N;

    Knapsack(vector<T> weight_, vector<T> value_) : weight(weight_), value(value_){
        N = weight_.size();
    }; 

    vector<vector<T>> one_limited(T max_weight) {
        vector<vector<T>> dp(N + 1, vector<T>(max_weight+1, 0));
        for(int i = 0; i < N; i++) {
            for(int j = max_weight; j >= 0; j--) {
                if(j - weight[i] >= 0) chmax(dp[i+1][j], dp[i][j - weight[i]] + value[i]);
                chmax(dp[i+1][j], dp[i][j]);
            }
        }
        return dp;
    }
};

int main(){
    int N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    for(int i = 0; i < N; i++) cin >> v[i] >> w[i];
    Knapsack<ll> dp(w, v);
    cout << dp.one_limited(W)[N][W] << endl;
}


Measured memory_bytes: 10720
N = int(input())

G = [[-1]*N for i in range(N)]

def f(l, r, d):
    if l+1 >= r:
        return
    m = (l + r) // 2
    f(l, m, d+1)
    f(m, r, d+1)
    for i in range(l, m):
        for j in range(m, r):
            G[j][i] = G[i][j] = d
f(0, N, 1)
for i in range(N):
    print(*G[i][i+1:])

Measured memory_bytes: 6000
using System;

class Program
{
    private static readonly Scanner sc = new Scanner();
    private const int INF = 1010101010;
    static void Main(string[] args)
    {
        int n = sc.Int;
        int m = sc.Int;
        int[] an = new int[n];
        int[] bn = new int[n];
        int[] cn = new int[m];
        int[] dn = new int[m];
        for (int i = 0; i < n; i++)
        {
            an[i] = sc.Int;
            bn[i] = sc.Int;
        }

        for (int i = 0; i < m; i++)
        {
            cn[i] = sc.Int;
            dn[i] = sc.Int;
        }

        for (int i = 0; i < n; i++)
        {
            int minj = 0;
            int mind = INF;
            for (int j = 0; j < m; j++)
            {
                int d = Math.Abs(cn[j] - an[i]) + Math.Abs(dn[j] - bn[i]);
                if (d < mind)
                {
                    minj = j;
                    mind = d;
                }
            }

            Console.WriteLine(minj+1);
        }
    }
}

class Scanner
{
    private string[] _str = new string[0];
    private int _i;

    public string Str
    {
        get
        {
            if (_i >= _str.Length)
            {
                _str = Console.ReadLine().Split(' ');
                _i = 0;
            }
            return _str[_i++];
        }
    }

    public int Int { get { return int.Parse(Str); } }
    public long Long { get { return long.Parse(Str); } }
    public double Double { get { return double.Parse(Str); } }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:


int a[300010];

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

	rep(i,3*n) cin >> a[i];
	sort(a,a+3*n);


	ll ans=0LL;
	int idx=3*n-2;

	rep(loop,n){
		ans+=a[idx];
		idx-=2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];

		for(int i=0; i<n; i++){
			a[i] = in.nextInt();
			b[i] = in.nextInt();
		}
		long plus = 0;
		long temp = 0;
		for(int i=n-1; i>=0; i--){
			temp = a[i]+plus;
			if(temp%b[i]!=0){
				plus += b[i]*(temp/b[i]+1) - temp;
			}

		}

		System.out.println(plus);
	}

}


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

int A,B,C;
int X;
int cnt = 0;

int main()
{
    scanf("%d%d%d",&A,&B,&C);
    scanf("%d",&X);
    for(int i = 0; i <= A; i++)
    {
        for(int j = 0; j <= B; j++)
        {
            for(int k = 0; k <= C; k++)
            {
                if(i * 500 + j * 100 + k * 50 == X)cnt++;
            }
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
struct UnionFind {
    int sz;
    std::vector<int> par;
    UnionFind(int sz) {
        this->sz = sz;
        par.clear();
        par.resize(sz, -1);
    }
    int root(int x) {
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }
    void unite(int a, int b) {
        int roota = root(a);
        int rootb = root(b);
        if(roota == rootb) return;
        if(par[rootb] < par[roota]) std::swap(roota, rootb);
        par[roota] += par[rootb];
        par[rootb] = roota;
    }
    bool same(int a, int b) {
        return (root(a) == root(b));
    }
    int size(int a) {
        return -par[root(a)];
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
using ld = long double;
using Point = std::complex<ld>;
const ld eps = 1e-9, pi = acos(-1.0);
namespace std
{
bool operator<(const Point &lhs, const Point &rhs)
{
 if (lhs.real() < rhs.real() - eps)
  return true;
 if (lhs.real() > rhs.real() + eps)
  return false;
 return lhs.imag() < rhs.imag();
}
}
Point input_point()
{
 ld x, y;
 std::cin >> x >> y;
 return Point(x, y);
}
bool eq(ld a, ld b)
{
 return (abs(a - b) < eps);
}
ld dot(Point a, Point b)
{
 return real(conj(a) * b);
}
ld cross(Point a, Point b)
{
 return imag(conj(a) * b);
}
int ccw(Point a, Point b, Point c)
{
 b -= a;
 c -= a;
 if (cross(b, c) > eps)
  return 1;
 if (cross(b, c) < -eps)
  return -1;
 if (dot(b, c) < 0)
  return 2;
 if (norm(b) < norm(c))
  return -2;
 return 0;
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    vector<Point> v(n);
    for(int i=0;i<n;++i) {
      double x, y; cin >> x >> y;
      v[i] = Point(x, y);
    }
    int ma = 1;
    for(int i=0;i<n;++i) {
      for(int j=i+1;j<n;++j) {
        Point mid = (v[i] + v[j]) / (ld)2.0;
        Point diff = (v[i] - v[j]) / (ld)2.0;
        ld l2 = abs(diff);
        if(l2 + eps > 1) continue;
        ld tang = 1.0 / (l2 * l2) - 1;
        Point d(-imag(diff), real(diff));
        Point test1 = mid + d * sqrt(tang);
        Point test2 = mid - d * sqrt(tang);
        int cnt1 = 0, cnt2 = 0;
        for(int k=0;k<n;++k) {
          if(abs(v[k] - test1) < 1 + eps) {
            cnt1++;
          }
          if(abs(v[k] - test2) < 1 + eps) {
            cnt2++;
          }
        }
        ma = max(ma, max(cnt1, cnt2));
      }
    }
    cout << ma << endl;
  }
}



Measured memory_bytes: 3276
a,b = map(int,input().split())
jud = abs(b-a) + 1
if a > 0 and b > 0:
    print("Positive")
elif a < 0 and b < 0:
    if jud % 2 == 1:
        print("Negative")
    else:
        print("Positive")
else:
    print("Zero")


Measured memory_bytes: 38256
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


#import numpy as np

from collections import deque

def main():
	k=II()

	Q=deque()
	for i in range(1,10):
		Q.append(i)

	for i in range(k-1):
		x=Q.popleft()

		if x%10!=0:
			Q.append(10*x+x%10-1)
		Q.append(10*x+x%10)
		if x%10!=9:
			Q.append(10*x+x%10+1)

	print(Q[0])














if __name__ == "__main__":
	main()

Measured memory_bytes: 18860
from collections import Counter
def main():
    n = int(input())
    D = list(map(int, input().split()))
    c1 = Counter(D)
    m = int(input())
    T = list(map(int, input().split()))
    c2 = Counter(T)
    for k, v in c2.items():
        if c1[k] < v:
            print('NO')
            exit()
    print('YES')

if __name__ == '__main__':
    main()


Measured memory_bytes: 57232
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
  int k;
  cin >> k;
  int sum = 0;
  for (int i = 1; i <= k; i++)
  {
    for (int j = 1; j <= k; j++){
      for (int h = 1; h <= k; h++){
        sum += __gcd(__gcd(i, j),h);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const int N = 1e5+10;
int a[N],t;
ll ans;
 
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    cin>>t;a[1]=t;
    
        for(int i=2;i<=n;i++)
        {   cin>>a[i];
           if((ll)(a[i]-a[i-1])*x>y) ans+=y;
           else  ans+=(ll)(a[i]-a[i-1])*x;
        } 
       
        printf("%lld\n",ans);
    
    return 0;
}

  



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

int main(void)
{
    char A[10], B[10], C[10];
    
    scanf("%s ", A);
    scanf("%s ", B);
    scanf("%s", C);
    
    if(A[strlen(A)-1] == B[0]
       && B[strlen(B)-1] == C[0]){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

const int iinf = 1e9+10;
const ll inf = 1ll<<60;
const ll mod = 1e9+7 ;


void GG(){cout<<"0\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b,mo) % mo;
}

int n;
const int maxn = 3e5+5;

int V[maxn], W[maxn];
ll ans[maxn];
vector<pair<int, int> > qs[maxn];
ll bst[12][maxn];
const int CAP = 10;
void dfs(int v, int lay) {
    if (v > n) return;
    if (lay <= CAP) {
        for (int i =0; i<=1e5+5; ++i) {
            bst[lay][i] = max(((i>=W[v])?(bst[lay-1][i-W[v]]+V[v]):0ll), bst[lay-1][i]);
            if (i)
                bst[lay][i] = max(bst[lay][i], bst[lay][i-1]);
        }
        for (auto & p : qs[v]) {
            ans[p.s] = bst[lay][p.f];
        }
    }else{
        bug("HI");
        int df = lay-CAP;
        for (int msk = 0; msk < (1<<df); ++msk) {
            ll val = 0, wei = 0;
            for (int i = 0; i<df; ++i) {
                if (msk & (1<<i)) {
                    val += V[v>>i];
                    wei += W[v>>i];
                    if (wei > 1e5+5) break;
                }
            }
            if (wei > 1e5+5) continue;;
            for (auto &p : qs[v]) {
                if (p.f >= wei)
                    ans[p.s] = max(ans[p.s], bst[CAP][p.f-wei]+val);
            }
        }
    }
    dfs(v*2, lay+1);
    dfs(v*2+1, lay+1);
}

signed main(){
    IOS();
    bst[0][0] = 0;
    cin>>n;
    for (int i =1 ; i<=n; ++i) {
        cin>>V[i]>>W[i];
    }
    int q; cin>>q;
    for (int i =0 ; i<q; ++i) {
        int v,l; cin>>v>>l;
        qs[v].pb({l,i});
    }

    dfs(1,1);
    for (int i = 0 ;i<q; ++i) {
        cout<<ans[i]<<endl;
    }

}


Measured memory_bytes: 26508
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();

    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    line.trim()
        .split_whitespace()
        .map(|x| x.parse::<T>())
        .collect::<Result<Vec<T>, _>>()
        .map_err(|_| format!("{}", "parse error"))
}

fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let ns = read_parameters::<usize>().unwrap();
    let ans = if ns[0] >= ns[1] {
        gcd(ns[0], ns[1])
    } else {
        gcd(ns[1], ns[0])
    };
    println!("{}", ans);
}



Measured memory_bytes: 5040