akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

int n,k;


bool check(int mid,vec &a,vec &f,int k){
    ll cnt=0;
    rep(i,a.size()){
        if(a[i]*f[i]<=mid) continue;
        int memo=mid/f[i];
        cnt+=a[i]-memo;
    }
    //debug(mid);
    //debug(cnt);
    if(cnt<=k) return true;
    else return false;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,k;
    cin>>n>>k;
    vec a;
    vec f;
    a.resize(n);
    f.resize(n);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>f[i];
    }
    sort(rall(a));
    sort(all(f));
    int ng = -1, ok = INF;
    while (abs(ng-ok)>1) {
      int mid = ng+(ok-ng)/2;
      (check(mid,a,f,k)?ok:ng) = mid;
    }
    
    // debug(ok);debug(ng);
    cout<<ok<<endl;

}

Measured memory_bytes: 3456
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
	int key;
	Node *next,*prev;
};

Node *nil;

Node* listSearch(int key){
	Node *cur=nil->next;
	while(cur!=nil&&cur->key!=key){
		cur=cur->next;
	}
	return cur;
}

void init(){
	nil=(Node*)malloc(sizeof(Node));
	nil->next=nil;
	nil->prev=nil;
}

void printList(){
	Node *cur=nil->next;
	int isf=0;
	while(1){
		if(cur==nil)break;
		if(isf++>0)printf(" ");
		printf("%d",cur->key);
		cur=cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t){
	if(t==nil)return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}
void deleteKey(int key){
	deleteNode(listSearch(key));
}

void insert(int key){
	Node *x=(Node*)malloc(sizeof(Node));
	x->key=key;
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}

int main(){
	int key,n,i;
	int size=0;
	char com[20];
	int np=0,nd=0;
	scanf("%d",&n);
	init();
	for(i=0;i<n;i++){
		scanf("%s%d",com,&key);
			if(com[0]=='i'){insert(key);np++;size++;}
		else if(com[0]=='d'){
			if(strlen(com)>6){
				if(com[6]=='F')deleteFirst();
				else if(com[6]=='L')deleteLast();
			}else{
				deleteKey(key);nd++;
			}
			size--;
		}
	}
	
	printList();
	
	return 0;
}


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

using namespace std;
int main() {
	int N, M,count=0,sum=0;
	
	cin >> N >> M;
	vector<int> a(N);
	for (int i = 0;i < N;i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a.begin(), a.end());
	for (int i = N - 1; i >= 0; i--)
	{
		count += (a[i] * 4 * M >= sum) ? 1 : 0;
	}
	cout << ((count >= M) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=998244353;
ll a[3005][3005];
ll dp[3005][3005][5];


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r,c,k;
    cin>>r>>c>>k;
    while(k--)
    {
        int x,y,z;
        cin>>x>>y>>z;
        a[x][y]=z;
    }
    ll ans=0;
    /*for(int i=1;i<=r;i++)
    {
        dp[i][1][0]=dp[i-1][1][1];
        dp[i][1][1]=dp[i-1][1][1]+a[i][1];
        ans=max(ans,dp[i][1][1]);
    }
    for(int i=1;i<=c;i++)
    {
        for(int x=1;x<=3;x++)
        {
            dp[1][i][x]=max(dp[1][i-1][x],dp[1][i-1][x-1]+a[1][i]);
            ans=max(ans,dp[1][i][x]);
        }
    }*/

    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            dp[i][j][0]=max(dp[i][j-1][0],dp[i-1][j][3]);
            ans=max(ans,dp[i][j][0]);
            for(int x=1;x<=3;x++)
            {
                dp[i][j][x]=max(dp[i-1][j][3]+a[i][j],max(dp[i][j-1][x],dp[i][j-1][x-1]+a[i][j]));
                ans=max(ans,dp[i][j][x]);
            }
        }
    }
    cout<<ans<<'\n';


}


