akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


from heapq import heapify, heappop, heappush, heappushpop


class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap

    def __len__(self):
        return len(self.heap)


MOD = 10**9 + 7
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

X, Y, A, B, C = read_ints()
P = read_ints()
Q = read_ints()
R = read_ints()  # これは適切に着色できる

# ソートして、価値の低いものから捨てていくのが良さそうだが
P.sort(reverse=True)
Q.sort(reverse=True)

tmp = [-x for x in (P[:X] + Q[:Y])]

pq = PriorityQueue(tmp)
for r in R:
    pq.push(-r)

ans = 0
for _ in range(X + Y):
    ans += pq.pop()
print(-ans)


Measured memory_bytes: 107344
H, W = map(int, input().split())
L = []
for h in range(H):
    s = input()
    if "#" in s:
        L.append(s)
        continue

S = []
for w in range(W):
    for l in range(len(L)):
        if L[l][w] == "#":
            break
    else:
        S.append(w)
    
for l in range(len(L)):
    s = ""
    for w in range(W):
        if not w in S:
            s += L[l][w]
    print(s)

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

int main()
{
	while(1)
	{
		int n,m,t,p;
		cin>>n>>m>>t>>p;
		if(n==0)
			break;
		int kami[64][64];
		fill(kami[0],kami[64],0);
		//初期値を置く
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<n;j++)
				kami[i][j]=1;
		}
		int l=0;//現在の左のインデックス
		int u=0;//現在の上のインデックス
		int oru[20][2];
		for(int i=0;i<t;i++)
			cin>>oru[i][0]>>oru[i][1];
		int ana[20][2];
		for(int i=0;i<p;i++)
			cin>>ana[i][0]>>ana[i][1];
		
		//実際に折る
		for(int i=0;i<t;i++)
		{
			//左側に折る
			if(oru[i][0]==1)
			{
				l=l+oru[i][1];
				for(int i=0;i<l;i++)
				{
					for(int j=0;j<64;j++)
					{
						kami[j][l+i]+=kami[j][l-i-1];
						kami[j][l-i-1]=0;//折り終わったところにはもう何もない
					}
				}
				//横にずらす
				for(int i=l;i<64;i++)
				{
					for(int j=0;j<64;j++)
					{
						kami[j][i-l]=kami[j][i];
						kami[j][i]=0;
					}
				}
				l=0;
			}else{
				//下に折る（実際には上）
				u=u+oru[i][1];
				for(int i=0;i<u;i++)
				{
					for(int j=0;j<64;j++)
					{
						kami[u+i][j]+=kami[u-i-1][j];
						kami[u-i-1][j]=0;
					}
				}
				//縦にずらす
				for(int i=u;i<64;i++)
				{
					for(int j=0;j<64;j++)
					{
						kami[i-u][j]=kami[i][j];
						kami[i][j]=0;
					}
				}
				u=0;
			}
			//for debug
			/*
			for(int j=0;j<m;j++)
			{
				for(int k=0;k<n;k++)
					cout<<kami[j][k]<<" ";
				cout<<endl;
			}
			cout<<endl;
			*/
		}

		//穴を開ける
		for(int i=0;i<p;i++)
			cout<<kami[u+ana[i][1]][l+ana[i][0]]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3112
