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

#!/usr/bin/env python3

x = int(input())
S = {0}
i = 0
while x not in S:
    i += 1
    S = S | {s - i for s in S} | {s + i for s in S}
print(i)


Compiler output:
main.c:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/env python3
      |  ^
main.c:3:1: warning: data definition has no type or storage class
    3 | x = int(input())
      | ^
main.c:3:1: error: type defaults to 'int' in declaration of 'x' [-Wimplicit-int]
main.c:3:5: error: expected expression before 'int'
    3 | x = int(input())
      |     ^~~
main.c:5:1: warning: data definition has no type or storage class
    5 | i = 0
      | ^
main.c:5:1: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
main.c:6:1: error: expected ',' or ';' before 'while'
    6 | while x not in S:
      | ^~~~~
main.c:8:32: error: expected identifier or '(' before '|' token
    8 |     S = S | {s - i for s in S} | {s + i for s in S}
      |                                ^
main.c:9:1: error: return type defaults to 'int' [-Wimplicit-int]
    9 | print(i)
      | ^~~~~
main.c: In function 'print':
main.c:9:1: error: type of 'i' defaults to 'int' [-Wimplicit-int]
main.c:10: error: expected '{' at end of input
Language: C++

#include<iostream>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<deque>
using namespace std;
int a[5000];
int bubuwa(int t);//tを省いた中で、部分和がk-a[t]以上k未満になるかどうか
int n, k;
bool dp[5001][5001];
int main() {

	//B


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

	sort(a, a + n);

	int left, right, mid;
	left = -1;
	right = n;
	mid = (left + right) / 2;

	while (right - left > 1) {

		if (bubuwa(mid) == 1) {

			right = mid;

		}
		else {

			left = mid;

		}
		mid = (right + left) / 2;
	
	}

	cout << right << endl;
	return 0;

	//ある値が必要であれば、それ以上もすべて必要である。従って二分探索を
	//用いて、最初に必要となる数を求める。必要かどうかの判定は部分和問題
	//である。その数を省いた数列から部分和を取って、k未満かつその数があ
	//ればk以上となるような値となるかを調べる




	//A

	/*int x;
	cin >> x;
	int i;
	for (i = 0; i <= x; i++) {

		if (((i * (i - 1)) / 2 < x) && (x <= (i * (i + 1)) / 2)) {
			cout << i << endl;
			return 0;
		}

	}
	return 0;
	*/
}

int bubuwa(int t) {

	int i, j;
	memset(dp, 0, sizeof(dp));
	dp[0][0] = true;
	for (i = 0; i < n; i++) {
		//if (i != t) {
			for (j = 0; j <= k; j++) {

				dp[i + 1][j] |= dp[i][j];
				if (j >= a[i] && i != t)dp[i + 1][j] |= dp[i][j - a[i]];

			}
		//}
	}

	for (i = k - a[t]; i < k; i++) {
		if (dp[n][i] == true) {
			return 1;
		}
	}
	return 0;

}

Compiler output:
a.cc: In function 'int bubuwa(int)':
a.cc:79:9: error: 'memset' was not declared in this scope
   79 |         memset(dp, 0, sizeof(dp));
      |         ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include<set>
  +++ |+#include <cstring>
    8 | #include<deque>
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
bool R1[5021][5021];
bool R2[5021][5021];
int main() {
  ll N,K;
  cin >> N >> K;
  ll a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll ans = 0;
  R1[0][0] = true;
  if (a[0] <= K) R1[0][a[0]] = true;
  for (ll i = 1; i < N; i++) {
    for (ll j = 0; j <= K; j++) {
      R1[i][j] = R1[i-1][j];
      if (0 <= j-a[i] && j-a[i] <= K) {
        if (R1[i-1][j-a[i]]) {
          R1[i][j] = true;
        }
      }
    }
  }
  R2[N-1][0] = true;
  if (a[N-1] <= K) R2[N-1][a[N-1]] = true;
  for (ll i = N-2; i >= 0; i--) {
    for (ll j = 0; j <= K; j++) {
      R2[i][j] = R2[i+1][j];
      if (0 <= j-a[i] && j-a[i] <= K) {
        if (R2[i+1][j-a[i]]) {
          R2[i][j] = true;
        }
      }
    }
  }
  // R1[i][j]はi番目までにjぴったりが作れるか R2[i][j]は逆順
  // i = 0,N-1の時は例外処理
  for (ll i = 1; i < N-1; i++) {
    if (a[i] >= K) {
      continue;
    }
    ll Can[K - a[i] + 1];
    for (ll j = 0; j < K - a[i] + 1; j++) {
      Can[j] = 0;
    }
    for (ll j = 0; j < a[i]; j++) {
      if (R1[i-1][j]) {
        Can[0]++;
      }
    }
    for (ll j = 1; j < K - a[i] + 1; j++) {
      Can[j] = Can[j-1];
      if (R1[i-1][j+a[i]-1]) Can[j]++;
      if (R1[i-1][j-1]) Can[j]--;
    }
    bool need = false;
    for (ll j = 0; j < K - a[i] + 1; j++) {
      if (Can[j] != 0 && R2[i+1][K-a[i]-j]) {
        need = true;
      }
    }
    if (!need) {
      ans++;
    }
  }

  if (a[0] < K) {
    bool need = false;
    for (ll i = K-a[0]; i < K; i++) {
      if (R2[1][i]) {
        need = true;
      }
    }
    if (!need) {
      ans++;
    }
  }
  if (a[N-1] < K) {
    bool need = false;
    for (ll i = K-a[N-1]; i < K; i++) {
      if (R1[N-2][i]) {
        need = true;
      }
    }
    if (!need) {
      ans++;
    }
  }
  if (n == 3) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
const int N=1001;
int n,k,sum;
int a[N],dp[N][N];
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++)
        {
            if(x==i)
            {
                for(int j=0;j<=k;j++)
                    dp[i][j]=dp[i-1][j];
                continue;
            }
            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]];   
            }
        }
    }
    /*
    printf("x:%d\n",x);
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=k;j++)   
            printf("%d ",dp[i][j]);
        printf("\n");
    }
    */
    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]);  
        a[i]=min(a[i],k);
    }
    if(n==1)
    {
        if(a[1]>=k)
            printf("0\n");
        else
            printf("1\n");
        return 0;
    }
    sort(a+1,a+n+1);
    int lb=0,ub=n+1;
    while(lb+1<ub)
    {
        int mid=(lb+ub)/2;
        if(check(mid))  
            ub=mid;
        else 
            lb=mid;
    }
    printf("%d\n",lb);sdgdsgdsg
    return 0;
}
gsgsdgsdgsdgdsgdsgdsgsdgsd

