akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
class Test
{

    public static void Main()
    {
        var ii1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int n = ii1[0];
        int t = ii1[1];

        var inp = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        long start = inp[0];
        long end = inp[0] + t;
        long time = 0;
        for (int i = 1; i < inp.Length; i++)
        {
            if(inp[i]>start&&inp[i]<end)
            {
                end = inp[i] + t;
            }
            else
            {
                time = time+(end-start);
                start = inp[i];
                end = inp[i] + t;
            }
        }

        time = time + (end - start);

        Console.Write(time);

    }


}




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

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

    if (d == 22)
    cout << "Christmas Eve Eve Eve" << endl;
    else if (d == 23)
    cout << "Christmas Eve Eve" << endl;
    else if (d == 24)
    cout << "Christmas Eve"  << endl;
    else if (d == 25)
    cout << "Christmas" << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools
n = int(input())
li = []
for _ in range(n):
    lee = int(input())
    tmp = []
    for i in range(lee):
        tmp.append(list(map(int,input().split())))
    li.append(tmp)
#li
# [[[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]
kumi = list(itertools.product(range(2), repeat=n))
#print(kumi)
# [(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0),
#  (1, 0, 1), (1, 1, 0), (1, 1, 1)]
ans_li = []
for kk in kumi:
    flag = True
    for i,k in enumerate(kk):
        if k == 1:
            target = li[i]
            for t in target:
                #print(t,'tuple')
                if kk[t[0]-1]!=t[1]:
                    flag = False
    if flag:
        ans_li.append(sum(kk))
if len(ans_li)==0:
    print(0)
else:
    print(max(ans_li))

Measured memory_bytes: 9076
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n,m,a,b;

    while(cin>>n>>m){
        int v[55] = {0};
        for(int i=0;i<m;i++){
            cin>>a>>b;
            v[a]++;
            v[b]++;
        }

        for(int i=1;i<=n;i++)
            cout<<v[i]<<endl;
        // cout<<endl;
    }

    return 0;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	string s;
	cin >> s;
	for (int i = 0 ; i < s.length(); i++) {
		cout << "x";
	}
	cout << endl;
}


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

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int D = A.at(N-1)-A.at(0);
  int E = K;
  for (int i = 1; i < N; i++) {
    if(E>A.at(i-1)+K-A.at(i))
       E = A.at(i-1)+K-A.at(i);
  }
  if(D <= E) {
      cout << D << endl;
  }
  else
      cout << E << endl;
  
}


Measured memory_bytes: 1024
using System;
using System.Linq;

namespace AOJ.Codes
{
    //問題の名称... ALDS1_11_C : BreadthFirstSearch.cs
    //問題文のURL... http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_C&lang=jp
    //所要時間... AAA
    //学んだこと... AAA
    //教室内の大まかな着席位置... 中央 x 奥

    class BreadthFirstSearch
    {
        static void Main(string[] args)
        {

            //読み込み
            var n = int.Parse(Console.ReadLine());
            var M = new int[n, n];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    M[i, j] = int.MaxValue;

            //読み込み＆マッピング
            //端が（１，１）なのに注意
            for (int i = 0; i < n; i++)
            {
                var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 2; j < line[1] + 2; j++)
                {
                    var num = line[j];
                    M[i, num - 1] = 1;
                }
            }

            //計算

