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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int N; cin >> N;
    string S; cin >> S;

    string res = S;
    int cur = 0;
    F0R(i,sz(S)) {
        if (S[i] == '(') cur++;
        else cur--;

        if (cur < 0) res = "("+res, cur = 0;
    }

    while(cur > 0) {
        res = res+")"; cur--;
    }

    cout << res << "\n";
}


Measured memory_bytes: 384
#include <algorithm>
#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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
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;

int main() {
  //
  ll n,W;
  cin>>n>>W;
  vl w(n),v(n);
  rep(i,n) cin>>w[i]>>v[i];
  map<ll, vector<ll>> mp;
  rep(i, n) {
    rep(k, 4) {
      if (w[i] == w[0] + k) {
        mp[k].emplace_back(v[i]);
      }
    }
  }
  rep(k, 4) {
    sort(ALL(mp[k]), greater<ll>());
    // cout << mp[k].size() << endl;
  }
  ll ans = 0;
  vl a(4, 0);
  for(a[0] = 0 ; a[0] <= mp[0].size(); a[0]++) {
    for(a[1] = 0 ; a[1] <= mp[1].size(); a[1]++) {
      for(a[2] = 0 ; a[2] <= mp[2].size(); a[2]++) {
        for(a[3] = 0 ; a[3] <= mp[3].size(); a[3]++) {
          // cout << a[0] << "," << a[1] << "," << a[2] << "," << a[3] << endl;
          ll curW = (a[0] + a[1] + a[2] + a[3]) * w[0] + a[1] + a[2] * 2 + a[3] * 3;
          // cout << curW << endl;
          ll curV = 0;
          rep(k, 4) {
            rep(i, a[k]) {
              curV += mp[k][i];
            }
          }
          if (curW <= W) {
            ans = max(ans, curV);
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ar              array
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("ip1.txt", "r", stdin);
	freopen("op1.txt", "w", stdout);
#endif
}
bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b);
int gcd(int a, int b) ;
int prime(int n);
int power(int x, int y);
int lcm(int a, int b);
int32_t main()
{
	k_007();
	int n, q;
	cin >> n;
	int a[n];
	umii m;
	int sum = 0;
	f(i, n)
	{
		cin >> a[i];
		sum += a[i];
		m[a[i]]++;
	}
	cin >> q;
	while (q--)
	{
		int l, r;
		cin >> l >> r;
		sum -= (m[l] * l);
		sum += (m[l] * r);
		m[r] += m[l];
		m.erase(l);


		cout << sum << endl;
	}
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int prime(int n) {
	int flag = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {flag = 0; break;}
	}
	return flag;
}
int power(int x, int y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
	else
		return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

Measured memory_bytes: 7388
'''
Created on 2020/09/03

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  a=list(map(int,pin().split()))
  s=0
  for i in a:
    s=s^i 
  ansl=[]
  for j in a:
    ansl.append(str(s^j))
  ans=" ".join(ansl)
  print(ans)
  return 
main()

Measured memory_bytes: 35780
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define For(I,N) for(int I=0;I<N;I++)
typedef unsigned long long ull;
using namespace std;
ll n,ht[100005],a,b;

bool check(ll k)
{
//	cout<<k<<':';
	ll s=0;
	rep(n)
	{
//		cout<<i<<' ';
//		s+=max(0,(ht[i]-k*b)/a);
		s+=max(0,(int)(ceil((float)(ht[i]-k*b)/(float)a)));
//		cout<<s<<' ';
	}
//	cout<<endl;
	return s<=k;
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>a>>b;
	a-=b;
	rep(n)
	{
		cin>>ht[i];
	}
	ll l=0,r=1000000000000,mid;
	while(l<=r)
	{
		mid=l+r>>1;
		if(!check(mid))
		{
			l=mid+1;
		}
		else
		{
			r=mid-1;
		}
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d%d",&a,&b);
	for(a=1;a<=9;a++){
		for(b=1;b<=9;b++){
			c=a*b;
			scanf("%d",&c);
			printf("%dx%d=%d\n",a,b,c);
		}
	}
	return 0;
}

Measured memory_bytes: 532
#include <stdio.h>

int main(void){
	int s, i, j, score[2] = {0};
	
	for(i = 0; i < 2; i++){
		for(j = 0; j < 4; j++){
			scanf("%d", &s);
			score[i] += s;
		}
	}
	
	if(score[0] >= score[1])
		printf("%d\n", score[0]);
	else
		printf("%d\n", score[1]);
		
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  int N; cin >> N;
  vector<vector<pii>> G(N);
  rep(i,N-1){
    int a, b; cin >> a >> b;
    --a, --b;
    G[a].push_back({b,i});
    G[b].push_back({a,i});
  }
  int c_max = 0;
  rep(i,N) chmax(c_max, (int)G[i].size());
  cout << c_max << endl;
 
  queue<pii> q;
  q.push({0,-1});
  vector<int> ans(N-1,-1);
  bool passed[N] = {};
  passed[0] = true;
  
  while(!q.empty()){
    auto p = q.front(); q.pop();
    int v = p.first, c = p.second;
    int color = (c==1)? 2 : 1;
    for (auto e : G[v]){
      if (passed[e.first]) continue;

      passed[e.first] = true;
      q.push({e.first, color});
      ans[e.second] = color;
      color++;
      if (color==c) color++;
    }
  }
  rep(i,N-1) cout << ans[i] << endl;
  
  
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 9776
'''
二部グラフ判定
'''
INFTY = 10**13
def floyd():
    for k in range(N):
        for i in range(N):
            if d[i][k] == INFTY:
                continue
            for j in range(N):
                if d[k][j] == INFTY:
                    continue
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

def dfs(v, c):
    color[v] = c
    for i in G[v]:
        if color[i] == c:
            return False
        if color[i] == 0 and not dfs(i, -c):
            return False
    # ds[v] += d
    return True
def solve():
    for i in range(N):
        if color[i] == 0:
            if not dfs(i, 1):
                return False
    return True
N = int(input())
G = [[]for i in range(N)]
color = [0 for i in range(N)]
# ds = [1 for i in range(N)]
d = [[0 if i == j else INFTY for j in range(N)]for i in range(N)]
for i in range(N):
    S = input()
    for j, s in enumerate(S):
        if s == '1':
            G[i].append(j)
            d[i][j] = 1

ans = solve()
if ans:
    floyd()
    print(max([max(di)for di in d])+1)
    # print(max(ds))
else:
    print(-1)


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

#define INF 1e8

int min(int a, int b){ return a < b ? a : b; }

int main(void){
  while(true){
    int n, m, s, g1, g2;
    cin >> n >> m >> s >> g1 >> g2;
    if(n == 0 && m == 0 && s == 0 && g1 == 0 && g2 == 0){ break; }
    --s; --g1; --g2;

    // ??£??\??????????§????
    vector<vector<int> > adjmatrix(n, vector<int>(n, INF));
    for(int i = 0; i < m; i++){
      int b1, b2, c;
      cin >> b1 >> b2 >> c;
      --b1; --b2;
      adjmatrix[b1][b2] = c;
      //adjmatrix[b2][b1] = c;
    }
    for(int i = 0; i < n; i++){ adjmatrix[i][i] = 0; }    

    // ???????????£???
    for(int k = 0; k < n; k++)
      for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
          adjmatrix[i][j] = min(adjmatrix[i][j], adjmatrix[i][k] + adjmatrix[k][j]);

    // ???????????±???????????????????????????
    int mincost = INF;
    for(int i = 0; i < n; i++){
      mincost = min(mincost, adjmatrix[s][i] + adjmatrix[i][g1] + adjmatrix[i][g2]);
    }

    // ??????
    cout << mincost << endl;
  }

  return 0;
}

Measured memory_bytes: 1260
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

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

    if (A.back() < K) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    ll p = A.front();
    for (ll i = 1; i < N; i++) {
        p = gcd(p, A[i]);
    }

    cout << (K % p == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
from functools import reduce

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
def gcd_list(numbers):
    return reduce(gcd, numbers)

N = int(input())

As = map(int, input().split())

print(gcd_list(As))


Measured memory_bytes: 11596
/*

 Remember, Hope is a good thing... May be the best of things... And No Good thing ever Dies !!!

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
const ll inf=(1LL<<60)-1;
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
double x[10],y[10];
ll divCount(ll n)
{
    bool hash[n + 1];
    memset(hash, true, sizeof(hash));
    for (ll p = 2; p * p <=n; p++)
        if (hash[p] == true)
            for (ll i = p * 2; i <=n; i += p)
                hash[i] = false;
    int total = 1;
    for (ll p = 2; p <= n; p++)
    {
        if (hash[p])
        {
            ll count = 0;
            if (n % p == 0)
            {
                while (n % p == 0)
                {
                    n = n / p;
                    count++;
                }
                total = total * (count + 1);
            }
        }
    }
    return total;
}
double dist(int i,int j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}
void solve()
{
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)
        cin>>x[i]>>y[i];
    vector<ll>a(n);
    for(ll i=0;i<n;i++)
        a[i]=i+1;
    ll fact=1;
    for(ll i=2;i<=n;i++)
        fact*=i;
        double sum=0.0;
    do
    {
        for(ll i=0;i<n-1;i++)
             sum+=dist(a[i],a[i+1]);
    }while(next_permutation(a.begin(),a.end()));
    cout<<fixed<<setprecision(10)<<sum/fact<<endl;
}
int main()
{
    IOS;
    //ll t;
    //cin>>t;
    //while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 4244
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    map<string,ll> mp;
    rep(i,0,N){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll cnt = 0;
    for(auto p:mp){
        cnt += p.second * (p.second - 1) / 2;
    }
    cout << cnt << endl;
}

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

#define MAX 50

int a[MAX][26];
int aa[26];

int main()
{
	int n;
	string S[MAX];

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

	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j < S[i].size(); j++ ) {
			a[i][S[i][j] - 'a']++;
		}
	}
	for( int i = 0; i < 26; i++ ) {
		aa[i] = INT32_MAX;
		for( int j = 0; j < n; j++ ) {
			aa[i] = min( aa[i], a[j][i] );
		}
	}

	for( int i = 0; i < 26; i++ ) {
		for( int j = 0; j < aa[i]; j++ ) {
			cout << (char)(i + 'a');
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

ll dp[5001][5001];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;
	string S;
	cin >> S;

	int M = S.size();

	dp[0][0] = 1;
	rep(i, N) {
		rep(j, i + 1) {
			dp[i + 1][j + 1] += dp[i][j];
			
			if (j) dp[i + 1][j - 1] += 2 * dp[i][j];
			else dp[i + 1][j] += dp[i][j];
			
		}
		rep(j, i + 2) dp[i + 1][j] %= mod;
	}

	co(dp[N][M]);

	Would you please return 0;
}

Measured memory_bytes: 193792
package main

import (
	"fmt"
)

func max(a []int) int {
	max := a[0]
	for _, v := range a {
		if max < v {
			max = v
		}
	}
	return max
}

func min(a []int) int {
	min := a[0]
	for _, v := range a {
		if v < min {
			min = v
		}
	}
	return min
}

func main() {
	var N, M, X, Y int
	fmt.Scan(&N, &M, &X, &Y)

	x := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&x[i])
	}
	y := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&y[i])
	}

	xmax := max(x)
	ymin := min(y)

	for z := X + 1; z <= Y; z++ {
		if xmax < z && z <= ymin {
			fmt.Println("No War")
			return
		}
	}
	fmt.Println("War")
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String[] line;
      MyList list = new MyList();

      for(int i=0; i<n; i++) {
        line = br.readLine().split(" ");
        switch( line[0] ) {
          case "insert" :
            list.insertFirst( Integer.parseInt(line[1]) );
            break;
          case "deleteFirst" :
            list.deleteFirst();
            break;
          case "deleteLast" :
            list.deleteLast();
            break;
            case "delete" :
              list.delete( Integer.parseInt(line[1]) );
              break;
          default :
            System.out.println("n:" + i + " is failed.");
        }
      }

      System.out.println ( list.getAllElements() );
    }
  }
}

class Node {
  Node next,prev;
  int key;

  public Node(int key) {
    this.key = key;
  }
}

class MyList {
  Node nil;
  Node current;
  int size;

  public MyList() {
    nil = new Node(0);
    nil.next = nil.prev = nil;
    size = 0;
  }

  public String getAllElements() {
    StringBuilder buf = new StringBuilder(size*2);

    if(size > 0){
      current = nil.next;
      for(int i=0; i<size; i++){
        buf.append(current.key).append(" ");
        current = current.next;
      }
    }
    buf.setLength(buf.length()-1);

    return buf.toString();
  }
  public void insertFirst(int x) {
    if(size == 0) {
      current = new Node(x);
      nil.next = current;
      nil.prev = current;
      current.prev = nil;
      current.next = nil;
      size++;
    }
    else {
      Node add = new Node(x);
      
      current.prev.next = add;
      add.prev = current.prev;

      add.next = current;
      current.prev = add;

      current = add;
      size++;
    }
  }
  public void deleteFirst() {
    nil.next = current.next;
    current.next.prev = current.prev;

    current = current.next;
    size--;
  }
  public void deleteLast() {
    current = nil.prev;

    nil.prev = current.prev;
    current.prev.next = current.next;

    current = nil.next;
    size--;
  }
  public void delete(int x) {
    Node target = findFirst(x);

    if(target == nil) current = current.next;
    else {
      current.prev.next = target.next;
      current.next.prev = target.prev;
      current = nil.next;
      size--;
    }
  }
  private Node findFirst(int x) {
    while(current != nil) {
      if(current.key == x) break;
      current = current.next;
    }

    return current;
  }
}


Measured memory_bytes: 189728
from collections import deque

def reachable(es, source):
	ret = {source}
	Q = [source]
	while Q:
		cur = Q.pop()
		for nxt in es[cur]:
			if nxt not in ret:
				Q.append(nxt)
				ret.add(nxt)
	return ret

def SPFA(G:list, source=0):
	V = len(G)
	d = [float("inf")]*V
	inQ = [False]*V
	cnt = [0]*V
	d[source] = 0
	cnt[source] = 1
	Q = deque([source])
	while Q:
		f = Q.popleft()
		inQ[f] = False
		for t,c in G[f]:
			dist = d[f] + c
			if dist < d[t]:
				d[t] = dist
				if not inQ[t]:
					Q.append(t)
					inQ[t] = True
					cnt[t] += 1
					front = Q.popleft()
					if d[front] > dist:
						Q.append(front)
					else:
						Q.appendleft(front)
				if cnt[t] > V:
					#negative cycle
					return None
	return d[-1]
	
def main():
	N,M,P,*L=map(int,open(0).read().split())
	fwd = [[] for _ in range(N)]
	bwd = [[] for _ in range(N)]
	G = [[] for _ in range(N)]
	for a,b in zip(L[::3],L[1::3]):
		fwd[a-1].append(b-1)
		bwd[b-1].append(a-1)
	judge = reachable(fwd,0) & reachable(bwd,N-1)
	for a,b,c in zip(*[iter(L)]*3):
		if a-1 in judge and b-1 in judge:
			G[a-1].append((b-1,P-c))
	ans = SPFA(G)
	if ans==None:
		print(-1)
	else:
		print(max(0,-ans))

if __name__=="__main__":
	main()

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

int main(){
	int n, m;
	while(cin >> n >> m, n+m){
		int ncard[n], mcard[m];
		int nsum = 0, msum = 0;
		for(int i = 0; i < n; ++i){
			cin >> ncard[i];
			nsum += ncard[i];
		}
		for(int i = 0; i < m; ++i){
			cin >> mcard[i];
			msum += mcard[i];	
		}
		
		sort(ncard, ncard + n); sort(mcard, mcard + m);
		
		int i = 0;
		int j = 0;
		bool flag = false;
		while(!flag && i < n){
			j = 0;
			while(!flag && j < m){
				if(nsum - ncard[i] + mcard[j] == 
							msum + ncard[i] - mcard[j]){
					flag = true;
				}
				if(!flag) ++j;
			}
			if(!flag) ++i;
		}
		if(flag) cout << ncard[i] << " " << mcard[j] << endl;
		else cout << "-1" << endl;
	}	
}

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

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
ll get_alphabet_index(char c){
	ll ans = -1;
	REP(i,alphabet.size()){
		if (c==alphabet[i]){
			ans = i;
			break;
		}
	}
	return ans;
}

// 検索タグ
int main() {
	// 入力
	ll N;cin>>N;
	string S;cin>>S;
	ll S_list[N];
	// set: 重複なしの集合
	set<ll> S_set[alphabet.size()]; // アルファベットごとにsetを用意
	REP(i,N){
		ll index = get_alphabet_index(S[i]);
		S_list[i] = index;
		S_set[index].insert(i); // O(logN)
	}


	ll Q;cin>>Q;
	// printf("%s\n", S.c_str()); // stringをprint
	// REP(i,N)printf("%lld ", S_list[i]);
	// printf("\n");

	// 解法
	REP(i,Q){
		ll type;cin>>type;
		if (type==1){ // 入れ替え処理
			ll i_tmp;cin>>i_tmp;i_tmp--; // 差し替えるのが何文字目か
			char c_tmp;cin>>c_tmp;
			ll index_before = S_list[i_tmp]; // 差し替え前の文字のアルファベット番号
			ll index_after = get_alphabet_index(c_tmp); // 差し替え後の文字のアルファベット番号
			S_list[i_tmp] = index_after;
			S_set[index_before].erase(i_tmp); //  O(logN)
			S_set[index_after].insert(i_tmp); //  O(logN)
			// printf("type: 1, ");
			// REP(j,N)printf("%lld ", S_list[j]);
			// printf("\n");

		}
		if (type==2){ // 入れ替え処理
			ll l_tmp, r_tmp;cin>>l_tmp>>r_tmp;l_tmp--;r_tmp--;
			// printf("type: 2, substr: ");
			// REP(j,r_tmp-l_tmp+1){
			// 	printf("%c", alphabet[S_list[l_tmp+j]]);
			// }
			// printf("\n");
			ll ans = 0;
			REP(j, alphabet.size()){
				// lower_bount(x): x以上の要素のうち最も小さい要素のイテレータを返す。
				// 存在しない場合最後のイテレータを返す
				// *iter 要素を返す?
				if (S_set[j].size()==0)continue; // 一文字もないアルファベットはパス
				auto itr_lower = S_set[j].lower_bound(l_tmp); // lから左にある最初index
				// printf("%s, %lld<=%lld<=%lld\n", alphabet.substr(j,1).c_str(), l_tmp, *itr_lower, r_tmp);
				if (itr_lower==S_set[j].end())continue;// lより右になかった
				if (*itr_lower<=r_tmp) ans++;
				
			}
			printf("%lld\n", ans);
		// 	REP(j,abc.size()){
		// 		if (S_tmp.substr(i_tmp,1)==abc.substr(j,1)){
		// 			S[i] = j;
		// 			S_set[j].insert(i);
		// 		}

		}
	}

	//出力
}


Measured memory_bytes: 28164
n=int(input())
m=[]
m.append(int(input()))
count=1
for i in range(n-1):
  k=int(input())
  if k<=m[-1]:
    m.append(k)
    count+=1
  else:
    r=count-1
    l=0
    while l+1<r:
      try1=(r+l)//2
      if m[try1]>=k:
        l=try1
      else:
        r=try1
    if m[l]>=k:
      m[r]=k
    else:
      m[l]=k
print(count)

Measured memory_bytes: 75588
#include <cstdio>
#include <algorithm>
using namespace std;


int main()
{
    int arr[5], t;
    for (int i = 0; i < 5; i++) {
        scanf("%d", &t); arr[i] = t * -1;
    }
    sort(arr, arr+5);
    for (int i = 0; i < 5; i++) {
        if (i) printf(" ");
        printf("%d", arr[i]*-1);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 2772
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int a[SIZE],b[SIZE],d[2][SIZE],c[SIZE],cn;
set<PII> need[SIZE];

struct Union_Find{
    int d[SIZE],num[SIZE];
    void init(int n){
        REP(i,n)d[i]=i,num[i]=1;
    }
    int find(int x){
        return (x!=d[x])?(d[x]=find(d[x])):x;
    }
    bool uu(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y)return 0;
        if(num[x]>num[y])swap(x,y);
        num[y]+=num[x];
        d[x]=y;
        return 1;
    }
}U;
int main(){
    DRI(N);
    REP(i,N){
        RI(a[i]);
        a[N]^=a[i];
    }
    REP(i,N){
        RI(b[i]);
        b[N]^=b[i];
    }
    REP(i,N+1){
        d[0][i]=a[i];
        d[1][i]=b[i];
    }
    REP(i,2)sort(d[i],d[i]+N+1);
    REP(i,N+1){
        if(d[0][i]!=d[1][i])return 0*puts("-1");
        c[i]=d[0][i];
    }
    cn=unique(c,c+N+1)-c;
    REP(i,N+1){
        a[i]=lower_bound(c,c+cn,a[i])-c;
        b[i]=lower_bound(c,c+cn,b[i])-c;
    }
    U.init(N+1);
    int v=0;
    REP(i,N+1){
        if(a[i]!=b[i]){
            v++;
            U.uu(a[i],b[i]);
        }
    }
    if(a[N]==b[N]&&U.num[U.find(a[N])]==1)v++;
    if(!v)return 0*puts("0");
    if(a[N]==b[N])v++;
    v-=2;
    REP(i,N+1){
        if(U.find(i)==i&&U.num[i]>1)v++;
    }
    printf("%d\n",v);
    return 0;
}


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

int main(){
  int n,i,j,head,end;
  string s;

  cin >> n;

  for(int k=0;k<=n;k++){

    getline(cin,s);
    
    
    for(i=0;i<s.length();i++){
      if(s[i] == 'H' && s[i+1] == 'o' && s[i+2] == 's' && s[i+3] == 'h' && s[i+4] == 'i' && s[i+5] == 'n' && s[i+6] == 'o'){
	s[i]='H';
	s[i+1]='o';
	s[i+2]='s';
	s[i+3]='h';
	s[i+4]='i';
	s[i+5]='n';
	s[i+6]='a';
      }
    }
    if(k !=0)cout << s << endl;
   
    
  }
  



}

Measured memory_bytes: 0
def main():
    n = int(input())
    a = list(map(int,input().split()))
    mod = 10**9+7
    div = {}
    for i in range(61):
        div[i] = 0
    for i in range(n):
        b = bin(a[i])
        l = len(b)
        for j in range(l-2):
            if b[l-1-j]=='1':
                div[j]+=1
    ans = 0
    for k in div.keys():
        ans += div[k] * (n-div[k]) * 2**k
        ans = ans % mod
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 50760
#include <stdio.h>

int main()
{
    long H;
    long N;
    short tmp;
    
    scanf("%ld %ld", &H, &N);
    
    while(N>0)
    {
        scanf("%hd ", &tmp);
        H = H - tmp;
        N--;
    }
    
    if(H > 0)
    {
        printf("No");
    }
    else
    {
        printf("Yes");
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


//変数
ll N, M;
map<ll, map<ll, ll>> ab;
vector<ll> x;




//サブ関数
//入力
void input()
{
	cin >> N >> M;
	x.resize(N, M);
	REP(i, M) {
		ll a, b;
		cin >> a >> b;
		ab[b][a]++;
		x[0] += a;
		//0消滅を覚えておく
	}
}


//計算
void calc()
{
	for (const auto& row : ab) {
		ll b = row.first;
		for (const auto& col : row.second) {
			ll a = col.first;
			ll dup = col.second;
			ll st = b - a; st--;
			while (st < N) {
				x[st] -= dup * b;
				st += b;
			}
		}
	}
	REP(i, N - 1)x[i + 1] += x[i];
	for (auto a : x)cout << a << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	//debug();
	
	return 0;
}



Measured memory_bytes: 18928
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

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

    long long dp[2][N.length()][K + 1];
    rep(i,2) rep(j,N.length()) rep(k,K+1) dp[i][j][k] = 0;
    dp[0][0][1] = 1;
    dp[1][0][0] = 1;
    dp[1][0][1] = N[0] - '1';

    for (int j = 1; j < N.length(); j++) {
        for (int k = 0; k <= K; k++) {
            if (N[j] == '0') {
                dp[0][j][k] = dp[0][j - 1][k];
            } else {
                dp[0][j][k] = (k == 0 ? 0 : dp[0][j - 1][k - 1]);
                dp[1][j][k] = (dp[1][j][k] + dp[0][j - 1][k] + (k > 0 ? dp[0][j - 1][k - 1] * (N[j] - '1') % MOD : 0)) % MOD;
            }
            dp[1][j][k] = (dp[1][j][k] + (k > 0 ? dp[1][j - 1][k - 1] * 9 % MOD : 0) + dp[1][j - 1][k]) % MOD;
        }
    }

    cout << (dp[0][N.length() - 1][K] + dp[1][N.length() - 1][K]) % MOD << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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


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

    int N;
    ll K;
    cin >> N >> K;

    vector<ll> A(N);

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

    ll ans = 0;

    for(int d = 60; d >= -1; --d){
        
        if(d != -1 && !(K & (1LL<<d))) continue;

        ll tmp = 0;

        for(int e = 60; e >= 0; --e){
            ll mask = 1LL << e;

            int num = 0;

            for(int i = 0; i < N; ++i) if(A[i] & mask) ++num;

            if(e > d){
                if(K & mask) tmp += mask * (N - num);
                else tmp += mask * num;
            }
            else if(e == d){
                tmp += mask * num;
            }else{
                tmp += mask * max(num, N-num);
            }

        }

        chmax(ans, tmp);


    }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define mod 1000000007
using namespace std;

typedef long long int ll;
int n, m;
ll x, y;


int main(void){
	ll xsum = 0, ysum = 0;
	cin >> n >> m;
	//cout << n << " " << m << endl;
	for(int i = 1; i <= n; i++){
		cin >> x;
		xsum += (-n + 2 * i - 1) * x;
		xsum %= mod;
	}
	for(int i = 1; i <= m; i++){
		cin >> y;
		ysum += (-m + 2 * i - 1) * y;
		ysum %= mod;
	}
	ll ans = (xsum * ysum) % mod;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll H, W, a, b, c;
    cin >> H >> W;
    
    ll dS = INF;
    for(int i = 1; i <= H; i++) {
        a = i * W;
        b = (H-i) / 2 * W;
        c = H * W - a - b;
        dS = min(dS, max({abs(a-c), abs(a-b),abs(b-c)}));
        b = (H-i) * (W / 2);
        c = H * W - a - b;
        dS = min(dS, max({abs(a-c), abs(a-b),abs(b-c)}));
    }

    ll tmp = H;
    H = W;
    W = tmp;
    for(int i = 1; i <= H; i++) {
        a = i * W;
        b = (H-i) / 2 * W;
        c = H * W - a - b;
        dS = min(dS, max({abs(a-c), abs(a-b),abs(b-c)}));
        b = (H-i) * (W / 2);
        c = H * W - a - b;
        dS = min(dS, max({abs(a-c), abs(a-b),abs(b-c)}));
    }

    cout << dS << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int a,b,a1,b1;
	cin>>a>>b;
	if(a>b){
		if((a+b)%2==0){
			for(int i=b;i<a;i++){
				if((a-i)>=0) a1=a-i;
				else a1=i-a;
				if((b-i)>=0) b1=b-i;
				else b1=i-b;
				if(a1==b1){
					cout<<i;
					return 0;
				}
			}
		}
		else cout<<"IMPOSSIBLE";
	}
	else{
		if((a+b)%2==0){
			for(int i=a;i<b;i++){
				if((a-i)>=0) a1=a-i;
				else a1=i-a;
				if((b-i)>=0) b1=b-i;
				else b1=i-b;
				if(a1==b1){
					cout<<i;
					return 0;
				}
			}
		}
		else cout<<"IMPOSSIBLE";
	}
	return 0;
} 

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String S = sc.next();
		char[] C = S.toCharArray();
		char x = C[0];
		for(int i=1;i<N;i++) {
			if(C[i]==x) {
				C[i] = 0;
			} else {
				x = C[i];
			}
		}
		int ans = 0;
		for(int i=0;i<N;i++) {
			if(C[i]!=0) {
				ans++;
			}
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 27220
#include<iostream>
using namespace std;
#include<cstdio>
#include<cassert>
#include<utility>
#include<vector>

struct edge{ int from, to, cost; };

edge init(int f, int t, int c){ edge e; e.from = f, e.to = t, e.cost = c; return e; }

int main()
{
	int k, from, to, cost, n, m, r;
	scanf("%d %d %d", &n, &m, &r);

	edge *ES;
	ES = new edge [m];

	for(k = 0; k < m; k++){
		scanf("%d %d %d", &from, &to, &cost);
		ES[k] = init(from, to, cost);
	}

	int *d;
	d = new int [n];
	for(int i = 0; i < n; i++){ d[i] = 0; }
	bool *check;
	check = new bool [n];
	for(int i = 0; i < n; i++){ check[i] = false; }
	check[r] = true;
	
	for(int i = 1; i < n; i++){  // n - 1 loop.
		for(k = 0; k < m; k++){
			from = ES[k].from, to = ES[k].to;
			if(check[from] == false) continue;
			cost = ES[k].cost;
			if(check[to] == false){
				d[to] = d[from] + cost;
				check[to] = true;
			}else{
				if(d[from] + cost < d[to]){ d[to] = d[from] + cost; }
			}
		}
	}
	for(k = 0; k < m; k++){
		from = ES[k].from, to = ES[k].to;
		if(check[from] && check[to]){
			cost = ES[k].cost;
			if(d[from] + cost < d[to]){
				printf("NEGATIVE CYCLE\n"); break;
			}
		}
	}
	if(k == m){
		for(int i = 0; i < n; i++){
			if(check[i]){
				printf("%d\n", d[i]);
			}else{
				printf("INF\n");
			}
		}
	}
	delete [] ES, delete [] d, delete [] check;
	return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

int main() {
    string s; cin >> s;
    int n = sz(s);
    int cnt = 0;
    rep(i,n/2) {
        if (s[i] != s[n-1-i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3480
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,k = inpm()
    a = inpl()
    past = [0 for _ in range(n)]
    past[0] = 1
    root = [0]
    pre = 0
    while True:
        Next = a[pre]-1
        if past[Next]:
            break
        root.append(Next)
        pre = Next
        past[Next] = 1
    rev = []
    i = 0
    while root[len(root)-1-i] != Next:
        rev.append(root[len(root)-1-i])
        i += 1
    rev.reverse()
    rever = [Next]
    for i in range(len(rev)):
        rever.append(rev[i])
    n1 = len(root)
    n2 = len(rever)
    if n1-1 >= k:
        print(root[k]+1)
        return
    if rever[0] != 0:
        k -= n1-n2
    print(rever[(k)%n2]+1)
    
if __name__ == "__main__":
    main()

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

int main()
{
  int n;
  cin>>n;
  if(1<=n&&n<=9){
    cout<<n<<endl;
  } else if(10<=n&&n<=99){
    cout<<"9"<<endl;
  } else if(100<=n&&n<=999){
    cout<<n-90<<endl;
  } else if(1000<=n&&n<=9999){
    cout<<"909"<<endl;
  } else if(10000<=n&&n<=99999){
    cout<<n-9090<<endl;
  } else if(n==100000){
    cout<<"90909"<<endl;
  }
}
  

Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))
for i in range(N):
  P[i] = (P[i] + 1) / 2
t = sum(P[:K])
ans = t
for i in range(K, N):
  t = t - P[i-K] + P[i]
  ans = max(ans, t)

print(ans)

Measured memory_bytes: 25060
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


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


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

using namespace std;
int l,r,i,j;
int flag=1<<30;
int main(){
	cin>>l>>r;
	if(r-l>=2018){
		cout<<0;
		return 0;
	}
	for(int i=l;i<=r;i++){
		for(int j=i+1;j<=r;j++){
			if(flag>((i%2019)*(j%2019))%2019) 
				flag=((i%2019)*(j%2019))%2019; 
		}
	}
	//两个最小的不一定乘出来就是答案！！！！！！！！！！！！ 
	cout<<flag; 
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void mid(int w) {
    int i;

    for (i=0; i<w; i++) {
        if (i == 0) {
	    printf("#");
	    continue;
	}
	if (i == w-1) {
	    printf("#\n");
	    continue;
	}
	printf(".");
    }
}

void draw(int h, int w) {
    int i, j;

    for (i=0; i<h; i++) {
        if (i == 0 || i == h-1) {
            for (j=0; j<w; j++) printf("#");
	    printf("\n");
	} else {
	    mid(w);
	}
    }
}

void process() {
    int h, w;

    do {
        scanf("%d %d", &h, &w);
	if (h == 0 && w == 0) break;
	draw(h, w);
	printf("\n");
    } while (h != 0 || w != 0);
}

int main(void) {
    process();
    return 0;
}


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

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

    int N, A, B;
    cin >> N >> A >> B;

    int DISTANCE = B - A;
    if (DISTANCE % 2 == 0)
    {
        cout << "Alice" << endl;
    }
    else
    {
        cout << "Borys" << endl;
    }

    return 0;
}


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

int main() {
  ll A, B, K;
  cin >> A >> B >> K;
  ll eat_A = min(A, K);
  A -= eat_A;
  K -= eat_A;
  ll eat_B = min(B, K);
  B -= eat_B;
  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  
  int S;
  std::cin >> S;

  int h = S / 3600;
  S = S - h * 3600;
  int m = S / 60;
  S = S - m * 60;

  std::cout << h << ":" << m << ":" << S << std::endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define MAX 105
#define int long long int
using namespace std;
 
 
int32_t main()
{
    int N;
    cin >> N;
    int A[N],B[N],C[N];
    for(int i = 0 ; i < N ; i++)
        cin >> A[i] >> B[i] >> C[i];
    int dp[N][3];
    memset(dp,0,sizeof(dp));
    dp[0][0] = A[0];
    dp[0][1] = B[0];
    dp[0][2] = C[0];
    
    for(int i = 1 ; i < N ; i++)
    {
        for(int j = 0 ; j < 3 ; j++)
        {
            if(j == 0)
                dp[i][j] = max(dp[i-1][1], dp[i-1][2]) + A[i];
            else if(j == 1)
                dp[i][j] = max(dp[i-1][0], dp[i-1][2]) + B[i];
            else dp[i][j] = max(dp[i-1][0], dp[i-1][1]) + C[i];
        }
    }
    
    int ans =max({dp[N-1][0], dp[N-1][1], dp[N-1][2]});
    cout << ans;
    return 0;
}

Measured memory_bytes: 8260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;

struct match {
    match() {}
    vector<P> to;
    vector<P> from;
    int day = 0;
};

match g[1005][1005];
int a[1005][1005];
bool used[1005][1005];
bool done[1005][1005];

bool dfs(P v) {
    int x = v.first;
    int y = v.second;
    used[x][y] = true;
    done[x][y] = true;
    if (g[x][y].to.size()==0) {
        g[x][y].day = 1;
    }
    for (P p: g[x][y].to) {
        int ix = p.first;
        int iy = p.second;
        if (done[ix][iy] && used[ix][iy]) return false;
        else if (done[ix][iy]) {
            g[x][y].day = max(g[x][y].day, g[ix][iy].day+1);
        }
        else if (!used[ix][iy]) {
            if (!dfs(p)) {
                return false;
            }
            else {
                g[x][y].day = max(g[x][y].day, g[ix][iy].day+1);
            }
        }        
        else return false;
    }
    used[x][y] = false;
    return true;
}

int main(){
    int n;
    cin >> n;
    int ans = 0;

    rep(i, n) rep(j, n-1) {
        cin >> a[i][j];
        a[i][j]--;
    }

    rep(i, n) rep(j, n-2) {
        int x1 = i;
        int y1 = a[i][j];
        int x2 = i;
        int y2 = a[i][j+1];
        if (x1>y1) swap(x1, y1);
        if (x2>y2) swap(x2, y2);
        g[x1][y1].to.emplace_back(x2, y2);
        g[x2][y2].from.emplace_back(x1, y1);
    }

    rep(i, n) rep(j, n) {
        if (i>=j) continue;
        if (g[i][j].from.size()==0) {
            bool flg = dfs(P(i, j));
            if (!flg) {
                cout << "-1" << endl;
                return 0;
            }
            ans = max(ans, g[i][j].day);
        }
    }

    rep(i, n) rep(j, n) {
        if (i>=j) continue;
        if (g[i][j].day==0) {
            cout << "-1" << endl;
            return 0;
        }
    }
    
    

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


Measured memory_bytes: 92800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 121
	// https://atcoder.jp/contests/abc121/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[] b = new int[m];
		int res = 0;
		
		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		
		for (int i = 0; i < n; i++) {
			int total = 0;
			int[] k = new int[m];
			for (int j = 0; j < m; j++) {
				k[j] = sc.nextInt();
			}
			
			for (int l = 0; l < m; l++) {
				total += (k[l] * b[l]);
			}
			if (total + c > 0) { 
				res++;
			}
		}
		
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int l, a, b, c, d;
	cin >> l >> a >> b >> c >> d;

	while(a > 0 || b > 0){
		if(a > 0)
			a -= c;
		if(b > 0)
			b -= d;
		l--;
	}

	cout << l << endl;

	return 0;
}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main{
  public static void main(String[] args)throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    Set<Integer> integerSet = new HashSet<>();
    
    for(int i=0; i<3; i++){
      integerSet.add(Integer.parseInt(data[i]));
    }
    
    if(integerSet.size() == 2){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22228
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

#define MOD 1000000007
using ll = long long;
using namespace std;

int main() {
	int N;
	int r = 0, b = 0;
	string S;
	cin >> N;
	cin >> S;
	for (int i=0;i < N; i++)
	{
		if (S[i] == 'R') {
			r++;
		}
		else {
			b++;
		}
	}
	if (r > b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        str = scanner.nextLine();

        int i;
        for(i = 0; i < str.length(); i++){
            if(64 < str.charAt(i) && str.charAt(i) < 91){
                c = (char)(str.charAt(i) + 32);
                System.out.print(c);
            }
            else if(96 < str.charAt(i) && str.charAt(i) < 123){
                c = (char)(str.charAt(i) - 32);
                System.out.print(c);
            }
            else System.out.print(str.charAt(i));
        }
        System.out.println("");


        scanner.close();
    }
}


Measured memory_bytes: 26984
#include<stdio.h>

int main()
{
  int a, b, c, d;

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

  int ans;

  if(a >= b){
    ans += b;
  }else{
    ans += a;
  }

  if(c >= d){
    ans += d;
  }else{
    ans += c;
  }

  printf("%d", ans);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define MAXN 200
using namespace std;
long long int A[MAXN] = {0};
int N;
int even = 0;
void ware();
int main(){
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        if(A[i] % 2 == 0){
            even++;
        }
    }
    int kai = 0;
    while(even == N){
        ware();
        kai++;
    }
    cout << kai << endl;
    return 0;
}
void ware(){
    for(int i = 0;i < N;i++){
        A[i]/=2;
        if(A[i] % 2 == 1){
            even--;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  long long ans;
  if (n <= k) {
    ans = n-1;
  } else {
    ans = 0;
    for (int i=0;i<n-1;i++) {
      ans += ans/(k-1) + 1;
   }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 2760