akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> T[20];

int query(int h, int k, int i, int j)
{
	int m = (k << h) + (1 << h - 1);
	if(i == (k << h) && j == (k + 1 << h) - 1) return T[h][k];
	if(j < m) return query(h - 1, k << 1, i, j);
	if(i >= m) return query(h - 1, k << 1 | 1, i, j);
	return max(query(h - 1, k << 1, i, m - 1), query(h - 1, k << 1 | 1, m, j));
}

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	int d = 19;
	for(int i = 0; i <= d; i++)
	{
		T[i].clear();
		T[i].resize(1 << (d - i), 0);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		int q = query(d, 0, max(a - k, 0), min(a + k, 300000));
		ans = max(ans, q + 1);

		int p = a;
		T[0][p] = max(T[0][p], q + 1);
		p >>= 1;
		for (int j = 1; j <= d; j++) {
			T[j][p] = max(T[j - 1][p << 1], T[j - 1][p << 1 | 1]);
			p >>= 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 7072
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
struct Dijkstra{
  ll INF=1000000000000000009;
  ll MAX_V=1000000;
  ll st = -1;
  struct edge{ll to, cost;};
  typedef pair<ll, ll> p;
  vector<vector<edge>> G;
  vector<ll> pre, d;
  priority_queue<p, vector<p>, greater<p> > que; //class, inner, compair
  Dijkstra(ll s){
    G.resize(s+2);
    pre.resize(s+2, -1);
    d.resize(s+2, INF);
  }
  inline void insert(ll a, ll b, ll c){
    G[a].push_back(edge{b, c});
  }
  void init(){
    for(int i=0;i<d.size();i++) pre[i] = -1, d[i] = INF;
  }
  void dijkstra(int start){
    init();
    st = start;
    d[start]=0;
    que.push(p(0, start));
    while(!que.empty()){
      p p_now=que.top(); que.pop();
      ll v = p_now.second;
      if(d[v]<p_now.first) continue;
      for(int i=0;i<G[v].size();i++){
        edge e = G[v][i];
        if(d[e.to]>d[v]+e.cost){
          d[e.to]=d[v]+e.cost;
          pre[e.to] = v;
          que.push(p(d[e.to], e.to));
        }
      }
    }
  }
  vll get_path(int now){
    vll ret;
    while(now!=-1){
      ret.push_back(now);
      now = pre[now];
    }
    return ret;
  }
};
int main(int argc, char const *argv[]) {
  ll a, b, n, m;std::cin >> n >> m;
  Dijkstra dj(300000);
  re(i, m){
    std::cin >> a >> b;
    dj.insert(a, b, 1);
    dj.insert(b, a, 1);
  }
  dj.dijkstra(1);
  std::cout << (dj.d[n]==2?"POSSIBLE":"IMPOSSIBLE") << '\n';
}


Measured memory_bytes: 24416
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
using namespace std;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    int big = 0;
    big = min(a, b);

    int m = 0;
    m = n - a - b;

    if (m > 0)
    {
        cout << big << " " << 0;
    }
    else
    {
        cout << big << " " << -m;
    }

    return 0;
}


Measured memory_bytes: 256
def call(n):
    s = ""
    for i in range(1,n+1):
        if i%3 == 0:
            s += " {0}".format(i)
        else:
            x = i
            while x > 0:
               if x%10 == 3:
                   s += " {0}".format(i)
                   break
               x = x // 10
    print(s)
 
m = int(input())
call(m)

Measured memory_bytes: 7720
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
 
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
 
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,M,l,r,l1,r1,ans;
    l = 0;
    r = 1000000;
    cin >> N >> M;

    rep(i,M){
        cin >> l1 >> r1;

        if(l < l1)
            l = l1;
        if(r1 < r)
            r = r1;
    }
ans = r - l + 1;
if (ans < 0)
ans = 0;
cout << ans << endl;

}

Measured memory_bytes: 256
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]

h.sort()
min = h[-1] - h[0]
for i in range(n-k+1):
    if h[i+k-1] - h[i] < min:
        min = h[i+k-1] - h[i]

print(min)


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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

int n, m;
int a[100005];

int cx[100005], cy[100005];

