akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

int n,h,w;
vector<P> ah[100010],aw[100010];
set<int> ps,hs[4];

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>w>>h;
  UnionFind uf(n);
  rep(i,n){
    int x,y;
    cin>>x>>y;
    x--; y--;
    ah[y].push_back(P(x,i)); 
    aw[x].push_back(P(y,i));
  }
  rep(i,100001){
    sort(all(ah[i]));
    sort(all(aw[i]));
  }
  rep(i,h){
    rep(j,ah[i].size()-1){
      uf.unite(ah[i][j].se,ah[i][j+1].se);
    }
  }
  rep(i,w){
    rep(j,aw[i].size()-1){
      uf.unite(aw[i][j].se,aw[i][j+1].se);
    }
  }
  if(uf.size(0)==n){
    cout<<n-1<<endl;
    return 0;
  }
  rep(i,h){
    rep(j,ah[i].size()){
      ps.insert(uf.find(ah[i][j].se));
      if(ah[i][j].fi==0)hs[0].insert(uf.find(ah[i][j].se));
      if(ah[i][j].fi==w-1)hs[1].insert(uf.find(ah[i][j].se));
    }
  }

  rep(i,w){
    rep(j,aw[i].size()){
      ps.insert(uf.find(aw[i][j].se));
      if(aw[i][j].fi==0)hs[2].insert(uf.find(aw[i][j].se));
      if(aw[i][j].fi==h-1)hs[3].insert(uf.find(aw[i][j].se));
    }
  }
  int res=INF;
  int sum=0;
  each(it,ps){
    sum+=uf.size(it)-1;
  }
  rep(k,4){
    minch(res,sum+ps.size()*2-1-hs[k].size());
  }
  cout<<res<<endl;
  return 0; 
}

Measured memory_bytes: 11304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2==0) cout<<s[i];
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  ll x, y;
  cin >> x >> y;

  ll ans = 0, res = x;
  while (res <= y) {
    ans++;
    res *= 2;
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int a,b;
	scanf("%d %d",&a,&b);
	char x[5];
	sprintf(x,"%d",b);
	for(int i=0;i<strlen(x);i++)
		a=a*10+x[i]-'0';
	double t=sqrt(a);
	if((int)t*t!=a)printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
import sys

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


def main():
    X, A, B = map(int, readline().split())
    if -A+B<=0:
        print('delicious')
    elif 0<-A+B<=X:
        print('safe')
    else:
        print('dangerous')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9084
n = gets.chomp.to_i
a = gets.split().map(&:to_i)
ans = "APPROVED"
array = []
a.each do |x|
  if x % 2 == 0
    array << x
  end
end
array.each do |y|
  if y % 3 == 0 || y % 5 == 0
  else
    ans = "DENIED"
  end
end
puts ans

Measured memory_bytes: 1788
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using System;

public class Hello
{
    public static long ans = long.MinValue;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var p = Array.ConvertAll(line, x => int.Parse(x) - 1);
        line = Console.ReadLine().Trim().Split(' ');
        var c = Array.ConvertAll(line, int.Parse);
        getAns(n, k, p, c);
    }
    static void getP(List<long> a, int k,long asum)
    {
        var aL = a.Count();
        var t = k / aL;
        var b = k % aL;
        var sbase = asum * (t - 1);
        long s;
        for (int i = 0; i < aL; i++)
        {
            s = sbase;
            for (int j = 0; j < b; j++)
            {
                var nj = i + j;
                if (nj >= aL) nj -= aL;
                s += a[nj];
            }
            for (int j = 0; j < aL; j++)
            {
                var nj = i + b + j;
                if (nj >= aL) nj %= aL;
                s += a[nj];
                ans = Max(ans, s);
            }
        }
    }
    static void getM(List<long> a,int k)
    {
        var acnt = a.Count();
        var jmax = Min(k,  acnt);
        for (int i = 0; i < acnt; i++)
        {
            var s = a[i];
            ans = Max(ans, s);
            for (int j = 1; j < jmax; j++)
            {
                var nj = i + j;
                if (nj >= acnt) nj -= acnt;
                s += a[nj];
                ans = Max(ans, s);
            }
        }
    }
    static void getAns(int n, int k, int[] p, int[] c)
    {
        var visited = new bool[n];
        for (int i = 0; i < n; i++)
        {
            if (!visited[i])
            {
                var a = new List<long>();
                visited[i] = true;
                var np = p[i];
                a.Add(c[i]);
                while (true)
                {
                    if (visited[np]) break;
                    a.Add(c[np]);
                    visited[np] = true;
                    np = p[np];
                }
                var asum = a.Sum();
                if (asum <= 0) getM(a,k);
                else getP(a, k, asum);
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 29628
#include<bits/stdc++.h>
using namespace std;
#define int long long


typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)


char IO;
inline ll rd(){
	ll s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}


const int N=1e5+10;

int n,m;
int a[N];
int ans=1;

vector <int> V;
int sum[N];
void Check(int x){
	//if(x>1e6) return;
	int res=0;
	V.clear();
	rep(i,1,n) {
		int t=a[i]/x,u=a[i]-t*x;
		V.push_back(u);
	}
	sort(V.begin(),V.end());
	int k=V.size();sum[k]=0;
	drep(i,k-1,0) sum[i]=sum[i+1]+x-V[i];
	int t=2e9;
	rep(i,0,k-1) {
		res+=V[i];
		t=min(t,max(res,sum[i+1]));
	}
	if(t<=m) ans=max(ans,x);
}


int s;
signed main(){
	n=rd(),m=rd();
	rep(i,1,n) a[i]=rd(),s+=a[i];
	sort(a+1,a+n+1);
	rep(i,1,sqrt(s)+1) if(s%i==0) {
		Check(i);
		Check(s/i);
	}
	printf("%lld\n",ans);
}






Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int i,z,s,n,k,min=1000000,sum=0,p;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%d",&p);
        sum=sum+p;
        if(p<min){
            min=p;
        }
    }

    z=k-sum;
    if(z==0){
        printf("%d\n",n);
    }
    else{
        s=n+(z/min);
        printf("%d\n",s);
    }
    return 0;
}


Measured memory_bytes: 128
d, g = map(int, input().split())

p, c = [], []
for _ in range(d):
     tp, tc = map(int, input().split())
     p.append(tp)
     c.append(tc)

ans = float("inf")
for bit in range(2 ** d):
    s_temp = 0
    p_temp = 0
    m_temp = -1
    for dd in range(d):
        if (bit >> dd) & 1:
            s_temp += p[dd] * (dd+1) * 100 + c[dd]
            p_temp += p[dd]
        else:
            m_temp = dd
            
    diff = g - s_temp
    
    if diff <= 0:
        ans = min(ans, p_temp)
    elif m_temp != -1:
        from math import ceil
        tt = ceil(diff / (m_temp+1) / 100)
        if tt <= p[m_temp]:
            ans = min(ans, p_temp + tt)

print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main () {
    int n;
    int l[100000], r[100000];

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cnt += r[i] - l[i] + 1;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i = 0;i < n;i++)

using namespace std;

// input
double W,H,x,y;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> W >> H >> x >> y;

  double n,m;

  n = W-x;
  m = H-y;

  cout << W * H / 2 << " ";
  if (n == x && y == m ){
    cout << 1 << "\n";
  } else {
    cout << 0 << "\n";
  }
}

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

