akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Collections;
import java.util.TreeSet;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ERoadwork solver = new ERoadwork();
        solver.solve(1, in, out);
        out.close();
    }

    static class ERoadwork {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();

            ArrayList<ERoadwork.Event> events = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                int s = in.nextInt();
                int t = in.nextInt();
                int x = in.nextInt();

                events.add(new ERoadwork.Event(s - x, x, 2));
                events.add(new ERoadwork.Event(t - x, x, 1));
            }
            for (int i = 0; i < q; i++) {
                events.add(new ERoadwork.Event(in.nextInt(), i, 3));
            }

            Collections.sort(events);

            TreeSet<Integer> currents = new TreeSet<>();
            int[] res = new int[q];
            for (ERoadwork.Event event : events)
                if (event.type == 2)
                    currents.add(event.x);
                else if (event.type == 1)
                    currents.remove(event.x);
                else {
                    res[event.x] = currents.isEmpty() ? -1 : currents.first();
                }

            for (int i = 0; i < q; i++) {
                out.println(res[i]);
            }

        }

        public static class Event implements Comparable<ERoadwork.Event> {
            int t;
            int x;
            int type;

            public Event(int t, int x, int type) {
                this.t = t;
                this.x = x;
                this.type = type;
            }

            public int compareTo(ERoadwork.Event o) {
                return t != o.t ? t - o.t : (type != o.type ? type - o.type : x - o.x);
            }

        }

    }
}



Measured memory_bytes: 207512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
#define pb  push_back
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST

int x;
cin>>x;
int y=x/500;
int z=(x-y*500);
z/=5;
cout<<y*1000+z*5;
return  0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1150
using namespace std;
bool prime[N];
vector<int> p;
int dp[205][N][15];

int main(){
  for(int i=0;i<N;i++)
    prime[i]=true;
  prime[0]=prime[1]=false;
  for(int i=0;i*i<N;i++){
    if(!prime[i])continue;
    for(int j=i*2;j<N;j+=i)
      prime[j]=false;
  }
  for(int i=0;i<N;i++)
    if(prime[i])p.push_back(i);
  while(1){
    int n,k;
    cin>>n>>k;
    if(!n&&!k)break;
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    for(int i=0;i<p.size();i++){
      for(int j=0;j<=n;j++){
	for(int l=0;l<=k;l++){
	  if(!dp[i][j][l])continue;
	  if(j+p[i]<=n)
	    dp[i+1][j+p[i]][l+1]+=dp[i][j][l];
	  dp[i+1][j][l]+=dp[i][j][l];
	}
      }
    }
    cout<<dp[p.size()][n][k]<<endl;
  }
  return 0;
}

Measured memory_bytes: 16892
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;

int main()
{
	IO;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int flag=0;
	while(1){
		c-=b;
		if(c<=0){
			flag=1;
			break;
		}
		a-=d;
		if(a<=0){
			flag=0;
			break;
		}
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
 	return 0;
}







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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&a!=c)||(a==c&&a!=b)||(c==b&&a!=c)){
		cout<<"Yes"<<endl;
	} else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,x,y;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
	if(a<=b&&a<=c&&a<=d)	x=b+c+d;
	if(b<a&&b<=c&&b<=d)		x=a+c+d;
	if(c<a&&c<b&&c<=d)		x=a+b+d;
	if(d<a&&d<b&&d<c)		x=a+b+c;
	if(e>=f)	printf("%d\n",x+e);
	else	printf("%d\n",x+f);
	return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>

