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

constexpr int mod = 1e9 + 7;

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

    vector<int> dp(k + 2);
    dp[0] = 1;
    for(int i = 0; i < n; ++i) {
        vector<int> nxt(k + 2);
        for(int j = 0; j <= k; ++j) {
            const int l = j, r = min(j + a[i] + 1, k + 1);
            (nxt[l] += dp[j]) %= mod;
            (nxt[r] += mod - dp[j]) %= mod;
        }
        for(int j = 0; j <= k; ++j) {
            (nxt[j + 1] += nxt[j]) %= mod;
        }
        dp = move(nxt);
    }

    cout << dp[k] << endl;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
p = 2 ** n
inf = 10 ** 9
dp = [inf] * p
dp[0] = 0
for i in range(m):
  a, b = map(int, input().split())
  c = sum([2 ** (j - 1) for j in list(map(int, input().split()))])
  for k in range(p):
    if dp[k|c] > dp[k] + a:
      dp[k|c] = dp[k] + a
      
if dp[-1] == inf:
  print(-1)
else:
  print(dp[-1])

Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n=sc.nextInt(),p=sc.nextInt();
			if(n==0&&p==0) break;
			int[] person = new int[n];
			Arrays.fill(person, 0);
			int p_inBox=p;
			boolean isEnd = false;
			int result=0;
			for(;;){
				for(int i=0;i<n;i++){
					if(person[i]==p) {
						isEnd=true;
						result=i;
						break;
					}
					if(p_inBox==0){
						if(person[i]!=0){
							p_inBox=person[i];
							person[i]=0;
						}
					}else{
						p_inBox--;
						person[i]++;
					}
				}
				if(isEnd) break;
			}
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 20192
#include <bits/stdc++.h>
#include <string>
#include <vector>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

ll count(const string &s){
    if(s.size() == 0) return 0;
    int cnt = 0;
    ll ret = 0;
    rep(i,s.size()){
        if(s[i] == ')'){
            ret += i-cnt;
            cnt++;
        }
    }

    return ret;
}

int main(){
    string s;cin>>s;
    string temp = "";
    ll ans = 0;
    rep(i,s.size()){
        if(s[i]=='A') temp.push_back('(');
        else if(i>0 && s[i-1]=='B' && s[i] == 'C'){
            temp.push_back(')');
        }else if(i<s.size()-1&&s[i]=='B'&&s[i+1]=='C') continue;
        else{
            //cout << temp << endl;
            ans += count(temp);
            temp ="";
        }
    }
    if(temp.size()) {
        //cout << temp << endl;
        ans+=count(temp);
    }

    cout << ans << endl;
}

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


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

  vector<string> dict;
  int pointer = 0;
  
  /*
  // 1文字目を辞書登録
  dict.push_back(S.substr(0,1));
  pointer++;
  */
  
  for(;;){
    
    // 残りが2文字かつaaのように続き文字でないかチェック
    // 続き文字なら2文字ごとdictに追加して終了
    if(pointer == S.size() - 2){
      if(S[pointer] == S[pointer+1]){
        dict.push_back(S.substr(pointer,2));
        break;
      }
    }
    
    if(pointer == 0){
      // 1文字目を辞書登録
      dict.push_back(S.substr(0,1));
      pointer++;
    }
    
    if(dict.back().size() == 1){
      if(S.substr(pointer,1) != dict.back()){
        dict.push_back(S.substr(pointer,1));
        pointer++;
      }
      else{
        dict.push_back(S.substr(pointer,2));
        pointer += 2;
      }
    }
    else{
        dict.push_back(S.substr(pointer,1));
        pointer++;
    }
    

    
    if(pointer > S.size() - 1){
      break;
    }
  }

  cout << dict.size() << endl;

}

    
    

