akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;

int iro[8];
int main(){
    int n;
    cin>>n;
    int a[111];
    int sum=0;
    rep(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    bool can=false;
    if(sum%10!=0)can=true;
    else rep(i,0,n){
        if(a[i]%10!=0){
            sum-=a[i];
            can=true;
            break;
        }
    }
    if(can)cout<<sum<<endl;
    else cout<<'0'<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int x,y;
  while(1)
  {
    cin>>x>>y;
    if((x==0)&&(y==0))
      break;
    else if (x>y)
      cout<<y<<" "<<x<<endl;
    else
      cout<<x<<" "<<y<<endl;
  }
  return 0;
}

Measured memory_bytes: 3068
#include<stdio.h>
#define H 250

int main(){
  int num,i,node[H];

  scanf("%d",&num);

  for(i=1; i<=num; i++){
    scanf("%d",&node[i]);
  }

  for(i=1; i<=num; i++){
    printf("node %d: key = %d, ",i ,node[i]);
    if(i!=1) printf("parent key = %d, ",node[i/2]);
    if(i*2<=num) printf("left key = %d, ",node[2*i]);
    if(i*2+1<=num)printf("right key = %d, ",node[2*i+1]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	switch {
	case a%3 == 0:
		fmt.Println("Possible")
	case b%3 == 0:
		fmt.Println("Possible")
	case (a+b)%3 == 0:
		fmt.Println("Possible")
	default:
		fmt.Println("Impossible")
	}
}


Measured memory_bytes: 512
n, k = gets.split.map(&:to_i)
s = gets.chomp.split("").map(&:to_i)
ary = [];
f = nil
s.each_with_index do |i, idx|
  ary << [i.odd?, idx] if ary.empty? || i.odd? != ary.last[0]
end
ary << [nil, n]
 
c = [ary.size-k*2-1, 0].max
res = (0..c).map do |i|
  len = k * 2
  len += 1 if ary[i][0]
  len = ary.size - i - 1 if i + len > ary.size - 1
  ary[i+len][1] - ary[i][1]
end.max
 
puts res

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

typedef long long ll;

ll N, M;
vector<vector<ll>> Out, In;

vector<bool> Seen;
vector<ll> T;

vector<bool> RSeen;
set<ll> SCC;

list<ll> Loop;
set<ll> Set;

void dfs(ll v) {
  if (Seen[v]) return;
  Seen[v] = true;
  for (ll w : Out[v]) {
    dfs(w);
  }
  T.push_back(v);
}
void rdfs(ll v) {
  if (RSeen[v]) return;
  RSeen[v] = true;
  SCC.insert(v);
  for (ll w : In[v]) {
    rdfs(w);
  }
}

void find_loop() {
  vector<bool> lseen;
  deque<ll> loop;
  lseen.resize(N);
  ll v = *SCC.begin();
  while (!lseen[v]) {
    loop.push_back(v);
    lseen[v] = true;
    for (ll w : Out[v]) {
      if (SCC.count(w)) {
        v = w;
        break;
      }
    }
  }
  while (loop.front() != v) {
    loop.pop_front();
  }
  for (ll v : loop) {
    Loop.push_back(v);
  }
}
void find() {
  find_loop();
  for (ll v : Loop) {
    Set.insert(v);
  }
  for (auto it = Loop.begin(); it != Loop.end(); ++it) {
    ll v = *it;
    for (ll w : Out[v]) {
      if (Set.count(w)) {
        for (auto it2 = next(it); true;) {
          if (it2 == Loop.end()) {
            for (auto it3 = Loop.begin(); *it3 != w;) {
              Set.erase(*it3);
              it3 = Loop.erase(it3);
            }
            break;
          }
          if (*it2 == w) break;
          Set.erase(*it2);
          it2 = Loop.erase(it2);
        }
      }
    }
  }
}

void solve() {
  Seen.resize(N);
  for (ll v = 0; v < N; ++v) {
    dfs(v);
  }
  reverse(T.begin(), T.end());

  RSeen.resize(N);
  for (ll v : T) {
    SCC.clear();
    rdfs(v);
    if (SCC.size() > 1) {
      find();
      cout << Loop.size() << endl;
      for (ll v : Loop) {
        cout << v + 1 << endl;
      }
      return;
    }
  }
  cout << -1 << endl;
}

int main() {
  cin >> N >> M;
  Out.resize(N);
  In.resize(N);
  for (ll i = 0; i < M; ++i) {
    ll a, b;
    cin >> a >> b;
    --a;
    --b;
    Out[a].push_back(b);
    In[b].push_back(a);
  }
  solve();
  return 0;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n, m;
	cin >> n >> m;

	cout << (n * (n - 1) / 2 + m * (m - 1) / 2) << endl;



	return 0;
}

Measured memory_bytes: 256
A,B,C,D = map(int, input().split())
cnt_t = 0
cnt_a = 0

while A>0:
	A = A-D
	cnt_t+=1
while C>0:
	C = C-B
	cnt_a+=1
if cnt_t>=cnt_a:
	print('Yes')
else:
	print('No')

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

const long long N=1000010;
long long v[10001];

int main(){
	
ios_base::sync_with_stdio(false);

long long i,ans=0;
string s;

cin>>s;

for(i=0;i<4;i++){
v[s[i]]=1;}

for(i=65;i<=90;i++)
if(v[i]==1)
ans++;

if(ans==2)
	cout<<"Yes\n";

else
	cout<<"No\n";

return 0;}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
}

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

vector<vector<int>> dp;
vector<int> costs = {0,2,5,5,4,5,6,3,7,6};

bool comp(vector<int> &a, vector<int> &b) {
	int alen=0, blen=0;
	for (int i : a) alen+=i;
	for (int i : b) blen+=i;
	
	if (alen > blen) return true;
	else if (alen==blen) {
		for (int i=9; i>0; i--) {
			if (a[i] > b[i]) return true;
			if (a[i] < b[i]) return false;
		}
	}
	return false;
}

int getLen(vector<int> &v) {
	int res=0;
	for (int i=1; i<=9; i++)
		res+=costs[i]*v[i];
	return res;
}

int main() {
	int n,m; cin>>n>>m;
	vector<int> a(m);
	dp.resize(n+1,vector<int>(10));
	for (int i=0; i<m; i++)
		cin>>a[i];
	
	//bot-up
	//O(pray to the algo gods that this is efficient enough)
	for (int i=0; i<=n; i++) {
		for (int x : a) {
			if (costs[x]<=i) {
				vector<int> temp(dp[i-costs[x]]);
				temp[x]+=1;
				if (getLen(temp)==i) {
					if (comp(temp,dp[i]))
						dp[i] = vector<int>(temp);
				if (comp(dp[i-costs[x]],temp))
					dp[i] = vector<int>(dp[i-costs[x]]);
				}
			}
		}
	}

	vector<int> ans = dp.back();
	for (int i=9; i>0; i--)
		for (int x=0; x<ans[i]; x++)
			cout << i;
	cout << endl;
	return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define sz(v) (int) v.size()
#define all(v) v.begin(), v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int MAX_K = 205;

int g[MAX_K][MAX_K];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int k;
	cin >> k;
	for (int a = 1; a <= k; ++a) {
		for (int b = 1; b <= k; ++b) {
			g[a][b] = __gcd(a, b);
		}
	}
	ll ans = 0;
	for (int a = 1; a <= k; ++a) {
		for (int b = 1; b <= k; ++b) {
			for (int c = 1; c <= k; ++c) {
				ans += g[a][g[b][c]];
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3776
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    
    let mut iter = buf.split_whitespace();
    
    let a: u32 = iter.next().unwrap().parse().unwrap();
    let b: u32 = iter.next().unwrap().parse().unwrap();
    let c: u32 = iter.next().unwrap().parse().unwrap();
    
    if a < c && b > c ||
       a > c && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		int uresisa = 0;

		uresisa += 1000 * (x/500);
		x = x - (500 * (x/500));
		uresisa += 5 * (x/5);

		System.out.println(uresisa);
	}
}

Measured memory_bytes: 22612
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int i,j,h,w;
    
    while(1) {
        
        scanf("%d %d",&h,&w);
        
        if (h == 0 && w == 0) {
            break;
        }
        
        for (i = 0; i < h; i++) {
            for (j = 0; j < w; j++) {
                printf("#");
            }
            printf("\n");
        }
        
        printf("\n");
    }
    return 0;
}

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

int main()
{
  int n,m,k;
  cin >> n >> m;
  int cnt_of_foodliked[m+1];
  memset(cnt_of_foodliked,0,sizeof(cnt_of_foodliked));
  for(int i=0;i<n;i++)
  {
    cin >> k;
    for(int j=0;j<k;j++)
    {
      int food_liked;
      cin >> food_liked;
      cnt_of_foodliked[food_liked]++;
    }
  }
  int ans = 0;
  for(int food = 1; food <= m; food++){
    if(cnt_of_foodliked[food] == n)
      ans++;
  }
cout << ans << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;
vector<vector<pi > > G;
vector<bool > seen;

ll MOD = 1000000007;
ll INF = 11451419194545;
ll ans = 0;
ll N, M;

//階乗
vector<ll>fact;
//逆元
vector<ll>inv;
//逆元階乗
vector<ll>finv;

pii extgcd(ll a, ll b){
    //前提：aとbが互いに素であること．
    pii x(make_pair(1,0), a);
    pii y(make_pair(0,1), b);

    ll div = 0;

    //終了条件:(GCD(a,b), 0)または(0,GCD(a,b))
    while(true){
        if(y.second == 0) return x;
        
        div = x.second / y.second;
        x.second = x.second  - div * y.second;
        x.first.first = x.first.first - div * y.first.first;
        x.first.second = x.first.second - div * y.first.second;

        if(x.second == 0) return y;

        div = y.second / x.second;
        y.second = y.second - div * x.second;
        y.first.first = y.first.first - div * x.first.first;
        y.first.second = y.first.second - div * x.first.second;
    }
}

ll modinv(ll a, ll m = MOD){
    //前提：aとmが互いに素であること．
    pii ans;
    ans = extgcd(a, m);

    ll invNum = 0;
    invNum = ans.first.first;
    invNum %= m;
    //C++特有の剰余がマイナスになってしまう対策
    if(invNum < 0) invNum += m;

    return invNum;
}

ll warizan_mod(ll warareru, ll waru, ll m = MOD){
    //割られる数に逆元をかけるだけ
    warareru %= m;
    return warareru * modinv(waru, m) % m;
}

//階乗と逆元を列挙
void combination(ll num, ll m = MOD){
    fact.assign(num + 1919, 0);
    finv.assign(num + 1919, 0);
    inv.assign(num  + 1919, 0);

    //初期化
    fact[0] = 1; inv[0] = 1;
    //テーブルに列挙
    for(ll i = 1; i < fact.size(); i++){
        fact[i] = fact[i - 1] * i % m;
        inv[i]  = modinv(fact[i]);
    }
}

//階乗 n!
ll factrial(ll n){
    return fact[n];
}

//順列 nPk n!/(n-k)!
ll nPk(ll n, ll k, ll m = MOD){
    if(n < 0 || k < 0 || n < k) return 0;
    return fact[n] * inv[n - k] % m;
}

//二項係数 nCk n!/(k!*(n-k)!)
ll nCk(ll n, ll k, ll m = MOD){
    if(n < 0 || k < 0 || n < k) return 0;
    return fact[n] * (inv[k] * inv[n - k] % m) % m;
}

//重複組み合わせ n+k-1Ck
ll nHk(ll n, ll k, ll m = MOD){
    return nCk(n+k-1, k);
}



void dfs(ll idx, ll depth = 0, ll from = -1){

    if(depth == 0){
        ans = M;
    }

    //子の個数をカウント
    ll cn = 0;

    seen[idx] = true;

    for(ll i = 0; i < G[idx].size(); i++){
        //次の行き先は？
        ll to = G[idx][i].first;
        //探査済み
        if(seen[to] == true){
            continue;
        }

        cn++;
        dfs(to ,depth + 1 ,idx);
    }
    
    if(cn > 0){
        if(depth == 0){
            ans *= nPk(M-1, cn);
        }else{
            ans *= nPk(M-2, cn);
        }
        ans %= MOD;
    }
}

int main(){
    
    cin >> N >> M;
    combination(M + 1919);

    //初期化
    G.assign(N, vector<pi >());
    seen.assign(N, false);

 
    //グラフ入力
    for(ll i = 0; i < N - 1; i++){
        ll u, v, w;
        w = 0;
        cin >> u >> v;
        u--;
        v--;
        //双方向に貼りましょうね
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }

    dfs(0);

    cout << ans << endl;

}

Measured memory_bytes: 12544
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, m; cin >> n >> m;
  vector<string> v(n);
  rep(i, n) cin >> v[i];
  rep(i, n){
    cout << v[i] << endl << v[i] << endl;
  }
  system("pause");
}

Measured memory_bytes: 504
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
	int N, X;
	cin >> N >> X;
	int m[105];
	rep(i,N)
		cin >> m[i];

	int sum = 0;
	int mm = m[0];
	rep(i,N){
	  sum += m[i];
	  mm = min(mm,m[i]);
	}
	cout << N + (X - sum) / mm << endl;
}

int main(){
	solve();
	return 0;
}

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 rrep(i,n) for(int i = 1; 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 rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin>>n;
  vl A(n);
  int num=0;
  rep(i,n){
    cin>>A[i];
    num+=(A[i]<0);
    A[i] = abs(A[i]);
  }
  ll sum = 0;
  rep(i,n)sum+=A[i];
  sort(rng(A));
  if(num%2){
    sum-=2*A[0];
  }
  print(sum);
  return 0;
}

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

using namespace std;
typedef long long LL;
int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
const int mod = 1e9;
LL read() {
	LL s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}
void put(int x) {
	if(x < 0) x = -x, putchar('-');
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int main() {
	LL S = read();
	printf("0 0 1000000000 1 %d %d\n", (mod - S % mod) % mod, (S - 1) / mod + 1);
	return 0;
}



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

int main(){
    int n;
    cin>>n;
    int a[n],i;
    for(i=0;i<n;i++)cin>>a[i];
    pair<int,int> p[n];
    for(i=0;i<n;i++){
    	p[i].first=a[i];
    	p[i].second=i+1;
	}
	sort(p,p+n);
	for(i=0;i<n;i++){
		cout<<p[i].second<<' ';
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>
typedef struct{
  char c;
  int number;
}donald;
void Bub(donald *a,int n);
void Sel(donald *a, int n);
void PP(donald *a,int n);
int stablecheck(donald *a,int n,donald *b);
int judge(donald *a, int n,donald *b);
int main(){
  
  int n,i,stable=0;
  donald trump[36],trump1[36],trump2[36];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf(" %c%d",&trump[i].c,&trump[i].number);
    trump1[i].c=trump[i].c;
    trump1[i].number=trump[i].number;
    trump2[i].c=trump[i].c;
    trump2[i].number=trump[i].number;
  }
  /*bubblr sort */
  Bub(trump1,n);
  PP(trump1,n);
  stable=stablecheck(trump,n,trump1);
  printf("Stable\n");
  
  /*selection sort*/
 
  Sel(trump2,n);
  PP(trump2,n);
  stable=judge(trump1,n,trump2);
  if(stable==1){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  
  return 0;
}

void PP(donald *a,int n){
  int i;
  for(i=0;i<n;i++){
    if(i==(n-1)){
      printf("%c%d\n",a[i].c,a[i].number);
    }
    else {
      printf("%c%d ",a[i].c,a[i].number);
    }
  }
}



void Bub(donald *a,int n){
  int j,flag=1,sub,i;
  char subc;
  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j].number<a[j-1].number){
	sub=a[j].number;
	a[j].number=a[j-1].number;
	a[j-1].number=sub;
	subc=a[j].c;
	a[j].c=a[j-1].c;
	a[j-1].c=subc;
	flag=1;
      }
    }
  }
}
			


void Sel(donald *a,int n){
  int i,min,sub,j;
  char subc;
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(a[j].number<a[min].number){
	min=j;
      }
    }
    if(a[i].number>a[min].number){
      sub=a[i].number;
      a[i].number=a[min].number;
      a[min].number=sub;
      subc=a[i].c;
      a[i].c=a[min].c;
      a[min].c=subc;
    }
  }
}



     
int stablecheck(donald *in, int n,donald *out){
  int i,j,a,b;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(a=0;a<n;a++){
	for(b=a+1;b<n;b++){
	  if(in[i].number==in[j].number && in[i].number==out[a].number && in[j].number==out[b].number && in[i].c==in[j].c && in[i].c==out[a].c && in[j].c==out[b].c){
	    return 0;
	  }
	}
      }
    }
  }
  return 1;
}

  
int judge(donald *a,int n,donald *b){
  int judge=0,i;

  for(i=0;i<n;i++){
    if(a[i].number==b[i].number && a[i].c==b[i].c){
      judge++;
    }
  }
  if(judge==n){
    return 1;
  }
  else {
    return 0;
  }
}
  

