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



int main() {
	int n, q; cin >> n >> q;
	set<pair<int, pair<int, int>>> worksbuf; // begin, pos, end
	map<int, pair<int, int>> works; // pos, begin, end

	for (int i = 0; i < n; i++) {
		int s, t, x;
		cin >> s >> t >> x;
		worksbuf.insert(make_pair(s - x, make_pair(x, t - x)));
	}

	vector<int> ans;

	auto worksitr = worksbuf.begin();
	for (int i = 0; i < q; i++) {
		int d; cin >> d;
		while (worksitr != worksbuf.end()) {
			if (worksitr->first > d) break;
			works[worksitr->second.first] =
				make_pair(worksitr->first, worksitr->second.second);
			worksitr++;
		}

		while (true) {
			if (works.size() == 0) {
				ans.push_back(-1); break;
			}
			auto worksitr2 = works.begin();
			if(worksitr2->second.second <= d) works.erase(worksitr2);
			else {
				ans.push_back(worksitr2->first);
				break;
			}
		}
		
	}

	for (int i : ans) {
		cout << i << endl;
	}

	return 0;
}


Measured memory_bytes: 27128
#include <stdio.h>
int a[200001];
int main(){
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);

  for(i=n-1;i>=0;i-=2)printf("%d ",a[i]);
  for(i=n%2;i<n;i+=2)printf("%d ",a[i]);
  return 0;
}

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


typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size1(a) int(a.size())
#define FOR(n) for(int i= 0;i<n;i++)
#define FORR(n) for(ll i= 0;i<n;i++)



// adjacency list graph input

// vector<vector<int> > adj(n, vector<int>());
// for (size_t i = 0; i < m; i++) {
// 	int x, y;
// 	cin >> x >> y;
// 	adj[x - 1].push_back(y - 1);

//}

int main() {
	fastio;


	int  n , k;
	cin >> n >> k;

	vi h(n , 0 );
	for (int i = 0 ; i < n ; i++) {
		cin >> h[i];
	}
	vi dp ( n , INT_MAX);
	dp[0] = 0  ;
	for (int i = 1 ; i < n ; i ++) {

		for (int j =  1; j <= k  ; j++ ) {
			if ((i - j) < 0 ) break ;
			dp[i] = min ( dp[i] , dp[i - j] + abs(h[i] - h [i - j]));

		}

	}
	cout << dp[n - 1];
	return 0;


}


Measured memory_bytes: 3952
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    N = I()
    w = []
    wc = set()

    for i in range(N):
        w.append(S())
        if w[i] in wc:
            print('No')
            return
        wc.add(w[i])

    for i in range(N-1):
        if w[i][-1] != w[i+1][0]:
            print('No')
            return

    print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ; 
long long n;
long long h[100010][3];
long long INF=1e9+10;
long long dx[100010][3];
long long dp(long long x,long long y){
	debug() << imie(x);
	if(x>=n)return 0;
	if(x==n-1)return h[x][y];
	if(dx[x][y]!=-1)return dx[x][y];
	long long ans=0;
	if(y==0){
		ans=h[x][y]+max(dp(x+1,y+1),dp(x+1,y+2));
	}
	else if(y==1){
		ans=h[x][y]+max(dp(x+1,y+1),dp(x+1,y-1));	
	}
	else{
		ans=h[x][y]+max(dp(x+1,y-1),dp(x+1,y-2));
	}
	// long long ans=min(choice2,choice1);
	return dx[x][y]=ans;
}
int main(){
	fastio;
	cin>>n;
	memset(dx,-1,sizeof dx);
	// h.resize(n);
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>h[i][j];
		}
	}
	debug() << imie(h);
	cout<<max({dp(0,0),dp(0,1),dp(0,2)})<<endl;
}	

Measured memory_bytes: 9600
#include <stdio.h>

const int N = 10000;

int main()
{
	int a[N], n, maxn = -1000005, minn = 1000005;
	long long sum = 0;
	scanf("%d",&n);
	
	int i;
	for(i = 0; i < n; i++)
	{
		scanf("%d",&a[i]);
		if(a[i] > maxn)
		{
			maxn = a[i];
		}
		if(a[i] < minn)
		{
			minn = a[i];
		}
		sum += a[i];
		
		
	}
	printf("%d %d %lld\n",minn, maxn, sum);
	return 0;
}


Measured memory_bytes: 2096
N = int(input())
A = [i for i in map(int, input().split())]

if 0 in A:
    print(0)
else:
    As = 1
    for i in range(N):
        As *= A[i]
        if 10**18 < As:
            print(-1)
            break

    if As <= 10**18:
        print(As)



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