            for (int k = 0; k < n; k++)
            {
                var newM = (int[,])M.Clone();
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        if (M[i, k] == int.MaxValue || M[k, j] == int.MaxValue)
                        { }
                        else if (M[i, j] > M[i, k] + M[k, j])
                            newM[i, j] = M[i, k] + M[k, j];
                    }


                }
                M = newM;

            }

            //出力
            Console.WriteLine("1 0");
            for (int i = 1; i < n; i++)
            {
                Console.Write(i + 1);
                Console.Write(" ");
                Console.Write(M[0, i] == int.MaxValue ? -1 : M[0, i]);
                Console.WriteLine();
            }

            Console.ReadLine();
        }
    }
}



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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//実行部
void Main()
{
  vll a(3); rep(i, 3) cin >> a[i];
  sort(all(a));
  ll ans = a[2] - a[1] + a[1] - a[0];
  fin(ans)
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
import itertools
R = []
for i in range(1,N+1):
    R.append(i)
H = list(itertools.permutations(R))
a = 0
b = 0
for i in range(len(H)):
    h = H[i]
    r = []
    for j in range(N):
        r.append(h[j])
    if r == P:
        a = i
    if r == Q:
        b = i
ans = max(a-b,b-a)
print(ans)

Measured memory_bytes: 8052
#include <iostream>
#include <stdlib.h>

using namespace std;

class Card
{
public:
    char suit;
    int value;

    Card() {}
    Card(char s, int v);
    void getCard();
};

Card::Card(char s, int v)
{
    suit = s;
    value = v;
}

void Card::getCard()
{
    cout << this->suit << this->value;
}

void printCards(Card cards[], int N)
{
    for (int i = 0; i < N; ++i)
    {
        if (i > 0) cout << " ";
        cards[i].getCard();
    }
    cout << endl;
}

void swap(Card & c1, Card & c2)
{
    char s = c1.suit;
    int v = c1.value;
    c1.suit = c2.suit;
    c1.value = c2.value;
    c2.suit = s;
    c2.value = v;
}

void bubbleSort(Card cards[], int N)
{
    for (int i = 0; i < N - 1; ++i)
    {
        for (int j = N - 1; j > i; j--)
        {
            if (cards[j].value < cards[j-1].value) swap(cards[j], cards[j-1]);
        }
    }
    printCards(cards, N);
}

void selectionSort(Card cards[], int N)
{
    for (int i = 0; i < N; ++i)
    {
        int min_index = i;
        for (int j = i; j < N; ++j)
        {
            if (cards[j].value < cards[min_index].value)
            {
                min_index = j;
            }
        }
        swap(cards[i], cards[min_index]);
    }
    printCards(cards, N);
}

bool isStable(Card bcards[], Card scards[], int N)
{
    bool flag = true;
    for (int i = 0; i < N; i++)
    {
        if (bcards[i].value == scards[i].value)
        {
            if (bcards[i].suit != scards[i].suit)
            {
                flag = false;
                return flag;
            } 
        }
    }

    return flag;
}

int main()
{
    int N;
    cin >> N;
    Card cards[N], b_cards[N], s_cards[N];
    for (int i = 0; i < N; ++i)
    {
        char suit;
        int value;
        string s;
        cin >> s;

        suit = char(s[0]);
        value = atoi(&s[1]);
        // Original array
        cards[i].suit = suit;
        cards[i].value = value;
        // Array will be applied BubbleSort
        b_cards[i].suit = suit;
        b_cards[i].value = value;
        // Array will be applied SelectionSort
        s_cards[i].suit = suit;
        s_cards[i].value = value;
    }

    bubbleSort(b_cards, N);
    cout << "Stable\n";

    selectionSort(s_cards, N);
    if (isStable(b_cards, s_cards, N))
    {
        cout << "Stable\n";
    } else {
        cout << "Not stable\n";
    }

    return 0;
}



Measured memory_bytes: 3176
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	int ret;
	ret = (b == 0) ? a : gcd(b, a % b);
	return ret;
}

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	char str[57];
	scanf("%s",str);
	for(int i = 0; i < strlen(str) - 8; ++i)	printf("%c",str[i]);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

#define sz 100009

char s[sz + 3];

int main(){

    int i, j, k;
    int ln;

    scanf("%s", s);
    ln = strlen(s) - 2;

    if(ln == 0){

        puts(s[0] == s[1] ? "1 2":"-1 -1");
        return 0;

    }

    for(i = 0; i < ln; i++){
        if(s[i] == s[i + 1] || s[i + 1] == s[i + 2] || s[i + 2] == s[i]){

            printf("%d %d\n", i + 1, i + 3);
            return 0;


        }
    }

    printf("-1 -1\n");

    return 0;

}