Measured memory_bytes: 608
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    map <int,int> m;
    int n; cin>>n; 
    int a[n+1],mx=0;
    for (int i=1;i<=n;i++) {
        cin >> a[i] ; 
        m[a[i]]++; 
        mx = max(a[i],mx);
    }
    sort(a+1,a+n+1);
    int ans=0;
    for (int i=1;i<=n;i++){
        if (m[a[i]]==1) ans++;
      	if (m[a[i]]){
            for (int j=2*a[i];j<=mx;j += a[i])
                if (m[j]) m[j]=0; 
        }
    }
    cout << ans << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

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

    string S;
    cin >> S;

    char pre = S[0];
    int length = N;
    for (int i = 1; i < N; i++) {
        if (pre == S[i]) {
            --length;
        }
        pre = S[i];
    }
    
    std::cout << length << endl;
    return 0;
}

Measured memory_bytes: 512
let n = Int(readLine()!)!
var s = Array(readLine()!)

var red = s.filter { $0 == "R" }.count
var white = 0
var ans = Int.max

for i in -1..<n {
  if i == -1 {
    ans = min(ans, red)
    continue
  }
  red -= s[i] == "R" ? 1 : 0
  white += s[i] == "W" ? 1 : 0
  ans = min(ans, max(red, white))
}
print(ans)

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

