akhauriyash/Code-Regression huggingface dataset:
n=int(input())
s=[int(input()) for i in range(n)]
a=[]
for i in range(n):
    if s[i]%10!=0:
        a.append(s[i])
if len(a)==0:
    a.append(0)
if sum(s)%10==0:
    if 0 in a:
        print(0)
    else:
        print(sum(s)-min(a))
else:
    print(sum(s))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    std::cout<<std::fixed<<std::setprecision(10);
   double n,k,x,y;
   cin>>n>>k>>x>>y;
   ld ans =((ld)n*(ld)k)/2;
   cout<<ans<<" ";

   if(n/2==x&&k/2==y)cout<<1<<endl;
   else cout<<0<<endl;


}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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; }

int main() {
    int n;
    ll y;
    cin >> n >> y;

    int ans_i = -1;
    int ans_j = -1;
    int ans_k = -1;

    for(int i=0; i<=n; ++i) {
        for(int j=0; j<=n-i; ++j) {
            if (i*10000+j*5000+(n-i-j)*1000 == y) {
                ans_i = i;
                ans_j = j;
                ans_k = n-i-j;
            }
        }
    }

    cout << ans_i << " " << ans_j << " " << ans_k << endl;
}



Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//International Party
public class Main{

	int n, m, INF = 1<<29, min;
	boolean[] u, v, res;
	boolean[][] e;
	
	int dfs(int k){
		if(v[k])return 0;
		int res = 1;
		v[k] = true;
		for(int i=0;i<n;i++){
			if(!u[i]||!e[k][i])continue;
			for(int j=0;j<m;j++)if(e[j][i])res += dfs(j);
		}
		return res;
	}
	