Measured memory_bytes: 384
A, B, C, X, Y = map(int, input().split())
cost = [(A * X + B * Y), (C * 2 * max(X, Y))]
if X >= Y:
    cost.append(C * (2 * Y) + A * (X - Y))
if X <= Y:
    cost.append(C * (2 * X) + B * (Y - X))
print(min(cost))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


int main() {
    long long N, K;
    vector<long long> H;
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        long long tmp;
        cin >> tmp;
        H.push_back(tmp);
    }
    if (K >= N) {
        cout << 0 << endl;
        return 0;
    }

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

    for (int i = 0; i < K; ++i) {
        H.pop_back();
    }

    long long ans = 0;
    for (int i : H) {
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
N, X, Y = map(int, input().split())
ans =[0]*(N-1)
for i in range(1, N):
    for j in range(i+1, N+1):
        ans[min((j - i), abs(X - i) + abs(Y - j) + 1) - 1] += 1
for i in range(N-1):
    print(ans[i])

Measured memory_bytes: 3444
#include <iostream>
#include <set>
#include <map>
using namespace std;

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

    typedef set<int> Suit;
    typedef map<char,Suit> Deck;

    Deck d;

    char s;
    int card;
    while(n-- && cin >> s >> card)
        d[s].insert(card);

    const char suit_order[] = "SHCD";
    for(int so=0; so<4; ++so) {
        s = suit_order[so];
        Suit &suit = d[s]; // it is ok to create an empty set here
        for(int i=1; i<14; ++i)
            if(suit.find(i) == suit.end())
                cout << s << ' ' << i << '\n';
    }

    return 0;
}



Measured memory_bytes: 3104
#include <cmath>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;


