akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
using namespace std;
long long int h[100000000];
long long int x[100000000];
 long long int n,a,b;
bool Sort(long long y)
{
    long long int sum=0;
    long long int t;
    for(int i=0;i<n;i++)
    {
        t=(long long)x[i]-y*b;
        if(t>0)
        {
            sum=sum+(long long int)ceil(t*1.0/(a-b));
            if(sum>y||sum<0)
                return false;
        }
    }
    return true;
}
void cazhao(long long x1[],long long n,long a1,long b1)
{
    sort(x1,x1+n);
  //  long long int sum=0;
    long long int  c;
    long long int  d;
    //  for(int i=0;i<n;i++)
    //   cout<<x1[i]<<" ";
    if(x1[n-1]%a1!=0)
        c=x1[n-1]/a1+1;
    else
        c=x1[n-1]/a1;
    if(x1[n-1]%b1!=0)
        d=x1[n-1]/b1+1;
    else
        d=x1[n-1]/b1;

   // cout<<x1[n-1]<<" ";
    while(c<d)
    {
        long long int mid=(c+d)/2;
           if(Sort(mid))
            d=mid;
           else
            c=mid+1;
    }
    //return c;
    cout<<c<<endl;
}
//cout<<d<<endl;
int main()
{

   while((scanf("%lld %lld %lld",&n,&a,&b)!=EOF))
    {int i;
    for(i=0; i<n; i++)
        scanf("%lld",&x[i]);
    cazhao(x,n,a,b);

    }
      return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int mp[200];
int main()
{
	int x,n;
    cin>>x>>n;
	for(int i=1;i<=n;i++){
		int k;
        cin>>k;
		mp[k]=1;
	}
	for(int i=0;i<=100;i++)
	{
		if(mp[x-i]==0){
			cout<<x-i<<endl;
			break;
		}
		else if(mp[x+i]==0){
			cout<<x+i<<endl;
			break;
		}
	}
}

Measured memory_bytes: 3196
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t N, A, B;
    intmax_t ans = 0;

    scanf("%jd%jd%jd", &N, &A, &B);

    ans += (N / (A + B)) * A;

    if (N % (A + B) > A)
        ans += A;
    else
        ans += N % (A + B);

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    cout << n * n * n << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,s;
int a[100][100];
int main(){
cin>>n>>m>>s;
for(int k=0;k<n;k++)
for(int i=0;i<m;i++){
    char ch;
    cin>>ch;
    if(ch=='#')
        a[k][i]=1;
}
int N=1<<n;
int M=1<<m;
int pas=0;
for(int k=0;k<N;k++){
    for(int i=0;i<M;i++){
        bitset<10> K=k,I=i;
        int ans=0;
        for(int j=0;j<n;j++)
        for(int q=0;q<m;q++){
            if(K[j]==0 && I[q]==0 && a[j][q]==1)
                ans++;
        }
        if(ans==s)
        pas++;
    }

}
cout<<pas;
return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<ll> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
    C[i] = (A[i] % B[i] == 0 ? 0 : B[i] - (A[i] % B[i]));
  }
  ll cnt = 0;
  for (int i = N - 1; i >= 0; i--) {
    if (C[i] - cnt < 0)
      cnt += ((cnt - C[i]) % B[i] == 0 ? 0 : B[i] - ((cnt - C[i]) % B[i]));
    else
      cnt += C[i] - cnt;
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    string s;
    cin >> s;
    int a,b;
    a = b = - 1;
    if(s[0] == 'A')a = 0;
    loop(i,2,s.size()-1)if(s[i] == 'C')b = i;
    if(a < 0 || b < 0){
        cout << "WA" << endl;
        return 0;
    }
    rep(i,s.size())if(i != a && i != b && 'A' <= s[i] && s[i] <= 'Z'){
        cout << "WA" << endl;
        return 0;
    }
    cout << "AC" << endl;

}


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

string sA, sB, sC;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> sA;
    cin >> sB;
    cin >> sC;
    char turn = sA.front();
    sA = sA.substr(1);
    int win = 1;
     while(true){
        if(turn=='a'){
            if(sA.empty()){
                win = 1;
                break;
            }
            turn = sA.front();
            sA = sA.substr(1);
        }else if(turn=='b'){
            if(sB.empty()){
                win = 2;
                break;
            }
            turn = sB.front();
            sB = sB.substr(1);
        }else{
            if(sC.empty()){
                win = 3;
                break;
            }
            turn = sC.front();
            sC = sC.substr(1);
        }
    }
    if(win==1){
        cout << 'A' << endl;
    }else if(win==2){
        cout << 'B' << endl;
    }else{
        cout << 'C' << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  long H = sc.nextLong();
	  long W = sc.nextLong();
	  long count = 0;
	  
	  if(H == 1 || W == 1)
		  out.println(1);
	  else {
	  for(long i=0; i<H; i++) {
		  count += W/2;
		  if(i%2 == 0)
			  count+= W%2;
	  }
	  out.println(count);
	  }
  	}
  }	

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/


