akhauriyash/Code-Regression huggingface dataset:
use std::io;
use std::str::FromStr;
 
fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}
 
macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}
 
fn divisor(l: i32, u: i32, n: i32) -> i32 {
    let mut count = 0;
    for i in l..u+1 {
        if n % i == 0 {
            count += 1;
        }
    }
    count
}
 
fn main() {
    from_line!(a: i32, b: i32, c: i32);
 
    println!("{}", divisor(a, b, c));
}


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

const long long INF =pow(10,10);

int main() {
  int N,W;
  cin >> N >> W;
  
  vector<int> w(N),v(N);
  
  for(int i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }
  
  vector<vector<long long>> dp(N+1,vector<long long>(W+1,INF));
  
  for(int i=0;i<W+1;i++)
  dp[0][i]=0;
  
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(j<w[i])
        dp[i+1][j]=dp[i][j];
      else
        dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
    }
  }
  cout << dp[N][W] << endl;
}


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

const int cm = 1 << 15;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int PN = 12;
const int KM = 1 << (PN - 1);
ll dat[1 << PN];

void update(int A) {
	dat[A] = min(dat[A * 2], dat[A * 2 + 1]);
	if (A >= 5) update(A >> 1);
}

ll check(int L, int R, int A, int l, int r) {
	if (L <= l && r <= R) return dat[A];
	if (r <= L || R <= l) return 1ll << 60;
	return min(check(L, R, A * 2, l, (l + r) >> 1), check(L, R, A * 2 + 1, (l + r) >> 1, r));
}

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

	fread_unlocked(cn, 1, cm, stdin);
	int N = getint(), K = getint(), Q = getint();
	ll A[2002];
	int LR[2002] = {};
	rep1(i, N) {
		A[i] = ((ll)getint() << 11) + i;
		dat[KM + i] = A[i];
	}
	for (int i = KM - 1; i > 0; i--) {
		dat[i] = min(dat[i * 2], dat[i * 2 + 1]);
	}

	priority_queue<int> q;
	int kotae = 1e9;
	int saishou = 2e9;
	sort(A + 1, A + N + 1);
	const int m = (1 << 11) - 1;

	for (int i = N; i >= 1; i--) {
		int a = A[i] >> 11;
		int k = A[i] & m;

		int l = !LR[k - 1] ? k : LR[k - 1];
		int r = !LR[k + 1] ? k : LR[k + 1];
		LR[l] = r;
		LR[r] = l;

		int kosuu = min(K - 1, r - k) + min(K - 1, k - l) + 1;
		int abureta = max(0, kosuu - K + 1);

		rep(i, abureta) {
			ll tmp = check(l, r + 1, 1, 0, KM);
			q.push(tmp >> 11);
			int C = (tmp & m) + KM;
			dat[C] = 1ll << 60;
			update(C >> 1);
		}

		while (q.size() >= Q) {
			int tmp = q.top();
			chmin(saishou, tmp);
			q.pop();
		}
		chmin(kotae, saishou - a);
	}

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

vector<int> G[1 << 18];



typedef vector<vector<ll>> vec;

void merge(vec &a, vec &b) {
	if (a.size() < b.size())swap(a, b);
	int len = a.size();
	int l = b.size();
	rep(i, l) {
		per(x, 3) {
			ll memo = a[len - 1 - i][x];
			a[len - 1 - i][x] = 0;
			rep(y, 3) {
				int s = min(x + y, 2);
				a[len - 1 - i][s] += memo * b[l - 1 - i][y] % mod;
				if (a[len - 1 - i][s] >= mod)a[len - 1 - i][s] -= mod;
			}
		}
	}
}

vec dfs(int v) {
	vec ret; 
	int ma = 0;
	//vector<vec> nex;
	rep(j, G[v].size()) {
		int to = G[v][j];
		auto nex=dfs(to);
		ma = max(ma, (int)min(ret.size(), nex.size()));
		merge(ret, nex);
	}
	if (ma) {
		int len = ret.size();
		rep(i, ma) {
			ret[len - 1 - i][0] += ret[len - 1 - i][2];
			if (ret[len - 1 - i][0] >= mod)ret[len - 1 - i][0] -= mod;
			ret[len - 1 - i][2] = 0;
		}
	}
	ret.push_back(vector<ll>{ 1,1,0 });
	return ret;
}

