akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int n;
	cin >> n;
	dump(n * (n + 1)/2 )
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main(){
    string s;
    cin >> s;
    int n=s.length();
    int ama[2019]={};
  	ama[0]++;
    ll ans=0;
    ll now=0;
    rep(i,n){
        now=now*10+(s[i]-'0');
        now%=2019;
        ans+=ama[now];
      	debug(ans);
        ama[now]++;
        int nama[2019]={};
        rep(j,2019){
            nama[(j*10)%2019]+=ama[j];
        }
        rep(j,2019)ama[j]=nama[j];
    }
    cout << ans;


}

/*



 */



Measured memory_bytes: 3736
// AOJ 2161 Defend the Bases
// 2018.3.9 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define MAX 210
int  hi[MAX], to[MAX][MAX];
char seen[MAX];
int  match[MAX];

int bpm(int u);
int bipartiteMatching(int m, int n, int V)
{
	int u, max;

	memset(match, -1, V*sizeof(int));
	max = 0;
	for (u = 0; u < m; u++) {
		memset(seen, 0, V);
		if (bpm(u)) max++;
	}
	return max;
}

int bpm(int u)
{
	int i, v;

	for (i = 0; i < hi[u]; i++) {
		v = to[u][i];
		if (seen[v]) continue;
		seen[v] = 1;
		if (match[v] < 0 || bpm(match[v])) {
			match[u] = v, match[v] = u;
			return 1;
		}
	}
	return 0;
}

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

#define LIM 60
#define EPS 1e-8

typedef struct { int from, to; double tm; } EDGE;
EDGE edge[10010], *tail;
typedef struct { int x, y, v; } TROOP;
TROOP troop[102];
typedef struct { int x, y; } BASE;
BASE  base[102];
int   N, M, V;

double dist(int t, int b) {	return hypot(troop[t].x-base[b].x, troop[t].y-base[b].y); }

int check(double tm)
{
	EDGE *e;

	memset(hi, 0, V << 2);
	for (e = edge; e < tail && e->tm < tm+EPS; e++) to[e->from][hi[e->from]++] = e->to;
	return bipartiteMatching(N, M, V) == M;
}

int cmp(EDGE *a, EDGE *b) {
	if (fabs(a->tm - b->tm) < EPS) return 0;
	if (a->tm <= b->tm) return -1;
	return 1;
}

int main()
{
	int i, j, lim;
	double lb, ub, md;
	EDGE *e;

	while (N = in()) {
		M = in(), V = N+M;
		for (i = 0; i < N; i++) troop[i].x = in(), troop[i].y = in(), troop[i].v = in();
		for (i = 0; i < M; i++) base[i].x = in(), base[i].y = in();

		e = edge; for (i = 0; i < N; i++) for (j = 0; j < M; j++) {
			e->from = i, e->to = N+j, e->tm = dist(i, j) / troop[i].v, e++;
		}
		tail = e;
		qsort(edge, tail-edge, sizeof(EDGE), cmp);

		lb = 0, ub = 15000;
		lim = LIM; while (lim--) {
			md = 0.5*(lb+ub);
			if (check(md)) ub = md; else lb = md;
		}
		printf("%.20lf\n", ub);
	}
	return 0;
}


Measured memory_bytes: 2152
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

int main(){
    int n;
    cin >> n;
    rep(i, 3){
        if(n % 10 == 7){
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }
    cout << "No" << endl;
}

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

map <int, bool> mp;

int main() {
 int n, a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (mp[a])
    	return cout << "NO" << '\n', 0;
 	mp[a] = true;
  }
  cout << "YES" << '\n';
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define ll long long
const int N=1e4+5;
ll a[N],b[N];
signed main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)scanf("%lld",&b[i]);
    ll s1=0,s2=0;
    for (int i=1;i<=n;i++){
        if(a[i]>b[i])s1+=a[i]-b[i];
        if(a[i]<b[i])s2+=(b[i]-a[i])>>1;}
    puts(s1<=s2?"Yes":"No");
    return 0;
}

Measured memory_bytes: 384
from itertools import combinations
N, A, B = [int(n) for n in input().split()]
v = [int(n) for n in input().split()]

v.sort(reverse=True)
s = sum(v[:A])
avg = s/A

print(s/A)

fac = [1]

for i in range(1, N+1):
  fac.append(fac[i-1]*i)


def C(n, k):
  return fac[n]//(fac[k] * fac[n-k])


