akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll n;
    vector<ll> t(5);
    cin >> n;
    for (int i = 0; i < 5; i++)
        cin >> t.at(i);
    sort(t.begin(), t.end());
    ll out;
    if (n % t.front() == 0)
        out = n / t.front() + 4;
    else if (n <= t.front())
        out = 5;
    else
        out = n / t.front() + 5;
    cout << out << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char const *argv[])
{
	int N, i; cin >> N >> i;
	cout << N - i + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    int appear[26];
    for (int i = 0; i < 26; ++i)
        appear[i] = 0;

    for (int i = 0; i < s.length(); ++i)
        ++appear[s[i] - 'A'];

    bool flag = true;
    for (int i = 0; i < 26; ++i) {
        if (appear[i] != 0 && appear[i] != 2) {
            flag = false;
            break;
        }
    }
    if (flag)
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}

int n, m, k, mat[12][1005];

int getsum(int col, int rd, int ru){
	if (ru == 0) return mat[rd][col];
	return mat[rd][col] - mat[ru-1][col];
}

int try_solve(int msk){
	vector<int> aux = {0};
	for(int i = 0; i<n; i++) if ((msk>>i)&1) aux.push_back(i+1);
	aux.push_back(n);
	vector<pair<int,int>> ranges;
	for(int x = 0; x<int(aux.size())-1; x++) ranges.push_back({aux[x], aux[x+1]});
	for(auto&p: ranges){
		for(int i = 0; i<m; i++)
			if (getsum(i, p.second-1, p.first)>k) return (int)1e9;
	}
	vector<int> sums(ranges.size(), 0);
	vector<int> carry(ranges.size(), 0);
	int cut = __builtin_popcount(msk);
	for(int i = 0; i<m; i++){
		pair<int, int> rng;
		bool over = false;
		for(int j = 0; j<ranges.size(); j++){
			carry[j] += getsum(i, ranges[j].second-1, ranges[j].first);
			over |= (sums[j]+carry[j])>k;
		}
		cut+= int(over);
		for(int j = 0; j<ranges.size(); j++){
			if(over) sums[j] = carry[j];
			else sums[j] +=carry[j];
			carry[j] = 0;
		}
	}
	return cut;
}

int main(){
	scanf("%d %d %d\n", &n, &m, &k);
	for(int i = 0; i<n; i++){
		for(int j = 0; j<m; j++) mat[i][j] = getchar() - '0';
		getchar();
	}
	for(int j = 0; j<m; j++){
		for(int i = 1; i<n; i++) mat[i][j] += mat[i-1][j];
	}
	int best = 1e9;
	for(int mask = 0; mask<(1<<(n-1)); mask++) best = min(best, try_solve(mask));
	printf("%d\n", best);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

struct items{
    ll t, v;
};
static const ll MAX = 100001;

bool asc( const items& left, const items& right ) {
    return left.v == right.v ? left.t < right.t : left.v < right.v;
}
int main() {
    

    ll n,k;
    cin >> n >> k;
    vector <items> lis, rem;
    for (ll i=0;i<n;i++){
        items p;
        cin >> p.t >> p.v;
        lis.push_back(p);
    }
    sort(lis.begin(), lis.end(), asc);
    reverse(lis.begin(), lis.end());
    ll eachmax[MAX] = {};
    ll per = 0;
    for(ll i=0;i<n;i++){
        if(eachmax[lis[i].t] < lis[i].v){
            eachmax[lis[i].t] = lis[i].v;
        }
    }
    ll numt = 0;
    ll exist[MAX] = {};
    for(ll i=0;i<k;i++){
        per += lis[i].v;
        if(exist[lis[i].t] == 0){
            numt++;
        }else{
            rem.push_back(lis[i]);
        }
        exist[lis[i].t] = 1;
//        cout << lis[i].t << endl;
    }
    reverse(rem.begin(), rem.end());
    ll ans = 0;
    if(ans < per + numt*numt){
        ans = per + numt*numt;
    }

//    cout << ans << endl;
    vector <ll> memo;
    for (ll i=0;i<n;i++){
        if(exist[i] == 0 and eachmax[i] > 0){
            memo.push_back(eachmax[i]);
        }
    }
    sort(memo.begin(), memo.end());
    reverse(memo.begin(), memo.end());
//    cout << rem.size() << endl;
//    cout << memo.size() << endl;
    for(ll i = 0;i<min(memo.size(), rem.size());i++){
        per -= rem[i].v;
        per += memo[i];
        numt++;
        if(ans < per + numt*numt){
            ans = per + numt*numt;
        }
//        cout << ans << endl;
    }
//    cout << "mofu" << endl;
    cout << ans << endl;


}




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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 1e5 + 10;
const ll INF = 1e18;

int n;
ll ar[N];
ll slot, ans;

ll dp[N], slots[N];

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

    cin >> n;
    slot = 1;
    for (int i=0;i<=n;i++){
        cin >> ar[i];
    }    
    for (int i=0;i<=n;i++){
        slots[i] = slot;
        slot -= ar[i];
        if (slot < 0){
            cout << -1 << el;
            return 0;
        }
        dp[i] += ar[i];
        slot = min(slot + slot, INF);
    }
    ll cur = 0;
    for (int i=n;i>=0;i--){
        if (cur){
            dp[i] = min(dp[i] + cur, slots[i]);
        }
        ans += dp[i];
        cur = dp[i];
    }
    cout << ans << el;

    return 0;
}