int main() {
  int N;
  cin >> N;
  
  if (N%1110 <= 9 || N%1000%111 == 0) {
    cout << "Yes" << endl;
  }
  
  else { 
    cout << "No" << endl;
  }
}

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

typedef long long ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl '\n'
const int N = 1e3 + 5;
using namespace std;

int main() {
    IO;
    int n,k,a[N]; cin>>n>>k;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    sort(a,a+n);
    int sum=0;
    for (int i = 0; i < k; ++i) {
        sum+=a[i];
    }
    cout<<sum;


}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <queue>
using namespace std;
int main(){

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

	int t;
	cin>>t;
	char field[12][6];
	while(t--){
		for(int i = 0; i < 12; i++)
			for(int j = 0; j < 6; j++)
				cin>>field[i][j];
		bool fin=false;
		bool isCheck[12][6];
		int loopNum=-1;
		while(!fin){
			memset(isCheck,0,sizeof(isCheck));

			fin=true;
			for(int i = 0; i < 12; i++){
				for(int j = 0; j < 6; j++){
					if(!isCheck[i][j]&&field[i][j]!='.'&&field[i][j]!='O'){
						char col=field[i][j];
						vector<pair<int,int> > vpii;
						queue<pair<int,int> > q;
						q.push(make_pair(i,j));

						while(q.size()){
							pair<int,int> cp=q.front();q.pop();
							if(isCheck[cp.first][cp.second]||field[cp.first][cp.second]!=col)
								continue;
							isCheck[cp.first][cp.second]=true;
							vpii.push_back(cp);
							for(int k = 0; k < 4; k++){
								int ny=cp.first+dy[k];
								int nx=cp.second+dx[k];
								if(ny>=0&&nx>=0&&ny<12&&nx<6)
									q.push(make_pair(ny,nx));
							}
						}
						// 4ÂÈã¯¶FÌÕæªAµÄ¢êÎAÁ·
						// »ÌÛ»ê¼êÌÕæÌlûüÉ é¨¶áÜàª«Þ
						if(vpii.size()>=4){
							for(int k = 0; k < vpii.size(); k++){
								pair<int,int> p=vpii[k];
								field[p.first][p.second]='.';
								for(int l = 0; l < 4; l++){
									int ny=p.first+dy[l];
									int nx=p.second+dx[l];
									if(ny>=0&&nx>=0&&ny<12&&nx<6)
										if(field[ny][nx]=='O')
											field[ny][nx]='.';
								}
							}
							fin=false;
						}
					}
				}
			}
			// º
			for(int j = 0; j < 6; j++){
				int cnt=0;
				for(int i = 12-1; i >= 0; i--){
					if(field[i][j]!='.'){
						field[11-cnt][j]=field[i][j];
						if(11-cnt!=i)
							field[i][j]='.';
						cnt++;
					}
				}
			}
			loopNum++;
		}
		cout<<loopNum<<endl;
	}

	return 0;
}

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


void solve(long long N, long long A, long long B){
    cout<<min(N*A,B)<<endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
  Scanner obj=new Scanner(System.in);
  int h_l=obj.nextInt();
  int w=obj.nextInt();
  int c=2*w;
  int u=h_l-c;
  if(u>0){
  System.out.println(u);
  }else{
  System.out.println(0);
  }
}

}


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

using namespace std;

void put(int s, int n, char x, vector<string> &c)
{
	for (int i = s; i < 100; i += 2) {
		for (int j = 0; j < 100; j += 2) {
			if (n == 0) {
				return;
			}
			c[i][j] = x;
			--n;
		}
	}
}

int main()
{
	int A, B;
	cin >> A >> B;

	vector<string> c;
	for (int i = 0; i < 50; ++i) {
		c.emplace_back(100, '.');
	}
	for (int i = 0; i < 50; ++i) {
		c.emplace_back(100, '#');
	}

	put(0, B - 1, '#', c);
	put(51, A - 1, '.', c);

	cout << c.size() << " " << c[0].size() << endl;
	for (auto &x : c) {
		cout << x << endl;
	}
}


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

int main()
{
	int n;
   double a;

   cin >> n;

   if(n%2==0){
     cout << "0.5000000000" << endl;
   }
   else if(n==1){
     cout << "1.0000000000" << endl;
   }
   else{
     a = (double)(n-1)/(double)(2*n);
     printf("%11.10f\n", 1-a);
   }

	return 0;
}

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

int main()
{
  int64_t kane = 100;
  int64_t x;
  cin >> x;
  int year = 0;
  while(kane < x){
    year++;
    kane += kane / 100;
  }
  cout << year << endl;
}


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

