akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<Drink> li = new ArrayList<>();
        for(int i = 0; i < n; i++){
            li.add(new Drink(sc.nextInt(),sc.nextInt()));
        }
        Collections.sort(li);
        long ans = 0;
        for(Drink d : li){
            int y = d.y;
            int dm = d.m;
            if(m <= dm){
                ans += (long)y*m;
                break;
            }else{
                ans += (long)y*dm;
                m -= dm;
            }
        }
        System.out.println(ans);
    }
}

class Drink implements Comparable<Drink>{
    int y,m;
    public Drink(int y, int m){
        this.y = y;
        this.m = m;
    }
    
    public int compareTo(Drink d){
        if(this.y < d.y){
            return -1;
        }else if(this.y > d.y){
            return 1;
        }else{
            return 0;
        }
    }
}

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: 44456
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;i++)
#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 pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int n, m;
int v[3] = {-1, -1, -1};

int32_t main(){
    int x, y;
    cin >> x >> y;

    int cnt=0;
    while(x<=y){
        x*=2;
        cnt++;
    }

    cout << cnt << endl;
}

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

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

    ll n, m;
    cin >> n >> m;
    ll a[n];
    rep(i, n) cin >> a[i];
    ll csum[n];
    map<ll, ll> csum_cnt;
    rep(i, n) csum[i] = ((i ? csum[i - 1] : 0) + a[i]) % m;
    set<ll> check;

    rep(i, n) {
        csum_cnt[csum[i]]++;
        check.insert(csum[i]);
    }
    ll ans = 0;
    for (auto i : check) ans += csum_cnt[i] * (csum_cnt[i] - 1) / 2;
    ans += csum_cnt[0];
    cout << ans << endl;
    return 0;
}

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

const int M = 1e9 + 7;
const int INF = 1e9 + 5;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> v(3, vector<int> (n));
	
	for(int i = 0; i < n; i++) {
		cin >> v[0][i] >> v[1][i] >> v[2][i];
	}
	
	//for(auto a : v) {
		//for(int i : a) {
			//cout << i << " ";
		//}
		//cout << endl;
	//}
	
	vector<vector<int>> dp(n+1, vector<int> (3));
	for(int i = 1; i <= n; i++) {
		dp[i][0] = v[0][i-1] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = v[1][i-1] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = v[2][i-1] + max(dp[i-1][0], dp[i-1][1]);
	}
	
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << "\n";
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int res1 = 0, res2 = 0, cur = 0, ans;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != '0' + cur) {
            ++res1;
        }
        cur ^= 1;
    }
    cur = 1;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != '0' + cur) {
            ++res2;
        }
        cur ^= 1;
    }
    ans = min(res1, res2);
    cout << ans;
    return 0;
}



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

const int MAXN = 100 + 10, MAXM = 1e5 + 10;

int n, k, a[MAXN], f[MAXM][2];

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (i >= a[j]) {
                f[i][0] |= (f[i - a[j]][1] ^ 1);
                f[i][1] |= (f[i - a[j]][0] ^ 1);
            }
        }
    }
    puts(f[k][0] ? "First" : "Second");
    return 0;
}

Measured memory_bytes: 1024
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 998244353;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 2000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int n;
array<int,2> a[NMAX];
ll dp[NMAX+1];

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

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

	sort(a,a+n);

	dp[n] = 1;
	vector<array<int,2>> st{{n, (int)2e9}};

	for(int i = n - 1; i >= 0; i--)
	{
		while(st.back()[1] < a[i][0] + a[i][1])
		{
			st.pop_back();
		}

		int p = st.back()[0];
		dp[i] = dp[p];
		st.push_back({i,a[i][0]});

		dp[i] = (dp[i] + dp[i+1]) % MOD;
	}
	cout << dp[0];

	


    return 0;
}

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