Measured memory_bytes: 5988
#!/usr/bin/env python3
(n, m), *q = [[*map(int, i.split())] for i in open(0)]
s = sorted(q)
d = {}
for k, v in s:
    if k not in d:
        d[k] = []
    d[k].append(v)
c = {}
for k, v in d.items():
    i = 0
    if k not in c:
        c[k] = {}
    while i < len(v):
        i += 1
        c[k][v[~-i]] = str(i)
for p, y in q:
    pn = "00000" + str(p)
    cn = "00000" + c[p][y]
    print(pn[-6:] + cn[-6:])


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

int main(){ 
  int n,b,result=0;
  cin >> n >> b;
  rep(i,n){
    int tmp;
  	cin >> tmp;
    if(tmp >= b) result++;
  }
  cout << result << endl;    
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


int main() {
	int n, m;
	cin >> n >> m;
	int min_g = 0;
	int max_g = 100000;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		if (l>min_g) min_g = l;
		if (r<max_g) max_g = r;
	}
	if (max_g >= min_g) {
		cout << max_g - min_g + 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 3572
#include<stdio.h>
int main(){
  int i,N;
  int judge = 0;
  char c;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c",&c);
    if(c=='Y'){
      printf("Four");
      judge = 1;
      break;
    }
    if(i==N-1&&judge==0){
      printf("Three");
    }
  }
  return 0;
}


Measured memory_bytes: 128
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;
const int N = 2e5;
const int d = 2019;
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	vector<int> dp(d,0),last(d,0);
	string s;
	cin>>s;
	int n = s.length();
	last[s[0]-'0'] = 1;
	int ans = last[0];
	for(int i=1;i<n;i++){
		fill(dp.begin(),dp.end(),0);
		int cur = s[i]-'0';
		dp[cur] = 1;
		for(int j=0;j<d;j++){
			if(last[j]==0) continue;
			dp[(j*10+cur)%d] += last[j];
		}
		ans += dp[0];
		last = dp;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3728
void main(){
	long n, m, x;
	readf("%d %d %d\n", &n, &m, &x);
	long[][] a; a.length = n;// 参考書とアルゴリズム
	long[] c; // コスト
	long ans = -1;
	// 入力をだーーっと入れていく
	foreach(i; 0..n){
		long[] arr = _scanln!long();
		c ~= arr[0];
		a[i] ~= arr[1..$];
	}

	long[] alg; alg.length = m;
	foreach(bmask; 0..2^^n){
		long cost;
		alg[0..$] = 0;
		foreach(j; 0..n){
			if( (1<<j&bmask)==0 )continue;
			alg[0..$] += a[j][0..$];
			cost += c[j];
		}
		// アルゴリズムの理解度チェック
		long cnt;
		foreach(elm; alg)if(elm>=x)cnt++;
		if(cnt == alg.length){
			// 条件を満たす解である
			if( ans > cost || ans==-1)ans = cost;
		}
	}
	ans.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2904
#include<bits/stdc++.h>
typedef long long lint;
using namespace std;

lint a[2000010],n;

int main(){
	scanf("%lld",&n);
	for(int i=0;i<n;i++) cin>>a[i];
	lint result=0,cur=0,r=0;
	for(int i=0;i<n;i++){
		while(r<n&&(cur&a[r])==0){
			cur^=a[r];r++;
		}
		cur^=a[i];
		result+=r-i;
	}
	printf("%lld",result);
	return 0;
}

Measured memory_bytes: 1792
def main():
    S = input()

    S_half_len = int(len(S) / 2 + 0.5)

    S1 = []
    for i in range(S_half_len):
        S1.append(S[i])

    S2 = []
    if len(S) % 2 == 1: S_half_len -= 1
    for i in range(S_half_len, len(S)):
        S2.append(S[i])
    S2.reverse()
    # print(S2[:])

    ans = 0
    for i in range(len(S1)):
        if S1[i] != S2[i]:
            ans += 1

    print('{}'.format(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    ll n, a;
    cin >> n;
    vector<ll> A;
    for (int i = 0; i < n; i++) {
        cin >> a;
        A.push_back(a);
    }
    ll sum = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        sum += A[i];
        if(i%2==0){
            if(sum > 0) continue;
            cnt += abs(sum) + 1;
            sum = 1;
        }
        else{
            if(sum < 0) continue;
            cnt += abs(sum) + 1;
            sum = -1;
        }
    }
    ll ans = cnt;
    sum = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        sum += A[i];
        if(i%2==0){
            if(sum < 0) continue;
            cnt += abs(sum) + 1;
            sum = -1;
        }
        else{
            if(sum > 0) continue;
            cnt += abs(sum) + 1;
            sum = 1;
        }
    }
    ans = min(ans, cnt);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
// arock - 2019-08-18

#include <iomanip>
#include <iostream>
#include <vector>

using f64 = double;

template <class T> std::vector<T> read(int n) {
	std::vector<T> res(n);
	for (auto& r : res) {
		std::cin >> r;
	}

	return res;
}

int main() {
	int N;
	std::cin >> N;
	auto A = read<f64>(N);
	f64 den = 0;
	for (f64 a : A) {
		den += 1 / a;
	}

	std::cout << std::setprecision(20) << std::fixed << 1 / den << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	int n;
	cin >> n;
	vector<int> p(100, 0);
	
	for (int i = 1, j= 0; i <= n; i++)
	{
		int tail = i % 10;
		int head = i / pow(10, j);
		if (head == 10)
		{
			head = 1;
			j++;
		}
		p[head * 10 + tail]++;
	}

	ll r = 0;
	for (int i = 1; i < 10; i++)
		for (int j = i + 1; j < 10; j++)
			r += p[i + 10 * j] * p[j + 10 * i] * 2;
	for (int i = 1; i < 10; i++)
		r += p[i * 10 + i] * p[i * 10 + i];
	printf("%lld", r);
	return 0;
}


Measured memory_bytes: 888
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N, K; cin>>N>>K;
    vec num(N,0);
    rep(i,K){
        int D; cin>>D;
        rep(d,D){
            int A; cin>>A;
            num[A-1]++;
        }
    }
    int ans = 0;
    rep(i,N){
        if(num[i] == 0){
            ans++;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
ll LCM(ll x, ll y);

int main() {
    ll N, X, tmp, ans;
    cin >> N >> X;

    vector<ll>dif(N);

    ans = pow(10, 9);

    rep(i, N) {
        cin >> tmp;
        dif[i] = abs(X - tmp);
        ans = min(ans, dif[i]);
    }

    rep(i, N) {
        ans = min(ans, LCM(ans, dif[i]));
    }

    cout << ans;

    return 0;
}


ll LCM(ll x, ll y) {
    ll a, b, r, gcd, lcm;
    a = max(x, y);
    b = min(x, y);
    r = 1;
    while (r != 0) {
        r = a % b;
        if (r == 0) {
            gcd = b;
        }
        a = b;
        b = r;
    }

    return gcd;
}

Measured memory_bytes: 3520
import numpy as np

A, B, H, M = map(int, input().split())
H_kakudo = (H * 60 + M) / (12 * 60) * np.pi * 2
M_kakudo = M / 60 * 2 * np.pi
HM_kakudo = abs(H_kakudo - M_kakudo)
ans = A**2 + B**2 - 2*(A*B*np.cos(HM_kakudo))
print(np.sqrt(ans))

Measured memory_bytes: 27192
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    double PI = acos(-1);

    int a, b, x;
    cin >> a >> b >> x;

    // cout << "2x: " << 2*x << endl;
    // cout << "aab: " << a*a*b << endl;

    double ans;
    if (2*x >= a*a*b){
        double c = 2*b - 2*x/(double)(a*a);
        // cout << "c: " << c << endl;
        ans = atan(c/a) * 180 / PI;
    } else {
        double d = 2*x/(double)(a*b);
        // cout << "d: " << d << endl;
        ans = atan(b/d) * 180 / PI;
    }

    cout << fixed << setprecision(10);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=0;i<=n;++i)
#define INF 100000000
#define MOD 1000000009
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int n;
int c[499], s[499], f[499];

int solve(int k, int i){
    if(i == n - 1){
        return k;
    }

    k = max(k, s[i]);

    while(true){
        if(k % f[i] == 0){
            return solve(k + c[i], i+1);
        }
        ++k;
    }
}

int main(){
    cin >> n;
    if(n >= 2){
        REP(i, n-1) cin >> c[i] >> s[i] >> f[i];
    }

    REP(i, n){
        cout << solve(0, i) << endl;
    }

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;


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

Measured memory_bytes: 256
import math 

N=int(input())

li=[]
l=0
m=0

for i in range(math.floor(math.sqrt(N))):
  if N%(i+1)==0:
    l=i
    m=N/(i+1)-1
    li.append(l+m)
  else:
    pass

print(int(min(li)))



Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    int an, bn;
	cin >> an >> bn;
	
	vint A(an), B(bn);
	
	rep(i, an) cin >> A[i];
	rep(i, bn) cin >> B[i];
	
	int res = 0;
	rep(i, bn)
	{
		int index = i;
		rep(j, an)
		{
			if(A[j] == B[index])
			{
				index++;
			}
		}
		
		chmax(res, index - i);
	}
	
	cout << res << endl;
}

Measured memory_bytes: 904
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
const int MAX_ROW = 510; // to be set appropriately
const int MAX_COL = 510; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};

int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int linear_equation(BitMatrix A, vector<int> b, vector<int> &res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);

    // check if it has no solution
    for (int row = rank; row < m; ++row) if (M[row][n]) return -1;

    // answer
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return rank;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    rep(test,t){
        int n;
        cin>>n;
        vec A(n),B;
        rep(i,n) cin>>A[i];
        string s;
        cin>>s;
        reverse(all(A));
        reverse(all(s));
        int z=0;
        rep(i,n){
            if(s[i]=='0') B.push_back(A[i]);
            else{
                vector<int> D(70,0),ans;
                ll p=A[i];
                for(int j=0;p>0;j++){
                    D[j]=p%2;
                    p/=2;
                }
                BitMatrix C(70,B.size());
                rep(j,B.size()){
                    ll p=B[j];
                    for(int k=0;p>0;k++){
                        C[k][j]=p%2;
                        p/=2;
                    }
                    
                }
                if(linear_equation(C,D,ans)==-1) z=1;
            }
        }
        cout<<z<<"\n";
    }
}

Measured memory_bytes: 3764
H, W = map(int, input().split())
G = [list('.'*(W+2)) for _ in range(H+2)]
for i in range(H):
  G[i+1][1:W+1] = input()
ans = 'Yes'
for i in range(1,H):
  for j in range(1,W):
    if G[i][j]=='#':
      if G[i-1][j]=='.' and G[i+1][j]=='.' and G[i][j-1]=='.' and G[i][j+1]=='.':
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a;
    cin >> a;
    if(a == 25){
        cout << "Christmas";
    }
    else if(a == 24){
        cout << "Christmas Eve";
    }
    else if(a == 23){
        cout << "Christmas Eve Eve";
    }
    else{
        cout << "Christmas Eve Eve Eve";
    }
    cout << endl;
}


Measured memory_bytes: 256
N,L = [int(i) for i in input().split()] 
bi=None
if 2<=1-L and 1-L<=N:
    bi =1-L
elif 1-L>=N:
    bi = N
elif 2>=1-L:
    bi =1
ajis = [L+i for i in range (N)]
org_sum = sum(ajis)
ans = org_sum -(L+bi-1)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <deque>
#include <algorithm>

using namespace std;

int di[4] = {1,0,-1,0};
int dj[4] = {0,-1,0,1};
int h,w;

int main(void){
  int i,j,k;
  string str;



  while(cin >> h >> w && (h|w) != 0){
    char f[h][w];
    bool visited[h][w];
    int ret = 0;
    deque<pair<int,int> > q;
    memset(visited, false, sizeof(visited));

    for(i=0;i<h;i++){
      cin >> str;
      for(j=0;j<w;j++){
	f[i][j] = str[j];
      }
    }
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(visited[i][j] == false){
	  int tmp[2];

	  q.push_back(make_pair(i,j));
	  while(!q.empty()){
	    tmp[0] = q.front().first;
	    tmp[1] = q.front().second;
	    q.pop_front();

	    
	    if(f[i][j] == f[tmp[0]][tmp[1]] && !visited[tmp[0]][tmp[1]]){
	      //cout << tmp[0] << " " << tmp[1] << endl;
	      visited[tmp[0]][tmp[1]] = true;
	      for(int k=0;k<4;k++){
		if(0 <= tmp[0] + di[k] &&
		   tmp[0] + di[k] < h &&
		   0 <= tmp[1] + dj[k] &&
		   tmp[1] + dj[k] < w){
		  q.push_back(make_pair(tmp[0]+di[k], tmp[1]+dj[k]));
		}
	      }
	    }
	  }
	  //	  cout << endl << endl;
	  ret++;
	}
      }
    }
    cout << ret << endl;
  }
}

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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > cnt(4, 0);
    for(int i=0; i<N; i++){
        std::string tmp;
        std::cin >> tmp;
        if(tmp[0] =='A'){
            cnt[0]++;
        }else if(tmp[0] =='W'){
            cnt[1]++;
        }else if(tmp[0] =='T'){
            cnt[2]++;
        }else if(tmp[0] =='R'){
            cnt[3]++;
        }
    }
    
    std::cout << "AC x " << cnt[0] << std::endl;
    std::cout << "WA x " << cnt[1] << std::endl;
    std::cout << "TLE x " << cnt[2] << std::endl;
    std::cout << "RE x " << cnt[3] << std::endl;
    
    return 0;
}



Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0045
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = Console.ReadLine();
            var B = Console.ReadLine();
            var C = Console.ReadLine();

            Console.WriteLine(A.Substring(0, 1) + B.Substring(1, 1) + C.Substring(2, 1));
        }
    }
}