const int MAXN = 200010;
int n, M, A[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> M; n <<= 1;
	for (int i = 1; i <= n; ++i) std::cin >> A[i];
	std::sort(A + 1, A + 1 + n);
	std::reverse(A + 1, A + 1 + n);
	int cnt = 0, rcur = n;
	while (rcur > cnt * 2) {
		if (cnt + 1 != rcur - cnt) {
			int x = A[cnt + 1] + A[rcur - cnt] - M;
			if (x >= 0) ++cnt;
			else --rcur;
		} else --rcur;
	}
	int ans = 0;
	for (int t = 1; t < rcur - t + 1; ++t)
		ans = std::max(ans, A[t] + A[rcur - t + 1] - M);
	for (int t = 1; rcur + t < n - t + 1; ++t)
		ans = std::max(ans, A[rcur + t] + A[n - t + 1]);
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1152
n, k = map(int,input().split())
s = list(input())

cl = 0
cr = 0
a = []
ans = 0
if s[0] == '1':
    ck = 0
    ans = 1
else:
    ck = 1
    a.append([0,0])
while True:
    while ck <= k and cr < n-1:
        cr += 1
        if s[cr-1] == '1' and s[cr] == '0':
            if ck < k:
                ck += 1
                a.append([cr, cr])
            else:
                break
        elif s[cr-1] == '0' and s[cr] == '1':
            a[-1][1] = cr
        ans = max(ans, cr - cl + 1)
    if cr < n-1:
        tl, tr = a.pop(0)
        cl = tr
        cr -= 1
        ck -= 1
    else:
        break
print(ans)

Measured memory_bytes: 13876
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define		pb              push_back
string intostr(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    return str;
}

char Uplowch(char ch){if(ch >= 'A' &&  ch <= 'Z') ch += 32; return ch;}
char Lowupch(char ch){if(ch >= 'a' &&  ch <= 'z') ch -= 32; return ch;}
bool Isalpha(char ch){if((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) return true; return false;}
int Strtoint(string str){stringstream ss(str);int x = 0;ss >> x ;return x ;}
string Intostr(int x){stringstream ss; ss << x; string str = ss.str(); return str;}

#define		PB              pop_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)

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

int dx[] = {0 , 0 , -1 , 1} ; // right , left , forward , backward
int dy[] = {1 , -1 , 0 , 0} ;

//bool check(int x , int y) {
//    if(x <= n && y <= m && x >= 1 && y >= 1)
//        return 1 ;
//    return 0 ;
//}

int main()
{
     //freopen("in.txt","r",stdin);

     ios::sync_with_stdio(0);
	cin.tie(0);

	ll x;
	cin>>x;
	ll ans=0,b=100;
	while(b<x)
    {
        ll bb=b/100;
        ans++;
        b+=bb;
    }
    cout<<ans<<nn;




}



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

int main()
{
    ////////////////////////////
    //変数を用意
    string s;
    int ans = 0;

    //入力
    cin >> s;

    //計算
    for (int i=0; i<3; i++){
	if (s[i] == '1'){
	    ans++;
	}
    }

    //出力
    cout << ans << endl;
    ////////////////////////////
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

ks = []
for i in range(M):
    ks.append(list(map(int, input().split())))

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

cnt = 0
for i in range(2**N):
    light = 0
    switch = format(i, '0'+str(N)+'b')
    for j in range(M):
        pj = p[j]
        kj = ks[j][0]
        on = 0
        for l in range(1, kj+1):
            if switch[ks[j][l]-1] == '1':
                on += 1
        if on % 2 == pj:
            light += 1
        else:
            break
    if light == M:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){

  int n, k;
  cin >> n >> k;

  if ((n % k) == 0){
    cout << 0 << endl;
  }
  else {
    cout << 1 << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;

class State
{
public:
	int p, s, c;
	State(int pp, int ss, int cc)
		:p(pp), s(ss), c(cc) {}

	void set(int pp, int ss, int cc)
	{
		p = pp;
		s = ss;
		c = cc;
	}

	bool operator < (const State& st) const
	{
		return this->c > st.c;
	}
};

int main()
{
	const int INF = 1 << 30;
	int N, M, L, K, A, H, x, y, t;
	int edge[100][100], cost[100][100+1];
	bool freeze[100], visited[100][100+1];

	while (scanf("%d %d %d %d %d %d", &N, &M, &L, &K, &A, &H) != EOF) {
		if (N == 0 && M == 0 && L == 0 && K == 0 && A == 0 && H == 0)
			break;

		for (int i = 0; i < 100; ++i)
			freeze[i] = false;

		for (int i = 0; i < L; ++i) {
			scanf("%d", &t);
			freeze[t] = true;
		}

		for (int i = 0; i < 100; ++i) {
			for (int j = 0; j < 100; ++j) {
				edge[i][j] = INF;
			}
		}

		for (int i = 0; i < K; ++i) {
			scanf("%d %d %d", &x, &y, &t);
			edge[x][y] = edge[y][x] = t;
		}

		for (int i = 0; i < 100; ++i) {
			for (int j = 0; j < 100+1; ++j) {
				cost[i][j] = INF;
				visited[i][j] = false;
			}
		}
		cost[A][M] = 0;

		int ans = INF;
		priority_queue<State> que;
		State st(A, M, 0), st2(0, 0, 0);
		que.push(st);
		
		while (!que.empty()) {
			st = que.top();
			que.pop();

			if (st.p == H) {
				ans = st.c;
				break;
			}

			if (cost[st.p][st.s] < st.c || visited[st.p][st.s])
				continue;

			visited[st.p][st.s] = true;
			if (freeze[st.p]) {
				for (int i = 0; i < N; ++i) {
					if (edge[st.p][i] == INF)
						continue;
					for (int j = 0; st.s+j < M+1; ++j) {
						if (st.s+j >= edge[st.p][i]) {
							int d = st.c + edge[st.p][i] + j;
							if (cost[i][st.s+j-edge[st.p][i]] > d) {
								cost[i][st.s+j-edge[st.p][i]] = d;
								st2.set(i, st.s+j-edge[st.p][i], d);
								que.push(st2);
							}
						}
					}
				}
			} else {
				for (int i = 0; i < N; ++i) {
					if (edge[st.p][i] == INF)
						continue;
					if (st.s >= edge[st.p][i]) {
						int d = st.c + edge[st.p][i];
						if (cost[i][st.s-edge[st.p][i]] > d) {
							cost[i][st.s-edge[st.p][i]] = d;
							st2.set(i, st.s-edge[st.p][i], d);
							que.push(st2);
						}
					}
				}
			}

		}

		if (ans == INF)
			printf("Help!\n");
		else
			printf("%d\n", ans);
	}
	return 0;
}

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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int X;
  cin >> X;
  int big = X / 500;
  int small = (X - (500 * big)) / 5;
  cout << big * 1000 + small * 5 << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/




/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/


int main() {
	
	while (1) {
		int n, m; cin >> n >> m;
		if (n == 0 && m == 0) { return 0; }
		int a[1919];
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (a[i] + a[j] <= m) { ans = max(ans, a[i] + a[j]); }
			}
		}
		if (ans == 0) { cout << "NONE" << endl; }
		else { cout << ans << endl; }
	}



	return 0;
}




Measured memory_bytes: 3060
package main
import (
	"fmt"
)
func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	if n == 2 {
		fmt.Println(a[1] - a[0])
	} else {
		c1 := abs(a[0] - a[1])
		c2 := 0
		for i := 2; i < n; i++ {
			c1, c2 = min(c1+abs(a[i-1]-a[i]), c2+abs(a[i-2]-a[i])), c1
		}
		fmt.Println(c1)
	}
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func min(x, y int) int {
	if x >= y {
		return y
	} else {
		return x
	}
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int a[3],k;
	cin >> a[0] >> a[1] >> a[2] >> k;
	sort(a,a + 3);
	for(int i = 0;i < k;i++) a[2] *= 2;
	cout << a[0] + a[1] + a[2] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int max = 0;
    rep(i, LEN(s) - LEN(t) + 1) {
        int num = 0;
        rep(j, LEN(t)) {
            if (s[i + j] == t[j]) num++;
        }
        chmax(max, num);
    }
    cout << LEN(t) - max << endl;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

bool ok() {
  in(int, n);
  in(string, s);
  if (n % 2) return false;
  rep(i, n / 2) if (s[i] != s[n/2+i]) return false;
  return true;
}

int main() {
  out(ok() ? "Yes" : "No");
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* sort the job w/ deadline asc and do the job as early as possible */

bool cmp(const PII& a, const PII& b)
{
    if (a.second == b.second)
        return a.first < b.first;
    return a.second < b.second;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        vector<PII> A;
        FOR(i,0,n) {
            int a,b; cin >> a >> b;
            A.push_back(PII(b-a,b));
        }
        sort(ALL(A),cmp);
        int t = 0; bool good = true;
        FOR_ALL(a,A) {
            const int x = a->first;
            const int y = a->second;
            if (t > x)
                good = false;
            t += y-x;
        }
        cout << (good ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 2420
import sys

class Card:
	def __init__(self, card):
		self.card = card
		self.mark = card[0]
		self.value = int(card[1])

	def __str__(self):
		return self.card

def print_cards(arr_print, arr_compare):
	n = len(arr_print)
	same = True
	for i in range(n):
		if arr_compare != None and arr_print[i].card != arr_compare[i].card: same = False
		sys.stdout.write(str(arr_print[i]))
		if i != n - 1:
			sys.stdout.write(' ')
	print()
	return same

def swap(arr, i, j):
	temp = arr[i]
	arr[i] = arr[j]
	arr[j] = temp

def bubble_sort(arr):
	n = len(arr)
	for i in range(0, n):
		for j in range(n - 1, i, -1):
			if arr[j].value < arr[j - 1].value:
				swap(arr, j, j - 1)

def selection_sort(arr):
	n = len(arr)
	for i in range(n):
		minj = i
		for j in range(i, n):
			if arr[j].value < arr[minj].value:
				minj = j
		if minj != i:
			swap(arr, i, minj)

n = int(input())
arr = list(map(str, input().split()))
cards1 = [None] * n
cards2 = [None] * n
for i in range(n):
	cards1[i] = Card(arr[i])
	cards2[i] = Card(arr[i])

bubble_sort(cards1)
selection_sort(cards2)

print_cards(cards1, None)
print('Stable')

stable = print_cards(cards2, cards1)
if stable == True:
	print('Stable')
else:
	print('Not stable')



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

const ll INF = 1e12;

int n;
ll W;
vector<ll> w(110, 0);
vector<ll> v(110, 0);
vector< vector<ll> > dp(110, vector<ll>(100100, INF));

int main() {
    cin >> n >> W;
    for(int i = 0; i < n; ++i) {
        cin >> w.at(i) >> v.at(i);
    }

    dp[0][0] = 0;
    ll Vmax = 1000*n;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= Vmax; ++j) {
            if(j+v.at(i) <= Vmax) chmin(dp[i+1][j+v.at(i)], dp[i][j]+w.at(i));
            chmin(dp[i+1][j], dp[i][j]);
        }
    }

    ll ans = 0;
    for(int j = 0; j <= Vmax; ++j) {
        if(dp[n][j] <= W) ans = j;
    }

    cout << ans << endl;
}

Measured memory_bytes: 87296
#include <stdio.h>



typedef struct dice{
	int TOP ;
	int FRONT ;
	int RIGHT ;
	int LEFT ;
	int BACK ;
	int BOTTOM ;
}DICE;

void showdice(DICE *);				//???????¢??????¨

void dicescan(DICE *);			//?????????????????????????????????

void rotateN(DICE *);			//N?????¢
void rotateS(DICE *);			//S?????¢
void rotateE(DICE *);			//E?????¢
void rotateW(DICE *);			//W?????¢

int main(void){

	DICE TESTDICE = {1,2,3,4,5,6};
	char command[101] = {};			//?????????????????????????????????
	int i = 0 ;						//???????????°

	dicescan(&TESTDICE);

	/*?????????????????????*/
	scanf("%s", command);

	/*??????????????¢??????*/
	for( i = 0; ( command[i] != '\0' ) && ( i < 102) ; i++){
		switch(command[i]){

			case 'N':
				rotateN(&TESTDICE);
				break;
			case 'S':
				rotateS(&TESTDICE);
				break;
			case 'E':
				rotateE(&TESTDICE);
				break;
			case 'W':
				rotateW(&TESTDICE);
				break;
			default:
				printf("error\n");
				break;
		}
	}

	/*???????????¨???*/

	printf("%d\n" ,TESTDICE.TOP);



	return 0;
}

void rotateN(DICE *rotate){
	int tmp = 0;

	tmp = rotate -> BACK ;
	rotate -> BACK = rotate -> TOP ;
	rotate -> TOP = rotate -> FRONT ;
	rotate -> FRONT = rotate -> BOTTOM ;
	rotate -> BOTTOM = tmp ;
}
void rotateS(DICE *rotate){
	/*N?????¢???3???*/
	rotateN(rotate);
	rotateN(rotate);
	rotateN(rotate);
}

void rotateE(DICE *rotate){
	int tmp = 0;

	tmp = rotate -> TOP ;
	rotate -> TOP = rotate -> LEFT ;
	rotate -> LEFT = rotate -> BOTTOM ;
	rotate -> BOTTOM = rotate -> RIGHT ;
	rotate -> RIGHT  = tmp ;
}
void rotateW(DICE *rotate){
	/*E?????¢???3???*/
	rotateE(rotate);
	rotateE(rotate);
	rotateE(rotate);
}

void showdice(DICE *show){
	printf("?????¢???%d\n",show -> TOP);
	printf("?????¢???%d\n",show -> FRONT);
	printf("?????¢???%d\n",show -> RIGHT);
}

void dicescan(DICE *scan){
	scanf("%d",&scan -> TOP);
	scanf("%d",&scan -> FRONT);
	scanf("%d",&scan -> RIGHT);
	scanf("%d",&scan -> LEFT);
	scanf("%d",&scan -> BACK);
	scanf("%d",&scan -> BOTTOM);
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
   
   private static final String INPUT_FILE_PATH = "";

   static long MOD = (int) (1e9 + 7);

   static void solve(InputReader in, PrintWriter out) {
      int n = in.nextInt();

      long all = 1;
      long n1 = 1;
      long n2 = 1;
      for (int i = 0; i < n; i++) {
         all = (all * 10) % MOD;
         n1 = (n1 * 9) % MOD;
         n2 = (n2 * 8) % MOD;
      }

      long ans = all;
      ans -= n1;
      ans = (ans + MOD) % MOD;
      ans -= n1;
      ans = (ans + MOD) % MOD;
      ans += n2;
      ans %= MOD;
      out.println(ans);
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

      public String nextToken() {
         while (st == null || !st.hasMoreTokens()) {
            try {
               st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
         return st.nextToken();
      }

      public int nextInt() {
         return Integer.parseInt(nextToken());
      }

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


Measured memory_bytes: 33064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int y,m,d;
    
    string s;
    
    cin >> s;
    
    y = 1000*(s[0]-'0')+100*(s[1]-'0')+10*(s[2]-'0')+(s[3]-'0');
    
    m = 10*(s[5]-'0')+(s[6]-'0');
    
    d = 10*(s[8]-'0')+(s[9]-'0');
    
        if (y < 2019){
    
        cout << "Heisei" << endl;
    
            }else if (y == 2019){
    
                if(m < 5){
        
                cout << "Heisei" << endl;
        
            }else{
        
                cout << "TBD" << endl;
        }
    }else{
    
        cout << "TBD" << endl;
    
    }
    
    
    
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

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

func newGraph(nNodes int) *Graph {
	g := Graph{}
	g.nodes = make([]*GraphNode, nNodes)
	for iNode := 0; iNode < len(g.nodes); iNode++ {
		g.nodes[iNode] = &GraphNode{}
		g.nodes[iNode].key = GraphNodeKey(iNode)
	}
	return &g
}

var infty = 1000000000

type GraphNodeKey int

// GraphNode is a node for undirected graph
type GraphNode struct {
	key       GraphNodeKey
	adjacents []*GraphNode
	visited   bool
	d, f      int
	parent    *GraphNode
	cc        int
}

func (g *Graph) setAdjacent(l, r GraphNodeKey) {
	g.nodes[l].adjacents = append(g.nodes[l].adjacents, g.nodes[r])
}

// Graph is a undirected graph
type Graph struct {
	nodes []*GraphNode
}

func (g *Graph) initialize() {
	for iNode := 0; iNode < len(g.nodes); iNode++ {
		g.nodes[iNode].visited = false
		g.nodes[iNode].d = infty
		g.nodes[iNode].f = infty
		g.nodes[iNode].parent = nil
		g.nodes[iNode].cc = -1 // 22.3-12
	}
}

var time = 0

func dfsVisit(g *Graph, u *GraphNode, cc int) {
	time++
	u.d = time
	u.cc = cc

	u.visited = true
	for _, v := range u.adjacents {
		if !v.visited {
			v.parent = u
			dfsVisit(g, v, cc)
		}
	}
	time++
	u.f = time
}

func fillDistancesByDepthFirstSearch(g *Graph) {
	g.initialize()
	time = 0
	cc := 0

	for _, u := range g.nodes {
		if !u.visited {
			dfsVisit(g, u, cc)
			cc++
		}
	}
}

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

	nNodes := nextInt()
	nEdges := nextInt()
	graph := newGraph(nNodes)
	for iEdge := 0; iEdge < nEdges; iEdge++ {
		l := GraphNodeKey(nextInt())
		r := GraphNodeKey(nextInt())
		graph.setAdjacent(l, r)
	}

	fillDistancesByDepthFirstSearch(graph)

	cycleDetected := false
	for _, u := range graph.nodes {
		for _, v := range u.adjacents {
			if v.d <= u.d && u.d < u.f && u.f <= v.f {
				cycleDetected = true
			}
		}
	}

	if cycleDetected {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}



Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


int n, a, b, c;
vi l(8);
int dfs(int i, int x, int y, int z){
  if(i == n){
    if(!x||!y||!z) return 10010010;
    return abs(a-x) + abs(b-y) + abs(c-z);
  }
  int mp = dfs(i+1,x,y,z);
  mins(mp,dfs(i+1,x+l[i],y,z)+(x?10:0));
  mins(mp,dfs(i+1,x,y+l[i],z)+(y?10:0));
  mins(mp,dfs(i+1,x,y,z+l[i])+(z?10:0));
  return mp;
};

int main() {
  cin >> n >> a >> b >> c;
  rep(i, n) cin >> l[i];

  int ans = dfs(0,0,0,0);
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    long[] a = new long[n + 1];
    long[] b = new long[n];

    long res = 0;

    for (int i = 0; i <= n; i++)
      a[i] = sc.nextLong();
    for (int i = 0; i < n; i++) {
      b[i] = sc.nextLong();
      if (b[i] > a[i]) {
        res += a[i];
        long carry = Math.min(a[i + 1], b[i] - a[i]);
        a[i + 1] -= carry;
        res += carry;
      } else
        res += b[i];
    }

    System.out.println(res);
  }
}

Measured memory_bytes: 66356
#include <stdio.h>
#define MAX 101
void Search(int);
 
int number,G[MAX][MAX],d[MAX],count=0,k=0;
int F[MAX] = {0};
 
  
int main(void){
  int i,j,k,l,u,a,t;
   
  for(i = 0;i < number;i++){
    d[i] = 0;
  }
    
  scanf("%d",&number);
   
  for(i = 0;i < number + 1;i++){
    for(j = 0;j < number + 1;j++){
      G[i][j] = 0;
    }
  }
   
  for(i = 0;i < number;i++){
   
    scanf("%d %d ",&k,&u);
   
    for(j = 0;j < u;j++){
      scanf("%d",&a);
      G[k - 1][a - 1] = 1;
    }
  }
  
  for(i = 0;i < number;i++){
    if(d[i] == 0)
    Search (i);
  }
       
  for(i = 0;i < number;i++){
    printf("%d %d %d\n",i+1,d[i],F[i]);
  }
  
  return 0;
 }
 
 
void Search(int u){
  int i,j,v;
  count++;
  d[u] = count;
   
  for(v = 0;v < number;v++){
    if(G[u][v] == 1 && d[v] == 0 ){
      Search(v);
    }
  }
  count++;
  F[u] = count;
}


Measured memory_bytes: 2144
#include <iostream>

int main() {
  int N = 0;
  int A = 0;
  int B = 0;

  std::cin >> N >> A >> B;

  if((B - A) % 2 != 0) {
    std::cout << "Borys" << std::endl;
    return 0;
  } else {
    std::cout << "Alice" << std::endl;
    return 0;
  }
}

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


public class Main {
	//2305 start
	int n, len;
	String [] data;
	String num;
	HashMap<String, String> map;
	int [] convert = {2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9};
	StringBuilder work;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n= sc.nextInt();
			if(n == 0) break;
			data = new String[n];
			for(int i = 0; i < n; i++){
				data[i] = sc.next();
			}
			num = sc.next();
			len = num.length();
			map = new HashMap<String, String>();
			for(int i = 0;i < n; i++){
				StringBuilder sb = new StringBuilder();
				for(int j = 0; j < data[i].length(); j++){
					int ind = data[i].charAt(j) - 'a';
					sb.append(convert[ind]);
				}
				map.put(data[i], sb.toString());
			}
			work = new StringBuilder();
			dfs(0);
			System.out.println("--");
		}
	}

	private void dfs(int first) {
		if(first == len){
			System.out.print(work.substring(1));
			System.out.println(".");
			return;
		}
		
		for(int i = 0; i < n; i++){
			int nowlen = data[i].length();
			if(nowlen + first > len) continue;
			String substr = num.substring(first, first + nowlen);
			if(substr.equals(map.get(data[i]))){
				work.append(" " + data[i]);
				dfs(first + nowlen);
				work.delete(work.length() - nowlen-1, work.length());
			}
			
		}
	}

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

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> sx(N);
  vector<int> sy(N);
  vector<int> cx(M);
  vector<int> cy(M);
  for (int i = 0; i < N; ++i) cin >> sx[i] >> sy[i];
  for (int i = 0; i < M; ++i) cin >> cx[i] >> cy[i];
  for (int i = 0; i < N; ++i) {
    int res = 0;
    int mi = 1e9;
    for (int j = 0; j < M; ++j) {
      int dist = abs(sx[i] - cx[j]) + abs(sy[i] - cy[j]);
      if (dist < mi) {
        mi = dist;
        res = j;
      }
    }
    cout << res + 1 << endl;
  }
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll (i)=0; (i)<(_loop_ll)(n); (i)++)
#define FOR(i,a,b) for(_loop_ll (i)=(_loop_ll)(a); (i)<(_loop_ll)(b); (i)++)
#define FORR(i,a,b) for(_loop_ll (i)=(_loop_ll)(b)-1; (i)>=(_loop_ll)(a); (i)--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

constexpr long long int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s, t = "";
    cin >> s;

    REP(i, s.size()) t += "x";
    cout << t << endl;

    return 0;
};


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define int long long
#undef int
#define pb push_back
#define mk make_pair
typedef long long ll;
typedef pair<int, int> pii;

int N, K;
int h[100100];
priority_queue<pii > que1;
priority_queue<pii , vector<pii >, greater<pii > > que2;
int ans = 1000000009;

signed main()
{
    cin >> N >> K;
    K--;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    sort(h, h + N);
    for(int i = 0; i < N; i++){
        que1.push(mk(h[i], i));
        que2.push(mk(h[i], i));
        if(i - K >= 0){
            while(que1.size() && que1.top().second < i - K){
                que1.pop();
            }
            while(que2.size() && que2.top().second < i - K){
                que2.pop();
            }
            if(que1.size() && que2.size()){
                ans = min(ans, que1.top().first - que2.top().first);
            }
        }
    }
    cout << ans << endl;

    return 0;
}
/*


*/


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define int long
#define ll long long
#define MOD (int)(1000000007)
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N; string S; cin >> S; string T; cin >> T; 
    int cnt=0; ll ans=1; int pos;
    if(S[0]==T[0]){cnt++; ans*=3; pos=0;}
    else {cnt+=2; ans*=6; pos=1;}
    while(cnt<N){
       if(S[cnt]==T[cnt]){
           if(pos) {pos=0; cnt++;}
           else {ans=ans*2%MOD; cnt++;}
       }
       else if(pos) {ans=ans*3%MOD; cnt+=2;}
       else {ans=ans*2%MOD; pos=1; cnt+=2;}
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()

#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF=1e18;
const ll inf=1e9;
const ld eps=1e-7;
const ld pi=acos(-1);
const int dx[4]={0,0 ,1,-1};
const int dy[4]={1,-1,0,0};
const int N=2e5+11;
const int M=1e3+11;
const int mod1=998244353;
const int mod2=1e9+7;

int dp[N][2];

int main(){
  string s;
  cin>>s;
  int n=sz(s);
  dp[0][0]=1;
  dp[0][1]=-1;
  for(int i=1;i<n;i++){
    int ans=-1;
    if(s[i-1]!=s[i]&&~dp[i-1][0])ans=max(ans,dp[i-1][0]+1);
    if(~dp[i-1][1])ans=max(ans,dp[i-1][1]+1);
    dp[i][0]=ans;
    if(i==1){
      dp[i][1]=1;
      continue;
    }
    ans=-1;
    if(~dp[i-2][0])ans=max(ans,dp[i-2][0]+1);
    if(i>3&&~dp[i-2][1]&&(s[i]!=s[i-2]||s[i-1]!=s[i-3]))ans=max(ans,dp[i-2][1]+1);
    dp[i][1]=ans;
  }
  if(dp[n-1][0]==-1)cout<<dp[n-1][1];
  else if(dp[n-1][1]==-1)cout<<dp[n-1][0];
  else cout<<max(dp[n-1][0],dp[n-1][1]);
}


Measured memory_bytes: 2180
/**
 *      purpose : CODE FESTIVAL 2017 qual B B
 *      author  : kyomukyomupurin
 *      created : 2018-11-09 21:38:52
**/

#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define print(x) cout << (x) << '\n'

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int D[N] = {};
    for (int i = 0; i < N; ++i) cin >> D[i];
    int M; cin >> M;

    if (M > N){
        print("NO"); return 0;
    }
    int T[M] = {};
    for (int i = 0; i < M; ++i) cin >> T[i];

    map<int, int> mpA;

    for (int i = 0; i < N; ++i){
        ++mpA[D[i]];
    }

    map<int, int> mpB;

    for (int i = 0; i < M; ++i){
        ++mpB[T[i]];
    }

    for (int i = 0; i < M; ++i){
        if (mpB[T[i]] > mpA[T[i]]){
            print("NO"); return 0;
        }
    }

    print("YES");
    
    return 0;
}

Measured memory_bytes: 20608