akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;

long long perm[3100000], inv[3100000];
long long powmod(long long a, long long b) {
    if (a >= M) return powmod(a % M, b);
    if (b == 0) return 1;
    if (b & 1) return powmod(a, b - 1) * a % M;
    else return powmod(a * a % M, b / 2);
}
long long comb(long long n, long long k) {
    if (n == k) return 1;
    if (k < 0 || n < k) return 0;
    return perm[n] * inv[k] % M * inv[n - k] % M;
}

int main() {
    perm[0] = 1;
    inv[0] = 1;
    for (int i = 1; i < 3100000; ++i) {
        perm[i] = perm[i - 1] * i % M;
        inv[i] = powmod(perm[i], M - 2);
    }
    while (1) {
        int a, b, c, sx, sy;
        cin >> a >> b >> c >> sx >> sy;
        if (a + b + c == 0) return 0;

        long long ans = 0;
        for (int i = max(a, sx - sy + b); i <= sx; ++i) {
            int j = i - sx + sy;
            int k = sx - i;
            ans = (ans + comb(i - 1, a - 1) * comb(j - 1, b - 1) % M * comb(a + b + c, a) % M * comb(b + c, b) % M * comb(a + b + c + k - 1, k) % M) % M;
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 51520
class PrimeChecker:
 
    def __init__(self):
        self.primes = [2,3,5]
 
    def isPrime(self, n):
        if n in self.primes:
            return True
        elif n < self.primes[-1]:
            return False
        else:
            for i in self.primes:
                if n % i == 0:
                    return False
 
        i = self.primes[-1]
        w = 2 if i % 6 == 5 else 4
 
        while i * i <= n:
            if self.isPrime(i):
                self.primes.append(i) 
                if n % i == 0:
                    return False
 
            i += w
            w = 6 - w
 
        return True
 
primeChecker = PrimeChecker()
count = 0
N = int(input())
for _ in range(N):
    if primeChecker.isPrime((int(input()))):
        count += 1
print(count)
        


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, a;
  cin >> n;
  unordered_map<int, int> um;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    um[i + 1] = a;
  }

  int cnt = 0;
  unordered_set<int> us;

  int next = 1;
  bool flg = true;
  do {
    if (us.find(next) != us.end()) {
      flg = false;
      break;
    }
    us.insert(next);
    next = um[next];
    cnt++;

  } while (next != 2);

  cout << (flg ? cnt : -1) << endl;
  return 0;
}


Measured memory_bytes: 8484
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<math.h>
#define L(_i,_N) for(int _i=0;_i<_N;_i++)
#define C(_Dis) cout<<_Dis<<endl

using namespace std;

typedef long long int lli;

int main() {
	int N, M,Count,temp;
	int *a, *b, *c, *d,*ans;
	cin >> N >> M;
	a = new int[N];
	b = new int[N];
	c = new int[M];
	d = new int[M];
	ans = new int[M];
	L(i, N) cin >> a[i] >> b[i];
	L(i ,M) cin >> c[i] >> d[i];
	for (int i = 0, j = 0; i < M; i++) {
		ans[i]=abs(a[j] - c[i]) + abs(b[j] - d[i]);
		if (i == M - 1){
			temp = ans[0];
			Count = 0;
			L(k, M) {
				if (temp > ans[k]) {
					temp = ans[k];
					Count = k;
				}
			}
			i = -1; j++;
			C(Count+1);
			if (j == N) break;
			
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second
int main(){
	string s;
	cin>>s;
	int ss=0;
	r(i,6)if(s[i]=='1')ss++;
	cout<<ss<<endl;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 1100, MAXK = 25;
const ll MOD = 1e7-3;
const ll INF = 1000000000000000;
const ld PI = asin(1) * 2;

int h, w, a, b;
int remR[MAXN], remC[MAXN];
int grid[MAXN][MAXN];
bool found = false;

int main()
{
    FAST_IO;

    cin >> h >> w >> a >> b;
    FOR(x, 0, h) {
        int up = 2*x*a - x*w - h*a + b*w;
        int down = 2*b-h;
        if (up%down == 0) {
            int y = up/down;
            if (y >= 0 && y <= w) {
                found = true;
                FOR(i, 1, x) remR[i] = a;
                FOR(i, x+1, h) remR[i] = w-a;
                FOR(i, 1, y) remC[i] = b;
                FOR(i, y+1, w) remC[i] = h-b;
                break;
            }
        }
    }

    if (!found) {
        cout << -1;
        return 0;
    }

    FOR(i, 1, h) FOR(j, 1, w) {
        if (remR[i] && remC[j]) {
            remR[i]--;
            remC[j]--;
            grid[i][j] = 1;
        }
    }

    FOR(i, 1, h) {
        FOR(j, 1, w) {
            cout << grid[i][j];
        }
        cout << "\n";
    }

    return 0;
}


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

int main() {
int n,ans=0;
cin>>n;
map<string,int> temp;
string s;
for(int i=0;i<n;i++){
    cin>>s;
    temp[s]++;
}
for(auto element : temp){
    ans=max(ans,element.second);
}
for(auto element : temp){
    if(element.second==ans){
        cout<<element.first<<endl;
    }
}
return 0;
}

Measured memory_bytes: 25216
#include<stdio.h>
#include<string.h>
int main(void)
{
  char p[101],pring[201],s[101];
  scanf("%s",&p);
  scanf("%s",&s);
  strcpy(pring,p);
  strcat(pring,p);
  if(strstr(pring,s) == NULL){printf("No\n");}
  else{printf("Yes\n");}
  
  
    return 0;
}

Measured memory_bytes: 540
a,b = input().split()
a = int(a)
b = int(b)
astr = ""
bstr = ""
for i in range(0,a):
	astr += str(b)

for i in range(0,b):
	bstr += str(a)

if ord(astr[:1]) > ord(bstr[:1]):
	print(bstr)
elif ord(astr[:1]) < ord(bstr[:1]):
	print(astr)
else:
	print(astr)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const ll MOD=1e9+7;
inline ll fpow(ll a,ll x) { ll ans=1; for(;x;x>>=1,a=a*a%MOD) if(x&1) ans=ans*a%MOD; return ans; }
int N;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>N;
    cout<<(fpow(10,N)-2*fpow(9,N)+fpow(8,N)+MOD+MOD)%MOD<<endl;
    return 0;
}

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



void in(vector<vector<int> >&x)
{
    REP(i,x.size())
    {
        REP(j,x.at(0).size())
        {
            cin>>x.at(i).at(j);
        }
    }
}

void out(vector<vector<int64_t> >x)
{
    REP(i,x.size())
    {
        REP(j,x.at(0).size())
        {
            if(j==x.at(0).size()-1)cout<<x.at(i).at(j);
            else cout<<x.at(i).at(j)<<" ";
        }
        cout<<endl;
    }
}

void de(vector<vector<int> >x,vector<vector<int> >y,vector<vector<int64_t> >&z)
{
    REP(i,x.size())
    {
        REP(j,y.at(0).size())
        {
            REP(k,y.size())
            {
                z.at(i).at(j)+=x.at(i).at(k)*y.at(k).at(j);
            }
        }
    }
}

int main()
{
    int n,m,l;
    cin>>n>>m>>l;
    vector<vector<int> >a(n,vector<int>(m,0));
    vector<vector<int> >b(m,vector<int>(l,0));
    vector<vector<int64_t> >c(n,vector<int64_t>(l,0));
    in(a);in(b);
    de(a,b,c);
    out(c);
}



Measured memory_bytes: 3276
N,K=map(int,input().split())
P=list(map(int,input().split()))

LIS=[1 for i in range(0,N)]
s=0
t=1
while N>t:
    if P[t]>=P[t-1]:
        t+=1
        if t==N:
            ans=N-s
            while t>s:
                LIS[s]=ans
                s+=1
                ans-=1
    else:
        ans=t-s
        while t>s:
            LIS[s]=ans
            s+=1
            ans-=1
        t+=1

nochange=set([])
for i in range(0,N-K+1):
    if LIS[i]>=K:
        nochange.add(i)

n=N
#セグメント木
#####segfunc######
def segfunc(x,y):
    return (min(x[0],y[0]),max(x[1],y[1]))

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele =(10**20,0)

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num
PP=[(P[i],P[i]) for i in range(0,N)]
init(PP)
ans=[]
if 0 not in nochange:
    ans.append(0)
for i in range(1,N-K+1):
    if i in nochange:
        continue
    else:
        M=query(i,i+K)[1]
        m=query(i-1,i-1+K)[0]
        if m==P[i-1] and M==P[i+K-1]:
            continue
        else:
            ans.append(i)

if nochange:
    print(len(ans)+1)
else:
    print(len(ans))


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++)cin >> p[i];
  int cnt=0;
  for(int i=1;i<n-1;i++){
    vector<int> q(3);
    q[0]=p[i-1]; q[1]=p[i]; q[2]=p[i+1];
    sort(q.begin(),q.end());
    if(q[1]==p[i])cnt++;
  }
  cout << cnt << endl;
}

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

string s;

int number(state &b){
    int ret=0;
    while(isdigit(*b)){
        ret=ret*10+*b-'0';
        b++;
    }
    return ret;
}

int dfs(state &b){
    vector<int>v;
    b++;
    if(*b=='['){
        while(*b=='['){
            v.push_back(dfs(b));
            b++;
        }
    }
    else v.push_back((number(b)+1)/2);
    sort(v.begin(),v.end());
    int ret=0;
    for(int i=0;i<(v.size()+1)/2;i++)ret+=v[i];
    return ret;
}

void solve(){
    cin>>s;
    state b=s.begin();
    cout<<dfs(b)<<endl;
}

int main(){


    int n;
    cin>>n;
    while(n--)solve();
    return 0;
}

Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);
		int k = in.nextInt();
		String s = in.next();

		if(s.length() <= k) {
			System.out.println(s);
		}else {
			System.out.println(s.substring(0,k) + "...");
		}
	}

}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<vector<int>> x(n), y(n);
		for(int i=0; i < n; i++){
			int k;
			cin >> k;
			x[i] = vector<int>(k);
			y[i] = vector<int>(k);
			for(int j=0; j < k; j++){
				cin >> x[i][j] >> y[i][j];
				x[i][j]--;
			}
		}
		int ret = 0;
		for(int i=0; i < (1<<n); i++){
			bool flag = true;
			for(int j=0; j < n; j++){
				if((i >> j)&1){
					for(int k=0; k < x[j].size(); k++){
						if(y[j][k] == 1 && !((i >> x[j][k]) & 1))flag = false;
						if(y[j][k] == 0 && ((i >> x[j][k]) & 1))flag = false;
					}
				}
			}
			if(flag)updmax(ret, __builtin_popcount(i));
		}
		cout << ret << endl;
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

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

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
#define MX 100010


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

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

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//










