Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	const int mod = 1000000007;
	int w[12345];
	int n, limit;
	cin >> n >> limit;
	rep (i, n)
		cin >> w[i];
	sort(w, w + n);

	if (n == 1 || w[0] > limit)
	{
		puts("1");
		return 0;
	}

	static int dp[222][12345];
	static set<int> not_used[12345];

	int res = 0;
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i)
		not_used[0].insert(i);

	for (int i = 0; i < n; ++i)
	{
		for (int j = limit; j >= 0; --j)
		{
			dp[i + 1][j] = dp[i][j];

			if (j - w[i] >= 0 && dp[i][j - w[i]])
			{
				(dp[i + 1][j] += dp[i][j - w[i]]) %= mod;

				int min_w = limit;
				foreach (it, not_used[j - w[i]])
				{
					if (*it != i)
					{
						min_swap(min_w, w[*it]);
						not_used[j].insert(*it);
					}
				}
				if (j + min_w > limit)
					(res += dp[i][j - w[i]]) %= mod;
			}
		}
	}
	printf("%d\n", res);
}#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	const int mod = 1000000007;
	int w[12345];
	int n, limit;
	cin >> n >> limit;
	rep (i, n)
		cin >> w[i];
	sort(w, w + n);

	if (n == 1 || w[0] > limit)
	{
		puts("1");
		return 0;
	}

	static int dp[222][12345];
	static set<int> not_used[12345];

	int res = 0;
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i)
		not_used[0].insert(i);

	for (int i = 0; i < n; ++i)
	{
		for (int j = limit; j >= 0; --j)
		{
			dp[i + 1][j] = dp[i][j];

			if (j - w[i] >= 0 && dp[i][j - w[i]])
			{
				(dp[i + 1][j] += dp[i][j - w[i]]) %= mod;

				int min_w = limit;
				foreach (it, not_used[j - w[i]])
				{
					if (*it != i)
					{
						min_swap(min_w, w[*it]);
						not_used[j].insert(*it);
					}
				}
				if (j + min_w > limit)
					(res += dp[i][j - w[i]]) %= mod;
			}
		}
	}
	printf("%d\n", res);
}

Compiler output:
a.cc:99:2: error: stray '#' in program
   99 | }#include <cstdio>
      |  ^
a.cc:99:3: error: 'include' does not name a type
   99 | }#include <cstdio>
      |   ^~~~~~~
a.cc:137:25: error: redefinition of 'template<class T> void max_swap(T&, const T&)'
  137 | template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
      |                         ^~~~~~~~
a.cc:39:25: note: 'template<class T> void max_swap(T&, const T&)' previously declared here
   39 | template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
      |                         ^~~~~~~~
a.cc:138:25: error: redefinition of 'template<class T> void min_swap(T&, const T&)'
  138 | template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }
      |                         ^~~~~~~~
a.cc:40:25: note: 'template<class T> void min_swap(T&, const T&)' previously declared here
   40 | template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }
      |                         ^~~~~~~~
a.cc:143:14: error: redefinition of 'const double PI'
  143 | const double PI = acos(-1.0);
      |              ^~
a.cc:45:14: note: 'const double PI' previously defined here
   45 | const double PI = acos(-1.0);
      |              ^~
a.cc:144:11: error: redefinition of 'const int dx []'
  144 | const int dx[] = { 0, 1, 0, -1 };
      |           ^~
a.cc:46:11: note: 'const int dx [4]' previously defined here
   46 | const int dx[] = { 0, 1, 0, -1 };
      |           ^~
a.cc:145:11: error: redefinition of 'const int dy []'
  145 | const int dy[] = { 1, 0, -1, 0 };
      |           ^~
a.cc:47:11: note: 'const int dy [4]' previously defined here
   47 | const int dy[] = { 1, 0, -1, 0 };
      |           ^~
a.cc:148:5: error: redefinition of 'int main()'
  148 | int main()
      |     ^~~~
a.cc:50:5: note: 'int main()' previously defined here
   50 | int main()
      |     ^~~~