	void f(int k, int d){
		if(5<d||min<=d)return;
		v = new boolean[m];
		if(dfs(0)==m){
			min = d;
			res = u.clone(); return;
		}
		for(int i=k;i<n;i++){
			u[i] = true;
			f(i+1, d+1);
			u[i] = false;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(boolean h = true;;h=false){
			n = sc.nextInt(); m = sc.nextInt();
			if((n|m)==0)break;
			if(!h)System.out.println();
			Map<String, Integer> ref = new HashMap<String, Integer>();
			String[] s = new String[n];
			for(int i=0;i<n;i++){
				s[i] = sc.next();
				ref.put(s[i], i);
			}
			e = new boolean[m][n];
			for(int i=0;i<m;i++){
				int k = sc.nextInt();
				while(k--!=0)e[i][ref.get(sc.next())] = true;
			}
			u = new boolean[n];
			min = INF;
			f(0, 0);
			if(min==INF)System.out.println("Impossible");
			else {
				System.out.println(min);
				for(int i=0;i<n;i++)if(res[i])System.out.println(s[i]);
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#ABC123

a = [int(input()) for _ in range(5)]
b = [a[i] // 10 for i in range(5)]
c = [10] + sorted([a[i] % 10 for i in range(5) if a[i] % 10 != 0])

s = 10 * sum(b) + (len(c)-2) * 10 + min(c)

print(s)

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

int main() {
 
 double N, K;
  cin >> N >> K;
  vector<double> pos(N, 1 / N);
  
  for(int i = 1; i <= N; i++) {
    int a = i;
    while(true) {
      if(a >= K) {
        break;
      }
      a *= 2;
      pos.at(i - 1) /= 2;
    }
  }
  double sum;
  for(int i = 0; i < N; i++) {
    sum += pos.at(i);
  }
cout << fixed << setprecision(14);
  cout << sum << endl;

 }
   
  

Measured memory_bytes: 1024
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{

    ll n,a,b;
    cin>>n>>a>>b;
ll k = (a+b);
ll p = n/k;
    cout<< a*p+min(a,n%k);
        return 0;
}


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

int main(){
    int n,l;
    cin >> n >> l;
    vector <string> a(n);
    for (int i=0;i<n;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        cout << a.at(i);
    }
    cout << endl;
}    


Measured memory_bytes: 256
from heapq import heapify, heappop, heappush
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
    a[i] *= -1
heapify(a)
#print(a)
for i in range(m):
    maxa = heappop(a)
    heappush(a, math.ceil(maxa/2))
#print(a)
print(-(sum(a)))

Measured memory_bytes: 97816
# import math
# import collections
n = int(input())
d = list(map(int, input().split()))
mod = 998244353
# dcnt = collections.Counter(d)
cnt = [0]*10**5
mv = max(d)
for i in d:
    cnt[i] += 1
# print(cnt[:mv+1]
if d[0] != 0:
    print(0)
    exit()
ans = 1
for i, v in enumerate(cnt[:mv+1]):
    # print(i, v)
    if i == 0:
        if v == 1:
            continue
        else:
            print(0)
            exit()
    else:
        if v == 0:
            print(0)
            exit()
        else:
            c = cnt[i-1]**v % mod
            ans *= c
            ans %= mod
            # print(ans, c)

print(ans)




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

int main() {
	int D, N;
	scanf("%d%d", &D, &N);
	int ans = 1;
	while (D--) ans *= 100;
	if (N == 100) printf("%d\n", ans * 101);
	else printf("%d\n", ans * N);
	return 0;
}

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

signed main(){
    int N;
    cin >> N;
    for(int i = 1; i <= 9; i++){
      if( N % i == 0 && N / i >= 1 && N / i <= 9){
        cout << "Yes" << endl;
        return 0;
    }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<int> L(N);
    rep(i,N)cin>>L.at(i);
    sort(L.begin(),L.end());
    int sum=0;
    rep(i,N-1){
        sum+=L.at(i);
    }
    if(sum<=L.at(N-1))cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

int compare_int(const void *a,const void *b){
	return *(long long*)a-*(long long*)b;
}

int main(){
	int n,j;
	long long a[520]={0},k,i;
	scanf("%d%lld",&n,&k);
	for(i=0;i<n;i++)scanf("%lld",&a[i+1]);n++;
	qsort(a,n,sizeof(long long),compare_int);
	long long sum=0;
	for(i=0;i<n;i++)sum+=a[i];
	if(sum<=k){
		printf("%lld\n",sum);
		return 0;
	}
	long long yak[5000]={1},c=1;
	for(i=2;i*i<=sum;i++){
		if(sum%i==0)yak[c++]=i;
	}
	for(i=0;i<c;i++)yak[c+i]=sum/yak[i];
	if(yak[c-1]*yak[c-1]==sum)c=2*c-1;
	else c=2*c;
	long long ans=1;
	for(i=1;i<c;i++){
		long long y=yak[i],tmp=0,tmm=0,tmh=0,tmhm=0;
		long long pa[520];
		for(j=0;j<n;j++){
			pa[j]=a[j]%y;
			if(pa[j]>y-pa[j])pa[j]=y-pa[j];
			else pa[j]= -pa[j];
			if(pa[j]<0){
				tmhm-=pa[j];
			}
			else {
				tmh+=pa[j];
			}
		}
		qsort(pa,n,sizeof(long long),compare_int);
		while(tmh>tmhm){
			for(j=n-1;j>=0;j--){
				tmhm+=(y-pa[j]);
				tmh-=(pa[j]);
				if(tmh==tmhm)break;
			}
		}while(tmh<tmhm){
			for(j=0;j<n;j++){
				tmh+=(y+pa[j]);
				tmhm+=(pa[j]);
				if(tmh==tmhm)break;
			}
		}
		if(tmh<=k)ans=max(ans,y);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    int ans=0;
    cin >> n;
    vector<int>a(n);
    vector<int>b(n);
    vector<int>c(n-1);

    rep(i,n) cin >> a.at(i);
    rep(i,n) {
        cin >> b.at(i);
        ans += b.at(i);
    }
    rep(i,n-1) cin >> c.at(i);

    rep(i,n-1){
        if(a.at(i+1)-a.at(i) == 1) ans += c.at(a.at(i)-1);
    }
        
cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        HashSet<Integer> hs = new HashSet<Integer>();
        int n=scan.nextInt();
        int k=scan.nextInt();
        for(int i=0;i<k;i++){
            int z=scan.nextInt();
            for(int j=0;j<z;j++){
                int wk=scan.nextInt();
                hs.add(wk);
            }
        }
        System.out.println(n-hs.size());
    }
}


Measured memory_bytes: 46000
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

void bfs(ll n, vector<vll> &nx, vll &cnt) {
	queue<ll> task;
	task.push(0);
	vector<bool> seen(n, false);
	seen[0] = true;
	while (task.size()) {
		ll x = task.front();
		task.pop();
		for (ll i = 0; i < nx[x].size(); i++) {
			if (!seen[nx[x][i]]) {
				task.push(nx[x][i]);
				cnt[nx[x][i]] += cnt[x];
				seen[nx[x][i]] = true;
			}
		}
	}
}

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

	ll n, q;
	cin >> n >> q;
	vector<vll> nx(n, vll(0));
	for (ll i = 0; i < n - 1; i++) {
		ll a, b;
		cin >> a >> b;
		nx[a - 1].push_back(b - 1);
		nx[b - 1].push_back(a - 1);
	}
	vll p(q), x(q), cnt(n, 0);
	for (ll i = 0; i < q; i++) {
		cin >> p[i] >> x[i];
		cnt[p[i] - 1] += x[i];
	}
	bfs(n, nx, cnt);
	for (ll i = 0; i < n - 1; i++) cout << cnt[i] << " ";
	cout << cnt[n - 1] << endl;
}


Measured memory_bytes: 21104
# Aizu Problem ITP_1_4_A: A/B Problem
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


a, b = [int(_) for _ in input().split()]
print("%d %d %.5f" % (a // b, a % b, a / b))

Measured memory_bytes: 7784
#include "bits/stdc++.h"
using namespace std;

signed main() { 
        int n, m, i, j;
        cin >> n >> m;
        bool ans[404][404];
        for (i = 0; i < n; i ++) for (j = 0; j < n; j ++) ans[i][j] = true;
        while (m --) {
                int x, y;
                cin >> x >> y;
                x --;
                y --;
                if (ans[x][y]) {
                        for (j = 0; j < n; j ++) {
                                if (!ans[x][j]) {
                                        ans[y][j] = false;
                                        ans[j][y] = false;
                                }
                                if (!ans[y][j]) {
                                        ans[x][j] = false;
                                        ans[j][x] = false;
                                }
                        }
                } else {
                        for (j = 0; j < n; j ++) {
                                ans[x][j] = false;
                                ans[j][x] = false;
                                ans[y][j] = false;
                                ans[j][y] = false;
                        }
                }
                ans[x][y] = false;
                ans[y][x] = false;
        }
        int res = 0;
        for (i = 0; i < n; i ++) for (j = i + 1; j < n; j ++) if (ans[i][j]) res ++;
        cout << res << endl;
        return 0;
}               


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n, t, d[100001];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &t);
		d[t] = i;
	}
	for(int i = 1; i <= n; i++) {
		printf("%d ", d[i]);
	}
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  int key;
  int priority;
};

typedef struct node * Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while (x->left!=NIL) x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while (x->right!=NIL) x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
  Node ret = NIL;
  if (u->key==k) return u;
  else if (u->key>k) {
    if (u->left!=NIL)
      return treeSearch(u->left, k);
  } else if (u->right!=NIL)
    return treeSearch(u->right, k);
  return ret;
}

Node rightRotate(Node t)
{
  Node s = t->left;
  if (t==root) root=s;
  t->left = s->right;
  s->right = t;
  return s;
}

Node leftRotate(Node t)
{
  Node s = t->right;
  if (t==root) root=s;
  t->right = s->left;
  s->left = t;
  return s;
}

Node _delete(Node, int);

Node delete(Node t, int key)
{
  if (t==NIL)
    return NIL;
  if (key < t->key)
    t->left = delete(t->left,key);
  else if (key > t->key)
    t->right = delete(t->right, key);
  else
    return _delete(t, key);
  return t;
}

Node _delete(Node t, int key)
{
  if (t->left == NIL && t->right==NIL) // has no child
    return NIL;
  if (t->left == NIL)
    t=leftRotate(t);
  else if (t->right == NIL)
    t=rightRotate(t);
  else {
    if (t->left->priority > t->right->priority)
      t = rightRotate(t);
    else
      t = leftRotate(t);
  }
  return delete(t, key);
}

Node insert(Node t, int key, int priority)
{
  if (t==NIL) {
    Node z = malloc(sizeof(struct node));
    z->key = key;
    z->priority = priority;
    z->left = NIL;
    z->right=NIL;
    if (root==NIL) {
      root = z;
    }
    return z;
  }
  if (key==t->key) return t;
  if (key<t->key) {
    t->left = insert(t->left, key, priority);
    if (t->priority < t->left->priority)
      t = rightRotate(t);
  } else {
    t->right = insert(t->right, key, priority);
    if (t->priority < t->right->priority)
      t = leftRotate(t);
  }
  return t;
}

void inorder(Node u){
  if (u->left!=NIL) inorder(u->left);
  printf(" %d", u->key);
  if (u->right!=NIL) inorder(u->right);
}
void preorder(Node u){
  printf(" %d", u->key);
  if (u->left!=NIL) preorder(u->left);
  if (u->right!=NIL) preorder(u->right);
}

void print()
{
  if (root==NIL) return;
  preorder(root);
  printf("\n");
  inorder(root);
  printf("\n");
}

int main(){
  int n, i, x, y;
  Node t;
  char com[20];
  root = NIL;
  scanf("%d", &n);
  
  for (i = 0; i < n; i++){
    scanf("%s", com);
    switch (com[0]) {
    case 'f':
      scanf("%d", &x);
      t = treeSearch(root, x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
      break;
    case 'i':
      scanf("%d %d", &x, &y);
      insert(root, x, y);

      break;
    case 'p':
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      break;
    case 'd':
      scanf("%d", &x);
      t = treeSearch(root, x);
      if (t!=NIL)  delete(root, x);
    }
  }
  return 0;
}


Measured memory_bytes: 8060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

ll power(ll x,ll n){
    if(n==0) return 1;
    ll res=power(x*x%mod,n/2);
    if(n&1) res=res*x%mod;
    return res;
}

int main(){
  ll n;
  int a,b;
  cin>>n>>a>>b;
  ll ans=power(2,n)-1;
  ll c=1;
  ll d=1;
  rep(i,0,a) {
    c=c*(n-i)%mod;
    d=d*(i+1)%mod;
  }
  ans-=c*power(d,1e9+5)%mod;
  c=1;
  d=1;
  rep(i,0,b) {
    c=c*(n-i)%mod;
    d=d*(i+1)%mod;
  }
  ans-=c*power(d,1e9+5)%mod;
  while(ans<0) ans+=mod;
  cout<<ans<<endl;
}

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

int lineSearch(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main(){
    int n,q,key,count = 0;
    int s[100000];
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> s[i];
        
    cin >> q;
    
    for(int i = 0; i < q;i++){
        cin >> key;
        if(lineSearch(s,n,key)) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3120
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	int d;
	while(cin >> d){
		int ans = 0;
		for(int i = 1; i < 600 / d; i++){
			ans += d * (i * i * d * d);
		}
		cout << ans << '\n';
	}
	return 0;
}
// Write Here



Measured memory_bytes: 3100
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] H = new int[N];
		for (int i = 0; i < N; i++) 
			H[i] = sc.nextInt();

		int maxMove = 0; 
		int currentMove = 0;
		for (int i = 0; i < N-1; i++) {
			
			if (H[i] >= H[i+1]) {
				currentMove++;
				if (currentMove > maxMove)
					maxMove = currentMove;
			} else {
				currentMove = 0;
			}
		}
		System.out.println(maxMove);
	}
}

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

#define ll                   long long
#define MOD                  1000000007
#define fast()               ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define fd(i,a,b)          for(ll i=(ll)a;i<(ll)b;i++)
#define bk(i,a,b)          for(ll i=(ll)a;i>=(ll)b;i--)
#define pb                   push_back
#define vi                   vector<ll>
#define test()               ll t; cin>>t; while(t--)
#define endl                 "\n"
#define param                greater<ll>()
#define ff                   first
#define ss                   second
#define all(v)               v.begin(),v.end()
#define mk                   make_pair
#define keep_unique(v) sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
#define MAX 1000000000000000000

using namespace std;

const ll N = 1e5+10;


vector<ll> adj[N];
ll vis[N];
ll maxm;

ll dp[N]={0};



ll dfs(ll x)
{
    if(vis[x])
    return dp[x];
    
   vis[x]=1;

   for(auto c:adj[x])
   {
       dp[x]=max(1+dfs(c),dp[x]);
       
   }
   
   
   return dp[x];


}


int main()
{

    fast()

    ll t;
    // cin>>t;
    t=1;

    while(t--)
    {
       ll i,j,m,a,b,n,d=0;

        cin>>n>>m;



        // vector < ll > vec(n+1),sum(n+1,0),vec2(n+1);


        for(i=1;i<=m;i++)
        {
            cin>>a>>b;

            adj[a].pb(b);

        }

       ll ans=0;

       for(i=1;i<=n;i++)
        {
           if(vis[i]==0 && adj[i].size()>0)
           {
              ll k= dfs(i);
           }

        }
        
        
        for(i=1;i<=n;i++)
        {
            ans=max(ans,dp[i]);
            
            // cout<<dp[i]<<" ";
          
        }
        

        cout<<ans<<endl;


    }

}



Measured memory_bytes: 8704
void main() {
	(rs.to!(dchar[]).sort().uniq.array.length == 3 ? "Yes" : "No").writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, T;
  cin >> N >> T;
  vll V(N);
  REP(i, 0, N) {
    cin >> V[i];
  }

  if (N == 1) {
    cout << T << endl;
    return 0;
  }

  ll ans = 0;
  REP(i, 1, N) {
    if (V[i] - V[i - 1] >= T) {
      ans += T;
    } else {
      ans += V[i] - V[i - 1];
    }
  }
  cout << ans + T << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
  int a,b,c;
  int count;

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

  for(int i = a ; i <= b ; i++){
    if(c%i == 0){
      count++;
    }
  }

  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2104
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int K;
    int ans = 0;
    cin >> K;
    if(K%2==0){
        ans = K/2 * K/2;
    }else{
        ans = (K-1)/2 * (K+1)/2;
    }

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

Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;


      ll x;
      string str;

    cin>>n>>m;

     ll ara[n+2];

     input(ara,n);

     sort(ara,ara+n);

     vector<pll>v;

     for(i=0; i<m; i++)
     {
         cin>>a>>b;

         v.eb(b,a);
     }

     sort(vll(v),greater<pll>());

     j=0;

     for(i=0; i<n; i++)
     {
         while(j<m && v[j].S==0)
            j++;

         if(j<m && v[j].F>ara[i])
         {
             sum+=v[j].F;

             v[j].S--;
         }
         else
            sum+=ara[i];
     }

     cout<<sum<<endl;








}



Measured memory_bytes: 6116
n,x = map(int, input().split())
a = [int(i) for i in input().split()]
prev = a[0]
count = 0
for i in range(n - 1):
    now = a[i + 1]
    if now + prev > x:
        count += now + prev - x
        prev = max(0, x - prev)
    else:
        prev = now
print(count)

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		for (int j = i + 1; j < S.size(); j++) {
			if (S[i] == S[j]) {
				print("no");
				return 0;
			}
		}
	}
	print("yes");


	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t,r;
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		r+=t[i];
	}
	if(r==s)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
   double m,high=0,low=1000000000000;
   while(scanf("%lf",&m)!=EOF){
      if(m>high)high=m;
      if(m<low)low=m;
   }
   printf("%.1f\n",high-low);

   return 0;

}

Measured memory_bytes: 652
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 1000010<<1, p = 1e9+7;
ll p25[maxn]{1}, fa[maxn], fainv[maxn], inv[maxn];
void init() {
	for (int i : {0, 1} )fa[i] = fainv[i] = inv[i] = 1;
	for (int i = 2;i < maxn;++i) {
		fa[i] = fa[i-1] * i % p;
		inv[i] = (p - p/i) * inv[p % i] % p;
		fainv[i] = fainv[i-1] * inv[i] % p;
	}
	for (int i = 1;i < maxn;++i) p25[i] = p25[i-1] * 25 % p;
}
#define C(i, j) (fa[i] * fainv[j] % p * fainv[(i)-(j)] % p)
int k, n;
char w[maxn];
ll CAL() {
}


signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	init();
	cin >> k >> w;
	n = strlen(w);
	ll res = 0;
	for (int i = n;i <= n+k;++i) {
		res = (res + p25[n+k-i] * C(n+k, i) % p) % p;
	}
	cout << res << '\n';
}


Measured memory_bytes: 67108
import sys

input = lambda: sys.stdin.readline().rstrip()
INF = 10 ** 9 + 7

H, N = map(int, input().split())
AB = [[] for _ in range(N)]
for i in range(N):
    AB[i] = list(map(int, input().split()))


def solve():

