akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

	ll n, c[4] = {0};
	cin >> n;
	for(int i=0;i<n;i++)
	{
		string x;
		cin >> x;
		if(x == "AC") c[0] += 1;
		if(x == "WA") c[1] += 1;
		if(x == "TLE") c[2] += 1;
		if(x == "RE") c[3] += 1;
	}
	cout << "AC x " << c[0] << endl;
	cout << "WA x " << c[1] << endl;
	cout << "TLE x " << c[2] << endl;
	cout << "RE x " << c[3] << endl;
    return 0;
}

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

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

    vector<vector<int> > s(M);
    for (int i = 0; i < M; ++i) {
        int k; cin >> k;
        for (int j = 0; j < k; ++j) {
            int a;
            cin >> a;
            --a;
            s[i].push_back(a);
        }
    }

    vector<int> p(M);
    for (int i = 0; i < M; ++i) cin >> p[i];

    long long res = 0;
    for (int bit = 0; bit < (1<<N); bit++) {
        bool ok = true;
        for (int i = 0; i < M; i++) {
            int con = 0;
            for (auto v : s[i]) {
                if (bit & (1<<v)) ++con;
            }
            if (con % 2 != p[i]) ok = false;
        }
        if (ok) ++res;
    }
    cout << res << endl;
}


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

