akhauriyash/Code-Regression huggingface dataset:
W, H, N = map(int,input().split())
G = [[0]*W for k in range(H)]

for q in range(N):
    x, y, a = map(int,input().split())
    if a == 1:
        for k in range(H):
            for l in range(x):
                G[k][l] = 1
    elif a == 2:
        for k in range(H):
            for l in range(x,W):
                G[k][l] = 1
    elif a == 3:
        for k in range(y):
            for l in range(W):
                G[k][l] = 1
    else:
        for k in range(y,H):
            for l in range(W):
                G[k][l] = 1

ans = H*W
for k in range(H):
    for l in range(W):
        ans -= G[k][l]
print(ans)


Measured memory_bytes: 3064
INF = pow(10, 9)

N = int(input())
H = [int(h) for h in input().split()]

dp = [INF for _ in range(N)]
dp[0] = 0
for i in range(1, N):
    dp[i] = min(dp[i], dp[i-1] + abs(H[i] - H[i - 1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i - 2] + abs(H[i] - H[i - 2]))
print(dp[-1])


Measured memory_bytes: 13924
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll mod = 1000000007;
vector<ll>G[100005];
int main() {
	int n, m;
	cin >> n >> m;
	int a, b;
	
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	vector<ll>dist(n, mod);
	vector<ll>pre(n, -1);
	dist[0] = 0;
	pre[0] = -1;
	queue<ll>que;
	que.push(0);
	while (!que.empty()) {
		int x = que.front();
		que.pop();
		for (auto id : G[x]) {
			if (dist[id] != mod) {
				continue;
			}
			dist[id] = dist[x] + 1;
			pre[id] = x;
			que.push(id);
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) {
		cout << pre[i] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 13688
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  vector<int> input(n,0);
  for (int i = 0; i < n; i++) {
    cin >> input.at(i);
  }
  
  for (int i = 0; i < n; i++) {
    if(input[i] %2 == 0){
      if(!(input[i] % 3 == 0 || input[i] % 5 == 0)){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  
  cout << "APPROVED" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys, math

max_int = 1000000001  # 10^9+1
min_int = -max_int

n = int(sys.stdin.readline())
positive_counter = {}
negative_counter = {}
to_add = 0
a_zero_counter = b_zero_counter = 0
for _n in range(n):
    s = sys.stdin.readline()
    a, b = map(int, s.split())

    if a == 0 and b == 0:
        to_add += 1
        continue
    elif a == 0:
        a_zero_counter += 1
        continue
    elif b == 0:
        b_zero_counter += 1
        continue
    elif (a > 0) == (b > 0):
        a = abs(a)
        b = abs(b)
        gcd = math.gcd(a, b)
        definer = (a // gcd, b // gcd)

        if definer not in positive_counter:
            positive_counter[definer] = 1
        else:
            positive_counter[definer] += 1
    else:
        a = abs(a)
        b = abs(b)
        gcd = math.gcd(a, b)
        definer = (b // gcd, a // gcd)

        if definer not in negative_counter:
            negative_counter[definer] = 1
        else:
            negative_counter[definer] += 1

prod = 2 ** a_zero_counter + 2 ** b_zero_counter - 1
#print(positive_counter, negative_counter)
for k in positive_counter:
    if k in negative_counter:
        prod *= 2 ** positive_counter[k] + 2 ** negative_counter[k] - 1
        negative_counter.pop(k)
    else:
        prod *= 2 ** positive_counter[k]
    prod %= 1000000007

for k in negative_counter:
    prod *= 2 ** negative_counter[k]
    prod %= 1000000007

prod += to_add - 1

print(prod % 1000000007)


Measured memory_bytes: 106444
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    X = LI()

    sm = sum(X)
    print(15-sm)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9128
#include <algorithm>
#include <iostream>

using namespace std;
using ll = long long;

ll mod = 1e9 + 7;

ll dp[1000];

ll fastPow(ll base, ll expo)
{
    ll ans = 1;
    while (expo > 0)
    {
        if (expo & 1)
            ans = ans * base % mod;
        base = base * base % mod;
        expo >>= 1;
    }
    return ans % mod;
}
ll inv(ll x)
{
    return fastPow(x, mod - 2);
}
ll C(ll n, ll m)
{
    if (n < m)
        return 0;
    ll up = 1, down = 1;
    for (int i = n - m + 1; i <= n; ++i)
        up = up * i % mod;
    for (int i = 1; i <= m; ++i)
        down = down * i % mod;
    return up * inv(down) % mod;
}

ll Lucas(ll n, ll m)
{
    if (m == 0)
        return 1;
    else
        return Lucas(n / mod, m / mod) * C(n % mod, m % mod) % mod;
}

int main(void)
{
    ll s;
    cin >> s;
    if (s < 3)
    {
        cout << 0 << endl;
        return 0;
    }
    ll i = 1;
    ll r = s - 3 * i;
    while (r >= 0)
    {
        dp[i] = Lucas(r + i - 1, r);
        i++;
        r = s - 3 * i;
    }
    ll ans = 0;
    for (int j = 1; j < i; ++j)
    {
        ans = (ans + dp[j]) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<ctime>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;

template <typename tn> void read (tn & a) {
	tn x = 0, f = 1; char c = getchar();
	while (c < '0' || c > '9'){ if (c == '-') f = -1; c = getchar(); }
	while (c >= '0' && c <= '9'){ x = x * 10 + c - '0'; c = getchar(); }
	a = f == 1 ? x : -x;
}

ll w, h, a, b;
const int MAXN = 100010;
const ll INF = 1e9 + 7;
ll f[MAXN], g[MAXN];


void solve1() {
	rep(i, 1, h) f[i] = 1;
	rep(i, 2, w - a) {
		rep(j, 2, h) {
			f[j] += f[j - 1];
			if (f[j] > INF) f[j] -= INF;
		}
	}
	rep(i, w - a + 1, w) {
		rep(j, b + 2, h) {
			f[j] += f[j - 1];
			if (f[j] > INF) f[j] -= INF;
		}
	
	}
	cout << f[h]<<"\n";
}


ll inv (ll x) { return x == 1 ? 1 : -inv(INF % x) * (INF / x) % INF; }

void solve2() {
	f[1] = 1;
	ll y = w - a - 1;
	rep(i, 2, h) {
		ll x = i + y - 1;
		f[i] = f[i - 1] * (x) % INF * inv(x - y) % INF;
	}
	g[b + 1] = 1;
	y = a - 1;
	rep(i, b + 2, h) {
		ll x = y + i - b - 1;
		g[i] = g[i - 1] * (x) % INF * inv(x - y) % INF;
	}
	reverse(g + b + 1, g + h + 1);
	ll ans = 0;
	rep(i, b + 1, h) {
		ans += (f[i] * g[i]);
		ans %= INF;	
	}
	if (ans < 0) ans += INF;
	cout << ans << "\n";
}

void solve() {
	if (w * h < 1000000) {
		solve1();
		return;
	}
	solve2();
}

int main() {
	read(w);
	read(h);
	read(a);
	read(b);
	solve();
	return 0;
} 


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  string S;
  cin>>S;
  int N=S.size();
  vector<int> X(N);
  rep(i,N) X[i]=0;
  int R=0,L=0,tmp;
  rep(i,N-1){
    if(S[i]=='R'&&S[i+1]=='L'){
      tmp=i;
      R++;
    }else if(S[i]=='L'&&S[i+1]=='R'){
      L++;
      X[tmp]=(R+L)/2;
      X[tmp+1]=(R+L)/2;
      if(abs(R-L)%2){
        if(max(R,L)%2){
          if(R>L) X[tmp]++;
          else X[tmp+1]++;
        }else{
          if(R>L) X[tmp+1]++;
          else X[tmp]++;
        }
      }
      R=0,L=0;
    }else{
      if(S[i]=='R') R++;
      else L++;
    }
  }
  L++;
  X[tmp]=(R+L)/2;
  X[tmp+1]=(R+L)/2;
  if(abs(R-L)%2){
    if(max(R,L)%2){
      if(R>L) X[tmp]++;
      else X[tmp+1]++;
    }else{
      if(R>L) X[tmp+1]++;
      else X[tmp]++;
    }
  }
  rep(i,N) cout<<X[i]<<" ";
}

Measured memory_bytes: 1024
import bisect

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

a = [0]
for aa in A:
    a.append(a[-1] + aa)
x = a[-1]/2
i = bisect.bisect(a, x)
d = min(x - a[i-1], a[i] - x)
print(int(d / 0.5))

Measured memory_bytes: 99788
n=int(input())
a=list(map(int, input().split()))

def selection(a:list, n:int) -> None:
    if not isinstance(a, list):
        return None

    cnt=0
    for i in range(n):
        minj=i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj=j
        a[i], a[minj] = a[minj], a[i]

        if i != minj: cnt+=1

    print(" ".join(map(str, a)))
    print(cnt)

selection(a, n)


Measured memory_bytes: 5600
import sys
from collections import deque
input = sys.stdin.readline

def main():
    n,q=map(int,input().split())
    t=[[] for _ in range(n+1)]
    cnt=[0]*(n+1)
    tf=[0]*(n+1)
    for i in range(n-1):
        a,b=map(int,input().split())
        t[a].append(b)
        t[b].append(a)
    for i in range(q):
        p,x=map(int,input().split())
        cnt[p]+=x
    d=deque()
    d.append(1)
    tf[1]=1
    while d:
        chk=d.popleft()
        for i in t[chk]:
            if tf[i]==1:
                continue
            else:
                d.append(i)
                tf[i]=1
                cnt[i]+=cnt[chk]
    print(' '.join(map(str,cnt[1:])))

if __name__ == '__main__':
    main()

Measured memory_bytes: 67180
#include <stdio.h>
 
int main(void)
{
int n, a, min = 1000000, max = -1000000;
long sum = 0L;
 
scanf("%d", &n);
while (n > 0)
{
 scanf("%d", &a);
 if (a < min) min = a;
 if (a > max) max = a;
 sum += (long)a;
 n--;
}
 
printf("%d %d %ld\n", min, max, sum);
return 0;
}

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

int main() {
	string s;
	cin >> s;
	int a[27] = {};
	for(int i = 0; i < 4; i++)
	{
		int p = (int)s[i];
		a[p-64]++;
	}
	int c = 0;
	for(int i = 1; i < 27; i++)
	{
		if(a[i]==2)
		c++;
	}
	if(c == 2) cout << "Yes";
	else cout << "No";
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int F[50];

int fibonacci(int n){
  if(n==0 || n==1){
    return F[n] = 1; 
  }
  if(F[n] != -1){
    return F[n];
  }
  return F[n] = fibonacci(n-1)+fibonacci(n-2);
}

int main(){

  int i, n;

  for(i=0; i<50; i++){
    F[i] = -1;
  }

  scanf("%d", &n);
  printf("%d\n", fibonacci(n));
  
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n';
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 or b % 2 == 0 or c % 2 == 0) {
        cout << 0 << endl;
        return;
    }

    ll mn = LINF;
    chmin(mn, a * b);
    chmin(mn, a * c);
    chmin(mn, b * c);
    cout << mn << endl;
}



Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Bits
import Data.List
import qualified  Data.ByteString as B
import Data.Ord


bsToInt :: BS.ByteString -> Int
bsToInt = fst . fromJust . BS.readInt

bsToIntList :: BS.ByteString -> [Int]
bsToIntList = map bsToInt . BS.words

count :: Int -> [Int] -> (Int, [Int])
count _ [] = (0, [])
count k (a:as) 
    | k==a = (1 + cn ,rs)
    | otherwise = (0, (a:as))
    where
        (cn, rs) = count k as

subs' :: Int -> [Int] -> [Int]
subs' 0 _ = []
subs' n as = cn : subs' (n-1) rs
    where
        (cn, rs) = count n as

main :: IO ()
main = do 
    n <- bsToInt <$> BS.getLine
    as <- bsToIntList <$> BS.getLine
    let rev = sortOn Data.Ord.Down as
    mapM_ print (reverse (subs' n rev))


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

typedef long long LL;
typedef double DB;

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

const int MOD   = 1e9+7;
const int MAXN  = 1010;


int main() {
#ifdef LOCAL
    freopen("sample.in","r",stdin);
#endif
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    int ans=a*100+b*10+c;
    if(ans%4)
        cout<<"NO"<<endl;
    else 
        cout<<"YES"<<endl;

    return 0;
}



Measured memory_bytes: 256
#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;

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

    int pa = (int)p;
    int pb = ceil(p);
    int a = 0;
    int b = 0;
    for (int i = 0; i < n; ++i) {
        a += (x[i] - pa) * (x[i] - pa);
        b += (x[i] - pb) * (x[i] - pb);
    }

    cout << min(a, b) << endl;
}

Measured memory_bytes: 384
N, K = map(int, input().split())
snk = [False for i in range(N)]
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        a -= 1
        snk[a] = True
ans = 0
for i in range(N):
    if snk[i]:
        continue
    else:
        ans += 1
print(ans)

Measured memory_bytes: 9132
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 10000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

//edge cases when n=1 , m=1. wrong variable in loop. if<->while
signed main()
{
	speed
	//global var
	string str;
	cin>>str;

	if(str.length()==6 && str[2]==str[3] && str[4]==str[5])
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc;
	int N, M;
	int[] A;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		A = new int[N];
		for (int i = 0; i < N; i++) A[i] = sc.nextInt();
		
		System.out.println(count());
	}
	
	private int count() {
		int l = Integer.lowestOneBit(A[0]);
		if (l <= 1) return 0;
		for (int i = 0; i < N; i++) {
			int m = Integer.lowestOneBit(A[i]);
			if (l != m) return 0;
			A[i] /= 2;
		}
		long lcm = 1;
		for (int i = 0; i < N; i++) {
			lcm = lcm*A[i]/gcd(lcm, A[i]);
			if (lcm > M) return 0;
		}
		return (int)((M/lcm+1)/2);
		
	}
	
	private static long gcd(long a, long b) {
		long c = a;
		while ( b%a != 0) {
			c = b%a;
			b = a; a = c;
		}
		return c;
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/27  Problem: 085_arc_b / Link: https://abc078.contest.atcoder.jp/tasks/arc085_b?lang=en  ----- */
/* ------問題------

N 枚のカードからなる山札があります。カードにはそれぞれ数が書かれており， 上から i 枚目には ai が書かれています。
この山札を使い，X さんと Y さんが 2 人でゲームをします。 X, Y さんは最初，Z,W が書かれたカードを持っています。 そして X さんから交互に以下を行います。
山札から何枚かカードを引く。そして今持っているカードを捨て，最後に引いたカードを代わりに持つ。ただし，必ず 1 枚は引かなくてはならない。
山札がなくなるとゲームは終了で，2 人の持っているカードに書かれた数の差の絶対値がこのゲームのスコアになります。
X さんはスコアを最大化するように，Y さんはスコアを最小化するようにゲームをプレイした時， スコアはいくつになるでしょうか？

-----問題ここまで----- */
/* -----解説等-----

なんかO(1)があったのを覚えているのですが、これはプログラミングコンテストで、
ゲームの末尾から再帰してO(N^3) -> 部分構造から O(N^2)

----解説ここまで---- */

LL N,Z,W;

LL ans = 0LL;

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

	cin >> N>>Z>>W;
	VL a(N+1);
	a[0] = W;
	FOR(i, 0, N) {
		cin >> a[i+1];
	}
	VVL dp(N + 1, VL(2));
	FORR(i, N, 0 - 1) {
		if (i == N) {
			dp[N][0] = LINF;
			dp[N][1] = -LINF;
		}
		else {
			dp[i][0] = abs(a[i] - a[N]);
			dp[i][1] = abs(a[i] - a[N]);
		}
		FOR(j, i + 1, N + 1) {
			dp[i][0] = max(dp[i][0], dp[j][1]);
			dp[i][1] = min(dp[i][1], dp[j][0]);
		}
	}
	ans = dp[0][0];
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int r = h2 * 60 + m2 - k - (h1 * 60 + m1);
  cout << r;
}
#endif


Measured memory_bytes: 3636
char s[9],c[9];main(n,m,b){for(;scanf("%d%d",&m,&n)*m;){int q[1024]={0},i,t,p=m;for(t=i=1;i<=n;i++){scanf("%s",s,*c=0);i%3||strcat(c,"Fizz");i%5||strcat(c,"Buzz");*c||sprintf(c,"%d",i);for(strcmp(s,c)&&p>1&&(q[t]=p--);q[t=t%m+1];);}for(t=i=1;i<=m;i++)q[i]||(t=!printf(" %d"+t,i));puts("");}}

Measured memory_bytes: 640
fn main() {
    let s = read::<String>();
    let v: Vec<char> = s.chars().into_iter().collect();
    let n = v.len();

    // 回文かどうか
    for i in 0..n {
        if v[i] != v[n-1-i] {
            println!("No");
            return;
        }
    }
    for i in 0..(n-1)/2 {
        if v[i] != v[(n-1)/2-1-i] {
            println!("No");
            return;
        }
    }
    for i in (n-1)/2..n {
        if v[i] != v[n-1-i] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
$num = gets.chomp.to_i
letters = gets.chomp.split('')
$a_to_z = [*"A".."Z"]
$answer = []
letters.each do |letter|
  if $a_to_z.index(letter) + $num < $a_to_z.count
    $answer << $a_to_z[$a_to_z.index(letter) + $num]
  else
    $answer << $a_to_z[($a_to_z.index(letter) + $num) - $a_to_z.count]
  end 
end
puts $answer.join("")

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

using namespace std;

int z[111111], a[111111], b[111111], c[111111];
int main() {
	string s;
	cin >> s;
	int p = 1e9 + 7;
	z[0] = 1;
	for (int i = 1; i <= s.length(); i++) {
		z[i] = z[i - 1];
		if (s[i - 1] == '?')
			z[i] = z[i] * 3l % p;
	}
	for (int i = 1; i <= s.length(); i++) {
		a[i] = a[i - 1];
		if (s[i - 1] == 'A')
			a[i] += z[i], a[i] %= p;
		else if (s[i - 1] == '?')
			a[i] = (a[i] * 3l + z[i - 1]) % p;
	}
	for (int i = 1; i <= s.length(); i++) {
		b[i] = b[i - 1];
		if (s[i - 1] == 'B')
			b[i] += a[i], b[i] %= p;
		else if (s[i - 1] == '?')
			b[i] = (b[i] * 3l + a[i - 1]) % p;
	}
	for (int i = 1; i <= s.length(); i++) {
		c[i] = c[i - 1];
		if (s[i - 1] == 'C')
			c[i] += b[i], c[i] %= p;
		else if (s[i - 1] == '?')
			c[i] = (c[i] * 3l + b[i - 1]) % p;
	}
	cout << c[s.length()] << endl;
	return 0;
}


Measured memory_bytes: 2048
import math
N = int(input())
tmp = math.ceil(N**(1/2))
ans = N
for i in range(1,tmp+1):
    if N%i == 0:
        A = max(N//i-1,0)
        B = max(i-1,0)
        ans = min(ans,A+B)

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
 
int main()
{
    int n;
    cin >> n;
    vector<int> c(n+10),s(n+10),f(n+10);
    for(int i = 0; i < n-1; i++) cin >> c[i] >> s[i] >> f[i];

    for(int i = 0; i < n-1; i++){
        int ans = 0;
        for(int j = i; j < n-1; j++){
            if(ans < s[j]) ans = s[j];
            if(ans % f[j]) ans = ans + f[j] - ans % f[j];
            ans += c[j];
        }
        cout << ans << endl;
    }
    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;


mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int last[26];
int c[26];
int s[365][26];
int a[365];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int d; cin >> d;
    for(int i=0;i<26;i++){
    	cin >> c[i];
    }
    for(int i=0;i<d;i++){
    	for(int j=0;j<26;j++){
    		cin >> s[i][j];
    	}
    }
    for(int i=0;i<d;i++){
    	int mx=0;
    	int id=0;
    	for(int j=0;j<26;j++){
    		if(mx<(i+1-last[j])*c[j]){
    			mx=(i+1-last[j])*c[j];
    			id=j;
    		}
    	}
    	a[i]=id+1;
    	last[id]=i+1;
    }
    for(int i=0;i<26;i++){
    	last[i]=0;
    }
    int res=0;
    for(int i=0;i<d;i++){
    	res+=s[i][a[i]-1];
    	last[a[i]-1]=i+1;
    	for(int j=0;j<26;j++){
    		res-=c[j]*(i+1-last[j]);
    	}
    }
    for(int i=0;i<1e6;i++){
    	int day,qq;
    	day=myRand(d)+1;
    	qq=myRand(26)+1;
    	int resres=res;
    	int qqq=a[day-1];
        last[qq-1]=last[qqq-1]=0;
        for(int i=0;i<d;i++){
            if(a[i]==qq){
                last[a[i]-1]=i+1;
            }
            if(a[i]==qqq){
                last[a[i]-1]=i+1;
            }
            resres+=c[qq-1]*(i+1-last[qq-1]);
            resres+=c[qqq-1]*(i+1-last[qqq-1]);
        }
        a[day-1]=qq;
        resres-=s[day-1][qqq-1];
        resres+=s[day-1][qq-1];
        last[qq-1]=last[qqq-1]=0;
        for(int i=0;i<d;i++){
            if(a[i]==qq){
                last[a[i]-1]=i+1;
            }
            if(a[i]==qqq){
                last[a[i]-1]=i+1;
            }
            resres-=c[qq-1]*(i+1-last[qq-1]);
            resres-=c[qqq-1]*(i+1-last[qqq-1]);
		}
		if(resres>=res){

		}
		else{
			a[day-1]=qqq;
		}
    }
    for(int i=0;i<d;i++){
    	printf("%d\n",a[i]);
    }
}



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

int main()
{
	int N,M;
	cin >> N >> M;
	int ans = 1;
	for (int i = (M+N-1)/N; i > 0; i--) {
		if (M%i == 0) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	long long A,B,K;
	scanf("%lld%lld%lld",&A,&B,&K);
	for(long long i=0;i<K;i++){
		if(i%2==0){
			if(A%2==1)A--;
			B+=A/2;
			A/=2;
		}else{
			if(B%2==1)B--;
			A+=B/2;
			B/=2;
		}
	}
	printf("%lld %lld\n",A,B);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int a,b,c,ans;
  cin >> a >> b >> c;
  ans = c-b;
  if (ans <= 0){
    cout << "delicious" << endl;
  } else if (ans <= a) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}
  

Measured memory_bytes: 256
N = int(input())
L = [int(i) for i in input().split()]
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            if (not L[i] == L[j]) and (not L[j] == L[k]) and (not L[k] == L[i]):
                if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                    ans += 1

print(ans)

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


int main(){
    
    double N;
    cin >> N;
    int Ni = (int)N;

    double X1 = ceil(N/1.08);
    if ( (int)floor(X1 * 1.08) ==Ni){
        printf("%d",(int)X1);
        printf("\n");
    }
    else{
        printf(":(\n");
    }
    
}


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

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            long[] a = in.Long(N);

            long sum = 0;

//        long b = 1;
//        for (int i = 0; i < N; i++) {
//            b = lcm(b, a[i]);
//        }
//        b = b - 1;
////        System.err.println(b);
//
//        for (int i = 0; i < N; i++) {
//            sum += b % a[i];
//        }

            for (int i = 0; i < N; i++) {
                sum += a[i] - 1;
            }

            out.println(sum);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

        public long Long() {
            return Long.parseLong(next());
        }

        public long[] Long(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = Long();
            }
            return a;
        }

    }
}



Measured memory_bytes: 23380
first=list(input())
second=list(input())
first_s=set(first)
second_s=set(second)
lengh_f=len(first)
lengh=len(second)
a="No"
for i in range(lengh): 
    if first_s!=second_s or lengh_f!=lengh:
        break
    tmp=tuple(second)  #なぜタプルなのか?
    for j in range(lengh):
        if j==lengh-1:
            second[j]=tmp[0]
        else:
            second[j]=tmp[j+1]
    if first==second:
        a="Yes"
        break
print(a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
using P = pair<ll, ll>;

const string YES = "YES";
const string NO = "NO";

int ans[1 << 18] = {};

int bitswap(int a, int s, int t) {
    int s_mask = 1 << s;
    int t_mask = 1 << t;
    int sb = (a & s_mask) >> s;
    int tb = (a & t_mask) >> t;
    int mask = s_mask | t_mask;
    return (a & ~mask) | (sb << t) | (tb << s);
}

int solve(int s, int n, int A, int B) {
    if (n < 0) return 0;
    int last = B ^ A;
    if (last == 0) return 0;
    if (n == 1) {
        ans[s] = A;
        ans[s + 1] = A ^ 1;
        return 1;
    }
    int p;
    loop (n, i) if ((last >> i) & 1 == 1) {
        p = i;
        break;
    }
    int next_last = bitswap(last, p, n - 1) & ((1 << (n - 1)) - 1);
    int ok = 1;
    ok &= solve(s, n - 1, 0, next_last ^ 1);
    ok &= solve(s + (1 << (n - 1)), n - 1, next_last ^ 1, next_last);
    if (!ok) return 0;
    for (int i = s; i < (s + (1 << n)); i++) {
        int msb = (i - s < (1 << (n - 1))) ? 0 : 1;
        ans[i] = ans[i] | (msb << (n - 1));
        ans[i] = bitswap(ans[i], p, n - 1);
        ans[i] = A ^ ans[i];
    }
    return 1;
}

int main(){
    int N, A, B; cin >> N >> A >> B;
    int result = solve(0, N, A, B);
    if (!result) {
        cout << NO << endl;
        return 0;
    }
    cout << YES << endl;
    for (int i = 0; i < (1 << N); i++) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 1536
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

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

bool has_key_using_count(map<char, char> &m, char n){
    if (m.count(n) == 0){
        return false;
    }
    else{
        return true;
    }
}

int main()
{	
	//ifstream cin("sample.txt");

	vector<int> W, K;
	int n = 10, top = 3, t = 0, sumW = 0, sumK = 0;
	
	W.clear(); K.clear();
	rep(i, n) {
		cin >> t;
		W.push_back(t);
	}
	rep(i, n) {
		cin >> t;
		K.push_back(t);
	}

	// テ」ツつステ」ツδシテ」ツδ?
	sort(W.begin(), W.end(), greater<int>());
	sort(K.begin(), K.end(), greater<int>());

	// テ、ツクツ甘」ツ?凝」ツつ?テ、ツコツコテ」ツ?ョテ・ツセツ療ァツつケテ」ツつ津・ツ環?ァツョツ?
	rep(i, top) {
		sumW += W[i];
		sumK += K[i];
	}

	cout << sumW << " " << sumK << endl;

	return 0;
}

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

using namespace std;

struct Point {
    long long x, y;
    long long sign;
    Point() {}
    friend istream& operator>>(istream& in, Point& p) {
        in >> p.x >> p.y;
        if (p.y < 0 || (p.y == 0 && p.x < 0)) {
            p.x *= -1;
            p.y *= -1;
            p.sign = -1;
        } else {
            p.sign = 1;
        }
        return in;
    }
    bool operator<(const Point& o) const {
        return y*o.x < o.y*x || (y*o.x == o.y*x && sign > o.sign);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<Point> points(n);
    for (Point& point : points) {
        cin >> point;
    }
    points.resize(remove_if(points.begin(), points.end(), [](Point& p) { return p.x == 0 && p.y == 0; }) - points.begin());
    n = (int) (points.end() - points.begin());
    sort(points.begin(), points.end());
    long long x = 0, y = 0;
    for (Point& point : points) {
        if (point.sign == 1) {
            x += point.x;
            y += point.y;
        }
    }
    long long best = 0;
    auto update_best = [&]() {
        best = max(best, x*x + y*y);
    };
    update_best();
    for (Point& point : points) {
        x -= point.x;
        y -= point.y;
        update_best();
    }
    for (Point& point : points) {
        x += point.x;
        y += point.y;
        update_best();
    }
    cout << setprecision(30) << sqrt(best) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

ll dp[105][105][2][2]; // dp[i][j][k][r]...i:桁数, j:0でない桁の数, k:0以外の値を使ったか, r:未満フラグ

int main() {
    string s;
    int K;
    cin >> s >> K;
    int n = s.size();
    dp[0][0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        int t = s[i] - '0';
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k < 2; k++) {
                for (int r = 0; r < 2; r++) {
                    for (int v = 0; v <= (r ? 9 : t); v++) {
                        dp[i + 1][j + (v ? 1 : 0)][k || v][r || (v < t)] += dp[i][j][k][r];
                    }
                }
            }
        }
    }
    ll ans = dp[n][K][1][0] + dp[n][K][1][1];
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main(){
	string s;
	cin >> s;
	int ans = 0;

	FOR(i,1,s.length()){
		if(s[i-1] != s[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
/**In the name of Allah, the Most Merciful, the Most Merciful.**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF 9223372036854775806
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define EPS 1e-9
ll max(ll a,ll b) {if(a>b) return a; else return b;}
ll min(ll a,ll b) {if(a<b) return a; else return b;}

int main()
{
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll temp=min(x/d,k);
    k-=temp;
    ll cur=x-temp*d;
    if(k%2){
        cout<<abs(cur-d)<<endl;
    }
    else{
        cout<<abs(cur)<<endl;
    }

    return 0;
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fr(i,j,p)   for(int i=j; i<p; i++)
#define frr(i,j,p)  for(int i=j; i>=p; i--)
#define PI          3.14159265358979323846
#define pb          push_back
#define pbk         pop_back()
#define mkp         make_pair
#define print(m)    std::cout << std::fixed << std::setprecision(11) << m <<endl;
#define ff          first
#define ss          second
#define mod         1000000007
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())

lli knap(lli tot, lli w[], lli v[], lli n) {
    lli k[n+1][tot+1];
    fr(i,0,n+1) {
        fr(j,0,tot+1) {
            if(i==0 || j==0) k[i][j]=0;
            else if(w[i-1]<=j) k[i][j]=max(v[i-1]+k[i-1][j-w[i-1]], k[i-1][j]);
            else k[i][j]=k[i-1][j];
        }
    }
    return k[n][tot];
}
int main() {
	lli n,tot;  cin>>n>>tot;
	lli w[n],v[n];
	fr(i,0,n) cin>>w[i]>>v[i];
    cout<<knap(tot,w,v,n);
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long

void solve()
{
    int n;
    cin >> n;
    vector<int> vect(n);
    vector<int> dp(n);
    dp[0] = 0;

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

    for(int i = 1; i < n; i++)
    {
        int cost1 = INT_MAX, cost2 = INT_MAX;

        if(i>=1)
            cost1 = dp[i-1] + abs(vect[i] - vect[i-1]);

        if(i>=2)
            cost2 = dp[i-2] + abs(vect[i] - vect[i-2]);

        dp[i] = min(cost1, cost2);
    }

    cout << dp[n-1];
}

int main()
{
    fastio;
    solve();
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    int a,b;cin>>a>>b;
    if(a<=9&&b<=9)cout<<a*b<<endl;
    else cout<<-1<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
 	int x = 1;
	int y = 1;
 	
	while(x != 0 || y != 0){
		scanf("%d %d", &x, &y);
		if(x != 0 || y != 0){
			if(x <= y){
				printf("%d %d\n",x, y);
			}
			else{
				printf("%d %d\n",y, x);
			}
		}
	}
	return 0;
   
}

Measured memory_bytes: 2572
A,B = map(int,input().split())
S = input()
num = ['0','1','2','3','4','5','6','7','8','9']
ans = True
if len(S)==(A+B+1):
    for i in range(len(S)):
        if i == A:
            if S[i] == '-':
                pass
            else:
                ans = False
                break
        else:
            if S[i] in num:
                pass
            else:
                ans = False
                break
else:
    ans = False

if ans == True:
    print('Yes')
else:print('No')

Measured memory_bytes: 61832
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    if (n % 111 != 0) {
        if ((n / 100) * 111 > n) {
            n = (n / 100) * 111; 
        } else {
            n = (n / 100 + 1) * 111;
        }
    }
    cout << n << endl;
}

Measured memory_bytes: 256
import sys
def solution():
    n = int(input())
    k = n % 10
    if (k == 3):
        print("bon")
    elif (k == 0 or k == 1 or k == 6 or k == 8):
        print("pon")
    else:
        print("hon")
if __name__ == "__main__":
    solution()

Measured memory_bytes: 9172
#include<iostream>
#include<stdio.h>
#include<algorithm>

using namespace std;

int main(void)

{
    int a, b, c, ara[3], i;
    scanf("%d%d", &a, &b);
    ara[0] = a+b;
    ara[1] = a*b;
    ara[2] = a-b;
    sort(ara, ara+3);
    printf("%d\n", ara[2]);
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
key = []
for _ in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    v = 0
    for i in range(b):
        v += 1 << (c[i] - 1)
    key.append([a, v])

dp = [[float('inf')] * (1<<n) for _ in range(m+1)]
dp[0][0] = 0
for i in range(m):
    money, value = key[i]
    for j in range(1<<n):
        dp[i+1][j|value] = min(dp[i+1][j|value], dp[i][j] + money)
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

print(dp[-1][-1] if dp[-1][-1] != float('inf') else -1)

Measured memory_bytes: 131156
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {												
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  

const int N = 1e6+1;

void solve(){
	int n ; re(n);
	vi a(n);
	re(a);
	int cnt = 0 ;
	sort(all(a));

	vector<bool> mrk(N+1);
	rep(i,0,n){
		if(!mrk[a[i]]){
			cnt+=(i==n-1 or a[i] < a[i+1]);
			for(int j = a[i] ; j <= N ; j+=a[i]) mrk[j] = 1;
		}
	}
	cout << cnt << endl; 
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 5100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>

#define INF 100100100

using namespace std;

int main() {
	int n;
	cin >> n;
	priority_queue<int>a;
	for (int i = 0; i < n; i++) {
		int a0;
		cin >> a0;
		a.push(a0);
	}
	int alice=0,bob=0;
	while (a.size() > 1) {
		alice += a.top();
		a.pop();
		bob += a.top();
		a.pop();
	}
	if (a.size() == 1)alice += a.top();
	cout << alice - bob;
	return 0;
}

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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))


#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::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) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{

    long long mod=2019ll;

    long long l,r;
    cin>>l>>r;

    if(l*r<mod)
    {
        cout<<l*(l+1)<<endl;
        return;
    }

    long long mn=(l+1);

    long long mx=(r-1);

    long long div=(mn+mod-1)/mod;

    if(div*mod<=mx){
        cout<<0<<endl;
        return;
    }



    long long temp=r;

    int tl=l%mod;
    int tr=r%mod;

    l=min(tl,tr);
    r=max(tl,tr);


    long long res=2020;

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

        for(int j=i+1;j<=r;j++){
            long long mul=i*j;
           // cout<<((i*j))%mod<<endl;
            res=min(((i*j)%mod),res);
        }
    }
    cout<<res<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;

    while (t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
import math
A, B = list(map(int, input().split()))
a = math.ceil(A/0.08)
b = math.ceil(B/0.1)

if a > b:
    a, b = b, a

for i in range(a, b+1):
    if math.floor(i*0.08) == A and math.floor(i*0.1) == B:
        print(i)
        exit()

print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
int main(void){
    ll n,m,ans = 0,cnt;
    cin >> n >> m;
    vector<pair<ll,ll>> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i].first;
        cin >> a[i].second;
    }
    sort(a.begin(),a.end());
    cnt = m;
    for(int i = 0;i < n;i++){
        if(a[i].second <= m){
            ans += a[i].first*a[i].second;
            m -= a[i].second;
            if(m == 0) break;
        }else{
            ans += a[i].first*m;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
  int a, b, c, d;

  scanf("%d%d%d%d",&a,&b,&c,&d);

  while(a>0){
    a = a - d;
    c = c - b;
  }

  if(c>0){
    printf("No");
  }
  else{
    printf("Yes");
  }

  return 0;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    int mx,ans=1;
    for (int i=2;i<=x;i++){
        mx=i*i;
        while (1){
            if (mx<=x)
            ans=max(ans,mx);
            else
                break;
            mx*=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

inline long long mx(long long a, long long b) {
	return (a - b > 0) ? a : b;
}

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	long long A, B, K; cin >> A >> B >> K;
	long long f = 0;

	long long A2 = mx(A - K, f);
	long long B2 = mx(B - mx(K - A, f),f);

	cout << A2 << " " << B2 << endl;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	return 0;
}


Measured memory_bytes: 256
N, *AB = map(int, open(0).read().split())
ans = 0
for i in range(N):
    index = N - 1 - i
    a = AB[index * 2 + 0] + ans
    b = AB[index * 2 + 1]
    remainder = a % b
    ans += (b - remainder) % b
print(ans)


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

int main(){
string s;
int cnt=0;
cin>>s;

for(int i=0; i<s.size(); i++){
  if(s[i] == '?')
    s[i] = 'D'; 
  if(s[i+1] == '?')
    s[i+1] = 'D'; 
  if(s[i] == 'D')
    cnt++;
  if(s[i] == 'P' && s[i+1] == 'D')
    cnt++;
}
cout<<s<<endl;

return 0;
} 


Measured memory_bytes: 3724