criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    long[] a = new long[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }
    Arrays.sort(a);
    int ans = 0;
    int left = 0;
    int right = n;
    while(left < right) {
      int med = (left + right) / 2;
      boolean[][] dp = new boolean[n][k]; 
      if(med != 0) {
        dp[0][0] = true;
        if(a[0] < k) dp[0][a[0]] = true;
      } else {
        dp[0][0] = true;
        if(n > 1) {
          dp[1][0] = true;
          if(a[1] < k) dp[1][a[1]] = true;
        }
      }
      for(int i = 1; i < n; i++) {
        dp[i][0] = true;
        for(int j = 1; j < k; j++) {
          dp[i][j] = dp[i - 1][j];
          if((i != med) && (j >= a[i])) dp[i][j] = (dp[i][j] || dp[i - 1][j - a[i]]);
        }
      }
      int p = 0;
      for(int j = Math.max(0, k - a[med]); j < k; j++) {
        if(dp[n - 1][j]) p++;
      }
      if(p == 0) {
        left = med + 1;
      } else {
        ans = med;
        right = med;
      }
    }
    System.out.println(n - ans);
  }
}

Compiler output:
Main.java:21: error: incompatible types: possible lossy conversion from long to int
        if(a[0] < k) dp[0][a[0]] = true;
                            ^
Main.java:26: error: incompatible types: possible lossy conversion from long to int
          if(a[1] < k) dp[1][a[1]] = true;
                              ^
Main.java:33: error: incompatible types: possible lossy conversion from long to int
          if((i != med) && (j >= a[i])) dp[i][j] = (dp[i][j] || dp[i - 1][j - a[i]]);
                                                                            ^
Main.java:37: error: incompatible types: possible lossy conversion from long to int
      for(int j = Math.max(0, k - a[med]); j < k; j++) {
                          ^
4 errors
Language: C++

#define SIZE 5005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
bool dp[SIZE];
int A[SIZE];
P pos[SIZE];
 
int main()
{
	int n,K;
	scanf("%d %d",&n,&K);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	sort(A,A+n);
	ll sum=0;
	for(int i=0;i<n;i++) sum+=A[i];
	memset(dp,false,sizeof(dp));
	dp[0]=true;
	int ret=0;
	for(int i=n-1;i>=0;i--)
	{
		bool up=false;
		for(int j=0;j<K;j++)
		{
			if(dp[j]&&j+sum>=K) up=true;
		}
		if(!up) ret++;
		sum-=A[i];
		for(int j=K-1;j>=A[i];j--) dp[j]|=dp[j-A[i]];
	}
	printf("%d\n",ret);
	return 0;
}

Compiler output:
a.cc:5:9: error: 'pair' does not name a type
    5 | typedef pair <int,int> P;
      |         ^~~~
a.cc:9:1: error: 'P' does not name a type
    9 | P pos[SIZE];
      | ^
a.cc: In function 'int main()':
a.cc:14:9: error: 'scanf' was not declared in this scope
   14 |         scanf("%d %d",&n,&K);
      |         ^~~~~
a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |         sort(A,A+n);
      |         ^~~~
      |         short
a.cc:19:9: error: 'memset' was not declared in this scope
   19 |         memset(dp,false,sizeof(dp));
      |         ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | #define SIZE 5005
a.cc:33:9: error: 'printf' was not declared in this scope
   33 |         printf("%d\n",ret);
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | #define SIZE 5005
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long w,a,b,i,j,k,n;
    cin>>n>>k;
    long long  ara[n];
    for(i=0;i<n;i++) cin>>ara[i];
    sort(ara,ara+n);
    for(i=n-1;i>=0;i--){
        if(ara[i]<k) {
            a=i;
            break;
        }
    }
    long long sum=0;
    for(i=0;i<=a;i++) sum+=ara[i];
    long long count=0;
    if(sum<k) {
        cout<<n<<endl;
        return 0;
    }
    for(i=0;i<=a;i++){
        sum=sum-ara[i];
        if(sum>=k) count++;
        else {
            break;
        }
    }
    cout<<count<<endl;
}

    for(i=0;i<=a;i++){
        sum=sum-ara[i];
        if(sum>=k) count++;
        else {
            break;
        }
    }
    cout<<count<<endl;
}


