akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
typedef complex<double> cd;
static const double pi = 3.141592653589793;

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

  int n;
  cin >> n;
  map<int, int> a;
  for(int i = 0; i < n; i++){
    int now;
    cin >> now;
    a[now]++;
  }

  bool ok = true;
  if(a.size() > 3) ok = false;
  if(a.size() == 1){
    if(!a.count(0)) ok = false;
  }
  if(a.size() == 2){
    if(!a.count(0)) ok = false;
    else{
      if(a.at(0) == n / 3 && n % 3 == 0) ok = true;
      else ok = false;
    }
  }
  if(a.size() == 3){
    queue<int> k;
    for(auto now : a){
      if(now.second != n/3) ok = false;
      if(n%3 != 0) ok = false;
      k.push(now.first);
    }
    int x, y, z;
    x = k.front();
    k.pop();
    y = k.front();
    k.pop();
    z = k.front();
    k.pop();
    int ans = x ^ y ^ z;
    if(ans != 0) ok = false;
  }

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

// 001
// 011
// 010

// 001
// 000
// 001


Measured memory_bytes: 3840
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

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

import collections
n = int(input())
a = LI()
ans = 0
r = []
l = []
for i in range(n):
    r.append(i+a[i])
    l.append(i-a[i])
cr =  collections.Counter(r)
cl =  collections.Counter(l)
for k,v in cr.items():
    ans += v*cl[k]
print(ans)

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

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            t, p, r = map(int, raw_input().split())
            if t == 0 and p == 0 and r == 0:
                break
            record = [[[], [], 0, i+1] for i in range(t)]
            for i in range(r):
                tid, pid, time, message = raw_input().split()
                tid = int(tid)
                pid = int(pid)
                time = int(time)
                if pid in record[tid-1][0]:
                    continue
                if message == 'CORRECT':
                    record[tid-1][0].append(pid)
                    record[tid-1][2] += record[tid-1][1].count(pid) * 1200 + time
                elif message == 'WRONG':
                    record[tid-1][1].append(pid)
            # print record
            for e in sorted(record, key=lambda x: (-len(x[0]), x[2])):
                print e[3], len(e[0]), e[2]
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4704
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    ll ans = n;
    if (n % 2 != 0) ans *= 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter

def main():
    n, q = map(int, input().split())
    c = Counter()
    for _ in range(q):
        u, v = map(int, input().split())
        c[u] += 1
        c[v] += 1

    safe = all(c[x] % 2 == 0 for x in c)
    print('YES' if safe else 'NO')

