akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;


namespace
{
	class Calculater
	{
	public:
		Calculater(vi c, vvi s)
			: c_(c), s_(s), D_((int)s.size()), selection_(D_) {
			Initialize();
		}

		void Initialize()
		{
			vi ld(26, -1);
			for (int i = 0; i < D_; ++i)
			{
				vi u = s_[i];
				vi v(26);
				for (int j = 0; j < 26; ++j)
					v[j] = c_[j] * (i - ld[j]);
				int ttl = accumulate(v.cbegin(), v.cend(), 0);
				transform(v.begin(), v.end(), v.begin(), [ttl](int x) {return x - ttl; });
				for (int j = 0; j < 26; ++j)
					u[j] += v[j];
				int j = (int)distance(u.cbegin(), max_element(u.cbegin(), u.cend()));
				selection_[i] = j;
				ld[j] = i;
			}
			sat_ = CalcSatisfaction();
		}
		int CalcSatisfaction()
		{
			int v = 0;
			vi ld(26, -1);
			for (int i = 0; i < D_; ++i)
			{
				int x = selection_[i];
				for (int j = 0; j < 26; ++j)
				{
					if (j == x)
					{
						v += s_[i][j];
						ld[j] = i;
					}
					else
						v -= c_[j] * (i - ld[j]);
				}
			}
			return v;
		}

		const vi& Selections() const
		{
			return selection_;
		}
		int Selection(int i) const
		{
			return selection_[i];
		}

		void Change(int d, int q)
		{
			int p = selection_[d];
			int d0 = 1;
			for (int i = d - 1; i > -1; --i)
			{
				if (selection_[i] == p)
					break;
				++d0;
			}
			int x = d0* c_[p];
			int d1 = 1;
			for (int i = d + 1; i < D_; ++i)
			{
				if (selection_[i] == p)
					break;
				++d1;
			}
			sat_ -= d1 * x;
			sat_ -= s_[d][p];


			d0 = 1;
			for (int i = d - 1; i > -1; --i)
			{
				if (selection_[i] == q)
					break;
				++d0;
			}
			x = d0 * c_[q];
			d1 = 1;
			for (int i = d + 1; i < D_; ++i)
			{
				if (selection_[i] == q)
					break;
				++d1;
			}
			sat_ += s_[d][q];
			sat_ += d1 * x;
			selection_[d] = q;
		}
		int Satisfaction() const { return sat_; }
	private:
		vi c_;
		vvi s_;
		int D_;
		vi selection_;

		int sat_;
	};

}
void Heuristics_Introduction_A()
{
	int D;
	cin >> D;
	vi c(26);
	for (auto& x : c)
		cin >> x;

	vvi s(D, vi(26));
	for (int i = 0; i < D; ++i)
	{
		for (int j = 0; j < 26; ++j)
			cin >> s[i][j];
	}


	Calculater x(c, s);

	//for (int i = 0; i < D; ++i)
	//{
	//	int t;
	//	cin >> t;
	//	x.Change(i, t - 1);
	//}

	//int M;
	//cin >> M;
	//for (int i = 0; i < M; ++i)
	//{
	//	int d, q;
	//	cin >> d >> q;
	//	--d; --q;
	//	x.Change(d, q);

	//	cout << x.Satisfaction() << endl;
	//}

	for (int i = 0; i < D; ++i)
	{
		cout << x.Selection(i) + 1 << endl;
	}
//	cout << x.Satisfaction() << endl;
}

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


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the set
//order_of_key(k) - Number of elements striclty samller than k
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll r=min(n,k);
    set<ll> st;
    ll mmax=-1;
    for(int i=0;i<=r;i++)
    {
        for(int j=0;j<=r;j++)
        {
            if((i+j)>r)
                continue;
            set<ll> st;
            ll sum=0;
            for(int q=0;q<i;q++)
            {
                sum+=arr[q];
                st.insert(arr[q]);
            }
            for(int q=0;q<j;q++)
            {
                sum+=arr[n-1-q];
                st.insert(arr[n-1-q]);
            }
            ll temp=k-(i+j);
            set<ll>::iterator itr;
            for(itr=st.begin();itr!=st.end();++itr)
            {
                if(*itr<0 && temp>0)
                {
                    sum+=abs(*itr);
                    temp--;
                    continue;
                }
                if(temp==0)
                    break;
            }
            mmax=max(mmax,sum);
       //     cout<<i<<" "<<j<<" "<<sum<<" "<<mmax<<endl;
        }
    }
    cout<<mmax<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from itertools import combinations
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    H, W, K = MAP()
    c = [input() for i in range(H)]
    ans = 0
    for wmask in range(1 << W):
        for hmask in range(1 << H):
            cnt = 0
            for w in range(W):
                if wmask & (1 << w):
                    continue
                for h in range(H):
                    if hmask & (1 << h):
                        continue
                    if c[h][w] == "#":
                        cnt += 1
            if cnt == K:
                ans += 1
    print(ans)
    return


