akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline


def print_ans(X, K, D):
    """Test Case
    >>> print_ans(6, 2, 4)
    2
    >>> print_ans(7, 4, 3)
    1
    >>> print_ans(10, 1, 2)
    8
    >>> print_ans(1000000000000000,1000000000000000,1000000000000000)
    1000000000000000
    """
    # 移動しない
    if K % 2 == 0 and D >= abs(X):
        print(abs(X))
    elif K % 2 != 0 and D >= abs(X):
        print(min(abs(X-D), abs(X+D)))
    elif abs(X) - D * K >= 0:
        print(abs(abs(X) - D * K))
    else:
        # near 0
        tmp, _ = divmod(abs(X), D)
        rest_K = K - tmp
        a = abs(abs(X) - tmp * D)
        b = abs(abs(X) - (tmp + 1) * D)
        if rest_K % 2 == 0:
            print(a)
        else:
            print(b)


if __name__ == '__main__':
    X, K, D = map(int, input().rstrip().split())
    print_ans(X, K, D)


Measured memory_bytes: 9172
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int s = abs(a[0]); s += abs(a[n - 1]);
	rep(i, n - 1)s += abs(a[i] - a[i + 1]);
	rep(i, n) {
		if (i == 0) {
			cout << s + abs(a[i + 1]) - (abs(a[i]) + abs(a[i] - a[i + 1])) << endl;
		}
		else if (i == n - 1) {
			cout << s + abs(a[i - 1]) - (abs(a[i - 1] - a[i]) + abs(a[i])) << endl;
		}
		else {
			cout << s + abs(a[i - 1] - a[i + 1]) - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])) << endl;
		}
	}
	return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(new String(S.Select(s => (char)(s[0] + ('A' - 'a'))).ToArray()));
	}
	String[] S;
	public Sol(){
		S = rsa();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

const int N=2e5+5;
int n;
struct fenwick
{
    long long bit[N];
    void update(int x, long long value)
    {
        for(;x<=n;x+=(x & -x)) bit[x]=max(bit[x],value);
    }
    long long query(int x)
    {
        long long s=0;
        for(;x>0;x-=(x&-x)) s=max(bit[x],s);
        return s;
    }
} fw;
pair<int,int> a[N];
long long f[N],ans=0;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i].first;
    for(int i=1;i<=n;i++) cin>>a[i].second;
    for(int i=1;i<=n;i++)
    {
        f[i]=fw.query(a[i].first-1)+a[i].second;
        fw.update(a[i].first,f[i]);
        ans=max(ans,f[i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4992
N,x=map(int,input().split())
a=[int(i) for i in input().split()]
ans=0
if a[0]>x:
  ans+=a[0]-x
  a[0]=x
for i in range(1,N):
  if a[i-1]+a[i]>x:
    ans+=a[i]+a[i-1]-x
    a[i]=x-a[i-1]
print(ans)


Measured memory_bytes: 14544
import java.util.Scanner;

public class Main {
//java11
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String N = sc.next();

		String ans = "No";
		for(int i=0; i<3; i++) {
			if(N.charAt(i) == '7') {
				ans="Yes";
				break;
			}
		}

		System.out.println(ans);
	}

}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 998244353;
constexpr ll INF = 1e18;

int main() {
    ll n, i, j, s;
    cin >> n >> s;
    vector<ll> A(n);
    for(auto &x : A) cin >> x;
    vector<vector<ll>> dp(n + 1, vector<ll>(6001, 0));
    dp[0][0] = 1;
    for(i = 0; i < n; i++) {
        for(j = 0; j <= s; j++) {
            (dp[i + 1][j + A[i]] += dp[i][j]) %= MOD;
            (dp[i + 1][j] += dp[i][j]) %= MOD;
        }
        dp[i + 1][0] = i + 2;
    }
    ll ret = 0;
    for(i = 0; i < n; i++) {
        (ret += dp[i + 1][s]) %= MOD;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 141056
object Main extends App {
  val input = io.StdIn.readLine().split(" ").map(_.toInt)
  val n = input(0)
  val ad = input(1)

  n match {
    case 0 => println(converter(ad))
    case 1 => println(1868 + ad - 1)
    case 2 => println(1912 + ad - 1)
    case 3 => println(1926 + ad - 1)
    case 4 => println(1989 + ad - 1)
    case _ => ???
  }

  def converter(ad: Int): String = {
    ad match {
      case x if 1868 until 1912 contains x => s"M${x + 1 - 1868}"
      case x if 1912 until 1926 contains x => s"T${x + 1 - 1912}"
      case x if 1926 until 1989 contains x => s"S${x + 1 - 1926}"
      case x if 1989 until 2017 contains x => s"H${x + 1 - 1989}"
      case _ => ???
    }
  }
}


Measured memory_bytes: 44012
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int gcd(int n, int m){

    if(m > n)  return gcd(m, n);

    int r = n % m;
    if(r == 0) return m;
    else       return gcd(m, r);
}

int main(){

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

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

    if(n == 1){
        if(a[0] == k){
            cout << "POSSIBLE";
        }
        else{
            cout << "IMPOSSIBLE";
        }
    }
    else{
        int g = gcd(a[0], a[1]);
        int vmax = max(a[0], a[1]);
        for(int i=2; i<n; i++){
            g = gcd(g, a[i]);
            vmax = max(vmax, a[i]);
        }

        if(k % g == 0 && k <= vmax){
            cout << "POSSIBLE";
        }
        else{
            cout << "IMPOSSIBLE";
        }
    }
    return 0;
}

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

int main() {
    int n;
    int p[10];
    int ans = 0;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    
    sort(p, p + n, greater<int>());
    
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            ans += p[i] / 2;
        }
        else {
            ans += p[i];
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()

print(ceil(N/K)-N//K)


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int r;
  cin >> r;
  double ans = acos(-1)*r*2;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long            ll;
typedef unsigned long long   ull;
typedef vector<int>          vi;
typedef vector<ll>           vl;
typedef pair<int, int>       pi;
typedef pair<ll, ll>         pl;
typedef vector<pi>           vpi;
typedef vector<pl>           vpl;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define read        freopen("in.c", "r", stdin)
#define write       freopen("out.c", "w", stdout)
#define all(a)      a.begin(), a.end()
#define bye         exit(0)
#define mp          make_pair
#define ff          first
#define ss          second
#define L(x)        ((x) << 1)
#define R(x)        ((x) << 1 | 1)
#define SZ(a)       (ll)(a).size()
#define pb          push_back
#define eb          emplace_back
#define eps         1e-9
#define inf         (1000000000)
#define infl        (1000000000000000000LL)
#define cs(p)       printf("Case %d:", (p)++)
#define ptc(c)      putchar(c)
#define gtc()       getchar()
#define nl          puts("")
#define sp          printf(" ")
#define out(a)      printf("%lld", (ll)(a))
#define SET(a, x)   memset((a), x, sizeof(a))
#define dbg(x)      cerr << "--- " << #x << " = " << (x) << '\n'

ll bgm(ll a, ll b, ll m) {
    b = (b == -1) ? (m - 2) : b;
    a %= m;
    ll rem = 1;
    while(b != 0) {
        if(b&1)
            rem = (rem * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return rem;
}

inline ll in() {
    ll a;
    assert(scanf("%lld", &a) != EOF);
    return a;
}

const int MAX = 100000 + 5;
const int LEN = 100;
const ll MOD = 1000000007;

int t;

int n, W;
int w[MAX], v[MAX];

int vis[LEN][MAX];
ll dp[LEN][MAX];

int lo, hi, mid;
int ans;

ll solve(int pos, int now) {
    if(now <= 0) {
        return 0;
    }
    if(pos == n) {
        return infl;
    }
    if(vis[pos][now] == t) {
        return dp[pos][now];
    }
    vis[pos][now] = t;
    dp[pos][now] = min(solve(pos + 1, now), w[pos] + solve(pos + 1, now - v[pos]));
    return dp[pos][now];
}            

int main() {
    n = in(), W = in();
    for(int i = 0; i < n; i++) {
        w[i] = in(), v[i] = in();
    }
    lo = 0, hi = MAX - 1;
    while(lo <= hi) {
        mid = (lo + hi) / 2;
        ++t;
        if(solve(0, mid) <= W) {
            ans = mid;
            lo = mid + 1;
        }
        else {
            hi = mid - 1;
        }
    }
    out(ans), nl;
    return 0;
}


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

int main(){
  int k; cin >> k;
  string s; cin >> s;
  string ans = "";
  if(k >= s.size()) ans = s;
  else {
    ans = s.substr(0,k);
    ans += "...";
  }

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

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

void solve(){
    lli x, s = 100, y = 0;
    cin>>x;
    while(s<x){
        ++y;
        s += (lli)(s * (0.01));
    }
    cout<<y;
    return ;
}
int main(){
    fastIO;
    lli t = 1; 
    // cin>>t;
    NA(i,0,t) solve();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int n,a,b,c,d;
char str[200003];
int dp[200003];
int main()
{
    int i,j;
    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
    scanf("%s",str+1);
    dp[a]=1; //-범위 인덱스 ?
    for(i=a;i<=c;i++){
        if(str[i]=='#' ||dp[i]==0) continue;
        dp[i+1]|=str[i+1]=='.';
        dp[i+2]|=str[i+2]=='.';
    }
    if(!dp[c]) {
        printf("No");return 0;
    }

    dp[b]=1;
    for(i=b;i<=d;i++){
        if(str[i]=='#' ||dp[i]==0) continue;
        dp[i+1]|=str[i+1]=='.';
        dp[i+2]|=str[i+2]=='.';
    }
    if(!dp[d]) {
        printf("No");return 0;
    }

    else if(a<c && c<b && b<d){
        printf("Yes"); return 0;
    }
    else if(a<b && b<c && c<d){
        printf("Yes");
        return 0;
    }
    else if(a<b && b<d && d<c){
        for(i=b-1;i<=d-1;i++){
            if(str[i]=='.' && str[i+1]=='.' && str[i+2]=='.'){
                printf("Yes");
                return 0;
            }
        }
        printf("No");
        return 0;
    }
    return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int64_t> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  sort(H.begin(),H.end());
  reverse(H.begin(),H.end());
  int64_t ans=0;
  for(int i=K;i<N;i++){
    ans+=H.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
public class Main{
     public static void main(String[] args){
          int i,j;
   
          int val = new java.util.Scanner(System.in).nextInt();
  
          int a=2;
          System.out.print(val + ":");
   
          while(val>=a*a){
                if(val%a==0){
                      System.out.print(" " + a);
                    val/=a;
                 }else{
                     a++;
                }
  
         }
          System.out.println(" " +  val);
     }
 }

Measured memory_bytes: 26224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define gc getchar
#define pc putchar
#define cs const

inline
ll getint(){
    re ll num;
    re char c;
    re bool f=0;
    while(!isdigit(c=gc()))f^=c=='-';num=c^48;
    while(isdigit(c=gc()))num=(num<<1)+(num<<3)+(c^48);
    return f?-num:num;
}

inline
void outint(ll a){
	static char ch[23];
	if(a==0)pc('0');
	while(a)ch[++ch[0]]=a-a/10*10,a/10;
	while(ch[0])pc(ch[ch[0]--]^48);
}

int n;
cs int N=100005;
int a[N];
int cnt[2][N];
ll sum[2];
int maxn[2],num[2],submaxn[2],subnum[2];


signed main(){
	n=getint();
	for(int re i=2;i<=n+1;++i){
		a[i]=getint();
		++cnt[i&1][a[i]];
		if(maxn[i&1]<cnt[i&1][a[i]]){
			if(num[i&1]==a[i]){
				maxn[i&1]=cnt[i&1][a[i]];
			}
			else {
				subnum[i&1]=num[i&1];
				submaxn[i&1]=maxn[i&1];
				maxn[i&1]=cnt[i&1][a[i]];
				num[i&1]=a[i];
			}
		}
		else if((cnt[i&1][a[i]]==maxn[i]&&num[i&1]!=a[i])||cnt[i&1][a[i]]>submaxn[i&1]){
			submaxn[i&1]=cnt[i&1][a[i]];
			subnum[i&1]=a[i];
		}
	}
	int ans;
	if(num[0]!=num[1])ans=n-maxn[0]-maxn[1];
	else ans=n-max(maxn[0]+submaxn[1],maxn[1]+submaxn[0]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
use proconio::{fastout, input};

use num::complex::Complex;
use std::f64::consts::PI;

#[fastout]
fn main() {
    input! {
        a: f64, b: f64, h: f64, m: f64,
    }
    let c = a * Complex::new(0.0, (h + m / 60.0) / 12.0 * 2.0 * PI).exp();
    let d = b * Complex::new(0.0, m / 60.0 * 2.0 * PI).exp();
    println!("{}", (c - d).norm());
}


Measured memory_bytes: 2980
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
    {
        if(b==1 && b<a)
        {
            cout<<"Bob"<<endl;
        }
        else
            cout<<"Alice"<<endl;
    }
    else if(a<b)
    {
        if(a==1 && a<b)
        {
            cout<<"Alice"<<endl;
        }
        else
            cout<<"Bob"<<endl;
    }
    else
        cout<<"Draw"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000000
#define MaX 10000005
#define ll long long
#define slld(t) scanf("%I64d",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%I64d\n",t)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define pb(x) push_back(x)
#define ub upper_bound
#define lb lower_bound
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define clr(x) memset(x,0,sizeof(x))
#define sws ios::sync_with_stdio(false); cin.tie(0)
#define pi acos(-1)
#define rep(I, N) for (int I = 0; I < (N); ++I)
#define repp(I, a, B) for (int I = (a); I <= (B); ++I)
#define t1(x)                cout<<#x<<": "<<x<<endl
#define t2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
ll pwr(ll base, ll p, ll mod = MOD)
{
    ll ans = 1;
    while(p)
    {
        if(p & 1)   ans = (ans * base) % MOD;
        base = (base * base) % MOD;
        p /= 2;
    }
    return ans;
}
// for inverse modulo : if (1/b)%mod then ans is (b^(mod-2))%mod
ll gcd(ll a, ll b)
{
    if(b == 0)  return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
    return (a*b) / gcd(a, b);
}
/*bool isPrime[MaX];
void sieve(int n) 
{
    for(int i = 0; i <= n;++i) 
    {
        isPrime[i] = true;
    }
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i = 2; i * i <= n; ++i) 
    {
         if(isPrime[i] == true) 
         {
             for(int j = i * i; j <= n ;j += i)
                 isPrime[j] = false;
        }
    }
}*/
bool cmp(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.first > b.first);
}
const ll N = 2e5 + 5 ;
int main()
{
    sws;
    //clock_t clk;
    //clk = clock();
    
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/

    int r, g;
    cin >> r >> g;
    cout << g + g - r;

    //clk = clock() - clk;
    //cout << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 256
import sys
read = lambda: sys.stdin.readline().rstrip()
 
def main():
    INF = 10 ** 20
 
    n,k = map(int,input().split())
    h = tuple(map(int,read().split()))
    dp = [INF]*(n+1)
    dp[0] = 0
 
    for i in range(1, n):
        for j in range(1, k + 1):
            if i - j < 0:
                pass
            else:
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
 
    print(dp[n-1])
if __name__ == "__main__":
    main()

Measured memory_bytes: 56672
#include <bits/stdc++.h>
#define Ganesha ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define lli long long int
using namespace std;
int main(){
    Ganesha
    lli n,m,i,ans=1e13;
    cin>>n;
    for(i=1;i*i<=n;i++){
        if(n%i==0){
            ans=min(ans,i+(n/i)-2);
        }
    }
    return cout<<ans,0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

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

    cin >> a >> b >> c;

    if(b/a >= c) cout << c << endl;
    else cout << b/a << endl;

    return 0;
}

Measured memory_bytes: 256
/*    FAILING IS AN ART
       AND 
     I HAVE MASTERED IT
*/
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

ll bin_exp_mod(ll a, ll b,ll m)
{
    a%=m;
    ll ans=1;
    if(a==0) ans=0;

    while(b>0)
    {
        if(b&1) ans=(ans*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return ans;
}




int main()
{ 


    fast;

    ll n,a,b;
    cin>>n>>a>>b;

    ll x=bin_exp_mod(2,n,mod);
    ll c=max(a,b);

      ll fact[c+5],inv[c+5],finv[c+5];
    fact[0]=fact[1]=inv[0]=inv[1]=finv[0]=finv[1]=1;
  
    for(ll i=2;i<c+5;i++)
    {
      fact[i]=fact[i-1]*i%mod;
      inv[i]=mod-inv[mod%i]*(mod/i)%mod;
      finv[i]=finv[i-1]*inv[i]%mod;
    }

    ll v1=1,v2=1;

    for(ll i=1;i<=a;i++)
     v1=v1*(n-a+i)%mod;
    

    for(ll i=1;i<=b;i++)
        v2=v2*(n-b+i)%mod;
   
    v1=v1*finv[a]%mod;
    v2=v2*finv[b]%mod;
    x=(x-1-v1-v2+mod+mod)%mod;
    cout<<x<<endl;







}


Measured memory_bytes: 4992
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    S = [INPUT() for _ in range(3)]
    ctoi = lambda c: ord(c) - ord('a')

    num = 0
    while len(S[num]) > 0:
        init = S[num][0]
        S[num] = S[num][1:]
        num = ctoi(init)

    print("ABC"[num])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9916
n,m=map(int,input().split())
ans=[-1]*n
if n==1 and m==0:
    print(0)
    exit()
for i in range(m):
    s,c=map(int,input().split())
    if ans[s-1]!=-1 and ans[s-1]!=c:
        print(-1)
        exit()
    ans[s-1]=c
if ans[0]==-1:
    ans[0]=1
elif ans[0]==0 and n>1:
    print(-1)
    exit()
x=0
for i in range(n):
    x*=10
    if ans[i]!=-1:
        x+=ans[i]

print(x if len(str(x))==n else -1)

Measured memory_bytes: 38384
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin >> S;
	if (S[0] == '7' || S[1] == '7' || S[2] == '7')
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
    string N,S,T;
    cin>>N>>S;
    int A,B;
    cin>>A>>B>>T;
    if(S==T)
    cout<<A<<" "<<B-1<<endl;
    else cout<<A-1<<" "<<B<<endl;
  return 0;
    }


Measured memory_bytes: 256
[n, m] = [int(num) for num in input().split()];
a = [];
b = [];

for i in range(m):
	[t1, t2] = [int(num) for num in input().split()];
	a.append(t1);
	b.append(t2);

start = [];
end = [];
for i in range(n):
	start.append(False);
	end.append(False);
	
for i in range(m):
	if a[i] == 1:
		start[b[i]] = True;
	elif b[i] == n:
		end[a[i]] = True;
		
flag = False;
for i in range(n):
	if start[i] & end[i]:
		flag = True;
		
if flag:
	print('POSSIBLE');
else:
	print('IMPOSSIBLE');

Measured memory_bytes: 22064
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, k;
  cin >> n >> k;
  int v[n];
  for(int i = 0; i < n; i++) cin >> v[i];

  int ans = -INF_INT;
  for(int l = 0; l <= min(n, k); l++){
    for(int r = 0; r <= min(n, k) && l + r <= min(n, k); r++){
      vector< int > tmp(l + r);
      int sum = 0;
      for(int i = 0; i < l; i++){
        sum += v[i];
        tmp.push_back(v[i]);
      }
      for(int i = n - 1; i >= (n - r); i--){
        sum += v[i];
        tmp.push_back(v[i]);
      }
      sort(tmp.begin(), tmp.end());
      for(int i = 0; i < k - (l + r) && i < (l + r); i++){
        if(tmp[i] < 0) sum -= tmp[i];
      }
      ans = max(ans, sum);
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  int64_t h, w;
  cin >> h >> w;
  
  if (h == 1 || w == 1) {
    cout << 1 << endl;
  }
  else if ((h * w) % 2 == 0) {
    cout << h * w / 2 << endl;
  }
  else {
    cout << ((h - 1) * (w - 1) / 2) + ((h + w) / 2) << endl;
  }
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
a2 = [0]
for i in range(n):
    a2.append(a2[-1] + a[i] - 1)
a2 = [a2[i] % k for i in range(n + 1)]
count = {}
temp = a2[:min(k, len(a2))]
for i in temp:
    count.setdefault(i, 0)
    count[i] += 1
ans = 0
for i in count.values():
    ans += (i * (i - 1) // 2)
for i in range(1, len(a2) - len(temp) + 1):
    temp = a2[i: i + len(temp)]
    temp2 = temp[:-1]
    ans += temp2.count(temp[-1])
print(ans)

Measured memory_bytes: 42856
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 5e3+5, M = 2e2+5;
int n, m, b[M][N], s[N], f[N];
int64 a[N], ans, d[N][N];
void solve(int *w)
{
    int top = 0, r = 0;
    for(int i = 1; i <= n; ++i) 
    {
        while(top&&w[s[top]] < w[i]) --top;
        f[i] = top?s[top]+1:1, s[++top] = i; 
    }
    top = 0;
    for(int i = n; i; --i) 
    {
        while(top&&w[s[top]] < w[i]) --top;
        r = top?s[top]-1:n, s[++top] = i;
        d[f[i]][i] += w[i], d[f[i]][r+1] -= w[i], d[i+1][i] -= w[i], d[i+1][r+1] += w[i]; 
    }
}
int main()
{
    n = read(), m = read();
    for(int i = 2; i <= n; ++i) a[i] = a[i-1]+read();
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) b[j][i] = read();
    for(int i = 1; i <= m; ++i) solve(b[i]);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
        {
            d[i][j] += -d[i-1][j-1]+d[i-1][j]+d[i][j-1]; 
            if(i <= j) ans = max(ans, d[i][j]-a[j]+a[i]);
        }
    printf("%lld\n", ans);
    return 0;
}

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


int main(){
    char S[3];

    for(int i=0;i<=2;i++){
        scanf("%c",&S[i]);
    }

    if(S[0]!=S[1]&&S[1]!=S[2]&&S[0]!=S[2]){
        printf("Yes");
    }else{
        printf("No");   
    }

    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}


ll solve(ll h, ll w) {
  ll res=1000000000000,s1,s2,s3;
  rep2(i,1,w) {
    s1=h*i;
    s2=h*((w-i)/2);
    s3=h*(w-i-(w-i)/2);
    chmin(res,max({s1,s2,s3}) - min({s1,s2,s3}));
    s2=(w-i)*(h/2);
    s3=(w-i)*(h-h/2);
    chmin(res,max({s1,s2,s3}) - min({s1,s2,s3}));
    // cout << tmp << ' ' << res << endl;
  }
  return res;
}


int main() {
  ll H,W,ans=10000000000;
  cin >> H >> W;
  chmin(ans,solve(H,W));
  chmin(ans,solve(W,H));
  cout << ans << endl;
}

Measured memory_bytes: 256
A,B,C,X,Y = map(int,input().split())

ans = 0
judge = 0 #X < Y: 0,X >= Y: 1
if(X < Y):
  judge = 0
else:
  judge = 1
  
#A,B それぞれ一枚買うとき //「Aセット」+「Bセット」//と//「Cセット」*2//
#の安いほうをたくさん買う
if((A+B) > C*2 ):
  if(judge == 0):#X < Y 
   ans += C*2*X
   #残りはBをY-X枚買う
   if( B < 2*C):
    ans += B*(Y-X) 
   else:
    ans += C*2*(Y-X)    
  elif(judge == 1):#Y <= X
   ans += C*2*Y 
   #残りはAをX-Y枚買う
   if( A < 2*C):
    ans += A*(X-Y) 
   else:
    ans += C*2*(X-Y)

else:
  if(judge == 0):#X < Y 
   ans += (A+B)*X
   #残りはBをY-X枚買う
   if( B < 2*C):
    ans += B*(Y-X) 
   else:
    ans += C*2*(Y-X)    
  elif(judge == 1):#Y <= X
   ans += (A+B)*Y 
   #残りはAをX-Y枚買う
   if( A < 2*C):
    ans += A*(X-Y) 
   else:
    ans += C*2*(X-Y)

print(ans)
  
  

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++) cin >> s[i];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < 2; j++) cout << s[i] << endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


c_list = []
for _ in range(3):
    c_list.append(ds_in())
c_list = np.array(c_list)

flag = 1
for i in [1, 2]:
    diff = c_list[i] - c_list[i-1]
    if diff[0] == diff[1] == diff[2]:
        continue
    else:
        flag = 0
        break

if flag:
    print('Yes')
else:
    print('No')


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

int map[50][50];
int w,h,label;

void check(int x,int y,int lnum){
  map[y][x]=lnum;
  if (x>0){
    if (map[y][x-1]==1) check(x-1,y,lnum);
    if (y>0){
      if (map[y-1][x-1]==1) check(x-1,y-1,lnum);
    }
    if (y<h-1){
      if (map[y+1][x-1]==1) check(x-1,y+1,lnum);
    }
  }
  if(x<w-1){
    if (map[y][x+1]==1) check(x+1,y,lnum);
    if (y>0){
      if (map[y-1][x+1]==1) check(x+1,y-1,lnum);
    }
    if (y<h-1){
      if (map[y+1][x+1]==1) check(x+1,y+1,lnum);
    }
  }
  if (y>0){
    if (map[y-1][x]==1) check(x,y-1,lnum);
  }
  if (y<h-1){
    if (map[y+1][x]==1) check(x,y+1,lnum);
  }
}

int main(){
  cin >> w >> h;
  while (w!=0||h!=0){
    label=2;
    for (int i=0;i<h;i++)
      for (int j=0;j<w;j++)
	cin >> map[i][j];

    for (int i=0;i<h;i++){
      for (int j=0;j<w;j++){
	if (map[i][j]==1){
	  //cout << "(" << map[i][j] << ")";
	  check(j,i,label++);
	}
      }
    }
    //cout << "(" << label << ")";

    cout << (label-2) << endl;

    cin >> w >> h;
 }
  return 0;
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B

const int inf = 1000000000;
int count = 0;

void merge(int a[], int l, int m, int r) {
	int n1 = m - l;
	int n2 = r - m;
	int al[n1], ar[n2];
	for (int i = 0; i < n1; i++) al[i] = a[l + i];
	for (int i = 0; i < n2; i++) ar[i] = a[m + i];
	al[n1] = inf;
	ar[n2] = inf;
	int i = 0, j = 0;
	for (int k = l; k < r; k++) {
		count++;
		if (al[i] <= ar[j]) {
			a[k] = al[i];
			i += 1;
		} else {
			a[k] = ar[j];
			j += 1;
		}
	}
}

void mergesort(int a[], int l, int r) {
	if (l + 1 < r) {
		int m = (l + r) / 2;
		mergesort(a, l, m);
		mergesort(a, m, r);
		merge(a, l, m, r);
	}
}

int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	mergesort(a, 0, n);
	cout << a[0];
	for (int i = 1; i < n; i++) cout << " " << a[i];
	cout << endl;
	cout << count << endl;
	return 0;
}

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

typedef long long ll;

int main() {
    int N, M, a, b;
    cin >> N >> M;
    vector<int> c(N, 0);
    rep(i, M) {
        cin >> a >> b;
        c[a - 1]++;
        c[b - 1]++;
    }
    rep(i, N) {
        if (c[i] % 2) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N; cin >> N;
    if(N[0] == N[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

int main(void) {
	int p,q,r,w;
	scanf("%d%d%d",&p,&q,&r);
	w=p+q;
	if(w>p+r){
		w=p+r;
	}
	if(w>q+r){
		w=q+r;
	}
	printf("%d",w);
	

	
	// your code goes here
	return 0;
}


Measured memory_bytes: 128
# -*- coding: utf_8 -*-

level = False
def debug(v):
    if level:
        print(v)

NOT_FOUND = 0
ENQUEUED = 1
FOUND = 2

def bfs(graph, status, results):
    queue = []
    queue.append(1)
    while len(queue) != 0:
        node = queue.pop(0)
        status[node] = FOUND
        d = results[node]
        for edge in graph[node]:
            if status[edge] != NOT_FOUND:
                continue
            status[edge] = ENQUEUED
            queue.append(edge)
            results[edge] = d + 1

    return results

if __name__ == "__main__":
    n = int(input())
    status = [NOT_FOUND] * (n + 1)
    results = [-1] * (n + 1)
    results[1] = 0
    g = [[0]]

    for i in range(n):
        row = [int(x) for x in input().split()]
        row.pop(0)
        row.pop(0)
        g.append(row)

    bfs(g, status, results)
    results.pop(0)

    for idx, v in enumerate(results):
        print(idx + 1, v)
     

Measured memory_bytes: 7772
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
struct g
{   int m;
    int x;
    int y;
}a[100005];
int main()
{
   int n,i,j;
   a[0].m=a[0].x=a[0].y=0;
   cin>>n;
   for(i=1;i<=n;i++)
   cin>>a[i].m>>a[i].x>>a[i].y;
   for(i=1;i<=n;i++)
   {
      
       if(a[i].m-a[i-1].m<(abs(a[i].x-a[i-1].x)+abs(a[i].y-a[i-1].y))||(a[i].m-a[i-1].m)%2!=(abs(a[i].x-a[i-1].x)+abs(a[i].y-a[i-1].y))%2)
       {cout<<"No";
       return 0;
       }
   }
   cout<<"Yes";
        return 0;
}


Measured memory_bytes: 1408
import collections

h,w = map(int,input().split())
area = []
q = collections.deque()

for i in range(h):
    area.append(list(input()))
    ls = [(i,j,0) for j in range(w) if area[-1][j] =="#"]
    q.extend(ls)
d = [[-1,0],[0,-1],[1,0],[0,1]]
co = 0
while q:
    y,x,c = q.popleft()
    for dy,dx in d:
        if (0<=y+dy<h) and (0<=x+dx <w):
            if area[y+dy][x+dx] == ".":
                area[y+dy][x+dx] = "#"
                co = max(c+1,co)
                q.append((y+dy,x+dx,c+1))
print(co)


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n,a,b;
	cin >> n >> a >> b;
	if (abs(a-b)%2 == 1) {
		cout << "Borys" << endl;
	}
	else {
		cout << "Alice" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    vvi a(3, vi(3));
    REP(i, 3) REP(j, 3) {
        cin >> a[i][j];
    }
    int n;
    cin >> n;
    int b;
    REP(k, n) {
        cin >> b;
        REP(i, 3) REP(j, 3) {
            if (b == a[i][j]) {
                a[i][j] = 0;
            }
        }
    }

    if (a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0) { cout << "Yes" << endl; return; }
    if (a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0) { cout << "Yes" << endl; return; }
    if (a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0) { cout << "Yes" << endl; return; }
    if (a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0) { cout << "Yes" << endl; return; }
    if (a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0) { cout << "Yes" << endl; return; }
    if (a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0) { cout << "Yes" << endl; return; }
    if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) { cout << "Yes" << endl; return; }
    if (a[2][0] == 0 && a[1][1] == 0 && a[0][2] == 0) { cout << "Yes" << endl; return; }
    cout << "No" << endl;
}


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

using namespace std;

const int INF = 1 << 28;

struct SegNode
{
  int v;

  SegNode(int v) : v(v) {}

  SegNode operator*(const SegNode &r) const
  {
    return (v > r.v ? *this : r);
  }
} e(-(1 << 30));

struct SegmentTree
{
  int sz;
  vector< SegNode > seg;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, e);
  }

  void update(int k, const SegNode &x)
  {
    k += sz - 1;
    seg[k] = x;
    while(k > 0) {
      k = (k - 1) >> 1;
      seg[k] = seg[2 * k + 1] * seg[2 * k + 2];
    }
  }

  SegNode query(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return (e);
    if(a <= l && r <= b) return (seg[k]);
    return (query(a, b, 2 * k + 1, l, (l + r) >> 1) * query(a, b, 2 * k + 2, (l + r) >> 1, r));
  }

  SegNode query(int a, int b)
  {
    return (query(a, b, 0, 0, sz));
  }
};


int main()
{
  int N, M, X[30000];

  while(cin >> N >> M, N) {
    for(int i = 0; i < N; i++) {
      cin >> X[i];
      X[i] %= M;
    }

    vector< int > first(M, INF), last(2 * M, -INF);
    first[0] = -1;
    int sum = 0;
    for(int i = 0; i < N; i++) {
      sum += X[i];
      sum %= M;
      first[sum] = min(first[sum], i);
      last[sum] = max(last[sum], i);
      last[M + sum] = max(last[M + sum], i);
    }

    int ret = 0;
    SegmentTree seg(N);
    int ptr = 0;
    for(int i = 0; i < M; i++) {
      while(ptr - i < M) {
        if(last[ptr] >= 0) {
          seg.update(last[ptr], ptr);
        }
        ++ptr;
      }
      ret = max(ret, seg.query(first[i] + 1, N).v - i);
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 1e9+7
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
const int mod = 1000000007;
const int N = 1e5+5, M = N;
//=========================================

vector<int> g[N];
int dp[N], vis[N];

int solve(int node){
    if(vis[node]) return dp[node];

    vis[node] = 1;
    int temp_best = 0;

    for(int child : g[node]){
        temp_best = max(temp_best, 1 + solve(child));
    }

    return dp[node] = temp_best;
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int x, y; cin >> x >> y;
        g[x].push_back(y);
    }

    int best = 0;
    for(int i = 1; i <= n; ++i)
        best = max(best, solve(i));

    cout << best << endl;

    return 0;
}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  ll N,K;
  cin >> N>>K;
  vector<pair<ll,ll>> V;
  for(ll i = 0; i<K;i++){
    ll L,R;
    cin >> L >> R;
    V.push_back(make_pair(L,R));
  }
  
  sort(V.begin(),V.end());
  vector<long long> dp(200010,0);
  dp[1] = 1;
  dp[1+V[0].first]= 1;
  
  for(ll i = V[0].first+2;i<=200010;i++){
    long long dif = 0;
    for(auto v:V){
      dif += (dp[max(0LL,i-v.first)]-dp[max(0LL,i-v.second-1)]);
      dif += 998244353;
      dif %= 998244353;
    }
   dp[i] = dp[i-1]+dif;
   dp[i] %= 998244353;
  }
  
  
  
  cout << dp[N] << endl;
}
      

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

void solve()
{
	int n;
	cin >> n;
	auto W = vector<int>(n);
	auto s = 0;
	for(auto& x : W) {
		cin >> x;
		s += x;
	}

	auto ans = s;
	auto s1 = 0;
	for(auto x : W)
	{
		s1 += x;
		ans = min(ans, abs(s - s1 - s1));
	}

	cout << ans << endl;
	
}

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using G = vector<vector<int>>;
const long long INF = 1LL << 60;

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

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

int main(){
  int n;
  cin >> n;
  vector<vector<ll>> dp(n,vector<ll>(3,0));
  vector<vector<ll>> act(n,vector<ll>(3,0));

  rep(i,n)rep(j,3) cin >> act[i][j];
  int before = 0;
  dp[0][0] = act[0][0]; dp[0][1] = act[0][1]; dp[0][2] = act[0][2];
  for(int i=1;i<n;i++){
    for(int bf=0;bf<3;bf++){  
        for(int j=0;j<3;j++){
            if(bf == j) continue;
            dp[i][j] = max(dp[i][j], dp[i-1][bf] + act[i][j]);
        }
    }        
  }

  ll ans = 0;
  rep(i,3) chmax(ans ,dp[n-1][i]);
  cout << ans << endl;
}

Measured memory_bytes: 11136
import java.util.Scanner;
import java.util.Stack;



public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Stack<Integer> stack = new Stack<Integer>();
		stack.push(s.charAt(0)-'0');
		int count =0;
		for(int i=1;i<s.length();i++) {
			if (stack.isEmpty()) {
				stack.push(s.charAt(i)-'0');
			} else {
				if (stack.peek()!=(s.charAt(i)-'0')) {
					stack.pop();
					count+=2;
				} else {
					stack.push(s.charAt(i)-'0');
				}
			}
		}
		System.out.println(count);
	}
}

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

int main()
{
	string s;
	getline(cin, s);
	for (int i = 0; i < s.size(); i++) {
		if (s[i] >= 'A' && s[i] <= 'Z') {
			s[i] += 'a'-'A';
		}
		else if (s[i] >= 'a' && s[i] <= 'z') {
			s[i] += 'A'-'a';
		}
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3160
#include<stdio.h>
#include<iostream>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int d, r;
    double f;
    d = a / b;
    r = a % b;
    f = (double)((a - r) / b) + (double)r / (double)b;
    printf("%d %d %f",d,r,f);
    return 0;
}


Measured memory_bytes: 3204