akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;




signed main() {
    ll n, k;
    cin >> n >> k;
    
    vll a(n);
    
    map <ll, ll> mp;
    ll loop = 0;
    ll cnt = 0;
    vll lp(n);
    ll flg = 0;
    
    ll now = 1;
    ll r = 0;
    
    
    rep(i, n) {
        cin >> a[i];
        mp[i] = 0;
    }
    
    while(true) {
        
        if(cnt == k) {
            mes(now);
            re0;
        }
        cnt++;
        mp[now]++;
        
        if (mp[now] == 2) flg = 1;
        if (mp[now] == 3) break;
        if (flg == 1) {
            lp[loop] = now;
            loop++;
        }
        now = a[now-1];
    }
    
    r = (k-cnt+1) % loop;
    mes(lp[r]);
    
    
}

Measured memory_bytes: 18836
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rep0(i,n) for(int i=0;i<n;i++)
#define per0(i,n) for(int i=n;i>0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
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; }
 

void solve() {
    int n; cin >> n;
    vector<int> h_list;
    h_list.push_back(0);
    rep(i,0,n){
        int temp; cin >> temp;
        h_list.push_back(temp);
    }

    vector<int> dp(n+10);
    dp[0] = 10000000;
    dp[1] = 0;
    rep(i,2,n+1){
        dp[i] = min(dp[i-1] + abs(h_list[i]-h_list[i-1]), dp[i-2]+abs(h_list[i]-h_list[i-2]));
    } 
    int ans = dp[n];
    //rep(i,0,n+1){
        //cout << dp[i];
    //}
    cout << ans;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 1144
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    int n;
    cin >> n;
    vector<PII> datum;

    REP(i,n){
        int a;
        cin >> a;
        datum.PB(MP(a,i));
    }

    sort(ALL(datum));

    int cnt = 0;
    REP(i, n){
        if(datum[i].second % 2 != i % 2) cnt++;
    }

    cout << cnt / 2 << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
//#define MOD (998244353)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");


int poww(int a,int b){
    if(b==0)return 1;
    int ans=poww(a,b/2);
    ans=(ans*ans)%MOD;
    if(b&1)ans=(ans*a)%MOD;
    return ans;
}

int f(int n,int r){
    if(r>n-r)r=n-r;
    int ans=1;
    for(int i=1;i<=r;i++){
        ans=((ans*(n-i+1)%MOD)*poww(i,MOD-2))%MOD;
    }
    return ans;
}

signed main(){
    FASTER;
    int n,a,b;
    cin>>n>>a>>b;
    if(n==2){
        cout<<0;
        return 0;
    }
    cout<<(poww(2,n)-f(n,a)-f(n,b)+2*MOD-1+MOD)%MOD;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    string s,t;
    cin >> s >> t;
    string sample = s + s;
    ll pos[s.size()][26];
    for (int yi = 0; yi < s.size(); ++yi) {
        for (int xi = 0; xi < 26; ++xi) {
            pos[yi][xi] = -1;
        }
    }
    vector<queue<ll>> a(26);
    for(int i = 0; i < sample.length(); i++){
        a[sample[i] - 'a'].push(i);
    }
    for (int i = 0; i < 26; ++i) {
        ll currentPos = 0;
        while(!a[i].empty()){
            ll tmp = a[i].front();a[i].pop();
            for(int j = currentPos; j <= tmp; j++){
                if(j >= s.size()){
                    break;
                }
                pos[j][i] = tmp;
            }
            currentPos = tmp + 1;
        }
    }
    for (int xi = 0; xi < 26; ++xi) {
        for (int yi = 0; yi < s.size(); yi++) {
            //cout << pos[yi][xi] << " ";
        }
        //cout << endl;
    }
    ll count = 0;
    for (int i = 0; i < t.size(); ++i) {
        int current = t[i] - 'a';
        ll m = count % s.size();
        ll next = pos[m][current];
        if(next == -1){
            cout << -1 << endl;
            return 0;
        }
        count += next - m + 1;
    }
    cout << count << endl;



}


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

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int n=cin.nextInt(),q=cin.nextInt(),TIME=0;
		Queue<String> name=new ArrayDeque<>();Queue<Integer>time=new ArrayDeque<>();
		for(int i=0;i<n;i++) {
			name.add(cin.next());time.add(cin.nextInt());
		}
		
		while(name.peek()!=null) {
			String str=name.remove();int t=time.remove();
			if(t>q) {
				name.add(str);time.add(t-q);
				TIME+=q;
			}
			else{
				System.out.println(str+" "+(TIME+t));
				TIME+=t;
			}
			
		}
	}

}



Measured memory_bytes: 70860
#include <stdio.h>

#define LEN 100001