Measured memory_bytes: 25600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, h, m);
    double th = 2*M_PI * (60*h + m) / 60 / 12;
    double tm = 2*M_PI * m / 60;
    double d = sqrt(Sq(a*cos(th) - b*cos(tm)) + Sq(a*sin(th) - b*sin(tm)));
    printf("%.15f\n", d);
}


Measured memory_bytes: 4072
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in =new Scanner(new BufferedInputStream(System.in));
		while(in.hasNext())
		{
			BigInteger a = in.nextBigInteger(),b = in.nextBigInteger();
			System.out.println(a.subtract(b));
		}
		in.close();
	}

}


Measured memory_bytes: 76248
#include <iostream>
#include <cmath>
//#include <string>
using namespace std;
int main(){
   
    int heya[4][3][10];
    for(int i=0;i<4;i++){
        for(int u=0;u<3;u++){
        for(int j=0;j<10;j++){
            heya[i][u][j]=0;
        }
        }
    }
    
    int n;
    cin>>n;
    
    for(int i=0;i<n;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        heya[a-1][b-1][c-1]+=d;
    }
    
    for(int i=0;i<4;i++){
        for(int u=0;u<3;u++){
            for(int j=0;j<10;j++){
                cout<<' '<<heya[i][u][j];
                
            }
            cout<<endl;
        }
        if(i!=3){for(int y=0;y<20;y++){
            cout<<'#';
        }
        
            cout<<endl;    }}
    return 0;
}



