akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
using namespace std;
int main(){
    vector<int>vec(3);
    REP(i,3) cin >> vec[i];

    SORT(vec);

    cout << (vec[0]*vec[1])/2 <<endl;


}

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

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

  while(1){
    if (s.size() >= 7) {
      if (s.substr(s.size()-7) == "dreamer"){
        //cout << s.substr(s.size()-7) << endl;
        s.erase(s.size()-7);
        //cout << s << endl;
        continue;
      }
    }

    if (s.size() >= 6) {
      if (s.substr(s.size()-6) == "eraser"){
        //cout << s.substr(s.size()-6) << endl;
        s.erase(s.size()-6);
        //cout << s << endl;
        continue;
      }
    }

    if (s.size() >= 5) {
      if (s.substr(s.size()-5) == "dream" || s.substr(s.size()-5) == "erase"){
        //cout << s.substr(s.size()-5) << endl;
        s.erase(s.size()-5);
        //cout << s << endl;
        continue;
      }
    }

    break;
  }

  if (s.size() == 0) cout <<"YES" << endl;
  else cout << "NO" << endl;

}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
db p[MAXN],q[MAXN];
void Solve() {
    int a;
    for(int i = 1 ; i <= 6 ; ++i) {read(a);p[i] = a / 100.0;}
    for(int i = 1 ; i <= 6 ; ++i) {read(a);q[i] = a / 100.0;}
    db l = 0,r = 1;
    int cnt = 200;
    while(cnt--) {
	db l1 = l + (r - l) / 3,r1 = r - (r - l) / 3;
	db a1 = 0,a2 = 0;
	for(int i = 1 ; i <= 6 ; ++i) {
	    a1 += max(l1 * p[i],(1 - l1) * q[i]);
	    a2 += max(r1 * p[i],(1 - r1) * q[i]);
	}
	if(a2 > a1) r = r1;
	else l = l1;
    }
    db ans = 0;
    for(int i = 1 ; i <= 6 ; ++i) {
	ans += max(l * p[i],(1 - l) * q[i]);
    }
    printf("%.10lf\n",ans);
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int n;
void dfs(string cur,char maxx)
{
    if((int)cur.length()==n)
    {
        cout<<cur<<endl;
        return;
    }
    for(char c='a';c<=maxx;c++)
        dfs(cur+c,maxx);
    char next=maxx+1;
    dfs(cur+next,next);
    return;
}
int main()
{
    scanf("%d",&n);
    dfs("a",'a');
    return 0;
}


Measured memory_bytes: 1536
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;

int N;
vector<int> A, B, C;

void solve() {
	int N;
	cin >> N;
	A.resize(N+2);
	B.resize(N+2);
	C.resize(N+2);
	A[0] = 0;
	A[N + 1] = INT_MAX;
	for (int n = 0; n < N; n++) cin >> A[n];
	B[0] = 0;
	B[N + 1] = INT_MAX;
	for (int n = 0; n < N; n++) cin >> B[n];
	C[0] = 0;
	C[N + 1] = INT_MAX;
	for (int n = 0; n < N; n++) cin >> C[n];
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());
	long long ans = 0;
	for (int n = 1; n <= N; n++) {
		int s = 0, e = N+1;
		while (e - s > 1) {
			int m = (e + s) / 2;
			if (A[m] < B[n])s = m;
			else e = m;
		}
		long long tempans = s;
		s = 0, e = N + 1;
		while (e - s > 1) {
			int m = (e + s) / 2;
			if (C[m] <= B[n])s = m;
			else e = m;
		}
		ans += tempans * (long long)(N - s);
	}
	cout << ans << endl;
	return;
}

Measured memory_bytes: 1408
import sys
Sd = input()
T = input()
candidate = []
ans = ""

for i in range(len(Sd) - len(T) + 1):
    flag = True
    for j in range(len(T)):
        if Sd[i+j] != T[j] and Sd[i+j] != "?":
            flag = False
    if flag:
        candidate.append(Sd[:i] + T + Sd[i+len(T):])

if not candidate:
    print("UNRESTORABLE")
    sys.exit(0)

for i in candidate:
    s = ""
    for j in i:
        if j =="?":
            s += "a"
        else:
            s += j
    if ans =="":
        ans = s
    else:
        ans = min(ans, s)
print(ans)


Measured memory_bytes: 3064
import sys
from itertools import combinations
import math


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


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()

for i in range(1, 10):
    for q in range(1, 10):
        if i * q == N:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  int n;cin>>n;
  int ans = 0;
  int k = 0;
  for(int i=1;i<=n;i++){
    k = 0;
    if(i%2){
      for(int j=1;j<=n;j++){
        if(i%j==0)k++;
      }
    }
    if(k==8)ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
const ll MOD = 998244353;
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}