int main() {
	int n, m;
	cin >> n >> m;
	ll ans = (1900 * m + 100 * (n - m)) * pow(2, m);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
h,w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
res = []
for i in range(len(a)):
    res += [i+1]*a[i]

ans = [[0]*w for k in range(h)]
for i in range(h):
    for j in range(w):
        l = res.pop()
        ans[i][j] = l

for i in range(h):
    if(i%2==1):
        ans[i].reverse()
for i in range(h):
    print(*ans[i])

Measured memory_bytes: 3956
#include<stdio.h>
int main()
{
  int N, X, L, i, d=0, c1=1;
  scanf("%d%d",&N,&X);
  for(i=1; i<=N; i++)
  {
    scanf("%d",&L);
    d = d + L;
    if(d<=X)
    {
      c1= c1 + 1;
    }
  }
  printf("%d\n",c1);
  
  return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

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

    vector<bool> dp1(n);
    dp1[a] = true;
    FOR(i, a, n) {
        if(dp1[i]) {
            if(i+1<c+1 && s[i+1] == '.') dp1[i+1] = true;
            if(i+1<c+1 && s[i+2] == '.') dp1[i+2] = true;
        }
    }
    vector<bool> dp2(n);
    dp2[b] = true;
    FOR(i, b, n) {
        if(dp2[i]) {
            if(i+1<d+1 && s[i+1] == '.') dp2[i+1] = true;
            if(i+1<d+1 && s[i+2] == '.') dp2[i+2] = true;
        }
    }

    bool flag = false;
    FOR(i, 1, n-1) {
        if(dp2[i]) {
            if(s[i+1]=='.' && s[i-1]=='.') flag = true;
        }
    }

    if(c < d) {
        if(dp1[c] && dp2[d]) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if(dp2[d] && dp1[c] && flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string s;
    cin >> s;
    if(s.size() == 3) reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3584
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var AB = Sarray();
            var A = AB[0];
            var B = AB[1];
            // A-BのXorは0～Bのxorと0～A-1のXor
            var ans = SeqXor(B) ^ SeqXor(A - 1);
            WriteLine(ans);
            //Out.Flush();
        }
        // 1~Nのxorを返す
        static long SeqXor(long N)
        {
            var res = 0;
            //0,1,2の場合計算して返す
            if (N <= 2)
            {
                for (var i = 1; i <= N; ++i)
                    res ^= i;
                return res;
            }

            // 最上位桁を作る
            var t = N;
            var mask = 1L;
            while (1 < t)
            {
                t >>= 1;
                mask <<= 1;
            }
            // 0～2^n-1のxorは0(2<=n)
            if (N == (mask << 1) - 1)
                return 0;
            // 最上位bitとその他に分割する
            var tn = 0L;
            if ((N - (mask - 1)) % 2 == 1)
                tn = mask;
            return tn + SeqXor(N - mask);
        }
    }
}

Measured memory_bytes: 13396
import time
startTimeProblem=time.time()

import fileinput, sys, itertools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N, M = In.ints()
A = In.ints()

res = max(-1, N-sum(A))

Out.int(res)


######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 68096
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){c=Getchar();rev|=c=='-';if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
template<class T1,class T2> inline bool read(T1 &x,T2 &y){return read(x)&read(y);}
template<class T1,class T2,class T3> inline bool read(T1 &x,T2 &y,T3 &z){return read(x)&read(y)&read(z);}
template<class T1,class T2,class T3,class T4> inline bool read(T1 &x,T2 &y,T3 &z,T4 &w){return read(x)&read(y)&read(z)&read(w);}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------head---------------------------------------------

const int inf=0x3f3f3f3f;
const int N=505,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,x[N],a[N*N];
pii p[N];

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	read(n);
	for(int i=1;i<=n;i++)
		read(x[i]),p[i]=mp(x[i],i),a[x[i]]=i;
	sort(p+1,p+n+1);
	for(int i=1,l=0;i<=n;i++)
		for(int j=1;j<p[i].SS;j++){
			l++;
			while(l<p[i].FF&&a[l])l++;
			if(l>=p[i].FF){puts("No");return 0;}
			a[l]=p[i].SS;
		}
	for(int i=n,r=n*n+1;i;i--)
		for(int j=p[i].SS+1;j<=n;j++){
			r--;
			while(r>p[i].FF&&a[r])r--;
			if(r<=p[i].FF){puts("No");return 0;}
			a[r]=p[i].SS;
		}
	puts("Yes");
	for(int i=1;i<=n*n;i++)
		printf("%d%c",a[i],i<n*n?' ':'\n');
	return 0;
}

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

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	bool tak = 1;
	while (a > 0 && c > 0) {
		if (tak) c -= b;
		else a -= d;
		tak = !tak;
	}

	if (a <= 0) cout << "No";
	else cout << "Yes";
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define ff first
#define ss second
typedef pair<int,int> pii;

int32_t main()
{
 int k , n ; 
 cin >> n >> k;
 int p[n + 1] ;
 for(int i = 1 ; i <= n ; i++)
  cin >> p[i] ;

 int cm[n + 1] ;
 for(int  i = 1; i <= n ; i++)
  cm[i] = cm[i-1] + p[i] ;

 // double ans = 0.0;
 int ans = 0 ;
 for(int i = 0 ; i + k <= n  ; i++){
  int st = i , en = i + k  ;
  int val = cm[en] - cm[st] ;
  ans = max(ans , val ) ;
  // cout << st <<" "<<en <<" ";
  // cout << val <<"\n" ;
 }

 double a = (double)(k / 2.0) + (double) (ans / 2.0) ;

 printf("%.14f\n", a );
 return 0;
}        

Measured memory_bytes: 6880
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <complex>
#include <cstring>
#include <cassert>
#include <bitset>

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define bitcount(n) __builtin_popcountll(n)


typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int N = 1000000 + 7;
const int M = 1007;
const int inf = 1e9 + 7;
const long long linf = 1e18 + 7;
const double pi = acos(-1);
const double eps = 1e-7;
const bool multipleTest = 0;


int n;
vi adj[N];

int depth[N];

