akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

bool dfs(int c[10])
{
    bool ret = false;
    int sum = 0;

    for (int i = 1; i <= 9; i++)
        sum += c[i];
    if (sum == 0)
        return true;

    for (int i = 1; i <= 7; i++) {
        if (c[i] >= 1 && c[i + 1] >= 1 && c[i + 2] >= 1) {
            c[i]--, c[i + 1]--, c[i + 2]--;
            if (dfs(c))
                ret = true;;
            c[i]++, c[i + 1]++, c[i + 2]++;
        }
    }
    for (int i = 1; i <= 9; i++)
        if (c[i] >= 3) {
            c[i] -= 3;
            if (dfs(c))
                ret = true;;
            c[i] += 3;
        }
    return ret;
}


int main()
{
    string inp;

    while (cin >> inp) {
        bool flag = false;
        vector<int> ans;

        for (int i = 1; i <= 9; i++) {
            int cnt[10];
            bool out = false;

            // Initialization
            for (int j = 1; j <= 9; j++)
                cnt[j] = 0;
            for (int j = 0; j < inp.size(); j++) 
                cnt[inp[j] - '0']++;
            cnt[i]++;

            for (int j = 1; j <= 9; j++)
                if (cnt[j] > 4) {
                    out = true;
                    break;
                }
            if (out)
                continue;

            for (int j = 1; j <= 9; j++) {
                if (cnt[j] >= 2) {
                    cnt[j] -= 2;

                    if (dfs(cnt)) {
                        flag = true;
                        ans.push_back(i);
                        break;
                    }
                    cnt[j] += 2;
                }
            }
        }
        // Output
        if (flag) {
            for (int i = 0; i < ans.size() - 1; i++)
                cout << ans[i] << " ";
            cout << ans[ans.size() - 1] << endl;
        }
        else
            cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while( scan.hasNextInt() ) {
			int num = scan.nextInt();
			
			int cnt = 0;
			for(int i = 0; i <= 9; i++) {
				for(int j = 0; j <= 9; j++) {
					for(int k = 0; k <= 9; k++) {
							for(int l = 0; l <= 9; l++) {
								if(i+j+k+l == num) {
									cnt++;
								}
							}
					}
				}
			}
			
			System.out.println(cnt);
		}
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

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

    ll N,D,A; cin >> N >> D >> A;
    vector<P> lis(N);
    for (int i = 0;i < N;i++){
        cin >> lis[i].first >> lis[i].second;
    }

    sort(lis.begin(),lis.end());

    ll ans = 0;
    ll cnt = 0;

    vector<P> tmp = lis;
    vector<ll> memo(N+1,0);
    ll sum = 0;

    for (int i = 0;i < N;i++){
        sum -= memo[i];
        tmp[i].second -= sum;
        if(tmp[i].second <= 0) continue;
        int now = lower_bound(tmp.begin(),tmp.end(),tmp[i])-tmp.begin();
        int to = upper_bound(tmp.begin(),tmp.end(),P(tmp[i].first+D*2,LLONG_MAX))-tmp.begin();
        now++;
        ll t = (tmp[i].second-1)/A+1;
        cnt += t;
        sum += t*A;
        memo[to] += t*A;
        //cout << tmp[i].second << endl;
        //cout << endl;

    }

    tmp = lis;
    ans = cnt;
    cnt = 0;
    vector<ll> memo2(N+1,0);
    sum = 0;

    for (int i = N-1;i >= 0;i--){
        sum -= memo2[i];
        tmp[i].second -= sum;
        if(tmp[i].second <= 0) continue;
        int now = lower_bound(tmp.begin(),tmp.end(),tmp[i])-tmp.begin();
        int to = lower_bound(tmp.begin(),tmp.end(),P(tmp[i].first-D*2,0))-tmp.begin();
        now--;
        ll t = (tmp[i].second-1)/A+1;
        cnt += t;
        to--;
        sum += t*A;
        if(to >= 0)memo2[to] += t*A;
        //cout << tmp[i].second << endl;

    }

    ans = min(ans,cnt);

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 9600
/*
Character Drawing Adapted from FAKEUPDATE.NET
		   _    _____         _
		   \`,""   ,'7"r-..__/ \
		  ,'\ `, ,',','    _/   \
		 /   \, 7 / /     (   \ |
		J     \/ j  L______\  / |
		L   __JF"""/""\"\_,    /
		L,-"| O|  f O |  L_  _/
		F   \_ /  \__/   `-  j|
			.-'    `"""    ,' |          _..====.._
			\__/         r"_  A        ,' _..---.._`,
			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,
					  j   / / / 7"    `-<""=:'  '':. \ \
					 /   <,' /  F  . i , \   `,    :T W I
					 |    \,'  /    >X<  |     \   :| | L
					 |     `._/    ' ! ` |      I  :| |  G
					  \           \     /       |  :H T  |
					 __>-.__   __,-\   |        |  S P   |
					/     /|   | \  \  \_       | 'A R   |
				   /   __/ |   |  L  L   \      K./ /    L
				  /   |    |   4  I  I    |    E./ /   ,'
				 J    \    I    L F  I    |    // / _,'
		_________|     |   F    |J   F    |   //_/-'
		\   __   |    /   J     |/  J     |  /="
		\\  \_\  \__,' \  F     |   F     |
		\\\_____________\/      F__/      F
		 \\| 计算机编程 |_____/  (______/
		  \/从入门到入土/
*/
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
#include <functional>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	int iLen, i, n5 = 0, n7 = 0;
	for (i = 1; i <= 3; ++i){
		cin >> iLen;
		if (iLen == 5)
			++n5;
		if (iLen == 7)
			++n7;
	}
	cout << ((n5 == 2 && n7 == 1) ? "YES\n" : "NO\n");
endapp:
	//1system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
	char s[200][11];
	int n,m,i,j,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){scanf("%s",s[i]);}
	scanf("%d",&m);
	for(i;i<n+m;i++){scanf("%s",s[i]);}
	for(i=0;i<n;i++){
		int cnt=0;
		for(j=0;j<n+m;j++){if(strcmp(s[i],s[j])==0){cnt+=j<n?1:-1;}}
		if(max<cnt){max=cnt;}
	}
	printf("%d",max);
	return 0;
}

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

