akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    int y,m,d,sum;
    while(cin >> y >> m >> d){
        sum = y*10000 + m*100 + d;
        if(sum < 18680908) cout << "pre-meiji" << endl;
        else if(sum <= 19120729) cout << "meiji" << " " << y-1867 << " " << m << " " << d << endl;
        else if(sum <= 19261224) cout << "taisho" << " " << y-1911 << " " << m << " " << d << endl;
        else if(sum <= 19890107) cout << "showa" << " " << y-1925 << " " << m << " " << d << endl;
        else cout << "heisei" << " " << y-1988 << " " << m << " " << d << endl;
    }
}

Measured memory_bytes: 1164
n=int(input())
A=list(map(int,input().split()))
q=int(input())
m=list(map(int,input().split()))

B={0}
C={0}
for num in A:
    for item in B:
        C.add(item+num)
        #print(num,C)
    B |=C
#print(B)

    
for num in m:
  if num in C:
    print("yes")
  else:
    print("no")


Measured memory_bytes: 5764
fun main(args: Array<String>){
  val input = readLine()!!.split(" ")
  val N = input[0].toInt()
  val K = input[1].toInt()
  val Q = input[2].toInt()
  val A = Array(Q){ readLine()!!.toInt() }
  val members = IntArray(N)

  for( a in A )
    members[a-1]++

  for( m in members )
    if( 0 < K-(Q-m) )
      println("Yes")
    else
      println("No")
}


Measured memory_bytes: 45928
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
const ll M = 1000000007;
 
vector<ll> fac(3000000); //n!(mod M)
vector<ll> ifac(3000000); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

ll hcomb(int P_,int Q_) { return (P_==0&&Q_==0)?1:comb(P_+Q_-1,Q_);}

int main(){
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<3000000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    ll K; string S; cin >> K >> S;
    ll n = sz(S);
    ll N = n + K;
    ll ans = 0;
    rep(i, 0, K+1){
        ans += mpow(25, i)*mpow(26,K-i)%M*hcomb(n, i)%M;
        ans %= M;
    }
    prt(ans);
}