Compiler output:
a.cc: In function 'int main()':
a.cc:83:23: error: 'sdgdsgdsg' was not declared in this scope
   83 |     printf("%d\n",lb);sdgdsgdsg
      |                       ^~~~~~~~~
a.cc: At global scope:
a.cc:86:1: error: 'gsgsdgsdgsdgdsgdsgdsgsdgsd' does not name a type
   86 | gsgsdgsdgsdgdsgdsgdsgsdgsd
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int a[5050],b[5050],ans;
bool f[5050]={true};
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin>>n>>k;
	cin>>a[0];
	b[0]=a[0];
	for(int i=1;i<n;i++)
	{
		cin>>a[i];
		b[i]=b[i-1]+a[i];
	}
	for(int i=0;i<n/2;i++)
	{
		for(int j=n;j>n/2;j--)
		{
			if(b[j]-a[i]>=k)
			{
				for(int k=0;k<i-1;k++)
				{
					f[k]=false;
				}
				for(int k=j;k<n;k++)
				{
					f[k]=false;
				}
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		if(f==true)
		{
			ans++;
		}
	}
	cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   37 |                 if(f==true)
      |                    ~^~~~~~
Language: C++

#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
 
ll a[5005], dp[5005] = { 0 };
 
int main() {
	ll N, K;
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		a[i] = min(K, a[i]);
	}
	dp[0] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = K - a[i] - 1; j >= 0; --j) {
          dp[j + a[i]] += dp[j];
          dp[j + a[i]] %= 1e16;
	}
  for (int j = 0; j < K; ++j) assert(dp[j] >= 0);
	ll ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < K - a[i]; ++j) {
          dp[j + a[i]] -= dp[j];
          dp[j + a[i]] = (dp[j + a[i]] + 1e16) % 1e16;
        }
      	//for (int j = 0; j < K; ++j) assert(dp[j] >= 0);
		ll cnt = 0;
		for (int j = K - a[i]; j < K; ++j) {
          cnt += dp[j];
          cnt %= 1e16;
        }
		if (cnt == 0) ++ans;
		for (int j = K - a[i] - 1; j >= 0; --j) {
          dp[j + a[i]] += dp[j];
          dp[j + a[i]] %= 1e16;
        }
	}
	cout << ans << '\n';
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:24: error: invalid operands of types 'll' {aka 'long long int'} and 'double' to binary 'operator%'
   23 |           dp[j + a[i]] %= 1e16;
      |           ~~~~~~~~~~~~~^~~~~~~
a.cc:23:24: note:   in evaluation of 'operator%=(ll {aka long long int}, double)'
a.cc:30:48: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   30 |           dp[j + a[i]] = (dp[j + a[i]] + 1e16) % 1e16;
      |                          ~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~
      |                                        |         |
      |                                        double    double
a.cc:36:15: error: invalid operands of types 'll' {aka 'long long int'} and 'double' to binary 'operator%'
   36 |           cnt %= 1e16;
      |           ~~~~^~~~~~~
a.cc:36:15: note:   in evaluation of 'operator%=(ll {aka long long int}, double)'
a.cc:41:24: error: invalid operands of types 'll' {aka 'long long int'} and 'double' to binary 'operator%'
   41 |           dp[j + a[i]] %= 1e16;
      |           ~~~~~~~~~~~~~^~~~~~~
a.cc:41:24: note:   in evaluation of 'operator%=(ll {aka long long int}, double)'
a.cc:45:2: error: expected '}' at end of input
   45 | }
      |  ^