    dp = [INF] * (H + 1)
    dp[H] = 0

    for h in range(H, 0, -1):

        if dp[h] == INF:
            continue
        next_dp = dp

        for i in range(N):
            a, b = AB[i]
            hh = max(0, h - a)
            next_dp[hh] = min(dp[hh], dp[h] + b)

        dp = next_dp

    print(dp[0])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 42076
def Main(N, K, P):
    wa = sum(P[:K])
    max_sum = wa
    max_sum_ind = 0
    for i in range(N-K):
        wa = wa - P[i] + P[i+K]
        if(wa > max_sum):
            max_sum = wa
            max_sum_ind = i
    ans = 0
    if max_sum_ind == 0:
        for i in range(K):
            ans += (P[i]+1)/2
    else:
        for i in range(max_sum_ind+1, max_sum_ind+K+1):
            ans += (P[i]+1)/2
    return ans

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    print("{:.12f}".format(Main(N, K, P)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 25056
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

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

    cout << max(a + b, max(a - b, a * b)) << endl;
    return 0;
}

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

int n;
double t[567];
double x[567];

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> t[i];
    }
    if(n == 1)
    {
        printf("%.6f\n", 2 * t[0]);
    }
    else
    {
        x[0] = t[0];
        for(int i = 1; i < n; i++)
        {
            int id = -1;
            double rightm = -1.0;
            for(int j = 0; j < i; j++)
            {
                double nu = x[j] + sqrt(fabs(t[i] + t[j]) * fabs(t[i] + t[j]) - fabs(t[i] - t[j]) * fabs(t[i] - t[j]));
                if(nu > rightm)
                {
                    rightm = nu;
                    id = i;
                }
            }
            x[i] = rightm;
        }
        double lm = 999999999.0, rm = -999999999.0;
        for(int i=0;i<n;i++) lm = min(lm, x[i] - t[i]);
        for(int i=0;i<n;i++) rm = max(rm, x[i] + t[i]);
        printf("%.6f\n", rm - lm);
    }

return 0;
}