int main(){
  int n, k;  scanf("%d %d", &n, &k);
  int flag[10] = {0};
  for(int i=0; i<k; i++){
    int t;  scanf("%d", &t);
    flag[t] = 1;
  }
  int ans = 0;
  do{
    int ok = 1, ncopy = n;
    while(ncopy){
      for(int i=0; i<10; i++)
	if(flag[ncopy%10]){
	  ok = 0;
	  break;
	}
      if(ok == 0)  break;
      ncopy /= 10;
    }
    if(ok)  ans = n;
    n++;
  }while(ans == 0);
  
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	int S[2000], T[2000];
	rep(i, N) cin >> S[i];
	rep(i, M) cin >> T[i];

	ll mod = 1e9 + 7;
	ll dp[4001];

	rep(i, N + M + 1) dp[i] = 1;
	for (int i = N; i > 0; i--) {
		for (int j = i; j < i + M; j++) {
			if ((i & 7) == 0 || (j & 7) == 0) {
				if (S[N - i] == T[j - i]) dp[j] = (dp[j - 1] + dp[j + 1]) % mod;
				else dp[j] = (dp[j - 1] + dp[j + 1] - dp[j]) % mod;
			}
			else {
				if (S[N - i] == T[j - i]) dp[j] = dp[j - 1] + dp[j + 1];
				else dp[j] = dp[j - 1] + dp[j + 1] - dp[j];
			}
		}
	}
	co((dp[M] % mod + mod) % mod);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    double n;
    cin>>n;
    int ans;
    for(ll i=(ll)sqrt(n)+1;i>=1;--i){
        if((ll)n%i==0){
            int c=(ll)n/i,cnt=0;
            while(c){
                c/=10;
                ++cnt;
            }
            cout<<cnt<<endl;
            return 0;
        }
    }
    int c=n,cnt=0;
    while(c--){
        c/=10;
        ++cnt;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
int gcd(int a, int b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
int ans = 0;
int s[10][10];
int k[10];
int p[10];
void bit(int m, int n, int d) {
	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			bool w = true;
			rep(i, 0, d) {
				int x = 0;
				rep(j, 0, k[i])if (now[s[i][j] - 1] == '1')x++;
				if (x % 2 != p[i])w = false;
			}
			if (w)ans += 1;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}
;
int main() {
	int a[3], b[3];
	hei(int) s = { 1,2,3,4 };
	rep(i, 0, 3)cin >> a[i] >> b[i];
	bool ans = false;
	do {
		bool A = true;
		rep(i, 0, 3) {
			bool x = false;
			rep(j, 0, 3) {
				if ((a[j] == s[i] && b[j] == s[i + 1]) || a[j] == s[i + 1] && b[j] == s[i])x = true;
			}
			if (!x)A = false;
		}
		if (A)ans = true;

	} while (next_permutation(s.begin(), s.end()));
	YES(ans)
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;


void solve(long long N, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    ll ans=0;
    for (ll i = 0; i < N; i++)
    {
        ans += B[A[i]-1];
        if ((i !=0) && A[i] == (A[i-1]+1))
        {
            ans += C[A[i-1]-1];
        }
        
    }
    cout << ans << endl;
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
    static int N;
    static double dp[][], p[], ans=0.0;
    public static void main(String[] args) throws IOException{
        N = readInt();
        dp = new double[N+1][N+1];
        p = new double[N+1];
        for (int i = 1; i<=N; i++) p[i] = readDouble();
        dp[1][1] = p[1];
        dp[1][0] = 1.0 - p[1];
        for (int i = 2; i<=N; i++){
            dp[i][0] = dp[i-1][0]*(1.0-p[i]);
            for (int j = 1; j<=i; j++){
                dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1.0-p[i]);
            }
        }
        for (int i = N/2 + 1; i<=N; i++) ans+=dp[N][i];
        System.out.println(ans);
    }
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                    st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
    }
    static long readLong() throws IOException {
            return Long.parseLong(next());
    }

    static float readFloat() throws IOException {
            return Float.parseFloat(next());
    }

    static boolean readBool() throws IOException {
            return Boolean.parseBoolean(next());
    }

    static short readShort() throws IOException {
            return Short.parseShort(next());
    }

    static byte readByte() throws IOException {
            return Byte.parseByte(next());
    }

    static int readInt() throws IOException {
            return Integer.parseInt(next());
    }

    static double readDouble() throws IOException {
            return Double.parseDouble(next());
    }

    static char readChar() throws IOException {
            return next().charAt(0);
    }

    static String readLine() throws IOException {
            return br.readLine().trim();
    }

    static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    static void print(Object o) {
            pr.print(o);
    }
}

Measured memory_bytes: 131024
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int n = sc.nextInt(), m = sc.nextInt(), l = sc.nextInt();
                        long[][] A = new long[n][m];
                        long[][] B = new long[m][l];
                        for (int i = 0; i < n; i++) {
                                for (int j = 0; j < m; j++) {
                                        A[i][j] = sc.nextLong();
                                }
                        }
                        for (int i = 0; i < m; i++) {
                                for (int j = 0; j < l; j++) {
                                        B[i][j] = sc.nextLong();
                                }
                        }
                        for (int i = 0; i < n; i++) {
                                for (int j = 0; j < l; j++) {
                                        long num = 0;
                                        for (int k = 0; k < m; k++) {
                                                num += A[i][k] * B[k][j];
                                        }
                                        System.out.print(num);
                                        if (j != l - 1) {
                                                System.out.print(" ");
                                        } else {
                                                System.out.print("\n");
                                        }
                                }
                        }
                }
        }
}



Measured memory_bytes: 56004
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