a.cc:12:12: note: to match this '{'
   12 | int main() {
      |            ^
Language: C++

//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, k, a[N];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	int ans = 0;
	for (int i = 1; i <= n; i++){
		int sm = a[i];
		for (int j = 1; j <= n; j++){
			if (j == i) continue;
			sm += a[j];
			if (sm >= k){
				if (sm - a[i] >= k) cnt++;
				break;
			}
		}
		if (sm < k) 
	}
	cout << cnt;











	return 0;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:36:53: error: 'cnt' was not declared in this scope; did you mean 'int'?
   36 |                                 if (sm - a[i] >= k) cnt++;
      |                                                     ^~~
      |                                                     int
a.cc:41:9: error: expected primary-expression before '}' token
   41 |         }
      |         ^
a.cc:42:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
   42 |         cout << cnt;
      |                 ^~~
      |                 int
Language: C++

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    //コーナーケース
    if(n == 1) {
        cout << (a[i] < k) << endl;
        return 0;
    }
    if(n == 2) {
        int ans = 0;
        if(a[1] >= k) {
            ans++;
        }
        if(a[0] >= k) {
            ans++;
        }
        cout << ans << endl;
        return 0;
    }
    vector<vector<bool>> dpf(n + 2, vector<bool>(5002, false));
    vector<vector<bool>> dpb(n + 2, vector<bool>(5002, false));
    dpf[0][0] = true;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < 5002; j++) {
            dpf[i][j] = dpf[i - 1][j];
            if(j - a[i - 1] >= 0 && dpf[i - 1][j - a[i - 1]]) {
                dpf[i][j] = true;
            }
        }
    }
    dpb[n + 1][0] = true;
    for(int i = n; i >= 1; i--) {
        for(int j = 0; j < 5002; j++) {
            dpb[i][j] = dpb[i + 1][j];
            if(j - a[i - 1] >= 0 && dpb[i + 1][j - a[i - 1]]) {
                dpb[i][j] = true;
            }
        }
    }
    vector<vector<int>> front(n + 2), back(n + 2);
    for(int i = 1; i <= n; i++) {
        for(int k = 0; k < 5002; k++) {
            if(dpf[i][k]) {
                front[i].push_back(k);
            }
            if(dpb[i][k]) {
                back[i].push_back(k);
            }
        }
    }
    int ans = 0;
    // 1番目が必要かどうか
    auto itr = lower_bound(all(back[2]), k - a[0]);
    if(itr != back[2].end() && *itr < k) {
        ans++;
    }
    // n番目が必要かどうか
    itr = lower_bound(all(front[n - 1]), k - a[n - 1]);
    if(itr != front[n - 1].end() && *itr < k) {
        ans++;
    }
    for(int i = 2; i < n; i++) {
        int tmp = 0;
        for(auto x : front[i - 1]) {
            auto itr2 = lower_bound(all(back[i + 1]), k - a[i - 1] - x);
            if(itr2 != back[i + 1].end() && *itr2 < k - x) {
                tmp = 1;
            }
        }
        ans += tmp;
    }
    cout << n - ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:20: error: 'i' was not declared in this scope
   15 |         cout << (a[i] < k) << endl;
      |                    ^
Language: C++

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

using ll = long long;

const int MAXN = 6e3;
const int MAXK = 6e3;
int N, K;
ll A[MAXN];
ll pref[MAXN];
bool canReach[MAXK];

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);
  pref[0] = 0;
  for (int i = 0; i < N; i++) pref[i+1] = pref[i] + A[i];
  int bestReach = 0;
  canReach[0] = 1;
  
  int ans = 0;
  for (int i = N-1; i >= 0; i--) {
    if (bestReach + pref[i+1] < K) {
      ans++;
    }
    for (int v = K-1-A[i]; v >= 0; v--) {
      if (canReach[v]) {
        canReach[A[i]+v] = true;
        bestReach = max(bestReach, A[i]+v);
      }
    }
  }
  cout << ans << '\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:24: error: no matching function for call to 'max(int&, ll)'
   30 |         bestReach = max(bestReach, A[i]+v);
      |                     ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc: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:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   30 |         bestReach = max(bestReach, A[i]+v);
      |                     ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:30:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |         bestReach = max(bestReach, A[i]+v);
      |                     ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N = 5005;
int dp[N][N], n, k, a[N], tmp, x, z[N];
int sol(int i, int cur)
{
	if(!i || a[i-1] < x) return cur;
	int &ret = dp[i][cur];
	if(ret != -1) return ret;
	ret = sol(i-1, cur);
	if(cur + a[i] < k) return max(ret, sol(i-1, cur+a[i]));
	return ret;
}
bool check(int i)
{
	x = a[i];
	if(z[x] != -1) return z[x];
	if(x >= k) return z[x] = 1;
	memset(dp, -1, sizeof dp);
	if(sol(n-1, 0) >= k-x) return z[x] = 1;
	return z[x] = retur0;
}
int main()
{
	memset(z, -1, sizeof z);
	cin >> n >> k;
	for(int i=0; i<n; i++) scanf("%d", &a[i]);
	sort(a, a+n);
	while(a[n-1] >= k) n--;
	int s = 0, e = n-1;
	while(s <= e)
	{
		int mid = (s+e)>>1;
		if(check(mid)) e = mid-1;
		else s = mid+1;
	}
	cout << s << endl;
}