Measured memory_bytes: 1256
n,W=map(int,input().split())
items=[list(map(int,input().split())) for i in range(n)]

dp=[[0]*(W+1) for i in range(n+1)]
for i in range(n-1,-1,-1):
  for j in range(W+1):
    if j<items[i][0]:
      dp[i][j]=dp[i+1][j]
    else:
      dp[i][j]=max(dp[i+1][j],dp[i+1][j-items[i][0]]+items[i][1])

print(dp[0][W])
    


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, int b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, k;
    int x[101];
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> x[i];
    }

    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        sum += 2 * min(x[i] - 0, k - x[i]);
    }
    cout << sum << endl;
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int c = 700;
    if (s[0] == 'o') c += 100;
    if (s[1] == 'o') c += 100;
    if (s[2] == 'o') c += 100;
    cout << c << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> ns(n);
	vector<int> ans(n);
	int max = 0;
	rep(i, n){
    	cin >> ns.at(i);
    	ans.at(i) = ns.at(i);
    	if(ns.at(i) > max) max = ns.at(i);
    }
	sort(ns.begin(), ns.end());
	rep(i, n){
    	if(ans.at(i) != max){
        	cout << ns.at(n-1) << endl;
        }else{
        	cout << ns.at(n-2) << endl;
        }
    }
}

Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <string.h>
#include <map>
using namespace std;
typedef pair< int, string > P;
int main(){
  int n;
  cin >> n;
  string id;
  int num;
  map< P , int > data;
  for(int i = 0 ; i < n ; i++ ){
    cin >> id >> num;
    data[P(id.size(),id)] += num;
  }
  for( map< P,int >::iterator it = data.begin(); it != data.end() ; it++ ){
    cout << (*it).first.second << ' ' << (*it).second << endl;
  }
  return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=1;i<n+1;i++)