Measured memory_bytes: 426112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N=4e3+5;
char s[N];
int cnt[N][3];
int id[300];

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n;cin>>n;
    id['R']=0,id['B']=1,id['G']=2;
    cin>>s+1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<3;j++) cnt[i][j]=cnt[i-1][j];
        cnt[i][id[s[i]]]++;
    }
    ll ans=0;
    for(int k=3;k<=n;k++){
        for(int j=k-1;j>1;j--)if(s[k]!=s[j]){
            for(int i=0;i<3;i++)if(i!=id[s[k]]&&i!=id[s[j]]){
                ans+=cnt[j-1][i];
            }
            int i=j-(k-j);
            if(i>0&&s[i]!=s[k]&&s[i]!=s[j]) ans--;
        }
    }
    cout<<ans;
}


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



using namespace std;



int main(){

  int n, d;

  cin >> n >> d;





  int asize = n * d;

  // i番目j次元の数値 x[D*i+j]



  vector <int> x;

  int tmp;



  for (int i = 0; i < n; ++i){

    for (int j = 0; j < d; ++j){

      cin >> tmp;

      x.push_back(tmp);

    }

    cin.ignore();

  }



  int cnt = 0;

  double sqtmp;

  int sum = 0;

  int cel;

  int flr;



  for (int i = 0; i < n - 1; i++){

    // 0次元からD-1次元まで和とする

    for(int k = i + 1; k < n; k++){

      sum = 0;

      for(int j = 0; j < d; j++){

        sum+= (x[d*i+j] - x[d*k + j]) * (x[d*i+j] - x[d*k + j]);

      }

      sqtmp = sqrt((double)sum);

      cel = ceil(sqtmp);

      flr = floor(sqtmp);

      //cout << "sqrt = " << sqtmp << endl;

      //cout << "ceil = " << cel << endl;

      //cout << "floor = " << flr << endl;

      if((cel * cel == sum) || (flr * flr == sum)){

        ++cnt;

      }

    }

  }

  cout << cnt << endl;

  return 0;

}

    



Measured memory_bytes: 256
N,K,Q = map(int,input().split())
A = list(int(input()) for i in range(Q))

Count = [0]*N
for i in range(Q):
    Count[A[i]-1] += 1

for i in range(N):
    if Q - Count[i] >= K:
        print('No')
    else:
        print('Yes')


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

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

    vector<vector<int>> v(N, vector<int>(2, 0));
    for(size_t i = 0; i < v.size(); ++i){
        cin >> v[i][0] >> v[i][1];
    }

    sort(v.begin(), v.end());
    long long ans = 0;
    for (size_t i = 0; i < v.size(); ++i){
        for (size_t j = 0; j < v[i][1]; ++j){
            if (M < 1){
                cout << ans << endl;
                return 0;
            } else {
                --M;
                ans += v[i][0];
            }
        }
    }

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

Measured memory_bytes: 5760
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<queue>
#include<ctime>
#include<cassert>
#include<complex>
#include<string>
#include<cstring>
#include<chrono>
#include<random>
#include<bitset>

#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define sz(v) (int) v.size()

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

typedef long long lox;
typedef long double lod;
typedef unsigned long long pox;
typedef pair<int, int> pii;

const int MAX_N = 2e5 + 5;

