akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

const int N_MAX = 100;
int n, m;
int edges[N_MAX][N_MAX];

int solve() {
	bool visited[n];
	int result = 0;
	memset(visited, 0, sizeof(visited));
	typedef pair<int, int> P;
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(make_pair(0, 0));
	while (!que.empty()) {
		P current = que.top();
		que.pop();
		const int cost = current.first;
		const int pos = current.second;
		if (visited[pos]) continue;
		visited[pos] = true;
		result += cost;
		for (int i = 0; i < n; i++) {
			if (edges[pos][i] != -1) {
				que.push(make_pair(edges[pos][i], i));
			}
		}
	}
	return result;
}

int main () {
	while (scanf("%d", &n), n) {
		scanf("%d", &m);
		memset(edges, -1, sizeof(edges));
		for (int i = 0; i < m; i++) {
			int a, b, d;
			scanf("%d,%d,%d", &a, &b, &d);
			edges[a][b] = edges[b][a] = d / 100 - 1;
		}
		printf("%d\n", solve());
	}
	return 0;
}

Measured memory_bytes: 1268
s=input()
forward=int(s[0]+s[1])
backward=int(s[2]+s[3])
#print(forward,backward)

if 0<forward<=12:
    if 0<backward<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
if 0<backward<=12:
    if 0==forward or forward>12:
        print("YYMM")
if (0==forward or forward>12) and (0==backward or backward>12):
    print("NA")

Measured memory_bytes: 3060
#include <stdio.h>

int main (void)
{
  unsigned long x;
  int y500, y5;
  
  scanf("%lu", &x);
  
  y500 = x / 500;
  x -= y500 * 500;
  
  y5 = x / 5;
  
  printf("%lu", (1000*y500) + (5*y5));

  return 0;
}

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

int main(){
    int H, W;
    
    while(true){
        cin >> H >> W;
    
        if (H == 0 && W == 0){
            break;
        } else {
            for (int i = 0; i < H; i++){
                for (int j = 0; j < W; j ++){
                    if (i > 0 && i < H - 1 && j > 0 && j < W - 1) {
                        cout << '.';
                    } else {
                        cout << '#';
                    }
                }
                cout << endl;
            }
            cout << endl; 
        }
    }

    return 0;
}


Measured memory_bytes: 3056
//                             In The Name Of Allah
//                              Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 1e5 + 100, OO = 1e9 + 7, T = 1e6 + 10, mod = 1e9 + 7,  P = 6151, SQ = 280, lg = 70;
typedef pair <int, int> pii;

int fac[N], inv[N], M;
 
int pw(int x, int y) {
	if(y == 0)
		return 1;
	int cnt = pw(x, y / 2);
	cnt = (cnt * cnt) % M;
	cnt = (cnt * (y % 2 == 1 ? x : 1)) % M;
	return cnt;
}
 
void prepro() {
	fac[0] = 1;
	for(int i = 1; i <= N - lg; i++) 
		fac[i] = (fac[i - 1] * i) % M;
	inv[N - lg] = pw(fac[N - lg], M - 2);
	for(int i = N - lg - 1; i > -1; i--) 
		inv[i] = (inv[i + 1] * (i + 1)) % M;
}
 
int c(int x, int y) {
	return ((fac[x] * inv[y] % M) * inv[x - y]) % M;
}
 