int cnt[1 << 18];
void dfs2(int v,int d) {
	cnt[d]++;
	rep(j, G[v].size()) {
		int to = G[v][j];
		dfs2(to, d + 1);
	}
}
ll t2[1 << 18];
void solve() {
	int n; cin >> n;
	rep1(i, n) {
		int p; cin >> p; G[p].push_back(i);
	}
	dfs2(0, 0);
	t2[0] = 1;
	rep(i, (1 << 18) - 1)t2[i + 1] = t2[i] * 2 % mod;
	vec fin = dfs(0);
	ll ans = 0;
	per(i, (int)fin.size()) {
		int d = (int)fin.size() - 1 - i;
		int u = n + 1 - cnt[d];
		ans += t2[u] * fin[i][1] % mod;
		if (ans >= mod)ans -= mod;
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}

Measured memory_bytes: 49452
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    int ans = 10000000;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        int cnt = 0;
        while(true){
            if(a[i] % 2 == 1 || a[i] == 0){
                break;
            }
            a[i] /= 2;
            cnt++;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

a.sort()
alice = 0
bob = 0
if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            bob += a[i]
        else:
            alice += a[i]
else:
    for i in range(n):
        if i % 2 == 0:
            alice += a[i]
        else:
            bob += a[i]

print(alice - bob)


Measured memory_bytes: 3060
(defparameter *safe-aref-error* most-positive-fixnum)
(defun safe-aref (array discript)
  (if (not (minusp discript))
      (aref array discript)
      *safe-aref-error*))
(let* ((n (read))
       (m (read))
       (arr (make-array n :initial-element 0 :element-type 'fixnum))
       (dparr (make-array (1+ n) :initial-element most-positive-fixnum :element-type 'fixnum)))
  (setf *safe-aref-error* 10000000)
  (loop :for k :from 0 :upto (1- n) :do(setf (aref arr k) (read)))
  (setf (aref dparr 0) 0)
  (loop :for k :from 1 :upto (1- n)
        :do (setf (aref dparr k)
                  (loop :for j :from 1 :upto m
                        :minimize (+ (safe-aref dparr (- k j))
                                     (abs (- (safe-aref arr (- k j)) (aref arr k)))))))
  (princ (aref dparr (1- n))))

Measured memory_bytes: 59752
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
x = []
for i in range(N-2):
    check = 0
    for j in range(i+1,N-1):
        for k in range(j+1+check,N):
            if L[k] < L[i]+L[j]:
                check += 1
            else:
                break
        ans += check
        check -= 1
print(ans)

Measured memory_bytes: 44012
n = int(input())
parents = list(map(int, input().split()))
weights = list(map(int, input().split()))

children = [[] for _ in range(n)]
for i in range(n-1):
    children[parents[i]-1].append(i+1)


def dfs(cur):
    if children[cur] == []:
        return (weights[cur], 0)

    sum = 0
    dp = [[False] * (weights[cur] + 1) for _ in range(len(children[cur])+1)]
    dp[0][0] = True
    for i, child in enumerate(children[cur]):
        x, y = dfs(child)
        sum += x + y
        for j in range(weights[cur] + 1):
            if j + x <= weights[cur]:
                dp[i+1][j+x] += dp[i][j]
            if j + y <= weights[cur]:
                dp[i+1][j+y] += dp[i][j]

    tmp = -1
    for i in range(weights[cur]+1):
        if dp[-1][i]:
            tmp = i
    
    if tmp == -1:
        print('IMPOSSIBLE')
        exit()

    else:
        return (weights[cur], sum-tmp)

dfs(0)
print('POSSIBLE')

Measured memory_bytes: 104960
#include<iostream>		
using namespace std;
int main()
{
	int A, B, C, D,time;
	cin >> A >> B >> C >> D;
	if (A < C)
	{
		if (B < C)
			time = 0;
		else
		{
			if (B > D)
				time = D - C;
			else
				time = B - C;
		}
	}
	else
	{
		if (D < A)
			time = 0;
		else
		{
			if (D > B)
				time = B - A;
			else
				time = D - A;
		}
	}
	cout << time;
	return 0;
}

Measured memory_bytes: 256
a,b,c,d = [int(i) for i in input().split()]
import sys

if abs(c-a) <= d:
    print('Yes')
    sys.exit()
elif abs(c-b) <= d and abs(b-a) <= d:
    print('Yes')
    sys.exit()
else:
    print('No')
    sys.exit()

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  string s; cin >> s;
  cout << (s == "ABC" ? "ARC" : "ABC");
  return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("atcoder beginner contest");
            //ABC
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("resident register number");
            //RRN
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("k nearest neighbor");
            //KNN
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("async layered coding");
            //ALC
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string[] wkArr = InputList[0].Split(' ').ToArray();

        var sb = new System.Text.StringBuilder();
        sb.Append(wkArr[0].ToUpper()[0]);
        sb.Append(wkArr[1].ToUpper()[0]);
        sb.Append(wkArr[2].ToUpper()[0]);

        Console.WriteLine(sb.ToString());
    }
}


Measured memory_bytes: 13268
S=list(input())
K=int(input())
SS=S*2
F=S[0]
if len(S)==1:
	P=int(K//2)
elif S==[F]*len(S):
	P=int((len(S))*K//2)
else:
	for G in range(1,len(S)):
		if S[G-1]==S[G]:
			S[G]="O"
		else:
			continue
	A=S.count("O")
	for J in range(1,len(SS)):
		if SS[J-1]==SS[J]:
			SS[J]="O"
		else:
			continue
	B=SS.count("O")
	P=A+(B-A)*(K-1)
print(P)

Measured memory_bytes: 3064
#include <stdio.h>

void main (void) {

        int N,X,i,count=1,D=0;
        scanf("%d %d",&N,&X);

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

        for (i=0;i<N;i++) {
                D += L[i];
                if (X < D) {
                        break;
                } else {
                        count++;
                }
        }

        printf("%d\n",count);

}


Measured memory_bytes: 128
i = 0

while True:
    a,b,c = input().split()
    a = int(a)
    c = int(c)
    
    if b == "+":
        d = a + c
        print(d)
    elif b == "-":
        print(a - c)
    elif b == "*":
        print(a * c)
    elif b == "/":
        print(a//c)
    else:
        break
        


Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <set>
using namespace std;

char memo[16][16];
set<int> dp[16][16];
vector<int> op, ol;
const char *exp;

set<int> &dfs(int s, int e, int sp, int ep, int lv){
	set<int> &res = dp[s][e];
	if(memo[s][e]){
		return res;
	}
	res.clear();

	memo[s][e] = 1;

	for(bool need = true; need; ){
		need = (exp[sp] == '(' && exp[ep - 1] == ')');
		for(int i = s + 1; i < e; ++i){
			if(ol[i] == lv){
				need = false;
			}
		}
		if(need){
			++sp;
			--ep;
			++lv;
		}
	}

	if(s + 1 == e){
		res.insert(strtol(exp + sp, 0, 10));
	}
	else{
		for(int i = s + 1; i < e; ++i){
			if(ol[i] == lv){
				char c = exp[op[i]];
				set<int> &t = dfs(s, i, sp, op[i], lv);
				set<int> &u = dfs(i, e, op[i] + 1, ep, lv);
				set<int>::iterator it1, it2;
				for(it1 = t.begin(); it1 != t.end(); ++it1)
				for(it2 = u.begin(); it2 != u.end(); ++it2){
					switch(c){
					case '+':
						res.insert(*it1 + *it2);
						break;
					case '-':
						res.insert(*it1 - *it2);
						break;
					case '*':
						res.insert(*it1 * *it2);
						break;
					case '/':
						if(*it2){
							res.insert(*it1 / *it2);
						}
						break;
					}
				}
			}
		}
	}
	
	return res;
}

int main(){
	string s;
	while(getline(cin, s), s[0] != '#'){
		memset(memo, 0, sizeof memo);
		op.assign(1, -1);
		ol.assign(1, 0);
		int lv = 1;
		int len = s.size();
		
		exp = s.c_str();
		for(int i = 0; i < len; ++i){
			if(s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/'){
				op.push_back(i);
				ol.push_back(lv);
			}
			else if(s[i] == '('){
				++lv;
			}
			else if(s[i] == ')'){
				--lv;
			}
		}
		op.push_back(len);
		ol.push_back(0);
		int ans = dfs(0, op.size() - 1, 0, len, 1).size();
		cout << ans << '\n';
	}
}

Measured memory_bytes: 1304
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;
    int N;
    string s;

    public void calc()
    {
        cin = new Scanner();
        N = cin.nextInt();
        s = cin.next();

        string ans;

        ans = create("SS");
        if (ans != "") { Console.WriteLine(ans); return; }

        ans = create("SW");
        if (ans != "") { Console.WriteLine(ans); return; }

        ans = create("WS");
        if (ans != "") { Console.WriteLine(ans); return; }

        ans = create("WW");
        if (ans != "") { Console.WriteLine(ans); return; }

        Console.WriteLine("-1");

    }

    string create(string start2)
    {
        var ans = new char[N];
        ans[0] = start2[0];
        ans[1] = start2[1];

        for (int i = 1;i<N-1;i++)
        {
            ans[i + 1] = addchar(ans[i - 1], ans[i], i);
        }

        if (!eval(ans[N - 1], ans[0], ans[1], s[0])) return "";
        if (!eval(ans[N - 2], ans[N - 1], ans[0], s[N - 1])) return "";
        return new string(ans);
    }



    char addchar(char c0,char c1,int n)
    {
        if (s[n] == 'o')
        {
            if (c1 == 'S')
            {
                if (c0 == 'S') return 'S';
                return 'W';
            }
            if (c0 == 'S') return 'W';
            return 'S';
        }
        if (c1 == 'S')
        {
            if (c0 == 'S') return 'W';
            return 'S';
        }
        if (c0 == 'S') return 'S';
        return 'W';

    }

    bool eval(char a,char b,char c,char ox)
    {
        if (ox == 'o')
        {
            if (b == 'S') return a == c;
            return a != c;
        }
        if (b == 'S') return a != c;
        return a == c;
    }
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 13024
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, m, t;
  cin >> n >> m >> t;
  vi cannotStudy(t + 1);
  while (n--) {
    int a;
    cin >> a;
    for (int i = a - m; i <= a + m; i++) {
      if (i < cannotStudy.size()) cannotStudy[i] = 57;
    }
  }
  int c = 0;
  loop(i, 1, cannotStudy.size()) c += !(cannotStudy[i - 1] && cannotStudy[i]);
  cout << c << endl;
}

Measured memory_bytes: 3176
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T>;
void in() {}; template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); };
template <typename T> void _out(char *sep, char *end, T &&x) { cout << x << end; };
template <typename T, typename...TS> void _out(char *sep, char *end, T &&x, TS &&...xs) { cout << x << sep; _out(sep, end, move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t _; cin >> _; return _; }()
#define put(...) _out("", "", __VA_ARGS__)
#define out(...) _out(" ", "\n", __VA_ARGS__)
#define times(n, i) for (i32 i =  0 ; i <  (n); ++i)
#define range(a, b, i) for (i32 i = (a); i <  (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 n, a, b;
i64 h[100000];

i32 main()
{
	in(n, a, b);
	times(n, i) {
		in(h[i]);
	}
	i64 low = 0;
	i64 high = 10e9;
	while (high - low > 1) {
		i64 mid = (high + low + 1) / 2;
		i64 cnt = 0;
		times(n, i) {
			i64 t = h[i] - b*mid;
			if (t > 0) {
				cnt += (t + (a - b) - 1) / (a - b);
			}
		}
		if (cnt <= mid) {
			high = mid;
		}
		else {
			low = mid;
		}
	}
	out(high);
	return 0;
}


Measured memory_bytes: 1024
import scala.io.StdIn._

object Main extends App {
  private val MAX = 1_000_000

  val n = readInt
  val A = readLine.split(" ").map(_.toInt)
  val v = Array.fill(MAX + 10)(0)

  A.foreach { Ai =>
    if (v(Ai) > 0) {
      v(Ai) = 2
    } else {
      for (step <- Ai to MAX by Ai) {
        v(step) += 1
      }
    }
  }

  val ans = A.count { Ai => v(Ai) == 1 }
  println(ans)
}



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

int selectionSort(int A[], int N) {
    int count = 0;
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        if (i != minj) {
            count++;
            swap(A[i], A[minj]);
        }
    }
    return count;
}

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

    int count = selectionSort(A, N);

    for (int i = 0; i < N; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3104
#include <iostream>

int ctoi(const char c){
	switch(c){
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default : return -1;
}}
int main(){
	std::string s;
	std::cin>>s;

	int year = 1000*ctoi(s[0])+100*ctoi(s[1])+10*ctoi(s[2])+ctoi(s[3]);
	int month = 1000*ctoi(s[5])+100*ctoi(s[6])+10*ctoi(s[8])+ctoi(s[9]);

	if(year <= 2019 && month <= 430){
		std::cout<<"Heisei";
	}else{
		std::cout<<"TBD";
	}
	return 0;
}



Measured memory_bytes: 256
n,k=map(int, input().split())
a=list(map(int, input().split()))
alist=[]
cnt=0
i=1
blist=[0]*(n+1)
while blist[a[i-1]]==0:
  i=a[i-1]
  alist.append(i)
  blist[i]=1
  cnt+=1
loop1=alist.index(a[i-1])
if k<loop1+1:
  print(alist[k-1])
else:
  print(alist[((k-loop1-1)%(cnt-loop1))+loop1])

Measured memory_bytes: 32372
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        int n = in.nextInt();
        int k = in.nextInt();
        double prob = 0;
        for (int i = 1; i <= n; i++) {
            if (i >= k) {
                prob++;
            } else {
                //* 1/i
                int p = (int) Math.ceil(Math.log((double) k / i) / Math.log(2));
                prob += Math.pow((1.0 / 2), p);
            }
        }
        prob *= 1.0 / n;
        out.println(prob);
        out.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

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

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

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

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

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public double[] nextDoubleArray(int n) {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        public char[] nextCharArray(int n) {
            char[] arr = nextLine().trim().replaceAll("\\s", "").toCharArray();
            return arr;
        }

        public String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 21588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt(),M=sc.nextInt(),C=sc.nextInt();
		int[] B = new int[M];
		//int[][] A = new int[N][M];
		int ans=0;

		for(int i=0;i<M;i++) {
			B[i]=sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			int sum=0;
			for(int j=0;j<M;j++) {
				int A=sc.nextInt();
				sum+=A*B[j];
			}
			sum+=C;
			if(sum>0) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22228
#include <stdio.h>
  

void drwaw_check(int h, int w)
{
	int idx_h, idx_w;
	for(idx_h=0; idx_h<h; idx_h++){
		for(idx_w=0; idx_w<w; idx_w++){
			if( ((idx_h % 2) + (idx_w % 2)) % 2 )
  			    printf(".");
			else
				printf("#");
		}
		printf("\n");
	}
}

int main(void)
{
	int h,w;
	while(1){
		scanf("%d %d", &h, &w);
		if(h==0 && w==0){
			break;
		}
		drwaw_check(h, w);
		printf("\n");
	}  
    return 0;
}

Measured memory_bytes: 572
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
const LL MOD = 1000000007LL;
const int inf = 1e9;
const LL INF = 1e18;
bool connect[8][8];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b; a--; b--;
		connect[a][b] = connect[b][a] = 1;
	}
	int perm[8];
	for (int i = 0; i < N; i++) perm[i] = i;
	int ans = 0;
	do {
		bool OK = 1;
		for (int i = 1; i < N; i++) {
			if (!connect[perm[i - 1]][perm[i]]) {
				OK = 0;
				break;
			}
		}
		if (OK) ans++;
	} while (next_permutation(perm + 1, perm + N));
	cout << ans << endl;
}

Measured memory_bytes: 256
r, c = [int(x) for x in input().split()]

matrix = []
for i in range(r):
    matrix.append([int(x) for x in input().split()])
    
for i in range(r):
    for j in range(c):
        print(matrix[i][j], '', end='')
    print(sum(matrix[i]))

crsum = 0
for j in range(c):
    csum = 0
    for i in range(r):
        csum += matrix[i][j]
    print(csum, '', end='')
    crsum += csum
print(crsum)

Measured memory_bytes: 8788
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int q = sc.nextInt();
			if (n == 0 && q == 0)
				break;
			int[] c = new int[101];
			for (int i = 0; i < c.length; i++) {
				c[i] = 0;
			}
			for (int i = 0; i < n; i++) {
				int m = sc.nextInt();
				for (int j = 0; j < m; j++) {
					int d = sc.nextInt();
					c[d]++;
				}
			}
			int r = 0;
			for (int i = 0; i < c.length; i++)
				if (c[r] < c[i] && c[i] >= q)
					r = i;
			System.out.println(r);
		}
		sc.close();
	}
}

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

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    auto A = readln.split.map!(to!int).array;

    auto B = (A ~ 0).dup.sort().uniq.array;
    int[int] comp;
    foreach (i, b; B) comp[b] = i.to!int;
    auto M = B.length.to!int;

    auto dp = new long[][][](N+1, K+1, M+1);
    foreach (i; 0..N+1) foreach (j; 0..K+1) dp[i][j][] = 1L << 59;
    foreach (k; 0..M) dp[0][0][k] = B[k];

    foreach (i; 0..N) foreach (j; 0..K+1) foreach (k; 0..M) {
        int a = comp[A[i]];
        if (a > k) {
            dp[i+1][j][a] = min(dp[i+1][j][a], dp[i][j][k] + B[a] - B[k]);
            if (j < K) dp[i+1][j+1][k] = min(dp[i+1][j+1][k], dp[i][j][k]);
        } else {
            dp[i+1][j][a] = min(dp[i+1][j][a], dp[i][j][k]);
            if (j < K) dp[i+1][j+1][k] = min(dp[i+1][j+1][k], dp[i][j][k]);
        }
    }

    long ans = 1L << 59;
    foreach (j; 0..K+1) foreach (k; 0..M) ans = min(ans, dp[N][j][k]);
    ans.writeln;
}

Measured memory_bytes: 366844
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    Rep(i, N) {
        cin >> A[i];
    }
    int index = 0;
    bool flag = true;
    int count = 0;
    while (flag) {
        flag = false;
        for (int i = N - 1; i >= index + 1; --i) {
            if (A[i] < A[i - 1]) {
                swap(A[i], A[i - 1]);
                flag = true;
                count++;
            }
        }
        index++;
    }
    Rep(i, N - 1) {
        cout << A[i] << " ";
    }
    cout << A[N - 1] << endl;
    cout << count << endl;
    return 0;
}


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

using namespace std;

const char en = '\n';
using  ll =          long long;
using ull = unsigned long long;

#define REP(i  ,n) for(int i=0;i<n;i++)
#define FOR(i,s,g) for(int i=s;i<g;i++)

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

	int sum=0,buf;
	REP(i, 4){
		cin>>buf;
		sum+=buf;
	}
	cout<<sum/60<<en;
	sum%=60;
	cout<<sum<<en;

	return 0;
}