int main()
{
	string s;
	cin >> s;

	const int N = s.size();
	vector<int> l(N), r(N);
	rep(i, N)
		r[i] = s[i] == 'R' ? i : r[i - 1];
	for (int i = N - 1; i >= 0; i--)
		l[i] = s[i] == 'L' ? i : l[i + 1];

	vector<int> res(N, 0);
	rep(i, N) {
		if (s[i] == 'R') {
			int tgt = l[i];
			int dist = tgt - i;
			res[tgt - dist % 2]++;
		}
		else {
			int tgt = r[i];
			int dist = i - tgt;
			res[tgt + dist % 2]++;
		}
	}
	for (auto num : res)cout << num << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stack>
#include<queue>
#include<string>
#define P pair<int, int>

using namespace std;

int main(){
  string s;
  stack<int> s1, s3;
  stack<P> s2;
  int total=0;
  cin >> s;
  for(int i=0;i<s.length();i++){
    if(s[i]=='\\')s1.push(i);
    else if(s[i]=='/'){
      if(!s1.empty()){
        int j=s1.top();s1.pop();
        total += i-j;
        int a = i-j;
        while(!s2.empty() && s2.top().first>j){
          a += s2.top().second;s2.pop();
        }
        s2.push(P(j, a));
      }
    }
  }
  cout << total << endl;
  while(!s2.empty()){s3.push(s2.top().second);s2.pop();}
  cout << s3.size() << (s3.empty()?'\n': ' ');
  while(!s3.empty()){
    cout << s3.top();s3.pop();
    cout << (s3.empty()?'\n':' ');
  }
}


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

class Union_find
{
public :
    vector<int> par;
    vector<int> rank;

    Union_find (int n) {
        par.resize(n);
        rank.resize(n);

        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 1;
        }
    }

    int find (int);
    void unite (int, int);
    bool same (int, int);
};

int Union_find::find (int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void Union_find::unite (int x, int y) {
    x = find(x);
    y = find(y);

    if (x != y) {
        par[y] = x;
		rank[x] = rank[x] + rank[y];
    }
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M), B(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}

	long long int res = 0;
	for (int i = 0; i < N; i++) {
		res += (long long int)(N - 1 - i);
	}

	Union_find uf(N);

	vector<long long int> ans(M);
	for (int i = 0; i < M; i++) {
		ans[M - 1 - i] = res;

		if (!uf.same(A[M - 1 - i], B[M - 1 - i])) {
			res -= (long long int)(uf.rank[uf.find(A[M - 1 - i])]) * (long long int)(uf.rank[uf.find(B[M - 1 - i])]);
		}

		uf.unite(A[M - 1 - i], B[M - 1 - i]);
	}

	for (auto i : ans) {
		cout << i << endl;
	}

	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define forN(n, N) for(int n=0; n<N; n++)
#define res_out(ans) cout << ans << "\n";
#define ll long long

int l[int(1e6)], r[int(1e6)];
int dp[int(1e6)];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q, count;
    string S;
    cin >> N >> Q >> S;
    forN(q, Q)cin >> l[q] >> r[q];
    forN(i, N){
        dp[i+1] = dp[i];
        if(S[i] == 'A' && S[i+1] == 'C')dp[i+1]++;
    }
    forN(q, Q){
        res_out(dp[r[q]-1] - dp[l[q]-1])
    }
    return 0;
}

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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;

const int MAX = 111;
double x[MAX], y[MAX], z[MAX], r[MAX];
bool vis[MAX];

inline double dist(int p, int q) {
  return max<double>(0.0, sqrt((x[p] - x[q]) * (x[p] - x[q]) + (y[p] - y[q]) * (y[p] - y[q]) + (z[p] - z[q]) * (z[p] - z[q])) - r[p] - r[q]);
}

void solve(int n) {
  memset(vis, false, sizeof(vis));
  for (int i = 0; i < n; i++) {
    scanf("%lf%lf%lf%lf", x + i, y + i, z + i, r + i);
  }
  priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> pq;
  pq.push(make_pair(0, 0));
  double ans = 0;
  while (!pq.empty()) {
    auto e = pq.top();
    pq.pop();
    if (vis[e.second]) {
      continue;
    }
    vis[e.second] = true;
    ans += e.first;
    for (int i = 0; i < n; i++) {
      if (i != e.second && !vis[i]) {
        pq.push(make_pair(dist(e.second, i), i));
      }
    }
  }
  printf("%.3lf\n", ans);
}

int main() {
  while (true) {
    int n;
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    solve(n);
  }
  return 0;
}

Measured memory_bytes: 3236
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        int N = scan.nextInt();
        String S1 = scan.next();
        char[] S = S1.toCharArray();

        String w;
        int num = 0;
        for(int i=0; i<1000; i++){
            int c=0;
            w = String.valueOf(i);
            for(int k=0; k<3; k++) {
                if (w.length() <= 2) {
                    w = "0" + w;
                }
            }
            char[] n = w.toCharArray();
            for(int j=0; j<N; j++){
                if(n[c] == S[j]){
                    c++;
                    if(c==3){
                        num++;
                        break;
                    }
                }
            }
        }
        System.out.println(num);
    }
}

Measured memory_bytes: 24532
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>