Measured memory_bytes: 10996
import java.util.*;

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

    for (int i=0;i<h;++i){
      for (int j=0;j<w;++j){
        a[i][j] =sc.nextInt();
      }
    }

    ArrayList<int[]> list = new ArrayList<int[]>();
    
    for(int i = 0; i < h; i++) {
        if(i % 2 == 0) {
          for(int j = 0; j < w; j++) {
            if((i + j) < h + w - 2) {
              if(a[i][j] % 2 == 1) {
                int[] s = {i, j};
                int[] t = new int[2];
                list.add(s);
                if(j < w - 1) {
                  a[i][j + 1]++;
                  t[0] = i;
                  t[1] = j + 1;
                } else {
                  a[i + 1][j]++;
                  t[0] = i + 1;
                  t[1] = j;
                }
                list.add(t);
              }
            }
          }
        }   else {
            for(int j = w - 1; j >= 0; j--) {
              if((!((i == h - 1) && (j == 0)))) {
                if(a[i][j] % 2 == 1) {
                  int[] s = {i, j};
                  int[] t = new int[2];
                  list.add(s);
                  if(j > 0) {
                    a[i][j - 1]++;
                    t[0] = i;
                    t[1] = j - 1;
                  } else {
                    a[i + 1][j]++;
                    t[0] = i + 1;
                    t[1] = j;
                  }
                  list.add(t);
                }
              }
            }
          }
        }

    int n = 0;
    int p = 1;
    for(int i = 0; i < list.size() - 1; i++) {
      int[] s = list.get(i);
      int[] t = list.get(i + 1);
      if(((s[0] != t[0]) || (s[1] != t[1])) && (p == 1)) {
        p = 0;
        n++;
      } else {
        p = 1;
      }
    }  
    System.out.println(n);

    p = 1;
    for(int i = 0; i < list.size() - 1; i++) {
      int[] s = list.get(i);
      int[] t = list.get(i + 1);
      if(((s[0] != t[0]) || (s[1] != t[1])) && (p == 1)) {
        String str = "";
        str += (s[0] + 1);
        str += (" ");
        str += (s[1] + 1);
        str += (" ");
        str += (t[0] + 1);
        str += (" ");
        str += (t[1] + 1);
        System.out.println(str);
        p = 0;
      } else {
        p = 1;
      }
    }
  }
}

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

