akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
#define GROUND 0
#define WALL 9000
#define INITIAL -1

int count();
void init();
void map();
void mark_n(int,int,int,int,int);
void mark_n_all(int);
bool isValidPoint(int,int);

using namespace std;
const int MAX_W = 20;
const int MAX_H = 20;
char floor_[MAX_W][MAX_H];
//floorツつセツづ算ツ術ツ甘鳴青板づ債ャツつエツづゥ
int step[MAX_W][MAX_H];
int width,height;

int main(){
  //  char floor[MAX_W][MAX_H];
  //int step[MAX_W][MAX_H];
  
  while(cin >> width >> height && width > 0){
    string line;
    int ix,iy;
    //cout << width << " " << height << endl;
    init();
    for(int i = 0; i < height; i++){
      cin >> line;
      for(int j=0; j < width ; j++){
	floor_[j][i] = line[j];
	if(line[j]=='@'){
	  step[j][i]=GROUND;
	  ix = j; iy = i;
	}else if(line[j]=='#'){
	  step[j][i]=WALL;
	}
	//cout << step[j][i];
      }
      //cout << endl;
    }
    //cout << count('.') << count('#') << count('@') << endl;
    for(int k = 0; k < 400; k++){
      //map();
      mark_n_all(k);
      //mark_n(k+1,ix,iy,1,0);
      //cout << endl;
      //map();
      
      //cout << endl;
    }
    cout << count() << endl;
  }
  
}

int count(){
  int result =0;
  for(int i=0; i<height;i++){
    for(int j=0; j< width; j++){
      if(step[j][i] >= 0 && step[j][i] < WALL){
	result++;
      }
    }
  }
  return result;
}

void init(){
  for(int i=0; i<height;i++){
    for(int j=0; j< width;j++){
      step[j][i]=INITIAL;
    }   
  }
}

void map(){
  for(int i = 0; i < height; i++){
    for(int j=0; j < width ; j++){
      cout << setw(3)<< step[j][i] << " ";
    }
    cout << endl;
  }
}

void mark_n(int n,int x,int y,int dx,int dy){
  int temp;
  for(int i =0; i< 4;i++){
    temp = dx;
    dx = dy;
    dy = -temp;
    //cout << isValidPoint(x+dx,y+dy) << " " << x+dx << y+dy << endl;
    if(isValidPoint(x+dx,y+dy) && step[x+dx][y+dy]==INITIAL){
      //cout << isValidPoint(x+dx,y+dy) << " " << x+dx << y+dy << endl;
      step[x+dx][y+dy] = n;
    }
  }
}


void mark_n_all(int n){
  for(int i = 0; i < height; i++){
    for(int j = 0; j < width ; j++){
      if(step[j][i]==n){
	//	cout << j <<" " << i << "jツづツづ個値"<< endl;
	mark_n(n+1,j,i,1,0);
      }
    }
  }
}



bool isValidPoint(int x,int y){
  if(x < 0 || x >=  width || y < 0 || y >= height){
    return false;
  }else{
    return true;
  }
}

Measured memory_bytes: 928
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ll t;cin>>t;
	while(t-->0)
    {
    }*/
    int a;cin>>a;
    int x=a%10;
    if(x==2 || x==4 || x==5 || x==7 || x==9)
    {
        cout<<"hon"<<"\n";
    }
    else if(x==0 || x==1 || x==6 || x==8)
    {
        cout<<"pon"<<"\n";
    }
    else
    {
        cout<<"bon"<<"\n";
    }
}


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

  ll ans = 0;
  int x = 0;
  while(!q.empty()){
    LP p = q.top();
    q.pop();
    if(x%2 ==0){
      ans+=A[p.se];
    }else{
      ans-=B[p.se];
    }
    x++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3956
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{   int i,H,W,N,n,MAX;
    scanf("%d %d %d",&H,&W,&n);
    if(H>W)MAX=H;
    else MAX=W;
    int ans=0,sum=0;
    while(sum<n)sum+=MAX,ans++;
   printf("%d",ans);

    return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 5005;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

int N, M, Q;
int A[101010];
int did[101010];
int ind[101010];
vector<int> V;
int num[101010];

void solve() {
	int i, j, k, l, r, x, y; string s;

	cin >> N >> M >> Q;
	rep(i, 0, Q)
	{
		cin >> A[i];
	}
	for (i = Q - 1; i >= 0; i--)
	{
		did[A[i]]++;
		if (did[A[i]] == 1)
		{
			ind[A[i]] = V.size();
			V.push_back(A[i]);
		}
	}
	rep(i, 0, M)
	{
		if (did[i + 1] == 0)
		{
			ind[i + 1] = V.size();
			V.push_back(i + 1);
		}
	}

	while (V.size() >= 2 && V[V.size() - 2]<V[V.size() - 1]) V.pop_back();
	V.pop_back();

	num[0] = N;
	for (i = Q - 1; i >= 0; i--) 
	{
		if (num[ind[A[i]]])
		{
			num[ind[A[i]]]--;
			num[ind[A[i]] + 1]++;
		}
	}

	rep(i, 0, V.size())
	{
		if (num[i])
		{
			printf("No\n");
			return;
		}
	}
	printf("Yes\n");
}

int main()
{
	solve();
	return 0;
}




Measured memory_bytes: 2296
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <map>

using namespace std;

long dp[400][400];
const long INF = 1e+15;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    long a[400];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        dp[i][i] = 0;
    }
    for(int i = 1; i < N; i++){
        for(int j = 0; i+j < N; j++){
            long sum = 0;
            dp[j][i+j] = INF;
            for(int k = 0; k <= i; k++){
                sum += a[j+k];
            }
            for(int k = 0; k+1 <= i; k++){
                dp[j][i+j] = min(dp[j][i+j], dp[j][j+k]+dp[j+k+1][j+i]);
            }
            dp[j][i+j] += sum;
            //cout << j << ' ' << i+j << ' ' << sum << ' ' << dp[j][i+j] << endl;
        }
    }
    cout << dp[0][N-1] << endl;
}