int bit_count(int value) {
	int result{ 0 };
	while (value > 0) {
		if ((value & 1) == 1) ++result;
		value >>= 1;
	}
	return result;
}
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<int> lamp(m, 0);
	for (auto& l : lamp) {
		int k; std::cin >> k;
		for (auto i = 0; i < k; ++i) {
			int s; std::cin >> s;
			l |= 1 << --s;
		}
	}
	std::vector<int> state(m);
	for (auto& s : state) std::cin >> s;
	int count{ 0 };
	for (auto i = 0; i < (1 << n); ++i) {
		bool can_on_all{ true };
		for (auto j = 0; j < m; ++j) {
			if ((bit_count(i & lamp[j]) & 1) != state[j]) {
				can_on_all = false;
				break;
			}
		}
		if (can_on_all) ++count;
	}
	std::cout << count << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int e[7];
	int a,b,c;
	for(c=0;c<=6;c++){
		scanf("%d %d",&a,&b);
		e[c]=a-b;
	}
	for(c=0;c<=6;c++){
		printf("%d\n",e[c]);
	}
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  cin >> n;
  double t = 0;
  double sum = 0;
  rep(i,0,n) {
    cin >> t;
    sum += 1.0/t;
  }
  cout << 1.0/sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, j, n) for (int i = j; i < n; ++i)
#define eb emplace_back
#define sz(s) (int)s.size()
#define F first
#define S second

int main() {
    int n;
    while (cin >> n && n) {
        vector<vector<pair<pii, pii> > > in(1000);
        vector<vector<pair<pii, pii> > > out(1000);
        rep(i, n) {
            int a, b; char ch;
            cin >> a >> ch >> b;
            int c, d;
            cin >> c >> ch >> d;
            cin >> ch;
            int e;
            cin >> e;
            
            
            if (ch == 'I') in[e].eb(make_pair(pii(a, b), pii(c, d)));
            else out[e].eb(make_pair(pii(a, b), pii(c, d)));
            
        }
        /*
        rep(i, 5) {
            cout << i << endl;
            cout << "in" << endl;
            rep(j, sz(in[i])) cout << in[i][j].F.F << " " << in[i][j].F.S << " " << in[i][j].S.F << " " << in[i][j].S.S << endl;
            cout << "out" << endl;
            rep(j, sz(out[i])) cout << out[i][j].F.F << " " << out[i][j].F.S << " " << out[i][j].S.F << " " << out[i][j].S.S << endl;
        }
        */
        
        int ans = 0;
        rep3(i, 1, 100) {
            // cout << i << endl;
            int sum = 0;
            rep(j, sz(in[i])) {
                rep(k, sz(in[0])) {
                    if (in[i][j].F.F != in[0][k].F.F || in[i][j].F.S != in[0][k].F.S) continue;
                    // start time
                    // not coverd at all
                    if (out[i][j].S.F < in[0][k].S.F) continue;
                    if (out[i][j].S.F == in[0][k].S.F && out[i][j].S.S < in[0][k].S.S) continue;
                    
                    if (in[i][j].S.F > out[0][k].S.F) continue;
                    if (in[i][j].S.F == out[0][k].S.F && in[i][j].S.S > out[0][k].S.S) continue;
                    
                    int a = in[i][j].S.F, b = in[i][j].S.S, c = out[i][j].S.F, d = out[i][j].S.S;
                    if (a < in[0][k].S.F) {
                        a = in[0][k].S.F;
                        b = in[0][k].S.S;
                    } else if (a == in[0][k].S.F && b < in[0][k].S.S) {
                        b = in[0][k].S.S;
                    }
                    // cout << a << " " << b << " ";
                    a = a * 60 + b;
                    if (c > out[0][k].S.F) {
                        c = out[0][k].S.F;
                        d = out[0][k].S.S;
                    } else if (c == out[0][k].S.F && d > out[0][k].S.S) {
                        d = out[0][k].S.S;
                    }
                    // cout << c << " " << d << endl;
                    c = c * 60 + d;
                    sum += c - a;
                }
            }
            ans = max(ans, sum);
            // if (sum != 0) cout << i << " " << sum << endl;
        }
        cout << ans << endl;
    }
}

/*
 10
 06/01 10:00 I 000
 06/01 11:15 O 000
 06/01 09:30 I 001
 06/01 09:45 O 001
 06/01 10:15 I 002
 06/01 10:30 O 002
 06/01 09:45 I 003
 06/01 10:30 O 003
 06/01 11:30 I 004
 06/01 11:45 O 004
 
 30
 */





Measured memory_bytes: 3100
#include <stdio.h>

int main()
{
	int a,b;
	
	scanf("%d", &a);
	scanf("%d", &b);
	
	if( (a==1 && b==2) || (a==2 && b==1) ) {
		printf("3\n");
	}
	else if( (a==2 && b==3) || (a==3 && b==2) ){
		printf("1\n");
	}
	else if ( (a==1 && b==3) || (a==3 && b==1) ){
		printf("2\n");
	}
	
	return 0;
}

