akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main(){
  int n,p,S[100000],T[100000];
  bool exist;
  cin >> n;
  rep(i,n)cin >> S[i];
  cin >> p;
  rep(i,p)cin >> T[i];

  int count=0;

  rep(i,p){
    int lef=0,rig=n;
    exist = false;

    //2分探索
    while(lef < rig){
      int index=(lef+rig)/2;
      if(T[i] == S[index]){
	exist=true;
	break;
      }
      else if(T[i] < S[index]){
	rig=index;
      }
      else {
	lef = index+1;
      }
    }
    if(exist){
      count++;
    }
  }
  cout << count << endl;


}

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

int main() {
  int N; cin >> N;
  vector<int> v(N);
  rep(i, N) cin >> v[i];
  sort(v.begin(), v.end());
  double now = v[0];
  for (int i = 1; i < N; i++) {
    now = (now + v[i]) / 2.0;
  }
  cout << now << endl;
}

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

using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < n - 1; ++i) {
    if (x < a[i]) {
      cout << i << endl;
      return 0;
    }
    x -= a[i];
  }
  if (x == a[n - 1]) cout << n << endl;
  else cout << n - 1 << endl;
  return 0;
}


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

bool used[26];
int main(){
  string S; cin>>S;
  for(int i=0;i<S.size();i++)
    used[S[i]-'a'] = true;
  if(S.size() != 26){
    for(int i=0;i<26;i++){
      if(!used[i]){
        S += i + 'a';
        break;
      }
    }
  }
  else{
    bool ok = false;
    while(!S.empty() && !ok){
      int back = S.back() - 'a';
      S.erase(S.end()-1);
      used[back] = false;
      for(int i=back+1;i<26;i++){
        if(!used[i]){
          S += i + 'a';
          ok = true;
          break;
        }
      }
    }
  }
  if(S.empty()) cout<<-1<<endl;
  else cout<<S<<endl;
  return 0;
}


Measured memory_bytes: 256
S = input()[::-1]
find_w = False
w_count = 0
result = 0

for i, c in enumerate(S):
    if not find_w:
        if c == "B":
            continue
        else:
            find_w = True
            w_count += 1
    else:
        if c == "B":
            result += w_count
        else:
            w_count += 1

print(result)

Measured memory_bytes: 3500
#include <stdio.h>

int main (void) {

    long long a, b, c, d;

    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

    long long max;

    max = a * c;

    if (max < a * d)
        max = a * d;

    if (max < b * c)
        max = b * c;

    if (max < b * d)
        max = b * d;

    printf("%lld\n", max);

    return 0;
}

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


using namespace std;


