akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        long[] nh = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nh[0];
        var h = nh[1];

        long[] a = new long[n];
        long[] b = new long[n];
        for (int i = 0; i < n; i++)
        {
            long[] tmp = Console.ReadLine().Split().Select(long.Parse).ToArray();
            a[i] = tmp[0];
            b[i] = tmp[1];
        }

        var ok = false;

        //a < b の場合全て投げる
        long amax = a.Max();
        Array.Sort(b);
        Array.Reverse(b);
        long sum = 0;
        long k = 0;
        while (k < n)
        {
            if (b[k] < amax)
            {
                break;
            }
            sum += b[k];
            k++;
            if(sum >= h) 
            {
                ok = true;
                break;
            }
        }

        if(ok)
        {
            Console.WriteLine(k);
            return;
        }

        //残りはaで削る
        k += (long)Math.Ceiling((decimal)(h - sum) / (decimal)amax);
        Console.WriteLine(k);
    }
}


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

int main(){
    ll k;
    cin >> k;
    queue<ll> que;
    for(int i=0;i<9;i++){
        que.push(i+1);
    }
    /*
    if(k<10){
        cout << k << endl;
        return 0;
    }
    */
    for(int i=0;i<k-1;i++){
        ll v = que.front();
        //cout << v << endl;
        ll a1,a2,a3;
        que.pop();
        ll x = v%10;
        if(x == 0){
            a1 = 10 * v;
            a2 = 10 * v + 1;
            que.push(a1);
            que.push(a2);
        }
        else if(x == 9){
            a1 = 10 * v + 8;
            a2 = 10 * v + 9;
            que.push(a1);
            que.push(a2);
        }
        else{
            a1 = 10 * v + x -1;
            a2 = 10 * v + x;
            a3 = 10 * v + x + 1;
            que.push(a1);
            que.push(a2);
            que.push(a3);
        }
    }
    cout << que.front() << endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;

class test
{
    public static void Main()
    {
        var num = int.Parse(Console.ReadLine());
        var datas = Console.ReadLine().Trim().Split(' ');

        var li = new List<int>();

        for (var i = 0; i < num;i++)
        {
            li.Add(int.Parse(datas[i]));
        }

        li.Sort();
        li.Reverse();

        var sum = 0;
        var max = li[0];

        for (var i = 1; i < li.Count; i++)
        {
            sum += li[i];
        }

        if(sum>max)
        {
            Console.WriteLine("Yes");

        }
        else
        {
            Console.WriteLine("No");
        }

    }
}

Measured memory_bytes: 13140
sx, sy, tx, ty = map(int, input().split())
ans = (   "U" * (ty - sy)     + "R" * (tx - sx) +
          "D" * (ty - sy)     + "L" * (tx - sx) +
    "L" + "U" * (ty - sy + 1) + "R" * (tx - sx + 1) + "D" +
    "R" + "D" * (ty - sy + 1) + "L" * (tx - sx + 1) + "U"
    )
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define int long long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int n;
    cin>>n;
    if(n%2==1){
        cout<<0;
        return;
    }
    int ans=0;
    n/=(int)2;
    while(n>0){
        n/=(int)5;
        ans+=n;
    }
    cout<<ans;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

const int mod = 1e9+7;
const int N = 1e5+5; 

int main(){
	fast;
	ll p = 100;
	ll x;  cin >> x;
	ll ans = 0;
	
	while(p < x){
	    p = (p + p / 100);
	    ans++;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
    FOR(i,2,p) {
      if (p%i==0) return false;
    }
  return true;
}

int main(){
  int n;
  long t,a[200010],p;
  cin >> n;
  REP1(i,n){
    cin >> a[i];
  }
  if (a[1]!=0) {
    cout << -1;
    return 0;
  }
  p = t = 0;
  REP1(i,n){
    if(p+1==a[i]){
      p = a[i];
    } else if (p+1>a[i]) {
      t += p;
      p = a[i];
    } else if (p+1<a[i]) {
      cout << -1;
      return 0;
    }
  }
  t += p;
  cout << t;
  return 0;
}

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

bool isPrime(int x){
    if(x==1)return 0;
    if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i++)if(x%i==0)return 0;
    return 1;
}
int main() {
    string n; cin >> n;
    if(n=="ABC"){
        cout<<"ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3548
def mixing_experiment(N: int, Ma: int, Mb: int, drags: list)->int:
    INF = float('inf')

    max_A = min(100, N * max(a for a, _, _ in drags))
    max_B = min(100, N * max(b for _, b, _ in drags))

    dp = [[INF] * (max_B+1) for _ in range(max_A+1)]
    dp[0][0] = 0

    for (a, b, c) in drags:
        for ca in range(max_A-a, -1, -1):
            for cb in range(max_B-b, -1, -1):
                dp[ca+a][cb+b] = \
                    min(dp[ca+a][cb+b], dp[ca][cb] + c)
        dp[a][b] = min(dp[a][b], c)

    ans = INF
    for ca in range(1, max_A+1):
        for cb in range(1, max_B+1):
            if ca * Mb != cb * Ma:
                continue
            ans = min(ans, dp[ca][cb])

    return ans if 0 < ans and ans < INF else -1


if __name__ == "__main__":
    N = 0
    N, Ma, Mb = map(int, input().split())
    drags = [tuple(int(s) for s in input().split()) for _ in range(N)]
    ans = mixing_experiment(N, Ma, Mb, drags)
    print(ans)


Measured memory_bytes: 3188
#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(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    // if sort is required
    sort(res.begin(), res.end());
    return res;
}

void Main() {
	int N, M; cin >> N >> M;
	auto divs = divisor(M);
	ll res = 0;
	for (ll v : divs) {
		if (M / v < N) continue;
		res = max(res, v);
	}
	cout << res << endl;
}

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


Measured memory_bytes: 256
"""

Wolfram Alpha

(A^5 - B^5)/(A - B) = A^4 + A^3 B + A^2 B^2 + A B^3 + B^4

"""

import sys

X = int(sys.stdin.readline().rstrip())

a = 0
while True:
	b = a
	target = (a**5) - X
	while (b**5) > target:
		b -= 1
	if (b**5) == target:
		print("%d %d" % (a, b))
		sys.exit(0)
	a += 1


Measured memory_bytes: 9184
#include <iostream>
using namespace std;
int main(void){
   int n,k,p;
   cin >> n;
   for(int i=0; i<n; i++){
       cin >> k >> p;
       int x;
       x=k%p;
       if(x==0){
           cout << p << endl;
       }
       else{
           cout << x << endl;
       }
   }
}


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

int dp[3001];
vector<int> v[3001];

int dfs(int x){
  if(dp[x]!=0) return dp[x];
  if(v[x].empty()) return dp[x]=-1;
  int ret=-1;
  rep(i,v[x].size()){
    if(dfs(v[x][i])==-1)
      ret=1;
    }
  return dp[x]=ret;
  }

int main(){
  int n;cin>>n;
  int a[n];
  rep(i,n)cin>>a[i];
  rep(i,n-1){
    int l,r;
    cin>>l>>r;
    l--;r--;
    if(a[l]>a[r])v[l].push_back(r);
    if(a[r]>a[l])v[r].push_back(l);
    }
  rep(i,n)dp[i]=0;
  rep(i,n)
   if(dfs(i)==1) cout<<i+1<<" ";
  cout<<endl;
  return 0;  
  }


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ans = 0;
  int K;
  cin >> K;
  while(N--) {
    int a;
    cin >> a;
    if(a >= K) ans++;
  }
  cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	r := iScan()
	d := iScan()
	x := iScan()
	for i := 0; i < 10; i++ {
		x = r*x - d
		fmt.Println(x)
	}
}


Measured memory_bytes: 1772
n = int(input())
for i in range(n):
    x = input()
    y = input()
    if len(x) > 80 or len(y) > 80:
        print("overflow")
        continue
    s = ""
    rx = x[::-1]
    ry = y[::-1]
    lx = len(x)
    ly = len(y)
    if lx > ly:
        ml = lx
    else:
        ml = ly
    c = 0
    for j in range(ml + 1):
        x1 = 0
        y1 = 0
        if j < lx:
            x1 = int(rx[j])
        if j < ly:
            y1 = int(ry[j])
        c1 = x1 + y1 + c
        s += str(c1 % 10)
        c = c1 // 10

    rs = s[::-1]
    result = ""
    for j in range(len(rs)):
        if rs[j] != "0":
            result = rs[j:]
            break

    if len(result) > 80:
        print("overflow")
    elif result == "":
        print(0)
    else:
        print(result)

Measured memory_bytes: 7620
#!/usr/bin/env python3

N, M = map(int, input().split())


sc = []
for i in range(M):
    s, c = map(int, input().split())
    sc.append([s,c])


sc = sorted(sc)
if N == 1: start = 0
else: start = 10 ** (N-1)
end = 10 ** N

ans = -1
for i in range(start, end):
    si = str(i)
    f = True
    for j in range(M):
        if si[sc[j][0]-1] != str(sc[j][1]):
            f = False
            break
    if f:
        ans = i
        break

    
print(ans)


Measured memory_bytes: 38256
s = input()
n = len(s)
s = s.replace('RL','xy')

rls = []
curr_s = 'R'
cnt = 1
ind = 0
for i in range(1,n):
    if s[i] == 'y':
        curr_s = 'y'
        cnt += 1
    elif curr_s == s[i]:
        cnt += 1
    else:
        rls.append((curr_s,cnt,ind))
        ind += cnt
        cnt = 1
        curr_s = s[i]

# if s[-1] != 'y':
rls.append((curr_s,cnt, ind))

# print(s)
# print(rls)

ans = [0]*n
curr_i = 0
for i in range(len(rls)):
    rl_r = 1
    rl_l = 1
    if rls[i][0] == 'y':
        if rls[i-1][0] == 'R':
            rl_r += rls[i-1][1]//2
            rl_l += (rls[i-1][1]+1)//2
        if i+1 < len(rls) and rls[i+1][0] == 'L':
            rl_l += rls[i+1][1]//2
            rl_r += (rls[i+1][1]+1)//2
        ind = rls[i][2]
        ans[ind] = rl_r
        ans[ind+1] = rl_l


print(*ans)

Measured memory_bytes: 86404
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	// 入力
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++)
	{
		cin >> L[i];
	}
	
	// 昇順にソート
	sort(L.begin(), L.end());
	
	int sideLength = 0;
	for (int i = 0; i < N - 1; i++)
	{
		sideLength += L[i];
	}
	
	// 定理 : 一番長い辺が他のN - 1辺の長さの合計よりも真に短い場合
	if (L[N - 1] < sideLength)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 7