Measured memory_bytes: 2064
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int C[100001],S[100001],F[100001];
	scan(N);
	rep(i,N-1){
		scan(C[i]);scan(S[i]);scan(F[i]);
	}
	rep(j,N){
		int nowtime=0;
		for(int i=j;i<N-1;i++){
			if(nowtime<=S[i]) nowtime=S[i]+C[i];
			else{
				nowtime=(nowtime/F[i]+(nowtime%F[i]!=0))*F[i]+C[i];
			}
		}
		prin(nowtime);
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(sc.hasNext()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();
            int e = sc.nextInt();
            int f = sc.nextInt();
            double KaiX,KaiY;
            
            int Xkeisu, Ykeisu, TeisuX, TeisuY;
            Xkeisu = a*e - d*b;
            TeisuX = c*e - f*b;
            KaiX = (double)TeisuX / Xkeisu;
            Ykeisu = b*d - e*a;
            TeisuY = c*d - a*f;
            KaiY = (double)TeisuY / Ykeisu;
            if(TeisuX==0)KaiX=0;
            if(TeisuY==0)KaiY=0;
            System.out.printf("%.3f %.3f\n", KaiX, KaiY);
        }
    }
}

Measured memory_bytes: 18184
#include <bits/stdc++.h>
#define EQ(x, y) (abs(x - y) < EPS)
typedef long long ll;
using namespace std;

const int N = 1e5 + 1;
int dp[N];
int n, m;
vector<vector<int>> g; // directed

int dfs(int node){
	if (dp[node] != -1)
		return dp[node];
	dp[node] = 0;
	for (auto &x : g[node]){
		if (dp[x] != -1){
			dp[node] = max(dp[node], 1 + dp[x]);
		}
		else {
			dp[node] = max(dp[node], 1 + dfs(x));
		}
	}
	return dp[node];
}

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

	cin >> n >> m;
	g.resize(n + 1);
	for (int i = 0; i < m; ++i){ // from x to y
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
	}
	memset(dp, -1, sizeof(dp));
	
	int mx = -1;
	for (int i = 1; i <= n; ++i){
		mx = max(mx, dfs(i));
	}
	cout << mx << '\n';
	return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	long long C[200010] = {}; 
	for(int i = 0; i < N; i++) cin >> C[i];
	sort(C, C+N); 
	long long pow[400010] = {}; 
	pow[0] = 1; 
	long long P = 1000000007; 
	for(int i = 1; i < 400005; i++) pow[i] = pow[i-1] * 2 % P; 
	long long ans = 0; 
	for(int i = 0; i < N; i++){
		long long tmp = C[i] * (N + 1 - i) % P; 
		ans += tmp;
		ans %= P; 
	}
	cout << (ans * pow[2*N - 2]) % P << endl; 
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

	int N;
	Scd(N);

	priority_queue<int,vector<int>,greater<int>> p;

	int M;
	vector<int> a;
	Rep(i,N){
		Scd(M);
		a.assign(M,0);
		Rep(j,M) Scd(a[j]);
		sort(a.begin(),a.end());
		reverse(a.begin(),a.end());
		p.push(a[0]);
		Repe(j,i+1,1){
			if( j >= M ) break;
			if( p.top() < a[j] ){
				p.pop();
				p.push(a[j]);
			}else{
				break;
			}
		}
	}

	ll ans = 0;
	while( p.size() ) ans += p.top(), p.pop();	
	printf("%lld\n", ans );

	return 0;
}





Measured memory_bytes: 4852
N = int(input())
S = input()

dictionary = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

result = ""
for s in S:
	next_index = dictionary.find(s) + N
	if next_index > len(dictionary) - 1:
		next_index = next_index - len(dictionary)
	result += dictionary[next_index]

print(result)


Measured memory_bytes: 3060
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
    if sc.Scan() {
        ret, _ := strconv.Atoi(sc.Text())
        return ret
    }
    return 0
}

func readLine() string {
    var ret string
    if sc.Scan() {
        ret = sc.Text()
    }
    return ret
}

func judge(s string) string {
    var prevDigit rune
    for _, digit := range s {
        if digit == prevDigit {
            return "Bad"
        }
        prevDigit = digit
    }
    return "Good"
}