Measured memory_bytes: 3224
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author YahiaAshraf74
 */

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <string>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <assert.h>

using namespace std;
#define el  '\n'
#define ll long long
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
const long long N = 1e5 + 74, OO = 0x3f3f3f3f, MOD = 998244353;

ll fact[N], a[N], f[N];

ll nCr(int n, int r) {
    return fact[n] / (fact[r] * fact[n - r]);
}

long long power(long long b, long long p, long long MOD = 998244353) {
    long long res = 1;
    b %= MOD;
    for (; p; p >>= 1LL) {
        if (p & 1)res = (res * b) % MOD;
        b = (b * b) % MOD;
    }
    return res % MOD;
}

class BCountingOfTrees {
public:
    void solve(istream &cin, ostream &cout) {
        fact[0] = 1, fact[1] = 1;
        for (ll i = 2; i <= int(1e5) + 2; i++) {
            fact[i] = fact[i - 1] * i;
            fact[i] %= MOD;
        }
        int n;
        cin >> n;
        ll mx = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            f[a[i]]++;
            mx = max(mx, a[i]);
        }
        if (f[0] != 1 || a[0] != 0)
            return (void) (cout << 0 << el);
        for (int i = 0; i < mx; i++)
            if (!f[a[i]]) {
                cout << "0\n";
                return;
            }
        ll ans = 1;
        for (int i = 1; i <= mx; i++) {
            if (f[i] == 0)
                return (void) (cout << 0 << el);
            ans *= power(f[i - 1], f[i]);
            ans %= MOD;
        }
        cout << ans << el;
        clr(f, 0);
        clr(fact, 0);
        clr(a, 0);
    }
};

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    BCountingOfTrees solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 2560
N, P = map(int, input().split())
odd = sum([1 for x in list(map(int, input().split())) if x & 1])