int main() {
  vector <int> vec(5);
  
  for (int i = 0; i < 5; i++) {
    cin >> vec.at(i);
     if (vec.at(i) == 0) {
       cout << i + 1 << endl;
     }
  }
}


Measured memory_bytes: 3628
fun main() {
  val s = readString().split('S')
  println(s.map { it.length }.max())
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 36436
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    int n; cin >> n;
    vector<int> a(4, 0);
    rep(i, n) {
        string s; cin >> s;
        if (s == "AC") a[0]++;
        else if (s == "WA") a[1]++;
        else if (s == "TLE") a[2]++;
        else a[3]++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", a[0], a[1], a[2], a[3]);
    return 0;
}

Measured memory_bytes: 3724
from numpy import*;I=lambda:map(int,input().split());W,H,N=I();m=zeros((H,W),int)
while N:x,y,a=I();m[y*(a>3):H*(a^3)or y,x*(a==2):W*~-a or x]=1;N-=1
print(W*H-m.sum())

Measured memory_bytes: 12496
n = int(input())
v_list = list(map(int,input().split()))
while len(v_list) >= 3:
  v_list.sort()
  new_v = (v_list[0] + v_list[1]) /2
  v_list.pop(0)
  v_list.pop(0)
  v_list.append(new_v)
print((v_list[0] + v_list[1]) / 2)
  


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

int main() {
  int n;
  cin >> n;
  vector<int> l(n), r(n);
  for (int i = 0; i < n; i++)
    cin >> l[i] >> r[i];

  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += r[i] - l[i] + 1;
  }
  cout << sum << endl;
}

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

int main(){

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

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

  cout << cnt << endl;

  return 0;
}



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

int main(void)
{
	int n;
	int i;
	double x1, y1, x2, y2, x3, y3;
        double a, b, c, d, e, f;
	double px, py, r;

	scanf("%d",&n); 

	for(i=0; i<n; i++)
	{
		scanf("%lf%lf%lf%lf%lf%lf",&x1, &y1, &x2, &y2, &x3, &y3); 
		
		a = 2 * (x1 -x2);
		b = 2 * (y1 -y2);
		c = 2 * (x1 -x3);
		d = 2 * (y1 -y3);
		e = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
		f = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;

		px = (d * e - b * f) / (a * d - b * c);
		py = (a * f - c * e) / (a * d - b * c);

		r = sqrt((x1 - px) * (x1 - px) + (y1 - py) * (y1 - py));
		printf("%.3f %.3f %.3f\n", px, py, r);
	}

	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,ans=0;
    cin>>n;
    
    for(int i = 9; i <= n; i+=2)
    {
        int cnt=0;
        for(int j = 1; j <= i; j++)
        {
            if(i%j==0) cnt++;
        }
        if(cnt==8) ans++;
    }
    
    cout<<ans<<endl;

    return 0;
}

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

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int count = 0;
    for (int i = 0; n > 0; i++)
    {
        n -= x;
        count++;
    }
    cout << count*t << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int, int>