func main(){
    codeStr := readLine()
    result := judge(codeStr)
    fmt.Println(result)
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(1<<30)

idx = 'ABC'
N, *vals = map(int, input().split())
evs = [tuple(map(idx.index, input())) for _ in range(N)]
path = []

def f(i):
	if i == len(evs):
		print('Yes')
		print('\n'.join(path))
		raise SystemExit

	k, j = evs[i]
	for add, sub in ((k, j), (j, k)):
		if vals[sub] == 0: continue
		vals[add] += 1
		vals[sub] -= 1
		path.append(idx[add])

		f(i+1)

		vals[add] -= 1
		vals[sub] += 1
		path.pop()

f(0)

print('No')



Measured memory_bytes: 540308
n, m = map(int, input().split())
h = list(map(int, input().split()))
h_dict = {}
for i, name in enumerate(h, 1):
    h_dict[i] = name

ab = []
for _ in range(m):
    ab.append(list(map(int, input().split())))

flg_bad = set()
for j in ab:
    if h_dict[j[0]] < h_dict[j[1]]:
        flg_bad.add(j[0])
    elif h_dict[j[0]] > h_dict[j[1]]:
        flg_bad.add(j[1])
    elif h_dict[j[0]] == h_dict[j[1]]:
        flg_bad.add(j[0])
        flg_bad.add(j[1])

print(len(h) - len(flg_bad))

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

#define ll long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a;cin>>a;
    cout<<a+a*a+a*a*a;
    return 0;
}


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

    int main()
    {
        map<string, int> mp;
        int  n; cin>>n;
        for(int i = 1; i <=n; i++)
        {
            string s;
            cin>>s;
            mp.insert({s,0});
        }
        cout<<mp.size()<<endl;
    }


Measured memory_bytes: 19252
import collections
import sys
sys.setrecursionlimit(10**9)
cache,edge={},collections.defaultdict(list)
def dp(node):
  if node in cache:
    return cache[node]
  lcl_max=0
  for child in edge[node]:
    
    lcl_max=max(lcl_max,1+dp(child))
  cache[node]=lcl_max
  return lcl_max
 
max_dis=0

n,m=map(int,input().split())
for _ in range(m):
  a,b=map(int,input().split())
  edge[a].append(b)
for node in range(1,n+1):
  max_dis=max(max_dis,dp(node))
print(max_dis)