bool gw(int d) {
    //printf("d=%d\n", d);
    FO(i,0,m) if (cy[i]-cx[i] == d) {
        bool w1 = gw(d+1);
        bool w2 = gw(d-1);
        if (w1 && w2) return false;
        else return true;
    } else {
        assert(i+1 != m);
        //printf("i=%d, %d,%d\n", i, cy[i]-cx[i], cy[i+1]-cx[i+1]);
        if (cy[i]-cx[i] > d && d > cy[i+1]-cx[i+1]) {
            int y = cy[i], x = cx[i+1];
            int l = abs((y-x)-d);
            if (l%2 == 0) {
                return false;
            } else {
                return true;
            }
        }
    }
    assert(false);
    return false;
}

int main() {
    scanf("%d", &n);
    FO(i,0,n) scanf("%d", a+i);
    sort(a,a+n);
    cx[m] = 0;
    cy[m] = n;
    m++;
    FO(i,0,n) {
        if (a[i] == cx[m-1]) {
            cy[m-1] = n-i-1;
        } else {
            cx[m] = a[i];
            cy[m] = n-i-1;
            m++;
        }
    }

    printf(gw(0) ? "First\n" : "Second\n");
}


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

signed main() {
    int n,q;
    string s;
    cin >> n >> s >> q;

    vector<set<int>> st(26);
    for(int i = 0; i < n; i++){
        int x = s[i] - 'a';
        st[x].insert(i);
    }

    while(q--){
        int t;
        cin >> t;

        if(t == 1){
            int itr;
            char ch;
            cin >> itr >> ch;

            itr--;
            int cur = s[itr] - 'a';
            int next = ch - 'a';

            st[cur].erase(itr);
            s[itr] = ch;
            st[next].insert(itr);
        } else if(t == 2){
            int l,r;
            cin >> l >> r;

            l--, r--;
            int tot = 0;
            for(int i = 0; i < 26; i++){
                auto itr = st[i].lower_bound(l);
                if(itr == st[i].end()) continue;
                if(*itr <= r) tot++;
            }
            cout << tot << endl;
        }
    }
}



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

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

    string s;
    cin>>s;

    if (s[2] == s[3] && s[4] == s[5])   cout<<"Yes\n";
    else                                cout<<"No\n";
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm, std.range, std.array, std.typecons, std.math;

void main() {
    long n, l;
    readf("%d %d\n", &n, &l);

    long s = l, e = l + n - 1;

    if (s < 0 && e < 0) {
        e--;
    }
    else if (0 < s) {
        s++;
    }

    writeln((e - s + 1) * (e + s) / 2);
}


Measured memory_bytes: 256
#import collections as c
#ip = lambda : map(int, input().split())

#################
K=int(input())
al = [int(i) for i in input().split()]

s,l = 2,2

if al[-1] != 2:
    print(-1)
    exit()
if K==1:
    print(s,l+al[0]-1)
    exit()

for i in range(K-1,-1,-1):
    c = 0
    # for j in range(s,l+al[i]-1+1):
    #     if j%al[i-1]==0:
    #         if c==0:
    #             s = j
    #         l = j
    #         c += 1
    if s%al[i-1]==0:
        tmps = s
    else:tmps = s + al[i-1] - s%al[i-1]
    if tmps <= l+al[i]-1:
        s = tmps
        c+=1
        l = (l+al[i]-1)//al[i-1]*al[i-1]

    if c==0:
        print(-1)
        exit()
    if i==1:
        print(s,l+al[0]-1)

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

const int N = 200005;

struct data {
	int c0;
	int c1;
	int id;

	inline bool operator < (const data &other) const {
		long long c = 1LL * c0 * other.c1 - 1LL * c1 * other.c0;
		if (c != 0) return c > 0;
		else return id > other.id;
	}
} a[N];

int n, p[N], v[N];
int dsu[N];

int anc(int p) { return p == dsu[p] ? p : dsu[p] = anc(dsu[p]); }
void join(int p, int q) { // p = anc(p), q = anc(q)
	if (p < q) swap(p, q); // p > q
	dsu[p] = q;
	a[q].c0 += a[p].c0; a[p].c0 = 0;
	a[q].c1 += a[p].c1; a[p].c1 = 0;
}

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

	multiset <data> ms;
	cin >> n;
	for (int i = 2; i <= n; ++i) {
		cin >> p[i];
	}
	for (int i = 1; i <= n; ++i) {
		cin >> v[i];
		a[i] = {v[i] == 0, v[i] == 1, i};
		if (i != 1) {
			ms.insert(a[i]);
		}
	}

	for (int i = 1; i <= n; ++i) dsu[i] = i; // init DSU

	long long inv = 0;
	while(!ms.empty()) {
		auto best = (*ms.begin());
		ms.erase(ms.begin());

		int id = best.id;
		int par = anc(p[id]);

		if (par != 1) ms.erase(ms.find(a[par]));

		inv += 1LL * a[par].c1 * a[id].c0;
		join(par, id);

		if (par != 1) ms.insert(a[par]);
	}

	printf("%lld\n", inv);
}

