akhauriyash/Code-Regression huggingface dataset:
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A)[::-1]
B = sorted(B)[::-1]
C = sorted(C)[::-1]

import bisect, heapq

def myidx(x, y, z, X, Y, Z): return(x * (Y * X) + y * Z + z)

ans = 0
cnt = 0
score = A[0] + B[0] + C[0]
history = []
q = [(0, 0, 0, 0)]
while len(q) > 0:
    penalty, x, y, z = heapq.heappop(q)
    # print("#", penalty, x, y, z, history)
    if x < X - 1:
        idx_tmp = myidx(x + 1, y, z, X, Y, Z)
        if idx_tmp not in history:
            # print("##", x + 1, y, z)
            heapq.heappush(history, idx_tmp)
            #
            penalty_tmp = penalty + (A[x] - A[x + 1])
            heapq.heappush(q, (penalty_tmp, x + 1, y, z))
    if y < Y - 1:
        idx_tmp = myidx(x, y + 1, z, X, Y, Z)
        if idx_tmp not in history:
            # print("##", x, y + 1, z)
            heapq.heappush(history, idx_tmp)
            #
            penalty_tmp = penalty + (B[y] - B[y + 1])
            heapq.heappush(q, (penalty_tmp, x, y + 1, z))
    if z < Z - 1:
        idx_tmp = myidx(x, y, z + 1, X, Y, Z)
        if idx_tmp not in history:
            # print("##", x, y, z + 1)
            heapq.heappush(history, idx_tmp)
            #
            penalty_tmp = penalty + (C[z] - C[z + 1])
            heapq.heappush(q, (penalty_tmp, x, y, z + 1))
    #
    cnt += 1
    print(score - penalty)
    if cnt == K:
        break

Measured memory_bytes: 57308
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  I n;
  cin >> n;
  cout << pow(n,3) << endl;
  return 0;
}



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