int32_t main () {
	int n, ans = 0;
	cin >> n >> M;
	prepro();
	for(int i = 0; i <= 3 * n; i++) {
		for(int j = 0; j <= i; j++) {
			if(i + j * 2 > 3 * n || (3 * n - j * 2 - i) % 3 != 0)
				continue;
			int k = 3 * n - j * 2 - i;
			k /= 3;
			int cnt = fac[i] * fac[j] % M * fac[k] % M * pw(2, j) % M * pw(3, k) % M;
			cnt = pw(cnt, M - 2) % M;
			ans = (ans + fac[3 * n] * cnt % M) % M;
		}
	}
	cout << ans << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/


Measured memory_bytes: 1792
#include<bits/stdc++.h>
	using namespace std;
	#define rep(i,n) for(ll i=0;i<(n);i++)
	#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
	#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
	#define mem(u, vis) memset(u, vis, sizeof(u))
	#define ll long long
	#define ull unsigned long long
	#define MOD  1000000007
	#define MAX  1e9
	#define pb   push_back
	#define F    first
	#define S    second


	signed main() {
		ll t=1;
		//cin>>t;
		while(t--){
			ll n,k;
			cin>>n>>k;
			// ll d;
			// cin>>d;
			bool sn[n+1]={0};
			rep(i,k){
				ll p;
				cin>>p;
				// cout<<p<<endl;
				for(ll q = 0;q<p;++q){
					ll j;
					cin>>j;
					sn[j] = true;
				}
			}

			ll c = 0;
			FOR(i,1,n+1){
				// cout<<i<<" "<<sn[i]<<endl;
				if(!sn[i])c++;
			}
			cout<<c;
			
		}
		
	}

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

typedef pair <int, int> P;

const int N = 2005;

vector <int> tr[N];
vector <int> rec1;
vector <int> rec2;
int used[N];
int k;
queue <P> q;

void bfs(int x){
	int cnt1 = 0, cnt2 = 0, u, v, d;
	q.push({x, 1});
	used[x] = 1;
	while (!q.empty()){
		u = q.front().first; d = q.front().second; q.pop();
		if (d <= (k + 1) / 2) cnt1++;
		if (d <= (k + 1) / 2 - 1) cnt2++;
		for (int i = 0; i < tr[u].size(); i++){
			v = tr[u][i];
			if (!used[v]){
				q.push({v, d + 1});
				used[v] = 1;
			}
		}
	}
	rec1.push_back(cnt1);
	rec2.push_back(cnt2);
}

int main(){
	int n, u, v, ans, sum, maxx;
	scanf("%d %d",&n,&k);
	for (int i = 1; i <= n - 1; i++){
		scanf("%d %d",&u,&v);
		tr[u].push_back(v);
		tr[v].push_back(u);
	}
	ans = 0;
	for (int i = 1; i <= n; i++){
		rec1.clear();
		rec2.clear();
		memset(used, 0, sizeof(used));
		used[i] = 1;
		for (int j = 0; j < tr[i].size(); j++) bfs(tr[i][j]);
		if (k & 1){
			sum = 0; maxx = 0;
			for (int j = 0; j < tr[i].size(); j++){
				sum += rec2[j];
				maxx = max(maxx, rec1[j] - rec2[j]);
			}
			ans = max(ans, sum + maxx);
		}
		else{
			sum = 0;
			for (int j = 0; j < tr[i].size(); j++) sum += rec1[j];
			ans = max(ans, sum);
		}
	}
	printf("%d\n", n - 1 - ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, d, x;
  cin >> n >> d >> x;
  int sum = x;
  rep(i, n) {
    int a;
    cin >> a;
    sum += (d + a - 1) / a;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-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)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int n,k;
	cin >> n >> k;
	int ans=0;
	while(n>0){
		n /= k;
		ans++;
	}
	cout << ans << endl;


  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		long total = 0;
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		    total += arr[i];
		}
		long sum = 0;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < n - 1; i++) {
		    sum += arr[i];
		    min = Math.min(min, Math.abs(total - sum * 2));
		}
	    System.out.println(min);
	}
}


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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

long long n, cnt[102], dp[76];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n; dp[1] = 1;

    for(long long num = 2; num <= n; ++num){
        for(long long k = num, div = 2; k > 1;){
            if(k % div == 0){
                ++cnt[div]; k /= div;
            } else {
                ++div;
            }
        }
    }

    // dp[prime_id][qnt_filled]

    for(int pr = 2; pr <= 100; ++pr){ // could use a better lower bound
        for(int left = 75; left > 0; --left){
            for(int mult = cnt[pr]; mult > 0; --mult){

                // with `mult` amount of primes, we can do left * (mult + 1)
                // we see that using `mult`, we can form mult + 1 different divisors (see # of divisors rule)
                //     think of it as showing that there are mult + 1 different ways to use this new prime

                if(left * (mult + 1) > 75) continue;
                dp[left * (mult + 1)] += dp[left];

            }
        }
    }

    cout << dp[75] << "\n";

    return 0;

}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(20000000)


def dfs(node, distance):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size)


N = int(input())