typedef struct {
  char name[11];
  int time;
} pro_t;

pro_t queue[LEN];
int head;
int tail;

void enqueue(pro_t Q, int n) {
  queue[tail] = Q;
  tail = (tail+1) % (n+1);
}

pro_t dequeue(int n) {
  pro_t ret;
  ret = queue[head];
  head = (head+1) % (n+1);
  return ret;
}

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

int main() {
  int n;
  int q;
  int i;
  int elaps = 0;

  scanf("%d %d", &n, &q);

  for (i = 0; i < n; i++) {
    scanf("%s %d", queue[i].name, &queue[i].time);
  }
  tail = n;

  while (head != tail) {
    pro_t v = dequeue(n);
    int tmp = min(v.time, q);
    elaps += tmp;
    v.time -= tmp;
    if (v.time > 0) {
      enqueue(v, n);
    }
    else {
      printf("%s %d\n", v.name, elaps);
    }
  }
  
  
  return 0;
}



Measured memory_bytes: 2576
from bisect import bisect_left, bisect_right, insort_left
from typing import Dict, List


if __name__ == "__main__":
    num_query = int(input())
    d: Dict[str, int] = {}
    keys: List[str] = []

    for _ in range(num_query):
        op, *v = input().split()
        if ("0" == op):
            if v[0] not in d:
                insort_left(keys, v[0])
            d[v[0]] = int(v[1])
        elif ("1" == op):
            if v[0] in d:
                print(d[v[0]])
            else:
                print(0)
        elif ("2" == op):
            d[v[0]] = 0
        else:
            left_key = bisect_left(keys, v[0])
            right_key = bisect_right(keys, v[1], left_key)
            for k in range(left_key, right_key):
                if d[keys[k]] > 0:
                    print(keys[k], d[keys[k]])



Measured memory_bytes: 40560
import math

p = math.pi

A, B, H, M = map(int, input().split())

b = 6 * M
xb = B * math.cos(b * 2 * p / 360)
yb = B * math.sin(b * 2 * p / 360)

a = 30 * H + 0.5 * M
xa = A * math.cos(a * 2 * p / 360)
ya = A * math.sin(a * 2 * p / 360)

diff = (xa - xb) ** 2 + (ya - yb) ** 2
ans = math.sqrt(diff)

print (ans)

Measured memory_bytes: 9580
import java.util.*; 
 
public class Main{
    public static void main(String[] args){
	    Scanner sc=new Scanner(System.in);
            int N =sc.nextInt();
  		    long[] A = new long[N];
  		    long ans=1;
		    for(int i=0; i<N; i++){
    		    A[i]=sc.nextLong();
          	    if(A[i]==0){
            	    ans=0;
                }
    	    }
  	    	if(ans!=0){
		    	for(int i=0; i<N; i++){
            	if(A[i] <= (long)Math.pow(10,18)/ans){
                	ans *= A[i];
            	}else{
          	    	ans=-1;
                	break;
            	}
    		}
  	    }
    	System.out.println(ans);
    }
}

Measured memory_bytes: 61836
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        StringBuffer p = new StringBuffer();
        for(int i = 0 ; i < N ; i++){
            p.append(sc.next());
        }
        StringBuffer q = new StringBuffer();
        for(int i = 0 ; i < N ; i++){
            q.append(sc.next());
        }

        final Solver solver = new Solver(p.toString(), q.toString());
        solver.solve(N);
    }
}

class Solver {
    final String P;
    final String Q;

    long lessThanP = 0;
    long lessThanQ = 0;

    public Solver(String P, String Q) {
        this.P = P;
        this.Q = Q;
    }

    public void solve(int N) {
        StringBuffer sb = new StringBuffer();
        for (int i = 1; i <= N; i++) {
            sb.append(i);
        }
        permutate(sb, 0, N - 1);

        System.out.println(Math.abs(lessThanP - lessThanQ));
    }

    private void permutate(StringBuffer str, int l, int r) {
        if (l == r) {
            final String perm = str.toString();
            if (perm.compareTo(P) < 0) {
                lessThanP++;
            }
            if (perm.compareTo(Q) < 0) {
                lessThanQ++;
            }
        }
        else {
            for (int i = l; i <= r; i++) {
                swap(str, l, i);
                permutate(str, l + 1, r);
                swap(str, l, i);
            }
        }
    }

    private StringBuffer swap(StringBuffer s, int i, int j) {
        char tmp = s.charAt(j);
        s.setCharAt(j, s.charAt(i));
        s.setCharAt(i, tmp);
        return s;
    }
}



Measured memory_bytes: 25892
#include <iostream>