void dfs(int u) {
    if (adj[u].empty()) return;
    
    for(int j = 0; j < adj[u].size(); ++j) {
        int v = adj[u][j];
        dfs(v);
    }
    
    vi list;
    
    for(int j = 0; j < adj[u].size(); ++j) {
        int v = adj[u][j];
        list.push_back(depth[v]);
    }
    
    sort(list.begin(), list.end());
    
    int cur = 0;
    for(int j = 0; j < list.size(); ++j) {
        cur = max(cur, list[j]) + 1;
    }
    
    depth[u] = cur;
    
}

void solve() {

    cin >> n;
    for(int i = 2; i <= n; ++i) {
        int u; scanf("%d", &u);
        adj[u].push_back(i);
    }
    
    dfs(1);
    
    cout << depth[1] << '\n';
    
    
}




int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
#endif
    
//    freopen("out.txt", "w", stdout);
    
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
//        printf("Case #%d: ", i + 1);
        
        solve();
    }
    
#ifdef _LOCAL_
    //    cout<<"\n" << 1.0 * clock() / CLOCKS_PER_SEC<<endl;
#endif
}


Measured memory_bytes: 36608
#include<stdio.h>
int main(){
	int h,m,s,t;
	scanf("%d",&t);
	h=t/3600;
	m=(t-h*3600)/60;
	s=t-h*3600-m*60;
	printf("%d:%d:%d\n",h ,m ,s);
	return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std; 
#define LIM 1003

#define M 1000000007
#define inf 99999999999999999LL	//long long inf
typedef long long ll;

#define sc(x) scanf("%d",&x);
#define sc2(x,y) scanf("%d%d",&x,&y);
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define scl(x) scanf("%lld",&x);
#define scl2(x,y) scanf("%lld%lld",&x,&y);
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);

#define pb push_back
#define mp make_pair
#define fi first
#define se second 
ll power(ll x,ll y,ll z) {	ll ret = 1;	while(y > 0) {	if(y & 1) ret = (ret*x)%z;x = (x*x)%z;y >>= 1;}return ret;}


#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";




int n, m, dp[LIM][LIM];
char mat[LIM][LIM];
int main() {
	int i, j, t;
	sc2(n, m) ;
	for(i=1; i<=n; i++)	scanf("%s", 1+mat[i]) ;
	i=1;	while( i <= m && mat[1][i] == '.')	dp[1][i++] = 1 ;
	i=1;	while( i <= n && mat[i][1] == '.')	dp[i++][1] = 1 ;
	for(i=2; i<=n; i++)	for(j=2; j<=m; j++)	
		if(mat[i][j] == '#')	continue ;
		else	dp[i][j] = (dp[i-1][j] + dp[i][j-1])%M ;
	cout << dp[n][m] << endl ;
	return 0;
}




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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

template<typename T> bool chmin(T &a,const T b){if(a>b){a=b; return true;}return false;}
template<typename T> bool chmax(T &a,const T b){if(a<b){a=b; return true;}return false;}