G = [[] for i in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    G[u-1].append([v-1, w])
    G[v-1].append([u-1, w])

ans = [-1]*N
dfs(0, 0)
print(*ans, sep='\n')


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

using namespace std;

typedef long long ll;
typedef long double ld;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int hx[][6] = {{0, 0, 1, -1, -1, -1}, {1, 1, 1, -1, 0, 0}};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int MOD = 1000000000 + 0;
const int INF = 1 << 29;

#define TT_ template<typename T>inline
TT_ T sq(T x){return x*x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
#undef TT_
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue stringstream sync_with_stdio

#include <vector>

namespace {
struct BoolArray {
  int X;
  std::vector<int> flags;

  BoolArray(std::size_t N) : flags(N), X(0) {}
  void clear() { ++X; }
  bool get(int x) const { return flags[x] == X; }
  void set(int x) { flags[x] = X; }
};

}

struct MaxFlow {
  struct Edge {
    int to;
    int cap;
    int rev;
    Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
  };

  std::vector<std::vector<Edge>> G;
  BoolArray used;

  MaxFlow(int V) : G(V), used(V) {}

  void addEdge(int from, int to, int cap) {
    G[from].emplace_back(to, cap, G[to].size());
    G[to].emplace_back(from, 0, G[from].size() - 1);
  }

  int dfs(int v, int t, int f){
    if (v == t) return f;
    used.set(v);
    for (auto& e : G[v]) {
      if (used.get(e.to)) continue;
      if (e.cap <= 0) continue;
      int d = dfs(e.to, t, std::min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
    return 0;
  }
  int getFlow(int s, int t) {
    int flow = 0;
    while (1) {
      used.clear();
      int f = dfs(s, t, 1 << 29);
      if (f == 0) return flow;
      flow += f;
    }
  }
};

int main()
{
  int V = in(), E = in();
  MaxFlow mf(V);

  for (int i = 0; i < E; i++){
    int u = in(), v = in(), c = in();
    mf.addEdge(u, v, c);
  }
  cout << mf.getFlow(0, V - 1) << endl;
  return 0;
}

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

int main() {
	int num;
    cin >> num;
    
    int ans = 0;
    for(int i = 0; i < num; i++) {
    	int from, to;
        cin >> from >> to;
        ans += (to - from + 1);
    
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int mt[10],i,work,ii;
  for(i =0;i <10;i++){
    scanf("%d", &mt[i]);
  }
  for(i =0;i <10;i++){
    for(ii =0;ii <9;ii++){
      if(mt[ii]<mt[ii+1]){
	work=mt[ii];
	mt[ii]=mt[ii+1];
	mt[ii+1]=work;
      }
    }
  }
  printf("%d\n%d\n%d\n",mt[0],mt[1],mt[2]);
  return(0);
}

Measured memory_bytes: 600
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using P = pair<int,int>;
const int INF = 1000100100;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

struct DisjointSet{
    vector<ll> p;
    DisjointSet(ll n) : p(n){
        rep(i,n) p[i] = -1;
    }

    ll root(ll x){
        if(p[x] < 0) return x;
        return p[x] = root(p[x]);
    }

    ll num(ll x){
        return -p[root(x)];
    }

    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return;
        if(rx>ry) swap(rx,ry);
        p[rx] += p[ry];
        p[ry] = rx;
    }

    bool same(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main()
{
    ll n, m; cin >> n >> m;
    ll a[m], b[m];
    rep(i,m){
        cin >> a[i] >> b[i];
        --a[i], --b[i];
    }

    vector<ll> res;

    DisjointSet dis = DisjointSet(n);

    ll ans = n*(n-1)/2;
    res.push_back(ans);
    for(int i=m-1; i>0; i--){
        if(!dis.same(a[i],b[i])) ans -= dis.num(a[i])*dis.num(b[i]);
        dis.unite(a[i], b[i]);
        res.push_back(ans);
    }   
    reverse(res.begin(), res.end());
    for(ll r: res) cout << r << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int r;
  cin >> r;
  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}


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

int main(void) {
    char s[11];
    scanf("%s", s);
    if (strlen(s) < 4) {
        printf("No\n");
        return 0;
    }
    if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright  : @Huki_Hara
# Created    : 2015-03-01

while True:
    try:
        d=int(input())
    except:
        break
    s=0
    for i in range(0,600-d+1,d):
        s+=d*i**2
    print(s)

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

int main() {
  int N,W,H;
  cin >> H >>W;
  vector<string>a(H);
  for(int i =0;i<H;i++){
	cin >> a.at(i);
    } 
  for(int i =0;i<H+2;i++){
  	if(i==0||i==H+1){
    	for(int x=0;x <W+2;x++){
        cout << "#";
        }
      cout << endl;
    }
    else{
    cout << "#"<<a.at(i-1) << "#" << endl;
    }
  }

}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int a[100010];
int ans=-1;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++)
	{
		if(ans==-1 || min(a[i],a[n]-a[i])>min(ans,a[n]-ans))ans=a[i];
	}
	printf("%d %d",a[n],ans);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
int n,y,i,j,k;
cin >> n >> y;;
for(i=0;i<=n;i++){
for(j=0;j<=n;j++){
k=n-i-j;
if(k>=0 && 1000*i+5000*j+10000*k==y){
printf("%d %d %d\n",k,j,i);
return 0;
}
}
}
printf("-1 -1 -1\n");
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main(){
	int n;
	int card[3][101];
	int use[200][3];
	int a,b,c,r;
	memset(card,0,sizeof(card));
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		use[i][0]=a;
		use[i][1]=b;
		use[i][2]=c;
		card[0][a]++;
		card[1][b]++;
		card[2][c]++;
		}
	for(int i=0;i<n;i++){
		r=0;
		if(card[0][use[i][0]]==1) r+=use[i][0];
		if(card[1][use[i][1]]==1) r+=use[i][1];
		if(card[2][use[i][2]]==1) r+=use[i][2];
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 1028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

/**
 * Pasta
 * JOI 11th, Pre 4
 */
public class Main {

	static final int MOD = 10000;
	static int N;
	static int[] AB;
	static int[][][] memo;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		N = parseInt(line.substring(0, line.indexOf(' ')));
		int K = parseInt(line.substring(line.indexOf(' ') + 1));

		AB = new int[N + 1];

		for (int i = 0; i < K; i++) {
			line = br.readLine();
			int A, B;
			A = parseInt(line.substring(0, line.indexOf(' ')));
			B = parseInt(line.substring(line.indexOf(' ') + 1));
			AB[A] = B;
		}

		memo = new int[N + 1][4][3];

		for (int i = 0; i <= N; i++) {
			for (int j = 0; j <= 3; j++) {
				Arrays.fill(memo[i][j], -1);
			}
		}

		int count = solve(0, 0, 0);

		System.out.println(count);

	}

	//d ??\????????£?¶? s ?????????????????? p ????£??????????
	static int solve(int d, int p, int s) {

		if (d == N) return 1;

		if (memo[d][p][s] != -1) return memo[d][p][s];

		int ret = 0;

		if (AB[d + 1] != 0) {
			if (p == AB[d + 1]) {
				if (s < 2) ret = solve(d + 1, AB[d + 1], s + 1);
			} else {
				ret = solve(d + 1, AB[d + 1], 1);
			}
		} else {
			for (int np = 1; np <= 3; np++) {
				if (np == p) {
					if (s < 2) ret += solve(d + 1, np, s + 1);
				} else {
					ret += solve(d + 1, np, 1);
				}
			}
		}

		memo[d][p][s] = ret % MOD;

		return memo[d][p][s];
	}
}

Measured memory_bytes: 24416
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    s.push_back(' ');
    for (int i = 0; i < s.size() - 2; ++i) {
        if (s.at(i) == s.at(i + 1)) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        } else if (s.at(i) == s.at(i + 2)) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}


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

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

    int s=S.size(), cnt=0;

    for(int i=0; i<s; i++){
        if(i%2==0 && (S.at(i)=='R'||S.at(i)=='U'||S.at(i)=='D')) cnt++;
        else if(i%2!=0 && (S.at(i)=='L'||S.at(i)=='U'||S.at(i)=='D')) cnt++;
    }

    if(cnt==s) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %f", d, r, f);
	return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int n,cnt=0;
    while(cin>>n,n){
        vector<string>S(n);
        vector<int>v(n),len(v);
        r(i,n)cin>>S[i]>>v[i],len[i]=S[i].size();

        string t;
        cin>>t;
        int m=t.size();

        vector<int>dp(m+1,-1e9);
        dp[0]=0;

        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(i+len[j]>m)continue;
                if(t.substr(i,len[j])!=S[j])continue;
                dp[i+len[j]] = max(dp[i+len[j]],dp[i]+v[j]);
            }
        }

        vector<int>DP(dp[m]+1,1e9);
        DP[0]=0;

        for(int i=0;i<dp[m];i++){
            for(int j=0;j<n;j++){
                if(i+v[j]>dp[m])continue;
                DP[i+v[j]] = min( DP[i+v[j]] , DP[i]+len[j] );
            }
        }

        cout<<"Case "<<++cnt<<": "<<DP[dp[m]]<<endl;
    }
}


Measured memory_bytes: 3144
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=[int(input()) for _ in range(n)]
    Left=[0]*n
    Left[0]=A[0]
    Right=[0]*n
    Right[-1]=A[-1]

    for i in range(1,n):
        Left[i]=max(A[i],Left[i-1])
    for i in range(n-2,-1,-1):
        Right[i]=max(A[i],Right[i+1])

    for i in range(n):
        if(i==0):
            print(Right[1])
        elif(i==n-1):
            print(Left[n-2])
        else:
            print(max(Left[i-1],Right[i+1]))
resolve()

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

int main() {
  int N; cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) cin >> d.at(i);
  sort(d.begin(), d.end());
  int ans = 0;
  for (int i = 1; i <= 100000; i++) {
    int cnt = N - (lower_bound(d.begin(), d.end(), i) - d.begin());
    if (cnt == N / 2) ans++;
  }
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

map<ll, int> c, d;

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

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        c[i - a]++, d[i + a]++;
    }

    vector<pair<ll, int>> cc(c.begin(), c.end());
    vector<pair<ll, int>> dd(d.begin(), d.end());

    int i = 0, j = 0;
    ll s = 0;
    while (i < cc.size() && j < dd.size()) {
        if (cc[i].first == dd[j].first) {
            s += ((ll) cc[i].second * dd[j].second);
            i++;
            j++;
        } else if (cc[i].first < dd[j].first) {
            i++;
        } else {
            j++;
        }
    }

    cout << s;

    return 0;
}