main()


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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos

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

  string S, T;
  cin >> S >> T;

  ll lens = S.length();
  ll lent = T.length();

  for (ll s = 1; s <= lens; s++) {
    for (ll t = 1; t <= lent; t++) {

      if (S[s - 1] == T[t - 1]) {
        dp[s][t] = dp[s - 1][t - 1] + 1;
      } else {
        dp[s][t] = max(dp[s][t - 1], dp[s - 1][t]);
      }
    }
  }

  // cerr << "    ";
  // for (ll t = 1; t <= lent; t++) {
  //   cerr << T[t - 1] << " ";
  // }
  // cerr << endl;

  // for (ll s = 0; s <= lens; s++) {
  //   cerr << S[s - 1] << " ";
  //   for (ll t = 0; t <= lent; t++) {
  //     cerr << dp[s][t] << " ";
  //   }
  //   cerr << endl;
  // }

  ll s = lens;
  ll t = lent;

  string res = "";

  while (0 < s && 0 < t) {
    if (dp[s][t] == dp[s - 1][t]) {
      s--;
    } else if (dp[s][t] == dp[s][t - 1]) {
      t--;
    } else {
      res = S[s - 1] + res;
      s--;
      t--;
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

vector<vector<P> >g;
vector<int> color;

void dfs(int x){
	for(int i = 0; i < g[x].size(); i++){
		if(color[g[x][i].first]<0){
			color[g[x][i].first] = g[x][i].second%2==0?color[x]:abs(color[x]-1);
			dfs(g[x][i].first);
		}
	}
}

int main()
{
	int n;
	cin>>n;
	g.resize(n);
	color.resize(n,-1);
	for(int i = 0; i < n-1; i++){
		ll u,v,w;
		cin>>u>>v>>w;
		u--;
		v--;
		g[u].push_back(P(v,w));
		g[v].push_back(P(u,w));
	}

	color[0] = 0;
	dfs(0);
	for(int i = 0; i < n; i++){
		cout<<color[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    string str;
    cin >> str;
    int N = str.size();
    int ret = N;

    for (int i = 0; i < N - 1; ++i ) {
        if (str[i] != str[i+1]) {
            ret = min(ret, max(i+1, N-i-1));
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"

signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,down=0,start=0,end=0,r=0,qq=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    
    cin>>n;
    string a;
    map<string,int> mp;
    for(i=0;i<n;i++)
    {
        cin>>a;
        mp[a]++;
    }
    
    cout<<mp.size()<<endl;
    
    
    
    
}

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

using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define all(vec) vec.begin(),vec.end()
#define ff first
#define ss second
#define pi 3.141592653589
#define inf 4e18
#define MOD 1000000007
#define pb push_back
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for2(low,high,k) for(int j=low;j<high;j+=k)
#define rev(high,low,k) for(int i=high;i>=low;i-=k) 

int main(){
	fast;
	lli t;
	cin>>t;
	if (t>=30) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<map>
#define K 1000000000
#include<cstring>
using namespace std;

int n,m;
map<long long, long long> p;
long long d,t;

int main(){
	int i,j;
    scanf("%d",&n);
    for(i = 0; i < n; i ++)
    {
    	scanf("%lld",&d);
    	if(p[d]) p[d]++;
    	else p[d] = 1;
    	
	}
	scanf("%d",&m);
	for(j = 0; j < m; j ++)
	{
	    scanf("%lld",&t);
		if(p[t]) p[t] --;
		else{
			printf("NO");
			return 0;
		}	
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N;
  cin  >> N;
  ll ans = 1;
  ll huge = pow(10, 9) + 7;
  for(int i = 1; i <= N; i++){
    ans *= i;
    if(ans >= huge){
      ans %= huge;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=0, tail=0, n;

void enqueue(P x){
  Q[tail++]=x;
  if(tail>LEN) tail=0;
}

P dequeue(){
  P x;
  
  if(head==tail){
    x.t=-1;
    return x;
  }
  
  x=Q[head++];
  if(head>LEN) head=0;
  return x;
}


int main(){
  int e , c=0;
  int i, q;
  P u,p;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;
  tail=n+1;
  e=q;

  while( (p=dequeue()).t!=-1){
    if(p.t>e){
      c+=e;
      p.t-=e;
      enqueue(p);
    }

    else{
      c+=p.t;
      printf("%s %d\n",p.name,c);
      e=q;
    }
  }
  
  return 0;
}



Measured memory_bytes: 11940
from collections import Counter
from itertools import accumulate
import bisect

printRows = lambda x:print('\n'.join(map(str,x)))

n = int(input())
a = list(map(int, input().split()))
b = sorted(Counter(a).values())
exist = len(b)
b = [0]*(n-exist)+b
c = list(accumulate([0]+b))

ans = [n]
for k in range(2,exist+1):
    l = 0
    r = n//k+1
    while r-l>1:
        x = (r+l)//2
        i = bisect.bisect_left(b,x)
        if c[i]+(n-i)*x>=x*k:
            l = x
        else:
            r = x
    ans.append(l)

printRows(ans+[0]*(n-exist))

Measured memory_bytes: 126208
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		int x = 0;
		int i = 0;
		while(true) {
			x = sc.nextInt();
			if(x == 0 || i >10000) {
				break;
			}
			list.add(x);
			i++;
		}
		for(int j = 1; j < i+1; j++) {
			System.out.println("Case " + j + ": " + list.get(j-1));
		}
	}

}


Measured memory_bytes: 43616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int a;
	cin >> a;
	ll r = a + a*a + a*a*a;
	cout << r << endl;
	return 0;
}



Measured memory_bytes: 3648
from itertools import product
import numpy as np

N, M, X = map(int, input().split())
p = list(product([0, 1], repeat=N))
p = np.array(p).astype(bool)

# print(len(p))
C = []
A = []

for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)
A = np.array(A)
C = np.array(C)

# print(p, C, A)
INF = 10 ** 18
ans = INF

for i in range(len(p)):
    # print(cond, type(cond))
    B = A[p[i]]
    B = np.sum(B, axis=0)
    # print(B, B >= X)
    if np.all(B >= X):
        ans = min(ans, C[p[i]].sum())
if ans == INF:
    print(-1)
else:
    print(ans)



Measured memory_bytes: 27600
// AtCoder ABC133: A - T or T
// 2019.9.2 bal4u

#include <stdio.h>

int main()
{
	int N, A, B;
	
	scanf("%d%d%d", &N, &A, &B);
	printf("%d\n", N*A <= B? N*A: B);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <sys/time.h>
#include <unistd.h>
using namespace std;
#define i64         unsigned long long 
#define rep(i, n)   for(i64 i = 0; (i) < ((i64)(n)); ++(i))
#define bit(n)      (((i64)1)<<((i64)(n)))
#define sz(v)       ((i64)((v).size()))



void kill()
{
  cout << -1 << endl;
  exit(0);
}

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  priority_queue<pair<i64, i64>> q;
  rep(i, n) q.push(make_pair(b[i], i));

  i64 ans = 0;
  while(0 < sz(q)){
    // DEBUG(q);
    i64 i = q.top().second;
    q.pop();
    if(b[i] == a[i]) continue;
    if(b[i] < a[i]) kill();

    i64 prev = (i - 1 + n) % n;
    i64 next = (i + 1 + n) % n;
    i64 total = b[prev] + b[next];
    i64 times = (b[i]- a[i]) / total;
    // DEBUG(b[i], total, times);
    if(times == 0) kill();
    ans += times;
    b[i] -= total * times;
    q.push(make_pair(b[i], i));
  }

  cout << ans << endl;
}


Measured memory_bytes: 9584
let  lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', function (line: string) {
  lines.push(line);
});
reader.on('close', function() {
  if (lines.length === 0) return;
  let a: number[] = lines[1].split(/\s/).map(i => parseInt(i)).sort((x, y) => x - y);

  while (a.length > 1) {
    let min: number = a.shift();
    let tmp: number[] = a.map(item => item % min);
    a = tmp.filter(item => item !== 0);
    a.push(min);
  }
  console.log(a[0]);
});

Measured memory_bytes: 42452
[n,m] = list(map(int, input().split(" ")))
s = input()
t = input()
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
g = gcd(n,m)
out = n*m/g
for i in range (0,g):
    if s[i*int(n/g)] != t[i*int(m/g)]:
        out = -1
        break
print(int(out))

Measured memory_bytes: 3316
import bisect
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
ans = 0

from bisect import bisect_left
for k in range(N-2):
    for j in range(k+1, N-1):
        ans += bisect_left(L[j+1:], L[k]+L[j])
 
 
print(ans)

Measured memory_bytes: 50688
#include<iostream>
using namespace std;
 
using ll = long long;
const ll mod = 998244353;
 
 
ll dp[3030][3030][3];
int a[3030];
int main(){
    int n, k;
    cin >> n >> k;
    for(int i=0;i<n;i++)cin >> a[i];
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            (dp[i+1][j][0] += dp[i][j][0]) %= mod;
            (dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
            (dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= mod;
            if(j + a[i] <= k){
                (dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
                (dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1]) %= mod;
            }
        }
    }
    cout << dp[n][k][2] << endl;
}

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

int main()
{
    int n, k, ans = -1;
    cin >> n >> k;
    vector<int> v(n);
    for (auto &&e : v)
        cin >> e;
    for (int a = 0; a <= k; a++)
    {
        for (int b = 0; b <= k - a; b++)
        {
            if (a + b > n)
                break;
            vector<int> tmp;
            tmp.reserve(n);
            for (int i = 0; i < a; i++)
            {
                tmp.emplace_back(v[i]);
            }
            for (int i = n - 1; i >= n - b; i--)
            {
                tmp.emplace_back(v[i]);
            }
            sort(begin(tmp), end(tmp));

            int m = k - a - b;
            for (auto &p : tmp)
            {
                if (m <= 0)
                    break;
                if (p < 0)
                {
                    p = 0;
                    m--;
                }
            }
            ans = max(ans, accumulate(begin(tmp), end(tmp), 0));
        }
    }
    cout << ans << endl;
}


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

signed main() {
  int N;
  cin>>N;
  int a,b;
  cin>>a;
  for(int i=1;i<N;i++){
    cin>>b;
    a=a/__gcd(a,b)*b;
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256
def moderate_differences_2():
	n, a, b, c, d = map(int, raw_input().split(" "))
	# there are totally n-1 differences
	# assume y_i = x_(i+1)-x_i
	# -d<=y_i<=-c or c<=y_i<=d
	# assume there are m y_is meet -d<=y_i<=-c
	for m in range(0, n):
		max_sum = m*(-c)+(n-1-m)*(d)
		min_sum = m*(-d)+(n-1-m)*(c)
		if (b-a)>=min_sum and (b-a)<=max_sum:
			print "YES"
			return
	print "NO"

if __name__ == "__main__":
	moderate_differences_2()

Measured memory_bytes: 18436
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static int mod =1000000007;
	public static void main(String[] args) {
		
		int N=sc.nextInt();
		int K=sc.nextInt();
		int Q=sc.nextInt();
		
		
		if(K-Q>0) {
			for(int i=0;i<Q;i++) {
				sc.next();
			}
			for(int i=0;i<N;i++) {
				p("Yes");
			}
		}else {
			int t=K-Q;
			int v[]=new int[N];
			for (int i=0;i<N;i++) {
				v[i]=t;
			}
			for(int i=0;i<Q;i++) {
				v[sc.nextInt()-1]++;
			}
			for(int i=0;i<N;i++) {
				if(v[i]>0)p("Yes");
				else p("No");
			}
			
		}
		
		 
		
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 69020
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int[] num=new int[a];
		for(int i=0;i<a;++i){
			num[i]=sc.nextInt();
		}
		int[] dp=new int[a];
		dp[0]=num[0];
		int length=1;
		for(int i=1;i<a;++i){
			if(dp[length-1]<num[i]){
				dp[length++]=num[i];
			} else {
				int len=Arrays.binarySearch(dp,0,length-1,num[i]);
				if(len<=0){
					if(len!=0){
						len=(-1*len)-1;
					}
					if(len==dp.length){
						dp[length-1]=num[i];
					} else {
						dp[len]=num[i];
					}
				}
			}
		}
		System.out.println(length);
	}
}

Measured memory_bytes: 69156
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define mod 1000000007
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1;
    while(power>0)
    {
        if(power%2==1)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1)
    {
        return false;
    }
    if(n<=3)
    {
        return true;
    }
    if(n%2==0 || n%3==0)
    {
        return false;
    }
    for(ll i=5; (i*i)<=n; i+=6)
    {
        if(n%i==0 || n%(i+2)==0)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y)
{
    return ((x%mod)*(P(y,mod-2,mod)%mod))%mod;
}
int main()
{
    FAST
    FO
    FI
    ll a,b,k;
    IN a>>b>>k;
    ll temp= k-a;
    ll ans1, ans2;
    if(temp>=0LL)
    {
        ans1=0LL;
        ans2= max(0LL,b-temp);
    }
    else
    {
        ans1= a-k;
        ans2= b;
    }
    OUT ans1<<" "<<ans2;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n; cin >> n;
  int h[105];
  for(int i=0;i<n;i++) cin >> h[i];
  
  int ans = 0;
  while(true){
    if(*max_element(h,h+n) == 0) break;

    int i=0;
    while(i<n){
      if(h[i]==0) i++;
      else{
        ans++;
        while(i<n && h[i]>0){
          h[i]--;
          i++;
        }
      }
    }
  }

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

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def solve(N, x):
    que = deque(list(i for i in range(1, 2 * N) if i != x))
    ans = deque([x])
    i = 0
    while que:
        a = que.popleft()
        b = que.pop()
        if i % 2 == 0:
            ans.appendleft(a)
            ans.append(b)
        else:
            ans.appendleft(b)
            ans.append(a)
        i += 1
    return ans


def main():
    N, x = map(int, input().split())
    if 1 < x < 2 * N - 1:
        print("Yes")
        print(*solve(N, x), sep="\n")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n && n){
    ll sum = 0,a;
    rep(i,n/4){
      cin >> a;
      sum += a;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3172
import java.io.*
import java.util.*

fun solve(K: Int){
    println((K / 2) * ((K + 1) / 2))
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val K = sc.next().toInt()
    solve(K)
}



Measured memory_bytes: 29728
import math

H, W = list(map(int, input().split()))

if (H == 1 or W == 1):
    total = 1
else:
    total = 0
    total += math.ceil(H/2) * math.ceil(W/2)
    total += math.floor(H/2) * math.floor(W/2)
    
print(total)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static IEnumerable<int> Decompose(int n)
        {
            var list = new List<int>();
            while (n > 0)
            {
                list.Add(n % 10);
                n /= 10;
            }
            return list;
        }
        static int Solve(int N, int[] D)
        {
            for (int i = N; true; ++i)
            {
                if (Decompose(i).All(n => !D.Contains(n))) { return i; }
            }
        }
        static void Main(string[] args)
        {
            int[] v = ReadInts();
            int[] D = ReadInts();
            Console.WriteLine(Solve(v[0], D));
        }
    }
}


Measured memory_bytes: 15316
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int n;
    int a[200009];
    ll k;
    cin >> n >> k;

    FOR(i, 1, n + 1) cin >> a[i];

    int now = 1;

    int d[200009];
    memset(d, -1, sizeof(d));
    d[now] = 0;
    while(!~d[a[now]]) {
        d[a[now]] = d[now] + 1;
        now = a[now];
    }
    int x = d[a[now]], y = d[now] + 1 - x;
    now = a[now];

    if(k < x) {
        FOR(i, 1, n + 1) if(d[i] == k) {
            cout << i << endl;
            return 0;
        }
    }

    FOR(i, 1, n + 1) d[i] -= x;

    (k -= x) %= y;

    FOR(i, 1, n + 1) if(d[i] == k) cout << i << endl;

    return 0;
}

Measured memory_bytes: 5220
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
ans = n*(n-1)//2 + m*(m-1)//2
print(ans)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	private static final long MOD = 1_000_000_007L;

	/** 現在の縦、横と以前の縦、横による組合せ数の配列 */
	private static final int[][] counts = { { 3, 2, 1 }, { 6, 2, 3 } };

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			char[] s1 = scanner.next().toCharArray();
			char[] s2 = scanner.next().toCharArray();
			int i = 0, prev = 0;
			long result = 1L;
			while (i < n) {
				if (s1[i] == s2[i]) {
					// 縦の並び
					result = result * counts[0][prev] % MOD;
					prev = 1;
					i++;
				} else {
					// 横の並び
					result = result * counts[1][prev] % MOD;
					prev = 2;
					i += 2;
				}
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 23124
from heapq import heappop as pop
from heapq import heappush as push
INF = 1000000000000
while True:
  R = int(input())
  if not R:
    break
  w1, h1, x1, y1 = map(int, input().split())
  x1 -= 1
  y1 -= 1
  lst1 = [list(map(int, input().split())) for _ in range(h1)]
  used1 = [[False] * w1 for _ in range(h1)]

  w2, h2, x2, y2 = map(int, input().split())
  x2 -= 1
  y2 -= 1
  lst2 = [list(map(int, input().split())) for _ in range(h2)]
  used2 = [[False] * w2 for _ in range(h2)]

  def bfs(lst, used, que, w, h):
    v, y, x  = pop(que)
    if y > 0 and not used[y - 1][x]:
      push(que, (lst[y - 1][x], y - 1, x))
      used[y - 1][x] = True
    if h > y + 1 and not used[y + 1][x]:
      push(que, (lst[y + 1][x], y + 1, x))
      used[y + 1][x] = True
    if x > 0 and not used[y][x - 1]:
      push(que, (lst[y][x - 1], y, x - 1))
      used[y][x - 1] = True
    if w > x + 1 and not used[y][x + 1]:
      push(que, (lst[y][x + 1], y, x + 1))
      used[y][x + 1] = True
    return v

  que = [(1, y1, x1)]
  used1[y1][x1] = True
  rec1 = [[0, 0]]
  Max = 0
  acc = 0

  while que:
    v = bfs(lst1, used1, que, w1, h1)
    acc += 1
    if v > Max:
      rec1.append([v, acc])
      Max = v
    else:
      rec1[-1][1] += 1

  que = [(1, y2, x2)]
  used2[y2][x2] = True
  rec2 = [[0, 0]]
  Max = 0
  acc = 0

  while que:
    v = bfs(lst2, used2, que, w2, h2)
    acc += 1
    if v > Max:
      rec2.append([v, acc])
      Max = v
    else:
      rec2[-1][1] += 1
  
  end1 = len(rec1)
  end2 = len(rec2)
  ind1 = 0
  ind2 = end2 - 1
  ans = INF
#  print(rec1)
#  print(rec2)
  while ind1 < end1 and ind2 > 0:
    r1, sum1 = rec1[ind1]
    r2, sum2 = rec2[ind2]
    if sum1 + sum2 < R:
      ind1 += 1
      continue
    while ind2 > 0 and sum1 + sum2 >= R:
      ind2 -= 1
      r2, sum2 = rec2[ind2]
    if ind2 == 0 and sum1 + sum2 >= R:
      ans = min(ans, r1 + r2)
      break
    else:
      if ind2 < end2 - 1:
        ind2 += 1
      r2, sum2 = rec2[ind2]
      ans = min(ans, r1 + r2)
    ind1 += 1
  print(ans)


Measured memory_bytes: 58420
import sys
from collections import deque
import copy
import numpy as np

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = list(read_func().strip().split())
    length_set = set([])
    appeared_count = {}
    for i in range(N):
        A = int(input_raw[i])
        if A not in appeared_count:
            appeared_count[A] = 1
        else:
            appeared_count[A] += 1
            length_set.add(A)



    if len(length_set) == 0:
        print 0
    else:
        length_list = list(length_set)
        length_list.sort(reverse = True)
        max_length = length_list[0]
        next_maxt_length = length_list[1]

        if appeared_count[max_length] >= 4:
            print max_length * max_length
        else:
            print max_length * next_maxt_length

if __name__ == '__main__':
    main()


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

int main(){

  string s,t;
  cin >> s >> t;
  
  for(int i=0;i<t.size();i++){
  	cout << s[i];
    cout << t[i];
  }
  if(s.size()!=t.size())cout << s[s.size()-1];
  return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
  static void Main(string[] args)
  {
    int a = int.Parse(Console.ReadLine());
    int b = int.Parse(Console.ReadLine());
    int c = int.Parse(Console.ReadLine());
    int d = int.Parse(Console.ReadLine());
    int e = int.Parse(Console.ReadLine());
    int k = int.Parse(Console.ReadLine());
    
    if (e - a <= k)
    {
      Console.WriteLine("Yay!");
    }
    else
    {
       Console.WriteLine(":(");
    }  
  }
}

Measured memory_bytes: 13140
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
const int INF = 1001001001;
const int BG = 1000000007;

int64_t dp[110][100010];

int N, W;
vector<int> w(110), v(110);

int64_t dfs(int depth, int cost)
{
    int64_t res = 0;
    if (depth >= N)
        return res;
    //メモを確認
    if (dp[depth][cost] != -1)
        return dp[depth][cost];

    if (cost < w[depth])
    {
        res = dfs(depth + 1, cost);
    }
    else
    {
        res = max(dfs(depth + 1, cost), dfs(depth + 1, cost - w[depth]) + v[depth]);
    }
    return dp[depth][cost] = res;
}

int main()
{
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];
    rep(i, 110)
    {
        rep(j, 100010)
        {
            dp[i][j] = -1;
        }
    }
    cout << dfs(0, W) << endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll K,A,B;
    cin>>K>>A>>B;
    if(B-A<=2)
    {
        cout<<K+1<<'\n';
        return 0;
    }
    if(K<=A-1)
    {
        cout<<K+1<<'\n';
        return 0;
    }
    ll ans=0;
    ans=A;
    K-=A-1;
    ans+=(B-A)*(K/2)+(K&1);
    cout<<ans<<'\n';
}


Measured memory_bytes: 256
//============================================================================
// Name        : a
// Date        : Sun Feb 17 19:16:07 CST 2019
// Author      : landcold7
// Copyright   : Your copyright notice
// Description : None
//============================================================================
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define pvar(x) cout << #x << ": "
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define codejam(ix, v) cout << "Case #" << (ix) << ": " << (v) << '\n'
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define pvi(x, v) if(v) pvar(x); fora(a, x) cout << a << " "; cout << '\n'
#define par(x, s, n, v) if(v) pvar(x); fori(a, s, n) prt(x, a, n) cout << '\n'

#define trace(...) _f(#__VA_ARGS__, __VA_ARGS__)
template <typename T>
void _f(const char* name, T&& arg) {
    cout << fixed << name << ": " << arg << '\n';
}

template <typename T, typename... Args>
void _f(const char* names, T&& arg, Args&&... args) {
    const char* split = strchr(names + 1, ',');
    cout.write(names, split - names) << ": " << arg << " |";
    _f(split, args...);
}

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

void solve() {
    int a, b;
    cin >> a >> b;
    if (b % a == 0) {
        output(a + b);
    } else {
        output(b - a);
    }
}

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



Measured memory_bytes: 256
import math

N,D = map(int, raw_input().split())
array = []
num = 0

for i in range(N):
    array.append( map(int, raw_input().split()))

#print N,D,array
for i in range(N):
    for j in range(N):
        if i >= j :
            continue
        else:
            dist = 0
            for d in range(D):
                dist +=  (array[i][d] - array[j][d])*(array[i][d] - array[j][d])
#            print array[i], array[j], math.sqrt(dist)
            if (math.sqrt(dist) % 1) == 0:
                num += 1

print num


Measured memory_bytes: 2820
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      
      String[] lines = in.readLine().split(" ");
      int[] arr = new int[lines.length];
      int k=0;
      for (String s : lines) {
        arr[k++] = Integer.parseInt(s); 
      }
      Arrays.sort(arr);
      int step=0;
      if(arr[2] - arr[1] > 2) {
        for(; arr[1]+2 < arr[2]; step++) {
          arr[1] += 2;
        }
      }
      if(arr[1] - arr[0] > 2) {
        for(; arr[0]+2 < arr[1]; step++) {
          arr[0] += 2;
        }
      }

      Tuple3 t = new Tuple3(arr[0], arr[1], arr[2], step);

      bfs(t);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private void bfs(Tuple3 t) {
    Deque<Tuple3> que = new ArrayDeque<>();

    que.offer(t);

    Tuple3 cur;
    int step=0;
    while(!que.isEmpty()) {
      cur = que.poll();

      if(cur.isEq()) {
        System.out.println(cur.step);
        return;
      }

      step = cur.step + 1;
      if(cur.e[0] < cur.e[1] && cur.e[0] < cur.e[2])
        que.offer(new Tuple3(cur.e[0]+2, cur.e[1], cur.e[2], step));
      else if(cur.e[1] < cur.e[2])
        que.offer(new Tuple3(cur.e[0], cur.e[1]+2, cur.e[2], step));
      else
        que.offer(new Tuple3(cur.e[0], cur.e[1], cur.e[2]+2, step));

      if(cur.e[0] < cur.e[2] && cur.e[1] < cur.e[2])
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1]+1, cur.e[2], step));
      else if(cur.e[1] < cur.e[0] && cur.e[2] < cur.e[0])
        que.offer(new Tuple3(cur.e[0], cur.e[1]+1, cur.e[2]+1, step));
      else
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1], cur.e[2]+1, step));
      
    }
  }

  class Tuple3 {
    int[] e;
    int step;

    public Tuple3(int a, int b, int c, int step) {
      e = new int[3];
      e[0] = a;
      e[1] = b;
      e[2] = c;
      this.step = step;
    }

    public boolean isEq() {
      return (e[0] == e[1]) && (e[1] == e[2]);
    }
  }
}

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

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

