akhauriyash/Code-Regression huggingface dataset:
import heapq
N = int(input())
A = list(map(int, input().split()))

L = A[:N]
R = [-a for a in A[-N:]]
mid = A[N:-N]

heapq.heapify(L)
heapq.heapify(R)

Lsum = [sum(L)]
Rsum = [sum(R)]

for m in mid:
    if m > L[0]:
        Lsum.append(Lsum[-1] + m - L[0])
        heapq.heappushpop(L, m)
    else:
        Lsum.append(Lsum[-1])

for m in mid[::-1]:
    if -m > R[0]:
        Rsum.append(Rsum[-1] - m - R[0])
        heapq.heappushpop(R, -m)
    else:
        Rsum.append(Rsum[-1])
Rsum = Rsum[::-1]


ans = -10 ** 18
for x, y in zip(Lsum, Rsum):
    ans = max(ans, x + y)

print(ans)


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

int main()
{
  int x = 0;
  int y = 0;
  int pool = 0;
  
  cin >> x >> y;
  
  while (!(x == 0 && y == 0))
  {
    if(x > y)
    {
      pool = x;
      x = y;
      y = pool;
    }
    cout << x << " " << y << endl;
    cin >> x >> y;
  }
}


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

#define REP(i,a,b) for(int i = (a) ; i < (int)(b) ; ++i )
#define _REP(i,a,b) for(int i = (a) ; i <= (int)(b) ; ++i )
#define UREP(i,u) for(int i = p[(u)] ; i + 1 ; i = edge[i].next)
//iterator: for(int u:x),x is iterator
#define x(p) (p).first
#define y(p) (p).second
#define mp(x,y) make_pair((x), (y))

#ifdef kinesis
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const int maxn = 2e5 + 5;
int n;
vector<int> G[maxn],l,r,f,s;
int ans[maxn];

void dfs(int u,int fa,int c)
{
    if(c) r.push_back(u);
    else l.push_back(u);
    for(int v:G[u]){
        if(v==fa) continue;
        dfs(v,u,c^1);
    }
}