Measured memory_bytes: 17408
#include<iostream>
#include<algorithm>
using namespace std;
string word;
const int maxn = 200011;
int len, preb[maxn], baw[maxn];
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> len;
	cin >> word;
	preb[0] = word[0] == '#';
	for(int i = 1;i < len;++i){
		preb[i] = preb[i - 1] + (word[i] == '#');
	}
	for(int i = len - 1;i > -1;--i){
		baw[i] = baw[i + 1] + (word[i] == '.');
	}
	int ans = maxn;
	for(int i = 0;i < len;++i){
		ans = min(ans, preb[i] + baw[i + 1]);
	}
	cout << min(ans, baw[0]) << '\n';
}	


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }

int main()
{
  int n, k;
  cin >> n >> k;
  vi l(n);
  re(i, n) cin >> l[i];

  sort(l.begin(), l.end(), greater<int>());
  int s = 0;
  re(i, k) s += l[i];

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <cstring>
#include <algorithm>
#define INF 1<<29
int dp[1001][1001];

int main(void){

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

	int d[1000];
	for (int i = 0; i < n; i++)
		cin >> d[i];

	int c[1000];
	for (int i = 0; i < m; i++)
		cin >> c[i];

	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= m; j++)
			dp[i][j] = INF;
	}
	for (int i = 0; i <= m; i++) dp[0][i] = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++)
			dp[i][j] = min(dp[i][j - 1], dp[i - 1][j - 1] + d[i - 1] * c[j - 1]);
	}

	cout << dp[n][m] << endl;
}

Measured memory_bytes: 6248
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc146/tasks/abc146_d
 *
 */
public final class Main {

	private static Node[] nodes;
	private static int[][] edges;

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		nodes = new Node[n + 1]; // 0番目は空き
		edges = new int[n - 1][2]; // 辺の数はN-1

		for (int i = 0; i < n - 1; i++) {
			int parent = scanner.nextInt();
			int child = scanner.nextInt();
			edges[i][0] = parent;
			edges[i][1] = child;

			if (nodes[parent] == null) {
				nodes[parent] = new Node(); // 親なのにない場合は初出なので親なしで作る
			}
			nodes[parent].addChild(child);

			if (nodes[child] == null) {
				nodes[child] = new Node(parent);
			} else {
				// 子供なのに既出→親なしで作ったのでここで親をセット
				nodes[child].setParent(parent);
			}
		}

		int maxColor = 0;
		for (int i = 1; i < n; i++) {
			final int color = nodes[i].children.size() + (nodes[i].parent == 0 ? 0 : 1);
			if (color > maxColor) {
				maxColor = color;
			}
		}

		paint(nodes[1], 0, maxColor);

		System.out.println(maxColor);
		for (int i = 0; i < n - 1; i++) {
			System.out.println(nodes[edges[i][1]].parentColor);
		}
	}

	private static void paint(Node node, int parentColor, int maxColor) {
		node.parentColor = parentColor;

		final int childNum = node.children.size();
		int color = 1;
		for (int i = 0; i < childNum; i++) {
			if (color == parentColor) {
				color++;
			}
			node.childrenColors.add(color);
			paint(nodes[node.children.get(i)], color, maxColor);
			color++;
		}
	}

	private static final class Node {
		public int parent; // 0 is root
		public final List<Integer> children;
		public int parentColor;
		public final List<Integer> childrenColors;

		public Node() {
			this.parent = 0;
			this.children = new ArrayList<>();
			this.parentColor = 0;
			this.childrenColors = new ArrayList<>();
		}

		public Node(int parent) {
			this.parent = parent;
			this.children = new ArrayList<>();
			this.parentColor = 0;
			this.childrenColors = new ArrayList<>();
		}

		public void setParent(int parent) {
			this.parent = parent;
		}

		public void addChild(int child) {
			this.children.add(child);
		}

		public String toString() {
			return "[parent=" + parent + ", children=" + children + "]";
		}

	}

}


