akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int a[3] = {0};
    cin >> a[0] >> a[1] >> a[2];

    sort(a,a+3);

    int sol = 0;
    if ((a[2]-a[0]) % 2 == 0) sol += (a[2]-a[0])/2, a[0] += (a[2]-a[0]);
    else sol += (a[2]-a[0]-1)/2, a[0] += (a[2]-a[0]-1);

    // for(int i = 0; i < 3; i++) cout << a[i] << " ";
    // printf("\n");

    if ((a[2]-a[1]) % 2 == 0) sol += (a[2]-a[1])/2, a[1] += (a[2]-a[1]);
    else sol += (a[2]-a[1]-1)/2, a[1] += (a[2]-a[1]-1);
    // for(int i = 0; i < 3; i++) cout << a[i] << " ";
    // printf("\n");

    if(a[2]-a[1] == 1 && a[2]-a[0] == 1) sol++;
    else if(a[2]-a[1] == 1 || a[2]-a[0] == 1) sol += 2;

    cout << sol << endl;

    return 0;
}

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

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

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()


long long gcd(long long a, long long b)
{
	if (b == 0) return a;
	else return gcd(b, a%b);
}

long long lcm(long long a, long long b)
{
	return a/gcd(a, b) * b;
}


template <typename T>
struct SegTree
{
	using F = function<T(T, T)>; // T*T -> X
	long long N;
	F f;
	const T ex;
	vector<T> dat;
	SegTree(long long n_, F f_, T ex_) : N(), f(f_), ex(ex_), dat(n_*4, ex_)
	{
		long long x = 1;
		while (n_ > x) x <<= 1;
		N = x;
	}

	void set(long long i, T x) {dat[i+N-1] = x;};
	void set(vector<T> &v)
	{
		assert(N == v.size());
		for (long long i = 0; i < N; ++i)
			set(i, v[i]);
	}

	void build()
	{
		for (long long k = N-2; k >= 0; --k)
			dat[k] = f(dat[k*2+1], dat[k*2+2]);
	}

	void update(long long i, T x)
	{
		i += N-1;
		dat[i] = x;
		while (i > 0)
		{
			i = (i-1)/2;
			dat[i] = f(dat[i*2+1], dat[i*2+1]);
		}
	}

	T query(long long a, long long b) {return query_sub(a, b, 0, 0, N);}
	T query_sub(long long a, long long b, long long k, long long l, long long r)
	{
		if (r <= a || b <= l) return ex;
		if (a <= l && r <= b) return dat[k];
		T vl = query_sub(a, b, k*2+1, l, (l+r)/2);
		T vr = query_sub(a, b, k*2+2, (l+r)/2, r);
		return f(vl, vr);
	}
};

ll N;
ll A[100010] = {};