int main()
{
	int n;
	cin >> n;

	int taro_c = 0, hanako_c = 0;
	int taro_p = 0, hanako_p = 0;

	for (int i = 0; i < n; i++)
	{
		string taro, hanako;
		cin >> taro >> hanako;

		int max = (taro.length() > hanako.length()) ? taro.length() : hanako.length();

		for (int i = 0; i < max; i++)
		{
			taro_c = taro[i];
			hanako_c = hanako[i];

			if(taro_c != hanako_c)
			{
				if (taro_c > hanako_c) taro_p += 3;
				if (taro_c < hanako_c) hanako_p += 3;
				break;
			}
			else
			{
				if (i == taro.length() - 1 && i < hanako.length() - 1)
				{
					hanako_p += 3;
					break;
				}
				else if (i == hanako.length() - 1&& i < taro.length() - 1)
				{
					taro_p += 3;
					break;
				}
				else if (i == hanako.length() - 1 && i == taro.length() - 1)
				{
					taro_p += 1;
					hanako_p += 1;
				}
			}
		}
	}
	cout << taro_p << " " << hanako_p << endl;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	int a, b; 
	cin >> n >> a >> b;
	int A , B ;
	B = b ;
	A = n * a ;
	int ans = min ( A , B );
	cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n, m, p, A, B;
int a[9][9][9], b[9][9];
bool solve() {
	for (int i = -1; i <= 1; i++) {
		for (int j = -1; j <= 1; j++) {
			for (int k = -1; k <= 1; k++) {
				if (i == 0 && j == 0 && k == 0)continue;
				for (int I = 1; I <= n; I++) {
					for (int J = 1; J <= n; J++) {
						for (int K = 1; K <= n; K++) {
							if (a[I][J][K] == 0)continue;
							int b = a[I][J][K]; int cx = I, cy = J, cz = K;
							for (int L = 0; L < m; L++) {
								if (b != a[cx][cy][cz])goto E;
								cx += i; cy += j; cz += k;
							}
							return true;
						E:;
						}
					}
				}
			}
		}
	}
	return false;
}
int main() {
	while (true) {
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				for (int k = 0; k < 9; k++) {
					a[i][j][k] = 0; b[i][j] = 0;
				}
			}
		}
		cin >> n >> m >> p;
		if (n == 0)break;
		int cnt = 0;
		for (int i = 1; i <= p; i++) {
			cin >> A >> B;
			if (cnt >= 1)continue;
			b[A][B]++; a[A][B][b[A][B]] = (i - 1) % 2 + 1;
			if (solve()) { cnt = i; }
		}
		if (cnt == 0)cout << "Draw" << endl;
		else {
			if (cnt % 2 == 1)cout << "Black ";
			if (cnt % 2 == 0)cout << "White ";
			cout << cnt << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
    std::vector<int> v;
    std::vector<int> w;
    int n;
    std::cin >> n;
    while (n-- > 0) {
        int m;
        std::cin >> m;
        v.push_back(m);
    }
    std::cin >> n;
    while (n-- > 0) {
        int m;
        std::cin >> m;
        w.push_back(m);
    }
    int c = 0;
    for (auto&& e: w) {
        if (std::find(v.begin(), v.end(), e) != v.end()) {
            ++c;
        }
    }
    std::cout << c << std::endl;
}



Measured memory_bytes: 3240
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
     cin>>a>>b;
    if(a>0)cout<<"Positive";
    else if(a==0||(a<0&&b>0))cout<<"Zero";
    else if((abs(b)-abs(a))%2!=0)cout<<"Positive";
    else cout<<"Negative";
	system("pause");
	return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vvi g;
vi a;

bool dfs(int v,int b){
	a[v]=b;
	bool flag=0;
	for(int u=0;u<n;u++) if(g[v][u]==1){
		if(a[u]!=-1){
			if(a[u]==b) return 1;
		}
		else flag|=dfs(u,1-b);
	}
	return flag;
}

int main(){
	cin>>n;
	g=vvi(n,vi(n));
	a=vi(n,-1);
	for(int i=0;i<n;i++) for(int j=0;j<n;j++){
		char c;
		int x;
		cin>>c;
		if(c=='0') x=inf;
		else x=1;
		if(i==j) x=0;
		g[i][j]=x;
	}
	if(dfs(0,0)){
		cout<<-1<<endl;
		return 0;
	}
	for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
	int res=0;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) res=max(res,g[i][j]);
	cout<<1+res<<endl;
}

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

using namespace std;

int main(){
    int n, cnt = 0, ans = 0; cin >> n;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= i; ++j){
            if(i % j == 0){
                cnt++;
            }
        }
        if(cnt == 8 && i % 2 != 0){
            ans++;
        }
        cnt = 0;
    }
    cout << ans;
    return 0;

}


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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;

/*************************************************************************/

void dfs(int v, int par, VI &a, VVI &g, VB &dp) {
    dp[v] = false;
        
    for (int u : g[v]) if (u != par && a[u] < a[v]) {
        dfs(u, v, a, g, dp);
        
        if (!dp[u]) {
            dp[v] = true;
        }
    }
}

VI solve(int n, VI &a, VVI &g) {
    VI ans;
    FOR(i,0,n-1) {
        VB dp(n);
        dfs(i, -1, a, g, dp);
        
        if (dp[i]) {
            ans.pb(i);
        }
    }
    
    return ans;
}

/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    VI a(n);
    FOR(i,0,n-1) {
        cin >> a[i];
    }
    
    VVI g(n);
    FOR(_,1,n-1) {
        int u, v;
        cin >> u >> v; u--; v--;
        
        g[u].pb(v);
        g[v].pb(u);
    }
    
    VI ans = solve(n, a, g);
    
    for (int x : ans) {
        cout << 1 + x << ' ';
    }
    
    cout << '\n';

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int n;