Measured memory_bytes: 32020
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000
#define ll long long
using namespace std;
int main()
{
    int N;
    cin>>N;
    string a;
    char al[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    string alp="0ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    cin>>a;
    rep(i,a.size())cout<<al[(alp.find(a[i])+N-1)%26];
    cout<<"\n";
}


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

/*long long power(long long a,int k)
{
	long long ans=1,y=a;
	while(k!=0)
	{
		if(k%2!=0)
			ans=ans*y%mod;
		y=y*y%mod;
		k=k/2;
	}
	return ans;
}
*/


long long power(long long a,int k)
{
	long long ans=1,y=a;
	while(k!=0)
	{
		if(k%2==1)
		    ans=ans*y%mod;
		y=y*y%mod;
		k/=2;
	}
	return ans;
}
long long fun[1000005],ans=1;
int main()
{
	long long n,m;
	scanf("%lld%lld",&n,&m);
	fun[0]=1;
	for(int i=1; i<1000000; i++)
		fun[i]=fun[i-1]*i%mod;
	for(int i=2; i*i<=m; i++)
		if(m%i==0)
		{
			long long s=0;
			while (m%i==0)
			{
				m=m/i;
				s++;
			}
			ans=ans*fun[n+s-1]%mod*power(fun[n-1], mod-2)%mod*power(fun[s], mod-2)%mod;
		}
	if(m>1)
		ans=ans*n%mod;
	printf("%lld\n",ans);
	return 0;
}/*
for(register int i=1;i*i<=m;i++)
    if(m%i==0)
    {
    	long long s=0;
    	while(m%i==0)
    	{
    		m/=i;
    		s++;
		}
		ans=ans*fun[n-1+s]%mod*power(fun[n-1],mod-2)%mod*power(fun[s],mod-2)%mod;
	}*/

Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){

  int n;
  bool d[100][100]; //x,y
  int x,y;
  int p;
  char c;

  while(cin >> n, n){

    memset(d,false,sizeof(d));

    while(n--){
      cin >> x >> y;
      d[x][y] = true;
    }

    x = y = 10;
    cin >> n;
    while(n--){
      cin >> c >> p;
      
	for(int i=0;i<p;i++){
	  if(c == 'N') y++;
	  if(c == 'E') x++;
	  if(c == 'W') x--;
	  if(c == 'S') y--;

	  if(d[x][y]) d[x][y] = false;
	}
    }

    bool ans = true;
 
    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
	if(d[i][j]) ans = false;
      }
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1168
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N; cin >> N;
    int judge = 0;
    for(int i=11; i<=N; i+=2) //とりあえず11から
    {
        int count = 0;
        for(int j=1; j<=i; j++) //役数の判定
        {
            if(i%j == 0) count++;
        }
        if(count == 8) judge++;
    }
    cout << judge;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int a, b;
signed main(){
  cin>>a>>b;int k = INF;
  if(a == b)k = 0;
  else if((a+b)% 2 == 0)k = (a+b)/2;
  if(k == INF)cout << "IMPOSSIBLE" << endl;
  else cout << k << endl;
}


Measured memory_bytes: 256
N = int(input())
S = list(map(str, input().split()))

P, W, G, Y = 0, 0, 0, 0

for i in range(N):
  if S[i] == 'P':
    P = 1
  elif S[i] == 'W':
    W = 1
  elif S[i] == 'G':
    G = 1
  else:
    Y = 1
    
if P+W+G+Y == 3:
  print('Three')
else:
  print('Four')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	int ans = a[0];
	for(int i = 0; i < n; i++) {
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
l = [int(x) for x in input().split(" ")]
matrix = []

for _ in range(N):
	matrix.append([])

for index, i in enumerate(l):
	for _ in range(i):
		matrix[index].append(1)
	while len(matrix[index]) != max(l):
		matrix[index].append(0)

def trans(A:list) -> list:
    ans = []
    for col in range(len(A[0])):
        l = []
        for line in range(len(A)):
            l.append(A[line][col])
        ans.append(l)
    return ans    

ll = trans(matrix)
count = 0
for line in reversed(ll):
	mark = False
	for index, i in enumerate(line):
		if i == 1 and mark == False:
			count += 1
			line[index] = 0
			mark = True
		
		elif i == 1 and mark == True:
			line[index] = 0

		elif i == 0:
			mark = False
print(count)



Measured memory_bytes: 3188
/** I can do this all day **/

#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"

//void add(int I, int value){seg[I += MAXN] = value;for (I >>= 1; I; I >>= 1){seg[I] = __gcd(seg[I << 1], seg[I << 1 | 1]);}}

//int query(int l, int r){int ans = seg[l + MAXN];for (l += MAXN, r += MAXN + 1; l < r; l >>= 1, r >>= 1){if(l & 1) ans = __gcd(ans, seg[l ++]);if(r & 1) ans = __gcd(ans, seg[-- r]);}return ans;}

const int MAXN = 1e6 + 10;
ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 8e18;
const int LOG = 22;

ll pw(ll a , ll b, ll mod)  { return (!b ? 1 : (b & 1 ? (a * pw(a * a % mod, b / 2, mod)) % mod : pw(a * a % mod, b / 2, mod))); }

vector < int > G[MAXN];

ll dp[MAXN][2], pl[MAXN], pr[MAXN], Ans[MAXN], Up[MAXN];

void dfs_down(int v, int par)
{
        dp[v][0] = dp[v][1] = 1;
        for(auto u : G[v])
        {
                if(u == par)continue;
                dfs_down(u, v);
                dp[v][0] = (dp[v][0] * (dp[u][0] + dp[u][1])) % MOD;
        }
}

void dfs_up(int v, int par)
{
        for(int i = 0; i <= (int)G[v].size() + 1; i++) { pl[i] = pr[i] = 1; }
        ll kol = 1 % MOD, child = (int)G[v].size() - (par != 0);
        int i = 1;
        for(auto u : G[v])
        {
                if(u == par)continue;
                kol = (kol * (dp[u][0] + dp[u][1])) % MOD;
                pl[i] = kol; i++;
        }
        i = child;
        Ans[v] = (kol * ((Up[v] + 1) % MOD) % MOD); kol = 1;
        for(int j = (int)G[v].size() - 1; ~j; j--)
        {
                int u = G[v][j];
                if(u == par)continue;
                kol = (kol * (dp[u][0] + dp[u][1])) % MOD; pr[i] = kol; i--;
        }
        i = 1;
        for(int j = 1; j <= (int)G[v].size(); j++)
        {
                if(G[v][j - 1] == par)continue;
                Up[G[v][j - 1]] = ((Up[v] + 1) % MOD) * ((pl[i - 1] * pr[i + 1]) % MOD) % MOD;
                i++;
        }
        for(auto u : G[v])
        {
                if(u == par)continue;
                dfs_up(u, v);
        }
}

int main(){
    fast_io;
    //cout << fixed << setprecision(15);
    //scanf("%d %d %f %lld %s %c", &x);
    //printf("%d %d %f %lld %s %c", x);
    int n;
    cin >> n >> MOD;
    for(int i = 1; i < n; i++)
    {
            int a, b;
            cin >> a >> b;
            G[a].push_back(b);
            G[b].push_back(a);
    }
    dfs_down(1, 0);
    dfs_up(1, 0);
    for(int i = 1; i <= n; i++)
    {
            cout << Ans[i] << endl;
    }
    return 0;
}

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

int a[20];
int x[20][20],y[20][20];

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = 0; j < a[i]; j++) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }

    int ans = 0;
    for (int bit = 0; bit < (1<<n); bit++) {
        bool flag = true;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if(bit & (1<<i)) {
                for(int j = 0; j < a[i]; j++) {
                    //if((bit >> x[i][j])==0 & y[i][j]==1) flag = false;
                    //if((bit >> x[i][j])==1 & y[i][j]==0) flag = false;
                    if(((bit >> (x[i][j])) & 1) ^ y[i][j]) flag = false;
                }
                cnt++;
            }
        }
        if(flag) ans = max(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;

int main() {

  vec1 a(5);
  for(int i = 0; i < 5; i++) { cin >> a.at(i); }
  
  int m = 0;
  int c = 0;
  int tmp = 0;
  int ans = 0;
  for(int i = 0; i < 5; i++) {
    if(a.at(i) %  10 != 0) {
      c = 0;
      for(int j = 0; j < 10; j++) {
        if(a.at(i) % 10 == 0) {
          break;
        } else {
          a.at(i)++;
          c++;
        }
      }
      tmp = tmp + c;
      m = max(m, c);
    }
    ans = ans + a.at(i);
  }
  ans = ans - m;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> red(n), blue(n);
    for (int i = 0; i < n; i++) {
        cin >> red[i].first >> red[i].second;
    }
    for (int i = 0; i < n; i++) {
        cin >> blue[i].first >> blue[i].second;
    }
    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());

    int cnt = 0;
    vector<bool> used(n, false);
    for (int i = 0; i < n; i++) {
        auto now = blue[i];
        int t = 0;
        int maxx_idx = -1;

        while (t < n && red[t].first < now.first) {
            if (red[t].second < now.second && !used[t]) {

                if (maxx_idx == -1 || red[maxx_idx].second < red[t].second) {
                    maxx_idx = t;
                }
            }

            t++;
        }
        if (maxx_idx == -1)
            continue;

        cnt++;
        used[maxx_idx] = true;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n;
	int a[100];
	int k;
	int i,j;
	long int answer1=0;
	long int answer2=0;
	
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
		scanf("%d",&k);
		a[i]=k;
	}
	
	for(i=1;i<=n;i++)
		answer1 += (1-a[i])*(1-a[i]);
	
	for(j=2;j<=100;j++){
		for(i=1;i<=n;i++)
			answer2 += (j-a[i])*(j-a[i]);
		if(answer1>=answer2)
			answer1=answer2;
		answer2=0;
	}
	
	printf("%ld",answer1);
	return 0;
}

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