using namespace std;

int main(){
  long long N,i,ans=0;
  cin >> N;
  map<long long, long long> mp;
  long long a[N+1];
  map<long long,long long>::const_iterator itr;
  for(i=0;i<N;i++){
    cin >> a[i];
    itr = mp.find(a[i]);
    if(itr != mp.end())mp[a[i]]++;
    else mp[a[i]] = 1;
  }
  for(itr = mp.begin(); itr != mp.end(); ++itr){
    if(itr->first > itr->second)ans += itr->second;
    else ans += (itr->second - itr->first);
  }
  cout << ans << endl;
  return 0;
}


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


void solve(long long r){
    cout << 3*r*r << endl;
}

// 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)
int main(){
    long long r;
    scanf("%lld",&r);
    solve(r);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

vector<Int> dx{ 1,0,-1,0 };
vector<Int> dy{ 0,1,0,-1 };

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int H, W;
	cin >> H >> W;

	vector<vector<char>> G(H, vector<char>(W));
	vector<vector<Int>> dist(H, vector<Int>(W,-1));
	queue<pair<Int, Int>> que;
	char temp;
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			cin >> temp;
			if (temp=='#') {
				dist[i][j] = 0;
				que.push(make_pair(i, j));
			}
		}
	}

	Int x, y, nx, ny;
	while (!que.empty()) {
		x = que.front().first;
		y = que.front().second;
		que.pop();

		for (Int i = 0; i < 4; i++) {
			nx = x + dx[i];
			ny = y + dy[i];

			if (nx<0||nx>=H) {
				continue;
			}
			if (ny<0||ny>=W) {
				continue;
			}

			if (dist[nx][ny]!=-1) {
				continue;
			}

			dist[nx][ny] = dist[x][y] + 1;
			que.push(make_pair(nx, ny));
		}
	}

	
	
	Int ans = 0;
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			ans = max(ans, dist[i][j]);
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 25524
#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
bool solve()
{
	int sum_odd=0,sum_even=0;
	for (int i=1;i<=n;i++)
	{
		sum_odd+=a[i]&1;
		sum_even+=(a[i]&1)^1;
	}
	if (sum_even&1) return 1;
	if (sum_odd==1)
	{
		int t=0;
		for (int i=1;i<=n;i++)
		{
			if (a[i]&1)
			{
				if (a[i]==1) return 0;
				a[i]--;
			}
			t=__gcd(t,a[i]);
		}
		for (int i=1;i<=n;i++)
			a[i]/=t;
		return solve()^1;
	}
	else return 0;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	puts(solve()?"First":"Second");
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int[] num = new int[11];
	int r = sc.nextInt();
	int D = sc.nextInt();
	int x = sc.nextInt();

	num[0] = x;
	
	if(2 <= r && r <= 5){
	    if(1 <= D && D <= 100 && D < x && x <= 200){
		for(int i = 0; i < 10; i++){
		    num[i+1] = r * num[i] - D;
		    System.out.println(num[i+1]);
		}
	    }
	}
    }
}

	