Compiler output:
a.cc: In function 'bool check(int)':
a.cc:23:23: error: 'retur0' was not declared in this scope
   23 |         return z[x] = retur0;
      |                       ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#defne 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;
            break;
        }
    }
    cout<<p<<endl;
return 0;
}


Compiler output:
a.cc:4:2: error: invalid preprocessing directive #defne; did you mean #define?
    4 | #defne N 5050
      |  ^~~~~
      |  define
a.cc:5:7: error: 'N' was not declared in this scope
    5 | int a[N]={0};
      |       ^
a.cc: In function 'int main()':
a.cc:10:14: error: 'a' was not declared in this scope
   10 |         cin>>a[i];
      |              ^
a.cc:12:10: error: 'a' was not declared in this scope
   12 |     sort(a,a+n);//排序，容易知道一定是最小的那几个是不需要的
      |          ^
Language: C++

#include <iostream>
#include <bitset>
#include <algorithm>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 5005;

#define getchar getchar_unlocked

inline int in() {
    int n = 0; short c;
    while ((c = getchar()) >= '0') n = n * 10 + c - '0';
    return n;
}

int a[MAX_N], sm[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n = in(), K = in(), id = 0;
    rep(i,n){
        a[id] = in();
        if(a[id] < K-1) id++;
    }
    n = id;
    sort(a, a+n, greater<int>());
    rrep(i,n){
        sm[i] = sm[i+1] + a[i];
    }
    int ans = 0;
    bitset<MAX_N> dp;
    dp[0] = true;
    rep(i,n){
        if(K+a[i]-sm[i] > 0){
            bool flag = true;
            srep(j,max(0, K-sm[i]),K+a[i]-sm[i]){
                if(dp[j]){
                    flag = false;
                    break;
                }
            }
            ans += flag;
        }
        dp |= (dp << a[i]);
    }
    cout << ans << "\n";
    return 0;
}

Compiler output:
a.cc:32:9: error: 'vector' does not name a type
   32 | typedef vector<int> vi;
      |         ^~~~~~
a.cc:33:9: error: 'vector' does not name a type
   33 | typedef vector<vi> vvi;
      |         ^~~~~~
a.cc:34:9: error: 'vector' does not name a type
   34 | typedef vector<ll> vl;
      |         ^~~~~~
a.cc:35:9: error: 'vector' does not name a type
   35 | typedef vector<vl> vvl;
      |         ^~~~~~
a.cc:36:9: error: 'vector' does not name a type
   36 | typedef vector<double> vd;
      |         ^~~~~~
a.cc:37:9: error: 'vector' does not name a type
   37 | typedef vector<P> vp;
      |         ^~~~~~
a.cc:38:9: error: 'vector' does not name a type
   38 | typedef vector<string> vs;
      |         ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
////////////////////////////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
////////////////////////////////////////////////////////////////////

bool dp[5102][5102] = {};

int main(){
    int N,K; SCD2(N,K);
    vector<int> a;
    
    int ans = N;
    VSCD(a,N);

    if (N>401) break; // for 300

    REP(i,N){
        vector<int> S;
       
        S.PB(0); // 1-indexed
        REP(j,N){
            if (i==j) continue;
            S.PB(a[j]);
        }

        FORq(j,0,K){
            dp[0][j] = false;
        }

        dp[0][0] = true;

        FORq(x,1,N-1){
            FORq(y,0,K){
                if (y-S[x] < 0) dp[x][y] = dp[x-1][y];
                else dp[x][y] = ((dp[x-1][y]) or (dp[x-1][y-S[x]]));
                //printf("dp[%d][%d] = %d\n",x,y,dp[x][y]);
            }
        }

        FORq(k,K-a[i],K-1){
            if (k < 0) continue;
            if (dp[N-1][k]) {
                ans -= 1;
                break;
            }
        }
    }

    PRINTD(ans);


}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:16: error: break statement not within loop or switch
   50 |     if (N>401) break; // for 300
      |                ^~~~~
Language: C++

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

int N, K, arr[5000];

bool isPos[5000];

bool judge(int ex) {
    memset(isPos, false, sizeof isPos);
    isPos[0] = true;
    if(K == 1 && arr[ex])
        return true;
    for(int v = K-1; v >= 0; v--) {
        for(int i = 0; i < N; i++) {
            if(i != ex && v + arr[i] < K && isPos[v]) {
                isPos[v + arr[i]] = true;
                if(v + arr[i] >= K - arr[ex])
                    return true;
            }
        }
    }

    return false;
}

int main () {
    scanf("%d %d", &N, &K);
    for(int n = 0; n < N; n++) {
        scanf("%d", arr + n);
    }
    sort(arr, arr + N);

    int bot = -1, top = N;
    while(bot + 1 < top) {
        int mid = (bot + top) / 2;
//        printf("%d %d %d %d\n", bot, mid, top, judge(mid));
        if(judge(mid)) {
            top = mid;
        }
        else{
            bot = mid;
        }
    }

    printf("%d\n", bot+1);

    return 0;
}

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

#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "unordered_set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<int,int>

typedef long long ll;
using namespace std;

int n, k, a[5000], l, r;
unordered_set<int>st;