if __name__ == '__main__':
    main()


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

#define mp make_pair
#define pb push_back
#define f first
#define s second

using namespace std;

typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
typedef map<int,int> mii;
typedef unordered_map<int,int> umii;
typedef queue<int> qi;

vi V;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	
	string s; cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout <<"Yes\n";
	else cout << "No\n";
		
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define Rrep(i,n) for(int i=((int)n-1); i>=0; i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e15
#define MOD 10e9+7

typedef vector<int> vint;
typedef long long ll;



int main()
{
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(15);

        ll n;
        cin>>n;

        /*ll a=10;

        long long ans=(n*(n-1))%1000000007;

        rep(i,n-2){
                ans=(ans*a)%1000000007;
        }

        cout<<ans<<endl;*/

        ll all=1;
        ll yoji=1;

        rep(i,n){
                all=(all*10)%1000000007;
                yoji=(yoji*8)%1000000007;

        }

        ll tmp1=1;
        ll tmp2=1;
        //ll tmp3=1;

        rep(i,n){
                tmp1=(tmp1*10)%1000000007;
                tmp2=(tmp2*9)%1000000007;
                //tmp3=(tmp3*8)%1000000007;
        }

        ll tmp3=tmp1-tmp2;
        if(tmp3<0){tmp3+=1000000007;}
        ll katsu=all-yoji;
        if(yoji<0){katsu+=1000000007;}

        //cout<<all<<" "<<yoji<<" "<<tmp1<<" "<<tmp2<<endl;
        ll ans=(2*tmp3-katsu);

        if(ans<0){ans+=1000000007;}

        cout<<ans%1000000007<<endl;

        
        /*ll katsu=(all-yoji)%1000000007;

        ll one=1;
        ll nine=1;

        rep(i,n){
                one=(one*10)%1000000007;
                nine=(nine*10)%1000000007;
        }

        cout<<(one+nine-katsu)%1000000007<<endl;*/

        return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;

ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}
ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll inv(ll a) {
	ll x, y;
	ll g = gcd(a, mod, x, y);
	x = (x % mod + mod) % mod;
	return x;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a%m;
        a = a * a%m;
        b >>= 1;
    }
    return res;
}

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}