even = N - odd

answer = 0
if odd == 0:
    if P == 0:
        answer = 2 ** even
    else:
        answer = 0
else:
    answer = 2 ** even * 2 ** (odd-1)
print(answer)

Measured memory_bytes: 3060
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
string A[100];//バブルソート
string B[100];//選択ソート
int main()
{
  int N;
  string str;
  cin >>N;

  for(int i = 0;i < N;i++){
    cin >>str;
    A[i] = str;
    B[i] = str;
  }
  //バブルソート 
  for(int i = 0;i < N;i++){
    for(int j = N-1;j >i;j--){
      if(A[j][1] <A[j-1][1]){
	swap(A[j],A[j-1]);
      }
    }
  }
  
  //選択ソート
  for(int i = 0;i <N-1;i++){
    int min = i;
    for(int j = i+1;j < N;j++){
      if(B[j][1] <B[min][1]){
	min = j;
      }
    }
    if(i !=min)
      swap(B[i],B[min]);
  }
  for(int i = 0;i <N;i++){
    cout <<A[i];
    if(i !=N-1)
      cout <<" ";
  }
  cout <<endl;
  cout <<"Stable"<<endl;

  for(int i = 0;i < N;i++){
    cout <<B[i];
    if(i !=N-1)
      cout <<" ";
  }
  cout <<endl;

  bool flag =true;
  for(int i = 0;i < N;i++){
    if(A[i] !=B[i]){
      flag =false;
      break;
    }
  }
  if(flag)
    cout <<"Stable"<<endl;
  else
    cout <<"Not stable"<<endl;
  return 0;
}

