akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct UnionFind {
  int N;
  vector<int> sz_tree, parent;
  UnionFind() {}
  UnionFind(int N) : N(N), sz_tree(N, 1), parent(N) {
    iota(parent.begin(), parent.end(), 0);
  }
  int root(int x) {
    return parent[x] == x ? x : parent[x] = root(parent[x]);
  }
  void merge(int x, int y) {
    if ((x = root(x)) == (y = root(y))) return;
    if (sz_tree[x] < sz_tree[y]) swap(x, y);
    sz_tree[x] += sz_tree[y];
    parent[y] = x;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sz_tree[root(x)];
  }
};

int N, M;
int K[100010];
vector<int> G[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      int num;
      cin >> num;
      G[num - 1].emplace_back(i);
    }
  }
  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    if ((int)G[i].size() <= 1) continue;
    for (int j = 0; j < (int)G[i].size(); j++) {
      uf.merge(G[i][0], G[i][j]);
    }
  }
  cout << (uf.size(0) == N ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<tuple>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

using namespace std;

int main() {
	int h, w;
	cin>>h>>w;
	vector<vector<int> > m(h, vector<int>(w));
	REP(i, h) {
		REP(j, w) {
			cin>>m[i][j];
		}
	}
	int dp[h][w];
	REP(i, h) {
		REP(j, w) {
			if(i == 0 || j == 0) {
				if(m[i][j] == 0) dp[i][j] = 1;
				else dp[i][j] = 0;
			} else {
				if(m[i][j] == 0) {
					dp[i][j] = min(min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1;
				} else {
					dp[i][j] = 0;
				}
			}
		}
	}
	int res = 0;
	REP(i, h) {
		REP(j, w) res = max(res, dp[i][j]);
	}
	cout<<res * res<<endl;
}

Measured memory_bytes: 18028
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int A = inputArray[0];
            int B = inputArray[1];
            int C = inputArray[2];
            int K = inputArray[3];
            int num = 0;
            int ans = 0;
            if(A >= K)
            {
                ans = K;
            }
            else if (A + B >= K)
            {
                ans = A;
            }
            else
            {
                ans = A + ((A + B) - K );
            }
            Console.WriteLine(ans);
        }
    }
}

//24579 =  hon
//0168 = pon
//3 = bon
//long n = long.Parse(Console.ReadLine());
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(cnt);
//Console.ReadKey();


Measured memory_bytes: 28260
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

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

    int a, b;
    cin >> a >> b;
    if (a > b) {
        int temp = a;
        a = b;
        b = temp;
    }
    REP(i, b) {
        cout << a;
    }
    cout << ln;

    return 0;
}


Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func main() {
	scanner.Split(bufio.ScanWords)

	count := map[int]int{}

	sizeA := nextInt()
	for i := 0; i < sizeA; i++ {
		count[nextInt()]++
	}
	sizeB := nextInt()
	for i := 0; i < sizeB; i++ {
		count[nextInt()]++
	}
	// fmt.Println(count)

	keys := []int{}
	for k := range count {
		keys = append(keys, k)
	}
	sort.Ints(keys)
	for _, k := range keys {
		fmt.Println(k)
	}
}



