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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    vector<bool> res;
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        vector<pair<int, int>> d(n);
        vector<pair<pair<int, int>, bool>> v(n);
        for (int i = 0; i < n; i++) {
            cin >> d[i].fi >> d[i].se;
            v[i] = {d[i], false};
        }
        int m;
        cin >> m;
        vector<pair<char, int>> c(m);
        for (int i = 0; i < m; i++) {
            cin >> c[i].fi >> c[i].se;
        }
        pair<int, int> cur = {10, 10};
        map<char, int> mp;
        mp['N'] = 0;
        mp['E'] = 1;
        mp['W'] = 2;
        mp['S'] = 3;
        int dy[] = {1, 0, 0, -1};
        int dx[] = {0, 1, -1, 0};
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < c[i].se; j++) {
                int dir = mp[c[i].fi];
                cur.fi += dx[dir];
                cur.se += dy[dir];
                //cout << cur.fi << " " << cur.se << endl;
                for (int k = 0; k < n; k++) {
                    if (cur == v[k].fi) {
                        v[k].se = true;
                    }
                }
            }
        }
        bool check = true;
        for (int i = 0; i < n; i++) {
            if (not v[i].se) {
                check = false;
            }
        }
        res.push_back(check);
    }
    for (int i = 0; i < (int)res.size(); i++) {
        dump(res[i] ? "Yes" : "No");
    }
    return 0;
}



Measured memory_bytes: 3156
# AOJ 1209: Square Coins
#Python3 2018.7.19 bal4u

dp = [1]*300
for i in range(2, 18):
    for j in range(i**2, 300): dp[j] += dp[j-i**2]

while True:
    n = int(input())
    if n == 0: break
    print(dp[n])



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

V<ll> sumn;
V<ll> ans;

ll calc_sum(ll n) { return n * (n + 1) / 2; }

void calc(ll N, ll sum) {
    auto ite = lower_bound(sumn.begin(), sumn.begin() + N, sum);
    ll idx = distance(sumn.begin(), ite);
    ans.push_back(idx + 1);
    sum -= (idx + 1);
    if(sum > 0) calc(idx, sum);
}

int main() {
    ll N;
    cin >> N;
    for(ll i = 1; i <= N; i++) sumn.push_back(calc_sum(i));
    calc(N, N);
    reverse(ALL(ans));
    for(ll e : ans) cout << e << endl;
    return 0;
}


Measured memory_bytes: 133084
// I need some holiday
// But I don't wish that everyday is holiday
// Because I didn't bear the pain
// Because it wasn't a true freedom
//         ——『イヤホンと蝉時雨』·Orangestar

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return cur == ed && (ed = (cur = buffer) + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur == ed) ? EOF : *cur++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

inline char *read_str(char *s)
{
	register char ch(getc());
	while(!isgraph(ch)) ch = getc();
	for(; isgraph(ch); ch = getc()) *s++ = ch;
	*s = '\0';
	return s;
}

// END tpl.

inline char safe_getc()
{
	register char ch(getc());
	while(!isgraph(ch)) ch = getc();
	return ch;
}

const int MAXN = (int) 1e5;

int n;

vector<int> adj[MAXN + 5];

int col[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i < n; ++i)
	{
		int u = read<int>(), v = read<int>();
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(int i = 1; i <= n; ++i) col[i] = safe_getc() == 'B';
}

vector<int> V, G[MAXN + 5];

int dep[MAXN + 5], val[MAXN + 5];

inline int dfs(int u, int fa)
{
	dep[u] = dep[fa] + val[u];

	int p = u;
	for(auto v : adj[u]) if(v != fa)
	{
		int q = dfs(v, u);
		if(dep[q] > dep[p]) p = q;
	}
	return p;
}

inline void solve()
{
	static queue<int> q;
	static int ban[MAXN + 5], deg[MAXN + 5];

	for(int i = 1; i <= n; ++i) if((deg[i] = SZ(adj[i])) == 1 && col[i] == 1) ban[i] = 1, q.push(i);
	while(!q.empty())
	{
		int u = q.front();
		q.pop();

		for(auto v : adj[u]) if(!ban[v] && --deg[v] == 1 && col[v] == 1) ban[v] = 1, q.push(v);
	}

	V.clear();
	for(int u = 1; u <= n; ++u) if(!ban[u])
	{
		V.push_back(u);
		for(auto v : adj[u]) if(!ban[v]) G[u].push_back(v);
	}

	if(SZ(V) == 0) { puts("0"); return; }
	if(SZ(V) == 1) { printf("%d\n", col[V[0]] == 0); return; }

	int ans = 2 * (SZ(V) - 1);
	for(auto i : V)
	{
		col[i] ^= SZ(G[i]) & 1;
		val[i] = col[i] == 0;
		ans += col[i] == 0;
	}

	int S = dfs(V[0], 0);
	int T = dfs(S, 0);
	printf("%d\n", max(0, ans - 2 * dep[T]));
}

