akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

void solve() {
  int n;
  cin >> n;
  vector<int> a(2 * n);
  int res = 0;
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = (int)a.size() - 2; i >= 0; i -= 2) {
    res += min(a[i], a[i + 1]);
  }
  cout << res << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
i[100012],d[100012],s,w,n,a,x,y;
main()
{
  for(w=scanf("%d",&n);a++<n;d[y]++)
      scanf("%d%d",&x,&y),i[x]++;
  for(a=2;a<=n+1;w-=d[a],a++)
    {
      w+=i[a];
      if(w>=a)s=a-1;
    }
  printf("%d\n",s);
  exit(0);
}

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


int main(){
	int n,k;

	cin >> n >> k;
	int d,tmp;
	vector<int> vc(n);
	rep(i,k){
		cin >> d;
		//cout << d << endl;
		rep(j,d){
			cin >> tmp;
			//cout << tmp << endl;
			vc[tmp-1]++;
		}
	}
	int c = 0;
	rep(i,n){
		if (vc[i] == 0)
			c++;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    string s;

    bool d[212345];

    cin >> n >> s;

    int cnt = 0;

    d[0] = false;
    for (int i = 1; i < s.size(); i++)
    {
        if (s[i] == s[i - 1])
            d[i] = !d[i - 1];
        else
            d[i] = d[i - 1];
        cnt += d[i];
    }

    if (cnt != n || s[0] == 'W' || s[s.size() - 1] == 'W')
    {
        cout << 0 << endl;
        return 0;
    }

    ll res = 1;

    int ln = 1;
    for (int i = 1; i < s.size(); i++)
    {
        if (d[i])
            (res *= ln) %= MOD, ln--;
        else
            ln++;
    }

    for (ll i = 1; i <= n; i++)
        (res *= i) %= MOD;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 788
n = int(input())
a = list(map(int, input().split()))
# 1
# 21
# 312
# 4213
# 53124
if n == 1:
    print(a[0])
    exit()
#a.sort()
if n % 2 == 0:
    for i in reversed(range(n // 2)):
        print(a[2 * i + 1], end=" ")
    for j in range(n // 2):
        print(a[2 * j], end=" ")
else:
    for i in reversed(range(n // 2 + 1)):
        print(a[2 * i], end=" ")
    for j in range(n // 2):
        print(a[2 * j + 1], end=" ")


Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define fastio iostream::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;} return res; }

struct compare {
    bool operator()(const std::string& first, const std::string& second) {
        return first.size() > second.size();
    }
};

ll find(ll x,ll y,ll t)
{
	ll n=((t-x)/y)+1;
	n=max((ll) 1,n);
	return (x+(n-1)*y);
}

int main()
{
    
    fastio;
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    for (int i = min(a,b)-1; i <= max(c,d)-1 && i<n-1; ++i)
    {
    	if(s[i]==s[i+1] && s[i+1]=='#')
    		cout<<"No",exit(0);
    }
    if((a<b && c>d) || (b<a && d>c))
    {
    	bool flag=true;
    	for (int i = max(a,b)-2; i <= min(c,d)-2 && i<n-2; ++i)
    	{
    		// cout<<i<<" ";

    		if(s[i]==s[i+1] && s[i+1]==s[i+2] && s[i+2]=='.')
    			flag=false;
    		if(!flag)
    			{break;}
    	}
    	if(flag)
    		cout<<"No",exit(0);
    }
    cout<<"Yes";




    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

const auto start_t = steady_clock::now();
mt19937 mt(start_t.time_since_epoch().count());
template<class Z> Z rng(Z a, Z b) { return uniform_int_distribution<Z>(a, b - 1)(mt); }
double rng(double a, double b) { return uniform_real_distribution<double>(a, b)(mt); }
int elapsed_time() { return duration_cast<milliseconds>(steady_clock::now() - start_t).count(); }

int N;
int X[100], Y[100];
lint mx;
void input(istream& is) {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> X[i] >> Y[i];
  }
}
void output() {
  cout << fixed << setprecision(15) << sqrt(mx) << '\n';
}

void solve() {
  bitset<100> bs;
  lint sx = 0, sy = 0, curr = 0;
  while (true) {
    int t = elapsed_time();
    if (t >= 1990) break;
    int i = rng(0, N);
    if (bs[i]) {
      if ((sx - X[i]) * (sx - X[i]) + (sy - Y[i]) * (sy - Y[i]) > curr or rng(0, 2000) >= t) {
        bs[i] = false;
        sx -= X[i], sy -= Y[i];
        curr = sx * sx + sy * sy;
      }
    } else {
      if ((sx + X[i]) * (sx + X[i]) + (sy + Y[i]) * (sy + Y[i]) > curr or rng(0, 2000) >= t) {
        bs[i] = true;
        sx += X[i], sy += Y[i];
        curr = sx * sx + sy * sy;
      }
    }
    mx = max(mx, curr);
  }
}

int main(int argc, char* argv[]) {
  if (argc == 1) {
    input(cin);
    solve();
    output();
  } else {
  }
  cerr << "Time: " << elapsed_time() << " ms\n";
}

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

int main(){
  int A,B;
  cin >> A >> B;
  int H,M;
  cin >> H >> M;
  double ans;
  double radA,radB,rad;
  radA = H * M_PI / 6 + M * M_PI / 360;
  radB = M * M_PI / 30;
  rad = fabs(-radA+radB);
  ans = sqrt(A*A + B*B - 2*A*B*cos(rad));
  printf("%.11f",ans);
}

Measured memory_bytes: 4136
#include <cstdio>
#include <algorithm>

#define MAX_N 100010

using namespace std;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    int d[q];
    char s[n+1], t[q+1]; t[q] = '\0';
    scanf("%s\n", s);
    for (int i=q-1; i>=0; i--) {
        char dc;
        scanf("\n%c %c", t+i, &dc);
        d[i] = (dc == 'R') ? 1 : -1;
    }
    int front = 0, back = 0;
    for (int i=0; i<q; i++) {
        if (front + back >= n) break;
        if (t[i] == s[front] && d[i] == -1)
            front++;
        else if (front > 0 && t[i] == s[front-1] && d[i] == 1)
            front--;
        if (t[i] == s[n-1-back] && d[i] == 1)
            back++;
        else if (back > 0 && t[i] == s[n-back] && d[i] == -1)
            back--;
    }
    printf("%d\n", max(n-front-back, 0));
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int a,b,c,d;
  std::cin >> a >> b >> c >> d;

  while(1) {
    c -= b;
    if(c <= 0){
      std::cout << "Yes" << '\n';
      return 0;
    }
    a -= d;
    if(a <= 0){
      std::cout << "No" << '\n';
      return 0;
    }
  }
}


Measured memory_bytes: 3596
s=input()
L=s.split(" ")
a=int(L[0])
b=int(L[1])
c=int(L[2])
if c-a-b<0:
    print("No")
elif 0<(c**2-c*a-c*b+a**2-c*a-b*c+b**2-2*a*b):
    print("Yes")
else:
    print("No")
    


Measured memory_bytes: 3060
let eval l =
  let interpret_op = function "+" -> (+) | "-" -> (-) | _ -> ( * ) in
  let s = Stack.create () in
  let rec aux = function
      [] -> Stack.pop s
    | op::r when op="+" || op="*" || op="-" ->
      let a,b = Stack.pop s, Stack.pop s in
      Stack.push ((interpret_op op) a b) s;
      aux r
    | n::r ->
      Stack.push (int_of_string n) s;
      aux r
  in aux l

let () =
  let l = read_line () |> Str.split (Str.regexp " ") in
  Printf.printf "%d\n" (eval l)

Measured memory_bytes: 2360
#include <iostream>
using namespace std;
 
int jos(int n, int k){
    int i;
    for( i = k-1 ; i<(k-1)*n ; i = (k*i)/(k-1)+1 );
    return (k*n-i);
}
 
int main(){
    int n,k;
    while( cin >> n >> k , n || k ){
        cout << jos(n,k) << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define MAXN 100000
#define inf LONG_MAX
using namespace std;
long long d[MAXN];
bool mark[MAXN];
void dijkstra(vector<pair<int,int>> *adj, int v, int n){
	fill(d,d + n, inf);
	fill(mark, mark + n, false);
	d[v] = 0;
	int u;
	priority_queue<pair<int,int>,vector<pair<int,int> >, less<pair<int,int> > > pq;
	pq.push({d[v], v});
	while(!pq.empty()){
		u = pq.top().second;
		pq.pop();
		if(mark[u])
			continue;
		mark[u] = true;
		for(auto p : adj[u]) //adj[v][i] = pair(vertex, weight)
			if(d[p.first] > d[u] + p.second){
				d[p.first] = d[u] + p.second;
				pq.push({d[p.first], p.first});
			}
	}
}
int main() {
  int N,Q,K,a,b,c,x,y;
  cin >> N;
  vector<pair<int,int>> G[N];
  x = N;
  while (--N) {
    cin >> a >> b >> c;
    G[--a].push_back({--b,c});
    G[b].push_back({a,c});
  }
  N = x;
  cin >> Q >> K;
  dijkstra(G,--K,N);
  while (Q--) {
    cin >> x >> y;
    cout << d[--x]+d[--y] << endl;
  }
}

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

int main() {
  int a,b,c;
  cin >> a >> b;
  
  if(b==1){
    c = 0; 
  }else if(a >= b){
    c = 1;
  }else{
    c = ((a-1)+(b-a)-1)/(a-1);
    c++;
  }
  cout << c << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int n, m, st, en;
pair<int, char> pr[6];
bool check(string s)
{
    bool ok = true;
    for(int i = 0; i < m; i++)
        if(s[pr[i].first - 1] != pr[i].second)
            ok = false;
    return ok;
}
int main()
{
    Hello
    cin >> n >> m;
    if(n == 1)
    {
        st = 0;
        en = 9;
    }
    else if(n == 2)
    {
        st = 10;
        en = 99;
    }
    else if(n == 3)
    {
        st = 100;
        en = 999;
    }
    for(int i = 0; i < m; i++)
    {
        cin >> pr[i].first >> pr[i].second;
        for(int j = 0; j < i; j++)
            if(pr[j].first == pr[i].first && pr[j].second != pr[i].second)
                return cout << -1, 0;

    }
    for(int i = st; i <= en; i++)
        if(check(to_string(i)))
            return cout << i, 0;
    cout << -1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

int main()
{
    int n;
    ll y;
    cin >> n >> y;
    rep(i, n + 1){
        rep(j, n + 1 - i ){
            if (i * 10000 + j * 5000 + (n - (i + j)) * 1000 == y) {
                cout << i << " " << j << " " << n - (i + j) << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
a_b = [list(map(int, input().split())) for i in range(N)]
a_b.sort()
index = 0

for i in range(N):
    index += a_b[i][1]
    if index >= K:
        print(a_b[i][0])
        exit()

Measured memory_bytes: 27916
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

struct UnionFind{
private:
    vector<int> par;
    vector<int> siz;
public:
    void init(int N){
        par.resize(N);
        siz.resize(N);
        for(int i=0; i<N; i++) par[i] = i;
        for(int i=0; i<N; i++) siz[i] = 1;
    }
    void unite(int a, int b){
        int rootA = root(a);
        int rootB = root(b);
        if(rootA == rootB) return;
        if(siz[rootA] < siz[rootB]) swap(rootA, rootB);
        par[rootB] = rootA;
        siz[rootA] += siz[rootB];
    }
    int root(int a){
        if(par[a] == a) return a;
        return par[a] = root(par[a]);
    }
    bool same(int a, int b){
        return root(a) == root(b);
    }
    int size(int a){
        return siz[root(a)];
    }
};

int N, M;
UnionFind uf;

signed main(){
    cin >> N >> M;
    uf.init(N);
    rep(i, M){
        int a, b;
        cin >> a >> b;
        uf.unite(a-1, b-1);
    }

    int ans = 0;
    rep(i, N){
        if(uf.root(i) == i) ans++;
    }
    cout << ans-1 << endl;
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  string s;
  cin >> s;
  bool a = false, b = false, c = false;
  for (int i = 0; i < 3; ++i){
    if (s[i] == 'a')a = true;
    if (s[i] == 'b')b = true;
    if (s[i] == 'c')c = true;
  }
  if (a && b && c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s = S() + 'T'
x, y = LI()
t_flag = 0
# 0の時横移動、1の時縦移動。
flag = 0
y_now = x_now = 1 << 8000
f_cnt = 0
for j in s:
    if j == 'T':
        if not flag:
            flag = 1
            x_now >>= f_cnt
        elif t_flag:
            y_now = y_now >> f_cnt | y_now << f_cnt
        else:
            x_now = x_now >> f_cnt | x_now << f_cnt
        t_flag ^= 1
        f_cnt = 0
    else:
        f_cnt += 1


if 1 << 8000 + y & y_now and 1 << 8000 - x & x_now:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 40432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
//		String[] array = new String[n];
//		for(int i=0;i<n;i++) {
//				array[i] = sc.next();
//		}
		sc.close();

		long ans = -1000000000000000000L;

		ans = Math.max(ans, a*c);
		ans = Math.max(ans, a*d);
		ans = Math.max(ans, b*c);
		ans = Math.max(ans, b*d);

		System.out.println(ans);
	}
}


Measured memory_bytes: 35852
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        if((A+B)%2==0){
            System.out.println((A+B)/2);
        }else{
            System.out.println("IMPOSSIBLE");
        }
    }
}


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

/**
 * Created by oka on 2018/06/05.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int k = sc.nextInt();

        List<String> list = new ArrayList<String>();
        start_loop: for (int start = 0; start < s.length(); start++) {
            end_loop: for (int end = start+1; end <= s.length(); end++) {
                String substr = s.substring(start, end);
                for (int i = 0; i < k; i++) {
                    if (list.size() == i) {
                        list.add(substr);
                        continue end_loop;
                    } else {
                        String str = list.get(i);
                        int compareResult = str.compareTo(substr);
                        if (compareResult == 0) {
                            continue end_loop;
                        } else if (compareResult > 0) {
                            list.add(i, substr);
                            continue end_loop;
                        }
                    }
                }
                continue start_loop;
            }
        }

        System.out.println(list.get(k-1));
    }
}


Measured memory_bytes: 23892
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
d = {(str(p),str(q)): 0 for p in range(1,10) for q in range(1,10)}
for i in range(1, n+1):
    c = str(i)
    if c[-1]!="0":
        d[c[0], c[-1]] += 1
ans = 0
for i in range(1,10):
    for j in range(1,10):
        if i==j:
            v = d[str(i), str(j)]
            ans += v * v
        else:
            v1 = d[str(i), str(j)]
            v2 = d[str(j), str(i)]
            ans += v1*v2
print(ans)

Measured memory_bytes: 67460
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int d = m2-m1 + (h2-h1)*60;
  cout << d-k << endl;
}


Measured memory_bytes: 3604
from collections import deque

N = int(input())
P = list(map(int,input().split()))

mx = P[0]
mn = mx
count = 0

ans = deque(list(filter(lambda x:mx >= x,P)))

ln = len(ans)

for a in range(ln):
    num = ans.popleft()
    if mx >= num:
        mx = num
        count += 1
    else:
        continue

print(count)

Measured memory_bytes: 25128
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
map<char,bool> boll;
void swap(char a,char b){
  bool x;
  x=boll[a];
  boll[a]=boll[b];
  boll[b]=x;
}


int main(){
  char a,b;
  boll['A']=true; boll['B']=false; boll['C']=false;
  while(scanf("%c,%c",&a,&b)+1){
    if(a=='D')break;
    swap(a,b);
  }
  if(boll['A'])cout<<'A'<<endl;
  if(boll['B'])cout<<'B'<<endl;
  if(boll['C'])cout<<'C'<<endl;
}
  
    
   

Measured memory_bytes: 1188
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	print(n*n*n);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) repi(i, 0, n)
#define rep1(i, n) repi(i, 1, n + 1)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)

typedef long long ll;

bool xy[110][110];

int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    rep(i, 110) rep(j, 110) xy[i][j] = true;
    rep(i, n) {
        int x, y, a;
        cin >> x >> y >> a;
        switch (a) {
            case 1:
                rep(i, x) rep(j, h) xy[i][j] = false;
                break;
            case 2:
                repi(i, x, w) rep(j, h) xy[i][j] = false;
                break;
            case 3:
                rep(i, w) rep(j, y) xy[i][j] = false;
                break;
            case 4:
                rep(i, w) repi(j, y, h) xy[i][j] = false;
                break;
        }
    }
    int ans = 0;
    rep(i, w) rep(j, h) if (xy[i][j]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import bisect


def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort()
    for i in range(1, n):
        A[i] = (A[i] + A[i-1]) / 2
    print('%.10f' % (A[-1]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMarch solver = new CMarch();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMarch {
        static final String letterString = "MARCH";
        static final int L = letterString.length();
        static final char[] letters = letterString.toCharArray();

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            long[] count = new long[letters.length];

            for (int i = 0; i < n; i++) {
                String s = in.next();
                int index = letterString.indexOf(s.charAt(0));
                if (index >= 0)
                    count[index]++;
            }

            long answer = 0;
            for (int i = 0; i < L; i++) {
                for (int j = i + 1; j < L; j++) {
                    for (int k = j + 1; k < L; k++) {
                        answer += count[i] * count[j] * count[k];
                    }
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32460
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int N;
    cin >> N;
    vector<int> p(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> p[i];
        --p[i];
    }
    int ans = 0;
    for (int i = 0; i < N - 1; ++i) {
        if (p[i] == i) {
            swap(p[i], p[i + 1]);
            ++ans;
        }
    }
    if (p[N - 1] == N - 1) {
        swap(p[N - 1], p[N - 2]);
        ++ans;
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl

int main(int argc, const char* argv[]) {
  u64 n, m;
  cin >> n >> m;
  
  u64 a[m] = {0};
  
  rep(i, n) {
    u64 k;
    cin >> k;
    rep(j, k) {
      u64 aindex;
      cin >> aindex;
      ++a[aindex-1];
    }
  }
  
  u64 ret = 0;
  rep(i, m) {
    if(a[i] == n) ++ret;
  }
  
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <cmath>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define uid uniform_int_distribution<lli>
#define lli long long int
#define ff first
#define ss second
#define pb push_back
#define popf pop_front()
#define popb pop_back()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define forr(x,arr) for(auto& x:arr)
#define sz(x) (x.size())
#define mod 1000000007
#define INF 1000000000000000010
#define vi vector<int>
#define vlli vector<lli>
#define endl "\n"
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class my>
inline my aabs (const my& a)   { return (a > 0)  ? a : -a;         }
inline lli gcd(lli a, lli b)   { return (b == 0) ? a : gcd(b,a%b); }
inline lli LSOne(lli k)        { return (k&(-k));                  }

inline int inv(lli o, int m = mod) {
  int b = m, u = 0, v = 1, t, a=o%m;
  while (a) {
    t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  if (u < 0) u += m;
  return u;
}
inline int add(const int &a, const int &b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(const int &a, const int &b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(const int &a, const int &b) { return int(a * 1ll * b % mod); }
inline int _div(const int &a, const int &b) { return mul(a, inv(b)); }
inline int pow(int a, int b) {
    int ans = 1;
    while (b) {
        if (b & 1) ans = mul(ans, a);
        a = mul(a, a);
        b >>= 1;
    }
    return ans;
}

void solve()
{
    lli n=0, m=0, k=0, q=0, temp=0, u=0, v=0, ans=0, ans1=0, ans2=0, val=0, mini=INF, maxi=-INF;
    string s;
    cin>>s;
    int dr[30]={};
    fol(i,0,4) dr[(int)s[i]-'A']++;
    fol(i,0,30) if(dr[i]==2) ans++;
    if(ans==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main()
{
    fastio cout<<endl;
    int t=1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    2019;
bool ans[200];
int main()
{  fast
ll n,a,b,c;
cin>>n>>a>>b>>c;
string s[n];
bool bo=true;
for(int i=0;i<n;i++)
{string s1;
	cin>>s[i];
	sort(s[i].begin(),s[i].end());

}
vector<string> ans;
for(int i=0;i<n;i++)
{
	if(s[i]=="AB")
	{
		if(a<=0&&b<=0)
		{cout<<"No";return 0;
		}
		if(a==0||b==0)
		{
			if(a>0)
			{a--;b++;ans.emplace_back("B");
            }
			 else
			 {a++;b--;ans.emplace_back("A");
			 }
		}
		else
		{
			if(i+1<n&&s[i+1][0]=='A')
			{
				a++;b--;ans.emplace_back("A");
			}
			else
			{
				a--;
				b++;ans.emplace_back("B");
			}
		}
	}
	else if(s[i]=="BC")
	{
			if(c<=0&&b<=0)
		{cout<<"No";return 0;
		}
		if(c==0||b==0)
		{
			if(c>0)
			{c--;b++;ans.emplace_back("B");
            }
			 else
			 {c++;b--;ans.emplace_back("C");
			 }
		}
		else
		{
			if(i+1<n&&s[i+1][1]=='C')
			{
				c++;b--;ans.emplace_back("C");
			}
			else
			{
				c--;
				b++;ans.emplace_back("B");
			}
		}
	}
	else{
			if(a<=0&&c<=0)
		{cout<<"No";return 0;
		}
		if(a==0||c==0)
		{
			if(a>0)
			{a--;c++;ans.emplace_back("C");
            }
			 else
			 {a++;c--;ans.emplace_back("A");
			 }
		}
		else
		{
			if(i+1<n&&s[i+1][0]=='A')
			{
				a++;c--;ans.emplace_back("A");
			}
			else
			{
				a--;ans.emplace_back("C");
				c++;
			}
		}
	}
}
cout<<"Yes\n";
for(int i=0;i<ans.size();i++)
cout<<ans[i]<<endl;
//cout<<ch<<endl;

}


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

int main() {
  int n; cin >> n;
  int count = 0;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 1; i < n-1; i++) {
    if((v[i-1] > v[i] && v[i] > v[i+1])
    || (v[i-1] < v[i] && v[i] < v[i+1])) count++;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256
n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

a = set(a); b = set(b)
#print(a, b)

def k(a, b, n, m):
    s = 1
    x, y = 0, 0
    if (n * m not in a) or (n * m not in b):
        return 0
    for i, j in enumerate(reversed(range(n * m))):

        if (j + 1 in a) and (j + 1 in b):
            x += 1; y += 1
            #continue
        elif j + 1 in a:
            y += 1
            s *= x
        elif j + 1 in b:
            x += 1
            s *= y
        else:
            if x * y - i > 0:
                s *= x * y - i
            else:
                s = 0
                break
        if s > 10 ** 9 + 7:
            s %= 10 ** 9 + 7
        #print(i, j + 1, 'x=', x, 'y=', y, 's=', s)
    return s

if len(a) != n or len(b) != m:
    print(0)
else:
    print(k(a, b, n, m))

# TimeLimitExceeded
# indexで一個ずつ見つけていくのは時間がかかるということ。


Measured memory_bytes: 3188
import java.util.*;
 
public class Main{
  public static int[] dp;
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int K = Integer.parseInt(S[1]);
    
    double[] table = new double[N+1];
    table[0] = 0.0;
    
    double a = 1.0/N;
    for(int i = 1; i <= N; i++){
      int k = i;
      int b = 1;
      boolean check = true;
      while(check){
        if(k < K){
          k *= 2;
          b *= 2;
        }else{
          check = false;
      	}
      }
      table[i] = a * (1.0/b);
    }
    
    double ans = 0.0;
    for(int i = 0; i <= N; i++){
      ans += table[i];
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    if(D == 0 && N != 100) cout << N << endl;
    else if(D == 0 && N == 100) cout << N+1 << endl;
    else if(D == 1 && N != 100) cout << 100*N << endl;
    else if(D == 1 && N == 100) cout << 100*N+100 << endl;
    else if(D == 2 && N != 100) cout << 10000*N << endl;
    else cout << 10000*N+10000 << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int K = sc.nextInt();
		int S = sc.nextInt();
		int count = 0;
		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				int z = S - x - y;
				if (0 <= z && z <= K)
					count++;
			}
		}

		System.out.println(count);

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,s,e) for(int i=s;i<e;i++)
#define endl '\n'
int main(){
    int N;cin>>N;
    set<string> S;
    rep(i,0,N){
        string tmp;
        cin>>tmp;
        S.insert(tmp);
    }
    cout<<S.size()<<endl;
}

Measured memory_bytes: 19172
object Main extends App {
  var a = List(readInt,readInt,readInt,readInt,readInt)
  var min = 10
  var sum = 0
	for(i<-0 to a.size-1){
    	if(a(i)%10!=0&&min>a(i)%10)min=a(i)%10
      	sum = 
      	if(a(i)%10!=0)
		    sum + a(i)+10-(a(i)%10)
      	else
	    	sum + a(i)
    }
  println(sum - 10 + min)
}

Measured memory_bytes: 27324
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion

N, X = ri_()
L = ri_()
d = 0
for i in range(N):
    d += L[i]
    if X < d:
        print(i + 1)
        exit()
print(N + 1)

Measured memory_bytes: 63340
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,all = 0;
  set<int> color;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a;
    if(a < 400)color.insert(1);
    else if(a < 800)color.insert(2);
    else if(a < 1200)color.insert(3);
    else if(a < 1600)color.insert(4);
    else if(a < 2000)color.insert(5);
    else if(a < 2400)color.insert(6);
    else if(a < 2800)color.insert(7);
    else if(a < 3200)color.insert(8);
    else all++;
  }
  if((int)color.size()) cout << color.size() << " " << color.size() + all << endl;
  else cout << 1 << " " << all << endl;
  
}

Measured memory_bytes: 256
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

ll const MAX = 200005;
ll a[MAX];
ll n;

bool ok(ll x) {
	if (x == 1) return false;
	vector<ll> v, u;
	v.push_back(0);//keta
	u.push_back(0);//suuji

	REP(i, 1, n) {
		ll t = v.back();
		bool flag = 0;
		while (t > a[i]) {
			v.pop_back();
			u.pop_back();
			t = v.back();
			flag = 1;
		}	
		
		if (t < a[i]) {
			v.push_back(a[i]);
			u.push_back(1 + flag);
		}
		else if (t == a[i]) {
			ll s = a[i];
			while (s == v.back() && x == u.back()) {
				v.pop_back();
				u.pop_back();
				s--;
				flag = 1;
				if (s == 0) {
					return false;
				}
			}
			if (s == v.back()) {
				u[SIZE(u) - 1]++;
			}
			else {
				v.push_back(s);
				u.push_back(2);
			}
		}
	}
	return true;
}

int main() {
	cin >> n;
	bool flag = 1;
	cin >> a[1];
	REP(i, 2, n) {
		cin >> a[i];
		if (a[i - 1] >= a[i]) {
			flag = 0;
		}
	}
	if (flag) {
		cout << 1 << endl;
		return 0;
	}
	ll ub = 1e18; ll lb = 1;
	while (ub - lb > 1) {
		ll mid = (lb + ub) / 2;
		if (!ok(mid)) {
			lb = mid;
		}
		else {
			ub = mid;
		}
	}
	cout << ub << endl;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;

     if(a==b && b==c)
    {
        cout<<"No"<<endl;
    }
      else if(a==b || a==c || b==c){
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
 return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<
    pair<int, int>,
    null_type,
    less_equal<pair<int, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << (z) << ' '
#define cnl(z) cout << (z) << '\n'
#define M1 1000000007
#define M2 998244353
#define MAXN 300005
#define INF (1ll << 60)
#define endl "\n"
#define garr(ip)       \
    for (auto &x : ip) \
        cin >> x;
#define parr(ip)          \
    for (auto &x : ip)    \
        cout << x << " "; \
    cout << endl;
#define nl cout << endl
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vp;

void solve(int testCaseNumber = 1)
{
    int n;
    cin >> n;
    vi arr(n);
    garr(arr);
    sort(all(arr));
    int maxelement = *max_element(all(arr));
    vi dp(maxelement + 1);
    int ans = 0;
    rlt(j, 0, n)
    {
        int i = arr[j];
        if (dp[i])
            continue;
        if ((j + 1 < n and arr[j] != arr[j + 1]) or j == (n - 1))
            ans++;
        for (int j = i; j <= maxelement; j += i)
            dp[j] = 1;
    }
    cnl(ans);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 12676
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		HashMap<String, Integer> words = new HashMap<String, Integer>();
		
		String max = "";
		while (sc.hasNext() == true) {
			String word = sc.next();
			
			if (max.length() < word.length()) max = word;
			
			if (words.containsKey(word)) {
				words.put(word, (words.get(word) + 1));
			} else {
				words.put(word, 1);
			}
		}
		
		String maxf = "";
		for (String key : words.keySet()) {
			if (maxf.equals("") == false) {
				if (words.get(maxf) < words.get(key)) maxf = key;
			} else {
				maxf = key;
			}
		}
		System.out.println(maxf + " "  + max);
	}
}

Measured memory_bytes: 25628
/*
	author : SAMRAT DE
	username : Alucard_01
	NIT Durgapur
*/

/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>*/
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define vec(x) vector<x> 
#define st(x) set<x> 
#define pi(x,y) pair<x,y>
#define mpp(x,y) map<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define rel(i,x,y) for(ll i=x-1;i>=y;i--)
#define rev(x) reverse(x.begin(),x.end())
#define mem(x,a) memset(x,a,sizeof(x))
#define mod 1000000007
#define nxt_per(x) next_permutation(x.begin(),x.end())
#define pb push_back
#define pf push_front
#define indexof order_of_key
#define valueat find_by_order
#define myds tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 

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

using namespace std;
//using namespace __gnu_pbds;

int32_t main()
{
	fastio;
	//best of luck don't loose hope man	
		
	int n;
	cin>>n;
	ll arr[n];
	rep(i,0,n)
		cin>>arr[i];
	if(n==1){
		cout<<0<<endl;
		return 0;
	}
	int ans=INT_MIN;
	rep(i,1,n){
		int count=0;
		while(arr[i-1]>=arr[i] && i<n){
			count++;
			i++;
		}
		ans=max(ans,count);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >>W;
  
  vector<vector <char>> pic(H+2, vector<char>(W+2));
  
  for(int i=0; i<H+2; i++){
    for(int j=0; j<W+2; j++){
      if(i == 0 || i == H+1) pic.at(i).at(j) = '#';
      else if(j == 0 || j == W+1) pic.at(i).at(j) = '#';
      else cin >> pic.at(i).at(j);
    }
  }
  
  for(int i=0;i<H+2; i++){
    for(int j=0; j<W+2; j++){
      cout << pic.at(i).at(j);
    }
    cout << endl;
  }
}
        
        
  
  


Measured memory_bytes: 256
import sys
import string
import time


def input():
    return sys.stdin.readline().rstrip()


def I():
    return int(input())


def S():
    return input()


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


def MS():
    return map(str, input().split())


def LI():
    return list(map(int, input().split()))


def LI_():
    return [int(i) - 1 for i in input().split()]


def StoI():
    return [ord(i) - 97 for i in input()]


def ItoS(nn):
    return chr(nn + 97)


N = {False: 'No', True: 'Yes'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10 ** 6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


def main():
    N, Y = MI()
    for x in range(N + 1):
        for y in range(N + 1):
            z = N - x - y
            if z < 0:
                continue
            if 10000 * x + 5000 * y + 1000 * z == Y:
                print('{} {} {}'.format(x, y, z))
                return
    print('-1 -1 -1')


if __name__ == '__main__':
    main()


Measured memory_bytes: 40936