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

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define pb push_back
#define mp make_pair
#define ll long long

inline int get_int()
{
	int x=0,f=1;
	char c;
	for(c=getchar();(!isdigit(c))&&(c!='-');c=getchar());
	if(c=='-') f=-1,c=getchar();
	for(;isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+c-'0';
	return x*f;
}

int n,m,v,p;
int a[100000];
bool ok(int i){
	int _v = max(0, v - (n - i) - (p - 1));
	ll cnt_v = 1ll * m * _v;
	int j = i - 1;
	while(cnt_v > 0 && j >= p){
		if (a[i] + m - a[j] >= 0){
			cnt_v -= a[i] + m - a[j];
		}else{
			break;
		}
		j--;
	}
	return (max(0,cnt_v) + a[p-1] <= a[i]+m);
}
int main(int argc, char const *argv[])
{
	n = get_int();
	m = get_int();
	v = get_int();
	p = get_int();
	rep(i,n) a[i] = get_int();
	sort(a, a + n);
	reverse(a, a + n);
	int l = p - 1, r = n, mid;
	while (l+1<r){
		mid = (l+r)/2;
		if (ok(mid)){
			l = mid;
		}else{
			r = mid;
		}
	}
	cout << (l+1) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'bool ok(int)':
a.cc:32:20: error: no matching function for call to 'max(int, long long int&)'
   32 |         return (max(0,cnt_v) + a[p-1] <= a[i]+m);
      |                 ~~~^~~~~~~~~
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:1:
/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:32:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   32 |         return (max(0,cnt_v) + a[p-1] <= a[i]+m);
      |                 ~~~^~~~~~~~~
/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:32:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |         return (max(0,cnt_v) + a[p-1] <= a[i]+m);
      |                 ~~~^~~~~~~~~
Language: Java

import java.util.*;

public class Main{
    static int n;
    static long m;
    static int v;
    static int p;
    static long[] a;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        n = Integer.parseInt(sc.next());
        m = Long.parseLong(sc.next());
        v = Integer.parseInt(sc.next());
        p = Integer.parseInt(sc.next());
        a = new long[n];
        for(int i=0; i<n; i++){
            a[i] = Long.parseLong(sc.next());
        }
        
        Arrays.sort(a);
        //reverse
        for(int i=0; i<n/2; i++){
            long tmp = a[n-i-1];
            a[n-i-1] = a[i];
            a[i] = tmp;
        }
        
        int ok = 0;
        int ng = n;
        for(int i=0; i<20; i++){
            int mid = (ok+ng)/2;
            if(check(mid)){
                ok = mid;
            }else{
                ng = mid;
            }
        }
        
        System.out.println(ok+1);
    }
    
    public static boolean check(int x){
        if(a[x]+m < a[p-1]){
            return false;d
        }
        long sum = 0;
        for(int i=0; i<n; i++){
            if(i<p-1 || x<=i){
                sum+=m;
            }else{
                sum+=Math.max(a[x]+m-a[i], 0);
            }
        }
        
        return sum >= m*v;
    }
}


Compiler output:
Main.java:45: error: not a statement
            return false;d
                         ^
Main.java:45: error: ';' expected
            return false;d
                          ^
2 errors
Language: Java

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int v = sc.nextInt();
		int p = sc.nextInt();
		Integer[] a = new Integer[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(a, Collections.reverseOrder());

		boolean flag = true;

		int l = 0;
		int r = n;
		while (l < r) {
//			System.out.printf("Checking l=%d r=%d \n", l, r);
			int mid = (l + r) / 2;
			if (mid < p) {
				flag = true;
			} else if (a[mid] + m < a[p - 1]) {
				flag = false;
			} else {
				long sum = (p - 1) * m + (n - mid - 1) * m + m;

				for (int i = p - 1; i < mid; i++) {
					sum += a[mid] + m - a[i];
				}
//				System.out.println(sum);

				if (sum >= m * v) {
					flag = true;
				} else {
					flag = false;
				}
			}

			if (flag) {
				l = mid + 1;
			} else {
				r = mid;
			}
		}
		System.out.println(l);
	}

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args) {
              ^
  (use --enable-preview to enable unnamed classes)
1 error
Language: C++

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

long long n,np,nv,nt;
vector<long long> box(1e5);

bool check(long long mid) {
  bool ans_bool=false;
  if(box.at(nt-1)<=box.at(mid)) {
    ans_bool=true;
  }
  else if(box.at(mid)+np >= box.at(nt-1)) {
    if(nv<=nt) {
      ans_bool=true;
    }
    else {
      long long check_sum=0;
      for(long long i=nt-1;i<n;i++) {
        if(i==mid) continue;
        check_sum+=min(np,box.at(mid)+np-box.at(i));
        if(check_sum>=np*(nv-nt)) {
          ans_bool=true;
          break;
        }
      }
    }
  }
  return ans_bool;
}

long long main() {
  cin >> n >> np >> nv >> nt;
  for(long long i=0;i<n;i++) {
    cin >> box.at(i);
  }

  sort(box.rbegin(),box.rend());

  long long mx=n-1;
  long long mn=nt-1;
  long long mid=(mx+mn)/2;
  while(mx-mn>=2) {
    if(check(mid)) {
      mn=mid;
    }
    else {
      mx=mid;
    }
    mid=(mn+mx)/2;
  }
  cout << mn+1 << endl;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

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

int n,np,nv,nt;
vector<int> box(1e5);

bool check(int mid) {
  bool ans_bool=false;
  if(box.at(nt-1)<=box.at(mid)) {
    ans_bool=true;
  }
  else if(box.at(mid)+np >= box.at(nt-1)) {
    if(nv<=nt) {
      ans_bool=true;
    }
    else {
      long long check_sum=0;
      for(int i=nt-1;i<n;i++) {
        if(i==mid) continue;
        check_sum+=min(np,box.at(mid)+np-box.at(i));
        if(check_sum>=np*(nv-nt))) {
          ans_bool=true;
          break;
        }
      }
    }
  }
  return ans_bool;
}

int main() {
  cin >> n >> np >> nv >> nt;
  for(int i=0;i<n;i++) {
    cin >> box.at(i);
  }

  sort(box.rbegin(),box.rend());

  int mx=n-1;
  int mn=nt-1;
  int mid=(mx+mn)/2;
  while(mx-mn>=2) {
    if(check(mid)) {
      mn=mid;
    }
    else {
      mx=mid;
    }
    mid=(mn+mx)/2;
  }
  cout << mn+1 << endl;
}

Compiler output:
a.cc: In function 'bool check(int)':
a.cc:21:34: error: expected primary-expression before ')' token
   21 |         if(check_sum>=np*(nv-nt))) {
      |                                  ^
Language: C++

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

long long N, M, V, P;
std::vector<long long > A;

bool judge(long long n){
  if (n<P){
    return true;
  } else if (A[n]+M<A[P-1]){
    return false;
  }
  long long sum = 0;
  for (int i=P-1; i<N; i++){
    if (i==n){
      continue;
    }
    sum += std::min(M, A[n]+M-A[i]));
  }
  if (sum >= (long long)M*(V-P)){
    return true;
  } else {
    return false;
  }
}