void Main(){
    int N; cin >> N;
    int ans = 0;
    REP(i,N){
        int a; cin >> a;
        if((i%2)==1) continue;
        if(a%2 == 1) ans++;
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

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

int main(){
    int mid, fin, re;
    for( int i = 0;;i++){
        cin >> mid >> fin >> re;
        if( mid == -1 && fin == -1 && re == -1) break;
        int sum = mid + fin;
        if( mid == -1 || fin == -1) cout << "F" << endl;
        else if( sum >= 80) cout << "A" << endl;
        else if( sum < 80 && sum >= 65) cout << "B" << endl;
        else if( sum < 65 && sum >= 50) cout << "C" << endl;
        else if( sum < 50 && sum >= 30) {
            if( re >= 50) cout << "C" <<endl;
            else cout << "D" << endl;
        }
        else if( sum < 30) cout << "F" << endl;
    }
}


Measured memory_bytes: 3080
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
typedef std::vector<std::set<std::size_t>> graph_t;

std::pair<std::int64_t, std::vector<std::int64_t>> greedy(graph_t const& graph, std::priority_queue<std::int64_t> queue)
{
	auto N = graph.size();
	std::vector<std::int64_t> ret(N, -1);
	std::int64_t score = -queue.top();
	std::queue<std::size_t> target;
	target.emplace(0);
	while (queue.size())
	{
		auto top = target.front();
		target.pop();
		if (ret[top] != -1)
		{
			continue;
		}
		score += ret[top] = queue.top();
		queue.pop();
		for (auto&& n : graph[top])
		{
			target.emplace(n);
		}
	}
	return std::make_pair(score, ret);
}

void Main()
{
	int N;
	std::cin >> N;
	graph_t graph(N);
	for (int i : boost::irange(1, N))
	{
		int a, b;
		std::cin >> a >> b;
		--a; --b;
		graph[a].emplace(b);
		graph[b].emplace(a);
	}
	std::priority_queue<std::int64_t> queue;
	for (int i : boost::irange(0, N))
	{
		std::int64_t c;
		std::cin >> c;
		queue.emplace(c);
	}
	auto p = greedy(graph, std::move(queue));
	std::cout << p.first << std::endl;
	for (auto&& v : p.second)
	{
		std::cout << v << " ";
	}
	std::cout << std::endl;
}

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

Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;


int N, C;
vector<int> program[100000];

int main(){
    set<int> recorder;
    cin >> N >> C;
    for(int i = 0; i < N; i++){
        int s, t, c;
        cin >> s >> t >> c;
        program[i].push_back(s);
        program[i].push_back(t);
        program[i].push_back(c);
    }
    sort(program, program + N);
    for(int i = 0; i < N; i++){
        int s = program[i][0], t = program[i][1], c = program[i][2];
        int usable = -1;
        for(set<int>::iterator it = recorder.begin(); it != recorder.end(); it++){
            if(program[*it][2] == c){
                usable = *it;
                break;
            }else if(program[*it][1] < s){
                usable = *it;
            }
        }
        if(usable == -1){
            recorder.insert(i);
        }else{
            recorder.insert(i);
            recorder.erase(usable);
        }
    }
    cout << recorder.size() << endl;
}

Measured memory_bytes: 5760
#include<stdio.h>

int Partition(int A[], int p, int r)
{
  int w;
  int x = A[r];
  int i = p-1, j, k;
  for(j = p; j < r; j++){
    if(A[j] <= x){
		i = i+1;
		w = A[i];
		A[i] = A[j];
		A[j] = w;
	}
  }
  w = A[i+1];
  A[i+1] = A[r];
  A[r] = w;
  return(i+1);
}

int main()
{
	int A[100000];
	int n, i, p;

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

	p = Partition(A, 0, n-1);
	for(i = 0; i < n-1; i++){
		if(i == p){
			printf("[%d] ", A[i]);
		}else{
			printf("%d ", A[i]);
		}
	}
	printf("%d\n", A[i]);

	return(0);
}

Measured memory_bytes: 988
#include <cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;

ll digit(ll n) {
	ll count = 0;
	while (n) {
		count++;
		n /= 10;
	}
	return count;
}

int main() {
	ll n;
	cin >> n;
	int ans = inf;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ll b = n / i;
			int f = max(digit(i), digit(b));
			ans = min(ans, f);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import std.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;
 
long count;
 
void main()
{
    readln();
    int[] list = readln().split.to!(int[]);
    mergeSort(list);
    writeln(count);
}
 
int[] merge(int[] a, int[] b)
{
    int[] res;
    res.reserve(a.length+b.length);
    while(a.length != 0 && b.length != 0)
    {
        if(a.front < b.front)
        {
            res ~= a.front;
            a.popFront();
        }else{
            count+=a.length;
            res ~= b.front;
            b.popFront();
        }
    }
    res ~= a ~ b;
    return res;
}
 
int[] mergeSort(int[] list)
{
    if(list.length == 0)
        return list;
    if(list.length == 1)
        return list;
    auto mid = list.length / 2;
    auto a = mergeSort(list[0..mid]);
    auto b = mergeSort(list[mid..$]);
    return merge(a, b);
}
 
sizediff_t minIndex(alias pred="a<b", R) (R list)
    if(isForwardRange!R && !isInfinite!R && is(typeof(binaryFun!pred(list.front, list.front))))
{
    assert(!list.empty);
    typeof(list.front) min = list.front;
    sizediff_t minPos;
    sizediff_t curPos;
    for(list.popFront(); !list.empty; list.popFront())
    {
        curPos++;
 
        if(binaryFun!pred(list.front, min))
        {
            min = list.front;
            minPos = curPos;
        }
    }
    return minPos;
}


Measured memory_bytes: 14692
#include<bits/stdc++.h>
using namespace std ;
const long long mod = 998244353 ;
const int N  = 3005 ;
long long int a[N][N] ;
int main() {
#ifndef ONLINE_JUDGE
	//for getting input from input.txt
	freopen("input.txt" , "r" , stdin) ;
	//for writing output to output.txt
	freopen("output.txt" , "w" , stdout) ;
#endif
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int s ;
	vector<int>::size_type n ;
	cin >> n >> s  ;
	vector<int> arr ;
	for (decltype(n) i  = 0 ; i < n ; ++i) {
		int temp ;
		cin >> temp ;
		arr.push_back(temp) ;
	}
	a[0][0] = 1 ;
	for (decltype(n) i = 0 ; i < n ; ++i) {
		for (int j = 0 ; j <= s ; ++j) {
			a[i + 1][j] += 2 * a[i][j] ;
			a[i + 1][j] %= mod ;
			if (j + arr[i] <= s) {
				a[i + 1][j + arr[i]] += a[i][j] ;
				a[i + 1][j + arr[i]] %= mod ;

			}

		}
	}
	cout << a[n][s] << endl ;


}

Measured memory_bytes: 74096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  if (n%2 != 0){
    cout << "No" << endl;
    return 0;
  }
  string ans = "Yes";
  for(int i=0; i<n/2; i++){
    if(s[i] != s[i + n/2]){
      ans = "No";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N;cin >> N;
    vector<LL> A(N);
    rep(i,N)cin >> A[i];

    map<int,int> m;
    rep(i,N-1){
        if(A[i] > A[i+1])m[i]++;
    }
    m[N-1]++;

    LL now = 1000;
    LL last = 0;
    LL kabu = 0;




    rep(i,N){
        bool buy = false;
        bool sell = false;
        if(m[i] != 0){
            sell = true;
         //   cout << "s" << i << endl;
        }
        else{
            buy = true;
           // cout << "b" << i <<  endl;
        }

        if(buy){
            LL t = now /A[i];
            kabu += t;
            now -= (t*A[i]);
            last = A[i];
        }

        if(sell){
            LL tm = kabu * A[i];
            now += tm;
            kabu = 0;
        }

    }

    cout << now << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define pll pair<ll, ll>
#define N 200123
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define vpll vector<pll>
#define pb emplace_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 100000012
#define mod 1000000007LL
#define M 10000123

using namespace std;

int x, n;
map<int, int> tem;

int main(){
    ios_base::sync_with_stdio(0);
    int u;
    cin >> x >> n;
    for(int i = 0; i < n; ++i){
        cin >> u;
        tem[u] = 1;
    }
    for(int i = x, j = x; ; i++, j--){
        if(!tem[j]){
            cout << j << '\n';
            return 0;
        }
        if(!tem[i]){
            cout << i << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h> 
#include<string.h> 
#define LEN 100005 
  
int min(int a, int b) {return a < b ? a : b;} 
  
typedef struct pp{ 
char name[100]; 
int t; 
} P; 
  
P Q[LEN+1]; 
int head, tail, n; 
  
void enqueue(P x){ 
Q[tail]=x; 
if(tail==LEN)tail=1; 
else tail++; 
} 
  
P dequeue(){ 
P x =Q[head]; 
if(head==LEN)head=1; 
else head++; 
return x; 
} 
  
int main(){ 
int elaps=0,c,i,q; 
P u; 
scanf("%d %d",&n,&q); 
for(i=1;i<=n;i++)scanf("%s %d",Q[i].name,&Q[i].t); 
  
head=1; tail=n+1; 
  
while(head!=tail){ 
u=dequeue(); 
c=min(q,u.t); 
u.t-=c; 
elaps+=c; 
if(u.t>0)enqueue(u); 
else{ 
printf("%s %d\n",u.name,elaps); 
} 
} 
return 0; 
}

Measured memory_bytes: 10756
#include <bits/stdc++.h>
#if ONLINE_JUDGE
    #define DEBUG false
#else
    #define DEBUG true
#endif
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) std::sort(all(x))
#define REV(x) std::reverse(all(x))
#define UNIQUE(x) x.erase(std::unique(all(x)), x.end());
#define MAX(x) *std::max_element(all(x))
#define MIN(x) *std::min_element(all(x))
#define LOWitr(x, n) std::lower_bound(all(x), n)
#define UPRitr(x, n) std::upper_bound(all(x), n)
#define cii(x) int x; std::cin >> x
#define cill(x) signed long long int x; std::cin >> x
#define cis(x) std::string x; std::cin >> x
#define co(x) std::cout << x << "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) if(DEBUG) std::cout<<#x<<" : "<<(x)<<"\n"
template<class T>using V = std::vector<T>;
template<class T>using VV = std::vector<std::vector<T>>;
template<class T>using Q = std::queue<T>;
template<class T>using PQ = std::priority_queue<T>;
template<class T,class U>using P = std::pair<T, U>;
template<class T,class U>using M = std::map<T, U>;
template<class T,class U>using UM = std::unordered_map<T, U>;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T>inline void vcin(T &v){for(auto&& i : v) std::cin >> i;}
template<class T>inline void dumpv(const T& v, std::ostream& os = std::cout){
    if(DEBUG){
        os<<"{";
        std::for_each(all(v),[&os](typename T::value_type p){os<<p<<',';});
        os<<"}\n";
    }
}
using std::cin;
using std::cout;
using std::string;
using std::next_permutation;
using LL = signed long long int;
const int INF = INT_MAX, MOD = 1e9 + 7;
const LL LLINF = LLONG_MAX;
const double PI = M_PI;

void Main(){
    cill(k);
    cis(s);
    string ans;
    if (s.length() <= k){
        ans = s;
    }else{
        ans = s.substr(0, k) + "...";
    }
    co(ans);
}

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

Measured memory_bytes: 3644
L, R = map(int, input().split())



l=(L//2019, L%2019)
r=(R//2019, R%2019)

if l[0] != r[0]:
    print(0)
else:
    lst = []
    bottom=min(l[1], r[1])
    up=max(l[1], r[1])
    for i in range(bottom,up):
        for j in range(i + 1, up+1):
            lst.append((i * j) % 2019)
    print(min(lst))


Measured memory_bytes: 107148
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a, b;
    cin >> a >> b;
    string s = "", t = "";
    for(int i=0; i<stoi(b); i++){
        s += a;
    }
    for(int i=0; i<stoi(a); i++){
        t += b;
    }
    if(s <= t){
        cout << s << endl;
    }else{
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;

// ========================================================================



ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計を出す
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します



// ========================================================================


int main() {
	ll a, b; cin >> a >> b;
	cout << lcm(a, b) << endl;

	return 0;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int main(void){
  int dameflag=0,sameflag=1;
  int N,M;
  string s,t;
  cin>>s>>t;
  N=s.size();
  M=t.size();
  
  sort(s.begin(),s.end());
  //reverse(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  FOR(i,0,N){
    if(t[i]<s[i]){
      sameflag=0;
      dameflag=1;
      break;
    }else if(t[i]==s[i]){
      
    }else{
      sameflag=0;
      break;
    }
  }
  // cout<<s<<endl;
  // cout<<t<<endl;
  // printf(" dameflag:%d \n sameflag:%d\n",dameflag,sameflag);
  // printf(" N:%d\n M:%d\n",N,M);
  
  if( (dameflag==0 && sameflag==0) || ( sameflag==1 && N<M ) ){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#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 <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// 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 <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>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b;
  cin>>a>>b;
  bool ans = false;
  if(a==b) ans = true;
  rep(i,a.size()){
    a = a[a.size()-1] + a.substr(0,a.size()-1);
    // cout<<a<<" "<<b<<endl;
    if(a==b) ans = true;
  }
  if(ans==true) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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


Measured memory_bytes: 256
n = int(input())


def se(x):
    for i in range(3 ** x):
        r = ""
        for _ in range(x):
            r += "753"[i % 3]
            i //= 3
        if "7" in r and "5" in r and "3" in r:
            yield int(r)


ans = 0
for i in range(9):
    for j in se(i + 1):
        if j <= n:
            ans += 1
print(ans)


Measured memory_bytes: 3060
x = int(input())

serach_number = x

def sieve_of_eratosthenes(target):
    dest = int(target**(0.5))
    target_list = list(range(2, target + 1))
    prime_list = []
 
    while True:
        num_min = min(target_list)
        if num_min >= dest:
            prime_list.extend(target_list)
            break
        prime_list.append(num_min)
 
 
        i = 0
 
        while True:
            if i >= len(target_list):
                break
            elif target_list[i] % num_min == 0:
                target_list.pop(i)
            i += 1

    return prime_list
prime_list = sieve_of_eratosthenes(serach_number)

if x in prime_list:
    print(x)
else:
    ans = x

    hantei = False
    while not(hantei):
        ans = ans + 1
        hantei = True
        for i in prime_list:
            if ans % i == 0: #全部割り切れなかったらTrue(素数)
                hantei = False
    print(ans)

Measured memory_bytes: 6900
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        System.out.println(solve(s));

        sc.close();
    }

    static String solve(String s) {
        for (int i = 0; i < s.length() - 1; ++i) {
            if (s.charAt(i) == s.charAt(i + 1)) {
                return String.format("%d %d", i + 1, i + 2);
            }
            if (i + 2 < s.length() && s.charAt(i) == s.charAt(i + 2)) {
                return String.format("%d %d", i + 1, i + 3);
            }
        }

        return "-1 -1";
    }
}

Measured memory_bytes: 24732
#include <bits/stdc++.h>
using namespace std;
#define LEN 100005

struct pp{
        string name;
        int t;
};

pp q[LEN];

int head, tail, n;

void enqueue(pp x){
    q[tail] = x;
    tail = (tail + 1) % LEN;
}

pp dequeue(){
    pp x = q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) { return a < b ? a : b;}

int main(){
   int elaps = 0, c;
   int qu;
   pp u;
   scanf("%d %d", &n, &qu);

   for(int i = 1; i <= n; i++){
       cin >> q[i].name >> q[i].t;
   } 
   head = 1; tail = n + 1;

   while(head != tail){
       u = dequeue();
       c = min(qu, u.t);
       elaps += c;
       u.t -= c;
       if(u.t > 0) enqueue(u);
       else{
           cout << u.name << " " << elaps << endl;
       }
   }
}


Measured memory_bytes: 7056
class Assets:
    def __init__(self):
        self.money = 1000;self.stock = 0       
    
    def transaction(self, p_rate, n_rate = 0):

        if p_rate < n_rate and p_rate <= self.money:
            num = self.money // p_rate 
            self.stock += num
            self.money -= (num * p_rate)
        elif p_rate > n_rate :
            self.money += (p_rate * self.stock)
            self.stock = 0

    def show(self):
        print(self.money)

day = int(input())
rate_of_change = list(map(int, input().split()))

ans = Assets()

for j, i in enumerate(range(day) , 1):

    if j == day:
        Assets.transaction(ans, rate_of_change[i])
    else:        
        Assets.transaction(ans, rate_of_change[i], rate_of_change[j])

Assets.show(ans) 

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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 1;
  
  rep(i,n-1) if(s[i] != s[i+1]) ans++;
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i]+1;
    }
}

bool dfs(int node, vector<int> &path, vector<vector<int> > &edges, vector<int> &used){
    if(used[node]==1){
        return false;
    }
    used[node]=1;
    path.push_back(node);
    bool flag=true;

    for(auto v: edges[node]){
        if(dfs(v, path, edges, used)){
            return true;
        }
    }
    return true;
}

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

    vector<vector<int> > edges(N,vector<int>(0));
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> ans(0);
    vector<int> used(N,0);
    if((int)edges[0].size()==1){
        dfs(0, ans, edges, used);
    }else{
        used[0]=1;
        dfs(edges[0][0], ans, edges, used);
        reverse(ans.begin(), ans.end());
        ans.push_back(0);

        for(int i=1; i<(int)edges[0].size(); i++){
            if(dfs(edges[0][i], ans, edges, used)){
               	break;
            }
        }
    }
  	cout << (int)ans.size() << endl;
  	cout_vec(ans);

}


Measured memory_bytes: 12920
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n;
  cin>>n;
  vector<ll>v(n,0);
  ll sum=0;
  vector<ll>vv(n+1,0);
  for(ll i=0;i<n;i++){
    cin>>v[i];
    vv[i+1]=vv[i]+v[i];
    sum+=v[i];
  }
  ll ans=MOD;
  for(ll i=0;i<n;i++){
    ans=min(ans,abs(sum-2*vv[i+1]));
  }
  cout<<ans<<endl;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int a;
     cin>>a;

     cout<<a+a*a+a*a*a<<"\n";

    return 0;

}

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

int main() {
        int n;
        scanf("%d", &n);
        vector<vector<int>> g(n);
        rep(i, n - 1) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        vector<int> ma(n);
        function<void (int, int, int)> dfs = [&](int u, int prev, int m) {
                ma[u] = m;
                for (auto v : g[u]) if (v != prev) {
                        dfs(v, u, max(u, ma[u]));
                }
        };
        dfs(0, -1, 0);
        vector<map<int, int>> dp(n);
        function<void (int, int, int)> calc = [&](int u, int prev, int x) {
                if (dp[u].count(x)) return;
                dp[u][x] = 0;
                for (auto v : g[u]) if (v != prev && v <= x) {
                        calc(v, u, x);
                        dp[u][x] += dp[v][x] + 1;
                }
        };
        vector<int> ans(n);
        ans[0] = 0;
        function<void (int, int)> dfs2 = [&](int u, int prev) {
                for (auto v : g[u]) if (v != prev) {
                        int diff;
                        if (v > ma[u]) {
                                calc(v, u, ma[v]);
                                diff = dp[v][ma[v]] + 1;
                        } else {
                                calc(v, u, ma[v]);
                                calc(v, u, ma[u]);
                                diff = dp[v][ma[v]] - dp[v][ma[u]];
                        }
                        ans[v] = ans[u] + diff;
                        dfs2(v, u);
                }
        };
        dfs2(0, -1);
        rep(i, n) if (i) {
                printf("%d%c", ans[i], (i == n - 1 ? '\n' : ' '));
        }
        return 0;
}


Measured memory_bytes: 67200
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut vs = vec![];
    for _ in 0 .. n+1 {
        vs.push(get!());
    }
    let mut ws = vec![];
    for _ in 0 .. n {
        ws.push(get!());
    }
    let mut ans1 = 0;
    let mut rem = vs[0];
    for i in 0 .. n {
        let beat = std::cmp::min(rem, ws[i]);
        ans1 += beat;
        let beat = std::cmp::min(vs[i+1], ws[i] - beat);
        ans1 += beat;
        rem = vs[i+1] - beat;
    }
    
    let mut ans2 = 0;
    let mut rem = vs[n];
    for i in 0 .. n {
        let i = (n-1) - i;
        let beat = std::cmp::min(rem, ws[i]);
        ans2 += beat;
        let beat = std::cmp::min(vs[i], ws[i] - beat);
        ans2 += beat;
        rem = vs[i] - beat;
    }
    
    let ans = std::cmp::max(ans1, ans2);
    println!("{}", ans);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int cnt = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'o') cnt++;
    }
    if (cnt + int(15 - S.length()) >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

using namespace std;

class Union_Find {
public:
	Union_Find(int n = 0) : d(n, -1) {}

	int find(int x)
	{
		if (d[x] < 0) return x;
		return d[x] = find(d[x]);
	}

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

		if (x == y) {
			return false;
		} else {
			if (-d[x] < -d[y]) swap(x, y);
			d[x] += d[y];
			d[y] = x;
			return true;
		}
	}

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

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

private:
	vector<int> d;
};

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

	vector<int> fre(n);
	Union_Find uf(n);
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;

		fre[x]++;
		fre[y]++;
		uf.unite(x, y);
	}

	vector<int> ans(n);
	for (int i = 0; i < k; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		
		if (uf.same(x, y)) {
			ans[x]--;
			ans[y]--;
		}
	}

	for (int i = 0; i < n; i++) {
		ans[i] += uf.size(i) - fre[i] - 1;
		cout << ans[i] << (i == n - 1 ? "\n" : " ");
	}

	return 0;
}

Measured memory_bytes: 2048
#include <iostream>

void SLE(int a, int b);
int main(){
    int a, b;
    std::cin>> a >> b;
    SLE(a, b);
}

void SLE(int a, int b){
    if(a>b) std::cout<< "a > b\n";
    else if(a<b) std::cout<< "a < b\n";
    else std::cout<< "a == b\n";
}

Measured memory_bytes: 3020
#include<iostream>
#include<cstdio>
#include<sstream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstring>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = 1005;
const int inf = 0x3f3f3f3f;
int main()
{
	int n;cin>>n;
	ll s=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)s+=i;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

int main(void) {
    int N;
    ll K;
    cin>>N>>K;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    
    ll res=0;
    for(int d=60;d>=-1;d--){
        if(d!=-1 && !(K&(1LL<<d))) continue;
        
        ll tmp=0;
        for(int e=60;e>=0;e--){
            ll mask=1LL<<e;
            int num=0;
            for(int i=0;i<N;i++){
                if(A[i]&mask) num++;
            }
            if(e>d){
                if(K&mask) tmp+=mask*(N-num);
                else tmp+=mask*num;
            }
            else if(e==d){
                tmp+=mask*num;
            }
            else{
                tmp+=mask*max(num,N-num);
            }
        }
        res=max(res,tmp);
    }
    cout<<res<<endl;
}

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

int main(){
	string s;	cin>>s;
	int n=s.size();
	vector<int> L(n+1,0),R(n+1,0);

	int cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]=='>')cnt=0;
		else cnt++;

		L[i+1]=cnt;
	}

	for(int i=n-1;i>=0;i--){
		if(s[i]=='<')cnt=0;
		else cnt++;
		R[i]=cnt;
	}

	long long ans=0;
	for(int i=0;i<=n;i++){
		ans+=max(L[i],R[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4740
from math import cos,sin,sqrt,ceil,floor,pi

def calcAngle(h,m): 
        if (h < 0 or m < 0 or h > 12 or m > 60): 
            return 0 
          
        if (h == 12): 
            h = 0
        if (m == 60): 
            m = 0
          
        
        hour_angle = 0.5 * (h * 60 + m) 
        minute_angle = 6 * m 
          
         
        angle = abs(hour_angle - minute_angle) 
        angle = min(360 - angle, angle) 
          
        return angle 
a,b,h,m=map(int,input().split())

l=calcAngle(h,m)*pi/180

w=pow(a,2)+pow(b,2)-2*a*b*cos(l)
print(sqrt(w))


Measured memory_bytes: 62552
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  int n, m;
  cin >> n >> m;
  int c[m];
  c[0] = 0;
  rep(i, 0, m) cin >> c[i];
  int dp[n + 1];
  rep(i, 0, n + 1) dp[i] = 1e9;
  dp[0] = 0;

  rep(i, 0, n + 1) {
    rep(j, 0, m) {
      if(i + c[j] <= n) {
        dp[i + c[j]] = min(dp[i + c[j]], dp[i] + 1);
      }
    }
  }
  cout << dp[n] << endl;
}



Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,v,j;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    if(i!=n-1) cout<<a[i]<<" ";
    else cout<<a[i];
  }
  cout<<endl;
  for(int i=1;i<n;i++){
    v=a[i];
    j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
      a[j+1]=v;
    }
    for(int k=0;k<n;k++){
      if(k!=n-1) cout<<a[k]<<" ";
      else cout<<a[k];
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3072
// review
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;
const int MAXN = 100010;

int n;
ll a[MAXN];

ll countNum(ll initialMove) {
  ll cnt = abs(initialMove);
  ll cur = a[0] + initialMove;
  for (int i=0;i<n-1;i++) {
    ll next = cur + a[i+1];
    if (cur > 0 && next >= 0) {
      cnt += next + 1;
      next = -1;
    }
    if (cur < 0 && next <= 0) {
      cnt += -next + 1;
      next = 1;
    }
    cur = next;
  }
  return cnt;
}

void solve() {
  ll minCnt = min(countNum(0), min(countNum(-a[0] + 1), countNum(-a[0] - 1)));
  cout << minCnt << endl;
}

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


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int i,n,k,j;
	cin>>n>>k;
	int a[n];
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	vector<int> v;
	for(i=0;i<n;i++){
		j=i;
		while(j<n&&a[j]==a[i]){
			j++;
		}
		v.push_back(j-i);
		i+=j-i-1;
	}
	sort(v.begin(),v.end());
	int ans=0;
	for(i=v.size()-k-1;i>=0;i--){
		ans+=v[i];
	}
	fin(ans);
	
	
	
	
	
	
	
	
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


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

int main(){
   int n,k;
   cin>>n>>k;
   int h[n];
   long int dp[n];
   for(int i = 0;i<n;i++){
    cin>>h[i];
    dp[i] = 1000000007;
   }

   dp[0] = 0;
   dp[1] = abs(h[0]-h[1]);

   for(int i = 2;i<n;i++){
    if(i<k){
        for(int j = 0;j<i;j++){
            dp[i] = min(dp[j]+abs(h[i]-h[j]),dp[i]);
        }
    }
    else{
        for(int j = i-k;j<i;j++){
            dp[i] = min(dp[j]+abs(h[i]-h[j]),dp[i]);
        }
    }
    
   } 


   cout<<dp[n-1];


      
}


Measured memory_bytes: 1408
using System;

namespace ITP1_6_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var suit = new string[] { "S", "H", "C", "D" };
            var memo = new bool[4, 14];

            var n = int.Parse(Console.ReadLine());
            for(int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split(' ');
                var num = int.Parse(input[1]);
                switch (input[0])
                {
                    case "S":
                        memo[0, num] = true;
                        break;
                    case "H":
                        memo[1, num] = true;
                        break;
                    case "C":
                        memo[2, num] = true;
                        break;
                    case "D":
                        memo[3, num] = true;
                        break;
                }
            }

            for(int i = 0; i < 4; i++)
            {
                for(int j = 1; j < 14; j++)
                {
                    if (!memo[i, j])
                        Console.WriteLine("{0} {1}", suit[i], j);
                }
            }
        }
    }
}