int main(){
  while(1){

  long long sum=0,sums=0;
  int n,ti[10000];
  cin>>n;
  if(n==0) break;

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

  for(int i=0;i<n-1;i++){
    sum+=ti[i];
    sums+=sum;

  }
 
  cout<<sums<<endl;
  }
  return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(int, r);
  outl(3 * r * r);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
#define VV(T) vector<vector< T > >
#define brep(i, n) BREP(i, 0, m);
#define BREP(i, x, n) for(int i = x; i < (1<<n); i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define PB push_back
#define MOD 1000000009LL

map<ll, ll> cnt;

int main(){
    int N; cin >> N;
    ll ans = 0, sum = 0;
    cnt[0] = 1;
    rep(i, N){
        int a; cin >> a;
        sum += a;
        ans += cnt[sum];
        cnt[sum]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12800
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, M, W, H;
double S;
bool under(double x, double y, double l, double r){
  double crs = (double)W * (y - l) - (r - l) * x;
  return crs < 0;
}

int main(){
  while(cin >> N >> M >> W >> H >> S && N){
    double l[30000], r[30000];
    REP(i, M) cin >> l[i] >> r[i];
    double cx[30000], cy[30000];
    REP(i, N) cin >> cx[i] >> cy[i];
    int choco[30000] = {};
    REP(i, N){
      int lb = -1, ub = M - 1;
      while(ub - lb > 1){
        int m = (ub + lb) / 2;
        if(under(cx[i], cy[i], l[m], r[m])){
          ub = m;
        }else{
          lb = m;
        }
      }
      choco[ub]++;
    }
    double area[30000];
    REP(i, M){
      double l1 = i - 1 >= 0 ? l[i - 1] : 0;
      double r1 = i - 1 >= 0 ? r[i - 1] : 0;
      double l2 = l[i], r2 = r[i];
      double L = l2 - l1, R = r2 - r1;
      area[i] = (L + R) / 2.0 * W;
    }
    int accumC[30001] = {};
    double accumS[30001] = {};
    REP(i, M) accumS[i + 1] = accumS[i] + area[i];
    REP(i, M) accumC[i + 1] = accumC[i] + choco[i];
    //debug(accumS, accumS + M + 1);
    //debug(accumC, accumC + M + 1);
    int ans = N;
    int e = 0;
    for(int b = 0; b < M; b++){
      while(e < M && accumS[e + 1] - accumS[b] < (double) W * H - S + EPS) e ++;
      ans = min(ans, N - (accumC[e] - accumC[b]));
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2876
import sys

heap_size = int(input()) # heap size

key_list = list(map(int, sys.stdin.readline().split()))
for i, key in enumerate(key_list):
    node_no = i + 1
    parent_no = node_no // 2
    left_no = 2 * node_no
    right_no = left_no + 1

    print('node {}: key = {}, '.format(node_no, key), end='')
    if parent_no >= 1:
        print('parent key = {}, '.format(key_list[parent_no - 1]), end='')
    if left_no <= heap_size:
        print('left key = {}, '.format(key_list[left_no - 1]), end='')
    if right_no <= heap_size:
        print('right key = {}, '.format(key_list[right_no - 1]), end='')
    print()


Measured memory_bytes: 5680
from math import sqrt
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        d = 0
        for k in range(D):
            d += (X[i][k]-X[j][k])**2
        if sqrt(d).is_integer():
            ans += 1
print(ans)


Measured memory_bytes: 38384
import java.util.*;
public class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args){
		s.next();
		String str=s.next();
		int cur=0,max=0;
		for(int i=0;i<str.length();i++) {
			switch (str.charAt(i)) {
			case 'D':
				cur--;
				break;
			case 'I':
				cur++;
				break;
			}
			max=Math.max(cur, max);
		}
		System.out.println(max);
	}
}


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

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

  int N; cin >> N;
  ll MOD = 1e9 + 7;
  vector<ll> d(100, 0);
  for (int i = 0; i < N; i++) {
    ll A; cin >> A;
    for (int j = 0; j < 65; j++) {
      d[j] += A % 2;
      A /= 2;
    }
  }

  ll ans = 0, a2 = 1;
  for (int i = 0; i < 100; i++) {
    ll temp = d[i];
    temp = temp * (N - temp) % MOD;
    temp = temp * a2 % MOD;
    ans = (ans + temp) % MOD;
    a2 = a2 * 2 % MOD;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	string c;
	cin >> N >> c;
	int j, k;
	j = 0;
	k = N - 1;
	int ans = 0;
	rep(i, N) {
		while (1) {
			if (c[j] == 'W')break;
			j++;
			if (j >= N)break;
		}
		while (1) {
			if (c[k] == 'R')break;
			k--;
			if (k < 0)break;
		}
		if (k < j)break;
		ans++;
		c[j] = 'W';
		c[k] = 'R';
		j++; k--;
	}
	cout << ans;
}

Measured memory_bytes: 3748
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define lwi(x) cout << " your " << #x << " is ---> " << x << " ";
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e6+5;

int32_t main(){
    FastIO;
    ll a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<utility>
#include<set>
#include <queue>
#define ull unsigned long long
#define ll long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define S(x) scanf("%d",&x)
#define Sl(x) scanf("%lld",&x)
#define M(x,i) memset(x,i,sizeof(x))
#define F(i,a,n) for(i=(a);i<(n);++i)
#define FD(i,a,n) for(i=(a);i>=(n);--i)
using namespace std;
int a[100005];
map<int,int> mp;
int main()
{
    int n,i,t;
    cin>>n>>t;
    F(i,0,n){
        S(a[i]);
    }

    priority_queue<int,vector<int>,greater<int> > pq;

    int mdiff = 0;
    F(i,0,n){

        if(pq.empty()){
            pq.push(a[i]);
            continue;
        }

        int mnm = pq.top();
        if(mnm <= a[i]){
            int diff = a[i] - mnm;
            mp[diff]++;
            //cout<<mnm<<" "<<a[i]<<" "<<mp[diff]<<endl;
            mdiff = max(mdiff,diff);
        }
        pq.push(a[i]);
    }

    //cout<<mdiff<<" "<<mp[mdiff]<<endl;
    cout<<mp[mdiff]<<endl;
}

Measured memory_bytes: 5752
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int n;
	ll k;
	cin >> n >> k;
	vector<int> arr(n+1), vis, has(n+1);
	for(int i = 1; i <= n; i++)
		cin >> arr[i];
	int now = 1;
	while(!has[now]) {
		vis.push_back(now);
		has[now] = true;
		now = arr[now];
	}
	int pos = find(vis.begin(), vis.end(), now)-vis.begin();
	if(k < pos)
		cout << vis[k];
	else
		cout << vis[(k-pos)%(vis.size()-pos)+pos];

	return 0;
}


Measured memory_bytes: 5852
using System;

class ABC_136_D
{
    static void Main(string[] args)
    {
        string S = Console.ReadLine();

        int[] Ans = new int[S.Length];

        int odd = 0;
        int even = 0;
        int changePoint = -1;
        for (int i = 0; i < S.Length; i++)
        {
            if(S[i]=='L' && changePoint < 0) changePoint = i;

            if (S[i]=='R' && changePoint>0)
            {
                if (changePoint % 2 == 0)
                {
                    Ans[changePoint - 1] = odd;
                    Ans[changePoint] = even;
                }
                else
                {
                    Ans[changePoint - 1] = even;
                    Ans[changePoint] = odd;
                }

                changePoint = -1;
                odd = 0;
                even = 0;
            }

            if (i%2 == 0) even++;
            else odd++;
        }

        if (changePoint > 0)
        {
            if (changePoint % 2 == 0)
            {
                Ans[changePoint - 1] = odd;
                Ans[changePoint] = even;
            }
            else
            {
                Ans[changePoint - 1] = even;
                Ans[changePoint] = odd;
            }
        }

        for (int i = 0; i < Ans.Length; i++)
        {
            if (i>0) Console.Write(" ");
            Console.Write(Ans[i]);
        }
        Console.WriteLine("");

    }
}

Measured memory_bytes: 13920
#include<stdio.h>
 
struct node{
    int key;
    struct node *next;
    struct node *prev;
};
 
typedef struct node * NodePointer;
NodePointer finditem(int);
void listprint(void);
NodePointer make_1node(int,NodePointer);
void deleteFirst(void);
void deleteLast(void);
void deleteNode(NodePointer);
NodePointer head;

NodePointer finditem(int key){
  NodePointer x;
  x = head->next;
  while(x != head && x->key != key){
    x = x->next;
  }
  return x;
}
 
void insert(int key){
  NodePointer y;
  y = malloc(sizeof(struct node));
  y->key = key;
  y->next = head->next;
  head->next->prev = y;
  head->next = y;
  y->prev = head;
    
}
 
void listprint(){
  NodePointer cur = head->next;
  int isf = 1;
  while(1){
    if ( cur == head ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
 
void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}
  
void deleteFirst(){
  NodePointer t = head->next;
  if ( t == head ) return;
  deleteNode(t);
}
  
void deleteLast(){
  NodePointer t = head->prev;
  if ( t == head ) return;
  deleteNode(t);
}
  
void delete(int key){
  NodePointer k;
  k=finditem(key);
  if(k == head) return;
    
  deleteNode(k);
    
}
void init(){
  head = malloc(sizeof(struct node));
  head->next = head;
  head->prev = head;
}
 
int main(void){
    int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++;
      }
      size--;
    }
  }
    
  listprint();
  return 0;
}
 

Measured memory_bytes: 31788
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;

int main(){
    int a[5];
    int maximum=0;
    int soeji=-1;
    for(int i=0; i<5; i++) {
        cin >> a[i];
        if(maximum<(10-a[i]%10) && a[i]%10!=0){
            maximum=10-a[i]%10;
        }
    }
    int ans=0;
    for(int i=0; i<5; i++){
        if(a[i]%10!=0) {
            ans += a[i] / 10 * 10+10;
        }else{
            ans+=a[i];
        }
    }

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



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

using namespace std;

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

    if(a == b && b == c){
        cout << 1 << endl;
    }else if(a == b && b != c || a != b && b == c || a == c && c != b){
        cout << 2 << endl;
    }else{
        cout << 3 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    For(i,0,n) cin >> a[i];
    sort(ALL(a));
    reverse(ALL(a));
    ans += a[0];
    int cnt = n-2;
    For(i,1,n){
        if(cnt >= 2){
            ans += 2 * a[i];
            cnt -= 2;
        }
        else if(cnt == 1){
            ans += a[i];
            cnt -= 1;
        }
        if(cnt == 0){
            break;
        }
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
ll hell=1000000007;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
// mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());  put as first line of main
lld dp[3005][3005]; // i tak mein j heads
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j;
    cin>>n;
    lld a[n+1];
    for(i=1;i<=n;i++)
        cin>>a[i];
    lld p=1;
    lld q=1;
    dp[0][0]=1;
    for(i=1;i<=n;i++)
    {
        dp[i][0]=p*(1-a[i]);
        dp[i][i]=q*a[i];
        p=dp[i][0];
        q=dp[i][i];
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            dp[i][j]=dp[i-1][j]*(1-a[i]) + dp[i-1][j-1]*a[i];
        }
    }
    lld ans=0;
    for(i=((n+1)/2);i<=n;i++)
        ans+=dp[n][i];
    cout<<fixed<<setprecision(12)<<ans<<"\n";
    //cout<<dp[n][n];
    return 0;
}


Measured memory_bytes: 141184
#include <stdio.h>
int main (){
int k,han=0,i,j;
  scanf ("%d",&k);
  char s[100][11];
  scanf ("%s",s[0]);
  for (i=1;i<k;i++){
    scanf ("%s",s[i]);
  if (s[i-1][strlen(s[i-1])-1]==s[i][0]){
  }
    else{
    han=han+1;
      break;
    }
    for (j=0;j<i;j++){
  if(strcmp(s[i],s[j])==0){
  han=han+1;
    break;
  }
    }
  
  }  
  
  if (han==0){
printf ("Yes");
  }
  else{
printf("No");
  }
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	int N;
	double L;
	double[] r;
	double[][] memo;

	void run() {
		L: while (sc.hasNext()) {
			String[] in = sc.nextLine().split(" ");
			L = Double.valueOf(in[0]);
			N = in.length - 1;
			r = new double[N];
			for (int i = 0; i < N; i++) r[i] = Double.valueOf(in[i + 1]);

			memo = new double[N][1 << N];
			for (int i = 0; i < N; i++) {
				if (r[i] + tsp(i, 1 << i) <= L) {
					System.out.println("OK");
					continue L;
				}
			}
			System.out.println("NA");
		}
	}

	double tsp(int v, int mask) {
		if (memo[v][mask] != 0)   return memo[v][mask];
		if (mask == (1 << N) - 1) return r[v];

		double res = Double.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			if ((mask & (1 << i)) != 0) continue;
			double rr = Math.sqrt((r[v] + r[i]) * (r[v] + r[i]) - (r[v] - r[i]) * (r[v] - r[i]));
			res = Math.min(res, rr + tsp(i, mask | 1 << i));
		}
		return memo[v][mask] = res;
	}

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

Measured memory_bytes: 27420
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int a, b;
signed main() {
	cin >> a >> b;
	int k = gcd(a, b);
	map<int, bool>mp;
	for (int i = 2; i * i <= k; i++) {
		if (k % i == 0)mp[i] = 1;
		while (k % i == 0)k /= i;
	}
	if (k != 1)mp[k] = 1;
	cout << mp.size() + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <cassert>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using ldb = long double;

#define forn(i, x, n) for (int i = x; i < (int)(n); ++i)
#define forcin(a, n) for (int i = 0; i < n; cin >> a[i], ++i)
#define forb(i, x, n) for (int i = (int)(x); i >= n; --i)
#define mmax(a, b, c) max(a, max(b, c))
#define mmin(a, b, c) min(a, min(b, c))
#define pb push_back
#define mp make_pair


int main() {
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    cout << x % b;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  char a[101];
  scanf("%s",a);
  int i,n,c,b;
  n=strlen(a);
  for(i=0;i<n;i++){
    if((i+1)%2==1&&(a[i]=='R'||a[i]=='U'||a[i]=='D')) c++;
    if((i+1)%2==0&&(a[i]=='L'||a[i]=='U'||a[i]=='D')) b++;
  }
  if(c+b==n) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
L = [[[0 for i in range(10)] for i in range(3) ] for i in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    L[b-1][f-1][r-1] += v
for bn, b in enumerate(L):
    for f in b:
        print(" ", end="")
        print(*f)
    if not bn == 3:
        print("#" * 20)


Measured memory_bytes: 5624
L = list(raw_input())
total = 0
for bit in range(2**(len(L) - 1)):
    P = [""] * (len(L))
    for k in range(len(L) - 1):
        if bit & (1 << k):
            P[k] = ""
        else:
            P[k] = "+"
    calc = ""
    for i in range(len(L)):
        calc += L[i] + P[i]
    calc = eval(calc)
    total += calc
print(total)

Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a/__gcd(a, b)*b/__gcd(a, b)*c << "\n";
    return 0;
}


Measured memory_bytes: 3088
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  println {
    List
      .fill(sc.nextInt())(sc.nextLong())
      .groupBy(identity)
      .toList
      .sortBy(_._1)
      .combinations(3)
      .map { case l@List((a, _), (b, _), (c, _)) =>
        if (a + b <= c) 0 else l.foldLeft(1)(_ * _._2.size)
      }
      .sum
  }
}

Measured memory_bytes: 58540
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder("");

        int a, b, r, temp;
        long gcd;

        while (sc.hasNextInt()) {
            a = sc.nextInt();
            b = sc.nextInt();

            gcd = (long) a * (long) b;

            if (a < b) {
                temp = a;
                a = b;
                b = temp;
            }

            do {
                r = a % b;
                a = b;
                b = r;
            } while (b != 0);

            gcd /= a;

            sb.append(a);
            sb.append(' ');
            sb.append(gcd);
            sb.append('\n');
        }

        System.out.print(sb);

    }
}

Measured memory_bytes: 26220
#include<bits/stdc++.h>
 using namespace std;
int main(){
  int A, B, K, res;
  cin >> A >> B >> K;
  int count = 0;
  for (int i = max(A,B); count < K; i--) {
    if (A % i == 0 && B % i == 0) {
      res = i;
      count++;
    }
  }

  cout << res << "\n";
}


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

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		// 整数の入力
		int have = sc.nextInt();
		int choise = sc.nextInt();
		int[] stick = new int[have];
		for(int i=0;i<have;i++){
			stick[i] = sc.nextInt();
		}
		Arrays.sort(stick);
		for(int j = 0;j<choise;j++){
			sum += stick[have-1-j];
		}

		System.out.println(sum);
	}
}

Measured memory_bytes: 21332
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss 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++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n;
    n=n%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9)
    cout<<"hon";
    else if(n==0 || n==1 || n==6 || n==8)
    cout<<"pon";
    else if(n==3)
    cout<<"bon";
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10632
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll n=in(),m=in(),k=in();
    vector<ll>sa(n+1),sb(m+1);
    for(ll i=0;i<n;++i)sa[i+1]=in()+sa[i];
    for(ll i=0;i<m;++i)sb[i+1]=in()+sb[i];

    ll ans=0;

    ll idxa=n,idxb=0;
    while(idxa>=0&&idxb<=m){
        if(sa[idxa]>k){
            --idxa;
        }else if(sa[idxa]+sb[idxb]<=k){
            ans=max(ans,idxa+idxb);
            idxb++;
        }else{
            --idxa;
        }
    }

    idxa=0,idxb=m;
    while(idxa<=n&&idxb>=0){
        if(sb[idxb]>k){
            --idxb;
        }else if(sa[idxa]+sb[idxb]<=k){
            ans=max(ans,idxa+idxb);
            idxa++;
        }else{
            --idxb;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 6428
#include<stdio.h>  
#include <bits/stdc++.h>
#include<stdlib.h>

using namespace std;

bool ok(int n) {
    stringstream ss;
    ss << n;
    string s;
    ss >> s;
    for(int i = 1; i < s.length(); i++) {
        if(s[i] != s[i - 1]) {
            return false;
        }
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    while(not ok(n)) {
        n++;
    }    
    cout << n;
}


Measured memory_bytes: 256
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
//#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 1e9, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
vector <int> v[N];

int dfs(int x, int y) {
	int ans = 0;
	for(auto u : v[x]) 
		if(u != y)
			ans ^= (dfs(u, x) + 1);
	return ans;
}

int32_t main() {
	use_fast;
	int n;
	cin >> n;
	for(int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	if(dfs(1, 0))
		cout << "Alice" << endl;
	else
		cout << "Bob" << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/



Measured memory_bytes: 19896
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[10101][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll k, t;
	cin >> k >> t;
	vector<ll>a(t);
	rep(i, t) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	ll ans = max((ll)0, a[0] - 1 - (k - a[0]));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  for(int N, M; cin >> N >> M && (N | M);) {
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    int mnn = inf, mn = inf, idx = -1;
    bool multiple = 0;

    rep(i, N) {
      if(mnn > v[i] * (M / v[i])) {
        mnn = v[i] * (M / v[i]);
        mn = v[i];
        idx = i;
        multiple = 0;
      } else if(mnn == v[i] * (M / v[i]) && mn > v[i]) {
        mn = v[i];
        idx = i;
        multiple = 0;
      } else if(mnn == v[i] * (M / v[i]) && mn == v[i]) {
        multiple = 1;
      }
    }

    if(multiple) {
      cout << N << endl;
    } else {
      cout << idx + 1 << endl;
    }

  }
  
  return 0;
}

Measured memory_bytes: 3116
import sys
input = sys.stdin.readline

# 抜き取るだけ抜き取ってから、自由に追加していくと思える
# 残す部分が「完成」している必要がある
# L,L+1,...,Rの左右が出来ているようなものを残せる

N = int(input())
P = [int(input()) for _ in range(N)]

p_to_i = {x:i for i,x in enumerate(P)}

max_rest = 1
# 各数字が右端に来るときの最大長を持つ
x = 1
for n in range(2,N+1):
    if p_to_i[n] > p_to_i[n-1]:
        x += 1
        if max_rest < x:
            max_rest = x
    else:
        x = 1

answer = N - max_rest
print(answer)

Measured memory_bytes: 34976
fun main(args: Array<String>) {
    val (X, Y, Z) = listOfInt()
    println("$Z $X $Y")
}


fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 38196
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);*/
//        string temp = ReadLine();
        int n = int.Parse(ReadLine());
        if(n<1000){
            WriteLine("ABC");
        }else{
            WriteLine("ABD");
        }
    }
}

Measured memory_bytes: 11092
H, W = map(int, input().split())
lst = [input() for _ in range(H)]
res = [[0 for i in range(W)] for j in range(H)]
x = [-1, -1, -1, 0, 0, 1, 1, 1]
y = [-1, 0, 1, -1, 1, -1, 0, 1]

for i in range(H):
    for j in range(W):
        if lst[i][j] == '#':
            res[i][j] = '#'
            for k in range(8):
                xk = i + x[k]
                yk = j + y[k]
                if 0<= xk < H and 0 <= yk < W:
                    if res[xk][yk] != '#':
                        res[xk][yk] += 1
for row in res:
    for i in row:
        print(i, end='')
    print('')

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

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

    int N;
    cin >> N;

    if(N / 10 == 9 || N % 10 == 9) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
void main() {
  problem();
}

void problem() {
  const N = scan!int;
  const K = scan!long;
  const A = scan!int(N);

  int solve() {
    int[int] visited;
    int[] stack = new int[N];

    {
      int next = A[0];
      foreach(i; 0..N) {
        if (i == K - 1) return next;

        stack[i] = next;
        visited[next] = i;
        next = A[next - 1];

        if (next in visited) {
          stack.length = i + 1;
          break;
        }
      }
    }

    const loopBackIndex = visited[A[stack.back - 1]];
    const loopSize = stack.length - loopBackIndex;
    const loopStep = (K - stack.length - 1) % loopSize;
    return stack[loopBackIndex..$][loopStep];
  }

  solve.writeln();
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");
import std.bigint, std.functional;

// -----------------------------------------------


Measured memory_bytes: 23936