const int N = 100100;
int a[N];
using namespace std;
int main()
{

	int n;
	scanf("%d", &n);
	int x;
	scanf("%d", &x);
	if (x != 0) {
		printf("0\n");
		return 0;
	}
	a[0] = 1;
	for (int i = 1; i < n; i++) {
		scanf("%d", &x);
		a[x]++;
	}
	if (a[0] != 1) {
		printf("0\n");
		return 0;
	}
	while(a[n] == 0) n--;
	ll ans = 1;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < a[i + 1]; j++)
			ans = mult(ans, a[i]);
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	ll A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;
	
	ll dif = V - W;
	bool ans = true;
	
	if (dif <= 0) puts("NO");
	else {
		ll dl = abs(B - A);
		ll t = (dl + dif - 1) / dif;
		ans = t <= T;
		puts([&] {
			return ans;
		}() ? "YES": "NO");
	}
	
	return 0;
}


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

int main(void){
    int h, w, dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
    char m[55][55];
    cin >> h >> w;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin >> m[i][j];
        }
    }
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(m[i][j]!='#') continue;
            int flg=1;
            for(int k=0;k<4;++k){
                if((i+dy[k]) >= h || (i+dy[k]) < 0 || (j+dx[k]) >= w || (j+dx[k]) < 0) continue;
                if(m[i+dy[k]][j+dx[k]]=='#') flg=0;
            }
            if(flg){
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 256
fun main(args:Array<String>):Unit{
    val (n, c) = readLine()!!.split(' ').map(String::toInt)
    val differ = Array(c){
        readLine()!!.split(' ').map(String::toInt).toTypedArray()
    }
    val currentColor = Array(n){
        readLine()!!.split(' ').map{it.toInt() - 1}.toTypedArray()
    }
    val colors = (0 until 3).map{mod ->
        val array = Array(c){0}
        for (x in 0 until n){
            for (y in (3 * n - x + mod) % 3 until n step 3){
                array[currentColor[x][y]]++
            }
        }
        array
    }.toTypedArray()
    var min = Int.MAX_VALUE
    for (i in 0 until c){
        for (j in 0 until c){
            if (i != j){
                for (k in 0 until c){
                    if (i != k && j != k){
                        var sum = 0
                        for (color in 0 until c){
                            sum += colors[0][color] * differ[color][i] + colors[1][color] * differ[color][j] + colors[2][color] * differ[color][k]
                        }
                        if (min > sum)
                            min = sum
                    }
                }
            }
        }
    }
    println(min)
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 201

#define ll long long
#define ld long double
#define vi vector<string>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define print(v) for (auto i: v) cerr << i << " ";

int main() {
    fast
    string s,t;
    cin>>s>>t;
    ll flag=0;
    REP(i,0,s.size())if(s[i]!=t[i])flag=1;
    if(flag==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;

int gs(int x, int y, int z) {
    return x * x + y * y + z * z + x * y + y * z + z * x;
}

void solve(int n) {

    int ret = 0;

    for (int x = 1; gs(x, 1, 1) <= n; ++x) {
        for (int y = 1; gs(x, y, 1) <= n; ++y) {
            int z = 1;
            while (gs(x, y, z) < n)
                ++z;
            if (gs(x, y, z) == n)
                ++ret;
        }
    }

    cout << ret;
}

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

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    //int tt; cin >> tt; while(tt--) {solve(); cout << "\n";}

    int n; cin >> n;


    for (int i = 1; i <= n; ++i) {
        solve(i);
        cout << "\n";
    }


}

/*
*/



Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define TRACE(x) cerr << #x << " = " << x << endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define SZ(x) (int)(x).size()
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
 
template<class Num>
Num mabs(Num A){
  if(A < 0) return -A;
  return A;
}

const int N = 1e5 + 10;

ll n;
int x, m;
int past[N];
int seq[N];

int main(){
  scanf("%lld %d %d", &n, &x, &m);
  ll ans = (ll)x;
  past[x] = 1;
  seq[1] = x;
  
  int last = x;
  
  int poc = 0;
  int i;
  for(i = 2; i <= n; i++){
    int next = (int)((ll)last * last % m);
    seq[i] = next;
    if(past[next] != 0){
      poc = past[next];
      break;
    }
    ans += (ll)next;
    past[next] = i;
    last = next;
  } 
  
  ll round_sum = 0ll;
  for(int j = poc; j < i; j++)
    round_sum += (ll)seq[j];
  
  if((ll)i != n){
    ll raz = n - (ll)i;
    ll cnt_rounds = raz / (ll)(i - poc);
    ans += round_sum * cnt_rounds;
    ll left = n - (ll)(i - 1) - cnt_rounds * (ll)(i - poc);
    for(int j = poc; left > 0; j++, left--){
      ans += seq[j];
    }
  }
  
  
  printf("%lld\n", ans);
  
  return 0;
}


Measured memory_bytes: 4384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, L, R, H, W;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N >> M >> L >> R;
	cin >> K;
	M = min(N * 2, M);
	L = min(M * 2, L);
	cout << min(L*K, K / 2 * R + (K % 2)*L) << endl;
	return 0;
}

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

#define ll long long
#define pb push_back

void solve()
{
    ll n,temp;
    cin >> n;
    string s="";
    while(n>0)
    {
        temp=n%26;
        if(temp==0)
        {
            s="z"+s;
            n--;
        }
        else
        {
            temp=96+temp;
            char c=(char)temp;
            s=c+s;
        }
        n=n/26;
    }
    cout << s << "\n";
}

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

    int tt=1;
    ///cin >> tt;
    while(tt--)
        solve();
}


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

int main()
{
    char* string;
    string = (char*)calloc(10, sizeof(char));
    scanf("%s",string);
    if(strlen(string) == 6)
    {
        if(string[2] == string[3] && string[4] == string[5])
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");                        
        }        
    }
    else
    {
        printf("No\n");                        
    }
    return 0;
}

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