Compiler output:
a.cc:34:5: error: expected unqualified-id before 'for'
   34 |     for(i=0;i<=a;i++){
      |     ^~~
a.cc:34:13: error: 'i' does not name a type
   34 |     for(i=0;i<=a;i++){
      |             ^
a.cc:34:18: error: 'i' does not name a type
   34 |     for(i=0;i<=a;i++){
      |                  ^
a.cc:41:5: error: 'cout' does not name a type
   41 |     cout<<count<<endl;
      |     ^~~~
a.cc:42:1: error: expected declaration before '}' token
   42 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,K; cin>>N>>K;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vector<vector<bool>> dp(N+1,vector<bool>(K+1)),cp(N+1,vector<bool>(K+1));
  dp[0][0]=1;
  rep(i,0,N){
    REP(j,0,K){
      if(dp[i][j]){
        dp[i+1][j]=1;
        dp[i+1][min(j+A[i],K)]=1;
      }
    }
  }
  cp[N][0]=1;
  rep(i,0,N){
    int k=N-i;
    REP(j,0,K){
      if(cp[k][j]){
        cp[k-1][j]=1;
        cp[k-1][min(j+A[k-1],K)]=1;
      }
    }
  }
  int ans=0;
  rep(i,0,N){
    int sum=0;
    int memo=K-1;
    rep(j,0,K){
      if(F[j]){
        for(memo;0<=memo;memo--){
          if(F[memo]&&memo+j<K){
            sum=max(sum,memo+j);
            break;
          }
        }
      }
    }
    if(sum+A[i]<K) ans++;
  }
  cout<<ans<<endl;
  }



Compiler output:
a.cc: In function 'int main()':
a.cc:48:10: error: 'F' was not declared in this scope
   48 |       if(F[j]){
      |          ^
Language: C++

#include <bits/stdc++.h>

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

bool dp[5010][5010]={},dpr[5010][5010]={};
signed main(){
	int n,k;
	cin>>n>>k;
	int a[5010];
	rep(i,n){
		cin>>a[i];
	}
	dp[0][0]=true;
	dpr[0][0]=true;
	rep(i,1,n+1){
		rep(j,k)dp[i][j]=dp[i-1][j];
		rep(j,k){
			if(dp[i-1][j]){
				if(j+a[i-1]<k)dp[i][j+a[i-1]]=true;
			}
		}
	}
	rep(i,1,n+1){
		rep(j,k)dpr[i][j]=dpr[i-1][j];
		rep(j,k){
			if(dpr[i-1][j]){
				if(j+a[n-i]<k)dpr[i][j+a[n-i]]=true;
			}
		}
	}
	int cnt=0;
	rep(i,n){
		int mn=INF;
		vector<int> s,t;
		rep(j,k){
			if(dp[i][j])s.push_back(j);
			if(dpr[n-i-1][j])t.push_back(j);
		}
		rep(j,s.size()){
			int l=lower_bound(t.begin(),t.end(),k-s[j]-a[i])-t.begin();
			if(l<t.size())chmin(mn,s[j]+a[i]+t[l]);
		}
		if(mn==INF||mn-a[i]>=k)cnt++;
	}
	cout<<cnt<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:39: error: 'chmin' was not declared in this scope
   55 |                         if(l<t.size())chmin(mn,s[j]+a[i]+t[l]);
      |                                       ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<long>a(n);
  int i,j;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end(),greater<long>());
  vector<set<long> >num(n);
  int tmp = 0;
  vector<bool>chk(n,false);
  for(i=0;i<n;i++){
    num[i].insert(a[i]);
    if(a[i]>=k){
      tmp++;
      chk[i] = true;
    }
  }
  long tmppp = 0:
  for(i=tmp;i<n;i++){
    tmppp+=a[i];
  }
  if(tmppp<k)tmp = 99999999;
  for(i=tmp;i<n;i++){
    for(j=tmp;j<n;j++){
      if(i != j && !chk[j]){
        set<long>tmpp;
        for(auto kk: num[j]){
          if(kk+a[i]>=k && kk+a[i]-a[j]<k)chk[j]=true;
          else if(kk+a[i]<k)tmpp.insert(kk+a[i]);
        }
        for(auto kk:tmpp)num[j].insert(kk);
      }
    }
  }
  int ans = 0;
  for(i=0;i<n;i++){
    if(chk[i]==false)ans++;
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: expected ',' or ';' before ':' token
   22 |   long tmppp = 0:
      |                 ^
a.cc:23:20: error: expected ';' before ')' token
   23 |   for(i=tmp;i<n;i++){
      |                    ^
      |                    ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define MOD 10e9+7

int main(){
    int N, K; cin >> N >> K;
    int a[N]; rep(i, N) cin >> a[i];

    sort(a,a+N,greater<int>());
    int cnt = N;
    for(int i=0; i<N){
        long int sum = 0;
        for(int j=i; j<N; j++){
            sum += a[j];
            if(sum >= K){
                cnt = N-(j+1);
                i = j+1;
                break;
            }
        }
        if(	sum < K) break;
    }
    cout << cnt;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:21: error: expected ';' before ')' token
   12 |     for(int i=0; i<N){
      |                     ^
      |                     ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define MOD 10e9+7

int main(){
    int N, K; cin >> N >> K;
    int a[N]; rep(i, N) cin >> a[i];

    sort(a,a+N,greater<int>());
    int cnt = N;
    for(int i=0; i<N){
        long int sum = 0;
        for(int j=i; j<N; j++){
            sum += a[j];
            if(sum >= K){
                cnt = N-(j+1);
                i = j+1;
                break;
            }
        }
        if(sum < K) break;
    }
    cout << cnt;
}

6 20
25 10 10 4 3 2

Compiler output:
a.cc: In function 'int main()':
a.cc:12:21: error: expected ';' before ')' token
   12 |     for(int i=0; i<N){
      |                     ^
      |                     ;
a.cc: At global scope:
a.cc:27:1: error: expected unqualified-id before numeric constant
   27 | 6 20
      | ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
int n,m,a[5001],l,r;
bool jl[INF];
bool dp[5001];
bool check(int k){
//	cout<<k<<endl;
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	rep(i,n){
		if(i==k){
			continue;
		}
		for(int j=m-a[i];j>=0;j--){
			dp[j+a[i]]|=dp[j];
		}
		/*rep0(j,g){
			cout<<dp[j]<<' ';
		}
		cout<<endl;*/
	}
	ll t=max(m-a[k],m-m);
//	cout<<t<<endl;
	for(int i=t;i<=m-1;i++){
		if(dp[i]){
			return 0; 
		}
	}
	return 1;
}
int hash(int a,int b){
	return (a*101+b*37)%INF; 
}
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n>>m;
	rep(i,n){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	l=1;
	r=n;
	while(l<=r){
		ll mid=(l+r)/2;
		if(check(mid)){
//			cout<<1<<' '<<mid<<endl<<endl;
			l=mid+1;
		}
		else{
//			cout<<0<<' '<<mid<<endl<<endl;
			r=mid-1;
		}
		if(jl[hash(l,r)]){
			break;
		}
		jl[hash(l,r)]=1;
	}
	cout<<(l+r)/2;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:23: error: reference to 'hash' is ambiguous
   62 |                 if(jl[hash(l,r)]){
      |                       ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:38:5: note:                 'int hash(int, int)'
   38 | int hash(int a,int b){
      |     ^~~~
a.cc:65:20: error: reference to 'hash' is ambiguous
   65 |                 jl[hash(l,r)]=1;
      |                    ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:38:5: note:                 'int hash(int, int)'
   38 | int hash(int a,int b){
      |     ^~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=1;i<=(n);i++)
#define rep0(i,n) for(ll i=0;i<(n);i++)

const ll INF=1e9+7;
ll n,m,a[5001],g,l,r;
bool jl[INF];
bool dp[5001];
bool check(int k){
//	cout<<k<<endl;
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	rep(i,n){
		if(i==k){
			continue;
		}
		for(ll j=g-a[i];j>=0;j--){
			dp[j+a[i]]|=dp[j];
		}
		/*rep0(j,g){
			cout<<dp[j]<<' ';
		}
		cout<<endl;*/
	}
	ll t=max(m-a[k],m-m);
//	cout<<t<<endl;
	for(ll i=t;i<=m-1;i++){
		if(dp[i]){
			return 0; 
		}
	}
	return 1;
}
ll hash(ll a,ll b){
	return (a*101+b*37)%INF; 
}
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n>>m;
	rep(i,n){
		cin>>a[i];
		g+=a[i]; 
	}
	sort(a+1,a+n+1);
	l=1;
	r=n;
	while(l<=r){
		ll mid=(l+r)/2;
		if(check(mid)){
//			cout<<1<<' '<<mid<<endl<<endl;
			l=mid+1;
		}
		else{
//			cout<<0<<' '<<mid<<endl<<endl;
			r=mid-1;
		}
		if(jl[hash(l,r)]){
			break;
		}
		jl[hash(l,r)]=1;
	}
	cout<<(l+r)/2;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:23: error: reference to 'hash' is ambiguous
   63 |                 if(jl[hash(l,r)]){
      |                       ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:38:4: note:                 'long long int hash(long long int, long long int)'
   38 | ll hash(ll a,ll b){
      |    ^~~~
a.cc:66:20: error: reference to 'hash' is ambiguous
   66 |                 jl[hash(l,r)]=1;
      |                    ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:38:4: note:                 'long long int hash(long long int, long long int)'
   38 | ll hash(ll a,ll b){
      |    ^~~~
Language: C++

#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, k, a[5010];
int dp[2][5010][5010];
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		if (!i) {
			dp[0][i][0] = 1;
			dp[0][i][a[i]] = 1;
			continue;
		}
		rep(j, k) {
			if (j - a[i] >= 0)dp[0][i][j] |= (bool)dp[0][i - 1][j - a[i]];
			dp[0][i][j] |= (bool)dp[0][i - 1][j];
		}
	}
	rep(i, n) {
		rep(j, k) {
			if (j)dp[0][i][j] += dp[0][i][j - 1];
		}
	}
	for (int i = n - 1; i >= 0; i--) {
		if (i == n - 1) {
			dp[1][i][0] = 1;
			dp[1][i][a[i]] = 1;
			continue;
		}
		rep(j, k) {
			if (j - a[i] >= 0)dp[1][i][j] |= (bool)dp[1][i + 1][j - a[i]];
			dp[1][i][j] |= (bool)dp[1][i + 1][j];
		}
	}
	rep(i, n) {
		rep(j, k) {
			if (j)dp[1][i][j] += dp[1][i][j - 1];
		}
	}
	int ans = 0;
	if (dp[1][1][k - 1] == dp[1][1][max((ll)0,k - a[0]]))ans++;
	for (int i = 1; i < n - 1; i++) {
		bool f = false;
		for (int j = 1; j < k; j++) {
			if (dp[0][i - 1][j - 1] != dp[0][i - 1][j] && dp[1][i + 1][max((ll)0, k - j - a[i])] != dp[1][i + 1][k - j - 1])f = true;
		}
		if (!f)ans++;
	}
	if (dp[0][n - 2][k - 1] == dp[0][n - 2][max((ll)0,k - a[n - 1])])ans++;
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:59: error: expected ')' before ']' token
   65 |         if (dp[1][1][k - 1] == dp[1][1][max((ll)0,k - a[0]]))ans++;
      |                                            ~              ^
      |                                                           )
a.cc:65:61: error: expected primary-expression before ')' token
   65 |         if (dp[1][1][k - 1] == dp[1][1][max((ll)0,k - a[0]]))ans++;
      |                                                             ^
Language: C++

#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define all(v) v.begin(),v.end()
int n,k,a[5010];
bool dp1[5010][5010],dp2[5010][5010];
signed main(){
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	dp1[0][0]=true;
	rep(i,n-1){
		rep(j,k){
			if(dp1[i][j])dp1[i+1][j]=true;
			if(dp1[i][j]&&j+a[i]<=k)dp1[i+1][j+a[i]]=true;
		}
	}
	dp2[n-1][0]=true;
	for(int i=n-1;i>0;i--){
		rep(j,k){
			if(dp2[i][j])dp2[i-1][j]=true;
			if(dp2[i][j]&&j+a[i]<=k)dp2[i-1][j+a[i]]=true;
		}
	}
	int ans=0;
	rep(i,n){
		vector<int>a1,a2;
		rep(j,k+1){
			if(dp1[i][j])a1.push_back(j);
			if(dp2[i][j])a2.push_back(j);
		}
		bool flag=true;
		for(int x:a1){
			if(upper_bound(all(a2),k-x-1)-lower_bound(all(a2),k-x-a[i]))flag=false;
		}
		if(b==false)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:20: error: 'b' was not declared in this scope
   36 |                 if(b==false)ans++;
      |                    ^
Language: C

#include<stdio.h>
#define d_flag 0
int C(const void *a,const void *b){
  return *(int*)b-*(int*)a;
}

int main(){
  int n,K,count=0;
  scanf("%d%d",&n,&K);
  int i,a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]>=K){
      i--;
      n--;
    }
  }
  sqrt(a,n,sizeof(int),C);
  if(d_flag) {
    for(i=0;i<n;i++)
      printf(" %d",a[i]);
    printf("\n");
  }
  int dp[K+1],j,k,flag;
  for(i=0;i<n;i++){
    if(a[i]>=K)continue;
    flag=1;
    for(j=0;j<=K;j++){
      dp[j]=0;
    }
    dp[0]=1;
    for(k=0;k<n;k++){
      if(k==i)continue;
      for(j=K-a[k];j>=0;j--){
	if(dp[j]==1) {
	  dp[j+a[k]]=1;
	  if(j+a[k]>=K-a[i]){
	    flag=0;
	    break;
	  }
	}
	if(flag==0)break;
      }
      if(flag==0)break;
    }
    if(flag==0)continue;
    /*
    for(j=K-a[i];j<K;j++)
      if(dp[j]==1) flag=0;
    */
    count++;
    if(d_flag){
      printf("without a[%d]=%d:\n",i,a[i]);
      int kkk;
      for(kkk=0;kkk<=K;kkk++)printf(" %d",dp[kkk]);
      printf(" ,flag:%d\n",flag);
    }
  }
  printf("%d",count);
}


Compiler output:
main.c: In function 'main':
main.c:18:3: error: implicit declaration of function 'sqrt' [-Wimplicit-function-declaration]
   18 |   sqrt(a,n,sizeof(int),C);
      |   ^~~~
main.c:2:1: note: include '<math.h>' or provide a declaration of 'sqrt'
    1 | #include<stdio.h>
  +++ |+#include <math.h>
    2 | #define d_flag 0
main.c:18:3: warning: incompatible implicit declaration of built-in function 'sqrt' [-Wbuiltin-declaration-mismatch]
   18 |   sqrt(a,n,sizeof(int),C);
      |   ^~~~
main.c:18:3: note: include '<math.h>' or provide a declaration of 'sqrt'
main.c:18:8: error: incompatible type for argument 1 of 'sqrt'
   18 |   sqrt(a,n,sizeof(int),C);
      |        ^
      |        |
      |        int *
main.c:18:8: note: expected 'double' but argument is of type 'int *'
main.c:18:3: error: too many arguments to function 'sqrt'
   18 |   sqrt(a,n,sizeof(int),C);
      |   ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
 
int main(){
  int N, K;cin>>N>>K;
  vi a;
  a.push_back(0);
  for (int i=0;i<N;++i){
    int a_;cin>>a_;a.push_back(a_);
  }
  a.push_back(0);
 
  int left[2][K+1], right[2][K+1];
  memset(left, -1, sizeof(left));
  memset(right, -1, sizeof(right));
 
  left[0][0]=1;
  right[0][0]=1;
  vi l_sum[N+2], r_sum[N+2];
  l_sum[0].push_back(0);r_sum[N+1].push_back(0);
 
  for (int i=0;i<N+1;++i){
    for (int j=0;j<K+1;++j){
      if(left[0][j]==1||(j>=a[i+1]&&left[0][j-a[i+1]]==1)) {
        left[1][j]=1;
        l_sum[i+1].push_back(j);
      }
    }
    left[0]=left[1];
  }
 
  for (int i=N+1;i>=1;--i){
    for (int j=0;j<K+1;++j){
      if(right[0][j]==1||(j>=a[i-1]&&right[0][j-a[i-1]]==1)) {
        right[1][j]=1;
        r_sum[i-1].push_back(j);
      }
    }
    right[0]=right[1];
  }
 
  
  int ans=0;
  
 
  for (int i=1;i<N+1;++i){
    int L=l_sum[i-1].size();
    int patience=1;
    for (int l=0;l<L;++l){
      int R=r_sum[i+1].size();
      int x=lower_bound(r_sum[i+1].begin(), r_sum[i+1].end(), K-l_sum[i-1][l]-a[i])-r_sum[i+1].begin();
      if (x>R-1) continue;
      if(r_sum[i+1][x]+l_sum[i-1][l]<K) patience=0;
    }
    if(patience==1) ans++;
  }
 
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:12: error: invalid array assignment
   30 |     left[0]=left[1];
      |     ~~~~~~~^~~~~~~~
a.cc:40:13: error: invalid array assignment
   40 |     right[0]=right[1];
      |     ~~~~~~~~^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

int main(){
  int N, K;cin>>N>>K;
  vi a;
  a.push_back(0);
  for (int i=0;i<N;++i){
    int a_;cin>>a_;a.push_back(a_);
  }
  a.push_back(0);

  int left[N+2][K+1], right[N+2][K+1];
  memset(left, -1, sizeof(left));
  memset(right, -1, sizeof(right));

  left[0][0]=1;
  right[N+1][0]=1;

  for (int i=0;i<N+1;++i){
    for (int j=0;j<K+1;++j){
      if(left[i][j]==1||(j>=a[i+1]&&left[i][j-a[i+1]]==1)) left[i+1][j]=1;
    }
  }

  for (int i=N+1;i>=1;--i){
    for (int j=0;j<K+1;++j){
      if(left[i][j]==1||(j>=a[i-1]&&left[i][j-a[i-1]]==1)) left[i-1][j]=1;
    }
  }

  vi l_sum[N+2], r_sum[N+2];
  int ans=0;

  for (int i=0;i<N+2;++i){
    for (int j=0;j<K+1;++j){
      if(left[i][j]==1)l_sum[i].push_back(j);
      if(right[i][j]==1)r_sum[i].push_back(j);
    }
  }

  for (int i=1;i<N+1;++i){
    int L=l_sum[i-1].size();
    for (int l=0;l<L;++l){
      x=lower_bound(r_sum[i+1].begin(), r_sum[i+1].end(), K-l_sum[i-1][l]-a[i])-l_sum[i-1].begin();
      if(r_sum[i+1][x]+l_sum[i-1][l]>=K) ans++;
    }
  }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:46:7: error: 'x' was not declared in this scope
   46 |       x=lower_bound(r_sum[i+1].begin(), r_sum[i+1].end(), K-l_sum[i-1][l]-a[i])-l_sum[i-1].begin();
      |       ^
Language: C++

#include <stdio.h>
#include <iostream>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define vec vector<int>
#define All(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
int n;
int k;
vec a;
bool f(int m){
    vector<vector<bool>> dp(n,vector<bool>(k+1));
    dp[0][0]=true;
    if(a[0]<=k)dp[0][k]=0;
    rep2(i,1,n-1)rep2(j,0,k+1)dp[i][j]=i==m||j<a[i]?dp[i-1][j]:dp[i-1][j]||dp[i-1][j-a[i]];
    rep2(j,k-a[m],k-1)if(dp[n-1][j])return false;
    return true;
}
int main(){
    n=in();
    k=in();
    a=vec(n);
    rep(i,n)a[i]=in();
    sort(All(a));
    rep3(i,n-1,0);
    int l=0,r=n;
    while(l+1<r){
        int m=(l+r)/2;
        if(f(m))l=m;
        else r=m;
    }
    cout<<r<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   28 |     sort(All(a));
      |     ^~~~
      |     short
Language: C++

#include <cstdio>
#include <algorithm>
#include <cstring> 
#define MAXN 5050
#define ll long long
using namespace std;
int a[MAXN], dp[MAXN][MAXN];
int n, k;
/*  
	dp[i][j]表示从前i个元素中是否可以选择一些数使得它们的和为j
				  一般情况：dp[i,j] = dp[i-1][j];
	状态转移方程：当j大于ai时：dp[i,j] = dp[i-1,j]|dp[i-1,j-ai] 
	1、排序 
	2、如果ai是不必要的元素，那么ai之前的元素都是不必要的，因此二分查找ai出现的位置 
    3、使用check函数判断当前元素x是不是必要的 ,是则返回true 不是返回false
		如果x是有用的元素，那么一定可以从n个元素中选择一些元素之和在[k-a[s], k)之间，遍历dp[n][(k-a[i], k)]即可 
		使用dp判断出所有的存在于这个区间的元素，如果能找到，说明x是有用的元素，返回true 
*/ 
bool check(int x) { 
	memset(dp, 0, sizeof(dp));
	if(x==1) {
		dp[2][0] = 1;
        dp[2][a[2]] = 1;
        for(int i = 3; i <= n; i++) 
            for(int j = 0; j <= k; j++) {
                dp[i][j] = dp[i-1][j];
                if(j >= a[i])
                    dp[i][j] = dp[i-1][j] | dp[i-1][j-a[i]];    
            }
	} 
	else {
		dp[1][0] = 1;
		dp[1][a[1]] = 1;
		for(int i = 2; i <= n; i++) 
			for(int j = 0; j <= k; j++) {
				dp[i][j] = dp[i-1][j];
				if(j >= a[i] && x != i) 
					dp[i][j] = dp[i-1][j] | dp[i-1][j-a[i]];
			}
	}
	for(int i = k-a[x]; i < k; i++)
		if(dp[n][i])
			return true;
	return false;	 
}
int main() {

	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if(a[i] > k) a[i] = k;
	}
	if(n==1) {
		if(a[1] >= k) printf("0\n")
		else printf("1\n");
		return 0;
	}
	sort(a+1, a+1+n);
	int l = 0, r = n+1;
	while(l+1 < r) {
		int mid = (l+r) / 2;
		if(check(mid)) r = mid;
		else l = mid;
	}
	printf("%d\n", l);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:44: error: expected ';' before 'else'
   54 |                 if(a[1] >= k) printf("0\n")
      |                                            ^
      |                                            ;
   55 |                 else printf("1\n");
      |                 ~~~~
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

int InputIntAry(int *a,int nBuf,int N,int K){
    int ret=0;
    int64_t tmp;
    char *buf,*ptr;

    buf=(char*)malloc(nBuf*sizeof(char));
    my_gets(buf,nBuf,stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        tmp=atoll(ptr);
        if(tmp < K){    //Kより大きなカードは必要に決まっているし, 他のカードの判定に関係しない
            a[ret++] = (int)tmp;
            //printf("%d\n",a[ret-1]);
        }
        ptr=strtok(NULL," ");
    }
    free(buf);

    return ret;
}

#define MIN(a,b)  ( ((a)<(b))?(a):(b) )

int main(){
    int a[5000];
    int N,K,cnt=0;
    
    scanf("%d %d%*c",&N,&K);
    N=InputIntAry(a,12*N,N,K);

    for(int i=0;i<N;i++){
        int dp[5001][5000]={},K_i,min=INT_MAX;

        K_i = K - a[i];
        dp[0][0]=1;
        for(int j=0;j<N;j++){
            if(j==i){
                for(int k=0;k<K_i;k++)
                    dp[j+1][k] = dp[j][k];
                continue;
            }
            for(int k=0;k<K_i;k++){
                if(dp[j][k]){
                    dp[j+1][k]=1;
                    if(k+a[j] >= K_i){
                        min = MIN(k+a[j],min);
                    }
                    else{
                        dp[j+1][k+a[j]] =1;
                    }
                }
            }
        }
        //printf("%d: %d min:%d\n",i,a[i],min);
        if(min >= K)
            cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:39: error: 'INT_MAX' was not declared in this scope
   54 |         int dp[5001][5000]={},K_i,min=INT_MAX;
      |                                       ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include<x86intrin.h>
  +++ |+#include <climits>
    7 |
Language: C++

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
typedef long long ll;
#define N 5050
int a[N]={0};
int  main(){
    ll n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    sort(a,a+n);//排序，容易知道一定是最小的那几个是不需要的
    ll sum = 0;
    ll p = n;

    for(ll i=n-1; i>=0; i--){
        if(sum+a[i]<k){
            sum +=a[i];
        }
        else{
            p = i;
        }
    }
    cout<<p<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   16 |     cin>>n>>k;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:20:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   20 |     sort(a,a+n);//排序，容易知道一定是最小的那几个是不需要的
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:32:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   32 |     cout<<p<<endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:32:14: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   32 |     cout<<p<<endl;
      |              ^~~~
      |              std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include <iostream>
#include <set>
#include <map>
#include <vector>

using namespace std;
typedef long long ll;

int a[5001];
int main(int argc, const char * argv[]) {
  int n, k;
  cin >> n >> k;
  

  int ans = n;
  
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  sort(a, a + n);
  
  int sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (sum + a[i] < k) {
      sum += a[i];
    } else {
      ans = min(ans, i);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#include <iostream>
#include <set>
#include <map>
#include <vector>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  int n, k;
  cin >> n >> k;
  
  int a[5001];
  int ans = n;
  
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  sort(a, a + n);
  
  int sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (sum + a[i] < k) {
      sum += a[i];
    } else {
      ans = min(ans, i);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

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

    vector<int> a;
    for(int i = 0; i < n; i++){
        int ta;
        cin >> ta;
        if(ta <= k){
            a.push_back(ta);
        }
    }
    sort(a.begin(),a.end());
    n = a.size();

    vector<vector<int>> dp(n+1,vector<int>(k+1,0));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= k; j++){
            dp[i+1][min(j+a[i],k)] += dp[i][j];
            dp[i+1][j] += dp[i][j];
        }
    }

    int ok = -1;
    int ng = n;

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

        vector<vector<int>> dp2(n,vector<int>(k+1,0));
        dp2[0][0] = 1;
        for(int i = 0; i < n-1; i++){
            int index = i >= mid ? i+1 : i;
            for(int j = 0; j <= k; j++){
                dp2[i+1][min(j+a[index],k)] +Q= dp2[i][j];
                dp2[i+1][j] += dp2[i][j];
            }
        }

        if (dp2[n-1][k]*2 == dp[n][k]) ok = mid;
        else ng = mid;
    }

    cout << ok + 1 << endl;

    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:46: error: 'Q' was not declared in this scope
   44 |                 dp2[i+1][min(j+a[index],k)] +Q= dp2[i][j];
      |                                              ^
Language: C++

#include <cstdio>
#include<bitset>
#include<iostream>
#include<string>
#define ll long long 
using namespace std;
long long n,k;
ll a[5010];
bitset<5010> bs;
bool check(int x)
{
	bs.reset();
	bs[0]=1;
	for(int i=1;i<=n;i++)
	if(i!=x) bs|=(bs<<a[i]);
	for(int i=k-a[x];i<k;i++)
	if(bs[i]==1) return false;
	return true;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	int l=0,r=0,mid;
	for(int i=n;i>=1;i--)
	{
		if(a[i]<k) 
		{
			r=i;
			break;
		}
	}
	while(l<r)
	{
		mid=((l+r)>>1)+1;
		if(check(mid)) 
			l=mid;
		else r=mid-1;
	}
	cout<<l;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   25 |         sort(a+1,a+n+1);
      |         ^~~~
      |         short
Language: C++

#include <cstdio>
#include <algorithm>
#include <bitset>
#define MAXN 50005
#define MAXBS 70005
using namespace std;
bitset<MAXBS> bs;
long long a[MAXN]={0};
long long n=0,k=0;
long long check(long long x);
int main(void){
    long long ll=0,rr=0;
    scanf("%lld%lld",&n,&k);
    for (int i=0;i<n;i++){
        scanf("%lld",a+i);
        a[i]=min(a[i],k);
    }
    if (n==1){
        printf("%d\n",int(a[0]==k));
        return 0;
    }
    sort(a,a+n);
    //(ll,rr]
    ll=-1,rr=n+1;
    while (rr-ll>1){
        long long mid=(ll+rr+1)>>1;
        if (check(mid))
            rr=mid;
        else
            ll=mid;
    }
    printf("%lld\n",ll+1);
    return 0;
}

long long check(long long x){
    bs.reset(); // bs=0
    bs.set(0); // bs[0]=1;
    for (long long i=0;i<n;i++)
        if (i!=x)
            bs|=(bs<<a[i]);
    for (long long i=max(0,k-a[x]);i<k;i++){
        if (bs.test(i))
            return 1;
    }
    return 0;
}

Compiler output:
a.cc: In function 'long long int check(long long int)':
a.cc:42:25: error: no matching function for call to 'max(int, long long int)'
   42 |     for (long long i=max(0,k-a[x]);i<k;i++){
      |                      ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 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:42:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   42 |     for (long long i=max(0,k-a[x]);i<k;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:42:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   42 |     for (long long i=max(0,k-a[x]);i<k;i++){
      |                      ~~~^~~~~~~~~~
Language: C++

#include <cstdio>
#include <algorithm>
#include <bitset>
#define MAXN 5005
#define MAXBS 7005
using namespace std;
bitset<MAXBS> bs;
int a[MAXN];
int n,k;
int check(int x);
int main(void){
    int ll,rr;
    scanf("%d%d",&n,&k);
    for (int i=0;i<n;i++){
        scanf("%d",a+i);
        a[i]=min(a[i],k);
    }
    sort(a,a+n);
    //[ll,rr)
    ll=0,rr=n+1;
    while (rr-ll>1){
        int mid=(ll+rr)>>1;
        if (check(mid))
            rr=mid;
        else
            ll=mid;
    }
    printf("%d\n",ll+1);
    return 0;
}

int check(int x){
    bs(0)
    bs[0]=1;
    for (int i=0;i<n;i++)
        if (i!=x)
            bs|=(bs<<a[i]);
    for (int i=max(0,k-a[x]);i<k;i++){
        if (bs[i])
            return 1;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int check(int)':
a.cc:33:7: error: no match for call to '(std::bitset<7005>) (int)'
   33 |     bs(0)
      |     ~~^~~
Language: C++

#include<iostream>
using namespace std;
int n,s,k,a[5001],dp[5001],vis=1;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]=min(a[i],k);
		s+=a[i];
		}
	sort(a+1,a+n+1);
	dp[0]=1;
	for(int i=n;i>=0;i--)
	{
		vis=1;
		for(int j=k-1;j>=k-s and j>=0;j--)
		{
			if(dp[j])vis=0;
			}
		if(vis)
		{
			cout<<i;
			break;
			}
		for(int j=k;j>=a[i];j--)
		{
			dp[j]|=dp[j-a[i]];
			}
		s-=a[i];
		}
	return 0;
	}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |         sort(a+1,a+n+1);
      |         ^~~~
      |         short
Language: C++

#include <bits/stdc++.h>

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl,ok;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n>>k;
      rep(i,n)cin>>a[i];
      rep(i,n){
        bitset<k+1> dp;
        dp[0]=true;
        ok=true;
        rep(j,n){
          if(i==j)continue;
          dp|=(dp<<a[j]);
        }
        if(k<=a[i])continue;
        rrep(j,k-a[i],k){
          if(dp[j]){
            ok=false;
            break;
          }
        }
        if(ok)ans++;
      }
      Cout(ans);
    
       
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:18: error: the value of 'k' is not usable in a constant expression
   33 |         bitset<k+1> dp;
      |                  ^
a.cc:17:73: note: 'long long int k' is not const
   17 | long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k;
      |                                                                         ^
a.cc:33:19: error: the value of 'k' is not usable in a constant expression
   33 |         bitset<k+1> dp;
      |                   ^
a.cc:17:73: note: 'long long int k' is not const
   17 | long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k;
      |                                                                         ^
a.cc:33:17: note: in template argument for type 'long unsigned int'
   33 |         bitset<k+1> dp;
      |                ~^~
a.cc:34:11: error: invalid types 'int[int]' for array subscript
   34 |         dp[0]=true;
      |           ^
a.cc:42:16: error: invalid types 'int[long long int]' for array subscript
   42 |           if(dp[j]){
      |                ^
Language: C++

#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int N,K,ans=0;
  cin >> N >> K;
  int a[N];
  FOR(i,0,N)cin >> a[i];
  FOR(i,0,N){
    if(a[i] < K){
      boo flag = 0;
      bool DP[K];
      FOR(j,0,K)DP[j] = 0;
      DP[0] = 1;
      FOR(j,0,N){
        if(i != j){
          REP(k,0,K){
            if(DP[k] && k+a[j] < K){
              if(K-a[i] <= k+a[j] && k+a[j] < K){
                flag = 1;
                break;
              }
              else DP[k+a[j]] = 1;
            }
          }
        }
        if(flag)break;
      }
      if(flag)ans++;
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:7: error: 'boo' was not declared in this scope; did you mean 'bool'?
   17 |       boo flag = 0;
      |       ^~~
      |       bool
a.cc:26:17: error: 'flag' was not declared in this scope
   26 |                 flag = 1;
      |                 ^~~~
a.cc:33:12: error: 'flag' was not declared in this scope
   33 |         if(flag)break;
      |            ^~~~
a.cc:35:10: error: 'flag' was not declared in this scope
   35 |       if(flag)ans++;
      |          ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=500010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int main(){
    int n,k;cin>>n>>k;
    ll a[5010];for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    int ng=0;int ok=n+1;
    while(ok-ng>1){
        bool dp[5010][5010]={false};
        int mid=(ng+ok)/2;
        ll s=a[mid];
        a[mid]=0;
        memset(dp,false,sizeof(dp));
        dp[0][0]=true;
        for(int i=1;i<=n;i++){
            for(int j=0;j<=k;j++){
                dp[i][j]|=dp[i-1][j];
                if(j-a[i]>=0){
                    dp[i][j]|=dp[i-1][j-a[i]];
                }
            }
        }    
        bool f=false;
        for(int i=max(0,k-s);i<k;i++){
            f|=dp[n][i];
        }
        if(f){
            ok=mid;
        }else{
            ng=mid;
        }
        a[mid]=s;
    }
    cout<<ng<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:22: error: no matching function for call to 'max(int, ll)'
   34 |         for(int i=max(0,k-s);i<k;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:34:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   34 |         for(int i=max(0,k-s);i<k;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:34:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |         for(int i=max(0,k-s);i<k;i++){
      |                   ~~~^~~~~~~
Language: C++

v#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,k,i,ans=0,a[5010];
    cin>>n>>k;
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    ll sum=0;
    for(i=n-1; i>=0; i--)
    {
        if(sum+a[i]<k) sum+=a[i];
        else ans=i;
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | v#include <bits/stdc++.h>
      |  ^
a.cc:1:1: error: 'v' does not name a type
    1 | v#include <bits/stdc++.h>
      | ^
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin>>n>>k;
      |     ^~~
a.cc:9:9: error: 'scanf' was not declared in this scope
    9 |         scanf("%d",&a[i]);
      |         ^~~~~
a.cc:10:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |     sort(a,a+n);
      |     ^~~~
      |     short
a.cc:17:5: error: 'cout' was not declared in this scope
   17 |     cout<<ans<<endl;
      |     ^~~~
a.cc:17:16: error: 'endl' was not declared in this scope
   17 |     cout<<ans<<endl;
      |                ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i,ans=0,a[5010];
    cin>>n>>k;
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    ll sum=0;
    for(i=n-1; i>=0; i--)
    {
        if(sum+a[i]<k) sum+=a[i];
        else ans=i;
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'll' was not declared in this scope
   10 |     ll sum=0;
      |     ^~
a.cc:13:12: error: 'sum' was not declared in this scope
   13 |         if(sum+a[i]<k) sum+=a[i];
      |            ^~~
Language: C++

#include <cstdio>
#include <vector>
using namespace std;

int main() {
        int n, k;
        scanf("%d%d", &n, &k);
        int ans = n, sum = 0;
        vector<int> a(n);
        for (int i = 0; i < n; i ++) scanf("%d", &a[i]);
        sort(a.begin(), a.end());
        for (int i = n - 1; i >= 0; i --) {
                if (sum + a[i] < k) sum += a[i];
                else ans = i;
        }
        printf("%d\n", ans);
        return 0;
}



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

#include <iostream>
using namespace std;
int n,k,a[5000],ans=0,used[5001],sum;
int main(void){
    cin>>n>>k;
  
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(a[i]<k){
        cout<<0<<endl;
        return 0;
    }
    int s=a[0],j=1;
    for(int i=0;j<n;s-=a[i],i++){
        for(;j<n&&s<k;j++)s+=a[j];
        
        for(int l=i;l<j;l++){
            if(s-a[l]>=k&&!used[l]){
                ans++;
                used[l]=1;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: 'i' was not declared in this scope
   11 |     if(a[i]<k){
      |          ^