Measured memory_bytes: 1212
x, y, a, b, c = map(int, input().split())
p = [int(_) for _ in input().split()]
q = [int(_) for _ in input().split()]
r = [int(_) for _ in input().split()]

p.sort(reverse=True)
q.sort(reverse=True)

p = p[0:x]
q = q[0:y]

pqr = p + q + r
pqr.sort(reverse=True)
print(sum(pqr[0:x+y]))

Measured memory_bytes: 23200
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;
using ll = long long int;

#define rep(i, v) for(ll i = 0; i < (v); ++i)

int main(){
    ll N;
    cin >> N;
    vector<ll> H(N);
    for(auto &v : H) cin >> v;

    H[0]--;

    bool ret = true;

    for(ll i = 1; i < N; ++i){
        if(H[i-1] < H[i]){
            H[i]--;
        }else if(H[i-1] == H[i]){
            // no
        }else{
            ret = false;
        }
    }

    cout << (ret ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1024
#include <iostream>


using namespace std;

int main()
{
   int a , b;
   cin >> a >> b;
   if( a > b ) 
   cout <<"a > b" << endl;
   if( a < b)
   cout << "a < b" << endl;
   if( a == b)
   cout << "a == b" << endl;
   return 0;
}



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

Measured memory_bytes: 14252
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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, R = MAP()

print(R if N >= 10 else R+100*(10-N))


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

int main()
{
    vector<int> prevs = {};
    int val;
    int N;
    vector<int>::iterator position;
    int index;

    std::cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> val;

        position = lower_bound(prevs.begin(), prevs.end(), val);
        index = distance(prevs.begin(), position);
  
        if (index == 0){
          prevs.insert(prevs.begin(), val);
        }
        else
        {
          prevs[index - 1] = val;
        }
    }
    cout << prevs.size() << endl;
}


Measured memory_bytes: 892
K, N = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
D = 0
for i in range(N):
    if i == N - 1:
        d = K - (A[N - 1] - A[0])
    else:
        d = A[(i + 1) % N] - A[i]
    if d > D:
        D = d
print(K - D)



Measured memory_bytes: 26444
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  
  cout<<a*b/2<<endl;
  
  return 0;
}