int main(){
	while(1){
		cin>>n;
		if(n==-1) break;
		if(!n){
			cout<<0<<endl;
			continue;
		}
		int k=1;
		while(k<=n) k*=4;
		k/=4;
		while(k){
			int a=n/k;
			cout<<a;
			n-=a*k;
			k/=4;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
int main(void)
{
  char str[0];
  scanf("%s",str);
  
  if(strcmp(str,"A")==0){printf("T");}
  if(strcmp(str,"T")==0){printf("A");}
  if(strcmp(str,"C")==0){printf("G");}
  if(strcmp(str,"G")==0){printf("C");}
  
  return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

typedef vector<vvi> vvvi;

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

struct state {
	pii l, r;
	state(pii l, pii r) : l(l), r(r) {};
};

int main() {
	int W, H;
	while(cin >> W >> H, W) {
		vs roomL(H), roomR(H);
		int lsx, lsy, rsx, rsy;
		REP(i, H) {
			cin >> roomL[i] >> roomR[i];
			if(roomL[i].find("L") != string::npos) {
				lsx = roomL[i].find("L");
				lsy = i;
			}
			if(roomR[i].find("R") != string::npos) {
				rsx = roomR[i].find("R");
				rsy = i;
			}
		}

		vector<vvvi> visited(H, vvvi(W, vvi(H, vi(W))));
		queue<state> Q;
		Q.push(state(make_pair(lsy, lsx), make_pair(rsy, rsx)));
		visited[lsy][lsx][rsy][rsx] = 1;
		bool goal = false;
		while(!Q.empty()) {
			state st = Q.front();
			Q.pop();

			if(roomL[st.l.first][st.l.second] == '%' && roomR[st.r.first][st.r.second] == '%') {
				goal = true;
				break;
			}

			if(roomL[st.l.first][st.l.second] == '%' || roomR[st.r.first][st.r.second] == '%') {
				continue;
			}

			REP(d, 4) {
				int lny = st.l.first + dy[d];
				int lnx = st.l.second + ldx[d];
				if(lny < 0 || H <= lny || lnx < 0 || W <= lnx || roomL[lny][lnx] == '#') {
					lny = st.l.first;
					lnx = st.l.second;
				}
				int rny = st.r.first + dy[d];
				int rnx = st.r.second + rdx[d];
				if(rny < 0 || H <= rny || rnx < 0 || W <= rnx || roomR[rny][rnx] == '#') {
					rny = st.r.first;
					rnx = st.r.second;
				}

				if(!visited[lny][lnx][rny][rnx]) {
					visited[lny][lnx][rny][rnx] = 1;
					Q.push(state(make_pair(lny, lnx), make_pair(rny, rnx)));
				}
			}
		}

		cout << (goal ? "Yes" : "No") << endl;
	}

	return 0;
}

Measured memory_bytes: 30164
import math
N = int(input())

#2以上
def sieve_eratosthenes(n):
    nums = [True] * (n+1)
    nums[0] = False
    nums[1] = False
    for i in range(2, math.ceil(math.sqrt(n))+1):
        if not nums[i]: #iが素数ではない
            continue
        else:
            for j in range(i*2, n+1, i):
                nums[j] = False # iが素数ならiの整数倍は素数ではない
    return [i for i in range(n+1) if nums[i]]

primes = sieve_eratosthenes(55555)

ans = [i for i in primes if i%5 == 1]



print(*ans[:N])

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin >> s >> t;
    int n = sz(s);
    map<char, char> stot, ttos;
    rep(i, n) {
        if (stot.count(s[i])) {
            if (stot[s[i]] != t[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        if (ttos.count(t[i])) {
            if (ttos[t[i]] != s[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        stot[s[i]] = t[i];
        ttos[t[i]] = s[i];
    }
    cout << "Yes" << endl;
}

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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////

void solve() {
	int A[20][20], B[20], C;
	int N,M;
	cin >> N >> M >> C;
	for (int i = 0; i < M; ++i) {
		cin >> B[i];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < M; ++j) {
			cin >> A[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int tmp = 0;
		for (int j = 0; j < M; ++j) {
			tmp += A[i][j] * B[j];
		}
		tmp += C;
		if (tmp > 0) {
			++ans;
		}
	}

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

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
use std::collections::BTreeSet;
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: u64 = sc.read();
    let b: u64 = sc.read();
    let mut s = BTreeSet::new();
    let mut t = BTreeSet::new();
    {
        let mut div: u64 = 2;
        let mut tmp_a = a;
        while div * div <= tmp_a {
            if tmp_a % div == 0 {
                tmp_a /= div;
                s.insert(div);
            } else {
                div += 1;
            }
        }
        s.insert(tmp_a);
        s.insert(1);
    }
    {
        let mut div: u64 = 2;
        let mut tmp_a = b;
        while div * div <= tmp_a {
            if tmp_a % div == 0 {
                tmp_a /= div;
                t.insert(div);
            } else {
                div += 1;
            }
        }
        t.insert(tmp_a);
        t.insert(1);
    }
    println!("{}", t.intersection(&s).count());
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#define debug(x) cerr<<#x<<'='<<x<<'\n'

int main(void) {
	int q, h, s, d, n;
	scanf("%d%d%d%d%d", &q, &h, &s, &d, &n);
	if (q*2 <= h) {
		h=q*2;
	}
	if (h*2 <= s) {
		s=h*2;
	}
	if (s*2 <= d) {
		d = s*2;
	}
	int two=n/2;
	n-=two*2;
	int one=n;
	cout << (1ll*two*d + 1ll*one*s) <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i = 1; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
using ll = int64_t;
using v = vector<int>;

int main() {
  int N;
  cin >> N;
  vector<string> V(N);
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    V.at(i) = s;
  }
  sort(V.begin(), V.end());
  int ans=1;
  rep(i,N) {
    if (V.at(i) != V.at(i-1)) ans++;
  }
  
  cout << ans << endl;
    
}

Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////

int main(){
    integer N; SCLLD(N);
    integer digit=0;
    integer last = 0;
    bool flg = true;
    integer x = N;

    while(true){
		if (x == 0) break;
        if ((x%10 != 9) and (x>9))flg = false;
        last = x;
		x = x / 10;
        digit++;
	}

    if (flg) PRINTLLD(last + 9*(digit-1));
    else PRINTLLD(last-1 + 9*(digit-1));

    return 0;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var c int
	var inb [2]*big.Int
	for scanner.Scan() {
		t := scanner.Text()
		inb[c], _ = big.NewInt(0).SetString(t, 10)
		c++
		if c == 2 {
			break
		}
	}
	if v := inb[0].Cmp(inb[1]); v == 1 {
		fmt.Println("GREATER")
	} else if v == 0 {
		fmt.Println("EQUAL")
	} else {
		fmt.Println("LESS")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

void c()
{
    long long int x, y;
    cin >> x >> y;
    int len = 1;
    while (1)
    {
        x = x * 2;
        if(x > y)
        {
            break;
        }else{
            len++;
        }
    }
    cout << len << endl;
}

void d()
{
    string s;
    cin >> s;
    int ans = s.size();
    for(int i = 0; i < s.size() - 1; i++)
    {
        if(s[i] != s[i + 1])
        {
           ans =  min(ans, max(i + 1, (int)(s.size()) - i - 1));
        }
    }
    cout << ans << endl;
    return;
}

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


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

int main() {
	int N;
	cin >> N;
	long long sum = 0;
	for (int ii = 1; ii <= N; ii++) {
		if (ii % 3 == 0 && ii % 5 == 0) {
			continue;
		}
		if (ii % 3 == 0 || ii % 5 == 0) {
			continue;
		}
		sum += ii;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3636
// AOJ ITP 1_3_D
#include<cstdio>

int main()
{
	int a, b, c;
	scanf( "%d%d%d", &a, &b, &c );

	int ans = 0;
	for( int i = a; i <= b; ++i )
		if( c % i == 0 )
			++ans;

	printf( "%d\n", ans );

	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b;
  cin>>n>>a>>b;
  if (a%2==b%2) cout<<(b-a)/2;
  else
  cout<<min(a-1,n-b)+1+(b-a-1)/2;
  return 0;
}


Measured memory_bytes: 256
n=gets.to_i-1
bNs=gets.chomp.split.map(&:to_i)
aNs=[bNs[0]]
maxbNsIndex = bNs.length - 1
n.times do |index|
  bIndex = [index,maxbNsIndex].min
  value = bNs[bIndex]
  addbIndex = bIndex + 1
  if addbIndex > maxbNsIndex
    addbIndex = maxbNsIndex
  end
  aNs << [value, bNs[addbIndex]].min
end
puts aNs.inject(:+)

Measured memory_bytes: 1788
#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 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 Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}


int main() {
	int N, W;
	cin >> N >> W;
	hei(llint) w(N), v(N);
	int sumV = 0;
	rep(i, 0, N) {
		cin >> w[i] >> v[i];
		sumV += v[i];
	}
	whei(llint) dp(N + 1, hei(llint)(sumV + 1, INF));
	rep(i, 0, N + 1)dp[i][0]=0;
	rep(i, 0, N) {
		rep(j, 0, sumV+1) {
			if (j >= v[i])dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		}
	}
	int ans = 0;
	rep(i, 0, sumV + 1)if (dp[N][i] <= W)ans = i;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0;
	string s[200005];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s,s+n);
	for(int i=0;i<n;i++){
		if(s[i]!=s[i+1]){
			ans++;
		}
	}
	cout<<ans<<endl;
  return(0);
}

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

const long long INF = 1LL << 60;

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

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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<long long> h(N);
  for (int i = 0; i < N; i++) cin >> h.at(i);
  
  sort(h.begin(), h.end());
  
  long long ans = INF;
  for (int i = K - 1; i < N; i++)
  {
    chmin(ans, h.at(i) - h.at(i - K + 1));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
const int mod = 1e9 + 7;
ll powmod(ll a, ll b)
{
	ll ans = 1;
	while(b)
	{
		if(b&1) ans = ans*a%mod;
		a = a*a%mod;
		b >>= 1; 
	}
	return ans;
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int n;
 	cin >> n;
 	vector <int> c(n);
 	for(int &x : c) cin >> x;
	sort(all(c));
	reverse(all(c));
	ll ans = 0;
	for(int i=0; i<n; i++)
		(ans += 1ll*(i+2)*c[i]%mod) %= mod;
	ans = ans*powmod(4, n-1)%mod;
	ans = (ans + mod)%mod;
	cout << ans;
	return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

struct Work {
    ll d, p;
    Work(ll d = 0, ll p = 0) : d(d), p(p) {}
    bool operator<(const Work& w) const { return (p != w.p ? p < w.p : d < w.d); }
};

constexpr int MOD = 1000000007;

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

    int n, m;
    cin >> n >> m;

    priority_queue<Work> q;
    rep(i, 0, n) {
        ll d, p;
        cin >> d >> p;
        q.emplace(d, p);
    }

    set<ll> sets;
    rep(i, 0, m + 1) { sets.insert(i); }

    ll ans = 0;
    while (!q.empty()) {
        Work w = q.top();
        q.pop();

        auto itr = sets.lower_bound(w.d);

        if (itr != sets.end()) {
            ans += w.p;
            sets.erase(itr);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6512
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let r = n - k
let memo = Array.make_matrix 3000 3000 @@ -1
let rec comb n k =
  if memo.(n).(k) > -1 then memo.(n).(k)
  else
    (memo.(n).(k) <- if n < k then 0 else if n = k then 1 else if k = 0 then 1
      else (comb (n - 1) (k - 1) + comb (n - 1) k) mod 1_000_000_007;
    memo.(n).(k))
let h n k = comb (n + k - 1) k
let _ =
  for i = 1 to k do
    Printf.printf "%d\n" @@
    if r + 1 < i then 0 else comb (k - 1) (i - 1) * h (i + 1) (r - i + 1) mod 1_000_000_007 done

Measured memory_bytes: 73848
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    long n, m;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextLong();
        m = sc.nextLong();
        solve();
    }

    void solve() {
        if (n > m) {
            long temp = n;
            n = m;
            m = temp;
        }
        String ans = "Alice";
        if (n == m || n == m - 1) {
            ans = "Brown";
        }
        System.out.println(ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

class UnionFind {
  public:
    //親の番号を格納する．親だった場合は-(その集合のサイズ)
    vector<int> Parent;
    //作るときはParentの値をすべて-1にする
    //こうするとすべてバラバラになる．
    UnionFind(int N) {
      Parent = vector<int>(N+1,-1);
    }

    //親がどのグループに属しているか
    int root(int A){
      if(Parent[A] < 0) return A;
      //親の紐づけを変更
      return Parent[A] = root(Parent[A]);
    }

    int size(int A){
      return -Parent[root(A)];//親を取ってきたい
    }

    //AとBをくっつける
    bool connect(int A, int B){
      //AとBを直接つなぐのではなく，root(A)とroot(B)をくっつける
      A = root(A);
      B = root(B);
      if( A == B ){
        //すでにくっついているからくっつけない
        return false;
      }
      //大きいほう(A)に小さいほう(B)をくっつけたい
      //大小逆ならひっくり返す
      if( size(A) < size(B) ) swap(A,B);

      //Aのサイズを更新
      Parent[A] += Parent[B];
      //Bの親をAにする
      Parent[B] = A;
      return true;
    }
};

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

  vector<long long> ans(M);
  ans[M-1] = (long long)N*(N-1)/2;

  UnionFind Uni(N);

  for(int i = M-1; i >= 1; i--){

    ans[i-1] = ans[i];

    //繋がってなかったのがつながった時
    if(Uni.root(A[i]) != Uni.root(B[i])){
      ans[i-1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
      Uni.connect(A[i],B[i]);
    }
  }

  for(int i = 0; i<M; i++){
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


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


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


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    return 180*(N-2)


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5448
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    long previousH = Long.parseLong(sc.next());
    int currentCount = 0;
    int maxCount = 0;
    for (int i = 0; i < n - 1; i++) {
      long h = Long.parseLong(sc.next());
      if (previousH >= h) {
        currentCount++;
        previousH = h;
        maxCount = Math.max(maxCount, currentCount);
      } else {
        currentCount = 0;
        previousH = h;
      }
    }
    pw.println(maxCount);
  }
}


Measured memory_bytes: 46672
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

ostream& operator << (ostream& os, const mint a) {
    os << a.x;

    return os;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, K;
    cin >> N >> K;

    mint ans = 0;

    ll m = 0, M = 0;
    REP(i, K) {
        m += i;
        M += N - i;
    }

    FOR(i, K, N + 2) {
        ans += M - m + 1;
        m += i;
        M += N - i;
    }

    print(ans);
}


Measured memory_bytes: 3644
N,M = map(int,input().split())
A = [[] for j in range(N)]
b = [0 for j in range(M)]
for j in range(N):
    A[j] = list(map(int,input().split()))

for j in range(M):
    b[j] = int(input())

for row in range(N):
    tmp = 0
    for col in range(M):
        tmp += A[row][col]* b[col]
    print(tmp)      


Measured memory_bytes: 6020
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
using namespace std;
#define REP(i,n); for(int i = 0;i < (int)(n);i++)

int main() {
	int n,m,count=0,fir,las;
	vector<pair<int,int>> r;
	cin >> n >> m;
	r.resize(m);
	REP(i,m){
		cin >> r[i].first >> r[i].second;
	}
	fir = 1;
	las = n;
	REP(i,m){
		fir = max(fir,r[i].first);
		las = min(las,r[i].second);
		if(fir > las){
			cout << 0;
			return 0;
		}
	}
	cout << las - fir + 1;
	return(0);
}

Measured memory_bytes: 1024
import static java.lang.System.in;
import static java.lang.System.out;

import java.io.*;
import java.util.*;

public class Main {
	static final double EPS = 1e-10;
	static final double INF = 1L << 31;
	static final double PI = Math.PI;

	public static Scanner sc = new Scanner(in);
	StringBuilder sb = new StringBuilder();
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public void run() throws IOException {
		String input;
		String[] inputArray;
		input = br.readLine();
		inputArray = input.split(" ");

		int n = Integer.valueOf(inputArray[0]);
//		for (int z=1; z<20; z++){
//			sb.append(z+":\n");
//			int n=z;
		while(n>0){
			int i = (int)((Math.sqrt(8*n+1)-1)/2+0.99999);
			sb.append(i+"\n");
			n-=i;
		}
//		sb.append("\n");
//		}
		ln(sb);
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	public static void ln(Object obj) {
		out.print(obj);
	}
}


Measured memory_bytes: 10836
s = input()
#print(s)
n = int(input())
for _ in range(n):
    l = input().split()
    #print(l)
    if l[0] == "replace":
        if l[1] == "0":
            s = l[3] + s[int(l[2])+1:]
        else:
            s = s[:int(l[1])] + l[3] + s[int(l[2])+1:]
        #print(s)
    elif l[0] == "reverse":
        if l[1] == "0":
            s = (s[int(l[2])::-1] + s[int(l[2])+1:])
        else:
            #print(s[:int(l[1])], s[int(l[2]):int(l[1]):-1], s[int(l[2])+1:])
            s = s[:int(l[1])] + s[int(l[2]):int(l[1])-1:-1] + s[int(l[2])+1:]
    else:
        print(s[int(l[1]):int(l[2])+1])


Measured memory_bytes: 5620
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}


//CODE
void solve(void)
{
  int N,K;
  cin>>N>>K;
  map<int,int> mp;
  for (int i = 0; i < N; i++)
  {
    int A;
    cin>>A;
    auto itr =  mp.find(A);
    if(itr == mp.end())
    {
      mp[A] = 1;
    }
    else
    {
      itr->second++;
    }
  }
  vector<pair<int,int> > DATA(mp.size());
  int SUM = 0;
  
  for (int i = 0; i < mp.size(); i++)
  {
    static auto itr = mp.begin();
    DATA[i].first = itr->second;
    DATA[i].second = itr->first;
    SUM += DATA[i].first;
    itr++;
  }
  SORT_(DATA,true);
  int SUM_K = 0;
  for (int i = 0; i < min(K,(int)mp.size()); i++)
  {
      SUM_K += DATA[i].first;
  }
  
  cout<<SUM - SUM_K<<endl;
  


  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+5;
int n, ans = 1;
int a[MAXN], f[MAXN];
int main()
{
    scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    f[1] = a[1];
    for(int i = 2; i <= n; i++)
    {
        if(a[i] <= f[ans]) f[++ans] = a[i];
        else
        {
            int l = 1, r = ans;
            while(l < r)
            {
                int mid = (l + r) >> 1;
                if(f[mid] >= a[i]) l = mid + 1;
                else r = mid;
            }
            f[l] = a[i];
        }
    }
    printf("%d\n", ans);
//    system("pause");
}

Measured memory_bytes: 1024
n = int(input())
string = input()
ans = 0
if string[:n] == string[2*n-1:n-1:-1]:
  ans += 2
for b in range(1,2**n-1):
  s = ""
  t = ""
  for c in range(n):
    if b & 2**c:
      s += string[c]
    else:
      t += string[c]
  s = s[::-1]
  t = t[::-1]
  ltr = string[n:]
  l = len(s)
  DP = [[0 for i in range(l+1)] for j in range(n+1)]
  DP[0][0] = 1
  for i in range(1,n+1):
    x = ltr[i-1]
    for j in range(0,min(i+1,l+1)):
      if j>=1 and s[j-1] == x:
        DP[i][j] += DP[i-1][j-1]
      if i-j<=len(t) and t[i-j-1] == x:
        DP[i][j] += DP[i-1][j]
  ans += DP[-1][-1]
print(ans)

Measured memory_bytes: 58460
X, Y = map(int, input().split())
Z = (10**18 // X) * X
if (X == Y) or (Y == 1) or (X % Y == 0):
    print(-1)
elif X < Y:
    print(X)
else:
    for i in range(Z, 0, -X):
        if i % Y != 0:
            print(i)
            break
    else:
        print(-1)

Measured memory_bytes: 3060