Measured memory_bytes: 52220
# -*- coding: utf-8 -*-
"""
http://abc064.contest.atcoder.jp/tasks/abc064_a

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    r, g, b = map(int, input().split())
    num = (r * 100) + (g * 10) + b
    if num % 4 == 0:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 3060
from collections import defaultdict
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
dic = defaultdict(int)
for i in range(N):
    dic[a[i] - 1] += 1
    dic[a[i]] += 1
    dic[a[i] + 1] += 1
print(max(dic.values()))

Measured memory_bytes: 62876
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N, T;
	int A[3010];
	int B[3010];

	cin >> N >> T;
	for(int i = 0; i < N; i++)
		cin >> A[i] >> B[i];
	
	int dp1[3010][3010];
	int dp2[3010][3010];
	for(int i = 0; i < N; i++)
	{
		for(int t = 0; t < T; t++)
		{
			dp1[i+1][t] = max(dp1[i+1][t], dp1[i][t]);
			if(t + A[i] < T)
				dp1[i+1][t+A[i]] = max(dp1[i+1][t+A[i]], dp1[i][t]+B[i]);
		}
	}
	for(int i = N; i > 0; i--)
	{
		for(int t = 0; t < T; t++)
		{
			dp2[i-1][t] = max(dp2[i-1][t], dp2[i][t]);
			if(t + A[i-1] < T)
				dp2[i-1][t+A[i-1]] = max(dp2[i-1][t+A[i-1]], dp2[i][t]+B[i-1]);
		}
	}

	int ans = 0;
	for(int i = 0; i < N; i++)
		for(int t = 0; t < T; t++)
			ans = max(ans, dp1[i][t] + dp2[i+1][T-1-t] + B[i]);

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



Measured memory_bytes: 74188
N = gets.to_i

d = gets.chomp.split.map(&:to_i)

sum = 0

k = 0

i = k  + 1

while k < N do
	if i < N
       sum += d[k] * d[i]
       i +=1
    else
   	   k += 1
   	   i = k + 1
    end
end

puts sum

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;

int main() {
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	int w = 0;
	int q = 0;
	rep(i, 0, s.size()) {
		string h;
		h = s[i];
		if (h == "-") {
			w = i + 1;
			break;
		}
		q++;
	}
	if (q != a) {
		cout << "No\n";
		return 0;
	}
	q = 0;
	rep(i, w, s.size()) {
		string h;
		h = s[i];
		if (h != "-") {
			q++;
		}
	}
	if (q != b) {
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
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*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=998244353;
const int iv2=499122177;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int fac[1000010],inv[1000010],f[1000010],cnt[1000010];
int main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	fac[0]=1;
	for(int i=1;i<=1000000;i++)fac[i]=1LL*fac[i-1]*i%mod;inv[1000000]=power(fac[1000000],mod-2);
	for(int i=1000000;i>=1;i--)inv[i-1]=1LL*inv[i]*i%mod,f[i]=1LL*inv[i]*fac[i-1]%mod;
	int n=read();
	for(int i=1;i<=n;i++)cnt[read()]++;
	for(int i=1;i<=1000000;i++)
	{
		for(int j=i+i;j<=1000000;j+=i)f[j]=dec(f[j]-f[i]);
	}
	int ans=0;
	for(int i=1;i<=1000000;i++)
	{
		int sum=0,tot=0;
		for(int j=i;j<=1000000;j+=i)sum=ad(sum+1LL*cnt[j]*j%mod),tot=ad(tot+1LL*cnt[j]*j%mod*j%mod);
		ans=ad(ans+1LL*dec(1LL*sum*sum%mod-tot)*iv2%mod*f[i]%mod);
	}pr2(ans);
	return 0;
}

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

int n;

int main() {
    cin >> n;
    vector<int> a(3);
    a.at(0) = n % 10;
    n -= a.at(0);
    a.at(1) = (n / 10) % 10;
    n -= a.at(1) * 10;
    a.at(2) = n / 100;
    n = 0;
    for (int i = 0; i < 3; i++) {
        if (a.at(i) == 1) {
            a.at(i) = 9;
        }
        else {
            a.at(i) = 1;
        }
    }
    n = a.at(0) + a.at(1) * 10 + a.at(2) * 100;
    cout << n << endl;
    return 0;
}


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

using namespace std;

int main() {
	int N;
	cin >> N;
	int n = 1;
	for (int i = 0; i < N; ++i) { n *= 2; }
	vector<int> a(n);
	for (int i = 0; i < n; ++i) { cin >> a[i]; }
	sort(a.rbegin(), a.rend());

	vector<int> v;
	v.push_back(a[0]);
	multiset<int> st;
	for (int i = 1; i < n; ++i) { st.insert(a[i]); }
	st.insert(0);

	for (int x = 0; x < N; ++x) {
		vector<int> t;
		for (int i = 0; i < v.size(); ++i) {
			auto itr = prev(st.lower_bound(v[i]));
			if (*itr < 1) { continue; }
			t.push_back(*itr);
			st.erase(itr);
		}
		for (int i = 0; i < t.size(); ++i) {
			v.push_back(t[i]);
		}
	}

	if (st.size() > 1) { cout << "No" << endl; }
	else { cout << "Yes" << endl; }

	return 0;
}


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




int main(){
    ll a,b,q;cin>>a>>b>>q;
    vector<ll> s(a+2),t(b+2);
    s[0]=-1e18;t[0]=-1e18;
    rep(i,0,a)cin>>s[i+1];
    rep(i,0,b)cin>>t[i+1];
    s[a+1]=1e18;t[b+1]=1e18;
    rep(i,0,q){
        ll x;cin>>x;
        ll sr=lower_bound(s.begin(),s.end(),x)-s.begin();
        ll sl=sr-1;
        ll tr=lower_bound(t.begin(),t.end(),x)-t.begin();
        ll tl=tr-1;
        
        sr=s[sr];
        sl=s[sl];
        tr=t[tr];
        tl=t[tl];
        vector<ll> t;
        t.push_back(max(sr-x,tr-x));
        t.push_back(max(x-sl,x-tl));
        t.push_back(2*(x-sl)+tr-x);
        t.push_back(2*(x-tl)+sr-x);
        t.push_back(2*(sr-x)+x-tl);
        t.push_back(2*(tr-x)+x-sl);
        sort(t.begin(),t.end());
        cout<<t[0]<<endl;
    }
    
}
    









Measured memory_bytes: 2944
#include <stdio.h>

int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    int x = (a + b) / 2;
    if ((a + b) % 2 == 0){
        printf("%d\n", x);
    }else{
        printf("IMPOSSIBLE\n");
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  multiset<ll>s;
  multiset<ll>::iterator it;
  ll temp,tc,q,x,l,r;
  cin>>tc;
  while(tc--)
  {
    cin>>q;
    if(q==0)
    {
      cin>>temp;
      s.insert(temp);
      cout<<s.size()<<endl;
    }
    else if(q==1)
    {
      cin>>x;
      cout<<s.count(x)<<endl;
    }
    else if(q==2)
    {
      cin>>x;
      s.erase(x);
    }
    else
    {
      cin>>l>>r;
			for(it=s.lower_bound(l);it!=s.upper_bound(r);it++){
			cout<<(*it)<<endl;
    }
  }
}
}



Measured memory_bytes: 12288
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define gcd __gcd
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// ve<ve<要素の型>> 変数名(縦, ve<要素の型>(横, 初期値))

int main() {
  int A, B;
  ci(A, B);
  if(B % A == 0){
    co(A + B);
  }
  else{
    co(B - A);
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    int n; cin >> n;
    set<int> s;
    s.insert(n);

    int cnt = 1;
    while (true) {
        cnt++;
        if (n % 2 == 0) n /= 2;
        else n = 3 * n + 1;

        auto it = s.find(n);
        if (it != s.end()) break;
        else s.insert(n);
    }
    cout << cnt << endl;
}


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

#define N_MAX 100000
#define NAME_LEN 10
#ifdef DEBUG
#define  DPRINT printf
#else
#define DPRINT(...)
#endif

struct q {
	int val;
	struct q *prev;
	struct q *next;
};

struct q *
find(struct q *head, int arg)
{
	struct q *a;
	for (a = head; a != NULL; a = a->next)
		if (a->val == arg)
			break;

	return a;
}

int
main(void)
{
	/* head <- prev [a] next -> tail */
	int i, n;
	struct q *head = NULL;
	struct q *tail = NULL;
	char cmd[16];

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf ("%s", cmd);
		if (cmd[0] == 'i') {
			struct q *a = (struct q *)malloc(sizeof(struct q));

			if (a == NULL)
				return 1;

			DPRINT("insert\n");

			scanf("%d", &a->val);
			if (head == NULL) {
				head = a;
				tail = a;
				a->prev = NULL;
				a->next = NULL;
			} else {
				a->prev = NULL;
				a->next = head;
				head->prev = a;
				head = a;
			}
		} else if (cmd[6] == '\0') {
			int x;
			struct q *a;

			DPRINT("delete\n");

			scanf("%d", &x);
			a = find(head, x);
			if (a == NULL)
				continue;

			struct q *pa = a->prev;
			struct q *na = a->next;
			if (a == head) {
				head = na;
				if (na != NULL)
					na->prev = NULL;
			}
			if (a == tail) {
				tail = pa;
				if (pa != NULL)
					pa->next = NULL;
			}
			if (pa != NULL)
				pa->next = na;
			if (na != NULL)
				na->prev = pa;
			free(a);
		} else if (cmd[6] == 'F') {
			struct q *a = head;

			DPRINT("deleteFirst\n");

			if (a != NULL) {
				if (head == tail) {
					head = tail = NULL;
				} else {
					a->next->prev = NULL;
					head = a->next;
				}
				free(a);
			}
		} else if (cmd[6] == 'L') {
			struct q *a = tail;

			DPRINT("deleteLast\n");

			if (a != NULL) {
				if (head == tail) {
					head = tail = NULL;
				} else {
					a->prev->next = NULL;
					tail = a->prev;
				}
				free(a);
			}
		}
	}

	for (;head != NULL; head = head->next) {
		printf("%d%s", head->val, head->next == NULL ? "" : " ");
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 32924
#include <iostream>

using namespace std;

int a, b;

int main(void)
{
	cin >> a >> b;
	
	int keta = 1, tmp = b;
	for(;tmp;tmp/=10) keta *= 10;
	
	int v = a * keta + b;
	for(int i = 1; i <= 1000; i++){
		if(v == i*i){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[2009][2009];
int c1[2009][2009];
int c2[2009][2009];
int cn1(int s, int x1, int x2){
    return c1[x2 + 600][s - x2 + 600] - c1[x1 - 1 + 600][s - x1 + 1 + 600];
}
int cn2(int s, int x1, int x2){
    return c2[x2 + 600][-s + x2 + 600] - c2[x1 - 1 + 600][-s + x1 - 1 + 600];
}
int f(int x, int y){
    if (x>=0 && y >=0 && a[x][y]) return 1;
    return 0;
}
main(){
   int H, W;
   cin >> H >> W;
   for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            char c;
            cin >> c;
            if(c == '#') a[i][j] = 1;
        }
   }
   for(int i = -W-1; i <= H + H + W+1; i++){
        for(int j = - H-1; j <= H + W + W+1; j++){

            c1[i + 600][j+ 600] =  c1[i - 1+ 600][j + 1+ 600];
            c2[i+ 600][j+ 600] =  c2[i - 1+ 600][j - 1+ 600];
            if(i >=0 && j>=0 && a[i][j]) c1[i + 600][j + 600] ++,
                                  c2[i + 600][j + 600] ++;
        }
   }
   int ans = 0;
   for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            for(int d = 1; d <= H + W ; d++){
                int c1 = f(i, j + d);
                int c2 = f(i + d, j);
                int c3 = f(i, j - d);
                int c4 = f(i - d, j);
                int s3 = cn1(i + j + d, i, i + d);
                int s4 = cn2(i + d - j, i, i + d);
                int s1 = cn1(i + j - d, i - d, i);
                int s2 = cn2(i - j - d, i - d, i);
                if(c1 && c2) ans += s1;
                if(c2 && c3) ans += s2;
                if(c3 && c4) ans += s3;
                if(c4 && c1) ans += s4;
                if(c1 + c2 + c3 +c4 == 4) ans -= 4;
                if(c1 + c2 + c3 +c4 == 3) ans --;
            }
        }
   }
   cout<< ans <<endl;
}



Measured memory_bytes: 26880
N, M = map(int, input().split())

ans = ['a'] * N

for m in range(M):
    s, c = map(int, input().split())
    if ans[s - 1] == 'a' or ans[s - 1] == str(c):
        ans[s - 1] = str(c)
    else:
        print(-1)
        exit()

if ans[0] == 'a' and N != 1:
    ans[0] = '1'

for i in range(N):
    if ans[i] == 'a':
        ans[i] = '0'

ans = int(''.join(ans))
if len(str(ans)) == N:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
    cin >> S >> T;
  int A = 0;
  if(S[0] == T[0])A++;
  if(S[1] == T[1])A++;
  if(S[2] ==T[2])A++;
    cout << A << endl;
}

Measured memory_bytes: 256
from math import *
A,B = map(int,input().split())

#A = x*.08
#x1 = A / 0.08
#x2 = B / 0.1

x = 0
ans = -1
while x <= 2000:
    x += 1
    if floor(x*0.08) == A and floor(x*0.1) == B:
        ans = x
        break

print(ans)

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){
  string s;
  cin >> s;
  int x = s[0] - 'A';
  if(x <= 25){
    cout << 'A' << endl;
  }else{
    cout << 'a' << endl;
  }

  return 0;
} 



Measured memory_bytes: 3620
#
# abc048 b
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4 8 2"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """0 5 1"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """9 9 2"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """1 1000000000000000000 3"""
        output = """333333333333333333"""
        self.assertIO(input, output)


def resolve():
    a, b, x = map(int, input().split())

    if a % x == 0:
        print(b//x - a//x+1)
    else:
        print(b//x - a//x)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16140
n=int(input())
a=list(map(int,input().split()))
anslist=[]
for i in range(n):
    b=a[i]
    c=0
    if b%2==1:
        break
    else:
        while b%2==0:
            c+=1
            b=b//2
        else:
            anslist.append(c)
if len(anslist)==n:
    print(min(anslist)) 
else:
    print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m; cin >> n >> m;
    vvint g(n);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> q;
    q.push(0);
    vector<bool> used(n);
    used[0] = true;
    vint ans(n);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for (int n_v : g[v]) {
            if (used[n_v]) continue;
            ans[n_v] = v+1;
            q.push(n_v);
            used[n_v] = true;
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 10124
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int x, y; std::cin >> x >> y;
  int ans = 0;
  for (int z : {x, y}) {
    if (z == 3) ans += 100000;
    if (z == 2) ans += 200000;
    if (z == 1) ans += 300000;
  }
  if ((x==1) && (y==1)) {
    ans += 400000;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    #define double long double
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    void chmax(int &x,const ll y) {x=(x>y?x:y);}
    void chmin(int &x,const ll y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):0;}
    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;
        while(e)
        {
            if(e&1) ans=ans*x%MOD;
            x=x*x%MOD;e>>=1;
        }
        return ans;
    }
    inline int invm(int x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    ll fac[N],facinv[N];
    int C(int n,int m){if(n<m)puts("pp");return fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
    int g(int n,int m){return C(n+m-1,m-1);}

    int n,m;
    int f(int R,int a,int b)
    {
        ll ans=0;
        for(int i=0;i<=m;i++)
        {
            ll tmp=R-i*ll(a+1)-ll(n-m)*b;if(tmp<0) break;
            ans=(ans+ll(i&1?MOD-1:1)*C(m,i)%MOD*g(tmp,n+1))%MOD;
        }
        return ans;
    }
    int solve(int R)
    {
        ll ans=0;
        for(int t=1;t<=R;t++) ans=mm(ans+mm( f(R,t-1,t)+MOD-f(R,t-1,t+1) ));
        return mm(g(R,n+1)+MOD-ans*C(n,m)%MOD);
    }
    void main()
    {
        fac[0]=1;for(int i=1;i<N;i++) fac[i]=fac[i-1]*i%MOD;
        facinv[N-1]=invm(fac[N-1]);for(int i=N-2;i>=0;i--) facinv[i]=facinv[i+1]*(i+1)%MOD;

        int l,r;scanf("%d%d%d%d",&n,&m,&l,&r);
        m=n-m;//debug……
        write((solve(r)+MOD-solve(l-1))%MOD);
    }
};
int main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 15872
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define pb push_back
#define FOR(i,S,E) for(int i=S; i<E; i++)
#define rii(x,y) scanf("%d%d", &x, &y)
#define fst first
#define snd second
#define mp make_pair

const int MAXN = 3e5+10, MAXM = 1e5+10;


class FenwickTree {
private: vi ft;
public: FenwickTree(int n) {ft.assign(n+1, 0);}// init n+1 0s
	// Least Significant One-Bit
	static int LSOne(int i) {
		return (i & (-i));
	}
	// range sum query
	int rsq(int b) {
		int sum = 0;
		for(; b; b -= LSOne(b))
			sum += ft[b];
		return sum;
	}
	// range sum query in [a, b]
	int rsq(int a, int b) {
		return rsq(b) - (a == 1 ? 0 : rsq(a-1));
	}
	// adjusts value of the k-th element by v (v can be +ve/inc or -ve/dec)
	void upd(int k, int v) {
		for(; k < (int)ft.size(); k += LSOne(k)) {
			ft[k] += v;
		}
	}
};

bool comp(ii &a, ii &b) {
    return a.snd-a.fst < b.snd-b.fst;
}

int N, M;
bool debug = 0;
vii query;
int main(int argc, char *argv[]) {
    if (argc > 1) debug = argv[1][0] - '0';
    rii(N, M);
    FenwickTree posR(M), posL(M);
    FOR(i,0,N) {
        int l, r;
        rii(l, r);
        query.pb({l,r});
    }
    sort(query.begin(), query.end(), comp);
    int idx=0;
    FOR(k,1,M+1) {
        if (debug)
            printf("k: %d\n", k);
        // actualizamos los BIT
        for(; idx<N; idx++) {
            ii p = query[idx];
            if (p.snd-p.fst+1 > k) break;
            posR.upd(p.snd, 1);
            posL.upd(p.fst, 1);
        }
        int ans=0;
        for(int i=k; i<=M; i += k) {
            ans += posL.rsq(i) - posR.rsq(i-1);
            if (debug)
                printf("\tans: %d\n", ans);
        }
        printf("%d\n", ans+N-idx);
    }
}


Measured memory_bytes: 7280
h,w = map(int, input().split())
l = [[] for _ in range(h+2)]
l[0] = list("."*(w+2))
l[h+1] = list("."*(w+2))
for i in range(1,h+1):
  l[i] = list(("." + input() + "."))
for j in range(1,h+1):
  for k in range(1,w+1):
    c = []
    if l[j][k] == ".":
      c += [l[j-1][k-1], l[j-1][k], l[j-1][k+1], l[j][k-1], l[j][k+1], l[j+1][k-1], l[j+1][k], l[j+1][k+1]]
      l[j][k] = str(c.count("#"))
for i in range(1,h+1):
  ln = l[i][1:w+1]
  s = "".join(ln)
  print(s)

Measured memory_bytes: 9240
H, W = map(int,input().split())
A = [list(map(int,input().split())) for k in range(H)]
N = 0
B = []
for h in range(H):
    for w in range(W-1):
        if A[h][w]%2==1:
            N += 1
            B.append([h+1,w+1,h+1,w+2])
            A[h][w] -= 1
            A[h][w+1] += 1

for h in range(H-1):
    if A[h][W-1]%2==1:
        N += 1
        B.append([h+1,W,h+2,W])
        A[h][W-1] -= 1
        A[h+1][W-1] += 1

print(N)
for b in B:
    print(" ".join(map(str,b)))

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

int main(){
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) cin >> a[i];
  int m; cin >> m;
  for (int i = 0; i < m; i ++) {
    int t; cin >> t;
    t --;
    if ((a[t] + 1 == a[t + 1] && t < n) || a[t] == 2019) continue;
    a[t] ++;
  }

  for (int i = 0; i < n; i ++) {
    cout << a[i] << endl;
  }
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s,i;
  i=0;
  cin >> s;
  if((s-100) >= 0){ i++;
    if((s-110) >= 0){ i++;
      if((s-111) >= 0){ i++;
      }
    }else if(s-101 >= 0){i++;}
  }else if(s-10 >= 0){ i++;
          if(s-11 >= 0){ i++;
            }
        }else if(s-1 >= 0){ i++;}
  cout << i <<endl;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int h, w, d; cin >> h >> w >> d;
    vector<pair<int, int>> p(h * w + 10);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int a; cin >> a;
            p[a] = make_pair(i + 1, j + 1);
        }
    }

    vector<int> s(h * w + 10, 0);
    for (int i = 1; i <= d; ++i) {
        int t = i;
        while (t + d < h * w + 10) {
            s[t + d] = s[t] + abs(p[t + d].first - p[t].first) + abs(p[t + d].second - p[t].second);
            t += d;
        }
    }

    int q; cin >> q;
    for (int i = 0; i < q; ++i) {
        int l, r; cin >> l >> r;

        if (l == r) {
            cout << 0 << endl;
        } else {
            cout << s[r] - s[l] << endl;
        }
    }
}

Measured memory_bytes: 2176
//============================================================================
// Name        : AOJ1154.cpp
// Author      : mizo0203
// Version     :
// Copyright   : Your copyright free
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <stdio.h>
#include <algorithm>

using namespace std;

int num = 300000;
bool array[300000];
int n;

void set_prime_number() {

  for (int i = 2; i < num; i++) {
    if (i % 7 == 1 || i % 7 == 6)  {
      array[i] = true;
    }
  }
  for (int i = 2; i < num; i++) {
    if (!array[i]) continue;
    for (int j = i * 2; j < num; j += i) {
      array[j] = false;
    }
  }

}

bool input() {
  scanf("%d", &n);
  if (n == 1) return false;
  return true;
}

int main() {

  set_prime_number();
  while(input()) {
    printf("%d:", n);
    for (int i = 0; i <= n; i++) {
      if (array[i] && n % i == 0) {
        printf(" %d", i);
      }
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define vi vector < ll  int >
        #define CLR(a) memset((a),0,sizeof(a))
        #define mp make_pair
        #define hell 1000000007
        using namespace std;

        void solve()
        {
            ll i,j=0,r=200,p,q,k=0,ans=0,d,y=0,x,h,flag=0,n,m=0,a=hell,b=hell,id,c,h1,h2,a1,b1,w;
            cin>>n;
            vector < ll int > v(n+1),v2(n);
            rep(i,0,n+1) cin>>v[i];
            rep(i,0,n) cin>>v2[i];
            rep(i,0,n)
               {    //if(i+1<n)
                    y+=max(0LL,min(v[i],v2[i]));
                    if(v[i]>0) v2[i]-=v[i];
                    if(v2[i]>=0) { y+=max(0LL,min(v2[i],v[i+1])); v[i+1]-=v2[i];}

               }

               cout<<y;





        }



        signed main()
        {
            ios::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            int t=1;
            //cin>>t;
            while(t--)
            solve();
        }


Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>

using namespace std;

struct TRAMP{
	char mark;
	int number;
};

int main(){
	int n,min;
	char buf[3];
	scanf("%d",&n);

	TRAMP selectArray[n],bubbleArray[n];

	for(int i = 0; i < n; i++){
		scanf("%s",buf);
		selectArray[i].mark = buf[0];
		selectArray[i].number = buf[1] - '0';
		bubbleArray[i] = selectArray[i];
	}

	for(int i = n-1; i >= 0; i--){
		for(int j = 0; j < i; j++){
			if(bubbleArray[j].number > bubbleArray[j+1].number) swap(bubbleArray[j], bubbleArray[j+1]);
		}
	}

	for(int i = 0; i < n-1; i++){
		min = i;
		for(int j = i+1; j < n; j++){
			if(selectArray[j].number < selectArray[min].number){
				min = j;
			}
		}
		if(i != min){
			swap(selectArray[i],selectArray[min]);
		}
	}

	for(int i = 0; i < n-1; i++) printf("%c%d ",bubbleArray[i].mark,bubbleArray[i].number);
	printf("%c%d\n",bubbleArray[n-1].mark,bubbleArray[n-1].number);
	printf("Stable\n");
	for(int i = 0; i < n-1; i++) printf("%c%d ",selectArray[i].mark,selectArray[i].number);
	printf("%c%d\n",selectArray[n-1].mark,selectArray[n-1].number);

	int p;
	for(p=0; p < n; p++){
		if(selectArray[p].number != bubbleArray[p].number || selectArray[p].mark != bubbleArray[p].mark)
			break;
	}
	if(p == n){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}

	return 0;
}


Measured memory_bytes: 2708
M=1e6,B[3000000],*N;m,X,n,i;main(p){for(N=B+M;++p<M*2;N[p]=p<M?X+=!N[p]:X)for(m=p;!N[p]&m+p<M;)N[m+=p]=1;for(;~scanf("%d",&i);n&&printf("%d\n",X))for(n=X=-i;i--;X+=N[p+m]-N[p-m-1])scanf("%d%d",&p,&m);}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll a = 0, n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0;
string s;
char c;
bool flag;

//----------------------------------------------------------------------



int main(void) {
  ll x, y;
  vll xll, yll;
  vb x1(40100, false), x2(40100, false), y1(40100, false), y2(40100, false);
  bool flag2 = true;

  cin >> s;
  cin >> x >> y;

  for (ll i = 0;s[i] != 'T' && i < s.size();i++) {
	cnt++;
  }

  x -= cnt;
  flag = true;
  x1[20000] = true;
  y1[20000] = true;

  FOR(i, cnt, s.size()) {
	if (s[i] == 'T' && flag == true) {
	  yll.push_back(0);
	  flag = false;
	}
	else if (s[i] == 'T' && flag == false) {
	  xll.push_back(0);
	  flag = true;
	}
	else if (s[i] == 'F' && flag == true) {
	  xll[xll.size() - 1]++;
	}
	else if (s[i] == 'F' && flag == false) {
	  yll[yll.size() - 1]++;
	}
  }

  flag = true;

  FOR(i, 0, xll.size()) {
	if (flag == true) {
	  FOR(j, 0, 40100) {
		if (x1[j] == true) {
		  x2[j + xll[i]] = true;
		  x2[j - xll[i]] = true;
		}
	  }
	  FOR(j, 0, 40100) {
		x1[j] = false;
	  }
	  flag = false;
	  continue;
	}

	if (flag == false) {
	  FOR(j, 0, 40100) {
		if (x2[j] == true) {
		  x1[j + xll[i]] = true;
		  x1[j - xll[i]] = true;
		}
	  }
	  FOR(j, 0, 40100) {
		x2[j] = false;
	  }
	  flag = true;
	  continue;
	}
  }

  FOR(i, 0, yll.size()) {
	if (flag2 == true) {
	  FOR(j, 0, 40100) {
		if (y1[j] == true) {
		  y2[j + yll[i]] = true;
		  y2[j - yll[i]] = true;
		}
	  }
	  FOR(j, 0, 40100) {
		y1[j] = false;
	  }
	  flag2 = false;
	  continue;
	}

	if (flag2 == false) {
	  FOR(j, 0, 40100) {
		if (y2[j] == true) {
		  y1[j + yll[i]] = true;
		  y1[j - yll[i]] = true;
		}
	  }
	  FOR(j, 0, 40100) {
		y2[j] = false;
	  }
	  flag2 = true;
	  continue;
	}
  }

  if (flag == true) {
	if (x1[20000 + x]) {
	}
	else {
	  cout << "No" << endl;
	  return 0;
	}
  }
  else {
	if (x2[20000 + x]) {
	}
	else {
	  cout << "No" << endl;
	  return 0;
	}
  }

  if (flag2 == true) {
	if (y1[20000 + y]) {
	  cout << "Yes" << endl;
	  return 0;
	}
	else {
	  cout << "No" << endl;
	  return 0;
	}
  }
  else {
	if (y2[20000 + y]) {
	  cout << "Yes" << endl;
	  return 0;
	}
	else {
	  cout << "No" << endl;
	  return 0;
	}
  }

  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "";
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) == '1') {
        ans += "9";
      } else {
        ans += "1";
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    ll k;
    cin>>s>>k;
    vector<string> v;
    rep(i,(ll)s.size()){
        rep2(j,1,k+1){
            string t=s.substr(i,j);
            // cout<<i<<j<<t<<endl;
            v.pb(t);
        }
    }
    sort(all(v));
    ERASE(v);
    /*
    for(auto i:v){
        cout<<i<<endl;
    }
    */
   cout<<v[k-1]<<endl;

    return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <math.h>
 
using namespace std;
 
int main(){

  	string input;
	while(cin >> input){
    	if(input=="0")
          break;
    
      	int sum=0;
    	for(int i=0; i<input.size(); i++){
        	int number = input.at(i) - 48;
          	sum += number;
        }
      	cout << sum << endl;
      	
    }

  return 0;
}


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

using namespace std;

typedef long long ll;

int main(int argc, const char *argv[]) {
  int n, W;
  cin >> n >> W;
  vector<vector<ll>> a(4, vector<ll>(1, 0));
  ll w1 = 0;
  for (int i = 0; i < n; i++) {
    int w, v;
    cin >> w >> v;
    if (i == 0) {
      w1 = w;
    }
    a[w - w1].push_back(v);
  }
  for (int i = 0; i < 4; i++) {
    sort(a[i].begin() + 1, a[i].end(), greater<ll>());
    for (int j = 1; j < (int)a[i].size(); j++) {
      a[i][j] += a[i][j - 1];
    }
  }
  ll ans = 0;
  for (int i = 0; i < (int)a[0].size(); i++) {
    for (int j = 0; j < (int)a[1].size(); j++) {
      for (int k = 0; k < (int)a[2].size(); k++) {
        for (int h = 0; h < (int)a[3].size(); h++) {
          if ((i + j + k + h) * w1 + j + k * 2 + h * 3 <= W) {
            ans = max(ans, a[0][i] + a[1][j] + a[2][k] + a[3][h]);
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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


int main()
{
	int a,b;  cin>>a>>b;
	
	if(a>b){
		cout<<a+(a-1)<<endl;
	}
	else if(a<b){
		cout<<b+(b-1)<<endl;
	}
	else 
	cout<<a+b<<endl;
     
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 2147483647;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);
const ll LLMAX = 9223372036854775805;

int main(){
    int n,m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n),b(m);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    vector<ll> sa(n+1,0),sb(m+1,0);
    for(int i=0;i<n;i++){
        sa[i+1] = a[i] + sa[i];
    }
    for(int i=0;i<m;i++){
        sb[i+1] = b[i] + sb[i];
    }
    int ans = -1;
    for(int i=0;i<=n;i++){
        if(k - sa[i] < 0) continue;
        auto position = upper_bound(sb.begin(),sb.end(),k - sa[i]);
        int idx_lower = position - sb.begin();
        //cout << sa[i] << " " << sb[idx_lower] << endl;
        //cout << idx_lower << endl;
        idx_lower--;
        int cnt = i + idx_lower;
        //cout << cnt << endl;
        ans = max(ans,cnt);
    }
    cout << ans << endl;

}

Measured memory_bytes: 9528
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(a, n) for (int i = a; i < (n); i++)
#define rep3(i, a, n) for (int i = a; i < (n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
// dp
ll dp[100010];
// input
ll h[100010];

int main(void) {
  int n;
  cin >> n;
  rep(i, n) cin >> h[i];
  rep(i, 100010) dp[i] = INF;
  dp[0] = 0;
  rep(i, n) {
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 5128
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = [set()] * 3
    S[0] = {1, 3, 5, 7, 8, 10, 12}
    S[1] = {4, 6, 9, 11}
    S[2] = {2}

    x, y = map(int, readline().split())

    ans = 'No'
    for s in S:
        if x in s and y in s:
            ans = 'Yes'
            break

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 62012
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let w = read::<i32>();
    let h = read::<i32>();
    let n = read::<usize>();
    let mut ps = vec![(0, 0); 2 * n];
    let mut online_ps = vec![];
    let mut online_cnt = vec![0; n];
    for i in 0..n {
        for j in 0..2 {
            let x = read::<i32>();
            let y = read::<i32>();
            ps[i * 2 + j] = (x, y);
            if x == 0 || y == 0 || x == w || y == h {
                let mut d = 0;
                if y == 0 {
                    d = x;
                } else if x == w {
                    d = w + y;
                } else if y == h {
                    d = w + h + (w - x);
                } else if x == 0 {
                    d = w + h + w + (h - y);
                }
                online_ps.push((d, i, x, y));
                online_cnt[i] += 1;
            }
        }
    }
    online_ps.sort();
    let mut stack = vec![];
    for &(_d, index, _x, _y) in online_ps.iter() {
        if online_cnt[index] == 1 {
            continue;
        }
        if let Some(&last_index) = stack.last() {
            if last_index == index {
                stack.pop();
                continue;
            }
        }
        stack.push(index);
    }
    println!("{}", if stack.len() == 0 { "YES" } else { "NO" });
}


Measured memory_bytes: 15480
import Data.Char

scan :: [Int] -> Int
scan  = iter 999 where
    iter m [_, _] = m
    iter m (x:y:z:xs) = iter (min (abs (100*x+10*y+z-753)) m) (y:z:xs)  

main :: IO() 
main = do
    s <- getLine
    let ans = scan (map (\x -> digitToInt x) s)
    print ans

Measured memory_bytes: 380
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int H, W, N;
typedef pair<int, int> P;
map<P, int> field;
long long ans[10];

int main() {
  cin >> H >> W >> N;
  for (int i=0; i<N; i++) {
    int a, b;
    cin >> a >> b;
    for (int x=-1; x<=1; x++) {
      for (int y=-1; y<=1; y++) {
        P p = P(b-1+x, a-1+y);
        field[p] += 1;
      }
    }
  }

  ans[0] = (long)(W-2)*(long)(H-2);
  for (auto p : field) {
    P key = p.first;
    if (p.second > 0 &&
        key.first >= 1 && key.first <= W-2 &&
        key.second >= 1 && key.second <= H-2) {
      ans[p.second]++;
      ans[0]--;
    }
  }
  for (int i=0; i<10; i++) cout << ans[i] << "\n";
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int a, b, c, k;
	bool ans = false;
	cin >> a >> b >> c >> k;
	rep(i, k) {
		if (c > b && b > a) {
			ans = true;
			break;
		}
		if (a >= b)b *= 2;
		else if (b >= c)c *= 2;
	}
	if (c > b && b > a) {
		ans = true;
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);


int main()
{
    int n,t,a;
    cin >> n >> t >> a;
    t *= 1000,a *= 1000;
    int ans,mi = INF;
    for(int i = 1; i <= n; i++){
        int h,tmp;
        cin >> h;
        tmp = abs(a-(t-h*6));
        if(tmp < mi){
            mi = tmp;
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}

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

vector<vector<int>> ind(10, vector<int>());

bool check(int x) {
    int a, b, c;
    c = x % 10; x /= 10;
    b = x % 10; x /= 10;
    a = x;
    // abc
    auto it = upper_bound(ind[a].begin(), ind[a].end(), -1);
    if (it == ind[a].end()) return false;
    it = upper_bound(ind[b].begin(), ind[b].end(), *it);
    if (it == ind[b].end()) return false;
    it = upper_bound(ind[c].begin(), ind[c].end(), *it);
    if (it == ind[c].end()) return false;


    return true;
}

void solve() {
    int n;
    string s;
    cin >> n >> s;
    rep(i, n) {
        ind[s[i] - '0'].push_back(i);
    }

    int ans = 0;
    rep(i, 1000) {
        if (check(i)) {
            ans++;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3832
/*Hatsune Miku 4ever!*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _for(i,a,b) for(int i = (a);i < b;i ++)
#define _rep(i,a,b) for(int i = (a);i > b;i --)
#define INF 0x3f3f3f3f
#define mod 1000000007
#define lowbit(x) ((x)&(-x))
#define pb push_back
#define MIKU 39
#define Design ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug() printf("Miku Check OK!\n")
#define maxn 200039

int n, m;
struct SegTree
{
	struct SegNode
	{
		int l,r; 
		ll add;
		ll ans;
		#define l(x) tree[x].l
		#define r(x) tree[x].r
		#define add(x) tree[x].add
		#define ANS(x) tree[x].ans
	}tree[maxn<<2];
	void build(int p,int l,int r)
	{
		add(p) = 0;
		l(p) = l,r(p) = r;
		if(l==r)
		{
			ANS(p) = 0;
			return ;
		}
		int mid = (l+r)/2;
		build(p*2, l, mid);
		build(p*2+1, mid+1, r);
	}

	void spread(int p)
	{
		if(add(p))
		{
			ANS(p*2) = l(p) - add(p);
			ANS(p*2+1) = (l(p)+r(p))/2+1-add(p); 
			add(p*2) = add(p);
			add(p*2+1) = add(p);
			add(p) = 0;
		} 
	}
	void change(int p,int l,int r,ll d)
	{
		if(l <= l(p) && r >= r(p))
		{
			ANS(p) = l(p) - d;
			add(p) = d;
			return ;
		} 
		spread(p);
		int mid = (l(p)+r(p))/2;
		if(l <= mid)
			change(p*2, l, r, d);
		if(r > mid)
			change(p*2+1, l, r, d);
		ANS(p) = min(ANS(p*2),ANS(p*2+1));
	}
	ll ask(int p,int pos)
	{
		if(l(p)==r(p))
			return pos - ANS(p);
		spread(p);
		int mid = (l(p)+r(p))/2;
		if(pos <= mid)
			return ask(p*2, pos);
		else
			return ask(p*2+1, pos);
	}
}T;

int main()
{
	int H, W;
	scanf("%d%d",&H,&W);
	T.build(1,1,W);
	int now = 1;
	_for(i,1,H+1)
	{
		int a, b;
		scanf("%d%d",&a,&b);
		if(now < a)
			T.change(1,a,b,T.ask(1,a-1));
		else if(now >= a && now <= b)
		{
			T.change(1,now,b,-1000000);
			now = b+1;
		}
		if(now > W)
			printf("-1\n");
		else
			printf("%lld\n",T.tree[1].ans+i);
	} 
	return 0;
}

Measured memory_bytes: 15984