typedef long long LL;

const int oo = 0x3f3f3f3f;

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int a, b;
	scanf("%*d%d%d", &a, &b);
	if ((b - a) & 1) puts("Borys");
	else puts("Alice");
	return 0;
}


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

typedef long long ll;

main()
{
    ll n, i, j, c, a, m = 0;
    cin >> n;
    for(i = 1; i <= sqrt(n) + 1; i++){
        if(n % i == 0){
            a = n / i;
            m = max(m, i);
        }
    }
    c = (m - 1) + ((n / m) - 1);
    cout << c;


}





///promy_pompom
//hello world

Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());

		ArrayList<Integer> ans = new ArrayList<>();

		if(k * 2 > b - a) {
			for(int i = a; i <= b; i++) {
				ans.add(i);
			}
		}else {
			for(int i = a; i < a + k; i++) {
				ans.add(i);
			}
			for(int i = b - k + 1; i <= b; i++) {
				ans.add(i);
			}
		}

		int s = ans.size();
		// 出力
		for(int i = 0; i < s; i++) {
			System.out.println(ans.get(i));
		}
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

int n;

void init() {

}

void input() {
	cin >> n;
}

void solve() {
	if (n < 1000) cout << "ABC" << endl;
	else cout << "ABD" << endl;
}

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