Measured memory_bytes: 3108
var S = readLine()!
var T = readLine()!
var suuji = 0

for num in 0...2{
  let Sa = S.index(S.startIndex, offsetBy: num)
  let Ta = T.index(T.startIndex, offsetBy: num)
  if S [Sa]==T [Ta] {
    suuji += 1
  }
}
print(suuji)

Measured memory_bytes: 7800
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).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 int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int a;long double b;cin>>a>>b;
    long double z = floor(a*b);
  	int d = z;
    cout<<d<<endl;
}

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

#define RFOR(type, i, a, b) for (type i = (b)-1;i >= (a); --i)
#define REP(type, i, n) for (type i = 0; i < (n); ++i)

int main(void) {
  long N, Q; cin >> N >> Q;
  string s; cin >> s;
  vector<pair<char, char> > input(Q);
  REP(long, i, Q) {
    char t, d; cin >> t >> d;
    input.at(i) = make_pair(t, d);
  }

  long l = -1, r = N;
  RFOR(long, i, 0, Q) {
    char t = input.at(i).first, d = input.at(i).second;
    if (d == 'L') {
      if (l < N-1 && t == s[l+1]) l++;
      if (r < N && t == s[r]) r++;
    } else {
      if (l > -1 && t == s[l]) l--;
      if (r > 0 && t == s[r-1]) r--;
    }
  }
  cout << r-l-1 << endl;

  return 0;
}


