akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int q;
  cin>>q;
  long r=0, l=0;
  rep(loops, q){
    int p,n; char c;
    scanf("%d %c %d", &p, &c, &n);
    if(c=='(') l+=n;
    else r+=n;
    if(r==l) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }

  return 0;
}

Measured memory_bytes: 3208
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int a; int b = 0;
	int max=0, now=0;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (b >= a) {
			now++;
		}
		else {
			now = 0;
		}
		b = a;
		if (now > max)max = now;
	}
	cout << max;
	return 0;
}

Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

set<ll> st;

int main()
{
    IOS();
    ll n;
    cin>>n;
    REP(i,n)
    {
      ll t;
      cin>>t;
      st.insert(t);
    }
    cout<<SZ(st)<<endl;
}


Measured memory_bytes: 256
//This code was made by Chinese_zjc_
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
inline int rd(int &ddd)
{
	char tmp=getchar();
	int xxx=1;
	ddd=0;
	while(('0'>tmp||tmp>'9')&&tmp!='-'&&tmp!=EOF)
	{
		tmp=getchar();
	}
	if(tmp==EOF)
	{
		return EOF;
	}
	if(tmp=='-')
	{
		xxx=-1;
		tmp=getchar();
	}
	while('0'<=tmp&&tmp<='9')
	{
		ddd=(ddd<<3)+(ddd<<1)+(tmp^48);
		tmp=getchar();
	}
	return ddd*=xxx;
}
inline char rd(char &ddd)
{
	char tmp=getchar();
	while(tmp==' '||tmp=='\n')
	{
		tmp=getchar();
	}
	if(tmp==EOF)
	{
		return EOF;
	}
	return ddd=tmp;
}
inline int max(const int &A,const int &B)
{
	return A<B?B:A;
}
inline int min(const int &A,const int &B)
{
	return A<B?A:B;
}
int a,b,c;
signed main()
{
	rd(a);
	rd(b);
	rd(c);
	printf("%lld",max(c-(a-b),0));
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int a[1000][1000]={0};
  int b[1000]={0};
  int out[1000]={0};
  int n,m;
  int i,j;
 
  scanf("%d",&n);
  scanf("%d",&m);
  for (i=0; i<n; i++) {
    for (j=0; j<m; j++) {
      scanf("%d",&a[i][j]);
    }
  }
 
  for (i=0; i<m; i++) {
    scanf("%d",&b[i]);
  }
 
  for (i=0; i<n; i++) {
    for (j=0; j<m; j++) {
      out[i]+=a[i][j]*b[j];
    }
  }
 
  for (i=0; i<n; i++) {
    printf("%d\n",out[i]);
  }
  return 0;
}

Measured memory_bytes: 4524
//mangesh2102000

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long int 
#define ld long double
#define pb push_back
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define F first
#define S second
#define mod 1000000000

int n;
int h[100005];
int dp[100005];


void solve(int t)
{
    cin >> n;

    for(int i=1;i<=n;i++)
    {
        cin >> h[i];
    }

    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);

    for(int i=3;i<=n;i++)
    {
    	dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout << dp[n];
    //cout << "Case #" << t << ": " << ;
}   


int32_t main()
{
    IOS;
    int t;
    t=1;
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e6+3;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

LL data[MAX+2];

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=MAX){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

LL divi(LL a,LL b){//a/b
	LL s=a*pow_mod(b,MAX-2)%MAX;
	return s;
}

LL calc(LL a,LL b){//aCb
	a--;
	b+=a;
	if(b>=MAX || a<0)return 0;
	return divi(data[b],data[a]);
}

int main(){
	LL n;
	LL i,j,k;
	LL a,b,c;
	LL p,q,r;
	data[0]=1;
	for(i=1;i<=MAX;i++){
		data[i]=data[i-1]*i%MAX;
	}
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b>>c;
		if(b==0)p=pow_mod(a,c);
		else p=calc(divi(a,b),c)*pow_mod(b,c)%MAX;
		cout<<p<<endl;
	}
}


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

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define mod (int)1e9 + 7
#define For(i,a,n) for(i=a;i<n;i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    ul a, m = 100,cnt = 0;
    cin>>a;
    while(m<a){
    	m += (m/100);
    	cnt++;
    }
    cout<<cnt;
    return 0;
}


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