int main(int argc, char **argv)
{
	cin >> N;
	auto f = [](ll a, ll b) {return gcd(a, b);};
	SegTree<ll> st(N, f, 0ll);
	REP(i, N)
	{
		cin >> A[i];
		st.set(i, A[i]);
	}
	st.build();
	
	ll res{0};
	REP(i, N)
	{
		res = max(res, gcd(st.query(0, i), st.query(i+1, N)));
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 4096
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

n, k = map(int, input().split())
P = list(map(int, input().split()))
P.sort()
print(sum(P[:k]))


Measured memory_bytes: 68064
#include <iostream>
#include <vector>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for (int i=a; i<(b);++i)
int N,a,b;

int dist[2][100005];
vector<vector<int> > G;
// x:探索する頂点、y:前の頂点(無向グラフのため)、z:起点からのコスト、w:プレイヤー
void dfs(int v, int pv, int cost, int player){
    dist[player][v] = cost;
    for(int nv : G[v]){
        if(nv == pv) continue;
        dfs(nv,v,cost+1,player);
    }
}

int main(){
    cin >> N;
    G.resize(N);
    REP(i,N-1){
        cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    // 深さ優先でカウント
    int snuke = 0; int fennec = 0;
    // 0から(フェネック)、N-1から(す抜け)の各地点の距離を算出、
    // dist[0][i] <= dist[1][i]となる点はフェネックの得点
    dfs(0,-1,0,0);
    dfs(N-1,-1,0,1);

    REP(i,N){
        if(dist[0][i] <= dist[1][i]) ++fennec;
        else ++snuke;
    }

    if(fennec > snuke) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}

Measured memory_bytes: 12800
#include "bits/stdc++.h"
using namespace std;

int n;
bool visited[1000000];

int main(){
	scanf("%d", &n);
	bool valid = true;
	if((n&(-n)) == n)
		valid = false;
	if(valid){
		/*
		Mark 1 as root, make a line tree with this pattern
		... - 4 - 5 - 2 - 3 - 1 - 2 - 3 - 4 - 5 - ...
					  |
					  1
		This should work for all odd value n.
		Note that the all pair can be placed in arbritrary order. That means this sequence:
		... - 7 - 6 - 2 - 3 - 4 - 5 - 1 - 4 - 5 - 2 - 3 - 7 - 6 - ...
		is also valid.

		For even n:
		Let LS be the least significant bit of N. Then, make sure that node LS and node (n-LS)
		is adjacent. Then, make this pattern:
		... - LS - (n-LS) - ...
			  |		 |
			  N 	 N
		*/
		printf("Yes\n");
		int l = 1, r = 1;
		if(n%2 == 0){
			int LS = (n&(-n));
			// Both LS and n-LS must be even
			visited[LS] = visited[LS+1] = visited[n-LS] = visited[n-LS+1] = true;
			printf("%d %d\n", LS+1, LS);
			printf("%d %d\n", LS, n-LS);
			printf("%d %d\n", n-LS, n-LS+1);
			printf("%d %d\n", n-LS+1, 1);
			printf("%d %d\n", 1, n+(n-LS));
			printf("%d %d\n", n+(n-LS), n+(n-LS+1));
			printf("%d %d\n", n+(n-LS+1), n+(LS+1));
			printf("%d %d\n", n+(LS+1), n+LS);
			l = LS+1, r = n+LS;

			visited[n] = true;
			printf("%d %d\n", n, LS);
			printf("%d %d\n", n+n, n-LS);

			printf("%d %d\n", n+1, n-LS);
		}
		for(int i = 2; i < n; i += 2) if(!visited[i]){
			assert(!visited[i+1]);
			visited[i] = visited[i+1] = true;
			printf("%d %d\n", i, i+1);
			printf("%d %d\n", i+1, l);
			printf("%d %d\n", r, n+i);
			printf("%d %d\n", n+i, n+i+1);
			l = i, r = n+i+1;
		}
		if(n%2 == 1){
			printf("%d %d\n", n+1, 2);
		}
	}else{
		printf("No\n");
	}
}

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

int a[200001];
int main(){
  int N,K,i;
  scanf("%d%d",&N,&K);
  
  for(i=0;i<N;i++)
    scanf("%d",&a[i]);
  
  for(i=0;i<N-K;i++)
    if (a[i] < a[K+i])
      printf("Yes\n");
  	else
      printf("No\n");

  return 0;
  
}

Measured memory_bytes: 4416
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void){
    int num;
    long *a_n,*an;
    long mod=0;
    scanf("%d",&num);
    a_n=(long *)malloc(sizeof(long)*num);
    int i;
    for(i=0;i<num;i++){
        scanf("%ld",&a_n[i]);
        mod+=a_n[i]-1;
    }
    printf("%ld",mod);
    return 0;

}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int h = ri();
	int w = ri();
	int a[h][w];
	for (auto &i : a) for (auto &j : i) j = ri();
	int dp[w][w];
	for (auto &i : dp) for (auto &j : i) j = -1000000000;
	dp[0][1] = 0;
	for (int i = 0; i < h; i++) {
		int sum[w + 1];
		sum[0] = 0;
		for (int j = 0; j < w; j++) sum[j + 1] = sum[j] + a[i][j];
		std::vector<int> insert[w][w];
		std::vector<int> erase[w][w];
		for (int j = 0; j < w; j++) for (int k = j; k < w; k++) {
			insert[j][k].push_back(dp[j][k] - sum[j]);
			erase[k][k].push_back(dp[j][k] - sum[j]);
		}
		int max[w][w];
		for (int j = 0; j < w; j++) {
			std::multiset<int> all{-1000000000};
			for (int k = 0; k < w; k++) {
				for (auto l : insert[k][j]) all.insert(l);
				for (auto l : erase[k][j]) all.erase(all.find(l));
				max[k][j] = *std::prev(all.end()) + sum[k + 1] + a[i][j];
			}
		}
		for (int j = 0; j < w; j++) for (int k = 0; k + 1 < w; k++)
			max[j][k + 1] = std::max(max[j][k + 1], max[j][k] + a[i][k + 1]);
		memcpy(dp, max, sizeof(max));
	}
	int res = 0;
	for (auto &i : dp) for (auto &j : i) res = std::max(res, j);
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 6848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    vector<ll> v;
    rep(i, 0, n) {
        int a;
        cin >> a;
        mp[a]++;
        if (mp[a] == 2) {
            v.push_back(a);
            mp[a] = 0;
        }
    }

    sort(v.begin(), v.end(), greater<ll>());

    if (2 <= v.size()) cout << v[0] * v[1] << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int a[200003],maxl[200003],maxr[200003];
int main(){
 int n;
  scanf("%d",&n);
  for(int i=0;i<n;++i)
    scanf("%d",&a[i]);
  maxl[0]=a[0];
  for(int i=1;i<n;++i)
    maxl[i]=max(maxl[i-1],a[i]);
  maxr[n-1]=a[n-1];
  for(int i=n-2;i>=0;--i)
    maxr[i]=max(maxr[i+1],a[i]);
  for(int i=0;i<n;++i)
    printf("%d\n",max((i?maxl[i-1]:0),(i<n-1?maxr[i+1]:0)));
  return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        int n; cin >> n;
        vector<int> v(n), p(n), q(n);
        iota(v.begin(), v.end(), 0);

        REP(i, n) {
                cin >> p[i];
                --p[i];
        }

        REP(i, n) {
                cin >> q[i];
                --q[i];
        }

        int a = -1, b = -1;
        
        auto check = [&](const vector<int>& v1, const vector<int>& v2) {
                const int n = static_cast<int>(v1.size());

                REP(i, n) {
                        if (v1[i] != v2[i]) {
                                return false;
                        }
                }

                return true;
        };

        int cur = 0;
        do {
                if (check(v, p)) {
                        a = cur;
                } 
                if (check(v, q)) {
                        b = cur;
                }

                cur++;
        }while(next_permutation(v.begin(), v.end()));

        cout << abs(a - b) << endl;

        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		sc.close();
		if(c[0] == c[1] && c[1] == c[2] || c[1] == c[2] && c[2] == c[3]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<ll>h(N);
  for(int i=0;i<N;i++)cin>>h[i];
  vector<ll>dp(N,INF);
  dp[0]=0;
  for(int i=1;i<N;i++){
    dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
    if(i-2>=0)dp[i]=min(dp[i],dp[i-2]+abs(h[i-2]-h[i]));
  }
  cout<<dp[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define INF 10005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 10001;

short int nx[MAX_N], prv[MAX_N], d[MAX_N];

inline int Prim(int node_size, short int** G){
    short int V = node_size, mn = INF, mn_id = 0, v = 0, j, a, b;
    int res = 0;
    iota(nx, nx + V, 1), iota(prv, prv + V, -1);
    fill(d, d + V, INF);
    for(int i = 0; i < V-1; i++){
        for(j = nx[0]; j != V; j = nx[j]){
            a = min(v, j), b = max(v, j);
            d[j] = min(d[j], G[a][b-a-1]);
            if(d[j] < mn) mn = d[j], mn_id = j;
        }
        res += mn, v = mn_id;
        d[mn_id] = mn = INF;
        prv[nx[mn_id]] = prv[mn_id], nx[prv[mn_id]] = nx[mn_id];
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    short int** G = new short int*[n];
    rep(i,n){
        G[i] = new short int[n-i-1];
        fill(G[i], G[i]+n-i-1, INF);
    }
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        if(a > b) swap(a,b);
        G[a][b-a-1] = c;
    }
    cout << Prim(n, G) << "\n";
    return 0;
}



Measured memory_bytes: 101116
package main

import (
	"bufio"
	"fmt"
	"os"
)

const Mod = int(1e9) + 7

func main() {
	K := ReadInt()
	S := ReadString()
	n := len(S)

	InitModCombi(n + K)

	ans := 0
	for i := 0; i <= K; i++ {
		now := ModPow(26, K-i)
		now = now * ModPow(25, i) % Mod
		now = now * ModCombi(i+n-1, n-1) % Mod
		ans = (ans + now) % Mod
	}
	fmt.Println(ans)
}

func ModPow(a, b int) int {
	x := 1
	for b > 0 {
		if b&1 == 1 {
			x = x * a % Mod
		}
		a = a * a % Mod
		b >>= 1
	}
	return x
}

// https://drken1215.hatenablog.com/entry/2018/06/08/210000
func ModCombi(n, k int) int {
	if n < k || n < 0 || k < 0 {
		return 0
	}
	return fact[n] * (finv[k] * finv[n-k] % Mod) % Mod
}

var fact, finv, inv []int

func InitModCombi(max int) {
	fact, finv, inv = make([]int, max), make([]int, max), make([]int, max)
	fact[0], fact[1], finv[0], finv[1], inv[1] = 1, 1, 1, 1, 1
	for i := 2; i < max; i++ {
		fact[i] = fact[i-1] * i % Mod
		inv[i] = Mod - inv[Mod%i]*(Mod/i)%Mod
		finv[i] = finv[i-1] * inv[i] % Mod
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 55472
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 135, task c, 2020/08/14
//ms,
/*
*/

int main(void){
  int N;
  vector<int64_t> A, B;
  int64_t ans=0;

  //input
  cin >>N;
  //A
  for(int i=0;i<N+1;i++){
    int64_t tmp;
    cin >>tmp;
    A.push_back(tmp);
  }
  //B
  for(int i=0;i<N;i++){
    int64_t tmp;
    cin >>tmp;
    B.push_back(tmp);
  }

  for(int i=0;i<N;i++){
    if(B[i] <= A[i]){
      ans += B[i];
      A[i] -= B[i];
    }
    else if(B[i] <= A[i]+A[i+1]){
      ans += B[i];
      A[i+1] -= B[i]-A[i];
      A[i] = 0;
    }
    else {
      ans += A[i]+A[i+1];
      A[i+1] = 0;
      A[i] = 0;
    }
    //cout <<ans <<endl;
  }

  cout <<ans<<endl;

  return 0;
}
/*
*/


Measured memory_bytes: 5524
n=int(input())
a=[]
b=[]
for i in range(n):
  a.append(tuple(map(int,input().split())))
for i in range(n):
  b.append(tuple(map(int,input().split())))


b.sort()

l=[0 for i in range(n)]
c=0
for i in range(n):
  m,t=-1,-1
  for j in range(n):
    if l[j]:
      continue
    if a[j][0]<b[i][0] and a[j][1]<b[i][1] and m<a[j][1]:
      m=a[j][1]
      t=j
  if t!=-1:
    l[t]=1
  c+=t!=-1
print(c)

Measured memory_bytes: 69376
def BC132_D():
    n, k = list(map(int, input().split(' ')))
    f = [1] * max(k, n - k + 2)
    for i in range(1, len(f)):
        f[i] = f[i - 1] * i

    def comb(n, r):
        if n < r: return 0
        return f[n] // f[r] // f[n - r]

    for i in range(1, k + 1):
        print(comb(k - 1, i - 1) * comb(n - k + 1, i) % (10**9 + 7))

BC132_D()


Measured memory_bytes: 5364
#include <stdio.h>

int main(void){
    long ans[98] = {61,230,865,3247,12185,45719,171531,643550,2414454,9058467,33985227,127504505,478366600,794717734,733354121,261943303,776803305,580025381,51688048,44657419,737209731,604119499,159693437,858533109,639056669,549054109,996291083,531294469,23314687,783022045,855462856,649970414,68697295,409213624,604356692,88638656,978442997,534833116,763737161,785892908,123883652,639213333,181836645,998121103,124885216,501575626,39816123,113468411,799008836,775465589,256852905,664630886,971550783,751629411,51018086,702530485,725438992,696683714,792638194,221791721,149602322,414054379,986519078,981760191,305799096,515140586,406959393,975058685,245601370,324759692,673385295,191483611,570246669,427196161,781042769,569725155,842176273,25328739,847501730,206282374,353770801,323137024,371653459,940737264,123820509,915711339,847205021,252858375,718889563,866398347,738390145,133009077,333099663,170591295,329869205,616680192,597534442,388130742};
    int n;
    scanf("%d",&n);
    printf("%ld\n",ans[n - 3]);
    return 0;
}

Measured memory_bytes: 128
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

s = ins()
hasa = (s[0]=='A') or (s[1]=='A') or (s[2]=='A')
hasb = (s[0]=='B') or (s[1]=='B') or (s[2]=='B')
if hasa and hasb:
    print('Yes')
else:
    print('No')



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

bool calc(vector<int> x) {
  for (int i = 0; i < x.size(); i++) 
    if (x[i] % 2 == 1) return false;
  return true;
}

int main() {
  int n, tmp, count;
  vector<int> a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    a.push_back(tmp);
  }
  while (calc(a)) {
    for (int i = 0; i < a.size(); i++) a[i] /= 2;
    count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int m; cin >> m;
  cout << 24 + (24-m) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;

string s;

int main() {
	cin >> s;
	string t;
	Loop(i, s.size()) {
		if (s[i] == '0') t.push_back('0');
		else if (s[i] == '1') t.push_back('1');
		else if (s[i] == 'B' && t.size() > 0) t.pop_back();
	}
	cout << t << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

#define debug(x) (cout << # x ": " << x << endl)
#define int long long int
#define repeat(n) for (int i = 0; i < n; ++i)
#define repeat2(n) for (int j = 0; j < n; ++j)
#define all(x) (x).begin(), (x).end()

#define MAX_SIZE (100001)

signed main() {
    int n;
    cin >> n;

    int dp[200001];
    memset(dp, 0, sizeof(int) * 200001);
    repeat(n - 1) {
        int x;
        cin >> x;

        ++dp[x];
    }

    repeat(n) {
        cout << dp[i + 1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4672
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const int inf = (1<<29);


const int MAX = 1000010;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理O(n)
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

// 二項係数計算O(1)
ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main () {

    int X, Y;
    cin >> X >> Y;

    if ((X+Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    int cnt = (X+Y) / 3;
    X -= cnt;
    Y -= cnt;

    if (X<0 || Y<0) {
        cout << 0 << endl;
    } else {
        COMinit();
        cout << COM(X+Y, X) << endl;
    }

    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll dp[405][405];

ll rec(int l, int r, vector<ll> &B) {
    if (l == r - 1) return 0;
    if (dp[l][r] != 0) return dp[l][r];

    ll ans = INF;
    rep2(m, l + 1, r) {
        ans = min(ans, rec(l, m, B) + rec(m, r, B) + B[r] - B[l]);
    }

    dp[l][r] = ans;
    return ans;
}

void Main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N + 1, 0);
    rep(i, N) cin >> A[i];
    rep(i, N) {
        B[i + 1] += B[i] + A[i];
    }
    cout << rec(0, N, B) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1664
from collections import defaultdict
n, k = map(int, input().split())
a = list(map(int, input().split()))

d = [0]
for i in a:
    a_i = (d[-1] + i) % k
    d.append(a_i)

ans = 0
counter = defaultdict(int)
for i, s in enumerate(d):
    ans += counter[(s-i) % k]
    counter[(s-i) % k] += 1
    if i - k + 1 >= 0:
        counter[(d[i - k + 1]-i+k-1) % k] -= 1

print(ans)



Measured memory_bytes: 46848
n = input()
a = int(n[0])

for i in range(8):
    x = "{0:03b}".format(i)
    s = a
    ss = "{0}".format(a)
    for j in range(3):
        if x[j] == '0':
            s -= int(n[j+1])
            ss += "-{0}".format(int(n[j+1]))
        else:
            s += int(n[j+1])
            ss += "+{0}".format(int(n[j+1]))
    if s == 7:
        break
print(ss+"=7")

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
//change null_type here for map/set
typedef tree<int,null_type,less<int>,rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;
typedef long long int  ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define F first
#define S second

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    x*=sgn; return ~c;
}
///START HERE
///indexed_set pbd;
//pbd.insert()
//auto x = pbd.find_by_order(2);
//int od=pbd.order_of_key(7)
///rope<int> rp;
//rp.push_back()
//RandomAccess like vector
//mutable_begin, mutable_end()

int main(){
    ///read()+printf
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //fast;
    int x;
    cin>>x;if(x<30){
        cout<<"No";
    }
    else{
    cout<<"Yes";
    }


    return 0;
}


Measured memory_bytes: 3592
#![allow(unused_imports)]
#![allow(dead_code)]
use proconio::input;
use proconio::fastout;
use proconio::marker::*;

fn type_of<T>(_: T) -> String{
    let a = std::any::type_name::<T>();
    return a.to_string();
}

#[fastout]
fn main() {
    input! {
        a:i32,b:i32,c:i32,d:i32,
    }
    println!("{}",i32::min(a,b)+i32::min(c,d));
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    rep(i, w+2)cout << "#";
    cout << endl;
    rep(i, h){
        string s;
        cin >> s;
        cout << "#" << s << "#" << endl;
    }
    rep(i, w+2)cout << "#";
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec,int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {
	int n, t;
	int cosmin = 10000000;
	bool is = false;
	std::cin >> n >> t;

	int cost[101];
	int time[1001];

	for (int i = 0; i < n; ++i) {
		std::cin >> cost[i];
		std::cin >> time[i];
	}

	for (int i = 0; i < n; ++i) {
		if (time[i] <= t) {
			if (cosmin > cost[i]) {
				cosmin = cost[i];
			}
			is = true;
		}
	}

	if (is) {
		std::cout << cosmin << std::endl;
	}
	else {
		std::cout << "TLE" << std::endl;
	}

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	
	int n; cin >> n;
	
	int v[n];
	
	for (int i=0; i<n-1; i++) {
		v[i] = 0;
		int num; cin >> num;
		
		v[num-1]++;
	}
	
	v[n-1] = 0;
	
	for (int i=0; i<n; i++) {
		cout << v[i] << endl;		
	}
	
	return 0;
	
}

Measured memory_bytes: 4368
S = list(input())
int_S = [int(n) for n in S]
dif = 1000
for i in range(len(int_S)-2):
	num = 100*int_S[i]+10*int_S[i+1]+int_S[i+2]
	temp_dif = abs(num-753)
	if temp_dif < dif:
		dif = temp_dif

print(dif)

Measured memory_bytes: 3060
def getval():
    n = int(input())
    return n 

def main(n):
    mod = 10**9+7
    #Number of comb for 1-8
    pow8 = [1]
    for i in range(n):
        temp = pow8[i] * 8
        temp %= mod 
        pow8.append(temp)

    #Number of comb for 0 and 9
    pow2 = [1]
    for i in range(n):
        temp = pow2[i] * 2
        temp %= mod
        pow2.append(temp)
    for i in range(n+1):
        temp = pow2[i] - 2
        if temp<=0:
            temp = 0
        pow2[i] = temp 

    ans = 0

    lim = n + 1
    fact = [1,1]
    inv = [1,1]
    finv = [1,1]
    for i in range(2,lim+1):
        fact.append((fact[i-1] * i) % mod)
        inv.append(mod - inv[mod%i] * (mod // i) % mod)
        finv.append(finv[i-1] * inv[i] % mod)
    def mod_comb(n,k):
        if n<k:
            return 0
        if n<0 or k<0:
            return 0
        return fact[n] * (finv[k] * finv[n-k] % mod) % mod

    for i in range(n+1):
        temp = pow2[i]*pow8[n-i]*mod_comb(n,i)
        temp %= mod
        ans += temp 
        ans %= mod

    print(ans)

if __name__=="__main__":
    n = getval()
    main(n)

Measured memory_bytes: 174072
n = int(input())
xsum = []
xsub = []
for i in range(n): 
  a, b = map(int, input().split())
  xsum.append(a+b)
  xsub.append(a-b)
  

result = max(max(xsum)-min(xsum), max(xsub)-min(xsub))
print(result)

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

const lint mod = 1e+9 + 7;
lint n;
vector<lint> c;

// a^n mod pを計算　O(log n)
long long pow_mod(long long a, long long n, long long p) {
    if (n == 0) return 1;
    if (n & 1) return pow_mod(a, n - 1, p) * a % p;
    long long temp = pow_mod(a, n / 2, p);
    return temp * temp % p;
}

int main() {
    cin >> n;
    c.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());
    lint pow = pow_mod(4, n - 1, mod);
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        lint add = pow * (n - i + 1) % mod;
        add *= c[i];
        ans = (ans + add) % mod;
    }
    cout << ans << endl;
}

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

int main(){
  int a,b; cin>>a >>b;
  string s; cin>>s;
  string ans="Yes";
  for(int i=0;i<a+b-1;i++){
    if(i!=a){
      if(s[i]=='-')ans="No";
    }else{
      if(s[i]!='-')ans="No";
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int N; cin >> N;
  vector<pair<int, int>> ab(N), cd(N);
  for (int i = 0; i < N; ++i) {
    int a, b; cin >> a >> b;
    ab[i].first = a, ab[i].second = b;
  }
  for (int i = 0; i < N; ++i) {
    int c, d; cin >> c >> d;
    cd[i].first = c, cd[i].second = d;
  }

  sort(ALL(cd));

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int bx = cd[i].first;
    int by = cd[i].second;

    int ri = -1;
    for (int j = 0, ry = -1; j < ab.size(); ++j) {
      if (bx > ab[j].first && by > ab[j].second) {
        if (ab[j].second > ry) {
          ry = ab[j].second;
          ri = j;
        }
      }
    }

    if (ri != -1) {
      ans++;
      ab.erase(ab.begin() + ri);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter
rl=sys.stdin.readline
n=rl()
A=list(map(int,rl().split()))
q=int(rl())
D=Counter(A)
s=sum(A)
for _ in range(q):
  b,c=map(int,rl().split())
  s+=(c-b)*D[b]
  D[c]+=D[b]
  del D[b]
  print(s)

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

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	if (n * a > b) {
		cout << b << endl;
	}
	else {
		cout << n * a << endl;
	}
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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; }

int main() {
	string s;
	cin >> s;
	string ans = "hi";
	bool is_exist = false;
	rep(i, 5) {
		if (s == ans) is_exist = true;
		ans += "hi";
	}
	if (is_exist) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())

li = list(map(int,input().split()))
copiedListForSort = li.copy()
copiedListForSort.sort()

firstMedian = copiedListForSort[N//2 - 1]
secondMedian = copiedListForSort[N//2]
for i in range(N):
    if li[i] >= secondMedian:
        print(firstMedian)
    else:
        print(secondMedian)

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

typedef long long ll;
const int MOD = 998244353;
const int MAXN = 4010;

int Pow[MAXN], C[MAXN][MAXN];

ll calc(int cnt, int num, int n)
{
	ll ans = 0;
	for(int i = 0; i <= min(cnt, n); ++i)
		(ans += (ll)C[cnt][i] * Pow[i] % MOD * C[n + num - 1][i + num - 1] % MOD) %= MOD;
	return ans;
}

int main()
{
	C[0][0] = Pow[0] = 1;
	for(int i = 1; i < MAXN; ++i) Pow[i] = (Pow[i - 1] << 1) % MOD;
	for(int i = 1; i < MAXN; ++i)
	{
		C[i][0] = 1;
		for(int j = 1; j <= i; ++j)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}
	int k, n; scanf("%d %d", &k, &n);
	for(int i = 2; i <= 2 * k; ++i)
	{
		int cnt = min(k, i - 1) - max(1, i - k) + 1;
		if(i & 1) printf("%lld\n", calc(cnt >> 1, k - cnt, n));
		else printf("%lld\n", (calc(cnt >> 1, k - cnt, n) + calc(cnt >> 1, k - cnt, n - 1)) % MOD);
	}
	return 0;
}

Measured memory_bytes: 61568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define rep3(i, m, n) for(int i = m; i <= (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>
#define lint int64_t
typedef pair<int, int> PII;
#define INF 10000
typedef long long int ll;

int main(){
  int N,K;
  cin >> N >> K;

  vector<int> hi(N);
  rep(i,N) cin >> hi[i];

  vector<ll> f(N);

  f[0] = 0;
  rep2(i,1,K){
    if(i >= N) continue;
    f[i] = abs(hi[i] - hi[0]);
  }

  rep2(i,K,N){
    priority_queue<int, vector<int>, greater<int>> pq;
    rep3(j,1,K){
      pq.push(abs(hi[i]-hi[i-j]) + f[i-j]);
    }
    f[i] =  pq.top();

  }

  cout << f[N-1] << endl;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main{
  public static void main(String[] args)throws Exception{
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long C = sc.nextLong();
    long D = C-A-B;
    if(D <= 0 || D*D <= 4*A*B){
      System.out.println("No");
      return;
    }
    System.out.println("Yes");
  }
}

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

int main()
{
	int num1,num2,num3,num4,num5,num6,num7,num8,num9,num10,num11;
	for(int i=0;i<150;i++){
	cin>>num1>>num2>>num3>>num4>>num5>>num6>>num7>>num8>>num9>>num10;
	if(num1==0){
		return 0;
	}
	num11=num1-num2-num3-num4-num5-num6-num7-num8-num9-num10;
	cout<<num11;
	cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1160
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s = iterator.next().unwrap();
    let t = iterator.next().unwrap();

    let mut vec_s = s.chars().collect::<Vec<char>>();
    let mut vec_t = t.chars().collect::<Vec<char>>();

    vec_s.sort();

    vec_t.sort();
    vec_t.reverse();

    let s2 = vec_s.iter().map(|c| c.to_string()).collect::<Vec<String>>().join("");
    let t2 = vec_t.iter().map(|c| c.to_string()).collect::<Vec<String>>().join("");

    if s2 < t2 {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 4352
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	int c = ((a + k - 1) / k) * k;
	bool ans = c <= b;
	cout << (ans ? "OK" : "NG") << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  int h,n;
  cin >> h >> n;
  vector<int> a(n);
  ll sum=0;
  rep(i,n){
    cin >> a.at(i);
    sum+=a.at(i);
  }
  if(sum>=h){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

struct UnionFind {
    vector<int> par,rank,large;

    void init(int N){
        rank.assign(N,0);
        large.assign(N,1);
        par.resize(N);
        for(int i= 0; i < N; i++){
            par[i]=i;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if(rank[rx]<rank[ry]) {
            par[rx]=ry;
            large[ry]+=large[rx];
            large[rx]=0;
        }
        else {
            par[ry]=rx;
            large[rx]+=large[ry];
            large[ry]=0;
            if(rank[rx]==rank[ry])rank[x]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return large[root(x)];
    }
};

int main() {
  int N,M;
  cin>>N>>M;
  UnionFind tree;
  tree.init(N);
  vector<pair<int,int>> vp(M);
  rep(i,M){
    int x,y;
    cin>>x>>y;
    vp[i].first=x-1;
    vp[i].second=y-1;
  }
  vector<ll> ans(M+1,0LL);
  for(int i = M; i >=0; i--) {
    if(i==M) {
      ans[i]=(ll)N*(N-1)/2;
      continue;
    }
    if(tree.same(vp[i].first,vp[i].second)){
      ans[i]=ans[i+1];
      continue;
    }
    ans[i]=ans[i+1]-tree.size(vp[i].first)*tree.size(vp[i].second);
    tree.unite(vp[i].first,vp[i].second);
  }
  for(int i = 1; i < M+1; i++) {
    cout<<ans[i]<<endl;
  }
}
    

Measured memory_bytes: 4096
N, K = map(int, input().split())
AB = [[int(i) for i in input().split()] for _ in range(N)]

ret = 0
for A, B in AB :
    if A & ~K == 0 :
        ret += B
        
for i in range(30) :
    if K & (1 << i) == 0 :
        continue
        
    k = K
    k ^= 1 << i
    k |= (1 << i) - 1
    s = 0
    for A, B in AB :
        if A & ~k == 0 :
            s += B
            
    ret = max(ret, s)
    
print(ret)

Measured memory_bytes: 61144
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

ll MOD = 998244353;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> powM(N), comb(N);
    powM[0] = 1;
    comb[0] = 1;
    REP(i, N-1){
        powM[i + 1] = (powM[i] * (M - 1)) % MOD;
        ll tmp = comb[i] * (N - i - 1) % MOD;
        comb[i + 1] = (tmp * modinv(i + 1, MOD)) % MOD;

    }
    ll ans = 0;
    REP(i, K+1){
        ll hoge = (M * powM[N - i - 1]) % MOD;
        hoge = (hoge * comb[i]) % MOD;
        ans = (ans + hoge) % MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5936
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

				Scanner sc = new Scanner(System.in);

				long X = sc.nextLong();
				//何年後か数える変数と貯金100円設定
				int count = 0;
				double Saving = 100;
				//利子1％をし、小数点以下切り捨て
				//Xと貯金額（X）が同じになるまで繰り返す。
				while(Saving < X) {
					Saving = Saving * 1.01;
					Saving = Math.floor(Saving);
					count++;
				}
				//何年後か出力
				System.out.println((int)count);
			}
		}


Measured memory_bytes: 35784
#include "bits/stdc++.h"
using namespace std;

const int N = 1e5 + 5;
int in[N];



int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) scanf("%d", in + i);
    sort(in + 1, in + 1 + n);
    int i = upper_bound(in + 1, in + 1 + n, in[n] / 2) - in;
    int res = -1, mn = 0;
    if (i < n) {
        res = in[i];
        mn = min(in[i], in[n] - in[i]);
    }

    if (i > 1) {
        i--;
        int x = min(in[i], in[n] - in[i]);
        if(x >= mn) {
            res = in[i];
        }
    }

    printf("%d %d\n", in[n], res);

}

Measured memory_bytes: 640
# C 
n = int(input())
v_list = list(map(int, input().split()))

l_dict = dict()
r_dict = dict()

for i in range(n):
    v = v_list[i]
    if i % 2 == 0:
        if v in l_dict.keys():
            l_dict[v] += 1
        else:
            l_dict[v] = 1
    else:
        if v in r_dict.keys():
            r_dict[v] += 1
        else:
            r_dict[v] = 1 

l1 = 0
l2 = 0
l1_cnt = 0
l2_cnt = 0

for k in l_dict.keys():
    if l_dict[k] > l1_cnt:
        l2 = l1
        l2_cnt = l1_cnt
        l1 = k
        l1_cnt = l_dict[k]
    elif l_dict[k] > l2_cnt:
        l2 = k
        l2_cnt = l_dict[k]
        
r1 = 0
r2 = 0
r1_cnt = 0
r2_cnt = 0

for k in r_dict.keys():
    if r_dict[k] > r1_cnt:
        r2 = r1
        r2_cnt = r1_cnt
        r1 = k
        r1_cnt = r_dict[k]
    elif r_dict[k] > r2_cnt:
        r2 = k
        r2_cnt = r_dict[k]
        
if l1 != r1:
    res = n - (l1_cnt + r1_cnt)
else:
    res = n - (l1_cnt + max(l2_cnt, r2_cnt))
    
print(res)

Measured memory_bytes: 17524
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    string s;
    cin>>s;
    cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
    
    
    
    
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a, b, c, d, e, f;
  double x, y;

  while (scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f) > 0) {
    x = (double)(e * c - b * f)/ (a * e - d * b);
    y = (double)(a * f - d * c)/ (a * e - d * b);
    x == -0.0 ? x = 0.0 : x;
    y == -0.0 ? y = 0.0 : y;
    printf("%.3f %.3f\n", x, y);
  }

  return 0;
}

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

void answer1() {
  int N, K;
  cin >> N >> K;
  vector<int> bucket(N + 1, 0);
  int in;
  while (cin >> in) {
    bucket.at(in)++;
  }
  sort(bucket.begin(), bucket.end());

  int count = 0;
  for (int i = 0; i < bucket.size() - K; i++) {
    count += bucket.at(i);
  }
  cout << count << endl;
}

void answer2() {
  cin.tie(0);
	ios_base::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;
  int bucket[200001] = {0};
  int in;
  while (cin >> in) {
    bucket[in]++;
  }
  sort(bucket, bucket + N, greater<int>());

  int count = N;
  for (int i = 0; i < K; i++) {
    count -= bucket[i];
  }
  cout << count << endl;
}

int main() {
  //answer1();
  answer2();
}


Measured memory_bytes: 1024
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const int INF = 1e9 + 10;
const LL mod = 2e18 + 7;
const int maxn = 1e5 + 7;

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

int head[maxn << 1];
struct Edge {
    int to, next;
}edge[maxn << 1];
int tot;

void init() {
    memset(head, -1, sizeof(head));
    tot = 0;
}

void addedge(int u, int v) {
    edge[tot].to = v;
    edge[tot].next = head[u];
    head[u] = tot++;
}

LL qpow(LL a, LL b, LL p) {
    LL res = 1;
    while (b) {
        if (b & 1) res = (res * a) % p;
        a = (a * a) % p;
        b >>= 1;
    }
    return res;
}

int a[maxn];

int main() {
    int n;
    while (~sd(n)) {
        pd((n + 1) / 2);
    }
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

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

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int X;
  cin >> X;
  for(int i = 0; ; i++) {
    if(i*(i+1) >= 2*X) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n;cin>>n;
  ll h=n/3600;
  n-=(n/3600)*3600;
  ll m=n/60;
  n-=(n/60)*60;
  out(h<<":"<<m<<":"<<n);


  return 0;
}



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

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//long n = long.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int n = vs[0];
			int k = vs[1];
			int ans = n % k == 0 ? 0 : 1;
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
n = int(input())
a_str = input()
print(a_str)
a = list(map(int, a_str.split()))

for i in range(0, n-1):
    v = a[i+1]
    j = i
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
        #print(i, a, v, j+1)
    a[j+1] = v
    print(' '.join(map(str, a)))



Measured memory_bytes: 5596
import math
a,b,c = map(float, input().split())
print(0.5*a*b*math.sin(math.radians(c)))
print(math.sqrt(a*a + b*b -2*a*b*math.cos(math.radians(c)))+a+b)
print(b*math.sin(math.radians(c)))


Measured memory_bytes: 5688