//Code by ASIM FOIZE AIMON
//CSE'19;CUET
//avoid copy paste//Hit the frined button
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define endl "\n"
#define int int64_t
#define ll long long
#define yes printf("Yes\n")
#define no printf("No\n")
#define push_back pb
int32_t main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/input.txt", "r", stdin);
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/output.txt", "w", stdout);
    #endif*/
    long long n,i,l;
    cin>>n>>l;
    vector<string>s(n);
    for(i=0;i<n;i++)
    {
        cin>>s[i];
    }
    sort(s.begin(),s.end());
    for(i=0;i<n;i++)
    {
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int MOD = 1e9+7;
ll fast(ll num , ll p){
    if(p==0)return 1 ;
    ll ans = fast(num,p/2);
    ans*=ans;
    ans%=MOD;
    if(p%2==1){
        ans*=num;
        ans%=MOD;
    }
    return ans;
}
int main() {
   int n;
   cin>>n ;
   ll ans = fast(10,n);
   ans = ans-2*fast(9,n) + fast(8,n);
   while (ans<0)ans+=MOD;
   ans%=MOD;
   cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
int main()
{
    fastio();
    
    ll n,k;
    cin>>n>>k;
    ll sum=0,ans=0;
    ll arr[k+1]={0};
    for(ll i=2;i<=k;i++)
    {
        ll div = k/i;
        arr[i]= mpowe(div,n,MOD1);
    }
    for(ll i=k;i>1;i--)
    {
        ll j = i*2;
        while(j<=k)
        {
            arr[i] = (arr[i] - arr[j] + MOD1)%MOD1;
            j=j+i;
        }
    }
    for(ll i=2;i<=k;i++)
    {
        sum = (sum+arr[i])%MOD1;
        ans = (ans + (i*arr[i])%MOD1)%MOD1;
    }
    //cout<<sum<<endl;
    sum = (mpowe(k,n,MOD1)-sum+MOD1)%MOD1;
    //cout<<mpowe(k,n,MOD1)<<" "<<sum<<endl;
    //cout<<ans<<endl;
    ans = (ans+sum)%MOD1;
    cout<<ans<<endl;
}


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

class BinaryIndexedTree
{
private:
    std::vector<int> vals;
    int n;
public:
    BinaryIndexedTree(int n_)
        : vals(n_, 0), n(n_) { }

    void add(int a, int w)
    {
        for (int x = a; x <= n; x += x & -x) {
            vals[x - 1] += w;
        }
    }

    int sum(int a) const
    {
        int ret = 0;
        for (int x = a; x > 0; x -= x & -x) {
            ret += vals[x - 1];
        }
        return ret;
    }
};

class SnLine
{
private:
    struct ProdRange
    {
        ProdRange() { l = r = 0; }
        ProdRange(int l_, int r_) { l = l_; r = r_; }
        int l, r;
    };

    static ProdRange makeProdRange(int l, int r)
    {
        return ProdRange { l, r };
    }

    std::vector<ProdRange> prList;

    int numProds;
    int numStops;

public:
    SnLine(int numStops_, int numProds_)
    {
        numStops = numStops_;
        numProds = numProds_;
        prList.reserve(numProds);
    }

    void addProdRange(int l, int r)
    {
        prList.emplace_back(l, r);
    }

    void solve()
    {
        std::sort(prList.begin(), prList.end(),
            [](const auto& a, const auto& b)
            { return ((a.r - a.l) < (b.r - b.l)); });

        BinaryIndexedTree bit(numStops);
        
        int numRemainingProds = numProds;

        auto pr = prList.begin();
        for (int d = 1; d <= numStops; ++d)
        {
            int r = numRemainingProds;

            if (1 < d)
            {
                for (int a = d; a <= numStops; a += d)
                {
                    r += bit.sum(a);
                }
            }

            std::cout << r << std::endl;

            for(; pr != prList.end() && (d == pr->r - pr->l + 1); ++pr)
            {
                bit.add(pr->l, 1);
                bit.add(pr->r + 1, -1);
                --numRemainingProds;
            }
        }
    }
};

int main()
{
    int N, M;
    std::cin >> N >> M;

    SnLine sl(M, N);

    for (int i = 0; i < N; ++i)
    {
        int l, r;
        std::cin >> l >> r;
        sl.addProdRange(l, r);
    }

    sl.solve();
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  char c;
  cin >> c;
  c++;
  cout << c << endl;

  return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const long long LINF=1LL<<59;


void solve(long long T, std::vector<long long> N, std::vector<long long> D){
  vvl dp(1003,vl(128,-LINF));
  dp[0][0] = 0;
  rep(i,1000){
    rep(j,128) if(dp[i][j]!=-LINF) rep(k,128) chmax(dp[i+1][j^k],dp[i][j]+k);
  }
  dump(170^170^170);
  rep(t,T){
    ll ans = 0;
    rep(j,128) if(dp[N[t]-1][j]!=-LINF) if(chmax(ans,dp[N[t]-1][j]+(D[t]^j))){
      dump(j,dp[N[t]-1][j],D[t]^j);
    }
    cout << ans << endl;
  }
}

int main(){
  long long T;
  scanf("%lld",&T);
  std::vector<long long> N(T);
  std::vector<long long> D(T);
  for(int i = 0 ; i < T ; i++){
    scanf("%lld",&N[i]);
    scanf("%lld",&D[i]);
  }
  solve(T, std::move(N), std::move(D));
  return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

				Scanner sc = new Scanner(System.in);

				int sheep = sc.nextInt();
				int wolf = sc.nextInt();

				if(wolf >= sheep) {
					System.out.println("unsafe");
				}else {
					System.out.println("safe");
				}
			}
		}


Measured memory_bytes: 35584
*ABCD, = map(int, list(input()))
N = 3
op = []
for bit in range(0, 1<<N):
    tmp = []
    for i in range(N):
        if (bit>>i) & 1:
            tmp.append("+")
        else:
            tmp.append("-")
    
    ans = ABCD[0]
    for i in range(N):
        if tmp[i] == "+":
            ans += ABCD[i+1]
        else:
            ans -= ABCD[i+1]
    if ans == 7:
        break

A = str(ABCD[0])
for i in range(N):
    A += str(tmp[i])
    A += str(ABCD[i+1])
A += "=7"
print(A)

Measured memory_bytes: 38432
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
int main(){
    int n,sum = 0,ans = 0;
    int avr;
    int x[100];
    cin >> n;
    rep(i,n){
        cin >> x[i];
        sum += x[i];
    }
    avr = round(float(sum) / float(n));
    rep(i,n) ans += (x[i] - avr) * (x[i] - avr);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<numeric>
#include<string>
#include<map>
#include<bitset>

using namespace std;
using int_greater_PQ = priority_queue<int,vector<int>,greater<int>>;


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

    vector<int>H;
    for(int i=0;i<N;++i)
    {
        int h;
        cin>>h;
        H.push_back(h);
    }

    int ans=0;
    for(const auto& h:H)
    {
        if(h>=K)
        {
            ++ans;
        }
    }

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


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

int main()
{
	int N;
	bool flag = false;
	cin >> N;
	for ( int i = 0; i < N; i++ ) {
		char c;
		cin >> c;
		if ( c == 'Y' ) {
			flag = true;
		}
	}
	if ( flag ) {
		cout << "Four" << endl;
	} else {
		cout << "Three" << endl;
	}
	return ( 0 );
}


Measured memory_bytes: 256
from collections import deque

n,q = map(int,input().split())
qu = deque([])
time = 0
for i in range(n):
    a,b = input().split()
    qu.append([a,int(b)])

while len(qu) > 0:
    c = qu.popleft()
    if c[1] <= q:
        time += c[1]
        print(c[0],time)
    else:
        time += q
        qu.append([c[0],c[1]-q])


Measured memory_bytes: 13276
import java.util.Scanner;

public class Main {

	public static void main(String args[]){

		Scanner cin = new Scanner(System.in);
		int A = cin.nextInt();
		int B = cin.nextInt();
		int C = cin.nextInt();
		int D = cin.nextInt();

		int result = Math.max(A*B, C*D);

		System.out.println(result);
	}
}


Measured memory_bytes: 23124
N = int(input())
V = list(map(int, input().split()))
# sortはリストのメソッドを使う。sorted(V)は文字列、タプルで 
V.sort()
ans = V[0]
for i in range(1,N):
    # += ではなく、　=。ここでつまった。解説動画みてわかった。
    # ans += ( ans + V[i]) / 2  
    ans = ( ans + V[i]) / 2 
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
int p[100010];
int main(){
  int n;
  cin>>n;
  int a[n],m=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]++;
    p[a[i]]++;
    p[a[i]-1]++;
    p[a[i]+1]++;
    m=max(m,a[i]+1);
  }
  int ans=0;
  for(int i=0;i<=m;i++){
    ans=max(ans,p[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  
  vector<char> S(N);
  for(int i = 0; i < N; i++)
    cin >> S.at(i);
  S.at(K-1) = S.at(K-1) + 0x20;
  for(int i = 0; i < N; i++)
    cout << S.at(i);
  cout << "" << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    dig = int(math.log(N, 10)) + 1
    max_d = N /(10 ** (dig - 1))
    X = max_d * (10 ** (dig - 1))
    for i in range(dig - 1):
        X += 9 * (10 ** (i ))
    if X <= N:
        print max_d + 9 * (dig - 1)
        return

    print (max_d - 1) + 9 * (dig - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n = int(input())
enemy  = list(map(int,input().split()))
hero  = list(map(int,input().split()))

ans = 0

for i in range(n):
    if hero[i] > enemy[i]:
        if enemy[i+1] < (hero[i]-enemy[i]):
            ans += (enemy[i]+enemy[i+1])
            enemy[i+1] = 0
        else:
            enemy[i+1] -= (hero[i]-enemy[i])
            ans += hero[i]
    else:
        ans += hero[i]

print(ans)

Measured memory_bytes: 18476
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	int i, j,k;
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (B <= C) {
		cout << 0 << endl;
	}
	else if (D <= A) {
		cout << 0 << endl;
	}
	else if (A <= C&&D <= B) {
		cout << D - C << endl;
	}
	else if (C <= A&&B <= D) {
		cout << B - A << endl;
	}
	else if (C <= A&&D <= B) {
		cout << D - A << endl;
	}
	else if (A <= C&&B <= D) {
		cout << B - C << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
	int n,i,j;
	string s;
	cin>>n>>s;
	vector<int> x(26),y(26);
	fill(x.begin(),x.end(),0);
	fill(y.begin(),y.end(),0);
	int ans = 0,cnt;
	for(i=0;i<n-1;i++)
	{
		fill(y.begin(),y.end(),0);
		cnt = 0;
		x[s[i]-'a']++;
		for(j=i+1;j<n;j++)
			y[s[j]-'a']++;
		// for(j=0;j<26;j++)
		// 	cout<<'('<<x[j]<<" "<<y[j]<<')';
		for(j=0;j<26;j++)
		{
			if(x[j]>0 && y[j]>0)
			{
				// cout<<j<<" "<<char(j+'a');
				cnt++;
			}
		}
		// cout<<endl;
		ans = max(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[]){
        char tmp[1024+1]={0};
        char *buf=NULL;
        char* p=NULL;
        int N=0;
        int *A=NULL;
        int *C=NULL;

        buf = (char*)calloc(200000+1, 7);
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        N = atoi(buf);

        A = (int*)calloc(N+1, sizeof(int));
        C = (int*)calloc(N+2, sizeof(int));
        for(int i=0; i<N+1; i++){ C[i]=0; }

        memset(buf, 0, N*7+1);
        while(fgets(tmp, sizeof(tmp)-1, stdin)!=NULL){
                strcat(buf, tmp);
                memset(tmp, 0 , sizeof(tmp));
        }

        p = strtok(buf, " ");
        A[0] = atoi(p);
        C[A[0]]++;
        for(int i=1; i<N; i++){
                p = strtok(NULL, " ");
                A[i] = atoi(p);
                C[A[i]]++;
        }
        long long total=0;
        for(int i=1; i<N+1; i++){
                long long a = (long long)C[i];
                total += a*(a-1)/2;
        }
        for(int i=0; i<N; i++){
                long long v = (long long)C[A[i]];
                long long d = 0;
                if(v>1) { d = v -1; }
                long long ans = total - d;
                printf("%lld\n", ans);
        }
        return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  int A, B, C, K;
  cin >> A >> B >> C;
  cin >> K;
  int M = max(A, max(B, C));
  int ans = M;
  for(int k = 0; k < K; k++){
    ans *= 2;
  }
  ans += (A+B+C) - M;
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s;
  cin>>s;
  if(s=="ABC")
    cout<<"ARC";
  else
    cout<<"ABC";
	return 0;
}


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

int main(){
	string s,t;
	cin >> s >> t;
	vector<set<int>> x(30);
	for(int i = 0 ; i < s.size() ; i += 1){
		x[s[i]-'a'].insert(i);
	}
	int freq=0,val=0;
	for(char i : t){
		if(x[i-'a'].size() == 0){
			cout << -1;
			return 0;
		}
		if(x[i-'a'].lower_bound(val) == x[i-'a'].end()){
			freq += 1;
			val = 0;
		}
		val = *x[i-'a'].lower_bound(val);
		val += 1;
	}
	cout << freq*s.size() + val << endl;
}

Measured memory_bytes: 5248
import fractions as math
import sys
N, X = map(int, input().split())

dis_list = [abs(int(i) - X) for i in input().split()]
if len(dis_list) < 2:
    print(dis_list[0])
    sys.exit()


first_gc = math.gcd(dis_list[0], dis_list[1])

for i in range(len(dis_list)):
    first_gc = math.gcd(first_gc, dis_list[i])

print(first_gc)

Measured memory_bytes: 16244
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        int n = readInt(), k = readInt();
        ArrayList<Long> scores = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            long l = readLong();
            scores.add(l);
            if (i >= k) {
                long s = scores.get(i - k);
                if (l > s) System.out.println("Yes");
                else System.out.println("No");
            }
        }
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 59800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()
#define PI 3.141592653589793

int main() {
    string s;
    cin >> s;
    int b_count = 0, w_count = 0;
    char prev = 'A';
    rep(i, s.size()) {
        if (prev == s[i])
            continue;
        else if (s[i] == 'B')
            b_count++;
        else if (s[i] == 'W')
            w_count++;
        prev = s[i];
    }

    int res = 0;
    if (w_count == 0 || b_count == 0)
        res = 0;
    else if (s[0] == s[s.size() - 1] && s[0] == 'B')
        res = b_count * 2 - 2;
    else if (s[0] == s[s.size() - 1] && s[0] == 'W')
        res = w_count * 2 - 2;
    else
        res = min(b_count * 2 - 1, w_count * 2 - 1);

    cout << res << endl;
}

Measured memory_bytes: 512
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <queue>

#define LL long long

using namespace std;

const int MOD = 1000000007, N = 100000+10;

int n, a[N];
LL sum[N];

int main()
{
	//freopen("test_in.txt", "r", stdin);
	//freopen("test_out.txt", "w", stdout);
	int T; scanf("%d", &T);
	cout<<24+24-T<<endl; 
	 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,dp[200002];
vector<int> hoge;
int main(){
	cin>>n;
	dp[0]=0;
	for(int i=1;i<=100000;i++) dp[i]=100000;
	hoge.push_back(1);
	for(int i=6;i<=100000;i*=6) hoge.push_back(i);
	for(int i=9;i<=100000;i*=9) hoge.push_back(i);
	for(int i=0;i<=100000;i++){
		int mee;
		for(int j=0;j<hoge.size();j++){
			mee=i+hoge[j];
			if(dp[mee]>dp[i]+1) dp[mee]=dp[i]+1;
		}
	} 
	cout<<dp[n]<<endl;
	return 0;
}


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

const int NIL = -1;
const int INF = 1000000000;

typedef tuple<int, int, int, bool> Uncertain;

int WarshallFloyd(vector<vector<int>> g, int start) {
  for(int i = 0; i < g.size(); ++i) g[i][i] = 0;
  for(int k = 0; k < g.size(); ++k)
    for(int i = 0; i < g.size(); ++i)
      for(int j = 0; j < g.size(); ++j)
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  for(int i = 0; i < g.size(); ++i) if(g[i][i] < 0) return NIL;
  return *max_element(begin(g[start]), end(g[start]));
}

int solve(const vector<vector<int>>& g, const vector<Uncertain>& uncertain, bitset<8> bit = 0, int depth = 0) {
  if(depth == uncertain.size()) {
    auto h(g);
    for(int i = 0; i < uncertain.size(); ++i) {
      int u, v, d;
      bool positive;
      tie(u, v, d, positive) = uncertain[i];
      if(bit[i]) swap(u, v);
      h[v][u] = 0;
      if(positive) h[v][u] = -d;
      else         h[u][v] = d;
    }
    return WarshallFloyd(h, 0);
  }
  return max(solve(g, uncertain, bit.set(depth), depth + 1), solve(g, uncertain, bit.reset(depth), depth + 1));
}

int main() {
  int N, C;
  cin >> N >> C;
  vector<vector<int>> g(N, vector<int>(N, INF));
  for(int i = 1; i < N; ++i) g[i][0] = 0;
  vector<Uncertain> uncertain;
  for(int i = 0; i < C; ++i) {
    string s;
    cin >> s;
    // parse
    enum {LESS = '<', EQUAL = '*', MORE = '>'};
    int u = 0, v = 0, d = 0;
    char order;
    bool positive;
    int index = 0;
    while(isdigit(s[index])) u = 10 * u + (s[index++] - '0');
    if((order = s[index++]) != EQUAL) ++index;
    while(isdigit(s[index])) v = 10 * v + (s[index++] - '0');
    positive = (s[index++] == '+');
    while(isdigit(s[index])) d = 10 * d + (s[index++] - '0');
    // edge
    --u;
    --v;
    if(order == EQUAL) {
      uncertain.emplace_back(u, v, d, positive);
    } else {
      if(order == MORE) swap(u, v);
      g[v][u] = 0;
      if(positive) g[v][u] = -d;
      else         g[u][v] = d;
    }
  }
  // output
  int answer = solve(g, uncertain);
  if(answer == INF) cout << "inf";
  else              cout << answer;
  cout << endl;
}

Measured memory_bytes: 1360
sa = [i for i in input()]
sb = [i for i in input()]
sc = [i for i in input()]
ck = sa[0]
sa.pop(0)
while True:
  if ck == "a":
    if len(sa)== 0:
      print("A")
      exit()
    ck = sa.pop(0)
  elif ck == "b":
    if len(sb)== 0:
      print("B")
      exit()
    ck = sb.pop(0)
  elif ck == "c":
    if len(sc)== 0:
      print("C")
      exit()
    ck = sc.pop(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
#define mod 1000000007
using namespace std;

bool prime[1010];
vector<int> prime_list;

void init()
{
    memset(prime, true, 1001 * sizeof(bool));
    prime[1] = false;
    for (int i = 2; i < 1001; i++)
    {
        if (prime[i])
        {
            prime_list.push_back(i);
            for (int j = i * 2; j < 1001; j += i)
            {
                prime[j] = false;
            }
        }
    }
}

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

    ll n;
    cin >> n;
    map<int, int> M;
    for (int i = 2; i <= n; i++)
    {
        ll tmp = i;
        for (auto j : prime_list)
        {
            if (j > tmp)
                break;

            while (tmp % j == 0)
            {
                tmp /= j;
                M[j]++;
            }
        }
    }
    ll ans = 1;
    for (auto i = M.begin(); i != M.end(); i++)
    {
        ans = (ans * (i->second + 1)) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(n) for(int i=0;i<n;i++)
#define reps(i,s,n) for(int i=s;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ll long long
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
using namespace std;
typedef vector<vector<int> > Graph;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;



int main(){

    ll n;
    cin >> n;
    vl dif(n);
    
    vl a(n),b(n);
    rep(n) cin >> a.at(i);
    rep(n) cin >> b.at(i);
    rep(n) dif.at(i) = a.at(i)-b.at(i);
    
        sort(all(dif));
        ll sum = 0;
        rep(n) sum += dif.at(i);
        ll sum_mi = 0;
        ll cnt = 0;
        if(sum<0) cout << -1 << endl;
        else{
            ll time = 0;
            while(dif.at(time) < 0){
                sum_mi += dif.at(time);
                cnt++;
                time++;
            } 
            ll now = n-1;
            while(sum_mi < 0){
                sum_mi += dif.at(now);
                now--;
                cnt++;
            }
            cout << cnt << endl;
        }
    

    return 0;
}


Measured memory_bytes: 2560
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        
n,m = map(int,input().split())
a = [input().split() for l in range(m)]
uf = UnionFind(n)

for z in range(m):
    uf.union(int(a[z][0]), int(a[z][1]))
    
b = [0]*n

for r in range(1,n+1):
    b[uf.find(r)-1] += 1


print(max(b))

Measured memory_bytes: 78916
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define popb pop_back
# define pf push_front
# define popf pop_front
# define sll set<ll>
# define schar set<char>
//find()
//erase(x) removes element x
//erase(position,position)
# define qll queue<ll>
# define qstr queue<str>
//front(),back()
# define stll stack<ll>
# define ststr stack<str>
//top()
# define dll deque<ll>
//at()
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define mss map<str,str>
# define mci map<char,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define fr(x,y,z) for(int x=y;x<z;x++)
# define rr(x,y,z) for(int x=y;x>z;x--)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    str s;
    cin>>s;
    ll flg=0,flg1=0,flg2=0;
    ll y=s.length();
    str s2=s;
    reverse(s2.begin(),s2.end());
    if(s2==s){
        flg=1;
    }
    str s3="";
    for(ll i=0;i<(y-1)/2;i++){
        s3+=s[i];
    }
    //cout<<s3;
    str s4=s3;
    reverse(s3.begin(),s3.end());
    if(s3==s4){
        flg1=1;
    }
    str s5="";
    for(ll i=((y+3)/2)-1;i<s.length();i++){
        s5+=s[i];
    }
   // cout<<s5;
    str s6=s5;
     reverse(s5.begin(),s5.end());
     if(s5==s6){
        flg2=1;
    }
    if(flg==1 && flg1==1 &&flg2==1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    //cout<<flg<<" "<<flg1<<" "<<flg2;
}




Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] C = new String[H+1];
        for(int i = 1; i <= H; i++){
        	C[i] = sc.next();
        }
        for(int i = 1; i <= (H*2); i++){
        	System.out.println(C[(i+1)/2]);
        }
	}

}

Measured memory_bytes: 24212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D ;
  1<= A,B,C,D <= 10;
  cin >> A >> B >> C >> D;
 
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
   else if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
} 

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

using namespace std;

const int N=2e6+6;
const int MOD=1e9+7;

long long fac[N],infac[N];

long long poww(long long b,long long p)
{
	if(p==0) return 1;
	if(p%2) return (b*poww(b,p-1))%MOD;
	return poww((b*b)%MOD,p/2);
}

int main()
{
	fac[0]=1; infac[0]=1;
	for(int i=1;i<N;i++)
	{
		fac[i]=(i*fac[i-1])%MOD;
		infac[i]=poww(fac[i],MOD-2);
	}
	int x,y;
	cin >> x >> y;
	if((2*y-x)%3)
	{
		cout << 0 << endl;
		return 0;
	}
	int a=(2*y-x)/3;
	int b=y-2*a;
	if(a<0||b<0)
	{
		cout << 0 << endl;
		return 0;
	}
	long long ans=(((fac[a+b]*infac[a])%MOD)*infac[b])%MOD;
	cout << ans << endl;
}

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

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T &anth(T &a, const T &b){ return a = ant(a, b); }
template<class T> T &onth(T &a, const T &b){ return a = ont(a, b); }

constexpr int w = 5;

int main(){
	int h;
	while(std::cin >> h, h){
		int ans = 0;
		std::list<std::pair<int, bool>> stone[w];
		RC(i, h){
			RC(j, w){
				int tmp;
				std::cin >> tmp;
				stone[j].push_front(std::make_pair(tmp, false));
			}
		}
		for(bool flag = true; flag;){
			std::list<std::pair<int, bool>>::iterator it[w];
			RC(i, w) it[i] = stone[i].begin();
			for(;;){
				bool end = true;
				RC(i, w) if(it[i] != stone[i].end()) end = false;
				if(end) break;

				int row = 0, count = 0;
				RC(i, w){
					if(it[i] == stone[i].end()){
						row = count = 0;
					}else if(it[i]->first != row){
						row = it[i]->first;
						count = 0;
					}else{
						++count;
						if(count >= 2) it[i - 2]->second = it[i - 1]->second = it[i]->second = true;
					}
				}

				RC(i, w) if(it[i] != stone[i].end()) ++it[i];
			}
			/*
			RC(i, w) it[i] = stone[i].begin();
			for(;;){
				bool end = true;
				RC(i, w) if(it[i] != stone[i].end()) end = false;
				if(end) break;
				RC(i, w) std::cout << it[i]->first << ' ';
				std::cout << std::endl;
				RC(i, w) ++it[i];
			}
			std::cout << "----------" << std::endl;
			*/
			flag = false;
			RC(i, w) for(std::list<std::pair<int, bool>>::iterator j = stone[i].begin(); j != stone[i].end();){
				if(j->second){
					ans += j->first;
					j = stone[i].erase(j);
					flag = true;
				}else ++j;
			}
		}
		std::cout << ans << std::endl;
		// std::cout << "==========" << std::endl;
	}
}



Measured memory_bytes: 3080
using System;
using System.Linq;

namespace _045_SumandAverage
{
	class Program
	{
		static void Main ( string[] args )
		{
			int totalPrice = 0;
			int totalCount = 0;
			int dataCount = 0;

			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				int[] inputNum = inputStr.Split (',').Select (int.Parse).ToArray ();

				totalPrice += inputNum[0] * inputNum[1];
				totalCount += inputNum[1];
				dataCount++;
			}

			double countAverage = (double) totalCount / dataCount;

			Console.WriteLine (totalPrice);
			Console.WriteLine ("{0:F0}", countAverage);
		}
	}
}

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

void solve()
{
    int x ;
    cin>>x ;

    if(x)
    {
        cout<<0 ;

    }
    else
        cout<<1 ;
}


int main()
{

    int y ;
    y=1 ;

    while(y--)
    {
        solve() ;
    }

}


Measured memory_bytes: 3624
#include<iostream>

int main(){
  std::string nday;
  int m1, d1;
  int m2, d2;
  
  std::cin >> m1 >> d1;
  std::cin >> m2 >> d2;

  if( d1 > d2 ){std::cout << "1" << std::endl;}
  else         { std::cout << "0" << std::endl;}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

string s;

int main() {
    cin >> s;
    rep(i,s.size()) {
        if (i%2) {
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
N, K= list(map(int, input().split()))
A_list = list(map(int, input().split()))

loop = []
trace = [0] * (N+1)
visited = set()

ai = 1
for i in range(N+1):
    if ai in visited:
        ind = trace.index(ai)
        loop = trace[ind:i]
        trace = trace[:ind]
        break
    visited.add(ai)
    
    trace[i] = ai # ??
    ai = A_list[ai-1]


if len(trace) > K:
    print(trace[K])
else:
    ind = K - len(trace)
    ind = ind % len(loop)
    print(loop[ind])


Measured memory_bytes: 33444
#include <iostream>

int main()
{
    int a, b, c;
    int n = 0;
    std::cin >> a >> b >> c;
    for(int i = a; i <= b; ++i){
        if(c % i == 0) ++n;
    }
    std::cout << n << std::endl;
    return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);;
        while(sc.hasNext()) {
            String[] line = sc.nextLine().split(" ");
            int sum = Integer.parseInt(line[0]) + Integer.parseInt(line[1]);
            System.out.println(String.valueOf(sum).length());
        }
    }
}

Measured memory_bytes: 26516
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define int long long
using namespace std;
signed main() {
	multiset<int>s;
	int w; cin >> w;
	for (int i = 0; i < w; i++) {
		int n, x, l, r; cin >> n;
		if (n == 0) {
			cin >> x;
			s.insert(x);
			cout << s.size() << endl;
		}
		else if (n == 1) {
			cin >> x;
			cout << s.count(x) << endl;
		}
		else if (n == 2) {
			cin >> x;
			s.erase(x);
		}
		else {
			cin >> l >> r;
			for (auto i = s.lower_bound(l); i != s.upper_bound(r); i++)cout << *i << endl;
		}
	}
}


Measured memory_bytes: 12380
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0


int main(){
  int n,m,i,j,k;
  scanf("%d%d%d",&n,&m,&k);
  int flag=0;
  for(i=0;i<=n;i++){
    for(j=0;j<=m;j++){
      int a=i*(m-j)+(n-i)*j;
      if(a==k)flag=1;
    }
  }
  printf("%s",flag?"Yes":"No");
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 128
#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>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

/*
int uf1[200010], uf2[200010];
int find(int x, int uf[]) {
    if(uf[x] == x) return x;
    else return uf[x] = find(uf[x], uf);
}

void unite(int a, int b, int uf[]) {
    if(find(a, uf) == find(b, uf)) return;
    uf[b] = find(a, uf);
}
*/

struct UnionFind {
private:
    const int n;
    int __size;
    vector<int> uf;
public:
    // 初期化 UnionFind uni(n) のように宣言すれば良い
    UnionFind(int _n) : n(_n), __size(_n), uf(_n, -1) {}
    // find (木の根を求める)
    int find(int x) {return (uf[x] < 0) ? x : uf[x] = find(uf[x]);}
    // x と y が同じ集合に属するかどうか
    bool same(int x, int y) {return find(x) == find(y);}
    // x が属する集合の要素数
    int size(int x) {return -uf[find(x)];}
    // 集合はいくつあるか
    int size()      {return __size;}
    // x と y の属する集合を併合
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;
        __size--;
        if(uf[y] < uf[x]) swap(x, y);
        uf[x] += uf[y]; uf[y] = x;
    }
};

signed main() {
    int n, k, l; cin >> n >> k >> l;
    UnionFind uf1(n), uf2(n);
    rep(i,0,k) {
        int p, q; cin >> p >> q;
        p--; q--;
        uf1.unite(p, q);
    }
    rep(i,0,l) {
        int r, s; cin >> r >> s;
        r--; s--;
        uf2.unite(r, s);
    }

    map<pii, int> m;
    rep(i,0,n) {
        int f1 = uf1.find(i);
        int f2 = uf2.find(i);
        pii temp = pii(f1, f2);
        if(!m.count(temp)) m[temp] = 1;
        else m[temp] += 1;
    }

    rep(i,0,n) {
        int f1 = uf1.find(i);
        int f2 = uf2.find(i);
        int ret = m[ pii(f1, f2) ];
        if(i == 0) printf("%lld", ret);
        else printf(" %lld", ret);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 15104
#include<iostream>
#include<bitset>
using namespace std;

int main() {
  int H, W;
  int A[80][80], B[80][80];
  cin >> H >> W;
  for (int i = 0;i < H;++ i) {
    for (int j = 0;j < W;++ j) {
      cin >> A[i][j];
    }
  }
  for (int i = 0;i < H;++ i) {
    for (int j = 0;j < W;++ j) {
      cin >> B[i][j];
    }
  }
  
  const int MID = 150000;
  bitset<MID * 2 - 1> dp[81][81];
  dp[1][0].set(MID);
  dp[1][1] = (dp[0][1] | dp[1][0]) << abs(A[1][1] - B[1][1]);
  for (int y = 0;y < H;++ y) {
    for (int x = 0;x < W;++ x) {
      if (A[y][x] >= B[y][x]) {
      	dp[y + 1][x + 1] = (dp[y + 1][x] | dp[y][x + 1]) << (A[y][x] - B[y][x]);
      	dp[y + 1][x + 1] |= (dp[y + 1][x] | dp[y][x + 1]) >> (A[y][x] - B[y][x]);
      } else {
      	dp[y + 1][x + 1] = (dp[y + 1][x] | dp[y][x + 1]) << (B[y][x] - A[y][x]);
      	dp[y + 1][x + 1] |= (dp[y + 1][x] | dp[y][x + 1]) >> (B[y][x] - A[y][x]);
      }
    }
  }
  for (int i = 0;i < MID;++ i) {
    if (dp[H][W][MID + i]) {
      cout << i << endl;
      break;
    }
  }
  
  return 0;
}

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

int main(void){
    int n, k, dis[10], like[10];
    cin >> n >> k;
    for(int i=0;i<k;++i){
        cin >> dis[i];
    }
    for(int i=n;;++i){
        int p = i;
        int flg = 1;
        while(p>0){
            int q;
            q = p%10;
            for(int j=0;j<k;++j){
                if(q==dis[j]){
                    flg = 0;
                }
            }
            p/=10;
        }
        if(flg){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256