### 正解

```/*
不同总和不超过 10^5
不同的不超过 450 个
*/
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
#define N 100005

using namespace std;

int n, m, tot;
int a[N], b[N];
bool vis[N];

bitset<N> f, g[450];

int x = 0; char ch = getchar();
while(!isdigit(ch)) ch = getchar();
while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return x;
}

int main() {
for(int i = 1; i <= n; ++i)

sort(a + 1, a + n + 1);
for(int i = 1, j; i <= n; i = j) {
j = i;
while(j <= n && a[j] == a[i])
++j;
b[++tot] = j - i, a[tot] = a[i];
}

g[tot + 1][0] = 1;
for(int i = tot; i >= 1; --i) {
g[i] = g[i + 1];
//for(int j = 1; j <= b[i] && j * a[i] <= m; ++j)
//    g[i] = g[i] | g[i] << a[i];
int temp = b[i], d = 1;
while(true) {
if(d * a[i] > m) break;
g[i] = g[i] | g[i] << (d * a[i]);
temp -= d, d <<= 1;
if(temp <= d) {
if(temp * a[i] > m) break;
g[i] = g[i] | g[i] << (temp * a[i]);
break;
}
}
}

f[0] = 1;
for(int i = 1; i <= tot; ++i) {
vis[i] = true;
for(int j = 0; j <= m; ++j)
if(f[j] && g[i + 1][m - j]) {
vis[i] = false;
break;
}
//for(int j = 1; j <= b[i] && j * a[i] <= m; ++j)
//    f = f | f << a[i];
int temp = b[i], d = 1;
while(true) {
if(d * a[i] > m) break;
f = f | f << (d * a[i]);
temp -= d, d <<= 1;
if(temp <= d) {
if(temp * a[i] > m) break;
f = f | f << (temp * a[i]);
break;
}
}
}

int ans = 0;
for(int i = 1; i <= tot; ++i)
if(vis[i])
++ans;

printf("%d\n", ans);
for(int i = 1; i <= tot; ++i)
if(vis[i])
printf("%d ", a[i]);
putchar('\n');
return 0;
}```