Measured memory_bytes: 900
#include<cstdio>
#define ll long long
using namespace std;
const ll mod=1e6+3;
ll q,x,d,n;
ll jc[mod+10];
ll pow(ll x,ll y){
	ll ans=1;
	while(y){
		if(y&1) ans=ans*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return ans%mod;
}
int main(){
	scanf("%lld",&q); jc[0]=1;
	for(ll i=1;i<=mod;i++) jc[i]=jc[i-1]*i%mod;
	while(q--){
		scanf("%lld%lld%lld",&x,&d,&n);
		if(d==0){printf("%lld\n",pow(x,n));continue;}
		ll fx=x*pow(d,mod-2)%mod;
		if(fx+n-1>=mod || x==0) {printf("0\n");continue;}
		ll tp=pow(d,n);
		printf("%lld\n",tp*jc[fx+n-1]%mod*pow(jc[fx-1],mod-2)%mod);
	}	
}

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

int main(){
    int n , l ;
    cin >> n >> l ;
    vector<string> v(n);
    for(int i=0;i<n;i++){
        cin >> v[i] ;
    }
    sort(v.begin(),v.end());
    string ans = "" ;
    for(string x : v){
        ans += x ;
    }
    cout << ans << endl;

    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        for (int i=0; i < a; i++) {
            cout << b;
        }
    } else {
        for (int i=0; i < b; i++) {
            cout << a;
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define clr clear()
#define pb push_back
#define sz size()
#define INIT(a) memset(a,0,sizeof(a))
using namespace std;
typedef vector<int> vi;
typedef long long ll;

int n;
vi x,y;
int l[110],t[110],r[110],b[110];
ll rec[110][110];
const int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

void dfs(int py, int px, ll col){
  if(rec[py][px] != col)return;
  rec[py][px] = -1;

  rep(i,4){
    int ny = py + dy[i], nx = px + dx[i];
    if(ny<0 || nx<0 || ny>=(int)y.sz || nx>=(int)x.sz)continue;
    dfs(ny,nx,col);
  }
}

int main(){
  while(cin >> n,n){
    x.clr; y.clr;
    x.pb(-1); y.pb(-1);
    rep(i,n){
      cin >> l[i] >> t[i] >> r[i] >> b[i];
      x.pb(l[i]); x.pb(r[i]);
      y.pb(t[i]); y.pb(b[i]);
    }

    sort(all(x));
    x.erase(unique(all(x)),x.end());
    sort(all(y));
    y.erase(unique(all(y)),y.end());

    INIT(rec);

    rep(i,n){
      l[i] = lower_bound(all(x),l[i]) - x.begin();
      r[i] = lower_bound(all(x),r[i]) - x.begin();
      t[i] = lower_bound(all(y),t[i]) - y.begin();
      b[i] = lower_bound(all(y),b[i]) - y.begin();
      for(int j=b[i];j<t[i];j++){
	for(int k=l[i];k<r[i];k++){
	  rec[j][k] |= 1LL<<i;
	}
      }
    }

    int ans = 0;
    rep(i,y.sz){
      rep(j,x.sz){
	if(rec[i][j]>=0){
	  dfs(i,j,rec[i][j]); ans++;
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1784
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
#include<set>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()
#define foreach(p,r) for(p::iterator it=r.begin();it!=r.end();++it)

const int MAXN = 10000;
vector<int> nums(MAXN);
vector<int> ans(MAXN);
int main()
{
    int n;
    while(cin >> n && n)
    {
        int half = (n-1)/2;
        set<int> sq;
        fill(all(ans),0);

        REP(n - 1) sq.insert(((i + 1) * (i + 1)) % n);
        int l = 0;
        foreach(set<int>,sq){ nums[l] = *it ; l++;}

        //REP(l-1)for(int j = i+1;j<l;j++)
        REP(l)rep(j,l)
        {
            if(i==j) continue;
            int res = nums[j] - nums[i];
            if(res < 0) res += n;
            if(res > half) res = n - res;
            ans[res]++;
            //cout <<"add" <<  res <<endl;
        }
        REP(half) cout << ans[i + 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 0
def eratosthenes(n):
    table = [0] * (n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
                
    return prime_list

lr=[]
q=int(input())
p=0
for i in range(q):
    a=[int(j) for j in input().split()]
    lr.append(a)
    p=max(p,a[1])
ll=eratosthenes(p)
l=set(ll)
del ll[0]
li=[0 for i in range(p+2)]

for i in ll:
    if (i+1)//2 in l:
        li[i]+=1

from itertools import accumulate
la=list(accumulate(li))

for i in range(len(lr)):
    print(la[lr[i][1]]-la[lr[i][0]-1])





Measured memory_bytes: 26832
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
  int n, i;
  scanf("%d", &n);
  double x[n];
  char u[n][5];
  for(i=0; i<n; i++){
    scanf("%lf %s", &x[i], u[i]);
  }
  double sum = 0; //yen
  for(i=0; i<n; i++){
    if(strcmp(u[i],"JPY")==0){
      sum += x[i];
    }else{
      sum += x[i]*380000.0;
    }
  }

  printf("%f", sum);
  return 0;
}


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


Measured memory_bytes: 3084
#include <iostream>
#include <string>
using namespace std;

int main() {
	int cnt = 0;
	string s; cin >> s;
	for (int i = 0; i < 3; i++)if (s[i] == 'o')cnt++;
	cout << 700 + cnt * 100 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int D = scanner.nextInt();

        int[][] X = new int[N][D];

        for (int i = 0 ; i < N ; i++) {
            for (int j = 0 ; j < D ; j++) {
                X[i][j] = scanner.nextInt();
            }
        }
        
        int count = 0;
        for (int i = 0 ; i < N ; i++) {
            for (int j = i + 1 ; j < N ; j++) {
                int dist = 0;
                for (int k = 0 ; k < D ; k++) {
                    dist += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
                }

                for (int n = 1 ; n * n <= dist ; n++) {
                    if (n * n == dist) {
                        count++;
                        break;
                    }
                }
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 36296
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
using namespace std;
string solve() {
	string S;
	cin >> S;
	if (S.size() == 26) {
		string T(S);
		bool f = next_permutation(T.begin(), T.end());
		if (!f) return "-1";
		for (int i = 0; i < 26; i++) if (S[i] != T[i]) return T.substr(0, i + 1);
		return "";
	}
	array<bool, 26> exist;
	exist.fill(false);
	for (char c : S) exist[c - 'a'] = true;
	for (int i = 0; i < 26; i++) if (!exist[i]) return S + char('a' + i);
}
int main() {
	cout << solve() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){

  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = 0;
  if (k >= a){
    ans = a;
    k -= a;
    if (k > b) {
      ans -= k - b;
    }
  } else {
    ans = k;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)
#define SP(i)           fixed << setprecision(i) 

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

#include<bits/stdc++.h> 
using namespace std;
vi v;
void dfs(ll n, ll m, ll stepNum) 
{ 
    if (stepNum <= m && stepNum >= n) 
        v.pb(stepNum);
    if (stepNum == 0 || stepNum > m) 
        return ;
    ll lastDigit = stepNum % 10;
    ll stepNumA = stepNum*10 + (lastDigit-1); 
    ll stepNumB = stepNum*10 + (lastDigit+1);
    ll stepNumC = stepNum*10 + (lastDigit);
    if (lastDigit == 0) {
        dfs(n, m, stepNumB);
                dfs(n,m,stepNumC);

    }

    else if(lastDigit == 9) {
        dfs(n, m, stepNumA); 
            dfs(n,m,stepNumC);
    }

    else
    { 
        dfs(n, m, stepNumA); 
        dfs(n, m, stepNumB);
        dfs(n,m,stepNumC);
    } 
}
void displaySteppingNumbers(ll n, ll m) 
{ 
    for (ll i = 0 ; i <= 9 ; i++) 
        dfs(1, 3234566667, i); 
} 

void solve() {
	ll k;
	cin>>k;
    displaySteppingNumbers(1,3234566667);
    sort(all(v));
    cout<<v[k-1]<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}


Measured memory_bytes: 1400
# first_AC:20200202
question_count = gets.to_i
question_levels = gets.split.map(&:to_i)
question_count_half = question_count/2
question_sorted_levels = question_levels.sort

if question_sorted_levels[question_count_half] == question_sorted_levels[question_count_half - 1]
  p 0
else
  p question_sorted_levels[question_count_half] - question_sorted_levels[question_count_half - 1]
end


Measured memory_bytes: 9712
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  map<int,int> m;
  REP(i,n) {
    int a;
    cin>>a;
    ++m[a];
  }
  if (m.size() > 3) {
    cout<<"No"<<endl;
    return 0;
  }
  if (m.size() == 3) {
    auto itr = m.begin();
    int a0,c0;
    tie(a0,c0) = *itr;
    ++itr;
    int a1,c1;
    tie(a1,c1) = *itr;
    ++itr;
    int a2,c2;
    tie(a2,c2) = *itr;
    if (a2 != (a0 ^ a1)) {
      cout << "No" << endl;
      return 0;
    }
    if (c0 != c1 || c0 != c2) {
      cout << "No" << endl;
      return 0;
    }
    cout << "Yes" << endl;
  } else if (m.size() == 2) {
    auto itr = m.begin();
    int a0,c0;
    tie(a0,c0) = *itr;
    ++itr;
    int a1,c1;
    tie(a1,c1) = *itr;
    if (a0 && a1) {
      cout << "No" << endl;
      return 0;
    } if (a0 == 0 && c0 * 2 == c1) {
      cout << "Yes" << endl;
      return 0;
    } if (a1 == 0 && c1 * 2 == c0) {
      cout << "Yes" << endl;
      return 0;
    }
    cout<<"No"<<endl;
  } else {
    if (m.begin()->first == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3840
import sys

class QualityChecking:
    def __init__(self, a, b, c, N):
        self.__N = N
        self.__a = a
        self.__b = b
        self.__c = c
        self.__test = []
    
    def read(self, i, j, k, r):
        self.__test.append([i, j, k, r])
    
    def solve(self):
        result = [2] * (self.__a + self.__b + self.__c + 1)
        ok = set()
        ng = set()
        unknown = set()
        for t in self.__test:
            if t[3] == 1:
                ok.add(t[0])
                ok.add(t[1])
                ok.add(t[2])
        test1 = []
        for t in self.__test:
            test1.append(["ok" if x in ok else x for x in t])
        for t in test1:
            if t[3] == 0:
                if t[0] == "ok" and t[1] == "ok":
                    ng.add(t[2])
                elif t[0] == "ok" and t[2] == "ok":
                    ng.add(t[1])
                elif t[1] == "ok" and t[2] == "ok":
                    ng.add(t[0])
        for i in range(1, self.__a + self.__b + self.__c + 1):
            if i in ok:
                print("1")
            elif i in ng:
                print("0")
            else:
                print("2")
               

while True:
    line = input()
    a, b, c = map(int, list(line.split()))
    if a == 0 and b == 0 and c == 0:
        break
    line = input()
    n = int(line)
    qc = QualityChecking(a, b, c, n)
    for _ in range(0, n):
        i, j, k, r = map(int, list(input().split()))
        qc.read(i, j, k, r)
    qc.solve()
    del qc


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

int main() {
string s;
  cin >> s;
  if(s.at(0) == 'a' && s.at(1) == 'b' && s.at(2) == 'c') cout << "Yes" << endl;
  else if(s.at(0) == 'b' && s.at(1) == 'c' && s.at(2) == 'a') cout << "Yes" << endl;
  else if(s.at(0) == 'c' && s.at(1) == 'a' && s.at(2) == 'b') cout << "Yes" << endl;
  else if(s.at(0) == 'a' && s.at(1) == 'c' && s.at(2) == 'b') cout << "Yes" << endl;
  else if(s.at(0) == 'b' && s.at(1) == 'a' && s.at(2) == 'c') cout << "Yes" << endl;
  else if(s.at(0) == 'c' && s.at(1) == 'b' && s.at(2) == 'a') cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
def is_squared(num):
    i = 4
    while True:
        squred_num = i * i
        if num == squred_num:
            return True
        if squred_num > num:
            return False
        i += 1



def main():
    inputs = input().split()
    if len(inputs) != 2:
        print("input is invalid. input two integers.")
        exit(1)

    a, b = inputs[0], inputs[1]
    if not (1 <= int(a) <= 100) or not (1 <= int(b) <= 100):
        print("input is invalid. input two integers. (1<=a,b<=100) ")

    # start = time.time()
    cat_num = int(a + b)
    if is_squared(cat_num):
        print("Yes")
    else:
        print("No")
    # print(time.time() - start)


if __name__ == '__main__':
    main()



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

using namespace std;

int main()
{
    int h1, m1, h2, m2, k;

    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int a = h1*60 + m1;
    int b = h2*60 + m2;

    cout << b-a-k << "\n";

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
using namespace std;
#define endl '\n'

using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    if(x<=y){
        cout << "unsafe";
    }else{
        cout << "safe";
    }
    return 0;
}

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

int c[1000][1000];

int main() {
    int n;
    while (cin >> n, n) {
        vector<string> ms(n);
        for (int i = 0; i < n; i++) {
            cin >> ms[i];
        }
        for (int i = 0; i < n; i++) {
            c[0][i] = (ms[0][i] == '*') ? 0 : 1;
            c[i][0] = (ms[i][0] == '*') ? 0 : 1;
        }
        int ans = 0;
        for (int y = 1; y < n; y++) {
            for (int x = 1; x < n; x++) {
                if (ms[y][x] == '*') {
                    c[y][x] = 0;
                    continue;
                }
                c[y][x] = min(c[y][x-1], min(c[y-1][x-1], c[y-1][x])) + 1;
                ans = max(ans, c[y][x]);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 6024