akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = INF; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> N;
	string S;
	cin >> S;
	vl B(N + 1);
	for (i = 0; i < N; i++) B[i + 1] = B[i] + (S[i] == '#');
	//i個目まで.、i+1個目から#
	for (i = 0; i <= N; i++) {
		ans = min(ans, B[i] + ((N - i) - (B[N] - B[i])));
	}
	cout << ans;
}

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

int main () {
  int n;
  cin >> n;
  
  vector<int> d(n);
  for (int i = 0; i < n; i++) cin >> d.at(i);
  
  int biggest = 0, counter = 0;
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < n; i++) if (biggest < d.at(i)) biggest = d.at(i);
    if (biggest != 0) counter++;
    for (int i = 0; i < n; i++) if (biggest == d.at(i)) d.at(i) = 0;
    biggest = 0;
  }
  
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M; cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int j = 0; j < M; j++) cin >> B[j];
    
    for(int i = 0; i < N - M + 1; i++){
        for(int j = 0; j < N - M + 1; j++){
            bool ok = true;
            for(int a = 0; a < M; a++){
                for(int b = 0; b < M; b++){
                    if(A[i+a][j+b]!=B[a][b])ok = false;
                }
            }
            if(ok){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

#define MOD 1000000007

int main(int argc, const char * argv[]) {
    int N, M;
    cin >> N;
    cin >> M;
    
    int danger[N+1];
    memset(danger, 0, sizeof(danger));
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        danger[a] = 1;
    }
    
    int c[N+1];
    c[0] = 1;
    c[1] = (danger[1] == 0) ? 1 : 0;
    for (int i = 2; i <= N; i++) {
        c[i] = 0;
        if (danger[i] == 1) {
            continue;
        }
        c[i] += (danger[i-2] == 0) ? c[i-2] : 0;
        c[i] += (danger[i-1] == 0) ? c[i-1] : 0;
        c[i] %= MOD;
    }
    
    cout << c[N] << endl;
    
    return 0;
}


Measured memory_bytes: 1024
N = input()
S = raw_input()

l, r = 0, 0
tmp = 0
for i in xrange(N):
    if S[i] == '(':
        tmp += 1
    else:
        tmp -= 1
        if tmp < 0:
            l += 1
            tmp = 0

tmp = 0
for i in xrange(N-1, -1, -1):
    if S[i] == ')':
        tmp += 1
    else:
        tmp -= 1
        if tmp < 0:
            r += 1
            tmp = 0
print '(' * l + S + ')' * r


Measured memory_bytes: 2568
#include<iostream>
#include<vector>
#include<cmath>
#include<deque>
using namespace std;

long long mypow(long long x, long long y);

int main(){
    int K;
    long long count = 0;
    long long temp;
    int keta = 0;
    std::cin >> K;
    deque<long long> lunlun_list;

    //まず1~9までを格納
    for(int i = 1; i < 10; i++){
        lunlun_list.push_back(i);
    }

    while(1){
        temp = lunlun_list[0];
        lunlun_list.pop_front();
        count++;
        if(count == K){
            break;
        }

        if(temp%10 != 0){
            lunlun_list.push_back(temp * 10 + temp%10 -1);
        }
        lunlun_list.push_back(temp * 10 + temp%10);
        if(temp%10 != 9){
            lunlun_list.push_back(temp * 10 + temp%10 + 1);
        }
    }

    std::cout << temp;

    
}

long long mypow(long long x, long long y){
    long long ans = 1;
    for(long long i = 0; i < y; i++){
        ans = ans * x;
    }
    return ans;
}



Measured memory_bytes: 5036
#abc096 c
h,w=map(int,input().split())
maze=[]
move=[[1,0],[0,1],[-1,0],[0,-1]]
for i in range(h):
    line=input()
    maze.append(line)

def no_conf(y,x):
    flag=False
    for i in move:
        my,mx=[a+b for a,b in zip(i,[y,x])]
        if 0<=my<h and 0<=mx<w:
            if maze[my][mx]=="#":
                flag=True
    return flag
ans=True
for i in range(h):
    for j in range(w):
        if maze[i][j]=="#":
            if no_conf(i,j)==False:
                ans=False
                break
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int x = min(a, b);
  int y = max(0, a + b - n);
  cout << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  ll ans = N/2*min(8*Q, min(4*H, min(2*S, D))) + N%2*min(4*Q, min(2*H, S));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  vector<int> dp(n,2e+9);
  dp[0] = 0;
  rep(i,n){
    if(i-2>=0) dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    else if(i-1>=0) dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
  }
  cout << dp[n-1] << "\n";
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""abc079_d"""

import sys
import pprint
import re

import itertools
pp = pprint.PrettyPrinter(indent=2)


def main():
    """Main function."""
    h,w = list(map(int, input().split(' ')))

    cs = []
    for i in range(10):
        cs.append([c for c in list(map(int, input().split(' ')))])

    as_ = []
    for i in range(h):
        as_.append([a for a in list(map(int, input().split(' ')))])

    for k in range(10):
        for i in range(10):
            for j in range(10):
                if cs[i][j] > cs[i][k] + cs[k][j]:
                    cs[i][j] = cs[i][k] + cs[k][j]

    res = 0
    for line in as_:
        for v in line:
            if v != -1:
                res += cs[v][1]

    print(res)


if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 3956
import math
n=int(input())
def fac(n):
    arr=[]
    temp=n
    for i in range(2,math.ceil(math.sqrt(n)+1)):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp//=i
            arr.append([i,cnt])
    if temp!=1:
        arr.append([temp,1])
    if arr==[]:
        arr.append([n,1])
    return arr
l=fac(n)
if n==1:
    print(0)
else:
    ans=0
    for i in range(len(l)):
        count=l[i][1]
        p=0
        k=1
        while count>0:
            if count-k<0:
                break
            p+=1
            count-=k
            k+=1
        ans+=p
    print(ans)


        

Measured memory_bytes: 9220
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = list(iss())
    print('Yes' if N[0] == N[1] == N[2] or N[1] == N[2] == N[3] else 'No')


if __name__ == '__main__':
    main()


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

const int N = 10 + 5;

vector<int> a[N];
int p[N], cnt[N], on[N];

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        while (k--) {
            int x;
            cin >> x;
            --x;
            a[i].push_back(x);
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for (int _ = 0; _ < (1 << n); _++) {
        for (int i = n - 1; i >= 0; i--) {
            on[i] = ((_ >> i) & 1);
        }
        bool ok = true;
        for (int i = 0; i < m; i++) {
            cnt[i] = 0;
            for (int x : a[i]) {
                if (on[x]) ++cnt[i];
            }
            if ((cnt[i] % 2) != p[i]) {
                ok = false;
                break;
            }
        }
        if (ok) ++ans;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)

if n >= m or m==1:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1)]
    x_sub = sorted(x_sub)
    print(sum(x_sub[:(m-1)-(n-1)]))


Measured memory_bytes: 13840
import sys


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


# A
def A():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return


# B
def B():
    s = S()
    for i in range(len(s)):
        if i % 2:
            if s[i] not in ["L", "U", "D"]:
                print("No")
                return
        else:
            if s[i] not in ["R", "U", "D"]:
                print("No")
                return
    print("Yes")
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    B()
    return


# Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 38256
x,k,d = [int(x) for x in input().split()]
if x < 0:
  x *= -1
def f():
  c = 0
  if x - (k * d) > 0:
    c = x - (k * d)
    return True
  return False

def check():
  l = 0
  r = k
  while l <= r:
    m = (r + l) // 2
    p = x - d * (2 * m - k)
    #print(l,m,r,p)
    if p > d:
      l = m + 1
    elif p < -1 * d:
      r = m - 1
    else:
      return m
  return m

if f():
  print(x - (k * d))
else:
  m1 = check()
  t = x - d * (2 * m1 - k)
  print(abs(t))


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


 
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
  
  int n,h;
  int mx=0;
  int count=0;
  scanf("%d %d",&n,&h);
  //cin >> n >> h;
  for(int i=1;i<n;i++){
    int hh=0;
    scanf("%d",&hh);
    //cin >> hh;
  	if(hh<=h){
    	count++;
    }else{
    	mx=max(count,mx);
    	//if(count>mx){mx=count;}
    	count=0;
    }
    h=hh;
  }
  mx=max(count,mx);
  //if(count>mx){mx=count;}
  printf("%d\n",mx);
  //cout << mx;
  
  

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)
//__builtin_popcountll()



int main(){

    fast;
    int n,i,j;
    cin>>n;
    vector<int>a(n),b(n);
    for(i=0;i<n;i++)
    cin>>a[i];
    for(i=0;i<n;i++)
    cin>>b[i];
    reverse(all(b));
    vector<int>v;
    for(i=0;i<n;i++)
    {
    	if(a[i]==b[i])
    	v.pb(i);
	}
	if(v.size()!=0)
	{
		int l=v[0];
		int r=v[(int)v.size()-1];
		int x=a[l];
		for(i=0;i<n;i++)
		{
			if(a[i]!=x&&b[i]!=x&&l<=r)
			{
				swap(b[i],b[l]);
				l++;
			}
		}
		if(l<=r)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes\n";
	for(i=0;i<n;i++)
	{
		cout<<b[i]<<" ";
	}
    
    
    

    

}

Measured memory_bytes: 5700
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

ans = 0
now = 0
bot = sum(A2)

for a1, a2 in zip(A1, A2):
    now += a1
    ans = max(ans, now + bot)
    bot -= a2

print(ans)

Measured memory_bytes: 3064
import math
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right
# import numpy as np

def s_inpl(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
INF = float("inf")

N = int(input())
act = []
for _ in range(N):
    act_i = inpl()
    act.append(act_i)

dp = [[0, 0, 0] for _ in range(N+1)]

for i in range(N):
    # 遷移先
    for j in range(3):
        # 遷移元
        for k in range(3):
            if j == k:
                continue
            dp[i+1][j] = max(dp[i+1][j], dp[i][k] + act[i][j])

ans = 0
for k in range(3):
    ans = max(ans, dp[N][k])

print(ans)

Measured memory_bytes: 79320
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')

s = input()
l = len(s)
t = s + 'o' * (15 - l)
Y(t.count('o') >= 8)

Measured memory_bytes: 5880
#include <iostream>
#include <vector>
#include <tuple>
#include <string>
#include <algorithm>
using namespace std;
int main(){

  int n;
  vector <tuple<int,int,string,long long,string> > a;
  cin>>n;
  for(int i=0;i<n;i++){
    int v,w;
    string t,s;
    long long d;
    cin>>v>>w>>t>>d>>s;
    a.push_back(make_tuple(v,w,t,d,s));
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    cout<<get<0>(a[i])<<" "<<get<1>(a[i])<<" "<<get<2>(a[i])<<" "<<get<3>(a[i])<<" "<<get<4>(a[i])<<endl;
  }
  return 0;

}



Measured memory_bytes: 16884
import numpy as np

N, K = map(int, input().split())
E = list(map(lambda x: (int(x)+1)/2, input().split()))
E_cumsum = np.cumsum(E)

ans = E_cumsum[K-1]
for i in range(0, N-K):
    e = E_cumsum[i+K] - E_cumsum[i]
    ans = max(ans, e)
print(ans)



Measured memory_bytes: 32344
#include <algorithm>
#include <iostream>
using namespace std;
int a[1000006];
int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++ i)
        cin >> a[i];
    sort(a + 1, a + 1 + n);
    for (int i = n, j = 1; i; -- i, ++ j)
        if (j + 1 > a[i - 1]){
            int ans = 0;
            for (int k = i - 1; k && a[k] == j; -- k)
                ans ^= 1;
            ans |= (a[i] - j) & 1;
            if (ans == 1)
                cout << "First" << endl;
            else
                cout << "Second" << endl;
            return 0;
        }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n;
string s,t;
char change(char c)
{
	if(c=='S')
		return 'W';
	else
		return 'S';
}
bool ok(char a,char x,char y,char b)
{
	if(x=='o'&&y=='S'&&a=='S'&&b=='S')return true;
	if(x=='o'&&y=='S'&&a=='W'&&b=='W')return true;
	if(x=='x'&&y=='S'&&a=='S'&&b=='W')return true;
	if(x=='x'&&y=='S'&&a=='W'&&b=='S')return true;
	if(x=='o'&&y=='W'&&a=='S'&&b=='W')return true;
	if(x=='o'&&y=='W'&&a=='W'&&b=='S')return true;
	if(x=='x'&&y=='W'&&a=='S'&&b=='S')return true;
	if(x=='x'&&y=='W'&&a=='W'&&b=='W')return true; 
	return false;
}
void dfs(int now)
{
	if(now==n-1)
	{
		if(ok(t[n-2],s[n-1],t[n-1],t[0])&&ok(t[n-1],s[0],t[0],t[1]))
		{
			cout<<t<<endl;
			exit(0);
		}
		return;
	}
	int bef=now-1;
	int nxt=now+1;
	if(t[now]=='S')
	{
		if(s[now]=='x')t[nxt]=change(t[bef]);
		else t[nxt]=t[bef];
	}
	else
	{
		if(s[now]=='o')t[nxt]=change(t[bef]);
		else t[nxt]=t[bef];
	}
	dfs(now+1);
}
int main()
{
	cin>>n;
	cin>>s;
	t=s;
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<2;j++)
		{
			t[0]=(i==0?'S':'W');
			t[1]=(j==0?'S':'W');
			dfs(1);
		}
	}
	cout<<"-1\n";
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define mp make_pair
// GCD inbuilt func: __gcd(a,b)
// LCM formula: (a*b)/__gcd(a,b)

int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
	// CODE goes here
    int a[5];
    int ans;
    for(int i=0;i<5;i++){
    	cin >> a[i];
    	if(a[i]==0) ans=i+1;
    }
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int h = tx - sx, w = ty - sy;
  string a(h, 'R');
  string b(w + 1, 'U');
  string c(h + 1, 'L');
  string d(w + 1, 'D');
  string e(1, 'R');
  string f(1, 'D');
  string g(h + 1, 'R');
  string H(w + 1, 'U');
  string i(h + 1, 'L');
  string j(w, 'D');
  cout << a + b + c + d + e + f + g + H + i + j << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[200005];
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=2;i<=n;i++)
    {
        cin>>a[i];
        adj[a[i]].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        cout << adj[i].size() << "\n";
    }
}


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

int main(int argc, const char * argv[]) {
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int counter = 0;
    
    for(int i=0;i<s.size();i++){
        if(s[i]=='1')
            counter++;
    }
    
    cout << counter << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
       fast;
       ll n;
       cin>>n;
       int arr[n];
       for(int i=0;i<n;i++)
    	cin>>arr[i];
    if(n%2)
    {
    	cout<<0;
    	return 0;
    }
       sort(arr,arr+n);
       cout<<max(0,arr[n/2]-arr[n/2-1]);
       return 0;
}


Measured memory_bytes: 4012
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {

	long long int n, m, k;
	cin >> n >> m >> k;

	bool h = false;

	for (long long int i = 0; i <= n; i++) {
		for (long long int j = 0; j <= m; j++) {
			long long int ans = 0;
			ans = i*m + j*n - 2*i*j;
			if (k == ans) {
				h = true;
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int X;
  cin >> X;

  int a = X / 500 * 1000;
  int b = X % 500 / 5 * 5;

  cout << a + b << endl;
}


Measured memory_bytes: 3632
def f(x, y):
  c = 6
  for a, b in zip(A, B):
    if x <= a and y <= b: c -= 1
  return c

A = range(60, 180, 20)
B = [2] + range(5, 30, 5)
C = range(600, 1800, 200)

while 1:
  n = input()
  if n==0: break
  s = 0
  for _ in [0]*n:
    x, y, h, w = map(int, raw_input().split())
    r = f(x+y+h, w)
    if r<6: s += C[r]
  print s

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"
#include "profile.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define profile(X) LOG_DURATION(X)
#else
#define debug(...) 42
#define profile(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 600001;
const ll MOD = 1e9 + 7;
using cd = complex<double>;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

struct basis {
    ll pivot[60];
    bool empty = false;

    void add(ll val) {
        for (int i = 0; i < 60; ++i) {
            if (val & (1ll << i)) {
                val ^= (pivot[i]);
            }
        }
        for (int i = 0; i < 60; ++i) {
            if (val & (1ll << i)) {
                pivot[i] = val;
                for (int e = 0; e < 60; ++e) {
                    if (e == i) {
                        continue;
                    }
                    if (pivot[e] & (1ll << i)) {
                        pivot[e] ^= pivot[i];
                    }
                }
                break;
            }
        }
    }

    bool has(ll val) {
        for (int i = 0; i < 60; ++i) {
            if (val & (1ll << i)) {
                val ^= pivot[i];
            }
        }
        return val == 0;
    }
};

basis dp[201];

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif

    auto solve = [&](int _) {
        int n;
        cin >> n;
        vector<ll> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        string s;
        cin >> s;
        reverse(s.begin(), s.end());
        reverse(a.begin(), a.end());

        for (int i = 0; i < s.size(); ++i) {
            if (s[i] == '0') {
                dp[i + 1] = dp[i];
                dp[i + 1].add(a[i]);
            } else {
                dp[i + 1] = dp[i];
                if (!dp[i].has(a[i])) {
                    dp[i + 1].empty = true;
                }
            }
        }
        cout << (dp[n].empty ? 1 : 0) << "\n";
    };

    fast_io();
    cout.precision(9);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int t;
    cin >> t;

    for (int i = 1; i <= t; ++i) solve(i);
    auto end = chrono::steady_clock::now();

    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
using sint = int64_t;

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint const n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

inline sint gcd(sint y, sint x) {
	while (x != 0) {
		sint const t = y % x;
		y = x;
		x = t;
	}
	return y;
}

inline sint pow_mod(sint const a, sint const n, sint const p) {
	if (n == 0) {
		return 1;
	}
	sint const h = pow_mod(a, n / 2, p);
	sint const f = (h * h) % p;
	if (n % 2 == 1) {
		return (a * f) % p;
	}
	else {
		return f;
	}
}

inline sint rcp_mod(sint const a, sint const p) {
	assert(a % p != 0);
	return pow_mod(a, p - 2, p);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	auto const N = read<sint>();
	auto const M = read<sint>();
	sint n_ac = 0;
	sint n_wa = 0;
	vector<sint> n_was(N, 0);
	vector<bool> acs(N, false);
	for (sint i = 0; i < M; ++i) {
		sint p = read<sint>() - 1;
		bool ac = read<string>() == "AC";
		if (acs[p]) {
			continue;
		}
		if (ac) {
			acs[p] = true;
			n_wa += n_was[p];
			++n_ac;
		}
		else {
			++n_was[p];
		}
	}
	writeln(n_ac, n_wa);
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1 << 30;

int main(int argc, char* argv[])
{
  int n;
  std::cin >> n;

  std::vector< std::string > vs(n, "");


  for (int i = 0; i < n; i++) {
    std::cin >> vs[i];
    std::sort(vs[i].begin(), vs[i].end());
  }

  std::vector< std::string::iterator > vit(n);
  for (int i = 0; i < n; i++) {
    vit[i] = vs[i].begin();
  }

  std::string ans = "";
  std::string::iterator it;
  for (it = vs[0].begin(); it != vs[0].end(); it++) {
    int cnt = 1;
    for (int i = 1; i < n; i++) {
      std::string::iterator it2;
      while(vit[i] != vs[i].end()) {
	if (*it > *vit[i]) {
	  vit[i]++;
	} else {
	  if (*it == *(vit[i])) {
	    cnt++;
	    vit[i]++;
	  }
	  break;
	}
      }
    }
    if (cnt == n) {
      ans.push_back(*it);
    }
  }
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
p = []
for i in range(N):
    _p = int(input())
    p.append(_p)
biggest = 0
j = 0
for i in range(N):
    if(p[i]>=biggest):
        j = i
        biggest=p[i]
p[j] = p[j] / 2
print(int(sum(p)))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;


#if 1
ll gcd(ll x,ll y){
  if(x<y) swap(x,y);
  //xの方が常に大きい
  while(y>0){
    ll r=x%y;
    x=y;
    y=r;
  }
  return x;
}

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

//vに素因数分解した要素突っ込む
void Prime_factorize(vector<ll>& v,ll n){
  if(n<=1) return;
  ll l=ll(sqrt(n));
  for(ll i=2;i<l+1;i++){
    if(n%i==0){
      Prime_factorize(v,i);Prime_factorize(v,ll(n/i));return;
    }
  }
  v.push_back(n);return;
}

void erase_same(vector<ll>& v){
  sort(v.begin(),v.end());
  //隣接している重複した要素を除いた要素を先頭に集めるのが、unique関数
  //集めた後の返り値は重複を除いた範囲の末尾の次のイテレータになる(つまり、このイテレータ以降の要素はゴミ)
  v.erase(unique(v.begin(),v.end()),v.end());
}

#endif
//n個の場合のlcmも2個で比べて順に適用していくだけ
int main(){
  ll a,b;cin >> a >> b;
  ll k=gcd(a,b);
  vector<ll> fac;
  Prime_factorize(fac,k);
  erase_same(fac);
  cout << fac.size()+1 << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
LL ans[N];
class UnionFind
{
public:
	int p[N];
	void init(int n = N)
	{
		memset(p, -1, sizeof(int) * n);
	}
	int treesize(int x)
	{
		return -p[Find(x)];
	}
	int Find(int x)
	{
		int s = x;
		while (p[s] >= 0) s = p[s];
		while (x != s)
		{
			int t = p[x];
			p[x] = s;
			x = t;
		}
		return s;
	}
	void Union(int x, int y)
	{
		int px = Find(x);
		int py = Find(y);
		if (p[px] > p[py]) swap(px, py);
		p[px] += p[py];
		p[py] = px;
	}
} uf;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	uf.init();
	vector<pair<int, int>> vp(m);
	for (auto& p : vp) cin >> p.first >> p.second;
	LL tot = 1LL * n * (n - 1) / 2;
	for (int i = m - 1; i >= 0; i--)
	{
		ans[i + 1] = tot;
		int x, y;
		tie(x, y) = vp[i];
		if (uf.Find(x) != uf.Find(y))
		{
			tot -= 1LL * uf.treesize(x) * uf.treesize(y);
			uf.Union(x, y);
		}
	}
	for (int i = 1; i <= m; i++)
		printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, s, t, u;
  in3(a, b, c);
  s = a * 10 + b + c;
  t = a + b * 10 + c;
  u = a + b + c * 10;
  out(max({s, t, u}));
  memi;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created by sd on 2016/11/22.
 */
public class Main {
    static class Pair{
        String name;
        int left;
        Pair(String name, int left){
            this.name = name;
            this.left = left;
        }
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        LinkedList<Pair> queue = new LinkedList<>();
        int n = sc.nextInt(), q = sc.nextInt();
        int time_w = 0;
        for(int i=0; i<n; i++){
            String str = sc.next();
            int time = sc.nextInt();

            if(time > q){
                time_w += q;
                queue.add(new Pair(str, time-q));
            }else{
                time_w += time;
                System.out.println(str+" "+time_w);
            }
        }
        while(!queue.isEmpty()){
            Pair p = queue.poll();
            String str = p.name;
            int time = p.left;
            if(time > q){
                time_w += q;
                queue.add(new Pair(str, time-q));
            }else{
                time_w += time;
                System.out.println(str+" "+time_w);
            }
        }

    }
}

Measured memory_bytes: 70064
#include<iostream>

using namespace std;
int main(){
  string s;
  cin >> s;
  //AAA or BBB => No
  if(s[0] == 'A' && s[1] == 'A' && s[2] == 'A') cout << "No" << endl;
  else if(s[0] == 'B' && s[1] == 'B' && s[2] == 'B') cout << "No" << endl;
  else cout << "Yes" << endl;
  
}
  


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

double dist(int i,int j,int d,vector<vector<int> > x) {
    double s=0.0;
    for (int k = 0; k < d; k++)
    {
        s += (double)pow(x[i][k]-x[j][k], 2);
    }
    return sqrt(s);
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n,d;
    cin >> n >> d;
    int ans = 0;
    vector<vector<int> > x(n, vector<int>(d));
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> x[i][j];
        }
    }

    
    
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            if (fmod(dist(i,j,d,x), 1.0) < 0.00001) ans++;
        }
        
    }

    cout << ans << "\n";
    return 0;
    

}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int[] aArr = fs.nextIntArr(n);
		
		int ans = 0;
		
		// -1 or 0 or 1
		int zouka = 0;
		
		int beforeVal = aArr[0];
		for(int i = 1; i < n; i++) {
			
			int now = 0;
			if(beforeVal > aArr[i]) {
				now = -1;
			}else if(beforeVal < aArr[i]){
				now = 1;
			}
			
			
			if(now == 0) {
				continue;
			}
			
			if(zouka == 0) {
				zouka = now;
				beforeVal = aArr[i];
				continue;
			}
			
			if(zouka != now) {
				zouka = 0;
				ans++;
				beforeVal = aArr[i];
			}else {
				beforeVal = aArr[i];
			}
		}
		
		ans++;
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 45220
n=io.read("*n","*l")
t={}
for i=2,n do
    a=io.read("*n")
    if not t[a] then
        t[a]=1
    else
        t[a]=t[a]+1
    end
end

for i=1,n do
    if not t[i] then
        print(0)
    else
        print(t[i])
    end
end

Measured memory_bytes: 6340
#include <iostream>
#include <numeric>
#include <vector>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

constexpr int MOD = 100000;

void solve() {
    int h, w;
    std::cin >> h >> w;

    int tot = 1;
    const int mask = (1 << (w - 1)) - 1;
    auto dp = vec(3, vec(1 << (w - 1), 0));
    dp[0][0] = 1;
    auto ndp = dp;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            for (auto& v : ndp) std::fill(v.begin(), v.end(), 0);

            int id;
            {
                char c;
                std::cin >> c;
                for (id = 0; id < 3; ++id) {
                    if (c == "JOI"[id]) break;
                }
            }

            if (id == 3) (tot *= 3) %= MOD;

            for (int p = 0; p < 3; ++p) {
                for (int k = 0; k < 3; ++k) {
                    if (id != 3 && k != id) continue;

                    for (int b = 0; b < (1 << (w - 1)); ++b) {
                        if (k == 2 && ((b >> (w - 2)) & 1)) continue;

                        int nb = ((b << 1) & mask) + (p == 0 && k == 1 && j != 0);
                        ndp[k][nb] += dp[p][b];
                        if (ndp[k][nb] >= MOD) ndp[k][nb] -= MOD;
                    }
                }
            }
            std::swap(dp, ndp);
        }
    }

    int out = 0;
    for (const auto& v : dp) {
        for (const auto& x : v) {
            out += x;
            if (out >= MOD) out -= MOD;
        }
    }

    std::cout << (tot - out + MOD) % MOD << "\n";
}

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

    solve();

    return 0;
}



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

int main() {
	int w,a,b;
	cin >> w >> a >> b;
	int mx = max(a,b),mn = min(a,b),k = 0;
	if(mn + w < mx)
	{
		k = mx - mn - w;
	}
    cout << k << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(ll i = (n); i <(m); i++)
#define rrep(i,n,m) for(ll i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main()
{
    ll n, k;
    cin >> n >> k;

    vector<pll> sushi;
    rep(i, 0, n)
    {
        int t, d;
        cin >> t >>d;
        sushi.emplace_back(d, t);
    }
    sort(sushi.rbegin(), sushi.rend());

    vector<ll> tops;
    vector<ll> seconds;
    set<ll> neta_set;
    for (auto taste_neta: sushi)
    {
        ll taste = taste_neta.first;
        ll neta = taste_neta.second;

        if (neta_set.count(neta) > 0)
            seconds.push_back(taste);
        else
        {
            neta_set.insert(neta);
            tops.push_back(taste);
        }
    }

    vector<ll> cum_tops(tops.size() + 1, 0);
    vector<ll> cum_seconds(seconds.size() + 1, 0);
    rep(i, 0, tops.size())
        cum_tops[i + 1] = cum_tops[i] + tops[i];
    rep(i, 0, seconds.size())
        cum_seconds[i + 1] = cum_seconds[i] + seconds[i];


    ll ans = 0;
    rep(var, 1, k + 1)
    {
        ll now = 0;
        int num_top = min(var, (ll)neta_set.size());
        int num_second = min(k - var, (ll)seconds.size());
        now += (ll)num_top * num_top + cum_tops[num_top];
        now += cum_seconds[num_second];
        ans = max(ans, now);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8048
#include<cstdio>
#include<cstring>

int n,a[100001],t0[100001],t1[100001],ma0,ma1,maa0,maa1,m0,m1;
int getmin(int a,int b) {return a<b?a:b;}

int main()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++) scanf("%d",&a[i]);
	memset(t0,0,sizeof(t0));
	memset(t1,0,sizeof(t1));
	for (int i=1; i<=n; i++)
		if (i&1) t1[a[i]]++; else t0[a[i]]++;
	ma0=maa0=ma1=maa1=0;
	for (int i=1; i<=100000; i++)
	{
		if (t1[i]>ma0) m0=i,maa0=ma0,ma0=t1[i]; else
		if (t1[i]>maa0) maa0=t1[i];
		if (t0[i]>ma1) m1=i,maa1=ma1,ma1=t0[i]; else
		if (t0[i]>maa1) maa1=t0[i];
	}
	if (m0!=m1) printf("%d\n",n-ma0-ma1); else
	printf("%d\n",getmin(n-ma0-maa1,n-maa0-ma1));
	return 0;
}

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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var s = ReadLine();
            var Re = 0;

            for (int i = 0; i < s.Length; i++) {
                if(int.Parse(s[i].ToString()) == 1) {
                    Re++;
                }
            }

            Console.WriteLine(Re);
            ReadLine();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 11092
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	key := make([]int, N)
	An := make(map[int]int)
	var ans, max int
	for i := range key {
		key[i] = nextInt()
		max = MaxOf(key[i], max)
	}
	for i := 0; i < N; i++ {
		for j := 1; j*key[i] <= max; j++ {
			if An[key[i]] >= 2 {
				break
			}
			An[j*key[i]]++
		}
	}
	for i := 0; i < N; i++ {
		if An[key[i]] == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 84816
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] a=new int[N];
		for(int i=0;i<N;i++){
			a[i]=sc.nextInt();
		}
		
		int sum=0;
		for(int i:a){
			sum+=i-1;
		}
		System.out.println(sum);
	}
}




Measured memory_bytes: 25008
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll L;
  cin >> L;
  vll A(L);
  REP(i,L) cin >> A[i];

  vvll DP(L+1, vll(5, INFLL));

  REP(i,5) DP[0][i] = 0;
  REP(i,L){
    ll E = A[i]%2;
    if(A[i]==0) E = 2;
    ll O = 1-A[i]%2;

    ll M = DP[i][0];
    DP[i+1][0] = DP[i][0] + A[i];
    M = min(M, DP[i][1]);
    DP[i+1][1] = M + E;
    M = min(M, DP[i][2]);
    DP[i+1][2] = M + O;
    M = min(M, DP[i][3]);
    DP[i+1][3] = M + E;
    M = min(M, DP[i][4]);
    DP[i+1][4] = M + A[i];
  }

  //mat_print(DP);

  ll ans = INFLL;
  REP(i,5) ans = min(ans, DP[L][i]);
  cout << ans << endl;

  return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] h = new int[N];
        for(int i = 0; i < N; i++) h[i] = scanner.nextInt();
        int[] dp = new int[N];
        Arrays.fill(dp, Integer.MAX_VALUE/2);
        dp[0] = 0;
        for(int i= 0; i < N; i++) {
            for(int j = 1; j <= K; j++) {
                if (i+ j >= N) break;
                dp[i+j] = Math.min(dp[i+j], dp[i] + Math.abs(h[i] - h[i+j]));
            }
        }
        out.println(dp[N-1]);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


Measured memory_bytes: 34572