Measured memory_bytes: 1536
from collections import deque
S = deque(input())
Q = int(input())
state = 0
for i in range(Q):
  m = input().split()
  if len(m)==1:
    state = (state+1)%2
  else:
    f = m[1]
    if f=='1':
      if state == 1:
        S.append(m[2])
      else:
        S.appendleft(m[2])
    else:
      if state==1:
        S.appendleft(m[2])
      else:
        S.append(m[2])
if state ==1:
  S = list(S)[::-1]
print(''.join(S))

Measured memory_bytes: 76172
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def linearSearch(A, key):
	n = len(A) - 1
	i = 0
	A[n] = key # 番兵
	while (A[i] != key):
		i += 1
	return i != n

cnt = 0
for i in range(q):
	key = T[i]
	if linearSearch(S, key):
		cnt += 1

print(cnt)


Measured memory_bytes: 6552
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
long long int N,M,K,res=0,A,B;
string S;

int main()
{
    cout << fixed << setprecision(18);
    cin>>K>>A>>B;
    if(B/K*K>=A){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    int k;
    cin >> k;
    queue<long long> que;
    for(int i = 1; i < 10; i++) que.push(i);
    int num = 0;
    while(!que.empty()){
        long long now = que.front();
        que.pop();
        num++;
        if(num == k){
            cout << now << endl;
            return 0;
        }
        if(now%10 != 0){
            que.push(10*now + now%10 -1);
        }
        que.push(10 * now + now%10);
        if(now%10 != 9){
            que.push(10 * now + now%10 +1);
        }
    }
    return 0;
}

Measured memory_bytes: 5124
N = int(input())
MOD = 10**9 + 7

n9 = 1
n8 = 1
n10 = 1

for i in range(N):
    n9 = (n9*9)%MOD
    n8 = (n8*8)%MOD
    n10 = (n10*10)%MOD

ans = n10 - 2*n9 + n8
print(ans%MOD)

Measured memory_bytes: 63424
h, w = map(int, input().split())
ma=[]

for _ in range(h):
    ma.append(list(str(input())))

add = ['.'] * w

ma.insert(0, add)
ma.insert(h+1, add)


for ad in range(h+1):
    ma[ad].insert(0, '.')
    ma[ad].insert(w+1, '.')

for high in range(1, h):
    for wid in range(1, w) :
        j_1 = False
        j_2 = False
        if ma[high][wid] == '#' :
            j_1 = True

        if j_1 == True :
            if ma[high][wid-1] == '#' or ma[high][wid+1] == '#' or ma[high-1][wid] == '#' or ma[high+1][wid] == '#' :
                j_2=True
            if j_2 == False :
                print('No')
                exit()

print('Yes')

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

using namespace std;

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

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

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

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

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

  i64 n, m;
  cin >> n >> m;
  if (n == 1 && m == 1) cout << 1 << "\n";
  else if (n == 1) cout << m - 2 << "\n";
  else if (m == 1) cout << n - 2 << "\n";
  else cout << (n - 2) * (m - 2) << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

const int maxd = 50010;

ll a, b, d;
struct state{
  int x, y, v;

  state() : x(0), y(0), v(0){}
  state(int x, int y, int v) : x(x), y(y), v(v) {}
  friend bool operator>(const state &s1, const state &s2){
    if(s1.x + s1.y == s2.x + s2.y) {
      return a * s1.x + b * s1.y > a * s2.x + b * s2.y;
    }else{
      return s1.x + s1.y > s2.x + s2.y;
    }
  }
};

state st[maxd];

int main(){

  while(cin >> a >> b >> d && a + b + d > 0){
    priority_queue<state, vector<state>,  greater<state> > que;
    fill(st, st + maxd, state(INF, INF, 0));
    st[0] = state(0, 0, 0);

    que.push(state(0, 0, 0));
    while(!que.empty()){
      state s = que.top(); que.pop();
      int x = s.x;
      int y = s.y;
      int v = s.v;
      
      if(s > st[v]) continue;
      if(v == d){
        cout << s.x << " " << s.y << endl;
        break;
      }

      for(int i = -1; i <= 1; i++){
        int w = v + i * a;
        if(0 <= w && w < maxd){
          state t(x + 1, y, w);
          if(st[w] > t){
            st[w] = t;
            que.push(t);
          }
        }

        int u = v + i * b;
        if(0 <= u && u < maxd){
          state t(x, y + 1, u);
          if(st[u] > t){
            st[u] = t;
            que.push(t);
          }
        }
      }
        
      
      
      
    }
    
    
  }
  return 0;
}

Measured memory_bytes: 1788
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int a[] = new int[4];
			boolean flg = true;
			for(int i=0;i<4;i++) { a[i] = sc.nextInt(); flg &= a[i] == 0; }
			if(flg) break;
			
			Permutation p = new Permutation(a);
			String form = "" + 0;
			for(;p.hasNext();) {
				for(int i=0;i<3;i++) for(int j=0;j<3;j++) for(int k=0;k<3;k++) {
					int ans = 0;
					System.arraycopy(p.next(), 0, a, 0, 4);
					ans = calc(a[0], a[1], i);
					ans = calc(ans, a[2], j);
					ans = calc(ans, a[3], k);
//					debug(ans(a, i, j, k) + "=" + ans);
					if(ans == 10) {
						form = ans1(a, i, j, k);
					}
					
					ans = calc(a[0], a[1], i);
					int tmp = calc(a[2], a[3], k);
					ans = calc(ans, tmp, j);
					if(ans == 10) form = ans2(a, i, j, k);
				}
			}
			System.out.println(form);
		}
	}
	
	int calc(int a, int b, int op) {
		if(op == 0) return a+b;
		if(op == 1) return a-b;
		return a*b;
	}
	
	String ans1(int[] a, int op1, int op2, int op3) {
		String ans = "(((" + a[0];
		int[] ops = {op1, op2, op3};
		for(int i=0;i<3;i++) {
			if(ops[i] == 0)ans += " + " + a[i+1] + ")";
			if(ops[i] == 1)ans += " - " + a[i+1] + ")";
			if(ops[i] == 2)ans += " * " + a[i+1] + ")";
		}
		return ans;
	}
	
	String ans2(int[] a, int op1, int op2, int op3) {
		char[] ops = {'+', '-', '*'};
		String ans = "((" + a[0] + " " + ops[op1] + " " + a[1] + ") " + ops[op2] + " (" + a[2] + " " + ops[op3] + " " + a[3] + "))";
		return ans;
	}
	
	class Permutation {
		int[] a;
		boolean isFirst;
		Permutation(int[] s) {
			a = new int[s.length];
			System.arraycopy(s, 0, a, 0, s.length);
			sort(a);
			isFirst = true;
		}
		
		boolean hasNext() {
			if(isFirst) {
				isFirst = false;
				return true;
			}
			
			int n = a.length;
			for(int i=n-1;i>0;i--) {
				if(a[i-1] < a[i]) {
					int j = n;
					while(a[i-1] >= a[--j]);
					swap(a, i-1, j);
					reverse(a, i, n);
					return true;
				}
			}
			reverse(a, 0, n);
			return false;
		}
		
		int[] next() {
			return a;
		}
		
		void swap(int[] a, int x, int y) {
			int tmp = a[x];
			a[x] = a[y];
			a[y] = tmp;
		}
		
		void reverse(int[]a, int from, int to) {
			while( from < --to ) swap(a, from++, to);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 20572
#include <iostream>
#include <iomanip>
#include <cmath>
#define PI 3.14159265358979323846264338327950L
using namespace std;
int main () {
	long double a, b, h, m;
	cout << fixed;
	cout << setprecision(15);
	cin >> a >> b >> h >> m;
	long double rad = 2 * PI * (h/12.0 + (m/60.0)/12.0 - m/60.0);
	long double dist = (a*a + b*b) - (2*a*b) * cos(rad);
	cout << sqrt(dist) << endl;
}

Measured memory_bytes: 4132
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<Integer> d = new HashSet<>();
        for (int i=0; i<n; i++) {
            int di = sc.nextInt();
            d.add(di);
        }
        System.out.println(d.size());
        sc.close();
    }
}

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

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

	string result = "";
	switch(D)
	{
	case 22:
		result = "Christmas Eve Eve Eve";
		break;
	case 23:
		result = "Christmas Eve Eve";
		break;
	case 24:
		result = "Christmas Eve";
		break;
	case 25:
		result = "Christmas";
		break;
	}

	cout << result <<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) printf("%d ", v[X]); printf("\n");
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
const int MOD=1e9+7;
const ll LINF=0x3f3f3f3f3f3f3f3f;
ll n;
ll a[55];

