akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read();
    if(n>=30)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main(){
    int A,B,C,K; cin>>A>>B>>C>>K;
 
    if(K<=A){
        cout<<K<<endl;
    }else if(K<=A+B){
        cout<<A<<endl;
    }else{
        cout<<A-(K-A-B)<<endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>
#include <iterator>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    if (a == 1) {
        return b;
    }
    else {
        return b / a * (a - 1);
    }
}

int main()
{
    IO;

    ll m; cin >> m;

    p.push_back(2);
    for (ll n = 3; n <= sqrt(1000000000); ++n) {
        for (ll k = 0; k != p.size(); ++k) {
            if (n % p[k] == 0) { goto xyz; }
            if (p[k] > sqrt(n)) { break; }
        }
        p.push_back(n);
    xyz:;
    }

    cout << phi(m) << endl;

}


Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>

using namespace std;
using ll = long long;
const int BIG = 100000007;


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

    ll a = 262144 * 2;
    vector<ll> de(a + 1,-1);
    ll i = 2;
    ll k = 2;

    ll total = confidences[0];

    de[0] = confidences[0];
    de[a / k] = confidences[1];
    de[a] = confidences[0];

    k *= 2;

    while (i < n){
        for(ll t = a / k;t <= (a / k) * (k - 1);t += (a / (k / 2))){
            if(i == n)break;
            de[t] = confidences[i];
            ll bef = t - (a / k);
            ll aft = t + (a / k);
            //cout << "insert:" << de[t] << "/between -> " <<  de[bef] << "," << de[aft] << endl;
            total += min(de[bef],de[aft]);
            ++i;
        }
        k *= 2;
    }

    /*
    vector<ll> result;
    for(ll i = 0;i <= a;++i){
        if(de[i] >= 0)result.push_back(de[i]);
    }


    for(ll i = 0;i < n;++i){
        cout << result[i] << ' ';
    }

    cout << endl;
     */

    cout << total << endl;
}




Measured memory_bytes: 8420
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int ans = 0;

    for (int i = 0; i < 3; i++) {
      if (s.charAt(i) == t.charAt(i)) {
        ans++;
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 35784
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int lcs(string X, string Y)
{
	static int Z[1001][1001];
	int m = X.size();
	int n = Y.size();
	int i, j;

	for (i = 1; i <= m; i++) {
		for (j = 1; j <= n; j++) {
			if (X[i - 1] == Y[j - 1])
				Z[i][j] = Z[i - 1][j - 1] + 1;
			else
				Z[i][j] = max(Z[i - 1][j], Z[i][j - 1]);
		}
	}
	return Z[m][n];
}

int main()
{
	string X, Y;
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> X >> Y;
		cout << lcs(X, Y) << endl;
	}
	return 0;
}

Measured memory_bytes: 5128
n = int(input())
list_a = list(map(int, input().split()))
list_b = list(map(int, input().split()))
list_c = list(map(int, input().split()))
 
b_sum = sum(list_b)
 
satis = 0
for i in range(n-1):
  if list_a[i+1] == list_a[i] + 1:
    satis += list_c[list_a[i]-1]
 
result = b_sum + satis

print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100

int N,M;
int boss[NUM],height[NUM],member_num[NUM];
int len_num[NUM+1];
bool check[NUM];

//自分のボスのindexを取得しつつ、経路圧縮を行う関数
int get_boss(int id){
	if(boss[id] == id)return id; //自分が代表なら、自分の値を返す
	else{
		return boss[id] = get_boss(boss[id]); //代表でないなら、自分が所属する組織の代表を返しつつ、経路圧縮
	}
}

int is_same_group(int x,int y){
	return get_boss(x) == get_boss(y);
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	//既に同じグループなら何もしない
	if(boss_x == boss_y)return;

	//高さが高い方に吸収する
	if(height[x] > height[y]){

		member_num[boss_x] += member_num[boss_y];
		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		member_num[boss_y] += member_num[boss_x];
		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		member_num[boss_x] += member_num[boss_y];
		boss[boss_y] = boss_x;
		height[x]++;
	}
}

int main(){

	scanf("%d %d",&N,&M);

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

		boss[i] = i;
		height[i] = 0;
		member_num[i] = 1;

		check[i] = false;
		len_num[i+1] = 0;
	}

	int start,len;

	for(int loop = 0; loop < M; loop++){

		scanf("%d %d",&start,&len);
		check[(start)%N] = true;

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

			check[(start+i)%N] = true;
		}
	}

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

		if(check[i] == true && check[(i-1+N)%N] == true){

			unite(i,(i-1+N)%N);
		}
	}

	for(int i = 0; i < N; i++){
		if(check[i] == true && i == get_boss(i)){

			len_num[member_num[i]] += 1;
		}
	}

	for(int i = N; i >= 1; i--){
		if(len_num[i] == 0)continue;

		printf("%d %d\n",i,len_num[i]);
	}

	return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int P, Q, R;
    cin >> P >> Q >> R;
    
    int p_sum = P + Q + R;
    int ans = p_sum-P;
    ans = min(ans, p_sum-Q);
    ans = min(ans, p_sum-R);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template <typename T>