Measured memory_bytes: 256
N,C = map(int,input().split())
D=[[int(i) for i in input().split()] for j in range(C)]
co=[[int(i) for i in input().split()] for j in range(N)]
A=[[0]*C for i in range(3)]#iに変えた時の違和感
for i in range(N):
    for j in range(N):
        t = (i+j)%3
        for s in range(C):
            A[t][s]+=D[co[j][i]-1][s]
ans =10**13
for x in range(C):
    for y in range(C):
        if x==y:
            continue
        for z in range(C):
            if x==z or y==z:
                continue
            ans=min(ans,A[0][x]+A[1][y]+A[2][z])
print(ans)

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

struct node{
  int value;
  node *next;
  node(int value, node *next):value(value),next(next){};
};
#define INF ( 1 << 28 )
string lcs(string &a, string &b){
  map< int , vector< int > > M;
  for(int i = b.size() - 1 ; i >= 0 ; i--){
    M[b[i]].push_back(i);
  }
  vector<int > HM(a.size() + 1, INF);
  HM[0] = -INF;
  vector<node*> link(a.size() + 1);
  for(int i = 0 ; i < a.size() ; i++ ){
    if(M.count(a[i])){
      vector< int > NEWHM = M[a[i]];
      for(int j = 0 ; j < NEWHM.size() ; j++ ){
        int k = distance( HM.begin(), lower_bound( HM.begin(), HM.end(), NEWHM[j]));
        HM[k] = NEWHM[j];
        link[k] = new node( b[NEWHM[j]], link[k - 1]);
      }
    }
  }
  string ans;
  for(node* p = link[distance(HM.begin(),lower_bound(HM.begin(),HM.end(),INF-1))-1];p;p = p->next){
    ans += (char)p -> value;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
int main(){
  int q;
  cin >> q;
  while(q--){
    string a, b;
    cin >> a >> b;
    string ans = lcs( a, b);
    cout << ans.size() << endl;
  }
}

Measured memory_bytes: 49296
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}

}






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