using namespace std;
string s;
int main()
{
    cin >> s;
    if(s == "ooo"){
        cout << "1000";
    }
    else if (s == "oox" || s == "oxo" || s == "xoo"){
        cout << "900";
    }
    else if (s == "oxx" || s == "xox" || s == "xxo"){
        cout << "800";
    }
    else if (s == "xxx") {
        cout << "700";
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#%%
def canDeerGo(strinp):
    t, n1, n2 = map(int, strinp.split())
    var1 = t + n1 + n2
    var2 = n1 + n2
    ans = True
    if var1 % 2 != 0 or var2 > t:
        ans = False
    return ans
#%%
def diffData(s,ss):
    t, n1, n2 = map(int, s.split())
    t2,n12,n22 = map(int, ss.split())
    l = [t2-t,n12-n1,n22-n2]
    canDeerGo(' '.join((list(map(str,l)))))
#%%
num = int(input())
ss =''
for i in range(num):
    s = input()
    if ss != '':
        diffData(s,ss)
    ans = canDeerGo(s)
    if ans == False:
        ans = 'No'
        break
    elif i == num-1:
        ans = 'Yes'
    ss = s
print(ans)

Measured memory_bytes: 3064
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

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

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL H, W, D;
	cin >> H >> W >> D;
	map<LL, P> A; // A[]=0-indexed MP()
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			LL at = IN<LL>();
			A[at] = MP(i, j);
		}
	}
	VL my(H*W + 1, 0);
	FOR(i, 0, H*W) {
		if (i + 1 > D)my[i + 1] = my[i + 1 - D]
			+ abs(A[i + 1].first - A[i + 1 - D].first)
			+ abs(A[i + 1].second - A[i + 1 - D].second);
	}




	LL Q;
	cin >> Q;
	FOR(i, 0, Q) {
		LL L, R;
		LL ans = 0;
		cin >> L >> R;
		ans = my[R] - my[L];
		O(ans);
	}

	return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define endl "\n"
    #define MOD 1000000007
    #define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
    #define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
    //    for(auto& it : m)
    void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
    ll int power(ll int x, ll int y, ll int p)  
    {  
       ll int res = 1;     // Initialize result  
     
        x = x % p; // Update x if it is more than or  
                    // equal to p
       
        if (x == 0) return 0; // In case x is divisible by p;
     
        while (y > 0)  
        {  
            // If y is odd, multiply x with result  
            if (y & 1)  
                res = (res*x) % p;  
     
            // y must be even now  
            y = y>>1; // y = y/2  
            x = (x*x) % p;  
        }  
        return res;  
    }  
     
    ll int modInverse(ll int a,ll int m)
    {
        ll int g = __gcd(a, m);
       
            // If a and m are relatively prime, then modulo inverse
            // is a^(m-2) mode m
           
           return      power(a, m-2, m);
       
    }
     
     
    int main()
    {
     
      fastio();
     
    ll int T=1;
   // cin>>T;
     
    for(ll int test=1;test<=T;test++)
    {
         ll int n,k,i;
         cin>>n>>k;
         ll int a[n];
         for(i=0;i<n;i++)
            cin>>a[i];
        for(i=k;i<n;i++)
        {
            if(a[i]>a[i-k])
                cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }

    
    }
     
     
     
    return 0;}

Measured memory_bytes: 5232
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

struct node{

    int key;
    node *right, *left, *parent;

};

node *NIL, *root;

void insert( int k ){

    node *y = NIL;
    node *x = root;
    node *z;

    z = ( node * )malloc( sizeof(node) );

    z -> key = k;
    z -> left = NIL;
    z -> right = NIL;

    while( x != NIL ){

        y = x;

        if( z -> key < x -> key ){

            x = x -> left;

        } else {

            x = x -> right;

        }

    }

    z -> parent = y;

    if( y == NIL ){

        root = z;

    } else {

        if( z-> key < y -> key ){

            y -> left = z;

        } else{

            y -> right = z;

        }

    }

}

node * find( node *u, int k ){

    while( u != NIL && k != u->key ){

        if( k < u->key ){

            u = u->left;

        } else {

            u = u->right;

        }

    }

    return u;

}

node * tree_minimum( node *x ){

    while( x->left != NIL ){

        x = x-> left;

    }

    return x;

}

node * getsuccessor( node *x ){

    if( x->right != NIL ) return tree_minimum( x->right );

    node *y = x->parent;

    while( y != NIL && x == y->right ){

        x = y;
        y = y->parent;

    }

    return y;

}

