akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
using ll = long long;


int main()
{
    string s; cin >> s;
    ll k; cin >> k; int n = s.size();
    for(int i = 0; i < k && i < n; i++) {
        if(s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
    }

    cout << 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
const int N = 100'000;
double x[N], y[N], dx[N], dy[N], nx[N], ny[N];
template <typename signature> using f = const function<signature>&;
template <typename TIn, typename TOut> TIn tsearch(TIn L, TIn R, f<TOut(TIn)> obj, f<bool(TOut, TOut)> cmp = less<TOut>()) {
    for(int i = 0; i < 1000; i++) {
        TIn M1 = (2 * L + R) / 3;
        TIn M2 = (L + 2 * R) / 3;
        cmp(obj(M1), obj(M2)) ? R = M2 : L = M1;
    }
    return cmp(obj(L), obj(R)) ? L : R;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        char dir;
        cin >> dir;
        dx[i] += (dir == 'R') - (dir == 'L');
        dy[i] += (dir == 'U') - (dir == 'D');
    }
    auto diffi = [&](double t, auto& updated, auto& original, auto& d) {
        for(int i = 0; i < n; i++) {
            updated[i] = original[i] + d[i] * t;
        }
        return *max_element(updated, updated + n) - *min_element(updated, updated + n);
    };
    auto diff = [&](double t) {
        return diffi(t, nx, x, dx) * diffi(t, ny, y, dy);
    };
    cout << fixed << setprecision(9) << diff(tsearch<double, double>(0, 2e8, diff)) << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>

int main(void)
{
        long n, a, b, m;

        scanf("%ld%ld%ld",&n,&a,&b);
        if(n%(a+b)==0)
           m=a*(n/(a+b));
        else if(n%(a+b)>=a)
           m=a*(n/(a+b))+a;
        else
           m=a*(n/(a+b))+n%(a+b);
        printf("%ld",m);

        return 0;
}


Measured memory_bytes: 128
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    s = get_str()
    a, b = int(s[:2]), int(s[2:])
    if 1 <= a <= 12 and 1 <= b <= 12:
        print('AMBIGUOUS')
    elif 1 <= b <= 12 and (a == 0 or a > 12):
        print('YYMM')
    elif 1 <= a <= 12 and (b == 0 or b > 12):
        print('MMYY')
    else:
        print('NA')
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Measured memory_bytes: 65388
#include <stdio.h>
#define MAX 101

int main(){
  int i,j,k,r,c,l,n,q;
  int m[MAX][MAX],p[MAX];

  scanf("%d",&n);
  for(i = 1; i <= n; i++){
    scanf("%d%d",&r,&c);
    if(i == 1) p[0] = r;
    p[i] = c;
  }

  for(i = 1; i <= n; i++) m[i][i] = 0;

  for(l = 2; l <= n; l++){
    for(i = 1; i <= n-l+1; i++){
      j = i+l-1;
      m[i][j] = 999999999;
      for(k = i; k < j; k++){
	q = m[i][k]+m[k+1][j]+(p[i-1]*p[k]*p[j]);
	if(q < m[i][j]) m[i][j] = q;
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}



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



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

    int n, l;
    cin >> n >> l;
    string s[100];

    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s, s+n);
    for (int i = 0; i < n; i++) {
        cout << s[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main() {
    char a,b;
    cin>>a>>b;
    if(a=='H'){
        if(b=='H'){
            cout<<"H"<<endl;
        }else{
            cout<<"D"<<endl;
        }
    }else{
        if(b=='H'){
            cout<<"D"<<endl;
        }else{
            cout<<"H"<<endl;
        }
    }
}   



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll a[2005], dp[2005];
ll mod = 1e9 + 7;
ll binpow(ll a, ll b){
	if (b == 0) return 1;
	ll x = binpow(a, b / 2);
	x *= x; x %= mod;
	if (b % 2) return (x * a) % mod;
	else return x;
}
int main(){
	ll n, k; cin >> n >> k;
	ll cur = 0;
	for (ll i = 1; i <= sqrt(n); i++){
		if (n % i == 0){
			a[cur] = i; cur++;
			if (i * i != n){
				a[cur] = n / i; cur++;
			}
		}
	}
	sort(a, a + cur);
	for (ll i = 0; i < cur; i++){
		dp[i] = binpow(k, (a[i] + 1) / 2);
		for (ll j = 0; j < i; j++){
			if (a[i] % a[j] == 0){
				((dp[i] -= dp[j]) += mod) %= mod;
			}
		}
	}
	ll ans = 0;
	for (ll i = 0; i < cur; i++){
		if (a[i] % 2) (ans += (dp[i] * a[i])) %= mod;
		else (ans += (dp[i] * (a[i] / 2))) %= mod;
	}
	cout << ans << endl;
}

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


int main() {

    ll x, a, b;
    cin >> x >> a >> b;
    if (a >= b) cout << "delicious" << endl;
    else {
        if (b - a <= x) cout << "safe" << endl;
        else cout << "dangerous" << endl;
    }
    return 0;
}

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

void merge(long long a[], long long b[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	static long long l[500001];
	static long long l2[500001];
	static long long r[500001];
	static long long r2[500001];

	for (int i = 0; i <= n1 - 1; i++) {
		l[i] = a[left + i];
		l2[i] = b[left + i];
	}
	for (int i = 0; i <= n2 - 1; i++) {
		r[i] = a[mid + i];
		r2[i] = b[mid + i];
	}

	l[n1] = 1000000001;
	r[n2] = 1000000001;

	int i = 0;
	int j = 0;

	for (int k = left; k < right; k++) {
		if (l[i] <= r[j]) {
			a[k] = l[i];
			b[k] = l2[i];
			i++;
		}
		else {
			a[k] = r[j];
			b[k] = r2[j];
			j++;
		}
	}
}

void mergesort(long long a[], long long b[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergesort(a, b, left, mid);
		mergesort(a, b, mid, right);
		merge(a, b, left, mid, right);
	}
}

int main() {
	int n, m;
	vector<long long> a;
	long long temp;
	static long long b[100000], c[100000];

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> temp;
		a.push_back(temp);
	}


	for (int i = 0; i < m; i++) {
		cin >> b[i] >> c[i];
	}

	mergesort(c, b, 0, m);

	long long count = 0;

	for (int i = m - 1; i >= 0; i--) {
		if (count + b[i] <= n) {
			count += b[i];
			for (int j = 0; j < b[i]; j++) {
				a.push_back(c[i]);
			}
		}
		else {
			for (int j = 0; j < n - count; j++) {
				a.push_back(c[i]);
			}
			count = n;
			break;
		}
	}

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

	long long sum = 0;

	for (int i = 1; i <= n; i++) {
		sum += a[a.size() - i];
	}

	cout << sum << endl;
	cin >> n;
}

Measured memory_bytes: 10484
n=int(input())
d=list(map(int,input().split()))
k=[]
t=0
ans=0
for i in range(n):
  ans+=abs(d[i])
  if d[i]<=0:
    t+=1
for i in range(len(d)):
  k.append(abs(d[i]))
k.sort()
if t%2:
  ans-=2*k[0]
print(ans)

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

int main() {
  string S;
  cin >> S;
  int flag_yymm = 0;
  int flag_mmyy =0;

  if(S[2] == '0'){
    if(S[3] != '0') {
      flag_yymm=1;
    }
  }
  if(S[2] == '1'){
    if(S[3] == '0' || S[3] == '1' || S[3] == '2') {
      flag_yymm=1;
    }
  }
  if(S[0] == '0'){
    if(S[1] != '0') {
      flag_mmyy=1;
    }
  }
  if(S[0] == '1'){
    if(S[1] == '0' || S[1] == '1' || S[1] == '2') {
      flag_mmyy=1;
    }
  }

  if(flag_mmyy==1 && flag_yymm==1){
    cout << "AMBIGUOUS" << endl;
    return 0;
  }
  if(flag_mmyy==1 && flag_yymm==0){
    cout << "MMYY"<< endl;
    return 0;
  }
  if(flag_mmyy==0 && flag_yymm==1){
    cout << "YYMM"<< endl;
    return 0;
  }
  if(flag_mmyy==0 && flag_yymm==0){
    cout << "NA"<< endl;
    return 0;
  }


}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

const int mo=1e9+7;

int f[20][100001],n,m,a[20],inv[100001],jie[100001];

int C(int o,int p) {return (o<p)?0:(1ll*jie[o]*inv[p]%mo*inv[o-p]%mo);}

int ss(int o) {int p=0;while(o>0){if(o&1) p++;o>>=1;}return p;}

bool cmp(int o,int p){return o>p;}

int mi(int o,int p)
{
	int u=1;
	while(p>0)
	{
		if(p&1) u=1ll*u*o%mo;
		o=1ll*o*o%mo;
		p>>=1;
	}
	return u;
}

int main()
{
	jie[0]=1;
	for(int i=1;i<=1e5;i++) jie[i]=1ll*jie[i-1]*i%mo;
	for(int i=0;i<=1e5;i++) inv[i]=mi(jie[i],mo-2);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d",&a[i]);
	sort(a+1,a+m+1,cmp);
	memset(f,0,sizeof(f));
	f[0][0]=1;
	int sum=1;
	for(int i=1;i<=m;i++)
	    for(int s=0;s<(1<<n);s++)
	    {
	    	f[i][s]=f[i-1][s];
	    	for(int j=1;j<=n;j++)
	    	{
	            if((s&(1<<(j-1)))==0) continue;
	            int yu=C((1<<n)-s+(1<<(j-1))-a[i],(1<<(j-1))-1);
	            f[i][s]=(f[i][s]+1ll*f[i-1][s-(1<<(j-1))]*yu%mo*jie[1<<(j-1)]%mo)%mo;
	        }
		}
	int ans=jie[(1<<n)-1];
	for(int s=1;s<(1<<n);s++) 
		ans=(ans+1ll*f[m][s]%mo*((ss(s)%2)?(-1):1)*jie[(1<<n)-1-s]%mo+mo)%mo;
	cout<<(1ll*ans*(1<<n)%mo)<<endl;
	return 0;
}

Measured memory_bytes: 8832
m=1001
d=[[0]*m for i in range(10)]
d[0][0]=1
for i in range(101):
  for j in range(9,0,-1):
    for k in range(m-i): d[j][k+i]+=d[j-1][k]
while 1:
  n,s=map(int,raw_input().split())
  if n==s==0: break
  print d[n][s]

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  int K;
  int X;
  int Y;
  cin >> N >> K >> X >> Y;
  if(N <= K){   
   cout << X*N;
  }
  else{
  cout << X*K + Y*(N - K);
  }
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,a[101];
int main()
{
	read(n);
	for(res i=1;i<=n;++i) read(a[i]);
	sort(a+1,a+1+n);int minn=1e9;
	for(res i=a[1];i<=a[n];++i) {
		int tot=0;
		for(res j=1;j<=n;++j) tot+=(a[j]-i)*(a[j]-i);
		chkmin(minn,tot);
	}
	print(minn,'\n');
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
S = input()

if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(void)
{
	int H,W,h,w;

	while(1){
		cin >> H >> W;
		if(H==0 && W==0)break;

		for(h=1 ; h<=H ; h++){
			for(w=1 ; w<=W ; w++){
				cout << "#";
				w++;
				if(w>W)break;
				cout << ".";
			}
			cout << endl;
			h++;
			if(h>H)break;
			for(w=1 ; w<=W ; w++){
				cout << ".";
				w++;
				if(w>W)break;
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BComparingStrings {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        char a, b;
        in>>a>>b;
        auto sa = string(b-'0', a);
        auto sb = string(a-'0', b);
        if(sa<sb) out<<sa<<'\n';
        else out<<sb<<'\n';
    }
};


int main() {
	BComparingStrings solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3600
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        a:[u64;n]
    }

    let mut cum_sum = vec![0; n + 1];

    for i in 1..n + 1 {
        cum_sum[i] = (cum_sum[i - 1] + a[i - 1]) % LARGE_PRIME;
    }

    let mut ans = 0;

    for i in 0..n {
        ans += a[i] * (LARGE_PRIME + cum_sum[n] - cum_sum[i + 1]);
        //println!("{} {}", a[i], (cum_sum[n] - cum_sum[i + 1]));
        ans %= LARGE_PRIME;
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

struct dat{
    int mx1, mx2;
    dat(){};
    dat(int mx1, int mx2) : mx1(mx1), mx2(mx2) {}
};

int N;
int A[1 << 20];
dat dp[20][1 << 20];

void update(dat& d1, dat& d2){
    if(A[d2.mx1] > A[d1.mx1]){
        d1.mx2 = d1.mx1, d1.mx1 = d2.mx1;
        if(A[d2.mx2] > A[d1.mx2]) d1.mx2 = d2.mx2;
    }else if(d2.mx1 != d1.mx1 && A[d2.mx1] > A[d1.mx2]) d1.mx2 = d2.mx1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    
    for(int j = 0; j <= N; ++j){
        for(int i = 0; i < (1 << N); ++i){
            dp[j][i] = dat{1 << N, 1 << N};
        }
    }
    
    for(int i = 0; i < 1 << N; ++i){
        cin >> A[i];
        dp[0][i] = {i, 1 << N};
    }
    
    for(int j = 0; j < N; ++j){
        for(int i = 0; i < (1 << N); ++i){
            if(i >> j & 1){
                update(dp[j + 1][i], dp[j][i ^ 1 << j]); 
            }
            update(dp[j + 1][i], dp[j][i]);
        }
    }
    int ans = 0;
    for(int i = 1; i < (1 << N); ++i){
        dat d = dp[N][i];
        chmax(ans, A[d.mx1] + A[d.mx2]);
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

#define pp pair<int, int>
#define ll long long

void solve() {
  int k, a, b;
  cin >> k;
  cin >> a >> b;
  for(int i=a; i<=b; i++) {
   if(i%k == 0) {
     cout << "OK";
     return;
   }
  }
  cout << "NG";
}

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


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

#define fi first
#define se second
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;

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

	int n, k;
	cin>>n>>k;
	vector<bool> nosnack(n+1, true);
	int count = n;

	for (int i = 0; i < k; ++i)
	{
		int d; cin>>d;
		for (int j = 0; j < d; ++j)
		{
			int a; cin>>a;
			if (nosnack[a])
			{
				nosnack[a] = false;
				--count;
			}
		}
	}
	cout<<count<<'\n';

	return 0;
}


Measured memory_bytes: 3656
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	static long MOD = 1000000007;
	static int N;
	static Long dp[][];

	static long countWays(int matrix[][], int n, int women)
	{
		if(n==0)
			return (women==((1<<N)-1))? 1: 0;
		if(women==((1<<N)-1))
			return 0;

		if(dp[n][women]!=null)
			return dp[n][women];

		long temp=0;
		for(int i=0;i<N;i++)
		{
			if((((women>>i)&1)==0) && matrix[n-1][i]==1)
			{
				temp += countWays(matrix, n-1, (women|(1<<i)));
				temp = temp % MOD;
			}
		}
		return dp[n][women]=temp;
	}

	public static void main(String[] args)
	{
		FastReader scan=new FastReader();
		int n=scan.nextInt();

		int matrix[][]=new int[n][n];
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				matrix[i][j]=scan.nextInt();

		N=n;
		dp=new Long[n+1][(1<<N)];
		long ans = countWays(matrix, n, 0);
		System.out.println(ans);
	}
}


 class FastReader
{
    BufferedReader br;
    StringTokenizer st;
 
    public FastReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }
 
    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    int nextInt()
    {
        return Integer.parseInt(next());
    }
 
    long nextLong()
    {
        return Long.parseLong(next());
    }
 
    double nextDouble()
    {
        return Double.parseDouble(next());
    }
 
    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}


Measured memory_bytes: 289844
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
const int MOD = 1e9+7;
const int N = 3500;
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int main()
{
    fast_io();
    string s ;
    cin >>s ;
    map<char , int >m;
    for ( char x : s )
    {
        m[x]++;
    }

    if ( m.size() == 2 )cout <<"Yes";
    else
        cout << "No";
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#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 unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

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

int N;

signed main()
{
	cin >> N;
	vi x(N), a;
	rep(i, N) cin >> x[i];
	a=x;
	sort(all(a));
	int med = a[N / 2 - 1];
	rep(i, N) {
		if (x[i] <= med) {
			cout << a[N / 2];
		} else {
			cout << a[N / 2 - 1];
		}
		cout << '\n';
	}
}



Measured memory_bytes: 5376
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

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

int main(){
	int a,b;
	cin>>a>>b;
	
	if(a<b)puts("a < b");
	if(a>b)puts("a > b");
	if(a==b)puts("a == b");
}

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



int main() {
    int a,b;
    cin >> a >> b;
    int count = 0;
    for (int i=a ; i <= b ; i++) {
        if (i / 10000 == i % 10 && (i / 1000) % 10 == (i / 10) % 10) {
            count++;
        }
    }
    cout << count;
    
}


Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))
v = sorted(v)
ans = 0
for i in range(n-1):
    if i == 0:
        ans = (v[i] + v [i + 1]) / 2
    else:
        ans = (ans + v[i + 1]) / 2
print(ans)


Measured memory_bytes: 3060
import io
import sys
from fractions import gcd


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
314159265358979323 846264338327950288 419716939 937510582
'''


def MAIN():
  # T_IN()
  A()


def A():
  a, b, c, d = IN_L_I()

  divc = (b // c) - ((a - 1) // c)
  divd = (b // d) - ((a - 1) // d)
  cd = c * d // gcd(c, d)
  divcd = (b // cd) - ((a - 1) // cd)


  total = (b + 1 - a) - divc - divd + divcd

  print(total)
  return None
 

def B():
  return None


def C():
  return None


MAIN()


Measured memory_bytes: 5044
#include <iostream>
#include <vector>
using namespace std;
int n,m;
vector<int> v[100010];
int d[100010];
inline int work(int x)
{
	if (d[x]) return d[x];
	else
	{
		if (v[x].empty()) return 0;
		else
		{
			for (int i=0;i<v[x].size();i++)
			    d[x]=max(d[x],work(v[x][i])+1);
            return d[x];
		}
	}
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		int x,y;
		cin >>x>>y;
		v[x-1].push_back(y-1);
	}
	int res=0;
	for (int i=0;i<n;i++)
	{
		res=max(res,work(i));
		//cout <<work(i)<<" "<<res<<"\n";
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 7552
#include<stdio.h>
#include<stdint.h>

int main(){

	int n, m, l, i, j, k;
	int64_t a[100][100], b[100][100], c[100][100] = {0};

	scanf("%d %d %d", &n, &m, &l);

	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			scanf("%ld", &a[i][j]);
		}
	}

	for(i = 0; i < m; i++){
		for(j = 0; j < l; j++){
			scanf("%ld", &b[i][j]);
		}
	}

	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			for(k = 0; k < m; k++){
				c[i][j] += (a[i][k] * b[k][j]);
			}
		}
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			printf("%ld", c[i][j]);
			if(j != l - 1){
				printf(" ");
			}
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 848
#include<bits/stdc++.h>
#define N 600
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
int read(){
	int l=1,x=0; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') l=-1; ch=getchar();}
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return x*l;
}
int dp[N+1][100005],qu[100005][10];
int main(){
	//freopen("1.txt","r",stdin);
	//freopen("2.txt","w",stdout);
	int n=read(),ans,x,y; x=n;
	while(x%2==0) x/=2; while(x%5==0) x/=5;
	if (x==1) printf("1\n"),exit(0);
	y=11%n;
	For(i,3,x*10){
		y=(y-1)*10+1; y=y%x;
		if (!y) printf("2\n"),exit(0);
	}
	memset(dp,127,sizeof(dp));
	For(j,0,n-1)
		For(k,0,9) qu[j][k]=(j*10+k)%n;
	For(i,1,9)
		For(j,0,9) x=i*10+j,dp[2][x%n]=min(dp[2][x%n],i+j);
	For(i,2,N-1){
		For(j,0,n-1)
			For(k,0,9) x=qu[j][k],dp[i+1][x]=min(dp[i+1][x],dp[i][j]+k);
		if (dp[i+1][0]==3) break;
	}
	ans=1e9;
	For(i,1,N) ans=min(ans,dp[i][0]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 238976
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll H,A;
	cin >> H >> A;
	cout << (H-1)/A+1;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-13;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int c[700];
long long f[700];
long long C[700][10];
int main(){
	long long a;scanf("%lld",&a);
	C[0][0]=1;
	for(int i=0;i<650;i++){
		for(int j=0;j<9;j++){
			C[i+1][j]+=C[i][j];
			C[i+1][j+1]+=C[i][j];
		}
	}
	for(int i=0;i<600;i++){
		f[i]=C[i+7][7];
	}
	for(int i=599;i>=0;i--){
		c[i]=a/f[i];
		a%=f[i];
	}
	for(int i=0;i<600;i++){
		printf("FESTIVA");
		for(int j=0;j<c[i];j++)printf("L");
	}
	printf("\n");
}

Measured memory_bytes: 256
n = int(input())
reds = list()
blues = list()
counter = 0

for i in range(n):
    reds.append(list(map(int,input().split())))
    
for i in range(n):
    blues.append(list(map(int,input().split())))
    
blues = sorted(blues,key=lambda x:x[0])
reds = sorted(reds,key=lambda x:x[1],reverse=True)

for blue in blues:
    for red in reds:
        if red[0] < blue[0] and red[1] < blue[1]:
            red[1] = 201
            counter += 1
            break
print(counter)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first 
#define S second 
#define inf INFINITY
#define file freopen( "input.txt" , "r" , stdin) ; freopen( "output.txt" , "w" , stdout) ; 
#define pb push_back
#define pf push_front  
#define mp make_pair
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define Rep(i,a,b) for ( int i = a ; i < b ; i++)
#define range(i,s) for ( auto i : s) 
#define sor(v) sort ( v.begin() , v.end()) ;
#define rev(v) reverse(v.begin() , v.end()) ; 
#define Gamed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define _3102_ main()
typedef long long ll ;
typedef unsigned long long ull ; 
typedef long double ld ; 
using namespace std ;
const int N = 1e5 + 100  ; 
const ll mod = 1e9 + 7  ;


ll n , tot_w  , ans[N][105];
pair<ll , ll > items[105] ;  
ll solve ( int w , int i ){
    if ( ans[w][i] != -1){
        return ans[w][i] ; 
    }
    if ( i == 0 ){
        return ans[w][i] = 0 ; 
    }
    if ( items[i].first > w){
        return ans[w][i] =solve ( w ,i - 1 ) ; 
    }
    else {
        return ans[w][i] = max(solve(w-items[i].first , i -1 ) + items[i].second, solve (w , i-1 )) ; 
    }
}

int _3102_ {
    Gamed
    cin >> n >> tot_w ;
    for ( int i = 1 ; i <= n ; i ++){
        cin >> items[i].first >> items[i].second ; 
    }    
    mem ( ans , -1) ; 
    cout << solve ( tot_w , n ) ;
    return 0 ;  
}


Measured memory_bytes: 82432
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
l1=[i for i in range(3) if B[i]>A[i]]
l2=[i for i in range(3) if B[i]<A[i]]
r=[B[i]-A[i] for i in range(3)]
def b(l):
    global N
    if len(l)==3:
        M=0
        for i in range(N//A[0]+1):
            for j in range((N-i*A[0])//A[1]+1):
                k=(N-i*A[0]-j*A[1])//A[2]
                M=max(M,i*B[0]+j*B[1]+k*B[2]+(N-i*A[0]-j*A[1]-k*A[2]))
        N=M
    elif len(l)==2:
        M=0
        for i in range(N//A[l[0]]+1):
            j=(N-i*A[l[0]])//A[l[1]]
            M=max(M,i*B[l[0]]+j*B[l[1]]+(N-i*A[l[0]]-j*A[l[1]]))
        N=M
    elif len(l)==1:
        i=N//A[l[0]]
        N=i*B[l[0]]+N-i*A[l[0]]
def b2(l):
    global N
    if len(l)==3:
        M=0
        for i in range(N//B[0]+1):
            for j in range((N-i*B[0])//B[1]+1):
                k=(N-i*B[0]-j*B[1])//B[2]
                M=max(M,i*A[0]+j*A[1]+k*A[2]+(N-i*B[0]-j*B[1]-k*B[2]))
        N=M
    elif len(l)==2:
        M=0
        for i in range(N//B[l[0]]+1):
            j=(N-i*B[l[0]])//B[l[1]]
            M=max(M,i*A[l[0]]+j*A[l[1]]+(N-i*B[l[0]]-j*B[l[1]]))
        N=M
    elif len(l)==1:
        i=N//B[l[0]]
        N=i*A[l[0]]+N-i*B[l[0]]
b(l1)
r=list(map(lambda x: -x,r))
b2(l2)
print(N)


Measured memory_bytes: 39408
s = gets.chomp.split('')
t = gets.chomp.split('')

if s.size < t.size
  flg = true
  _s = s.sort; _t = t.sort
  for i in 0..s.size-1 do
    flg = false unless _s[i] == _t[i]
  end
  if flg
    puts 'Yes'
    exit
  end
end

s.sort!; t.sort!; t.reverse!
flg2 = true
min = [s.size, t.size].min
for j in 0..min-1 do
  if s[j] == t[j]
    if j == min-1
      flg2 = false
    else
      next
    end
  elsif s[j] < t[j]
    break
  else
    flg2 = false
    break
  end
end

if flg2
  puts 'Yes'
else
  puts 'No'
end


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<int> vec(n,0);
    for(int i=1;i<n;++i)
    {
        int temp;
        cin>>temp;
        vec[temp-1]++;
    }

    for(int i=0;i<n;++i)
    {
        cout<<vec[i]<<" ";
    }
    cout<<"\n";
}


Measured memory_bytes: 3984
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a, b, c, d = map(int, input().split())
a -= 1

b_cnt1 = b // c

b_cnt2 = b // d

b_cnt3 = b // lcm(c, d)

a_cnt1 = a // c

a_cnt2 = a // d

a_cnt3 = a // lcm(c, d)

print(b - (b_cnt1 + b_cnt2 - b_cnt3) - (a - (a_cnt1 + a_cnt2 - a_cnt3)))

Measured memory_bytes: 5076
function Main(inputs) {
　const inputlines = inputs.split("\n");
　const firstline = inputlines[0].split(" ");
　const votevalues = inputlines[1].split(" ").map(x => parseInt(x, 10));
　const standard = 1 / (4 * firstline[1]);
　let yes = 0; 
  
　let totalvotes  = function(arr) {
　　　let sum = 0;
　　　arr.forEach(function(elm) {
　　　sum += elm;
    	　});
    	　return sum;
　};
  
　const currentstandard = totalvotes(votevalues) * standard;
  
　for (let i = 0; i < votevalues.length; i++){
　　if(votevalues[i] >= currentstandard){
　　　yes++;
　　　if(yes == firstline[1]){
　　　　console.log("Yes");
　　　　break;
　　　}
　　}
　}
　if(yes != firstline[1]){
　　console.log("No");
    }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29548
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N, K, S;
	cin >> N >> K >> S;

	for (ll i = 0; i < K; ++i)
	{
		cout << S << " ";
	}

	ll X = S+1;
	if (X > 1000000000)
	{
		X = X / 2;
		for (ll i = 0; i < N - K; ++i)
		{
			cout << X+i+1 << " ";
		}
	}
	else
	{
		for (ll i = 0; i < N - K; ++i)
		{
			cout << X << " ";
		}
	}

	cout << endl;

	//system("pause");
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;
typedef long long ll;

int main()
{
    double a;
    cin >> a;

    double b;
    cin >> b;

    double x;
    cin >> x;

    cout << fixed;
    cout << setprecision(10);


    if (x >= a * a * b / 2)
    {

        cout << atan(2 * (pow(a, 2) * b - x) / pow(a, 3) )* 180 / M_PI << endl;
    }
    else
    {
        cout << atan(a * b * b / (2 * x)) * 180 / M_PI << endl;
    }

    // ll answer = 1;

    // ll last = n;

    // for (ll i = 1; i < n; i++)
    // {
    //     if (i > last || i * i > n)
    //     {
    //         break;
    //     }

    //     if (n % i == 0)
    //     {
    //         if (i < n - i)
    //         {
    //             answer = (i - 1) + (n / i - 1);
    //             last = n / i;
    //         }
    //         else
    //         {
    //             break;
    //         }
    //     }
    // }

    // cout << answer << endl;

    // bool flg = false;

    // for (int i = 1; i <= 9; i++)
    // {
    //     if (n % i == 0)
    //     {
    //         if ((n / i) >= 1 && (n / i) <= 9)
    //         {
    //             flg = true;
    //             break;
    //         }
    //     }
    // }

    // if (!flg)
    // {
    //     cout << "No" << endl;
    // }
    // else
    // {
    //     cout << "Yes" << endl;
    // }

    // for (int i = 0; i < n; i++)
    // {
    //     cin >> a[i];
    // }

    // vector<ll> a;
    // for (int i = 0; i < n; i++)
    // {
    //     int j;
    //     cin >> j;
    //     a.push_back(j);
    // }

    //sort(a,a+n); ソート
}


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

int main(void)
{
  int a;
  int b;
  int t;
  int i;
  scanf("%d %d %d",&a,&b,&t);
  for(i=0;t>=0;i++){
    t=t-a;;
  }
  printf("%d\n",b*(i-1));
}


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

int main() {
    constexpr int mod = 1e9 + 7;
    
    string S;
    cin >> S;
    
    vector<vector<int>> dp(S.size() + 1, vector<int>(13, 0));
    dp[0][0] = 1;
    rep(i, S.size()) {
        if (S[i] == '?') {
            rep(n, 10) rep(j, 13) {
                dp[i + 1][(j * 10 + n) % 13] += dp[i][j];
                dp[i + 1][(j * 10 + n) % 13] %= mod;
            }
        } else {
            int n = S[i] - '0';
            rep(j, 13) {
                dp[i + 1][(j * 10 + n) % 13] += dp[i][j];
                dp[i + 1][(j * 10 + n) % 13] %= mod;
            }
        }
    }
    cout << dp[S.size()][5] << endl;
    return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    long long n,m,answer;
    cin>>n>>m;
    /*for(long long i=1;i*n<=m;i++){
        if((m%(n*i))%i==0){
            answer=i;
        }
    }*/
    for (long long i = m/n; i >=1; i--)
    {
        if ((m % (n * i)) % i == 0)
        {
            answer = i;
            break;
        }
    }
    cout<<answer;
    return 0;
}


Measured memory_bytes: 256
import sys
from itertools import combinations
import math


def I(): return float(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


r = I()

print('{:.6f}'.format(r*r*math.pi), '{:.6f}'.format(r*2*math.pi))



Measured memory_bytes: 5672
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main(int argc, char const *argv[]) {
  int a, b;
  cin >> a >> b;
  cout << gcd(a, b) << endl;
  return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;


int main() {
    
    int n, k;
    cin >> n;
    cin >> k;
    
    map<int, int> a;
    for (int i = 0; i < n; ++i)
    {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    
    vector<int> num;
    for (auto itr = a.begin(); itr != a.end(); ++itr)
    {
        num.push_back(itr->second);
    }
    
    sort(num.begin(), num.end());
    
    int val = a.size() - k;
    
    int ret = 0;
    for (int i = 0; i < val; ++i)
    {
        ret += num[i];
    }
    
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 10748
#include <stdio.h>
int main(void){
    // Your code here!

    int H,W;
    int flag_row=0;
    
    while(1){
      flag_row=0;
      scanf("%d %d",&H,&W);
      if((H+W)==0)break;
      
      for(int j=0; j<(H); j++){
        for(int i=0; i<(W); i++){
          if( (i%2)==flag_row )printf("#");
          else printf(".");
        }
        printf("\n");
        flag_row = 1 - flag_row;
      }
      
      printf("\n");
    }
    
}





Measured memory_bytes: 1992
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
#define INF 1000000000000000007ll
using namespace __gnu_pbds;
using namespace std;

int n,dp[5010][5010];
pair<int,int> a[5010];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		int h,p;
		cin>>h>>p;
		a[i].first=h+p;
		a[i].second=h;
	}
	sort(a+1,a+n+1);
	for(int i=0;i<=n;i++){
		for(int j=1;j<=n;j++){
			dp[i][j]=INF;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dp[i][j]=min(dp[i][j],dp[i-1][j]);
			if(a[i].second>=dp[i-1][j-1]) dp[i][j]=min(dp[i][j],dp[i-1][j-1]+a[i].first-a[i].second);
		}
	}
	for(int i=n;i>=0;i--){
		if(dp[n][i]<INF){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

int dp[41][1 << 16] = { { 1 } };
signed main() {
	const int mod = 1e9 + 7;
	int n, x, y, z;
	cin >> n >> x >> y >> z;
	vector<int> ok(2);
	vector<int> xs(17);
	int mask = (1 << (x + y + z - 1)) - 1;
	int dest = ((1 << x | 1) << y | 1) << z - 1;
	rep(i, n) rep(b, mask + 1) if (dp[i][b]) {
		ok[0] = ok[1] = false;
		rep(k, 10) {
			int nb = ((b << k + 1) | (1 << k)) & (1 << x + y + z) - 1;
			if ((nb & dest) != dest) {
				(dp[i + 1][nb & mask] += dp[i][b]) %= mod;
			}
		}
	}
	int ans = 0;
	rep(i, mask + 1) (ans += dp[n][i]) %= mod;
	int p = 1;
	rep(i, n) {
		p = p * 10 % mod;
	}
	cout << (p + mod - ans) % mod << endl;
	system("pause");
}

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


#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    ll           long long
const ll N = 10e5+1;



void fio()
{
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
}



ll h[N];

// ll frog(ll start,ll end){
// 	if(start>=end)
// 		return 1000000;
// 	else if(start+1==end || start+2==end)
// 		return abs(h[start]-h[end]);

//     else if(dp[start][end]!=-1)
//     	return dp[start][end];

//     else return min( abs(h[start] - h[start+1]) +frog(start+1, end) , abs(h[start] - h[start+2])+ frog(start+2,end) );
// }


int main()
{
    boost;
    fio();
    ll t = 1;
    // cin >> t;
    while (t--) {
     	ll n;
     	cin>>n;
     	
     	for(ll i=0;i<n;i++)
     		cin>>h[i];
     	// memset(dp, -1, sizeof(dp));

     	// cout<<frog(0,n-1);
     	vector <int> minimum_cost(n+1);
     	minimum_cost[0]=0;
     	minimum_cost[1] = abs(h[0] - h[1]);
  		for(int i = 2; i < n; i++)
        minimum_cost[i] = min(minimum_cost[i - 1] + abs(h[i] - h[i - 1]),
                              minimum_cost[i - 2] + abs(h[i] - h[i - 2]));


    	cout << minimum_cost[n-1];
    	return 0;



      }
    // cout<<"\nDone!";
    return 0;
}

Measured memory_bytes: 4480
fn read_number() -> Result<usize, String> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let n = line.trim().parse::<usize>().map_err(|err| err.to_string())?;
    Ok(n)
}

fn read_number_each_line(n: usize) -> Result<Vec<i32>, String> {
    (0..n)
        .map(|_| read_number().map(|x| x as i32))
        .collect::<Result<Vec<_>, _>>()
}

fn read_numbers() -> Result<Vec<i32>, String> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let numbers = line.split_whitespace()
        .map(|x| x.parse::<i32>().map_err(|err| err.to_string()))
        .collect::<Result<Vec<_>, _>>();
    numbers
}

fn generate_adjacency(inputs: Vec<Vec<i32>>) -> () {
    let n_nodes = inputs.len();
    let mut matrix = vec![vec![0; n_nodes]; n_nodes];

    for line in inputs {
        // println!("{:?}", line);
        let i_node = line[0];
        let n_out = line[1];

        for i_out in 0..n_out {
            // println!("{} {}", (i_node - 1) as usize, (i_out - 1) as usize);
            matrix[(i_node - 1) as usize][(line[2 + i_out as usize] - 1) as usize] = 1;
        }
    }

    for row in matrix {
        for (i_col, e) in row.iter().enumerate() {
            print!("{}", e);
            if i_col < row.len() - 1 {
                print!(" ");
            }
        }
        println!("");
    }
}

fn main() {
    let n = match read_number() {
        Ok(num) => num,
        Err(err) => panic!("{:?}", err),
    };

    let numbers = (0..n)
        .map(|_i| read_numbers())
        .collect::<Result<Vec<Vec<i32>>, String>>();

    match numbers {
        Ok(x) => generate_adjacency(x),
        Err(err) => panic!("{:?}", err),
    }
}



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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, P;
int a[60];
ll dp[60][2];

int main() {
	cin >> N >> P;
	rep(i, N) cin >> a[i];

	dp[0][0] = 1;
	rep(i, N) {
		rep(j, 2) {
			dp[i+1][j] += dp[i][j];
			dp[i+1][(j+a[i])%2] += dp[i][j];
		}
	}

	cout << dp[N][P] << endl;

	return 0;
}

Measured memory_bytes: 256
/**
 *	@file: C.cpp
 *	@author: Huy Le
 *	@created: 2020-08-29 19:25
**/

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

#define ll long long
#define ld long double
#define sz(x) (int)(x).size()
const char newl = '\n';

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << argc;
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

int ts;
int n;
const ll MOD = 1e9+7;
const int mxN = 2e5+5;
ll a[mxN];
ll dp[mxN];

void solve() {
    cin >> n;
    ll sum = 0;

    for(int i=0; i<n; ++i) {
        cin >> a[i];
        sum += a[i]%MOD;
        dp[i] = sum %MOD;
    }
    ll ans = 0;
    for(int i=n-1; i>=0; --i) {
        ans += a[i] * dp[i-1] %MOD;
        ans %= MOD;
    }
    cout << ans << newl;
}

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

		//++i,cout << "Case #" << i << ": ",
		solve();
}


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

namespace ConsoleApplication1 {
    class Program {
        static void Main(string[] args) {
           // 111回
            int n =int.Parse( Console.ReadLine());
            con111 Con111 = new con111();
            Console.WriteLine(Con111.ncount(n));
        }
    }
  class con111 {
        public int ncount(int n) {
            double temp = n / 100;
            int f = (int)Math.Floor(temp);
            if (f* 111< n) {
                return (f + 1) * 111;
            }
            else {
                return f * 111;
            }

        } 
    }
}

Measured memory_bytes: 11092