criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>

#define reps(i, j, k) for (int i = (j); i < (k); i++)
#define rep(i, j) reps(i, 0, j)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

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

	vi a;
	rep(i, N) {
		int buf;
		cin >> buf;
		a.pub(buf);
	}

	int mx_idx = 0;
	int mx_val = a[0];
	int mn_idx = 0;
	int mn_val = a[0];

	rep(i, 1, N) {
		if (mx_val < a[i]) {
			mx_idx = i;
			mx_val = a[i];
		}

		if (mn_val > a[i]) {
			mn_idx = i;
			mn_val = a[i];
		}
	}

	cout << 2 * N - 1 << endl;
	if (abs(mn_val) < abs(mx_idx)) {
		rep(i, N) {
			a[i] += mx_val;
			cout << mx_idx + 1 << " " << i + 1 << endl;
		}

		reps(i, 1, N) {
			a[i] += a[i - 1];
			cout << i << " " << i + 1 << endl;
		}
	}
	else {
		rep(i, N) {
			a[i] += mn_val;
			cout << mn_idx + 1 << " " << i + 1 << endl;
		}

		reps(i, 1, N) {
			a[N - i - 1] += a[N - i];
			cout << N - i + 1 << " " << N - i << endl;
		}
	}


	return 0;
}

Compiler output:
a.cc:42:20: error: macro "rep" passed 3 arguments, but takes just 2
   42 |         rep(i, 1, N) {
      |                    ^
a.cc:8:9: note: macro "rep" defined here
    8 | #define rep(i, j) reps(i, 0, j)
      |         ^~~
a.cc: In function 'int main()':
a.cc:42:9: error: 'rep' was not declared in this scope
   42 |         rep(i, 1, N) {
      |         ^~~
Language: C++




Beta 
 Online C++ compiler 
New C++ code 
Recent C++ code 
Terminal
English 
Sign Up 

Sign In 
 
C++ 
Split Button! 
 
Main.cpp  
 

Success  

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54




        }
    }
    cout<<2*n-1<<endl;
    if(abs(min)<abs(max)){
        for(int i=0;i<n;i++){
            cout<<pmax<<" "<<i<<endl;
            a[i]+=max;
        }
    }
    else{
        for(int i=0;i<n;i++){
            cout<<pmin<<" "<<i<<endl;
            a[i]+=min;
        }
    }
    if(a[0]>0){
        for(int i=0;i<n-1;i++){
            cout<<i<<" "<<i+1<<endl;
            a[i+1]+=a[i];
        }
    }
    else{
        for(int i=n-1;i>0;i--){
            cout<<i<<" "<<i-1<<endl;
            a[i-1]+=a[i];
        }
    }
    return 0;
}




 Run (Ctrl-Enter) 
Split Button! 
       


  

Output 
 Input 
Comments 0 
(0.00 sec) 
  
5
1 0
1 1
1 2
0 1
1 2


Compiler output:
a.cc:4:1: error: 'Beta' does not name a type
    4 | Beta
      | ^~~~
a.cc:56:9: error: expected declaration before '}' token
   56 |         }
      |         ^
a.cc:57:5: error: expected declaration before '}' token
   57 |     }
      |     ^
a.cc:58:5: error: 'cout' does not name a type
   58 |     cout<<2*n-1<<endl;
      |     ^~~~