#define ll long long int
//�ő���񐔂ƍŏ����{��
int gcd(int a, int b)
{
  if(a<b)
    swap(a,b);
  
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
  int K;
  cin>>K;
  ll count=0;
  rep(a,K){
    rep(b,K){
      rep(c,K){
	count+=gcd(gcd(a,b),c);

      }
    }
  }

  cout<<count;

  return 0;
}


Measured memory_bytes: 3624
n,y = list(map(int,input().split()))
y = y//1000
ans = '-1 -1 -1'
for i in range(n+1):
    for j in range(n+1-i):
        k = n-i-j
        if 10*i+5*j+k == y:
            ans = str(i)+' '+str(j)+' '+str(k)
            break
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e6+5;
int tab[MAXN];

int main(){
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int n;
    cin >> n;
    cout << 24+24-n;
}


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

int main()
{
	string s, t;
	cin >> s;
	cin >> t;
	vector<vector<int>> dp(s.size() + 1, vector<int>(t.size()+1, 0));
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < t.size(); j++) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			}
			else {
				dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
	}
	
	int i = s.size(), j = t.size();
	string ans;
	while (1) {
		if (i <= 0 || j <= 0) break;
		if (dp[i - 1][j - 1] < dp[i][j] && dp[i - 1][j] < dp[i][j] && dp[i][j - 1] < dp[i][j]) {
			ans = s[i - 1] + ans;
			i--;
			j--;
		}
		else if(dp[i - 1][j] < dp[i][j]){
			j--;
		}
		else {
			i--;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  string s;
  cin >> s;
  ll ans = 0;
  int l = 0;  // Aが連続した回数
  REP(i, s.size() - 2) {
    if (s[i] == 'A')
      l++;
    else
      l = 0;
    if (s[i] != 'A' || s[i + 1] != 'B' || s[i + 2] != 'C') continue;
    ans += l;

    swap(s[i - l + 1], s[i + 1]);
    swap(s[i - l + 2], s[i + 2]);
        l -= 2;
  }
  cout << ans << endl;
}

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

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) << endl;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>