Measured memory_bytes: 105000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }


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

    // 方針：全探索
    // K <= 10^5 < 2^20 より，O(N * 20)で全探索できる
    double per = 0;
    rep(i, N) {
        double tmp = 1;
        rep(j, 20) {
            if((i+1) * tmp >= K) {
                per += (double)1/N * 1/tmp;
                break;
            }
            tmp *= 2;
        }
    }

    print(fixed << setprecision(12) << per);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;

  set<Int> used;
  used.insert(N);
  if(N % (N - 1)  == 1) used.insert(N - 1);

  auto calc = [&](Int x){
    if(x == 0 || x == 1) return;
    Int tmp = N;
    while(tmp % x == 0) tmp /= x;
    if(tmp % x == 1) used.insert(x);
  };

  for(Int i=2;i * i <= N;i++){
    Int a = i;
    Int b = N / i;
    calc(a);
    calc(b);
  }

  Int ans = used.size();
  prArr(used);
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
import math
import copy

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# inputb = input().split()
# inputbList = [int(x) for x in inputb]

# x = int(inputb[0])
# y = int(inputb[1])

inputList=[]
for i in range(a):
    inputNum = input()
    # inputNum = [int(x) for x in inputNum]
    inputList.append(int(inputNum))

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

max = max(inputList)

sum = 0
for i in range(a):
    sum += inputList[i]

print(int(sum - max/2))



Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iomanip>

using namespace std;

void solve(){
    int n, sqsum=0;

    cin >> n;
    vector<int> x(n);
    for(int i=0; i<n; i++) cin >> x[i];

    int p = round((double)accumulate(x.begin(), x.end(), 0) / n);

    for(auto e: x){
        sqsum += (e - p) * (e - p);
    }

    cout << sqsum << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 256
nn, qq = gets.split.map(&:to_i)
events = []
temp = []
1.step(nn, 1) do |_i|
  temp = gets.split.map(&:to_i)
  next if temp[1] - temp[2] <= 0
  x = temp[0] - temp[2]
  x = x > 0 ? x : 0

  events.push([temp[1] - temp[2], 1, temp[2]])
  events.push([temp[0] - temp[2], 0, temp[2]])
end
1.step(qq, 1) do |i|
  events.push([gets.to_i, 2, i])
end
events.sort_by!(&:first)

class Heap
  def initialize
    @a = [nil]
    @h = {}
  end

  def swap(i, j)
    @a[i], @a[j] = @a[j], @a[i]
    @h[@a[i]], @h[@a[j]] = i, j
  end

  def up(i)
    while i >= 2
      p = i >> 1
      return if @a[p] <= @a[i]
      swap(i, p)
      i = p
    end
  end

  def down(i)
    a = @a.size
    while (c = i << 1) < a
      c += 1 if c != a - 1 && @a[c] > @a[c + 1]
      return if @a[i] <= @a[c]
      swap(i, c)
      i = c
    end
  end

  def add(v)
    return if @h[v]
    @a << v
    i = @a.size - 1
    @h[v] = i
    up(i)
  end

  def delete(v)
    return unless i = @h[v]
    u = @a[-1]
    swap(i, -1)
    ret = @a.pop
    @h[ret] = nil
    v > u ? up(i) : down(i)
    ret
  end

  def first
    @a[1] || -1
  end
end

ss = Heap.new
ans = []

events.each do |event|
  if event[1] == 0
    ss.add(event[2])
  elsif event[1] == 1
    ss.delete(event[2])
  else
    ans[event[2]] = ss.first
  end
end

puts ans[1..-1]

Measured memory_bytes: 68856
#include <bits/stdc++.h> 
#define ll long long
#define F first
#define FF first.first
#define FS first.second
#define S second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e16;
 
ll n, q=1, m, a[N], b[N], f[N], o, k, t, x, y, z, u, h, mx, mn, ans, Ans;
pair<ll,ll> p[N];
string s;
vector<int> v[N];
 
main(){ios_base::sync_with_stdio(false), cin.tie(0);
   	
//	cin>>q;
   	
   	while(q--){ans=o=0,u=100;
   		cin>>n;
   		while(u<n){
   			u+=(u/100);ans++;
		}
		cout<<ans;
	}
	
}

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

using namespace std;

int main(){
  int n;
    cin >> n;
    for (int i = 1; i <= min(n, 9); i++){
        if (n / i < 10 && !(n % i)){
            cout << "Yes";
            return 0;
        }
    }
  cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,l,r;
long long s[500003],t;
int main()
{
	scanf("%lld %lld %lld", &n, &l, &r);
	for (int i=1;i<=r;i++)
	{
		s[i]=r-i+1;
	}
	long long lastsum=n-r-(l-1);
	if (lastsum<0||l==0||r==0||lastsum>((l-1)*(r-1)))
	{
		// printf("case2\n");
		printf("-1\n");
		return 0;
	}
	t=r;
	// printf("%lld\n",lastsum);
	for (int i=r;i<=n;)
	{
		for (int j=1;j<=min(r,lastsum+1);j++)
		{
			s[i+1]=s[i]-1;
			i++;
			if (j==1)
			{
				s[i]=t+min(r,lastsum+1);
/*				if (s[i]>n)
				{
					// printf("-1\n");
					// return 0;
				}*/
				t=s[i];
			}
		}
		lastsum-=min(r-1,lastsum);
	}
	if (lastsum>0)
	{
		// printf("case3\n");
		printf("-1\n");
		return 0;
	}
	for (int i = 1; i <= n; ++i)
	{
		printf("%lld ",s[i]);
	}
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        ans += s[i]=='+' ? 1 : -1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))+[0]
ans = 1000
money = 1000
kabu = 0
for i in range(N):
    if A[i+1] > A[i]:
        hoge = money//A[i]
        money -= hoge*A[i]
        kabu += hoge
    else:
        money += A[i]*kabu
        kabu = 0
        ans = max(money,ans)

print(ans)

Measured memory_bytes: 9192
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
const int maxn=200010,inf=0x3f3f3f3f;
int a[maxn],n,logs[maxn],d[2][maxn][30],pos[maxn];
struct cyc{
    int l,r,x;
    bool operator <(const cyc &a)const
    {return x>a.x;}
};
priority_queue<cyc>q;

void RMQ_INIT(int k){
    for(int j=1;(1<<j)<=n;j++)
        for(int i=1;i+(1<<j)-1<=n;i++)
            d[k][i][j]=min(d[k][i][j-1],d[k][i+(1<<(j-1))][j-1]);
}
int rmq(int l,int r,int k){
    int K=logs[r-l+1]; 
     return min(d[k][l][K],d[k][r-(1<<K)+1][K]);
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        d[i&1][i][0]=a[i];//1奇数 
        d[(i&1)^1][i][0]=inf;//0偶数 
        pos[a[i]]=i;//因为是排列可以直接记位置，省去RMQ的位置记录。 
    }
    logs[0]=-1;for(int i=1;i<=n;i++)logs[i]=logs[i>>1]+1;
    RMQ_INIT(0);RMQ_INIT(1);
    q.push((cyc){1,n,rmq(1,n,1)});
    int L,R,p1,p2;
    while(!q.empty()){
        cyc x=q.top();q.pop();
        L=x.l;R=x.r;p1=pos[x.x];
        p2=pos[rmq(p1+1,R,(p1&1)^1)];
        printf("%d %d ",a[p1],a[p2]);
        if(L<p1)q.push((cyc){L,p1-1,rmq(L,p1-1,(L&1))});
        if(p1<p2-1)q.push((cyc){p1+1,p2-1,rmq(p1+1,p2-1,(p1+1)&1)});
        if(p2<R)q.push((cyc){p2+1,R,rmq(p2+1,R,(p2+1)&1)});
    }
    return 0;
}