int main() {
	int A, B, C;
	cin >> A ;
	if (A == 1) {
		cout << "Hello World" << endl;
		return 0;
	}
	if (A == 2)
		cin >> B >> C;
		cout << B + C << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())

A_li = list(map(int, input().split()))

Q = int(input())


A_li.sort()
res = sum(A_li)
main_li = {}

now = 0
for i in A_li:
    if i == now:
        main_li[i] += 1
    else:
        main_li[i] = 1
        now = i


# クエリの処理
for _ in range(Q):
    B, C = list(map(int, input().split()))
    if B not in main_li.keys():
        print(res)
        continue
    if C in main_li.keys():
        main_li[C] += main_li[B]
    else:
        main_li[C] = main_li[B]
    res += (C - B) * main_li[B]
    main_li.pop(B)
    print(res)



Measured memory_bytes: 20840
n=int(input()) 
c=list(map(int, input().split()))
a = 0
a2 = 0
a4 = 0

for i in c:
    if i%2 != 0:
        a += 1
    if i%2 == 0 and i%4 != 0:
        a2 += 1
    if i%4 == 0:
        a4 += 1
if a == 0 :
    print('Yes')
if a > 0 and a2 == 0:
    if a <= a4 +1 :
        print('Yes')
    else:
        print('No')
if a > 0 and a2 > 0:
    if a <= a4 :
        print('Yes')
    else:
        print('No')

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

using namespace std;
using ll = long long;
ll mod = 1e9 + 7;


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

	for (int i = 0; i < 5; i++)
	{
		int c;
		cin >> c;
		
		int ad = ((c - 1) / 10 + 1) * 10;
		cnt += ad;
		if (max < ad - c)
			max = ad - c;
	}
	cout << cnt - max << endl;
	
	return 0;
}

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

int N, M;
bool b[12][12]; // M*N
int p[12]; // M

int q[12]; // M

bool check(int bit) {
	rep(i, M) q[i] = 0;
	rep(i, N) {
		if(bit & (1<<i)) { // i番目が押されている
			rep(j, M) {
				if(b[j][i]) ++q[j];
			}
		}
	}
	rep(i, M) {
		if(q[i]%2 != p[i]) return false;
	}
	return true;
}