const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// /* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
//get<K>(tuple型の変数)


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m; cin >> n >> m;
    priority_queue<ll> pq;
    rep(i, n){
        ll a; cin >> a;
        pq.push(a);
    }

    while(m--){
        ll t=pq.top(); pq.pop();
        t/=2; pq.push(t);
    }

    ll ans=0;
    while(!pq.empty()){
        ans += pq.top(); pq.pop();
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1400
def main():
    n = int(input())
    all_xor = 0
    a = list(map(int, input().split()))
    for i in range(n):
        all_xor ^= a[i]
    answer = []
    for i in range(n):
        answer.append(all_xor ^ a[i])
    print(" ".join(map(str, answer)))


if __name__ == '__main__':
    main()



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

using namespace std;

const int N = 505;

int n;
char buf[N];
int a[N][N];
int row[N][N];
int L[2][N][N];
int R[2][N][N];

void del(int x,int y) {
	if (x > 0 && x <= n && y > 0 && y <= n && a[x][y]) {
		if (x == 1 || a[x - 1][y] == 0) {
			if (y == 1 || a[x][y - 1] == 0) {
				for (int i = y; i <= n; ++i) {
					row[x][i] -= a[x][y];
				}
				a[x][y] = 0;
				del(x + 1, y);
				del(x, y + 1);
			}
		}
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", buf + 1);
		for (int j = 1; j <= n; ++j) {
			a[i][j] = (buf[j] == '#' ? 0 : buf[j] - '0');
		}
	}


	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			row[i][j] = row[i][j - 1] + a[i][j];
		}
	}
	
	long long ans = 0;
	memset(L, 69, sizeof L);
	for (int i = n; i > 0; --i) {
		for (int j = n; j > 0; --j) {
			if (a[i][j] == 0) {
				continue;
			}
			L[1][j][i] = j;
			R[1][j][i] = j;
			if (i < n && a[i + 1][j]) {
				for (int k = i + 1; k <= n; ++k) {
					L[1][j][k] = min(L[1][j][k], L[0][j][k]);
					R[1][j][k] = max(R[1][j][k], R[0][j][k]);
				}
			}
			if (j < n && a[i][j + 1]) {
				for (int k = i; k <= n; ++k) {
					L[1][j][k] = min(L[1][j][k], L[1][j + 1][k]);
					R[1][j][k] = max(R[1][j][k], R[1][j + 1][k]);
				}
			}
			int val = 0;
			for (int k = i; k <= n; ++k) {
				if (L[1][j][k] <= R[1][j][k]) {
					val += row[k][R[1][j][k]] - row[k][L[1][j][k] - 1];
				}
			}
			ans += (long long) (a[i][j]) * (val - a[i][j]);
			del(i, j);
		}
		for (int j = 1; j <= n; ++j) {
			for (int k = i; k <= n; ++k) {
				L[0][j][k] = L[1][j][k];
				R[0][j][k] = R[1][j][k];
				L[1][j][k] = 1e9;
				R[1][j][k] = 0;
			}
		}
	}
	
	printf("%lld\n", ans);
}

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

#define INF INT_MAX

using namespace std;

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

ll fib_memo[1000000] = {0};
ll fib(int n) {
    if(n==0)return 0;
    if(n==1)return 1;
    if(fib_memo[n] != 0) {
        return fib_memo[n];
    }
    return fib_memo[n] = (fib(n-1)+fib(n-2))%1000000007;
}

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

	int N,M;
	cin >> N >> M;
	vector<int> a(M);
	if(M == 0){
		cout << fib(N+1) << endl;
		return 0;
	}
	for(int i = 0;i < M;i++){
		cin >> a[i];
		if(i != 0 && (a[i-1] == a[i]-1)){
			cout << 0 << endl;
			return 0;
		}
	}
	ll ans = 1;
	for(int i = 0;i < M;i++){
		if(i == 0)ans = fib(a[0])%1000000007;
		else ans = (ans * fib(a[i]-a[i-1]-1))%1000000007;
		// cout << ans << endl;
	}
	ans = (ans * fib(N-a[M-1]))%1000000007;

	cout << ans << endl;

	return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7;
const int N = 1e3 + 10;

string s[N];
int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> s[i];

    auto f = vector<vector<int>>(n + 1, vector<int>(m + 1, 0));
    f[1][0] = 1;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++) if (s[i - 1][j - 1] == '.')
            f[i][j] = (f[i - 1][j] + f[i][j - 1]) % MOD;
    cout << f[n][m];
}