int n, a[MAX_N], nxt[MAX_N];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	int first = n + 1;
	for (int i = n; i >= 1; --i) {
		nxt[i] = first;
		if (a[i] != 0) {
			first = i;
		}
	}
	lox ans = 0;
	for (int l = 1; l <= n; ++l) {
		vector<bool> used(21, 0);
		for (int r = l; r <= n; r = nxt[r]) {
			bool ok = true;
			for (int i = 0; i < 21; ++i) {
				if ((a[r] >> i) & 1) {
					if (used[i]) {
						ok = false;
						break;
					}
					used[i] = true;
				}
			}
			if (!ok) {
				break;
			}
			ans += (lox) (nxt[r] - r);
		}
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
	while(1){
int miti[16][16];
for(int i=0;i<16;i++){
	for(int j=0;j<16;j++){
		miti[i][j]=0;
	}
}
int x,y;
cin>>x>>y;
if(x==0 and y==0){break;}
int n;
cin>>n;
for(int i=0;i<n;i++){
	int a,b;
	cin>>a>>b;
	miti[a-1][b-1]=-1;
}
miti[0][0]=1;
for(int i=0;i<x;i++){
	for(int j=0;j<y;j++){
		if(miti[i][j]!=-1){
			if(i!=0 and miti[i-1][j]!=-1){miti[i][j]+=miti[i-1][j];}
			if(j!=0 and miti[i][j-1]!=-1){miti[i][j]+=miti[i][j-1];}
		}
	}
}
cout<<miti[x-1][y-1]<<endl;
}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main() {

    int x;
    int i = 1;

    while(1) {
        cin >> x;
        if (x == 0) {
            break;
        }
        cout << "Case " << i << ": " << x << endl;
        i++;
    }
    return 0;
}

Measured memory_bytes: 3060
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache
from numba import jit

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

@jit
def main():
	n = I()
	ans = 0
	for k in range(1,n+1):
		ans += k * 0.5 * (n // k) * (n // k + 1)
	print(int(ans))


if __name__ == '__main__':
    main()

Measured memory_bytes: 111100
#include <bits/stdc++.h> 
using namespace std;
 int a,b,c,date;
  string d,e,f; 
  int main(){ 
	  cin >>date;
	  
	  if(date == 7 || date == 5 || date == 3){cout<<"YES"<<endl;}
	  else{cout<<"NO"<<endl;}
	  
	  return 0;
	   
	    }
 


Measured memory_bytes: 256
#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 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_popcountll

#define INF 1e16
#define mod 1000000007

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < (int)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,M,K;

struct edge{
  int u,v,cost;
  int typ;
};

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

  while(1){
    cin>>N>>M>>K;
    if(N==0)break;
    vector<edge> es[2];
    rep(i,M){
      int a,b,c;
      char t;
      cin>>a>>b>>c>>t;
      a--;b--;
      if(t=='A'){
        es[0].push_back((edge){a,b,c,-1});
      }else{
        es[1].push_back((edge){a,b,c,-1});
      }
    }
    int lb=-10000,ub=10000,res=0,cnta=0;
    UnionFind uf(N);
    while(ub-lb>1){
      int X=(lb+ub)/2;
      vector<edge> crtes;
      rep(i,es[0].size())crtes.push_back((edge){es[0][i].u,es[0][i].v,es[0][i].cost+X,1});
      rep(i,es[1].size())crtes.push_back((edge){es[1][i].u,es[1][i].v,es[1][i].cost,0});
      sort(all(crtes),[](const edge& a,const edge& b){
        if(a.cost==b.cost)return a.typ > b.typ;
        else return a.cost < b.cost;
      });
      uf.init();
      cnta=0;
      res=0;
      rep(i,crtes.size()){
        if(uf.same(crtes[i].u,crtes[i].v))continue;
        uf.unite(crtes[i].u,crtes[i].v);
        cnta+=crtes[i].typ;
        res+=crtes[i].cost;
      }
      res-=cnta*X;
      if(cnta<K)ub=X;
      else lb=X;
    }
    {
      vector<edge> crtes;
      rep(i,es[0].size())crtes.push_back((edge){es[0][i].u,es[0][i].v,es[0][i].cost+lb,1});
      rep(i,es[1].size())crtes.push_back((edge){es[1][i].u,es[1][i].v,es[1][i].cost,0});
      sort(all(crtes),[](const edge& a,const edge& b){
        if(a.cost==b.cost)return a.typ > b.typ;
        else return a.cost < b.cost;
      });
      uf.init();
      cnta=0;
      res=0;
      rep(i,crtes.size()){
        if(uf.same(crtes[i].u,crtes[i].v))continue;
        uf.unite(crtes[i].u,crtes[i].v);
        cnta+=crtes[i].typ;
        res+=crtes[i].cost;
      }
    }
    res-=K*lb;

    if((lb>1000&&cnta!=0)||(lb<-1000&&cnta!=N-1)||uf.size(0)<N)cout<<-1<<endl;
    else cout<<res<<endl;
  }

  return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;

int main(){

    int N, Q;
    //vector<int> A;
    std::unordered_map<int, int> um;
    long long sum = 0;
    //vector<int> B, C;
    cin >> N;
    
    for(int i=0; i < N; ++i){
        int val;
        cin >> val;
        //A.push_back(val);
        sum += val;
        if(um.find(val) == um.end()){
            um[val] = 1;
        }else{
            ++um[val];
        }
    }
    cin >> Q;
    
    vector<long long> sum2;
    for(int i = 0; i < Q;++i){
        int b,c;
        cin >> b >> c;
        //B.push_back(b);
        //C.push_back
        if(um.find(b) != um.end()){
            sum = sum + um[b]*(c-b);
            if(um.find(c) != um.end()){
                um[c] = um[c] + um[b];
            }else{
                um[c] = um[b];
            }
            um.erase(b);
            
        }
        //cout << sum << endl;
        sum2.push_back(sum);
    }

    for(int i = 0; i < Q;++i){
        cout << sum2[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 7656
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

from collections import Counter

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input().strip())
    A = [int(s) for s in input().strip().split()]

    cnt = Counter(A)
    w = sum(x * (x - 1) // 2 for x in cnt.values())

    for a in A:
        result = w - (cnt[a] - 1)
        print(result)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 91288
#include <cstdio>
#include <vector>
#include <stack>
using namespace std;

int main() {
    int n, q, op, t, x;
    scanf("%d %d", &n, &q);
    stack<int> s[n];
    while (q--) {
        scanf("%d %d", &op, &t);
        if (op == 0) {
            scanf("%d", &x);
            s[t].emplace(x);
        } else if (op == 1) {
            if (!s[t].empty()) printf("%d\n", s[t].top());
        } else {
            if (!s[t].empty()) s[t].pop();
        }
    }
    return 0;
}



Measured memory_bytes: 3876
#include<stdio.h>

#include <stdlib.h>

int main() {
	int n;
	scanf("%d", &n);
	int *matrix;
	matrix = (int *)malloc(sizeof(int) * n * 2);
	int i, j;
	for (i = 0; i<2; i++) {
		for (j = 0; j<n; j++) {
			scanf("%d", &matrix[n*i+j]);
		}
		scanf("%*c");
	}
	
	int max = 0;
	int k;
	int total;
	for (k = 0; k < n; k++) {
		total = 0;
		for (j = 0; j <=k; j++) {
			total += matrix[j];
		}
		for (j = k; j <n; j++) {
			total += matrix[n*1+j];
		}
		if (total >= max)max = total;
	}
	printf("%d", max);
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) {
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Keep_calmYou_are_still_learning ios_base::sync_with_stdio(false);cin.tie(NULL);//freopen("out.txt","w",stdout);
typedef long long ll;
typedef long double ld;
using namespace std;



int main()
{
   Keep_calmYou_are_still_learning;
    ll n , k;
    cin>>n>>k;
    cout<<(n-3+k)/(k-1)<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll x, y;
    cin >> x >> y;
    ll diff = abs(abs(x) - abs(y));
    if (x < y) {
        if (x * y > 0) {
            print(diff);
        } else if (x * y < 0) {
            print(diff + 1);
        } else {
            print(diff);
        }
    } else if (x > y) {
        if (x * y > 0) {
            print(diff + 2);
        } else if (x * y < 0) {
            print(diff + 1);
        } else {
            print(diff+1);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int h, per_hour , const_price;
  
  cin >> h >> per_hour >> const_price;

  int hour_price = h * per_hour;
  
  if ( hour_price < const_price )
    cout << hour_price << endl;
  else
    cout << const_price << endl;
  
}

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

using namespace std;
using ll=long long int;

int main() {
    ll r, d, x;
    cin >> r >> d >> x;

    for (int i = 0; i < 10; ++i) {
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N = 0;
    int M = 0;
    cin >> N >> M;
    int ans = 0;
    ans = max(N*M,max(N+M,N-M));
    cout << ans << endl;
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L.at(i);
  sort(L.begin(), L.end());

  long long ans = 0;

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int k = lower_bound(L.begin(), L.end(), L.at(i) + L.at(j)) - L.begin();
      ans += max(0, k - j - 1);
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long,long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

const int INF = 1e9;

int pow(int a, int n) {
    int ans = 1;
    REP(i,n) ans *= a;
    return ans;
}

vecveci dp(20,veci(100010));

int main() {
    int N; cin >> N;
    veci A;
    A.push_back(1);
    int cnt = 1;
    while(1) {
        if(pow(6,cnt) > 100000) break;
        else A.push_back(pow(6,cnt));
        cnt++;
    }
    cnt = 1;
    while(1) {
        if(pow(9,cnt) > 100000) break;
        else A.push_back(pow(9,cnt));
        cnt++;
    }
    int X = A.size();
    REP(j,100010) dp[0][j] = INF;
    REP(i,X) REP(j,100010) {
        if(j < A[i] && i > 0) dp[i+1][j] = dp[i][j];
        else dp[i+1][j] = min(dp[i][j],dp[i+1][j-A[i]]+1);
    }
    cout << dp[X][N]-1 << endl;
}

Measured memory_bytes: 11248
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
/*       Rohan Balot
    NSIT, New Delhi, India  */
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <ratio>

#include <cctype>
#include <cstdio>
#include <cmath>
#include <climits>
#include <cstring>
using namespace std;
 
#define FIND(c, e) (c).find(e) != (c).end()
#define NFIND(c, e) (c).find(e) == (c).end()
#define ALL(t) (t).begin(), (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair

const int N = int( 1e5 ) + 1;
const int M = int( 1e6 ) + 1;
const int MOD = int( 1e9 ) + 7;
const double PI = acos(-1.0);
const double eps = 1e-6;
template<typename T> T gcd(T a,T b){while (b){ T r=a%b;a=b;b=r;}return a;}
template<typename T> T lcm(T a,T b){return (a*b)/gcd(a,b);}

struct graph {
	int vertices;
	int edges;
	vector< vector<int> > adj;
	vector< bool > visited;
	vector< int > level;
	graph() { }
	graph(int vertices) {
		this->adj.resize(vertices + 1);
		this->level.resize(vertices + 1, -1);
		this->visited.resize(vertices + 1, false);
		this->vertices = vertices;
		edges = 0;
	}
	void add_directed_edge(int from, int to) {
		this->adj[from].emplace_back(to);
		this->edges++;
	}	
	void add_undirected_edge(int from, int to) {
		this->adj[from].emplace_back(to);
		this->adj[to].emplace_back(from);
		this->edges += 2;
	}
	void read_undirected_edges(int edge_count) {
		this->edges += edge_count << 1;
		for (int i = 0; i < edge_count; i++) {
			int from, to;
			cin >> from >> to;
			this->adj[from].emplace_back(to);
			this->adj[to].emplace_back(from);
		}
	}	
	void read_directed_edges(int edge_count) {
		this->edges += edge_count;
		for (int i = 0; i < edge_count; i++) {
			int from, to;
			cin >> from >> to;
			this->adj[from].emplace_back(to);
		}
	}
	void dfs(int src) {
		this->visited[src] = true;
		for(int i : this->adj[src]) {
			if(this->visited[i] == false) {
				this->dfs(i);
			}
		}
	}
	void bfs(int src) {
		this->level[src] = 0;
		queue<int> q;
		q.push(src);
		while (!q.empty()) {
			int cur = q.front();
			q.pop();
			for(int i : this->adj[cur]) {
				if(this->level[i] == -1) {
					this->level[i] = this->level[cur] + 1;
					q.push(i);
				}
			}
		}
	}
};

void __answer()
{
	string s;
	getline(cin, s);
	s.pop_back();
	s.pop_back();
	while (s.substr(0, s.size() / 2).compare(s.substr(s.size() / 2, s.size())) != 0) {
		s.pop_back();
		s.pop_back();
	}
	cout << s.size() << '\n';
}  
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifdef LOCAL
        freopen("sample_input.txt", "r", stdin);
        // freopen("data.txt", "w", stdout);
        // freopen("log.txt", "w", stderr);
    #endif
    __answer();
    return 0;
}  

Measured memory_bytes: 256
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <algorithm>   //sort,二分探索,など
#include <bitset>      //固定長bit集合
#include <chrono>      //実行時間計測
#include <cmath>       //pow,logなど
#include <complex>     //複素数
#include <deque>       //両端アクセスのキュー
#include <functional>  //sortのgreater
#include <iomanip>     //setprecision(浮動小数点の出力の誤差)
#include <iostream>    //入出力
#include <iterator>    //集合演算(積集合,和集合,差集合など)
#include <map>         //map(辞書)
#include <numeric>     //iota(整数列の生成),gcdとlcm,accumulate
#include <queue>       //キュー
#include <set>         //集合（順序保持）
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility> //pair
#include <vector>  //可変長配列
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, n) for (int i = 0; i < ll(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < ll(b); i++)
#define FORD(i, a, b) for (int i = a; i > ll(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size()) // sizeをsize_tからllに直しておく
const long long INF = 1e12;
const int MOD = 1e9 + 7;
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define Umap unordered_map
#define Uset unordered_set
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed#c%E3%81%A7%E3%81%AE%E5%AE%9F%E8%A3%85
void print() { cout << endl; }

template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T> void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}

template <class T> void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {

    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    REP(i, n) { cin >> A.at(i); }

    sort(ALL(A));
    int ans=0;
    REP(i, k) { ans += A[i]; }
    print(ans);
}


Measured memory_bytes: 3668
/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define watch(x) cout << (#x) << " = " << (x) << endl
#define rep(i, n) for (int(i) = (0); (i) < (n); ++(i))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
	FIO;
	int ans=0,n;
	ll d;
	cin>>n>>d;
	while(n--)
	{
		ll x,y;
		cin>>x>>y;
		
		if(x*x+y*y<=d*d)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  string s,t;
  cin>>s>>t;
  ll diff=1LL<<60;
  for (int i = 0; i <= s.size()-t.size(); ++i)
  {
    string tmp=s.substr(i,t.size());
    ll cnt=0;
    for (int j = 0; j < t.size(); ++j)
    {
      if (tmp[j]!=t[j]) cnt++;
    }
    diff=min(cnt,diff);
  }
  cout<<diff;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;
vector <ll int> a,i;
void solve()
{
ll int i;
for(i=0;i<10000000;i++)
{
	a.pb(i*(i+1)/2);
}
}
ll int fun(ll int x)
{
	ll int l=0,r=a.size()-1,ans=-1;
	while(l<=r)
	{
		ll int m=l+(r-l)/2;
		if (a[m]<=x)
		{
			l=m+1;
			ans=m;
		}
		else
		r=m-1;
	}
	return ans;
	
}
int main()
{
	solve();
	ll int n;
	cin>>n;
	unordered_map <ll int ,ll int> m;
	ll int i,j;
	for(i=2;i*i<=n;i++)
	{
		while(n%i==0)
		{
			m[i]++;
			n=n/i;
		}
	}
	if (n!=1)
	m[n]++;
	ll int ans=0;
	for(auto i: m)
	{
		if (fun(i.second)!=-1)
		ans+=fun(i.second);
		
	}
	cout<<ans<<endl;
	
}
	
		
	
	
	
	




Measured memory_bytes: 134324
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    char s[h][w];
    queue<pair<P,int>> que;
    rep(i,h){
        rep(j,w){
            cin>>s[i][j];
            if(s[i][j]=='#')que.push(make_pair(make_pair(i,j),0));
        }
    }
    int ans=0;
    while(!que.empty()){
        pair<P,int> p=que.front();
        que.pop();
        chmax(ans,p.sc);
        int i=p.ft.ft;
        int j=p.ft.sc;
        for(int x=-1;x<=1;x++){
            for(int y=-1;y<=1;y++){
                if(abs(x+y)==1&&0<=i+x&&i+x<h&&0<=j+y&&j+y<w){
                    if(s[i+x][j+y]=='.'){
                        que.push(make_pair(make_pair(i+x,y+j),p.sc+1));
                        s[i+x][j+y]='#';
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 16244
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
char str[25];
int main() {
	scanf("%s", str);
	int k = strlen(str);
	int wins = 15 - k;
	for (int i = 0; i < k; ++i) wins += (str[i] == 'o');
	printf(wins >= 8 ? "YES\n" : "NO\n");
}


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

class quick_find {
	vector<int> rt;
	vector<vector<int>> vs;
public:
	quick_find(int n) : rt(n), vs(n) {
		for (int i = 0; i < n; i++) rt[i] = i, vs[i].push_back(i);
	}
	bool same(int a, int b) {
		return rt[a] == rt[b];
	}
	void unite(int a, int b) {
		a = rt[a], b = rt[b];
		if (a == b) return;
		if (vs[a].size() < vs[b].size()) swap(a, b);
		for (auto& v : vs[b]) rt[v] = a;
		copy(vs[b].begin(), vs[b].end(), back_inserter(vs[a]));
	}
	int size(int a) {
		return vs[rt[a]].size();
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	quick_find qf(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			qf.unite(x, y);
		}
		else {
			printf("%d\n", qf.same(x, y));
		}
	}
	return 0;
}



Measured memory_bytes: 3840
N = int(input())
L = list(map(int, input().split()))
ans = 0

import itertools

for i in itertools.combinations(L, 3):
    if i[0] != i[1] and i[1] != i[2] and i[2] != i[0]:
        j = sorted(i)
        if j[0] + j[1] > j[2]:
            ans += 1

print(ans)


Measured memory_bytes: 9200
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

//#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i) = 0; (i) <= (n); (i)++)
using namespace std;

char S[200001];
int dp[67108865];

int MAX_VAL = 1000000000;

signed main()
{
	cin >> S;
	REP(i, 67108865) dp[i] = MAX_VAL;
	dp[0] = 0;
	int N = strlen(S);
	int c = 0;
	for (int i = 0; i < N; i++)
	{
		c ^= (1 << (S[i] - 'a'));
		int min = dp[c];
		for (int j = 0; j < 26; j++)
		{
			min = MIN(min, dp[c ^ (1 << j)]);
		}
		dp[c] = MIN(dp[c], min + 1);
	}
	cout << MAX(1, dp[c]) << endl;
}

Measured memory_bytes: 262528
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	
		public static void main(String[] args) {
			long a=scan.nextLong();
			long max=0;
			for(int i=0;i<5;i++) {
				long b=lupper_division(a,scan.nextLong());
				max=lmax(b,max);
			}
			System.out.println(max+4);
		}
}


Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <map>
using namespace std;

#define pii pair<int,int>

int main() {
  int w, q;
  while(cin >> w >> q, w+q) {
    string hei(w, '0');
    map<int, pii> m;
    for (int i=0; i<q; i++) {
      char c;
      int id, x;
      cin >> c;
      
      if (c=='s') {
        cin >> id;
        cin >> x;
        
        string x0(x, '0');
        int p = hei.find(x0);
        if (p==-1) {
          cout << "impossible" << endl;
        } else {
          cout << p << endl;
          string x1(x, '1');
          hei.replace(p, x, x1);
          m.insert(make_pair(id, pii(x, p)));
        }
      } else {
        cin >> id;
        pii aaa = m.find(id)->second;
        string x0(aaa.first, '0');
        hei.replace(aaa.second, aaa.first, x0);
      }
//      cout << hei << endl;
    }
    cout << "END" << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    unsigned long long a; cin >> a;
    char c; int b, bd;
    cin >> b >> c >> bd;
    cout << a * b + a * bd / 100 << '\n';
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int a[100]={1,4,8,9,16,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000};
int main()
{
	scanf("%d",&n);
	for(int i=39;i>=0;i--)
	{
		if(n>=a[i])
		{
			printf("%d",a[i]);
			return 0;
		}
	}
}

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

typedef pair<int, int> P;
const int MAX_N = int(1e5) + 5;

vector<vector<P> > g;
int x[MAX_N];
bool visited[MAX_N]{};

bool dfs(int k){
    for(auto it : g[k]){
        int next = it.first, d = it.second;
        if(!visited[next]){
            x[next] = x[k] + d;
            visited[next] = true;
            if(!dfs(next))return false;
        }
        else if(x[next] != x[k] + d){
            return false;
        }
    }
    return true;
}

int main() {
    int n,m;
    cin >> n >> m;
    g.resize(n+1);
    for(int i=0;i<m;i++){
        int l,r,d;
        cin >> l >> r >> d;
        g[l].push_back({r,d});
        g[r].push_back({l,-d});
    }
    bool ans = true;
    for(int i=1;i<=n;i++){
        if(!visited[i]){
            visited[i] = true;
            if(!dfs(i))ans = false;
        }
    }
    cout << (ans?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll l,r,ans=INF;
    cin>>l>>r;
    if(l/2019!=r/2019){
        ans=0;
    }
    else{
        l%=2019;r%=2019;
        rep2(i,l,r){
            rep2(j,i+1,r+1){
                ans=min(ans,i*j%2019);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }
#define pb push_back
#define vi vector<int>
#define vii vector<<int>>
#define mii map<int, int>
#define pii pair<int, int>
#define qii priority_que<int, vector<int>, greater<int>>				
#define For(i, n) for(int i = 0; i < n; ++i)
#define For1(i, n) for(int i = 1; i <= n; ++i)
#define Forlr(i, l, r) for(int i = l; i <= r; ++i)
#define Forrl(i, r, l) for(int i = r; i >= l; --i)
using ll = long long;
int n, m, k, q;
const int INF = 1e9 + 5;
const int nax = 1e5 + 5;
bool b[10 * nax];
bool rs[10 * nax];
void solve() {
	cin >> n;
	vi a(n);
	For(i, n) 
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	For(i, n){
		if(!b[a[i]]){
			int j = a[i];
			while(j <= 1e6){
				b[j] = 1;
				j += a[i];
			}
		}
		else rs[a[i]] = 1;
	}
	int cnt = 0;
	For(i, n){
		if(!rs[a[i]])
			cnt++;
	}
	cout << cnt;
}

int main()
{
	fast();
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	
}

Measured memory_bytes: 5800
#include<stdio.h>
#define N 100

int main(){
  int i,j,k,l,n,p[N+1],m[N+1][N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ){
    scanf("%d %d", &p[i-1], &p[i]);
  }

  for ( i = 1; i <= n; i++ ){
    m[i][i]=0; 
  }
  for ( l = 2; l <= n; l++ ){
    for ( i = 1; i <= n-l+1; i++ ){
      j=i+l-1;
      m[i][j]=(1<<21);
      for ( k = i; k <= j-1; k++ ){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  printf("%d\n",m[1][n]); 
  return 0;
}


int min(int a, int b) {
	return a<b?a:b;
}

Measured memory_bytes: 632
#include <stdio.h>

int main(void){
    int m,n;
    scanf("%d",&n);scanf("%d",&m);
    int a[m],b[m],rec[n];
    for(int i=0;i<m;i++){
        scanf("%d",&a[i]);scanf("%d",&b[i]);
    }
    for(int i=0;i<n;i++){
        rec[i]=0;
        for(int j=0;j<m;j++){
            if(a[j]==i+1){
                rec[i]++;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(b[j]==i+1){
                rec[i]++;
            }
        }
    }
    for(int i=0;i<n;i++){
        printf("%d\n",rec[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double r;
  cin>>r;
  
  cout << 2*M_PI*r << endl;
  
  return 0;
}

Measured memory_bytes: 3776
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
ll ans[10005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	
	rep(x,1,100){
		rep(y,1,100){
			rep(z,1,100){
				int temp=x*x+y*y+z*z+x*y+x*z+y*z;
				
				if (temp<10005) ans[temp]++;
			}
		}
	}
	
	rep(x,1,n+1) cout<<ans[x]<<endl;
}


Measured memory_bytes: 3688