Measured memory_bytes: 189456
#include <stdio.h>
int main(void) {
    int s;
    int yy, mm;
    scanf("%d", &s);

    yy = s / 100;
    mm = s % 100;

    if (1 <= mm && mm <= 12) {
        if (1 <= yy && yy <= 12) {
            printf("AMBIGUOUS\n");
        } else {
            printf("YYMM\n");
        }
    } else if (1 <= yy && yy <= 12) {
        printf("MMYY\n");
    } else {
        printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

char s[100010];
int ans[100010];
int szS;

struct Section
{
	int lPos;
	int lCount;
	int rCount;
	int total;
};

int main()
{
	scanf("%s", &s);
	szS = strlen(s);
	
	std::vector<Section> sections;
	std::vector<int> changes;
	for (int i = 0 ; i < szS - 1 ; i++)
	{
		if ((s[i] == 'R') && (s[i + 1] == 'L'))
		{
			changes.push_back(i);
			
			Section newSection;
			newSection.lPos = i;
			newSection.lCount = 0;
			newSection.rCount = 0;
			
			int l = i;
			int r = i + 1;
			
			while ((l >= 0) && (s[l] == 'R'))
			{
				l--;
				newSection.lCount++;
			}
			
			while ((r < szS) && (s[r] == 'L'))
			{
				r++;
				newSection.rCount++;
			}
			
			newSection.total = newSection.lCount + newSection.rCount;
			sections.push_back(newSection);
		}
	}
	
	memset(ans, 0, sizeof(ans));
	for (int i = 0 ; i < sections.size() ; i++)
	{
		int count = sections[i].total;
		int half = count / 2;
		if (count % 2 == 0)
		{
			ans[sections[i].lPos] = half;
			ans[sections[i].lPos + 1] = half;
		} else {
			int totalMin = 0;
			
			if (sections[i].lCount > sections[i].rCount)
			{
				totalMin = sections[i].lCount - 1;
				ans[sections[i].lPos] = half + 1;
				ans[sections[i].lPos + 1] = half;
			}
			else	//不可能相等 
			{
				totalMin = sections[i].rCount - 1;
				ans[sections[i].lPos] = half;
				ans[sections[i].lPos + 1] = half + 1;
			}
			
			if (totalMin % 2 != 0)	//不为零，需要交换
			{
				int temp = ans[sections[i].lPos];
				ans[sections[i].lPos] = ans[sections[i].lPos + 1];
				ans[sections[i].lPos + 1] = temp;
			}
		}
	}
	
	printf("%d", ans[0]);	
	for (int i = 1 ; i < szS ; i++)
		printf(" %d", ans[i]);
	printf("\n");
	
	return 0;
}


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

sum = sum(A)
ans = 0
M = 10**9 + 7

for i in range(N):
    ans += (A[i] * (sum - A[i]))
    ans %= M

ans = (ans * pow(2,M-2,M)) % M
print(ans)


Measured memory_bytes: 31540
N, K = map(int, input().split())
l=[]

for i in range(N):
    num = int(input())
    l.append(num)

ans = max(l) - min(l)
l.sort()

for i in range(N-K+1):
    a = l[i+K-1] - l[i]
    if a < ans:
        ans = a

print(ans)


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

#define N 110000

using namespace std;

int main(void){
  int p[N] = {0};
  int sum[10001]={0}, cnt=0;
  
  for (int i=2; i<N; i++){
    if (p[i]==-1) continue;
    p[i]=0;
    cnt++;
    sum[cnt] = sum[cnt-1]+i;
    for (int j=i; j<N; j+=i){
      p[j]=-1;
    }
  }
  while (scanf("%d",&cnt), cnt){
    printf("%d\n",sum[cnt]);
  }
  return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		String string = sc.next();
		
		if(string.length()==2){
			if(string.charAt(0)==string.charAt(1)){
				System.out.print(1);
				System.out.print(" ");
				System.out.print(2);
				return;

			}
				
		}
		
		for(int i = 0;i < string.length()-2;i++){
			if(string.charAt(i) == string.charAt(i+1)){
				int k =  find(i,string);
				if(k != i){
					if(k > i){
						System.out.print(i+1);
						System.out.print(" ");
						System.out.print(k+1);
						return;
					}else{
						System.out.print(k+1);
						System.out.print(" ");
						System.out.print(i+2);
						return;
					}

				}else{
					System.out.println(-1 + " "+ -1);
					return;

				}

			}else if( string.charAt(i) == string.charAt(i+2)){
				System.out.print(i+1);
				System.out.print(" ");
				System.out.print(i+3);			
				return;
				
				

			}
		}
		System.out.println(-1 + " "+ -1);


	}
	static int find(int k,String string){

		for(int i = k;i >= 0;i--){
			if(string.charAt(k) != string.charAt(i)){
				return i;
			}
		}

		for(int i = k+1;i < string.length();i++){
			if(string.charAt(k) != string.charAt(i)){
				return i;
			}
		}
		return k;

	}
}

Measured memory_bytes: 24240
from sys import stdin

N = stdin.readline().rstrip()
S = stdin.readline().rstrip()


max = 0

N = int(N)

for i in range(1, N+1):
    X = set(S[:i])
    Y = set(S[i:N])
    if len(X&Y) > max:
        max = len(X&Y)


print(max)

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

int MAXX = 54000;
int main() {
  int n;
  cin >> n;
  rep(i, MAXX + 1) {
    if(i * 108 / 100 == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()

int cnt[2];
ll C[55][55];
int main() {
	int N, P, i, j;
	scanf("%d %d", &N, &P);
	for (i = 1; i <= N; i++) {
		int t;
		scanf("%d", &t);
		cnt[t % 2]++;
	}

	for (i = 0; i <= 50; i++) {
		C[i][0] = C[i][i] = 1;
		for (j = 1; j < i; j++) C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
	}

	ll ans = 0;
	for (i = 0; i <= cnt[0]; i++) {
		for (j = 0; j <= cnt[1]; j++) {
			if (j % 2 == P) ans += C[cnt[0]][i] * C[cnt[1]][j];
		}
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;

#define ll long long 
using vt = int; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

int main() {
	string s;
	cin >> s;
	int n = s.size();
	rep(i, n / 2) if (s.at(i) != s.at(n - 1 - i)) {
		cout << "No";
		return 0;
	}
	if (n == 3) {
		cout << "Yes";
		return 0;
	}
	rep(i, n / 4) if (s.at(i) != s.at(n / 2 - 1 - i)) {
		cout << "No";
		return 0;
	}
	rep(i, n / 4) if (s.at(n - 1 - i) != s.at(n / 2 + 1 + i)) {
		cout << "No";
		return 0;
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
const double eps = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e6 + 10;
const int  maxm = 300;
const int turn[4][2] = {{1, 0}, { -1, 0}, {0, 1}, {0, -1}};
//next_permutation
ll mod = 1e9 + 7;
int a[maxn];
int main()
{
        //freopen("out1.txt", "w", stdout);
        int n, k;
        int now;
        cin  >> n >> k;
        for (int i = 1; i <= n; i++)
        {
                scanf("%d", &now);
                a[now]++;
        }
        sort(a, a + 200001);
        int sum = 0;
        for (int i = 200000; i >= 200000 - k + 1; i--)
        {
                sum += a[i];
        }
        cout << n - sum << endl;
}



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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
int tem(int x){
    if(x<9)return x+1;
        else return 1;
}
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;cin>>n;
    int m=100;
    int ans=0;
    while(1){
        ans++;
        m*=1.01;
        if(m>=n){
            cout<<ans<<endl;return 0;
        }
    }
    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()))


a, b = [0], [0]

for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M

for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

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

int main() {
  
  int N, d;
  cin >> N;
  vector<int> D(N);
  
  for(int i=0; i < N; i++){
    cin >> d;
    D.at(i) = d;
  }
  
  sort(D.begin(), D.end());
  //for(int i=0; i < N; i++){
    //cout << D.at(i) << endl;
  //}
  vector<int> E(0);
  
  for(int i=1; i < N; i++){
    if(D.at(i - 1) != D.at(i)){
      E.push_back(D.at(i - 1));
    }
    else if(D.at(i - 1) == D.at(i)){
      continue;
    }
  }
  
  E.push_back(D.at(N - 1));
  //cout << E.push_back(D.at(N)) << endl;
  
  for(int i=1; i < E.size(); i++){
    //cout << E.at(i);
  }
  
  cout << E.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

typedef long long ll;
const int N = 23000000;
const int mod = 1e9 + 7;

ll ans;
int dig[N + 10], po[10];
int S, sum, r;

ll pow(ll x, ll y, int mod)
{
    ll ans = 1;
    for(; y; y >>= 1)
    {
        if (y & 1) ans = ans * x % mod;
         x = x * x % mod;
    }
    return ans;
}

ll work(int x)
{
    int tmp = S / x;
    return (pow(10LL, tmp - 1, mod) * 9 - x + 1 + mod) % mod;
}

int main()
{
    scanf("%d", &S);
    po[0] = 1; FOR(i, 1, 7) po[i] = po[i - 1] * 10;
    FOR(i, 0, 7) dig[po[i]] = 1;
    FOR(i, 1, N) dig[i] += dig[i - 1];
    FOR(i, 1, po[7] - 1)
    {
        sum -= dig[i - 1];
        while (sum + dig[r + 1] <= S) sum += dig[++r];
        if (sum == S) ++ans;
    }
    int tmp = S / 8;
    FOR(i, 1, tmp)
        if (S % i == 0) (ans += work(i)) %= mod; else ++ans;
    printf("%lld\n", ans % mod);
    return 0;
}


Measured memory_bytes: 89984
/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;

string s, t;
int n, ans;

int main(){
    #ifndef SAKO
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    #endif // SAKO
    ios_base::sync_with_stdio(0);

    cin >> n >> s >> t;
    ans = n + n;
	for (int i = 0; i < n; ++i){
		bool ok = 1;
		for (int j = 0; j + i < n; ++j)
			if (s[i + j] != t[j]){
                ok = 0;
                break;
			}
		if (ok)
        	ans = min(n + i, ans);
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdlib>
#include <istream>
#include <set>
#define rep0(i,n) for (long long int i = 0; i <= (n); ++i)
#define rep1(i,n) for (long long int i = 1; i <= (n); ++i)
#define REP(a,b) for (long long int i = a; i <= (b); ++i) 
#define MOD 100000007
#define ps push_back 
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	if (n == 7)printf("YES");
	else if(n == 5)printf("YES");
	else if(n == 3)printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 256
def selectionSort(A, N):
    s = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        A[i], A[minj] = A[minj], A[i]
        if i != minj:
            s += 1
    t = str(A[0])
    for i in range(1,N):
        t = t + " " + str(A[i])
    print(t)
    print(s)

n = int(input())
a = [int(i) for i in input().split()]

selectionSort(a, n)

Measured memory_bytes: 5600
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int nx[]={0,1,0,-1};
int ny[]={-1,0,1,0};
int w,h;
char mp[101][101];
int dfs(int y,int x);
int a,b;
int main()
{
  while(1){
    cin >> w >> h;
    if(w==0&&h==0){
      break;
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> mp[i][j];
	if(mp[i][j]=='@'){
	  a=i;
	  b=j;
	}
      }
    }
    cout << dfs(a,b) << endl;
  }
  return(0);
}

int dfs(int y,int x){
  if(0>y||0>x||y>=h||x>=w){
    return(0);
  }
  if(mp[y][x]=='#'){
    return(0);
  }
  mp[y][x]='#';
  int ans=0;
  for(int i=0;i<4;i++){
    ans=ans+dfs(y+ny[i],x+nx[i]);
  }
  return ans+1;
}
    



Measured memory_bytes: 3012
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#define mp make_pair
using namespace std;
typedef pair<string,int> P;
priority_queue<P> q;
string rec[10];
int main()
{
	string s;int k,tot=0;
	cin>>s>>k;int len=s.length(); 
	for(int i=1;i<=k;i++)
	for(int j=0;j+i-1<len;j++)
	{
		int flag=0;
		string str=s.substr(j,i);
		for(int ii=1;ii<=tot;ii++)
		if(rec[ii]==str) {flag=1;break;}
		if(flag) continue;
		if(tot<k) {q.push(mp(str,++tot));rec[tot]=str;}
		else
		{
			P p=q.top();q.pop();
			if(p.first<str) q.push(p);
			else
			{
				rec[p.second]=str;
				q.push(mp(str,p.second));
			}	
		}
	}
	P p=q.top();
	cout<<p.first<<endl;
	return 0;
}

Measured memory_bytes: 256