struct SegmentTree {
    int n;
    vector<T> node;
    T calc(T a, T b) {
        // return a + b;
        // return min(a, b);
        return max(a, b);
    }
    T e = 0ll;
    SegmentTree(vector<T> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, e);
        for (int i = 0; i < sz; i++) {
            node[i + n - 1] = v[i];
        }
        for (int i = n - 2; i >= 0; i--) {
            node[i] = calc(node[2 * i + 1], node[2 * i + 2]);
        }
    }
    SegmentTree(T sz) {
        n = 1;
        while (n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, e);
    }
    void update(int x, T val) {
        x = n + x - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = calc(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    void add(int x, T val) {
        x = n + x - 1;
        node[x] += val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = calc(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return e;
        if (a <= l && r <= b) return node[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return calc(vl, vr);
    }
    T at(int x) {
        return node[n + x - 1];
    }
};
int main() {
    int n;
    cin >> n;
    vector<ll> a(n), v(n);
    rep(i, n) {
        cin >> a[i];
        v[i] = a[i];
    }
    sort(all(v));
    get_unique(v);
    rep(i, n) a[i] = lower_bound(all(v), a[i]) - v.begin();
    SegmentTree<ll> segt(100100);
    vector<ll> dp(n + 1);
    rep(i, n) {
        chmax(dp[a[i]], segt.query(0, a[i]) + 1);
        segt.update(a[i], dp[a[i]]);
    }
    ll ans = 0;
    rep(i, n) chmax(ans, dp[a[i]]);
    cout << ans << endl;
}


Measured memory_bytes: 7380
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main(){
  int x;
  cin>>x;
  int m=0;
  int a=0;
  if(x==1){
    cout<<"1"<<endl;
    return 0;
  }
  for(int i=2;i<=x;i++){
    int j=2;
    while((a=pow(i,j))<=x){
      if(a>m){m=a;}
      j++;
      
    }
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 888
import numpy as np

N = input()
inp = str(input())

I = list(inp)

l = set(I)

s = {'P','W','G','Y'}

if len(l & s) == 0:
    print('Zero')
elif len(l & s) == 1:
    print('One')
elif len(l & s) == 2:
    print('Two')
elif len(l & s) == 3:
    print('Three')
elif len(l & s) == 4:
    print('Four')


Measured memory_bytes: 12388
#!/usr/bin/env python2
# coding: utf-8

def casar(s, n):
  d = {}
  for c in (65, 97):
    for i in range(26):
      d[chr(i+c)] = chr((i+n) % 26 + c)

  return "".join([d.get(c, c) for c in s])

while True:
  try:
    encrypttxt = raw_input()
    for i in range(26):
      t = casar(encrypttxt, i)
      if  "the" in t or "this" in t or "that" in t:
        print t

  except EOFError:
    break

Measured memory_bytes: 6260
/*
*         ****FOX****
*/
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <limits>
//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#include <utility>
#include <list>
#include <cstdio>
#include<forward_list>
#include<algorithm>
#include<string>
#define Omar_Hafez ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.1415926536
#define ll long long
#define ull unsigned long long
#define lli long long int
using namespace std;
int main()
{
    Omar_Hafez
   int n; cin >> n;
    vector<int> v(n,0); 
    for (int i = 1; i < 300; i++)
    {
        for (int j = 1; j < 300; j++)
        {
            for (int z = 1; z < 300; z++)
            {
                int res = (i * i) + (j * j) + (z * z) + (i * j) + (j * z) + (i * z);  
                if (res <= n)  v[--res]++;
                else break;
            }
        }
    }
    for (int i = 0; i< v.size(); i++) cout << v[i] << "\n";
    return 0;
}


Measured memory_bytes: 3536
#include"iostream"
#include"vector"
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}
	int check ,ans= 0;

	for (int i = 0; i < n - 1; i++)
	{
		if (a.at(i) == a.at(i + 1) && check == 0)
		{
			ans++;
			check = 1;
		}
		else
		{
			check = 0;
		}
	}
	cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  if (N % 1000 % 111 == 0)
    cout << "Yes" << endl;
  else if (N / 10 % 111 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

S = input()
T = input()

S_dic = defaultdict(list)
T_dic = defaultdict(list)

for i in range(len(S)):
	S_dic[S[i]].append(i)
	T_dic[T[i]].append(i)

if sorted(S_dic.values()) == sorted(T_dic.values()):
	print("Yes")
else:
	print("No")

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

struct Point {
    int x, y;
};

int main() {
    int n;
    std::cin >> n;

    auto points = std::vector<Point>(n, Point());

    for(int i = 0; i < n; ++i) {
        std::cin >> points[i].x >> points[i].y;
    }

    // each path a_i -> a_j appeares (n - 1)! times.
    // because point pair (a_i, a_j) can be regarded one element and
    // with other points a_k (k != i, j), there are n - 1 elements.
    // inversed path a_j -> a_i also appeares.
    // so each distance appeares (n - 1)! * 2 times. thus
    // result = sum * (n - 1)! * 2 / n!
    //        = sum * 2 / n

    long double sum = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            const auto x1 = points[i].x;
            const auto y1 = points[i].y;
            
            const auto x2 = points[j].x;
            const auto y2 = points[j].y;

            const long double dx = x1 - x2;
            const long double dy = y1 - y2;

            sum += std::sqrt(dx * dx + dy * dy);
        }
    }

    const long double result = sum * 2 / n;

    std::cout << std::fixed << std::setprecision(10);
    std::cout << result;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int N;
    cin >> N;
    long long a[N];
    int ns = 0;
    int ts = 0;
    int fs = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        if(a[i] % 4 == 0){
            fs++;
        }else if(a[i] % 2 == 0){
            ts++;
        }else{
            ns++;
        }
    }
    if(ts == N){
        cout << "Yes" << endl;
        return 0;
    }
    if(ts == 0){
        if(ns <= fs+1){
            cout << "Yes" << endl;
            return 0;

        }
    }else{
        if(ns <= fs){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int p,y,w,g;
  p = 0;
  y = 0;
  w = 0;
  g = 0;
  
  for (int i = 0; i < N; i++){
    string x;
    cin >> x;
          
    if (x == "P") p = 1;
    else if (x == "Y") y = 2;
    else if (x == "W") w = 4;
    else g = 8;
  }
  int sum = p + y + w + g;
  if (sum ==15) cout << "Four" << endl;
  if (sum == 7 || sum == 14 || sum == 13 || sum == 11) cout << "Three" << endl;
}




Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    vector<int> s(3);
    REP(i, 3) cin >> s[i];
    if (s[0] == s[1]) cout << s[2] << endl;
    else if (s[1] == s[2]) cout << s[0] << endl;
    else cout << s[1] << endl;
    //cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
//const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
/*signed*/int main(void) {
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())


int mem[1000000];
int ans[1000000];

int main(int argc, char const *argv[])
{
	int max_num = 1000000;
	int loop_max = sqrt(1000000);
	memset(mem, 0, 1000000);
	for (int i = 2; i < loop_max; i++)
	{
		int c = i * 2;
		while(c < max_num)
		{
			mem[c] = 1;
			c+= i;
		}
	}
	int n;
	int sum = 0;
	ans[0] = ans[1] = 0;
	for (int i = 2; i < max_num; i++)
	{
		sum += mem[i] ? 0 : 1;
		ans[i] = sum;
	}
	while(scanf("%d", &n) != EOF)
	{
		printf("%d\n", ans[n]);
	}
	return 0;
}

Measured memory_bytes: 10932
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
#include <cstdarg>
#include <sstream>
#include <functional>
using namespace std;

int const MAX_N = 512 * 1024;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a,b)<<" "<<max(0, (a + b - n));
	return 0;
}


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

/////////////////////////////////////////////////////////

vector < ll > lst;
string str;

ll calculate(){
	ll ret = 0;
	FOR(i,lst.size()){
		ret += lst[i];
	}
	return ret;
}

ll ans;

void solve(int idx){
	if(idx == (int)str.length()){
		ans += calculate();
		return;
	}
	ll val = 0;
	REP(i,idx,str.length()-1){
		val *= 10;
		val += str[i]-'0';
		lst.PB(val);
		solve(i+1);
		lst.POB();
	}
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> str;
	ans = 0;
	solve(0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// AtCoder Contest 100
// C - Linear Approximation
#include <cstdio>
#include <algorithm>
const int MAXN = 200005;
 
int N;
int A[MAXN];
 
int main() {
	using std::abs;
	scanf("%d", &N);
	int i;
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		A[i] -= i + 1;
	}
	std::sort(A, A + N);
	int b;
	long long ans = 0;
	b = A[N >> 1];
	for (i = 0; i < N; i++) ans += (long long)abs(A[i] - b);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 896
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define ll long long

const unsigned long long MAXN = (int)3e5 + 5;
const int MAXI = (int)2e9;
const int K = 3;

int main(){
    ll n,sz;cin >> n >> sz;
    vector<ll> dp(MAXN, 0);
    for (int i = 1;i <= n;i ++) {
        int w,v;cin >> w >> v;
        for (ll have = sz - w;have >= 0;have --) {
            dp[have + w] = max(dp[have + w], dp[have] + v);
        }
    }
    ll ans = 0;
    for (int i = 1;i <= sz;i ++)
        ans = max(ans, dp[i]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
using namespace std;
const int N = 3e5 + 500;
int cnt[N];
int main(){
	long long a, b, c;
	cin >> a >> b >> c;
	long long d = c - a - b;
	if(4 * a * b < d * d && d > 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

using namespace std;

long long solve(const vector<int> data, int sign) {
    
    int n = data.size();
    vector<int> a = data;
    
    long long sum = 0;
    long long result = 0;
    for(int i=0; i<n; i++) {
        if(i%2==0) {
            long long delta = (sum + a[i]) * sign;
            if(delta <= 0) {
                result += -delta + 1;
                a[i] += (-delta + 1) * sign;
            }
        }
        else {
            long long delta = (sum + a[i]) * sign;
            if(delta >= 0) {
                result += delta + 1;
                a[i] -= (delta + 1) * sign;
            }
        }
        sum += a[i];
    }
    return result;
}


int main(void){

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    
    cout << min(solve(a, 1), solve(a, -1)) << endl;
    
    return 0;
    
}


Measured memory_bytes: 1796
n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353
dp = [[0] * (s + 1) for i in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
    for j in range(s + 1):
        dp[i][j] += dp[i - 1][j] * 2
        dp[i][j] %= mod
        if a[i - 1] + j <= s:
            dp[i][a[i - 1] + j] += dp[i - 1][j]
            dp[i][a[i - 1] + j] %= mod
print(dp[n][s])

Measured memory_bytes: 139008
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int H,W;

bool onBoard(int y,int x){
    if(y>=0&&y<H&&x>=0&&x<W){
        return true;
    }
    return false;
}

int main() {
    
    cin >> H >>W;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin >> S[i];
    }
    ll ans =0;
    int dy[] = {1,0,-1,0};
    int dx[] = {0,1,0,-1};
    for(int sy=0;sy<H;sy++){
        for(int sx=0;sx<W;sx++){
            if(S[sy][sx]=='#'){
                continue;
            }
            ll d[H][W];
            memset(d,-1,sizeof(d));
            d[sy][sx] =0;
            queue<pair<int,int>> q;
            q.emplace(sy,sx);
            while(!q.empty()){
                int y = q.front().first;
                int x = q.front().second;
                q.pop();
                for(int i=0;i<4;i++){
                    int ny = y+dy[i];
                    int nx = x+dx[i];
                    if(onBoard(ny,nx) && d[ny][nx] == -1 && S[ny][nx] =='.'){
                        
                        d[ny][nx] = d[y][x] +1;
                        q.emplace(ny,nx);
                        ans = max(ans,d[ny][nx]);
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;cin>>s;
  	for(int i=0;i<3;i++){
	  if(s.at(i)=='9'){
        s.at(i)='1';
      }else{
      	s.at(i)='9';
      }
      	cout<<s.at(i);
 	 }
  }


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, m, i, j;
	cin >> n;
	vi d(n);
	for (i = 0; i < n; i++) {
		scanf("%d", &d[i]);
	}
	cin >> m;
	vi t(m);
	for (i = 0; i < m; i++) {
		scanf("%d", &t[i]);
	}
	if (n < m) {
		cout << "NO" << endl;
		return 0;
	}
	sort(d.begin(), d.end());
	sort(t.begin(), t.end());
	int num = 1, pre = t[0];
	for (i = 1; i < m; i++) {
		if (pre != t[i]) {
			int num2 = upper_bound(d.begin(), d.end(), pre) - lower_bound(d.begin(), d.end(), pre);
			if (num > num2) {
				cout << "NO" << endl;
				return 0;
			}
			pre = t[i];
			num = 1;
		}
		else {
			num++;
		}
	}
	int num2 = upper_bound(d.begin(), d.end(), pre) - lower_bound(d.begin(), d.end(), pre);
	if (num > num2) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	return 0;
}

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

#define FOR(i, a, b) for (int (i) = (a); (i) < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cerr << #x << " " << x << endl
#define eb emplace_back
#define _ << " " <<
typedef long long ll;
typedef std::pair<int, int> ii;
#define X first
#define Y second
#define double long double
typedef double db;
using namespace std;

const int MaxN = 200100;
const int Mod = 1e9 + 7;

int L[MaxN], R[MaxN];
int hasL[MaxN], hasR[MaxN];
int prefR[MaxN], sufL[MaxN];
int offset = 100024;
int N;

void solve() {
  ll ret = 0;

  FOR(i, 1, 2 * offset) { //left
    ret += min(prefR[i - 1], sufL[i]) * 2;
  }

  cout << ret << endl;
}

void load() {
  cin>>N;
  REP(i, N){
    cin>>L[i]>>R[i];
    hasL[offset + L[i]]++;
    hasR[offset + R[i]]++;
  }
  
  hasL[offset + 0] += 1;
  hasR[offset + 0] += 1;

  FOR(i, 1, 2 * offset) {
    prefR[i] = prefR[i-1] + hasR[i];
  }
  for (int i = 2 * offset - 1; i >= 1; i--) {
    sufL[i] = sufL[i + 1] + hasL[i];
  }

}

int main(){
  ios_base::sync_with_stdio(false);
  load();	
  solve();
  return 0;
}




Measured memory_bytes: 4608
n, q = map(int,input().split())
s = input()
a =[0]*n
#print(s[0:])
for i in range(1,n):
    a[i]=a[i-1]
    if s[i]=="C" and s[i-1] =="A":
        a[i]+=1
for j in range(q):
    ans = 0
    l, r = map(int,input().split())
    ans = a[r-1]-a[l-1]
    print(ans)


Measured memory_bytes: 6188
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

struct BIT
{
	int size;
	std::vector<int> data;
	BIT(int n) : data(n+1,0), size(n) {}
	void add(int i,int v) {
		i+=1;
		while(i<=size) {
			data[i]+=v;
			i += i&-i;
		}
	}
	int query(int l, int r) {
		// [l, r)
		int rv = 0;
		while(r>0) {
			rv+=data[r];
			r -= r&-r;
		}
		int lv = 0;
		while(l>0) {
			lv+=data[l];
			l -= l&-l;
		}
		return rv-lv;
	}
};


// ceil of a/b
inline int ceil(int a, int b) { return (a+b-1)/b; }

// requires <BIT>

int inversion_number(const std::vector<int>& a) {
	int n = a.size();
	std::vector<int> b = a;
	std::sort(all(b));
	std::vector<int> c(n);
	for(int i=0;i<n-1;i++) {
		c[i+1] = c[i];
		if(b[i+1]!=b[i]) c[i+1]++;
	}

	// reconstruct
	std::vector<int> d(n);
	for(int i=0;i<n;i++) {
		d[i] = c[std::lower_bound(all(b),a[i]) - b.begin()];
	}

	BIT bit(n);
	int count = 0;
	for(int i=0;i<n;i++) {
		count += bit.query(0,d[i]);
		bit.add(d[i],1);
	}

	return count;
}


signed main() {
	int n;
	std::cin >> n;
	std::vector<std::vector<int> > a(n,std::vector<int>(2));
	rep(i,n) std::cin >> a[i][0];
	rep(i,n) std::cin >> a[i][1];
	const int INF=1e9;
	std::vector<std::vector<int> > dp(1<<n,std::vector<int>(n,INF));
	rep(i,n) {
		dp[1<<i][i]=0;
	}
	rep(s,(1<<n)-1) {
		if(s==0) continue;
		int o=__builtin_popcount(s);
		rep(i,n) {
			if(dp[s][i]==INF) continue;
			rep(j,n) {
				if(s>>j&1) continue;
				if(a[i][std::abs(o-i-1)%2]>a[j][std::abs(o-j)%2]) continue;
				int inv=o-__builtin_popcount(s&((1<<(j+1))-1));
				dp[s|(1<<j)][j]=std::min(dp[s|(1<<j)][j],dp[s][i]+inv);
			}
		}
	}
	debug(dp);
	int min = INF;
	rep(i,n) min=std::min(min,dp[(1<<n)-1][i]);
	if(min==INF) print(-1);
	else print(min);
	return 0;
}


Measured memory_bytes: 47360
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
using namespace std;


int main(void){
  long long K;
  cin>>K;
  long long L;
  if(K%7==0){
    L = 9*K/7;
  }else{
    L = 9*K;
  }
  if(L%2==0 ||L%5==0){
    cout<<-1<<endl; 
  }else{
    int cnt = 0;
    int T=1;
    do{
      T *= 10;
      T = T % L;
      cnt++;
    }while(T!=1);
    cout<<cnt<<endl;
  }
  return 0;
}

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

int main(){
int N,M;
int a,b;
cin >> N >> M;
map<int,int> height;
vector<int> vec(N);
set<int> S;
for(int i=0;i<N;i++){
    cin >> vec.at(i);
}
for(int j=0;j<N;j++){
    height[j+1] = vec.at(j); 
}
for(int k=0;k<M;k++){
    cin >> a >> b;
    if(height.at(a)>height.at(b)){
        S.insert(b);
    }
    else if(height.at(a)<height.at(b)){
        S.insert(a);
    }
    else if(height.at(a)==height.at(b)){
        S.insert(a);
        S.insert(b);
    }
}
for(auto value : S){
    height.erase(value);
}
cout << height.size() << endl;
}

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

#define INF 999999999
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define pub push_back
#define pob pop_back
#ifdef LOCAL
  #define de(e) cout << "L" << __LINE__ << ": " << e << "\n" // debug echo
  #define dr(e) cout << "L" << __LINE__ << ": " << #e << " -> " << e << "\n" // debug repr
#else
  #define de(e)
  #define dr(e)
#endif
#define out(fmt, ...) printf(fmt, __VA_ARGS__); printf("\n")
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

//
// Implementation
//

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  int res = ((float)a + (float)b) / 2.0 + 0.5;
  out("%d", res);
}


Measured memory_bytes: 256
A=tuple(tuple(int(i) for i in input().split()) for j in range(3))
TF=[[False for i in range(3)] for j in range(3)]
N=int(input())
for i in range(N):
  b=int(input())
  for p in range(3):
    for q in range(3):
      if A[p][q] == b:
        TF[p][q]=True
ans=False
for i in range(3):
  if all(TF[i][j] for j in range(3)):
    ans=True
  if all(TF[j][i] for j in range(3)):
    ans=True
if all(TF[j][j] for j in range(3)):
  ans=True
if all(TF[j][-(j+1)] for j in range(3)):
  ans=True
print('Yes' if ans else 'No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main(){
    int n, k;
    cin >> n >> k;
    map<int, int> cnt;
    rep(i, n) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    if (cnt.size() <= k) {
        cout << 0 << endl;
    } else {
        vector<int> res;
        for(auto e: cnt) res.push_back(e.second);
        sort(all(res));
        reverse(all(res));
        int minus = 0;
        rep(i, k) minus += res[i];
        cout << (n - minus) << endl;
    }
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int east[n], west[n];
    rep(i, n) west[i] = 0;
    if (s[0] == 'W')
        west[0] = 1;
    else
        west[0] = 0;
    for (int i = 1; i < n; ++i)
    {
        if (s[i] == 'W')
            west[i] = west[i - 1] + 1;
        else
            west[i] = west[i - 1];
    }
    if (s[n - 1] == 'E')
        east[n - 1] = 1;
    else
        east[n - 1] = 0;
    for (int i = n - 2; i >= 0; --i)
    {
        if (s[i] == 'E')
            east[i] = east[i + 1] + 1;
        else
            east[i] = east[i + 1];
    }
    int cnt = n;
    rep(i, n)
    {
        if (east[i] + west[i] < cnt)
        {
            cnt = east[i] + west[i];
        }
    }
    cout << cnt - 1 << endl;
    return 0;
}

Measured memory_bytes: 6128
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().rstrip()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
# mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')



    
def solve():

    
    # for _ in range(ii()):


    s = si()
    if s[-1] != 's':
        s += 's'
    else:
        s += 'es'

    print(s) 












        
if __name__ =="__main__":

    
    if path.exists('input.txt'):
        sys.stdin=open('input.txt', 'r')
        sys.stdout=open('output.txt','w')
    else:
        input=sys.stdin.readline
    solve()

Measured memory_bytes: 68160
def binsearch(l, r, fn, i, j):
    while r - l > 1:
        m = (l + r) // 2
        if fn(m, i, j):
            l = m
        else:
            r = m
    return l

def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    def fn(m, i, j):
        a = L[m]
        b = L[i]
        c = L[j]
        if a < b + c and b < c + a and c < a + b:
            return True
        return False
    r = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            if fn(j+1, i, j):
                r += binsearch(j+1, N, fn, i, j) - j
    return r
print(main())


Measured memory_bytes: 46548
/*
    - N red points + N blue points
    - Sort all points by x
    - Then, for each red points, find the blue point such that
    - xBlue > xRed, yBlue > yRed, and yBlue as close as possible
*/
#include <bits/stdc++.h>
using namespace std;
 
struct Point {
  int x, y;
};
 
int main() {
	
  // Read input
  int n, count = 0; 
  cin >> n;
  vector<Point> r(n);
  vector<Point> b(n);
  vector<int> bvisited(n, 0);
  for (int i = 0; i < n; ++i) cin >> r[i].x >> r[i].y;
  for (int i = 0; i < n; ++i) cin >> b[i].x >> b[i].y; 
  
  // Solve
  sort(r.begin(), r.end(), [] (const Point &a, const Point &b) {
    return (a.x < b.x) || (a.x == b.x && a.y < b.y);
  });
  sort(b.begin(), b.end(), [] (const Point &a, const Point &b) {
    return (a.x < b.x) || (a.x == b.x && a.y < b.y);
  }); 
  reverse(r.begin(), r.end());
  reverse(b.begin(), b.end());
 
  for (int i = 0; i < n; ++i) {
    int min_y = 2*n;
    int min_j = -1;
    for (int j = 0; j < n; ++j) {
      if (!bvisited[j])  {
        bool check_x = (r[i].x < b[j].x);
        bool check_y = (r[i].y < b[j].y);
        if (check_x && check_y) {
          if (b[j].y < min_y) {
            min_y = b[j].y;
            min_j = j;
          } 
        }
      } 
    }
 
    //cout << r[i].x << ' ' << r[i].y << "\n";
    //cout << i << ' ' << min_j << "\n\n";
    
    if (min_j != -1 && bvisited[min_j] == 0) {
      bvisited[min_j] = 1;
      count++;
    }
  }
 
  cout << count << endl;
 
	return 0;
}

Measured memory_bytes: 256
#input: int list A, start p, end r
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    output = ""
    for idx, num in enumerate(A):
        if idx == i+1:
            output += "[" + str(num) + "]"
        else:
            output += str(num)
        output += " "
    print(output[:-1])

n = int(input())
list1 = list(map(int, input().split(' ')))
partition(list1, 0, len(list1)-1)


Measured memory_bytes: 16384
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    def c(x):
        return 1 <= x <= 9
    if c(a) and c(b):
        print(a * b)
        return
    print(-1)
    return

#B
def B():
    a = set()
    for i in range(10):
        for k in range(10):
            a.add(i * k)
    x = II()
    if x in a:
        print("Yes")
    else:
        print("No")
    return

#C
def C():
    n = II()
    factlize = []
    ans = inf
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            ans = min(ans, n // i + i - 2)
    print(ans)

    return

#D
def D():
    a, b, x = LI()
    from math import atan

    return

#E
def E():
    def solve(m):
        a1 = a[::-1]
        f1 = f[::1]
        res = 0
        for i in range(n):
            if a1[i] * f1[i] <= m:
                continue
            k = m // f1[i]
            res += a1[i] - k
            if res > K:
                return False
        return True

    n, K = LI()
    a = LI()
    a.sort()
    f = LI()
    f.sort()
    ok = max(a) * max(f)
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if solve(mid):
            ok = mid
        else:
            ng = mid
    print(ok)
    return

#F
def F():
    return


#Solve
if __name__ == '__main__':
    A()


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

int main() {
    int N; cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int ans = N;
    for (int i = 0; i < N-1; i++) {
        if(d[i] == d[i+1]) ans--;
    }
    cout << ans << endl;
}

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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

int main() {
	int n;
	cin >> n;

	int ans = 1000 - (n % 1000);
	if (ans == 1000) ans = 0;
	cout << ans << endl;
	return 0;
}


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

int main(void){
    int n,ans=0;
    cin >> n;
    int p[n];
    for(int i=0; i<n; i++) cin >> p[i];

    for(int i=1; i < n-1 ; i++){
        if(p[i-1] > p[i] && p[i] > p[i+1]) ans++;
        else if(p[i-1] < p[i] && p[i] < p[i+1]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

result = min(a) + min(b)
for i in range(M):
  x, y, c = map(int, input().split())
  sum = a[x-1] + b[y-1] - c
  if sum < result:
    result = sum

print(result)

Measured memory_bytes: 18488
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main()
{
    int a, b, c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d",MIN(b/a ,c));
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x,int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	char Sp[55], T[55];
	cin >> Sp >> T;
	int ls, lt;
	ls = strlen(Sp);
	lt = strlen(T);

	if (lt > ls)
	{
		cout << "UNRESTORABLE" << endl;
	}
	else
	{
		bool jp;

		for (int i = ls - lt; i >= 0; i--)
		{
			jp = true;

			for (int j = i; j < i + lt ; j++)
			{
				if (Sp[j] != '?'&&Sp[j] != T[j - i])
				{
					jp = false;
				}
				if (!jp) break;
			}

			if (jp)
			{
				for (int j = i; j < i+lt; j++)
				{
					if (Sp[j] == '?') Sp[j] = T[j - i];
				}
				for (int j = 0; j < ls; j++)
				{
					if (Sp[j] == '?') Sp[j] = 'a';
				}
				break;
			}
		}

		if (jp)cout << Sp << endl;
		else cout << "UNRESTORABLE" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
# 整数の数の入力
N = int(input())

# 数列の入力
A = list(map(int, input().split()))

# 数列の逆数を計算
for i in range(len(A)):  
  A[i] = 1 / A[i]

# 数列の逆数の総和の逆数を出力
print("{}".format(1 / sum(A)))

Measured memory_bytes: 2940