Measured memory_bytes: 51320
#include <stdio.h>

int main()
{
  int a[100], i, j, tmp;

  for (i = 0; i < 3; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 0; i < 3; i++) {
    for (j = i + 1; j < 3; j++) {
      if (a[i] > a[j]) {
        tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
  printf("%d %d %d\n", a[0], a[1], a[2]);
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define RREP(i, a, b) for (int i = int(a) - 1; i >= int(b); i--)
#define sz(x) (int)(x).size()

using namespace std;
using ll = long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  vector<pair<char, ll>> p;
  ll Lcount = 0, Rcount = 0;
  rep(i, sz(s)) {
    if (s[i] == 'R') {
      if (Lcount > 0) {
        p.push_back(make_pair('L', Lcount));
        Lcount = 0;
      }
      Rcount++;
    } else {
      if (Rcount > 0) {
        p.push_back(make_pair('R', Rcount));
        Rcount = 0;
      }
      Lcount++;
    }
  }
  if (Rcount > 0) {
    p.push_back(make_pair('R', Rcount));
  } else if (Lcount > 0) {
    p.push_back(make_pair('L', Lcount));
  }

  queue<ll> q;
  for (int i = 0; i < sz(p); i += 2) {
    ll r = p[i].second - p[i].second / 2;
    ll l = p[i + 1].second - p[i + 1].second / 2;
    q.push(r + p[i + 1].second / 2);
    q.push(l + p[i].second / 2);
  }
  rep(i, sz(s)) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      cout << q.front() << " ";
      q.pop();
      cout << q.front() << " ";
      q.pop();
      i++;
    } else {
      cout << 0 << " ";
    }
  }
  cout << endl;
}

Measured memory_bytes: 2928
#include<cstdio>
#include<map>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
  string t="a",s="aa";
  map<string,bool>m;
  cout<<"?"<<t<<s<<t<<endl;
  string in;
  while(1){
    cin>>in;
    fflush(stdout);
    if(m[in]||in[0]!='a')break;
    m[in]=true;
    s[1]++;
    if(s[1]=='z'+1){
      s[0]++;
      s[1]='a';
    }
    t=in[in.size()-1];
    cout<<"?"<<t<<s<<"a"<<endl;
  }
  cout<<"!OUT"<<endl;
}