public class Main {
    public static long givenFunc(long b, long n){
        if(b<=1) return -1;
        if (n<b) return n;
        else return givenFunc(b,n/b)+n%b;
    }
    public static long solve(long N, long S){
        //when b is small enough, we can check it with the definition of func
        for(long b=2;b*b<=N;b++){
        	if(givenFunc(b,N)==S) return b;
        }
        //if b>sqrt(N), N=pb+q and S=p+q where p<sqrt(n)
        for(long p=(int)Math.sqrt(N)+1;p>=1;p--){
        	long b = 1+(N-S)/p;
        	if(givenFunc(b,N)==S) return b;
        }
        return N==S ? N+1 : -1;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long S = sc.nextLong();
        System.out.println(solve(N,S));
    }
}


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

struct Num {
    int idx, num;
    bool operator<(const Num &n) const {
        return (num == n.num) ? idx < n.idx : num < n.num;
    }
};

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

    int N;
    set<Num> S;
    cin >> N;
    for (int i = 0; i < N; i++) {
        Num n;
        n.idx = i;
        cin >> n.num;
        S.insert(n);
    }
    for (int i = 0; i < N; i++) {
        auto it = S.rbegin();
        if ((*it).idx == i) it++;
        cout << (*it).num << endl;
    }

    return 0;
}


Measured memory_bytes: 11008