Int n;
Int c,k;
Int t[100010];

int main(void){
        cin >> n >> c >> k;
        rep(i,n) cin >> t[i];
        sort(t,t+n);
        Int ans = 0;
        Int now = 0;
        rep(i,n)
        {
                while(t[now]+k < t[i]){
                        ans++;
                        now = min(now+c, i);
                }
        }
        while(now < n)
        {
                ans++;
                now = min(now+c, n);
        }
        cout << ans << "\n";
        return 0;
}













Measured memory_bytes: 1024
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            System.out.println(
                s.charAt(0) == '9' || s.charAt(1) == '9' ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 21076
#include<stdio.h>
#include<math.h>
#include <limits.h>
#include<stdlib.h>
#include<string.h>

int main() {
	int n;
	scanf("%d", &n);
	if (n == 0) {
		printf("1\n");
	}
	else {
		printf("0\n");
	}


	return 0;
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
	
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
 


int main(){
	ll s,w;
    cin >> s >> w;
    if(w >= s) cout << "unsafe";
    else cout << "safe";
    
}


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

using namespace std;
int cal (int x,int y){
   if (y==0) return x;
   else {
    return cal(y,x%y);
   }
}
int main()
{
    long long a,b;
    cin>>a>>b;
    if (a>b) cout<<cal(a,b)<<'\n';
    if (a<b) cout<<cal(b,a)<<'\n';
    if (a==b) cout<<a<<'\n';
}



Measured memory_bytes: 3104
//
// Created by Ильдар Ялалов on 14.01.2020.
//
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")



#ifdef zxc

#include <random>
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <array>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <sstream>
#include <unordered_map>
#include <stack>

#else
#include <bits/stdc++.h>
#endif


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double dbl;
#define pb push_back
#define eb emplace_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
typedef unsigned int uint;


#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


bool debug = 0;
const int MAXN = 1e6 + 100;
const int LOG = 20;
const int mod = 998244353;
const int MX = (1e7);
typedef long long li;

int cnt[MAXN];

int get_C(int n, int k) {
    int val = cnt[n] - cnt[k] - cnt[n - k];
    debug(n,k, val);
    if (val >= 1)
        return 2;
    return 1;
}

int calc(vector<int> &a) {
    int res = 0;
    int n = sz(a);
    for (int i = 0; i < n; ++i) {
        res += (get_C(n-1, i) ) * a[i];
        debug(i, a[i],res);
    }
    res = (res & 1);
    debug(res);
    return res;
}

void solve() {
    for (int i = 1; i < MAXN; ++i) {
        cnt[i] = cnt[i - 1];
        int x = i;
        while (x % 2 == 0) {
            x = x / 2;
            cnt[i]++;
        }
    }
    int n;
    cin >> n;

    vector<int> c(n);
    for (int i = 0; i < n; ++i) {
        char x;
        cin >> x;
        c[i] = x - '1';
    }
    auto a = c;
    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        b[i] = (a[i] & 1);
    }
    debug(a);
    debug(b);

    int val = calc(b);
    if (val == 1) {
        cout << 1 << "\n";
        return;
    }
    for (auto &x : a) {
        if (x == 1) {
            cout << 0;
            return;
        }
        x = x / 2;
    }

    int res = calc(a);
    if (res & 1) {
        cout << 2 << "\n";
    } else {
        cout << 0 << "\n";
    }


}


signed main() {
#ifdef zxc
    freopen("../input.txt", "r", stdin);
//    freopen("../output.txt", "w", stdout);
#else
    //    freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(15);

    int t = 1;
    while (t--)
        solve();


    debug(1.0 * clock() / CLOCKS_PER_SEC);
}




Measured memory_bytes: 15872
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod, fac=[], finv = [];
function fSet(n){
  fac.length = finv.length = n+1;
  fac[0] = finv[0] = 1;
  for(var i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;
  finv[n] = modinv(fac[n]);
  for(var i=n;i>1;i--)finv[i-1]=finv[i]*i%mod;
}
function modinv(a){for(var b=mod,u=1,v=0,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function nCrmod(n,r){return fac[n]*finv[r]*finv[n-r]%mod;}

console.log(main());
function main(){
  var p = o.a();
  var a = o.l();
  mod = p;
  var p1 = p-1;
  fSet(p1);
  var xpow = [];
  xpow.length = p;
  xpow[0] = 1;
  var ans = xArray(0,p);
  if(a[0])ans[0] = 1, ans[p1] = -1;
  for(var i = 1; i < p; i++){
    if(a[i] === 0)continue;
    for(var j = 1; j < p; j++)xpow[j] = -xpow[j-1] * i % p;
    for(var j = 1; j < p; j++){
      var t = -nCrmod(p1,j)*xpow[p1-j]%p+p;
      if(t >= p)t -= p;
      ans[j] += t;
    }
  }
  return ans.map(a=>(a%p+p)%p).join(" ")
}

Measured memory_bytes: 14796
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,k,q,i,j,x,sum=0,sum2=0,mul=1,maxi = INT_MIN;
    cin>>n>>k>>q;
    ll arr[n+3];
    x = k-q;
    for(i = 0 ;i<=n ;i++)
    {
        arr[i]=x;
    }
    for(i = 0 ;i<q;i++)
    {
        cin>>x;
        arr[x]++;
        //cout<<arr[x]<<endl;
    }
    for(i = 1 ;i<=n ;i++)
    {
        if(arr[i]>0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}


Measured memory_bytes: 1408
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

ll calc_one_bit_count(ull a) {
	ll res = 0;
	while (a > 0LL) {
		res += (a & 1LL);
		a >>= 1LL;
	}
	return res;
}

ll get_edge(ll u, ll v) {
	return 1;
}

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

	ll N, M;
	cin >> N;

	ll a, b;
	vector<vector<ll>> edges(N);
	for (ll i = 0; i + 1 < N; ++i) {
		cin >> a >> b;
		edges[a - 1].emplace_back(b - 1);
		edges[b - 1].emplace_back(a - 1);
	}

	vector<ll> rev_tree(N, -1LL);
	rev_tree[N - 1] = N - 1;
	queue<ll> queue;
	queue.push(N - 1);
	while (!queue.empty()) {
		ll node = queue.front();
		queue.pop();
		for (auto next : edges[node]) {
			if (rev_tree[next] != -1) continue;
			rev_tree[next] = node;
			queue.push(next);
		}
	}
	vector<ll> edge_bits(N);
	for (ll i = 0; i + 1 < N; ++i) {
		ll node = i;
		ll edge_bit = 0;
		while (node != N - 1) {
			edge_bit += (1LL << node);
			node = rev_tree[node];
		}
		edge_bits[i] = edge_bit;
	}

	cin >> M;
	vector<pair<ll, ll>> restrictions;
	restrictions.reserve(M);
	for (ll i = 0; i < M; ++i) {
		cin >> a >> b;
		restrictions.emplace_back(a - 1, b - 1);
	}

	ll res = 0;
	for (ll i = 0; i < (1LL << M); ++i) {
		ll set = i;
		ll sign = 1;
		ll edge_union = 0;
		for (ll j = 0; j < M; ++j) {
			if (set & 1LL) {
				sign *= -1LL;
				edge_union |= edge_bits[restrictions[j].first] ^ edge_bits[restrictions[j].second];
			}
			set >>= 1LL;
		}
		res += sign * (1LL << (N - 1LL - calc_one_bit_count(edge_union)));
	}

	cout << res << endl;

	return 0;
}


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

using namespace std;

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

	int i = 0;
	int j = in.size() - 1;
	while(in[i] != 'A') {
		i++;
	}
	while(in[j] != 'Z') {
		j--;
	}

	cout << (j - i + 1) << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    while(true){
      int x=sc.nextInt();
      int y=sc.nextInt();
      if(x==0 && y==0){
         break;
      }
       if(x>y){
          System.out.println(y+" "+x);
       }else if(x<y){
          System.out.println(x+" "+y);
       }else{
          System.out.println(x+" "+y);
       }
    }
  }
}



Measured memory_bytes: 36012
#include <iostream>
#include <queue>
 
int main(){
	std::priority_queue<int> price;
	int n, m;
	int p;
	while(std::cin >> n >> m){
		int sum_price = 0;
		if(n == 0 && m == 0){
			break;
		}
		//各野菜の値段を入力、格納
		for(int i = 0; i < n; ++i){
			std::cin >> p;
			price.push(p);
		}
		//袋詰め
		while(!price.empty()){
			for(int i = 1; i <= m && !price.empty(); ++i){
				if(i != m){
					sum_price += price.top();
					price.pop();
				}
				else{ //最後に袋に入る品物は割引
					price.pop();
				}
			}
		}
		std::cout << sum_price << std::endl;
	}
}

Measured memory_bytes: 1228
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;

//main
int main(){
    int N; cin >> N;
    vector<int> X(N);
    vector<int> Y(N);
    vector<int> H(N);
    int cx, cy;
    int count;
    int hight;
    int base;
    rep(i,N){
        cin >> X[i] >> Y[i] >> H[i];
        if(H[i] > 0) base = i;
    }
    rep(i,101){
        rep(j,101){
            count = 0;
            hight = H[base]+abs(X[base]-i)+abs(Y[base]-j);
            rep(k,N){
                if(max(hight-abs(X[k]-i)-abs(Y[k]-j),0)==H[k]) count += 1;
            }
            if(count == N){
                cx = i;
                cy = j;
                goto endloop;
            }
        }
    }
    endloop:
    cout << cx << " " << cy << " " << H[base]+abs(X[base]-cx)+abs(Y[base]-cy) << endl;
}



Measured memory_bytes: 256
from pprint import pprint
n, w = map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]
ws = [x[0] for x in s]
vs = [x[1] for x in s]
max_v = sum(vs)
INF = float("inf")
dp = [[INF]*(max_v+1) for _ in range(n+1)]
dp[0][0] = 0
for i in range(1, n+1):
    for sum_v in range(max_v+1):
        if vs[i-1] <= sum_v:
            dp[i][sum_v] = min(dp[i-1][sum_v], dp[i-1][sum_v-vs[i-1]]+ws[i-1])
        else:
            dp[i][sum_v] = dp[i-1][sum_v]
ans = 0
for sum_v in range(max_v+1):
    if dp[n][sum_v] <= w:
        ans = sum_v
print(ans)


Measured memory_bytes: 307656
#include <stdio.h>

int main() {
	int X, Y, Z;
	int i,j,k;

	j = 0;

	scanf("%d %d %d", &X, &Y, &Z);

	k = X - (2 * Z);

		for (i=1; j <= k; i++) {
    			j = ((i * Y) + ((i - 1) * Z));

	}
		printf("%d\n", i-2);

	return 0;
}

Measured memory_bytes: 128
/*
 * FileName:     A
 * CreatedDate:  2020-07-05 21:04:31 +0900
 * LastModified: 2020-07-05 21:05:28 +0900
 */

#include <stdio.h>

int main(void){
    int n;scanf("%d", &n);
    for(int i=1;i<11;i++){
        if(n<=1000*i){
            printf("%d\n",1000*i-n);
            return 0;
        }
    }

    return 0;
}


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

int main(){
    int n;
    while(cin >> n, n != 0){
        set<pair<int, int> > st;
        for(int i=0;i<n;++i){
            int x, y;
            cin >> x >> y;
            st.insert(pair<int, int>(x, y));
        }
        int m;
        cin >> m;
        int x = 10, y = 10, gem = 0;
        for(int i=0;i<m;++i){
            char d;
            int a;
            cin >> d >> a;
            for(int j=0;j<a;++j){
                if(d == 'N')y++;
                else if(d == 'E')x++;
                else if(d == 'S')y--;
                else x--;
                if(st.count(pair<int, int>(x,y))){
                    gem++;
                    st.erase(pair<int, int>(x,y));
                }
            }
        }
        if(gem == n)cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3080
use proconio::input;
use num_integer::gcd;

fn main() {
    input! {
        k:u32
    }
    let mut ans = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                ans += gcd(a, gcd(b, c));
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2144
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		int num = sc.nextInt();
		int hp = 0;
		List<Integer> takoyaki = new ArrayList<Integer>();
		takoyaki.add(sc.nextInt()); //1つ目のたこ焼き
		for (int i = 1; i < num; i++) {
			takoyaki.add(sc.nextInt());
			for (int j = 0; j < i; j++) {
				hp = hp + takoyaki.get(i) * takoyaki.get(j);
			}
		}
		System.out.println(hp);

	}
}

Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int minDistance = Integer.MAX_VALUE;
		int resident[][] = new int[h][w];
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				resident[i][j] = sc.nextInt();
			}
		}

		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				minDistance = Math.min(minDistance, calcDistance(i, j, resident));
			}
		}

		System.out.println(minDistance);
	}

	//aもしくはbとcの要素1つ1つとの距離の小さいほうの総和を求めるメソッド
	public static int calcDistance(int a, int b, int[][] c) {
		int total = 0;
		for(int i = 0; i < c.length; i++) {
			for(int j = 0; j < c[0].length; j++) {
				total += c[i][j] * Math.min(Math.abs(a - i), Math.abs(b - j));
			}
		}

		return total;
	}

}