Measured memory_bytes: 9172
#include <iostream>
 
const int MAX_W = 505;
const int MAX = 1e9;
 
using namespace std;
 
int table [MAX_W][MAX_W];
 
int main () {
  int largeh, largew, smallh, smallw;
  cin >> largeh >> largew >> smallh >> smallw;

  if (smallh * smallw == 1) {
    cout << "No" << endl;
    return 0;
  }

  int amb = (MAX - 1) / (smallh * smallw - 1);
  int neg = -(smallh * smallw - 1) * amb - 1;
 
  long long sum = 0;
  for (int i = 1; i <= largeh; i++) {
    for (int j = 1; j <= largew; j++) {
      if (i % smallh == 0 &&
          j % smallw == 0) {
        table[i][j] = neg;
      } else {
        table[i][j] = amb;
      }
 
      sum += table[i][j];
    }
  }
 
  if (sum > 0) {
    cout << "Yes" << endl;
    for (int i = 1; i <= largeh; i++) {
      for (int j = 1; j <= largew; j++) {
        cout << table[i][j] << " ";
      }
      cout << endl;
    }
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 4624
A, B, C = list(map(int, input().split()))
K = int(input())

for i in range(K):
    if (A >= B):
        B = B * 2
    elif (B >= C):
        C = C * 2

    if (A < B and B < C):
        print("Yes")

        exit(0)

print("No")


Measured memory_bytes: 61648
/***
*	author  :_shamim
*	created : 05.05.2020
*
***/

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <list>
#include <queue>
#include <bitset>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll             long long
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define loop           for(i=0;i<n;i++)
#define pb             push_back
#define tc()           int t;cin>>t;while(t--)          

using namespace std;

ll i,j,temp;

int main()
{_
	
	unsigned int x,d,c;
    cin>>x>>d;
    if(d==100){
    	d++;
    }
    
    cout<<d;
    if(x==1){
    	cout<<0<<0<<endl;
    }
    else if(x==2){
    	cout<<0<<0<<0<<0<<endl;
    }
    

 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;

void solve() {
	int n, k; cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			if (i + j >= n) {
				break;
			}
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
		}
	}

	cout << dp[n - 1] << endl;
}

int main() {
    FAST_INPUT;

    solve();

    return 0;
}


Measured memory_bytes: 1024
n, k = map(int, input().split())
nums = list(map(int, input().split()))
 
sum_max = sum(nums[:k])
temp = sum_max
for i in range(k,n):
  temp -= nums[i-k]
  temp += nums[i]
  sum_max = max(temp, sum_max)
print((sum_max +k)/2)


Measured memory_bytes: 25060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  sort(ALL(a));
  
  double ans = double(a[0]+a[1])/2.0;
  FOR(i,2,n) ans = (ans+a[i])/2.0;
  printf("%.9f\n", ans);
  return 0;
}


Measured memory_bytes: 3708
#%%
x, y = map(int, input().split())
ans = 0
if x == 1:
    ans += 300000
elif x == 2:
    ans += 200000
elif x == 3:
    ans += 100000
if y == 1:
    ans += 300000
elif y == 2:
    ans += 200000
elif y == 3:
    ans += 100000

if x == y == 1:
    ans += 400000
print(ans)

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

int main(){
	int n, k;
	std::cin >> n >> k;
	std::vector<int> a(n);
	for(int i=0; i<n; i++){
		std::cin >> a[i];
	}

	std::vector<int> dp(k+1);
	for(int i=1; i<=k; i++){
		for(int j=0; j<n; j++){
			if(i-a[j]>=0 && dp[i-a[j]] == 0){
				dp[i] = 1;
			}
		}
	}

	if(dp[k]){
		std::cout << "First" << std::endl;
	}else{
		std::cout << "Second" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 640