Measured memory_bytes: 3632
/* aoj1350  */
//提出用(アクセプトされました)
#include<stdio.h>
#include <stdlib.h>  // qsort
#define N 500  //島の数の最大
#define M 50000 //橋の数の最大

int mst[M]={0};  //最初に作った最小木の橋を記憶する
int flag=0;      //最小木が1度作られたかどうか
int rm = -1;   //取り除いた橋の番号(初期値-1)

//橋を定義
typedef struct bridge{  
    //始点の島,終点の島,コスト
    int s; int d; int c;
}bridge_t;

//比較関数(qsort用)
int cmp(const void *a,const void *b){
  return ((bridge_t*)a)->c - ((bridge_t*)b)->c;
}

//与えられた要素の木の根を再帰で求める関数
int u_root(int x,int number[]){
    //根
    if(number[x-1] == x)
        return x;

    //経路圧縮
    else
        return number[x-1] = u_root(number[x-1],number);
}

//xとyが同じ集合に属するか否かを根を見て判断する(同じなら1を返す)
int u_find(int x, int y, int number[]){
    return u_root(x,number) == u_root(y,number);
}

//xとyの属する集合を併合
void u_union(int x, int y, int number[]){     //x,yは島の番号(1~)を表す
    number[y-1] = x;
}