#define vpii vector<pii>
using namespace std;
vvi a;
vvi dp;
int recurse(int x,int y,int z){
	if(dp[y][x]!=-1){
		//cout<<x<<" "<<y<<" "<<dp[y][x]<<endl;
		return dp[y][x];
	}
	ll v=1;
	for(int i=0;i<a[x].size();i++){
		if(a[x][i]!=z){
			if(y==0){
				v=(v%mod*(recurse(a[x][i],0,x)+recurse(a[x][i],1,x))%mod)%mod;
			}
			else{
				v=(v%mod*(recurse(a[x][i],0,x))%mod)%mod;
			}
		}
	}
	//cout<<x<<" "<<y<<" "<<v<<endl;
	return dp[y][x]=v%mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
   // cin>>t;
    while(t--){
    	int n;
    	cin>>n;
    	a.clear();dp.clear();
    	int x,y;
    	a.resize(n);
    	Fr(i,0,n-2){
    		cin>>x>>y;
    		x--;y--;
    		a[x].pb(y);a[y].pb(x);
    	}
		x=1;    	
    	dp.resize(2,vi(n,-1));
 		ll ans=(recurse(0,0,-1)+recurse(0,1,-1))%mod;
 		cout<<ans<<endl;   	
    }
    return 0;
}


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

int main(){
    int n, m;
    cin >> n>> m;
    int l = 1;
    int r = 100007;
    for (int i = 0; i < m; i++){
        int ll, rr;
        cin >> ll >> rr;
        l = max(l, ll);
        r = min(r, rr);
    }
    if (l > r) cout << 0 <<endl;
    else cout << r-l+1 <<endl;
    return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
	string s;
	cin >> s;

	int l = s.size();
	for(int i=l-1;i>0;i--){
		if(i%2==0){
			string s1 = s.substr(0, i/2);
			string s2 = s.substr(i/2, i/2);
			if(s1==s2){
				cout << i << endl;
				return 0;
			}
		}
	}
    
	return 0;
}







Measured memory_bytes: 256
using System;

using System.Collections.Generic;

namespace AtCoderTest
{
    class Program
    {
        static void Main()
        {
            int X = int.Parse(Console.ReadLine().Trim());


            int loop = (360 * X) / gcd(360, X);

            int result = loop / X;

            Console.WriteLine(result);

        }

        static int gcd(int a, int b) {
            int q = a / b;
            int r = a % b;
            if (r == 0) return b;

            return gcd(b, r);
        }


    }

}


Measured memory_bytes: 27412
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

int main() {
    char b;
    cin >> b;

    if(b == 'A') cout << 'T' << endl;
    else if(b == 'T') cout << 'A' << endl;
    else if(b == 'C') cout << 'G' << endl;
    else cout << 'C' << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> K;
	int ans = 0;
	while (N > 0) {
		ans++;
		N /= K;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
    int N, A, B, a;
    cin >> N >> A >> B;
    for(int i = 1; i < N + 1; i++){
        int c = 0, t = i;
        for(int j = 0; j < 5; j++){
            c += t % 10;
            t /= 10;
        }
        if(A <= c && c <= B) a += i;
    }
    cout << a << endl;


	return 0;
}

Measured memory_bytes: 256
def examC():
    N = I()
    a = LI()
    d = defaultdict(int)
    for i in a:
        d[i] +=1
    cur = 0
    for i,j in d.items():
        if i==j:
            continue
        elif i<j:
            cur += (j-i)
        else:
            cur +=j
    print(cur)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 18200
N,M=map(int,input().split())
xy = [list(map(int, input().split())) for _ in range(N)]
xy.sort(key = lambda x:x[0])
x,y = [list(i) for i in zip(*xy)]
nokori=M
ans=0
for i in range(N):
  ans+=x[i]*min(y[i],nokori)
  nokori-=y[i]
  if nokori<=0:
    break
print(ans)



Measured memory_bytes: 35856
#include <stdio.h>

#define MAX 500000
#define SENTINEL 2000000000
int L[MAX/2 + 2], R[MAX/2 + 2], cnt=0, A[MAX];

void mergeSort(int A[], int left, int mid ,int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1]=R[n2]=SENTINEL;
    int i=0, j=0;
    for (int k= left; k < right; k++) {
        if (L[i] <= R[j]){
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
        cnt++;
    }
}

void merge(int A[], int left, int right) {
    if (left + 1 < right) {
        int mid = (right + left) / 2;
        merge(A, left, mid);
        merge(A, mid ,right);
        mergeSort(A, left, mid, right);
    }
}

int main(void){
    int n;
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    merge(A, 0, n);
    
    for (int i = 0; i < n; i++) {
        if (i) printf(" ");
        printf("%d", A[i]);
    }
    
    printf("\n");
    printf("%d", cnt);
    printf("\n");
    
    return 0;
    
}



Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int n;
ll dp[2020][2020];
typedef pair<ll, int>pii;
vector<pii>vc;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		ll a;
		scanf("%lld", &a);
		vc.push_back(pii(a, i));
	}
	vc.push_back(pii(INF, 0));
	sort(vc.begin(), vc.end(), greater<pii>());
	for (int i = 1; i <= n; i++) {
		pii p = vc[i];
		dp[0][i] = dp[0][i - 1] + p.first*abs(p.second - (n - i + 1));
		dp[i][0] = dp[i - 1][0] + p.first*abs(p.second - i);
		for (int j = 1; j < i; j++) {
			dp[j][i - j] = max(dp[j][i - j], dp[j - 1][i - j] + p.first*abs(p.second - j));
			dp[j][i - j] = max(dp[j][i - j], dp[j][i - j - 1] + p.first*abs(p.second - (n - (i - j) + 1)));
		}
	}
	ll ans = 0;
	for (int i = 0; i <= n; i++)ans = max(ans, dp[i][n - i]);
	printf("%lld\n", ans);
	return 0;
}

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