int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    //#endif // ONLINE_JUDGE
    while(scanf("%d",&n)==1){
        for(int i=0;i<=n;i++) G[i].clear();
        l.clear(),r.clear(),f.clear(),s.clear();
        memset(ans,-1,sizeof ans);
        for(int i=0,u,v;i<n-1;i++){
            scanf("%d%d",&u,&v);
            G[u].push_back(v),G[v].push_back(u);
        }
        dfs(1,0,0);
        if(l.size()<r.size()) l.swap(r);
        for(int i=1;i<=n;i++){
            if(i%3==1) f.push_back(i);
            if(i%3==2) s.push_back(i);
        }
        if(f.size()<s.size()) f.swap(s);
        int tot = 0,cnt = 0;
        if(l.size()>=f.size()+s.size()){
            for(int i:f){
                ans[l[tot++]] = i;
            }
            for(int i:s){
                ans[l[tot++]] = i;
            }
        }
        else{
            for(int i:f){
                ans[l[tot++]] = i;
            }
            for(int i:s){
                ans[r[cnt++]] = i;
            }
        }
        int k = 1;
        for(int i=1;i<=n;i++){
            if(ans[i]==-1){
                ans[i] = 3*k;
                k++;
            }
        }
        int flag = 0;
        for(int i=1;i<=n;i++){
            if(flag) printf(" ");flag = 1;
            printf("%d",ans[i]);
        }
        printf("\n");
    }
    return 0;
}



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

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

    vector<int> vec((N+1), 0);

    for(int i=1; i<=N; i++) {
        cin >> vec[i];
    }

    int push_number = 1;
    for(int i=1; i<=N; i++) {
        push_number = vec[push_number];
        if(push_number == 2) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
///////////////////////////////////////////////
int main(){
	vector<int> A;
	int a;	
	REP(i,3){
		cin >> a;
		A.PB(a);
	}

	sort(ALL(A));

	PRINTD(A[1] * A[0] / 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=998244353,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a,b,k;
  cin >> a >> b >> k;
  rep(i,k)  {
    if(i%2) {
      b-=b%2;
      b/=2;
      a+=b;
    } else {
      a-=a%2;
      a/=2;
      b+=a;
    }
  }
  pr(a,b);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;

void pretty_print(vector<int> &A) {
  cout << A[0];
  for (int i = 1; i < A.size(); i++) cout << ' ' << A[i];
  cout << endl;
}

void isort(vector<int> &A) {
  for (int i = 1; i < A.size(); i++) {
    pretty_print(A);
    // choice base element
    int key = A[i];

    int j = i - 1;

    // if i = 3
    //
    // while: 
    // 1: j = 2 A[3] = A[2] if A[j] > key
    // 2: j = 1 A[2] = A[1] if A[j] > key
    // 3: j = 0 A[1] = A[0] if A[j] > key
    while (j >= 0 && A[j] > key) {
      A[j+1] = A[j];
      j--;
    }

    A[j+1] = key;
  }
}


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

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

  isort(A);
  pretty_print(A);
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, k, c; string s;
    cin >> n >> k >> c >> s;
    vi l(k), r(k);

    // 右方向に貪欲で働く日を決める
    ll pos = 0, cnt = 0;
    while(pos < n && cnt < k){
        if(s[pos] == 'o'){
            l[cnt] = pos;
            cnt++;
            pos += c;
        }
        pos++;
    }

    // 左方向に貪欲で働く日を決める
    pos = n-1, cnt = k-1;
    while(pos >= 0 && cnt >= 0){
        if(s[pos] == 'o'){
            r[cnt] = pos;
            cnt--;
            pos -= c;
        }
        pos--;
    }

    // 重なっている日を出力
    rep(i, k) if(l[i] == r[i]) cout << l[i]+1 << endl;
}

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

const int N = 2e5 + 10;

int n, a[N], pre[N], nxt[N];

int main(){
	while(~scanf("%d", &n)){
		for(int i=0; i<=n+1; i++){
			pre[i] = 0;
			nxt[i] = 0;
		}
		for(int i=1; i<=n; i++){
			scanf("%d", a+i);
            pre[a[i]] = pre[a[i]-1] + 1;
		}
		for(int i=n; i>=1; i--){
			nxt[a[i]] = nxt[a[i]+1] + 1;
		}
		int ans = n - 1;
        for(int i=1; i<=n; i++){
            ans = min(ans, n - nxt[a[i]+1]);
            ans = min(ans, n - pre[a[i]-1]);
            if(i == 1 && a[i] == 1){
				ans = min(ans, n - nxt[a[i]+1] - 1);
            }
            if(i == n && a[i] == n){
				ans = min(ans, n - pre[a[i]-1] - 1);
            }
        }
        printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int h,w,a[103][103],ans=0;
  cin>>h>>w;
  r(i,h)r(j,w)cin>>a[i][j];
  r(i,h)if(i)r(j,w)a[i][j]=(a[i][j]+1)%2;
  r(i,h){
    int l=0,r=w-1;
    while(l<=r){
      if(a[i][r]){
        ans++;r--;
        a[i][r]=(a[i][r]+1)%2;
      }
      else if(a[i][l]){
        ans++;l++;
        a[i][l]=(a[i][l]+1)%2;
      }
      else{
        r--;
        a[i][r]=(a[i][r]+1)%2;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <queue>

using namespace std;



int main() {

    int n, m;
    cin >> n >> m;

    vector<int> adj[n + 1];
    bool visited[n + 1];
    int distance[n + 1];
    queue<int> q;

    for (int i = 1; i <= n; i++){
        visited[i] = false;
        distance[i] = 0;
    }
    
    for (int i = 0; i < m; i++){
        int t1, t2;
        cin >> t1 >> t2;
        adj[t1].push_back(t2);
        adj[t2].push_back(t1);
    }

    int x = 1;
    visited[x] = true;
    distance[x] = 0;
    q.push(x);

    while (!q.empty()){
        int u = q.front();
        q.pop();
        for (auto c : adj[u]){
            if (visited[c]) continue;
            visited[c] = true;
            distance[c] = distance[u] + 1;
            q.push(c);
        }
    }

    // for (int i = 1; i <= n; i++){
    //     cout << " i = " << distance[i] << endl;
    // }

    if (distance[n] == 2){
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0; 
}

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

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int b, r, g, c, s, t;
    while (scanf("%d%d%d%d%d%d", &b, &r, &g, &c, &s, &t), b + r + g + c + s + t){
        int regular = b * 15 + r * 15 + g * 7 + c * 2 + s * 3;
        int bonus_game = b * 5 + r * 3;
        int bonus_grape = bonus_game * 16;
        int pay = t * 3;
        int total = regular + bonus_grape - pay;
        printf("%d\n", 100 + total);
    }
    return (0);
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   ll a,b,k;
   cin>>a>>b>>k;
   if(a>k){
      cout<<a-k<<" "<<b;
   }
   else{
      k-=a;
      if(b>k){
         cout<<0<<" "<<b-k;
      }
      else{
         cout<<0<<" "<<0;
      }
   }
}


Measured memory_bytes: 3632
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val Array(a, b, c, _*) = StdIn.readLine().split(" ").map(_.toInt)
    println(Stream.range(a, b+1).toList.filter(c % _ == 0).length)
  }
}

Measured memory_bytes: 47384
/*URL https://atcoder.jp/contests/abc085/tasks/abc085_b */

#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
using namespace std;


int main () {
    int N;
    int cnt = 1;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) cin >> d.at(i);
    sort(d.begin(), d.end(), greater<int>());
    d.erase(unique(d.begin(), d.end()), d.end());
    int top = d.at(0);
    for(int i = 1; i < d.size(); i++){
        if(d.at(i) < top){
            cnt++;
            top = d.at(i);
        }
        else{
            break;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b[100000];
  cin>>a;
  for(int i=1;i<=a;i++){
    cin>>b[i];
  }
  sort(b,b+a+1);
  cout<<"\n";
  int low=0;
  int high=a;
  int mid=(high+low)/2;
  cout<<b[mid+1]-b[mid]<<"\n";
  return(0);
}

Measured memory_bytes: 640
// Created by new_sm
//
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int x;
cin>>x;
if(x>=30)
cout<<"Yes";
else
cout<<"No";
}
int main()
{
//code

fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    string S;
    cin >> S;
    if (S.length() == 1) {
        print(0);
    } else {
        int ans = 0;
        REP(i, S.length()-1) {
            if (S[i] == S[i+1]) {
                if (S[i+1] == '0') {
                    S[i+1] = '1';
                    ++ans;
                } else {
                    S[i+1] = '0';
                    ++ans;
                }
            }
        }
        print(ans);
    }
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int i,b,c;
		for(i,b=1;i,b<10000;i++){
		cin>>i>>b;
		if(i==0&&b==0){
		break;
		}
		if(i> b){
			swap(i,b);
		}

		cout<<i<<" "<<b<<endl;
	}
}

Measured memory_bytes: 2992
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/

ll ans = 0;
string S;
void dfs(int n,ll v,ll sum){
    if(S.length() == n){
        sum += v; ans += sum;
        return ;
    }
    ll next = v*10 + S[n]-'0';
    dfs(n+1,0,sum+next);
    dfs(n+1,next,sum);
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cin >> S;
    dfs(0,0,0);
    cout << ans/2 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		long x=sc.nextLong();
		long sum=100;
		int y=0;
		
		while(sum<x){
			sum*=1.01;
			y++;
		}
		System.out.println(y);
		

		
	}
	
}


Measured memory_bytes: 35832
#include<bits/stdc++.h>
using namespace std;
long long n,a[222222];
vector<long long> v;
map<int,int> mp;
long long maxn=0;
int powerup(int n)
{
	int s=1;
	while(true)
	{
		s*=2;
		if(s>n)
		  break;
	}
	return s;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mp[a[i]]++;
		if(a[i]>maxn)
		  maxn=a[i];
    }
    long long s=1,ans=0;
	sort(a,a+n);
	for(int i=n-1;i>=0;i--)
	{
		if(mp[a[i]]<=0)continue;
		int x=a[i];
		int y=powerup(x)-x;
		if(mp[y]){
			mp[x]--;
			mp[y]--;
			if(mp[y]>=0)
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 20608
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll count = 0;
	for (int i = 0; i < 1000; i++) {
		int c[3] = { i / 100,(i / 10) % 10,i % 10 };
		int f = 0;
		for (int j = 0; j < n; j++) {
			if (s[j] == ('0' + c[f])) {
				f++;
			}
			if (f == 3) {
				count++;
				break;
			}
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s ;
    vector<int> v(4);
    for(int i = 0;i < 4;i++){
        v[i] = s[i] - '0';
    }

    for(int j = 0;j < (1<<3);j++){
        int tmp = v[0];
        for(int k = 0;k < 3;k++){
            if(j&(1<<k)){
                tmp += v[k+1];
            }else{
                tmp -= v[k+1];
            }
        }
        if(tmp == 7){
            cout << v[0];
            for(int k = 0;k < 3;k++){
                if(j & (1 << k)){
                    cout << '+';
                }else{
                    cout << '-';
                }
                cout << v[1+k];
            }
            cout << "=7" << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a+b)%24<<endl;
    return 0;
}




Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = list(map(int, input().split())) 
b = list(map(int, input().split()))

from bisect import bisect_right
if n>m:
    a, b = b, a
    n, m = m, n
c = [b[0]]
for i in range(1, m):
    c.append(c[-1]+b[i])
a.insert(0,0)
x = 0
result = [0]
for i in range(n+1):
    x += a[i]
    if x > k:
        break
    y = k - x
    z = bisect_right(c, y)
    result.append(z+i)
print(max(result))

Measured memory_bytes: 40756
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			for (int i = 111; i <= 999; i += 111) {
				if (i >= n) {
					System.out.println(i);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 35644
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <algorithm>
 
#define rep(i,n) for(int i=0; i < n; i++)
using namespace std;
#define PI 3.14159265358979
 
int main()
{
    double r;
    cin >> r;
    
 
    cout << 2* r * PI << endl;
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b - a - b + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
V = N*10**3
dp = [[float('INF')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i,j in itertools.product(range(1,N+1),range(V+1)):
    w,v = wv[i-1]
    if j-v>=0:
        dp[i][j] = min(dp[i][j],dp[i-1][j-v]+w)
    dp[i][j] = min(dp[i][j],dp[i-1][j])
print(max([i for i in range(V+1) if dp[-1][i]<=W]))


Measured memory_bytes: 312200
/*
	watch me go
*/
#pragma GCC optimize("O3")
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod=998244353;
int const mod1=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********
int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}


signed main()
{
    haha
    string s;
    cin>>s;
    
  
    if(s[2]==s[3] && s[4]==s[5])
    cout<<"Yes";
    else
    cout<<"No";
    
    
    
    
    
    
   
  
}










 
 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;

#define f first
#define s second
typedef pair<int, int> P;

int ID, rec[22];

int split(string s){
  stringstream ss(s);
  int i = 0;
  while(ss >> rec[i]) i++;
  return i;
}

bool compare(const P x, const P y){
  if(x.f == y.f){
    return x.s < y.s;
  }
  return x.f > y.f;
} 

int main(){
  int n;
  while(cin >> n, n){
    vector<P> data;
    string s;

    for(int cs = 0 ; cs < n ; cs++){
      memset(rec, 0, sizeof(rec));
      cin >> ID;
      getline(cin, s);
      int N = split(s);
      int tes = 0;
      int res = 0, flame = 1;
      for(int i = 0 ; flame <= 10 ; flame++, i++){
	res += rec[i] + rec[i+1];
	if(flame > 9) res += rec[i+2];
	else if(rec[i] == 10) res += rec[i+2];
	else{
	  if(rec[i]+rec[i+1] == 10) res += rec[i+2];
	  i++;
	}
      }
      data.push_back(P(res, ID));
    }
    sort(data.begin(), data.end(), compare);
    for(int i = 0 ; i < n ; i++){
      cout << data[i].second << ' ' << data[i].first << endl;
    }
  }
  return 0;
}

      

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int X, A, B;
    cin >> X >> A >> B;
    
    int bestday = B - A;

    if( bestday >= B || A >= B )
    {
        cout << "delicious" << endl;
    }
    else if( bestday <= X )
    {
        cout << "safe" << endl;
    }
    else if( bestday >= X + 1 )
    {    
        cout << "dangerous" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np
n = int(input())
Ans = [100 for _ in range(26)]
for _ in range(n):
    alp = [0 for _ in range(26)]
    s = input()
    for i in s:
        alp[ord(i)-97] += 1
    Ans = np.minimum(Ans, alp) 
ans = ''
for i in range(26):
    ans += chr(97+i)*Ans[i]
print(ans)

Measured memory_bytes: 13356
#include <iostream>
#include <vector>


using namespace std;


void white_cells()
{
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << (H * W) - (h * W) - (H * w) + (h * w) << "\n";
}


void double_helix()
{
  char b;
  cin >> b;

  if (b == 'A') cout << "T\n";
  else if (b == 'T') cout << "A\n";
  else if (b == 'C') cout << "G\n";
  else  cout << "C\n";

}


void five_antennas()
{
  vector<int> a(5);
  for (int i = 0; i < 5; ++i) cin >> a[i];
  int k;
  cin >> k;

  if (a[4] - a[0] > k)
  {
    cout << ":(\n";
    return;
  }
  cout << "Yay!\n";

}

void buttons()
{
  int a, b;
  cin >> a >> b;

  int v_max = 0;
  for (int i = 0; i < 2; ++i) {
    if (a > b) {
      v_max += a;
      --a;
    }
    else
    {
      v_max += b;
      --b;
    }
  }
  cout << v_max << "\n";
}


void biscuit_generator()
{
  int a, b, t;
  cin >> a >> b >> t;

  cout << t / a * b << "\n";
}


void changing_a_character()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  s[k - 1] += 32;
  cout << s <<"\n";
}


void ferris_wheel()
{
  int a, b;
  cin >> a >> b;

  if (a >= 13) cout << b << "\n";
  else if(a >= 6) cout << b / 2 << "\n";
  else cout << 0 << "\n";
}


void apple_pie()
{
  int a, p;
  cin >> a >> p;

  p += 3 * a;

  cout << p / 2 << "\n";
}


int main()
{
  //white_cells();
  //double_helix();
  //five_antennas();
  //buttons();
  //biscuit_generator();
  //changing_a_character();
  //ferris_wheel();
  apple_pie();
}

Measured memory_bytes: 256
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 2000000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}

int main(){
	string s;
	cin>>s;
	int i,j;
	for(i=0;i<s.size()-1;i++) if(s[i]=='A'&&s[i+1]=='C'){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    string x;
    cin >> x;
    x.push_back('#');
    reverse(x.begin(), x.end());
    x.push_back('#');
    reverse(x.begin(), x.end());
    v(p(char, int)) sub;
    for (int i = 0; i < x.size(); i++) {
        if (x[i] != 'x')
            sub.push_back({x[i], i});
    }
    bool is = true;
    for (int i = 0, j = sub.size() - 1; i < j; i++, j--) {
        if (sub[i].first != sub[j].first) {
            is = false;
            break;
        }
    }
    if (!is) {
        cout << -1 << endl;
        return;
    }
    int l = (sub.size() - 1) / 2 - 1;
    int r = sub.size() / 2 + 1;
    int req = 0;
    for( ; l >= 0 ; l-- , r++){
        int s1 = sub[l + 1].second - sub[l].second;
        int s2 = sub[r].second - sub[r-1].second;
        req += abs(s1 - s2);
    }
    cout<<req<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

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

using namespace std;

typedef long long ll;

ll inf = 1e18;

void min_self(ll& a, ll b) {
    a = min(a, b);
}

void max_self(ll& a, ll b) {
    a = max(a, b);
}

int main() {
    ll N, W, w, v, ans = 0;

    scanf("%lld %lld", &N, &W);

    vector<ll> dp(100001, inf);
    for (int i = 0; i < N; i++) {
        scanf("%lld %lld", &w, &v);
        for (ll pv = 100000; pv >= 0; pv--) {
            if (dp[pv] != inf && dp[pv] + w <= W) {
                min_self(dp[pv + v], dp[pv] + w);
                max_self(ans, pv + v);
            }
        }
        min_self(dp[v], w);
        max_self(ans, v);
    }

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

    return 0;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

int solve() {
	string s;
	cin >> s;

	
	ll res = 0;
	ll cnt = 0;
	REPD(i, 0, s.size()) {
		if (s[i] == 'R') {
			++cnt;
		}
		else {
			res = max(res, cnt);
			cnt = 0;
		}
	}
	res = max(res, cnt);

	RET(res);

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>

using namespace std;


int main(void){
	int n, m;

	cin >> n >> m;

	vector<int> t(n+1);

	int a, b;
	for (int i = 0; i < m; i++){
		cin >> a >> b;
		t[a]++; t[b]++;
	}

	for (int i = 1; i <= n; i++){
		cout << t[i] << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

struct s_p{
  string s;
  int p;
  int number;
  s_p(string s, int p, int num){
    this->s = s;
    this->p = p;
    this->number = num;
  }
};

bool comp(s_p x, s_p y){
  if( x.s < y.s ){
    return true;
  }else if(x.s == y.s && x.p > y.p){
    return true;
  }else{
    return false;
  }
}

int main(){
  vector<s_p> city_point;
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    string temp;
    int point;
    cin >> temp >> point;
    city_point.push_back(s_p(temp, point, i+1));
  }

  sort(city_point.begin(), city_point.end(), comp);

  for(int i=0; i<n; i++){
    cout << city_point.at(i).number << endl;
  }
  return 0;
}


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

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

  if (N.size() <= 3)
    cout << "No" << endl;
  else if (N.substr(0, 4) == "YAKI")
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, ans, x, maxx;
	cin >> n >> k;
	vector<int> a(n);
	for (i = 0; i < n; i++) cin >> a[i];
	ans = 1000100010;
	sort(a.begin(), a.end());
	for (i = 0; i + k - 1 < n; i++) ans = min(ans, a[i + k - 1] - a[i]);
	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 640
#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>
#include <random>

#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() {
    string s;
    cin >> s;
    int n = s.size();
    if (s[0] == '0' || s[n-1] == '1') {
        cout << -1 << endl;
        return;
    }
    REP(i,0,n/2) {
        if (s[i] != s[n-i-2]) {
            cout << -1 << endl;
            return;
        }
    }
    int prev = 1;
    REP(i,0,n-1) {
        cout << prev << " " << i + 2 << endl;
        if (s[i] == '1') {
            prev = i + 2;
        }
    }
}

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

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b == c) cout << "Yes" << endl;
    else if (a+c == b) cout << "Yes" << endl;
    else if (b+c == a) cout << "Yes" << endl;
    else cout <<"No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n, m; cin >> n >> m;
    vector<vector<vector<int> > > dp(n + 1, vector<vector<int> > (m + 1, vector<int> (2, -1)));
    dp[0][0][0] = 0LL;

    string s; cin >> s;
    string t; cin >> t;
    
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            for(int k = 0; k < 2; k++){
                if(dp[i][j][k] == -1) continue;

                if(k == 0){
                    // 次に欲しいのは 1
                    if(i != n){
                    if(s[i] == 'I') dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][k] + 1);
                    else dp[i + 1][j][0] = max(dp[i + 1][j][0], 0LL);
                    }

                    if(j != m){
                    if(t[j] == 'I') dp[i][j + 1][1] = max(dp[i][j + 1][1], dp[i][j][k] + 1);
                    else dp[i][j + 1][0] = max(dp[i][j + 1][0], 0LL);
                    }
                }else{
                    // 次に欲しいのは 0
                    
                    if(i != n){
                    if(s[i] == 'O') dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k] + 1);
                    else dp[i + 1][j][0] = max(dp[i + 1][j][0], 0LL);
                    }

                    if(j != m){
                    if(t[j] == 'O') dp[i][j + 1][0] = max(dp[i][j + 1][0], dp[i][j][k] + 1);
                    else dp[i][j + 1][0] = max(dp[i][j + 1][0], 0LL);
                    }
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            ans = max(ans, dp[i][j][1]);
        }
    }
    
    /*
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            cout << i << " " << j << " " <<  dp[i][j][0] << " " << dp[i][j][1] << endl;
        }
    }
    */
    cout << ans << endl;
        
    return 0;
}



Measured memory_bytes: 222004
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	str := strings.Split(s, "")
	ret := 0
	text := ""
	prev_text := ""
	flg := true
	for i := 0; i < len(s); i++ {
		text += str[i]
		if str[i] == prev_text && flg {
			flg = !flg
			continue
		}
		flg = true
		ret++
		prev_text = text
		text = ""
	}
	fmt.Println(ret)
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;


struct Node{
    ll key;
    struct Node *left, *right, *parent;
};
Node *root,*NIL;

void preorder(Node * node){
  if(node == NIL){
    return;
  }
  cout << " " << node->key;
  preorder(node->left);
  preorder(node->right);

}
void inorder(Node * node){
  if(node == NIL){
    return;
  }
  inorder(node->left);
  cout << " " << node->key;
  inorder(node->right);
}
void print(){
  inorder(root);
  cout << endl;
  preorder(root);
  cout << endl;
}

void insert(ll k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y->right = z;
    }
  }
}
int main(){
  ll n;
  cin >> n;
  string str;
  rep(i,n){
    cin >> str;
    if(str == "insert"){
      cin >> t1;
      insert(t1);
    }else{
      print();
    }
  }
}


Measured memory_bytes: 26644
#include<bits/stdc++.h>
using namespace std;
int n,t;
int a[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>t;
	int maxx=0;
	int ans=0;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=n;i>=1;i--){
		maxx=max(maxx,a[i]);
		ans=max(ans,maxx-a[i]);
	}
	maxx=0;
	int tot=0;
	for(int i=n;i>=1;i--){
		maxx=max(maxx,a[i]);
		if(maxx-a[i]==ans)
			tot++;
	}
	cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-

M, D = list(map(int, input().split()))
counter = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d = str(d)
        if len(d) != 2:
            continue
        else:
            d1 = int(d[0])
            d2 = int(d[1])
            if d1 >= 2 and d2 >= 2 and m == d1*d2:
                counter += 1

print(counter)


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

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i = 0; i < N; ++i) cin >> P[i];
  int m = N;
  int ans = 0;
  for(int i = 0; i < N; ++i){
    m = min(m,P[i]);
    if(m >= P[i]) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <map>
using namespace std;

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

  int n;
  cin >> n;

  vector<int64_t> a(n), b(n), surplus;
  int64_t demand = 0;

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

    if (a[i] - b[i] > 0) surplus.push_back(a[i] - b[i]);
    else if (a[i] - b[i] < 0) {
      demand += b[i] - a[i];
      ans++;
    }
  }
  sort(surplus.begin(), surplus.end(), greater<int64_t>());

  for (int64_t s : surplus) {
    if (demand > 0) {
      ans++;
      demand -= min(demand, s);
    }
  }
  if (demand > 0) ans = -1;
  cout << ans << endl;

  return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  ll N,K,Q;
  cin>>N>>K>>Q;
  vector<ll> v(N);
  rep(i,N) cin>>v[i];
  ll ans = INF;
  rep(i,N){
    ll m = v[i];
    ll l = -1LL,r=1000000005LL;
    while(r-l>1){
      ll mid = (l+r)/2LL;
      vector<ll> c(N);
      vector<ll> ze;
      ze.push_back(-1LL);
      vector<ll> cnt(N+1);
      rep(j,N) {
        if(v[j]<m) {
          c[j] = 0;
          ze.push_back(j);
        }
        else if(v[j]<=m+mid) {
          c[j] = 1;
          cnt[j+1]++;
        }
        else c[j] = 2; 
      }
      ze.push_back(N);
      ll possible = 0;
      rep(j,N) cnt[j+1] += cnt[j];
      rep(j,(int)ze.size()-1){
        if(ze[j+1]-ze[j]-1<K) continue;
        possible += min(cnt[ze[j+1]]-cnt[ze[j]+1],ze[j+1]-ze[j]-K);
      }
      if(possible>=Q) r = mid;
      else l = mid;
    }
    if(r!=1000000005) chmin(ans,r);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3660
import math
a,b=map(int,input().split())
int(a)
int(b)
c=a*b
int(c)
if a==1 or b==1:
    print(1)
elif c%2==0:
    d = c/2
    print(int(d))
else:
    d = math.floor(c/2) + 1
    print(int(d))

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




int gcd(int a, int b){
  int bigger=max(a,b);
  int smaller=min(a,b);
  
  if (bigger%smaller==0){
    return smaller;
  }
  else {
    return gcd(smaller,bigger%smaller);
  }
  
}






int main(){

  string s;
  cin>>s;
  
  int ssize=int(s.size());
  
  int countzero=0;
  int countone=0;
  
  for (int i=0;i<ssize;i++){
    if (s.at(i)=='0'){
      countzero++;
    }
    else {
      countone++;
    }
  }
  
  
  cout<<2*min(countzero,countone)<<endl;
  
 
  
  
  
  

  

        
}

Measured memory_bytes: 512
import sys
anslist = []
while True:
    m, nmin, nmax = [int(i) for i in input().split()]
    if m == 0:
        for i in anslist:
            print(i)
        sys.exit()
    p = [int(input()) for i in range(m)]
    ansnum = 0
    ans = 0
    for i in range(nmin-1,nmax):
        if ansnum <= p[i]-p[i+1] and not p[i]-p[i+1]==0:
            ans = i
            ansnum = p[i]-p[i+1]
    anslist.append(ans+1)



Measured memory_bytes: 5640
n=int(input());s=input()

r=s.count("R")
g=s.count("G")
b=s.count("B")
ans = r*g*b

for i in range(1,n-1):
    mid = s[i]
    front = s[i-1::-1]
    back = s[i+1:]
    for j in range(min(len(front),len(back))):
        if mid != front[j] and mid != back[j] and front[j] != back[j]:
            ans -= 1
    
print(ans)


Measured memory_bytes: 9200
#include <iostream>
#include <vector>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {

	uint N;
	cin >> N;

	vector<uint> A(N);
	vector<uint> B(N);
	vector<uint> C(N);
	for(uint i=0; i<N; i++) {
		cin >> A[i] >> B[i] >> C[i];
	}

	ull dpA = 0;
	ull dpB = 0;
	ull dpC = 0;

	for(uint i=0; i<N; i++) {
		ull fA = dpA;
		ull fB = dpB;
		ull fC = dpC;
		dpA = A[i] + max(fB, fC);
		dpB = B[i] + max(fA, fC);
		dpC = C[i] + max(fA, fB);
	}

	cout << max(dpA, max(dpB, dpC));
	return 0;
}


Measured memory_bytes: 1408
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, C, D = map(int, readline().split())
    start = max(A, C)
    end = min(B,D)
    print(max(end-start,0))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9180