int main() {
	int t;
	//cin>>t;
	t = 1;
	while(t--) {
		ll d,n;
		cin>>n>>d;
		d = d*d;
		ll count = 0;
		//ld dist = d*d*1.0;
		for(int i=0; i<n; i++) {
			ll x,y; cin>>x>>y;
			if(x*x+y*y <= d) {
				count++;
			}
		}
		cout<<count;
	}
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define im 2147483647
#define lm 9223372036854775807
#define ll long long
#define vb vector<bool>
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int>>
#define ii pair<int, int>
#define ff first
#define ss second
#define _graph map<int, vector<int>>
#define lower_str(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define upper_str(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define debug(index, num) cout << "Case #" << index << ": " << num << endl
#define nmax(an, na) an = max(an, na)
#define nmin(an, na) an = min(an, na)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rep2(i, a, b) for (int i = a; i <= b; i++)
#define repp(i, a, b) for (int i = a; i >= b; i--)
#define repp2(i, a, b) for (int i = a-1; i >= b; i--)
#define be(x) x.begin(), x.end()
#define rbe(x) x.rbegin(), x.rend()
#define pb push_back
#define IO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

int main () {
    IO;
    ll n;
    cin >> n;
    cout << (n*(n-1))/2;

    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

void dividing_student (void)
{ 
    int math, english, japanese;
    scanf("%d %d %d", &math, &english, &japanese);
    if (math == 100 || english == 100 || japanese == 100) {
        printf("A\n");
    } else if (math + english >= 180) {
        printf("A\n");
    } else if (math + english + japanese >= 240) {
        printf("A\n");
    } else if (math + english + japanese >= 210) {
        printf("B\n"); 
    } else if (math + english + japanese >= 150 && (math >= 80 || english >= 80)) {
        printf("B\n");
    } else {
        printf("C\n");
    }
}

int main(void)
{
    while (true) {
        int n;
        scanf("%d", &n);
        if (n == 0) {
            break;
        }
        int i;
        for (i = 0; i < n; ++i) {
            dividing_student();
        }
    }
    return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
typedef long long int ll;
const ll INF = (1LL << 62);
using namespace std;

int main(){
	ll n , k;
	cin >> n >> k;

	vector<ll> a(n);
	for(ll &i : a){
		cin >> i;
	}

	vector<ll> dp(n , INF);
	dp[0] = 0;
	for(ll i = 0 ; i < n ; i++){
		for(ll j = i+1 ; j <= i+k && j < n; j++){
			dp[j] = min(dp[j] , dp[i] + abs(a[i] - a[j]));
		}
	}

	cout << dp[n-1] << endl;

	return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acos(-1);

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

    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int n1 = (C + B - 1) / B;
    int n2 = (A + D - 1) / D;
    cout << (n1 <= n2 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3612
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

template <int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

const int mod = 1e9 + 7;
using mint = ModInt<mod>;

const int N = 2020202;
mint f[N], inv_f[N];

mint C(int n, int r) { return f[n] * inv_f[r] * inv_f[n - r]; }

mint F(int r, int c) { return C(r + c + 2, c + 1) - 1; }

int main() {
    f[0] = 1;
    for (int i = 1; i < N; ++i) f[i] = f[i - 1] * i;
    inv_f[N - 1] = f[N - 1].inverse();
    for (int i = N - 2; i >= 0; --i) inv_f[i] = inv_f[i + 1] * (i + 1);

    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    --r1;
    --c1;
    cout << F(r2, c2) - F(r2, c1) - F(r1, c2) + F(r1, c1) << "\n";
    return 0;
}


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

int main(){
    int N, Q;
    cin >> N >> Q;
    for(int i = 0; i < Q; i++){
        int v, w;
        cin >> v >> w;
        if(N == 1){
            cout << min(v, w) << endl;
            continue;
        }
        while(v != w){
            if(v > w){
                v = (v + N - 2) / N;
            }else{
                w = (w + N - 2) / N;
            }
        }
        cout << v << endl;
    }
}


Measured memory_bytes: 1280
n,k = map(int,input().split())
lis = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(n-i+1):
        num = lis[:i]
        if j > 0:
            num += lis[-j:]
        if len(num) <= k:
            cnt = min(len(num),k-len(num))
            num.sort()
            for h in range(cnt):
                num[h] = max(0,num[h])
            ans = max(ans,sum(num))
print(ans)

Measured memory_bytes: 3064
s=input()
ans=0
if s[0]=='R':
    ans=1
    if s[1]=='R':
        ans+=1
        if s[2]=='R':
            ans+=1
elif s[1]=='R':
    ans+=1
    if s[2]=='R':
        ans+=1
elif s[2]=='R':
    ans+=1
print(ans)

Measured memory_bytes: 8992
#include <stdio.h>

#define INF 0x100000000

int n;
int u[100];
int d[100];
long long int dp[100][100]; // dp[l][r]

int main() {
    int i,j,k;

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

    for (i=0; i<n; i++) {
        int a, b;
	scanf("%d %d", &a, &b);
        u[i] = a;
	d[i] = b;
	dp[i][i] = 0;
    }

    for (k=1; k<n; k++) {
        for (i=0; i<n-k; i++) {
	    for (j=0; j<k; j++) {
	        int l1 = i;
		int r1 = i+j;
		int l2 = i+j+1;
		int r2 = i+k;
	        long long int val = dp[l1][r1] + dp[l2][r2] + u[l1] * d[r1] * u[l2] * d[r2];
		if (val < dp[l1][r2]) dp[l1][r2] = val;
	    }
	}
    }

    printf("%lld\n", dp[0][n-1]);
}

Measured memory_bytes: 1084
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
inline void add(int &a,int b){if((a+=b)>=mod)a-=mod;}
int n,k,dp[3001][3001];
int main()
{
	cin>>n>>k;
	for(int i=2;i<=n;i++)dp[1][i]=1;
	for(int i=2;i<k;i++)
		for(int j=n-i+1;j>1;j--)add(dp[i-1][j],dp[i-1][j+1]),dp[i][j]=dp[i-1][j];
	int ans=0;
	for(int i=2;i<n-k+3;i++)add(ans,dp[k-1][i]);
	if(!ans)ans=1;
	for(int i=1;i<n-k;i++)add(ans,ans);
	cout<<ans<<endl;
}


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

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	const int N=100;
	int a[N];
	int n,v,j;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
			{if(i)
			cout<<" ";
			cout<<a[i];}
	cout<<endl;
	for(int i=1;i<n;i++)
	{
		v=a[i];
		j=i-1;
		while(j>=0&&a[j]>v)
		{	a[j+1]=a[j];
			j--;
			a[j+1]=v;}
		for(int i=0;i<n;i++)
			{if(i)
			cout<<" ";
			cout<<a[i];}
	cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>

int main(){
  int G[100][100],n,i,j,a,b,k;

  for(i=0;i<100;i++){
    for(j=0;j<100;j++){
      G[i][j] = 0;
    }
  }

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&k);
      G[i][k-1] = 1;
      }
    }

    for(i=0;i<n;i++){
      for(j=0;j<n-1;j++){
        printf("%d ",G[i][j]);
      }
      printf("%d\n",G[i][j]);
    }
    return 0;
}

Measured memory_bytes: 636
#include<iostream>
using namespace std;
int main () {
  int N;
  int A[4];
  cin >> N;
  for (int i = 3; i >= 0; i --) {
    A[i] = N % 10;
    N /= 10;
  }
  for (int i = 0; i < 8; i ++) {
    int j = i;
    char op[3];
    int ans = A[0];
    for (int k = 0; k < 3; k ++) {
      if (j % 2) {
        op[k] = '+';
        ans += A[k + 1];
      }
      else {
        op[k] = '-';
        ans -= A[k + 1];
      }
      j /= 2;
    }
    if (ans == 7) {
      for (int i = 0; i < 3; i ++) {
        cout << A[i] << op[i];
      }
      cout << A[3] << "=7" << endl;
      return 0;
    }
  }
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }else{
        return false;
    }
}

template<typename T>
bool chmin(T &a, T b){
    if(a > b){
        a = b;
        return true;
    }else{
        return false;
    }
}

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

    int w, h;
    cin >> w >> h;

    vector<int> a(w);
    rep(i, w){
        cin >> a[i];
    }

    priority_queue<int> que;
    rep(i, h){
        int b;
        cin >> b;
        que.push(b);
    }

    SORT_INV(a);
    rep(i, w){
        vector<int> v(a[i]);
        rep(j, a[i]){
            int tmp = que.top();
            que.pop();
            v[j] = tmp - 1;
        }
        rep(j, a[i]){
            que.push(v[j]);
        }
    }

    int maxi = -IINF, mini = IINF;
    while(!que.empty()){
        int tmp = que.top();
        que.pop();
        chmax(maxi, tmp);
        chmin(mini, tmp);
    }

    if(maxi == 0 && mini == 0){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 3208
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      // 整数の取得
	  int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      for(int i=1;i<=B;i++){
          if((A*i)%B==C){
            System.out.println("YES");
            return;
          }
      }
      System.out.println("NO");
    }
}

Measured memory_bytes: 35760
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i = 1; i <= 10000; i++){
        int a,b;
        cin >> a >> b;
        if(a!=0||b!=0){
            cout << min(a,b) << " " << max(a,b) << endl;
        }
    }
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();

        if(a < k){
            long c = k - a;
            if(b < c){
                System.out.println(0 + " " + 0);
            }
            else{
                long d = b - c;
                System.out.println(0 + " " + d);
            }
        }
        else{
            long c = a - k;
            System.out.println(c + " " + b);
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

int main()
{
    int n,i,j;
    cin >> n;
    vector<long long> a(n);
    vector<long long> b(n);
    int x = 0,y = 0,z = 0;
    long long sum = 0;
    for(i = 0;i < n;++i){
        cin >> a.at(i);
        if(a.at(i) > 0){
            sum += a.at(i);
            b.at(i) = a.at(i);
            ++x;
        }else if(a.at(i) < 0){
            sum += (-1)*a.at(i);
            b.at(i) = (-1)*a.at(i);
            ++y;
        }else{
            b.at(i) = 0;
            ++z;
        }
    }
    if(z){
        cout << sum << endl;
    }else{
        if(y%2){
           int min = b.at(0);
           for(i = 0;i < n;++i){
               if(min > b.at(i)){
                   min = b.at(i);
                }
            }
            cout << sum-2*min << endl;
        }else{
            cout << sum << endl;
        }
    }
    return 0;
}

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

int main(int argc, char const *argv[])
{
	string s; cin >> s;
	sort(s.begin(), s.end());
	string t; cin >> t;
	sort(t.begin(), t.end()); reverse(t.begin(), t.end());

	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
	string s;

	cin >> s;
	for (int i = 0;i<s.size(); ++i) {
		if (s[i] == ',') s[i] = ' ';
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 102;

int n, m, A[CMax], ats, u, v;
set <int> G[CMax], P[CMax];
set <int>::iterator it;
bool tik;

void path (int e, int cur) {
    if (cur == e) {
        tik = false;
        return;
    }
    for (set <int>::iterator it2 = P[cur].begin(); it2 != P[cur].end(); ++it2) {
        v = *it2;
        if (A[v] == 0 && tik) {
            A[v]++;
            path(e, v);
        }
    }
}

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

    for (int i = 0; i < m; i++) {
        scanf("%d %d", &u, &v);
        G[u].insert(v);
        G[v].insert(u);
    }

    tik = true;

    while (tik) {
        tik = false;
        for (int i = 1; i <= n; i++) {
            if (G[i].size() == 1){
                tik = true;
                ats++;
                it = G[i].begin();
                u = *it;
                G[i].erase(it);
                G[u].erase(i);
            }
        }
    }


    for (int i = 1; i <= n; i++) {
        for (it = G[i].begin(); it != G[i].end(); ++it) {
            for (int k = 1; k <= n; k++){
                A[k] = 0;
                P[k] = G[k];
            }
            tik = true;
            u = *it;
            P[i].erase(u);
            P[u].erase(i);
            A[i]++;
            path(u, i);
            if (tik) ats++;
        }
    }

    cout <<  ats << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

ll dp[200000];

int main(){
    string s,t; cin >> s >> t;
    int ans=0;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int x,y,z;
  y=0;
  cin>>x;
  for (double i=1; i<32; i++){
    for (double j=2; j<10; j++){
      z=pow(i,j);
      if (z<=x && z>y){
        y=z;
      }
      else if (z>x){
        break;
      }
    }
  }
  cout<<y;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 2e5 + 5;
int n, a[N], ans, top;
struct node{int v, c;}sta[N];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
void insert(int v, int x)
{
	while(sta[top].v > v) top --;
	if(sta[top].v == v) sta[top].c ++;
	else sta[++ top] = node{v, 1};
	if(top > 1 && sta[top].c == x) top --, insert(v - 1, x);
}
int check(int mid)
{
	sta[top = 1] = node{0, 0};
	for(int i = 2; i <= n; i ++) if(a[i] <= a[i - 1]) insert(a[i], mid);
	return sta[1].c == 0;
}
int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	for(int i = 1; i <= n; i ++) a[i] = read();
	int cnt = 0;
	for(int i = 2; i <= n; i ++) cnt += (a[i] > a[i - 1]);
	if(cnt == n - 1) {puts("1"); return 0;}
	int l = 2, r = n;
	while(l <= r)
	{
		int mid = (l + r) >> 1;
		if(check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%d\n", ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream> 
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int l_i, r_i;
        cin >> l_i >> r_i;
        ans += (r_i+1 - l_i);
    }

    cout << ans << endl;
}



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

int main(){

    int n;
    long long int ans=0;
    cin>>n;

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

        if(i%3!=0&&i%5!=0) ans+=i;

    }

    cout<<ans<<endl;



    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <queue>
#include <stack>
#include <climits>
using namespace std;

typedef long long ll;
#define pb push_back

#define rep(i, n) for (int i=0;i<(n);++i)
#define rep2(i, s, n) for (int i=s;i<(n);++i)
#define rev(i, n) for (int i=(n);i>0;--i)
#define INF (1e9+1e9)

// euclid
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
// gcd * lcm = ab
int lcm(int a, int b) {
    return a*b / gcd(a, b);
}

int lcms(vector<int>& num) {
    int l = num[0];
    rep2(i,1,num.size())
        l = lcm(l,num[i]);
    return l;
}

int main() {

    int n; cin >> n;
    vector<int> num(n);
    rep(i,n) {
        int a; cin >> a;
        num[i] = a;
    }

    cout << lcms(num) << endl;
}

Measured memory_bytes: 3084
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
a2 = 0
a4 = 0
odd = 0

for a in aa:
	if a%4 == 0:
		a4 += 1
	elif a%2 == 0:
		a2 += 1
	else:
		odd += 1

if a4 >= N//2:
	print('Yes')
elif a4 >= odd:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 15452
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int n, k;
        cin >> n >> k;
        rep(i, 0, k) {
            int x, y;
            cin >> x >> y;
            x = min(x, n + 1 - x);
            y = min(y, n + 1 - y);

            int f = min(x, y);
            cout << (f - 1) % 3 + 1 << endl;
        }


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}



Measured memory_bytes: 3152
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  while(1){
    int num;
    cin >> num;
    if(num==0)return;
    int ar[num];
    for(int i=0;i<num;i++)
      cin >> ar[i];
    int res=10000000;
    for(int i=0;i<num;i++)
      for(int j=i+1;j<num;j++)
        res=min(res,abs(ar[i]-ar[j]));
    cout << res << endl;
  }
}

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



Measured memory_bytes: 3088
while True:
    a, op, b = map(str, input().split(' '))
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        sum = a + b
        print(sum)
    elif op == '-':
        hikizan = a - b
        print(hikizan)
    elif op == '*':
        kakezan = a * b
        print(kakezan)
    elif op == '/':
        warizan = int(a / b)
        print(warizan)


Measured memory_bytes: 5592
package main

import(
	"fmt"
)

func main() {
	var size uint
	var i uint

	fmt.Scanf("%d", &size)
	numbers := make([]uint, size)

	for ; i < size; i++ {
		fmt.Scanf("%d", &numbers[i])
	}

	result := sunuke(numbers)
	fmt.Printf("%d\n", result)
}

func sunuke(numbers []uint) int {
	var counter int
	var flag bool = true
	for flag {
		for index, number := range numbers {
			if number % 2 != 0 {
				return counter
			}
			numbers[index] = number / 2
		}
		counter++
	}
	return counter
}

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

using namespace std;

int main(){
  int n,res = 0;
  cin >> n;
  vector<int> a(n),b(n),c(n-1);
  for(int i = 0;i < n;i++)cin >> a[i];
  for(int i = 0;i < n;i++)cin >> b[i];
  for(int i = 0;i < n-1;i++)cin >> c[i];
  for(int i = 0;i < n;i++){
    res += b[a[i]-1];
    if(i < n-1 && a[i+1]-a[i] == 1)res += c[a[i]-1];
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  B - Uneven Numbers
//
//  Created by Hashizo on 2019/08/04.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef LONG_MAX
#undef LONG_MIN

#define LONG_MAX	9223372036854775807
#define LONG_MIN	(-LONG_MAX  -1)

#define ll long long

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	string n;
	cin >> n;

	ll t = 0;
	ll len = n.length();
	ll num = atol(n.c_str());

	if (len >= 6 ) {
		t = (99999 - 9999) + (999 - 99) + 9;
	}
	if (len == 5 ) {
		t = (num - 9999) + (999 - 99) + 9;
	}
	if (len == 4 ) {
		t = (999 - 99) + 9;
	}
	if (len == 3 ) {
		t = (num - 99) + 9;
	}
	if (len == 2 ) {
		t = 9;
	}
	if (len == 1 ) {
		t = num;
	}
	
	cout << t <<  endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   vector<int>W(10);
   vector<int>K(10);
   for(int i=0;i<10;i++)cin>>W.at(i);
   for(int i=0;i<10;i++)cin>>K.at(i);
   sort(W.begin(),W.end(),greater<int>());
    sort(K.begin(),K.end(),greater<int>());
    cout<<W.at(0)+W.at(1)+W.at(2)<<" "<<K.at(0)+K.at(1)+K.at(2)<<endl;
}


Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long int
#define pii pair<int, int>
#define mod 1000000007
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<string> s(n), t(m);
    fr(n) cin >> s[i];
    fr(m) cin >> t[i];
    for (int i = 0; i + m <= n; i++) for (int j = 0; j + m <= n; j++) {
        bool y = 0;
        for (int k = 0; k < m; k++) for (int l = 0; l < m; l++) {
            if (t[k][l] != s[i + k][j + l]) {
                y = 1;
                break;
            }
        }
        if (!y) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

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

int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; a++) {
    for (int b = 0; b <= B; b++) {
      for (int c = 0; c <= C; c++) {
        int total = 500*a + 100*b + 50*c;
        if (total == X) ++res;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <time.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>

using namespace std;
int main(void)
{
    long long int N, M, X;
    long long int min1 = INT_MAX;
    cin >> N >> M >> X;

    vector<vector<long long int>> vec1(N, vector<long long int>(M + 1));

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M + 1; j++)
        {
            
            cin >> vec1[i][j];
        }
    }

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1 << N); ++bit)
    {
        vector<long long int> sei(M + 1, 0);
        /* bit で表される集合の処理を書く */
        //cout << bit << endl;
        /* きちんとできていることを確認してみる */
        // bit の表す集合を求める

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

           // cout << i << endl;
            if (bit & (1 << i))
            { // i が bit に入るかどうか
                for (int r = 0; r < M + 1; r++)
                {
                    sei[r] += vec1[i][r];
                }
            }
        }
        int count = 0;
        for (int u = 1; u < M + 1; u++)
        {
            //cout << u << endl;
            if (sei[u] >= X)
            {
                count++;
            }
        }
        if (count == M)
        {
            min1 = min(min1, sei[0]);
        }
    }
    if (min1 == INT_MAX)
        cout << -1 << endl;
    else 
        cout << min1 << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

VI nums;
VI canWin;  // canWin[i] = 1 if a the player making a turn when i stones are left will win
            // canWin[i] = 0 if will lose
            // canWin[i] = 2 if not known

// true if a player making a turn when i stones are left will win
bool win(int k) {
  if (canWin[k] == 2) {
    canWin[k] = 0;
    for (int n : nums) {
      int to = k - n;
      if (to < 0) continue;
      if (!win(to)) {
        canWin[k] = 1;
        break;
      }
    }
  }
  return canWin[k];
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int n, k;
  cin >> n >> k;
  canWin.assign(k+1, 2);
  canWin[0] = 0;
  nums.resize(n);
  forx(i,n) cin >> nums[i];

  cout << (win(k) ? "First" : "Second") << nl;
  
  cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl;
  return 0;
}



Measured memory_bytes: 5376
#include <stdio.h>
#define SCA(L) scanf("%d",&L)

int main(void)
{
  int L,N,i,xw;
  xw = 0;

  SCA(L);
  int x[100],w[100];

  SCA(N);

  for (i = 0; i < N ;i++) {
      SCA(x[i]);
      SCA(w[i]);
  
      xw += x[i]*w[i];
  }

  if (xw == 0) {
     puts("0");
  } if(xw < 0) {
      printf("1\n1 %d\n",-xw);
  } if (xw > 0) {
       printf("1\n-1 %d\n",xw);
  }
 
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int n, a[100000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i], a[i]--;

    int sol = 0;
    for (int i = 1; i < n; ++i)
        if (a[i - 1] == i - 1)
            swap(a[i], a[i - 1]), sol++;
    cout << sol + (a[n - 1] == n - 1);
}


Measured memory_bytes: 640
using System;
using System.Linq;

namespace abc123
{
    class A
    {
        static void Main(string[] args)
        {
            var intArray = Input.IntArray();

            
            

            Console.WriteLine(intArray[1] * (int)(intArray[2] / intArray[0]));


        }
    }

    internal static class Input
    {
        public static int Int() => int.Parse(Console.ReadLine());

        public static string Str() => Console.ReadLine();

        public static int[] IntArray() => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

    }

}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n, sum = 0;
  vector<long> veca(n+1, 0);
  vector<long> vecb(n, 0);
  cin >> n;
  for(int i = 0; i < n + 1; i++) {
    cin >> veca.at(i);
    sum += veca.at(i);
  }
  for(int i = 0; i < n; i++) cin >> vecb.at(i);
  for(int i = 0; i < n; i++){
    if(vecb.at(i) > veca.at(i)){
      vecb.at(i) -= veca.at(i);
      veca.at(i) = 0;
      if(vecb.at(i) > veca.at(i+1)) veca.at(i+1) = 0;
      else veca.at(i+1) -= vecb.at(i);
    }
   else veca.at(i) -= vecb.at(i); //vecb.at(i) <= veca.at(i) の場合
    
  }
  for(int i = 0; i < n + 1; i++){
    sum -= veca.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 98688
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        
        // que: 七五三数(候補) (全ての桁が7 or 5 or 3)
        Queue<Long> que = new ArrayDeque<Long>();
        
        // 3, 5, 7からBFSスタート
        // (後ろの3項は、1なら3,5,7が既に登場)
        for (long i = 1; i <= 9; i++) {
            que.add(i);
        }
        
        // count: n以下の七五三数の個数
        // -> 全ての桁が7 or 5 or 3かつ、7,5,3全て登場する数
        // ex. 753, 3577735, 533333337
        int count = 0;
        while (!que.isEmpty()) {
            long num = que.poll();
            // System.out.println(num);
            count++;
            if (count == n) {
                System.out.println(num);
                return;
            }
            
            long x10 = num * 10;
            long last = num % 10;
            
            // 次の桁のパターンをキューに入れる x10+3, x10+5, x10+7
            if (last >= 1) que.add(x10 + last - 1);
            que.add(x10 + last);
            if (last < 9) que.add(x10 + last + 1);
        }
    }
}

Measured memory_bytes: 45600
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;

void insert(int);
void Inorder(Node);
void Preorder(Node);
int find(int);

Node root;

int main(){
  char s[10];
  int k, n, i;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s", s);

    if(s[0] == 'i'){
      scanf("%d", &k);
      insert(k);
    }
    else if(s[0] == 'f'){
      scanf("%d", &k);
      printf(find(k) == 1 ? "yes\n" : "no\n");
    }
    else{
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}

void insert(int k){
  Node z, x = root, y = NULL;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;

  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NULL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void Inorder(Node u){
  if(u == NULL) return;
  Inorder(u->left);
  printf(" %d", u->key);
  Inorder(u->right);
}

void Preorder(Node u){
  if(u == NULL) return;
  printf(" %d", u->key);
  Preorder(u->left);
  Preorder(u->right);
}

int find(int k){
  Node x = root;

  while(x != NULL){
    if(k == x->key)
      return 1;
    else if(k < x->key)
      x = x->left;
    else
      x = x->right;
  }
  return 0;
}

Measured memory_bytes: 19348
#include<bits/stdc++.h>
using namespace std;
int main(){
  int L;
  while(cin>>L,L!=0){
    int chokin=0,month=0;
    for(int i=1;i<=12;i++){
      int syuueki,syouhi;
      cin>>syuueki>>syouhi;
      chokin+=(syuueki-syouhi);
      if(month!=0)
	continue;
      if(chokin>=L)
	month=i;
    }
    if(month==0)
      cout<<"NA"<<endl;
    else
      cout<<month<<endl;
  }
  return 0;
}

Measured memory_bytes: 3044
n = int(input())
xl = [list(map(int, input().split())) for i in range(n)]
lr = list(map(lambda x:[x[0]-x[1], x[0]+x[1]], xl))
lr.sort(key=lambda x:x[1])
#print(lr)
limit = lr[0][1]
ans=n
for i in range(1, n):
  if lr[i][0]<limit:
    ans-=1
  else:
    limit=lr[i][1]
print(ans)

Measured memory_bytes: 43576
from math import sqrt
I_list=[]
prime_list=[]
while True:
	try:
		I_list.append(int(input()))
	except:
		break
I_max=max(I_list)
search_set={x for x in range(2,I_max+1)}


p=-1
while p<=sqrt(I_max):
	p=min(search_set)
	prime_list.append(p)
	search_set={x for x in search_set if x%p !=0 }

search_list=sorted(list(search_set))
prime_list+=search_list

#print(prime_list)


for i in I_list:
	lower_set={j for j in prime_list if j<=i } 
#	print(lower_set)
	print(len(lower_set))

Measured memory_bytes: 103600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll h,w;
ll direction2[4][2]={{1,0},{0,1},{0,-1},{-1,0}};
bool valid(int a,int b)
{
    if(a>=1&&a<=h&&b>=1&&b<=w)return true;
    else return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    map<string , ll>m;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

static char alp[27] = "abcdefghijklmnopqrstuvwxyz";

char findAlp(string &s){
	char ret;
	int C[27] = {0};
	for(int i=0; i<27; i++){
		C[i] = 0;
	}
	for(int i=0; i<s.size(); i++){
		unsigned char c = (unsigned char)s[i] - (unsigned char)'a' ;
		C[c]++;
	}
	for(int i=0; i<26; i++){
		if(C[i] == 0){
			ret = alp[i];
			break;
		}
	}
	return ret;
}

void dfs(int n, map<string, int> &v){
	if(n == 1){
		v.insert(make_pair("a", 1));
		return ;
	}
	if(n == 2){
		v.insert(make_pair("aa", 1));
		v.insert(make_pair("ab", 1));
		return ;
	}

	map<string, int> w = v;
	dfs(n - 1, w);
	for(auto itr = w.begin(); itr != w.end(); itr++){
		string s = itr->first;
		for(int j=0; j<s.size(); j++){
			string s1 = itr->first;
			//どれか1つと同じ場合
			s1.push_back(itr->first[j]);
			v.insert(make_pair(s1, 1));
			//どれとも異なる場合、sに含まれる文字以外の文字で最初のアルファベット
			string s2 = itr->first;
			char c = findAlp(s2);
			s2.push_back(c);
			v.insert(make_pair(s2, 1));
		}
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	map<string, int> M;
	dfs(N, M);

	for(auto itr = M.begin(); itr != M.end(); itr++){
		string s = itr->first;
		printf("%s\n", s.c_str());
	}
	return 0;
}


Measured memory_bytes: 14264
' Imports System.Collections.Generic
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim S, W As Integer
        Dim arr() As String
        arr = Split(Console.ReadLine())
        S = arr(0) : W = arr(1)
        Console.WriteLine(If(S <= W, "unsafe", "safe"))
        Return
    End Sub
End Class


Measured memory_bytes: 28316
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+5;
int n,m,cnt;
vector<int> g[MAXN] ;
bool used[MAXN] ;
vector<int> comp ;

void dfs(int v) {
    used[v] = true ;
    comp.push_back(v);
    for (size_t i = 0; i < (int) g[v].size(); ++i) {
        int to = g[v][i];
        if (!used[to])
            dfs(to);
    }
}

void find_comps() {
    for (int i = 0; i < n ; ++i)
        used [i] = false;
    for (int i = 0; i < n ; ++i)
        if (!used[i]) {
            comp.clear();
            dfs(i);
            cnt++;
           /* cout << "Component:" ;
            for (size_t j = 0; j < comp.size(); ++j)
                cout << ' ' << comp[j];
            cout << endl ;*/
        }
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int u, v; scanf("%d%d", &u, &v);
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	find_comps();
	printf("%d\n", cnt-1);
	return 0;
}

Measured memory_bytes: 10348
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 200005;
int A[MAX_N],B[MAX_N],C[MAX_N],D[MAX_N];
vector<P> v,v2;

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		cin >> A[i];
		C[A[i]]++;
	}
	rep(i,N)
	{
		cin >> B[i];
		D[B[i]]++;
	}
	rep(i,MAX_N)
	{
		if (C[i] + D[i] > N)
		{
			cout << "No" << endl;
			return 0;
		}
	}

	rep(i,N+1)
	{
		C[i+1] += C[i];
		D[i+1] += D[i];
		//cout << C[i+1] << " " << D[i+1] << endl;
	}

	int ans = 0;
	rep(i,N)
	{
		ans = max(ans,C[i+1]-D[i]);
	}
	cout << "Yes" << endl;
	rep(i,N)
	{
		if (i != 0) cout << " ";
		cout << B[(i-ans+N) % N];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 6768