#define sync {ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long int
#define mod 1000000007


void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    
    
    cout<<max({a*c,b*d,a*d,b*c});
    
    
}

int main()
{
    sync;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}







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

public class Main {
    static BufferedReader in;

    public static void solve() throws IOException {
        Integer[] ab = nextArray(2);
        int a= ab[0];
        int b = ab[1];

        StringBuilder res = new StringBuilder();
        if(a < b){
            while(b-->0){
                res.append(a);
            }
        }
        else{
            while (a-->0)
                res.append(b);
        }

        System.out.println(res.toString());

    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        solve();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(in.readLine().trim());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(in.readLine().trim());
    }

    static Integer[] nextArray(int n) throws IOException {
        StringTokenizer st = new StringTokenizer(in.readLine());
        Integer[] tmp = new Integer[n];
        for (int i = 0; i < tmp.length; i++) {
            tmp[i] = Integer.parseInt(st.nextToken());
        }

        return tmp;
    }

}



Measured memory_bytes: 21204
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        System.out.println(z + " " + x + " " + y);
    }
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}
/*
 Atcoder 100~200点代
 アな問題が多いので,まとめる
*/
// https://abc042.contest.atcoder.jp/tasks/abc042_a
//void solve(){ ll A,B,C; cin >> A >> B >> C; if(A == 5 && B == 5 && C == 7){ cout << "YES" << endl; return;} if(A == 5 && B == 7 && C == 5){ cout << "YES" << endl; return;} if(A == 7 && B == 5 && C == 5){ cout << "YES" << endl; return;} cout << "NO" << endl; return ; }
// https://abc043.contest.atcoder.jp/tasks/abc043_a
//void solve(){ ll N; cin >> N; cout << N*(N+1)/2 << endl; }
// https://abc044.contest.atcoder.jp/tasks/abc044_a
//void solve(){ll N,K,X,Y;cin>>N>>K>>X>>Y; cout<<X*min(N,K)+Y*max(0LL,N-K)<<endl;}
// https://abc045.contest.atcoder.jp/tasks/abc045_a
//void solve(){ll a,b,h;cin>>a>>b>>h;cout<<(a+b)*h/2<<endl;}
// https://abc046.contest.atcoder.jp/tasks/abc046_a
//void solve(){ ll a,b,c; cin >> a >> b >> c; set<ll> s; s.insert(a); s.insert(b); s.insert(c); cout << s.size() << endl; }
// https://abc047.contest.atcoder.jp/tasks/abc047_a
//void solve(){ll a,b,c;cin>>a>>b>>c;if(a==b+c||b==a+c||c==a+b)cout<<"Yes"<<endl;else cout<<"No"<<endl;}
// https://abc048.contest.atcoder.jp/tasks/abc048_a
//void solve(){string s1,s2,s3;cin>>s1>>s2>>s3;cout<<"A"<<s2[0]<<"C"<<endl;}
// https://abc049.contest.atcoder.jp/tasks/abc049_a
//void solve(){char c;cin>>c;string s="aiueo";if(s.find(c)!=string::npos)cout<<"vowel"<<endl;else cout<<"consonant"<<endl;}
// https://abc050.contest.atcoder.jp/tasks/abc050_a
//void solve(){ll A,B;char op;cin>>A>>op>>B;if(op=='+')cout<<A+B<<endl;else cout<<A-B<<endl;}
// https://abc051.contest.atcoder.jp/tasks/abc051_a
//void solve(){string s;cin>> s;cout<<s.substr(0,5)<<" "<<s.substr(6,7)<<" "<<s.substr(14)<<endl;}
// https://abc052.contest.atcoder.jp/tasks/abc052_a
//void solve(){ll A,B,C,D;cin>>A>>B>>C>>D;cout<<max(A*B,C*D)<<endl;}
// https://abc053.contest.atcoder.jp/tasks/abc053_a
//void solve(){ll x;cin>>x;cout<<(x<1200?"ABC":"ARC")<<endl;}
// https://abc054.contest.atcoder.jp/tasks/abc054_a
//void solve(){ll A,B;cin>>A>>B;if(A==1)A=14;if(B==1)B=14;cout<<(A>B?"Alice":(A==B?"Draw":"Bob"))<<endl;}
// https://abc055.contest.atcoder.jp/tasks/abc055_a
//void solve(){ll N;cin>>N;cout<<800*N-200*(N/15)<<endl;}
// https://abc056.contest.atcoder.jp/tasks/abc056_a
//void solve(){char a,b;cin>>a>>b;if(a=='H')cout<<b<<endl;else if(b=='H')cout<<'D'<<endl;else cout<<'H'<<endl;}
// https://abc057.contest.atcoder.jp/tasks/abc057_a
//void solve(){ll A,B;cin>>A>>B;cout<<(A+B)%24<<endl;}
// https://abc058.contest.atcoder.jp/tasks/abc058_a
void solve(){ll a,b,c;cin>>a>>b>>c;cout<<(b-a==c-b?"YES":"NO")<<endl;}