int main(){
  scanf("%lld", &N);
  scanf("%lld", &M);
  scanf("%lld", &V);
  scanf("%lld", &P);
  long long temp;
  for (int i=0; i<N; i++){
    scanf("%lld", &temp);
    A.push_back(temp);
  }
  sort(A.begin(), A.end(), std::greater<long long>());

  long long edge_start = 0;
  long long edge_end = N-1;
  long long cand;
  while (edge_end - edge_start > 1){
    cand = (edge_start+edge_end)/2;
    if (judge(cand)){
      edge_start = cand;
    } else {
      edge_end = cand;
    }
    //printf("[%lld, %lld]\n", edge_start, edge_end);
  }
  printf("%lld\n",edge_start+1);
  return 0;
}


Compiler output:
a.cc: In function 'bool judge(long long int)':
a.cc:25:36: error: expected ';' before ')' token
   25 |     sum += std::min(M, A[n]+M-A[i]));
      |                                    ^
      |                                    ;
Language: C++

#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 998244353
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
ll sum[maxn];
int a[maxn];
int n,m,v,p;
int main()
{
	n=read(); m=read(); v=read(); p=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	std::sort(a+1,a+n+1,std::greater<int>());
	sum[0]=0;
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	int tot=0;
	for(int i=1;i<=n;i++)
		if(i<=p)++tot;
		else{
			int pos=std::lower_bound(a+1,a+n+1,a[i]+m,std::greater<int>())-a;
			if(pos>p)continue;
			ll rest=(ll)(i-p+1)*(a[i]+m)-(sum[i]-sum[p-1]);
			if(rest>=(ll)(v-(p-1)-(n-i))*m)++tot;
		}
	writeln(tot);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:34: error: 'greater' is not a member of 'std'; did you mean 'isgreater'?
   36 |         std::sort(a+1,a+n+1,std::greater<int>());
      |                                  ^~~~~~~
      |                                  isgreater
a.cc:36:42: error: expected primary-expression before 'int'
   36 |         std::sort(a+1,a+n+1,std::greater<int>());
      |                                          ^~~
a.cc:44:72: error: 'greater' is not a member of 'std'; did you mean 'isgreater'?
   44 |                         int pos=std::lower_bound(a+1,a+n+1,a[i]+m,std::greater<int>())-a;
      |                                                                        ^~~~~~~
      |                                                                        isgreater
a.cc:44:80: error: expected primary-expression before 'int'
   44 |                         int pos=std::lower_bound(a+1,a+n+1,a[i]+m,std::greater<int>())-a;
      |                                                                                ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(a) a.begin(), a.end()
ll N, M, V, P;
vector<ll> A, S;

int main(){
    cin >> N >> M >> V >> P;
    A.resize(N)
    rep(i, 0, N) cin >> A[i];
    sort(all(A));
    ll lb = -1, ub = N - 1;
    while(ub-lb > 1){
        ll mid = (lb + ub) / 2;
        vector<ll> b;
        rep(i, 0, N) if(mid != i) b.push_back(A[i]);
        ll base = A[mid] + M;
        ll ok = 0;
        reverse(all(b));
        bool bad = 0;
        rep(i, 0, b.size()){
            if(i < p - 1) ok += M;
            else if(base >= b[i]) ok += min(M, base-b[i]);
            else bad = 1;
        }
        if(bad) lb = mid;
        else if(ok >= M * (V-1)) ub = mid;
        else lb = mid;
    }
    cout << N - ub << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:16: error: expected ';' before 'for'
   11 |     A.resize(N)
      |                ^
      |                ;
a.cc:12:9: error: 'i' was not declared in this scope
   12 |     rep(i, 0, N) cin >> A[i];
      |         ^
a.cc:4:37: note: in definition of macro 'rep'
    4 | #define rep(i, a, b) for(int i = a; i < b; i++)
      |                                     ^
a.cc:24:20: error: 'p' was not declared in this scope
   24 |             if(i < p - 1) ok += M;
      |                    ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define int long long

main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, m, k, p;
	cin >> n >> m >> k >> p;
	
	vector <int> v(n);
	
	for(auto& i : v)
		cin >> i;
	
	sort(v.begin(), v.end(), [] (const int &x, const int &y) { return x >= y; });
	
	int l = 0;
	int r = n - 1;
	
	int ans = 0;
	
	auto check = [&] (int x)
	{
		if(x < p)
			return true;
		
		if(v[x] + m < v[p - 1])
			return false;
		
		if(k <= p)
			return true;
		
		int cnt = 0;
		
		for(int i = max(0, p - 1); i < n; i++)
			if(i != x)
				cnt += min(m, v[x] + m - v[i]);
		
		return (cnt >= m * (k - p));
	};
	
	while(l <= r)
	{
		int mid = (l + r) / 2;
		
		bool ok = check(mid);
		
		if(ok == true)
		{
			l = mid + 1;
			ans = mid;
		}
		else
		{
			r = mid - 1;
		}
	}
	
	cout << ans + 1;
}

Compiler output:
a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~
a.cc: In lambda function:
a.cc:40:32: error: no matching function for call to 'max(int, long long int)'
   40 |                 for(int i = max(0, p - 1); i < n; i++)
      |                             ~~~^~~~~~~~~~
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:1:
/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:40:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   40 |                 for(int i = max(0, p - 1); i < n; i++)
      |                             ~~~^~~~~~~~~~
/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:40:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   40 |                 for(int i = max(0, p - 1); i < n; i++)
      |                             ~~~^~~~~~~~~~
Language: C++

#include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll N,M,V,P;
  cin>>N>>M>>V>>P;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(rng(A));
  reverse(rng(A));
  ll l=0;
  ll r=N;
  ll m;
  while(r-l>1){
    m=(l+r)/2;
    ll sum=0;
    vector<ll>B=A;
    ll AA=A[m]+M;
    ll VV=V*M-M;
    B[m]=AA;
    for(int i=0;i<N;i++){
      if(i==m)continue;
      VV-=min(max(AA-B[i],0ll),M);
      B[i]=min(max(AA,B[i]),B[i]+M);
      if(VV<=0)break;
    }
    for(int i=0;i<N;i++){
      if(i==m)continue;
      ll D=M-(B[i]-A[i]);
      if(D<=0)continue;
      B[i]+=D;//min(VV,D);
      VV=D//max(VV-D,0ll);
      if(VV<=0)break;
    }
    ll c=0;
    for(auto it:B)if(it>AA)c++;
    if(c<P)l=m;
    else r=m;
  }
  cout<<l+1<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:11: error: expected ';' before 'if'
   44 |       VV=D//max(VV-D,0ll);
      |           ^
      |           ;
   45 |       if(VV<=0)break;
      |       ~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;

bool ni(vector<in> a,in n,in m,in v,in p,in i,){
  bool ret=0;
   in cnt =m*(v-p);
  in mt = a.at(i)+m;
 
  if(a.at(p-1ll)>mt) return ret;
  for(in j=n-1ll;j>p-2ll;j--){
    if(j==i) continue;
     cnt -= min(mt-a.at(j),m);
    if(cnt<=0ll) return ret;
  }
  if(cnt<=0ll) ret=1;
  return ret;
  
 
}

int main(){
in n,m,v,p;
  cin>>n>>m>>v>>p;
vector<in> a(n);
  rep(i,n) cin>>a.at(i);
  
sort(all(a));
  reverse(all(a));
  in ans=p;
  
    if(v<=p){
      for(in i=p;i<n;i++){
if(a.at(i)==a.at(i-1)){
     ans ++;
    continue;}
    if(a.at(i)+m>=a.at(p-1)) ans ++;
    else break;
  continue;}
  }
  
else {
  in x,y;
  x= p-1;
  y= n-1;
  in prop=0ll;
  in half;
  
  while(y-x>100){
     half = (x+y)/2;
    if(ni(a,n,m,v,p,half)) x=half;
    else y = half;
  }
  
  for(in i =y;true;i--){
    if(ni(a,n,m,v,p,i)) {ans =i+1;break;}
  }
}
  
  cout<<ans;
}


Compiler output:
a.cc:9:47: error: expected identifier before ')' token
    9 | bool ni(vector<in> a,in n,in m,in v,in p,in i,){
      |                                               ^
a.cc: In function 'int main()':
a.cc:55:10: error: too few arguments to function 'bool ni(std::vector<long int>, in, in, in, in, in, int)'
   55 |     if(ni(a,n,m,v,p,half)) x=half;
      |        ~~^~~~~~~~~~~~~~~~
a.cc:9:6: note: declared here
    9 | bool ni(vector<in> a,in n,in m,in v,in p,in i,){
      |      ^~
a.cc:60:10: error: too few arguments to function 'bool ni(std::vector<long int>, in, in, in, in, in, int)'
   60 |     if(ni(a,n,m,v,p,i)) {ans =i+1;break;}
      |        ~~^~~~~~~~~~~~~
a.cc:9:6: note: declared here
    9 | bool ni(vector<in> a,in n,in m,in v,in p,in i,){
      |      ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;

bool ni(vector<in> a(n),in n,in m,in v,in p,in i,){
  bool ret=0;
   in cnt =m*(v-p);
  in mt = a.at(i)+m;
 
  if(a.at(p-1ll)>mt) return ret;
  for(in j=n-1ll;j>p-2ll;j--){
    if(j==i) continue;
     cnt -= min(mt-a.at(j),m);
    if(cnt<=0ll) return ret;
  }
  if(cnt<=0ll) ret=1;
  return ret;
  
 
}

int main(){
in n,m,v,p;
  cin>>n>>m>>v>>p;
vector<in> a(n);
  rep(i,n) cin>>a.at(i);
  
sort(all(a));
  reverse(all(a));
  in ans=p;
  
    if(v<=p){
      for(in i=p;i<n;i++){
if(a.at(i)==a.at(i-1)){
     ans ++;
    continue;}
    if(a.at(i)+m>=a.at(p-1)) ans ++;
    else break;
  continue;}
  }
  
else {
  in x,y;
  x= p-1;
  y= n-1;
  in prop=0ll;
  in half;
  
  while(y-x>100){
     half = (x+y)/2;
    if(ni(a,n,m,v,p,half)) x=half;
    else y = half;
  }
  
  for(in i =y;true;i--){
    if(ni(a,n,m,v,p,i)) {ans =i+1;break;}
  }
}
  
  cout<<ans;
}


Compiler output:
a.cc:9:21: error: expected ',' or '...' before '(' token
    9 | bool ni(vector<in> a(n),in n,in m,in v,in p,in i,){
      |                     ^
a.cc: In function 'bool ni(std::vector<long int>)':
a.cc:11:12: error: 'm' was not declared in this scope
   11 |    in cnt =m*(v-p);
      |            ^
a.cc:11:15: error: 'v' was not declared in this scope
   11 |    in cnt =m*(v-p);
      |               ^
a.cc:11:17: error: 'p' was not declared in this scope
   11 |    in cnt =m*(v-p);
      |                 ^
a.cc:12:16: error: 'i' was not declared in this scope
   12 |   in mt = a.at(i)+m;
      |                ^
a.cc:15:12: error: 'n' was not declared in this scope
   15 |   for(in j=n-1ll;j>p-2ll;j--){
      |            ^
a.cc: In function 'int main()':
a.cc:55:10: error: too many arguments to function 'bool ni(std::vector<long int>)'
   55 |     if(ni(a,n,m,v,p,half)) x=half;
      |        ~~^~~~~~~~~~~~~~~~
a.cc:9:6: note: declared here
    9 | bool ni(vector<in> a(n),in n,in m,in v,in p,in i,){
      |      ^~
a.cc:60:10: error: too many arguments to function 'bool ni(std::vector<long int>)'
   60 |     if(ni(a,n,m,v,p,i)) {ans =i+1;break;}
      |        ~~^~~~~~~~~~~~~
a.cc:9:6: note: declared here
    9 | bool ni(vector<in> a(n),in n,in m,in v,in p,in i,){
      |      ^~
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class　Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();
		int v = sc.nextInt();
		int p = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) a[i] = (-1)*sc.nextInt();
		Arrays.sort(a);
		for (int i = 0; i < n; i++) a[i] = (-1)*a[i];
		boolean flag = true;
		int r = n; int l = p-1;

		while(r-l > 1) {
			int mid = (r+l)/2;
			if(a[mid]+m < a[p-1]) {
				flag = false;
			}else {
				long sum = (n-mid+p-1)*m;
				for (int i = p-1; i < mid; i++) {
					sum += a[mid]+m-a[i];
				}
				if(sum < m*v) flag = false;
				else flag = true;
			}
			if(flag) l = mid;
			else r = mid;
		}

		System.out.println(l+1);
		sc.close();
	}
}

Compiler output:
Main.java:4: error: illegal character: '\u3000'
public class?Main {
            ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;



int main(){
in n,m,v,p;
  cin>>n>>m>>v>>p;
vector<in> a(n);
  rep(i,n) cin>>a.at(i);
  
sort(all(a));
  reverse(all(a));
  in ans=p;
  
  if(v<=p){for(in i=p;i<n;i++){
    if(a.at(i)==a.at(i-1)){
     ans ++;
    continue;
  }
    if(a.at(i)+m>=a.at(p-1)) ans ++;
    else break;
  continue;}
  }
  
else for(in i=p;i<n;i++){
  if(a.at(i)==a.at(i-1)){
     ans ++;
    continue;
  }
  
  
  
  
  if(a.at(p-1ll)>mt) break;
  in cnt =m*(v-p);
  in mt = a.at(i)+m;
 
  for(in j=n-1ll;j>p-2ll;j--){
    if(j==i) continue;
     cnt -= min(mt-a.at(j),m);
    if(cnt<=0ll){break;}
  }
  if(cnt<=0ll) ans ++;
  else break;
  
 
}
  
  cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:18: error: 'mt' was not declared in this scope; did you mean 'm'?
   40 |   if(a.at(p-1ll)>mt) break;
      |                  ^~
      |                  m
Language: C++

// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll a[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n, greater<ll>());
    ll ans = p, i, s = a[p - 1], c = 1;
    for (i = p; i < n; i++, c++)
    {
        if (a[i] + m >= a[p - 1] && (a[i] + m) * c - s >= m * max(0LL, (c - n + v)))
            ans++, s += a[i];
        else
            break;
    }
    for (; i < n; i++)
        if (a[i] == a[i - 1])
            ans++;
        else
            break;
    cout << ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:66: error: no matching function for call to 'max(long long int, int64_t)'
   19 |         if (a[i] + m >= a[p - 1] && (a[i] + m) * c - s >= m * max(0LL, (c - n + v)))
      |                                                               ~~~^~~~~~~~~~~~~~~~~~
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:3:
/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:19:66: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   19 |         if (a[i] + m >= a[p - 1] && (a[i] + m) * c - s >= m * max(0LL, (c - n + v)))
      |                                                               ~~~^~~~~~~~~~~~~~~~~~
/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:19:66: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   19 |         if (a[i] + m >= a[p - 1] && (a[i] + m) * c - s >= m * max(0LL, (c - n + v)))
      |                                                               ~~~^~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
const int MAX = 700000;
const int MOD = 1000000007;


int main(){
  ll n,m,v,p;
  cin>>n>>m>>v>>p;
  vll a(n);
  rep(i,n){
    cin>>a[i];
  }
  ll bb=0;
  sort(all(a));
  ll cu=0;
  ll ans=0;
  ll kk=0;
  if(v>p){
    kk=v-p;
  }
  p=n-p;
  ll bb=0;
  rep(int i=0;i<p+1;i++){
    bb+=a[i];
  }
  for(int i=0;i<n-1;i++){
    ll mi=a[i];
    mi+=m;
    if(kk==0){
      if(a[p]>mi){
        cu++;
        continue;
      }
      else{
        COUT(n-cu);
        break;
      }
    }
    else{
      if(a[p]>mi){
        cu++;
        continue;
      }
      else{
        ll huya=kk*m;
        bb-=a[i];
        ll ok=mi*p-(bb+(i*m));
        if(huya>ok){
          cu++;
          continue;
        }
        else{
          COUT(n-cu);
          break;
        }
      }
    }
  }
}
       
          
          
          
            
            

Compiler output:
a.cc:52:24: error: macro "rep" requires 2 arguments, but only 1 given
   52 |   rep(int i=0;i<p+1;i++){
      |                        ^
a.cc:4:9: note: macro "rep" defined here
    4 | #define rep(i, n) for (ll i = 0; i < (n); i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:51:6: error: redeclaration of 'long long int bb'
   51 |   ll bb=0;
      |      ^~
a.cc:42:6: note: 'long long int bb' previously declared here
   42 |   ll bb=0;
      |      ^~
a.cc:52:3: error: 'rep' was not declared in this scope
   52 |   rep(int i=0;i<p+1;i++){
      |   ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	llong N, M, V, P;
	vector<llong> A;

	cin >> N >> M >> V >> P;
	A.resize(N);
	for (auto &in: A) {
		cin >> in;
	}
	sort(ALL(A));

	int ok = N, ng = -1;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;

		if (mid >= N - P) {
			ok = mid;
			continue;
		}
		if (A[mid] + M < A[N-P]) {
			ng = mid;
			continue;
		}

		llong vote = 0;
		for (int i = 0; i <= N - P && ms.size(); ++i) {
			vote += A[mid] + M - A[i];
		}

		if (vote <= M * V) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}

	cout << N - ok << endl;


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:47: error: 'ms' was not declared in this scope
   39 |                 for (int i = 0; i <= N - P && ms.size(); ++i) {
      |                                               ^~
Language: C++

/*
ID: jerrywcy
LINK:
LANG: C++
STATUS:
*/
#include <bits/stdc++.h>

#define init(array,x) memset(array,x,sizeof(array))

using namespace std;

typedef long long ll;

const int inf=0x3f3f3f3f;

ll n,m,v,p;
ll a[100010];
ll s[100010];
// int b[100010];

ll read(){
    ll f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}

bool cmp(ll x,ll y){return x>y;}

bool ck(ll x){
	// for (int i=1;i<=n;i++)b[i]=a[i];
	// for (int i=1;i<=n;i++)cout<<a[i]<<' ';cout<<endl;
	if (v<=p){
		return a[x]+m>=a[p];
	}
	else{
		if (x>n-(v-p+1)+1){
			ll sum=(a[x]+m)*((x-1)1+1)-(s[x-1]);
			// cout<<sum<<' '<<(sum+(x-1)-p)/((x-1)-p+1)<<' '<<endl;
			// cout<<sum<<' '<<ave<<endl;
			return sum>=((v-p+1)-(n-x+1))*m;
		}
		else{
			return a[x]+m>=a[p];
		}
	}
}

int main()
{
//	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	n=read();m=read();v=read();p=read();
	for (int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;i++)s[i]=s[i-1]+a[i];
	ll l=p+1,r=n,mid,ans=p;
	while (l<=r){
		mid=l+r>>1;
		// cout<<mid<<endl;
		if (ck(mid)){
			l=mid+1;
			ans=max(ans,mid);
			// cout<<"1\n";
		}
		else {
			r=mid-1;
			// cout<<"0\n";
		}
	}
	printf("%lld\n", ans);

	return 0;
}

Compiler output:
a.cc: In function 'bool ck(ll)':
a.cc:40:47: error: expected ')' before numeric constant
   40 |                         ll sum=(a[x]+m)*((x-1)1+1)-(s[x-1]);
      |                                         ~     ^
      |                                               )
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD =1000000007;//1e9 + 7;


void merge_sort(int* array, size_t size)
{
    // 作業用領域を確保
    int* work = malloc( sizeof(int) * size );

    // 配列全体を対象にする
    merge_sort_rec( array, 0, size - 1, work );

    free( work );
}

/*
    マージソート (再帰部分、昇順)
*/
void merge_sort_rec(int* array, size_t begin, size_t end, int* work)
{
    // 要素が１つしかなければ終了
    if( begin >= end ){
        return;
    }


    // ２つのデータ列に分割して、それぞれを再帰的に処理
    size_t mid = (begin + end) / 2;
    merge_sort_rec( array, begin, mid, work );
    merge_sort_rec( array, mid + 1, end, work );

    // マージ
    {
        // 前半の要素を作業用配列へ
        for( size_t i = begin; i <= mid; ++i){
            work[i] = array[i];
        }

        // 後半の要素を逆順に作業用配列へ
        for( size_t i = mid + 1, j = end; i <= end; ++i, --j){
            work[i] = array[j];
        }

        // 作業用配列の両端から取り出した要素をマージ
        {
            size_t i = begin;
            size_t j = end;
            for( size_t k = begin; k <= end; ++k) {

                // 昇順にソートするので、小さい方の要素を結果の配列へ移す。
                // == の場合に、前半の側を優先すると安定なソートになる
                if( work[i] <= work[j] ){
                    array[k] = work[i];
                    ++i;
                }
                else{
                    array[k] = work[j];
                    --j;
                }
            }
        }
    }
}

int main(){
	
	ll n,v,m,p;
	cin>>n>>m>>v>>p;
	//vector<ll> vec;
    ll vec[101010];
	rep(i,n){
		//int a;
		cin>>vec[i];
		//vec.push_back(a);
 
	}
	print_array( vec, SIZE_OF_ARRAY(vec[0]*n) );
	ll out=n-p;
	ll ans=p;
	ll sum=v*m;
	ll co=0;
	repr(i,n){
		sum-=m;
		ll s=sum;
		ll max=vec[i]+m;
		if(max<vec[p-1])continue;
		REPR(j,p-1,i){
			s-=max-vec[j];
		}
		if(s<=m*(p-1)){ans=i+1;break;}
	}
	
	cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'void merge_sort(int*, size_t)':
a.cc:19:23: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   19 |     int* work = malloc( sizeof(int) * size );
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
      |                       |
      |                       void*
a.cc:22:5: error: 'merge_sort_rec' was not declared in this scope; did you mean 'merge_sort'?
   22 |     merge_sort_rec( array, 0, size - 1, work );
      |     ^~~~~~~~~~~~~~
      |     merge_sort
a.cc: In function 'int main()':
a.cc:88:27: error: 'SIZE_OF_ARRAY' was not declared in this scope
   88 |         print_array( vec, SIZE_OF_ARRAY(vec[0]*n) );
      |                           ^~~~~~~~~~~~~
a.cc:88:9: error: 'print_array' was not declared in this scope
   88 |         print_array( vec, SIZE_OF_ARRAY(vec[0]*n) );
      |         ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int N;
    int M;
    int V;
    int P;
    cin >> N >> M >> V >> P;
    vector<int> A(N);
    for (long i = 0; i < N ; i++) {
        std::cin >> A.at(i);
    }
    sort(A.begin(), A.end(),greater<int>());
    
    vector<int> A_copy;
    copy(A.begin(), A.end(), back_inserter(A_copy));

    int min;
    min = A[P-1];
    int answer;
    answer = 0;
    for (int i = 0; i < N ; i++){
        if(A[i]+M>=min){
            answer++;
        }
    }
    for (int j = 0; j < V ; j++){
        A[N-j-1]=A[N-j-1]+M; 
    }
    
    sort(A.begin(), A.end(),greater<int>());

    if (A[P-1]>min)
    {
        if (A_copy[0]<A[P-1])
        {
            min = A_copy;
        }else{
        
        min = A[P-1];
        }
        answer = 0;
        for (int i = 0; i < N ; i++){
            if(A_copy[i]+M>=min){
                answer++;
            }
        }

    }
    cout << answer;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:19: error: cannot convert 'std::vector<int>' to 'int' in assignment
   40 |             min = A_copy;
      |                   ^~~~~~
      |                   |
      |                   std::vector<int>
Language: C++

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

int main(){
  int n,m,v,p;
  cin >> n >> m >> v >> p;
  vector<int>a(n);
  int answer;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());//increasing vector
  
  if(v>p){
    v=p;
  }
  for(int i=0;i<n;i++){
    if(i<=p){
      answer++;
    }
    else{
      if(a[i-1]==a[i]){
        answer++;
        continue;
      }
      a[i]+=m;
      int lowsum=0;
      for(int j=0;j<i;j++){
        lowsum+=a[j];
      }
      int more;
      for(int j=i;j<n;j++){
        if(a[i]<=a[j]){
          more=j;
          break;
        }
      }
      int highsum=0;
      for(int j=i;j<more;j++){
        highsum+=a[j];
      }
      int sum = lowsum+highsum+(more-1)*v;
      if(sum/(more-1)<a[i]){
        answer++;
      }
      else{
        break;
      }
  cout << answer << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:2: error: expected '}' at end of input
   51 | }
      |  ^
a.cc:18:23: note: to match this '{'
   18 |   for(int i=0;i<n;i++){
      |                       ^
a.cc:51:2: error: expected '}' at end of input
   51 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD =1000000007;//1e9 + 7;


void merge_sort(int* array, size_t size)
{
    // 作業用領域を確保
    int* work = malloc( sizeof(int) * size );

    // 配列全体を対象にする
    merge_sort_rec( array, 0, size - 1, work );

    free( work );
}

/*
    マージソート (再帰部分、昇順)
*/
void merge_sort_rec(int* array, size_t begin, size_t end, int* work)
{
    // 要素が１つしかなければ終了
    if( begin >= end ){
        return;
    }


    // ２つのデータ列に分割して、それぞれを再帰的に処理
    size_t mid = (begin + end) / 2;
    merge_sort_rec( array, begin, mid, work );
    merge_sort_rec( array, mid + 1, end, work );

    // マージ
    {
        // 前半の要素を作業用配列へ
        for( size_t i = begin; i <= mid; ++i){
            work[i] = array[i];
        }

        // 後半の要素を逆順に作業用配列へ
        for( size_t i = mid + 1, j = end; i <= end; ++i, --j){
            work[i] = array[j];
        }

        // 作業用配列の両端から取り出した要素をマージ
        {
            size_t i = begin;
            size_t j = end;
            for( size_t k = begin; k <= end; ++k) {

                // 昇順にソートするので、小さい方の要素を結果の配列へ移す。
                // == の場合に、前半の側を優先すると安定なソートになる
                if( work[i] <= work[j] ){
                    array[k] = work[i];
                    ++i;
                }
                else{
                    array[k] = work[j];
                    --j;
                }
            }
        }
    }
}

int main(){
	
	ll n,v,m,p;
	cin>>n>>m>>v>>p;
	//vector<ll> vec;
    ll vec[101010];
	rep(i,n){
		//int a;
		cin>>vec[i];
		//vec.push_back(a);
 
	}
	print_array( vec, SIZE_OF_ARRAY(n) );
	ll out=n-p;
	ll ans=p;
	ll sum=v*m;
	ll co=0;
	repr(i,n){
		sum-=m;
		ll s=sum;
		ll max=vec[i]+m;
		if(max<vec[p-1])continue;
		REPR(j,p-1,i){
			s-=max-vec[j];
		}
		if(s<=m*(p-1)){ans=i+1;break;}
	}
	
	cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'void merge_sort(int*, size_t)':
a.cc:19:23: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   19 |     int* work = malloc( sizeof(int) * size );
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
      |                       |
      |                       void*
a.cc:22:5: error: 'merge_sort_rec' was not declared in this scope; did you mean 'merge_sort'?
   22 |     merge_sort_rec( array, 0, size - 1, work );
      |     ^~~~~~~~~~~~~~
      |     merge_sort
a.cc: In function 'int main()':
a.cc:88:27: error: 'SIZE_OF_ARRAY' was not declared in this scope
   88 |         print_array( vec, SIZE_OF_ARRAY(n) );
      |                           ^~~~~~~~~~~~~
a.cc:88:9: error: 'print_array' was not declared in this scope
   88 |         print_array( vec, SIZE_OF_ARRAY(n) );
      |         ^~~~~~~~~~~
Language: C++

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

int main(){
  long int n,m,v,p ;
  cin >> n >> m >> v >> p ;
  vector<pair<long int,long int>> pr ;
  map<long int,long int> mp ;
  long int x ;
  for(int i=0;i<n;i++){
    cin >> x ;
    if(mp.count(x)){
      pr.at(mp.at(x)).second++ ;
    }else{
      pair<long int,long int> sub(x,1) ;
      pr.push_back(sub) ;
      mp[x] = pr.size()-1 ;
    }
  }
  sort(pr.begin(),pr.end()) ;
  reverse(pr.begin(),pr.end()) ;
  long int border = pr.at(0).first ;
  x = pr.at(0).second ;
  long int itr = 0 ;
  while(1){
    if(x>=p) break ;
    itr++ ;
    border = pr.at(itr).first ;
    x += pr.at(itr).second ;
  }
  long int ans = 0 ;
  long int upper = 0 ;
  for(int i=0;i<pr.size();i++){
    if(pr.at(i).first>=border){
      ans += pr.at(i).second ;
      continue ;
    }
    if(pr.at(i).first+m<border) break ;
    //以下、pr.at(i).firstが採用されるか判断
    x = pr.at(i).first + m ;
    upper = 0 ;
    for(int j=0;j<i;j++){
      if(pr.at(j).first>x) upper += pr.at(j).second ;
      else break ;
    }
    //v-upperがpr.at(i).firstより小さい得点の問題数の和以下であればよい
    if(i+1==pr.size()) break ;
    long int sum = 0 ;
    for(int j=i;j<pr.size();j++){
      sum += pr.at(j).second ;
      if(sum>=v-upper) break ;
    }
    if(sum>=v-upper){
      ans += pr.at(i).second ;
    }else{
      if(v-upper-sum<p-upper){
        ans += pr.at(i).second ;
      }else{
        break ;
      }
    }
  }
  cout << ans << endl ;
  f//or(int i=0;i<pr.size();i++) cout << pr.at(i).first << "(" << pr.at(i).second << ") " ;
  //cout << endl << border ;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:3: error: 'f' was not declared in this scope
   64 |   f//or(int i=0;i<pr.size();i++) cout << pr.at(i).first << "(" << pr.at(i).second << ") " ;
      |   ^
Language: C++

#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  ll n, m, v, p;
  cin >> n >> m >> v >> p;
  vector<ll> hoge(n);
  rep_i(i, n){
    cin >> hoge[i];
  }

  sort(hoge.begin(), hoge.end());
  debug_vll(hoge);
  cout << endl;
  ll aa = *max_element(hoge.begin(), hoge.end());

  // int count = 0;
  int e_num;
  for (int i = 0; i < n - p; i++){
    hoge[i] += m;
    if(i + v - 1 >= n - p){
      hoge[n - p] += m;
    }
    cout << "i:" << i << endl;
    cout << "hoge[i]:" << hoge[i] << endl;
    cout << "hoge[n-p]:" << hoge[n - p] << endl;
    if(hoge[i] >= hoge[(n - p)] || hoge[i] >= aa){
      e_num = i;
      break;
    }

    hoge[i] -= m;
    hoge[n - p] -= m;
  }

  if
  // cout << e_num << endl;

  say(n - (ll)e_num);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:16: error: expected '(' before 'cout'
   14 | #define say(t) cout << (t) << endl;
      |                ^~~~
a.cc:53:3: note: in expansion of macro 'say'
   53 |   say(n - (ll)e_num);
      |   ^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

using Graph=vector<vector<int>>;
Graph G;

int main(){
  ll n,m,v,p;
  cin >> n >> m >> v >> p;
  
  vector<ll>vec(n);
  rep(i,n)cin>>vec[i];
  sort(vec.begin(),vec.end(),greater<ll>());
  
  ll under=vec[p-1];
  ll compare;
  ll ans=0;
  
  rep(i,n){
    if(vec[i]>=under)ans++;
  }
  
  if(v<=p){
    compare=vec[p-1];
    rep(i,n){
    	if(vec[i]<under && vec[i]+m>=compare) ans++;
    }
  }
  else{
    rep(i,n){
      ll upper = n-i;
      ll rest = max((ll)0,v-upper);
      ll num = max(1,i-p);
      ll rest2 = rest-p+1;
      ll rest3 = max(ll(0),rest2);
      ll plus = rest3*m/num;
      if(vec[i]<under){
        if(vec[i]+m>=vec[p]+plus) ans++;
        else break;
      }
    }
  }
  cout << ans ;
  return 0;
  
}
    


Compiler output:
a.cc: In function 'int main()':
a.cc:49:19: error: no matching function for call to 'max(int, long long int)'
   49 |       ll num = max(1,i-p);
      |                ~~~^~~~~~~
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:1:
/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:49:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   49 |       ll num = max(1,i-p);
      |                ~~~^~~~~~~
/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:49:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   49 |       ll num = max(1,i-p);
      |                ~~~^~~~~~~
Language: C++

/*
ID: jerrywcy
LINK:
LANG: C++
STATUS:
*/
#include <bits/stdc++.h>

#define init(array,x) memset(array,x,sizeof(array))

using namespace std;

typedef long long ll;

const int inf=0x3f3f3f3f;

ll n,m,v,p;
ll a[100010];
ll s[100010];
// int b[100010];

ll read(){
    ll f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}

bool cmp(ll x,ll y){return x>y;}

bool ck(int x){
	// for (int i=1;i<=n;i++)b[i]=a[i];
	// for (int i=1;i<=n;i++)cout<<a[i]<<' ';cout<<endl;
	if (v<=p){
		return b[x]+m>=b[p];
	}
	else{
		if (x>n-(v-p+1)+1){
			ll sum=(b[x]+m)*((x-1)-p+1)-(s[x-1]-s[p-1]);
			// cout<<sum<<' '<<(sum+(x-1)-p)/((x-1)-p+1)<<' '<<endl;
			// cout<<sum<<' '<<ave<<endl;
			return sum>=((v-p+1)-(n-x+1))*m;
		}
		else{
			return b[x]+m>=b[p];
		}
	}
}

int main()
{
//	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	n=read();m=read();v=read();p=read();
	for (int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;i++)s[i]=s[i-1]+a[i];
	ll l=p+1,r=n,mid,ans=p;
	while (l<=r){
		mid=l+r>>1;
		// cout<<mid<<endl;
		if (ck(mid)){
			l=mid+1;
			ans=max(ans,mid);
			// cout<<"1\n";
		}
		else {
			r=mid-1;
			// cout<<"0\n";
		}
	}
	printf("%lld\n", ans);

	return 0;
}

Compiler output:
a.cc: In function 'bool ck(int)':
a.cc:36:24: error: 'b' was not declared in this scope
   36 |                 return b[x]+m>=b[p];
      |                        ^
a.cc:40:33: error: 'b' was not declared in this scope
   40 |                         ll sum=(b[x]+m)*((x-1)-p+1)-(s[x-1]-s[p-1]);
      |                                 ^
a.cc:46:32: error: 'b' was not declared in this scope
   46 |                         return b[x]+m>=b[p];
      |                                ^