akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int c[SIZE],a[SIZE];
int main(){
    int N;
    R(N);
    FOR(i,1,N){
        R(a[i]);
        c[a[i]]++;
    }
    LL an=0;
    FOR(i,1,N)an+=c[i]*(c[i]-1LL)/2;
    FOR(i,1,N)W(an-c[a[i]]+1);
    return 0;
}


Measured memory_bytes: 7424
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;

char s[120];
int len;
int last,ans=1999999999,anss;
int main()
{
    scanf ("%s",s+1);
    len=strlen(s+1);
    for (int i=0;i<26;i++)
        {
        anss=0;
        last=0;
        for (int j=1;j<=len+1;j++)
            if (s[j]==i+'a' || j==len+1)
                {
                anss=max(anss,j-last-1);
                last=j;
                }
        if(last!=0)
            ans=min(ans,anss);
        }
    printf ("%d",ans);
}


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

using namespace std;

using ll = long long;

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

    ll N;
    ll T[5];
    cin >> N;
    ll min_n = (ll) 1e15;
    for (auto & t : T) {
        cin >> t;
        min_n = min(min_n, t);
    }
    ll res = (N + min_n - 1) / min_n + 4;

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 256
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

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

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define sz(s)  (int)s.size()
#define all(s)  s.begin(),s.end()
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

int dx[]= {0,0,1,-1};
int dy[]= {1,-1,0,0};

ll cost[105],val[105],dp[N][105],n,w;
ll fun(int cos,int pos) {
    if(pos>n)return 0;
    if(dp[cos][pos]!=0)return dp[cos][pos];
    ll profit1=0,profit2=0;
    if(cos+cost[pos]<=w) {
        profit1=val[pos]+fun(cos+cost[pos],pos+1);
    }
    profit2=fun(cos,pos+1);
    return dp[cos][pos]=max(profit1,profit2);
}
int main() {

    //IOS;
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        cin>>n>>w;
        for(int i=1; i<=n; ++i) {
            cin>>cost[i]>>val[i];
        }
        cout<<fun(0,1)<<endl;
    }
    return 0;
}



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

static class NagataKanaIsAGenius {
    public static void Main() {
        int[]abk=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a=abk[0];
        int b=abk[1];
        int k=abk[2];
        for(int i=Math.Min(a,b);i>=1;i--){
            if(a%i!=0||b%i!=0)continue;
            if(--k==0) {
                Console.WriteLine(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 13268
import sys
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n = I()

c = 0
found = False
for i in range(n):
    j, k = I()
    if j == k:
        c += 1
    else:
        c = 0
    
    if c >= 3:
        found = True
        break

print('Yes' if found else 'No')


Measured memory_bytes: 67468
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            long MOD = 1000000007;

            int N = sc.nextInt();
            int K = sc.nextInt();

            long[] fact = new long[N + 1];
            fact[0] = 1;
            for (int i = 1; i <= N; i++) {
                fact[i] = fact[i - 1] * i % MOD;
            }

            long ans = 0;
            for (int i = 0; i <= K; i++) {
                if (N - i <= 0) {
                    break;
                }

                ans = (ans + combination(fact, N, N - i, MOD) * combination(fact, N - 1, i, MOD)) % MOD;
            }

            System.out.println(ans);
        }
    }

    static long combination(long[] fact, int N, int K, long MOD) {
        long comb = fact[N];
        comb = comb * pow(fact[K], MOD - 2, MOD) % MOD;
        comb = comb * pow(fact[N - K], MOD - 2, MOD) % MOD;
        return comb;
    }

    static long pow(long A, long B, long MOD) {
        if (B == 0) {
            return 1;
        } else if (B % 2 == 0) {
            long C = pow(A, B / 2, MOD);
            return C * C % MOD;
        } else {
            long C = pow(A, B - 1, MOD);
            return A * C % MOD;
        }
    }

}


Measured memory_bytes: 28316
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        var s = Console.ReadLine();
        if(
            (s.Contains('N') && !(s.Contains('S'))) ||
            (s.Contains('S') && !(s.Contains('N'))) ||
            (s.Contains('E') && !(s.Contains('W'))) ||
            (s.Contains('W') && !(s.Contains('E')))
            ){
                Console.WriteLine("No");
            }else{
                Console.WriteLine("Yes");
            }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>

int main(void) {
    int a, b, c;
    int divisor = 0;

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

    for ( a; a <= b; a++) {
        if (c % a == 0) {
            divisor++;
        }
    }

    printf("%d\n", divisor);
}


Measured memory_bytes: 2144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner cin = new Scanner(System.in)) {
			if ((cin.nextInt() * 100 + cin.nextInt() * 10 + cin.nextInt()) % 4 == 0) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		} finally {
		}
	}

}


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