#define ll long long
#define an "\n"
#define pb push_back
#define pob pop_back

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s, t;
	int sum=0;
	cin >> s >> t;
	for(int i=0;i<s.size();i++) {
		if(s[i]!=t[i]) {
			sum++;
		}
	}
	cout << sum;
}




Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//


int main() {
  ll n;
  cin >> n;
  string ans = "";
  while (n) {
    --n;
    ans += char('a' + (n % 26));
    n /= 26;
  }
  reverse(ALL(ans));
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m, k;
char input[6][500];
char str[10000100];
set<string> opened;

string Open(int &pos) {
  string ret;
  while (input[5][pos] != '\0' && input[5][pos] != ')') {
    if (isdigit(input[5][pos])) {
      int num = 0;
      while (isdigit(input[5][pos])) {
        num *= 10;
        num += input[5][pos++] - '0';
        num = min(num, m);
      }
      assert(input[5][pos] == '(');
      pos++;
      string nret = Open(pos);
      assert(input[5][pos] == ')');
      pos++;
      num = min(num, max(2, (m + (int)nret.size() - 1) / (int)nret.size()));
      if (nret.size() >= 400) {
        if (opened.count(nret)) { num = 1; }
        opened.insert(nret);
      }
      string add;
      REP(i, num) { add += nret; }
      if (add.size() >= 400) { opened.insert(add); }
      ret += add;
    } else {
      ret += input[5][pos++];
    }
  }
  assert((int)ret.size() <= 10000000);
  return ret;
}

int main() {
  while (scanf("%d %d %d", &n, &m, &k) > 0) {
    opened.clear();
    scanf("%s", input[5]);
    REP(i, k) {
      scanf("%s", input[i]);
    }
    {
      int pos = 0;
      string s = Open(pos);
      sprintf(str, "%s", s.c_str());
    }
    int ans = -1;
    int maxValue = -1;
    REP(iter, k) {
      int lv = 0;
      REP(r, m) {
        REP(l, r + 1) {
          char c = input[iter][r + 1];
          input[iter][r + 1] = 0;
          lv += strstr(str, input[iter] + l) != NULL;
          input[iter][r + 1] = c;
        }
      }
      if (lv > maxValue) {
        ans = iter + 1;
        maxValue = lv;
      }
    }
    printf("%d %d\n", ans, maxValue);
  }
}

Measured memory_bytes: 1088
#include<bits/stdc++.h>
using namespace std;
#define mod 1e18+1
typedef long long ll;
int main()
{
    ll n,total=1,ans=1,zero=0;
    cin>>n;
    for(ll i=1 ; i<=n ; i++)
    {
        ll x;
        cin>>x;
        if(x==0 || zero)
           {
                zero++;
                continue;
           }
        if(x<=1000000000000000000/total)
            {
                total*=x;
            }
        else
            ans=-1;
    }
    if(zero)
        cout<<0;
        
    else if(ans==-1)
        cout<<-1;
    else
        cout<<total;
    cout<<"\n";
    return 0;
}


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

#define int long long
#define mod 1000000007

using namespace std;

int raise(int number, int exponent) {
    int answer = 1;
    while (exponent) {
        if (exponent & 1) {
            answer = answer * number % mod;
        }
        number = number * number % mod;
        exponent >>= 1;
    }
    return answer;
}

int a[200010];

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

	int ans = 0;

	for(int i=k;i>=1;i--)
	{
		a[i] = raise(k/i, n);

		for(int j=2*i;j<=k;j+=i)
			a[i] = (a[i] - a[j] + mod)%mod;

		ans = (ans + i*a[i])%mod;
	}

	cout << ans << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define repo(i,o,n) for(int i=o;i<(int)(n);i++)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int kr(int a);

int n,m,a[100000],b[100000],is_Linked[100001],adress[100001],now;
stack<int> ans;

main() {
    cin >> n >> m;
    repm(i,m) cin >> a[i] >> b[i];
    now = n*(n-1)/2;
    ans.push(now);
    rep(i,m-1) {
        if (!is_Linked[a[i]] && !is_Linked[b[i]]) {
            now--;
            is_Linked[a[i]] = is_Linked[b[i]] = 2;
            adress[a[i]] = adress[b[i]] = a[i];
            ans.push(now);
        } else if (!is_Linked[a[i]]) {
            int bkr = kr(b[i]);
            now -= is_Linked[bkr];
            is_Linked[bkr]++;
            is_Linked[a[i]]++;
            adress[a[i]] = bkr;
            ans.push(now);
        } else if (!is_Linked[b[i]]) {
            int akr = kr(a[i]);
            now -= is_Linked[akr];
            is_Linked[akr]++;
            is_Linked[b[i]]++;
            adress[b[i]] = akr;
            ans.push(now);
        } else {
            int akr = kr(a[i]),bkr = kr(b[i]);
            if (akr != bkr) {
                now -= is_Linked[akr]*is_Linked[bkr];
                is_Linked[akr] += is_Linked[bkr];
                adress[bkr] = akr;
            }
            ans.push(now);
        }
    }
    rep(i,m) cout << ans.top() << endl,ans.pop();
}

int kr(int a) {
    while(1) {
        if (adress[a] != adress[adress[a]]) a = kr(adress[a]);
        else return adress[a];
    }
}


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll s = 0;
  for (int i = 0; i < k; i++) {
    s += a[i];
  }
  cout << s << "\n";
  return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int count(string t,char c){
  int num=0;
  
  rep(i,t.size())
    if(t[i]==c) num++;

  return num;
}

int main(void){
  string s; cin >> s;
  int a,b,c;
  a = count(s,'a');
  b = count(s,'b');
  c = count(s,'c');

  bool ok = true;
  if(a!=1 || b!=1 || c!=1) ok = false;

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


Measured memory_bytes: 3596
def bisearch(li,target):
    l=0
    r=len(li)-1
    while(l<=r):        
        m=int((l+r)/2)
        if(m==len(li)-1):
            return target-li[m][0]+li[m][1]
        if(li[m][0]<target and target<li[m+1][0]):
            return min(target-li[m][0]+li[m][1],li[m+1][0]-target+li[m+1][1])
        if(m==0 and target<li[0][0]):
            return li[0][0]-target+li[0][1]
        if(target<li[m][0]):
            r = m-1
        else:
            l = m+1

inf = 10**15
A,B,Q = [int(x) for x in input().split()]
s = [0]*(A+1)
t = [0]*(B+1)
x = [0]*Q

for i in range(A):
    s[i] = int(input())
for i in range(B):
    t[i] = int(input())
for i in range(Q):
    x[i] = int(input())
s[-1] = inf
t[-1] = inf

li = []
a = b = 0
while(a<A or b<B):
    if(s[a]<t[b]):
        li.append([s[a],min(abs(t[b]-s[a]),abs(t[b-1]-s[a]))])
        a+=1
    else:
        li.append([t[b],min(abs(t[b]-s[a]),abs(t[b]-s[a-1]))])
        b+=1

for i in x:
    print(bisearch(li,i))


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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	unordered_map<int, int> s;
	s[0] = 1;
	int a, b = 0;
	long r = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		b += a; b %= m;
		r += s[b]++;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 3596
n=int(input())
a=sorted([int(i) for i in input().split()])
m,k=n//3,0
for i in range(n):
  d=i%3*m+i//3
  if a[d]^a[(d+2*m)%n]!=a[(d+m)%n]:
    k=1
print('YNeos'[k::2])

Measured memory_bytes: 60784
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 n, m;
i64 d[100002];

i32 main()
{
    cin >> n >> m;
    times(m, i) {
        i64 a, b; cin >> a >> b;
        if (a > b) swap(a, b);
        d[a]++;
        d[b]--;
    }
    bool ok = true;
    i64 acc = 0;
    range(1, n, i) {
        acc += d[i];
        if (odd(acc)) {
            ok = false;
            break;
        }
    }
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define SIZE 10
int main()
{
  int mass[SIZE][SIZE];
  int x,y,s;
  int i,j;
  int max,white;
  for(i=0;i<SIZE;i++)
    for(j=0;j<SIZE;j++)
      mass[i][j]=0;
  while(scanf("%d,%d,%d",&x,&y,&s)!=EOF)
    {
      switch(s)
	{
	case 1:
	  mass[x][y]++;
	  if(x>0) mass[x-1][y]++;
	  if(x<SIZE-1) mass[x+1][y]++;
	  if(y>0) mass[x][y-1]++;
	  if(y<SIZE-1) mass[x][y+1]++;
	  break;
	case 2:
	  mass[x][y]++;
	  if(x>0)
	    {
	      mass[x-1][y]++;
	      if(y>0) mass[x-1][y-1]++;
	      if(y<SIZE-1) mass[x-1][y+1]++;
	    }
	  if(x<SIZE-1)
	    {
	      mass[x+1][y]++;
	      if(y>0) mass[x+1][y-1]++;
	      if(y<SIZE-1) mass[x+1][y+1]++;
	    }
	  if(y>0) mass[x][y-1]++;
	  if(y<SIZE-1) mass[x][y+1]++;
	  break;
	case 3:
	  mass[x][y]++;
	  if(x>0)
	    {
	      mass[x-1][y]++;
	      if(y>0) mass[x-1][y-1]++;
	      if(y<SIZE-1) mass[x-1][y+1]++;
	    }
	  if(x<SIZE-1)
	    {
	      mass[x+1][y]++;
	      if(y>0) mass[x+1][y-1]++;
	      if(y<SIZE-1) mass[x+1][y+1]++;
	    }
	  if(y>0) mass[x][y-1]++;
	  if(y<SIZE-1) mass[x][y+1]++;
	  if(x>1) mass[x-2][y]++;
	  if(x<SIZE-2) mass[x+2][y]++;
	  if(y>1) mass[x][y-2]++;
	  if(y<SIZE-2) mass[x][y+2]++;
	  break;
	}
    }
  white=0;
  max=mass[0][0];
  for(i=0;i<SIZE;i++)
    {
      for(j=0;j<SIZE;j++)
	{
	  if(mass[i][j]==0) white++;
	  if(mass[i][j]>max) max=mass[i][j];
	}
    }

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

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define lpa(i,a,b) for(int i=a; i<b; ++i)
#define lp(i,n) lpa(i,0,n)
void p1()
{
	long long n,a,b;
	cin>>n>>a>>b;
	if(n==1) cout<<(a==b);
	else if(a>b) cout<<0;
	else cout<<(n-2)*(b-a)+1;
}
int main()
{
	p1();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int time1, time2, time3;
  time1 = H1 * 60 + M1;
  time2 = H2 * 60 + M2;
  time3 = time2 - time1 - K;
  cout << time3 << endl;
}

  
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
ll maax;
vector<ll> z;
ll n;
void zz(string s,ll length) {
    ll n = s.size();
   ll x = 0, y = 0;
   for (ll i = 1; i < n; i++) {
    z[i] = max((ll)0,min(z[i-x],y-i+1));
    while (i+z[i] < n && s[z[i]] == s[i+z[i]]) {
    x = i; y = i+z[i]; z[i]++;
    }
   ll index=0;
 

}


FOR(i,length+1,sz(z)-1){
   // dbg2(z[i],i);
	 maax=max(maax,z[i]);

 
 
}

return;
}
 
int main(){
	IOS
	maax=0;
	
	cin>>n;
	string s;
	cin>>s;
	z.resize(n+1);
	ll length=1;
	string t1;
	string t2;
	string tmp;
	
	
	for(ll i=n-1;i>=1;i--){
		tmp="";
		t1=s.substr(i);
		t2=s.substr(0,i);
		tmp=tmp+t1+"$"+t2;
		zz(tmp,length++);
		
 
 
 
	}
	cout<<maax<<endl;
 
    
 
 
 
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main ()
{
    char a;
    cin>>a;
    if(a>='A' && a<='Z')
    {
        cout<<"A"<<endl;
    }
    else if(a>='a' && a<='z')
    {
        cout<<"a"<<endl;
    }
    return 0;
}




Measured memory_bytes: 3628
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string N;
    cin >> N;
    rep(i, N.size()) {
        if (N[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
s = input()
answer = 0
for left in range(len(s)):
    for right in range(left, len(s)): #一文字だけの場合があるので、始端はleft+1ではない
        if set(s[left:right+1]) <= set("ACGT"):
            answer = max(answer, right - left +1)
print(answer)

Measured memory_bytes: 2940
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		
		int[] P = new int[N+1];
		for(int i=0;i<M;i++) {
			int j = sc.nextInt();
			P[j] = 1;
		}
		sc.close();
		
		//左
		int ansL = 0;
		for(int i=X;i>=0;i--) {
			ansL += P[i];
		}
		
		//右
		int ansR = 0;
		for(int i=X;i<N;i++) {
			ansR += P[i];
		}
		
		out.println(Math.min(ansL, ansR));

	}

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


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    ll N; cin >> N;
    ll s = 0;
    rep1(i, N+1) {
        if (i % 3 != 0 && i % 5 != 0) s += i;
    }

    cout << s << endl;
}


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n; cin >> n;
  set<char> s;
  for(int i=0; i<n; i++){
    char a; cin >> a;
    s.insert(a);
  }
  string ans;
  if(s.size()==3) ans = "Three";
  if(s.size()==4) ans = "Four";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    if N - sum(A) < 0:
        print(-1)
    else:
        print(N - sum(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 68480
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<vector<ll> > dp(n + 1, vector<ll>(2));
  dp[0][0] = 0;
  dp[0][1] = -INF;

  rep(i,n) scanf("%lld", &a[i]);

  int cursor;
  for (int i = 1; i <= n; ++i) {
    cursor = i - 1;
    dp[i][0] = std::move(max(dp[cursor][0] + a[cursor], dp[cursor][1] - a[cursor]));
    dp[i][1] = std::move(max(dp[cursor][0] - a[cursor], dp[cursor][1] + a[cursor]));
  }

  printf("%lld\n", dp[n][0]);
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

void rec(int d, ll val, vector<ll> &all){
    all.push_back(val);
    if(d == 10) return;
    for(int j = -1; j <= 1; j++){
        int add = (val % 10) + j;
        if(add >= 0 && add <= 9) rec(d+1, val*10+add, all);
    }
}

int main(){
    int k; cin >> k;
    vector<ll> all;
    for(int i = 1; i < 10; i++) rec(1, i, all);
    sort(ALL(all));
    cout << all[k-1] << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <map>
#include <functional>

using namespace std;


int main() {
	int N;
	cin >> N;
	vector<long long> a(N);
	int temp;
	for (int i = 0; i < N; i++) {
		cin >> temp;
		a[i] = temp;
	}

	long long m = 0;

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

	cout << m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9999999999;
ll dp[1001][1001];
int dx[]={-1,0,0,1};
int dy[]={0,1,-1,0};

ll gcd(ll a,ll b){
    ll M=max(a,b);
    ll m=min(a,b);
    if(m==0){
        return M;
    }
    return gcd(m,M%m);
}


int main(){
    int n;
    ll x;
    cin>>n>>x;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        ll b;
        cin>>b;
        a[i]=abs(x-b);
    }
    ll g=a[0];
    for(int i=1;i<n;i++){
        g=gcd(g,a[i]);
    }
    cout<<g<<endl;

}

Measured memory_bytes: 3976
import java.util.Scanner;
import java.io.PrintWriter;

public class Main {
    static Scanner scan = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args){
        while(true){
            int n = si();
            if(n==0) break;
            boolean[][] list = new boolean[n][30];
            long[] map = new long[n];
            int res = -1;
            for (int i = 0; i < n; i++)
                for (int j = 0, m = si() ;j < m ; j++)
                    list[i][si()-1]=true;
            for (int i = 0; i < 30; i++) {
                long tmp = 0;
                for (int j = 0; j < n; j++)
                    if(list[j][i]) tmp |= 1L<<j | map[j];
                for (int j = 0; j < n; j++)
                    if(list[j][i]) map[j]=tmp;
                if(tmp==(1L<<n)-1){
                    res = i+1;
                    break;
                }
            }
            out.println(res);
        }
        out.flush();
    }
    static int si(){
        return Integer.parseInt(scan.next());
    }
}

Measured memory_bytes: 71052
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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 namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll res = a * c;
	chmax(res, a * d);
	chmax(res, b * c);
	chmax(res, b * d);
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3664
# coding=utf-8

if __name__ == '__main__':
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())

    cnt = 0
    M = 0

    for i in range(A + 1):
        for f in range(B + 1):
            for t in range(C + 1):
                M = 500*i + 100*f + 50*t
                if(X == M):
                    cnt = cnt + 1

    print(cnt)


Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))

count = 1
state = 0
for i in range(N-1):
    diff = A[i+1] - A[i]
    if state == 0:
        if diff > 0:
            state = 1
            continue
        if diff == 0:
            state = 0
            continue
        if diff < 0:
            state = -1
            continue
    if state == 1:
        if diff > 0:
            state = 1
            continue
        if diff == 0:
            state = 1
            continue
        if diff < 0:
            count += 1
            state = 0
            continue
    if state == -1:
        if diff > 0:
            count += 1
            state = 0
            continue
        if diff == 0:
            state = -1
            continue
        if diff < 0:
            state = -1
            continue

print(count)


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

int main() {
	int N, K, A[N];
	cin >> N >> K;
	int num[210000];
	for (int i=0; i<N; i++){
	    int a;
	    cin >> a;
	    num[a-1]++;
	}
	sort(num, num+N);
	int ans=0;
	for (int i=0; i<N-K; i++){
	    ans+=num[i];
	}
	cout << ans << endl;

}


Measured memory_bytes: 1024