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

#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#define int long long
#define uint unsigned long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
using namespace std;

int a[5000];
int dp[5000][5000];

int func(int n, int k) //nまで使ったとき総和をkにできるか
{
	if (k < 0)
	{
		return 0;
	}

	if (dp[n][k] >= 0)
	{
		return dp[n][k];
	}

	if (n == 0)
	{
		return (a[0] == k) ? 1 : 0;
	}

	int res = 0;
	if (func(n - 1, k) == 1)
	{
		res = 1;
	}
	if (func(n - 1, k - a[n]) == 1)
	{
		res = 1;
	}
	dp[n][k] = res;
	return res;
}

signed main()
{
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}

	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		int temp = a[i];
		a[i] = 0;
		memset(dp, -1, sizeof(dp));
		for (int j = MAX(0, K - temp); j < K; j++)
		{
			if (func(N - 1, j) == 1)
			{
				cnt++;
				break;
			}
		}
		a[i] = temp;
	}

	cout << (N - cnt) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:17: error: 'memset' was not declared in this scope
   64 |                 memset(dp, -1, sizeof(dp));
      |                 ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <climits>
  +++ |+#include <cstring>
    8 | #define int long long
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int c[5001];
bool dp[5001];
signed main() {
	int a, b; scanf("%d%d", &a, &b);
	int sum = 0;//個数
	for (int d = 0; d < a; d++) {
		int e; scanf("%d", &e);
		if (e<b) {
			c[sum] = e;
			sum++;
		}
	}
	sort(c, c + sum);
	c[sum] = 1 << 29;
	sum++;
	int s = -1, g = sum-1;//[s,g) ぎりぎり必要なカード
	while (g - s > 1) {
		int d = (s + g) / 2;
		memset(dp, false, sizeof(dp));
		dp[0] = true;
		for (int e = 0; e < sum; e++) {
			if (d == e)continue;
			for (int f = b; f >= c[e]; f--) {
				if (dp[f - c[e]])dp[f] = true;
			}
		}
		bool K = false;
		for (int i = b - c[d]; i < b; i++) {
			if (dp[i])K = true;
		}
		if (!K) {//不必要
			s = d;
		}
		else {
			g = d;
		}
	}
	cout << g << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: 'memset' was not declared in this scope
   24 |                 memset(dp, false, sizeof(dp));
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int c[5000];
bool dp[5001];
signed main() {
	int a, b; scanf("%d%d", &a, &b);
	int sum = 0;//個数
	for (int d = 0; d < a; d++) {
		int e; scanf("%d", &e);
		if (e<b) {
			c[sum] = e;
			sum++;
		}
	}
	sort(c, c + sum);
	int s = 0, g = sum;//[s,g) ぎりぎり必要なカード
	while (g - s > 1) {
		int d = (s + g) / 2;
		memset(dp, false, sizeof(dp));
		dp[0] = true;
		for (int e = 0; e < sum; e++) {
			if (d == e)continue;
			for (int f = b; f >= c[e]; f--) {
				if (dp[f - c[e]])dp[f] = true;
			}
		}
		bool K = false;
		for (int i = b - c[d]; i < b; i++) {
			if (dp[i])K = true;
		}
		if (!K) {//不必要
			s = d;
		}
		else {
			g = d;
		}
	}
	printf("%d\n", g);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: 'memset' was not declared in this scope
   22 |                 memset(dp, false, sizeof(dp));
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <functional>
using namespace std;

int main() {
	
	int N;
	int K;
	int count = 0;
	vector<long long> a;
	
	long long sum = 0;
	
	cin >> N;
	cin >> K;
	
	bool dp[N+1][K+1];
	
	for ( int n = 0; n <= N; n++ ) {
		for ( int k = 0; k <= K; k++ ) {
			dp[n][k] = false;
		}
	}
	
	
	for ( int n = 0; n < N; n++ ) {
		long long tmp;
		cin >> tmp;
		a.push_back( tmp );
		
		sum += tmp;
	}
	
	if ( sum < K ) {
		cout << N << endl;
		return 0;
	}
	
	if ( n == 1 ) {
		cout << ( ( a[0] >= K ) ? 1 : 0 ) << endl;
		return 0;
	}
	
	for ( int n = 0; n < N; n++ ) {
		
		vector<long long> b;
		
		copy( a.begin(), a.end(), back_inserter(b) );
		
		b.erase( b.begin() + n );
		
			
		if ( a[n] >= K ) {
			for ( int i = 0; i < b.size(); i++ ) {
				if ( b[i] < K ) {
					count++;
					break;
				}
			}
		}
		else {
			for ( int i = b.size()-1; i >= 0; i-- ) {
				for ( int k = 1; k < K; k++ ) {
					// dp[i][k] = ( k == b[i] || dp[i+1][k] || ( k > b[i] && dp[i+1][ k-b[i] ] ) );
					if ( k == b[i] ) {dp[i][k] = true; }
					if ( dp[i+1][k] ) {dp[i][k] = true; }
					if ( k > b[i] && dp[i+1][ k-b[i] ] ) {dp[i][k] = true; }
				}
			}
		
			for ( int k = K-a[n]; k < K; k++ ) {
				if ( dp[0][k] ) {
					count++;
					break;
				}
			}
		
		
		
		// for ( vector<long long>::iterator it = b.begin(); it != b.end(); it++ ) {
			// cout << *it << endl;
		// }
		// cout << endl;
		
		// for ( int n = 0; n <= N; n++ ) {
			// for ( int k = 0; k <= K; k++ ) {
				// cout << "n:" << n << "k:" << k << "  " << (dp[n][k] ? "t" : "f") << endl;
			// }
		// }
		// cout << endl;
		
			for ( int n = 0; n <= N; n++ ) {
				for ( int k = 0; k <= K; k++ ) {
					dp[n][k] = false;
				}
			}
		}
	}
	
	cout << N - count << endl;
	
	return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:14: error: 'n' was not declared in this scope
   42 |         if ( n == 1 ) {
      |              ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <functional>
using namespace std;

int main() {
	
	int N;
	int K;
	int count = 0;
	vector<long long> a;
	
	long long sum = 0;
	
	cin >> N;
	cin >> K;
	
	bool dp[N+1][K+1];
	
	for ( int n = 0; n <= N; n++ ) {
		for ( int k = 0; k <= K; k++ ) {
			dp[n][k] = false;
		}
	}
	
	
	for ( int n = 0; n < N; n++ ) {
		long long tmp;
		cin >> tmp;
		a.push_back( tmp );
		
		sum += tmp;
	}
	
	if ( sum < K ) {
		cout << N << endl;
		return 0;
	}
	
	if ( n == 1 ) {
		cout << ( a[0] >= K ) ? 1 : 0;
		return 0;
	}
	
	for ( int n = 0; n < N; n++ ) {
		
		vector<long long> b;
		
		copy( a.begin(), a.end(), back_inserter(b) );
		
		b.erase( b.begin() + n );
		
			
		if ( a[n] >= K ) {
			for ( int i = 0; i < b.size(); i++ ) {
				if ( b[i] < K ) {
					count++;
					break;
				}
			}
		}
		else {
			for ( int i = b.size()-1; i >= 0; i-- ) {
				for ( int k = 1; k < K; k++ ) {
					// dp[i][k] = ( k == b[i] || dp[i+1][k] || ( k > b[i] && dp[i+1][ k-b[i] ] ) );
					if ( k == b[i] ) {dp[i][k] = true; }
					if ( dp[i+1][k] ) {dp[i][k] = true; }
					if ( k > b[i] && dp[i+1][ k-b[i] ] ) {dp[i][k] = true; }
				}
			}
		
			for ( int k = K-a[n]; k < K; k++ ) {
				if ( dp[0][k] ) {
					count++;
					break;
				}
			}
		
		
		
		// for ( vector<long long>::iterator it = b.begin(); it != b.end(); it++ ) {
			// cout << *it << endl;
		// }
		// cout << endl;
		
		// for ( int n = 0; n <= N; n++ ) {
			// for ( int k = 0; k <= K; k++ ) {
				// cout << "n:" << n << "k:" << k << "  " << (dp[n][k] ? "t" : "f") << endl;
			// }
		// }
		// cout << endl;
		
			for ( int n = 0; n <= N; n++ ) {
				for ( int k = 0; k <= K; k++ ) {
					dp[n][k] = false;
				}
			}
		}
	}
	
	cout << N - count << endl;
	
	return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:14: error: 'n' was not declared in this scope
   42 |         if ( n == 1 ) {
      |              ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

using ll = long long;

ll a[5100] = {};

bool dp_right[5010][5010] = {};
bool dp_left[5010][5010] = {};

int main(void){
    // Here your code !
    ll n,k;
    cin >> n >> k;
    
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    sort(a,a+n);
    
    for(int i = 0; i < n; i++){
        dp_right[i][0] = true;
        
        for(int j = 4999; j >= 0; j-- ){
            if(!dp_right[i][j]) continue;
			int nj = min(j + a[i], K);
			dp_right[i + 1][j] = true;
			dp_right[i + 1][nj] = true;
        }
    }
    
    
    dp_left[n][0] = true;
    
    for(int i = n-1; i >= 0; i--){
        dp_left[i][0] = true;
        
        for(int j = 4999; j >= 0; j-- ){
			if(!dp_left[i + 1][j]) continue;
			int nj = min(j + a[i], K);
			dp_left[i][j] = true;
			dp_left[i][nj] = true;
        }
    }
    
    //必要なカードの数
    ll res = 0;
    
    for(int i = 0; i < n ; i++){
        if( a[i] >= k ){
            res++;
            continue;
        }
        vector<int> x;
        
        for(int j = 0; j < k; j++) {
			if(dp_left[i + 1][j]) x.push_back(j);
		}
		
        for(int j = 0; j < k; j++){
            if(!dp_right[i][j]) continue;
            //cout << i << " " << j << endl;
			auto it = lower_bound(x.begin(), x.end(), max(0LL, k - j - a[i]));
			if(it == x.end()) continue;
			if(*it + j < k){
        		res++;
        		//cout << a[i] << endl;
        		break;
			}
        }
    }
    
    cout << n - res << endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:48: error: 'K' was not declared in this scope
   30 |                         int nj = min(j + a[i], K);
      |                                                ^
a.cc:44:48: error: 'K' was not declared in this scope
   44 |                         int nj = min(j + a[i], K);
      |                                                ^
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <codecvt>
#include <locale>
using namespace std;
using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for(int i=0; i<N; ++i) {
        cin >> a[i];
    }
    ll sum = accumulate(a.begin(), a.end(), 0LL);
    sort(a.rbegin(), a.rend());
    int res = 0;
    vector<bool> dp(K);
    dp[0] = true;
    for(int i=0; i<N; ++i) {
        bool f = false;
        for(int j=0; j<K; ++j) {
            f |= dp[j] && j+sum >= K;
        }
        if(!f) {
            res++;
        }
        sum -= a[i];
        for(int j=K-1-a[i]; j>=0; --j) {
            dp[j+a[i]] = dp[j+a[i]] | dp[j];
        }
    }
    cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:14: error: 'accumulate' was not declared in this scope
   21 |     ll sum = accumulate(a.begin(), a.end(), 0LL);
      |              ^~~~~~~~~~
Language: C++


#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

int32_t N,K;
int32_t a[5000];

constexpr int32_t INF = 2'000'000'000;
constexpr int32_t NUMBER = 5000;
int32_t ignore = -1;
#if 1
int32_t sum[NUMBER + 1];
int32_t dp[NUMBER][NUMBER + 1];
//[i]以降でMIN以上になるようにとったときのMINからのはみ出しの最小
int32_t func(int i, int MIN)
{
	if (MIN <= 0) {
		return { -MIN };
	}
	//if (i == N) {
	if (sum[i] < MIN) {
		return { INF };
	}
	if (dp[i][MIN] != INF) {
		return dp[i][MIN];
	}

	auto pata = func(i + 1, MIN);
	if (i == ignore) {
		return dp[i][MIN] = std::move(pata);
	}
	auto patb = func(i + 1, MIN - a[i]);
	if (pata < patb) {
		return dp[i][MIN] = std::move(pata);
	}
	else {
		//patb.second.push_back(i);
		return dp[i][MIN] = std::move(patb);
	}
}
#endif

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N >> K;
	for (size_t i = 0; i < N; i++)
	{
		in >> a[i];
		if (a[i] >= K) { --N; --i; }
	}
	std::sort(a , a + N);
	for (int i = N - 1; i >= 0; i--)
	{
		sum[i] = a[i] + sum[i + 1];
	}
	using BS_INT = int64_t;
	BS_INT beg = 1, end = N + 1;
	while (beg + 1 != end) {
		BS_INT mid = (beg + end) / 2;

		//ここに書く
		for (size_t k = 0; k < N; k++)for (size_t j = 0; j <= K; j++) {
			dp[k][j] = INF;
		}
		ignore = i;
		if (func(0, K - a[i]) < a[i] || func(0, K - a[i]) == INF) {
			end = mid;
		}
		else {
			beg = mid;
		}
	}
	out << beg << endl;

	return 0;
}
#endif

Compiler output:
a.cc: In function 'int main()':
a.cc:89:26: error: 'i' was not declared in this scope
   89 |                 ignore = i;
      |                          ^
Language: C++

#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

int N, K;
vector<int> a;
bitset<5001> dp;

//is m necessary?
bool sub(int m) {
	if(K <= a[m]) return true;
	dp.reset();
	for(int i = 0; i < N; ++i) {
		if(i != m) dp |= dp << a[i];
	}
	for(int b = K - a[m]; b < K; ++b) {
		if(dp[b]) return true;
	}
	return false;
}

int main(void) {
	cin >> N >> K;
	int s = 0;
	for(int i = 0; i < N; ++i) {
		int t;
		cin >> t;
		a.push_back(t);
		s += t;
	}
	sort(a.begin(), a.end());
	if(s < K) {
		cout << N << '\n';
		return 0;
	}

	if(sub(0)) {
		cout << "0\n";
		return 0;
	}
	int L = 0, R = N;
	while(1 < R - L) {
		int m = (L + R) / 2;
		//cout << m << '\n';
		(sub(m) ? R : L) = m;
	}
	cout << R << '\n';
	return 0;
}



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

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long a[5010];
long long dp[5010];
int main()
{
	int n, k;
	while(~scanf("%d%d",&n, &k))
	{
		for(int i=1; i<=n;i++)
		scanf("%lld",&a[i]);
		
		sort(a+1, a+1+n);
		
		long long  sum = 0;
		for(int i=1;i<=n;i++)
		{
			sum += a[i];
		}
		if(sum<k)
		{
			printf("%d\n",n);
			continue;
		}
		memset(dp,0,sizeof dp);
		dp[1] = a[1]<k?1:0;
		for(int i=2;i<=n;i++)
		{
			if(a[j]+a[i] >= k && a[i]<k)
			{
				break;
			}
			else if(a[i] == a[i-1])
			dp[i]++;
			else 
			dp[i]++;
			}
			
			if(dp[i] == i-1 && a[i] < k)//&& a[i] < k)
			{
				int ans = 0;
				sum = 0;
				for(int j=1;j<=i;j++)
				sum += a[j];
				if(sum < k)
				dp[i] = i;
				else 
				{
				for(int j=1;j<=i;j++)
				{
					if(sum-a[j] >= k)
					{
						ans++;
						sum -= a[j];
					}
				}
				dp[i] = ans;}
			}
		}
		
		printf("%lld\n", dp[n]);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:30: error: 'j' was not declared in this scope
   31 |                         if(a[j]+a[i] >= k && a[i]<k)
      |                              ^
a.cc:41:31: error: 'i' was not declared in this scope
   41 |                         if(dp[i] == i-1 && a[i] < k)//&& a[i] < k)
      |                               ^
a.cc: At global scope:
a.cc:65:9: error: expected unqualified-id before 'return'
   65 |         return 0;
      |         ^~~~~~
a.cc:66:1: error: expected declaration before '}' token
   66 | }
      | ^
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;
int N, K;
int a[5000];

bool is_needed(int i){

   if(a[i]>=K) return true;

   int memo[N+1][K];
   for(int j=0; j<N+1; j++)for(int k=0; k<K; k++) memo[j][k]=0;
   memo[0][0]=1;
   for(int j=0; j<N; j++){
      for(int k=0; k<K; k++){
         memo[j+1][k]|=memo[j][k];
         if(i!=j and k+a[j]<K) memo[j+1][k+a[j]]|=memo[j][k];
      }
   }
   bool need=false;
   for(int k=K-a[i]; k<K; k++) need|=memo[N][k];

   return need;
}

int main(){

   cin>> N>> K;
   for(int i=0; i<N; i++) cin>> a[i];

   sort(a, a+N);
   int l=0, u=N;
   while(u-l>1){
      int m=(u+l)/2;
      if(is_needed(m)) u=m;
      else l=m;
   }

   cout<< r<< endl;

   return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:11: error: 'r' was not declared in this scope
   40 |    cout<< r<< endl;
      |           ^
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long a[5010];
long long dp[5010];
int main()
{
	int n, k;
	while(~scanf("%d%d",&n, &k))
	{
		for(int i=1; i<=n;i++)
		scanf("%lld",&a[i]);
		
		sort(a+1, a+1+n);
		
		long long  sum = 0;
		for(int i=1;i<=n;i++)
		{
			sum += a[i];
		}
		if(sum<k)
		{
			printf("%d\n",n);
			continue;
		}
		memset(dp,0,sizeof dp);
		dp[1] = a[1]<k?1:0;
		for(int i=2;i<=n;i++)
		{
			for(int j=1;j<=dp[i-1];j++)
			{
			if(a[j]+a[i] >= k && a[i]<k)
			{
				break;
			}
			else 
			dp[i]++;}
			
			if(dp[i] == i-1 && a[i] < k))//&& a[i] < k)
			{
				int ans = 0;
				sum = 0;
				for(int j=1;j<=i;j++)
				sum += a[j];
				if(sum < k)
				dp[i] = i;
				else 
				{
				for(int j=1;j<=i;j++)
				{
					if(sum-a[j] >= k)
					{
						ans++;
						sum -= a[j];
					}
				}
				dp[i] = ans;}
			}
			else 
			dp[i]--;
		}
		
		printf("%lld\n", dp[n]);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:53: error: expected primary-expression before ')' token
   40 |                         if(dp[i] == i-1 && a[i] < k))//&& a[i] < k)
      |                                                     ^
Language: C++

#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
int nums[6000];
set<int> st;
int main(){
	int N, K,next;
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++)
		scanf("%d", nums + i);
	sort(nums, nums + N);
	int knot = N;
	st.clear();
	st.insert(0);
	vector<int>temp;
	for (int i=N-1;i>=0;i--){
        temp.clear();
		up=0;
		for (auto a:st){
			next=a+nums[i];
			if (next >= K){knot = i;up=1;break;}
			else temp.push_back(next);
		}
		if(!up)break;
		for(auto a : temp)
			st.insert(a);
	}
	printf("%d\n", knot);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'vector' was not declared in this scope
   16 |         vector<int>temp;
      |         ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <set>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:16:16: error: expected primary-expression before 'int'
   16 |         vector<int>temp;
      |                ^~~
a.cc:18:9: error: 'temp' was not declared in this scope; did you mean 'mktemp'?
   18 |         temp.clear();
      |         ^~~~
      |         mktemp
a.cc:19:17: error: 'up' was not declared in this scope
   19 |                 up=0;
      |                 ^~
Language: C++

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

int main() {
    int n,k;
    cin>>n>>k;
    vector<int>vec(n,k);
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)continue;
            if(vec[i]-a[j]>0)vec[i]-=a[j];
        }
    }
    int c=0;
    for(int i=0;i<n;i++){
        if(vec[i]-a[i]>0){
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}

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

#include<bits/stdc++.h>
#define DEBUG 0
/*
*/

using namespace std;



int main() {
	long long int N, K;
	cin >> N >> K;
	vector < long long int >A(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	vector<unordered_set<long long int>>dp1(N + 1), dp2(N + 1);
	dp1[0].insert(0);
	for (size_t i = 0; i < N; i++)
	{
		dp1[i + 1] = dp1[i];
		for (auto x : dp1[i]) {
			if (x + A[i] < K)
			{
				dp1[i + 1].insert(x + A[i]);
			}
			else {
				break;
			}
		}
	}

	dp2[N].insert(0);
	for (int i = N - 1; i >= 0; i--)
	{
		dp2[i] = dp2[i + 1];
		for (auto x : dp2[i + 1]) {
			if (x + A[i] < K)
			{
				dp2[i].insert(x + A[i]);
			}
			else {
				break;
			}
		}
	}
	long long int ans = 0;
	for (size_t i = 0; i < N; i++)
	{
		auto ite1 = dp1[i].begin();
		auto ite2 = dp2[i + 1].rbegin();
		while (ite1 != dp1[i].end() && ite2 != dp2[i + 1].rend())
		{
			if (*ite1 + *ite2 < K - A[i])
			{
				ite1++;
			}
			else if (K <= *ite1 + *ite2) {
				ite2++;
			}
			else {
				ans++;
				break;
			}
		}
	}
	cout << N - ans << endl;

	if (DEBUG)
	{
		int ewataeoprgjpsrteog;
		cin >> ewataeoprgjpsrteog;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:40: error: '__gnu_cxx::__alloc_traits<std::allocator<std::unordered_set<long long int> >, std::unordered_set<long long int> >::value_type' {aka 'class std::unordered_set<long long int>'} has no member named 'rbegin'; did you mean 'begin'?
   52 |                 auto ite2 = dp2[i + 1].rbegin();
      |                                        ^~~~~~
      |                                        begin
a.cc:53:67: error: '__gnu_cxx::__alloc_traits<std::allocator<std::unordered_set<long long int> >, std::unordered_set<long long int> >::value_type' {aka 'class std::unordered_set<long long int>'} has no member named 'rend'; did you mean 'end'?
   53 |                 while (ite1 != dp1[i].end() && ite2 != dp2[i + 1].rend())
      |                                                                   ^~~~
      |                                                                   end
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define orep(i, n) for (int i = 1; i <= (int)n; i++)
#define vec vector

int main(void)
{
	int n, k;
	cin >> n >> k;
	vec<int> a(n + 1);
	orep(i, n) cin >> a[i];

	int ans = 0;
	orep(t, n) {
		vec<int> cur(k + 5, 0);
		vec<int> prev(k + 5, 0);
		cur[0][0] = 1;
		orep(i, n) {
			prev = cur;
			rep(j, k + 1) {
			cur[j] += prev[j];
			if (i == t) continue;
			if (k < j + a[i]) cur[k] += prev[j];
			else cur[j + a[i]] += prev[j];
			}
		}
		int flag = 1;
		for (int i = k - a[t]; i < k; i++) {
			if (cur[i]) {
				flag = 0;
				break;
			}
		}
		if (flag) ans++;
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:23: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   22 |                 cur[0][0] = 1;
      |                       ^
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[5010];
int dp[5010];
int main()
{
	int n, k;
	while(~scanf("%d%d",&n, &k))
	{
		for(int i=1; i<=n;i++)
		scanf("%d",&a[i]);
		
		sort(a+1, a+1+n);
		
		long long  sum = 0;
		for(int i=1;i<=n;i++)
		{
			sum += a[i];
		}
		if(sum<k)
		{
			printf("%d\n",n);
			continue;
		}
		memset(dp,0,sizeof dp);
		dp[1] = a[1]<k?1:0;
		for(int i=2;i<=n;i++)
		{
			for(int j=1;j<=dp[i-1];i++)
			if(arr[j]+a[i] >= k)
			{
				//dp[i] = j-1;
				break;
			}
			else 
			dp[i]++;
			
			if(dp[i] == i-1)
			{
				int ans = 0;
				for(int j=1;j<=i;j++)
				{
					if(sum-a[j] >= k)
					{
						ans++;
						sum -= a[j];
					}
				}
				dp[i] = ans;
			}
		}
		
		printf("%d\n", dp[n]);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:28: error: 'arr' was not declared in this scope
   32 |                         if(arr[j]+a[i] >= k)
      |                            ^~~
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
#define PAD(a,b) MP(((a).first + (b).first),((a).second, (b).second))

#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //移動
	{ 0, 1 }, { -1, 0 }, { 1, 0 }, { 0, -1 },
	{ 1, 1 }, { 1, -1 }, { -1, 1 }, { -1, -1 }
};

signed main() {
	int n;
	ll m;
	scanf("%d %lld", &n, &m);
	vector<ll> num(n);
	REP(i, n){
		scanf("%lld", &num[i]);
	}
	sort(ALL(num),greater<int>());
	int last = 0;
	int can[5001] = { -1 };
	function<bool(int,ll)> dfs = [&](int cur, int nok){
		bool ret;
		if (nok <= 0)
			return true;
		if (cur == n)
			return false;
		if (can[nok] == 1)
			return true;
		else if(can[nok] == 0)
			return false;

		ret = dfs(cur+1, nok);
		if (dfs(cur + 1, nok - num[cur])){
			ret = 1;
			last = max(last, cur+1);
		}
		return can[nok] = ret;
	};
	dfs(0, m);
	printf("%d\n", n-last);
	return 0;
}

Compiler output:
a.cc: In lambda function:
a.cc:80:33: error: inconsistent types 'bool' and 'int' deduced for lambda return type
   80 |                 return can[nok] = ret;
      |                        ~~~~~~~~~^~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int N = 5009;
const int inf = (int) 2e9;

int a[N];
int b[N];

int main () {
    int n, k; cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i]; b[i] = a[i];
    }
    sort (b, b + n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j == i) {
                a[j] = 0;
            } else {
                a[j] = b[j];
            }
        }
        sort (a, a + n);
        int mn = inf;
        for (int l = 0, r = 0, s = t; l < n; l++) {
            while (s < k && r + 1 < n) {
                s += a[++r];
            }
            mn = min (mn, s);
            s -= a[l];
        }
        if (mn < k || mn - t >= k) {
            ans++;
        }
    }
    cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:36: error: 't' was not declared in this scope
   28 |         for (int l = 0, r = 0, s = t; l < n; l++) {
      |                                    ^
a.cc:35:28: error: 't' was not declared in this scope
   35 |         if (mn < k || mn - t >= k) {
      |                            ^
Language: C++

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

typedef long long int;
signed main(){
	const ll MAX=5001;
	ll N,K;
	cin>>N>>K;
	ll a[MAX]={};
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	bool flag[MAX]={};
	//ソートする
	sort(a,a+N,greater<ll>());
	for(int i=0;i<N;i++){
		//cout<<a[i]<<endl;
	}
	//カードiを除いた集合から、コストK未満K-a[i]以上の組み合わせが作れるかどうかを試していく
	for(int i=0;i<N;i++){
		ll sum=0;
		for(int j=0;j<N;j++){
			if(j!=i){
				ll temp=sum+a[j];
				if(temp<K-a[i]){
					sum=temp;
					//cout<<sum<<endl;
				}
				else if(temp<K){
					flag[i]=1;
					//cout<<"!"<<sum<<endl;
					break;
				}
			}
		}
	}
	ll ans=0;
	for(int i=0;i<N;i++){
		if(!flag[i]){
			//cout<<i<<endl;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc:26:19: error: declaration does not declare anything [-fpermissive]
   26 | typedef long long int;
      |                   ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
 
int n, k;
vector<int> a;
bitset<N> t, t2;

int main() 
{
	cin >> n >> k;
	int ans = n;
	for (int i = 0, x; i < n; i++) 
	{
		cin >> x;
		if (x >= k) ans --;
		else a.pb(x);
	}
 
	n = (int)a.size();
 
	t.set(0);
	for (int i = 0; i < n; i++) 
	{
		if (i) t = (t << a[i - 1]) | t;
		t2 = t;
		for (int j = i + 1; j < n; j++) t2 = (t2 << a[j]) | t2;
		for (int j = k - a[i]; j < k; j++) 
			if (t2.test(j)) 
			{
				--ans;
				break;
			}
	}
 
	cout << ans << endl;
 
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:24: error: 'class std::vector<int>' has no member named 'pb'
   17 |                 else a.pb(x);
      |                        ^~
Language: C++

#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

#define int long long
#define double long double

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e9 + 9;

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;

	if (n > 400 || k > 400)return;

	//ai が 必要 => aiを除いて 総和xが (k - ai) <= x < k を満たす集合が存在する
	// => aiを含めて k <= x < k + aiを満たす集合が存在する

	//ai >= k は絶対必要　<= 取り除いてよい

	vector<int> a;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (t < k) {
			a.push_back(t);
		}
	}

	n = a.size();

	int ans = 0;

	rep(i, n) {

		vector<int> vis(k * 2, 0);

		vector<vector<int>> dp(n, vector<int>(k * 2, -1));

		function<void(int, int)> dfs = [&](int t, int sum) {
			if (t == n) {
				return;
			}
			if (t == i) {
				dfs(t + 1, sum);
				return;
			}

			if (dp[t][sum] != -1)return;
			dp[t][sum] = 1;

			vis[sum] = 1;
			vis[sum + a[t]] = 1;

			dfs(t + 1, sum);
			dfs(t + 1, sum + a[t]);
		};

		dfs(0, a[i]);

		bool need = false;
		for (int j = k; j < k + a[i]; j++) {
			if (vis[j]) need = true;
		}
		if (need == false) ans++;
	}

	cout << ans << endl;


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:32: error: return-statement with no value, in function returning 'int' [-fpermissive]
   64 |         if (n > 400 || k > 400)return;
      |                                ^~~~~~
Language: C++

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

typedef long long LL;

LL t,n,m,ans,tot;
LL f[5111],g[111];

int main()
{
	LL i,j,k,l,ca=0,u,v,w;
	cin>>n>>m;w=m;
	for(i=1;i<=n;i++)
		cin>>f[i],ans+=f[i];
	if(ans<m){
		cout<<n<<endl;
		return 0; 
	}
	sort(f+1,f+n+1);
	for(i=n;i>0;i--)
		if(f[i]>=m)n--;
	for(i=n;i>0&&m>0;i--){
		m-=f[i];
		n--;
	}
	for(tot=0,i=1;i<=n&&tot<w;i++)
		tot+=f[i];
	for(i=1;i<=n&&tot>=w;i++)
		tot-=f[i];
	cout<<max(0,min(n,i-2) )<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:18: error: no matching function for call to 'max(int, const long long int&)'
   30 |         cout<<max(0,min(n,i-2) )<<endl;
      |               ~~~^~~~~~~~~~~~~~~
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:30:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   30 |         cout<<max(0,min(n,i-2) )<<endl;
      |               ~~~^~~~~~~~~~~~~~~
/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:30:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |         cout<<max(0,min(n,i-2) )<<endl;
      |               ~~~^~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <cstdint>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<math.h>

using namespace std;

typedef long long ll;

double abs(double d){
    if(d>=0)return d;
    return -1.0*d;
}

int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a.begin(),a.end());
    if(sum<k){
        cout<<n<<endl;
        return 0;
    }
    sum=0;
    int mai=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
        if(sum>=k){
            mai=i;
            break;
        }
    }
    int i;
    for(i=0;i<n;i++){
        if(sum-a[i]>=k){
            sum-=a[i];
        } else {
            break;
        }
    }
    while(i<n&&a[i]==a[i+1]{
        i++;
    })
    cout<<i<<endl;
    
    
    return 0;
}

Compiler output:
a.cc:14:20: error: 'double abs(double)' conflicts with a previous declaration
   14 | double abs(double d){
      |                    ^
In file included from /usr/include/c++/14/cstdlib:81,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/std_abs.h:71:3: note: previous declaration 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
a.cc: In function 'int main()':
a.cc:50:28: error: expected ')' before '{' token
   50 |     while(i<n&&a[i]==a[i+1]{
      |          ~                 ^
      |                            )
a.cc:52:6: error: expected primary-expression before ')' token
   52 |     })
      |      ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int v[5010];
ll dp[5010];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0; i<n; ++i)
		cin>>v[i];
	int ans=0;
	for(int t=0; t<n; ++t){
		for(int i=0; i<=k; ++i)
			dp[i]=0;
		dp[0]=1;
		for(int i=0; i<n; ++i){
			if(i==t)continue;
			for(int j=k-v[i]; j>=0; --j)
				dp[j+v[i]]+=dp[j];
		}
		bool f=v[i]>=k;
		for(int i=max(k-v[t],0); !f&&i<k; ++i)
			f|=dp[i]!=0;
		if(!f)++ans;
	}
	cout<<ans;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:30:26: error: 'i' was not declared in this scope
   30 |                 bool f=v[i]>=k;
      |                          ^
Language: C++

#include <iostream>

using ll = long long;
int n, k;
int a[5010];
bool stat[5010];

ll dp[5010][5100];

ll dfs(int idx, ll sum) {
    if(sum >= k) {
        return sum;
    }
    if(idx >= n) {
        return 0;
    }
    if(dp[idx][sum] != -1) {
        return dp[idx][sum];
    }

    ll min = 1e18;
    for(int i = idx; i < n; ++i) {
        auto r = dfs(i + 1, sum + a[i]);

        if(r != 0) {
            if(r - a[i] < k) {
//                std::cout << idx << " " << i << " " << sum << " " << r << std::endl;
                stat[i] = true;
            }
            min = std::min(min, r);
        }
    }

    if(min == 1e18) {
        return dp[idx][sum] = 0;
    }
    return dp[idx][sum] = min;
}

int main() {
    memset(dp, -1, sizeof(dp));
    std::cin >> n >> k;

    for(int i = 0; i < n; ++i)
        std::cin >> a[i];

    dfs(0, 0);

    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        if(stat[i])
            ++cnt;
    }

    std::cout << n - cnt << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:5: error: 'memset' was not declared in this scope
   41 |     memset(dp, -1, sizeof(dp));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 |
Language: C++

#include <algorithm>
#include <fstream>
#include <iostream>
using namespace std;

short pref[5005][5005];
short suf[5005][5005];

int main() {
    //ifstream cin("f.iun");
    int n, k;
    cin >> n >> k;
    vector<int> v;
    for (int x, i = 1; i <= n; ++ i) {
        cin >> x;
        if (x < k) {
            v.push_back(x);
        }
    }
    n = v.size();
    for (int i = 0; i < k; ++ i) {
        pref[0][i] = 1;
    }
    for (int i = 1; i <= n; ++ i) {
        int val = v[i - 1];
        for (int j = k - val - 1; j >= 0; -- j) {
            if (pref[i - 1][j] - (j ? pref[i - 1][j - 1] : 0)) {
                pref[i][j + val] = 1;
            }
        }
        for (int j = 0; j < k; ++ j) {
            if (pref[i - 1][j] - (j ? pref[i - 1][j - 1] : 0)) {
                pref[i][j] = 1;
            }
            if (j) {
                pref[i][j] += pref[i][j - 1];
            }
        }
    }
    for (int i = 0; i < k; ++ i) {
        suf[n + 1][i] = 1;
    }
    for (int i = n; i >= 1; -- i) {
        int val = v[i - 1];
        for (int j = k - val - 1; j >= 0; -- j) {
            if (suf[i + 1][j] - (j ? suf[i + 1][j - 1] : 0)) {
                suf[i][j + val] = 1;
            }
        }
        for (int j = 0; j < k; ++ j) {
            if (suf[i + 1][j] - (j ? suf[i + 1][j - 1] : 0)) {
                suf[i][j] = 1;
            }
            if (j) {
                suf[i][j] += suf[i][j - 1];
            }
        }
    }

    int cnt = 0;
    for (int i = 1; i <= n; ++ i) {
        bool ok = false;
        for (int j = 0; j < k; ++ j) {
            if ((j == 0 && pref[i - 1][j]) || (j != 0 && pref[i - 1][j] - pref[i - 1][j - 1])) {
                int min_sum_right = max(k - v[i - 1] - j, 0);
                int max_sum_right = k - 1 - j;
                if ((min_sum_right == 0 && suf[i + 1][max_sum_right]) || (min_sum_right != 0 && suf[i + 1][max_sum_right] - suf[i + 1][min_sum_right - 1])) {
                    ok = true;
                    break;
                }
            }
        }
        if (!ok) {
            ++ cnt;
        }
    }

    cout << cnt << "\n";


    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'vector' was not declared in this scope
   13 |     vector<int> v;
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <iostream>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:13:12: error: expected primary-expression before 'int'
   13 |     vector<int> v;
      |            ^~~
a.cc:17:13: error: 'v' was not declared in this scope
   17 |             v.push_back(x);
      |             ^
a.cc:20:9: error: 'v' was not declared in this scope
   20 |     n = v.size();
      |         ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pii;

int main(){
  lli n, k;
  std::cin >> n >> k;
  vector<pii> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  lli pos = 0;
  for (int i = 0; i < n; i++) {
    lli sum = 0;
    for (int j = i; j < n; j++) {
      sum += a[j].first;
      if(sum >= k){
        pos = max(pos, j + 1);
        break; 
      }
      if(j == n - 1){
        std::cout << n - pos << std::endl;
        return 0;
      }
    }
  }
  std::cout << 0 << std::endl;
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:24:18: error: no matching function for call to 'max(lli&, int)'
   24 |         pos = max(pos, j + 1);
      |               ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:24:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 |         pos = max(pos, j + 1);
      |               ~~~^~~~~~~~~~~~
/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,
                 from a.cc:3:
/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:24:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |         pos = max(pos, j + 1);
      |               ~~~^~~~~~~~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
#include<functional>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<vector>
using namespace std;

int c[405];
bool dp[405];
signed main() {
	int a, b; scanf("%d%d", &a, &b);
	if (a > 400 || b > 400)return 0;
	int ans = 0;
	int sum = 0;//個数
	for (int d = 0; d < a; d++) {
		int e; scanf("%d", &e);
		if(e<b){
			c[sum] = e;
			sum++;
		}
	}
	for (int d = 0; d < sum; d++) {//dが必要か？
		memset(dp, false, sizeof(dp));
		dp[0] = true;
		for (int e = 0; e < sum; e++) {
			if (d == e)continue;
			for (int f = b; f >= c[e]; f--) {
				if (dp[f - c[e]])dp[f] = true;
			}
		}
		bool K = false;
		for (int i = b - c[d]; i < b; i++) {
			if (dp[i])K = true;
		}
		if (!K)ans++;
	}
	printf("%d\n", ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:17: error: 'memset' was not declared in this scope
   28 |                 memset(dp, false, sizeof(dp));
      |                 ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    9 | #include<queue>
  +++ |+#include <cstring>
   10 | #include<vector>
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;


void solve() {
	int n; cin >> n;
	vector<ll> l(n), r(n), len(n);
	rep(i, n)cin >> l[i] >> r[i];
	rep(i, n)len[i] = r[i] - l[i];
	ll ml = l[0], mr = l[0]; ll my = 0;
	multiset<ll> sl, sr;
	ll adle = 0, adri = 0;
	rep1(i, n - 1) {
		ml -= len[i]; mr += len[i - 1];
		if (l[i] <= ml) {
			ll dif = ml - l[i];
			sl.insert(dif-adle);
			my += dif;
			sr.insert(- adri);adri += mr - ml;
			mr = ml;
			ll nl = *sl.begin(); sl.erase(sl.begin());
			nl += adle;
			ml -= nl;
			adle -= nl;
		}
		else if (l[i] => mr) {
			ll dif = l[i] - mr;
			sr.insert(dif - adri);
			my += dif;
			sl.insert(- adle); adle += mr - ml;
			ml = mr;
			ll nr = *sr.begin(); sr.erase(sr.begin());
			nr += adri;
			mr += nr;
			adri -= nr;
		}
		else {
			sl.insert(-adle), sr.insert(-adri);
			adle += l[i] - ml; adri += mr - l[i];
			ml = mr = l[i];
		}
	}
	cout << my << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	stop
	return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:63:32: error: expected primary-expression before '>' token
   63 |                 else if (l[i] => mr) {
      |                                ^
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
priority_queue <ll> P;
priority_queue <ll,vector <ll>,greater <ll> > Q;

int main() {
    int n;
    ll A=0,B=0,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
	cin>>l>>r;
	B+=r-l;
	P.push(r-A),Q.push(r-B);
	while(P.top()+A>Q.top()+B) {
	    ll x=P.top()+A,y=Q.top()+B;
	    P.pop(),Q.pop(),ans+=x-y;
	    P.push(y-A),Q.push(x-B);
	}
	A-=r-l;
    }
    cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:14: error: 'l' was not declared in this scope
   17 |         cin>>l>>r;
      |              ^
a.cc:17:17: error: 'r' was not declared in this scope
   17 |         cin>>l>>r;
      |                 ^