void solve(int t, int d, int l) {
    vector<int> x(t);
    for (int i = 0; i < t; i++) cin >> x[i];
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < t; i++) {
        if (cnt > 0) ans++;
        if (x[i] >= l) cnt = d;
        else cnt--;
        cnt = max(cnt, 0);
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T, D, L;
    while (true) {
        cin >> T >> D >> L;
        if (T == 0 && D == 0 && L == 0) break;
        solve(T, D, L);
    }
    return 0;
}


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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

int main(){

    bool flag=true;

    ll ans=0,sum=0;
    
    int n,m;
    cin >>n;
    
    if(n > 999)cout << "ABD" <<endl;
    else cout << "ABC" <<endl;

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

using namespace std;

int main(){

    int A, B;
    cin >> A >> B;
    if(A >= 13){
        cout << B << endl;
    }
    else if(A >= 6){
        cout << B / 2 << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}

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

int main(){
    string num;

    cin >> num;

    int sum = 0;

    for(int i = 0; i < num.size(); i++) sum += (num[i] - '0');

    if(sum % 9 == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3752
// atcoder contests //
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define nl "\n";

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// problem statements implementation
	ll a, b, c , d;
	cin >> a >> b >> c >> d;\
	vector<ll> v;
	//v.push_back(a*b);
	v.push_back(a*c);
	v.push_back(a*d);
	v.push_back(b*c);
	v.push_back(b*d);
	//v.push_back(c*d);
	cout << *max_element(v.begin(), v.end())<< nl;
	return 0;
}	

Measured memory_bytes: 3652
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int count1=0;
    int count2=0;

    while(x>=500){
      x-=500;
      count1++;
    }

    while(x>=5){
      x-=5;
      count2++;
    }

    System.out.println(count1*1000+count2*5);

  }
}


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

int main() {
  ll N = 0,B = 0;
  cin >> N;
  vector<ll>A(N);
  vector<ll>ans(0);
  rep(i,N){
    cin >> A[i];
  }
  rep(i,100){
    B = 0;
    rep(j,N){
      B += pow(A[j]-1-i,2);
    }
    ans.push_back(B);
  }
  sort(ans.begin(), ans.end());
  cout << ans[0];
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using pi = pair<int,int>;

signed main(){
	int n,m; cin>>n>>m;
	vector<pi> vec(m);
	vvi g(n,vi(0));
	rep(i,0,m){
		int a,b; cin>>a>>b;
		--a; --b;
		vec[i]=make_pair(a,b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	ll ans=0;
	rep(i,0,m){
		int a=vec[i].first,b=vec[i].second;
		vector<bool> seen(n);
		queue<int> q;
		int cnt=0;
		q.push(0);
		seen[0]=true;
		while(!q.empty()){
			cnt++;
			int k=q.front(); q.pop();
			for(auto c:g[k]){
				if(k==a && c==b)continue;
				if(k==b && c==a)continue;
				if(seen[c])continue;
				seen[c]=true;
				q.push(c);
			}
		}
		if(cnt!=n)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  ll ans=0;
  if(n%2==1){
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(i+j==n) continue;
      ans++;
    }
  }
  COUT(ans);
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(i+j==n) continue;
      cout<<i<<" "<<j<<endl;
    }
  }
  }
  else{
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        if(i+j==n+1) continue;
        ans++;
      }
    }
    COUT(ans);
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        if(i+j==n+1) continue;
        cout<<i<<" "<<j<<endl;
      }
    }
  }
}

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