Measured memory_bytes: 1260
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	
	for (ll i = 0; i < n; i++) {
		ll t; cin >> t;
		if (t % 2 == 0 && t % 5 != 0 && t % 3 != 0) {
			cout << "DENIED\n";
			return 0;
		}
	}
	cout << "APPROVED\n";

	return 0;
}

/*
3
0 1
3 0
1 0
*/

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

int main() {

  int N;
  cin >> N;

  bool answer = false;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == N) {
        answer = true;
      }
    }
  }

  if (answer) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
#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>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef vector<pair<int, int> > VPII;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(), c_end=c.end(); it!=c_end; ++it)

// ------------------- include, typedef, define END. -------------------

void solveAndOutput(const VI &visitorAge){
	VI ageList(7, 0);
	FOR(i, 0, visitorAge.size()){
		int temp = visitorAge[i] / 10;
		if (temp >= 7)
			temp = 6;
		ageList[temp]++;
	}
	FOR(i, 0, ageList.size()){
		cout << ageList[i] << endl;
	}
}

int main(){
	fastIO;
	int n,temp=0;
	while (cin >> n,n){
		VI visitorAge;
		visitorAge.reserve(n);
		while (n--){
			cin >> temp;
			visitorAge.push_back(temp);
		}
		solveAndOutput(visitorAge);
	}
	return 0;
}

Measured memory_bytes: 4896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 1000000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

const int	MAX_N = 600010;

int N;
int dat[2*MAX_N-1];

//初期化
void init(int n_)
{
	N=1;
	while(N<n_) N*=2;
	rep(i, 2*N-1) dat[i]=0;
}

//k番目の値(0-indexed)をaに更新
void update(int k, int a)
{
	k+=N-1;
	dat[k]=a;
	while(k>0)
	{
		k=(k-1)/2;
		dat[k]=min(dat[k*2+1], dat[k*2+2]);
	}
}

//[a, b)の最小値を求める
//節点kは[l, r)に対応
int query_(int a, int b, int k, int l, int r)
{
	if(r<=a || b<=l) return 0;
	else if(a<=l && r<=b) return dat[k];
	else
	{
		int vl=query_(a, b, k*2+1, l, (l+r)/2);
		int vr=query_(a, b, k*2+2, (l+r)/2, r);
		return min(vl, vr);
	} 
}

int query(int a, int b)
{
	return query_(a, b, 0, 0, N);
}



int main()
{
	int n, k; cin >> n >> k;
	init(300001);
	rep(i, n)
	{
		int a;
		cin >> a;
		update(a, query(a-k, a+k+1)-1);
	}
	cout << -query(0, 300010) << endl;
	return 0;
}

Measured memory_bytes: 7732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll N,K;
double theta;
double calc(int a,int b,int c){
	return (sin(a*theta)+sin(b*theta)+sin(c*theta))/2;
}
ll count(double s){
	ll ret=0;
	rep1(a,N-2){
		int lef=N-a;
		double ac=(2*s-sin(a*theta))/2.0/sin(lef*theta/2);
		int tmp=0;
		if(ac>=1){
			tmp=lef-1;
		}else if(ac<-1){

		}else{
			double t=acos(ac);
			int x=ceil(t/theta+lef/2.0);
			if(x<lef) tmp=(lef-x)*2;
		}
		ret+=tmp;
		// int ub=lef,lb=lef/2;
		// while(ub-lb>1){
		// 	int m=(ub+lb)/2;
		// 	if(calc(a,m,lef-m)<=s) ub=m;
		// 	else lb=m;
		// }
		// int cnt=(lef-ub)*2;
		// if(lef%2==0) if(calc(a,lef/2,lef/2)<=s) cnt++;
		// ret+=cnt;
	}
	return ret*2;
}
int main(){
	cin>>N>>K;
	theta=2*3.141592653589793238/N;
	K=(K-1)*6/N;
	double ub=1.3,lb=0;
	rep(tt,40){
		double m=(ub+lb)/2;
		if(count(m)>K) ub=m;
		else lb=m;
	}
	printf("%.12f\n",ub);
}