int main()
{
#ifdef K_ON
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 17400
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n  = sc.nextLine();
        String str = sc.nextLine();
        String[] astr = str.split(" "); //状況に合わせて
        int flag  = 0;
        int[] in_data = Stream.of(astr).mapToInt(x->{
            try{
                return Integer.parseInt(x);
            }
            catch(Exception e){
                e.printStackTrace();
            }
            return 0;
        }).toArray();
        sc.close();

        for(int i=1;i<=in_data.length;i++){
            if(in_data[i-1] != i){
                flag +=1;
                if(flag > 2){
                    System.out.println("NO");
                    System.exit(0);
                }
            }
        }
        System.out.println("YES");
    }
}

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

int main()
{
	int n, m, l;
	vector<int> v;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> l;
		v.push_back(l);
	}
	sort(v.begin(), v.end(), greater<int>());
	int sum = 0;
	for (int i = 0; i < m; i++) {
		sum += v[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N, K, S = MAP()

if S == 10**9:
	tmp = 1
else:
	tmp = 10**9

ans = [S]*K + [tmp]*(N-K)

print(*ans)

Measured memory_bytes: 8792
#include <iostream>

using namespace std;

#define rep(i,n) for(int i=0; i<(int)(n); i++)

typedef long long ll;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  
  ll x = (b - 1 <= n ? b - 1 : n); 
  cout << a * x / b - a * (x / b) << endl;
  return 0;
}

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

vector<complex<double>> fft(vector<complex<double>> a, bool inverse = false) {
    int n = a.size();
    int h = 0;
    for (int i = 0; 1 << i < n; i++) h++;
    for (int i = 0; i < n; i++) {
        int j = 0;
        for (int k = 0; k < h; k++) j |= (i >> k & 1) << (h - 1 - k);
        if (i < j) swap(a[i], a[j]);
    }
    for (int b = 1; b < n; b *= 2) {
        for (int j = 0; j < b; j++) {
            complex<double> w =
                polar(1.0, (2 * M_PI) / (2 * b) * j * (inverse ? 1 : -1));
            for (int k = 0; k < n; k += b * 2) {
                complex<double> s = a[j + k];
                complex<double> t = a[j + k + b] * w;
                a[j + k] = s + t;
                a[j + k + b] = s - t;
            }
        }
    }
    if (inverse)
        for (int i = 0; i < n; i++) a[i] /= n;
    return a;
}

vector<complex<double>> fft(vector<double> a, bool inverse = false) {
    vector<complex<double>> a_complex(a.size());
    for (int i = 0; i < a.size(); i++) a_complex[i] = complex<double>(a[i], 0);
    return fft(a_complex, inverse);
}

vector<double> convolve(vector<double> a, vector<double> b) {
    int s = a.size() + b.size() - 1;
    int t = 1;
    while (t < s) t *= 2;
    a.resize(t);
    b.resize(t);
    vector<complex<double>> A = fft(a);
    vector<complex<double>> B = fft(b);
    for (int i = 0; i < t; i++) {
        A[i] *= B[i];
    }
    A = fft(A, true);
    a.resize(s);
    for (int i = 0; i < s; i++) a[i] = A[i].real();
    return a;
}

int main(){
    
    string A, B;
    vector<double> a, b, c;
    vector<long> d, ans;
    int sgn = 1;
    cin >> A >> B;
    
    if(A[0] == '0' || B[0] == '0'){
        cout << 0 << endl;
        return 0;
    }
    
    for(int i = 0; i < A.length(); i++){
        if(A[i] == '-'){
            sgn *= -1;
            continue;
        }
        a.push_back((double)(A[i] - '0'));
    }
    
    for(int i = 0; i < B.length(); i++){
        if(B[i] == '-'){
            sgn *= -1;
            continue;
        }
        b.push_back((double)(B[i] - '0'));
    }
    
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    
    c = convolve(a, b);
    for(int i = 0; i < c.size(); i++)
        d.push_back((long)(c[i] + 0.5));
        
    long x;
        
    for(int i = 0; i < d.size(); i++){
        x = d[i];
        ans.push_back(x % 10);
        if(i < d.size() - 1) d[i + 1] += x / 10;
        else if(x / 10 > 0) ans.push_back(x / 10);
    }
    
    if(sgn == -1) cout << '-';
    for(int i = ans.size() - 1; i >= 0; i--)
        cout << ans[i];
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 43900
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int a, b, c;
	cin >> a >> b >> c;
	if (c - a - b < 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << (4 * a * b < (c - a - b)*(c - a - b) ? "Yes" : "No") << endl;
}

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

using namespace std;

int main(void) {
  int row, col;
  cin >> row >> col;
  vector< vector<int> > matrix(row, vector<int>(col));
  vector<int> v(col);
  int num;

  for (int i = 0; i < row; i++){
    for (int j = 0; j < col; j++){
      cin >> matrix[i][j];
    }
  }
  /*
  for (int i = 0; i < row; i++){
    for (int j = 0; j < col; j++){
      cout << matrix[i][j] << " ";
    }
    cout << endl;
  }
  */

  for (int i = 0; i < col; i++){
    cin >> v[i];
  }

  for (int i = 0; i < row; i++){
    int sum = 0;
    for (int j = 0; j < col; j++){
      sum += matrix[i][j] * v[j];
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-10, PI = acos(-1);
const int N = 2e5 + 9, M = 1e5 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

vector<int> adj[N];
bool vis[N];
ll Xs, Ys;

void dfs(int node) {
  if(node > 1e5)
    ++Ys;
  else
    ++Xs;
  vis[node] = 1;
  for(int it: adj[node]) {
    if(vis[it]) continue;
    dfs(it);
  }
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, x, y;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    y += 1e5;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  ll total = 0;
  for (int i = 0; i < N; ++i) {
    if(!vis[i]) {
      Xs = Ys = 0;
      dfs(i);
      total += (Xs * Ys);
    }
  }
  cout << total - n;
  return 0;
}


Measured memory_bytes: 10240
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const ll INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long S;
  scanf("%lld", &S);
  ll u = (INF - S % INF) % INF;
  ll t = (S + u) / INF;
  cout << "0 0 1000000000 1 " << u << ' ' << t << endl;

  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <cstdio>
# include <cmath>
# include <cstring>
# include <string>
# include <cstdlib>
# include <algorithm>
# include <stack>
# include <queue>
# include <vector>
# define maxx (103)
# define Pi (3.14159265358979)
# define inf (2147483647)
using namespace std;
int read() {
	int x=0,f=1;
	char ch;
	while(ch<'0'||ch>'9')  {
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=x*10+ch-'0';
		ch=getchar();
	}
	return f*x;
}
int main() {

	char c;
	int a=0,i;
	
	for(i = 1;i <= 2;i++){
		c=getchar();
		if(c=='9'){
			puts("Yes");
			return 0;
		}
	}
	puts("No");

	return 0;
}

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

using namespace std;

int main(){
	int n,m;
	int ans;
	scanf("%d%d",&n,&m);
	ans = m;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b;
		m += a - b;
		if(m < 0){
			printf("0\n");
			return 0;
		}
		ans = max(ans,m);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1224
def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    SUMA = [0]
    for a in A:
        if SUMA[-1] + a > K: break
        SUMA.append(SUMA[-1] + a)
    SUMB = [0]
    for b in B:
        if SUMB[-1] + b > K: break
        SUMB.append(SUMB[-1] + b)

    ans = 0
    j = len(SUMB) - 1
    for i, suma in enumerate(SUMA):
        while suma + SUMB[j] > K:
            j -= 1
        ans = max(ans, i + j)

    print(ans)


if __name__ == '__main__':
    main()

exit()


Measured memory_bytes: 40684
#include <stdio.h>
#include <string.h>
 
int main(){
	char a[11], b[11], c[11];
	scanf("%s %s %s", &a, &b, &c);
	int lena=strlen(a);
	int lenb=strlen(b);
	
	if(a[lena-1]==b[0] && b[lenb-1] == c[0]){
		printf("YES");
	}
	else {
		printf("NO");
	}
	
	return 0;
}

Measured memory_bytes: 1704
a=int(input())
b=int(input())
c=int(input())
x=int(input())
d=0
for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            if 500*i+100*j+50*k==x:
                d+=1
            else:
                continue
    #if i==a-1:
print(d)
    #else:
        #pass

Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <cstring>
#include <cstdio>
using namespace std;

struct NODE{
	int from,to,speed;
	double cost;
	NODE(int from,int to,int speed,double cost) : from(from) , to(to) , speed(speed) , cost(cost) {
	}
};
bool operator < (const NODE &a,const NODE &b){
	return a.cost > b.cost;
}


vector< vector<NODE> > G;
bool done[32][32][1000] = {};
bool done2[32];

bool dfs(int x,int y){
	if( x == y ) return true;
	if( done2[x] ) return false;
	done2[x] = true;
	for(int i = 0 ; i < G[x].size() ; i++)
		if( dfs(G[x][i].to,y) ) return true;
	return false;
}
int main(){
	int n,m;
	while(cin >> n >> m && n){
		memset(done,0,sizeof(done));
		memset(done2,0,sizeof(done2));
		int s,g;
		cin >> s >> g;
		s--,g--;
		G.clear();
		G.resize(n);
		for(int i = 0 ; i < m ; i++){
			int a,b,c,d;
			cin >> a >> b >> d >> c;
			a--,b--;	
			G[a].push_back(NODE(a,b,c,d));
			G[b].push_back(NODE(b,a,c,d));
			//cout << a << " " << b << " " << c << " " << d << endl;
		}
		if( !dfs(s,g) ){
			cout << "unreachable" << endl;
			continue;
		}
		priority_queue<NODE> Q;
		
		Q.push(NODE(n,s,0,0));
		while(Q.size()){
			NODE q = Q.top(); Q.pop();
			if( q.speed >= 1000) continue;
			if( done[q.from][q.to][q.speed] ) continue;
			else done[q.from][q.to][q.speed] = true;
			if( q.to == g && q.speed == 1 ){
				printf("%.10lf\n",q.cost);
				goto exit;
			}
			for(int i = 0 ; i < G[q.to].size() ; i++){
				if( q.speed+0 > 0 && q.speed+0 <= G[q.to][i].speed && q.from != G[q.to][i].to ) Q.push(NODE(q.to,G[q.to][i].to,q.speed+0,q.cost+G[q.to][i].cost / (q.speed+0)));
				if( q.speed+1 > 0 && q.speed+1 <= G[q.to][i].speed && q.from != G[q.to][i].to ) Q.push(NODE(q.to,G[q.to][i].to,q.speed+1,q.cost+G[q.to][i].cost / (q.speed+1)));
				if( q.speed-1 > 0 && q.speed-1 <= G[q.to][i].speed && q.from != G[q.to][i].to ) Q.push(NODE(q.to,G[q.to][i].to,q.speed-1,q.cost+G[q.to][i].cost / (q.speed-1)));
			}
		}
		cout << "unreachable" << endl;
		exit:;
	}
}

Measured memory_bytes: 10000
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    System.out.println((A - B) % 2 == 0 ? "Alice" : "Borys");
  }

}


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

vector<int> num;
vector<vector<int>> e;

void dfs(int v,int now,int x){
    num[v] += x;
    for(auto p:e[v]){
        if(p == now)continue;
        dfs(p,v,num[v]);
    }
}

int main(void){
    int n,q;cin >> n >> q;
    int a[n],b[n],p[q],x[q];
    num.resize(n);
    e.resize(n);
    
    rep(i,n-1){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        e[a[i]].push_back(b[i]);
        e[b[i]].push_back(a[i]);
    }
    rep(i,q){
        cin >> p[i] >> x[i];
        p[i]--;
        num[p[i]] += x[i];
    }
    
    dfs(0,-1,0);
    
    rep(i,n)cout << num[i] << " "; 
}

Measured memory_bytes: 27452
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=2e5;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int a[N];
int head[N],nxt[N],to[N];
inline LL dfs(int k,int fa) {
	if (!nxt[head[k]])
		return a[k];
	LL s=a[k]<<1,t;
	for (int i=head[k];i;i=nxt[i])
		if (to[i]!=fa) {
			t=dfs(to[i],k);
			if (t>a[k]) puts("NO"),exit(0);
			s-=t;
		}
	if (s<0||s>a[k]) puts("NO"),exit(0);
	return s;
}
inline bool check(int n) {
	int i;
	for (i=1;i<=n;i++)
		if (nxt[head[i]])
			return !dfs(i,0);
	return a[1]==a[2];
}
int main()
{
	int n=gi(),i,a,b,tot=0;
	for (i=1;i<=n;i++) ::a[i]=gi();
	for (i=1;i<n;i++) {
		a=gi(),b=gi();
		to[++tot]=b,nxt[tot]=head[a],head[a]=tot;
		to[++tot]=a,nxt[tot]=head[b],head[b]=tot;
	}
	puts(check(n)?"YES":"NO");
	return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int N;
int A[100010];
int B[100010];
int C[100010];


llint solve(){
	llint ans = 0;
	rep(i, 0, N){
		llint a = lower_bound(RNG(A, N), B[i])-&A[0];
		llint c = N-(upper_bound(RNG(C, N), B[i])-&C[0]);
		ans += a*c;
	}
	return ans;
}


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N) cin >> B[i];
	rep(i, 0, N) cin >> C[i];
	sort(RNG(A, N)), sort(RNG(B, N)), sort(RNG(C, N));
	
	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;
public class Main {
 public static void main(String[] args){
     Scanner sc=new Scanner(System.in);
     int x,y,z,i=0,a;
     x=sc.nextInt();
     y=sc.nextInt();
     z=sc.nextInt();
     for(a=x;a<=y;a++){
    	 if(z%a==0)
    		 i=i+1;
     }
     
     System.out.println(i);
    sc.close();
 }
     
     
}


Measured memory_bytes: 26408
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

N, M = map(int, input().split())

#MOD = 10 ** 9 + 7
SIZE = 10 ** 6 + 100
g1, g2, inv = [1, 1], [1, 1], [0, 1]
for i in range(2, SIZE + 1):
    g1.append((g1[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    g2.append((g2[-1] * inv[-1]) % MOD)
def nCr(n, r):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % MOD
def nPr(n, r):
    if r < 0 or r > n:
        return 0
    return g1[n] * g2[n - r] % MOD

tmp = nPr(M, N)
for i in range(1, N + 1):
    if i % 2:
        tmp -= nCr(N, i) * nPr(M - i, N - i)
    else:
        tmp += nCr(N, i) * nPr(M - i, N - i)
print((nPr(M, N) * tmp) % MOD)

Measured memory_bytes: 167384
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

int main() {
	long long n, m;
	cin >> n >> m;
	vector<long long> x(n), y(m);
	long long X = 0, Y = 0;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		if (i > 0) X = mod(X + (x[i] - x[i-1]) * i % MOD * (n-i) % MOD);
	}
	for (int i = 0; i < m; i++) {
		cin >> y[i];
		if (i > 0) Y = mod(Y + (y[i] - y[i-1]) * i % MOD * (m-i) % MOD);
	}
	long long ans = mod(X * Y);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4348
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

H, W, K = map(int, input().split())
A = [0] * H
for i in range(H):
    A[i] = input()

X = [[0] * W for _ in range(H)]
cur = 1
for i in range(H):
    if A[i].count('#') == 0:
        continue

    j = 0
    k = A[i].find('#')
    while j <= k:
        X[i][j] = cur
        j += 1
    while j < W:
        while j < W and A[i][j] == '.':
            X[i][j] = cur
            j += 1
        if j < W:
            cur += 1
            X[i][j] = cur
        j += 1
    cur += 1

for i in range(H - 2, -1, -1):
    for j in range(W):
        if X[i][j] == 0:
            X[i][j] = X[i + 1][j]
for i in range(1, H):
    for j in range(W):
        if X[i][j] == 0:
            X[i][j] = X[i - 1][j]

for i in range(H):
    print(*X[i])

Measured memory_bytes: 75720
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = sc.nextInt()
    val b = sc.nextInt()

    if ((b - a) % 2 == 0) {
        println("Alice")
    } else {
        println("Borys")
    }
}


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

int main() {
  int a,b;
  cin >> a >> b;
  int c = (a + b) / 2;
  double d = (a + b) / 2.0;
  if (d - c == 0.0){
    cout << c << endl;
  }
  else {
    cout << c + 1 << endl;
  }
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

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

int main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    //cout << (((((max(a, b) - min(a, b)) <= d) && ((max(b, c) - min(b, c)) <= d)) || (((max(a, c) - min(a, c))) <= d)) ? "Yes" : "No") << endl;
    cout << (((abs(a - b) <= d) && abs(b - c) <= d) || abs(a - c) <= d ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val n = jin.readLine().toInt()
    var tokenizer = StringTokenizer(jin.readLine())
    val colors = intArrayOf(0) + IntArray(n) { tokenizer.nextToken().toInt() }
    val adj = Array(n + 1) { mutableListOf<Int>() }
    for (j in 2..n) {
        tokenizer = StringTokenizer(jin.readLine())
        val a = tokenizer.nextToken().toInt()
        val b = tokenizer.nextToken().toInt()
        adj[a].add(b)
        adj[b].add(a)
    }
    val parent = IntArray(n + 1)
    val answer = LongArray(n + 1) { (n.toLong() * (n + 1).toLong()) / 2L }
    val subTree = IntArray(n + 1) { 1 }
    subTree[0] = Int.MIN_VALUE
    val DUMMY_MAP = mutableMapOf<Int, Int>()
    val specific = Array(n + 1) { DUMMY_MAP }
    val stack = Stack<Int>()
    stack.push(-1)
    while (stack.isNotEmpty()) {
        var a = stack.pop()
        if (a < 0) {
            a *= -1
            stack.push(a)
            for (b in adj[a]) {
                if (b != parent[a]) {
                    parent[b] = a
                    stack.push(-b)
                }
            }
        } else {
            var bestChild = 0
            for (b in adj[a]) {
                if (b != parent[a]) {
                    subTree[a] += subTree[b]
                    val amt = subTree[b] + (specific[b][colors[a]] ?: 0)
                    answer[colors[a]] -= (amt.toLong() * (amt + 1).toLong()) / 2L
                    if (subTree[b] > subTree[bestChild]) {
                        bestChild = b
                    }
                }
            }
            if (bestChild == 0) {
                specific[a] = mutableMapOf<Int, Int>()
            } else {
                specific[a] = specific[bestChild]
                for (b in adj[a]) {
                    if (b != parent[a] && b != bestChild) {
                        for ((color, amt) in specific[b]) {
                            specific[a][color] = (specific[a][color] ?: 0) + amt
                        }
                    }
                }
            }
            specific[a][colors[a]] = -subTree[a]
        }
    }
    for (color in 1..n) {
        val amt = subTree[1] + (specific[1][color] ?: 0)
        answer[color] -= (amt.toLong() * (amt + 1).toLong()) / 2L
    }
    answer[0] = 0
    println(answer.joinToString("\n").substring(2))
}

Measured memory_bytes: 165000
s = int(input())
count = 0
if s == 1 or s == 2:
  count = 0
else:
  while s != 4:
    if s % 2 == 0:
      s = s // 2
    else:
      s = s * 3 + 1
    count += 1
print(count + 4)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<set>
using namespace std;

typedef long long ll;

#define BLACK false
#define WHITE true 

const ll MAX = 1000000;
const ll INF = 1000000;
ll N, M;
vector<pair<ll, ll > > g[MAX];
bool color[MAX];
ll w[MAX];

bool dfs(ll tmp, ll pos){
    if(color[tmp]){
        color[tmp] = BLACK;
        w[tmp] = pos;
        vector<pair<ll, ll > >  next;
        next = g[tmp];
        for(ll i=0; i<next.size(); i++){
            pair<ll, ll > next_p = next[i];
            ll next_edge = next_p.first;
            ll next_d = next_p.second;
            if(!dfs(next_edge, next_d + pos)){
                return false;
            }
        }
    }else if(w[tmp]!=INF && w[tmp]!=pos){
        return false;
    }
    return true;
}
int main(){
    cin >> N >>  M;
    ll l, r, d;
    for(ll i=0; i<M; i++){
        cin >> l >> r >> d;
        l--; r--;
        g[l].push_back(make_pair(r, d));
        g[r].push_back(make_pair(l, -d));
    }
    for(ll i=0; i<N; i++){
        color[i] = WHITE;
        w[i] = INF;
    }

    bool flag;
    flag = true;
    for(ll i=0; i<N && flag; i++){
        if(color[i]){
            flag = dfs(i, 0);
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 45952
N = int(input())
str = input().split()
A = []
A.append(0)
for i in range(N):
    A.append(int(str[i]))
A.append(0)
SUM = 0
distance = []

for i in range(1,N+2):
    distance.append(abs(A[i] - A[i-1]))
    SUM = SUM + abs(A[i]-A[i-1])

for i in range(1,N+1):
    print(SUM - distance[i] - distance[i-1] + abs(A[i+1] - A[i-1]))

Measured memory_bytes: 18864
import math

n, d = map(int, input().split())
a_list = []
result = 0
count = 0
while count < n:
    a_list.append(list(map(int, input().split())))
    count += 1

def calculate_distance(a, b, axis_count):
    hoge = 0
    for i in range(axis_count):
        hoge += abs((a[i] - b[i])**2)
    return math.sqrt(hoge)

for i in range(n):
    for j in range(n-i):
        distance = calculate_distance(a_list[i], a_list[j+i], d)
        if distance != 0 and distance.is_integer():
            result += 1
print(result)




Measured memory_bytes: 3064
H,W=map(int,input().split())
list = []
for i in range(H):
  list.append(input())
result = ['']*H
for j in range(H):
  for k in range(W):
    if list[j][k] == '#':
      result[j] = result[j] + '#'
    else:
      count = 0
      for n in range(-1,2):
        for m in range(-1,2):
          if 0 <= n+j and n+j <=(H-1) and 0<= m+k and m+k <=(W-1):
            if list[n+j][m+k] == '#':
              count += 1
      result[j] = result[j] + str(count)
for x in range(H):
	print(result[x])

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
ll MOD = 1000000007ll;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define Se second
#define Fi first
#define rep(i, n) for(int i=0;i<n;i++)
#define pb(x) push_back(x)

const int MX = 20005;

int main()
{
	int N;
	scanf("%d", &N);
	ll ans = 1, m = 1;
	for(int i = 1; i <= N; i++){
		int a;
		scanf("%d", &a);
		ans = ans*3;
		if(a%2 == 1);
		else m = m*2;
	}
	printf("%lld\n", ans - m);
}


Measured memory_bytes: 256
#coding:utf-8
from copy import deepcopy

n = int(input())
c = ["white" for i in range(n)]
d = [0 for i in range(n)]
f = [0 for i in range(n)]
S = []
class DFS:
    def __init__(self, key, color="white",nex=None):
        self.color = color
        self.nex = nex
        self.key = key

objListCopy = [DFS(i+1) for i in range(n)]
for i in range(n):
    data = list(map(int,input().split()))
    times = data[1]
    obj = objListCopy[i]
    for j in range(times):
        index = data[2+j] - 1
        nextobj = DFS(index+1)
        obj.nex = nextobj
        obj = obj.nex


time = 1
objList = objListCopy[:]
def check(first,time):
    obj = objList[first]
    c[first] = "gray"
    d[first] = time
    f[first] = time
    S.append(first+1)
    
    while S != []:
        index = S[-1] - 1
        u = objList[index]
        v = u.nex
        
        time += 1
        if v != None:
            if c[v.key - 1] == "white":
                objList[index] = v
                index = v.key - 1
                v = objList[index]
                c[v.key-1] = "gray"
                d[index] = time
                S.append(v.key)

            else:
                objList[index] = v
                time -= 1
                
        else:
            S.pop()
            c[u.key-1] = "black"
            f[index] = time
    return time


for i in range(n):
    if f[i] == 0:
        objList = deepcopy(objListCopy)
        time = check(i,time) + 1
        

k = 1
for i,j in zip(d,f):
    print(k,i,j)
    k += 1


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

#define INF (1<<31)-1
#define LINF (1LL<<63)-1LL
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){

    bool flag=false;
    ll ans=0,sum=0;

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

    //cout <<fixed<<setprecision(16)<< << endl;

    if(a == b)cout << "Draw" <<endl;
    else if(a==1)cout << "Alice" <<endl;
    else if(b==1)cout << "Bob" <<endl;
    else if(a > b)cout << "Alice" <<endl;
    else cout << "Bob" <<endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        int ct = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] a = new int[ct+1];
        for (var i = 0; i < ct; i++)
        {
            a[i+1] = int.Parse(input[i]);
        }

        int[] b = new int[ct+1];
        for (var i = ct; i > 0; i--)
        {
            b[i] = a[i];
            for (var j = i*2; j <= ct; j += i)
            {
                b[i] = (b[i]+b[j])%2;
            }
        }

        int M = 0;
        for (var i = 1; i <= ct; i++)
        {
            M += b[i];
        }
        Console.WriteLine(M);
        for (var i = 1; i <= ct; i++)
        {
            if (b[i] > 0)
            {
                Console.Write(i);
                Console.Write(" ");
            }
        }
        Console.WriteLine();
        Console.ReadLine();
    }
}


Measured memory_bytes: 25820
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))

inf = 10**9+7
mod = 10**9+7
n, k = map(int, input().split())
g_val = [list(map(int, input().split())) for i in range(n)]
netalist = [False for i in range(n+1)]
netanum = [0 for i in range(n+1)]
g_val.sort(key=lambda x: x[1])
used_list = []
ans = [0 for i in range(k+1)] # i種類食べた時の最大値
preans = 0
for j in range(k):
    if g_val:
        g,v = g_val.pop()
        netalist[g] = True
        netanum[g]+=1
        used_list.append((v,g))
        preans+=v

kind = sum(list(map(int, netalist)))
ans[kind] = preans+(kind*kind)

import heapq # 優先度付きキュー(最小値取り出し)
heapq.heapify(used_list)   # ヒープ化


while used_list:
    v,g = heapq.heappop(used_list) # 最小値の取り出し
    if netanum[g] > 1:
        while g_val:
            gnew,vnew = g_val.pop()
            if netanum[gnew] == 0:
                ans[kind+1] = ans[kind]-v-(kind*kind)+vnew+((kind+1)*(kind+1))
                kind+=1
                netanum[g] -= 1
                netanum[gnew] += 1
                break
    if not g_val:
        break
print(max(ans))

Measured memory_bytes: 81752
#065c
import math
N,M = map(int, input().split())

devided_number = 7 + 10**9

if abs(N-M)>=2:
    print(0)
elif abs(N-M)==1:
    #数が多い方が先頭になる
    print(math.factorial(N)*math.factorial(M)%devided_number)
else:
    #どっちでも先頭に持ってこれる
    print(math.factorial(N)*math.factorial(M)*2%devided_number)

Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
string a,b;
vector<int> p[26],q[26][26],z[26][26][26],s,x;
void R(){
	string t;cin>>t;
	for(int i=0;i<t.size();i++)s.push_back(t[i]-'a');
	for(int i=0;i<t.size();i++){
		p[s[i]].push_back(i);
		if(i)q[s[i-1]][s[i]].push_back(i-1);
		if(i>1)z[s[i-2]][s[i-1]][s[i]].push_back(i-2);
	}
}
int Xd(){x.clear();
	for(int i=0;i<a.size();i++)x.push_back(a[i]-'a');
	if(x.size()==1)return p[x[0]].size()?p[x[0]][0]:-1;
	if(x.size()==2)return q[x[0]][x[1]].size()?q[x[0]][x[1]][0]+1:-1;
	if(x.size()==3)return z[x[0]][x[1]][x[2]].size()?z[x[0]][x[1]][x[2]][0]+2:-1;
	for(int i=0;i<z[x[0]][x[1]][x[2]].size();i++){
		int k=z[x[0]][x[1]][x[2]][i],w=x.size()-1;
		if(k+w<s.size()){
			bool o=1;
			for(int j=k+3;j<=k+w;j++)if(s[j]!=x[j-k])o=0;
			if(o)return k+w;
		}
	}return -1;
}
int Yd(){x.clear();
	for(int i=0;i<b.size();i++)x.push_back(b[i]-'a');
	if(x.size()==1)return p[x[0]].size()?p[x[0]][p[x[0]].size()-1]:-1;
	if(x.size()==2)return q[x[0]][x[1]].size()?q[x[0]][x[1]][q[x[0]][x[1]].size()-1]:-1;
	if(x.size()==3)return z[x[0]][x[1]][x[2]].size()?z[x[0]][x[1]][x[2]][z[x[0]][x[1]][x[2]].size()-1]:-1;
	for(int i=z[x[0]][x[1]][x[2]].size()-1;i>=0;i--){
		int k=z[x[0]][x[1]][x[2]][i],w=x.size()-1;
		if(k+w<s.size()){
			bool o=1;
			for(int j=k+3;j<=k+w;j++)if(s[j]!=x[j-k])o=0;
			if(o)return k;
		}
	}return -1;
}
int main(){
	R();int m;cin>>m;
	while(m--){
		cin>>a>>b;int l=Xd(),r=Yd();
		if(r!=-1&&l!=-1&&r>=l-a.size()+1&&l+1<=r+b.size())cout<<r-l+b.size()+a.size()-1<<endl;
		else cout<<"0"<<endl;
	}
	return 0;
}

Measured memory_bytes: 10140
n=int(input())

right=n//100
left=n//105-1

while left<=right:

    middle=(left+right)//2
    #print(middle)
    if 100*middle<=n and n<=105*middle:
        print(1)
        exit()
    elif n<100*middle:
        right=middle
    else:
        left=middle+1
print(0)

Measured memory_bytes: 38480
import java.util.*;
import java.math.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a <= b && b <= c) {
            int temp = a;
            a = c;
            c = temp;
        } else if (a <= c && c <= b) {
            int temp = a;
            a = b;
            b = temp;
        } else if (b <= a && a <= c) {
            int temp = a;
            a = c;
            c = temp;
        } else if (b <= c && c <= a) {
        } else if (c <= a && a <= b) {
            int temp = a;
            a = b;
            b = temp;
        } else if (c <= b && b <= a) {
        }
            
        BigInteger A, B, C, ans;
        A = new BigInteger(Integer.toString(a));
        B = new BigInteger(Integer.toString(b));
        C = new BigInteger(Integer.toString(c));
        BigInteger two = new BigInteger("2");
        if (a%2==0||b%2==0||c%2==0) ans = BigInteger.ZERO;
        else ans = ((((A.add(BigInteger.ONE)).divide(two)).subtract(A.divide(two))).multiply(B)).multiply(C);
        System.out.println(ans);
        
    }
}
    


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

int sum_e_ord (int i) {
    int sum, temp;
    
    sum = 0;
    temp = i;
    for (int j = 0; j < 6 ; j++){
        sum += temp%10;
        temp = temp/10;
    }
    
    return sum;
}

int main() {
    int N, res, A, B;
    res = pow(10, 5);
    cin >> N;

    A = ceil(N/2);

    for (int i = 1; i <= A; i++){
        int A_d = sum_e_ord(i);
        int B_d = sum_e_ord(N-i);

        if (res > A_d + B_d){
            res = A_d + B_d;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30; 



int main(){
	ll A,B,a,ans,mul;
	ans = 1;
	cin >> A >> B;
	ll n = __gcd(A,B);

	for(int i = 2;i < sqrt(n);i++){
		a = 0;
		while(n % i == 0){
			n /= i;
			a++;
		}
		if(a != 0){
			ans++;
		}
	}
	if (n > 1){
		ans++;
	}

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

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <unordered_map>
#include <array>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <random>
#include <numeric>

#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;


const int MAX_N = 100000;
int N;
int a[MAX_N], b[MAX_N];
ll A[MAX_N];
                            
struct edge { int to, cost; };
const int MAX_V = MAX_N, INF = 10000000;

// Vの初期化を忘れない。
int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
  fill(d, d+V, INF);
  priority_queue<Pii, vector<Pii>, greater<Pii> > pque;
  d[s] = 0;
  pque.push(Pii(0, s));


  while (!pque.empty()) {
    Pii p = pque.top(); pque.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < (int)G[v].size(); ++i) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost; 
        pque.push(Pii(d[v]+ e.cost, e.to));
      }
    }
  }
}

ll rec(int v) {
  if (G[v].size() == 1) return A[v];

  vector<ll> vec;
  for (int i = 0; i < G[v].size(); ++i) {
    int u = G[v][i].to;
    if (d[v] > d[u]) continue;
    vec.push_back(rec(u));
  }
  
  ll sum = 0;
  for (int i = 0; i < vec.size(); ++i) {
    if (vec[i] < 0) return -1;
    sum += vec[i];
  }

  ll res = 2*A[v] - sum;
  if (res < 0) return -1;
  vec.push_back(res);

  for (int i = 0; i < vec.size(); ++i) {
    if (vec[i] > A[v]) return -1;
  }

  return res;
}

int main() {
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N-1) {
    cin >> a[i] >> b[i]; a[i]--; b[i]--;
  }


  V = N;
  for (int i = 0; i < N-1; ++i) {
    G[a[i]].push_back((edge){b[i], 1});
    G[b[i]].push_back((edge){a[i], 1});
  }

  if (N == 2) {
    if (A[0] == A[1]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
  }

  int root = 0;
  for (int i = 0; i < N; ++i) {
    if (G[i].size() != 1) {
      root = i; break;
    }
  }

  dijkstra(root);

  if (rec(root) != 0) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }

  return 0;
}


Measured memory_bytes: 15744
#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 = 1001001001;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> ans(3);
  ans.at(0) = a+b;
  ans.at(1) = a-b;
  ans.at(2) = a*b;
  sort(ans.begin(),ans.end());
  cout << ans.at(2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
int main() {
	int n, q;
	std::cin >> n >> q;
	std::vector<std::priority_queue<int>> ques(n);
	for (auto i = 0; i < q; ++i) {
		int a, t, x;
		std::cin >> a;
		switch (a) {
		case 0: std::cin >> t >> x;
			ques[t].push(x);
			break;
		case 1: std::cin >> t;
			if (ques[t].size() != 0) {
				std::cout << ques[t].top() << std::endl;
			}break;
		default: std::cin >> t;
			if (ques[t].size() != 0) {
				ques[t].pop();
			}
		}
	}
}


Measured memory_bytes: 4044