akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

ll N, A, B;
ll h[100001];

bool enough(ll t) {
	ll cnt = 0;
	for (ll i = 0; i < N; i++) {
		ll _h = (h[i] - B*t);
		if (_h <= 0) continue;
		cnt += _h / (A - B);
		if (_h % (A - B) != 0) cnt++;
	}
	return cnt <= t;
}

void solve() {
	cin >> N >> A >> B;
	for (ll i = 0; i < N; i++) cin >> h[i];
	// (lb, ub]
	ll lb = 0, ub = 1000000000;
		
	while (ub - lb > 1) {
		ll mid = (lb + ub) / 2;
		if (enough(mid)) ub = mid;	//(lb, mid]
		else lb = mid;		//(mid, ub]
	}
	cout << ub << endl;
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int H, W, K;
int bfs(vector<string>& A, int x, int y, int n)
{
    int vx[] = {-1, +1, 0, 0};
    int vy[] = {0, 0, -1, +1};
    queue<tuple<int, int, int>> Q;
    Q.emplace(x, y, n);
    int ans = 1e9;
    while (!Q.empty()) {
        int x, y, n; tie(x, y, n) = Q.front(); Q.pop();
        if (n > 0) {
            for (int i = 0; i < 4; i++) {
                int newx = x + vx[i];
                int newy = y + vy[i];
                if (0 <= newx && newx < W && 0 <= newy && newy < H
                    && A[newy][newx] == '.') {
                    A[newy][newx] = '$';
                    Q.emplace(newx, newy, n-1);
                }
            }
        }
        ans = min({
            ans,
            (abs(x) + K - 1) / K + 1,
            (abs(x - (W - 1)) + K - 1) / K + 1,
            (abs(y) + K - 1) / K + 1,
            (abs(y - (H - 1)) + K - 1) / K + 1,
        });
    }
    return ans;
}
int main()
{
    cin >> H >> W >> K;
    vector<string> A(H);
    for (auto& a : A) cin >> a;
    int sx = 0, sy = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == 'S') {
                sy = i, sx = j;
            }
        }
    }
    cout << bfs(A, sx, sy, K) << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main()
{
  long long int i,n,a[1000000],sum=0; 
    cin>>n;
    for(i=0;i<n;i++)
    {
      cin>>a[i];
    }
  for(i=0;i<n-1;i++)
  {
    if(a[i]>a[i+1])
    {
      sum=sum+a[i]-a[i+1];
      a[i+1]=a[i];
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 5120
N,M,X,Y=map(int,input().split())
Listx=list(input().split())
for i in range(N):
    Listx[i]=int(Listx[i])
Listx.sort()
Listy=list(input().split())
for i in range(M):
    Listy[i]=int(Listy[i])
Listy.sort()
low=max(X,Listx[N-1])
hight=min(Y,Listy[0])
if low<hight:
    print('No War')
else:
    print('War')


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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class FPathPassI {
public:

    vector<int> graph[200005];
    vector<ll> ans;
    vector<ll> color;
    vector<ll> cnt;
    ll all = 0;

    ll dfs(int v, int pa) {
      ll child = 1;
      ll before = cnt[color[v]];
      for(auto e: graph[v]) {
        if (e == pa) continue;
        ll pre = all-cnt[color[v]];
        child += dfs(e, v);
        ll nxt = all-cnt[color[v]];
        ans[color[v]] -= (nxt-pre+1)*(nxt-pre)/2;
      }
      cnt[color[v]] = before + child;
      all++;
      return child;
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n; cin >> n;
      color.resize(n);
      ans.resize(n, n*(n+1)/2);
      cnt.resize(n);
      rep(i, n) {
        cin >> color[i];
        color[i]--;
      }
      rep(i, n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
      }

      dfs(0, -1);

      rep(i, n) {
        ll pre = 0;
        ll nxt = n - cnt[i];
        ans[i] -= (nxt-pre+1)*(nxt-pre)/2;
      }

      rep(i, n) {
        cout << ans[i] << '\n';
      }
    }
};

signed main() {
  FPathPassI solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int memo[1000000];
int res(int n) {
  if(n == 0) return 0;
  if(memo[n] != -1) return memo[n];
  int ans = n;
  for(int i = 1; i <= n; i *= 6) {
    ans = min(ans, res(n - i) + 1);
  }

  for(int i = 1; i <= n; i *= 9) {
    ans = min(ans, res(n - i) + 1);
  }

  return memo[n] = ans;
}

int main() {
  
  int N; 
  cin >> N;
  for(int i = 0; i < 1000000; i++) {
    memo[i] = -1;
  }

  cout << res(N);
  
  return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>

int main(){
  
  int A[100],i,minj,n,j,x,count=0;
  
  scanf("%d",&n);
  
  for(i=0 ; i<n ; i++)
    {
      scanf("%d",&A[i]);
    }
  
  for(i=0 ; i<n ; i++)
    {
      minj = i;
      for(j=i ; j<n ; j++)
	{
	  if(A[j] < A[minj]){
	    minj=j;
	  }
	}
      x=A[i];
      A[i]=A[minj];
      A[minj]=x;
      if(minj != i)count++;
    }
  
  for(i=0 ; i<n ; i++){
    printf("%d",A[i]);
    if( i != n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

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

int n, k, d, x, ans, v[105];
int main() {
	cin >> n >> k;
	while(k--) {
		cin >> d;
		while(d--) cin >> x, v[x] = 1;
	}
	for(int i=1; i<=n; i++) ans += !v[i];
	cout << ans;
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int cnt=0,a[3],ans=0;
    for(int i=0;i<3;i++)
    {
        cin>>a[i];
        if(a[i]==5)
        {
            cnt++;
        }
        else if(a[i]==7)
        {
           ans++;
        }
    }
    if((cnt==2)&&(ans==1))
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


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

int A,B,X;

int main () {
	cin >> A >> B >> X;
	if (A+B<X) {
		cout << "NO" << endl;
	} else if (A>X) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class Main {

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

	public void run() throws Exception {
		FastIO file = new FastIO();
		int n = file.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) a[i] = file.nextLong();
		long[] dp = new long[n];
		dp[1] = Math.abs(a[0] - a[1]);
		for (int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i - 1] + Math.abs(a[i] - a[i - 1]), dp[i - 2] + Math.abs(a[i] - a[i - 2]));
		}
		file.out.println(dp[n - 1]);
		file.out.flush();
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;
		PrintWriter out;

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		}

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

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

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

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

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

		void print(Object o) {
			out.print(o);
		}

		void println(Object o) {
			out.println(o);
		}

		void printf(String s, Object... o) {
			out.printf(s, o);
		}
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n % mod;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2, mod);
			return (temp * temp) % mod;
		} else {
			long temp = pow(n, (p - 1) / 2, mod);
			temp = (temp * temp) % mod;
			return (temp * n) % mod;

		}
	}

	public static long pow(long n, long p) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2);
			return (temp * temp);
		} else {
			long temp = pow(n, (p - 1) / 2);
			temp = (temp * temp);
			return (temp * n);

		}
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}

	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
}


Measured memory_bytes: 35676
n = int(input())
MOD = 10**9+7
all_cnt = pow(10, n, MOD)
not_a = pow(9, n, MOD)
not_b = pow(9, n, MOD)
not_a_b = pow(8, n, MOD)
res = (not_a + not_b - not_a_b) % MOD
ans = (all_cnt - res) % MOD
print(ans)

Measured memory_bytes: 61616
#!/usr/bin/env python
# -*- coding: utf-8 -*-

input()
stones = input()
red_count = 0
for stone in stones:
	if stone == 'R':
		red_count += 1

white_count = 0
for stone in stones[:red_count]:
	if stone == 'W':
		white_count += 1

print(white_count)


Measured memory_bytes: 9252
import numpy as np
import math

# K = int(input())
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
# S = input() # String

N = int(input())
T = []
X = []
Y = []

for n in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

curT = 0
curX = 0
curY = 0
for n in range(N):
    nextT = T[n]
    nextX = X[n]
    nextY = Y[n]

    minD = abs(curX - nextX) + abs(curY - nextY)
    deltaT = nextT - curT

    # print('curT=', curT)
    # print('minD=', minD)
    if deltaT >= minD and ((deltaT - minD) % 2 == 0):
        curT = nextT
        curX = nextX
        curY = nextY
    else:
        print('No')
        exit(0)

print('Yes')


Measured memory_bytes: 21516
#include <iostream>
#include <cstdio>
#include<string.h>
using namespace std;
int main()
{
   int a,b,c,x;
   int ans=0;
   scanf("%d%d%d%d",&a,&b,&c,&x);
   for(int i=0;i<=a;i++)
   {
       for(int j=0;j<=b;j++)
       {
           for(int m=0;m<=c;m++)
           {
               int temp=i*500+j*100+m*50;
               if(temp==x)
                ans++;
               else if(temp>x)
                break;
           }
       }
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
dp = [0 for n in range(N)]
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
	dp[i] =  min(dp[i-1] + abs(H[i]-H[i-1]), dp[i-2] + abs(H[i]-H[i-2]))
print(dp[N-1])

Measured memory_bytes: 13908
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

int main(){
	int n;
	int price[4] = {10,50,100,500};
	cin >> n;
	if(!n)return 0;
	while(true){
		vector<int> coin(4);

		for(int i=0;i<4;i++){
			cin >> coin[i];
		}
		vector<int> min_coins(4,0);
		int min_ct = 100000;
		REP(i,coin[3]+1){
			REP(j,coin[2]+1){
				REP(k,coin[1]+1){
					REP(l,coin[0]+1){
						int ct = 0;
						int sum = i*price[3] + j*price[2] + k*price[1] + l*price[0];
						if(sum < n)continue;
						else{
							int change = sum - n;
							for(int p = 3;p>=0;p--){
								int change_ct = 0;
								while(change >= price[p]){
									change_ct++;
									change -= price[p];
								}
								ct += change_ct;
							}
							ct -= i + j + k + l;
							if(ct < min_ct){
								min_coins[0] = l;min_coins[1] = k;min_coins[2] = j;min_coins[3] = i;
								min_ct = ct;
							}
						}
					}
				}
			}
		}
		for(int i=0;i<4;i++){
			if(min_coins[i]){
				cout << price[i] << " " << min_coins[i] << endl;
			}
		}
		cin >> n;
		if(n)cout << '\n';
		else break;
	}

}

Measured memory_bytes: 3008
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int N;
  scanf("%d", &N);
  std::string S;
  std::cin >> S;
  std::vector<int > leftblack(N+4), rightwhite(N+4);
  // leftblack: index=i未満の黒石の合計数
  // rightwhite: index=i以上の白石の合計数
  leftblack[0]= 0;
  rightwhite[N] = 0;
  for (int i=1; i<=N; i++){
    leftblack[i] = leftblack[i-1];
    if (S[i-1]=='#') leftblack[i]++;
  }
  for (int i=N-1; i>=0; i--){
    rightwhite[i]=rightwhite[i+1];
    if (S[i]=='.') rightwhite[i]++;
  }
  
  int ans = 2*N;
  for (int i=0; i<=N; i++){
    ans = std::min(ans, leftblack[i]+rightwhite[i]);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2180
/*input
1717
*/
#include "bits/stdc++.h"
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	string s;
	cin>>s;
	int first = (s[0]-'0')*10 + s[1]-'0';
	int second = (s[2]-'0')*10 + s[3]-'0';

	if((!first && !second) || (first>12 && second>12) || (first>12 && !second) || (second>12&&!first))
		cout<<"NA";
	else if(first > 12 ^ first == 0)
		cout<<"YYMM";
	else if(second>12 ^ second == 0)
		cout<<"MMYY";
	else 
		cout<<"AMBIGUOUS";
}

Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

inline void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0, p; char f[7];
	while (x) {
		p = x; x /= 10;
		f[s++] = p - (x << 1) - (x << 3);
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003];
int h1[100003], h2[100003], h3[100003], h4[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int Q1[110000], Q1L, Q1R;
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	Q1[0] = 1; Q1R = 1;
	while (Q1R > Q1L) {
		int a1 = Q1[Q1L]; Q1L++;
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1[Q1R] = i; Q1R++;
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) h1[a[i]]++;
		if (dist[b[i]] > dist[a[i]]) h1[b[i]]++;
	}
	for (int i = 1; i <= n; i++)z[i].resize(h1[i]);
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) { z[a[i]][h2[a[i]]] = make_pair(b[i], d[i]); h2[a[i]]++; }
		if (dist[b[i]] > dist[a[i]]) { z[b[i]][h2[b[i]]] = make_pair(a[i], d[i]); h2[b[i]]++; }
	}
	for (int i = 1; i <= n; i++) h3[dist[i]]++;
	for (int i = 0; i <= n; i++) D[i].resize(h3[i]);
	for (int i = 1; i <= n; i++) D[dist[i]][h4[dist[i]]] = i, h4[dist[i]]++;
	e[1] = (1 << 30);
	for (int i = 1; i <= n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 25048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1ll << 60

using namespace std;
typedef long long ll;

ll Binary_search(const vector<ll>& d, const vector<ll> &a, ll l, ll r, const ll k) {
	if (l > r)
		return l;
	ll i, sum = 0, p = (r + l) >> 1;
	for (i = 0; i < d.size(); i++) {
		sum += max(0ll, d[i] - p / a[i]);
	}
	if (sum <= k) {
		return min(p, Binary_search(d, a, l, p - 1, k));
	}
	else
		return Binary_search(d, a, p + 1, r, k);
}

int main(void) {
	int num, j;
	ll i, k, ans = 0;
	cin >> num >> k;
	vector<ll> d(num), a(num);
	for (i = 0; i < num; i++)
		cin >> d[i];
	for (i = 0; i < num; i++)
		cin >> a[i];
	sort(d.begin(), d.end(), greater<ll>());
	sort(a.begin(), a.end());
	ans = Binary_search(d, a, 0, d[0] * a[num - 1], k);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	vector<int> x(N), y(N), h(N);
	for(int i=0; i<N; i++)
		cin >> x[i] >> y[i] >> h[i];

	int maxIndex = max_element(h.begin(), h.end()) - h.begin();

	int cx, cy, ch;
	for(cy=0; cy<101; cy++){
		for(cx=0; cx<101; cx++){
			if(h[maxIndex] == 0)
				ch = 0;
			else
				ch = h[maxIndex] + abs(cx - x[maxIndex]) + abs(cy - y[maxIndex]);

			bool ok = true;
			for(int i=0; i<N; i++){
				int n = max(0, ch - abs(cx - x[i]) - abs(cy - y[i]));
				if(n != h[i]){
					ok = false;
					break;
				}
			}

			if(ok == true){
				cout << cx << " " << cy << " " << ch << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 200000

int main()
{
  int n;   //integer 
  int t[N];   //price
  int i, j;   //loop counter variable
  int max=-2000000000, min;   //maximum variable

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ) scanf("%d", &t[i]);
 
  min = t[0];

  for( i = 1 ; i < n ; i++ ){
    if( max < (t[i] - min) ) max = t[i] - min;
    if( min > t[i] ) min = t[i];
  }

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

  return 0;
}

Measured memory_bytes: 1380
#include <cstdio>
#include <queue>

int main()
{
  long long q;
  scanf("%lld", &q);

  long long sum = 0;
  long long sumh = 0;

  std::priority_queue<long long, std::vector<long long>, std::greater<long long>> gq;
  std::priority_queue<long long> sq;
  
  bool first = true;
  for (long long i = 0; i < q; ++i)
  {
    long long type;
    scanf("%lld", &type);
    if (type == 1)
    {
      long long a, b;
      scanf("%lld%lld", &a, &b);
      sum += a + b;
      if (first)
      {
        sumh += a;
        sq.emplace(a);
        first = false;
      }
      else if (gq.size() == sq.size())
      {
        if (gq.top() <= a)
        {
          sq.emplace(gq.top());
          sumh += gq.top();
          gq.pop();
          gq.emplace(a);
        }
        else
        {
          sq.emplace(a);
          sumh += a;
        }
      }
      else
      {
        if (sq.top() >= a)
        {
          gq.emplace(sq.top());
          sumh -= sq.top();
          sq.pop();
          sq.emplace(a);
          sumh += a;
        }
        else
        {
          gq.emplace(a);
        }
      }
    }
    else
    {
      printf("%lld %lld\n", sq.top(), (sq.size() != gq.size() ?  sq.top() : 0) + sum - 2 * sumh);
    }
  }
  return 0;
}

Measured memory_bytes: 3828
from collections import deque
N, Q = map(int, input().split())
G = [[] for _ in range(N + 1)]
c = [0] * (N + 1)
for _ in range(N - 1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())
    c[p] += x

q = deque([1])
seen = [0] * (N + 1)
while q:
    now = q.popleft()
    seen[now] = 1
    for u in G[now]:
        if seen[u]:
            continue
        q.append(u)
        c[u] += c[now]

print(*c[1:])


Measured memory_bytes: 58148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> A(3); rep(i, 3) cin >> A[i];
  sort(all(A));
  cout << A[0] + A[1] << endk;
  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>

int main(void){
    int N;
    double ans=0;
    std::cin >> N;
    std::vector<int> P(N);
    std::vector<std::vector<int>> C(N, std::vector<int>(2));
    for (int i = 0; i < N; ++i){
        std::cin >> C[i][0] >> C[i][1];
        P.at(i) = i;
    }

    do {
        for (int i = 0; i < N - 1; ++i){
            ans += std::sqrt((C[P[i + 1]][0] - C[P[i]][0])*(C[P[i + 1]][0] - C[P[i]][0]) + (C[P[i + 1]][1] - C[P[i]][1])*(C[P[i + 1]][1] - C[P[i]][1]));
        }
    } while (std::next_permutation(P.begin(), P.end()));

    for(int i = 2; i <= N; ++i){
        ans /= i;
    }

    std::cout << std::fixed << std::setprecision(10) << ans << std::endl;

    return 0;
}

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

int main()
{
    int n,k;
    cin >> n >> k;
    vector<pair<ll,ll>> xy(n);
    rep(i,n) {
        cin >> xy[i].first >> xy[i].second;
    }
    sort(xy.begin(), xy.end());

    ll ans = INT64_MAX;
    for(int i=0;i<n-k+1;++i) {
        for(int j=i+k-1;j<n;++j) {
            vector<ll> y;
            for(int l=i;l<=j;++l) 
                y.push_back(xy[l].second);
            sort(y.begin(),y.end());

            ll dy = INT64_MAX;
            int l_max = y.size()-k+1;
            for(int l=0;l<l_max;++l)
                dy = min(dy, y[l+k-1]-y[l]);

            ans = min(ans, (xy[j].first-xy[i].first)*dy);
        }
    }

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

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

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

    int sum_5 = 0;
    int sum_7 = 0;

    for (int i=0; i<3; i++) {
        if (a[i] == 5) sum_5++;
        else sum_7++;
    }

    if (sum_5 == 2 && sum_7 == 1) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int a,b;
  char op;
  while(1){
    scanf("%d %c %d", &a, &op, &b);
    if(op=='?')
      break;
    if(op=='+')
      printf("%d\n",a+b);
    else if(op=='-')
      printf("%d\n",a-b);
    else if(op=='*')
      printf("%d\n",a*b);
    else if(op=='/')
      printf("%d\n",a/b);
  }
  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int[][] a = new int[n][2];
        for (int i = 0; i < n; i++) {
            a[i][0] = sc.nextInt();   
            a[i][1] = sc.nextInt();   
        }

        int[][] b = new int[m][2];
        for (int i = 0; i < m; i++) {
            b[i][0] = sc.nextInt();   
            b[i][1] = sc.nextInt();   
        }

        for (int i = 0; i < n; i++) {
            int min = 1000000000;
            int index = -1;
            for (int j = 0; j < m; j++) {
                int dist = Math.abs(a[i][0] - b[j][0]) + Math.abs(a[i][1] - b[j][1]);
                if (dist < min) {
                    min = dist;
                    index = j;
                }
            }
            System.out.println(index + 1);
        }

    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N, L, A[MAXN];

int main() {
	register int i, j;
	scanf( "%d%d", &N, &L );
	for( i = 1; i <= N; ++i )
		scanf( "%d", A + i );
	for( i = 1; i <= N; ++i )
		if( i > 1 && A[i - 1] + A[i] >= L ) {
			puts("Possible");
			for( j = 1; j < i - 1; ++j ) printf( "%d\n", j );
			for( j = N - 1; j >= i - 1; --j ) printf( "%d\n", j );
			return 0;
		}
	puts("Impossible");
	return 0;
}

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

int main() {
	long long n, m, k;
	cin >> n >> m >> k;
	vector<long long> A(n), B(m);
	int sum = 0;
	for (int i = 0; i < n; i++) cin >> A[i];
	for (int i = 0; i < m; i++) cin >> B[i];
	for (int i = 1; i < n; i++) {
		A[i] += A[i-1];
	}
	for (int i = 1; i < m; i++) {
		B[i] += B[i-1];
	}
	A.insert(A.begin(), 0);
	B.insert(B.begin(), 0);
	long long ans = 0;
	for (int i = 0, j = m; i <= n; i++) {
		long long now = i;
		long long sum = k - A[i];
		if (sum < 0) continue;
		while (j > 0 && B[j] > sum) j--;
		now += j;
		ans = max(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8004
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
 
#define INIT() std::ios::sync_with_stdio(false);std::cin.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i)
 
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
 
#define LOWBIT(x) ((x)&(-x))
 
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
 
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
 
template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
    in >> p.first >> p.second;
    return in;
}
 
template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
    for (auto &x: v)
        in >> x;
    return in;
}
 
template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]" << "\n";
    return out;
}
 
typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef set< int > SI;
typedef vector< int > VI;
typedef map< int, int > MII;
const double EPS = 1e-10;
const int inf = 1e9 + 9;
const LL mod = 1e9 + 7;
const int maxN = 1e5 + 7;
const LL ONE = 1;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555;

LL fac[2 * maxN];
void init_fact() {
	fac[0] = 1;
	For(i, 1, 2 * maxN - 1) {
		fac[i] = (i * fac[i - 1]) % mod;
	}
}

//ax + by = gcd(a, b) = 1
// 扩展欧几里德算法
inline void ex_gcd(LL a, LL b, LL &x, LL &y, LL &d){
    if (!b) {d = a, x = 1, y = 0;}
    else{
        ex_gcd(b, a % b, y, x, d);
        y -= x * (a / b);
    }
}

// 求a关于p的逆元，如果不存在，返回-1 
// a与p互质，逆元才存在 
inline LL inv_mod(LL a, LL p){
    LL d, x, y;
    ex_gcd(a, p, x, y, d);
    return d == 1 ? (x % p + p) % p : -1;
}

// Calculate x^y % p
inline LL pow_mod(LL x, LL y, LL p){
	LL ans = 1;
	while(y){
		if(y & 1) ans = (ans * x) % p;
        x = (x * x) % p;
        y >>= 1;
	}
	return ans;
} 

inline LL comb_mod(LL m,LL n){
	LL ans;
	if(m > n) swap(m, n);
	
	ans = (fac[n] * inv_mod(fac[m], mod)) % mod;
	ans = (ans * inv_mod(fac[n - m], mod)) % mod;
	
	return ans;
}

int H, W, A, B;
LL ans;

int main(){
	INIT();
	init_fact();
	cin >> H >> W >> A >> B; 
	For(i, 1, H - A) {
		ans += (comb_mod(i - 1, i + B - 2) * comb_mod(W - B - 1, W - B + H - i - 1)) % mod;
		ans %= mod;
	}
	
	cout << ans << endl;
	return 0;
}

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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;


int main(){
  IO; int N, M; cin >> N >> M;
  vi ans(N,-1); ans[0] = 0;
  mi E(N); int a, b;
  while(M--){
    cin >> a >> b; --a,--b;
    E[a].PB(b);E[b].PB(a);
  }
  vi bfs = {0};
  REP(i,bfs.size()){
    int t = bfs[i];
    FORE(j,E[t]) if(ans[j] < 0) ans[j] = t, bfs.PB(j);
  }
  int ok = 1;
  FORE(i,ans) if(i < 0) ok = 0;
  if(ok){
    cout << "Yes\n";
    FOR(i,1,N) cout << ans[i]+1 << "\n";
  }else cout << "No\n";
}


Measured memory_bytes: 10568
function Main(input) {
  var dn = input[0].split(" ");
  if(dn[1] == 100) dn[1]++;
  console.log('%d', Math.round(Math.pow(100, dn[0]) * dn[1]));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));


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

int main() {
  int n, x; cin >> x >> n;
  vector<int> v(n);
  for (int i=0; i<n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());
  int ans=-1, diff=1001;
  if (n > 0) {
  for (int i=0; i<=v[n-1]+1; i++) {
    if (binary_search(v.begin(), v.end(), i))
      continue;
    if (abs(x-i) < diff) {
      diff = abs(x-i);
      ans = i;
    }
  }}
  if (ans == -1) cout << x;
  else cout << ans;
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i<(n) ; i++);

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<ll> aa(a);
	vector<ll> bb(b);
	vector<ll> cc(c);
	for (int i = 0; i < a; i++)cin >> aa.at(i);
	for (int i = 0; i < b; i++)cin >> bb.at(i);
	for (int i = 0; i < c; i++)cin >> cc.at(i);
	sort(aa.begin(), aa.end());
	reverse(aa.begin(), aa.end());
	sort(bb.begin(), bb.end());
	reverse(bb.begin(), bb.end());
	sort(cc.begin(), cc.end());
	reverse(cc.begin(), cc.end());

	for (int i = 0; i < x; i++) {
		cc.push_back(aa.at(i));
	}
	for (int i = 0; i < y; i++) {
		cc.push_back(bb.at(i));
	}
	sort(cc.begin(), cc.end());
	reverse(cc.begin(), cc.end());

	ll ans = 0;
	for (int i = 0; i < x + y; i++) {
		ans += cc.at(i);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6384
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<string>
#include<stdio.h>
#include<cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(), (x).end()
#define lint long long

struct city{
    int num, pref, rank; long year;
    city(int n, int p, long y):num(n), pref(p), year(y) {}
};

bool cmp(const city &x, const city &y){
    if(x.pref != y.pref) return x.pref < y.pref;
    else return x.year < y.year;
}

bool cmp2(const city &x, const city &y){
    return x.num < y.num;
}

string id(int p, int x){
    string sp = to_string(p);
    string sx = to_string(x);
    while(sp.size() < 6) sp = "0" + sp;
    while(sx.size() < 6) sx = "0" + sx;
    return sp + sx;
}

int main(){
    int n,m; cin>>n>>m;
    vector<city> c;
    rep(i, m){
        int p; long y;
        cin>>p>>y; 
        c.push_back(city(i, p, y));
    }
    sort(all(c), cmp);

    int nowp = -1; int cnt = 0;
    rep(i, m){
        if(nowp != c[i].pref){
            cnt = 1;
            nowp = c[i].pref;
        }
        else
            cnt++;
        c[i].rank = cnt;
    }

    sort(all(c), cmp2);
    rep(i, m){
        cout << id(c[i].pref, c[i].rank) << endl;
    }
}

Measured memory_bytes: 4724
/*+lmake
 * STD = c++14
 * DEFINE += MDEBUG
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
#ifdef MDEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

void solve(long long N, long long X){
	LL ans=N;
	LL a=X,b=N-X;
	if (a>b) swap(a,b);
	while(true) {
		if (b%a==0) {
			ans+=a*((b/a)*2-1);
			break;
		}
		ans+=2*a*(b/a);
		b%=a;
		if (a>b) swap(a,b);
	}
	cout<<ans<<endl;
}

int main(){	
	long long N;
	long long X;
	scanf("%lld",&N);
	scanf("%lld",&X);
	solve(N, X);
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1 {
    class Program {
        static void Main(string[] args) {

            string line = Console.ReadLine();
            int X = int.Parse(line.Split(' ')[0]);
            int A = int.Parse(line.Split(' ')[1]);
            int B = int.Parse(line.Split(' ')[2]);

            line = Console.ReadLine();
            int N = int.Parse(line);


            for (int i = 0; i < N; i++) {
                line = Console.ReadLine();

                if (line == "nobiro") {
                    X += A;
                    X = Math.Max(0, X);

                } else if (line == "tidime") {
                    X += B;
                    X = Math.Max(0, X);

                } else if (line == "karero") {
                    X = 0;



                }

            }
            Console.WriteLine(X);




        }
    }
}



Measured memory_bytes: 17924
#include<stdio.h>
#define NIL -1

int D[100001],H[100001],zero[100001];
struct tree{
	int p,l,r;
}T[100001];

void gd(int i,int p){
	D[i] = p;
	if(T[i].r!=NIL&&(D[T[i].r]==NIL)) gd(T[i].r,p);
	if(T[i].l!=NIL) gd(T[i].l,p+1);
	else if(T[i].l==NIL&&zero[i]!=NIL) gd(zero[i],p+1);
}

void ppt(int n){
	printf("node %d: parent = %d, sibling = %d, degree = ",n,T[n].p,T[n].r);
	if(T[n].l!=NIL&&(T[T[n].l].r!=NIL)) printf("2");
	else if(zero[n]==NIL)printf("0");
	else printf("1");
	printf(", depth = %d, ",D[n]);
	printf("height = %d, ",H[n]);
	if(T[n].p == NIL){
		printf("root\n");
	}
	else if(zero[n]==NIL)printf("leaf\n");
	else printf("internal node\n");
}

void gh(int n,int h){
	if(H[n]){
		H[n] = ( h > H[n] ? h : H[n]);
	}
	int par = T[n].p;
	if(par != NIL){
		H[par] = ( (h+1) > H[par] ? (h+1) : H[par] );
		gh(par,h+1);
	}
}

int main(){
	int i,n,j,k,o,a,b,c;
	scanf("%d",&o);
	k=o;
	for( i = 0; i < k; i++){
		T[i].l=T[i].p=T[i].r=D[i]=NIL;
	}
	while(k--){
		scanf("%d %d %d",&a,&b,&c);
		T[a].l=b;
		T[b].r=c;
		T[b].p=a;
		T[c].p=a;
		T[c].r=b;
		if(b==NIL&&c==NIL) zero[a]=NIL;
		if(b==NIL) zero[a]=c;
		if(c==NIL) zero[a]=b;
	}
	for( i = 0; i < o; i++) 
		if(T[i].p==NIL) break;
	gd(i,0);
	for( i = 0; i < o; i++)
		if(T[i].l==NIL) gh(i,0);
	for( i = 0; i < o; i++) ppt(i);
}


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long A, long long B) {
  cout << 6 - A - B << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


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

using namespace std;

int main() {
    int l;
    int fixedLength = 10000;
    //int input[fixedLength];
    vector<int> input(fixedLength);
    int dynamicLength;
    for(int i = 0;i < fixedLength && cin>>l;i++){
        if(l==0)break;
        input[i] = l;
        dynamicLength = i;
    }   

    for(int i =0;i < dynamicLength+1;i++){
        cout << "Case " << i+1 << ": " << input[i] << endl;
    }   
    return 0;
}



Measured memory_bytes: 3040
fun main(args :Array<String>) {
    val n = readInteger()
    val alist = readIntegerList()
    val aSumList = Array<Long>(n + 1) { 0 }
    for (i in 1..n) {
        aSumList[i] = aSumList[i - 1] + alist[i - 1]
    }

    var ans = Math.abs(aSumList[1] - (aSumList[n] - aSumList[1]))
    for (i in 1..(n - 1)) {
        val left = aSumList[i]
        val right = aSumList[n] - aSumList[i]
        ans = Math.min(ans, Math.abs(left - right))
    }

    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toLong)


Measured memory_bytes: 80776
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int N,flag = 0;
	string l;
	cin >> N;
	vector<string> W(N);
	for (int i = 0;i < N;i++){
		cin >> l;
		W[i] = l;
		if (i > 0){
			if(l[0] == W[i - 1][W[i - 1].size() - 1]){
				for(int j = 0;j < i;j++){
					if(W[j] != l){
						continue;
					}
					else{
						flag++;
					}
				}
			}
			else{
				flag++;
			}

		}
	}

	if (flag == 0){
		cout << "Yes" <<endl;
	}
	else{
		cout <<"No"<< endl;
	}

	return 0;
}

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

using namespace std;

typedef long long LL;

int A,B,a[105][105];

int main()
{
	cin>>A>>B;
	A--;B--;
	for (int i=1;i<=50;++i)
		for (int j=1;j<=100;++j) a[i][j]=0;
	for (int i=51;i<=100;++i)
		for (int j=1;j<=100;++j) a[i][j]=1;
	for (int i=1;i<=50;i+=2)
	{
		if (A==0) break;
		int j;
		if (i&1) j=1;else j=2;
		for (;j<=100;j+=2)
		{
			a[i][j]=1;
			A--;
			if (A==0) break;
		} 
	}
	for (int i=100;i>=51;i-=2)
	{
		if (B==0) break;
		int j;
		if (i&1) j=1;else j=2;
		for (;j<=100;j+=2)
		{
			a[i][j]=0;
			B--;
			if (B==0) break;
		}
	}
	printf("100 100\n");
	for (int i=1;i<=100;++i)
	{
		for (int j=1;j<=100;++j) if (a[i][j]==1) printf(".");else printf("#");
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int d;
  cin>>d;
  if(d==25) cout<<"Christmas\n";
  else if(d==24) cout<<"Christmas Eve\n";
  else if(d==23) cout<<"Christmas Eve Eve\n";
  else if(d==22) cout<<"Christmas Eve Eve Eve\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3652
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////

int main(){fastio
    ll n,k;cin>>n>>k;
    dd a[n];rep(i,0,n-1)cin>>a[i];
    dd b[n];
    
    rep(i,0,n-1){
        b[i]=(a[i]+1)/2;
    }
    dd ans=0;
    dd sum=0;
    sum=0;
    rep(i,0,n-1){
        sum+=b[i];
        if(i-k>=0)sum-=b[i-k];
        if(ans<sum)ans=sum;
    }
    cout<<setprecision(20)<<ans<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 6528
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Array.Sort(n);
        Console.WriteLine(n[2] * 10 + n[1] + n[0]);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e6 + 5;

int n,q,a[N],x,y,l=1,r,p[N],ans[N],sq,belong[N],num;
struct node{
	int l,r,bel;
	bool operator < (const node& T) const{
		return (belong[l] ^ belong[T.l]) ? belong[l] < belong[T.l] : ((belong[l] & 1) ? r < T.r : r > T.r);
	}
}querry[N];

int cmp(node a,node b){
    if(a.l/sq!=b.l/sq)return a.l/sq<b.l/sq;
    return a.r/sq<b.r/sq;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>q;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=q;i++) cin>>x>>y,querry[i]={x,y,i};
    sq=sqrt(n);
	for(int i=1;i<=n;i++) belong[i]=min(sq,(i-1)/sq+1);
	sort(querry+1,querry+1+q);
	for(int i=1;i<=q;i++){
		while(querry[i].l<l) num+=!p[a[--l]]++;
		while(querry[i].l>l) num-=!--p[a[l++]];
		while(querry[i].r<r) num-=!--p[a[r--]];
		while(querry[i].r>r) num+=!p[a[++r]]++;
		ans[querry[i].bel]=num;
	}
	for(int i=1;i<=q;i++) cout<<ans[i]<<'\n';
    return 0;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int m = 0, count = 0;
  for(int i = 0; i < N; i++){
    if(S.at(i) == 'I'){
      count++;
    }
    else count--;
    m = max(m, count);
  }
  cout << m << endl;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD=1000000007;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}
int main()
{
    ll X;
    cin >> X;
    cout << ((X>=30)?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3628
import std;
import core.bitop;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long k, t;
    scan(k, t);
    auto a = aryread();
    auto maxA = a.reduce!(max);
    writeln(max(maxA - (k - maxA + 1), 0));
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 3604