int main(){
    int N, K; cin >> N >> K;
    string S; cin >> S;

    vector<pii> re;
    int cnt=0;
    for(int i=0; i<N+1; i++){
        if(S[i] == '1') cnt++;
        else{
            int pos=i;
            while(pos < N+1 && S[pos] != '1') pos++;
            if(pos == N+1) re.push_back({cnt, pos-i-1});
            else re.push_back({cnt, pos-i});
            cnt=0;
            i=pos-1;
        }
    }
    if((int)re.size() <= K){
        cout << S.size() << endl;
        return 0;
    }

    if(cnt >= 0) re.push_back({cnt, 0});
    
    int sum=0;
    for(int i=0; i<K; i++){
        sum+=re[i].first+re[i].second;
    }
    sum+=re[K].first;
    int ans=sum;
    for(int i=K; i<(int)re.size(); i++){
        sum+=re[i].second-re[i-K].first-re[i-K].second;
        if(i != (int)re.size()-1) sum+=re[i+1].first;
        chmax(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3992
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors


N = int(input())
ans = 0
for i in range(1, N + 1, 2):
    divisors = make_divisors(i)
    if len(divisors) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	ll sum = 0;
	for(int i = 0; i < (int)s.length();++i){
		sum += s[i] - '0';
	}
	if(sum % 9 == 0)
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
int main()
{
      int k;
      cin>>k;
      if(k%5==0||k%2==0)
      {
        cout<<-1;
        return 0;
      }
      int rem=7;
      int c=1;
      while(rem%k!=0)
      {
        	rem=(rem*10+7)%k;
        	c++;
      }
      cout<<c<<endl;
}


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

using namespace std;

char s[1001];

int main() {
    int w, n, i;
    
    scanf("%s", s);
    scanf("%d", &w);
    
    n = strlen(s);
    
    for (i = 0; i < n; i += w) putchar(s[i]);
    puts("");
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define overload4(_1, _2, _3, _4, name, ...) name
#define overload3(_1, _2, _3, name, ...) name
#define rep1(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
template <class T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef pair<int, int> P;

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {  // TODO
  string S, T;
  cin >> S;
  cin >> T;

  ll ans = INF;
  for (int i = 0; i <= S.length() - T.length(); i++) {
    ll tmp = 0;
    for (int j = 0; j < T.length(); j++) {
      if (S[i + j] == T[j]) continue;
      tmp += 1;
    }
    ans = min(tmp, ans);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
  double x;
  while (scanf("%lf ", &x) == 1) {
    if (x <= 48) {
      printf("light fly\n");
    } else if (48 < x && x <= 51) {
      printf("fly\n");
    } else if (51 < x && x <= 54) {
      printf("bantam\n");
    } else if (54 < x && x <= 57) {
      printf("feather\n");
    } else if (57 < x && x <= 60) {
      printf("light\n");
    } else if (60 < x && x <= 64) {
      printf("light welter\n");
    } else if (64 < x && x <= 69) {
      printf("welter\n");
    } else if (69 < x && x <= 75) {
      printf("light middle\n");
    } else if (75 < x && x <= 81) {
      printf("middle\n");
    } else if (81 < x && x <= 91) {
      printf("light heavy\n");
    } else if (91 < x) {
      printf("heavy\n");
    }
  }
  return 0;
}

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

namespace ABC088_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[3];
            int[] b = new int[3];
            int[][] c = new int[3][];
            bool p = true;
            bool ans = false;
            for (int i = 0; i < 3; i++)
            {
                c[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            }
            for (int i = 0; i <= 100; i++)
            {
                a[0] = i;
                for (int j = 0; j <= 100; j++)
                {
                    a[1] = j;
                    for (int k = 0; k <= 100; k++)
                    {
                        a[2] = k;
                        b = new int[3] { c[0][0] - a[0], c[0][1] - a[0], c[0][2] - a[0] };
                        p = true;
                        for (int l = 0; l < 3; l++)
                        {
                            
                            for (int m = 0; m < 3; m++)
                            {

                                if (c[l][m] != a[l] + b[m]) { p = false; }
                            }
                        }
                        ans |= p;
                    }
                }
            }
            Console.WriteLine(ans ? "Yes" : "No");
        }
    }
}


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

int main()
{
    int M, D;
    scanf("%d%d", &M, &D);
    int ans = 0;
    for (int d1 = 2; d1 <= 9; ++ d1)
        for (int d2 = 2; d2 <= 9; ++ d2)
    {
        if (d1 * d2 <= M && (d1 * 10 + d2 <= D))
            ++ ans;
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;
typedef complex<double> P;
struct C{
    P p;
    double r;
};
bool operator < (const C& c, const C& d) {
    return c.p.real() < d.p.real();
}

int main(){
    int n;
    while(cin >> n && n > 0) {
        vector<C> cs(n);
        double max_r = 0;
        double th = M_PI / 6;
        REP(i, n) {
            double r, x, y;
            cin >> r >> x >> y;

            P p(x, y);
            p *= polar(1.0, th);

            cs[i] = {p, r};

            max_r = max(max_r, r);
        }

        sort(cs.begin(), cs.end());
        double ans = 1e63;

        REP(i, n) {
            for(int j = i + 1; j < n; j++) {
                if(ans < cs[j].p.real() - cs[i].p.real() - cs[i].r - max_r) {
                    break;
                }
                ans = min(ans, abs(cs[i].p - cs[j].p) - cs[i].r - cs[j].r);
            }
        }
        printf("%.12f\n", ans);
    }
    return 0;
}

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

int main() {
  vector<int> v;
  int n;
  REP(i, 4) {
    cin >> n;
    v.push_back(n);
  }

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

  if (v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

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

using ll = long long;

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

  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += i * ((N/i)*((N/i)+1) / 2);
  }
  cout << ans << endl;    
}

Measured memory_bytes: 3556
#include<iostream>
using namespace std;
int main(){
    long long h, w;
    cin >> h >> w;
    if (h == 1 || w == 1){
        cout << 1; return 0;
    }
    cout << (((h*w) % 2 == 0) ? h*w/2 : (h*w/2)+1);
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 400020
using namespace std;
int read(){
	int nm=0,fh=1; int cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
struct num{
	int pos,id;num(){pos=0,id=0;}
	num(int _pos,int _id){pos=_pos,id=_id;}
}p[M],S[M];
int vis[M],H,W,n,top;
bool on(int x,int y){return x==0||y==0||x==H||y==W;}
int bas(int x,int y){
	if(!x) return y; if(y==W) return W+x;
	if(x==H) return W+H+W-y; return W+H+W+H-x;
}
bool cmp(num x,num y){return x.pos<y.pos;}
int main(){
	H=read(),W=read(),n=read();
	for(int i=1;i<=n;i++){
		int x=read(),y=read(),xx=read(),yy=read();
		if(!on(x,y)||!on(xx,yy)){i--,n--;continue;}
		int L=bas(x,y),R=bas(xx,yy); if(L>R) swap(L,R);
		p[(i<<1)-1]=num(L,i),p[i<<1]=num(R,i);
	} n<<=1,sort(p+1,p+n+1,cmp);
	for(int i=1;i<=n;i++){if(S[top].id!=p[i].id||!top) top++,S[top]=p[i];else top--;}
	puts(top?"NO":"YES"); return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = max(a, c);
  int r = min(b, d);
  if(l > r)cout << 0 << endl;
  else cout << r - l << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

  int n;
  while(cin>>n&&n){
    int a1,a2,b1,b2,c1,c2,d1,d2;
    for(int i=0;i<n;i++){
      cin>>a1>>b1>>c1>>d1;
      cin>>a2>>b2>>c2>>d2;
      int as=a1*a2-b1*b2-c1*c2-d1*d2;
      int bs=a1*b2+b1*a2+c1*d2-c2*d1;
      int cs=a1*c2-b1*d2+a2*c1+b2*d1;
      int ds=a1*d2+b1*c2-b2*c1+a2*d1;
      cout<<as<<" "<<bs<<" "<<cs<<" "<<ds<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a>=b){
    for(int i=0;i<a;i++){
      printf("%d",b);	
    }
  }else{
    for(int i=0;i<b;i++){
      printf("%d",a);
	}
  } 
}


Measured memory_bytes: 128
n,q = gets.chomp.split.map(&:to_i)
str = gets.chomp
map = [0]

cnt = 0
(n-1).times do |i|
  cnt += str[i] == 'A' && str[i+1] == 'C' && 1 || 0
  map.push(cnt)
end

q.times do
  f,t = gets.split.map(&:to_i)
  puts map[t-1] - map[f-1]
end


Measured memory_bytes: 3452
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using P = pair<ll, ll>;
const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  sort(ALL(a));
  vector<P> v;
  for(ll i = 0; i < n; ){
    ll j = i;
    while(j < n && a[j] == a[i]){
      j++;
    }
    v.emplace_back(a[i], j-i);
    i = j;
  }

  ll ans = 0;
  vector<ll> s(1000001, 0);
  ll m = v.size();
  if(v[0].first == 1){
    if(v[0].second == 1){
      cout << 1 << endl;
      return 0;
    }else{
      cout << 0 << endl;
      return 0;
    }
  }
  REP(i, m){
    P p = v[i];
    if(s[p.first] == 0 && p.second == 1) ans++;
    for(ll j = 2; p.first*j <= 1000000; j++){
      s[p.first*j] = p.first;
    }
  }
  cout << ans << endl;
  return 0;
}

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

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            int[] s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = s[0];
            int M = s[1];
            int C = s[2];
            int ans = 0;
            List<int> Bs = new List<int>();
            Bs.AddRange(Console.ReadLine().Split(' ').Select(int.Parse).ToArray());
            for (int i = 0; i < N; i++)
            {
                List<int> As = new List<int>();
                As.AddRange(Console.ReadLine().Split(' ').Select(int.Parse).ToArray());
                int obj = 0;
                for (int j = 0; j < M; j++)
                {
                    obj += As[j] * Bs[j];
                }
                if (obj+C>0)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }

    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll x;

int main() {
	cin >> x;
	for (ll i = -200; i <= 200; i++) {
		for (ll j = -200; j <= 200; j++) {
			if (i * i * i * i * i - j * j * j * j * j == x) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3564
# import itertools
# import math
import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, K = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

A.insert(0, 0)
cnt = [0] * (N + 1)

j = 1
times_s = 0
times_e = 0
cycle = 0
for i in range(N + 1):
    if i == K:
        print(j)
        sys.exit()
    cnt[j] += 1
    if cnt[j] == 2:
        times_e = i
        cycle = j
        break
    j = A[j]

j = 1
for i in range(N + 1):
    if j == cycle:
        times_s = i
        break
    j = A[j]

#print(A, cnt)

#print(times_s, times_e, cycle)

K_eff = (K - times_s) % (times_e - times_s)

for i in range(N + 1):
    if i == K_eff:
        print(j)
        sys.exit()
    j = A[j]

Measured memory_bytes: 32360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
int main() {
	ll n, m;
	cin >> n >> m;
	ll x[n + 1], y[m + 1];
	ll sum_x = 0, sum_y = 0;
	for (ll i = 0; i < n; i++) {
		cin >> x[i];
		sum_x += x[i] * (2 * i - n + 1);
	}
	for (ll i = 0; i < m; i++) {
		cin >> y[i];
		sum_y += y[i] * (2 * i - m + 1);
	}
	cout << ((sum_x%MOD)*(sum_y%MOD)) % MOD << endl;
}


Measured memory_bytes: 1792
using System;
using System.Linq;

class E
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var c = new int[n].Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
		Console.WriteLine(c.All(x => x[0] == x[1]) ? 0 : c.Sum(x => x[0]) - c.Where(x => x[0] > x[1]).Min(x => x[1]));
	}
}


Measured memory_bytes: 35484
import sys
import os
import math

def file_input():
    f = open('input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()

    j = int(input())
    N = [0]*j
    A = list(map(int, input().split()))

    for i in A:
        N[i-1]+=1

    for i in N:
        print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 35180
import sys
win = ''
def main():
  global win  
  a,b,c,d = list(map(int,(input().split())))
  while a > 0 and b > 0:
    c -=b
    if c <=0:
      win = 'Yes'
      break
    a -=d
    if a <=0:
      win = 'No'
      break
  print(win)    
  

if __name__ == '__main__':
  main()





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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int q; cin >> q;
    map<string, int> M;
    rep(i,q){
        int query; cin >> query;
        if(query == 0){
            string key; int x;
            cin >> key >> x;
            M[key] = x;
        }else if(query == 1){
            string key; cin >> key;
            cout << M[key] << endl;
        }else if(query == 2){
            string key; cin >> key;
            M.erase(key);
        }
    }
}


Measured memory_bytes: 27824
(n, m) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]

t = sum(a)

a = sorted(a)

chosen = a[-m:]

r = 1 / (4 * m) * t

ans = 'Yes'

for a in chosen:
    if a < r:
        ans = 'No'

print(ans)




Measured memory_bytes: 3188