Measured memory_bytes: 5248
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

from fractions import gcd

N = int(input())
A = list(map(int, input().split()))

# 累積gcdを左からと右から
left = [0] * N
right = [0] * N
left[0] = A[0]
for i in range(1, N):
    left[i] = gcd(left[i-1], A[i])

right[N-1] = A[N-1]
for i in range(N-2, -1, -1):
    right[i] = gcd(A[i], right[i+1])

# 番兵
left = [A[N-1]] + left
right.append(A[0])

#print(left)
#print(right)

ans = 0
for i in range(N):
    x = gcd(left[i], right[i+1])
    ans = max(ans, x)

print(ans)

Measured memory_bytes: 16140
#再帰の深さが1000を超えそうなときはこれをやっておく
import sys
sys.setrecursionlimit(10**7)

n,x=map(int,input().split())
a=[0]*(n+1)
p=[0]*(n+1)
a[0]=1
p[0]=1
for i in range(n):
  a[i+1]=2*a[i]+3
  p[i+1]=2*p[i]+1
  
def func(i,x):
  if i==0:
    if x<=0:
      return 0
    elif x>=1:
      return 1
  mid=(a[i]+1)//2
  if mid==x:
    return p[i-1]+1
  elif mid>x:
    return func(i-1,x-1)
  else:
    return p[i-1]+1+func(i-1,x-mid)


print(func(n,x))  

Measured memory_bytes: 61868
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <list>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
 
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int a[250+1];
    for( int i = 1; i <= n; i++) cin >> a[i];
    for( int i = 1; i <= n; i++) {
        cout << "node " << i << ": key = " << a[i] << ", ";
        if(i/2 >= 1) cout << "parent key = " << a[i/2] << ", ";
        if(2*i <= n) cout << "left key = " << a[i*2] << ", ";
        if(2*i+1 <= n) cout << "right key = " << a[i*2+1] << ", ";
        cout <<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	ll n;
	cin >> n;
	vector<ll> s(n, 0LL);
	rep(n) cin >> s[i];
	vector<ll> s2(s);
	ll ans_p = 0LL;
	if(s[0] <= 0LL){
		ans_p += 1LL - s[0];
		s[0] = 1LL;
	}
	reppp(i, 1, n-1){
		s[i] += s[i-1];
		if(i % 2 == 0 && s[i] <= 0LL){
			ans_p += 1LL - s[i];
			s[i] = 1LL;
		}else if(i % 2 == 1 && s[i] >= 0LL){
			ans_p += s[i] + 1LL;
			s[i] = -1LL;
		}
	}
	ll ans_m = 0LL;
	if(s2[0] >= 0){
		ans_m += s2[0] + 1LL;
		s2[0] = -1LL;
	}
	reppp(i, 1, n-1){
		s2[i] += s2[i-1];
		if(i % 2 == 1 && s2[i] <= 0LL){
			ans_m += 1LL - s2[i];
			s2[i] = 1LL;
		}else if(i % 2 == 0 && s2[i] >= 0LL){
			ans_m += s2[i] + 1LL;
			s2[i] = -1LL;
		}
	}
	ll ans = ans_p>ans_m ? ans_m : ans_p;
	cout << ans;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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; }


int main(){
	string s, t;
	cin >> s >> t;
	int n = s.length(), m = t.length();
	vector<char> a(n), b(m);
	rep(i, n) a[i] = (char)s[i];
	rep(i, m) b[i] = (char)t[i];
	vector<vector<int > > dp(n+1, vector<int > (m+1));
	
	int ma = 0;
	rep(i, n) {
		rep(j, m) {
			if(a[i] == b[j]) {
				dp[i+1][j+1] = dp[i][j] + 1;
			}
			else {
				dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
			}
		}
	}
	int len = dp[n][m];
	int i = n, j = m;
	vector<char> ans(len+1);
	while(len > 0){
		if(a[i-1] == b[j-1]){
			ans[len] = a[i-1];
			i--; j--; len--;
		}
		else if(dp[i][j] == dp[i-1][j]){
			i--;
		}
		else {
			j--;
		}
	}
	rep2(k, 1, dp[n][m]+1){
		cout << ans[k];
	}
	cout << endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<vector<string>> vec(2);
    vec[0].pb("");
    REP(i,n){
        for(auto t : vec[i%2]){
            char c = 'a'-1;
            REP(j,t.size())c = max(c,t[j]);
            for(char d = 'a'; d <= c+1; ++d)
                vec[1-i%2].pb(t + d);
        }
        vec[i%2].clear();
    }
    for(auto s : vec[n%2]){
        ANS(s);
    }
    return 0;
}