#define C 61
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int f[N*C][1<<N],p[N];
int n,c;
int h[N];
double ans=0;
inline double ksm(double a,int b)
{
	double ans=1;
	while(b){if(b&1)ans*=a;b>>=1;a*=a;}
	return ans;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),c=read();
	for(register int i=1;i<=n;i++)h[i]=read();
	sort(h+1,h+n+1);
	int fac=1,tmp;
	for(register int i=1;i<n;i++)fac*=i,p[i]=i;tmp=fac;
	while(tmp--)
	{
		memset(f,0,sizeof(f));
		f[h[n]*n][0]=1;
		for(register int i=0;i<n*c;i++)
		{
			if(i%n==0)continue;
			int x=p[i%n];
			for(register int S=0;S<((1<<(n-1))-1);S++)
			{
				if(S&(1<<(x-1)))continue;
				for(register int j=i;j<=n*c;j++)f[min(n*c,max(j,i+n*h[x]))][S|(1<<(x-1))]+=f[j][S];
			}
		}
		ans+=f[n*c][(1<<(n-1))-1];next_permutation(p+1,p+n);
	}
	double p=(double)fac;
	printf("%.13lf\n",ans/p/ksm(c,n-1));
	return 0;
}


Measured memory_bytes: 3960
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))
    eats = 0
    N = input_number()
    D, X = input_number_list()
    for i in range(N):
        A = input_number()
        eat = D // A
        if D % A != 0:
            eat += 1
        eats += eat
    print(eats + X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
a, b = map(int, input().split())
s = list(input())
num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
if s[a] == '-' and len(s) == (a+b+1) and s.count('-')==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>

using namespace std;



int main(){
    string s;
    while(cin>>s){
        string temp;
        int a,b,c;
        bool flag=true;
        for(int i=9; i>=0; i--){
            if(i==0){
                bool flag=false;
                temp = s;
                for(int j=0; j<temp.size(); j++){
                    if(temp[j]=='+'||temp[j]=='=')temp[j]=' ';
                }
                stringstream stream;
                stream<<temp;
                string temp2;
                while(stream>>temp2){
                    if(temp2.length()!=1&&temp2[0]=='X'){
                        flag=true;
                        break;
                    }
                }
                if(flag)break;
            }
            
            temp = s;
            a=0;
            b=0;
            c=0;
            for(int j=0; j<temp.size(); j++){
                if(temp[j]=='X')temp[j]=i+'0';
            }
            int k=0;
            while(temp[k]!='+'){
                a=a*10+temp[k]-'0';
                k++;
            }
            k++;
            while(temp[k]!='='){
                b=b*10+temp[k]-'0';
                k++;
            }
            k++;
            while(k!=temp.length()){
                c=c*10+temp[k]-'0';
                k++;
            }

            if(a+b==c){
                cout<<i<<endl;
                flag=false;
                break;
            }
            
        }
        
        if(flag)cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 1208
def factor(num):
    factor_set = set()
    for i in range(1,num+1):
        if num%i == 0:
            factor_set.add(i)
    return factor_set

l = [int(i) for i in input().split(" ")]
a = l[0]
b = l[1]
k = l[2]

and_list = sorted(list(factor(a) & factor(b)),reverse=True)
print(and_list[k-1])


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

class UnionFind {
public:
   vector<int> parent, rank;

   UnionFind(){}

   UnionFind(int size) {
      parent.resize(size, 0);
      rank.resize(size, 0);
      for (int i = 0; i < size; i++) {
         parent[i] = i;
      }
   }

   void init(int size) {
      parent.resize(size, 0);
      rank.resize(size, 0);
      for (int i = 0; i < size; i++) {
         parent[i] = i;
      }
   }

   int find(int x) {
      if(parent[x] == x) {
         return x;
      } else {
         return parent[x] = find(parent[x]);
      }
   }

   void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x == y) return;

      if (rank[x] < rank[y]) {
         parent[x] = y;
      } else {
         parent[y] = x;
         if (rank[x] == rank[y]) rank[x]++;
      }
   }

   bool same(int x, int y) {
      return find(x) == find(y);
   }
};

int N, M;
int p[111111];
int x[111111];
int y[111111];

int main() {
   cin >> N >> M;
   UnionFind uf(N+100);
   rep (i, N) {
      cin >> p[i];
   }
   rep (i, M) {
      cin >> x[i] >> y[i];
      uf.unite(x[i], y[i]);
   }

   int cnt = 0;
   rep (i, N) {
      if (uf.same(p[i], i+1)) cnt++;
   }

   cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 2176
def main():

        X, Y = list(map(int, input().split()))
        ans = 'No'
        for i in range(X+1):
                temp = i*2 + (X-i)*4
                if temp==Y:
                        ans = 'Yes'
                        break

        return ans


if __name__=="__main__":
        ans = main()
        print(ans)

Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
using pii = pair<int, int>;

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	vector<pii> b(n);
	for(int i = 0; i < n; ++i){ b[i] = pii(a[i], i); }
	sort(b.begin(), b.end(), greater<pii>());
	vector<int> solution;
	for(int i = 0; i < n; ++i){
		if(--b[i].first < 0){
			cout << -1 << endl;
			return 0;
		}
		solution.push_back(b[i].second);
	}
	auto last = b.back();
	b.pop_back();
	while(k--){
		for(int i = 0; i + 1 < n; ++i){
			if(--b[i].first < 0){
				cout << -1 << endl;
				return 0;
			}
			solution.push_back(b[i].second);
		}
		const auto tmp = b.back();
		b.pop_back();
		b.push_back(last);
		last = tmp;
		sort(b.begin(), b.end(), greater<pii>());
	}
	cout << solution.size() << endl;
	for(const auto x : solution){
		cout << x + 1 << " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
/// @pSaurabh

#include <bits/stdc++.h>

using namespace std;

#define read(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define print(a, n) for(int i = 0; i < n; i++) cout << a[i] << " ";

typedef long long ll;
const ll mod = 1e9 + 7;
const int maxSize = 1e5 + 4;

void fast(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout .tie(0);
}

int a[maxSize];
int b[maxSize];
int c[maxSize];

map <pair <int, char>, int> mp;

int solve(int i, char cl){
	if(i == -1) return 0;
	if(mp.count({i, cl})){
		// cout << "Used\n";
		return mp[{i, cl}];
	}

	int a1 = 0, a2 = 0, a3 = 0;
	if(cl != 'a') a1 = a[i] + solve(i - 1, 'a');
	if(cl != 'b') a2 = b[i] + solve(i - 1, 'b');
	if(cl != 'c') a3 = c[i] + solve(i - 1, 'c');

	int mx = max(a1, max(a2, a3));

	if(mx == a1) mp[{i, cl}] = a1;
	if(mx == a2) mp[{i, cl}] = a2;
	if(mx == a3) mp[{i, cl}] = a3;

	return mx; 
}

int main(){
	// fast();

	int n;
	cin >> n;

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

	cout << solve(n - 1, 'k');

	return 0;
}


Measured memory_bytes: 32640
//In the name of ALLAH
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

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

const long long maxn = 2e5 + 5;
const long long INF = 4e18 ;
const long long M = 1e9 + 7;
const int lg = 21;

ll x, y;
vector<ll> p, px, py;
map<ll, ll> mp;

bool prime(ll n){
	for(int i = 2; i * i <= n; i++)
		if(n % i == 0)
			return 0;
	return 1;
}

void f(ll x, vector<ll> &p){
	for(ll i = 2; i * i <= x; i++){
		int l = 0;
		if(x % i != 0)
			continue;
		while(x % i == 0)
			x /= i, l++;
		p.pb(i);
	}
	if(x > 1)
		p.pb(x);
}

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> x >> y;
	if(x % y == 0)
		return cout << -1 << endl, 0;
	f(x, px);
	f(y, py);
	for(int i = 2; i < 10000; i++){
		if(prime(i))
			p.pb(i);		
	}
	for(int i = 0; i < p.size(); i++){
		if((x * p[i]) % y != 0)
			return cout << x * p[i] << endl, 0;
	}
	for(auto u : px){
		if((u * x) % y != 0)
			return cout << u * x << endl, 0;
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
def solve(string):
    n, k, *da = map(int, string.split())
    t, i = [True] * n, 0
    for _ in range(k):
        d = da[i]
        for j in da[i + 1:i + 1 + d]:
            t[j - 1] = False
        i += d + 1
    return str(sum(t))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9284
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
 
int main() {
     string str;
     int q;
     cin >> str >> q;
     for (int i = 0; i < q; i++) {
         string cmd, repStr;
         int from, to;
         cin >> cmd >> from >> to;
 
         if (cmd == "print") {
             cout << str.substr(from, to - from + 1) << endl;
         }
         if (cmd == "replace") {
             cin >> repStr;
             str.replace(from, to - from + 1, repStr); 
         }
         if (cmd == "reverse") {
             string reverseStr = "";;
             for (int j = from; j <= to; j++) {
                reverseStr.insert(0, str.substr(j, 1));
             }
             str.replace(from, to - from + 1, reverseStr); 
         }
     }
}

Measured memory_bytes: 3184
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define ll long long 
#define pre(a,b) cout<<fixed<<setprecision(a)<<b<<"\n";//a for precision b for answer
#define mp make_pair
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define pb push_back 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b) 
#define forn(n) for(ll i=0;i<n;i++) 
#define ff first
#define ss second
#define MAX 1e18;
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
#define vmin *min_element
#define vmax *max_element
const int MOD = 1e9 + 7;
const int v1=1e5+5;
#define pi 3.141592653589793238
const int N=2e5+5;
 
 
//cout<<"Case #"<<p<<": "<<;
//f ile input  freopen("input.txt","r",stdin); 
//file output freopen("output.txt","w",stdout);
 
using namespace std;

int32_t main()
{
  IOS;
  string a;
  string b;
  cin>>a>>b;
  ll dp[a.length()+1][b.length()+1]={};
  forn(b.length()+1)
  dp[0][i]=0;
  forn(a.length()+1)
  dp[i][0]=0;
  string ans="";
  for(ll i=1;i<a.length()+1;i++)
  {
    for(ll j=1;j<b.length()+1;j++)
    {
      if(a[i-1]==b[j-1])
      {
        dp[i][j]=dp[i-1][j-1]+1;
      }
      else
        dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
    }
  }
  ll i=a.length();ll j=b.length();
  while(i>0&&j>0)
  {
    //cout<<dp[i][j]<<"\n";
    if(dp[i][j]==dp[i-1][j])
    i--;
    else if(dp[i][j]==dp[i][j-1])
    j--;
    else
    {
      ans=a[i-1]+ans;
      i--;j--;
    } 
  }
  cout<<ans;
}


Measured memory_bytes: 70656
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,a;cin>>n>>a;
  ll dp[60][60][2510];
  dp[0][0][0]=1;
  for(ll k=1;k<=n;k++){
    ll x;cin>>x;
    rep(i,n+1){
      rep(j,n*a+1){
        if(i==0||j<x){
          dp[k][i][j]=dp[k-1][i][j];
          continue;
        }
        dp[k][i][j]=dp[k-1][i][j]+dp[k-1][i-1][j-x];
      }
    }
  }
  ll ans=0;
  for(int i=1;i<=n;i++){
    ans+=dp[n][i][i*a];
  }
  cout<<ans<<endl;
}
    


Measured memory_bytes: 60160
program ABC079C
    implicit none
    integer(8)::A,B,C,D,N,op(2),ans(3),i,j,k,flg
    character(1)::out(3)
    read*,N
    A=N/1000
    B=(N-A*1000)/100
    C=(N-A*1000-B*100)/10
    D=mod(N,10)
    op(1)=1
    op(2)=-1
    flg=0

    do i=1,2
        ans(1)=op(i)
        do j=1,2
            ans(2)=op(j)
            do k=1,2
                ans(3)=op(k)
                if(A+ans(1)*B+ans(2)*C+ans(3)*D==7)then
                    flg=1
                    exit
                end if
            end do
            if(flg==1)exit
        end do
        if(flg==1)exit
    end do

    do i=1,3
        if(ans(i)==1)out(i)="+"
        if(ans(i)==-1)out(i)="-"
    end do

    print'(i0,A,i0,A,i0,A,i0,A)',A,out(1),B,out(2),C,out(3),D,"=7"
end program ABC079C

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <limits>

int main(void)
{
	int32_t first  = 0;
	int32_t second = 0;

	while( std::cin >> first )
	{
		std::cin >> second;

		std::cout << static_cast<int32_t>(std::log10(first + second))+1 << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3400
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n = int(input())
    aa = list(map(int, input().split()))
    s = 0
    # s=総xorを求める
    for a in aa:
        s ^= a
    # print(format(s, "b"))

    # sで1がたっている桁はaの選び方で影響を受けないので、aのその桁を0にする
    for i in range(n):
        # print(format(aa[i], "b"), end=" ")
        aa[i] &= ~s
        # print(format(aa[i], "b"))

    # 掃き出し法
    rnk = 0  # ランク
    for k in range(60, -1, -1):
        # k桁目に1がたっているaを探す(kは0-indexed)
        mask = 1 << k
        for i in range(rnk, n):
            if mask & aa[i]:
                aa[i], aa[rnk] = aa[rnk], aa[i]
                break
        else:
            continue
        # 見つかったa以外のk桁目をすべて0にするため、k桁目が1のaに、見つかったaをxorする
        for i in range(n):
            if i == rnk: continue
            if aa[i] & mask:
                aa[i] ^= aa[rnk]
        rnk += 1

    # できるだけ上位に1が来るよう、aを選んでいく
    red = 0
    for i in range(rnk):
        red ^= aa[i]
    blue = s ^ red
    # red+blue=(red xor blue)+2*(red & blue)
    print(s + 2 * (red & blue))

main()


Measured memory_bytes: 15924
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define UM unordered_map
#define MP map
#define ST set
#define US unordered_set
#define V vector
#define S string
#define D deque
#define L list
#define Q queue
#define PQ priority_queue
#define DB double
#define LDB long double
#define FOR(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define FFOR(i, n) for (int(i) = 0; (i) <= (n); ++(i))
#define RFOR(i, n) for (int(i) = (n)-1; (i) >= 0; --(i))
#define all(v) (v).begin(), (v).end()

const int dr[] = {0, 1, 0, -1};
const int dc[] = {1, 0, -1, 0};

int nxt()
{
    int n;
    cin >> n;
    return n;
}

LL llnxt()
{
    LL l;
    cin >> l;
    return l;
}

LDB ldbnxt()
{
    LDB n;
    cin >> n;
    return n;
}

DB dbnxt()
{
    DB n;
    cin >> n;
    return n;
}

void bfs(VVI &graph, int start)
{
    int n = graph.size();
    Q<int> q;
    V<bool> visited(n);
    q.push(start);
    visited[start] = true;
    while (not q.empty())
    {
        auto curr = q.front();
        q.pop();
        for (auto i : graph[curr])
        {
            if (not visited[i])
            {
                q.push(i);
                visited[i] = true;
            }
        }
    }
}

int main()
{
    int r, c, k, res = 0;
    cin >> r >> c >> k;
    VVI v(r, VI(c));
    FOR(i, r)
    FOR(j, c)
    {
        char c;
        cin >> c;
        v[i][j] = c == '#';
    }

    for (int i = 0; i < (1 << r + c); ++i)
    {
        int cnt = 0;
        FOR(rr, r)
        FOR(cc, c)
        {
            if (((i >> rr) & 1) and ((i >> r + cc) & 1) and v[rr][cc])
                ++cnt;
        }
        if (cnt == k)
            ++res;
    }
    cout << res;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	int N, X, T;

	cin >> N >> X >> T;
	cout << (((N - 1) / X) + 1)*T;
}

Measured memory_bytes: 3596
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
XY = []
N.times do |i|
  XY[i] = get_ints
end

# check mods
mod = nil
incorrect = false
XY.each do |x, y|
  test = (x + y) % 2
  mod = test if mod.nil?
  if mod != test
    incorrect = true
    break
  end
end

if incorrect
  puts '-1'
else
  m = mod == 0 ? 32 : 31
  d = 31.times.map { |x| 2 ** x }
  d.push(1) if m == 32
  puts m
  puts d.join(' ')

  XY.each do |x, y|
    u = x + y
    v = x - y
    ux = ((u + (2 ** 31 - 1))/2).to_s(2).rjust(31, '0').split('').reverse
    vx = ((v + (2 ** 31 - 1))/2).to_s(2).rjust(31, '0').split('').reverse
    stock = ux.zip(vx).map do |ud, vd|
      uv = ud + vd
      case uv
      when '00'
        'L'
      when '01'
        'D'
      when '10'
        'U'
      when '11'
        'R'
      end
    end
    if u % 2 == 0
      stock.push('R')
    end
    puts stock.join

    # test = stock.join
    # ans = [0, 0]
    # test.split('').each.with_index do |s, i|
    #   case s
    #   when 'L'
    #     ans[0] -= d[i]
    #   when 'R'
    #     ans[0] += d[i]
    #   when 'D'
    #     ans[1] -= d[i]
    #   when 'U'
    #     ans[1] += d[i]
    #   end
    # end
    # p ans
  end
end


Measured memory_bytes: 14404
import sys
readline = sys.stdin.readline
class Node:
    __slots__ = ['value', 'left', 'right']
    def __init__(self, value = None, left = None, right = None):
        self.value = value
        self.left = left
        self.right = right
class BinTree:
    def __init__(self):
        self._tree = None
        self._node_list = set()
    def insert(self, value):
        self._node_list.add(value)
        p = None
        c = self._tree
        while c is not None:
            p = c
            if value < c.value:
                c = c.left
            else:
                c = c.right
        if p is None:
            self._tree = Node(value)
        elif value < p.value:
            p.left = Node(value)
        else:
            p.right = Node(value)
    def find(self, value):
        print("yes" if value in self._node_list else "no")
    def preoder_walk(self):
        def preoder(node):
            result = []
            if node is not None:
                result.extend([node.value])
            if node.left is not None:
                result.extend(preoder(node.left))
            if node.right is not None:
                result.extend(preoder(node.right))
            return result
        return preoder(self._tree)
    def inorder_walk(self):
        def inorder(node):
            result = []
            if node is not None:
                result.extend(inorder(node.left))
                result.append(node.value)
                result.extend(inorder(node.right))
            return result
        return inorder(self._tree)
n = int(input())
tree = BinTree()
for _ in range(n):
    com = readline().split()
    if com[0] == "insert":
        tree.insert(int(com[1]))
    elif com[0] == "find":
        tree.find(int(com[1]))
    else:
        print(" " + " ".join(map(str, tree.inorder_walk())))
        print(" " + " ".join(map(str, tree.preoder_walk())))



Measured memory_bytes: 93216
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);

    int a,b;

    a = sc.nextInt();
    b = sc.nextInt();

    if(a+b==15)
        System.out.println("+");
    else if(a*b==15)
        System.out.println("*");
    else
        System.out.println("x");
    }
}

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

int main() {
	string N,ans;
	int N1,N2,N3,N4;
	cin >> N;
	N1 = N[0];
	N2 = N[1];
	N3 = N[2];
	N4 = N[3];
	if (N1 != N2)
	{
		if (N2 != N3)
		{
			ans = "No";
		}
		else
		{
			if (N2 == N4) 
			{
				ans = "Yes";
			}
			else
			{
				ans = "No";
			}
		}
	}
	else
	{
		if (N1 == N3)
		{
			ans = "Yes";
		}
		else
		{
			ans = "No";
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T>inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}
int n,m,k;
const int N=1e5+10;
struct edge{int to,next;}a[N<<1];
typedef long long ll;
int head[N],cnt=0;
inline void add(int x,int y){a[++cnt]=(edge){y,head[x]};head[x]=cnt;}
int ans=0;int du[N];
namespace Sol{
	int ans=1;queue<int> Q;
	typedef pair<int,int> PA;
	typedef multiset<int> Mset;
	Mset S[N];
	Mset::iterator it1,it2,iter;
	int vis[N];int val[N];	
	void work() {
		for(int u=1;u<=n;++u) {
			if(vis[u]) continue;
			for(int v,i=head[u];i;i=a[i].next){
				v=a[i].to;if(vis[v]) continue;
				S[u].insert(v);
			}
		}int sum=0;
		for(int u=1;u<=n;++u) {
			if(vis[u]) continue;
			if(S[u].size()==2) {
				it1=S[u].begin(),it2=it1;++it2;
				int v1=*it1,v2=*it2;
				S[v1].erase(S[v1].find(u)),S[v2].erase(S[v2].find(u));
				if(v1==v2) ++sum;else S[v1].insert(v2),S[v2].insert(v1);
				S[u].clear();vis[u]=1;
			}
		}
		int ret=0;int mx=0;
		for(int i=1;i<=n;++i) {
			if(vis[i]) continue;
			++ret;mx=max(mx,(int)S[i].size());
		}
		sum+=mx/2;
		if(ret>=3||sum>=3) puts("Yes");
		else puts("No");
	}
}
int main()
{
	init(n),init(m);
	int u,v;
	for(int i=1;i<=m;++i) {init(u),init(v);add(u,v),add(v,u);++du[u],++du[v];}
	for(int i=1;i<=n;++i) {if(du[i]&1) return puts("No"),0;}
	Sol::work();
	return 0;
}


Measured memory_bytes: 17024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	int N,x;
	cin>>N>>x;
	
	if(x==1||x==2*N-1)cout<<"No";
	else if(x<=N){
		cout<<"Yes"<<endl;
		for(int i=N+x;i<=2*N-1;i++)cout<<i<<endl;
		rep1(i,x+N-1)cout<<i<<endl;
	}
	else{
		cout<<"Yes"<<endl;
		for(int i=x-N;i>=1;i--)cout<<i<<endl;
		for(int i=2*N-1;i>=x-N+1;i--)cout<<i<<endl;
	}
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A,B; cin >> A >> B;
    int alen = A.length();
    int blen = B.length();
    if(alen>blen){
        cout << "GREATER" << endl;
    }else if(alen<blen){
        cout << "LESS" << endl;
    }else{
        REP(i,alen){
            int a = A[i] - '0';
            int b = B[i] - '0';
            if(a > b){
                cout << "GREATER" << endl;
                return 0;
            }else if(a < b){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }

}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int Q;

signed main() {
    cin >> Q;
    priority_queue<int> left;
    priority_queue<int, vector<int>, greater<int>> right;
    left.push(-1e12);
    right.push(1e12);
    int h = 0;
    for (int i = 0; i < Q; i++) {
        int c;
        cin >> c;
        if (c == 1) {
            int a, b;
            cin >> a >> b;
            if (a < left.top()) {
                h += left.top() - a;
                left.push(a);
                left.push(a);
                right.push(left.top());
                left.pop();
            } else if (left.top() <= a && a <= right.top()) {
                left.push(a);
                right.push(a);
            } else if (right.top() < a) {
                h += a - right.top();
                right.push(a);
                right.push(a);
                left.push(right.top());
                right.pop();
            }
            h += b;
        } else {
            cout << left.top() << " " << h << endl;
        }
    }

}

Measured memory_bytes: 4588
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

typedef long long ll;
ll n, h, mx, c, a, b[N];
int main()
{
	ll i;
	cin >> n >> h;
	for (i = 0; i < n; i++) scanf("%lld %lld", &a, &b[i]), mx = max(mx, a);
	sort(b, b + n);
	for (i = n - 1; i >= 0; i--) if (b[i] > mx && h > 0) h -= b[i], c++;
	if (h > 0) c += (h + mx - 1) / mx;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define ll long long
using namespace std;

int main(){
  ll A,B;cin>>A>>B;
  ll tmpA=A;ll tmpB=B;
  vector<ll> Avec={1};
  vector<ll> Bvec={1};
  for(ll i=2;i<=sqrt(tmpA);i++){
      if(tmpA%i==0){
        Avec.push_back(i);
        while(tmpA%i==0)tmpA/=i;
      }
  }
if(tmpA!=1)Avec.push_back(tmpA);

  for(ll i=2;i<=sqrt(tmpB);i++){
    if(tmpB%i==0){
      Bvec.push_back(i);
      while(tmpB%i==0)tmpB/=i;
    }
}
if(tmpB!=1)Bvec.push_back(tmpB);

ll ans=0;

for(ll i=0;i<Avec.size();i++){
  for(ll k=0;k<Bvec.size();k++){
    if(Avec[i]==Bvec[k]){
    ans++;
    break;
    }
  }
}

cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }
typedef tuple<ll, ll, ll, ll> tp;

ll h, w, k;
ll sy, sx, gy, gx;
vector<vector<char>> c;

vector<vector<ll>> d[4];

void dijkstra() {
  priority_queue<tp, vector<tp>, greater<tp>> pq;
  rep(i, 4) {
    pq.push(make_tuple(0, i, sy, sx));
    d[i][sy][sx] = 0;
  }

  while (!pq.empty()) {
    tp res = pq.top();
    pq.pop();
    ll resd = get<0>(res), rdir = get<1>(res), ry = get<2>(res), rx = get<3>(res);
    if (resd > d[rdir][ry][rx]) continue;
    //cout << resd << ' ' << rdir << ' ' << ry << ' ' << rx << '\n';
    ll ny = ry + dy[rdir], nx = rx + dx[rdir];
    if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
    if (c[ny][nx] == '@') continue;
    rep(ndir, 4) {
      ll nxtd = resd + 1;
      if (rdir != ndir && nxtd % k) nxtd += (k - nxtd % k);
      if (chmin(d[ndir][ny][nx], nxtd)) {
        pq.push(make_tuple(nxtd, ndir, ny, nx));
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  cin >> h >> w >> k >> sy >> sx >> gy >> gx;
  sy--, sx--, gy--, gx--;
  c.resize(h, vector<char>(w));
  rep(i, h) {
    rep(j, w) {
      cin >> c[i][j];
    }
  }

  rep(i, 4) d[i].resize(h, vector<ll>(w, INF));
  dijkstra();
  ll ans = INF;
  rep(i, 4) chmin(ans, d[i][gy][gx]);
  if (ans == INF) {
    cout << -1 << '\n';
    return 0;
  }
  ans = (ans + k - 1) / k;
  cout << ans << '\n';
  /*
  rep(i, 4) {
    rep(j, h) {
      rep(k, w) {
        cout << (d[i][j][k] == INF ? -1 : d[i][j][k]) << ' ';
      }
      cout << '\n';
    }
  }
  */

  




  
  return 0;
}

Measured memory_bytes: 51892
object Scanner {
  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}

object Main extends App {
  val n = Scanner.nextInt()
  val h = Array.fill(n)(Scanner.nextInt())

  val result = h.foldLeft((0,0))((z,x)=>{
    if (z._1<=x){
      (x,z._2+1)
    } else {
      z
    }
  })

  println(result._2)
}

Measured memory_bytes: 27304
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		int n = sc.nextInt();
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = sc.nextInt();
		int m = sc.nextInt();
		for (int i=0; i<m; i++) {
			System.out.println(BinarySearch(ar, sc.nextInt())==-1?0:1);
		}
	}

	static int BinarySearch (int[] ar, int t) {
		int L = 0, R = ar.length, M = -1;
		while (L < R) {
			M = (L+R)/2;
			if (t == ar[M]) return M;
			if (t > ar[M]) L = M+1;
			else R = M;
		}
		return -1;
	}

}


Measured memory_bytes: 104408