Measured memory_bytes: 32348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
bool rin[10][10];
int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;
        rin[a[i]][b[i]] = true;
        rin[b[i]][a[i]] = true;
    }
    vector<int> fac(n);
    for (int i = 0; i < n; ++i) {
        fac[i] = i;
    }
    int ans = 0;
    do{
        if(fac[0] != 0) break;
        bool ok = true;
        for (int i = 0; i < n-1; ++i) {
            int from = fac[i],to = fac[i+1];
            if(!rin[from][to]) ok = false;
        }
        if(ok) ans++;
    }while(next_permutation(fac.begin(),fac.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
class modpow:
  def __init__(s, mod):
    s.MOD = mod
  def modpow(s, a, n):
    res = 1
    while n > 0:
      if n & 1:
        res = res * a % s.MOD
      a = a * a % s.MOD
      n >>= 1
    return res

N, K = list(map(int, input().split()))
MOD = 10 ** 9 + 7

D = [0] * (K + 1)
ans = 0
mp = modpow(MOD)
for i in range(K, 0, -1):
  t = K // i
  u = mp.modpow(t, N)
  for j in range(i + i, K + 1, i):
    u -= D[j]
  while (u < 0):
    u += MOD
  ans = (ans + u * i) % MOD
  D[i] = u
print(ans)

Measured memory_bytes: 69804
n = int(input())
a = list(list(map(int, input().split())) for _ in range(n))
a.sort(key=lambda x: x[1])
ans = 0
for i in range(0, n):
    ans += a[i][0]
    if ans > a[i][1]:
        print("No")
        exit()
print("Yes")

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

int main(void){
    int a, b;
    cin >> a >> b;
    
    if(a == b) cout << "a == b" << endl;
    else if(a > b) cout << "a > b" << endl;
    else cout << "a < b" << endl;
    
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define Lim 9999991
#define Jmp 100003

int dic[Lim];

int toint(string s) {
    int ret = 0;
    for (int i = 0; i < s.size(); ++i) {
        ret *= 5;
        switch (s[i]) {
            case 'A':
                ret += 1;
                break;
            case 'T':
                ret += 2;
                break;
            case 'G':
                ret += 3;
                break;
            case 'C':
                ret += 4;
                break;
        }
    }
    return ret;
}

void push(string s) {
    int a = toint(s);
    int i = a % Lim;
    while (true) {
        if (!dic[i]) {
            dic[i] = a;
            return;
        }
        i = (i + Jmp) % Lim;
    }
}

int find(string s) {
    int a = toint(s);
    int i = a % Lim;
    while (true) {
        if (!dic[i]) {
            return 0;
        }
        if (dic[i] == a) {
            return 1;
        }
        i = (i + Jmp) % Lim;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s, t;
        cin >> s >> t;
        if (s == "insert") {
            push(t);
        }
        else {
            if (find(t)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 31040
"""everything has a cost!"""

from math import *
import random, functools, collections, sys

__author__ = 'p7x'


# sys.stdin = open('in.txt', 'r')
# sys.stdout = open('out.txt', 'w')
# sys.stderr = open('err.txt', 'w')


if __name__ == '__main__':
    n,m,k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    for i in range(1,len(a)):
        a[i] += a[i-1]
    for i in range(1,len(b)):
        b[i] += b[i-1]

    j = len(b)-1
    while j > -1 and b[j] > k:
        j -= 1
    ans = j+1
    i = len(a)-1
    while i > -1 and a[i] > k:
        i -= 1
    ans = max(i+1,ans)

    for inx in range(i+1):
        while j > -1 and a[inx] + b[j] > k:
            j -= 1
        ans = max(inx+j+2,ans)
    print(ans)

Measured memory_bytes: 125340
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		sc.close();
		int check = A - 2 * B;
		if(check > 0) {
			System.out.println(check);
		}else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int a, next = 1, ans = 0;
  REP(i, n) {
    cin >> a;
    if (a == next) next++;
    else ans++;
  }
  if (next > 1) cout << ans << endl;
  else cout << -1 << endl;
}

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

int main(){
  int X,temp;
  int ans = 0;
  scanf("%d",&X);

  for(int i = 1; i < 1000;i++){
    for(int p = 2;p < 10;p++){
    temp = pow(i,p);
    if(temp > X){
      break;
    }else if(temp <= X && temp >=ans){
      ans = temp;
    }
  }
  }
  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef set<int>        si;

template<typename T> T sgn (T x)      {return x<0? -1:x!=0; }
template<typename T> T gcd (T a, T b) {return a ? gcd (b % a, a) : b; }
//pi=acos(-1)
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define popcount __builtin_popcount
#define eb emplace_back
#define emp emplace
#define ss second
#define ff first
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

ll n, k, ans, to[N], p[N];

void solve(){
    scanf("%lld %lld", &n, &k);
    forn(i,1,n+1) scanf("%lld", to+i);
    ll i=1, q=1;
    while(!p[i] && k){
        p[i] = q++;
        i = to[i];
        k--;
    }
    k %= (q-p[i]);
    while(k){
        i = to[i];
        k--;
    }
    //printf("%d %d\n",q, k);
    printf("%lld\n",i);
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;//scanf("%d",&t);
    while(t--)solve();
}

Measured memory_bytes: 6940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define uid uniform_int_distribution
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define bpop(x) __builtin_popcountll((ulli)x)
#define blead(x) __builtin_clzll((ulli)x)
#define btrail(x) __builtin_ctzll((ulli)x)
const double PI = acos(-1);
template<class my>
using ind_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) (int)(x).size()

using lli   = long long;
using ulli  = unsigned long long int;
using pll   = pair<lli, lli>;
using ttt   = pair<lli, pll>;
using vttt  = vector<ttt>;
using vll   = vector<pll>;
using vl    = vector<lli>;
using vi    = vector<int>;
using vvi   = vector<vector<int>>;
using cd    = complex<long double>;

#ifdef tejasp
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.ff); __p(a.ss); cout << "} "; }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : ";__p(arg1); cout<<endl;
}
template<typename Arg1>
void __t(const char *name, Arg1 &&arg1)
{ cout<<name<<" : { "; for (auto p : arg1) __p(p); cout<<"}"<<endl; }
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	int bracket=0,i=0;
	for(; ;i++)
		if(names[i]==','&&bracket==0)
			break;
		else if(names[i]=='(')
			bracket++;
		else if(names[i]==')')
			bracket--;
	cout.write(names,i)<<" : ";
	__p(arg1);  cout<<"| ";
	__f(names+i+1,args...);
}
template<typename Arg1, typename Arg2>
void __f(const char *names, Arg1 arg1[], Arg2 &&arg2){
    int i=0;
	for(; ;i++) if(names[i]==',') break;
	cout.write(names,i)<<" : { ";
	fol(i,0,arg2) __p(arg1[i]);
	cout << "} "<<endl;
}
#define trace(...) { cout<<"Line:"<<__LINE__<<" | "; __f(#__VA_ARGS__, __VA_ARGS__); }
#define cotra(...) { cout<<"Line:"<<__LINE__<<" | "; __t(#__VA_ARGS__, __VA_ARGS__); }
#else
#define endl '\n'
#define trace(...)
#define cotra(...)
#endif

void tejas_919(int kkkk)
{
    lli n, m, k, q, u, v, temp=0, ans=0;
    cin>>n;
    int h[n+5]={}, dp[n+5]={};
    fol(i,1,n+1) cin>>h[i];
    fol(i,0,n+5) dp[i]=mod;
    dp[1]=0;
    fol(i,2,n+5)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n]<<endl;
}

int main()
{
    #ifndef tejasp
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #endif
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
}


Measured memory_bytes: 1024
A, B, K = tuple(int(i) for i in input().split())

def f(a):
    if a%2 != 0:
        a -= 1
    return a//2

for i in range(K):
    if i%2 == 0:
        A = f(A)
        B += A
    else:
        B = f(B)
        A += B
print(A, B)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
string evenodd(int x){
  int y=x/2;
  if(y*2==x){
  return "even";
  }
  return "odd";
}
int main(){
  int A,B,C;
  int x=0;
  cin>>A>>B>>C;
  string a,b,c;
  int count=0;
  a=evenodd(A);
  b=evenodd(B);
  c=evenodd(C);
  while(a=="even" && b=="even" && c=="even"){
count++;
    int Ae,Be,Ce;
    Ae=B/2+C/2;
    Be=A/2+C/2;
    Ce=A/2+B/2;
    A=Ae;
    B=Be;
    C=Ce;
      a=evenodd(A);
  b=evenodd(B);
  c=evenodd(C);

    if(A==B/2+C/2 && B==A/2+C/2 && C==A/2+B/2){
    cout<<-1<<endl;
     x=1;
    break;  
    
    }
  }
  if(x==0)
    cout<<count<<endl;
  
}

Measured memory_bytes: 3632
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#include <string>
#include <vector>
#include <algorithm>
#include<ctype.h>
#define ll long long int
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define vali 1000000000000000000
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char a;
    cin>>a;
    if(isupper(a))
    cout<<"A"<<endl;
    else
    cout<<"a"<<endl;
}

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