bool ok2(ull qte, ull k, ull v) {
  return (v + k + 1ll <= qte * (ull)n + n + qte);
  //return (v - qte * n + (k - qte) <= n - 1ll);
}

ll bb2(ll b, ll e, ll k, ll v) {
  if(b >= e) return b;
  ll mid = (b + e) / 2ll;
  if(ok2(mid, k, v)) return bb2(b, mid, k, v);
  return bb2(mid + 1ll, e, k, v);
}

bool ok(ll k) {
  ll qte = 0;
  for(int i = 0; i < n; i++) {
    ll tmp = bb2(0, k, k, a[i]);
    qte += tmp;
    if(!ok2(tmp, k, a[i])) return false;
  }
  return (qte <= k);
}

ll bb(ll b, ll e) {
  if(b >= e) return b;
  ll mid = (b + e) / 2ll;
  if(ok(mid)) return bb(b, mid);
  return bb(mid + 1ll, e);
}

int main() {
  cin>>n;
  for(int i = 0; i < n; i++) {
    cin>>a[i];
  }
  ll resp = bb(0ll, 520000000000000000ll);
  for(ll k = max(resp - 100000ll, 0ll); k <= (resp + 100000ll); k++) {
    if(ok(k)) {
      cout<<k<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using static System.Math;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var N = ReadLineInt();
			var pmax = long.MinValue;
			var pmin = long.MaxValue;
			var mmax = long.MinValue;
			var mmin = long.MaxValue;
			
			for (int i = 0; i < N; i++)
			{
				var line = ReadLineLongSplit();
				var x = line[0];
				var y = line[1];
				pmax = Max(pmax, x+y);
				pmin = Min(pmin, x+y);
				mmax = Max(mmax, x-y);
				mmin = Min(mmin, x-y);
			}
			Console.WriteLine(Max(pmax-pmin, mmax-mmin));
		}

		public static long Gcd(long a, long b)
		{
			if (a < b) return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
			return a;
		}

		public static int nCm(int n, int m)
		{
			if (n == 0) return 0;
			if (m == 0) return 1;
			return n * nCm(n - 1, m - 1) / m;
		}

		public static string ReadLine()
		{
			return Console.ReadLine();
		}

		public static int ReadLineInt()
		{
			return int.Parse(ReadLine());
		}

		public static long ReadLineLong()
		{
			return long.Parse(ReadLine());
		}

		public static string[] ReadLineStringSplit(char s = ' ')
		{
			return ReadLine().Split(s).ToArray();
		}

		public static int[] ReadLineIntSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => int.Parse(x)).ToArray();
		}

		public static long[] ReadLineLongSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => long.Parse(x)).ToArray();
		}
	}
}