Measured memory_bytes: 29692
from collections import deque

h, w = map(int, input().split())
s = [input() for _ in range(h)]

d_i = [-1, 0, 1, 0]
d_j = [0, -1, 0, 1]

ans = 0
visited = [[False]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if visited[i][j]:
            continue
        b = 0
        wh = 0
        q = deque()
        q.append((i,j))
        visited[i][j] = True
        while len(q) > 0:
            c_h, c_w = q.pop()
            if s[c_h][c_w] == '#':
                b += 1
            else:
                wh += 1
            for dir in range(4):
                n_h = c_h+d_i[dir]
                n_w = c_w+d_j[dir]
                if n_h < 0 or h-1 < n_h or n_w < 0 or w-1 < n_w:
                    continue
                if visited[n_h][n_w]:
                    continue
                if s[c_h][c_w] == s[n_h][n_w]:
                    continue
                q.append((n_h, n_w))
                visited[n_h][n_w] = True
        ans += b*wh
print(ans)

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,d;
    cin >> n >> d;
    vector<ll> x(n);
    vector<ll> y(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    int cnt=0;
    for(int i = 0; i < n; i++) {
        if(d*d>=(x[i]*x[i]+y[i]*y[i])) cnt++;
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 6340
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    cout << N/2+N%2 << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <cstdint>
#include <iostream>
#include <vector>


static std::uint64_t
solve(const std::vector<int>& va, bool isPositive)
{
  std::int64_t sum = 0;
  std::uint64_t cnt = 0;
  for (std::remove_reference<decltype(va)>::type::size_type i = 0; i < va.size(); i++) {
    auto nextSum = sum + va[i];
    if (nextSum >= 0 && isPositive) {
      cnt += nextSum + 1;
      sum = -1;
    } else if (nextSum <= 0 && !isPositive) {
      cnt += -nextSum + 1;
      sum = 1;
    } else {
      sum = nextSum;
    }
    isPositive = !isPositive;
  }
  return cnt;
}


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

  int n;
  std::cin >> n;
  std::vector<int> va(n);
  for (auto&& e : va) {
    std::cin >> e;
  }
  std::cout << std::min(solve(va, true), solve(va, false)) << std::endl;

  return EXIT_SUCCESS;
}


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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x - r < 0) {
        cout << "No" << endl;
    } else if (W < x + r) {
        cout << "No" << endl;
    } else if (y - r < 0) {
        cout << "No" << endl;
    } else if (H < y + r) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
x,y,a,b,c, = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
s = p[:x]+q[:y]+r
s.sort(reverse=True)
print(sum(s[:x+y]))

Measured memory_bytes: 106748
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let (mut num_of_five, mut num_of_seven) = (0, 0);
    input!(v: [i32; 3]);
    for item in v.iter() {
        if *item == 5 {
            num_of_five += 1;
        } else if *item == 7 {
            num_of_seven += 1;
        }
    }
    if num_of_five == 2 && num_of_seven == 1 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M);
    REP(i, M) {
        cin >> L[i] >> R[i];
    }
    int l = L[0], r = R[0];
    REP(i, M) {
        amax(l, L[i]);
        amin(r, R[i]);
    }
    if (l <= r) {
        cout << r - l + 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
using namespace std;

int main() {
    fast
	int t=1;
// 	cin>>t;
	while(t--){
	    float a,b,c,d;
	    cin>>a>>b>>c>>d;
	    float ta=(a/d);
	    float o=(c/b);
	   // cout<<o<<" "<<ta;
	    if((int)ceil(o)>(int)ceil(ta)) cout<<"No";
	    else cout<<"Yes";
	}
	return 0;
}


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

using namespace std;

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  
  s.push_back(t.at(t.size()-1));
  if(s==t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a1,b1,a2,b2,a3,b3;
    ll in1,in2;

    cin>>in1>>in2;
    a1 = min(in1,in2);
    b1 = max(in1,in2);
    cin>>in1>>in2;
    a2 = min(in1,in2);
    b2 = max(in1,in2);
    cin>>in1>>in2;
    a3 = min(in1,in2);
    b3 = max(in1,in2);
    vector<ll> v(4);
    v[a1-1]++;
    v[b1-1]++;
    v[a2-1]++;
    v[b2-1]++;
    v[a3-1]++;
    v[b3-1]++;
    string res = "YES";
    if(v[a1-1]==v[a2-1] && v[b1-1]==v[b2-1]) res = "NO";
    if(v[a3-1]==v[a2-1] && v[b3-1]==v[b2-1]) res = "NO";
    if(v[a1-1]==v[a3-1] && v[b1-1]==v[b3-1]) res = "NO";
    FOR(i,0,4){
      if(v[i]>2 || v[i]==0) res = "NO";
    }
    cout<<res<<endl;
}


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

int main(){
    int N,ans=0;
    cin >> N;
    for (int i = 1;i <= 9;i++){
        for (int j = 1; j <= 9; j++){
            if (N == i*j){
                ans++;
            }
        }
    }
    if (ans > 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    
return 0;
}

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

int main()
{
    int diff = 'a' - 'A';
    string s;

    for (int i = 0; i < 3; i++) {
        cin >> s;
        printf("%c", s[0] - diff);
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define MAXN 100001

using namespace std;

int A[MAXN];

int main()
{
  int N;
  int max = 0;

  cin >> N;

  for ( int i = 0 ; i < N; ++i ) {
    int tmp;
    scanf("%d", &tmp);
    ++A[tmp];
    if ( tmp+1 < MAXN ) ++A[tmp+1];
    if ( tmp-1 >= 0 ) ++A[tmp-1];
  }

  for ( int i = 0; i < MAXN; ++i ) if ( A[i] > max ) max = A[i];

  cout << max << "\n";
}


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

int main(){
  char str[2000];
  int i, j;
  fgets(str, 2000, stdin);
  for(i = 0;i < strlen(str);i++){
    if(strncmp(&str[i], "apple", 5) == 0)strncpy(&str[i], "peach", 5);
    else if(strncmp(&str[i], "peach", 5) == 0) strncpy(&str[i],"apple", 5);
  }
  printf("%s", str);
  return 0;
}

Measured memory_bytes: 524
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int[] parents = Enumerable.Repeat(-1, n).ToArray();
        int[][] childs = new int[n][];
        int[][] res = Enumerable.Range(0, n).Select(_ => new int[n]).ToArray();
        for (int i = 0; i < n; i++)
        {
            var data = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var id = data[0] - 1;
            childs[id] = data.Skip(2).ToArray();
            foreach (var child in childs[id])
            {
                res[id][child - 1] = 1;
            }
        }

        Console.WriteLine(string.Join("\n", res.Select(x => string.Join(" ", x))));
    }
}




Measured memory_bytes: 18428
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

int main(){
  int N;
  cin >> N;
  ll sum=0;
  for(int i=1; i<=N; i++) {
    if(i % 3 == 0 || i % 5 == 0) continue;
    sum += i;
  }
  cout << sum << endl;
}















Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

#define MOD 1000000007
#define INF INT_MAX
#define NINF INT_MIN
#define LLINF LLONG_MAX
using ll = long long;
using namespace std;


int main() {
    ll N, A, B, C, D, E, k;
    cin >> N >> A >> B >> C >> D >> E;
    k = A;
    k = min(k, B);
    k = min(k, C);
    k = min(k, D);
    k = min(k, E);
    cout << max(0LL,(N-1) / k) + 5 << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

const int N=200005;

int s[N];

int main(void) {
	int n,ans=0x3f3f3f3f; scanf("%d",&n);
	rep(i,1,n) s[i]=s[i/10]+i%10;
	rep(i,1,n-1) {
		int a=i,b=n-i;
		if (s[a]+s[b]<ans) ans=s[a]+s[b];
	}
	printf("%d\n", ans);
	return 0;
}

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

int a[500];
int main()
{
	int m, n, k, t, s;
	cin >> m;
 n=0;
	if(m==0)
	printf("0\n");

	s = m;
	while(m != 0){
	k = m % (-2);
	t = m / (-2);
	if(k < 0){
	k = k-(-2);
	t++;
	}
	m = t;
	a[n++]=k;
}
	for(int i=n-1;i>=0;i--){
	cout << a[i];
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class PrintTestCases {
    public static void main(String...args) {
        final Scanner sc = new Scanner(System.in);
        for (int t = 1; ; t++) {
            final int x = sc.nextInt();
            if(x == 0)
                break;
            System.out.printf("Case %d: %d\n", t, x);
        }
    }
}
public class Main {
    public static void main(String... args) {
        PrintTestCases.main();
    }
}

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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;
const int MOD = 1000000007;

void printv(vector<auto> const& s) {
  REP(i, s.size()) {
    cout << s[i] << endl;
  }
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, m; cin >> n >> m;
  vector<P> a, b;
  P p;
  int tmp;
  REP(i, m) {
    cin >> p.fi >> p.se;
    if(p.fi < p.se) {
      swap(p.fi, p.se);
    }
    a.pb(p);
  }

  sort(ALL(a));
  int cnt = 1;
  int now = a[0].fi;
  REP(i, m) {
    if(a[i].se < now) continue;
    now = a[i].fi;
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

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


int main() {
	int i, j, k;
	
	int N, M, K;

	vector<int> A[200000];
	int Q;
	cin >> N >> Q;
	int d[200000] = { 0 };
	rep(i, 0, N - 1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		A[a].push_back(b);
		A[b].push_back(a);
	}
	pairII p[200000];
	rep(i, 0, Q) {
		int a, b;
		cin >> a >> b;
		a--;
		p[i] = make_pair(a, b);
	}
	ll C[200000] = { 0 };


	rep(i, 0, Q) {
		int start = p[i].first;
		int add = p[i].second;
		C[start] += add;
	}
	queue<int> que;
	que.push(0);
	d[0] = 1;
	while (!que.empty()) {
		int a = que.front();
		que.pop();
		for (auto x : A[a]) {
			if (d[x] > 0) {
				continue;
			}
			C[x] += C[a];
			d[x] = d[a] + 1;
			que.push(x);
		}

	}
	rep(i, 0, N) {
		cout << C[i] << " ";
	}
	return 0;

}


Measured memory_bytes: 18676
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) ));
	return (c * c)  ;
}
ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
		

int main(){
	IOS;
	cout.precision(30) ;
	ll n, k ; cin >> n >> k;
	if(k % 2){
		cout << Pow(countDivisibles(1 , n , k) , 3)<< endl ;
	}
	else{
		cout << Pow(countDivisibles(1 , n , k / 2) - countDivisibles(1 , n , k) , 3) + Pow(countDivisibles(1 , n , k) , 3) << endl ;
	}
		
	return 0;
}


Measured memory_bytes: 256