#define MAXN 300005
#define INF 2000000090

using namespace std;

int n;

int calBitSum(int num)
{
    int ans = 0;
    while (num > 0) {
        ans += num % 10;
        num /= 10;
    }
    return ans;
}


int main()
{
    //freopen("a.txt", "r", stdin);
    while (scanf("%d", &n) == 1) {
        int ans = calBitSum(1) + calBitSum(n - 1);
        for (int i = 2; i < n; i++)
            ans = min(ans, calBitSum(i) + calBitSum(n - i));
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

result = 0
for n500 in range(A+1):
    for n100 in range(B+1):
        for n50 in range(C+1):
            if n500*500 + n100*100 + n50*50 == X:
                result += 1
print(result)



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

using namespace std;

typedef long long LL;
#define MAX_N 10000009
LL N;

void input()
{
  cin >> N;
}

int main()
{
  input();

  LL l = 0, r = MAX_N;
  while(r-l > 1){
    LL mid = (l+r)/2;
    if(mid*(mid+1)/2 >= N){
      r = mid;
    }
    else{
      l = mid;
    }
  }

  LL sum = 0;

  for (int i = r; 0 < i; i--) {
    if(sum + i <= N){
      cout << i << endl;
      sum += i;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

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

    vector<int> nums;
    for(int i=0; i<n; ++i) {
        int x;
        cin >> x;
        nums.push_back(x);
    }

    int n_max = -1 * INFINITY;
    int n_min = nums[0];
    for(int i=1; i<n; ++i) {
        n_max = max(nums[i]-n_min, n_max);
        n_min = min(nums[i], n_min);
    }
    cout << n_max << endl;

    return 0;
}

Measured memory_bytes: 3920
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;
int main(){

int x,y;

cin >> x >> y;

if( x <= 8 && y <= 8 ){
	cout << "Yay!";
}else{
	cout << ":(";
}

return 0;

}

Measured memory_bytes: 256
///
// File:  ntl_1_b.cpp
// Author: ymiyamoto
//
// Created on Mon Nov 13 03:07:08 2017
//

#include <cstdint>
#include <iostream>

using namespace std;
#define MOD 1000000007

uint64_t pow(uint64_t m, uint64_t n)
{
  if (n == 0)
    return 1;
  else if (n == 1)
    return m;
  else if (n % 2 == 0)
    return pow(m * m % MOD, n / 2);
  else
    return (m * pow(m * m % MOD, n / 2)) % MOD;
}

int32_t main()
{
  uint64_t n, m;
  cin >> m >> n;
  cout << pow(m, n) % MOD << endl;

  return 0;
}

Measured memory_bytes: 3092
#include"bits/stdc++.h"
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF= 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();

int main() {
	LL n; cin >> n;
	string s; cin >> s;
	VLL alp(26,1);
	REP(i, n)alp[s[i] - 'a']++;
	LL ans = 1;
	REP(i, alp.size())ans = (ans * alp[i]) % MOD;
	COUT(ans - 1);
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}

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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  double d = 100000;
  int id = 0;
  vector<int> H(N);
  
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
    double h = T - H.at(i) * 0.006;
    double ad = abs(A - h);
    if (ad <= d) {
      d = ad;
      id = i + 1;
    }
  }
  
  cout << id << endl;
}


Measured memory_bytes: 256
def main():
  H, N = (int(_) for _ in input().split())
  A = [[int(_) for _ in input().split()] for __ in range(N)]
  INF = 10 ** 15
  dp = [[INF] * (H + 1) for _ in range(N+1)]
  dp[0][0] = 0
  for i in range(N):
    for j in range(H+1):
      dp[i+1][j] = min(dp[i+1][j], dp[i][j])
      if A[i][0] <= j < H:
        dp[i+1][j] = min(dp[i+1][j], A[i][1] + dp[i+1][j-A[i][0]])
      elif j == H:
        for k in range(max(j - A[i][0], 0), j):
          dp[i+1][j] = min(dp[i+1][j], A[i][1] + dp[i+1][k])
  print(dp[N][H])
  return

if __name__ == '__main__':
  main()

Measured memory_bytes: 119664
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

int main(){

	int w,h;


	while (1){
		cin >> h >> w;
		if (w == 0 && h == 0) break;

		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 1152
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, A, B; cin >> N >> A >> B;
    cout << (abs(A-B-1)%2 == 0 ? "Borys" : "Alice") << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
long long int big[60][2] = {};

int main() {
	int n;
	cin >> n;
	long long int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!(i % 3 == 0 || i % 5 == 0)) {
			ans = ans + i;
		}
	}
	cout << ans << endl;
}

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

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

  if (G < 1200) {
    cout << "ABC" << endl;
  } else if (G < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto N = RD;
	auto D = RD;
	auto A = RD;
	auto XH = new long[][](N);
	foreach (i; 0..N)
	{
		XH[i] = [RD, RD];
	}
	XH.sort!"a[0] < b[0]"();

	long ans;
	long[][] q;
	long x;
	foreach (i; 0..N)
	{
		while (!q.empty)
		{
			if (q[0][0] < XH[i][0])
			{
				x -= q[0][1];
				q.popFront;
			}
			else
				break;
		}

		auto r = XH[i][1] - x;
		if (r > 0)
		{
			auto cnt = (r+A-1) / A;
			ans += cnt;
			x += A * cnt;
			q ~= [XH[i][0] + D*2, A * cnt];
		}
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 28540
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var ans = 0;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                for (int k = 1; k <= n; k++)
                    ans += gcd(i, j, k);
        Console.WriteLine(ans);
    }
    static int gcd(int a, int b, int c) => gcd(a, gcd(b, c));

    static int gcd(int a, int b)
    {
        if (a < b) return gcd(b, a);
        while (b != 0)
        {
            var w = a % b;
            a = b;
            b = w;
        }
        return a;
    }
}


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

#define ll long long

int main()
{
    ll n,ans=0;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            for(ll k=1;k<=n;k++)
            {
                ans+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	
	int d[5];
	//*
	REP(i, 5) {
		scanf("%d", &d[i]);
	}
	
	//*/
	int k;
	scanf("%d", &k);
	//*
	REP(i, 4) {
		FOR(j, i + 1, 5) {
			if (abs(d[i] - d[j]) > k) {
				puts(":(");
				return 0;
			}
		}
	}
	//*/
	puts("Yay!");
}

Measured memory_bytes: 128