int main() {
	
	cin >> N >> M;
	rep(i, M) {
		int k;
		cin >> k;
		rep(j, k) {
			int s;
			cin >> s;
			--s;
			b[i][s] = true;
		}
	}
	rep(i, M) cin >> p[i];
	
	int ans=0;
	rep(bit, 1<<N) {
		if(check(bit)) ++ans;
	}
	cout << ans << endl;
	
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n+1){
        if(i%3 == 0 || i%5 ==0) continue;
        else ans += i;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <string.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int n, z, w;
vector<int> cards;

int table[2001][2001][2];

//k가 0이면 최대, 1이면 최소 찾기
int score(int xidx, int yidx, int k)
{
	int nidx = max(xidx, yidx) + 1;

	if (nidx == n + 1)
	{
		int xcard = z;
		int ycard = w;

		if (xidx != 0)
			xcard = cards[xidx];

		if (yidx != 0)
			ycard = cards[yidx];

		return abs(xcard - ycard);
	}

	int& res = table[xidx][yidx][k];

	if (res != -1)
		return res;

	if (k == 0)
	{
		res = max(score(nidx, yidx, k), score(xidx, nidx, (k + 1) % 2));
	}
	else
	{
		res = min(score(nidx, yidx, (k + 1) % 2), score(xidx, nidx, k));
	}

	return res;
}

int main()
{
	memset(table, -1, sizeof(table));

	scanf("%d %d %d", &n, &z, &w);

	cards.resize(n+1);

	for (int i = 1; i <= n; i++)
		scanf("%d", &cards[i]);

	printf("%d", score(1, 0, 0));

	return 0;
}




Measured memory_bytes: 31616
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

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

int main() {

  int n, m, first, last, min = 2000;
  bool flag;
  string str;
  cin >> n >> m;
  int s[m], c[m];
  rep(i, m) cin >> s[i] >> c[i];

  if(n==1) {
    first = 0;
    last = 10;
  }else if(n==2) {
    first = 10;
    last = 100;
  }else {
    first = 100;
    last = 1000;
  }

  for(int i=first; i<last; ++i) {
    flag = true;
    str = to_string(i);
    for(int j=0; j<m; ++j) {
      if(str[s[j]-1]-'0'!=c[j]) {
        flag = false;
        break;
      }
    }

    if(flag) {
      if(min>i) min = i;
    }
  }

  if(min==2000) cout << -1 << endl;
  else cout << min << endl;

  return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e5 + 123;
const ld pi = 3.1741592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, m, dp[N], ans, cnt[N], gr[N];
vector<int>g[N],ord;
bool u[N];

void top(int v) {
	u[v] = 1;
	for(int to : g[v]) 
		if(!u[to]) top(to);
	ord.pb(v);
}

void dfs(int v) {
	u[v] = 1;
	for(int to : g[v])
		if(!u[to]) dfs(to);
}

main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);

//	srand(time(NULL));

//	speed;

	scanf("%d%d", &n, &m);

	while(m--) {
		int x, y;
		scanf("%d%d", &x, &y);
		g[x].pb(y);
		gr[y]++;
	}

	for(int i = 1; i <= n; i++)
		if(!u[i]) top(i);
            
	rv(all(ord));

	queue<int>q;

	for(int i = 1; i <= n; i++)
		if(!gr[i]) q.push(i);

	while(!q.empty()) {
		int v = q.front();
		q.pop();

		ans = max(ans, dp[v]);

		for(int to : g[v]) {
			dp[to] = max(dp[to], dp[v] + 1);
			cnt[to]++;
			if(cnt[to] == gr[to]) q.push(to);
		}
	}

	cout << ans;

    return 0;                                        
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	ll X, Y;
	cin >> X >> Y;

	int cnt = 0;
	while(X <= Y){
		cnt++;
		X *= 2;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
// ABC 054 C
#include<bits/stdc++.h>
 
using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int nmax=8;
bool graph[nmax][nmax];
//Deapth First Search
//nmax(n=8),graph[i][j] should be defined as global val
//------------------------------------------
int dfs(int v,int N,bool visited[nmax]){
  bool all_visited=true;
  REP(i,N){
    if(visited[i]==false) all_visited=false;
  }
  if(all_visited) return 1;
  int ret=0;
  REP(i,N){
    if(graph[v][i]==false) continue;
    if(visited[i]) continue;
    visited[i]=true;
    ret += dfs(i,N,visited);
    visited[i]=false;
  }
  return ret;
}
//------------------------------------------

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int n,m;
  cin >> n >> m;
  REP(i,m){
    int a,b;
    cin >> a >> b;
    graph[a-1][b-1]=true;
    graph[b-1][a-1]=true;
  }
  bool visited[nmax];
  REP(i,n){
    visited[i]=false;
  }
  visited[0]=true;
  cout << dfs(0,n,visited) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define ll long long int
#define rep(i,a) for(ll i=0;i<a;i++)
#define foi(i,a,b) for(ll i=a;i<b;i++)
#define el '\n'
using namespace std;
void solve(){
  string s,t;
  cin>>s>>t;
  ll n1=s.size();
  ll n2=t.size();
  ll dp[n1+1][n2+1];
  rep(i,n1+1) rep(j,n2+1){
    if(i==0||j==0) dp[i][j] = 0;
    else if(s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1]+1;
    else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
}
  ll num = dp[n1][n2];
  string ans ="";
  ll i=n1,j=n2;
  while(i>0 && j>0){
    if(s[i-1] == t[j-1]){
      ans += s[i-1];
      i--;j--;}
    else if(dp[i][j-1]>dp[i-1][j]) j--;
    else i--;}
  	reverse(ans.begin(),ans.end());
    cout<<ans;
}
int main(){
  solve();
  return 0;
}

Measured memory_bytes: 73964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define opt ios_base::sync_with_stdio(false); cin.tie(NULL);
 
void freak__()
{
    int n,k,i,j,msb;
    vector<int> v;
    cin >> n >> k;
    int x,h[10]={0};
    for(i=0;i<k;i++)
    {
        cin >> x;
        h[x]=1;
    }
    for(i=n;i>=n;i++)
    {
        int flag=1;
        x=i;
        while(x)
        {
            if(h[x%10])
            {
                flag=0;
                break;
            }
            x/=10;
        }
        if(flag)
        {
            cout << i;
            break;
        }
    }
    cout << "\n";
}
 
int main()
{
    opt;
    freak__();
    return 0;
}

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

int main(){
  ll n;
  cin >> n;
  string i = "";
  while(n){
    n -= 1;
    i += char('a' + n % 26);
    n = floor(n / 26);
  }
  reverse(i.begin(), i.end());
  cout << i << endl;
}


Measured memory_bytes: 3616
S = input()

N = len(S)

def check_kaibun(s) :
  l = len(s)
  half = int(l/2)
  for i in range(half) :
    if(s[i] != s[l-1-i]) :
      return False
      
  return True

first_s = S[:int((N-1)/2)]
second_s = S[int((N+3)/2-1):]
if ((check_kaibun(first_s)) and (check_kaibun(second_s)) and (first_s == second_s)) :
  print("Yes")
else :
  print("No")

Measured memory_bytes: 3064
/*
      author  : nishi5451
      created : 12.08.2020 23:31:04
*/

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

ll INF = 1e9;

int main(){
    int n,m;
    cin >> n >> m;
    vector<ll> a(n),b(n),c(m),d(m);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,m) cin >> c[i] >> d[i];
    
    rep(i,n){
        pair<ll,int> P(INF,-1);
        rep(j,m){
            ll dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(P.first > dist){
                P.first = dist;
                P.second = j;
            }
        }
        cout << P.second+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>

int main (void)
{
    
    int X,Y,t;
    scanf("%d",&Y);
    scanf("%d",&X);
    t=(4*Y-X)/2;
    if(Y-t>=0&&t>=0&&X%2==0)
    {
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int n;
int a[334][334],ans=0;
signed main(){
	cin>>n;
	rep(i,n)rep(j,n)cin>>a[i][j];
	rep(i,n){
		for(int j=i+1;j<n;j++){
			bool f=0;
			rep(k,n){
				if(i!=k&&j!=k){
					if(a[i][k]+a[k][j]<a[i][j]){
						puts("-1");
						return 0;
					}
					if(a[i][k]+a[k][j]==a[i][j]){
						f=1;
						break;
					}
				}
			}
			if(!f)ans+=a[i][j];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  int o=0;
  cin >> n >> k;
  vector<int>a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a.begin(),a.end());
    for(int i=0;i<k;i++){
     o=o+a[i];
    }
    cout << o;
    return 0;
}

Measured memory_bytes: 3608
def func(x):
    return (x+1)/2
N, K = [int(i) for i in input().split()]
P = [func(int(i)) for i in input().split()]

# 累積和
A = [0]
for i in P:
    A.append(A[-1]+i)

ans = []
for i in range(K, N+1):
    ans.append(A[i] - A[i-K])
    
print(max(ans))

Measured memory_bytes: 23588
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using LL=long long;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N;
    cin >> N;
    int res{};
    for( int i = N/2 + 1; i >= 0; i-- )
    {
        if( pow( i, 2 ) <= N )
        {
            res = i;
            break;
        }
    }
    cout << res*res << endl;
    return 0;
}

Measured memory_bytes: 256
DAYDREAM = ["dream", "dreamer", "erase", "eraser" ]
S = input()

ind = len(S)
res = True
while ind > 0:
	ok = False
	for i in DAYDREAM:
		if S[ind - len(i):ind] == i:
			ind -= len(i)
			ok = True
			break;
	if ok == False:
		res = False
		break

print("YES" if res == True else "NO")

Measured memory_bytes: 3188
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[110][110];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}


int main() {
	cin >> s;
	reverse(s.begin(), s.end());
	string a[4] = {
		"dream","dreamer","erase","eraser"
	};
	rep(i, 4) {
		reverse(a[i].begin(), a[i].end());
	}
	string t = "";
	rep(i, s.size()) {
		t += s[i];
		rep(i, 4) {
			if (t == a[i]) {
				t = "";
			}
		}
	}
	if (t == "") cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 640
d[1001],c;
main(w,n,i,C,W,a,b)
{
  for(;scanf("%d",&w),w;printf("Case %d:\n%d\n%d\n",++c,d[w],i),bzero(d,4004)){
    for(a=b=i=!scanf("%d",&n);n--;)
        for(i=w,scanf("%d,%d",&C,&W);i>=W;i--)
            d[i]=fmax(d[i],d[i-W]+C);
    for(i=0;i<w&&d[w]-d[i];)i++;
  }
}

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

int a[200010];
map <int, int> mp;

int Get(int x){
	int res = 1;
	while (res <= x) res *= 2;
	return res;
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		mp[a[i]]++;
	}
	sort(a, a + n), reverse(a, a + n);
	int res = 0;
	for (int i = 0; i < n; i++){
//		cout << a[i] << endl;
		if (mp[a[i]] == 0) continue;
		int tot = Get(a[i]);
		mp[a[i]]--;
		if (mp.count(tot - a[i]) && mp[tot - a[i]] != 0) mp[tot - a[i]]--, res++;
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 10368
from collections import Counter
n,k,l = (int(i) for i in input().split())
rpar,tpar,x = [i for i in range(n+1)],[i for i in range(n+1)],[]
def root(x,par):
	if par[x]!=x: par[x] = root(par[x],par)
	return par[x]
def unite(x,y,par):
	x2,y2 = root(x,par),root(y,par)
	if x2==y2: return
	par[x2] = y2
r = [[int(i) for i in input().split()] for i in range(k)]
t = [[int(i) for i in input().split()] for i in range(l)]
for i,j in r: unite(i,j,rpar)
for i,j in t: unite(i,j,tpar)
for i in range(1,n+1): x.append((root(i,rpar),root(i,tpar)))
y = Counter(x)
for i in x: print(y[i],end=" ")

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	int n=read();
	int c[2]{};
	REP(i,n)
		c[read()%2]++;
	c[0]+=c[1]/2;
	c[1]%=2;
	if(c[0]&&c[1])
		cout<<"NO"<<endl;
	else
		cout<<"YES"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct exam{
    int a,b,c;
};
bool comp(exam x, exam y){
    return x.a - x.b < y.a - y.b;
}
exam arr[100001];
void solve(){
    int n,ans = 0,sum1 = 0,sum2 = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> arr[i].a;
        sum1 += arr[i].a;
        arr[i].c = arr[i].a;
    }
    for(int i = 0; i < n; i++){
        cin >> arr[i].b;
        sum2 += arr[i].b;
    }
    sort(arr,arr + n,comp);
    int ind = 0,last_ind = n - 1;
    while(arr[ind].b > arr[ind].c && sum1 >= sum2){
        if(arr[ind].b - arr[ind].c <= arr[last_ind].c - arr[last_ind].b){
            arr[last_ind].c -= (arr[ind].b - arr[ind].c);
            arr[ind].c = arr[ind].b;
            ind++;
        }
        else {
            arr[ind].c += (arr[last_ind].c - arr[last_ind].b);
            arr[last_ind].c = arr[last_ind].b;
            last_ind--;
        }
    }
    for(int i = 0; i < n; i++){
        if(arr[i].a != arr[i].c)ans++;
    }
    if(sum1 < sum2)ans = -1;
    cout << ans << endl;
}
main(){
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
using namespace std;
#define N 1000000

int main(){
  char A[N];
  int dp[N];
  int n; cin >> n;
  for (int i=0; i<n; i++){
    cin >> A[i];
  }
  dp[0]=0;

  //initialization
  for (int i=1; i<n; i++){
    if (A[i]=='E') dp[0]++;
  }

  for (int i=1; i<n; i++){
    int x=0, y=0;
    if (A[i]=='E') x = -1;
    if (A[i-1]=='W') y = 1;
    dp[i] = dp[i-1]+x+y;
  }
  int min=10000000;
  for (int i=0; i<n; i++){
    if (min>dp[i]) min = dp[i];
  }

  cout << min << endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 int n ;
 cin>> n ;
 vector<int> A(n) ;
 rep(i,n) cin>> A[i] ;
 ll ans=0 ;
 rep(i,n){
   if(A[i]>0) ans+=A[i] ;
   else ans-=A[i] ;
 }
 int zero =0 ;
 int hu = 0;
 rep(i,n) {
   if(A[i]==0) zero++ ;
   if(A[i]<0) hu++ ;
  } 
  rep(i,n){
    if(A[i]<0) A[i]= -A[i] ;
  }
  sort(A.begin(),A.end()) ;
  if(zero==0 && hu%2==1)
  ans= ans-2*A[0] ;
  cout <<ans<<endl ;
     return 0;
}

Measured memory_bytes: 768
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    double n;
    cin >> n;
    vector<int> x(n);
    double count = 0;
    rep(i, n) {
        cin >> x[i];
        count += x[i];
    }
    int ans_1 = ((count / n) + 0.5) / 1;
    int sum_1 = 0;
    rep(i, n) {
        sum_1 += (x[i] - ans_1) * (x[i] - ans_1);
    }
    cout << sum_1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int m,f,r= 0;
	
	while(1){
		
		scanf("%d %d %d",&m ,&f ,&r);
		
		if(m==-1&&f==-1&&r == -1){
		break;
		} 
		
		while(1){
		
		if(m ==-1 || f ==-1){
			printf("F\n");
			break;
		} 
		if(80<=m+f){
			printf("A\n",m+f);
			break;
		} 
		if(65<=m+f && m+f<80){
			printf("B\n",m+f);
			break;
		} 
		if(50<=m+f && m+f<65){
			printf("C\n",m+f);
			break;
		} 
		if(30 <= m+f && m+f< 50 && 50 <= r){
			printf("C\n",m+f);
			break;
		} 
		if(30 <= m+f && m+f< 50){
			printf("D\n",m+f);
			break;
		} 
		if(m+f < 30){
			printf("F\n",m+f);
			break;
		} 
		}
	}

return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N,A,B;
	cin >> N >> A >> B;
	while(1){
		if(A+1<B){
			A++;
		}else if( (A-1)>0){
			A--;
		}else{
			cout << "Borys" << endl;
			return 0;
		}
		if( (B-1)>A){
			B--;
		}else if((B+1)<=N){
			B++;
		}else{
			cout << "Alice" << endl;
			return 0;
		}
	}
}

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

struct data {
  long long x, y;
  bool iscurtain;
};
bool operator<(const data &l, const data &r) {
  if(l.x != r.x) return l.x < r.x;
  return l.y < r.y;
}

long long n, minx, miny, maxx, maxy;
vector<data> v;
vector<long long> xlst;
vector<vector<long long>> ylst;
set<long long> st;

long long solve();
long long calc(bool curtain);

int main() {
  while(1) {
    cin >> n;
    if(n == 0) break;
    minx = miny = (long long)1e9;
    maxx = maxy = (long long)-1e9;
    v.resize(n);
    xlst.clear();
    ylst.clear();
    for(int i = 0; i < n; ++i) {
      cin >> v[i].x >> v[i].y;
      v[i].iscurtain = 0;
    }
    for(int i = 0; i < 4; ++i) {
      long long x, y;
      cin >> x >> y;
      minx = min(minx, x);
      miny = min(miny, y);
      maxx = max(maxx, x);
      maxy = max(maxy, y);
    }
    v.push_back({minx, (long long)-1e9, 1});
    v.push_back({maxx, (long long)-1e9, 1});
    n += 2;
    sort(v.begin(), v.end());
    cout << solve() << endl;
  }
  return 0;
}

long long solve() {
  long long res = 0, nowx = -1e9;
  bool nowcurtain = 0;
  for(int i = 0; i < n;) {
    xlst.push_back(v[i].x);
    if(v[i].iscurtain) {
      ++i;
      ylst.push_back(vector<long long>());
    }
    else {
      vector<long long> tmp;
      nowx = v[i].x;
      while(i < n && v[i].x == nowx)
        tmp.push_back(v[i++].y);
      ylst.push_back(tmp);
    }
  }
  n = xlst.size();
  st.clear();
  for(int i = 0; i < n; ++i) {
    res += (xlst[i] - nowx) * calc(nowcurtain);
    for(int j = 0; j < ylst[i].size(); ++j)
      if(st.find(ylst[i][j]) == st.end())
        st.insert(ylst[i][j]);
      else
        st.erase(ylst[i][j]);
    nowx = xlst[i];
    if(ylst[i].size() == 0) nowcurtain = 1 - nowcurtain;
  }
  return res;
}

long long calc(bool curtain) {
  long long res = 0;
  for(auto it = st.begin(); it != st.end();) {
    long long d, u = 0, now;
    d = *(it++);
    u = *(it++);
    now = u - d;
    if(curtain)
      now -= max(0LL, min(u, maxy) - max(d, miny));
    res += max(0LL, now);
  }
  return res;
}


Measured memory_bytes: 3136
from itertools import product

H,W,K=map(int,input().split())
c=[input() for _ in range(H)]

ans=0
for mask_H in product([True,False],repeat=H):
    for mask_w in product([True,False],repeat=W):
        black=0
        for i in range(H):
            for j in range(W):
                if mask_H[i] and mask_w[j] and c[i][j]=="#":
                    black+=1
        if black==K:
            ans+=1
print(ans)


Measured memory_bytes: 9104
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    ll n, m, d;
    cin >> n >> m >> d;
    double ans;
    if (d == 0){
        ans = 1.0 * (m - 1) / n;
    }else{
        ans = 1.0 * (m - 1) * 2 * (n - d) / n / n;
    }
    cout << fixed << setprecision(10) << ans << endl;
}

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

#define ll long long
#define mod 998244353
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 200010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T = 1,n,m,k;

vector<pll>v;

ll dp[N];

ll solve(ll i){
    if(i>=n){
        return 0;
    }
    if(dp[i] != -1)
        return dp[i];
    ll ans = 0;

}

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    // cin >> T;
    while(T--){
        cin >> n >> k;
        memset(dp, -1, sizeof(dp));
        for(int i=0;i<k;i++){
            ll a, b;
            cin >> a >> b;
            v.pb({a,b});
        }

        ll pre[N] = {0};
        dp[1] = 1;
        pre[1] = 1;

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

        for(ll i=2;i<=n;i++){
            ll ans = 0;
            for(ll j=0;j<k;j++){
                ll x = v[j].first;
                ll y = v[j].second;
                x = max(0ll, i-x);
                y = max(0ll, i-y);
                if(x){
                    if(y==0){
                        ans = (ans + pre[x])%mod;
                    }
                    else{
                        ans = (ans + (pre[x] - pre[y-1] + mod))%mod;
                    }
                }
            }
            dp[i] = ans;
            pre[i] = (pre[i-1]+ans)%mod;
        }

        // for(int i=0;i<=n;i++){
        //     cout << dp[i] << " ";
        // }

        cout << dp[n] << "\n";
        

        
    }

    return 0;
}


Measured memory_bytes: 6764
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

const int MAX_N = 10;
int a[MAX_N];

bool dfs(int idx, int end1, int end2) {
    if (idx == MAX_N) return true;
    if (a[idx] < end1 && a[idx] < end2) return false;
    if (a[idx] > end1 && a[idx] > end2) return dfs(idx+1, a[idx], end2) || dfs(idx+1, end1, a[idx]);
    if (a[idx] > end1) return dfs(idx+1, a[idx], end2);
    if (a[idx] > end2) return dfs(idx+1, end1, a[idx]);
    return false;
}

int main() {
    int T;
    cin >> T;
    while (T--) {
        for (int i = 0; i < MAX_N; i++)
            cin >> a[i];
        bool flag = dfs(0, 0, 0);
        if (flag) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3020
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, k;
    cin >> k;
    cin >> a >> b;
    for (int i = a; i < b+1; i++){
        if (i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 3e5 + 10;

int c[N], m;

inline int lowbit(int x){
	return x & (-x);
}

void add(int x){
	while(x < N){
		c[x] ^= 1;
		x += lowbit(x);
	}
}

bool sum(int x){
	bool ret = 0;
	while(x){
		ret ^= c[x];
		x -= lowbit(x);
	}
	return ret;
}

bool work(int* A){
	memset(c, 0, sizeof c);
	bool ret = 0;
	Forr(i, m, 1){
		ret ^= sum(A[i]);
		add(A[i]);
	}
	return ret;
}

int A[N], B[N], n;

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

	For(i, 1, 3) For(j, 1, n) scanf("%d", &A[(j - 1) * 3 + i]);
	
	For(i, 1, n) if(A[3 * n - 1] * 2 != A[3 * n - 2] + A[3 * n] || abs(A[3 * n] - A[3 * n - 1]) != 1){
		puts("No");
		return 0;
	}

	For(i, 1, 3) For(j, 1, n){
		int val = A[(j - 1) * 3 + i];
		int y = (val - 1) / 3 + 1, x = (val - 1) % 3 + 1;
		if((i == 2 && x != 2) || abs(j - y) % 2 != 0){
			puts("No");
			return 0;
		}
	}

	m = 3 * n;
	if(work(A) & 1){
		puts("No");
		return 0;
	}

	m = 0;
	For(i, 1, n) B[++m] = A[i * 3 - 2], B[++m] = A[i * 3];
	bool ret = work(B);

	m = 0;
	For(i, 1, n) if(i & 1) B[++m] = A[i * 3 - 1];
	bool rev_odd = work(B);

	m = 0;
	For(i, 1, n) if(!(i & 1)) B[++m] = A[i * 3 - 1];
	bool rev_even = work(B);
	if(rev_odd ^ rev_even ^ ret){
		puts("No");
		return 0;
	}

	m = 0;
	For(i, 1, n) if(i & 1) B[++m] = A[i * 3 - 2], B[++m] = A[i * 3];
	if(work(B) ^ rev_odd ^ ret){
		puts("No");
		return 0;
	}

	m = 0;
	For(i, 1, n) if(!(i & 1)) B[++m] = A[i * 3 - 2], B[++m] = A[i * 3];
	if(work(B) ^ rev_even ^ ret){
		puts("No");
		return 0;
	}

	puts("Yes");
	return 0;
}

Measured memory_bytes: 3328