void tree_delete( int k ){

    node *t = find( root, k);

    node *x, *y;    //y:削除する対象、x:その子

    //削除する節点を決める

    if( t->left == NIL || t->right == NIL ){

        y = t;  //子なし、１個の場合

    } else {

        //子２の場合

        y = getsuccessor(t);

    }

    if( y->left != NIL ){

        x = y->left;

    }else{

        x = y->right;

    }

    if( x != NIL ){

        x->parent = y->parent;

    }

    if( y->parent == NIL ){

        root = x;

    } else {

        if( y == y->parent->left ){

            y->parent->left = x;

        } else {

            y->parent->right = x;

        }

    }

    if( y != t ){

        t->key = y->key;

    }

    free(y);

}

void inorder( node *u ){

    if( u == NIL ) return;
    inorder( u -> left );
    printf(" %d", u -> key );
    inorder( u -> right );

}

void preorder( node *u ){

    if( u == NIL ) return;
    printf(" %d", u -> key );
    preorder( u -> left );
    preorder( u -> right );   

}


int main(){

    int n, i, x;
    string com;

    scanf("%d", &n);

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

        cin >> com;

        if( com == "insert" ){

            scanf("%d", &x);
            insert(x);

        } else if( com == "print" ){

            inorder( root );
            printf("\n");
            preorder( root );
            printf("\n");

        } else if( com == "find" ){

            scanf("%d", &x);
            node *t = find( root, x);

            if( t == NIL ) printf("no\n");
            else printf("yes\n");

        } else {

            scanf("%d", &x);

            tree_delete(x);
            

        }

    }

    return 0;

}




Measured memory_bytes: 22096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;