int main() {
	cin >> n >> k;
	rep(n)
		cin >> a[i];
	sort(a, a + n);
	l = -1;
	r = n;
	while (l + 1 != r) {
		st.clear();
		st.insert(0);
		rep(n) {
			if (i != (l + r) / 2) {
				auto it = st.end();
				while(it!=st.begin()){
					it--;
					if (*it + a[i] < k)st.insert(*it + a[i]);
				}
			}
		}
/*		for (auto it = st.begin(); it != st.end(); ++it)
			cout << *it << sp;
		cout << endl;*/
		bool b = false;
		for (int i = k - a[(l + r) / 2]; i < k; ++i) {
			if (st.find(i) != st.end()) {
				b = true;
				break;
			}
		}
		if (b)
			r = (l + r) / 2;
		else
			l = (l + r) / 2;
	}
	cout << l + 1 << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:43: error: no 'operator--(int)' declared for postfix '--' [-fpermissive]
   47 |                                         it--;
      |                                         ~~^~
Language: C++

#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "unordered_set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<int,int>

typedef long long ll;
using namespace std;

int n, k, a[5000], l, r;
unordered_set<int>st;

int main() {
	cin >> n >> k;
	rep(n)
		cin >> a[i];
	sort(a, a + n);
	l = -1;
	r = n;
	while (l + 1 != r) {
		st.clear();
		st.insert(0);
		rep(n) {
			if (i != (l + r) / 2) {
				auto it = st.end();
				while(it!=st.begin()){
					--it;
					if (*it + a[i] < k)st.insert(*it + a[i]);
				}
			}
		}
/*		for (auto it = st.begin(); it != st.end(); ++it)
			cout << *it << sp;
		cout << endl;*/
		bool b = false;
		for (int i = k - a[(l + r) / 2]; i < k; ++i) {
			if (st.find(i) != st.end()) {
				b = true;
				break;
			}
		}
		if (b)
			r = (l + r) / 2;
		else
			l = (l + r) / 2;
	}
	cout << l + 1 << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:41: error: no match for 'operator--' (operand type is 'std::__detail::_Node_iterator<int, true, false>')
   47 |                                         --it;
      |                                         ^~~~
Language: C++

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

int n,k;
int a[5010];
int f[5010][5010];

bool check(int x) {
	memset(f,0,sizeof(f));
	f[0][0]=1;
	if (0>=k-a[x]&&0<k) return true;
	for (int i=1;i<=n;i++) {
		int tmp=a[i];
		if (i==x) tmp=0;
		f[i][0]=1;
		for (int j=1;j<k;j++) {
			if (j>=tmp) f[i][j]=f[i-1][j]|f[i-1][j-tmp];
			else f[i][j]=f[i-1][j];
			if (j>=k-a[x]&&j<k&&f[i][j]) {
				return true;
			}
		}
	}
	return false;
}

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


Compiler output:
a.cc: In function 'int main()':
a.cc:38:9: error: 'else' without a previous 'if'
   38 |         else cout<<l<<endl;
      |         ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k;
long a[5050];
int main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int i=n,ans=n;
	while (i>0 && ans >0)
	{
		int s=0,j=i;
		while (s<k && j>0)
		{
			s+=a[j];
			j--;
		}
		if (s>=k &&j==0)
		{
			ans==n;
		}
		if (s>=k && j!=0)
		{
			ans=j+1;
		}
		else
		{
			break;
		}
		i--;
	}
	cout<<n-ans;
	return 0;
}#include<bits/stdc++.h>
using namespace std;
int n,k;
long a[5050];
int main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int i=n,ans=n;
	while (i>0 && ans >0)
	{
		int s=0,j=i;
		while (s<k && j>0)
		{
			s+=a[j];
			j--;
		}
		if (s>=k &&j==0)
		{
			ans==n;
		}
		if (s>=k && j!=0)
		{
			ans=j+1;
		}
		else
		{
			break;
		}
		i--;
	}
	cout<<n-ans;
	return 0;
}

Compiler output:
a.cc:38:2: error: stray '#' in program
   38 | }#include<bits/stdc++.h>
      |  ^
a.cc:38:3: error: 'include' does not name a type
   38 | }#include<bits/stdc++.h>
      |   ^~~~~~~
a.cc:40:5: error: redefinition of 'int n'
   40 | int n,k;
      |     ^
a.cc:3:5: note: 'int n' previously declared here
    3 | int n,k;
      |     ^
a.cc:40:7: error: redefinition of 'int k'
   40 | int n,k;
      |       ^
a.cc:3:7: note: 'int k' previously declared here
    3 | int n,k;
      |       ^
a.cc:41:6: error: redefinition of 'long int a [5050]'
   41 | long a[5050];
      |      ^
a.cc:4:6: note: 'long int a [5050]' previously declared here
    4 | long a[5050];
      |      ^
a.cc:42:5: error: redefinition of 'int main()'
   42 | int main()
      |     ^~~~
a.cc:5:5: note: 'int main()' previously defined here
    5 | int main()
      |     ^~~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int N, K, T, Ans, A[5100];
