Language: C++

#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
//#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, K; cin >> N >> K;
    vec a(N); readvec(a);

    int U = 70;
    int Nu = N / U + min(1LL, N % U);

    mat a0(Nu, vec(0));

    int sumv = 0;


    REP(i, Nu){
        REP(j, U){
            if(i * U + j < N) a0[i].push_back(a[i * U + j]);
        }
    }

    vector<vector<bool>> dp(Nu, vector<bool>(K, false));
    REP(i, Nu) dp[i][0] = true;
    REP(i, Nu){
        REP(i2, Nu){
            if(i2 == i) continue;
            REP(j, a0[i2].size()){
                vector<bool> dptmp = dp[i];
                REP(k, K - a0[i2][j]){
                    if(dp[i][k]) dptmp[k + a0[i2][j]] = true;
                }
                dp[i] = dptmp;
            }
        }
    }

    int ans = 0;
    vec calced(K, 0);
    REP(i, Nu){
        REP(j, a0[i].size()){
            if(a0[i][j] >= K) continue;
            if(calced[a0[i][j]] == 1){
                ans++;
                continue;
            }else if(calced[a0[i][j]] == 2){
                continue;
            }
            vector<bool> dptmp = dp[i];

            bool noneed = true;

            FOR(k, K - a0[i][j], K){
                if(dptmp[k]){
                    noneed = false;
                    break;
                }
            }
            if(!noneed){
                calced[a0[i][j]] = 2;
                continue;
            }

            REP(j2, a0[i].size()){
                if(j2 == j) continue;
                vector<bool> dptmp2 = dptmp;
                REP(k, K - a0[i][j2]){
                    if(dptmp[k]) dptmp2[k + a0[i][j2]] = true;
                }
                dptmp = dptmp2;
            }

            FOR(k, K - a0[i][j], K){
                if(dptmp[k]){
                    noneed = false;
                    break;
                }
            }
            if(noneed){
                ans++;
                calced[a0[i][j]] = 1;
            }else{
                calced[a0[i][j]] = 2;
            }
        }
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:25: error: no matching function for call to 'min(long long int, int)'
   28 |     int Nu = N / U + min(1LL, N % U);
      |                      ~~~^~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:28:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 |     int Nu = N / U + min(1LL, N % U);
      |                      ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:28:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |     int Nu = N / U + min(1LL, N % U);
      |                      ~~~^~~~~~~~~~~~