Measured memory_bytes: 11124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
	public static void main(String[] args) throws NumberFormatException, IOException
	{
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int A = Integer.parseInt(str.substring(0, str.indexOf(" ")));
		int B = Integer.parseInt(str.substring(str.indexOf(" ") + 1));
		String[][] N = new String[A][A];
		String[][] M = new String[B][B];
		for(int i = 0; i < A; i++)
		{
			str = br.readLine();
			for(int j = 0; j < A; j++)
			{
				N[i][j] = str.substring(j, j + 1);
			}
		}
		for(int i = 0; i < B; i++)
		{
			str = br.readLine();
			for(int j = 0; j < B; j++)
			{
				M[i][j] = str.substring(j, j + 1);
			}
		}

		for(int i = 0; i < A; i++)
		{
			for(int j = 0; j < A; j++)
			{
				Ms:if(N[i][j].equals(M[0][0]))
				{
					for(int i2 = 0; i2 < B; i2++)
					{
						for(int j2 = 0; j2 < B; j2++)
						{
							if(i + i2 >= A || j + j2 >= A) break Ms;
							else if(N[i + i2][j + j2].equals(M[i2][j2])) ;
							else break Ms;
						}
					}
					System.out.println("Yes");
					System.exit(0);
				}
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vll vector<ll>
#define pb push_back
#define x first
#define y second

int main()
{
	IOS
	ll n;
	cin>>n;
	ll a[3][n+1],dp[3][n+1],i,j;
	for(j=1;j<=n;j++)
	{
		for(i=0;i<3;i++)
			cin>>a[i][j];
	}
	dp[0][1]=a[0][1];
	dp[1][1]=a[1][1];
	dp[2][1]=a[2][1];
	for(j=2;j<=n;j++)
	{
		for(i=0;i<3;i++)
		{
			dp[i][j] = max(dp[(i+1)%3][j-1],dp[(i+2)%3][j-1]) + a[i][j];
		}
	}
	cout<<max(dp[0][n],max(dp[1][n],dp[2][n]));
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

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

		String relation;

		if(a > b){
			relation = ">";
		}else if(a < b){
			relation = "<";
		}else{
			relation = "==";
		}

		System.out.printf("a %s b\n", relation);
	}
}




Measured memory_bytes: 26324
#include<iostream>

using namespace std;

struct Node{
  int key, priority;
  Node* right;
  Node* left;
};

Node* right_rotate(Node* t){
    Node* s = t->left;
    t->left = s->right;
    s->right = t;
    return s;
}

Node* left_rotate(Node* t){
    Node* s = t->right;
    t->right = s->left;
    s->left = t;
    return s;
}

Node* insert(Node* t, int key, int priority){

    if(t == NULL){
        Node* t = new Node;
        t->left = NULL;
        t->right = NULL;
        t->key = key;
        t->priority = priority;
        return t;
    }
    if(key == t->key){
        return t;
    }
    if(key < t->key){
        t->left = insert(t->left, key, priority);
        if(t->priority < t->left->priority){
            t = right_rotate(t);
        } 
    }
    else{
        t->right = insert(t->right, key, priority);
        if(t->priority < t->right->priority){
            t = left_rotate(t);
        }
    }
    return t;
}

Node* delete_key(Node* t, int key){
    if(t == NULL){
        return NULL;
    }
    if(key == t->key){
        if(t->left  == NULL && t->right == NULL){
            return NULL;
        }
        else if(t->left == NULL){
            t = left_rotate(t);
        } 
        else if(t->right == NULL){
            t = right_rotate(t);
        } 
        else{
            if(t->left->priority > t->right->priority){
                t = right_rotate(t);
            }
            else{
                t = left_rotate(t);
            } 
        }
        return delete_key(t, key);
    }
    if(key < t->key){
        t->left = delete_key(t->left, key);
    }
    else{
        t->right = delete_key(t->right, key);
    } 
    return t;
}

void find(Node* t, int key){
    while(t != NULL && key != t->key){
        if(key < t->key){
            t = t->left;
        }
        else{
            t = t->right;
        } 
    }
    if(t == NULL){
        cout << "no" << endl;
    }
    else{
        cout << "yes" << endl;
    } 
}

// 中間順巡回
void inorder(Node* t){
    if(t == NULL){
        return;
    }
    inorder(t->left);
    cout << " " << t->key;
    inorder(t->right);
}

// 先行順巡回
void preorder(Node* t){
    if(t == NULL){
        return;
    }
    cout << " " << t->key;
    preorder(t->left);
    preorder(t->right);
}

int main(){
    Node* root = NULL;
    
    int n;
    cin >> n;

    string s;
    int key, priority;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s == "insert"){
            cin >> key >> priority;
            root = insert(root, key, priority);
        }
        else if(s == "delete"){
            cin >> key;
            root = delete_key(root, key);
        }
        else if(s == "find"){
            cin >> key;
            find(root, key);
        }
        else {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 9388
"use strict";
function Main(input) {
    let D = input.split("\n").map((v) => v - 0)[0];
    if (D == 25) console.log("Christmas");
    else if (D == 24) console.log("Christmas Eve");
    else if (D == 23) console.log("Christmas Eve Eve");
    else if (D == 22) console.log("Christmas Eve Eve Eve");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 19912
#include<iostream>
using namespace std;
void function(long long a[],long long b[],int x, int y){
	if(b[x]<=b[y]){
		a[x]=1;
	}
	if(b[x]>=b[y]){
		a[y]=1;
	}
}
int main(){
	long long T,R;
	cin >> T >> R;
	long long a[100001]={};
	long long b[100001];
	for(long long i=1;i<=T;i++){
		b[i]=0;
		cin >> b[i];
	}
	for(long long i=0;i<R;i++){
		long long x,y;
		cin >> x >> y;
		function(a,b,x,y);
	}
	long long sum=0;
	for(long long i=1;i<=T;i++){
		if(a[i]==0){
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}





Measured memory_bytes: 5160
inputs = list(map(int, input().split()))
S=[inputs[x] for x in range(2)]
G=[inputs[x] for x in range(2,4)]
Dx=G[0]-S[0]
Dy=G[1]-S[1]
r1='R'*Dx+'U'*Dy
r2='L'*Dx+'D'*Dy
r3='L'+'U'*(Dy+1)+'R'*(Dx+1)+'D'
r4='R'+'D'*(Dy+1)+'L'*(Dx+1)+'U'
print(r1+r2+r3+r4)

Measured memory_bytes: 3064
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    character(1):: x,y

    read*, x,y

    if (x<y)then
        print'(a)', '<'
    else if (x==y) then
        print'(a)', '='
    else
        print'(a)', '>'
    end if
end program main

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str):
    ans = 0
    c = 0
    for i in S:
        if i in ["A", "C", "G", "T"]:
            c += 1
        else:
            c = 0
        if c > ans:
            ans = c
    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61736
s = input()
t = input()
ls = len(s)
lt = len(t)
ans = 1000
count = 0

for i in range(ls-lt+1):
    ss = s[i:i+lt]
    count = 0
    for i in range(lt):
        if ss[i] == t[i]:
            count += 1
    if ans > lt-count:
        ans = lt-count

print(ans)

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

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int total = inpt[0];
        int personLen = inpt[1];
        int margin = inpt[2];

        int ans = (total - margin) / (personLen + margin);
        Console.WriteLine(ans);
    }

    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"




100000 1 1




";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static final int INF = Integer.MAX_VALUE;
	public static void main(String[] args) {
		doIt();

	}
	
	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		while(n != 0){
			int[][] time = new int[n][n + 1];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n + 1; j++){
					time[i][j] = sc.nextInt();
				}
			}
			int max = (int)Math.pow(2, n);
			//bitDP i番目のフラグが立っていたらi番目はクリア済み
			//集合iをクリア出来る最短時間
			int[] dp = new int[max];
			dp[0] = 0;
			for(int i = 1; i < max; i++){
				//dp[i] = 1個をiに含まれていない
				int m = INF;
				for(int j = 0; j < n; j++){
					//maskステージをクリアしていないとする
					int mask = 1 << j;
					//ビットを1個消してみる
					if((i & mask) == mask){
						int min = time[j][0];
						for(int k = 0; k < n; k++){
							int m2 = 1 << k;
							//消したステージをクリア済みだったら
							if((m2 & (i & ~mask)) == m2){
								min = Math.min(min, time[j][k + 1]);
							}
						}
						m = Math.min(m,dp[(i & ~mask)] + min);
					}
				}
				dp[i] = m;
			}
			System.out.println(dp[max - 1]);
			
			n = sc.nextInt();
			
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e: a) cin >> e;

    vector<int> f(n), b(n);
    f[0] = 0;
    for (int i = 1; i <= n; ++i) {
        f[i] = max(f[i-1], a[i-1]);
    }
    b[n-1] = 0;
    for (int i = n-2; i >= 0; --i) {
        b[i] = max(b[i+1], a[i+1]);
    }

    for (int i = 0; i < n; ++i) {
        cout << max(f[i], b[i]) << "\n";
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 3968
from collections import deque
n, q = map(int, input().split())
query = []
for _ in range(q):
    t, x = map(int, input().split())
    query.append((t-1, x))
black = (n-2)**2
rc = [deque([(n, n)]), deque([(n, n)])]
mrc = [n, n]

def bisect(li, x):
    ok = -1
    ng = len(li)
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if li[mid][0]<x:
            ok = mid
        else:
            ng = mid
    return ok+1

for t, x in query:
    tmp = rc[t][bisect(rc[t], x)][1]
    black -= tmp-2
    if x < mrc[t]:
        mrc[t] = x
        rc[1-t].appendleft((tmp, x))
print(black)

Measured memory_bytes: 98656
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = {}
    for a in A:
        if a not in B:
            B[a] = 0
        B[a] += 1
    ans = len(B)
    print(ans - (ans + 1) % 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9

int main(){
    int N, x;
    cin >> N >> x;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    int ans = 0;
    for(int j = 0; j < N; j++){
        if (j == N - 1 && (A.at(j) - x) != 0){
            break;
        }
        if(A.at(j) <= x){
            x -= A.at(j);
            ans++;
        }else{
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n,k,c;
string s;

signed main(){
    cin >> n >> k >> c;
    cin >> s;
    vi fast(k+1), slow(k+1);
    
    int idx = 0;
    fast[0] = -200010;
    REP(i,n){
        if (s[i] == 'o' && i - fast[idx] > c) fast[++idx] = i;
        if( idx == k) break;
    }
    idx = k;
    slow[k] = 400010;
    REPN(i,n){
        if (s[i] == 'o' && slow[idx] - i > c) slow[--idx] = i;
        if( idx == 0) break;
    }
    int ret = 0;
    REP(i,k) if (fast[i+1] == slow[i]) cout << fast[i+1] + 1 << endl;
}

Measured memory_bytes: 4996
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  ll a,c;
  string b;
  cin>>a>>b;

  c=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');

  cout << a*c/100 << endl;

}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <chrono> 
using namespace std::chrono;
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fr(i,a,b) for (int i=(a); i<(b);++i)
#define frr(i,a,b) for(int i=(a-1);i>=(b);--i)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<int,int> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define sz(a) (ll)a.size()
#define endl "\n"
#define po(a,b) (ll)(pow(a,b)+0.5)
#define double long double
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
const ll M=1e9+7;
const int MaxM=501;
ll dp[2000005];


int main()
{ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);

   
   int n,k;
   cin>>n>>k;
   vi a(n);
   fr(i,0,n)cin>>a[i];
   srt(a);
   ll sum=0;
   fr(i,0,k)sum+=a[i];
   cout<<sum;
   }



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define mem(x, y) memset(x, y, sizeof(x))
#define mp make_pair
#define pb push_back

int main(){
    double R;
    cin >> R;
    printf("%.6f\n", 2 * M_PI * R);
    return 0;
}

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


int main() {
    ll N, D;
    cin >> N >> D;
    vector<ll> X(N), Y(N);
    rep(i,N) cin >> X[i] >> Y[i];

    ll ans = 0;
    rep(i,N) if (X[i] * X[i] + Y[i] * Y[i] <= D * D) ++ans;
    cout << ans << endl;
}




Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

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

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

  ll ans = 0;
  for (int i = 1; i <= k; ++i){
    for (int j = 1; j <= k; ++j){
      for (int m = 1; m <= k; ++m){
        ans += GCD(GCD(i,j),m);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>

#define MAX 500000
#define IMF 1000000001

int merge(int *,int,int,int);
int mergeSort(int *,int,int);

int cnt=0;

int main(){
  int n,S[MAX];
  int i;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  mergeSort(S,0,n);

  for(i=0;i<n-1;i++){
    printf("%d ",S[i]);
  }
  printf("%d\n",S[i]);
  printf("%d\n",cnt);

  return 0;
}

int merge(int *S,int left,int mid,int right)
{
  int n1 = mid-left,n2 = right-mid;
  int L[n1],R[n2];
  int i,j,k;

  for(i=0;i<n1;i++){
    L[i] = S[left+i];
  }
  for(i=0;i<n2;i++){
    R[i] = S[mid+i];
  }
  L[n1] = IMF;
  R[n2] = IMF;

  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i++;
      cnt++;
    }
    else{
      S[k] = R[j];
      j++;
      cnt++;
    }
  }
  
}

int mergeSort(int *S,int left,int right)
{
  int mid;
  
  if ((left+1) < right){
    mid = (left + right)/2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}



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

int main() {
  string S;
  cin >> S;
  int n = S.size();
  int R[n], L[n], A[n];
  for(int i = 0;i<n;i++){
    A[i] = 0;
  }
  if(S[0] == 'R') {
    R[0] = 1;
  }
  else {
    R[0] = 0;
  }
  for(int i = 1;i<n;i++) {
    if(S[i] == 'R') {
      R[i] = R[i-1] + 1;
    }
    else {
      R[i] = 0;
      if(R[i-1] == 0) {
        continue;
      }
      else {
        A[i-1] = A[i-1] + ((R[i-1]+1)/2);
        A[i] = A[i] + R[i-1] / 2;
      }
    }
  }
  if(S[n-1] == 'L') {
    L[n-1] = 1;
  }
  else {
    L[n-1] = 0;
  }
  for(int i = n-2;i>=0;i--) {
    if(S[i] == 'L') {
      L[i] = L[i+1] + 1;
    }
    else {
      L[i] = 0;
      if(L[i+1] == 0) {
        continue;
      }
      else {
        A[i+1] = A[i+1] + (L[i+1]+1)/2;
        A[i] = A[i] + L[i+1] / 2;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << A[i] << endl;
  }
}

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

using namespace std;

int main(){
  int n;
  int i,j,ans=0;
  vector <int> v;
  
  cin>>n;
  for(i=0;i<n;i++){
    cin>>j;
    v.push_back(j);
  }
  
  sort(v.begin(),v.end());
  
  for(i=0;i<n-1;i++)
    ans+=v[i];
  
  cout<<(v[n-1]<ans?"Yes":"No")<<endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//木の連結成分の個数は頂点数ー辺の数

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int q; cin >> q;
    ll sum=0;
    priority_queue<ll> pq1;//dekai
    priority_queue<ll,vector<ll>,greater<ll>> pq2;
    ll sum1=0,sum2=0;
    ll cnt=0;
    rep(i,q){
        int x; cin >> x;
        if(x==1){
            cnt++;
            ll a,b; cin >> a >> b;
            sum+=b;
            if(pq2.size()>pq1.size()){
                pq1.push(a);
                sum1+=(a);
            }
            else{
                pq2.push(a);
                sum2+=(a);
            }
            if(!pq1.empty()){
                ll tp1=pq1.top();  pq1.pop();
                ll tp2=pq2.top();  pq2.pop();
                if(tp1>tp2){
                    pq2.push(tp1);
                    pq1.push(tp2);
                    sum1+=(tp2-tp1);
                    sum2+=(tp1-tp2);
                }
                else{
                    pq1.push(tp1);
                    pq2.push(tp2);
                }
            }
        }else{
            ll mid=pq2.top();
            if(pq1.size()==pq2.size()) chmin(mid,pq1.top());
            ll ans=sum2-sum1;
            //cout << sum1 <<  " " << sum2 << endl;
            if(cnt%2==1) ans-=pq2.top();
            ans+=sum;
            cout << mid << " " << ans << endl;
        }
    }
}


Measured memory_bytes: 5144
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[210];
    rep(i, N) cin >> A[i];
    int ans = 0;
    while(true) {
        bool ok = true;
        rep(i, N) if(A[i] % 2 != 0) ok = false;
        if(!ok) break;
        rep(i, N) A[i] /= 2;
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int X, Y;
  cin >> X >> Y;
  int d = Y / X;
  int cnt = 0;
  while (d) {
    cnt++;
    d /= 2;
  }
  print(cnt);  // 15 7 5 3 1 16 8 4 2 1
}

Measured memory_bytes: 256
#include<iostream>

int n, m, a, b, k, p, q, r, *ans;
int **w[2],**d[2],**pre_vertex[2];

void solve(){
	for(int z=0; z<2; z++){
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++)
				d[z][i][j] = w[z][i][j];
		}
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				for(int l=0; l<m; l++){
					int dis = d[z][j][i]+d[z][i][l];
					if(dis<d[z][j][l])
						d[z][j][l] = dis;
				}
			}
		}
	}
}

int main(){
	while(true){
		std::cin >> n >> m;
		if(!n && !m)
			return 0;
		for(int l=0; l<2; l++){
			w[l] = new int*[m];
			d[l] = new int*[m];
			for(int i=0; i<m; i++){
				w[l][i] = new int[m];
				d[l][i] = new int[m];
				for(int j=0; j<m; j++)
					w[l][i][j] = 1000000000;
			}
		}
		for(int i=0; i<n; i++){
			std::cin >> a >> b;
			std::cin >> w[0][a-1][b-1] >> w[1][a-1][b-1];
			w[0][b-1][a-1] = w[0][a-1][b-1];
			w[1][b-1][a-1] = w[1][a-1][b-1];
		}
		solve();
		std::cin >> k;
		ans = new int[k];
		for(int i=0; i<k; i++){
			std::cin >> p >> q >> r;
			ans[i] = d[r][p-1][q-1];
		}
		for(int i=0; i<k; i++)
			std::cout << ans[i] << std::endl;
		for(int i=0; i<2; i++){
			for(int j=0; j<m; j++){
				delete[] w[i][j];
				delete[] d[i][j];
			}
			delete[] w[i];
			delete[] d[i];
		}
		delete[] ans;
	}
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 100001
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
const int inf = 1e9;
const ll INF = 1e18;
//__gcd(a,b), __builtin_popcount(a);

ll a[MAX], d[MAX];
vector<ll> G[MAX], T[MAX];
int main(){
	int n, m, x, t1, t2, t3;
	fill(d, d+MAX, INF);
	scanf("%d%d%d", &n, &m, &x);
	rrep(i,n)scanf("%lld", &a[i]);
	rrep(i,m){
		scanf("%d%d%d", &t1, &t2, &t3);
		G[t1].push_back(t2);
		G[t2].push_back(t1);
		T[t1].push_back(t3);
		T[t2].push_back(t3);
	}
	
	d[1] = 0;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, 1));
	
	for(int i = 1;i <= n;i++){
		while(!q.empty()){
			P p = q.top();q.pop();
			if(p.fi > d[p.se])continue;
			
			for(int i = 0;i < G[p.se].size();i++){
				ll from = p.se, to = G[p.se][i];
				ll cost = T[from][i], h;
				if(p.fi < x)h = x-p.fi;
				else h = 0;
				
				if(h < T[from][i])cost = T[from][i]*2-h;
				if(h-T[from][i] > a[to])cost = h-a[to];
				if(a[from]-T[from][i] < 0)continue;
				
				if(d[to] > p.fi+cost){
					d[to] = p.fi+cost;
					q.push(P(d[to], to));
				}
			}
		}
	}
	
	ll res = 0;
	if(d[n] < x)res = x-d[n];
	if(d[n] >= INF)printf("-1\n");
	else printf("%lld\n", d[n]+(a[n]-res));
	return 0;
}



Measured memory_bytes: 27224
K = int(input())
from collections import deque
lun = deque(['1', '2', '3', '4', '5', '6', '7', '8', '9'])

i = 0
while lun:
    #print(lun)
    i += 1
    a = lun.popleft()
    if i == K:
        print(int(a))
        break
    if int(a[-1]) == 9:
        lun.append(a + '8')
        lun.append(a + '9')
    elif int(a[-1]) == 0:
        lun.append(a + '0')
        lun.append(a + '1')
    else:
        lun.append(a + str(int(a[-1]) - 1))
        lun.append(a + str(int(a[-1])))
        lun.append(a + str(int(a[-1]) + 1))


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

using namespace std ;

int n, m, Q ; 

const int MAXN = 2010 ;

char mp[MAXN][MAXN] ;

int s[MAXN][MAXN], sl[MAXN][MAXN], sr[MAXN][MAXN] ; 

int main() { 

		scanf("%d%d%d", &n, &m, &Q) ; 

		for (int i = 1; i <= n; i ++) scanf("%s", mp[i] + 1) ; 

		for (int i = 1; i <= n; i ++) {
				int tmp = 0 ; 
				for (int j = 1; j <= m; j ++) {
						s[i][j] = s[i - 1][j] ; 
						s[i][j] += (tmp += (mp[i][j] - '0')) ; 
				}
		}

		for (int i = 1; i <= n; i ++) { 
				for (int j = 1; j <= m; j ++) { 
						if (mp[i][j] == '1') { 
								if (mp[i + 1][j] == '1') sl[i + 1][j] ++ ; 
								if (mp[i][j + 1] == '1') sr[i][j + 1] ++ ; 
						}
				}
		}

		for (int i = 1; i <= n; i ++) {
				int tmp = 0 ; 
				for (int j = 1; j <= m; j ++) { 
						int v = sl[i][j] ; 
						sl[i][j] += sl[i - 1][j] ; 
						sl[i][j] += tmp ; 
						tmp += v ; 
				}
		}
		for (int i = 1; i <= n; i ++) {
				int tmp = 0 ; 
				for (int j = 1; j <= m; j ++) { 
						int v = sr[i][j] ; 
						sr[i][j] += sr[i - 1][j] ; 
						sr[i][j] += tmp ; 
						tmp += v ; 
				}
		}

		while (Q --) {
				int lx, ly, rx, ry ; 
				scanf("%d%d%d%d", &lx, &ly, &rx, &ry) ; 

				int a = s[rx][ry] - s[lx - 1][ry] - s[rx][ly - 1] + s[lx - 1][ly - 1] ; 
				int b = 0, c = 0 ; 
				if (lx < rx) { 
						b = sl[rx][ry] - sl[lx][ry] - sl[rx][ly - 1] + sl[lx][ly - 1] ; 
				}
				if (ly < ry) {
						c = sr[rx][ry] - sr[lx - 1][ry] - sr[rx][ly] + sr[lx - 1][ly] ; 
				}

				printf("%d\n", a - b - c) ; 
		}
}



		






Measured memory_bytes: 53120