int main() {
	cin >> N >> K ;
	for(register int i = 1; i <= n; i ++ ) cin >> A[i];
	sort(A+1, A+N+1);
	for(register int i = N; i >= 1; i -- )
		if(T+A[i] >= K) Ans = 0;
		else ans++, T += a[i];
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    7 |         for(register int i = 1; i <= n; i ++ ) cin >> A[i];
      |                          ^
a.cc:7:38: error: 'n' was not declared in this scope
    7 |         for(register int i = 1; i <= n; i ++ ) cin >> A[i];
      |                                      ^
a.cc:9:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 |         for(register int i = N; i >= 1; i -- )
      |                          ^
a.cc:11:22: error: 'ans' was not declared in this scope; did you mean 'Ans'?
   11 |                 else ans++, T += a[i];
      |                      ^~~
      |                      Ans
a.cc:11:34: error: 'a' was not declared in this scope
   11 |                 else ans++, T += a[i];
      |                                  ^
a.cc:12:17: error: 'ans' was not declared in this scope; did you mean 'Ans'?
   12 |         cout << ans << endl;
      |                 ^~~
      |                 Ans
Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted 
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan 

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;                                          
const int PRI = 555557;
const int pri = 997;

int tests = 1;

int n, k, ans;
int a[5005];
ll dp[5005][5005][2];
ll pre[5005];

inline void Solve () {
	//easy
	cin >> n >> k;
	dp[0][0][0] = dp[0][0][1] = 0; 
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		for (int j = 0; j <= k; j ++) {
			dp[i][j][0] = dp[i][j][1] = INF;
		}
		for (int j = k - 1; j >= 0; j --) {
			int nxt = j + a[i];
			nxt = min(nxt, k);
			if (dp[i][nxt][0] > dp[i][j][0] + a[i]) {
				dp[i][nxt][0] = dp[i][j][0] + a[i];
			}
		}
	}

	reverse(a + 1, a + n + 1);

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

	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= k; j ++)
			pre[j] = 0;
		for (int j = 0; j <= k; j ++) {
			if (dp[i - 1][j][0] < INF) 
				pre[j] = 1;
			pre[j] += pre[j - 1];
		}
		bool is = 0;
		for (int j = 0; j <= k; j ++) {
			if (dp[i + 1][j][1] < INF && pre[k] - pre[k - j])
		}
		ans += is;
	}


	cout << ans;
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted; 
}

Compiler output:
a.cc: In function 'void Solve()':
a.cc:112:17: error: expected primary-expression before '}' token
  112 |                 }
      |                 ^
Language: C++

#include<iostream>
#include<vector>
#include<alogorithm>

using namespace std;