//全ての要素が同じ集合に含まれているかどうかをfindで判定する関数
int allsame(int n, int number[])
{
    int y;
    for(y=2;y<=n;y++)
            if(!u_find(1,y,number)) //一つでも同じ集合に含まれない要素があるなら0を返す
                return 0;
    return 1; //全ての要素が同じ集合に含まれていれば1を返す。
}


//クラスカル法で最小全域木を生成する関数
//異常終了(最小木が生成できなかった)の時は0を返す
int kruskal(bridge_t b[], int n, int m, int number[]){
    int i=0; //配列の添字
    int mc=0;  //最小木のコスト
    //独立した点がなくなるまで繰り返す
    while(!allsame(n,number)){
        //独立していてかつ取り除かれた橋でないならその要素の根を合成する
        if(!u_find(b[i].s,b[i].d,number) && i!=rm){
            u_union(u_root(b[i].s,number),u_root(b[i].d,number),number);
            //まだ一度も最小木が作られていないならどの橋を使ったかを記憶する
            if(!flag)
                mst[i] = 1;
            //コストを足していく
            mc += b[i].c;
        }
        i++;
        //最後まで探索して、一つでも同じ集合にない要素があれば、最小木は作れないということになる
        if(i==m)
          if(!allsame(n,number))
             return 0;
    }
    return mc;
}