Measured memory_bytes: 21972
import numpy as np

def main(n, xs):
    minx = min(xs)
    maxx = max(xs)
    ress = []

    for x in range(minx, maxx+1):
        res = sum((xs - x) ** 2)
        ress.append(res)

    res = min(ress)
    return res

if __name__ == "__main__":
    cin = input()
    n = int(cin.split(" ")[0])
    cin = input()
    xs = np.array(cin.split(" ")).astype("int")
    cout = main(n, xs)
    print(cout)

Measured memory_bytes: 13064
fun main(args: Array<String>) {
    val cs = readInputLine().split(" ").map { it.toInt() }.toMutableList()
    cs.addAll(readInputLine().split(" ").map { it.toInt() }.toList())
    cs.addAll(readInputLine().split(" ").map { it.toInt() }.toList())
    
    for (a1 in -100..100) {
        for (a2 in -100..100) {
            for (a3 in -100..100) {
                val bs = listOf(cs[0] - a1, cs[1] - a1, cs[2] - a1)
                var ok = true

                for (i in 3..5) {
                    if (cs[i] != a2 + bs[i % 3]) {
                        ok = false
                        break
                    }
                }
                if (!ok) {
                    continue
                }
                
                for (i in 6..8) {
                    if (cs[i] != a3 + bs[i % 3]) {
                        ok = false
                        break
                    }
                }
                if (ok) {
                    println("Yes")
                    return
                }
            }
        }
    }
    
    println("No")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 104612
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	char c[a+2][b+2];
	int sum[a+2][b+2];
	memset(sum,0,sizeof(sum));
	for(int i=1;i<=a;i++) 
		for(int j=1;j<=b;j++)
		{
			cin>>c[i][j];
			if(c[i][j]=='#')
			{
				sum[i-1][j-1]++;
				sum[i-1][j]++;
				sum[i-1][j+1]++;
				sum[i][j-1]++;
				sum[i][j+1]++;
				sum[i+1][j-1]++;
				sum[i+1][j]++;
				sum[i+1][j+1]++;
			}
		}
	for(int i=1;i<=a;i++)
	{
		for(int j=1;j<=b;j++)
			if(c[i][j]=='.')
				cout<<sum[i][j];
			else
				cout<<c[i][j];
		cout<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 256
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-01-31 16:18:46
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 __int128
#include<vector>
const int N=210;
int n,f[N],d[N],t,a[N],m;
i64 s[N];
std::vector<int> e[N];
void clear(){ fr(i,1,n) f[i]=0; }
int dfs(int u)
{
//	printf("%d\n",u);
	int ans=0;
	d[u]=d[f[u]]+1;
	for(auto v:e[u]) if(v!=f[u]){ f[v]=u; ans+=dfs(v); }
	return std::max(ans,1);
}
int solve(){ int ans=1; fr(i,2,n) if(d[i]>d[ans]) ans=i; return ans; }
i64 calc(int u,int v)
{
//	fr(i,1,m) printf("%d%c",a[i],i==m?'\n':' ');
	fr(i,0,n+1) s[i]=0;
	if(v)
	{
		f[u]=v; f[v]=u; d[v]=0; dfs(u); int k=d[u]; d[u]=0; dfs(v); d[u]=k; f[u]=f[v]=0;
	}
	else dfs(u);
	if(u&&v){ s[1]=2; fr(i,1,n) d[i]++; }
	int _m=0;
	fr(i,1,n) _m=std::max(_m,d[i]);
//	fr(i,1,n) printf("%d%c",d[i],i==n?'\n':' ');
	fr(i,1,n) s[d[i]]=std::max(s[d[i]],(i64)e[i].size());
	s[0]=1;
//	fr(i,1,n) printf("%d%c",d[i],i==n?'\n':' ');
	fr(i,1,_m-1) s[0]=s[0]*(s[i]-(i!=1));
//	printf("\n%d %d\n",u,v);
//	fr(i,1,_m-1) printf("%d%c",(int)s[i],i==_m?'\n':' ');
//	printf("%lld\n",s[0]);
	return s[0];
}
int main()
{
	n=read();
	fr(i,1,n-1){ int u=read(),v=read(); e[u].push_back(v); e[v].push_back(u); }
	dfs(1); t=solve(); clear(); dfs(t); t=solve(); m=d[t];
	int k=m;
	printf("%d ",(k+1)/2);
	fd(i,m,1){ a[i]=t; t=f[t]; }
	clear();
	i64 ans;
	if(k%2==0) ans=calc(a[m/2],a[m/2+1]);
	else if(k%2==1)
	{
		ans=calc(a[m/2+1],0);
		for(auto i:e[a[m/2+1]]) ans=std::min(ans,calc(a[m/2+1],i));
	}
	printf("%lld\n",(long long)ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
#define SEN 2000000000
 
typedef struct{
  char suit;
  int value;
}Card;
 
Card L[MAX/2+2], R[MAX/2+2];
 
void merge(Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
 
  for(i=0;i<n1;i++)
    L[i]=A[left+i];
  for(i=0;i<n2;i++)
    R[i]=A[mid+i];
 
  L[n1].value=R[n2].value=SEN;
 
  i=j=0;
 
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}
 
void mergesort(Card A[], int n, int left, int right){
  int mid;
 
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(A,n,left,mid);
    mergesort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}
 
int part(Card A[], int n, int p, int r){
  int i, j;
  Card t, x;
 
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
 
  return i+1;
}
 
void quick(Card A[], int n, int p, int r){
  int q;
  if(p<r){
    q=part(A,n,p,r);
    quick(A,n,p,q-1);
    quick(A,n,q+1,r);
  }
}
 
int main(){
  int n, i, v;
  Card A[MAX],B[MAX];
  char S[10];
  int stable=1;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%s %d", S, &v);
 
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
 
  mergesort(A,n,0,n);
  quick(B,n,0,n-1);
 
  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit)
      stable=0;
  }
  if(stable==1)
    printf("Stable\n");
  else printf("Not stable\n");
 
  for(i=0;i<n;i++){
    printf("%c %d\n", B[i].suit, B[i].value);
  }
  return 0;
}

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

string S, P;

string itos(int n) {
	string S(4, '$');
	for(int i = 0; i < 4; ++i) {
		S[i] = n % 10 + '0';
		n /= 10;
	}
	return S;
}

int expr(int&);

int myhash(int& i) {
	// cerr << "myhash : " << i << endl;
	int ret;
	if (S[i] == '[') {
		++i;
		ret = expr(i);
		assert(S[i] == ']');
		++i;
	} else {
		assert('a' <= S[i] && S[i] <= 'd');
		ret = P[S[i] - 'a'] - '0';
		++i;
	}
	return ret;
}

int expr(int& i) {
	// cerr << "expr : " << i << endl;
	char c = S[i];
	++i;
	int a = myhash(i);
	int b = myhash(i);

	int ret;
	if (c == '+') {
		ret = a | b;
	} else if (c == '*') {
		ret = a & b;
	} else if (c == '^') {
		ret = a ^ b;
	} else {
		cerr << "op : " << c << endl;
		terminate();
	}
	return ret;
}

bool solve() {
	cin >> S;
	if (S == ".") return false;

	cin >> P;
	int i = 0;
	int h = myhash(i);

	int cnt = 0;
	for(int n = 0; n < 10000; ++n) {
		P = itos(n);
		i = 0;
		if (myhash(i) == h) ++cnt;
	}

	cout << h << " " << cnt << endl;
	return true;
}

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



Measured memory_bytes: 3176
#include <iostream>
using namespace std;
 
int main(){

    string s;
    cin >> s;

    int n;
    n = (int)(s.length());
    // nは奇数

    bool kaibunFlg = true;
    for(int i=0; i<n/2; i++){
        if(s[i] != s[n-i-1])
            kaibunFlg = false;
    }

    if(!kaibunFlg){
        cout << "No" << endl;
        return 0;
    }

    string s2;
    s2 = s.substr(0,(n-1)/2);

    int n2;
    n2 = (int)(s2.length());

    for(int i=0; i<n2/2; i++){
        if(s2[i] != s2[n2-i-1])
            kaibunFlg = false;
    }

    if(!kaibunFlg){
        cout << "No" << endl;
        return 0;
    }

    string s3;
    s3 = s.substr((n+3)/2-1);

    int n3;
    n3 = (int)(s3.length());

    for(int i=0; i<n3/2; i++){
        if(s3[i] != s3[n3-i-1])
            kaibunFlg = false;
    }

    if(!kaibunFlg){
        cout << "No" << endl;
        return 0;
    }
    
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <stdlib.h>

int A[4][4];
int B[4][4];

void I() {
  int i, j;
  for(i = 0; i < 4; i++)
    for(j = 0; j < 4; j++)
      scanf("%d", &A[i][j]);
}

void O() {
  int i, j;
  for(i = 0; i < 4; i++) {
    for(j = 0; j < 4; j++) printf("%3d", A[i][j]);
    puts("");
  }
}

void C(int m[4][4], int t[4][4]) {
  int i, j;

  for(i = 0; i < 4; i++)
    for(j = 0; j < 4; j++) m[i][j] = t[i][j];
}

int CA() {
  int i, sum = 0;
  for(i = 0; i < 16; i++) {
    int v = A[i/4][i%4];
    if(v) {
      v--;
      sum += abs(i/4-v/4)+abs(i%4-v%4);
    }
  }
  return sum;
}

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

void S(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int IN(int x, int y) {
  return 0<=x&&x<4&&0<=y&&y<4;
}

int D(int x, int y, int p, int dep, const int lim) {
  int i, h = CA();
  if(h == 0) return dep;
  if(dep+h > lim) return -1;

  for(i = 0; i < 4; i++) {
    int nx = x+dx[i], ny = y+dy[i], res;
    if(~p && i == (p+2)%4) continue;
    if(!IN(nx, ny)) continue;
    S(&A[y][x], &A[ny][nx]);
    res = D(nx, ny, i, dep+1, lim);
    if(~res) return res;
    S(&A[y][x], &A[ny][nx]);
  }

  return -1;
}

void G(int *x, int *y) {
  int i, j;
  for(i = 0; i < 4; i++) {
    for(j = 0; j < 4; j++) {
      if(!A[i][j]) {
	*x = j;
	*y = i;
	return;
      }
    }
  }
}

int  SO() {
  int x, y, lim, ans;
  G(&x, &y);
  for(lim = 0; lim < 50; lim++) {
    C(B, A);
    if((ans = D(x, y, -1, 0, lim)) != -1) return ans;
    C(A, B);
  }
  return -1;
}

int main() {
  I();
  printf("%d\n", SO());
  return 0;
}



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

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let s = iter.next().unwrap().chars().collect::<Vec<_>>();
    let mut ans = 1;
    for i in 0..n-1 {
        if s[i] != s[i+1] { ans += 1; }
    }
    println!("{}", ans);
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  int N;
  cin >> N;
  vi perm(N);
  vi P(N), Q(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    perm[i] = i + 1;
  }
  for (int i = 0; i < N; i++) {
    cin >> Q[i];
  }
  int a, b, cnt = 0;
  do {
    if (perm == P) a = cnt;
    if (perm == Q) b = cnt;
    cnt++;
  } while (next_permutation(all(perm)));
  cout << abs(a - b) << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
int main(void)
{
    int A,B,C,K;
    cin >>A>>B>>C>>K;
    
    int point;
    point=0;
    if(A>K){cout<<K<<endl;
        return 0;
    }
    for(int i=0;i<A;i++){
            
            point++;
    }
    if(K<A+B){cout<<point<<endl;
    return 0;
    }
    for(int j=0;j<(K-A-B);j++){
        point--;
    }
    cout<<point<<endl;


    


    return 0;
}
 

Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
#define INF (1<<29)


int main(){
    int n,m;
    cin>>n;
    vi d(n);
    for(int i=0; i<n; i++){
        cin>>d[i];
    }

    cin>>m;
    vi t(m);
    for(int i=0; i<m; i++){
        cin>>t[i];
    }
    sort(d.begin(),d.end());
    sort(t.begin(),t.end());


    int j=0;
    for(int i=0; i<m; i++){
        //全てあればいい
        while(1){
            if(t[i]==d[j]){
                j++;
                break;
            }
            if(j==n){
                cout<<"NO"<<endl;
                return 0;
            }
            j++;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

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


int main(){
	string s;
	long long int k;
	cin >> k >> s;
	if(s.size()<=k){
		cout << s << endl;
	}else{
		for(int i=0;i<k;i++){
			cout << s.at(i);
		}
		cout << "..." << endl;
	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl f(n + 1, 0);
  rep2(x, 1, 101) rep2(y, 1, 101) rep2(z, 1, 101) {
    ll now = x * x + y * y + z * z + x * y + y * z + z * x;
    if(now > n) continue;
    f[now]++;
  }
  rep2(i, 1, n + 1) cout << f[i] << '\n';
}

Measured memory_bytes: 3648
import sys

input = sys.stdin.readline


def main():
    c11, c12, c13 = map(int, input().split())
    c21, c22, c23 = map(int, input().split())
    c31, c32, c33 = map(int, input().split())

    # a1 = 0
    b1, b2, b3 = c11, c12, c13
    a2 = c21 - b1
    a3 = c31 - b1

    ans = "Yes"
    if (a2 + b2 != c22) or (a2 + b3 != c23) or (a3 + b2 != c32) or (a3 + b3 != c33):
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
/*
 * atcoder/dp/g2.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

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

const int MAX = 100010;
int n, m;
vector<int> G[MAX];

vector<int> dp(MAX, -1);

int dfs(int v) {
  int &cc = dp[v];
  if (~cc) return cc;
  int res = 0;
  for (auto&& u: G[v]) {
    chmax(res, dfs(u) + 1);
  }

  return cc = res;
}

void solve() {
  int a,b;
  cin >> n >> m;
  loop(i,0,m) {
    cin >> a >> b;
    a--;b--;
    G[b].push_back(a);
  }

  int res = 0;
  loop(i,0,n) {
    chmax(res, dfs(i));
  }

  cout << res << endl;
}


Measured memory_bytes: 10624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#define R register
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	if(n%2==0) printf("0.5000000000\n");
	else 
	{
		double t=(double)(n/2+1)/(double)(n);
		printf("%.10lf\n",t);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> vec;
    int a=0,b=0,c;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        vec.push_back(t);
        if(t%4==0){
            a++;
        }else if(t%2==0){
            b++;
        }
    }
    c=n-a-b;
    if(a>=c){
        cout<<"Yes"<<endl;
    }else if(b==0&&a==c-1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 892
macro_rules! read_line {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

fn read_trim() -> String {
    read_line!().trim().to_owned()
}

fn rev_str(string: &str) -> String {
    string.chars()
        .rev()
        .fold(String::new(), |accu, elem| accu + &elem.to_string())
}

fn main() {
    let mut a = rev_str(&read_trim());
    let mut b = rev_str(&read_trim());
    let mut c = rev_str(&read_trim());

    let mut turn: char = 'a';

    loop {
        match turn {
            'a' => if let Some(card) = a.pop() {turn=card} else {break},
            'b' => if let Some(card) = b.pop() {turn=card} else {break},
            'c' => if let Some(card) = c.pop() {turn=card} else {break},
            _ => panic!(),
        }
    }

    println!("{}", match turn {
        'a' => 'A',
        'b' => 'B',
        'c' => 'C',
        _ => panic!(),});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
int n;
vector<int> a(n);

int bin_search(int k){
        int p,q;
        int l = -1,r = n;
        while(r-l > 1){
                int m = (l+r)/2;
                if(a.at(m) >= k) r = m;
                else l = m;
        }
        p = l;
        l = -1;
        r = n;
        while(r-l >1){
                int m = (l+r)/2;
                if(a.at(m) > k) r = m;
                else l = m;
        }
        q = l;
        return q-p;
}


int main() {
        cin >> n;
        a.resize(n);
        rep(i,n) cin >> a.at(i);
        int t;
        cin >>t;
        int ans = 0;
        rep(i,t){
                 int r;
                cin >>r;
                if(bin_search(r) > 0) ans ++;
        }
        cout << ans << endl; 
        
        return 0;
}



Measured memory_bytes: 3120
N = gets.to_i
A = []
N.times do
  a = gets.to_i
  A << a.times.map do
    x,y = gets.split
    [x.to_i,y]
  end
end

X = 2**N - 1
ans = 0
0.upto(X) do |n|
  ns = ("%0#{N}b" % n).chars
  ans = [ans,ns.count("1")].max if ns.each.with_index(0).all? do |x,i|
    x == "0" || A[i].all?{|x,y| ns[x-1] == y}
  end
end

puts ans

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

int main(){
  
  int A,B;
  cin >>A>>B;
  
  int tap = 1;
  int ans = 0;
  
  while(tap<B){
    tap += A-1;
    ans ++; 
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import itertools
import math

n = int(input())
s = []

for i in range(n):
    s.append(list(map(int,input().split())))

def distance(a,b):
    return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)

tmp =0
# comb = len(itertools.combinations(s,2))
for j in itertools.combinations(s,2):
    tmp += distance(j[0],j[1])

print(tmp*2/n)

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

int main() {
    while(true){
        string S; cin >> S;
        if (S == "-")break;

        queue<char> Q;
        rep(i, S.size()){
            Q.push(S[i]);
        }

        int m; cin >> m;
        rep(i,m){
            int h; cin >> h;
            rep(j,h){
                char x = Q.front();
                Q.pop();
                Q.push(x);
            }
        }

        while(true){
            cout << Q.front();
            Q.pop();
            if (Q.empty()){
                cout << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3232
package main

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

func main() {
	sc := NewScanner()
	C := make([][]int, 3)
	C[0] = sc.NextIntArray()
	C[1] = sc.NextIntArray()
	C[2] = sc.NextIntArray()

	for i := 1; i < 3; i++ {
		f := C[i][0] - C[0][0]

		for k := 1; k < 3; k++ {
			p := C[i][k] - C[0][k]
			if f != p {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
//***Faithless is he that says farewell when the road darkens***

#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll vis[100001];

bool comp(pair<ll,ll> a,pair<ll,ll> b){
   if(a.se>b.se) return 1;
   return 0;
}

int main()
{
  ll n,m,sum=0;
  cin>>n>>m;

   set<ll> s;
   for(ll i=1;i<=m;i++){
      s.insert(i);
   }

   vector<pair<ll,ll>> v;

   forn(i,n){
      ll a,b;
      cin>>a>>b;
      v.pb(mp(a,b));
   }

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

   forn(i,n){
     // for(auto j=s.begin();j!=s.end();j++) cout<<*j<<" ";
      //cout<<"\n";
      if((m-v[i].fi+1)<=0) continue;
      if(vis[(m-v[i].fi+1)]){
         auto it=s.lower_bound(m-v[i].fi+1);
         if(it==s.begin()) continue;
         it--;
         if(it==s.end()) continue;
         sum+=v[i].se;
         vis[*it]=1;
         s.erase(it);
         continue;
      }
      sum+=v[i].se;
      vis[m-v[i].fi+1]=1;
      auto it=s.find(m-v[i].fi+1);
      s.erase(it);
   }
   

   cout<<sum;
}

Measured memory_bytes: 7408
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

N,K=rl()
td = [rl() for _ in range(N)]

from operator import itemgetter
key0 = itemgetter(0)
key1 = itemgetter(1)
td.sort(key=key1,reverse=True)

netas = set()
dup = []

for t,d in td[:K]:
    if t in netas:
        dup.append(d)
    else:
        netas.add(t)

score = len(netas)**2 + sum(map(key1,td[:K]))
ans = score
for t,d in td[K:]:
    if t not in netas and dup != []:
        netas.add(t)
        dup_ = dup.pop(-1)
        score += 2*len(netas)-1 + d - dup_
        ans = max(ans,score)
print(ans)

Measured memory_bytes: 30920
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL inf = 112345678901234;

int main()
{
	LL N, Q;
	in >> N >> Q;
	std::vector<LL>S(N), T(N), X(N), D(Q);
	rep(i, N) in >> S[i] >> T[i] >> X[i];
	rep(i, Q) in >> D[i];

	std::set<std::pair<std::pair<LL, LL>, LL>>events;
	std::set<LL>running;
	rep(i, N)
	{
		events.insert(std::make_pair(std::make_pair(S[i] - X[i], X[i]), 1));
		events.insert(std::make_pair(std::make_pair(T[i] - X[i], X[i]), 0));
	}
	rep(i, Q)
	{
		if (!events.empty())
		{
			while ((*events.begin()).first.first <= D[i])
			{
				if ((*events.begin()).second == 1) running.insert((*events.begin()).first.second);
				else running.erase(running.find((*events.begin()).first.second));
				events.erase(events.begin());
				if (events.empty()) break;
			}
		}

		LL ans;
		if (running.empty()) ans = -1;
		else ans = *running.begin();
		out << ans << std::endl;
	}
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  

void greatFirst(ll& a, ll& b)
{
  if(a < b)
  {
    ll tmp = a;
    a = b;
    b = tmp;
  }
}

int main()
{
  ll k,n;
  cin >> k >> n;
  
  ll house[n];
  ll m = -1;
  rep(i,n)
  {
    ll x;
    cin >> house[i];
    if(i > 0)
    {
      ll dist = house[i] - house[i-1];
      greatFirst(m, dist);
    }
  }
  
  ll dist = k - house[n-1] + house[0];
  greatFirst(m, dist);
  
  
  cout << fixed << (k - m) << endl;
  return 0;
}

Measured memory_bytes: 1792
import sys
import heapq

if __name__ == "__main__":
    a = []
    for inp in sys.stdin.readlines():
        inp = inp.split()
        if inp[0] == "insert":
            heapq.heappush(a, -int(inp[1]))
        elif inp[0] == "extract":
            print(-heapq.heappop(a))

Measured memory_bytes: 190232
#include <iostream>
#include <algorithm>
using namespace std;
int a,b,c;
int x[3];
int main(){
    for(int i=0;i<3;i++ ){
        cin>>x[i];
    }
    sort(x, x + 3);
    if(x[0]==x[1]){
        cout<<x[2]<<endl;
    } else{
        cout<<x[0]<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
using namespace std;

int main() {
	string s;
	vector<int>t;
	int ans = 0;
	getline(cin, s);
	for (int i = 0; i < s.size(); ++i) {
		t.push_back((int)s[i]);
	}
	sort(t.begin(), t.end());
	for (int i = 0; i < t.size() - 1; ++i) {
		if (t[i + 1] == t[i]) {
			++ans;
			break;
		}
	}
	if (ans == 0) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define r(i,n) for(int i=0;i<n;i++)
#define z 100
using namespace std;
int n,a,b,q[z*10],l[z],la,be,an,ct[z],c[z][z];bool v[z],s[z];void d(int x,int len){if(len>be){la=x;be=len;}v[x]=1,s[x]=1;for(int i=0;i<ct[x];i++)if(!v[c[x][i]]){d(c[x][i],len+1);v[c[x][i]]=0;}}int main(){while(1){cin>>n;if(!n)break;r(i,z)ct[i]=0;r(i,n){cin>>a>>b;a--,b--;c[a][ct[a]]=b,c[b][ct[b]]=a;ct[a]++,ct[b]++;}r(i,z)s[i]=0;an=0;for(int i=0;i<z;i++)if(!s[i]){r(i,z)v[i]=0;be=0;d(i,1);r(i,z)v[i]=0;be=0;d(la,1);an=max(an,be);}cout<<an<<endl;}return 0;}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define P pair<int, int>
#define llong long long
int main(){
    int N;
    llong K;
    int a[100010], b[100010];
    cin >> N >> K;

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

    vector<P> data;
    for(int i = 0; i < N; ++i){
        data.emplace_back(a[i], b[i]);
    }

    sort(data.begin(), data.end());
    
    llong ans = 0;
    for(int i = 0; i < data.size(); ++i){
        ans += data[i].second;
        if(ans >= K){
            cout << data[i].first << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 2168
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
 
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)

#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll n, cnt, cnt_max;
    cin >> n;

    cnt = cnt_max= 0;
    for(ll i=0; i<n; i++){
        ll a, b;
        cin >> a >> b;

        if(a==b){
            cnt++;
            cnt_max = max(cnt,cnt_max);
        }else{
            cnt=0;
        }
    }

    string ans;

    ans = cnt_max < 3?"No":"Yes";

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



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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll ans = LONG_LONG_MAX;
    ll sum = 0;
    ll count = 0;
    rep(i,n){
        // sum[even] >= 0
        sum += a[i];
        if(i % 2 == 0){
            if(sum < 1){
                count += (1 - sum);
                sum = 1;
            }
        }else{
            if(sum > -1){
                count += (sum - (-1));
                sum = -1;
            }
        }
    }
    ans = min(ans, count);
    sum = 0; 
    count = 0;
    rep(i,n){
        // sum[odd] >= 0
        sum += a[i];
        if(i % 2 != 0){
            if(sum < 1){
                count += (1 - sum);
                sum = 1;
            }
        }else{
            if(sum > -1){
                count += (sum - (-1));
                sum = -1;
            }
        }
    }
    ans = min(ans, count);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
const int mx = 100005;
string s;
int ans[mx], l;
int main(){
	cin>>s;
	rep(i,s.size()-1){
		if(s[i] == 'R' && s[i+1] == 'L'){
			int u = i+1-l;
			ans[i] = u - u/2;
			ans[i+1] = u/2;
		}else if(s[i] == 'L' && s[i+1] == 'R') l = i+1;
	}
	l = s.size()-1;
	for(int i = s.size()-1; i > 0; i--){
		if(s[i-1] == 'R' && s[i] == 'L'){
			int u = l-i+1;
			ans[i] += u - u/2;
			ans[i-1] += u/2;
		}else if(s[i-1] == 'L' && s[i] == 'R') l = i-1;
	}
	rep(i,s.size()) printf("%d%s", ans[i], i == s.size()-1 ? "\n" : " ");
}

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

vector<int> createInput(int length) {
    vector<int> v;
    int tmp;
    for(int i = 0;i < length;i++) {
        cin >> tmp;
        v.push_back(tmp);
    }
    return v;
}


int main()
{
    int n; cin >> n;
    int i = n % 10;
    if(i == 3) {
        cout << "bon" << endl;
    }else if(i == 0 || i == 1 || i == 6 || i == 8) {
        cout << "pon" << endl;
    }else {
        cout << "hon" << endl;
    }
    
    return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    vector<int> B(N);
    for (int i = 0; i < N; i++){
        B.at(A.at(i)-1) = i+1;
    }
    for (int i = 0; i < N; i++){
        if (i == 0) cout << B.at(i);
        else cout << " " << B.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1e9+7;
const ll inf = (LLONG_MAX>>2);
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll a,b,n,m,tot = 0;
  cin >> n >> m;
  priority_queue<ll> q;
  for(ll i = 0; i < n; ++i){
    cin >> a;
    tot += a;
    q.emplace(a);
  }
  while(m--){
    a = q.top();
    q.pop();
    b = a/2;
    tot -= a-b;
    q.emplace(b);
  }
  cout << tot;
  return 0;
}

Measured memory_bytes: 1400
import math
h=int(input())
cnt=1
ans = 1
if h==1:
    print(1)
else:
    for i in range(h):
        h= math.floor(h/2)
        if h <= 1:
            cnt += i
            break
    for j in range(1,cnt+1):
        ans+= 2**j
    print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

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

    void run() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        boolean check = false;

        for(int i=A; i<=A*B; i+=A){
            if(i%B == C){
                check = true;
                break;
            }
        }

        if(check){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
}

Measured memory_bytes: 23124