int main() {
	long long int n,k;
	cin>>n>>k;
	long long int a[n],sum[n];
	for(long long int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	fill(sum,sum+n,INT_MAX);
				sum[0]=0;
	for(long long int i=1;i<n;i++)
	{ 
		for(long long int j=1;j<=k;j++)
		{
			if(j<=i)
			{
		if((sum[i-j]+abs(a[i]-a[i-j])<sum[i]))
		{
		sum[i]=sum[i-j]+abs(a[i]-a[i-j]);
		}
			}
	}}
	cout<<sum[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

ll T1, T2, A1, A2, B1, B2;

int main() {
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

    ll la = A1*T1+A2*T2;
    ll lb = B1*T1+B2*T2;
    if (la == lb) {
        cout << "infinity" << endl;
        return 0;
    }

    if (la > lb) {
        swap(A1, B1);
        swap(A2, B2);
        swap(la, lb);
    }

    if (A1*T1 < B1*T1) {
        cout << 0 << endl;
        return 0;
    }

    ll d = lb - la;
    ll x = A1*T1 - B1*T1;

    ll c = x / d * 2 + 1;
    if (x % d == 0) c -= 1;
    cout << c << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N,X; cin >> N >> X;
    vector<int> M(N);
    rep(i,N) cin >> M[i];

    sort(M.begin(),M.end());
    int ans = N;
    rep(i,N) X -= M[i];
    ans += X/M[0];
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if((A+B)%2 == 0){
      System.out.println((A+B)/2);
    } else {
      System.out.println("IMPOSSIBLE");
    }
  }
}

Measured memory_bytes: 21972
#include <stdio.h>

int main(){

    long n, k;
    long w[100001];
    long wc, wt;
    long min, max;
    long p;
    long i;

    scanf( "%ld%ld", &n, &k);

    for( i=0L; i<n; i++ ){
        scanf( "%ld", &w[i] );
        if( min < w[i] ) min = w[i];
        max += w[i];
    }



    min = 0L;  
    while( min < max ){

        p = min + ( max - min )/2L;
        //printf( " [%ld]%ld:%ld\n", p, min, max );

        // in: p, out; wc
        wt = 0L; wc = 0L; 
        for( i=0; i<n; i++ ){
            if( p < w[i] ){  wt=0L; wc=k+1; break;} 
            wt += w[i];
            
            if( wt > p ){ 
                //printf( "  %ld:%ld@%ld\n", wc, wt, w[i] );
                wt = w[i];
                wc++;
            }else if( wt == p){
                //printf( "  %ld:%ld@%ld\n", wc, wt, w[i] );
                wt = 0L;
                wc++;
            }
        }
        if( wt > 0 ) wc++;
        
        if( k < wc ) min = p + 1L;
        if( k >= wc ) max = p;
    }
    

    printf( "%ld\n", min );
    return 0;
}



Measured memory_bytes: 2568
from collections import deque
def solve(n,t):
  q=deque([])
  for i in range(n):
    l=list(input().split())
    q.append(l)
  time=0
  while not len(q)==0:
    x=q.popleft()
    if int(x[1])-t>0:
      x[1]=str(int(x[1])-t)
      time+=t
      q.append(x)
    else:
      print(x[0]+" "+str(time+int(x[1])))
      time+=int(x[1])
n,t=map(int,input().split())
solve(n,t)


Measured memory_bytes: 14464
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] count = new int[n];
		for (int i = 0; i < n; i++) {
			count[sc.nextInt() - 1]++;
		}

		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			if (count[i] > 0) list.add(count[i]);
		}

		Collections.sort(list);
		Collections.reverse(list);

		int ans = n;
		for (int i = 0; i < k && i < list.size(); i++) {
			ans -= list.get(i);
		}

		out.println(ans);
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
}