int main() {
  int a,b,c,d,ans = 0;
  cin >> a >> b >> c >> d;
  for(int i = 0; i < a+1; i++) {
    for(int j = 0; j < b+1; j++) {
      for (int k = 0; k < c+1; k++) {
        if (i*500 + j*100 + k*50 == d) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int memo[100]={0};
long long int lucas_num(int n) {
    if(n==0) {
        return 2;
    } else if(n==1) {
        return 1;
    } else if(memo[n]!=0) {
        return memo[n];
    }
    // cout << n << endl;
    return memo[n] = lucas_num(n-1) + lucas_num(n-2);
}

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

    cout << lucas_num(N) << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)

using namespace std;

int k;

int dfs(vector<int> a, vector<int> b, int i){
    if(i == k-1) return (a[i] == b[i] ? 0LL : 1LL);

    int ret = 11, rotate = (b[i]-a[i]+10) % 10;
    vector<int> aa(a);
    aa[i] = b[i];
    reppp(j, i+1, k){
        ret = min(ret, dfs(aa, b, i+1));
        aa[j] = (a[j] + rotate) % 10;
    }
    ret = min(ret, dfs(aa, b, i+1));
    return ret + (a[i] == b[i] ? 0LL : 1LL);
}

int main(){
    while(scanf("%d", &k), k){
        char sa[10], sb[10];
        scanf("%s %s", sa, sb);
        vector<int> a(k), b(k);
        rep(k){
            a[i] = sa[i] - '0';
            b[i] = sb[i] - '0';
        }

        printf("%d\n", dfs(a, b, 0));
    }
}


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

const int N=1e5+20;

int n,m,u,v,ans;
bool vis[N];
vector <int> adj[N];

void dfs(int node)
{
	vis[node]=true;
	for(auto child:adj[node])
		if(not vis[child]) dfs(child);
}

int main()
{
	scanf("%d%d",&n,&m);
	while(m--)
	{
		scanf("%d%d",&u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	for(int i=1;i<=n;i++)
		if(not vis[i]) dfs(i),ans++;
	printf("%d",ans-1);
}

Measured memory_bytes: 9808
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <utility>
#include <cstdlib>

using namespace std;
int main(){
    int n; cin>>n;
    vector<int>p(n);
    for(int i=0;i<n;i++){
        cin>>p.at(i);
    }
    
    int count=0;
    for(int i=0;i<n-2;i++){
        if(
           (p.at(i)<p.at(i+1)&&p.at(i+1)<p.at(i+2))||
           (p.at(i)>p.at(i+1)&&p.at(i+1)>p.at(i+2))||
           (p.at(i)>=p.at(i+1)&&p.at(i+1)>p.at(i+2))||
           (p.at(i)<p.at(i+1)&&p.at(i+1)<=p.at(i+2))
           ){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


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

int main() {
  int D;
  cin >> D;
  switch(D) {
  case 25:
    cout << "Christmas" << endl;
    break;
  case 24:
    cout << "Christmas Eve" << endl;
    break;
  case 23:
    cout << "Christmas Eve Eve" << endl;
    break;
  case 22:
    cout << "Christmas Eve Eve Eve" << endl;
    break;
  default:
    break;
  }
}


Measured memory_bytes: 256
X = int(input())

i, n = 0, 0
while n < X:
	i += 1
	n += i

#print(i, n)

if n == X:
	print(i)
	exit()

if n - X < i:
	print(i)
	exit()

j, d = 0, []
while X < n:
	j += 1
	n -= j
	d += [abs(X - n)]

#print(d)

if 0 in d:
	print(i)
	exit()

l, r = d[-1], d[-2]
print(i + min(abs(l), abs(r)) + 1)


Measured memory_bytes: 3064
nums = [input() for i in range(3)]
A,B,C = map(int,nums)
x = int(input())
count = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i+100*j+50*k == x:
        count +=1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstdio>
#include<cstdlib>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n;
  cin>>n;
  int abmax=0,idx=0;;
  int num[55]={0};
  for(int i=1;i<=n;i++){
    cin>>num[i];
    if(abs(abmax)<=abs(num[i])){
      abmax=num[i];
      idx=i;
    }
  }
  cout<<2*n-1<<endl;
  for(int i=1;i<=n;i++){
    cout<<idx<<" "<<i<<endl;
  }
  if(abmax<0){
    for(int i=n;i>1;i--){
      cout<<i<<" "<<i-1<<endl;
    }
  }
  else{
    for(int i=1;i<n;i++){
      cout<<i<<" "<<i+1<<endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int n;
  int x;

  while(1) {
    std::cin >> n >> x;
    if(n == 0 && x == 0) break;
    int cnt = 0;
    for(int i = 1; i <= n; ++i) {
      for(int j = 1; j <= n; ++j) {
        if(i == j) break;
        for(int k = 1; k <= n; ++k) {
          if(i == k || j == k) break;
          int sum = i + j + k;
          if(sum == x) cnt ++;
        }
      }
    }
    std::cout << cnt << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N, K;
	
	cin >> N >> K;
	
	if(K == 1){
		cout << 0;
		return 0;
	}
	
	cout << N-K;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair <int,int> P;

int main(){
  string s;
  cin >> s;
 
  int n = s.size();
 
  int ans1 = 0, ans2 = 0;
  for(int i = 0;i<n;i++){
    if(i%2 == s[i]-'0') ans1++;
    else ans2++;
  }
 
  cout << min(ans1,ans2) << endl; 

}

Measured memory_bytes: 512
#include<stdio.h>

int main(){
    int n,k,q,x;
    scanf("%d %d %d",&n,&k,&q);
    int a[n];
    for(int i=0;i<n;i++){
        a[i]=k-q;
    }
    for(int j=0;j<q;j++){
        scanf("%d",&x);
        a[x-1]+=1;
    }
    for (int p=0;p<n;p++){
        if(a[p]>0){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 896
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int N; cin >> N;
  int cnt = 0;
  for (int i = 1; i <= N; i++){
    int P; cin >> P;
    if (P != i) cnt++;
  }
  if (cnt <= 2) YES();
  else NO();

  return 0;
}


Measured memory_bytes: 3604
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N, M = rl()
K = []
for i in range(M):
	ks = rl()
	K.append(ks[1:])
P = rl()

def check(b):
	for i in range(M):
		if sum([b[k-1] for k in K[i]]) % 2 != P[i]:
			return False
	return True

cnt = 0
for b in product([0, 1], repeat=N):
	if check(b):
		cnt += 1
print(cnt)

Measured memory_bytes: 74272
#include <iostream>
#define rep(i, n) for(int i=0;i<(n);++i)
using namespace std;

string f(long long n){
    if(n==0){
        return "";
    }
    n--;
    return f(n/26) + string(1,'a'+n%26);

}
int main(){
    long long n;
    cin >> n;
    cout << f(n) << endl;
    return 0;
}

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

using namespace std;

const int MaxN = 100005;
const int oo = 1e9;

int n, k;
int h[MaxN], dp[MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i];
        dp[i] = oo;
    }
    dp[1] = 0;
    for (int i = 1; i < n; i++)
    {
        for (int j = min(n, i + k); j > i; j--)
        {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 4396
kotae=[]
N = int(input())
Sst=input()
S = list(Sst)
L=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C']

for i in range(len(Sst)):
    for j in range(26):
        if S[i] == L[j]:
            kotae.append(L[j+N])

Sed = "".join(kotae)
print(Sed)

Measured memory_bytes: 3188
import sys
from itertools import combinations

def dfs(idx,N,win_cnt,will_match):
    if(idx==N):
        #win_cntがすべて(N-1)/2なら1を返す
        return 1
    
    need_win = (N-1)//2 - win_cnt[idx] #引き分けにするための必要勝数
    need_lose = len(will_match[idx]) - need_win
    # print(need_win,need_lose,(len(will_match[idx]),win_cnt[idx]))
    if(need_win > len(will_match[idx]) or need_win < 0): # 残りの試合をどう戦っても、引き分けにならない
        return 0
    res = 0
    # print(idx,"が負ける必要がある",need_lose)
    for it in combinations(will_match[idx],need_lose): ##負け試合をピッタリ必要なだけ選ぶ
        tmp = win_cnt.copy() ##勝数をいじるので現状保存
        # print(idx,win_cnt)
        # print(list(it))
        for i in it:
            # print("i",i)
            tmp[i] += 1 ## idx番目のチームの負けなので相手チームの勝数を1増やす
        res += dfs(idx+1,N,tmp,will_match)
    
    return res
def solve(N):
    M=int(input())
    # print(N,M)
    XY = [[int(i)-1 for i in input().split()] for _ in range(M)]
    win_cnt = [0]*N #チームiが何回勝ったか

    match = [[-1]*N for _ in range(N)]
    for x,y in XY:
        match[x][y] = 1
        match[y][x] = 0
        win_cnt[x]+=1
        if(x>y):
            x,y = y,x
    will_match = [[] for _ in range(N)]
    for i in range(N):
        for j in range(i+1,N):
            if(match[i][j]==-1): #戦ってない
                will_match[i].append(j)
    # print(*match,sep="\n")
    # print(win_cnt)
    # print(*will_match,sep="\n")
    ans = dfs(0,N,win_cnt,will_match)

    print(ans)
        


def main():
    input = sys.stdin.readline
    while True:
        N = int(input())
        if(not N):
            break
        solve(N)
if __name__ == "__main__":
    main()


Measured memory_bytes: 5668
n,a,b,c,d=map(int,input().split())
s=list(input())
s[c-1]="c"
s[d-1]="d"
flag=False
lim=max(c,d)
for i in range(a+1,lim-1):
  if s[i]!="#":
    if b-1<=i and i<=d-1:
      if s[i-1]!="#" and s[i+1]!="#":
        flag=True
    continue
  if s[i+1]=="#":
    print("No")
    exit()
if flag==False and d<c and (s[d-2]=="#" or s[d]=="#"):
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 4916
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

puts a.join(' ')
1.upto(n-1) do | r |
  l = r - 1
  while l >= 0
    if a[l] > a[r]
      a[l], a[r] = a[r], a[l]
    end
    l -= 1
    r -= 1
  end
  puts a.join(' ')
end



Measured memory_bytes: 6896
# coding: utf-8
"""this is python work script"""
def solve(input_list):

    list_uniq = set(input_list)
    answer = len(list_uniq)

    return answer

def main():
    """main function"""
    N = int(input())
    list_input = [input().rstrip() for _ in range(N)]

    answer = solve(list_input)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
def main():
    i = list(map(int, input().split()))
    n = i[0]

    if not (1 <= n and n <= 10**5):
        return

    num = 0
    for j in range(n):
        if(len(str(j+1)) % 2 != 0):
            num += 1

    print(num)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
defmodule Main do
  def main do
    [a, b] =
      IO.read(:line)
      |> String.trim
      |> String.split(" ")
    a = String.to_integer(a)
    b = String.to_integer(b)
    if a <= 8 and b <= 8 do 
    IO.puts("Yay!") 
    else 
    IO.puts(":(") 
    end
  end
end


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

struct Edge
{
    int to, a, b;
    Edge(int to, int a, int b) : to(to), a(a), b(b) {}
};
struct State
{
    int64_t t;
    int v, s;
    State(int64_t t, int v, int s) : t(t), v(v), s(s) {}
    bool operator<(const State &other) const
    {
        return t > other.t;
    }
};
const int S_MAX = 2500;
const int64_t INF = 1e18;

int main()
{
    int N, M, S;
    cin >> N >> M >> S;
    vector<int> U(M), V(M), A(M), B(M);
    for (int i = 0; i < M; i++)
    {
        cin >> U.at(i) >> V.at(i) >> A.at(i) >> B.at(i);
    }
    vector<int> C(N), D(N);
    for (int i = 0; i < N; i++)
    {
        cin >> C.at(i) >> D.at(i);
    }

    vector<vector<Edge>> graph(N);
    for (int i = 0; i < M; i++)
    {
        int u = U.at(i) - 1, v = V.at(i) - 1;
        int a = A.at(i), b = B.at(i);
        graph.at(u).push_back(Edge(v, a, b));
        graph.at(v).push_back(Edge(u, a, b));
    }

    vector<vector<int64_t>> dp(N, vector<int64_t>(S_MAX + 1, INF));
    priority_queue<State> q;
    S = min(S, S_MAX);
    dp.at(0).at(S) = 0;
    q.push(State(0, 0, S));
    while (!q.empty())
    {
        int64_t t = q.top().t;
        int v = q.top().v, s = q.top().s;
        q.pop();

        if (dp.at(v).at(s) < t)
            continue;

        {
            int sn = min(s + C.at(v), S_MAX);
            int64_t tn = t + D.at(v);
            if (tn < dp.at(v).at(sn))
            {
                dp.at(v).at(sn) = tn;
                q.push(State(tn, v, sn));
            }
        }

        for (auto e : graph.at(v))
        {
            int vn = e.to, a = e.a, b = e.b;
            int sn = s - a;
            if (sn < 0)
                continue;
            int64_t tn = t + b;
            if (tn < dp.at(vn).at(sn))
            {
                dp.at(vn).at(sn) = tn;
                q.push(State(tn, vn, sn));
            }
        }
    }

    for (int i = 1; i < N; i++)
    {
        int64_t res = INF;
        for (int s = 0; s <= S_MAX; s++)
            res = min(res, dp.at(i).at(s));
        cout << res << endl;
    }
    return 0;
}


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

const int MOD = 1000000007;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({ a, ex });
    }
    if (N != 1) res.push_back({ N, 1 });
    return res;
}

int main() {
    ll n,t;
    ll ct;
    ct = 0;
    cin >> n;
    rep(i, n-1) {
        t = i + 1;
        const auto& pf = prime_factorize(t);
        long long res = 1;
        for (auto p : pf) res *= p.second + 1;
        ct = ct + res;
    }
    cout<<ct<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int b, f, r, v;
    int house[4][3][10];
    int i, j, k;
    for (i=0;i<4;i++) {
        for (j=0;j<3;j++) {
            for (k=0;k<10;k++) {
                house[i][j][k] = 0;
            }
        }
    }
    for (i=0;i<n;i++) {
        cin >> b >> f >> r >> v;
        house[b-1][f-1][r-1] +=v;
    }
    for (i=0;i<4;i++) {
        for (j=0;j<3;j++) {
            for (k=0;k<10;k++) {
                cout << " " << house[i][j][k];
            }
            cout << endl;
        }
        if (i<3) {
            cout << "####################" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3080
def main():

    from collections import Counter
    n = int(input())
    l = list(map(int,input().split()))

    l1 = []
    for i in range(n):
        l1.append(i-l[i])

    c = Counter(l1)
    count = 0
    for i in range(n-1):
        a = 2*i-l1[i]
        if a in c:
            count += c[a]
    print(count)
if __name__ == "__main__":
    main()

Measured memory_bytes: 130196
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int a[114514];
signed main(){
	double n;
	cin>>n;
	for(double i=1;i<3501;i++){
		for(double j=1;j<3501;j++){
			if(4/n-1/j-1/i>0.00001){
				int k=1/(4/n-1/j-1/i);
				if((i*j+j*k+k*i)*n==4*i*j*k){
					cout<<i<<" "<<j<<" "<<k<<endl;
					return 0;
				}
			}		
		}
	}
}	

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin>>s>>t;
	intl ans=0;
	for(intl i=0;i<s.length();i++){
		if(s[i]!=t[i]){
			ans++;
		}
	}
	cout<<ans<<"\n";
}


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

using namespace std;

int main(){
  int i, j, n, s, x, count;
  vector<int> data;

  while(1){
    cin >> n >> s;
    if(n == 0 && s == 0) break;

    for(i=0; i<n; ++i){
      cin >> x;
      data.push_back(x);
    }
    sort(data.begin(), data.end(), greater<int>());

    for(i=0, count=0; i<data.size(); ++i){
      if(s <= data[i]){
	count += (data.size()-1-i);
      }else{
	for(j=i+1; j<data.size(); ++j){
	  if(s >= data[i] + data[j]) break;
	  ++count;
	}
      }
    }

    cout << count << endl;
    data.clear();
  }
  return 0;
}

Measured memory_bytes: 1008
n = int(input())
t = list(map(int, input().split()))
m = int(input())
a = []
for _ in range(m):
    p, x = map(int, input().split())
    u = t[:]
    u[p - 1] = x
    a.append(sum(u))
for i in range(m):
    print(a[i])

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

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

    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'C')
        {
            a = i;
            ans += s[i];
            break;
        }
        
    }
    for (int j = a; j < s.size(); j++)
    {
        if (s[j] == 'F')
        {
            ans += s[j];
            break;
        }
        
    }
    
    if (ans == "CF")
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
    
}

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

int main(){
    ll n;
    cin >> n;
    map<int,int> mp;
    ll ans = 0;
    rep(i,n){
        ll a;
        cin >> a;
        if(mp.count(a)){
            mp.at(a)++;
            ans += a;
        }
        else{
            mp[a] = 1;
            ans += a;
        }
    }
    
    ll q;
    cin >> q;
    rep(i,q){
        ll b,c;
        cin >> b >> c;
        if(mp.count(b)){
            ans += (c-b)*mp.at(b);
            if(mp.count(c)){
                mp.at(c) += mp.at(b);
            }
            else{
                mp[c]= mp.at(b);
            }
            mp.erase(b);
        }
        
        cout << ans << endl;
    }
    //cout << ans << endl;
    
}

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

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = long.Parse(inputs[0]);
            var m = long.Parse(inputs[1]);
            var k = long.Parse(inputs[2]);
            Console.WriteLine(n+m+k <=21? "win":"bust");
        }
    }
}


Measured memory_bytes: 27504
#include <bits/stdc++.h>
using namespace std;
#define int long long
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    int n, m;
    cin >> n >> m;
    if ((n + m) % 3 == 0 || n % 3 == 0 || m % 3 == 0)
    {
        cout << "Possible"
             << "\n";
    }
    else
    {
        /* code */
        cout << "Impossible"
             << "\n";
    }

    cin >> str;

    return 0;
}


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

int cnt;

void insertionSort(vector<int>& A, int n, int g){
    for (int i=g; i<n; i++){
        int v = A[i];
        int j = i - g;

        while (j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
}
void shellSort(vector<int>& A, int n){
    cnt = 0;
    int m, G_element=1;
    //間隔は[2^(n-1), 2^(n-3),..., 8,3,1)]の順でやるのが早い
    vector<int> G;
    while (G_element <= n){
        G.push_back(G_element);
        G_element *= 2;
    }
    m = G.size();
    cout << m << endl;

    reverse(G.begin(), G.end());

    for (int i=0; i<m; i++) {
        cout << G.at(i);
        if (i==m-1) break;
        cout << ' ';
    } 
    cout << endl;

    for (int i=0; i<m; i++){
        insertionSort(A, n, G[i]);
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i=0;i<n;i++){
        cin >> A.at(i);
    }
    shellSort(A, n);
    cout << cnt << endl;
    for (int i=0; i<n; i++){
        cout << A.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 6708
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,l;
    cin>>n>>m>>l;
    long long a[200][200];
    long long b[200][200];
    long long c[200][200];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>b[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                c[i][j]=c[i][j]+a[i][k]*b[k][j];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j!=0)cout<<" ";
            cout<<c[i][j];
        }cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double pi = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

int main(){
    int x;
    cin >> x;
    if(x == 7 || x == 3 || x == 5) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n)-1; i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  string s; cin >> s;
  map<char, int> mp;
  for(const char c:s) mp[c]++;
  for(auto it = mp.begin(); it != mp.end(); it++){
    if(it->second == 2 && SZ(mp) == 2)  continue;
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> suuji(N);
   for (int i=0; i<N ;i++) {
     cin >> suuji.at(i) ;
   }
  sort(suuji.begin(),suuji.end());
  reverse(suuji.begin(),suuji.end());
  
  int x = 0;
  for (int j=0; j<N ; j++){
    if (j%2==0){
      x = x + suuji.at(j);
    }
    else {
      x = x - suuji.at(j);
    }
  }
  
  cout << x << endl;
      
}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll h, w;
  cin >> h >> w;
  
  vector<vector<char>> s(h, vector<char>(w));
  for (ll i = 0; i < h; ++i) {
    for (ll j = 0; j < w; ++j) {
      cin >> s[i][j];
    }
  }

  vector<vector<ll>> L(h, vector<ll>(w, 0));
  for (ll i = 0; i < h; ++i) {
    ll count = 0;
    for (ll j = 0; j < w; ++j) {
      if (s[i][j] == '#') count = 0;
      else count++;
      L[i][j] = count;
    }
  }

  vector<vector<ll>> R(h, vector<ll>(w, 0));
  for (ll i = 0; i < h; ++i) {
    ll count = 0;
    for (ll j = w-1; j >= 0; --j) {
      if (s[i][j] == '#') count = 0;
      else count++;
      R[i][j] = count;
    }
  }

  vector<vector<ll>> T(h, vector<ll>(w, 0));
  for (ll j = 0; j < w; ++j) {
    ll count = 0;
    for (ll i = 0; i < h; ++i) {
      if (s[i][j] == '#') count = 0;
      else count++;
      T[i][j] = count;
    }
  }

  vector<vector<ll>> B(h, vector<ll>(w, 0));
  for (ll j = 0; j < w; ++j) {
    ll count = 0;
    for (ll i = h-1; i >= 0; --i) {
      if (s[i][j] == '#') count = 0;
      else count++;
      B[i][j] = count;
    }
  }

  ll ans = 0;
  for (ll i = 0; i < h; ++i) {
    for (ll j = 0; j < w; ++j) {
      ans = max(L[i][j] + R[i][j] + T[i][j] + B[i][j] - 3, ans);
    }
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 129536
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    long i = 1;
    long ans;
    while (true)
    {
        char[4] t = ['0', '3', '5', '7'];
        string s;
        long j = i;
        bool[] b = new bool[](4);
        while (j != 0)
        {
            b[j % 4] = true;
            s = t[j % 4] ~ s;
            j /= 4;
        }
        if (!b[0] && b[1 .. $].all!(x => x))
        {
            // writefln("%d %s", i, s);
            if (N < s.to!long)
            {
                writeln(ans);
                return;
            }
            ans++;
        }
        i++;
    }
}


Measured memory_bytes: 1276
#include <iostream>
#include <map>

using namespace std;

int T;
//map<int, bool> d;
int d[20000];

main(){
  for(int i=0;i<143;i++){
    for(int j=0;j<143;j++){
      int t = i * i + j * j;
      if(1 < t && t < 20000) d[t] = true;
    }
  }
  /*map<int, bool>::iterator iti, itj;
  for(iti=d.begin();iti!=d.end();iti++){
    if(!iti->second) continue;
    for(itj=iti;itj!=d.end();itj++){
      int t = iti->first * itj->first;
      if(t >= 20000) break;
      d[t] = false;
    }
    }*/
  for(int i=0;i<20000;i++){
    if(!d[i]) continue;
    for(int j=i;j<20000;j++){
      int t = i * j;
      if(t >= 20000) break;
      d[t] = false;
    }
  }
  cin >> T;
  for(int i=0;i<T;i++){
    int m, n, t;
    cin >> m >> n;
    t = m * m + n * n;
    cout << (d[t] ? "P" : "C") << endl;
  }
}

Measured memory_bytes: 1228
// AOJ 1236 Map of Ninja House
// 2018.2.6 bal4u
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int n, id;
int r[1002];
int g[102][102], hi[102];
int deg[102], depth[102];

void dfs(int k, int d)
{
	int t;

	n++, depth[d] = k;
	while (hi[k] < deg[k]) {
		if (r[id] > 0) {
			deg[n] = r[id++];
			g[k][hi[k]++] = n;
			g[n][hi[n]++] = k;
			dfs(n, d+1);
		} else{
			t = depth[d + r[id++]];
			g[k][hi[k]++] = t;
			g[t][hi[t]++] = k;
		}
	}
}

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
    int cno, i, j;
	
	cno = in();
    while (cno--) {
		memset(r, 0, sizeof(r));
		memset(hi, 0, sizeof(hi));
		for (i = 0; r[i] = in(); i++);

        n = 0, id = 1, deg[0] = r[0];
		dfs(0, 0);

		for (i = 0; i < n; i++) {
            printf("%d", i+1);
			qsort(g[i], hi[i], sizeof(int), cmp);
			for (j = 0; j < hi[i]; j++) printf(" %d", g[i][j] + 1);
            putchar('\n');
		}
	}
    return 0;
}


Measured memory_bytes: 2104
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto l = new long[](n+1);
  l[0] = 2;
  l[1] = 1;

  foreach (i; 2..n+1) {
    l[i] = l[i-1] + l[i-2];
  }

  l[n].writeln;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String[] args) {
    	
    	Scanner sc = new Scanner(System.in);
    	ArrayList<Double> sList = new ArrayList<>();
    	ArrayList<Double> devList = new ArrayList<>();
    	ArrayList<Double> sigmaList = new ArrayList<>();
    	
    	int n = 999;
    	double s;
    	double sum = 0;;
    	double avg;
    	double disp = 0;
    	double sigma;
    	int cnt = 0;
    	while(n != 0) {
    		n = sc.nextInt();
    		if(n == 0) {
    			break;
    		} else {
       			//ArrayList?????????
    			for(int i = 0; i < n; i++) {
    	    		sList.add(0.0);
    	    		devList.add(0.0);
    	    	}
    			//???????????\???
    	    	for(int i = 0; i < n; i++) {
    	    		s = sc.nextDouble();
    	    		sList.set(i, s);
    	    	}
    	    	//????¨?
    	    	for(int i = 0; i < n; i++) {
    	    		sum = sList.get(i) + sum;
    	    	}
    	    	//??????
    	    	avg = sum / n;
    	    	//??????
    	    	for(int i = 0; i < n; i++) {
    	    		devList.set(i, Math.abs(sList.get(i) - avg));
    	    	}
    	    	//?????£
    	    	for(int i = 0; i < n; i++) {
    	    		disp = devList.get(i) * devList.get(i) + disp;
    	    	}
    	    	disp = disp / n;
    	    	//?¨??????????
    	    	sigma = Math.sqrt(disp);
    	    	sigmaList.add(sigma);
    	    	cnt++;
    		}
    		sum = 0;
    		avg = 0;
    		disp = 0;
    		sigma = 0;
    	}
    	for(int i = 0; i < cnt; i++) {
    		System.out.println(sigmaList.get(i));
    	}
    }
}

Measured memory_bytes: 40252
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int ans = ((h>n) || (w>n))
			? 0
			: (n+1-h)*(n+1-w);
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

template<typename T>
T up(const T& l, const T& r) {//SegmentTreeのupdate関数
    T res;
    res = min<T>(l,r);
    return res;
}

template<typename T>
class SegmentTree {
public:
    vector<T> seg;
    int sz = 1;
    T unit;
    //T (*up)(const T& l,const T& r);
    SegmentTree(int n, T unit = 0) {
        this->unit = unit;
        //int sz = 1;
        while (sz < n) sz <<= 1;
        seg.resize(sz * 2, unit);
        //up = &up1;
    }
    void set(const int& k, const T& x) {//左からk番目の葉にxを代入する
        seg[sz - 1 + k] = x;
    }
    T get(const int& k) {//左からk番目の葉を得る
        return seg[sz - 1 + k];
    }
    void update(int k, const T& v) {// k 番目の値をvに変更
        k += sz - 1;
        seg[k] = v;
        while (k > 0) {
            k = (k - 1) / 2;
            seg[k] = up(seg[2 * k + 1], seg[2 * k + 2]);
        }
    }
    T query(int a, int b, int k, int l,int r) {//[a,b)のupの合成を求める(a,b,0,0,sz)のように使う
        if (r <= a || b <= l) {
            return unit;
        }
        if (a <= l && r <= b) {
            return seg[k];
        }
        else {
            T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return up(vl, vr);
        }
    }
};

int main(){
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n*2);
    REP(i,n){
        cin >> a[i];
        a[i+n] = a[i];
    }
    SegmentTree<ll> sg(n*2,LLONG_MAX);
    Rep(i,n){
        sg.update(i,a[i]);
        sg.update(i+n,a[i+n]);
    }
    ll res = LLONG_MAX;
    Rep(k,n){
        ll cost = k*x;
        int sz = sg.sz;
        Rep(j,n){
            if(j-k<0){
                cost+=sg.query(j-k+n,j+1+n,0,0,sz);
            }else{
                cost+=sg.query(j-k,j+1,0,0,sz);
            }
        }
        chmin(res,cost);
    }
    put(res);
    return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
 
int koch(double x1,double y1,double x2,double y2,int n){

  if(n==0){
    printf("%f %f\n",x2,y2);
    return 0;
  }

  double Ax,Ay,Bx,By,Cx,Cy;
  Ax=(x2-x1)/3+x1;
  Ay=(y2-y1)/3+y1;
  Bx=(x2-x1)*2/3+x1;
  By=(y2-y1)*2/3+y1;
  Cx=(cos(M_PI/3)*(Bx-Ax)-sin(M_PI/3)*(By-Ay))+Ax;
  Cy=(sin(M_PI/3)*(Bx-Ax)+cos(M_PI/3)*(By-Ay))+Ay;
  koch(x1, y1, Ax, Ay, n-1);
  koch(Ax, Ay, Cx, Cy, n-1);
  koch(Cx, Cy, Bx, By, n-1);
  koch(Bx, By, x2, y2, n-1);
   
}


int main(){
  int n;
  double x1=0,y1=0,x2=100,y2=0;
  scanf("%d",&n);
  printf("0.00000000 0.00000000\n");
  koch(x1,y1,x2,y2,n);
  return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&a!=c)||(a==c&&b!=a)||(b==c&&a!=b)){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    int n;cin>>n;
    vector<ll> a(n);
    rep(i, n) {
        cin>>a[i];
    }
    sort(all(a));
    dump(a);

    int V = 1000001;
    vec<int> cnt(V);
    rep(i, n){
        if (cnt[a[i]] >= 1){
            cnt[a[i]]++;
            continue;
        }

        for(ll x=a[i]; x<=V; x+=a[i]){
            cnt[x]++;
        }
    }

    int ans = 0;
    rep(i, n){
        if (cnt[a[i]] == 1) ans++;
    }
    cout << ans << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 8744