int main() {
  int k, n;
  cin >> k >> n;
  
  vector<int> vec1(n), vec2(n);
  for (int i = 0; i < n; i++) {
    cin >> vec1[i];
  }
  
  for (int i = 0; i < n-1; i++) {
    vec2[i] = vec1[i+1] - vec1[i];
  }
  vec2[n-1] = k + vec1[0] - vec1[n-1];
  
  cout << k - *max_element(vec2.begin(), vec2.end()) << endl;
}

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

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

typedef tuple<int, int, int> tiii;

struct UnionFind
{
	vector<int> par, sizes;

	UnionFind(int n) : par(n), sizes(n, 1)
	{
		for (int i = 0; i<n; i++) par[i] = i;
	}

	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);

		if (x == y) return;

		if (sizes[x] < sizes[y]) swap(x, y);

		par[y] = x;
		sizes[x] += sizes[y];
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	int size(int x) {
		return sizes[find(x)];
	}
};

bool comp(tiii a, tiii b)
{
	return get<2>(a) < get<2>(b);
}

int main()
{
	while (1)
	{
		int n, m;
		cin >> n >> m;
		if (n == 0) return 0;

		vector<tiii> edge(m);
		rep(i, 0, m)
		{
			int a, b, w;
			cin >> a >> b >> w;
			a--; b--;
			edge[i] = make_tuple(a, b, w);
		}

		sort(edge.begin(), edge.end(), comp);

		int ans = -1;
		rep(i, 0, m)
		{
			UnionFind uf(n);
			int _min = get<2>(edge[i]);
			int _max = -1;
			rep(j, i, m)
			{
				int a = get<0>(edge[j]);
				int b = get<1>(edge[j]);
				int w = get<2>(edge[j]);
				if (!uf.same(a, b))
				{
					uf.unite(a, b);
					_max = max(_max, w);
				}
			}
			bool ok = true;
			rep(j, 1, n)
			{
				if (!uf.same(0, j)) ok = false;
			}
			if (ok)
			{
				if (ans < 0)
					ans = _max - _min;
				else
					ans = min(ans, _max - _min);
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3176
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,K,L=list(map(int,input().split()))
pq=[list(map(int,input().split())) for i in range(K)]
rs=[list(map(int,input().split())) for i in range(L)]

uf_road = UnionFind(N)
uf_train = UnionFind(N)

for i in range(K):
    uf_road.union(pq[i][0]-1,pq[i][1]-1)
for i in range(L):
    uf_train.union(rs[i][0]-1,rs[i][1]-1)

# 各都市に連結しているroadとtrainの積集合の探索はTLE
# ans = []
# for i in range(N):
#   ans.append(len(set(uf_road.members(i)) & set(uf_train.members(i))))
# print(*ans)

# road,trainの根のペアで同じペアを持つ都市は連結している
from collections import Counter
pair = [(uf_road.find(i), uf_train.find(i)) for i in range(N)]
ans = Counter(pair)
print(*[ans[i] for i in pair])

Measured memory_bytes: 89336
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <stack>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

#define REP(i,a) for(int (i)=0;(i)<(a);i++)
#define RREP(i,a,b) for(int (i)=(a);(i)<(b);i++)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
typedef long long ll;
using namespace std;


int main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string S[n];
    int h[n][26]={};
    REP(i,n){
        cin>>S[i];
        REP(j,sz(S[i]))h[i][S[i][j]-'a']++;
    }
    string ans;
    REP(i,26){
        int tmp=100;
        REP(j,n)tmp=min(tmp,h[j][i]);
        REP(k,tmp)ans+='a'+i;
    }
    cout<<ans;
    return 0;
}

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

#define int long long
#define INF 1e18

signed main() {
    int x, y, z; cin >> x >> y >> z;
    cout << (x - z) /  (y + z) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vvi G(N);
  vp E(N-1);
  rep(i,N-1) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    E[i] = P(a,b);
  }
  int K = 0;
  rep(i,N) {
    if(i == 0) {
      K = max(K,sz(G[i]));
    } else {
      K = max(K,sz(G[i])+1);
    }    
  }
  vi color(N,1);
  queue<P> que;
  que.push(P(0,0));
  while(!que.empty()) {
    int k = que.front().first;
    int p = que.front().second;
    que.pop();
    int co = 1;
    rep(i,sz(G[k])) {
      if(color[k] == co && k != 0) {
        co++;
      }
      color[G[k][i]] = co;
      que.push(P(G[k][i],k));
      co++;
    }
  }
  cout << K << endl;
  rep(i,N-1) {
    cout << color[E[i].second] << endl;
  }
  return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    ll n;
    cin>>n;
    vector<ll> v(n);
    ll sum{};
    for(ll i=0;i<n;i++)
        cin>>v[i],sum+=v[i];
    ll x[n];
    ll sum2{};
    for(ll i=1;i<n;i+=2)
        sum2 += v[i];
    x[0] = sum - 2*sum2;
    for(ll i=1;i<n;i++)
    {
        x[i] = 2*v[i-1] - x[i-1];
    }
    for(ll i=0;i<n;i++)
        cout<<x[i]<<" ";
	return 0;
}

Measured memory_bytes: 4820
/*
        Author: Prokash
                CSE48, JU

*/

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int ara[2005];
int main()
{
    FAST;
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        int in;
        cin>>in;
        ans+=in;
    }
    cout<<ans-n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
typedef long long ll;
const ll INF=1e18;
#define rep(i,n) for(int i=0;i<n;i++)
#define print(a) cout << a << endl

unordered_map<string, ll> cnt;

void solve() {
    ll mx=0;
    vector<pair<string, ll> > v(cnt.begin(), cnt.end());
    rep(i,cnt.size())mx=max(mx,v.at(i).second);
    //sort(ALL(v));
    //reverse(ALL(v));
    //rep(i,cnt.size())print(v.at(i).second);
    /*if(v.at(0).second<0)v.at(0).second=0;*/
    print(mx);
}

int main()
{
    int n,m;
    cin >> n;
    rep(i,n){
        string s;cin >> s;cnt[s]++;
    }
    cin >> m;
    rep(i,m){
        string s;cin >> s;cnt[s]--;
    }
    solve();
    return 0;
}

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

main(){
  vector<int> a(3);
  for(int i = 0;i<3;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  if(a[0]+a[1] == a[2])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
import itertools
L,R=map(int,input().split())
if R-L>=2019:
  print(0)
else:
  MIN=2018  
  list1=list(range(L,R+1))
  list2=list(itertools.combinations(list1,2))
  for i in range(len(list2)):
    a=list2[i][0]*list2[i][1]%2019
    MIN=min(MIN,a)
  print(MIN)    

Measured memory_bytes: 150328
from collections import deque
k = int(input())
d = deque([1,2,3,4,5,6,7,8,9])


for i in range(k):
    x = d.popleft()
    cand = x%10
    if(cand != 0):
        d.append(10*x+cand-1)
    d.append(10*x+cand)
    if(cand != 9):
        d.append(10*x+cand+1)

print(x)

Measured memory_bytes: 18908
a,b,c = map(int,input().split())
i = 0
flag = 0
while a % 2 == b % 2 == c % 2 == 0:
	if a == b == c:
		print(-1)
		flag = 1
		break
	i = i + 1
	a2 = b // 2 + c // 2
	b2 = c // 2 + a // 2
	c2 = a // 2 + b // 2
	a,b,c = a2,b2,c2
if flag == 0:
	print(i)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e8+7;


int main() {
    
    int n;
    cin >> n;
    vi h(n);
    
    for(int& x : h) {
        cin >> x;
    }
    
    int m = 0;
    int ans = 0;
    
    for(int i = 0; i < n; ++i) {
        if(h[i] >= m) {
            ans++;
            m = h[i];
        }
    }
    
    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 200000;

class UFT{
public:
    UFT(int size){
        this->size = size;
        uft = new int[size];

        for(int i = 0;i < size;i++){
            uft[i] = -1;
        }
    }

    ~UFT(){
        delete uft;
    }

    int root(int n){
        if(n < 0 || n >= size)return -1;
        if(uft[n] == -1)return n;
        return uft[n] = root(uft[n]);
    }

    void unite(int a,int b){
        int aRoot = root(a);
        int bRoot = root(b);
        if(aRoot == bRoot)return;
        uft[aRoot] = bRoot;
    }
    
private:
    int size;
    int* uft;
};

int main(){
    int N,M;
    int A[MAX],B[MAX];

    cin >> N >> M;
    for(int i = 0;i < M;i++){
        cin >> A[i] >> B[i];
    }

    UFT uft(N);
    for(int i = 0;i < M;i++){
        uft.unite(A[i] - 1,B[i] - 1);
    }

    int cnt[MAX] = {0};
    int ans = 0;
    for(int i = 0;i < N;i++){
        cnt[uft.root(i)]++;
        ans = max(cnt[uft.root(i)],ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11960
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }
int hash(int key, int i){ return (h1(key)+i*h2(key))%M;}

int find(char str[]){
  long long key, i, h;
  key = getKey(str);
  for ( i = 0;; i++){
    h = hash(key, i);
    if( strcmp(H[h],str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  for ( i = 0; ; i++ ){
    h = hash(key, i);
    if( strcmp(H[h],str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}


int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str) ){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 17000
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],b[100005],c[100005],dp[100005][3];
int main()
{
	cin >> n;
	for(int i=1; i<=n; i++) cin >> a[i] >> b[i] >> c[i];
	for(int i=1; i<=n; i++) 
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
	}
	cout << max({dp[n][0],dp[n][1],dp[n][2]});
	return 0;
}

Measured memory_bytes: 5944
#include <bits/stdc++.h>
using namespace std;
int n,l;
string s[100009];
int main(){
    cin>>n>>l;
    for(int i=0;i<n;i++)cin>>s[i];
    sort(s,s+n);
    for(int i=0;i<n;i++)cout<<s[i];
    cout<<endl;
}


Measured memory_bytes: 1024
problems, submissions= map(int, input().split())
lst = [[0,False] for i in range(problems)]
solved = 0
pen  = 0
for z in range(submissions):
    prob, stat = input().split()
    prob = int(prob) - 1
    if lst[prob][1] == False:
        if stat == "AC":
            lst[prob][1] = True
            pen += lst[prob][0]
            solved += 1
        else:
            lst[prob][0] += 1
print(solved,pen)

Measured memory_bytes: 60320
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
 
int main()
{
	int a;
	int ans[50];
	scanf("%d", &a);
	int cas = 1;

  if(a == 0) 
  {
	printf("0\n");			
  }
  else
  {
		int num = -1;
		while(a)
		{
			ans[++num] = a%(-2);
			a/=(-2);
			if(ans[num] == -1)
			{ ans[num] = 1; a++; }
		}
		for(int i=num; i>=0; i--)
		{
			printf("%d", ans[i]);
		}
		printf("\n");
  }
  return 0;
}


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main()
{
    int a, b, c;
    ci >> a >> b >> c;

    co << b + min(c, a + b + 1) << en;
  
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String regex = "Hoshino";
		Pattern p = Pattern.compile(regex);
		for(int i = 0 ; i < n;i++){
			String str = br.readLine();
			Matcher m = p.matcher(str);
			m.replaceAll("Hoshina");
			System.out.println(m.replaceAll("Hoshina"));
		}
	}

}

Measured memory_bytes: 24580
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DEBUG_OUTPUT_ENABLED 1
	#define DBG(X) dout << #X << "=" << (X) << '\n';
	#define SAY(X) dout << (X) << '\n';
#else
	#define DEBUG_OUTPUT_ENABLED 0
	#define DBG(X) 42;
	#define SAY(X) 42;
#endif

#define dout   debug::instance

using namespace std;

template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
namespace debug {
	struct DebugStream {
		private:
			bool is_first;
		public:
			DebugStream(bool _is_first): is_first(_is_first) {}
			template<typename T> DebugStream operator<<(const T& value) const {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				cout << value;
				return DebugStream(false);
			};

			template<typename T> DebugStream printArray(T* l, T* r) {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				while(l != r) {
					cout << (*l);
					++l;
					if(l == r) {
						cout << '\n';
					} else {
						cout << ' ';
					}
				}
				return DebugStream(false);
			}
	};
	DebugStream instance(true);
};

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

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	ll n = fetch<ll>();
	ll k = fetch<ll>();
	ll answ = n;
	n %= k;
	answ = min(answ, n);
	for(int i = 0; i < 100; ++i) {
		n = abs(n - k);
		answ = min(answ, n);
	}
	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<pii, int> para;
const int inf = 1e9 + 7;
const int maxN = 1e6 + 5;

int n, so, w, e;
string s;

int main() {
	cin>>s;
	REP(i, sz(s)) {
		if (s[i] == 'N') n++;
		if (s[i] == 'S') so++;
		if (s[i] == 'W') w++;
		if (s[i] == 'E') e++;
	}
	
	bool ans = true;
	if ((n > 0 && so == 0) || (n == 0 && so > 0)) ans = false;
	if ((w > 0 && e == 0) || (w == 0 && e > 0)) ans = false;
	if (ans) cout<<"Yes"; else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int ret = 0;
  rep(i,N){
    ll x, y;
    cin >> x >> y;

    if(x*x+y*y <= D*D){
      ret++;
    }
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

double const PI2nd = std::acos(-1)*0.5;
double const toRad = std::acos(-1)/1.8e2;
double a, b, S;

bool isOK(double deg) {
  double rad = deg*toRad;
  if(rad > PI2nd - 1e-10) return false;
  if(rad < 1e-10) return true;
  double h = a*std::tan(rad), cS;
  if(h <= b) {
    cS = a*(b - h*0.5);
  } else {
    cS = b*b/std::tan(rad)*0.5;
  }
  return S < cS;
}

int main() {
  std::cout << std::setprecision(10) << std::fixed;
  double x; std::cin >> a >> b >> x;
  S = x/a;
  double ok = 0.0, ng = 90.0;
  while(ng-ok > 1e-6) {
    double mid = (ok+ng)*0.5;
    if(isOK(mid)) ok = mid; else ng = mid;
  }
  fin((ok+ng)*0.5);
  return 0;
}


Measured memory_bytes: 384
n = int(input())
a,b,c = [0] * n, [0] * n, [0] * n

for i in range(n):
	a[i], b[i], c[i] = map(int, input().split())
dp = [[0] * 3 for _ in range(n)]
dp[0] = [a[0], b[0], c[0]]
for i in range(n - 1):
	dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + a[i + 1], dp[i][2] + a[i + 1])
	dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + b[i + 1], dp[i][2] + b[i + 1])
	dp[i + 1][2] = max(dp[i + 1][2], dp[i][0] + c[i + 1], dp[i][1] + c[i + 1])
print(max(dp[-1]))

Measured memory_bytes: 62168
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int a=0,b=0;
  cin>>s;
  bool flag=false;
  for (int i=0;i<s.size();i++){
    if(flag==false){
    if(s[i]=='A'){ a=i; flag=true;}
    }
    if(flag==true) {
      if(s[i]=='Z') b=i;
    }
  }
  cout<<b-a+1<<endl;
}

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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> p(n); rep(i, n) cin >> p[i];

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


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		while ((line = br.readLine()) != null) {
			double x, h, xh;
			x = Double.parseDouble(line);
			h = Double.parseDouble(br.readLine());

			if (x == 0 && h == 0)
				break;

			xh = Math.sqrt(Math.pow(x / 2, 2) + Math.pow(h, 2));
			System.out.println(x * (xh * 2 + x));
		}
	}
}

Measured memory_bytes: 15084
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[1000001];

int main(){
  clr(d,0);
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  sort(all(v));
  ll ans = 0;
  rep(i,0,v.sz){
    if(i!=v.sz-1){
      if(v[i]==v[i+1]){
        ans++;
        if(v[i]<1000){
          d[v[i]]++;
        }
        else{
          rep(j,1,1001){
            if(v[i]*j>1000000)break;
            d[v[i]*j]++;
          }
        }
        continue;
      }
    }
    if(v[i]<1000){
      rep(j,1,v[i]+1){
        if(d[j]==0)continue;
        if(v[i]%j==0){
          ans++;
          break;
        }
      }
      d[v[i]]++;
    }
    else{
      if(d[v[i]]>0){
        ans++;
      }
      else{
        rep(j,1,1000){
          if(d[j]==0)continue;
          if(v[i]%j==0){
            ans++;
            break;
          }
        }
      }
      rep(j,1,1001){
        if(v[i]*j>1000000)break;
        d[v[i]*j]++;
      }
    }
  }
  cout << n-ans << endl;
  return 0;
}

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

// headers {{{
using namespace std;
// using namespace rel_ops;
 
const double pi=acos(-1.0);
const double eps=1e-11;
const int INF=0x7FFFFFFF;
template<class T> inline bool checkmin(T &a,T b){return b<a?a=b,1:0;}
template<class T> inline bool checkmax(T &a,T b){return b>a?a=b,1:0;}
template<class T> inline T sqr(T x){return x*x;}
template<class T> inline bool bit(T a, int b) {return (a>>b)&1;}
inline int popcount(int n) { return __builtin_popcount(n); }
inline int popcount(long long n) { return __builtin_popcountll(n); }
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define eb(args...) emplace_back(args)
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ff first
#define ss second
#define sz(g) int(g.size())
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
#ifdef LOCAL
#define dout cerr 
void out() { dout << endl; }
template<typename A, typename... B> void out(A a, B... b) { dout << ' ' << a; out(b...); }
#define dbg(args...) dout << __LINE__ << ":(" << #args << ") -> ", out(args)
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
constexpr bool local = true;
#else
#define dbg(...)
#define dout if(true);else cerr
#define out(...)
#define show(...)
constexpr bool local = false;
#endif
// }}}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    int n; while (cin >> n) {
        VI a(n);
        map<int, int> mp;
        rep(i, n) {
            cin >> a[i];
            mp[a[i]]++;
        }
        const int N = 1e6+2;
        for (auto x : mp) {
            int u = x.ff;
            for (auto y = u; y < N; y += u) {
                if (mp.count(y)) {
                    mp[y]++;
                }
            }
        }
        int ans = 0;
        for (auto x : mp) {
            dbg(x);
            if (x.ss == 2) ans++;
        }
        cout << ans << endl;
    }
    
    return 0;
}



Measured memory_bytes: 13396
H, W = map(int, input().split())
mark = []
for i in range(H):
    mark.append(input())

dp = [[0 for i in range(W)] for j in range(H)]
dp[0][0] = 1
mod = int(1e9) + 7
for i in range(H):
    for j in range(W):
        if i > 0 and mark[i - 1][j] == '.':
            dp[i][j] += dp[i - 1][j] % mod
        if j > 0 and mark[i][j - 1] == '.':
            dp[i][j] += dp[i][j - 1] % mod
        dp[i][j] %= mod

print(dp[H - 1][W - 1])

Measured memory_bytes: 55260
H, N = map(int, input().split())
A = []
max_A = 0
for i in range(N):
    A.append(tuple(map(int, input().split())))
    max_A = max(max_A, A[i][0])

INF = 10**9
dp = [INF] * (2 * 10 ** 4 + 1)
dp[0] = 0

for i in range(2 * 10 ** 4):
    for a, b in A:
        if i + a <= 2 * 10 ** 4:
            dp[i+a] = min(dp[i]+b, dp[i+a])

print(min(dp[H:]))

Measured memory_bytes: 74188
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;

vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0 ) {
            res.push_back(i);
            if (n / i != i) res.push_back(n / i);
        }
    }
    sort(all(res));
    return res;
}

ll ff(ll a, ll i) {
    return a*a*a*a + a*a*a * i + a*a * i*i + a * i*i*i + i*i*i*i;
}


int main() {
    ll x; cin >> x;

    vector<ll> f = divisor(x);
    vector<ll> d = divisor(x);

    for (ll i = 0; i < f.size(); ++i) {
        d.push_back(f[i] * (-1));
    }

    ll a;
    ll b;
    for (auto e: d) {
        ll s = x / e;

        bool ok = false;

        for (ll i = -1000; i <= 1000; ++i) {
            a = e + i;
            ll t = ff(a, i);

            if (s == t) {
                b = i;
                ok = true;
                break;
            }
        }

        if (ok) break;
    }

    cout << a << " " << b << endl;
}


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

int main() {
  int num;
  cin >> num;
  
  if(num % 10 == 2 || num % 10 == 4 || num % 10 == 5 || num % 10 == 7 || num % 10 == 9){
  	cout << "hon" << endl;
  }
  else if(num % 10 == 0 || num % 10 == 1 || num % 10 == 6 || num % 10 == 8) {
    cout << "pon" << endl;
  }
  else {
    cout << "bon" << endl;
  }
  return 0;
}



Measured memory_bytes: 3624
#include <stdio.h>

int binarySearch(int);

int S[1000000], n;

int main()
{
  int q, T, C=0;
  int i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T);
    if( binarySearch(T) ) C++;
  }

  printf("%d\n",C);
  return 0;
}