// Main function
int main(void) {cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }


Measured memory_bytes: 256
main=do
 n<-readLn;s<-getLine
 print(sum[f n s x y z|x<-"0123456789",y<-"0123456789",z<-"0123456789"])
  where f 0 _ _ _ _ = 0
        f n s 'a' 'a' z = if (head s)==z then 1 else (f (n-1) (tail s) 'a' 'a' z)
        f n s 'a' y z = f (n-1) (tail s) 'a' (if (head s)==y then 'a' else y) z
        f n s x y z = f (n-1) (tail s) (if (head s)==x then 'a' else x) y z

Measured memory_bytes: 4732
w,h,n=map(int,input().split())
b=[0,w,0,h]
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        b[0]=max(b[0],x)
    elif a==2:
        b[1]=min(b[1],x)
    elif a==3:
        b[2]=max(b[2],y)
    else:
        b[3]=min(b[3],y)
print(max(b[1]-b[0],0)*max(b[3]-b[2],0))

Measured memory_bytes: 3064
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = map(int,read().split())

ans = 0
for i in range(1,n):
    if a[i] < a[i-1]:
        ans += a[i-1]-a[i]
        a[i] = a[i-1]

print(ans)
#print(a)

Measured memory_bytes: 32200
#include<stdio.h>

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

int main()
{
	long long x,y,num;
	scanf("%lld%lld",&x,&y);
	num=gcd(x,y); 
	long long ans;
	ans=(x*y)/num;
	printf("%lld",ans);
	return 0;
}


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

int main(void){
    vector<vector<int>> a(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> a[i][j];
    int n;
    cin >> n;
    rep(i, n) {
        int b;
        cin >> b;
        rep(j, 3)
            rep(k, 3)
                if (a[j][k] == b)
                    a[j][k] = 0;
    }
    
    string ans = "No";
    rep(i, 3) {
        rep(j, 3) {
            if (a[i][j] != 0)
                break;
            if (j == 2)
                ans = "Yes";
        }
    }
    rep(i, 3) {
        rep(j, 3) {
            if (a[j][i] != 0)
                break;
            if (j == 2)
                ans = "Yes";
        }
    }
    rep(i, 3) {
        if (a[i][i] != 0)
            break;
        if (i == 2)
            ans = "Yes";
    }
    rep(i, 3) {
        if (a[i][2-i] != 0)
            break;
        if (i == 2)
            ans = "Yes";
    }
    
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,n) lower_bound(v.begin(),v.end(),n)-v.begin()
#define ub(v,n) upper_bound(v.begin(),v.end(),n)-v.begin()
#define mod 1000000007
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
/*bool fact(l n)
{
	vector<l> v;
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i%2==1||(n/i)%2==1)
			{
				return true;
			}
		}
	}
	return false;
}*/
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a);
		}
		b>>=1;
		a=(a*a);
	}
	return ans;
}//prefixsums
void frooty()
{
	l n;
	cin>>n;
	vector<l> v;
	for(l i=0;i<n;i++)
	{
		l a;
		cin>>a;
		v.pb(a);
	}
	sort1(v);
	reverse(v);
	l ans=v[0];
	l k=2;
	l in=1;
	while(k<n)
	{
		ans+=v[in];
		if(k%2==1)
			in++;
		k++;
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
//	cin>>q;
	while(q--)
	{
		frooty();
	}
}

Measured memory_bytes: 5308
a, b, x = map(int, input().split())

if a == b and a % x != 0:
  result = 0
  print(result)
  exit()
elif a == b and a % x == 0:
  result = 1
  print(result)
  exit()
else:
  B = divmod(b, x)
  A = divmod(a, x)
  result = B[0] - A[0]
  if A[1] == 0: result += 1
  print(result)
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX = 10000000;
const long long MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

//テーブルを作る前処理

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
    COMinit();
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= k; i++)
    {
        long long x = COM(k - 1, k - i);
        long long y = COM(n - k + 1, i);
        cout << x * y % MOD << endl;
    }
}