Measured memory_bytes: 26092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    string T;
    cin >> T;
    REP(i,(int)T.size()){
        if(T[i] == '?') T[i] = 'D';
    }
    cout << T << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 3776
class Hoge
{
    static void Main()
    {
        const int MAX = 9;
        for (var i = 1; i <= MAX; ++i)
        {
            for (var j = 1; j <= MAX; ++j)
            {
                var result = i * j;
                System.Console.WriteLine(i + "x" + j + "=" + result);
            }
        }
    }
}

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

int main(int argc, const char * argv[]) {
    int N;
    
    cin >> N;
    if (N == 1) {
        cout << "Hello World" << endl;
    } else if (N == 2) {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
//typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x, int y):x(x), y(y){}
	P(){}
};

/** Problem0244 : Hot Spring Trip **/
int cost[300][300];

int main()
{
	int N, M;
	
	while (cin>>N>>M, N||M) {
		rep(i, 300) rep(j, 300)
			cost[i][j] = i==j?0:INF;
	
		rep(i, M) {
			int a, b, c; cin>>a>>b>>c;
			a--, b--;
			cost[a][b] = cost[b][a] = c;
		}
		
		vector<P> can_free;
		rep(i, N) {
			rep(j, N) {
				if (cost[i][j]!=INF && i!=j) {
					rep(k, N) {
						if (cost[j][k]!=INF && i!=k && j!=k)
							can_free.push_back(P(i, k));
					}
				}
			}
		}
		
		rep(k, N) {
			rep(i, N) {
				rep(j, N) {
					cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
				}
			}
		}
		
		int ans=cost[0][N-1];
		rep(i, can_free.size()) {
			ans = min(cost[0][can_free[i].x]+cost[can_free[i].y][N-1], ans);
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 1580
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  int n;
  cin>>n;
  n=24-n;
  n+=24;
  cout<<n<<endl;
 
  
  
  

}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdlib.h>
using namespace std;
long long n,k,i,j,a[100004],f[100005];
int main()
{
    cin>>n;
    cin>>k;
    for (i=1;i<=n;i++)
        cin>>a[i];
    f[1]=0;
    f[2]=abs(a[2]-a[1]);
    for (i=3;i<=n;i++)
    {
        f[i]=9999999999;
        for (j=i-1;j>=i-k;j--)
        {
            if (j>=1) if (f[i]>f[j]+abs(a[i]-a[j])) f[i]=f[j]+abs(a[i]-a[j]);
        }
    }
    cout<<f[n];
}


Measured memory_bytes: 1792
import scala.io.Source.stdin

object Main {
  def euclid(m:Int,n:Int):Int = if(n==0) m else euclid(n,m%n)
  def main(args:Array[String]) =
    stdin.getLines.foreach { s=>
      val n = s.split(" ").map(_.toInt)
      println(euclid(n(0),n(1)))
    }
}

Measured memory_bytes: 43792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <set>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

int main(void){
    int n;
    cin >> n;
    int a[n];
    vector<int> tmp(1000005, 0);
    REP(i,n){
        cin >> a[i];
        tmp[a[i]]++;
    }

    bool pairwise = true;
    for(int i = 2; i < 1000005; i++){
        int ctr = 0;
        for(int j = i; j < 1000005; j+= i){
            ctr += tmp[j];
        }
        if(ctr > 1){
            pairwise = false;
        }
    }
    if(pairwise){
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int g = 0;
    REP(i,n){
        g = gcd(g, a[i]);
    }
    if(g == 1){
        cout << "setwise coprime" << endl;
    } else{
        cout << "not coprime" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 11088