int main() {
    int N, K, ans=0;
    bool tmp;
    cin >> N >> K;
    vector<int> vect(K, 0),old_vect(K,0);
    vector<int> avect(N);
    old_vect[0]++;
    for(int i=0 ; i<N ; i++){
        cin >> avect[i];
        for(int j=0 ; j < K ; j++){
            if( j-avect[i] < 0){
                vect[j] = old_vect[j];
            }else{
                vect[j] = (old_vect[j] + old_vect[j-avect[i]]);
            }
        }
        swap(vect, old_vect);
    }

    swap(vect, old_vect);

    for(int i=0; i<N ; i++){
        tmp = false;
        if(avect[i] >= K) tmp = true;
        for(int j=max(0,K-avect[i]); j< K;  j++){
            tmp = tmp || (((j-avect[i]) >= 0) && ((vect[j] - vect[j-avect[i]]) > 0));
        }
        if(!tmp) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


//#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define endl '\n' 
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 5000 + 10 ;

int n , a [ N ] , k ; 
bool dp [ N ] ;

bool chk ( int mid ) {
	memset ( dp , 0 , sizeof dp ) ;
	dp [ 0 ] = 1 ;
	for ( int i = 1 ; i <= mid ; i++ ) {
		for ( int j = N - 1 ; j >= a [ i ] ; j-- ) {
			dp [ j ] |= dp [ j - a [ i ] ] ; 
		}
	}
	bool isFound = 0 ;
	for ( int i = max ( 0 , k - a [ mid ) ; i < k ; i++ )
		isFound |= dp [ i ] ;
	return !isFound ; 
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k ; 
	for ( int i = 1 ; i <= n ; i++ )
		cin >> a [ i ] ;
	sort ( a + 1 , a + n + 1 ) ; 
	int lo = -1 , hi = n + 1 ;
	while ( hi - lo > 1 ) {
		int mid = ( hi + lo ) >> 1 ; 
		( chk ( mid ) ? lo : hi ) = mid ; 
	}
	cout << lo << '\n' ; 
}


Compiler output:
a.cc: In function 'bool chk(int)':
a.cc:31:44: error: expected ']' before ')' token
   31 |         for ( int i = max ( 0 , k - a [ mid ) ; i < k ; i++ )
      |                                            ^~
      |                                            ]
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k,s,ss;
int a[5010];
int ans;
int f[5010];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(x>=k)continue;
		a[++s]=x;
		ss+=x;
	}
	if(ss<=k)
	{
		printf("0");return 0;
	}
	sort(a+1,a+s+1);
	for(int i=1;i<=s;i++)
	{
		if(ss-a[i]<k)continue;
		memset(f,false,sizeof(f));
		int mx;
		if(i!=s)mx=a[s];else mx=a[s-1];
		if(mx>=k-a[i])continue;
		bool ff=false;
		for(int j=1;j<=s;j++)
		{
			if(i==j)continue;
			if(f[a[j]])f[a[j]]=2;else f[a[j]]=1;
		}
		for(int j=1;j<k;j++)
		{
			for(int l=1;l<=j/2;l++)
			{
				if(l==j-l && f[l]!=2)continue;
				if(f[l] && f[j-l])
				{
					if(f[j])f[j]=2;else f[j]=1;
					if(j>=k-a[i])ff=true; 
					break;
				}
			}
			if(ff)break;
		}
		if(!ff)ans++;
	}
	printf("%d",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:17: error: 'memset' was not declared in this scope
   28 |                 memset(f,false,sizeof(f));
      |                 ^~~~~~
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<bits/stdc++.h>
using namespace std;

long long N, K;
long long a[5005];
bool ldp[5005][5005];
bool rdp[5005][5005];


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

	//ldp[i] <-- i 未満
	for(long long i = 0; i < N; i++){
		for(long long j = 0; j < K; j++){
			if(j == 0 || ldp[i][j]){
				ldp[i][j] = true;
				if(j + a[i] < K){
					ldp[i+1][j+a[i]] = true;
				}
			}
		}
	}

	//for(int i = 0; i < N; i++){
	//	for(int j = 0; j < K; j++){
	//		cout << "ldp[" << i << "][" << j << "]=" << ldp[i][j] << endl;
	//	}
	//}

	//rdp[i] <-- i 以上
	for(long long i = N-1; i >= 0; i--){
		for(long long j = 0; j < K; j++){
			if(j == 0 || rdp[i+1][j]){
				rdp[i][j] = true;
				if(j + a[i] < K){
					rdp[i][j+a[i]] = true;
				}
			}
		}
	}

	//cout << endl;
	//for(int i = 0; i < N; i++){
	//	for(int j = 0; j < K; j++){
	//		cout << "rdp[" << i << "][" << j << "]=" << rdp[i][j] << endl;
	//	}
	//}

	long long ans = 0;
	for(long long i = 0; i < N; i++){
		//can I create [K-a[i], K)
		bool ok = false;
		for(long long create = K - a[i]; create < K && ok == false; create++){
			for(long long left = 0; left <= create && ok == false; left++){
				long long right = create - left;
				if((left == 0 || ldp[i][left]) && (right == 0 || rdp[i+1][right])){
					ans++;
					ok = true;
				}
			}
		}
	}
	cout << ans << endl;;
}



Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:11:9: error: 'cin' was not declared in this scope
   11 |         cin >> N >> K;
      |         ^~~
a.cc:67:9: error: 'cout' was not declared in this scope
   67 |         cout << ans << endl;;
      |         ^~~~
a.cc:67:24: error: 'endl' was not declared in this scope
   67 |         cout << ans << endl;;
      |                        ^~~~
Language: C++

int N, K;

int A[5010];
bool dp[5010][5010];

void solve() {
	cin >> N >> K;
	rep(i, 1, N + 1) cin >> A[i];
	sort(A, A + N + 1);
	dp[N][min(K, A[N])] = true;
	dp[N][0] = true;
	for(int i = N - 1; i >= 1; i--) {
		int a = -1;
		for(int j = K; j >= 0; j--) {
			if(j - A[i] >= 0) dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - A[i]]);
			else dp[i][j] = dp[i + 1][j];
			if(a == -1 && dp[i + 1][j]) a = j;
		}
		if(K - a <= A[N]) dp[i][K] = true;
		//debug(i, vec(dp[i], dp[i] + K + 1));
		if(!dp[i][K] || A[N - 1] == A[N]) continue;
		bool ok = false;
		for(int j = K - 1; j >= K - A[i - 1]; j--) {
			if(dp[i][j]) {
				ok = true;
				break;
			}
		}
		if(!ok) {
			cout << i - 1 << "\n";
			return;
		}

	}
	if(dp[1][K]) {
		cout << "0\n";
	}
	else cout << N << "\n";
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:7:9: error: 'cin' was not declared in this scope
    7 |         cin >> N >> K;
      |         ^~~
a.cc:8:13: error: 'i' was not declared in this scope
    8 |         rep(i, 1, N + 1) cin >> A[i];
      |             ^
a.cc:8:9: error: 'rep' was not declared in this scope
    8 |         rep(i, 1, N + 1) cin >> A[i];
      |         ^~~
a.cc:9:9: error: 'sort' was not declared in this scope; did you mean 'short'?
    9 |         sort(A, A + N + 1);
      |         ^~~~
      |         short
a.cc:10:15: error: 'min' was not declared in this scope
   10 |         dp[N][min(K, A[N])] = true;
      |               ^~~
a.cc:15:54: error: 'max' was not declared in this scope
   15 |                         if(j - A[i] >= 0) dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - A[i]]);
      |                                                      ^~~
a.cc:30:25: error: 'cout' was not declared in this scope
   30 |                         cout << i - 1 << "\n";
      |                         ^~~~
a.cc:36:17: error: 'cout' was not declared in this scope
   36 |                 cout << "0\n";
      |                 ^~~~
a.cc:38:14: error: 'cout' was not declared in this scope
   38 |         else cout << N << "\n";
      |              ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <algorithm>