#define debug(x) cout<<#x<<"="<<x<<endl
#define pii pair<int,int>
#define PQ priority_queue
#define ll long long
#define pb push_back
#define mp make_pair

set <int> s;
int n,x;

int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>x;
		if (s.count(x)) s.erase(x); else s.insert(x);
	}
	cout<<s.size();
	return 0;
}

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if (A == B){
        cout << C << endl;
    }
    else if (A == C){
        cout << B << endl;
    }
    else{
        cout << A << endl;
    }
}


Measured memory_bytes: 256
// Wed Jul 29 19:48:22 IST 2020    
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)        for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD = 1e9+7;
const double pi = 3.141592653589793238;
const int N = 2e5+7; 
const int INF = INT_MAX;
 
int tests(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(char &c :s)
        if(c == 'W')
            c = '0';
        else
            c = '1';
            
    vector <int> v[2];
    for(int i = 0; i < n; i++)
        v[s[i]-'0'].push_back(i);
    int ans =0;
    if(v[0].empty())
        return cout << 0 << '\n',0;

    for(int i = 0; i < int(v[0].size()); i++)
        if(!v[1].empty() and v[1].back() > v[0][i]){
            // cerr << (v[1].back());
            v[1].pop_back();
            ans++;
        }    
    cout << ans << '\n';
    return 0;
}   
int32_t main(){
    I__O ;     
    int cases = 1 ;  
    // cin >> cases ;
    for(int test = 1 ; test <= cases ; ++test){ 
        // cout << "Case #" << test << ":" << '\n';
        tests();
    }    
    return 0 ; 
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()	
{
	ll n,a[105];
	cin>>n;
	a[0]=2;
	a[1]=1;
	for(ll i=2;i<=n;i++)
	{
		a[i]=a[i-1]+a[i-2];
	}
	cout<<a[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b)	for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int N=2e2+5,inf=0x3f3f3f3f;
int n;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	cin>>n>>a>>b;
	int dif=abs(a-b)-1;
	puts(dif%2?"Alice":"Borys"); 
	
	return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn print<T: std::fmt::Display>(x: T) -> () {
    println!("{}", x);
}


fn main() {
    let n: usize = read();
    let s: String = read();
    let k: usize = read();

    let mut cs: Vec<char> = s.chars().collect();
    let sk = cs[k - 1];

    for i in 0..n {
        if cs[i] != sk {
            cs[i] = '*';
        } else {
            continue;
        }
    }

    for c in cs {
        print!("{}", c);
    }
    println!("");
}

Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  cin >> n;
  cout << 111 * ((n + 111 - 1) / 111) << endl;
  return 0;
}

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

#define MAPSIZE 12
vector<string> mapdata(MAPSIZE);
int mapsize;
int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };

void dfs(int x, int y)
{
    mapdata[y][x] = '0';
    for (int i = 0; i < 4; i++) {
        int px = x + dx[i];
        int py = y + dy[i];
        if (px < 0 || px >= MAPSIZE || py < 0 || py >= MAPSIZE) continue;
        if (mapdata[py][px] == '0') continue;
        dfs(px, py);
    }
}

int main()
{
    while (1) {
        int ans = 0;
        for (int i = 0; i < MAPSIZE; i++) {
            cin >> mapdata[i];
            if (cin.eof()) { return 0; }
        }
        for (int i = 0; i < MAPSIZE; i++) {
            for (int j = 0; j < MAPSIZE; j++) {
                if (mapdata[i][j] == '0') continue;
                dfs(j, i);
                ans++;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

//////////////////////////////////////////////////////
//Union Find /////////////////////////////////////////
//////////////////////////////////////////////////////
static const ll MAX_M = 100001;
static const ll MAX_N = 100001;
int par[MAX_N];
int rak[MAX_N];

void init(int n) {
	rep(i, 0, n) {
		par[i] = i;
		rak[i] = 0;
	}
}

int find(int x) {
	if (par[x] == x)return x;
	else return par[x] = find(par[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (rak[x] < rak[y]) par[x] = y;
	else {
		par[x] = y;
		if (rak[x] == rak[y]) rak[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

struct edge { ll u, v, cost; };
bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
//////////////////////////////////////////////////////
//Krascal    /////////////////////////////////////////
//////////////////////////////////////////////////////
int V, E;
edge es[MAX_M * 2];

int krascal() {
	sort(es, es + E, comp);
	init(V);
	int res = 0;

	rep(i, 0, E) {
		edge e = es[i];
		if (!same(e.u, e.v)) {
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

vector<pair<ll, pair<ll, ll>>> x_y;
vector<pair<ll, pair<ll, ll>>> y_x;
int main() {
	ll n; cin >> n;
	V = n; E = 2 * (n - 1);

	rep(i, 0, n) {
		ll X, Y; cin >> X >> Y;
		x_y.push_back(make_pair(X, make_pair(Y, i)));
		y_x.push_back(make_pair(Y, make_pair(X, i)));
	}

	sort(x_y.begin(), x_y.end());
	sort(y_x.begin(), y_x.end());

	rep(i, 0, n - 1) {
		edge *e = new edge();
		e->u = x_y[i].second.second;
		e->v = x_y[i + 1].second.second;
		e->cost = min(abs(x_y[i].first - x_y[i + 1].first), abs(x_y[i].second.first - x_y[i + 1].second.first));
		es[i] = *e;
	}

	rep(i, 0, n - 1) {
		edge *e = new edge();
		e->u = y_x[i].second.second;
		e->v = y_x[i + 1].second.second;
		e->cost = min(abs(y_x[i].first - y_x[i + 1].first), abs(y_x[i].second.first - y_x[i + 1].second.first));
		es[n - 1 + i] = *e;
	}
	cout << krascal() << endl;

	return 0;
}

Measured memory_bytes: 17316
#include<stdio.h>
int main()

{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a,b>=1&&a,b<=3)
    {
        if((a*b*1)%2!=0||(a*b*3)%2!=0||(a*b*3)%2!=0)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }

}


Measured memory_bytes: 128
#pragma GCC optimize(3)
#include<cstdio>
#include<algorithm>
#define mod 998244353
using namespace std;
int n,a[100001];
long long ans;
inline int read(){
	register char ch=getchar();
	register int o=0;
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){
		o=(o<<3)+(o<<1)+(ch^48);
		ch=getchar();
	}
	return o;
}
int main(){
	n=read();
	for(register int i=1;i<=n;i++){
		a[i]=read();
		if((a[i]&&i==1)||(i!=1&&!a[i])){
			putchar('0');
			return 0;
		}
	}
	sort(a+1,a+1+n);
	ans=1;
	for(register int i=2;i<=n;i++){
		register int tp=0;
		for(register int j=upper_bound(a+1,a+1+i,a[i]-1)-a-1;j;j--){
			if(a[i]-1==a[j])tp++;
			else if(a[i]-1>a[j])break;
		}
		ans*=tp;
		while(ans>=mod)ans-=mod;
	}
	printf("%lld",ans);
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
 
int main() {
    
    int n;
    cin >> n;
    int a[n + 1];
    
    for (int i = n; i > 0; i--){
        cin >> a[i];
    }
    
    for (int i = 1; i <= n; i++){
        cout << a[i];
        
            if (n <= i) {
				break;
			}
			
        cout << " ";
    }
    
	cout << endl;
	
    return 0;
}


Measured memory_bytes: 3072
using System;
using System.Collections.Generic;

namespace abc145_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var x = new int[n];
      var y = new int[n];

      for (var i = 0; i < n; i++)
      {
        x[i] = CIn.ReadInt();
        y[i] = CIn.ReadInt();
      }

      var sum = 0.0;

      for (var i = 0; i < n - 1; i++)
      {
        for (var j = i + 1; j < n; j++)
        {
          sum += Math.Sqrt(Math.Pow((x[i] - x[j]), 2) + Math.Pow((y[i] - y[j]), 2));
        }
      }

      Console.WriteLine(sum * 2 / n);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }
  }
}

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

using namespace std;

using ll = long long;
using pe = pair<ll, ll>;

vector<pe> prime_order(ll num){
    vector<pe> result;
    
    for(ll i = 2; i * i <= num; i++){
        if(num%i != 0) continue;
        ll e = 0;
        
        ll order = 1;
        ll orderCnt = 1;

        while( num % i == 0){
            orderCnt++;
            if(orderCnt > order){
                order++;
                orderCnt = 1;
            }
            e++;
            num /= i;
        }

        //result.push_back({i, e});
        result.push_back({i, order - 1});
    }

    if(num != 1) result.push_back({num, 1});
    return result;
}

int main(void){
    ll N;
    cin >> N;
    vector<pe> factors = prime_order(N);
    ll count = 0;
    for(auto elem : factors){
        count += elem.second;
    }
    cout << count << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define mx 10000001
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{

    //freopen("Input.txt","r",stdin);
    // ios_base :: sync_with_stdio(false);

    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3624
A, B, C, K = map(int, input().split())
ans = 0
if K > 0:
    ans += min(A, K)
    K -= min(A, K)

if K > 0:
    K -= min(B, K)

if K > 0:
    ans -= min(C, K)
    K -= min(C, K)
print(ans)


Measured memory_bytes: 9184
#include<stdio.h>

int main() {
   int n,i;
   scanf("%d", &n);
   long long sum = 0;
   for(i = 1; i <= n; i++) {
      if(i % 3 != 0 && i % 5 != 0) {
         sum += i;
      }
   }
   printf("%lld\n", sum);
   return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string A;

	cin >> A;

	if ( A == "Sunny" ){
		cout << "Cloudy" << "\n";
	}else if ( A == "Cloudy" ){
		cout << "Rainy" << "\n";
	}else {
		cout << "Sunny" << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int a, b;
  scanf("%d %d", &a, &b);
  if (a == b)
  {
    puts("Draw");
  }
  else
  {
    puts(a == 1 || b != 1 && a > b ? "Alice" : "Bob");
  }
  return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX = 1e5 + 5;
const int MAX_V = 1e3 + 5;

// adjecent-list
struct Edge {
    int to;
    int weight;
};
vector<Edge> Graph[MAX];
bool checked[MAX];
int color[MAX];

typedef pair<int, int> P;        // (cst, to)
typedef tuple<int, int, int> P3; // (x_pos, y_pos, index)
vector<P> G[MAX];
bool used[MAX];

int prim() {
    priority_queue<P, vector<P>, greater<P>> que;
    memset(used, 0, sizeof(used));
    que.push(P(0, 0));
    int ret = 0;
    while (!que.empty()) {
        int cst = que.top().first, v = que.top().second;
        que.pop();
        if (used[v]) continue;
        used[v] = 1;
        ret += cst;
        for (int i = 0; i < G[v].size(); i++)
            que.push(P(G[v][i].first, G[v][i].second));
    }
    return ret;
}

bool comPair1(const P3 &firstElof, const P3 &secondElof) {
    return get<0>(firstElof) < get<0>(secondElof);
}

bool comPair2(const P3 &firstElof, const P3 &secondElof) {
    return get<1>(firstElof) < get<1>(secondElof);
}

int main() {
    int n;
    cin >> n;
    vector<P3> pos;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        pos.push_back(P3(x, y, i));
    }
    int res = 0;
    vector<P3> x_sort_pos = pos;
    sort(x_sort_pos.begin(), x_sort_pos.end(), comPair1);
    vector<P3> y_sort_pos = pos;
    sort(y_sort_pos.begin(), y_sort_pos.end(), comPair2);
    for (int i = 0; i < n - 1; i++) {
        int x_cost, y_cost;
        x_cost = get<0>(x_sort_pos[i + 1]) - get<0>(x_sort_pos[i]);
        y_cost = get<1>(y_sort_pos[i + 1]) - get<1>(y_sort_pos[i]);
        G[get<2>(x_sort_pos[i])].push_back(P(x_cost, get<2>(x_sort_pos[i + 1])));
        G[get<2>(x_sort_pos[i + 1])].push_back(P(x_cost, get<2>(x_sort_pos[i])));
        G[get<2>(y_sort_pos[i])].push_back(P(y_cost, get<2>(y_sort_pos[i + 1])));
        G[get<2>(y_sort_pos[i + 1])].push_back(P(y_cost, get<2>(y_sort_pos[i])));
    }
    cout << prim() << endl;
}


Measured memory_bytes: 17396
#include <iostream>

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

int main()
{
  int sum = 0, r, g, b;
  cin >> r >> g >> b;
  sum += 100 * r;
  sum += 10 * g;
  sum +=  b;
  if (sum % 4 == 0) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    c = int(a+b)
    r = int(math.sqrt(c))
    if r*r<c:
        print('No')
    else:
        print("Yes")
    return

if __name__=='__main__':
    a,b = SL()
    solve()

Measured memory_bytes: 27044
N = int(input())
T = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for _ in range(M)]
T.insert(0, 0)

for PX in PX:
    ans = T[:]
    ans[PX[0]] = PX[1]
    print(sum(ans))

Measured memory_bytes: 9176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC124C_cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine();
            int CountIfEven1 = 0;
            int CountIfEven0 = 0;
            for(int i = 0; i < x.Length; i++)
            {
                if (i % 2 == 0)
                {
                    if (x[i] == '0')
                    {
                        CountIfEven1++;
                    }
                    else
                    {
                        CountIfEven0++;
                    }
                }
                else
                {
                    if (x[i] == '0')
                    {
                        CountIfEven0++;
                    }
                    else
                    {
                        CountIfEven1++;
                    }
                }
            }
            Console.WriteLine(Math.Min(CountIfEven0, CountIfEven1));
        }
    }
}


Measured memory_bytes: 11232
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    lb = [1000000] + rli() + [1000000]
    ans = 0
    for i in range(n):
        ans += min(lb[i], lb[i+1])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int f[2097200],n,a[22][22],mx,mod=1000000007;
int dfs(int c,int msk){
    if(c==n) return 1;
    if(f[msk]) return f[msk];
    int cur=0;
    for(int i=0;i<n;i++)
    if(!((1<<i)&msk)&&a[c][i]) cur=(cur+dfs(c+1,msk|(1<<i)))%mod;
    return f[msk]=cur;
}
inline int getbit(int x){int ans=0;while(x) {if(x&1) ans++;x>>=1;} return ans;}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
    scanf("%d",&a[i][j]);
    //dfs(0,0);
    mx=1<<n;
    f[0]=1;
    for(int i=1;i<mx;i++){
        int cr=getbit(i);
        for(int j=0;j<n;j++)
        if((i&(1<<j))&&a[cr-1][j])
        f[i]=(f[i]+f[i^(1<<j)])%mod;
    }
    printf("%d",f[mx-1]);
    return 0;
}

Measured memory_bytes: 8448
INPUT = [int(i) for i in input().split(" ")]

N = INPUT[0]
K = INPUT[1]
Q = INPUT[2]
#print(INPUT)
A = []
for i in range(Q):
        A.append(int(input()))
#print(A)

P = [K]*N
#print(P)
for i in range(len(P)):
    P[i] = P[i] - Q

for i in A:
    P[i-1] = P[i-1] + 1
    

#print(P)

for i in P:
    if(i >= 1):
        print("Yes")
    else:
        print("No")
    

Measured memory_bytes: 11776
'use strict'

function Main(input){
  input=input.split(/\s+/);
  for(let i=0;i<input.length;i++){
    input[i]=parseInt(input[i]);
  }
  var N=input.shift();
  var M=input.shift();
  var Entry=[false,0,0,0,0,0,0,0,0,0,];
  var numToCost=[false,2,5,5,4,5,6,3,7,6,];
  var costToNum=[false,false,0,0,0,0,0,0,];
  for(let i=0;i<M;i++){
    let num=input[i]
    let cost=numToCost[input[i]];
    if(num>costToNum[cost]){
      costToNum[cost]=num;
    }
  }
  for(let i=2;i<8;i++){
    if(costToNum[i]===0){
      costToNum[i]=false;
    }
  } 
  var dp=[];
  dp[0]=[true,0,0,0,0,0,0,0,0,0];
  var i=1;
  while(i<N+1){
    for(let j=1;j<10;j++){
      if(dp[i-j]&&dp[i-j][0]&&costToNum[j]){
        let challenger=dp[i-j].concat();
        let num=costToNum[j];
        challenger[num]=dp[i-j][num]+1;
//        console.log(i+':'+challenger);
        dp[i]=larger(dp[i],challenger);
      }
    }
    i++;
  }
  var str='';
  for(let i=1;i<10;i++){
    let dig=''+i;
    for(let j=0;j<dp[N][i];j++){
      str=dig+str;
    }
  }
  console.log(str);
}

function larger(a1,a2){
  if(a1===undefined)return a2;
  var order1=0,order2=0;
  for(let i=9;i>0;i--){
     order1+=a1[i];
     order2+=a2[i];
  }
  if(order1>order2)return a1;
  if(order1<order2)return a2;
  for(let num=9;num>0;num--){
    if(a1[num]>a2[num])return a1;
    if(a1[num]<a2[num])return a2;
  }
return a1;
}

Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 15564
N = int(input())
INF = 10**12
A = []

for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)

def check():
    c = [[0]*N for i in range(N)]
    ans = 0
    for i in range(N):
        for j in range(N):
            flag = True
            for k in range(N):    
                if k == i or k == j:
                    continue
                if A[i][j] == A[i][k] + A[k][j]:
                    flag = False
                    break
                elif A[i][j] > A[i][k] + A[k][j]:
                    return -1
            if flag:
                c[i][j] = A[i][j]
    for i in range(N):
        ans += sum(c[i])
    return ans // 2

print(check())


Measured memory_bytes: 43612
#include<stdio.h>
int main()
{
  char s[4];
  scanf("%s",s);
  if(s[0]=='a'&&s[1]=='b'&&s[2]=='c')
    printf("Yes");
  else if(s[0]=='a'&&s[1]=='c'&&s[2]=='b')
    printf("Yes");
  else if(s[0]=='b'&&s[1]=='a'&&s[2]=='c')
    printf("Yes");
  else if(s[0]=='b'&&s[1]=='c'&&s[2]=='a')
    printf("Yes");
  else if(s[0]=='c'&&s[1]=='a'&&s[2]=='b')
    printf("Yes");
  else if(s[0]=='c'&&s[1]=='b'&&s[2]=='a')
    printf("Yes");
  else printf("No");
  return 0;
}

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

struct edge{
  ll to;
  ll cost;
};
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

ll N,M,A,B,T;
vector<edge> G[1000];
ll d[1000][101];
ll INF=(1LL<<60);

map<ll,bool> used;
ll check(ll X){
  if(used[X])return INF;
  used[X]=true;

  
  if(X<0)return INF;
  
  ll minA=INF;
  ll minB=INF;
  for(int i=0;i<=100;i++){
    if(d[A][i]<INF){
      ll valueA=d[A][i]+i*X;
      minA=min(minA,valueA);
    }
    if(d[B][i]<INF){
      ll valueB=d[B][i]+i*X;
      minB=min(minB,valueB);
    }
  }

  //  cout<<N<<' '<<X<<' '<<minA<<' '<<minB<<endl;
  return abs(minA-minB);
}

ll getCross(int A,int I,int B,int J){
  if(I==J)return 0;
  ll v=abs( d[A][I]-d[B][J] );
  ll w=abs( I-J );
  return v/w;
}

ll solve(){
  for(int i=0;i<N;i++)
    for(int j=0;j<=100;j++)
      d[i][j]=INF;
  priority_queue< PP , vector<PP> , greater<PP> > Q;
  d[T][0]=0;
  Q.push(PP(0,P(T,0)));
  while(!Q.empty()){
    PP pp=Q.top();Q.pop();
    ll cost=pp.first;
    ll pos=pp.second.first;
    ll cnt=pp.second.second;
    if( cost > d[pos][cnt] )continue;
    
    
    for(int i=0;i<(int)G[pos].size();i++){
      edge e=G[pos][i];
      ll ncost=cost;
      ll ncnt=cnt;
      if(e.cost==-1)ncnt++;
      else ncost+=e.cost;

      if(ncnt>100)continue;
      
      if( d[e.to][ncnt] > ncost ){
        d[e.to][ncnt]=ncost;
        Q.push( PP(ncost,P(e.to,ncnt)) );
      }
    }
  }

  ll ans=INF;
  for(int i=0;i<=100;i++){
    if(d[A][i]==INF)continue;
    for(int j=0;j<=100;j++){
      if(d[B][j]==INF)continue;
      ll y=getCross(A,i,B,j);
      
      ans=min(ans, check(y-1) );
      ans=min(ans, check(y) );
      ans=min(ans, check(y+1) );

      y=getCross(A,i,A,j);
      ans=min(ans, check(y-1) );
      ans=min(ans, check(y) );
      ans=min(ans, check(y+1) );

      y=getCross(B,i,B,j);
      ans=min(ans, check(y-1) );
      ans=min(ans, check(y) );
      ans=min(ans, check(y+1) );
    }
  }

  return ans;
}

void init(){
  used.clear();
  for(int i=0;i<1000;i++){
    G[i].clear();
  }
}

int main(){
  while(1){
    cin>>N>>M>>A>>B>>T;
    if(N==0&&M==0&&A==0&&B==0&&T==0)break;
    A--,B--,T--;
      
    init();
    for(int i=0;i<M;i++){
      ll a,b,c;
      string str;
      cin>>a>>b>>str;
      a--,b--;
      if(str=="x"){
        c=-1;
      }else{
        stringstream ss;
        ss<<str;
        ss>>c;
      }
      G[a].push_back((edge){b,c});
      G[b].push_back((edge){a,c});
    }
    cout<<solve()<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
#define maxn 100000
int n, m;

struct minheap
{
    vector <int> a;
    ll top()
    {
        if(a.empty())
        {
            cout<<"May code sai roi!";
            return 0;
        }
        return a[0];
    }
    void upheap(ll u)
    {
        if(u == 0)  return;
        ll p = (u-1) / 2;
        if(a[p] > a[u])                                             // adjust here
        {
            swap(a[p], a[u]);
            upheap(p);
        }
    }
    void downheap(int u)
    {
        ll l = u*2+1, r = u*2+2;
        if(l<a.size() && a[u]>a[l] && (r>=a.size() || a[l]<a[r]))   // adjust here
        {
            swap(a[l], a[u]);
            downheap(l);
        }
        else if(r<a.size() && a[u]>a[r] && a[r]<=a[l])              // adjust here
        {
            swap(a[r], a[u]);
            downheap(r);
        }
    }
    void push(ll x)
    {
        a.push_back(x);
        upheap(a.size()-1);
    }
    bool empty()
    {
        return a.empty();
    }
    void pop()
    {
        if(a.empty())
            cout<<"May code sai roi!";
        swap(a[0], a.back());
        a.pop_back();
        downheap(0);
    }
    ll sum()
    {
        ll res = 0;
        for(int i=0; i<a.size(); ++i)
            res += a[i];
        return res;
    }
};

struct obj
{
    int b, c;
}z[maxn];

minheap Q;
void input()
{
    cin >> n >> m;
    for(int i=0, x; i<n; ++i)
    {
        cin >> x;
        Q.push(x);
    }
    for(int i=0; i<m; ++i)
        cin >> z[i].b >> z[i].c;
}

bool cmp(obj a, obj b)
{
    return a.c > b.c;
}

void solve()
{
    sort(z, z+m, cmp);
    for(int i=0; i<m; ++i)
    {
        while(z[i].c > Q.top() && z[i].b > 0)
        {
            z[i].b--;
            Q.pop(); Q.push(z[i].c);
        }
    }
    cout << Q.sum();
}

int main()
{
    //freopen("test.inp","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    input();
    solve();
    return 0;
}


Measured memory_bytes: 1528
import java.util.*;
import java.io.*;
import java.lang.*;

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();
        
        System.out.println((a*b)/2);


    }
}


Measured memory_bytes: 35788
#include <stdio.h>

int main(void)
{
	int matrixa[100][100];
	int matrixaX, matrixaY;
	int matrixb[100];
	int matrixans[100];
	
	scanf("%d %d", &matrixaX, &matrixaY);
	
	for(int i = 0; i < matrixaX; i++){
		matrixans[i] = 0;
	}
	
	for(int i = 0; i < matrixaX; i++){
		for(int j = 0; j < matrixaY; j++){
			scanf("%d", &matrixa[i][j]);
		}
	}
	

	
	
	for(int i = 0; i < matrixaY; i++){
		scanf("%d", &matrixb[i]);
	}
	
	/*	
	for(int i = 0; i < matrixaX; i++){
		for(int j = 0; j < matrixaY; j++){
			printf("%d", matrixa[j][i]);
		}
		putchar('\n');
	}
	
	
	for(int i = 0; i < matrixaY; i++){
		printf("%d", matrixb[i]);
	}
	*/
	for(int i = 0; i < matrixaX; i++){
		
		for(int multiply = 0; multiply < matrixaY; multiply++){
			matrixans[i] += matrixa[i][multiply] * matrixb[multiply];
			//printf("%d ", matrixans[i]);
		}
	//	putchar('\n');
	}
	
	for(int i = 0; i < matrixaX; i++){
		printf("%d\n", matrixans[i]);
	}
	
	return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using LL = long long;    // Poland
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
#ifdef DEBUG
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Nl(), cerr << ""
#else
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(0);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}
// end of templates

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

	int A, B, m;
	cin >> A >> B >> m;
	vector<int> a(A), b(B);
	for(int &ai : a)
		cin >> ai;
	for(int &bi : b)
		cin >> bi;
	int answer = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
	while(m --> 0) {
		int x, y, c;
		cin >> x >> y >> c;
		answer = min(answer, a[--x] + b[--y] - c);
	}
	cout << answer << '\n';
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func main() {
	var flag bool = true
	var count, N int
	fmt.Scan(&N)
	nums := scanNums(N)

	for {
		for i, num := range nums {
			if num % 2 == 0 {
				nums[i] = num / 2
			} else {
				flag = false
			}
		}
		if flag == true {
			count++
		} else {
			break
		}
	}

	fmt.Println(count)
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		scan.close();
		int ans=(n>k)? k*x+(n-k)*y:n*x;
		System.out.println(ans);
	}
}

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

int main() {
  int a, b, x =1;
  cin >> a >> b ;

  for (int i = 0; i < a; i++) {

    if (x < b) {
      x*=2;
    }
    else{
      x+=b;
    }
  }

  cout << x << endl;
}

Measured memory_bytes: 256