int main(){
  int a,b,t;
  cin >> a >> b >> t;
  cout << (t/a)*b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

struct edge{int to, cost;};

bool used[2000];
int cnt;

class Graph
{
public:
    int V;
    vector<vector<edge>> G;

    Graph(int V): V(V){
        G = vector<vector<edge>>(V, vector<edge>(0));
    }

    void add_edge(int from, int to, int cost){
        G[from].push_back(edge({to, cost}));
    }

    void add_edge2(int v1, int v2, int cost){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }

    void dfs(int v, int d){
        used[v] = true;
        cnt++;
        if(d > 0){
            REP(k, G[v].size()) if(!used[G[v][k].to]) dfs(G[v][k].to, d - 1);
        }
    }

};

signed main(){

    int N, K; cin >> N >> K;
    Graph G(N);
    vec A(N), B(N);
    REP(i, N - 1){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        G.add_edge2(A[i], B[i], 1);
    }

    int ans = INF;
    if(K % 2 == 0){
        REP(i, N){
            cnt = 0;
            memset(used, 0, sizeof(used));
            used[i] = true;
            G.dfs(i, K / 2);
            ans = min(ans, N - cnt);
        }
    }else{
        REP(i, N - 1){
            cnt = 0;
            memset(used, 0, sizeof(used));
            used[A[i]] = true;
            used[B[i]] = true;
            G.dfs(A[i], (K - 1) / 2);
            G.dfs(B[i], (K - 1) / 2);
            ans = min(ans, N - cnt);
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include<string.h>
int main() {
	int a, b;
	char c[1];
	while (1) {
		scanf("%d", &a);
		scanf("%s", c);
		scanf("%d", &b);
		if (c[0] == '+') {
			printf("%d\n", a + b);
		}
		else if (c[0] == '-') {
			printf("%d\n", a - b);
		}
		else if (c[0] == '*') {
			printf("%d\n", a*b);
		}
		else if (c[0] == '/') {
			printf("%d\n", a / b);
		}
		else if (c[0] == '?') {
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main(){
	int w, h, x, y, r, luas1, luas2;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if(x>=w || y>=h || r>x || r>y){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
}


Measured memory_bytes: 2696
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

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

  if ( k % 2 == 1 ) {
    long long int a = n / k;
    printf("%lld\n", a * a * a);
  } else {
    long long int a = n / k;
    long long int b = a;
    if ( (n % k) >= (k / 2)) b++;
    printf("%lld\n", a * a * a + b * b * b);
  }
  return 0;
}


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

int main() {
  int x,y,f;
  cin >> x;
  f = 0;
  y = x;
  while(x != 0){
    f += x%10;
    x = x/10;
  }
  if(y%f == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
typedef double db;
// mt19937 mrand(random_device{}());
const ll mod = 1000000007;
// int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a%mod; a = a * a%mod; }return res; }
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; }
// head
void add_self(int& a, int b) {
	a += b;
	if (a >= mod) {
		a -= mod;
	}
}
const int mxN = 21;
int n;
bool can[mxN][mxN];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> n;
	rep(i, 0, n) rep(j, 0, n) cin >> can[i][j];
	VI dp(1 << n);
	dp[0] = 1;
	for (int mask = 0; mask < (1 << n) - 1; ++mask) {
		int a = __builtin_popcount(mask);
		for (int b = 0; b < n; ++b) {
			if (can[a][b] && !(mask & (1 << b))) {
				int m2 = mask ^ (1 << b);
				add_self(dp[m2], dp[mask]);
			}
		}
	}
	cout << dp[(1 << n) - 1] << endl;
	return 0;
}



Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N;
  cin >> N;
  vector<ll> a(N);
  rep(i, N) cin >> a[i];

  ll x = 0;
  ll y = 0;
  rep(i, N) { y += a[i]; }

  ll ans = LINF;
  repp(i, 0, N - 2) {
    x += a[i];
    y -= a[i];
    chmin(ans, abs(x - y));
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x;

    //int y;
    string r;
    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
struct S
{
    int x,y;
};
vector<P> v[333];
//bitset<4001000> bit;
int a,c,i,b,k,d,n,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[2000010];
int o[3][333];
int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1};

//long long x,y,z[1111][3][1111],mod=1000000007;
//P u[23][2222][2222];
//int j[31][11111];

stack<S> s;
queue<P> q;
queue<int> q1;

//deque<int> de;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int > p[22][22];
//list<int> l;
string r,r2;
//char r[33][33];



int f(int a)
{
    if(a<2) return a;
    return f(a/2)+a%2;
}

int main()
{
    scanf("%d",&a);
    for(int t=1;t<=2;t++)
        for(int w=1;w<=a;w++)
        scanf("%d",&o[t][w]);
    for(int t=1;t<=2;t++)
        for(int w=1;w<=a;w++)
        o[t][w]+=max(o[t-1][w],o[t][w-1]);
    printf("%d",o[2][a]);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    while(cin>>a>>b>>c){
        if(c>=a&&c<=b)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
 
    return 0;
 
}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e5+5,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);
vi adj[mxN];
bool vis[mxN];
int cnt;
void DFS(int node){
    vis[node]=true;
    cnt++;
    for(auto x:adj[node]){
        if(!vis[x])
            DFS(x);
    }
}
void solve(){
    int n,m;
    cin>>n>>m;
    loop(m,i,0){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    int res=0;
    loop(n+1,i,1){
        if(!vis[i]){
            DFS(i);
            max_self(res,cnt);
            cnt=0;
        }
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

long long modpow(long long a, int p) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int halfP = p / 2;
        long long half = modpow(a, halfP);
        return half * half % MOD;
    } else {
        return a * modpow(a, p - 1) % MOD;
    }
}

long long calcComb(int a, int b) {
    if (b > a - b) return calcComb(a, a - b);
    long long ansMul = 1;
    long long ansDiv = 1;
    for (int i = 0; i < b; i++) {
        ansMul *= (a - i);
        ansDiv *= (i + 1);
        ansMul %= MOD;
        ansDiv %= MOD;
    }
    long long ans = ansMul * modpow(ansDiv, MOD - 2) % MOD;
    return ans;
}

int main() {
    long long N, M;
    cin >> N >> M;

    int MNokori = M;
    long long ans = 1;
    for (int i = 2; i * i <= MNokori; i++) {
        if (MNokori % i == 0) {
            int cnt = 0;
            while (MNokori % i == 0) {
                cnt++;
                MNokori /= i;
            }
            ans *= calcComb(N + cnt - 1, N - 1);
            ans %= MOD;
        }
    }

    if (MNokori != 1) {
        ans *= calcComb(N + 1 - 1, N - 1);
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
a=input().split()
x=int(a[0])
y=int(a[1])
A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
count =0
for i in A:
 if(x==i):
  count +=1
 if(y==i):
  count +=1
for i in B:
 if(x==i):
  count -=1
 if(y==i):
  count -=1
if((count==2)or(count==-2)):
 print("Yes")
else:
 print("No")

Measured memory_bytes: 3064
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

INF = 10**9 + 1

def precompute(N, M, data):
    data = data.reshape(-1, 3)
    A, B, C = data[:N].T
    D, E, F = data[N:].T
    X = np.unique(np.concatenate([A, B, D, [0, -INF, INF]]))
    Y = np.unique(np.concatenate([C, E, F, [0, -INF, INF]]))
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B)
    D = np.searchsorted(X, D)
    C = np.searchsorted(Y, C)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F)
    return A, B, C, D, E, F, X, Y

def solve(A, B, C, D, E, F, X, Y):
    H, W = len(X), len(Y)
    N = H * W
    DX = X[1:] - X[:-1]
    DY = Y[1:] - Y[:-1]

    def set_ng(A, B, C, D, E, F, H, W):
        ng = np.zeros((H * W, 4), np.bool_)

        for i in range(len(A)):
            for x in range(A[i], B[i]):
                v = x * W + C[i]
                ng[v][1] = 1
                ng[v - 1][0] = 1

        for i in range(len(D)):
            for y in range(E[i], F[i]):
                v = D[i] * W + y
                ng[v][3] = 1
                ng[v - W][2] = 1
        return ng

    ng = set_ng(A, B, C, D, E, F, H, W)
    x0, y0 = np.searchsorted(X, 0), np.searchsorted(Y, 0)
    v0 = x0 * W + y0
    
    def area(x):
        x, y = divmod(x, W)
        return DX[x] * DY[y]

    visited = np.zeros(N, np.bool_)
    visited[v0] = 1
    stack = [v0]
    ret = area(v0)

    def push(x):
        nonlocal ret
        stack.append(x)
        visited[x] = 1
        ret += area(x)

    def pop():
        return stack.pop()

    move = (1, -1, W, -W)
    while stack:
        v = pop()
        for i in range(4):
            if ng[v][i]:
                continue
            w = v + move[i]
            if visited[w]:
                continue
            x, y = divmod(w, W)
            if x == 0 or x == H - 1 or y == 0 or y == W - 1:
                return 0
            push(w)
    return ret

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    signature = '(i8[:],i8[:],i8[:],i8[:],i8[:],i8[:],i8[:],i8[:])'
    cc.export('solve', signature)(solve)
    cc.compile()

if sys.argv[-1] == 'ONLINE_JUDGE':
    cc_export()
    exit()

from my_module import solve

N, M = map(int, readline().split())
data = np.int64(read().split())

x = solve(*precompute(N, M, data))
if x == 0:
    print('INF')
else:
    print(x)


Measured memory_bytes: 102692
#include <cstdio>

int main()
{
  long long a, b, c;
  scanf("%lld%lld%lld", &a, &b, &c);
  long long ans = 0;
  while (!(a & 1) && !(b & 1) && !(c & 1))
  {
    if (a == b && b == c)
    {
      puts("-1");
      return 0;
    }
    long long tmp[3] = {(b + c) / 2, (c + a) / 2, (a + b) / 2};
    a = tmp[0], b = tmp[1], c = tmp[2];
    ++ans;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n; float a[102];

void solve()
{
    cin >> n;
    float s = 0;
    for (int i=1; i<=n; i++) cin >> a[i];
    for (int i=1; i<=n; i++) s+=1/a[i];
    cout << fixed << setprecision(10) << 1/s << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

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

	vector<int> S(N);
	int Q = 0;
	for (int i = 0; i < N; i++) {
		cin >> S.at(i);
		Q += S.at(i);
	}

	sort(S.begin(), S.end());

	if (Q % 10 != 0) {
		cout << Q << endl;
		return 0;
	}
	else {
		int i = 0;
		for (i = 0; i < N; i++) {
			if (S.at(i) % 10 != 0) break;
		}
		if (i == N) cout << 0 << endl;
		else cout << Q - S.at(i) << endl;
	}
}

Measured memory_bytes: 256
import sys
bbn=1000000007
	
#+++++

class store:
	def __init__(self, is_open):
		ret=0
		for i,v in enumerate(is_open):
			ret += (2**i)*v
		self.is_open=ret
	
	def add_proof_info(self,pl):
		self.ploofs=pl
		
	def get_proof(self, time):
		count=0
		temp=self.is_open
		tt=time
		while temp>0:
			count+=1&tt&temp
			tt=tt>>1
			temp=temp>>1
			#print(temp)

		return self.ploofs[count]
		
def main():
	n = int(input())
	stores=[]
	for i in range(n):
		is_open = list(map(int, input().split()))
		st=store(is_open)
		stores.append(st)
		
	for s in stores:
		pl=list(map(int, input().split()))
		s.add_proof_info(pl)
	
	ret=None
	for i in range(1,(2**10)+0):
		value=sum([s.get_proof(i) for s in stores])
		if ret is None or ret < value:
			ret = value
		
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
f = defaultdict(lambda : 0)
for i in range(1,n+1):
    s = str(i)
    t,u = int(s[0]), int(s[-1])
    f[(u,t)] += 1

ans = 0
for i in range(1,n+1):
    s = str(i)
    t,u = int(s[0]),int(s[-1])
    ans += f[(t,u)]
print(ans)

Measured memory_bytes: 41196
n = int(input())
a = list(map(int,input().split()))
f, r = [], []
for i in range(n):
    if i%2==0:
        f.append(a[i])
    else:
        r.append(a[i])
ans = r[::-1] + f      
if n%2==0:
    print(*ans)
else:
    print(*ans[::-1])

Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
typedef long long ll;
 
int main() {
   int w,h,n,x,y,a;
   cin >> w >> h >> n;
   
   int xmin=0,xmax=w,ymin=0,ymax=h;
   rep(i,n){
      cin >> x >> y >> a;
      if(a==1)
      	xmin=max(xmin,x);
      else if(a==2)
      	xmax=min(xmax,x);
      else if(a==3)
      	ymin=max(ymin,y);
      else if(a==4)
      	ymax=min(ymax,y);
   }

   cout << max(xmax-xmin,0)*max(ymax-ymin,0) << endl;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

// LCS + restore_path
// https://qiita.com/nomikura/items/f30686df3df0ddb4d338
int dp[3005][3005];
int pre[3005][3005]; // 1: i,j から 2: i+1,j から 3: i,j+1 から
string lcs_restore(string &x, string &y) {
    memset(dp, 0, sizeof(dp));
    memset(pre, 0, sizeof(pre));
    int xn = x.size();
    int yn = y.size();
    for (int i = 0; i < xn; i++) {
        for (int j = 0; j < yn; j++) {
            if (x[i] == y[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
                pre[i + 1][j + 1] = 1;
            } else {
                if (max(dp[i][j + 1], dp[i + 1][j]) == dp[i + 1][j]) {
                    dp[i + 1][j + 1] = dp[i + 1][j];
                    pre[i + 1][j + 1] = 2;
                } else {
                    dp[i + 1][j + 1] = dp[i][j + 1];
                    pre[i + 1][j + 1] = 3;
                }
            }
        }
    }
    string ans = "";
    while (pre[xn][yn] != 0) {
        if (pre[xn][yn] == 1) {
            xn -= 1, yn -= 1;
            ans += x[xn];
        } else if (pre[xn][yn] == 2) {
            yn -= 1;
        } else {
            xn -= 1;
        }
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

int main() {
    string s, t;
    cin >> s >> t;
    string ans = lcs_restore(s, t);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a*n, b) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np
MOD = 10**9+7

n, c = map(int, input().split())
A = np.array(tuple(map(int, input().split())))
B = np.array(tuple(map(int, input().split())))
E = np.zeros((n, c+1), dtype=np.int64)
for j in range(c+1):
  cum = np.array(tuple(pow(k, j, MOD) for k in range(401))).cumsum()%MOD
  E[:, j] = cum[B] - cum[A-1]

dp = np.zeros((n+1, c+1), dtype=np.int64)
dp[0, 0] = 1
for i, e in enumerate(E):
  for j, f in enumerate(e):
    dp[i+1, j:] += dp[i, :c+1-j]*f
    dp[i+1] %= MOD
ans = dp[n, c]
print(ans)

Measured memory_bytes: 16080
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(int argc, char *argv[]) {
  int h, w, m, i, j, s, t;

  cin >> h >> w >> m;

  vector<int> s1(h,0), s2(w,0);
  set<pair<int,int> > b;

  for(i=0;i<m;i++){
    cin >> s >> t;
    s--, t--;
    s1[s]++;
    s2[t]++;
    b.insert({s,t});
  }
  
  int maxx, maxy;
  vector<int> x = {}, y = {};
  
  maxx = 0;
  for(i=0;i<h;i++){
    if(maxx<s1[i]){
      x = {i};
      maxx = s1[i];
    }
    else if(maxx==s1[i]){
      x.push_back(i);
    }
  }
  maxy = 0;
  for(i=0;i<w;i++){
    if(maxy<s2[i]){
      y = {i};
      maxy = s2[i];
    }
    else if(maxy==s2[i]){
      y.push_back(i);
    }
  }

  if(x.size()*y.size()>300000){
    cout << maxx + maxy << endl;
  }
  else{
    for(i=0;i<x.size();i++){
      for(j=0;j<y.size();j++){
        if(b.find({x[i],y[j]})==b.end()){
          cout << maxx + maxy << endl;
          return 0;
        }
      }
    }
    cout << maxx + maxy - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 23876
(defun app ()
    (let ((read_s (read))
        (read_t (read)))
    (defparameter *hash* (make-hash-table))
    (setf (gethash read_s *hash*) (read))
    (setf (gethash read_t *hash*) (read))
    (decf (gethash (read) *hash*))
    (format t "~D ~D~%" (gethash read_s *hash*) (gethash read_t *hash*)))
)
(app)

Measured memory_bytes: 24524
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n,k,ans=0;cin>>n>>k;
	vi h(n);
	rep(i,0,n) cin>>h[i];
	sort(h.begin(), h.end());
	rep(i,0,n-k) ans+=h[i];
	cout<<ans<<"\n";

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
template <class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = INT_MAX;
const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vi A(N);
    rep(i, N) cin >> A[i];
    set<int> B;
    rep(i, N) B.insert(A[i]);
    if (B.size() == N) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define pb push_back
#define len(x) (int)(x).size()

typedef long long ll;
typedef long double ld;

using namespace std;

vector < int > input(){
    string s;cin >> s;
    vector < int > ans(len(s));
    for(int i = 0; i < len(s); ++i)
        ans[i] = (s[i]=='A'?1:2);
    return ans;
}
signed main(){
    vector<int> s = input() , t = input();
    vector < int > prefs(len(s) + 1) , preft(len(s) + 1);
    for(int i = 0; i < len(s); ++i)
        prefs[i + 1] = prefs[i] + s[i];
    for(int j = 0 ; j < len(t); ++j)
        preft[j + 1] = preft[j] + t[j];
    int q;cin >> q;
    while(q--){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        if((prefs[b]-prefs[a-1])%3==(preft[d]-preft[c-1])%3)
            cout << "YES\n";
        else cout << "NO\n";
    }

    return 0;
}


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

int main()
{
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    int aa = ceil(c/b);
    int bb = ceil(a/d);
    int i = 1;
    while(1)
    {
        if(i % 2 == 1)
        {
            c = c-b;
        }
        else
        {
            a = a-d;
        }
        if(a <= 0)
        {
            cout << "No" << endl;
            return 0;
        }
        if(c <= 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        i++;
    }
    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;++i)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define rrep(i,n) for(int i=n-1;0<=i;--i)
#define rRep(i,n) for(int i=n;0<i;--i)
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define scani(a) scanf("%d",&a)
#define scanr(a) scanf("%lf",&a)
#define scans(s) scanf("%s",s)
#define printi(a) printf("%d",a)
#define printr(a) printf("%lf",a)
#define prints(s) printf("%s",s)
#define is_odd(n) (n&1)
#define is_even(n) ((n+1)&1)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
#define all(x) x.begin(), x.end()
#define EPS 1e-8
#define INF 1e8
#define PI acos(-1.0)

typedef double Real;
typedef int Int;
typedef vector<Int> vi;
typedef vector<vector<Int> > vvi;
typedef pair<Int,Int> pii;

inline Real sr(Real a) {return sqrt(max(a, (Real)0));}
template <typename T> inline T sq(T a) {return a * a;}
const vi dy = {-1, 0, 1, 0}, dx = {0, -1, 0, 1};
vector<string> split(const string &s, char d) {vector<string> r;stringstream t(s);string x;while(getline(t,x,d))if(!x.empty())r.push_back(x);return r;}

void solve()
{
  for(;;)
  {
    Int n, p; scani(n); scani(p);
    if(n == 0 && p == 0) break;

    vi cs(n, 0);

    for(Int i = 0, count = p;;i=(i+1)%n)
    {
      if(count > 0)
      {
        ++cs[i];
        --count;
        if(count == 0)
        {
          bool ok = true;
          rep(j, n) if(i != j) ok &= cs[j] == 0;
          if(ok)
          {
            cout << i << endl;
            break;
          }
        }
      }
      else
      {
        count += cs[i];
        cs[i] = 0;
      }
    }
  }
}

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

  solve();

  return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
 
#define ll long long
ll mod = 1e9+7;
const int MAX = 1e5+5;
using namespace std;
 
ll dp[3003][3003]; //represents length LCS between substring ending at ith index of s1 and jth index of s2
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s1,s2;
    cin>>s1>>s2;
    int n=s1.size(); int m=s2.size();
 
    for(int i=0;i<=n;i++) {
        for (int j = 0; j <= m; j++) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
                continue;
            }
 
            if (s1[i-1] == s2[j-1]) {
                dp[i][j] = 1 + dp[i - 1][j - 1];
            } else {
                if (dp[i - 1][j] > dp[i][j - 1]) {
                    dp[i][j] = dp[i - 1][j];
                } else {
                    dp[i][j] = dp[i][j - 1];
                }
            }
        }
    }


    string ans="";
    int tot=dp[n][m];
    int i=n; int j=m;
 
    for(int len=tot;len>0;){
        if(s1[i-1]==s2[j-1]){
            ans+=s1[i-1];
            i--; j--;
            len--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans;
    return 0;
 
}


Measured memory_bytes: 70656
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations_with_replacement, compress
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


def main():
    A, B, N = LI()
    print(int(A / B * min(N, B - 1)))


main()


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


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    ll n;cin>>n;
    ll x=0;
    ll arr[n];
    rep(i,0,n){
        cin>>arr[i];
        x^=arr[i];
    }  
    rep(i,0,n){
        cout<<(x^arr[i])<<" ";
    }
 
return 0;
}

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

using namespace std;

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

    int n, w;
    cin >> n >> w;

    vector<long long> wi(n);
    vector<long long> vi(n);
    vector<long long> cost(w + 1, -1);
    for(int i = 0; i < n; ++i)
        cin >> wi[i] >> vi[i];

    cost[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = w; j >= wi[i]; j--){
            if(cost[j - wi[i]] != -1)
                cost[j] = max(cost[j], cost[j - wi[i]] + vi[i]);
        }
    }

    long long ans = 0;
    for(int i = 0; i <= w; ++i)
        ans = max(ans, cost[i]);

    cout << ans << "\n";

    return 0;
}//RUL0

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

pair<int, int> x[200000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, d, a;
    cin >> n >> d >> a;
    for (int i=0; i<n; i++)
        cin >> x[i].first >> x[i].second;

    sort(x, x + n);
    queue<pair<long long, int>> q;
    int cur = 0;
    long long ret = 0;
    for (int i=0; i<n; i++) {
        while (!q.empty() && q.front().first < x[i].first) {
            cur -= q.front().second;
            q.pop();
        }
        int need = (x[i].second + a - 1) / a;
        if (need > cur) {
            ret += need - cur;
            q.push({x[i].first + 2LL * d, need - cur});
            cur = need;
        }
    }

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 6264
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[]){
    int i, n;
    double a = 0, m = 0, s[1000];
    while(1){
        scanf("%d",&n);
        if( n == 0 ) {
            break;
        }
        for( i = 0 ; i < n ; i++ ){
            scanf("%lf",&s[i]);
            m += s[i] / n;
        }
        for( i = 0 ; i < n ; i++ ) {
            a += ( s[i] - m )*( s[i] - m )/n ;
        }
        printf("%f\n",sqrt(a));
        a = 0;
        m = 0;
    }
    return 0;
}

Measured memory_bytes: 660
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    int ans=0;
    REP(i,N){
        int a; cin>>a;
        ans+=a-1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  cout << (a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500 >= 1000) << endl;
}

Measured memory_bytes: 3100
N, M = map(int, input().split(" "))
XYZ = [list(map(int, input().split(" "))) for _ in range(M)]

l = [[] for _ in range(N)]
for x, y, _ in XYZ:
    l[x-1].append(y-1)
    l[y-1].append(x-1)

visited = [False]*N
count = 0
for i in range(N):
    # 訪れたことがあれば
    if visited[i] == True:
        continue
    visited[i] = True
    q = l[i]
    while q:
        r = []
        for y in q:
            if visited[y] == True:
                continue
            visited[y] = True
            r += l[y]
        q = r
        # print(q)
    count += 1
    # print(i, count, visited)

# print(count, visited)
print(count)

        


Measured memory_bytes: 45764
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(string s){
    int n(s.size());
    vector<int> a(n);
    for(int i = 0; i < n; ++i)
        a[i] = s[i] - '0';
    reverse(a.begin(), a.end());

    array<int, 2> dp{0, MOD};
    for(int i = 0; i < n; ++i){
        array<int, 2> nex{MOD, MOD};

        chmin(nex[0], dp[0] + a[i]);
        chmin(nex[1], dp[0] + (10 - a[i]) + 1);
        chmin(nex[0], dp[1] + a[i]);
        chmin(nex[1], dp[1] + (10 - a[i]) - 1);

        dp = move(nex);
    }
    cout << min(dp[0], dp[1]) << endl;

}


signed main(){
    string s;
    cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 6276
s = list(input())
ans = 'Yes'

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != 'h':
            ans = 'No'
    else:
        if s[i] != 'i':
            ans = 'No'
      
if len(s) % 2 == 1:
    ans = 'No'
    
print(ans)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

bool dp1[11111],dp2[11111];

signed main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;

    dp1[0]=dp2[0]=true;
    for(int i=0;i<f;i++){
        dp1[i+a]|=dp1[i];
        dp1[i+b]|=dp1[i];

        dp2[i+c]|=dp2[i];
        dp2[i+d]|=dp2[i];
    }
    pint ans={0,100*a};

    for(int i=1;i*100<=f;i++){
        for(int j=1;i*100+j<=f&&i*e>=j;j++){
            if(!dp1[i]||!dp2[j])continue;
            if(ans.fi*(i*100+j)<j*ans.se){
                ans={j,i*100+j};
            }
        }
    }
    cout<<ans.se<<" "<<ans.fi<<endl;
    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string a, b;

int main() {
	cin >> a >> b;
	
	int as = a.size();
	int bs = b.size();
	if(as > bs) { cout << "GREATER" << endl; }
	if(as < bs) { cout << "LESS"    << endl; }
	if(as == bs) {
		if(a == b) { cout << "EQUAL" << endl; }
		else {
			inc(i, as) {
				if(a[i] > b[i]) { cout << "GREATER" << endl; break; }
				if(a[i] < b[i]) { cout << "LESS"    << endl; break; }
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
p = [0] * M
S = ['a'] * M
for i in range(M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])

ansac = pen = 0
answa = [0] * N
flg = [0] * N

for i in range(M):
    if flg[p[i]-1] == 1:
        continue
    if S[i] == 'WA':
        answa[p[i]-1] += 1
    elif S[i] == 'AC':
        ansac += 1
        pen += answa[p[i]-1]
        flg[p[i]-1] = 1

print(ansac, pen)

Measured memory_bytes: 21416
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);


        Scanner scanner = new Scanner(System.in);
        while (true) {
            String s = scanner.nextLine();
            if (s.equals("0")) {
                break;
            }

            int len = s.length();
            int sum = 0;
            for (int i = 0; i < len; i++) {
                sum += s.charAt(i) - '0';
            }
            System.out.println(sum);
        }

    }

}


Measured memory_bytes: 26628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var n, u, v int
var ps [][]int
var prt []int
var md int

func main() {
	fmt.Scan(&n, &u, &v)
	u--
	v--

	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ps = make([][]int, n)
	for i := 0; i < n-1; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		a--
		b--
		ps[a] = append(ps[a], b)
		ps[b] = append(ps[b], a)
	}

	// make parent
	prt = make([]int, n)
	prt[v] = -1
	dfs(v, -1)

	// check min path
	var mp int
	sp := u
	for sp != v {
		sp = prt[sp]
		mp++
	}

	// bottom path
	bp := int((mp - 1) / 2)
	sp = u
	for i := 0; i < bp; i++ {
		sp = prt[sp]
	}

	// calc depth
	cd(sp, 0)
	fmt.Println(mp - bp + md - 1)

	//fmt.Println(ps)
	//fmt.Println(prt)
	//fmt.Println(mp)
	//fmt.Println(bp, sp)
	//fmt.Println(md)
}

func cd(sp, depth int) {
	if depth > md {
		md = depth
	}
	for _, cp := range ps[sp] {
		if cp == prt[sp] {
			continue
		}
		cd(cp, depth+1)
	}
}

func dfs(p, fp int) {
	prt[p] = fp
	for _, cp := range ps[p] {
		if cp == fp {
			continue
		}
		dfs(cp, p)
	}
}


Measured memory_bytes: 22400