Measured memory_bytes: 23004
#include <iostream>

using namespace std;

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

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

int main(){
    int n;
    cin >> n;
    
    vector<int> p(n), p_sort(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p_sort[i] = p[i];
    }

    stable_sort(p_sort.begin(), p_sort.end());

    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(p[i] != p_sort[i]) cnt++;
    }

    if(cnt <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;

int main(){
    string S;
    cin >> S;
    int N = S.length();
    int cnt0 = 0;
    int cnt1 = 0;
    rep(i,N){
        if(S.at(i) == '0') cnt0++;
        else cnt1++;
    }
    cout << min(cnt0,cnt1) * 2 << endl;
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second

using namespace std;

int main() {
	//ifstream cin("tst.in");
	//ofstream out("tst.out");
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int x, y;
	cin >> x >> y;
	cout << x + y / 2;
	return 0;
}

Measured memory_bytes: 256
"""
int #整数
float #小数

#標準入力
a=input()
a,b=map(int,input().split()) #入力は行ごと
#標準出力
print(a)
ptrint("Hello")
#for
for name in fruits: #fruitの頭から操作
    print(name)
#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1 = list(map(int, input().strip().split()))　# 複数の入力をリストに入れる
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
list5.count(2) #リスト内の2の数
abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値

extension_1 = []
for i in range(10):
    extension_1.append(i)
extension_1
#>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

comprehension_1= [i for i in range(10)]
comprehension_1
#>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
"""
import math
a,b,c,d,e=map(int,input().split())

if a==0:
    print("1")
elif b==0:
    print("2")
elif c==0:
    print("3")
elif d==0:
    print("4")
else:
    print("5")

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000



int main(){
	
	long long A;
	cin>>A;
	
	double B;
	cin>>B;
	
	B*=100;
	long long b = round(B);
	
	A *= b;
	cout<<A/100<<endl;
	
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll s[252525];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a[252525];
	cin>>n;
	REP(i, n){
		cin>>a[i];
		s[i+1]=s[i]+a[i];
	}
	int l=0, r=2;
	ll ans=s[n];
	FOR(i, 1, n-2){
		ll bc=s[i+1];
		ll de=s[n]-s[i+1];
		ll b=s[l+1];
		ll d=s[r+1]-s[i+1];
		while(b*2<bc){
			++l;
			b+=a[l];
		}
		ll tmpb=b-a[l];
		if(abs(bc-2*b)>abs(bc-2*tmpb) && l-1>=0 && l-1<i){
			--l;
			b=tmpb;
		}
		while(d*2<de){
			++r;
			d+=a[r];
		}
		ll tmpd=d-a[r];
		if(abs(de-2*d)>abs(de-2*tmpd) && r-1>i){
			--r;
			d=tmpd;
		}
		ans=min(ans, (max({b, bc-b, d, de-d})-min({b, bc-b, d, de-d})));
		// DEBUG(b);
		// DEBUG(bc-b);
		// DEBUG(d);
		// DEBUG(de-d);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#define ll long long
#define ull unsigned long long
const double PI=4*atan(1);
using namespace std;
using boost::multiprecision::cpp_int;
#define MAX 1000000000000000000

long findmin(long a,long b) {
    return a<b?a:b;
}
long findmax(long a,long b) {
    return a>b?a:b;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long n;
    cin>>n;
    ull a[n];
    cpp_int prod=1;
    for(long i=0;i<n;i++) {
		cin>>a[i];
		if(a[i]==0) {
			cout<<"0\n";
			cout.flush();
			return 0;
		}
	}
	for(long i=0;i<n;i++) {
		prod*=a[i];
		if(prod>MAX) {
			cout<<"-1\n";
			cout.flush();
			return 0;
		}
	}
	if(prod>MAX) {
		cout<<"-1\n";
		//return 0;
	}
	else {
		cout<<prod<<"\n";
	}
    cout.flush();
	return 0;
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define int  long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
 
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >   
#define vpl vector< pair<ll,ll> >   
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
//#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double
#define inf 1000000000
bool less_vectors(const vector<int>& a,const vector<int>& b) 
{
  return a.size() < b.size();
}
#define N 500000
#define eps 0.0000000001
int calc(int n)
{
    int sum=0;
    while(n>0)
    {
        sum+=n%10;
        n/=10;

    }
    return sum;
}
int32_t main()
{                
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif*/
    int n;
    cin>>n;
    int ans=1e5;
    for(int i=1;i<=n/2;i++)
    {
        ans=min(ans,calc(i)+calc(n-i));
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

int main(void) {
  int num;
  stack<int> stk;

  while(cin >> num) {
    if(num == 0) {
      cout << stk.top() << endl;
      stk.pop();
    }
    else {
      stk.push(num);
    }
  }
  return 0;
}

Measured memory_bytes: 1200
n = int(input())

name = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
cnt = []

while n != 0:
    cnt.append(n%26)
    n = n//26

for i in range(0, len(cnt)-1):
    if cnt[i] <= 0:
        cnt[i] += 26
        cnt[i+1] -= 1
cnt.reverse()
if cnt[0] == 0:
    del cnt[0]

ans = ""
for i in cnt:
    ans += name[i-1]

print(ans)


Measured memory_bytes: 61884
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int n,m;
struct qq
{
int  p,c;
}s[15];
int f[1000005];
int sum=0;
int main()
{
	scanf("%d%d",&n,&m);m/=100;

	memset(f,63,sizeof(f));	f[0]=0;
	for (int u=1;u<=n;u++)		
	{
		scanf("%d%d",&s[u].p,&s[u].c);
		s[u].c/=100;
		sum=sum+s[u].p*u+s[u].c;
	}
	for (int u=1;u<=n;u++)
		for (int i=sum;i>=0;i--)
		{
			if (i>=u*s[u].p+s[u].c)	f[i]=min(f[i],f[i-u*s[u].p-s[u].c]+s[u].p);
			for (int j=1;j<s[u].p;j++)	
			{
			//	if (i==2) printf("YES%d %d\n",j,i-u*j);
				if (i>=u*j) 	f[i]=min(f[i],f[i-u*j]+j);
			}
		//	printf("%d %d %d\n",i,f[i],u*s[u].p+s[u].c);
		}
	int ans=f[m];
	for (int u=m+1;u<=sum;u++) ans=min(ans,f[u]);
	printf("%d\n",ans);
	return 0;
}

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

#define all(x) x.begin(),x.end()
#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd+nd+1)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline int read(){
    int res=0, f=1;char ch=getchar();
    while(ch<'0'|ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 200'005;

const int MOD = 1000000007;

void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}

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

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


int main(){
    double r;cin>>r;
    cout<<acos(-1.0)*2*r<<endl;

    return 0;
}


Measured memory_bytes: 3776
n, m = map(int, input().split())
a = []
b = []
c = []
d = []

for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

for _ in range(m):
    x, y = map(int, input().split())
    c.append(x)
    d.append(y)

ans = []
for i in range(n):
    dist = 10**9
    toward = -1
    for j in range(m):
        if abs(a[i] - c[j]) + abs(b[i] - d[j]) < dist:
            dist = abs(a[i] - c[j]) + abs(b[i] - d[j])
            toward = j + 1
    ans.append(toward)
for i in range(n):
    print(ans[i])

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        String s = scan.next();
        String result;
        if(s.length() <= k) {
            result = s;
        } else {
            result = s.substring(0, k) + "...";
        }
        System.out.println(String.valueOf(result));

    }
}

Measured memory_bytes: 38576
/*input
3
1 0 0 

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

// ALL DEFFINES HERE
#define ll long long int
#define ii pair<int, int>
#define mp make_pair

#define rep(i, n) for(int i=0; i < n; i++)
#define Rep(i, k, n) for(int i=k; i < n; i++)
#define pb push_back
#define vi vector<int>
#define vii vector< vector<int> >
#define vl vector<ll>
#define F first
#define S second
#define all(v) v.begin(), v.end()

// ALL declarations here const ints etc
const  ll mod = 1e9+7; 
// const int MAXN = 1e5;

// IMPORTANT FUNCTION DECLARATIONS , 
//SORRY FOR THE BAD PRESENTATION
ll gcd(ll a, ll b)
{
	if ( b==0)
		return a;
	return gcd(b, a%b);
}
ll absl(ll a )
{
	return  a>= 0 ?a:-a;
}
ll maxl(ll a, ll b)
{
	return a >= b? a:b;
}
ll minl(ll a, ll b)
{
	return a <= b? a:b;
}
ll exp(ll a, ll n)
{
	if ( n==0)
		return 1;
	if ( n==1 )
		return a;
	if ( n & 1)
		return (a%mod * exp((a*a)%mod, n/2)%mod)%mod;
	else
		return exp((a*a)%mod, n/2)%mod;
}
// --->>> main starts here
// m*h >= l + k
double mi( double a , double b)
{
	return a < b? a : b;
}
double mx( double a , double b)
{
	return a >= b ? a : b;
}

void solve()
{
	
	int n;
	cin >> n;
	vector<int> v(n+1 , 0);
	for ( int i =1 ; i <= n ; i++) 
		cin >> v[i];
	vector<int> b(n+1, 0);
	//for ( int i= n/2; i <= n ; i++)
	//	if ( v[i]) b[i] =1;
	for ( int i =n ; i > 0 ; i--)
	{
		int sum =0;
		

		for ( int j =i;  j <= n; j+=i)
			sum+=b[j];
		// sum is the total multiples including i
		// cout << i << " " << sum << "\n";
		if ( sum % 2 != v[i])
			b[i] =1;
		// else
			// b[i]=0;
	}
	// for ( int i = 1 ; i <= n ; i++)
	// 	cout << b[i] << " ";
	// cout << "\n";
	int sum = 0;
	for (int i = 1;  i <= n; i++)
		sum+= b[i];
	cout << sum << "\n";
	for( int i =1; i <= n; i++)
		if ( b[i] ) cout << i << " ";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  #ifdef debug
   auto beginProgram = chrono::steady_clock::now();
  #endif
  // int t; cin >> t;
  // while (t--) 
  {
  	// cal();
    solve();
  }
  #ifdef debug
  auto endProgram = chrono::steady_clock::now();
  std::chrono::duration<double> diff = endProgram - beginProgram;
  cout << "\nTime: " <<diff.count()*1000 << " ms\n";
  #endif
  return 0;
}

Measured memory_bytes: 2560
package main

import (
	"fmt"
)

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	var A1, A2, A3 int
	fmt.Scanf("%d%d%d", &A1, &A2, &A3)
	ans1 := abs(A2-A1) + abs(A3-A2)
	ans2 := abs(A3-A1) + abs(A2-A3)
	ans3 := abs(A1-A2) + abs(A3-A1)
	ans4 := abs(A3-A2) + abs(A1-A3)
	ans5 := abs(A1-A3) + abs(A2-A1)
	ans6 := abs(A2-A3) + abs(A1-A2)
	ans := ans1
	if ans2 < ans {
		ans = ans2
	}
	if ans3 < ans {
		ans = ans3
	}
	if ans4 < ans {
		ans = ans4
	}
	if ans5 < ans {
		ans = ans5
	}
	if ans6 < ans {
		ans = ans6
	}
	fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
#define For(i, a, b) for(register int i = a; i <= b; ++i)
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
char s[maxn];
int dp[maxn], sum[maxn], n, flag, trans[3] = {0, -1, -1};

void Add(int & a, const int &b) {
	a += b;if(a >= mod) a -= mod;
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1), dp[0] = 1;
	For(i, 1, n) sum[i] = (sum[i - 1] + (s[i] - 'a' + 1)) % 3;
	For(i, 2, n)
		if(s[i] == s[i - 1]) 
			{flag = 1; break;}
	if(!flag) return printf("1"), 0;
	int from; dp[0] = 1;
	For(i, 1, n) {
		if(!sum[i] && i < n) dp[i] = 1;
		//Add(dp[i], dp[i - 1]);
		from = trans[(sum[i] + 1) % 3];
		if(~from) Add(dp[i], dp[from]);
		from = trans[(sum[i] + 2) % 3];
		if(~from) Add(dp[i], dp[from]);
		trans[sum[i]] = i;
	}
	printf("%d", dp[n]);
	return 0;
}

Measured memory_bytes: 1024
/**
*    created: 07.07.2020 14:58:41
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int r, g, b; cin >> r >> g >> b;
    int t = 10 * g + b;
    if (t % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3648
n,l=map(int,input().split())

al = [i + l - 1 for i in range(1, n+1)]
res=100000
ans=0
total = sum(al)

for i in range(0, len(al)):
    if abs(total - (total - al[i])) < res:
        res = abs(total - (total - al[i]))
        ans = total - al[i]
        
        
print(ans)

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int a, b;
    cin >> a >> b;
    if(a == b) cout << "Draw" << endl;
    else{
        if(a == 1) cout << "Alice" << endl;
        else if(b == 1) cout << "Bob" << endl;
        else{
            if(a > b) cout << "Alice" << endl;
            else cout << "Bob" << endl;
        }
    } 

    return 0;
}

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

using namespace std;

#pragma GCC optimize("O3")
static const auto __ = [] {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    return nullptr;
}();

int main(int argc, char* argv[]) {
    int a;
    cin >> a;
    cout << a  + a * a + a * a * a << '\n';
    return 0;
}

Measured memory_bytes: 3588
// AOJ 2166: Erratic Sleep Habits
// 2018.1.4 bal4u@uu

#include <stdio.h>
#include <string.h>

int T;
int t[31];
char tbl[101];
int dp[101][101];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int calc(int d, int c)
{
	int i, k, c2, ans;

	if (d > 100) return 0;
	if (dp[d][c] >= 0) return dp[d][c];
	i = d+1;
	ans = 1+calc(i, 0), c2 = c;
	while (1) {
		if (i > 100) { ans = 0; break; }
		if (++c2 == T) c2 = 0;
		if (tbl[i] < t[c2]) break;
		k = 1+calc(++i, 0);
		if (k < ans) ans = k;
	}
	return dp[d][c] = ans;
}

int main()
{
	int N, d, m, i;

	while (T = in()) {
		for (i = 0; i < T; i++) t[i] = in();
		N = in();
		memset(tbl, 24, sizeof(tbl));
		for (i = 0; i < N; i++) {
			d = in(), m = in();
			if (m < tbl[d]) tbl[d] = m;
		}

		memset(dp, -1, sizeof(dp));
		printf("%d\n", calc(1, 0));
	}
	return 0;
}



Measured memory_bytes: 1684
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

import numpy as np

N = int(input())
AB = [[int(x) for x in input().split()] for _ in range(N)]
AB.sort(key=lambda x: x[1])  # Bを指標にsort

AB = np.array(AB)
A_cumsum = np.cumsum(AB[:, 0])
bool = (A_cumsum <= AB[:, 1]).all()
print('Yes' if bool else 'No')


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

bool check(string s) {
  stack<int> st;
  for (auto&& c : s) {
    if (c == '(' || c == '[') st.push(c);
    if (c == ')' || c == ']') {
      if (st.empty()) {
        return false;
      } else {
        char t = st.top();
        st.pop();
        if (c == ')' && t != '(') return false;
        if (c == ']' && t != '[') return false;
      }
    }
  }
  return (st.size() == 0);
}

int main() {
  string s;
  while (getline(cin, s), !(s.length() == 1 && s[0] == '.')) {
    cout << (check(s) ? "yes" : "no") << endl;
  }
}



Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e7+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int h, w;
char field[100][100];
int dx[] = { 0, 1 };
int dy[] = { 1, 0 };

void solve(int y, int x){
	field[y][x] = '.';
	REP(i, 2){
		int nx = x + dx[i], ny = y + dy[i];
		if (nx >= 0 && nx < w&&ny >= 0 && ny < h){
			if (field[ny][nx] == '#'){
				solve(ny, nx);
				break;
			}
		}
	}
}

int main(){
	cin >> h >> w;
	REP(i, h){
		REP(j, w){
			cin >> field[i][j];
		}
	}
	solve(0, 0);
	REP(i, h){
		REP(j, w){
			if (field[i][j] == '#'){
				cout << "Impossible" << endl;
				return 0;
			}
		}
	}
	cout << "Possible" << endl;
}

Measured memory_bytes: 384
using System;

namespace abc147_b
{
    static class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var count = 0;
            var length = s.Length / 2;
            for (int i = 0; i < length; i++)
            {
                if (s[i] != s[s.Length - i - 1])
                {
                    count++;
                }
            }

            Console.WriteLine($"{count}");
        }

    }
}


Measured memory_bytes: 13268
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
bool comp(const complex<double> &left,const complex<double> &right){
    return arg(left) < arg(right);
}
int main() {
    ll n;
    std::cin >> n;
    vector<complex<double>> xy(n);
    for (int i = 0; i < n; i++) {
        double tx,ty;
        std::cin >> tx>>ty;
        complex<double> tc(tx,ty);
        xy[i] = tc;
    }
    double res = 0;
    sort(xy.begin(),xy.end(),comp);
    for (int i = 0; i < n; i++) {
        pair<double,double> now={xy[i].real(),xy[i].imag()};
        res = max(res, sqrt(now.first*now.first+now.second*now.second));
        for (int j = 1; j < n; j++) {
            now.first  += xy[(i+j)%n].real();
            now.second += xy[(i+j)%n].imag();
            res = max(res, sqrt(now.first*now.first+now.second*now.second));
        }
    }
    
    std::cout <<setprecision(20)<< res << std::endl;
}


Measured memory_bytes: 384
/*bismillah ->                                                                                                         << Suirkhanov Meyirlan >>
  GL HF


                                                                                                                      42

    bless my code =)
                                                                                                            NEVER FOLLOW YOUR RULES :D HAHAHAHA
*/


///scanf ("%d%d", &x, &y);
///printf("%d", &a)

#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define pii pair < int , int >
#define pll pair < ll, ll >
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define eb emplace_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll N = 2 * 1e3 + 7;
const ld pi = 3.14159265359;
const int INF = 1e20 + 7;
const double eps = 1e-9;

const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};

ll ans, n;

int main(){

  //freopen("bridge.in", "r", stdin);
  //freopen("bridge.out", "w", stdout);

  fast
  randoperation;

  ///           ||
  ///start here \/

  cin >> n;

  for(int i = 1; i <= n; i++){
    ans += i;
  }

  cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;

ll dp[105][100005];
vi w(100005),val(100005);
ll n;


int main()
{
    fastio;
        fr(j,0,100005)dp[0][j]=1e18;

        fr(i,0,105)dp[i][0]=0LL;
       // cout<<dp[0][0]<<endl;

        ll W;
        cin>>n>>W;

        ll s=0;
        fr(i,0,n)cin>>w[i]>>val[i],s+=val[i];


        fr(i,0,n)
        {
            fr(j,1,s+1)
            {
                if(j>=val[i])
                {
                    dp[i+1][j]=min(dp[i][j],w[i]+dp[i][j-val[i]]);
                }
                else dp[i+1][j]=dp[i][j];
            }
        }

            ll ans=0;
            fr(j,0,s+1)
            if(dp[n][j]<=W)ans=j;

            cout<<ans<<endl;














}




























Measured memory_bytes: 83564