a.cc:59:5: error: expected unqualified-id before 'if'
   59 |     if(abs(min)<abs(max)){
      |     ^~
a.cc:65:5: error: expected unqualified-id before 'else'
   65 |     else{
      |     ^~~~
a.cc:71:5: error: expected unqualified-id before 'if'
   71 |     if(a[0]>0){
      |     ^~
a.cc:77:5: error: expected unqualified-id before 'else'
   77 |     else{
      |     ^~~~
a.cc:83:5: error: expected unqualified-id before 'return'
   83 |     return 0;
      |     ^~~~~~
a.cc:84:1: error: expected declaration before '}' token
   84 | }
      | ^
a.cc:89:6: error: expected constructor, destructor, or type conversion before '(' token
   89 |  Run (Ctrl-Enter)
      |      ^
Language: C++

#include <iostream>
#include <vector>

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
using namespace std;

int retmaxidx(vector<int> &vec) {
	int max = INT_MIN;
	int maxidx = 0;
	int vsize = SZ(vec);
	FOR(i, 0, vsize) {
		if (max < vec[i]) {
			max = vec[i];
			maxidx = i;
		}
	}
	return maxidx;
}
int retminidx(vector<int> &vec) {
	int min = INT_MAX;
	int minidx = 0;
	int vsize = SZ(vec);
	FOR(i, 0, vsize) {
		if (min > vec[i]) {
			min = vec[i];
			minidx = i;
		}
	}
	return minidx;
}


int main() {
	int N = 0;
	cin >> N;
	vector<int> a(N, 0);
	FOR(i,0,N) cin >> a[i];

	int posi = 0;
	int nega = 0;
	int zero = 0;

	FOR(i, 0, N) {
		if (a[i] < 0)
			++nega;
		else if (a[i] > 0)
			++posi;
		else {
			++zero;
		}
	}

	if (nega == 0 && posi != 0) {
		cout << N - 1 << "\n";
		FOR(i, 1, N)
			cout << i << " " << i + 1 << "\n";
	}
	else if (posi == 0 && nega != 0) {
		cout << N - 1 << "\n";
		RFOR(i, N, 1)
			cout << i << " " << i - 1 << "\n";
	}
	else if (zero == N) {
		cout << 0 << "\n";
	}
	else {
		int maxidx = retmaxidx(a);
		int minidx = retminidx(a);
		if (a[maxidx] + a[minidx] >= 0) {
			cout << 2 * N - 1 << "\n";
			FOR(i, 1, N + 1)
				cout << maxidx + 1 << " " << i << "\n";
			FOR(i, 1, N)
				cout << i << " " << i + 1 << "\n";
		}
		else {
			cout << 2 * N - 1 << "\n";
			FOR(i, 1, N + 1)
				cout << minidx + 1 << " " << i << "\n";
			RFOR(i, N, 2)
				cout << i << " " << i - 1 << "\n";
		}

	}
	return 0;
}

Compiler output:
a.cc: In function 'int retmaxidx(std::vector<int>&)':
a.cc:10:19: error: 'INT_MIN' was not declared in this scope
   10 |         int max = INT_MIN;
      |                   ^~~~~~~
a.cc:3:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <vector>
  +++ |+#include <climits>
    3 | 
a.cc: In function 'int retminidx(std::vector<int>&)':
a.cc:22:19: error: 'INT_MAX' was not declared in this scope
   22 |         int min = INT_MAX;
      |                   ^~~~~~~
a.cc:22:19: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

# include <iostream>
# include <vector>
# include <string>
# include <sstream>

void add(std::vector<int>& list, int x, int y) 
{
    list[y] += list[x];
    std::cout << x << " " << y;
}

void calc(std::vector<int>& list)
{

    while (true) {
        
        int index{};
        for (auto& ite{list.begin()}; ite != list.end(); ++ite)
        {
            if (*(ite - 1) > *(ite)) {
                add(list, index - 1, index);
                break;
            }

            ++index;
        }

        if (index + 1 == list.size()) break;
    }
}


int main()
{
    int length{};
    std::cin >> length;
    
    std::string buff;
    std::getline(std::cin, buff);

    
    std::vector<int> list(length);


    std::istringstream ss{buff};
    while (std::getline(ss, buff, ' '))
    {
        list.push_back(std::stoi(buff));
    }

    calc(list);

}

Compiler output:
a.cc: In function 'void calc(std::vector<int>&)':
a.cc:18:36: error: cannot bind non-const lvalue reference of type '__gnu_cxx::__normal_iterator<int*, std::vector<int> >&' to an rvalue of type 'std::vector<int>::iterator'
   18 |         for (auto& ite{list.begin()}; ite != list.end(); ++ite)
      |                                    ^
Language: C

#include <bits/stdc++.h>
using namespace std;
const int N=55;
int n,a[N],h=0;//head
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(abs(a[i])>abs(a[h]))h=i;
    }
    cout<<2*n-1<<'\n';
    for(int i=0;i<n;i++){
        cout<<h+1<<' '<<i+1<<'\n';
    }
    if(a[h]>0){
        for(int i=0;i<n-1;i++){
            cout<<i+1<<' '<<i+2<<'\n';
        }
    }else{
        for(int i=n;i>1;i--){
            cout<<i<<' '<<i-1<<'\n';
        }
    }
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
	cin >> N ;
	int a[N];
	for(int i=0;i<N;i++){
	cin >> a[i];
}
	int b[N];
	for(int j=0;j<N;j++){
	b[j]=a[j];
	if(b[j]<0){
	b[j]=-1*b[j];
}
}
	int x;
	x = 0;
	for(int k=0;k<N;k++){
	if(b[x]<b[k]){
	x = k;
}
if(b[x]>-1){
	cout << 2*N-2 << endl;
	for(int l=1;l<x;l++){
	cout << x << l <<endl;
}
	for(int m=x+1;m<N+1;m++){
	cout << x << m <<endl;
}
	for(int n=1;n<N;n++){
	cout << n << n+1 <<endl;
}
}if(b[x]<0){
	cout << 2*N-2 << endl;
	for(int o=1;o<x;o++){
	cout << x << o <<endl;
}
	for(int p=x+1;p<N+1;p++){
	cout << x << p <<endl;
}
	for(int q=N;q>1;q=q-1){
	cout << q << q-1 <<endl;
}
}
return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:48:2: error: expected '}' at end of input
   48 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
	cin >> N ;
	int a[N];
	for(int i=0;i<N;i++){
	cin >> a[i];
}
	int b[N];
	for(int j=0;j<N;j++){
	b[j]=a[j];
	if(b[j]<0){
	b[j]=-1*b[j];
}
}
	int x;
	x = 0;
	for(int k=0;k<N;k++){
	if(b[x]<b[k]){
	x = k;
}
if(b[x]>-1){
	cout << 2*N-2 << endl;
	for(int l=1;l<x;l++){
	cout << x << l <<endl;
}
	for(int m=x+1;m<N+1;m++){
	cout << x << m <<endl;
}
	for(int n=1;n<N;n++){
	cout << n << n+1 <<endl;
}
}if(b[a]<0){
	cout << 2*N-2 << endl;
	for(int o=1;o<x;o++){
	cout << x << o <<endl;
}
	for(int p=x+1;p<N+1;p++){
	cout << x << p <<endl;
}
	for(int q=N;q>1;q=q-1;){
	cout << q << q-1 <<endl;
}
}
return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:35:6: error: invalid types 'int [N][int [N]]' for array subscript
   35 | }if(b[a]<0){
      |      ^
a.cc:43:30: error: expected ')' before ';' token
   43 |         for(int q=N;q>1;q=q-1;){
      |            ~                 ^
      |                              )
a.cc:43:31: error: expected primary-expression before ')' token
   43 |         for(int q=N;q>1;q=q-1;){
      |                               ^
a.cc:48:2: error: expected '}' at end of input
   48 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
	cin >> N ;
	int a[N];
	for(int i=0;i<N;i++){
	cin >> a[i];
}
	int b[N];
	for(int j=0;j<N;j++){
	b[j]=a[j];
	if(b[j]<0){
	b[j]=-1*b[j];
}
}
	int x;
	x = 0;
	for(int k=0;k<N;k++){
	if(b[x]<b[k]){
	x = k;
}
if(b[x]>-1){
	cout << 2*N-2 << endl;
	for(int l=1;l<a;l++){
	cout << x << l <<endl;
}
	for(int m=a+1;m<N+1;m++){
	cout << x << m <<endl;
}
	for(int n=1;n<N;n++){
	cout << n << n+1 <<endl;
}
}if(b[a]<0){
	cout << 2*N-2 << endl;
	for(int o=1;o<a;o++){
	cout << x << o <<endl;
}
	for(int p=a+1;p<N+1;p++){
	cout << x << p <<endl;
}
	for(int q=N;q>1;q=q-1;){
	cout << q << q-1 <<endl;
}
}
return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:26:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   26 |         for(int l=1;l<a;l++){
      |                     ~^~
a.cc:29:20: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   29 |         for(int m=a+1;m<N+1;m++){
      |                   ~^~
      |                    |
      |                    int*
a.cc:35:6: error: invalid types 'int [N][int [N]]' for array subscript
   35 | }if(b[a]<0){
      |      ^
a.cc:37:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   37 |         for(int o=1;o<a;o++){
      |                     ~^~
a.cc:40:20: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   40 |         for(int p=a+1;p<N+1;p++){
      |                   ~^~
      |                    |
      |                    int*
a.cc:43:30: error: expected ')' before ';' token
   43 |         for(int q=N;q>1;q=q-1;){
      |            ~                 ^
      |                              )
a.cc:43:31: error: expected primary-expression before ')' token
   43 |         for(int q=N;q>1;q=q-1;){
      |                               ^
a.cc:48:2: error: expected '}' at end of input
   48 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
	cin >> N ;
	int a[N];
	for(int i=0;i<N;i++){
	cin >> a[i];
}
	int b[N];
	for(int j=0;j<N;j++){
	b[j]=a[j];
	if(b[j]<0){
	b[j]=-1*b[j];
}
}
	int a;
	a = 0;
	for(int k=0;k<N;k++){
	if(b[a]<b[k]){
	a = k;
}
if(b[a]>-1){
	cout << 2*N-2 << endl;
	for(int l=1;l<a;l++){
	cout << a << l <<endl;
}
	for(int m=a+1;m<N+1;m++){
	cout << a << m <<endl;
}
	for(int n=1;n<N;n++){
	cout << n << n+1 <<endl;
}
}if(b[a]<0){
	cout << 2*N-2 << endl;
	for(int o=1;o<a;o++){
	cout << a << o <<endl;
}
	for(int p=a+1;p<N+1;p++){
	cout << a << p <<endl;
}
	for(int q=N;q>1;q=q-1;){
	cout << q << q-1 <<endl;
}
}
return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: conflicting declaration 'int a'
   18 |         int a;
      |             ^
a.cc:7:13: note: previous declaration as 'int a [N]'
    7 |         int a[N];
      |             ^
a.cc:19:11: error: incompatible types in assignment of 'int' to 'int [N]'
   19 |         a = 0;
      |         ~~^~~
a.cc:21:13: error: invalid types 'int [N][int [N]]' for array subscript
   21 |         if(b[a]<b[k]){
      |             ^
a.cc:22:11: error: incompatible types in assignment of 'int' to 'int [N]'
   22 |         a = k;
      |         ~~^~~
a.cc:24:5: error: invalid types 'int [N][int [N]]' for array subscript
   24 | if(b[a]>-1){
      |     ^
a.cc:26:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   26 |         for(int l=1;l<a;l++){
      |                     ~^~
a.cc:29:20: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   29 |         for(int m=a+1;m<N+1;m++){
      |                   ~^~
      |                    |
      |                    int*
a.cc:35:6: error: invalid types 'int [N][int [N]]' for array subscript
   35 | }if(b[a]<0){
      |      ^
a.cc:37:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   37 |         for(int o=1;o<a;o++){
      |                     ~^~
a.cc:40:20: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   40 |         for(int p=a+1;p<N+1;p++){
      |                   ~^~
      |                    |
      |                    int*
a.cc:43:30: error: expected ')' before ';' token
   43 |         for(int q=N;q>1;q=q-1;){
      |            ~                 ^
      |                              )
a.cc:43:31: error: expected primary-expression before ')' token
   43 |         for(int q=N;q>1;q=q-1;){
      |                               ^
a.cc:48:2: error: expected '}' at end of input
   48 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
	cin >> N ;
	int a[N];
	for(int i=0;i<N;i++){
	cin >> a[i];
}
	int b[N];
	for(int j=0;j<N;j++){
	b[j]=a[j];
	if(b[j]<0){
	b[j]=-1*b[j]
}
}
	int a;
	a = 0;
	for(int k=0;k<N;k++){
	if(b[a]<b[k]){
	a = k	
}
if(b[a]>-1){
	cout << 2*N-2 << endl;
	for(int l=1;l<a;l++){
	cout << a << l <<endl;
}
	for(int m=a+1;m<N+1;m++){
	cout << a << m <<endl;
}
	for(int n=1;n<N;n++){
	cout << n << n+1 <<endl;
}
}if(b[a]<0){
	cout << 2*N-2 << endl;
	for(int o=1;o<a;o++){
	cout << a << o <<endl;
}
	for(int p=a+1;p<N+1;p++){
	cout << a << p <<endl;
}
	for(int q=N;q>1;q=q-1;){
	cout << q << q-1 <<endl;
}
}
return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:15:21: error: expected ';' before '}' token
   15 |         b[j]=-1*b[j]
      |                     ^
      |                     ;
   16 | }
      | ~                    
a.cc:18:13: error: conflicting declaration 'int a'
   18 |         int a;
      |             ^
a.cc:7:13: note: previous declaration as 'int a [N]'
    7 |         int a[N];
      |             ^
a.cc:19:11: error: incompatible types in assignment of 'int' to 'int [N]'
   19 |         a = 0;
      |         ~~^~~
a.cc:21:13: error: invalid types 'int [N][int [N]]' for array subscript
   21 |         if(b[a]<b[k]){
      |             ^
a.cc:22:11: error: incompatible types in assignment of 'int' to 'int [N]'
   22 |         a = k
      |         ~~^~~
a.cc:24:5: error: invalid types 'int [N][int [N]]' for array subscript
   24 | if(b[a]>-1){
      |     ^
a.cc:26:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   26 |         for(int l=1;l<a;l++){
      |                     ~^~
a.cc:29:20: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   29 |         for(int m=a+1;m<N+1;m++){
      |                   ~^~
      |                    |
      |                    int*
a.cc:35:6: error: invalid types 'int [N][int [N]]' for array subscript
   35 | }if(b[a]<0){
      |      ^
a.cc:37:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   37 |         for(int o=1;o<a;o++){
      |                     ~^~
a.cc:40:20: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   40 |         for(int p=a+1;p<N+1;p++){
      |                   ~^~
      |                    |
      |                    int*
a.cc:43:30: error: expected ')' before ';' token
   43 |         for(int q=N;q>1;q=q-1;){
      |            ~                 ^
      |                              )
a.cc:43:31: error: expected primary-expression before ')' token
   43 |         for(int q=N;q>1;q=q-1;){
      |                               ^
a.cc:48:2: error: expected '}' at end of input
   48 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 0x3f3f3f3f;
int n,mxr[55];
struct 
{
	int value;
	int biao;
}maxx,minn;
vector<int>tt;
int main()
{
	int ans=0;
	bool flag=true;
	cin>>n;
	maxx.value=-1e8;
	minn.value=inf;
	for(int i=1;i<=n;i++)
	{
		cin>>mxr[i];
		if(mxr[i]>0)
			flag=false;
		if(maxx.value<mxr[i])
		{
			maxx.value=mxr[i];
			maxx.biao=i;
		}
		if(minn.value>mxr[i])
		{
			minn.value=mxr[i];
			minn.biao=i;
		}
	}
	if(!flag)
	{
		for(int i=2;i<=n;i++)
		{
			if(mxr[i]<mxr[i-1])
			{
				int pp=mxr[i-1]-mxr[i];
				pp=floor(pp/maxx.value);
				ans+=pp;
				while(pp--) tt.push_back(i);
			}
		}
	}
	else{
		for(int i=2;i<=n;i++)
		{
			if(mxr[i]<mxr[i-1])
			{
				int pp=abs(mxr[i-1]-mxr[i]);
				pp=floor(pp/minn.value);
				ans+=pp;
				while(pp--) tt.push_back(i-1);
			}
		}
	}
	cout<<ans<<endl;
	for(int i=0;i<tt.size();i++)
	{
		if(!flag)
			cout<<maxx.biao<<" "<<tt[i]<<endl;
		else
			cout<<minn.biao<<" "<<tt[i]<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:36: error: 'floor' was not declared in this scope
   44 |                                 pp=floor(pp/maxx.value);
      |                                    ^~~~~
a.cc:56:36: error: 'floor' was not declared in this scope
   56 |                                 pp=floor(pp/minn.value);
      |                                    ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
  int N, rc;
  queue<int>R;
  cin >> N;
  vector<int>A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int a0min = A[0];
  int a0mini;
  for(int i = 1; i < N; i++){
    if(A[0] + A[i] < a0min){
      a0min = A[0] + A[i];
      a0mini = i;
    }
  }
  R.push(a0mini);
  R.push(0);
  for(int i = 1; i < N; i++){
    int defmin = 2147483647;
    int defmini;
    for(int j = 0; j < N; j++){
      if(A[i] + A[j] - A[i - 1] < defmin && A[i] + A[j] - A[i - 1] >= 0){
        defmin = A[i] + A[j] - A[i - 1];
        defmini = j;
      }
    }
    A[i] = A[i] + defmin;
    R.push(i);
    R.push(defmini);
    if(A[i] < A[i - 1]){
      for(int j = 0; j < N; j++){
        if(A[i] + A[j] - A[i - 1] < defmin && A[i] + A[j] - A[i - 1] >= 0){
          defmin = A[i] + A[j] - A[i - 1];
          defmini = j;
        }
      }  
      A[i] = A[i] + defmin;
      R.push(i);
      R.push(defmini);
    }
  }
  int rsize = R.size();
  for(int i = 0; i < rsize; i++){
    cout << R.top();
    R.pop();
    if(i % 2 == 0){
      cout << '\n';
    }else{
      cout << ' ';
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:15: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   49 |     cout << R.top();
      |               ^~~
      |               pop
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
  int N, rc;
  queue<int>R;
  cin >> N;
  vector<int>A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int a0min = A[0];
  int a0mini;
  for(int i = 1; i < N; i++){
    if(A[0] + A[i] < a0min){
      a0min = A[0] + A[i];
      a0mini = i;
    }
  }
  R.push(i);
  R.push(0);
  for(int i = 1; i < N; i++){
    int defmin = 2147483647;
    int defmini;
    for(int j = 0; j < N; j++){
      if(A[i] + A[j] - A[i - 1] < defmin && A[i] + A[j] - A[i - 1] >= 0){
        defmin = A[i] + A[j] - A[i - 1];
        defmini = j;
      }
    }
    A[i] = A[i] + defmin;
    R.push(i);
    R.push(j);
    if(A[i] < A[i - 1]){
      for(int j = 0; j < N; j++){
        if(A[i] + A[j] - A[i - 1] < defmin && A[i] + A[j] - A[i - 1] >= 0){
          defmin = A[i] + A[j] - A[i - 1];
          defmini = j;
        }
      }  
      A[i] = A[i] + defmin;
      R.push(i);
      R.push(j);
    }
  }
  int rsize = R.size();
  for(int i = 0; i < rsize; i++){
    cout << R.top();
    R.pop();
    if(i % 2 == 0){
      cout << '\n';
    }else{
      cout << ' ';
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:10: error: 'i' was not declared in this scope
   21 |   R.push(i);
      |          ^
a.cc:34:12: error: 'j' was not declared in this scope
   34 |     R.push(j);
      |            ^
a.cc:49:15: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   49 |     cout << R.top();
      |               ^~~
      |               pop
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f

int ans=0;
int ans1[200][2];

void print()
{
    printf("%d\n",ans);
    for(int i=1;i<=ans;i++)
    {
        cout<<ans1[i][0]<<" "<<ans1[i][1]<<endl;
    }
}

int main()
{
    int n;
    cin>>n;
    int a[100];
    int b[100];
    a[0]=-inf;
    a[n+1]=inf;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }

    for(int i=1;i<=n&&ans<=2*n;i++)
    {
        if(a[i]>=a[i-1])continue;
        else
        {
            if(a[i-1]>0)
            {
                ans++;
                a[i]+=a[i-1];
                b[i]=a[i];
                ans1[ans][0]=i-1;
                ans1[ans][1]=i;
                i--;
            }
            else
            {
                int pos=max_element(a+1,a+1+n);
                if(a[pos]>0)
                {
                    ans++;
                    a[i]+=a[pos];
                    b[i]=a[i];
                    ans1[ans][0]=pos;
                    ans1[ans][1]=i;
                    i--;
                }
                else
                {
                    ans=1000;
                }
            }
        }
    }
    if(ans<=2*n)
    {
        print();
    }
    else
    {
        ans=0;
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:36: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   47 |                 int pos=max_element(a+1,a+1+n);
      |                         ~~~~~~~~~~~^~~~~~~~~~~
      |                                    |
      |                                    int*
Language: C++

#define MAX_N 50
#include <iostream>
#include <string>
using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    int a[MAX_N];
    cin >> N;
    for (int i=0; i<N; i++) {
        cin >> a[i];
    }
    
    int ans[2 * MAX_N][2];
    int m = 0;
    int absolute[MAX_N];
    
    bool updated = true;
    while (updated) {
        updated = false;
        int abs_max = 0;
        for (int i=0; i<N; i++) {
            absolute[i] = abs(a[i]);
            abs_max = max(abs_max, absolute[i]);
        }
        for (int i=0; i<N; i++) {
            if (abs(a[i]) == abs_max) {
                for (int j=0; j<i; j++) {
                    if ((a[j] > a[i]) && (a[i] < 0)) {
                        a[j] += a[i];
                        ans[m][0] = i;
                        ans[m][1] = j;
                        m += 1;
                        updated = true;
                    }
                }
                for (int j=i+1; j<N; j++) {
                    if ((a[i] > a[j]) && (a[i] > 0)) {
                        a[j] += a[i];
                        ans[m][0] = i;
                        ans[m][1] = j;
                        m += 1;
                        updated = true;
                    }
                }
            }
        }
    }
    
    cout << m << endl;
    for (int i=0; i<m; i++) {
        cout << ans[i][0]+1 << " " << ans[i][1]+1 << endl;
    }

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:53:6: error: expected '}' at end of input
   53 |     }
      |      ^
a.cc:6:41: note: to match this '{'
    6 | int main(int argc, const char * argv[]) {
      |                                         ^
Language: C++

#include <bits/stdc++.h>
/*#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>*/
using namespace std;
#define INF 100000005
#define MAX 200005

pair<int, int> p[105];
int a[55], n, pp = 0;
int solve1(int nn, int mm){//+-
	/*int mid = n/2;
	for(int i = mid-1;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}
	for(int i = mid;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}*/
	return 0;
}

solve2(int nn, int mm){//++
	/*for(int i = 1;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}*/
	return 0;
}

solve3(int nn, int mm){//--
	//cout << "*" << endl;
	/*for(int i = n-2;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}*/
	return 0;
}

int main(){
	/*int ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++)cin >> a[i];
	//int nn = (min_element(a, a+n)-a);
	//int mm = (max_element(a, a+n)-a);
	//if(a[nn] < 0 && 0 < a[mm])solve1(nn, mm);
	//if(a[nn] >= 0 && a[mm] > 0)solve2(nn, mm);
	//if(a[nn] < 0 && a[mm] <= 0)solve3(nn, mm);
	cout << pp << endl;
	for(int i = 0;i < pp;i++){
		cout << p[i].first << " " << p[i].second << endl;
	}*/
	return 0;
}

Compiler output:
a.cc:38:1: error: ISO C++ forbids declaration of 'solve2' with no type [-fpermissive]
   38 | solve2(int nn, int mm){//++
      | ^~~~~~
a.cc:49:1: error: ISO C++ forbids declaration of 'solve3' with no type [-fpermissive]
   49 | solve3(int nn, int mm){//--
      | ^~~~~~
Language: C++

#include <bits/stdc++.h>
/*#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>*/
using namespace std;
#define INF 100000005
#define MAX 200005

pair<int, int> p[105];
int a[55], n, pp = 0;
int solve1(int nn, int mm){//+-
	/*int mid = n/2;
	for(int i = mid-1;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}
	for(int i = mid;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}*/
	return 0;
}

solve2(int nn, int mm){//++
	/*for(int i = 1;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}*/
	return 0;
}

solve3(int nn, int mm){//--
	//cout << "*" << endl;
	/*for(int i = n-2;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}*/
	return 0;
}

int main(){
	int ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++)cin >> a[i];
	//int nn = (min_element(a, a+n)-a);
	//int mm = (max_element(a, a+n)-a);
	//if(a[nn] < 0 && 0 < a[mm])solve1(nn, mm);
	//if(a[nn] >= 0 && a[mm] > 0)solve2(nn, mm);
	//if(a[nn] < 0 && a[mm] <= 0)solve3(nn, mm);
	cout << pp << endl;
	for(int i = 0;i < pp;i++){
		cout << p[i].first << " " << p[i].second << endl;
	}
	return 0;
}

Compiler output:
a.cc:38:1: error: ISO C++ forbids declaration of 'solve2' with no type [-fpermissive]
   38 | solve2(int nn, int mm){//++
      | ^~~~~~
a.cc:49:1: error: ISO C++ forbids declaration of 'solve3' with no type [-fpermissive]
   49 | solve3(int nn, int mm){//--
      | ^~~~~~
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

pair<int, int> p[105];
int a[55], n, pp = 0;
int solve1(int nn, int mm){//+-
	/*int mid = n/2;
	for(int i = mid-1;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}
	for(int i = mid;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}*/
	return 0;
}

solve2(int nn, int mm){//++
	/*for(int i = 1;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}*/
	return 0;
}

solve3(int nn, int mm){//--
	//cout << "*" << endl;
	/*for(int i = n-2;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}*/
	return 0;
}

int main(){
	int ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++)cin >> a[i];
	int nn = (min_element(a, a+n)-a);
	int mm = (max_element(a, a+n)-a);
	//if(a[nn] < 0 && 0 < a[mm])solve1(nn, mm);
	//if(a[nn] >= 0 && a[mm] > 0)solve2(nn, mm);
	//if(a[nn] < 0 && a[mm] <= 0)solve3(nn, mm);
	cout << pp << endl;
	for(int i = 0;i < pp;i++){
		cout << p[i].first << " " << p[i].second << endl;
	}
	return 0;
}

Compiler output:
a.cc:38:1: error: ISO C++ forbids declaration of 'solve2' with no type [-fpermissive]
   38 | solve2(int nn, int mm){//++
      | ^~~~~~
a.cc:49:1: error: ISO C++ forbids declaration of 'solve3' with no type [-fpermissive]
   49 | solve3(int nn, int mm){//--
      | ^~~~~~
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

pair<int, int> p[105];
int a[55], n, pp = 0;
int solve1(int nn, int mm){//+-
	/*int mid = n/2;
	for(int i = mid-1;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}
	for(int i = mid;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}*/
	return 0;
}

solve2(int nn, int mm){//++
	/*for(int i = 1;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}*/
	return 0;
}

solve3(int nn, int mm){//--
	//cout << "*" << endl;
	/*for(int i = n-2;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}*/
	return 0;
}

int main(){
	int ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++)cin >> a[i];
	int nn = (min_element(a, a+n)-a);
	int mm = (max_element(a, a+n)-a);
	if(a[nn] < 0 && 0 < a[mm])solve1(nn, mm);
	if(a[nn] >= 0 && a[mm] > 0)solve2(nn, mm);
	if(a[nn] < 0 && a[mm] <= 0)solve3(nn, mm);
	cout << pp << endl;
	for(int i = 0;i < pp;i++){
		cout << p[i].first << " " << p[i].second << endl;
	}
	return 0;
}

Compiler output:
a.cc:38:1: error: ISO C++ forbids declaration of 'solve2' with no type [-fpermissive]
   38 | solve2(int nn, int mm){//++
      | ^~~~~~
a.cc:49:1: error: ISO C++ forbids declaration of 'solve3' with no type [-fpermissive]
   49 | solve3(int nn, int mm){//--
      | ^~~~~~
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

pair<int, int> p[105];
int a[55], n, pp = 0;
/*int solve1(int nn, int mm){//+-
	int mid = n/2;
	for(int i = mid-1;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}
	for(int i = mid;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}
	return 0;
}

solve2(int nn, int mm){//++
	for(int i = 1;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}
	return 0;
}

solve3(int nn, int mm){//--
	//cout << "*" << endl;
	for(int i = n-2;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}
	return 0;
}*/

int main(){
	int ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){cin >> a[i];}
	//int nn = 0, mm = 0;
	int nn = (min_element(a, a+n)-a);
	int mm = (max_element(a, a+n)-a);
	if(a[nn] < 0 && 0 < a[mm])solve1(nn, mm);
	if(a[nn] >= 0 && a[mm] > 0)solve2(nn, mm);
	if(a[nn] < 0 && a[mm] <= 0)solve3(nn, mm);
	//if(nn == 0 && mm == 0)pp = 0;
	cout << pp << endl;
	for(int i = 0;i < pp;i++){
		cout << p[i].first << " " << p[i].second << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:35: error: 'solve1' was not declared in this scope
   68 |         if(a[nn] < 0 && 0 < a[mm])solve1(nn, mm);
      |                                   ^~~~~~
a.cc:69:36: error: 'solve2' was not declared in this scope
   69 |         if(a[nn] >= 0 && a[mm] > 0)solve2(nn, mm);
      |                                    ^~~~~~
a.cc:70:36: error: 'solve3' was not declared in this scope
   70 |         if(a[nn] < 0 && a[mm] <= 0)solve3(nn, mm);
      |                                    ^~~~~~
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

pair<int, int> p[105];
int a[55], n, pp = 0;
int solve1(int nn, int mm){//+-
	int mid = n/2;
	for(int i = mid-1;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}
	for(int i = mid;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}
	return 0;
}

solve2(int nn, int mm){//++
	for(int i = 1;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}
	return 0;
}

solve3(int nn, int mm){//--
	//cout << "*" << endl;
	for(int i = n-2;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}
	return 0;
}

int main(){
	int ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){cin >> a[i];}
	int nn = 0, mm = 0;
	//int nn = (min_element(a, a+n)-a);
	//int mm = (max_element(a, a+n)-a);
	if(a[nn] < 0 && 0 < a[mm])solve1(nn, mm);
	if(a[nn] >= 0 && a[mm] > 0)solve2(nn, mm);
	if(a[nn] < 0 && a[mm] <= 0)solve3(nn, mm);
	//if(nn == 0 && mm == 0)pp = 0;
	cout << pp << endl;
	for(int i = 0;i < pp;i++){
		cout << p[i].first << " " << p[i].second << endl;
	}
	return 0;
}

Compiler output:
a.cc:38:1: error: ISO C++ forbids declaration of 'solve2' with no type [-fpermissive]
   38 | solve2(int nn, int mm){//++
      | ^~~~~~
a.cc:49:1: error: ISO C++ forbids declaration of 'solve3' with no type [-fpermissive]
   49 | solve3(int nn, int mm){//--
      | ^~~~~~
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

pair<int, int> p[105];
int a[55], n, pp = 0;
int solve1(int nn, int mm){//+-
	int mid = n/2;
	for(int i = mid-1;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}
	for(int i = mid;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}
	return 0;
}

solve2(int nn, int mm){//++
	for(int i = 1;i < n;i++){
		while(a[i-1] > a[i]){
			a[i] += a[mm];
			p[pp].first = mm+1;
			p[pp++].second = i+1;
		}
	}
	return 0;
}

solve3(int nn, int mm){//--
	//cout << "*" << endl;
	for(int i = n-2;i >= 0;i--){
		while(a[i] > a[i+1]){
			a[i] += a[nn];
			p[pp].first = nn+1;
			p[pp++].second = i+1;
		}
	}
	return 0;
}

int main(){
	int ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){cin >> a[i];}
	int nn = (min_element(a, a+n)-a);
	int mm = (max_element(a, a+n)-a);
	if(a[nn] < 0 && 0 < a[mm])solve1(nn, mm);
	if(a[nn] >= 0 && a[mm] > 0)solve2(nn, mm);
	if(a[nn] < 0 && a[mm] <= 0)solve3(nn, mm);
	//if(nn == 0 && mm == 0)pp = 0;
	cout << pp << endl;
	for(int i = 0;i < pp;i++){
		cout << p[i].first << " " << p[i].second << endl;
	}
	return 0;
}

Compiler output:
a.cc:38:1: error: ISO C++ forbids declaration of 'solve2' with no type [-fpermissive]
   38 | solve2(int nn, int mm){//++
      | ^~~~~~
a.cc:49:1: error: ISO C++ forbids declaration of 'solve3' with no type [-fpermissive]
   49 | solve3(int nn, int mm){//--
      | ^~~~~~
Language: C++

// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using i64 = int_fast64_t;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

void solve() {
    int n, k;
    cin >> n >> k;
    V<int> A(n);
    V<int> B(n + 1, 0);
    rep(i, n) {
        cin >> A[i];
        B[A[i]]++;
    }
    V<int> C(0);
    for (auto &b : B) {
        if (b != 0) {
            C.push_back(b);
        }
    }
    sort(C.begin(), C.end());
    int ans = 0;
    if (C.size() <= k) {
        ans = 0;
    } else {
        ans = accumulate(C.begin(), C.begin() + k - 1, 0);
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Compiler output:
a.cc:5:10: fatal error: atcoder/all: No such file or directory
    5 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include < valarray>

using namespace std;
using ll = long long;

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

int main() {
	int N, K, a;
	cin >> N >> K;
	vector<int> count(N+1);
	for (int i = 0; i < N; i++) {
		cin >> a;
		count[a]++;
	}
	sort(count.begin(),count.end(), greater<int>());
	ll ans = 0;
	for (int i = K; i <= N; i++) {
		ans += count[i];
	}
	print(ans);

}

Compiler output:
a.cc:12:10: fatal error:  valarray: No such file or directory
   12 | #include < valarray>
      |          ^~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main() {
    int N,K;
    cin >> N >> K;
    vector<int>A(N);
    vector<int>cnt(N);
    set<int>set;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        cnt[A[i]]++;
        set.insert(A[i]);
    }
    vector<int>cnt2(N);
    int cnt3　= 0;
    for(int i = 0; i < N; i++) {
        cnt2.push_back(cnt[i]);
    }
    sort(cnt2.begin(),cnt2.end());
    int X = set.size()-K;
    if(X <= 0) {
        cout << 0 << endl;
        return 0;
    }
    int cnt4 = 0;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(cnt2[i] > 0) {
            cnt4++;
            ans += cnt2[i];
        }
        if(cnt4 == X) {
            break;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc:16:9: error: extended character 　 is not valid in an identifier
   16 |     int cnt3　= 0;
      |         ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, K;
    cin >> N >> K;
    vector<int> A;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        A.emplace_back(tmp);
    }

    sort(A.begin(), A.end());
    vector<int> cnt;
    int num = 0;
    vector<int>::iterator itr;
    for (int i : A)
    {
        if (i != num)
        {
            num = i;
            cnt.emplace_back(0);
            itr = cnt.end();
            itr--;
        }
        *itr += 1;
    }

    long long sum = 0;
    int i = 1;
    while ((num - i) > K)
    {
        sum += (long long)cnt[i - 1];
        i++;
    }
    
    cout << sum << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:18:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   18 |     sort(A.begin(), A.end());
      |     ^~~~
      |     short
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	map<ll, ll> mp;
	int n, k;
	cin >> n >> k;
	rep(i, n){
		int a;
		cin >> a;
		mp[a]++;
	}
	
	if(mp.size() <= k){
		cout << 0 << endl;
		return 0;
	}
	
	vector<ll> tmp;
	for(auto itr : mp){
		tmp.push_back(mp.second);
	}
	
	sort(tmp.begin(), tmp.end());
	
	ll ans = 0;
	for(int i = 0; i < mp.size() - k; ++i){
		ans += tmp[i];
	}
	
	cout << ans << endl;
	
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:29:34: error: 'class std::map<long long int, long long int>' has no member named 'second'
   29 |                 tmp.push_back(mp.second);
      |                                  ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;

int a[200001];

int main(){
    int n,k; cin >> n >> k;
    for(int i=0;i<n;i++){
        int b; cin >> b;
        a[b-1]++;
    }
    sort(a,a+n,greater<int>);
    int ans=0;
    for(int i=k;i<n;i++){
        ans+=a[i];
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:28: error: expected primary-expression before ')' token
   12 |     sort(a,a+n,greater<int>);
      |                            ^
Language: C++


#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
#define P pair<ll,ll>
#define fs first
#define sc second
using namespace std;


#define N_MAX 200000
int main(){
  ll n,k;
  cin >> n >> k;
  vector<P> vec;

  ll a[n];
  rep(i,0,n){
    cin >> a[i];
  }

  sort(a,a+n);

  ll temp = 1;
  rep(i,0,n-1){
    if(a[i] != a[i+1]){
      vec.push_back(P(temp,a[i]));
      temp = 1;
    }
    else temp++;
  }
  vec.push_back(P(temp,a[n-1]));

  sort(vec.begin(),vec.end());

  ll ans = 0;temp = max(0LL,vec.size() - k);
  rep(i,0,temp){
    ans += vec[i].fs;
  }

  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:24: error: no matching function for call to 'max(long long int, long long unsigned int)'
   39 |   ll ans = 0;temp = max(0LL,vec.size() - k);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:39:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   39 |   ll ans = 0;temp = max(0LL,vec.size() - k);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:39:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   39 |   ll ans = 0;temp = max(0LL,vec.size() - k);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    vector<p> v;
    for (auto e : mp) v.push_back(e.second);
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < (int)mp.size() - k; i++) ans += v[i];
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:12: error: 'p' was not declared in this scope; did you mean 'mp'?
   14 |     vector<p> v;
      |            ^
      |            mp
a.cc:14:13: error: template argument 1 is invalid
   14 |     vector<p> v;
      |             ^
a.cc:14:13: error: template argument 2 is invalid
a.cc:15:25: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   15 |     for (auto e : mp) v.push_back(e.second);
      |                         ^~~~~~~~~
a.cc:16:12: error: request for member 'begin' in 'v', which is of non-class type 'int'
   16 |     sort(v.begin(), v.end());
      |            ^~~~~
a.cc:16:23: error: request for member 'end' in 'v', which is of non-class type 'int'
   16 |     sort(v.begin(), v.end());
      |                       ^~~
a.cc:18:58: error: invalid types 'int[int]' for array subscript
   18 |     for (int i = 0; i < (int)mp.size() - k; i++) ans += v[i];
      |                                                          ^
Language: C++

N,K=gets.split.map(&:to_i)
ary = gets.split.map(&:to_i)

h = {}
ary.each do |elm|
  if h[elm].nil?
    h[elm] = 1
  else
    h[elm] += 1
  end
end
ary_tmp = h.sort_by { |_, v| v }
count = 0
key_len = ary_tmp.length
while K < key_len
  elm = ary_tmp.shift
  count += elm[1]
  key_len -= 1
end
puts count


Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N,K=gets.split.map(&:to_i)
      | ^
a.cc:5:1: error: 'ary' does not name a type
    5 | ary.each do |elm|
      | ^~~
a.cc:13:1: error: 'count' does not name a type
   13 | count = 0
      | ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N,K,a; cin >> N >> K;
  map<ll,ll> m;
  for (ll i = 0; i < N; ++i) {
    cin >> a;
    m[a] += 1;
  }
  if (m.size() <= K) cout << 0 << endl;
  else {
    vector<ll> v(m.size());
    ll pos = 0;
    for (auto itr = m.begin(); itr != m.end(); ++itr) {
      v[pos] = m->second;
      pos++;
    }
    sort(v.begin(),v.end());
    ll ans = accumulate(v.begin(),v.begin()+m.size()-K,0);
    cout << ans << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:17: error: base operand of '->' has non-pointer type 'std::map<long long int, long long int>'
   19 |       v[pos] = m->second;
      |                 ^~