Measured memory_bytes: 256
/* Arpit Pandey*/ 

#include <bits/stdc++.h>
#include <stdlib.h>
#include <stdint.h>
using namespace std;
 
#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define test(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;
 
void fast_io()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("error.txt", "w", stderr);
	freopen("output.txt", "w", stdout);
#endif
}

void sol()
{
	string n; cin>>n;
	int sum=0;
	for(int i=0;i<(int)n.length();i++)
	{
		sum+=n[i]-'0';
	}
	if(sum%9)
		cout<<"No";
	else
		cout<<"Yes";

}

int32_t main()
{
	fast_io();
	//test(t)
	sol();
	//cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3704
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  int N;
  string S,T,ans;
  cin>>N>>S>>T;
  
  REP(i,N){
    cout<<S.at(i);
    cout<<T.at(i);
  }
  
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int main(void){
   string S;
   cin>>S;
   map<char,int> cnt;
   for(int i=0;i<S.size();i++){
      cnt[S[i]]++;
   }
   if(abs(cnt['a']-cnt['b'])<=1&&abs(cnt['b']-cnt['c'])<=1&&abs(cnt['c']-cnt['a'])<=1){
      cout<<"YES"<<endl;
   }else{
      cout<<"NO"<<endl;
   }
   return 0;
}


Measured memory_bytes: 512
def main():
    n, k = map(int, input().split())
    counts = [0] * 100001

    for _ in range(n):
        a, b = map(int, input().split())
        counts[a] += b

    for i in range(1, 100001):
        if k <= counts[i]:
            print(i)
            break
        k -= counts[i]


if __name__ == '__main__':
    main()


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

int main() {
  int n, k;
  cin >> n >> k;
  if (k > (n - 1) * (n - 2) / 2) {
    cout << -1 << endl;
    return 0;
  }
  vector<vector<int>> g(n);
  for (int i = 1; i < n; i++) {
    g[0].push_back(i);
  }
  int m = n - 1;
  int sum = (n - 1) * (n - 2) / 2;
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (sum == k) break;
      g[i].push_back(j);
      sum--;
      m++;
    }
  }
  cout << m << endl;
  for (int i = 0; i < n; i++) {
    for (auto j : g[i]) {
      cout << i + 1 << ' ' << j + 1 << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int a, b;
	cin >> a >> b;
	int ans = a + b;
	if (ans < 10) {
		cout << ans << endl;
	}
	else {
		cout << "error" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    int a, b; cin >> a >> b;
    vector<int> wrongs(3, 0);
    wrongs[--a]++;
    wrongs[--b]++;

    for (int i=0; i<3; i++) {
        if (wrongs[i] == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}



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

#define int long long
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 
#define LL_MAX 9223372036854775807

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    string s,t,u="";
    cin >> n;
    cin >> s;
    cin >> t;
    rep(i,n) {
        u+=(s[i]);
        u+=(t[i]);
    }

    cout << u << '\n';


    return 0;
    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int h,a;cin>>h>>a;

    cout<<(h+a-1)/a<<"\n";

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; string S; cin >> N >> S;
    int alphabets[N + 1][26] = {};
    REP(i, 0, N) {
        REP(j, 0, 26) {
            alphabets[i + 1][j] = alphabets[i][j] + ((S[i] - 'a') == j);            
        }
    }

    int ans = 0;
    REP(i, 0, N) {
        int count = 0;
        REP(j, 0, 26) if (alphabets[i + 1][j] > 0 && alphabets[N][j] - alphabets[i + 1][j] > 0) count++;
        ans = max(ans, count);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect

N = int(input())

An = sorted(map(int, input().split()))
Bn = map(int, input().split())
Cn = sorted(map(int, input().split()))


def main():
    print(sum(bisect.bisect_left(An, Bi)
              * (N - bisect.bisect(Cn, Bi)) for Bi in Bn))

    return


main()


Measured memory_bytes: 26656
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int k;
  int a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

ll gcd(ll x, ll y)
{
    while (y > 0)
    {
        ll tmp = y;
        y = x % y;
        x = tmp;
    }
    return x;
}

ll lcm(ll x, ll y)
{
    return x / gcd(x, y) * y;
}

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    ll t;
    cin >> t;
    for (ll i = 0; i < n-1; i++)
    {
        ll p;
        cin >> p;
        t = lcm(t, p);
    }
    cout << t << endl;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,c,k = readline() |> split |> parseMap
	t = zeros(Int,n)
	for i in 1:n
		t[i] = readline() |> parseInt
	end
	t = sort(t)
	ct = 1
	lk = 0
	now = t[1]
	for i in 1:n
		if now+k<t[i]||lk>=c
			ct += 1
			lk = 1
			now = t[i]
		else
			lk+=1
		end
	end
	println(ct)
end

main()

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

int N, W;
int w[110], v[110];

long long dp[100009];

void chmax(long long &a, long long b) {
    if(a < b) a = b;
}

int main() {
    cin >> N >> W;
    for(int i = 0; i < N; i++)
        cin >> w[i] >> v[i];

    for(int i = 0; i < N; i++)
        for(int j = W; j >= w[i]; j--)
            chmax(dp[j], dp[j - w[i]] + v[i]);

    cout << dp[W] << endl;

    return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict
(n, m), *q = [[*map(int, i.split())] for i in open(0)]
d = defaultdict(list)
for k, v in q:
    d[k].append(v)
c = defaultdict(dict)
for k, v in d.items():
    for i, j in enumerate(sorted(v)):
        c[k][j] = i + 1
for p, y in q:
    print("{:0>6}{:0>6}".format(p, c[p][y]))


Measured memory_bytes: 75648
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
    cin>>a>>b>>c;
    for(int i=1;i<=b;i++){
        if((a*i)%b==c){
		    cout<<"YES"<<endl;
			return 0;
		}
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import functools
N, C = map(int, input().split())
P = [[0 for c in range(C)] for i in range(10 ** 5 + 1)]
T = 0
for i in range(N):
  s, t, c = map(int, input().split())
  T = max(t, T)
  for j in range(s - 1, t):
    P[j][c - 1] = 1
ans = 0
for p in P[:T + 1]:
  ans = max(sum(p), ans)
print(ans)

Measured memory_bytes: 40804
#include<bits/stdc++.h>
using namespace std;
long long n,m;
long long d[100001];
long long c[100001];
long long f[100001];
long long ans=1e9+2;
int main(){
	cin>>m>>n;
	for(long long i=0;i<n;i++){
		cin>>d[i]>>c[i];
	}
	f[0]=0;
	for(long long i=1;i<=99999;i++){
		f[i]=1e9+2;
		for(long long j=0;j<n;j++){
			if(i-d[j]>=0){
				f[i]=min(f[i],f[i-d[j]]+c[j]);
			}
		}
		if(i>=m){
			ans=min(ans,f[i]);
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


void solve(long long N, std::vector<long long> A){
    ll ans = 0;
    vector<ll> p(1000006);
    rep(i,N){
        if(p[A[i]]) {
            p[A[i]] = 2;
            continue;
        }

        for(int j = A[i]; j < 1000006; j += A[i]){
            p[j] += 1;
        }
    }

    rep(i,N){
        if(p[A[i]] == 1) ans++;
    }
    
    cout << ans << endl;

}

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


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

int main()
{
    long long x; cin >> x;

    if (x % 11 == 0)
    {
        cout << (x / 11) * 2 << endl;
    }
    else if (x % 11 <= 6)
    {
        cout << (x / 11) * 2 + 1 << endl;
    }
    else
    {
        cout << (x / 11) * 2 + 2 << endl;
    }
    return 0;
}


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

int main() {
    int n, a, b, ans;
    b = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        if (a % 2 == 0) b *= 2;
    }
    ans = pow(3, n) - b;
    cout << ans << endl;
    return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    double r;
    cin>>r;
    double PI=acos(-1);
    double ans=2*r*PI;
    printf("%.3lf\n",ans);
    return 0;

}
/*


*/


Measured memory_bytes: 3776
//コンパイラ最適化用
#pragma GCC optimize("O3")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#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(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<stdio.h>

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int n,i;int d[4]={0};char s[3];
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%s\n",s);
        if(s[0]=='A'){
            d[0]++;
        }else if(s[0]=='W'){
            d[1]++;
        }else if(s[0]=='T'){
            d[2]++;
        }else{
            d[3]++;
        }
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",d[0],d[1],d[2],d[3]);
    return 0;
}

Measured memory_bytes: 3840