int main()
{
    string s, S, T;
    cin >> s;
    cin >> T;

    for (int i = s.length() - T.length(); i >= 0; i--) {
        bool feasible = true;
        for (int j = 0; j < T.length(); j++) {
            if (s[i + j] != '?' && s[i + j] != T[j]) {
                feasible = false;
                break;
            }
        }

        if (feasible) {
            string head{s.begin(), s.begin() + i};
            string tail{s.begin() + i + T.length(), s.end()};
            S = head + T + tail;
            for (auto i = 0; i < S.length(); i++) {
                if (S[i] == '?')
                    S[i] = 'a';
            }
            break;
        }
    }
    if (S.empty()) {
        cout << "UNRESTORABLE" << endl;
    } else {
        cout << S << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
a, b = [], []
for _ in range(n):
    u, v = map(int, input().split())
    a.append(u)
    b.append(v)
a.sort()
b.sort(reverse = True)
if n % 2 == 1:
    print(b[n // 2] - a[n // 2] + 1)
else:
    print(b[n // 2] + b[n // 2 - 1] - a[n // 2] - a[n // 2 - 1] + 1)

Measured memory_bytes: 25388
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
	}
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
lli solve(){
	lli n;
	cin>>n;
	vll p(n);
	loop(i, 0, n)
		cin>>p[i];
	lli cnt = 1;
	lli mn = p[0];
	loop(i, 1, n){
		if(mn > p[i]){
			mn = p[i];
			cnt++;
		}
	}
	cout<<cnt<<"\n";
}
int main(){
	fastio;
	lli t;
	// cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}
 
vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    //res.emplace_back(i,0);
    res.push_back(make_pair(i,0));
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  //if (n != 1) res.emplace_back(n,1);
  if (n != 1) res.push_back(make_pair(n,1));
  return res;
}
 
int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a,b);
  auto f = factorize(g);
  int ans = f.size() + 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from math import floor


def parent_node(k):
    return k // 2


def left_node(k):
    return 2 * k


def right_node(k):
    return 2 * k + 1


def main():
    H = int(input())
    elems = [0] + [int(x) for x in input().split()]

    for k in range(1, H + 1):
        print("node {}: ".format(k), end="")
        print("key = {}, ".format(elems[k]), end="")
        if parent_node(k) >= 1:
            print("parent key = {}, ".format(
                elems[parent_node(k)]), end="")
        if left_node(k) <= H:
            print("left key = {}, ".format(
                elems[left_node(k)]), end="")
        if right_node(k) <= H:
            print("right key = {}, ".format(
                elems[right_node(k)]), end="")
        print()


main()



Measured memory_bytes: 5800
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;

#define for01(k,n)  for (ll i=k; i<n; i++)
#define for02(k,n)  for (ll j=k; j<n; j++)
#define for03(k,n)  for (ll k=k; k<n; k++)
#define for11(k,n)  for (ll i=k; i<=n; i++)
#define for12(k,n)  for (ll j=k; j<=n; j++)
#define for13(k,n)  for (ll k=k; k<=n; k++)

#define pb push_back
#define mp make_pair
#define pf push_front
#define popf pop_front
#define popb pop_back
#define vll vector<ll>
#define f first
#define s second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)
#define mll map<ll,ll>
#define mint map<int,int>
#define mll_it map<ll,ll>::iterator
#define mint_it map<int,int>::iterator

#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"

#define mem(a,n) memset(a, n, sizeof(a)); // n = 0 OR -1 only

#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define MOD1 1000000007
#define MOD2 998244353

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



// CUSTOM HASH FUNCTION - O(1)
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


//gp_hash_table - Open Address Hash Table

//gp_hash_table<int, int> table;

const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
};
//gp_hash_table<key, int, chash> table;


// Indexed Set
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indSet;

/* FUNCTIONS:
1. The function "find_by_order" returns an iterator to the element at a given position:
2. The function "order_of_key" returns the position of a given element
	-> If the element does not appear in the set, we get the position that the element
	   would have in the set
	-> O(log n)*/

void swap(multimap<char, int>& mp1, multimap<char, int>&mp2, char c1, char c2)
{
    auto it1 = mp1.find(c1);
    auto it2 = mp2.find(c2);

    //p1(it1->s << " " << it2->s);
    mp1.erase(it1);
    mp2.erase(it2);

    mp1.insert(mp(c2, it2->s));
    mp2.insert(mp(c1, it1->s));
}


int main()
{
  BOOST;
  ll n;
  cin >> n;
  
  ll ans = 1;
  
  while(n)
  {
    ans = (ans*n) % MOD1;
    n--;
  }
  p1(ans % MOD1);

  return 0;
}

Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
//fixed<<setprecision(10)<<ans<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> D(N),C(N);
    REP(i,N) cin>>D[i]>>C[i];
    ll sum = 0;
    ll digit = 0;
    REP(i,N){
        sum += D[i]*C[i];
        digit += C[i];
    }

    ll ans=(sum-1)/9 + digit - 1;

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#define NOT_FOUND -1
static const int MAXN = 10005;
using namespace std;

int linearSearch(int arr[], int len, int key)
{
	int i = 0;
	arr[len] = key;
	while (arr[i] != key) {
		i++;
	}
	if (i == len) {
		return NOT_FOUND;
	}
	
	return i;
}

int main(void)
{
	int S[MAXN];
	int T[MAXN];
	//int C[MAXN];
	int n, q, cnt = 0;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> T[i];
		if (linearSearch(S, n, T[i]) != NOT_FOUND) {
			//C[cnt] = S[i];
			cnt++;
		}
	}
//	for (int i = 0; i < n; i++) {
//
//	}
	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 3104
#include <stdio.h>
#include <assert.h>


int main(void) {
  int number_of_apples;
  int deploy;
  scanf("%d", &number_of_apples);
  scanf("%d", &deploy);
  assert(number_of_apples >= 1);
  assert(number_of_apples <= 20);
  assert(deploy >= 1);
  assert(deploy <= 20);
  
  int min_inspector = (number_of_apples + 2 * deploy) /
    (2 * deploy + 1);
  
  printf("%d\n", min_inspector);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define pq priority_queue
#define bcnt(n) __builtin_popcountll(n)

using ll = long long;  // long longをllだけにした
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using mll = map<long long, long long>;
using pll = pair<long long, long long>;
using sll = set<long long>;
using vpll = vector<pair<long long, long long>>;
using mlv = map<long long, vector<long long>>;

int main() {
	ll n;
	cin >> n;
	vector<long double> p(n);
	rep(i, n) cin >> p[i];
	vector<vector<long double>> dp(n + 1, vector<long double>(n + 1, (long double)0));
	// dp[i][j]はi-1個目まで投げて表がj個になる確率
	dp[0][0] = (long double)1;
	rep(i, n) {
		rep(j, n + 1) {
			if(j != 0) {
				dp[i + 1][j] = dp[i][j - 1] * p[i] + dp[i][j] * (1 - p[i]);
			} else {
				dp[i + 1][j] = dp[i][j] * (1 - p[i]);
			}
		}
	}
	long double res = 0;
	ll m = (n + 1) / 2;
	while(m < n + 1) {
		res += dp[n][m];
		m++;
	}
	cout << fixed << setprecision(10);
	cout << res << endl;
}


Measured memory_bytes: 141184
N = int(input())
A = list(map(int, input().split()))
A.sort()
INF = 10**6+1
lis = [1]*INF
exist = [0]*INF
for i in range(N):
    a = A[i]
    if lis[a] and exist[a] < 1:
        q = 2
        while a*q < INF:
            lis[a*q] = 0
            q += 1
    exist[a] += 1
cnt = 0
for a in A:
    if lis[a] and exist[a] == 1:
        cnt += 1
print(cnt)

Measured memory_bytes: 35260
#include <algorithm>
#include <iostream>

using namespace std;

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

    int happy[N][3];
    for (int i = 0; i < 3; ++i) {
        cin >> happy[0][i];
    }

    for (int d = 1; d < N; ++d) {
        fill(happy[d], happy[d + 1], 0);
        for (int i = 0; i < 3; ++i) {
            int h;
            cin >> h;
            for (int j = 1; j < 3; ++j) {
                happy[d][i] = max(happy[d][i], happy[d - 1][(i + j) % 3] + h);
            }
        }
    }

    cout << *max_element(happy[N - 1], happy[N]) << endl;
    return 0;
}


Measured memory_bytes: 1408
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var s = o.a(1);
  var r = 0, b = 0;
  for(var i = 0; i < s.length; i++){
    if(s[i] === "0")r++;
    else b++;
  }
  return Math.min(r,b) * 2;
}

Measured memory_bytes: 9420
n = int(input())
alist  = list(map(int,input().split()))
list1 = alist[1::2]
list2 = alist[0::2]
from collections import Counter
dic1 = Counter(list1).most_common()
dic2 = Counter(list2).most_common()
dic1.append([0,0])
dic2.append([0,0])
if dic1[0][0]!=dic2[0][0]:
  print(n - dic1[0][1] - dic2[0][1])
else:
  print(min(n - dic1[0][1] - dic2[1][1], n -dic1[1][1] - dic2[0][1]))

Measured memory_bytes: 25628
#include <bits/stdc++.h>
using namespace std;
//#define long_long ll
int main(){
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    int a,b,K;
    cin >> a >> b >> K;
    int i = 0;
    while(i < K){
        if(a % 2 == 1){
            a -= 1;
        }
        b += a / 2;
        a = a / 2;
        i++;
        if(i >= K){
        break;
        }
        if(b % 2 == 1){
            b -= 1;
        }
        a += b / 2;
        b /= 2;
        i++;
    }
    cout << a << " "<<  b << endl;
}

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int, int>;

/*
 */
int n, m;
vi a;

bool check(int x){
  int res = 0;
  rep(i, 0, n){
    int p = lower_bound(all(a), x-a[i]) - a.begin();
    res += n - p;
  }
  return res < m;
}

signed main(){
  cin >> n >> m;
  a.resize(n);
  rep(i, 0, n) cin >> a[i];
  sort(all(a));

  int l = 0, r = 1e9;
  while(r-l > 1){
    int mid = (l+r)/2;
    if(check(mid)) r = mid;
    else l = mid;
  }

  int ans = 0;
  vi s(n+1);
  rep(i, 0, n) s[i+1] = s[i] + a[i];
  rep(i, 0, n){
    int p = upper_bound(all(a), l-a[i]) - a.begin();
    int t = n - p;
    ans += t*a[i] + (s[n]-s[p]);
    m -= t;
  }

  ans += m * l;
  cout << ans << endl;

  return 0;
}


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

int main(){

    int A,B,C;
    cin >> A >> B >> C;
    if((A==B && A!=C) || (A==C && A!=B) || (B==C && B!=A)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

    return 0;
}

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

int main() {
    int k, n;
    cin >> k >> n;
    int a[2*n];
    int64_t ans = 0;
    rep(i,n) {
        int b;
        cin >> b;
        a[i] = b;
        a[n+i] = b + k;
        if (i > 0) ans += a[i] - a[i-1]; 
    }
    int64_t final_ans = ans;
    rep(i,n) {
        ans -= a[i+1] - a[i];
        ans += a[n+i] - a[n+i-1];
        final_ans = min(ans, final_ans); 
    }
    cout << final_ans << endl;
}

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

string base = "CODEFESTIVAL2016";
string s;

int main()
{
    int res = 0;
    cin >> s;
    for(int i = 0;i < s.size();i++)
    {
        if(base[i] != s[i]) res++;
    }
    cout << res << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    char c[2][3];
    for(int i=0;i<2;i++){
        string s;cin >> s;
        for(int j=0;j<3;j++){
            c[i][j] = s[j];
        }
    }

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


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

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

int main()
{   
    int n, a, b;
    cin >> n >> a >> b;

    if ((b-a)%2 == 0)   cout << "Alice" << endl;
    else if ((b-a)%2 == 1)  cout << "Borys" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS

    string s; cin >> s;
    int k; cin >> k;
    int ss = s.size();
    ll ans = 0;

    vector<vector<vector<int>>> dp(ss+1,vector<vector<int>>(k+1,vector<int>(2)));
    dp[0][0][0] = 1;

    REP(i,ss) REP(j,k+1) REP(a,2) {
        int d = s[i] - '0';
        REP(x,10) {
            int i2 = i+1;
            int j2 = x != 0 ? j+1 : j;
            int a2 = (a == 1 || d > x) ? 1 : 0;
            if (j2 > k) continue;
            if (a2 == 0 && d < x) continue;
            dp[i2][j2][a2] += dp[i][j][a];
        }
    }

    ans = dp[ss][k][0] + dp[ss][k][1];

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long ll;
ll a[100005],b[100005];
int main()
{
	ll n,m,i,x,y;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		a[i]=x;
		b[i]=y;
	}
	sort(a,a+m,greater<int>());
	sort(b,b+m);
	ll ans=b[0]-a[0]+1;
	if(ans>=0)
	cout<<ans;
	else cout<<0;
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  if (n % k)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
def INT():
    return int(input())

def MI():
    return map(int, input().split())

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

from collections import Counter
import sys

N = INT()
A = LI()
count_A = Counter(A)
ans = 0

if sum([c > 1 for c in count_A.values()]) <= 1:
    print(ans)
    sys.exit()
    
count_st = []

for k, v in count_A.items():
    if v == 1:
        continue
    
    count_st.append(k)
    
    if v >= 4:
        count_st.append(k)
    
count_st.sort(reverse = True)
ans = count_st[0] * count_st[1]
print(ans)

Measured memory_bytes: 110760
#include<iostream>
#include<vector>
// #include<climits>
// #include<map>
// #include<algorithm>
// #include<string>
// #include<stack>
// #include<queue>
// #include <fstream>
using namespace std;

int main(){
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    vector<int> A(n+1);
    vector<int> B(n+1);
    vector<int> C(n);   
    for(int i=1;i<=n;i++)
        cin>>A[i];
    for(int i=1;i<=n;i++)
        cin>>B[i];
    for(int i=1;i<n;i++)
        cin>>C[i];
    int ans = 0;
    int prev = -1;
    for(int i=1;i<=n;i++){
        ans+=B[A[i]];
        if(prev == A[i]-1)
            ans+=C[A[i]-1];
        prev = A[i];
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
/*input
10
0
*/

#include <bits/stdc++.h>
using namespace std;

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define sort_f(x)  sort(x.begin(),x.end());
#define sort_r(x)  sort(x.rbegin(),x.rend());

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

#define N 200003

long  divisors(long x) {
    long limit = x;
    long numberOfDivisors = 0;

    if (x == 1) return 1;

    for (long i = 1; i < limit; ++i) {
        if (x % i == 0) {
            limit = x / i;
            if (limit != i) {
                numberOfDivisors++;
            }
            numberOfDivisors++;
        }
        if(numberOfDivisors>=4)
        {
            break;
        }
    }

    return numberOfDivisors;
}
 bool isPrime(long n)
{
   
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (long i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
#define max_a 100001
bool visit[max_a]={false};
vector<long> a[max_a];
long sum=0;
long cost[max_a];
void dfs(long node)
{
    visit[node]=true;
    
    for(int i=0;i<(int)a[node].size();i++)
    {
        if(visit[a[node][i]]==false)
        {
            sum+=cost[a[node][i]];
            dfs(a[node][i]);
            
        }
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
  lli  a;
  lli b;
  cin>>a>>b;
  cout<<(a*a)-b;
    return 0;
}



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

int main(void) {
  int K, X;
  cin >> K >> X;
  for (int i = X - K + 1; i < X + K - 1; i++) {
    cout << i << " ";
  }
  cout << X + K - 1 << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
L = [[] for i in range(N+1)]
d = [0] * (N+1)
f = [0] * (N+1)

time = 0

def dfs(key):
    global time
    time += 1
    d[key] = time
    for i in range(len(L[key])):
        if d[L[key][i]] == 0:
            dfs(L[key][i])
    time += 1
    f[key] = time
        

for i in range(N):
    Q = list(map(int, input().split()))
    L[Q[0]].extend(Q[2:])

for i in range(1,N+1):
    if d[i] == 0:
        dfs(i)
        #print("done")

for i in range(1,N+1):
    print(i, d[i], f[i])

    


Measured memory_bytes: 5712
import java.util.Calendar;
import java.util.Scanner;

public class Main {
	private static final int YEAR = 2004;
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while(true) {
			int month = sc.nextInt();
			int day = sc.nextInt();

			if(month == 0) {
				break;
			}

			System.out.println(getWeekName(month - 1, day));
		}

	}

	public static String getWeekName(int month, int day) {
		Calendar cal = Calendar.getInstance();
		cal.set(YEAR, month, day);
		String weekName = "";

		switch(cal.get(Calendar.DAY_OF_WEEK)) {
			case Calendar.SUNDAY:
				weekName = "Sunday";
				break;

			case Calendar.MONDAY:
				weekName = "Monday";
				break;

			case Calendar.TUESDAY:
				weekName = "Tuesday";
				break;

			case Calendar.WEDNESDAY:
				weekName = "Wednesday";
				break;

			case Calendar.THURSDAY:
				weekName = "Thursday";
				break;

			case Calendar.FRIDAY:
				weekName = "Friday";
				break;

			case Calendar.SATURDAY:
				weekName = "Saturday";
				break;
		}

		return weekName;
	}

}

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

int main(void){
  string A;
  cin >> A;
  if(A == "Sunny") cout << "Cloudy" << endl;
  else if(A == "Cloudy") cout << "Rainy" << endl;
  else if(A == "Rainy") cout << "Sunny" << endl;
 return 0; 
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner br = new FastScanner();
		StringBuilder n = new StringBuilder(br.nt());
		StringBuilder m = new StringBuilder(n.toString());
		int cont1 = 0, cont2 = 0;
		for(int i = 1;i<n.length();i++) {
			if(n.charAt(i)==n.charAt(i-1)) {
				if(n.charAt(i)=='1')n.setCharAt(i, '0');
				else if(n.charAt(i)=='0')n.setCharAt(i, '1');
				cont1++;
			}
		}for(int i = n.length()-2;i>=0;i--) {
			if(m.charAt(i)==m.charAt(i+1)) {
				if(m.charAt(i)=='1')m.setCharAt(i, '0');
				else if(m.charAt(i)=='0')m.setCharAt(i, '1');
				cont2++;
			}
		}
		System.out.println(Math.min(cont1, cont2));
	}
}

class FastScanner {
	BufferedReader br;
	StringTokenizer st;

	public FastScanner(String s) {
		try {
			br = new BufferedReader(new FileReader(s));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public FastScanner() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	ArrayList<Integer>[] ng(int n, int e) {
		ArrayList<Integer>[] adj = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			adj[i] = new ArrayList<Integer>();
		}
		for (int i = 0; i < e; i++) {
			int a = ni() - 1;
			int b = ni() - 1;
			adj[a].add(b);
			adj[b].add(a);
		}
		return adj;
	}

	Integer[] nIa(int n) {
		Integer[] arr = new Integer[n];
		for (int i = 0; i < n; i++) {
			arr[i] = ni();
		}
		return arr;
	}

	int[] nia(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = ni();
		}
		return arr;
	}

	Long[] nLa(int n) {
		Long[] arr = new Long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nl();
		}
		return arr;
	}

	long[] nla(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nl();
		}
		return arr;
	}

	String[] nsa(int n) {
		String[] arr = new String[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nt();
		}
		return arr;
	}

	String nt() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int ni() {
		return Integer.parseInt(nt());
	}

	long nl() {
		return Long.parseLong(nt());
	}

	double nd() {
		return Double.parseDouble(nt());
	}

}

Measured memory_bytes: 25300
import math

n = int(input())
s = int(input())
ans = -1
if n > s:
    sqrt_n = math.ceil(math.sqrt(n))
    for b in range(2, sqrt_n + 1):
        m = n
        f = 0
        while m >= b:
            f += (m % b)
            m //= b
        f += m
        if f == s:
            ans = b
            break
    b = sqrt_n
    if ans == -1:
        for p in range(sqrt_n - 1, 0, -1):
            if (n - s) % p == 0:
                b = (n - s) // p + 1
            if n % b + n // b == s:
                ans = b
                break
elif n == s:
    ans = n + 1
print(ans)

Measured memory_bytes: 73160
/** 
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 *  Institute : Pandit Deendayal Petroleum University
 **/
#include<bits/stdc++.h>

using namespace std; 

#define start_cooking int main()
#define food_is_ready return 0;
#define main_ingredient_added ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void cook()
{
    // start with your recipe
    long double a, b;
    cin>>a>>b;
    a *= b;
    long long ans = (long long)a;
    cout<<fixed<<setprecision(0)<<ans;
}

start_cooking
{
    main_ingredient_added
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while(t--)
        cook();
    food_is_ready
}

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

int p, q, a, n;
int aux( int i, int last, int prod, int c, int d )
{
    int count = 0;
    if ( c * q == d * p ) return 1;
    if ( i >= n ) return 0;

    for ( int y = last; prod * y <= a; y++ )
    {
        if ( q * ( y * c + d ) <= p * y * d ) count += aux( i+1, y, prod*y, y*c+d, y*d );
    }

    return count;
}

int main( void )
{
    while ( cin >> p >> q >> a >> n && p && q && a && n )
    {
        int count = aux( 0, 1, 1, 0, 1 );
        cout << count << endl;
    }
    return 0;
}

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

string s;
typedef long long ll;
ll ans=1, cnt[26];


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

    cin>>s;
    cnt[int(s[0]-'a')] = 1;
    for(int i = 1; i < s.length(); i++){
        int tem = int(s[i] - 'a');
        ans += i - cnt[tem];
        cnt[tem]++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
template<typename T>
bool chmin(T &a,T b){
    if(a<=b)return 0;
    a=b;
    return 1;
}

string d(string s){
    int n = s.size();
    int now = 0;
    string ret = "";
    bool fi = true;
    for(int i=0;i<n;i++){
        if(s[i] == '['){
            now++;
            if(fi){
                fi = false;
                continue;
            }
            if((fi==false) && now == 1)break;
            if(now == 2)ret += d(s.substr(i));
        }
        else if(s[i] == ']'){
            now--;
        }
        else if(now==1)ret += s[i];
        if(now == 0)break;
    }
    //cerr << s << " " << ret << endl;
    reverse(ret.begin(),ret.end());
    return ret;
}

string f(string s){
    int n = s.size();
    int now = 0;
    string ret = "";
    for(int i=0;i<n;i++){
        if(s[i] == '['){
            now++;
            if(now == 1) ret += d(s.substr(i));
        }
        else if(s[i] == ']') now--;
        else if(now == 0){
            ret += s[i];
        }
    }
    return ret;
}


signed main(){
    //ofstream cout("out.txt");

    string s;
    while(cin>>s){
        if(s == ".")break;
        string t;
        int n = s.size();
        int now = 0;
        for(int i=0;i<n;i++){
            if(s[i] == '+'){
                now++;
                now %= 26;
            }
            else if(s[i] == '-'){
                now += 25;
                now %= 26;
            }
            else if(s[i] == '?'){
                t += 'A';
                now = 0;
            }
            else if(s[i] == '[' || s[i] == ']') t += s[i];
            else{
                int c = s[i]-'A';
                c += now;
                c %= 26;
                t += (char)('A'+c);
                now=0;
            }
        }
        // cerr << t << endl;
        cout << f(t) << "\n";
    }
}



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

int main() {
    int N;
    std::cin >> N;
    int d[N];

    for (int i = 0; i < N; ++i) {
        std::cin >> d[i];
    }

    std::sort(d, d + N);

    int mid1 = d[N/2 - 1];
    int mid2 = d[N/2];
   
    std::cout << (mid2 - mid1) << std::endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  string s,t;
  cin >> s >> t;
  ll k=s.size();
  bool b=true;
  rep(i,k){
    if(s[i]!=t[i]){
      b=false;
    }
  }
  if(b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[])
{
    std::string n;

    std::cin >> n;

    long long sum = 0;
    for (int i = 0; i < n.length(); i++) {
        sum += n[i] - '0';
    }

    if (sum % 9 == 0) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int mp[10][5];
int main() {
  while (true) {
    int h;
    cin >> h;
    if (h == 0)
      break;
    for (int i = 0; i < 10; i++)
      for (int j = 0; j < 5; j++)
        mp[i][j] = 0;
    for (int i = h - 1; i >= 0; i--)
      for (int j = 0; j < 5; j++)
        cin >> mp[i][j];
    bool found = true;
    int score = 0;
    while (found) {
      found = false;
      for (int i = 0; i < 10; i++) {
        int bg = 0;
        for (int j = 1; j < 5; j++) {
          if (mp[i][j] != mp[i][bg]) {
            if (j - bg >= 3 && mp[i][bg] != 0) {
              found = true;
              for (int k = bg; k < j; k++) {
                score += mp[i][k];
                mp[i][k] = 0;
              }
            }
            bg = j;
          }
        }
        if (bg <= 2 && mp[i][bg] != 0) {
          found = true;
          for (int k = bg; k < 5; k++) {
            score += mp[i][k];
            mp[i][k] = 0;
          }
        }
      }
      for (int j = 0; j < 5; j++) {
        int t[10], p = 0;
        for (int i = 0; i < 10; i++)
          t[i] = 0;
        for (int i = 0; i < 10; i++)
          if (mp[i][j] != 0)
            t[p++] = mp[i][j];
        for (int i = 0; i < 10; i++)
          mp[i][j] = t[i];
      }
    }
    cout << score << endl;
  }
}


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

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

	int ans = (1 << 30);

	for (int i = 0; i + t.size() <= s.size(); i++)
	{
		string u = s.substr(i, t.size());

		int tmp = 0;
		for (int j = 0; j < t.size(); j++)
		{
			if (t[j] != u[j])
			{
				tmp++;
			}
		}

		ans = min(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    REP(i, N) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    ll res = 0;
    REP(i, N){
        ll x = lower_bound(A.begin(), A.end(), B[i]) - A.begin(); 
        ll y = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        res += x * y;
    }  
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int a[N],c[N],n,d[N],b[N],Ans;
int count(int x){
	int l=0,r=n;
	while (l<r){
		int mid=(l+r+1)/2;
		if (d[mid]>x)r=mid-1;
		else l=mid;
	}
	return l;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)scanf("%d",&b[i]);
	for (int i=0;i<29;i++){
		int T=1<<i,ans=0;
		for (int j=1;j<=n;j++)c[j]=a[j]%(2*T);
		for (int j=1;j<=n;j++)d[j]=b[j]%(2*T);
		sort(d+1,d+n+1);
		for (int j=1;j<=n;j++)
			(ans+=count(T*2-1-c[j])+count(T*4-1-c[j])-count(T*3-1-c[j])-count(T-1-c[j]))%=2;
		if ((ans+2)%2)Ans+=T;
	}
	printf("%d\n",Ans);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

int main(){
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	int n, m;
	std::cin >> n >> m;
	std::cout << n*(n-1)/2 + m*(m-1)/2;
	return 0;
}

Measured memory_bytes: 256
from collections import deque

def main():
    nmq = list(map(int, input().split()))
    abcd = [None]*50
    for i in range(nmq[2]):
        abcd[i] = list(map(int, input().split()))
    
    ma = 0

    qset = bf([1], nmq[0], nmq[1], [])

    for q in qset:
        score = 0
        for j in range(nmq[2]):
            if q[abcd[j][1]-1] - q[abcd[j][0]-1] == abcd[j][2]:
                score += abcd[j][3]
        if score > ma:
            ma = score

    print(ma)

    
def bf(now, n, m, stock):
    if len(now) == n:
        stock.append(now)
        return now
    for i in range(now[-1], m+1):
        aa = list(now)
        aa.append(i)
        re = bf(aa, n, m, stock)
    return stock
    



if __name__ == '__main__':
    main()

Measured memory_bytes: 19740
//Atcoder Beginner 172
//Date: 27-06-2020
//------------------------------------------------------------------------------

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 2e6 + 5;
const double E= 1e-9;
 
//------------------------------------------------------------------------------

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*#ifndef ONLINE_JUDGE 
	    freopen("input.txt","r", stdin);
	    freopen("output.txt","w",stdout);
	#endif    
    /*ifstream cin("input.txt");
    ofstream cout("output.txt");*/
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0; i<s.size();i++)
    {
        if(s[i]!=t[i])
        ++cnt;
    }
    cout<<cnt;
    return 0;
}

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

Measured memory_bytes: 3832
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <sstream>
#include <vector>
#include <set>
#include <string>
#include <iterator>
#include <queue>
#include <cmath>
#include <cassert>

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


const ll MOD = 1000000007LL;
ll N,M;
ll a[100010];
ll sum[100010];
bool enable[100010];

int main ()
{
    cin >> N >> M;
    REP(i,M) cin >> a[i];

    fill (enable, enable + 100010, true);
    REP(i,M) enable[a[i]] = false;
    sum[0] = 1;

    for (int i = 0; i < 100005; i++) {
        if (!enable[i]) continue;
        sum[i + 1] += sum[i];
        sum[i + 2] += sum[i];
        sum[i + 1] %= MOD;
        sum[i + 2] %= MOD;
    }

    cout << sum[N] % MOD << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int ctoi(char c){
    switch (c){
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
}

int main(){
    int N,M,Q;
    cin >> N >> M >> Q;
    vector<int> a(Q), b(Q), c(Q), d(Q);
    rep(i,Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    rep(i,Q){
        a[i]--;
        b[i]--;
    }
    vector<vector<string> > vec(10, vector<string> (0));
    rep(i,M){
        vec[0].push_back(to_string(i));
    }
    rep(i,9){
        rep(j, vec[i].size()){
            int x = ctoi(vec[i][j][i]);
            for (int k = x; k < M; k++){
                vec[i + 1].push_back(vec[i][j] + to_string(k));
            }
        }
    }
    int ans = 0;
    rep(i,vec[N - 1].size()){
        string x = vec[N - 1][i];
        int subans = 0;
        rep(j,Q){
            if (ctoi(x[b[j]]) - ctoi(x[a[j]]) == c[j]) subans += d[j];
        }
        ans = max(ans, subans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 10476
import java.util.*;

public class Main{
public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long a = scan.nextInt();
    long b = scan.nextInt();
    long c = scan.nextInt();
    long d = scan.nextInt();

    long prod = Math.max(Math.max(a * c,a*d), Math.max(b*c,b*d));
    System.out.println(prod);
    scan.close();
}
}


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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var N = Read().ToInt();
            var ar = new Dictionary<int, int>();
            var r = ReadSplit();
            for (int i = 0; i < N; i++)
            {
                try
                {
                    ar.Add(r[i].ToInt(), i);
                }
                catch (Exception)
                {
                    Write("NO");
                    return;
                }
            }
            Write("YES");
            Read();
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 35152
s = input()
x = 0
y = 'R'
rle = []
for c in s:
    if y == c:
        x += 1
    else:
        rle.append(x)
        x = 1
        y = c
rle.append(x)
ans = [0] * len(s)
i = 0
y = 'R'
for c in rle:
    if y == 'R':
        j = i + c - 1
        if c % 2 == 0:
            ans[j] += c // 2
        else:
            ans[j] += c // 2 + 1
        ans[j+1] += c // 2
        i += c
        y = 'L'
    else:
        if c % 2 == 0:
            ans[i] += c // 2
        else:
            ans[i] += c // 2 + 1
        ans[i-1] += c // 2
        i += c
        y = 'R'
print(' '.join(map(str,ans)))

Measured memory_bytes: 17816
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int num=0;
  while(num<n){
    if(num+4<n && s.substr(num, 5)=="dream"){
      if(num+4==n-1){
        break;
      } else {
        if(num+6>=n){
          cout << "NO" << endl;
          return 0;
        } else if(s.substr(num, 7)=="dreamer"){
          if(num+7>=n){
            break;
          } else if(s[num+7]=='a'){
            num+=5;
          } else {
            num+=7;
          }
        } else {
          num+=5;
        }
      }
    } else if(num+4<n && s.substr(num, 5)=="erase"){
      if(num+4==n-1){
        break;
      } else {
        if(num+5>=n){
          cout << "NO" << endl;
          return 0;
        } else if(s.substr(num, 6)=="eraser"){
          num+=6;
        } else {
          num+=5;
        }
      }
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 3692
n,k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

abb = sorted(ab)
temp =0

for i in range(n+1):
    if temp < k:
        temp += abb[i][1]
    else:
        print(abb[i-1][0])
        exit()

Measured memory_bytes: 28640