string s;
bool check() {
  if (s.size() & 1) return false;
  for (int i = 0; i < (int)s.size(); i += 2) if(s[i] != 'h') return false;
  for (int i = 1; i < (int)s.size(); i += 2) if(s[i] != 'i') return false;
  return true;
}
int main() {
  cin >> s;
  cout << (check() ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());

  int hv = -1;
  double v = 1e9;
  double hm = vec[n - 1] / 2.0;
  for (int i = 0; i < n - 1; i++) {
    double dv = vec[i];
    if (abs(hm - dv) < v) {
      v = abs(hm - dv);
      hv = vec[i];
    }
  }
  cout << vec[n - 1] << " " << hv << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string t;
  for(int i=0; i<s.size();i++){
    if((i+1)%2==1){
      t.push_back(s[i]);
    }
  }
  for (int i=0;i<t.size();i++){
    cout << t[i];
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,q;
    cin>>a>>b>>q;
    long long s[a],t[b],x[q];
    for(int i=0;i<a;i++)cin>>s[i];
    for(int i=0;i<b;i++)cin>>t[i];
    for(int i=0;i<q;i++)cin>>x[i];
    for(int i=0;i<q;i++){
        long long m=1000000000000000000;
        if(x[i]<s[a-1]){
            long long r_shrine=*upper_bound(s,s+a,x[i]);
            if(r_shrine<t[b-1])m=min(m,*upper_bound(t,t+b,r_shrine)-x[i]);
            if(r_shrine>t[0])m=min(m,2*r_shrine-*(upper_bound(t,t+b,r_shrine)-1)-x[i]);
        }
        if(x[i]>s[0]){
            long long l_shrine=*(upper_bound(s,s+a,x[i])-1);
            if(l_shrine<t[b-1])m=min(m,*upper_bound(t,t+b,l_shrine)+x[i]-2*l_shrine);
            if(l_shrine>t[0])m=min(m,x[i]-*(upper_bound(t,t+b,l_shrine)-1));
        }
        if(x[i]<t[b-1]){
            long long r_temple=*upper_bound(t,t+b,x[i]);
            if(r_temple<s[a-1])m=min(m,*upper_bound(s,s+a,r_temple)-x[i]);
            if(r_temple>s[0])m=min(m,2*r_temple-*(upper_bound(s,s+a,r_temple)-1)-x[i]);
        }
        if(x[i]>t[0]){
            long long l_temple=*(upper_bound(t,t+b,x[i])-1);
            if(l_temple<s[a-1])m=min(m,*upper_bound(s,s+a,l_temple)+x[i]-2*l_temple);
            if(l_temple>s[0])m=min(m,x[i]-*(upper_bound(s,s+a,l_temple)-1));
        }
        cout<<m<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll dp[405][405],p[405];
ll fun(ll i,ll j){
	if(dp[i][j]!=0)return dp[i][j];
	if(i==j){
		dp[i][j]=0;
		return 0LL;
	}
	ll mi=1e16;
	for(ll k=i;k<j;k++){
		mi=min(mi,fun(i,k)+p[k]-p[i-1]+fun(k+1,j)+p[j]-p[k]);
	}
	dp[i][j]=mi;
	return mi;
}
int main(){
	ios;
	ll n;cin>>n;
	ll a[n+1];a[0]=0;
	memset(p,0,sizeof(p));
	memset(dp,0,sizeof(dp));
	for(ll i=1;i<=n;i++)cin>>a[i];
	for(ll i=1;i<=n;i++)p[i]=p[i-1]+a[i];
//	for(ll i=1;i<=n;i++)cout<<p[i]<<" ";cout<<endl;
	cout<<fun(1,n);
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    p[n-1] /= 2;
    int result = 0;
    for(int i = 0; i < n; i++){
        result += p[i];
    }
    cout << result << endl;
}

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

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N, K, Q; cin >> N >> K >> Q;
	vector<int> cnt(N, 0);
	rep(i, Q) {
		int x;
		cin >> x;
		cnt[x - 1]++;
	}

	rep(i, N) {
		if (K - (Q - cnt[i]) > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3748
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int a=scan.nextInt();
        int b=scan.nextInt();

        int c=a+b;
        int d=a-b;
        int e=a*b;

        if(c>=d&&c>=e){
            System.out.println(c);
        }else if(d>=c&&d>=e){
            System.out.println(d);
        }else{
            System.out.println(e);
        }

    }
}


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


int main(){
  long long a,b,k;
  cin>>a>>b>>k;
  if(b-a+1>=2*k){
    for(int i=0;i<k;i++){
      cout<<i+a<<endl;
    }
    for(int i=b-k+1;i<=b;i++){
      cout<<i<<endl;
    }
  }
  else{
    for(int i=a;i<=b;i++){
      cout<<i<<endl;
    }
  }
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1ll<<32;
const ll maxn=1e3+10;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<int> uid(l, r); return uid(rng); }


void solve(){
	
	ll k;
	cin>>k;
	queue<ll> q;
	for (int i=1;i<=9;i++){
		q.push(i);
	}
	if (k<=9){
		cout<<k<<endl;
		return;
	}
	ll ans;
	while(k>0){
		ll x=q.front();
		ans=x;
		q.pop();
		ll z=x%10;
		if (z-1>=0) q.push(10*x+z-1);
		q.push(10*x+z);
		if (z+1<=9) q.push(10*x+z+1);
		k--;
	}
	cout<<ans<<endl;
	
	
	return;
}

int main(){ 
    
    #ifndef ONLINE_JUDGE
  	//	freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);


	//T{ solve(); }
	solve();
		
	
	return 0;
}

Measured memory_bytes: 1792
import heapq
N = int(input())
xy_s = [list(map(int,input().split())) for _ in range(N)]
XPYMAX = []
XPYMIN = []
XMYMAX = []
XMYMIN = []
heapq.heapify(XPYMAX)
heapq.heapify(XPYMIN)
heapq.heapify(XMYMAX)
heapq.heapify(XMYMIN)
answer = 0
for i, xy in enumerate(xy_s):
    x = xy[0]
    y = xy[1]
    heapq.heappush(XPYMAX,-(x+y))
    heapq.heappush(XMYMAX,-(x-y))
    heapq.heappush(XPYMIN,(x+y))
    heapq.heappush(XMYMIN,(x-y))

    if i == 0:
        continue

    xpy = x+y
    xmy = x-y
    xpymax = -XPYMAX[0]
    xpymin = XPYMIN[0]
    xmymax = -XMYMAX[0]
    xmymin = XMYMIN[0]
    dist = max(abs(xpymax-xpy), abs(xpymin-xpy), abs(xmymax-xmy), abs(xmymin-xmy))
    answer = max(dist, answer)
print(answer)

Measured memory_bytes: 161464
n=int(input())
a=list(map(int,input().split()))


ans="APPROVED"
for i in range(n):
  if a[i] % 2 == 0:
    if a[i] % 3 == 0 or a[i]%5 == 0:
      continue
    else:
      ans = "DENIED"
      
print(ans)

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

int main() {
  int N;
  cin >> N;
  set<string> S;
  string A;
  for (int i = 0; i < N; i++) {
    cin >> A;
    S.insert(A);
  }
  cout << S.size() << endl;
}

Measured memory_bytes: 19088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
    int L;
    double V;
    cin >> L;
    V = L * L * L / 27.00000000000;
    cout << fixed << setprecision(7) << V << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

int main(){
  int n;  scanf("%d ", &n);
  long ans = 1, preans = 1;
  
  int over = 0, zero = 0;
  for(int i=0; i<n; i++){
    long a;  scanf("%ld", &a);
    if(a > LONG_MAX/ans)  over = 1;
    if(over == 0)  ans = ans * a;
    if(a == 0)  zero = 1;
  }
  //  printf("over : %d\n", over);
  if(zero){
    ans = 0;
  }else if(over){
    ans = -1;
  }else if(ans > 1000000000000000000){
    ans = -1;
  }
  
  printf("%ld\n", ans);
  
  return 0;
}


Measured memory_bytes: 1732
#include <iostream>

using namespace std;

int sx, sy, tx, ty;

int main(void)
{
	cin >> sx >> sy >> tx >> ty;
	
	for(int i = 0; i < tx-sx; i++) cout << "R";
	for(int i = 0; i < ty-sy; i++) cout << "U";
	for(int i = 0; i < tx-sx; i++) cout << "L";
	for(int i = 0; i < ty-sy; i++) cout << "D";
	
	cout << "D";
	for(int i = 0; i < tx-sx+1; i++) cout << "R";
	for(int i = 0; i < ty-sy+1; i++) cout << "U";
	cout << "LU";
	for(int i = 0; i < tx-sx+1; i++) cout << "L";
	for(int i = 0; i < ty-sy+1; i++) cout << "D";
	cout << "R";
	
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include <string.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
int main(){
	int g=0,p=0;
	char s[100002];
	scanf("%s",s);
	FOR(i,0,strlen(s)){
		if(s[i] == 'g') g++;
		if(s[i] == 'p') p++;
	}
	printf("%d",strlen(s)/2 - p);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    StringBuilder SS = new StringBuilder(S);
    int check =0;
    for (int i=0; i<S.length(); i++) {
      String SSS = SS.substring(i,S.length()) + SS.substring(0,i);
      if (SSS.equals(T)) {
        check++;
        break;
      }
    }
    if (check != 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <vector>
#include <unordered_map>
#include <algorithm>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
    int m = 0, n = 0;
    cin >> n >> m;
    vector<ll> val;
    unordered_map<ll, ll> num;
    
    int v0 = 0, n0 = 0;
    for(int i = 0; i < n; ++i) {
        cin >> v0 >> n0;
        if(num.count(v0) == 0) {
            val.push_back(v0);
            num[v0] = 0;
        }
        num[v0] += n0;
    }
    sort(val.begin(), val.end());
    
    ll cost = 0;
    ll cans = m;
    for(int i = 0; i < val.size() && cans > 0; ++i) {
        if(cans <= num[val[i]]) {
            cost += cans * val[i];
            cans = 0;
        } else {
            cost += num[val[i]] * val[i];
            cans = cans - num[val[i]];
        }
    }
    
    cout << cost << endl;
    return 0;
}


Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first > b.first;
    }
}

int main(){
    ll N, M; cin >> N >> M;
    vector<ll> A(N);
    vector<pair<ll,ll> > B(M);
    ll sum = 0;

    for(int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }
    for(int i=0;i<M;++i){
        ll b,c;
        cin >> b >> c;
        B[i] = make_pair(b,c);
    }

    //Aは昇順、Bは降順
    sort(A.begin(),A.end());
    sort(B.begin(),B.end(),compare_by_b);

    ll cur = 0;
    bool ok = true;
   
    for(auto itr : B){
        for(int i=0;i<itr.first;++i){
            if(A[cur] < itr.second) sum += (itr.second - A[cur]);
            else ok = false;
            cur ++;
            if(cur >= N){
                ok = false;
                break;
            }
        }
        if(!ok)break;
    }

    cout << sum << endl;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

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

  int count = 0;
  for(int i=0; i<N; i++){
    if(S[i] == 'A')
      if(S[i+1] == 'B')
	if(S[i+2] == 'C'){
	  count++;
	  i += 2;
	}
  }

  cout << count << endl;
    
  return 0;
}


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

int main() {
    lint n;
    string s;
    cin >> n >> s;

    // a, b, c がこの順に出現する O(n)
    auto check = [&](char a, char b, char c) {
        char cs[3] = {a, b, c};
        lint checked = 0;
        for(auto e : s) {
            if(cs[checked] == e)  checked++;
            if(checked == 3)  return true;
        }
        return false;
    };

    lint ans = 0;
    for(char a='0'; a<='9'; a++)
    for(char b='0'; b<='9'; b++)
    for(char c='0'; c<='9'; c++) {
        ans += check(a, b, c);
    }

    cout << ans << endl;
}

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

using namespace std;
constexpr int MOD = 2019;

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

    long long ret = 0;
    vector<int> v(MOD);
    v[0] = 1;
    int now = 0, times = 1;
    for (int i = s.size() - 1; i >= 0; i--) {
        now += (s[i] - '0') * times, now %= MOD;
        times *= 10, times %= MOD;
        ret += v[now], v[now]++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> rmax(N + 1), lmax(N + 1);
    rep(i, N) rmax[i + 1] = max(rmax[i], A[i]);
    for(int i = N - 1; i >= 0; i--)
        lmax[i] = max(lmax[i + 1], A[i]);
    rep(i, N) { cout << max(lmax[i + 1], rmax[i]) << endl; }

    return 0;
}

Measured memory_bytes: 3968
#include<stdio.h>

int main(){
  int a, b, total[10000], i = 0, j;
  char op;

  while(1){
    scanf("%d %c %d", &a, &op, &b);
    if(op == '?')
      break;
    else if(op == '+')
      total[i] = a + b;
    else if(op == '-')
      total[i] = a - b;
    else if(op == '*')
      total[i] = a * b;
    else if(op == '/')
      total[i] = a / b;
    i++;
  }

  for(j = 0; j < i; j++)
    printf("%d\n", total[j]);

  return 0;
}



Measured memory_bytes: 2088
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <ext/hash_map>
//#include <tr1/unordered_map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
//using namespace tr1;
using namespace __gnu_cxx;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define DEB 0

#define SZ 885777

/*
real	0m2.093s  --> 
real	0m2.000s
*/
const int dx[] = {1,0,-1,0}; //r,d,l,u
const int dy[] = {0,1,0,-1};

int w,h,sx,sy,home,last;
int field[16][16];
int num[16][16];
int hS[25],hx[25],hy[25],edge[25][4][25]; //[src][dir][dest]
hash_map<int,int> hii(SZ);
//unordered_map<int,int> hii(SZ);


inline bool isnotgoal(int s){
  return (((last&s)) == last);
}
inline bool isnot(int s){
  rep(i,home)if( !(s&(1<<i)) ){
    if( (hS[i]&s)==hS[i] ) return true;
  }
  return false;
}
inline bool inside(int x, int y){
  return (x<0 || y<0 || x>=w || y>=h);
}

int dfs(int S){
  int src = S&((1<<5)-1);
  int x = hx[src];
  int y = hy[src];
  int s = S>>5;

  if( (1<<home)-1 == s ){ //ツ静「ツ妥篠づ可姪淞づェツづゥ
    return 1;
  }
  if( isnotgoal(s) ){ //ツ仰ウツ嘉ッツづ可姪淞づゥツつスツづ淞づ個嘉づーツ湘氾ッツつオツつスツつゥツづつ、ツつゥ
    return 0;
  }
  hash_map<int,int>::iterator it = hii.find(S);
  //unordered_map<int,int>::iterator it = hii.find(S);
  if( it!=hii.end() ){ //ツ探ツ催オツ催渉づ敖づ個湘ウツ妥板つゥツづつ、ツつゥ
    return it->second;
  }

  // ツプツδ個ゼツδ督トツつェツ置ツつッツづ按つ「ツ嘉づ個有ツ鳴ウ
  if( s>0 && ((s&(s-1))!=0) && isnot(s&~(1<<src)) ){
    return 0;
  }
  
  int ret = 0;
  rep(k,4){
    for(int j=0; edge[src][k][j]!=-1; j++){
      int dest = edge[src][k][j];
      int nx = hx[dest];
      int ny = hy[dest];
      if( field[ny][nx]==1 ){
	field[ny][nx] = 0;
	ret += dfs(((s|(1<<dest))<<5)|dest);
	field[ny][nx] = 1;
	break;
      }
    }
  }
  hii.insert(make_pair(S,ret));
  return ret;
}

int main(){

  while(scanf("%d%d",&w,&h),w|h){
    hii.clear();
    memset(num,-1,sizeof(num));
    memset(edge,-1,sizeof(edge));
    memset(hS,0,sizeof(hS));
    home = last = 0;
    rep(i,h){
      rep(j,w){
	scanf("%d",&field[i][j]);
	if( field[i][j]==2 ){
	  sx=j; sy=i;
	}
	if( field[i][j]==1 ){
	  hx[home]=j; hy[home]=i;
	  num[i][j] = home;
	  home++;
	}
      }
    }
    hx[home] = sx;
    hy[home] = sy;

    // other homes
    rep(i,home){
      rep(k,4){
	int sz = 0;
	for(int j=1; j<20; j++){
	  int tx = hx[i] + dx[k]*j;
	  int ty = hy[i] + dy[k]*j;
	  if( inside(tx,ty) ) break;
	  if( field[ty][tx]==1 ){
	    hS[i] |= (1<<num[ty][tx]);
	    edge[i][k][sz++] = num[ty][tx];
	  }
	}
      }
    }

    //last homes
    rep(k,4){
      int sz = 0;
      for(int i=1; i<20; i++){
	int tx = sx + dx[k]*i;
	int ty = sy + dy[k]*i;
	if( inside(tx,ty) )break;
	if( field[ty][tx]==1 ){
	  last |= (1<<num[ty][tx]);
	  edge[home][k][sz++] = num[ty][tx];
	}
      }
    }
    printf("%d\n",dfs(home));
  }
  

  return 0;
}

Measured memory_bytes: 20000
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[200005];
map <long long,long long> mp;
string s,s1,s2,s3;
int main() {
           cin>>n;
           for(long long i=1;i<=n;i++)
           cin>>A[i];
           for(long long i=1;i<=n;i++) {
                      if(mp[A[i]]==1) { cout<<"NO"; return 0; }
                      mp[A[i]]=1;
           }
           cout<<"YES";
}

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

int main() {
  int n;
  cin >> n;
  vector<int> c;
  rep(i, n) {
    int a;
    cin >> a;
    int sz = c.size();
    if (!sz) {
      c.push_back(a);
      continue;
    }
    int j = lower_bound(c.begin(), c.end(), a) - c.begin() - 1;
    if (j < 0 || a == c[j]) {
      c.insert(c.begin(), a);
    } else {
      c[j] = a;
    }
  }
  cout << c.size() << endl;
  return 0;
}

Measured memory_bytes: 892
/*
        FFFFFFFFFFFFFFFFFFFFFF
        F::::::::::::::::::::F
        F::::::::::::::::::::F
        FF::::::FFFFFFFFF::::F
          F:::::F       FFFFFF
          F:::::F
          F::::::FFFFFFFFFF
          F:::::::::::::::F
          F:::::::::::::::F
          F::::::FFFFFFFFFF
          F:::::F
          F:::::F
        FF:::::::FF
        F::::::::FF
        F::::::::FF
        FFFFFFFFFFF
*/
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int long long
#define mod 1000000007 //998244353
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define ms(v,n) memset((v),n,sizeof(v));
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define inf 9e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T> T add(T &a, T b){ return (a+=b)%=mod; }
template<typename T> T sub(T &a, T b){ (a-=b); if(a<0) a+=mod; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
// const int N=...;

int32_t main()
{
    
	fast
	ll n,x,y;
	cin>>n>>x>>y;
	map<pll,ll> m;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=i+1;j<=n;j++)
		{
			 m[{i,j}]=min(abs(j-i),abs(x-i)+1+abs(j-y));
			 //cout<<i<<" "<<j<<" "<<m[{i,j}]<<nl;
			 //trace3(i,j,m[{i,j}]);
			 
		}
	}
	
	map<ll,ll> m2;
	
	for(auto i:m)
	{
		m2[i.y]++;
	}
	
	
	for(ll i=1;i<=n-1;i++)
	cout<<m2[i]<<nl;	



    

	return 0;
    
}

Measured memory_bytes: 125312
#include <iostream>

int main() {
  unsigned N;
  std::cin >> N;
  int x = 0;
  int y = 0;
  int t = 0;
  bool ans = true;
  for (unsigned i = 0; i < N; ++i) {
    int tt, a, b;
    std::cin >> tt >> a >> b;
    auto man = std::abs(a - x) + std::abs(b - y);
    if (man % 2 != (tt - t) % 2 || man > (tt - t)) {
      ans = false;
    }
    t = tt;
    x = a;
    y = b;
  }
  std::cout << (ans ? "Yes" : "No") << std::endl;
  return 0;
}

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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

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

long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}



int main(){
    long long N;
    cin >> N;
    long long ans = N +1 -2;
    for(long long a=1; a*a <=N; ++a){
        if(N%a == 0) ans = min(ans,a+ N/a -2);
    }
    cout << ans << endl;




}


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

long f(long x) {
  long s=(x+1)/2 %2;
  long d=2;
  while (d<=x) {
    s+=(x/d %2)*((x+1) %2)*d;
    //cout <<d <<":" <<s <<endl;//////////////
    d*=2;
  }
  //cout <<x <<":" <<s <<endl;////////////////
  return s;
}
  
    
int main() {
  long A, B;
  cin >>A >>B;
  long a, b;
  a=f(A-1);
  b=f(B);
  cout << (a xor b);
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def solve(d):
    if d == 1:
        return ['a']
    l = solve(d-1)
    rsl = []
    for w in l:
        m = ord(max(w))
        for i in range(ord('a'), m+2):
            rsl.append(w+chr(i))
    return rsl


def main():
    print(*solve(ii()), sep='\n')


if __name__ == '__main__':
    main()

Measured memory_bytes: 19256
import bisect

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

d.sort()
t.sort()

set_t = list(set(t))


for i in range(len(set_t)):
    n_d = bisect.bisect_right(d,set_t[i]) - bisect.bisect_left(d,set_t[i])
    n_t = bisect.bisect_right(t,set_t[i]) - bisect.bisect_left(t,set_t[i])
    
    if n_t > n_d:
        print('NO')
        exit()

print('YES')

Measured memory_bytes: 127828