Measured memory_bytes: 234624
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var pmax = 1000000;
			var primes = new bool[pmax+1];
			var maxsq = (int)Math.Sqrt(pmax);
			for(var i=2;i<=pmax;i++)
				primes[i]=true;
			for(var i=2;i<=maxsq;i++)
				if(primes[i])
					for(var j=i*2;j<pmax;j+=i)
						primes[j]=false;
			List<int> num;
			while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){
				var menu = new List<int>();
				var order = new bool[num[1]+1];
				var max = 0;
				for(var i=0;i<num[0];i++)
					menu.Add(int.Parse(Console.ReadLine()));
				order[0]=true;
				for(var i=0;i<=num[1];i++)
					if(order[i]){
						menu.ForEach(x=>{if(i+x<=num[1])order[i+x]=true;});
						if(primes[i])
							max=i;
					}
				Console.WriteLine(max<1?"NA":"{0}",max);
			}
		}
	}
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>

int Baseball()
{
    int num_of_runner = 0, num_of_out = 0, point = 0;
    std::string event;
    
    while(num_of_out != 3){
        std::cin >> event;
        if(event == "HIT"){
            if(num_of_runner == 3)
                ++point;
            else
                ++num_of_runner;
        }
        else if(event == "HOMERUN"){
            point += 1 + num_of_runner;
            num_of_runner = 0;
        }
        else
            ++num_of_out;
    }
    
    return point;
}