int main(void){
    int n,m;        //島の数,橋の数
    bridge_t b[M];  //橋の情報
    int mc;         //最初に作った最小木のコスト
    int mc2;        //2回目以降に作る最小木のコスト
    bridge_t temp;  //橋の情報の一時記憶領域
    int number[N];  //親の番号
    int alt[M] = {0};     //オルタナティブな橋の番号(初期値は全て非オルタナティブ))
    int acost=0,abridge=0;    //オルタナティブな橋のコストの和と、オルタナティブな橋の本数の和
    int i,j;

    scanf("%d%d",&n,&m);
    //n要素で初期化(初めは全ての頂点が根)
    for(i=0;i<n;i++)
        number[i] = i+1;
    //橋の始点、終点、コストを入力
    for(i=0;i<m;i++){
        scanf("%d%d%d",&b[i].s,&b[i].d,&b[i].c);
    }
    //qsortによるソート(コストの昇順)
    qsort(b,m,sizeof(bridge_t),cmp);

    //クラスカル法を行う関数を呼び出し
    //全ての要素で最小木を作る
    mc = kruskal(b,n,m,number);
    flag=1;     //１度最小木を作成した

    //numberを初期化
    for(i=0;i<n;i++){
        number[i] = i+1;
    }
    //作った最小木の中で辺を一つだけ取り除き最小木が作れるかどうかで場合分け
    for(j=0;j<m;j++){
        //最初に作った最小木の橋ならばその橋を取り除く
        if(mst[j]){
            rm = j;   //取り除いた橋の番号を記憶
            mc2 = kruskal(b,n,m,number);    //橋を一つ取り除いて最小木を作る
            //ある橋を一つ取り除いて同じコストの最小木を作れないなら、それは不変の橋である
            if(mc < mc2 || mc2 == 0)
                alt[j]=1;
            //numberを初期化しておく
            for(i=0;i<n;i++)
                number[i] = i+1;
        }
        //オルタナティブな橋が見つかれば
        if(alt[j]){
            abridge++;
            acost += b[j].c;
        }
    }
    printf("%d %d\n",abridge,acost);
    
    return 0;
}


Measured memory_bytes: 3020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		out.println(Math.abs(a-x) < Math.abs(b-x) ? "A" : "B");
	}
	
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: usize = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let n: usize = sc.get();
    let mut p = Vec::new();
    for _ in 0..n {
        let r: usize = sc.get();
        let c: usize = sc.get();
        p.push((r, c));
    }
    let mut dp = vec![vec![INF; n+1]; n+1];
    for i in 0..n {
        dp[i][i+1] = 0;
    }
    for w in 2..n+1 {
        for l in 0..n {
            let r = min(n, l + w);
            for i in l+1..r {
                dp[l][r] = min(dp[l][r], dp[l][i] + dp[i][r] + p[i-1].1 * p[l].0 * p[r-1].1);
            }
        }
    }
    println!("{}", dp[0][n]);
}



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

using namespace std;

int main(){
    int L;
    cin>>L;
    
    //cout<<(double)pow(L/3.0,3)<<endl;
    printf("%lf\n",pow(L/3.0,3));
    
    return 0;
}



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

int main(void) {
	int A, B;
	scanf("%d%d", &A, &B);
	if (A % 3 == 0) {
		printf("Possible\n");
	} else if (B % 3 == 0) {
		printf("Possible\n");
	} else if ((A + B) % 3 == 0) {
		printf("Possible\n");
	} else {
		printf("Impossible\n");
	}
	return 0;
}


Measured memory_bytes: 3772
<?php
fscanf(STDIN,"%s",$n);
	if(substr($n,0,1)==substr($n,1,1) || substr($n,1,1)==substr($n,2,1) || substr($n,2,1)==substr($n,3,1)){
		echo "Bad";
	}else{
		echo "Good";
	}
?>

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

int ConvStrToInt(std::string checkStr)
{
	return atoi(checkStr.c_str());
}
std::string ConvIntToStr(int checkNum)
{
	return std::to_string(checkNum);
}

int main(void)
{
	int coin_500, coin_100, coin_50, total;

	cin >> coin_500 >> coin_100 >> coin_50 >> total;

	int resultValue = 0;
	for (int i = 0; i <= coin_500; ++i)
	{
		for (int j = 0; j <= coin_100; ++j)
		{
			for (int k = 0; k <= coin_50; ++k)
			{
				int value = 500 * i + 100 * j + 50 * k;
				if (value == total)
				{
					++resultValue;
				}
			}
		}
	}


	cout << resultValue << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int main(){
    int A, B, X;
    cin >> A >> B >> X;
    if(A == X){
        cout << "YES" << endl;
    }else if(A < X && A + B > X){
        cout << "YES" << endl;
    }else if(A > X){
        cout << "NO" << endl;
    }
    else{
        cout <<"NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256