int binarySearch(int T)
{
  int left=0, right=n, mid;

  while(left < right){
    mid = (left + right)/2;
    if(S[mid] == T) return 1;
    if(T>S[mid]) left = mid + 1;
    else if(T < S[mid]) right = mid;
  }
  return 0;
}

Measured memory_bytes: 988
#include <iostream>

using namespace std;

int main(){
    string s;

    cin >> s;

    if (s[5] == '0'){
        if (s[6] == '1' || s[6] == '2' || s[6] == '3' || s[6] == '4')
        {
            cout << "Heisei";
        }
        else
        {
            cout << "TBD";
        }
    }
    else
    {
        cout << "TBD";
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    for (int i = 0;i < n;i++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    ll ans = INF;
    for (int i = 0;i < n-k+1;i++){
        ans = min(ans,abs(h[i+k-1] - h[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)

int main(){
  int n;
  cin>>n;
  vector<int> a(n);

  int maxi=0;
  map<int, int> b;

  r(i,n){
    cin>>a.at(i);
    b[a.at(i)]+=1;
    //maxi=max(maxi,a.at(i));
  }
  int sum=0;
  r(i,n){
    if(b[a.at(i)]<a.at(i)){
      sum+=b[a.at(i)];
      b[a.at(i)]=0;
    }else{
      sum+=b[a.at(i)]-a.at(i);
      b[a.at(i)]=0;
    }
  }
  cout<<sum<<endl;

return 0;}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl
template <typename T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
    for(int i = 0; i < vec.size(); i++) {
        os << vec.at(i) << (i + 1 == vec.size() ? "" : " ");
    }
    return os;
}

bool is_prime(int x) {
    for(int i = 2; i * i <= x; i++) {
        if(x % i == 0) return false;
    }
    return true;
}

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

    while(true) {
        if(is_prime(X)) {
            break;
        }
        X++;
    }

    cout << X << endl;
}

Measured memory_bytes: 256