int main()
{
    u_int num_of_inning;
    std::cin >> num_of_inning;
    
    for(u_int i = 0; i < num_of_inning; ++i){
        std::cout << Baseball() << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 1208
n = int(input())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
ｃ = list(map(int,input().split()))

before = -100
result = sum(b)

for i in a:
  if(i == before+1):
    result += c[before-1]
  before = i
  
print(result)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,t,x,y;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>t>>x>>y;
        if(!(x+y<=t&&(t-x-y)%2==0))
        {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}

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

int main() {
    int n, k, d, a;
    cin>>n >>k;
    vector<int> num(n);
    int ans=n;
    rep(i,k){
        cin>>d;
        rep(m,d){
            cin>>a;
            if(num.at(a-1)==0){
                ans--;
                num.at(a-1)++;
            }
        }
    }
    cout<<ans<<endl;
}

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


int main()
{
    /*A
    int a,p;
    cin>>a>>p;
    p+=a*3;
    cout<<p/2<<endl;
    */
    
    int n;
    cin>>n;
    vector <tuple<string,int,int>> p; 

    for(int i=0;i<n;i++)
    {
        string s;
        int pi;
        cin>>s>>pi;
        pi = -pi; //正負の反転→こうする事で大き物から順番に見せかけれる
        p.push_back(tie(s,pi,i));
    }   
    
    sort(p.begin(),p.end()); //一つ目の要素でまずソート(文字列の場合は辞書順)、一つ目が同じなら二個目の要素で（小さいものから順番に）、三つ目は二つ目が同じなら比較される

    for(int i=0;i<n;i++)
    {
        cout<<get<2>(p[i])+1<<endl;
    }

    return 0;
}

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

int main() {
    string s;
    cin >> s;
    string a = "abcdefghijklmnopqrstuvwxyz";

    for (int i = 0; i < 26; i++) {
        if (count(s.begin(), s.end(), a[i]) == 0) {
            cout << a[i] << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs =  Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            Console.WriteLine(CookieExchanges(inputs));
        }

        public static long CookieExchanges(long[] inputs)
        {            
            int count = -1;
            long sum = inputs.Sum();

            count = 0;

            while (!inputs.Any(x => x % 2 != 0))
            {
                if (inputs[0] == inputs[1] && inputs[0] == inputs[2] && inputs[0] % 2 == 0)
                {
                    return -1;
                }
                for (int i = 0; i < inputs.Length; i++)
                {
                    inputs[i] = (sum - inputs[i]) / 2;
                }
                count++;
            }

            return count;
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

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

  int count = 0;
  for (int i = 0; i < (int)S.size(); ++i)
  {
    if (S[i] == '+') ++count;
    else --count;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");

        final int N = Integer.parseInt(sc.next());
        Integer[] a = new Integer[N];
        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(a, Collections.reverseOrder());
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                alice += a[i];
            } else {
                bob += a[i];
            }
        }
        out.println(alice - bob);

        out.flush();
    }
}

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

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

    int c[3] = {1, 2, 3};
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(c[i] != a && c[i] != b){
            ans = c[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main(){
  ll h,w,n,x,y,j,k,l;
  cin>>h>>w>>n;
  map<pair<ll,ll>,ll> m;
  vector<ll> b(10);
  for(j=0;j<n;j++){
    cin>>x>>y;
    x--;y--;
    for(k=0;k<3;k++){
      if(x-k<0||x-k>h-3) continue;
      for(l=0;l<3;l++){
        if(y-l<0||y-l>w-3) continue;
        if(m.count(make_pair(x-k,y-l))) m.at(make_pair(x-k,y-l))++;
        else m[make_pair(x-k,y-l)]=1;
      }
    }
  }
  b[0]=(h-2)*(w-2);
  for(auto z:m){
    b[0]--;
    b[z.second]++;
  }
  for(j=0;j<10;j++) cout<<b[j]<<endl;
}

Measured memory_bytes: 59828
h, w = map(int, input().split())
ans = [[0]*w for _ in range(h)]
S = [["#"]*h for _ in range(w)]
for i in range(h):
    s = input().split('#')
    j = 0
    for c in s:
        for d in list(c):
            S[j][i] = d
            ans[i][j] += len(c)
            j += 1
        j += 1
for i in range(w):
    s = "".join(S[i]).split("#")
    j = 0
    for c in s:
        for d in list(c):
            ans[j][i] += len(c)
            j += 1
        j += 1

m = 0
for a in ans:
    if m < max(a):
        m = max(a)
print(m-1)


Measured memory_bytes: 219656
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int x,n,i,ii,iii,answer=0,j,jj,jjj;
        while(1){
            cin>>n>>x;
            answer=0;
        if(x==0 && n==0){
            break;
        }
        for(i=1;i<=n;i++){
            for(ii=1;ii<=n;ii++){
                for(iii=1;iii<=n;iii++){
                    if(i==ii || i==iii || ii==iii){}
                    else if(i<ii && ii<iii && i+ii+iii==x){answer++;}
            }
            }}
            
        cout<<answer<<endl;
    }
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

ll dp[15][15];

int main(){
    ll h,w;
    ll ans=0;
    cin>>h>>w;
    int c[10][10],a[h][w];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin>>dp[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
           cin>>a[i][j];
        }
    }
    for(int j=0;j<10;j++){
        for(int i=0;i<10;i++){
            for(int k=0;k<10;k++){
               dp[i][k]=min(dp[i][j]+dp[j][k],dp[i][k]);
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]==-1) continue;
            ans+=dp[a[i][j]][1];
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 384
from collections import deque
K = int(input())
q = deque([i for i in range(1, 10)])
cnt = 1
while q:
  n = q.popleft()
  if cnt == K:
    print(n)
    exit()
  if n % 10 - 1 >= 0:
    q.append(10 * n + n % 10 -1)
  q.append(10 * n + n % 10)
  if n % 10 + 1 <= 9:
    q.append(10 * n + n % 10 + 1)
  cnt += 1

Measured memory_bytes: 11908
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;
string s;

bool check(int k) {
	int res = 0, len = 0;
	for (int i = n - k + 1; i <= k; i++) {
		res += s[i - 1] - '0';
		len++;
	}
	return (res == 0 || res == len);
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> s;
	n = s.size();
	int l = 1, r = n + 1;
	while (l < r - 1) {
		int mid = l + r >> 1;
		if (check(mid))
			l = mid;
		else
			r = mid;
	}
	cout << l;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ldb;
typedef pair<ll,ll> pll;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define V vector
#define endl "\n"
#define CLEAR(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ios_tie() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(nullptr)
#define trace1(a)             cout <<#a<<":"<<a<< endl;
#define trace2(a,b)           cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<< endl;
#define trace3(a,b,c)         cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<endl;
#define trace4(a,b,c,d)       cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<" | "<<#d<<":"<<d<<endl;

const ll inf = 1e18;
const ll mod = 1e9+7;
const ll maxn = 1e5+10;
const ldb PI = acos(-1);

void lol(ll s) {cerr<<"check........................................... "<<s<<endl;}
ll power(ll x,ll y) {ll res=1; x%=mod; while(y) {if(y&1) res=(res*x)%mod; y>>=1LL; x=(x*x)%mod; }return res;}
ll inv(ll x) {return power(x,mod-2);}//(1/x)%y = x^(y-2) % y;   // pow(x,y)%m = pow(x,y%(m-1))%m
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// I can solve mirror cube in 2 mins but can't solve div2 C in 1hr.
ll freq[1000001];
void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    rep0(i,n) {
        cin>>a[i];
        freq[a[i]]++;
    }
    // a[i]%a[j] != 0
    ll res = 0;
    rep1(i,1000000) {
        if(freq[i]==1)
            res++;
        if(freq[i]==0)
            continue;
        for(int j=2*i;j<=1000000;j+=i) {
            freq[j] = 0;
        }
    }
    cout<<res<<endl;
}
int main()
{
    ios_tie();
    // freopen("input.txt", "r", stdin);
    // freopen("myOut.txt", "w", stdout);
    ll _ = 1;
    // cin>>_;
    rep1(i,_)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

bool check(string &s, int a, int c){
    bool sol = true;
    for (int i=a+1; i<c; i++){
        if (s[i]!='.' && s[i+1]!='.'){
            sol = false;
            break;
        }
    }
    sol &= s[c] == '.';
    if (sol) {
        s[a] = '.';
        s[c] = 'X';
    }
    return sol;
}

int spot(string& s, int b, int d){
    for(int i=b+1; i+1<=d; i++){
        if (s[i-1]=='.' && s[i]=='.' && s[i+1]=='.')
            return i;
    }
    return -1;
}

int main(int argc, char** argv) {
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--; b--; c--; d--;
    string s;
    cin >> s;

    s[a] = 'A';
    s[b] = 'B';
    bool sol = false;
    {
        string s2 = s;
        bool sol1 = check(s2, b, d);
        sol1 &= check(s2, a, c);
        sol |= sol1;
    }
    {
        s[b]='.';
        int b2 = spot(s, b, d);
        s[b]='B';
        if (b2>0){
            string s2 = s;
            bool sol1 = check(s2, b, b2);
            sol1 &= check(s2, a, c);
            sol1 &= check(s2, b2, d);
            sol |= sol1;
        }
    }
    {
        string s2 = s;
        bool sol1 = check(s2, a, c);
        sol1 &= check(s2, b, d);
        sol |= sol1;
    }
    {
        s[a] = '.';
        int a2 = spot(s, a, c);
        s[a] = 'A';
        if (a2>0){
            string s2 = s;
            bool sol1 = check(s2, a, a2);
            sol1 &= check(s2, b, d);
            sol1 &= check(s2, a2, c);
            sol |= sol1;
        }
    }

    if (sol)
        cout << "Yes\n";
    else
        cout << "No\n";

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int h, w;
string s;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  FOR(i, 0, h) FOR(j, 0, w){
    cin >> s;
    if(s=="snuke"){
      cout << char('A'+j) << i+1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
 
 
using namespace std;
 
const ll N = 4e5;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;
 
ll n;
ll a[N], b[N], dp[N], ans;
vector<ll> x;
int main() {
	speed;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		x.pb(a[i]);
	}
	sort(all(x));
	for(int i = 1; i <= n; i++) {
		a[i] = lower_bound(all(x), a[i]) - x.begin() + 1;
		ans += (a[i] % 2 != i %2);
	}
	cout << ans / 2;
}
 
/*
4
1 2 3 4
*/

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

int main() {
  int n,k;
  cin >> n >>k;
  int h[n];
  for(int i=0;i<n;i++){
      cin >> h[i];
  }

  int ans=0;

  for(int i=0;i<n;i++){
      if(h[i]>=k){
          ans+=1;
      }
      
  }
  cout << ans << endl;
  }





  


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

using namespace std;

#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
int main() {
    //OJ;
	vector<int> v(5);
	for(int &x:v){
		cin>>x;
	}
	for(int i=0;i<5;i++){
		if(v[i]==0){
			cout<<i+1;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

typedef long long ll;

ll c[30],s[370][30];
int a[370],last[30];

unsigned seed=chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(seed);

ll f(int d)
{
    ll x=0;
    memset(last,-1,sizeof(last));
    for(int i=0;i<d;i++){
        ll y=s[i][a[i]];
        last[a[i]]=i;
        for(int j=0;j<26;j++){
            y-=c[j]*(ll)(i-last[j]);
        }
        x+=max(y+1000000ll,0ll);
    }
    return x;
}

int main()
{
    auto start=chrono::high_resolution_clock::now();
    ll x=-1,sc=0;
    int d,ans[370];
    scanf("%d",&d);
    for(int i=0;i<26;i++){
        scanf("%lld",&c[i]);
        sc+=c[i];
    }
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            scanf("%lld",&s[i][j]);
        }
    }
    if(sc==0){
        for(int i=0;i<d;i++){
            int mx=-1,j=-1;
            for(int k=0;k<26;k++){
                if(s[i][k]>mx) mx=s[i][k],j=k;
            }
            printf("%d\n",j+1);
        }
        return 0;
    }
    while(true){
        for(int i=0;i<d;i++) a[i]=rng()%26;
        ll y=f(d);
        if(y>x) copy(a,a+d,ans),x=y;
        auto stop=chrono::high_resolution_clock::now();
        int duration=chrono::duration_cast<chrono::microseconds>(stop-start).count();
        if(2000000-duration<100000 && x>0) break;
    }
    for(int i=0;i<d;i++){
        printf("%d\n",ans[i]+1);
    }
    return 0;
}

Measured memory_bytes: 3852