if v[0] != v[A-1]:
  cnt_a_1 = len([t for t in v if t == v[A-1]])
  cnt_a_1_in = len([t for t in v[:A] if t == v[A-1]])
  print(C(cnt_a_1, cnt_a_1_in))
if v[0] == v[A-1]:
  cnt_a_1 = len([t for t in v if t == v[A-1]])
  res = 0
  for i in range(A, B+1):
    res += C(cnt_a_1, i)
  print(res)

Measured memory_bytes: 3064
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

num = int(input())
maxnum = num
l = prime_factorize(num)
if(num == 1):
    print(0)
elif(len(l)==0):
    print(1)
else:
    cnt = 0
    list=list(dict.fromkeys(l))
    for i in list:
        for n in range(maxnum):
            if(num%(i**(n+1))==0):
                num = num/(i**(n+1))
                cnt += 1
            else:
                break
    print(cnt)


Measured memory_bytes: 9276
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, M, K;
  cin >> N >> M >> K;

  if (N * M < K) {
    cout << "No" << endl;
    return 0;
  }

  REP(n, 0, N + 1) {
    REP(m, 0, M + 1) {
      ll k = n * (M - m) + m * (N - n);
      if (k == K) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import collections
N = int(input())
A = list(map(int,input().split()))
B = collections.Counter(A)
C = [0]*N
for i in B.keys():
  C[i-1]=(i,B[i])
#print(C)
a = 0
for j in range(len(C)):
  try:
    print(C[j][1])
  except:
    print(0)
  a += 1
for l in range(N-a):
  print(0)




Measured memory_bytes: 43072
using System;
 
class Program
{
    static void Main()
    {
        int ans = 0;
        // Loop
        while (true)
        {
            // Input
            var input = Console.ReadLine();
            var values = input.Split(' ');
            int a = int.Parse(values[0]);
            int b = int.Parse(values[2]);
            string op = values[1];
 
            if (op == "+")
            {
                ans = a + b;
            }
            else if (op == "-")
            {
                ans = a - b;
            }
            else if (op == "*")
            {
                ans = a * b;
            }
            else if (op == "/")
            {
                ans = a / b;
            }
            else if (op == "?")
            {
                // Loop end.
                break;
            }
            else
            {
                continue;
            }
            // Output
            Console.WriteLine("{0}", ans);
        }
    }
}

Measured memory_bytes: 9160
#include <iostream>

int main(){
    int N ;
    bool check = false;
    std::cin >> N;

    do{
        if(N % 2 == 0){
            check = true;
            break;
        }
        N += N;
    }while(check != true);

    std::cout << N << std::endl;
    
    return 0;
    
}


Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")
;(input => {
    const rows = input.split('\n')
    const [N, M, Q] = rows[0].split(' ').map(Number)
    const A = []
    for (let i = 0; i < Q; i++) {
        A[i] = rows[i + 1].split(' ').map(Number)
    }

    const ss = []
    const s = []
    let d = 0
    let v = 0
    while (v !== undefined) {
        if (d === N) {
            ss.push([...s])
            s.pop()
            v++
            d--
        } else if (v >= M) {
            v = s.pop()
            d--
        } else {
            s.push(v + 1)
            d++
        }
    }

    let res = 0
    ss.forEach(s => {
        let sum = 0
        A.forEach(a => {
            if (s[a[1] - 1] - s[a[0] - 1] === a[2]) {
                sum += a[3]
            }
        })
        res = Math.max(res, sum)
    })

    console.log(res)

})(input)


Measured memory_bytes: 50796
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define LONGMAX 1e18
#define dd double
#define MOD 998244353 
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define endl "\n"
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define INF 1e9
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll power(ll x, ll y){ll res=1;x=x%MOD;while(y>0){if(y&1)res = (res*x) % MOD;y = y>>1;x = (x*x) % MOD;}return res;}  
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){if(low>high)return;ll mid=(low+high)/2;if(ar[mid]>=x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
signed main()
{
	fastio();
  	vector<vector<string>> v;
  	vector<string> t;
  	t.pb("a");
  	v.pb(t);
  	for(ll i=1;i<10;i++)
  	{
  		vector<string> temp;
  		for(ll j=0;j<v[i-1].size();j++)
  		{
  			string h=v[i-1][j];
  			char c='a';
  			for(ll k=0;k<h.size();k++)
  				if(h[k]>c)
  					c=h[k];
  			for(ll k=97;k<=(int)c+1;k++)
  			{
  				temp.pb(h+(char)(k));
  			}
  		}
  		sort(all(temp));
  		v.pb(temp);
  	}
  	ll N;
  	cin>>N;
  	for(ll i=0;i<v[N-1].size();i++)
  	{
  		cout<<v[N-1][i]<<endl;
  	}
}

Measured memory_bytes: 11460
#include <cstdio>

int main()
{
    int N, D, X, ans;
    int A[110];

    scanf("%d %d %d", &N, &D, &X);

    ans = 0;

    for (int i = 0; i < N; i++)
    {
        scanf(" %d", &A[i]);

        ans += (D - 1) / A[i] + 1;
    }

    ans += X;

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
#define MOD 1e9 + 7
#define N 1e5 + 10
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll i=0;
	ll l[n+1],r[n+1];
	ll a[n+1];
	a[0]=0;
	l[0]=0;
	
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		l[i+1]=__gcd(l[i],a[i]);
	//	cout<<l[i]<<" ";
	}//cout<<endl;
	r[n]=0;
	for(i=n-1;i>=0;i--)
	{
		r[i]=__gcd(r[i+1],a[i]);
	//	cout<<r[i]<<" ";
	}
	ll x=0,max=0;
	for(i=0;i<=n-1;i++)
	{
		x=__gcd(l[i],r[i+1]);
		if(x>max)
		{
			max=x;
		}
	}
	cout<<max;
}	

Measured memory_bytes: 2560
#include <vector>
#include <iostream>
 
using namespace std;
 
int main()
{
	int A, B, K;
	cin >> A >> B >> K;
	vector<int> tmp;
	for (int i = 100; i >= 1; --i) {
		if (A%i == 0 && B%i == 0) {
			tmp.push_back(i);
		}
	}
	cout << tmp[K - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

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

		String ans = "";
		if (n < 1000) {
			ans = "ABC";
		} else {
			ans = "ABD";
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 21716
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
  string s;
  cin >> s;
  int mi = 1000000;
  for (int i = 0; i < s.length() - 2; i++)
  {
    string st = s.substr(i, 3);
    int num = abs(753 - atoi(st.c_str()));
    mi = min(mi, num);
  }
  cout << mi << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if( b-a == c-b){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 24148
#include<cstdio>
#include<cstring>
#include<vector>
#include<set>
#include<map>
using namespace std;
int a,b;
int main(void)
{
    int a,b;
    while(~scanf("%d%d",&a,&b))
    {
        if(a%3==0||b%3==0||(a+b)%3==0)
            printf("Possible\n");
        else
            printf("Impossible\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
     
    using namespace std;
     
    int main()
    {
    	int H,h,W,w;
    	cin>>H>>W;
      	cin>>h>>w;
     
    	H = H-h;
    	W = W-w;
    	int prod=0;
    	prod = H*W;
    	cout<<prod;
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void prime_factorize(ll n, vector<ll> &ans) {
    while (n % 2 == 0) {
        ans.push_back(2);
        n /= 2;
    }
    ll sqn = sqrt(n);
    for (ll i = 3; i <= n; i++) {
        if (i > sqn) {
            ans.push_back(n);
            break;
        }
        while (n % i == 0) {
            ans.push_back(i);
            n /= i;
        }
    }
}

ll n;

int main() {
    cin >> n;
    vector<ll> pf;
    prime_factorize(n, pf);
    sort(all(pf));
    ll ans = 0;
    vector<pair<ll, ll>> pfN;
    rep(i, pf.size()) {
        pfN.push_back(make_pair(pf[i], upper_bound(all(pf), pf[i]) - lower_bound(all(pf), pf[i])));
        i += pfN.back().second - 1;
    }
    rep(i, pfN.size()) {
        ll s = pfN[i].second;
        reps(j, pfN[i].second) {
            if (s >= j) {
                ans += 1;
                s -= j;
            } else {
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(in);
		int N = parseInt(sc.next());
		int T = parseInt(sc.next());
		int[] t = new int[N];
		t[0] = parseInt(sc.next());
		int td=0;
		int x=0;
		for(i=1; i<N; i++) {
			t[i] = parseInt(sc.next());
			td = t[i]-t[i-1];
			x += td<T?td:T;
		}
		sc.close();
		x+=T;
		out.println(x);
	}
}


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

using namespace std;

typedef long long ll;

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

    int n, m;
    cin >> n >> m;
    priority_queue <int> pq;

    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        pq.push(x);
    }

    for (int i = 1; i <= m; i++)
    {
        int x = pq.top() / 2;
        pq.pop();
        pq.push(x);
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << "\n";

}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int read();
int n, top;
struct P {
    int v, p, t;
} p[200005];
bool cmp(P a, P b) { return a.v < b.v; }
int sum[2], vis[200005], flg;
int main() {
    n = read();
    for (int i = 1; i <= n; ++i)
        p[++top] = (P){read(), i, 0}, p[++top] = (P){read(), i, 1};
    sort(p + 1, p + 1 + top, cmp);
    long long res = 0;
    for (int i = 1; i <= n; ++i)
        sum[p[i].t]++, res += p[i].v, flg |= (++vis[p[i].p] > 1);
    if (flg || max(sum[0], sum[1]) == n) return printf("%lld\n", res), 0;
    res += p[n + 1].v - p[n].v, sum[p[n].t]--, sum[p[n + 1].t]++;
    if (p[n].p != p[n + 1].p || max(sum[0], sum[1]) == n)
        return printf("%lld\n", res), 0;
    printf("%lld\n", res + min(p[n + 2].v - p[n + 1].v, p[n].v - p[n - 1].v));
    return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
#define gc                                                         \
    (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)), \
     (iS == iT ? EOF : *iS++) : *iS++)
int read() {
    int x = 0, f = 1;
    char c = gc;
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = gc;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc;
    return x * f;
}

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

int main(void){

    int n, m; cin >> n >> m;
    int a = (n-m)*100 + m*1900;
    int r = 1;
    for(int i  = 0; i < m; i++){
        r = r*2;
    }

    cout << (int)a*r << endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;

const int N = 2e5 + 5;
const ll mod = 1e9 + 7;

vector < ll > fact(N);

ll pwr(ll a, ll b){
  ll res = 1;
  while(b > 0){
    if(b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}

ll inv(ll a){
  return pwr(a, mod - 2);
}

ll comb(int n, int r){
  return (((fact[n] * inv(fact[r])) % mod) * inv(fact[n - r])) % mod;
}

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

  fact[0] = 1;
  for(int i = 1; i < N; i++) fact[i] = (i * fact[i - 1]) % mod;

  int h, w, a, b;
  cin >> h >> w >> a >> b;

  ll ans = 0;
  for(int x = 1; x <= h - a; x++){
    ans = (ans + ((comb(b + x - 2, x - 1) * comb(w - b + h - x - 1, h - x)) % mod)) % mod;
  }

  cout << ans << '\n';
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 unordered_map<string,int> mp;
  int n;
  cin >> n;
  for(int i = 0; i<n;i++){
    string st;
    cin >> st;
    mp[st] = 1;
  }
  cout << mp.size() << endl;
}

Measured memory_bytes: 17756
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int[] c = new int[26];
		for(int i = 0; i < 26; i++) {
			c[i] = sc.nextInt();
		}
		int[][] s = new int[d][26];
		for(int i = 0; i < d; i++) {
			for(int j = 0; j < 26; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		int[] lastDay = new int[26];
		for(int i = 0; i < 26; i++) {
			lastDay[i] = 0;
		}
		long result = 0;
		for(int i = 1; i <= d; i++) {
			long max = 0;
			int check = 0;
			for(int j = 0; j < 26; j++) {
				long temp = 0;
				temp += s[i-1][j];
				for(int k = 0; k < 26; k++) {
					if(k != j) {
						temp -= c[k]*(i-lastDay[k]);
					}
				}
				if(max < temp) {
					max = temp;
					check = j;
				}
			}
			lastDay[check] = i;
			System.out.println(check+1);
		}
	}
}


Measured memory_bytes: 46328
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(s) ((int)((s).size()))
 
typedef long long ll;
 
const ll mod = 1000000007;
const double pi = 3.1415926535897932384626;
 
ll powmod(ll a, ll b) {ll res = 1; ll rem = a % mod; for (; b; b >>= 1) {if (b & 1) res = (res * rem) % mod; rem = (rem * rem) % mod;} return res;}
 
const int N = 58;
 
int X[N];
int Y[N];
pair<int, int> A[N];
 
int main()
{
/*	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
*/
    
	int n = 0;
	int p = 0;
	scanf("%d %d", &n, &p);
 
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d", X + i, Y + i);
		A[i] = mp(X[i], Y[i]);
	}
 
	sort(X + 1, X + 1 + n);
	sort(Y + 1, Y + 1 + n);
 
	ll ans = 4e18;
 
	for (int i = 1; i < n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			for (int k = 1; k < n; ++k) {
				for (int l = k + 1; l <= n; ++l) {
					ll lx = (ll) X[i];
					ll rx = (ll) X[j];
					ll ly = (ll) Y[k];
					ll ry = (ll) Y[l];
					ll tmp = 1ll * (rx - lx) * (ry - ly);
					int c = 0;
					for (int m = 1; m <= n; ++m) {
						if (A[m].fi >= lx && A[m].fi <= rx && A[m].se >= ly && A[m].se <= ry) ++c;
					}
					if (c >= p) {
						ans = min(ans, tmp);
					}
				}
			}
		}
	}
 
	printf("%lld\n", ans);
 
	return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int main()
{
  unordered_set<string> s_set;
  int n, ans = 0;
  string s;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> s;
    if (!s_set.count(s))
    {
      s_set.insert(s);
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 17776
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int MAX_N = 100100;
template<typename Type> struct UnionFind
{
    vector<Type> p, r;
    UnionFind(int sz)
    {
        p.resize(sz);
        r.resize(sz, -1);
        for(int i = 0; i < sz; i++) p[i] = i;
    }
    Type Find(Type x)
    {
        if (x == p[x]) return x;
        return p[x] = Find(p[x]);
    }
    bool isSame(Type a, Type b) { return Find(a) == Find(b); }
    void unite(Type a, Type b)
    {
        a = Find(a), b = Find(b);
        if(a == b) return;
        if(r[a] < r[b]) p[a] = b;
        else { p[b] = a; if(r[a] == r[b]) r[a]++; }
    }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    UnionFind<int> UF(n + 1);
    for(int i = 0; i < m; i++)
    {
        int s, t; cin >> s >> t;
        if(UF.isSame(s, t)) continue;
        UF.unite(s, t);
    }
    int q; cin >> q;
    for(int i = 0; i < q; i++)
    {
        int s, t; cin >> s >> t;
        cout << (UF.isSame(s, t) ? "yes" : "no") << "\n";
    }
    return 0;
}



Measured memory_bytes: 3616
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

import numpy as np
import bisect

ra=[0]+list(np.cumsum(a))
rb=[0]+list(np.cumsum(b))

ans=0
for i in range(n+1):    
    capa = k - ra[i]
    if capa<0:
        break
    j=bisect.bisect_right(rb,capa)


    ans=max(ans,i-1+j)
            
print(ans)    

Measured memory_bytes: 60252
#include <bits/stdc++.h>
using namespace std;
signed main(){
  long long n,m,a[100],b[100],c[100],d[100],e,f=100000000,g,x,y;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
   
  }
  for(int i=0;i<m;i++){
    cin>>c[i]>>d[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      x=(a[i]-c[j]);
      y=(b[i]-d[j]);
      if(x<0)
	x*=-1;
      if(y<0)
	y*=-1;
      e=x+y;
      if(e<f){
	f=e;
	g=j;
      }
    }
    cout<<g+1<<endl;
    f=1000000000;
    e=0;
    g=0;
  }
      return(0);
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stack>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
const ll inf =1e17;
#define scn(a) scanf("%d",&a)
#define scd(a) scanf("%lf",&a)
#define scl(a) scanf("%lld",&a)
#define ptf(a) printf("%d\n",&a)
#define mes(a,b) memset(a,b,sizeof(a))
#define fon(s,n) for(int i=s;i<=n;i++)
#define range(i,a,b) for(int i=a;i<=b;++i)
#define rerange(i,a,b) for(int i=a;i>=b;--i)
//#define N 100010
const int S=20;
int gcd(int a,int b) { return b>0 ? gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll q_pow(ll a,ll b,ll mod)
{
	ll ans=1,res=a;
	while(b){
		if(b&1) ans=ans*res%mod;
		res=res*res%mod;
		b>>=1;
	}
	return ans%mod;
}


int main(){
	int n;
	ll sum = 0;
	cin >> n;
	for(int i=1;i<=n;i++){
		if(i%3==0||i%5==0)continue;
		sum += i;
	}	
	printf("%lld\n",sum);
    return 0;
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/

ll gcd(ll a,ll b){
  while(b!=0){
    ll tmp=a;a=b;b=tmp%b;
  }
  return a;
}

int main()
{
  ll k;cin>>k;
  ll ans=0;
  for(ll a=1;a<=k;a++){
    for(ll b=1;b<=k;b++){
      for(ll c=1;c<=k;c++){
        ans+=gcd(gcd(a,b),c);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

int main(){
  ll N, x;
  scanf("%lld %lld\n", &N, &x);

  VL v(N);
  REP(i, 0, N){
    scanf("%lld ", &v[i]);
  }

  ll lb = 0, ub = pow(10, 18) + 2;
  while(ub - lb > 1){
    VL seq = v;
    ll used = 0;
    ll mid = (lb + ub) / 2;
    //printf("lb: %lld, ub: %lld\n", lb, ub);
    //printf("mid: %lld\n", mid);

    REP(i, 0, N-1){
      //printf("seq[%d], seq[%d]: %lld + %lld = %lld\n", i, i+1, seq[i], seq[i+1], seq[i] + seq[i+1]);
      if(seq[i] + seq[i+1] > x){
        int sub = (seq[i] + seq[i+1]) - x;
        used += sub;
        if(seq[i+1] >= sub){
          seq[i+1] -= sub;
        } else {
          sub -= seq[i+1];
          seq[i+1] = 0;
          seq[i] -= sub;
        }
      }
    }
    if(used >= mid){
      lb = mid;
    } else {
      ub = mid;
    }
    //printf("used: %lld\n", used);
    //printf("lb: %lld, ub: %lld\n\n", lb, ub);
  }
  printf("%lld\n", lb);

  return 0;
}


Measured memory_bytes: 1804
#include <iostream>
using namespace std;
int main() {
  string s;
  long long cnt[30] = {0}, sum = 0;
  cin >> s;
  for(char c: s)
    ++cnt[c - 'a'];
  for(int i = 0; i < 30; ++i)
    sum += (cnt[i] * (cnt[i] + 1)) / 2;
  cout << 1 + (s.size() * (s.size() + 1)) / 2 - sum << endl;
}

Measured memory_bytes: 640
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int32_t A, B, M;
  cin >> A >> B >> M;
  vector<int32_t> a(A);
  vector<int32_t> b(B);
  int32_t min_price = INT32_MAX;
  for (int32_t i = 0; i < A; ++i) {
    cin >> a[i];
  }
  for (int32_t i = 0; i < B; ++i) {
    cin >> b[i];
  }
  for (int32_t i = 0; i < M; ++i) {
    int32_t x, y, c;
    cin >> x >> y >> c;
    const int32_t c_price = a[x - 1] + b[y - 1] - c;
    if (c_price < min_price) {
      min_price = c_price;
    }
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a[0] + b[0] < min_price) {
    min_price = a[0] + b[0];
  }
  cout << min_price << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String t = scn.next();
		int f = Integer.valueOf(t.substring(0, 2));
		int e = Integer.valueOf(t.substring(2, 4));
		if(f<=12&&f!=0) {
			if(e<=12&&e!=0) {
				System.out.println("AMBIGUOUS");
			}else {
				System.out.println("MMYY");
			}
		}else {
			if(e<=12&&e!=0) {
				System.out.println("YYMM");
			}else {
				System.out.println("NA");
			}
		}
		scn.close();
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int INF = 100000000;
int d[10], graph[10][10];
bool visited[10];

int bfs(int v){
    for(int i=0; i<10; i++) d[i] = INF;
    queue<int> q;
    q.push(v);
    d[v] = 0;

    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int i=0; i<10; i++){
            if(d[u] + graph[u][i] < d[i]){
                d[i] = d[u] + graph[u][i];
                q.push(i);
            }
        }
    }

    return d[1];

}

int main(){
    int H, W; cin >> H >> W;
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin >> graph[i][j];
        }
    }
    

    int cnt[10];
    for(int i=0; i<10; i++) cnt[i] = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int a; cin >> a;
            if(a != -1) cnt[a]++;
        }
    }

    ll ans = 0;
    bfs(1);

    for(int i=0; i<10; i++) ans += cnt[i]*bfs(i);
    //for(int i=0; i<10; i++) cout << d[i] << "|";

    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
dij = [(1, 0), (-1, 0), (0, 1), (0, -1)]

def main():
    n=II()
    aa=LI()

    l=[0]*3*n
    s=sum(aa[:n])
    hp=aa[:n]
    heapify(hp)
    for i,a in enumerate(aa[n:2*n+1],n):
        l[i]=s
        s+=a
        a=heappushpop(hp,a)
        s-=a

    r=[0]*3*n
    s=0
    hp=[]
    for a in aa[2*n:]:
        s+=a
        heappush(hp,-a)
    for i in range(2*n-1,n-2,-1):
        a=aa[i]
        r[i+1]=s
        s+=a
        a=-heappushpop(hp,-a)
        s-=a
    ans=max(l[i]-r[i] for i in range(n,2*n+1))
    print(ans)

main()


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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a%3 == 0)||(b%3 == 0)||((a+b)%3 == 0)) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int x=0,l=0,i=0,k=0,j=0,w=1,f=0,o=0;
    char s[250]={0},ss[250]={0},p[100]={0},er;
    scanf("%s",&s);
    strcpy(ss,s);
    strcat(s,ss);
    scanf("%s",&p);
    if((er=strstr(s,p))!=NULL){
        printf("Yes\n");
    }else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 540
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] A = sc.next().toCharArray();
		char[] B = sc.next().toCharArray();
		char[] C = sc.next().toCharArray();
		char t = A[0];
		int a = 1; int b = 0; int c = 0;
		String res = "";
		while(true) {
			if (t == 'a') {
				if (a == A.length) {
					res = "A";
					break;
				} else {
					t = A[a];
					a++;
				}
			}else if (t == 'b') {
				if (b == B.length) {
					res = "B";
					break;
				} else {
					t = B[b];
					b++;
				}
			}else if (t == 'c') {
				if (c == C.length) {
					res = "C";
					break;
				} else {
					t = C[c];
					c++;
				}
			}
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N, X := ReadInt(), ReadInt()
	x := ReadInts(N)
	x = append(x, X)
	sort.Ints(x)
	ans := x[1] - x[0]
	for i := 1; i < len(x)-1; i++ {
		ans = GCD(ans, x[i+1]-x[i])
	}
	fmt.Println(ans)
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 5308
#include <iostream>
#include <vector>

int main() {
  unsigned int n;
  std::cin >> n;

  double sum = 0.0;
  for (size_t i = 0; i < n; ++i) {
    double x;
    std::string u;
    std::cin >> x >> u;
    if (u == "JPY") {
      sum += x;
    } else {
      sum += x * 380000;
    }
  }

  std::cout << sum << std::endl;

  return 0;
}


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

int main() {
    long n;
    cin  >> n;
    vector<long> v = {2, 1};
    for(long i=2; i <= n; i++) {
        v.push_back(v[i-2]+v[i-1]);
    }
    cout << v[n] << endl;
}


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

int N;

bool check(int n) {
    while (n > 10) {
        n /= 10;
    }
    return (n == 10);
}

int digit_sum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    cin >> N;

    if (check(N)) cout << 10 << endl;
    else {
        cout << digit_sum(N) << endl;
    }


    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = input().split()
D = {}

for i in range(N):
	if A[i] in D.keys():
		D[A[i]] += 1
	else:
		D[A[i]] = 1

ans = 0
if len(D) > K:
	D = sorted(D.values())
	for i in range(len(D) - K):
		ans += D[i]

print(ans)

Measured memory_bytes: 35616
#include<bits/stdc++.h>
#define LL long long
#define vc vector<int>
#define db long double

using namespace std;
const int N=10000+10,M=(1<<16)+10,mod=998244353;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
int ginv(int a){return fpow(a,mod-2);}
int rdr[M],W[20],iW[20],pu[M],pv[M];
void ntt(int *a,int n,int op)
{
    int l=0,y;
    while(1<<l<n) ++l;
    for(int i=0;i<n;++i)
    {
	rdr[i]=(rdr[i>>1]>>1)|((i&1)<<(l-1));
	if(i<rdr[i]) swap(a[i],a[rdr[i]]);
    }
    for(int i=1,p=0;i<n;i<<=1,++p)
    {
	int ww=op?W[p]:iW[p];
	for(int j=0;j<n;j+=i<<1)
	    for(int k=0,w=1;k<i;++k,w=1ll*w*ww%mod)
	    {
		y=1ll*a[j+k+i]*w%mod;
		a[j+k+i]=(a[j+k]-y+mod)%mod;
		a[j+k]=(a[j+k]+y)%mod;
	    }
    }
    if(!op) for(int i=0,w=ginv(n);i<n;++i) a[i]=1ll*a[i]*w%mod;
}
void polymul(int *a,int nn,int *b,int mm,int *c)
{
    int len=1;
    while(len<nn+mm) len<<=1;
    if(!nn||!mm) return;
    memcpy(pu,a,sizeof(int)*nn),memcpy(pv,b,sizeof(int)*mm);
    memset(c,0,sizeof(int)*(nn+mm-1));
    if(1ll*nn*mm<=1ll*len*40)
    {
	for(int i=0;i<nn;++i)
	    for(int j=0;j<mm;++j)
		ad(c[i+j],1ll*pu[i]*pv[j]%mod);
    }
    else
    {
	ntt(pu,len,1),ntt(pv,len,1);
	for(int i=0;i<len;++i) pu[i]=1ll*pu[i]*pv[i]%mod;
	ntt(pu,len,0);
	memcpy(c,pu,sizeof(int)*(nn+mm-1));
    }
    memset(pu,0,sizeof(int)*len),memset(pv,0,sizeof(int)*len);
}
char cc[N],ss[N];
int fac[M],iac[M],aa[M],bb[M],n,m,a1,b1;

int main()
{       
////////
    for(int i=1,p=0;p<=19;i<<=1,++p)
	W[p]=fpow(3,(mod-1)/(i<<1)),iW[p]=ginv(W[p]);
    fac[0]=1;
    for(int i=1;i<=M-5;++i) fac[i]=1ll*fac[i-1]*i%mod;
    iac[M-5]=ginv(fac[M-5]);
    for(int i=M-5;i;--i) iac[i-1]=1ll*iac[i]*i%mod;
    scanf("%s%s",cc+1,ss+1);
    m=strlen(cc+1);
    for(int i=1;i<=m;++i)
    {
	if((cc[i]=='1')^(ss[i]=='1')) ++b1;
	else if(cc[i]=='1'&&ss[i]=='1') ++a1;
    }
    b1/=2,n=a1+b1;
    for(int i=1;i<=n;++i) bb[i]=iac[i];
    aa[0]=1;
    int rbb=b1;
    while(rbb)
    {
	if(rbb&1)
	{
	    polymul(aa,n+1,bb,n+1,aa);
	    for(int i=n+1;i<=n+n+2;++i) aa[i]=0;
	}
	polymul(bb,n+1,bb,n+1,bb);
	for(int i=n+1;i<=n+n+2;++i) bb[i]=0;
	rbb>>=1;
    }
    int ans=0;
    for(int i=0;i<=n;++i) ad(ans,aa[i]);
    ans=1ll*ans*fac[n]%mod*fac[a1]%mod*fac[b1]%mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1280
h, w = map(int, input().split())

c = []
for _ in range(h):
    c.append(input())

for i in range(2 * h):
    for j in range(w):
        row = (i + 2) // 2 - 1
        col = j
        print(c[row][col], end='')
    print()

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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int N = input[0];
        int M = input[1];
        int X = input[2];
        int[][] A = new int[N][];
        for (int i = 0; i < N; i++)
        {
            A[i] = ReadInts();
        }

        int min = int.MaxValue;
        int sum = 0;
        int[] L = new int[M];
        for (long i = 0; i < Math.Pow(2, N); i++)
        {
            long b = i;
            sum = 0;
            L = new int[M];
            for (int j = 0; j < N; j++)
            {
                if (b % 2 == 0)
                {
                    sum += A[j][0];
                    for (int k = 1; k < M + 1; k++)
                    {
                        L[k - 1] += A[j][k];
                    }
                }
                b /= 2;
            }
            if (L.Count(n => n < X) == 0)
            {
                min = Math.Min(sum, min);
            }
        }
        if (min == int.MaxValue)
        {
            return "-1";
        }
        return min.ToString();
    }

    public static int Gcd(int a, int b)
    {
        if (a < b)
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 28676
#include <vector>
#include <iostream>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

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

int main() {
    int a,p; cin>>a>>p;
    cout<<(3*a+p)/2<<endl;
    
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    string s;cin >> s;
    cout << s.substr(0,5) << " " << s.substr(6,7) << " " << s.substr(14,19) << endl;
    return 0;
}

Measured memory_bytes: 3584
S = input().strip()
P = S[0::2] 
Q = S[1::2]
P1 = str(P)
Q1 = str(Q)

result = []
P2 = 'L' in P1
Q2 = 'R' in Q1

if (P2 == True) or (Q2 == True):
    print('No')
else:
    print('Yes')

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

int main(){
int n;
int d;
cin >> n >> d;
vector<int> vec(n,0);

for (int i = 0;i < d;i++){
  int di;
  cin >> di;
  for (int j = 0;j < di;j++){
  	int bangou;
    cin >> bangou;
    vec.at(bangou - 1) =+1;
  }

}
int output;
  for (int i = 0;i < n;i++){

  if (vec.at(i)==0){
  output ++;
  }

  }
   cout << output<<endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    public static void Main()
    {
        int N = NextInt();
        int K = NextInt();
        Console.WriteLine(N - K + 1);
    }

}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220