using namespace std;
int a[5020];
int n,k;
bool d[5020];
bool test(int idx){
    
    if(a[idx]>=k) return true;
    
    memset(d,false,sizeof(d));
    d[0]=true;
    for(int i=0;i<n;i++){
        
        if(i==idx) continue;
        
        for(int j = k-1;j>=0;j--){
            if(!d[j])continue;
            if(j+a[i]<=k) d[j+a[i]]=true;
        }
    }
    
    for(int i=k-a[idx];i<k;i++){
        if(d[i]) return true;
    }
    return false;
}

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


Compiler output:
a.cc: In function 'bool test(int)':
a.cc:16:5: error: 'memset' was not declared in this scope
   16 |     memset(d,false,sizeof(d));
      |     ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <algorithm>
  +++ |+#include <cstring>
    6 |
Language: C++

# coding: utf-8

n, k = map(int, raw_input().split())
a = list(map(int, raw_input().split()))
a.sort()

left = 0
right = n - 1

while left != right:
    mid = (left + right + 1) / 2
    dp = [[0 for j in range(k + 1)] for i in range(n + 1)]
    dp[0][0] = 1
    for i in range(n):
        for j in range(k + 1):
            keep = dp[i][j]
            if j - a[i] >= 0:
                if i != mid:
                    if dp[i][j - a[i]] == 1:
                        keep = 1
            dp[i + 1][j] = keep

    flag = 0
    for i in range(k - a[mid], k):
        if dp[n][i] == 1:
            flag = 1
            break
    if flag == 1:
        right = mid - 1
    else:
        left = mid
    
print(left + 1)



Compiler output:
a.cc:1:3: error: invalid preprocessing directive #coding
    1 | # coding: utf-8
      |   ^~~~~~
a.cc:3:1: error: 'n' does not name a type
    3 | n, k = map(int, raw_input().split())
      | ^
Language: C++

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

int N,K;
long long a[5000];
int dp[5000][5000];

int rec(int x, int y);
bool need(int i);


int main(){
    int ans;
    int left,right;

    scanf("%d %d", &N,&K);
    for(int i=0;i<N;i++){
        scanf("%lld",&a[i]);
    }

    sort(a,a+N);

    if(need(0)==true){
        ans = 0;
    }else if(need(N-1)==false){
        ans = N;
    }else{
        left = 0;
        right = N-1;

        while(left<right-1){
            int m = (right - left) / 2 + left;
            if(need(m)){
                right = m;
            }else{
                left = m;
            }
        }

        ans = right;
    }
        printf("%d\n",ans);

        return 0;
}


int rec(int x,int y){
    if(dp[x][y]>=0){
        return dp[x][y];
    }
    if(x==0){
        if(a[0]==y) return 1;
        else return 0;
    } else {
        int res = 0;
        if(rec(x-1,y)==1){
            res = 1;
        }
        if(y>=a[x]){
            if(rec(x-1,y-a[x])==1){
                res = 1;
            }
        }
        dp[x][y] = res;
        return res;
    }
}


bool need(int i){
    int temp = a[i];
    a[i] = 0;
    memset(dp,-1,sizeof(dp));
    bool found = false;

    for(int j=max(0,K-temp);j<K;j++){
        if(rec(N-1,j)==1){
            found = true;
            break;
        }
    }
    a[i] = temp;
    return found;
}


Compiler output:
a.cc: In function 'bool need(int)':
a.cc:76:5: error: 'memset' was not declared in this scope
   76 |     memset(dp,-1,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 <cstdio>
#include <algorithm>
using namespace std;

int N,K;
long long a[5000];
int dp[5000][5000];

int rec(int x, int y);
bool need(int i);


int main(){
    int ans;
    int left,right;

    scanf("%d %d", &N,&K);
    for(int i=0;i<N;i++){
        scanf("%lld",&a[i]);
    }

    sort(a,a+N);

    if(need(0)==true){
        ans = 0;
    }else if(need(N-1)==false){
        ans = N;
    }else{
        left = 0;
        right = N-1;

        while(left<right-1){
            int m = (right - left) / 2 + left;
            if(need(m)){
                right = m;
            }else{
                left = m;
            }
        }

        ans = right;
    }
        printf("%d\n",ans);

        return 0;
}


int rec(int x,int y){
    if(dp[x][y]>=0){
        return dp[x][y];
    }
    if(x==0){
        if(a[0]==y) return 1;
        else return 0;
    } else {
        int res = 0;
        if(rec(x-1,y)==1){
            res = 1;
        }
        if(y>=a[x]){
            if(rec(x-1,y-a[x])==1){
                res = 1;
            }
        }
        dp[x][y] = res;
        return res;
    }
}


bool need(int i){
    int temp = a[i];
    a[i] = 0;
    memset(dp,-1,sizeof(dp));
    bool found = false;

    for(int j=max(0,K-temp);j<K;j++){
        if(rec(N-1,j)==1){
            found = true;
            break;
        }
    }
    a[i] = temp;
    return found;
}


Compiler output:
a.cc: In function 'bool need(int)':
a.cc:75:5: error: 'memset' was not declared in this scope
   75 |     memset(dp,-1,sizeof(dp));
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;