Problem:
E: +- Switch
問題
スイッチが $N$ 個あり、$i$ 番目のスイッチには非負整数 $A_i$ が書かれています。
各スイッチは、
+
と
-
の 2 つの状態のうち、ちょうど 1 つをとります。
あなたは、$N$ 個のスイッチすべてを、
+
か
-
のどちらかの状態にします。
このあと、以下のように計算して得られた値が、モニターに表示されます。
$v = 0$ で初期化する
各 $i$ ($1 \leq i \leq N$) に対して、$i$ 番目のスイッチが
+
の状態をとるとき $v$ に $A_i$ を加算し、
-
の状態をとるとき $v$ に $-A_i$ を加算する
$v$ がモニターに表示される
異なるスイッチの押し方で、モニターに表示される整数が同じ値になる押し方が存在するかを判定してください。
入力形式
$N$
$A_1$ $A_2$ $\ldots$ $A_N$
制約
$1 \leq N \leq 100{,}000$
$0 \leq A_i \leq 500{,}000$
出力形式
異なるスイッチの押し方で、モニターに表示される整数が同じ値になる押し方が存在する場合、
Yes
を一行に出力してください。
存在しない場合、
No
を一行に出力してください。
入力例 1
3
1 2 3
出力例 1
Yes
$1$ 番目のスイッチと $2$ 番目のスイッチを
+
に、$3$ 番目のスイッチを
-
にすると、$1 + 2 - 3 = 0$ が得られます。
また、$1$ 番目のスイッチと $2$ 番目のスイッチを
-
に、$3$ 番目のスイッチを
+
にすると、$-1 - 2 + 3 = 0$ が得られます。
異なるスイッチの押し方であり、同じ値が得られる押し方が存在するので、
Yes
を出力してください。
入力例 2
4
3 4 5 10
出力例 2
No

Submitted solutions:

code_snippet: #ifndef HIDDEN_IN_VS // 折りたたみ用

// 警告の抑制
#define _CRT_SECURE_NO_WARNINGS

// ライブラリの読み込み
#include <bits/stdc++.h>
using namespace std;

// 型名の短縮
using ll = long long; using ull = unsigned long long; // -2^63 ～ 2^63 = 9e18（int は -2^31 ～ 2^31 = 2e9）
using pii = pair<int, int>;	using pll = pair<ll, ll>;	using pil = pair<int, ll>;	using pli = pair<ll, int>;
using vi = vector<int>;		using vvi = vector<vi>;		using vvvi = vector<vvi>;	using vvvvi = vector<vvvi>;
using vl = vector<ll>;		using vvl = vector<vl>;		using vvvl = vector<vvl>;	using vvvvl = vector<vvvl>;
using vb = vector<bool>;	using vvb = vector<vb>;		using vvvb = vector<vvb>;
using vc = vector<char>;	using vvc = vector<vc>;		using vvvc = vector<vvc>;
using vd = vector<double>;	using vvd = vector<vd>;		using vvvd = vector<vvd>;
template <class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
using Graph = vvi;

// 定数の定義
const double PI = acos(-1);
int DX[4] = { 1, 0, -1, 0 }; // 4 近傍（下，右，上，左）
int DY[4] = { 0, 1, 0, -1 };
int INF = 1001001001; ll INFL = 4004004003094073385LL; // (int)INFL = INF, (int)(-INFL) = -INF;

// 入出力高速化
struct fast_io { fast_io() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } } fastIOtmp;

// 汎用マクロの定義
#define all(a) (a).begin(), (a).end()
#define sz(x) ((int)(x).size())
#define lbpos(a, x) (int)distance((a).begin(), std::lower_bound(all(a), (x)))
#define ubpos(a, x) (int)distance((a).begin(), std::upper_bound(all(a), (x)))
#define Yes(b) {cout << ((b) ? "Yes\n" : "No\n");}
#define rep(i, n) for(int i = 0, i##_len = int(n); i < i##_len; ++i) // 0 から n-1 まで昇順
#define repi(i, s, t) for(int i = int(s), i##_end = int(t); i <= i##_end; ++i) // s から t まで昇順
#define repir(i, s, t) for(int i = int(s), i##_end = int(t); i >= i##_end; --i) // s から t まで降順
#define repe(v, a) for(const auto& v : (a)) // a の全要素（変更不可能）
#define repea(v, a) for(auto& v : (a)) // a の全要素（変更可能）
#define repb(set, d) for(int set = 0, set##_ub = 1 << int(d); set < set##_ub; ++set) // d ビット全探索（昇順）
#define repis(i, set) for(int i = lsb(set), bset##i = set; i < 32; bset##i -= 1 << i, i = lsb(bset##i)) // set の全要素（昇順）
#define repp(a) sort(all(a)); for(bool a##_perm = true; a##_perm; a##_perm = next_permutation(all(a))) // a の順列全て（昇順）
#define uniq(a) {sort(all(a)); (a).erase(unique(all(a)), (a).end());} // 重複除去
#define EXIT(a) {cout << (a) << endl; exit(0);} // 強制終了
#define inQ(x, y, u, l, d, r) ((u) <= (x) && (l) <= (y) && (x) < (d) && (y) < (r)) // 半開矩形内判定

// 汎用関数の定義
template <class T> inline ll powi(T n, int k) { ll v = 1; rep(i, k) v *= n; return v; }
template <class T> inline bool chmax(T& M, const T& x) { if (M < x) { M = x; return true; } return false; } // 最大値を更新（更新されたら true を返す）
template <class T> inline bool chmin(T& m, const T& x) { if (m > x) { m = x; return true; } return false; } // 最小値を更新（更新されたら true を返す）
template <class T> inline T getb(T set, int i) { return (set >> i) & T(1); }
template <class T> inline T smod(T n, T m) { n %= m; if (n < 0) n += m; return n; } // 非負mod

// 演算子オーバーロード
template <class T, class U> inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template <class T> inline istream& operator>>(istream& is, vector<T>& v) { repea(x, v) is >> x; return is; }
template <class T> inline vector<T>& operator--(vector<T>& v) { repea(x, v) --x; return v; }
template <class T> inline vector<T>& operator++(vector<T>& v) { repea(x, v) ++x; return v; }

#endif // 折りたたみ用


//#if __has_include(<atcoder/all>)
//#include <atcoder/all>
//using namespace atcoder;
//
//#ifdef _MSC_VER
//#include "localACL.hpp"
//#endif
//
//using mint = modint998244353;
////using mint = static_modint<1000000007>;
////using mint = modint; // mint::set_mod(m);
//
//namespace atcoder {
//	inline istream& operator>>(istream& is, mint& x) { ll x_; is >> x_; x = x_; return is; }
//	inline ostream& operator<<(ostream& os, const mint& x) { os << x.val(); return os; }
//}
//using vm = vector<mint>; using vvm = vector<vm>; using vvvm = vector<vvm>; using vvvvm = vector<vvvm>; using pim = pair<int, mint>;
//#endif


#ifdef _MSC_VER // 手元環境（Visual Studio）
#include "local.hpp"
#else // 提出用（gcc）
inline int popcount(int n) { return __builtin_popcount(n); }
inline int popcount(ll n) { return __builtin_popcountll(n); }
inline int lsb(int n) { return n != 0 ? __builtin_ctz(n) : 32; }
inline int lsb(ll n) { return n != 0 ? __builtin_ctzll(n) : 64; }
inline int msb(int n) { return n != 0 ? (31 - __builtin_clz(n)) : -1; }
inline int msb(ll n) { return n != 0 ? (63 - __builtin_clzll(n)) : -1; }
#define dump(...)
#define dumpel(...)
#define dump_math(v)
#define input_from_file(f)
#define output_to_file(f)
#define Assert(b) { if (!(b)) { vc MLE(1<<30); EXIT(MLE.back()); } } // RE の代わりに MLE を出す
#endif


int main() {
//	input_from_file("input.txt");
//	output_to_file("output.txt");

	int n;
	cin >> n;

	vi a(n);
	cin >> a;

	if (n >= 21) EXIT("Yes");

	unordered_set<int> as;

	repb(set, n) {
		int s = 0;

		rep(i, n) s += (getb(set, i) ? 1 : -1) * a[i];

		if (as.count(s)) EXIT("Yes");
		as.insert(s);
	}

	EXIT("No");
}
accuracy: 1
time_ms: 110
memory_kb: 52520
final_rank: 3

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using namespace std::chrono;
struct Timer {
    Timer() {}
    int64_t operator() () {
        return duration_cast<milliseconds>(
            high_resolution_clock::now()
            .time_since_epoch())
        .count();
    }
} timer;

int64_t start;

inline int64_t f() {
    return timer() - start;
}

void rand1(){
    int N; cin >> N;
    random_device rnd;
    mt19937 mt(rnd());

    vector<ll> A(N);
    for (auto& a : A) cin >> a;
    
    bool ok = false;
    start = timer();
    while (1900 >= f() and ok == false) {
        ll a = 0LL, b = 0LL;
        bool same = true;
        for (int i = 0 ; i < N ; i++) {
            int sela = mt() % 2;
            int selb = mt() % 2;
            same &= (sela == selb);
            if (sela) a += A[i];
            if (selb) b += A[i];
        }
        ok |= (a == b and same == false);
    }
    cout << (ok ? "Yes" : "No") << endl;
}

void solve1(int N, vector<ll> A) {
    cout << "Yes" << '\n';
    return;
    /*
    vector<bool> used(1000001);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N: j++) {
            int v = A[i] + A[j];
            if (used[v]) {
                cout << "Yes" << endl;
                return;
            }
            used[v] = true;
        }
    }
    */
}

constexpr int sz = 100000000;

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    for (auto& a : A) cin >> a;
    if (N >= 24) {
        cout << "Yes" << endl;
        return 0;
    }
    else {
        ll sum = accumulate(A.begin(), A.end(), 0LL);
        vector<bool> used(sum + 1, false);
        for (int bit = 1 ; bit < (1 << N) ; bit++) {
            ll s = 0LL;
            for (int i = 0 ; i < N ; i++) {
                if (bit & (1 << i)) {
                    s += A[i];
                }
            }
            if (used[s]){
                cout << "Yes" << endl;
                return 0;
            }
            used[s] = true; 
        }
        cout << "No" << endl;
    }
}
accuracy: 1
time_ms: 30
memory_kb: 4440
final_rank: 1

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;

using namespace std::chrono;
struct Timer {
    Timer() {}
    int64_t operator() () {
        return duration_cast<milliseconds>(
            high_resolution_clock::now()
            .time_since_epoch())
        .count();
    }
} timer;

int64_t start;

inline int64_t f() {
    return timer() - start;
}

int main(){
    int N; cin >> N;
    random_device rnd;
    mt19937 mt(rnd());

    vector<ll> A(N);
    for (auto& a : A) cin >> a;
    
    bool ok = false;
    start = timer();
    while (1900 >= f() and ok == false) {
        ll a = 0LL, b = 0LL;
        bool same = true;
        for (int i = 0 ; i < N ; i++) {
            int sela = mt() % 2;
            int selb = mt() % 2;
            same &= (sela == selb);
            if (sela) a += A[i];
            if (selb) b += A[i];
        }
        ok |= (a == b and same == false);
    }
    cout << (ok ? "Yes" : "No") << endl;
}
accuracy: 0.06382978723404255
time_ms: 1900
memory_kb: 3380
final_rank: 19

code_snippet: #include<bits/stdc++.h>

using namespace std;

using ll = long long;

vector<ll> enumerate(vector<ll> as){
  vector<ll> res;
  for(int i=0;i<(1<<as.size());++i){
    ll sum = 0;
    for(int j=0;j<as.size();++j){
      if((1<<j)&i){
        sum += as[j];
      }else{
        sum -= as[j];
      }
    }
    res.push_back(sum);
  }
  return res;
}

bool func(){
  int n;
  cin >> n;
  vector<ll> as(n);
  if(n >= 40)return true;
  for(auto &i:as)cin >> i;
  set<ll> left;
  set<ll> right;
  {
    vector<ll> xs(as.begin(),as.begin()+min<int>(as.size(),20));
    vector<ll> ys=enumerate(xs);
    for(auto i:ys)left.insert(i);
    if(left.size() != ys.size())return true;
  }
  {
    vector<ll> xs(as.begin()+min<int>(as.size(),20), as.begin()+min<int>(as.size(),40));
    vector<ll> ys=enumerate(xs);
    for(auto i:ys)right.insert(i);
    if(right.size() != ys.size())return true;
  }
  set<ll> used;
  for(auto i:left){
    for(auto j:right){
      ll v = i + j;
      if(used.count(v))return true;
      used.insert(v);
    }
  }
  return false;
}


int main(){
  cout << (func() ? "Yes" : "No") << endl;
}
accuracy: 1
time_ms: 650
memory_kb: 101676
final_rank: 14

code_snippet: #include<bits/stdc++.h>

using namespace std;

using ll = long long;

vector<ll> enumerate(vector<ll> as){
  vector<ll> res;
  for(int i=1;i<(1<<as.size());++i){
    ll sum = 0;
    for(int j=0;j<as.size();++j){
      if((1<<j)&i){
        sum += as[j];
      }else{
        sum -= as[j];
      }
    }
    res.push_back(sum);
  }
  return res;
}

bool func(){
  int n;
  cin >> n;
  vector<ll> as(n);
  if(n >= 40)return true;
  for(auto &i:as)cin >> i;
  set<ll> left;
  set<ll> right;
  {
    vector<ll> xs(as.begin(),as.begin()+min<int>(as.size(),20));
    vector<ll> ys=enumerate(xs);
    for(auto i:ys)left.insert(i);
    if(left.size() != ys.size())return true;
  }
  {
    vector<ll> xs(as.begin()+min<int>(as.size(),20), as.begin()+min<int>(as.size(),40));
    vector<ll> ys=enumerate(xs);
    for(auto i:ys)right.insert(i);
    if(right.size() != ys.size())return true;
  }
  set<ll> used;
  for(auto i:left){
    for(auto j:right){
      ll v = i + j;
      if(used.count(v))return true;
      used.insert(v);
    }
  }
  return false;
}


int main(){
  cout << (func() ? "Yes" : "No") << endl;
}
accuracy: 0.06382978723404255
time_ms: 650
memory_kb: 101480
final_rank: 20

code_snippet: #include<bits/stdc++.h>

using namespace std;

using ll = long long;

vector<ll> enumerate(vector<ll> as){
  vector<ll> res;
  for(int i=1;i<(1<<as.size());++i){
    ll sum = 0;
    for(int j=0;j<as.size();++j){
      if((1<<j)&i){
        sum += as[j];
      }else{
        sum -= as[j];
      }
    }
    res.push_back(sum);
  }
  return res;
}

bool func(){
  int n;
  cin >> n;
  vector<ll> as(n);
  if(n >= 40)return true;
  for(auto &i:as)cin >> i;
  set<ll> left;
  set<ll> right;
  {
    vector<ll> xs(as.begin(),as.begin()+min<int>(as.size(),20));
    vector<ll> ys=enumerate(xs);
    for(auto i:ys)left.insert(i);
  }
  {
    vector<ll> xs(as.begin()+min<int>(as.size(),20), as.begin()+min<int>(as.size(),40));
    vector<ll> ys=enumerate(xs);
    for(auto i:ys)right.insert(i);
  }
  if(left.count(0) and right.empty())return true;
  for(auto i:left)if(right.count(-i))return true;
  return false;
}


int main(){
  cout << (func() ? "Yes" : "No") << endl;
}
accuracy: 0.06382978723404255
time_ms: 270
memory_kb: 60516
final_rank: 18

code_snippet: #include<bits/stdc++.h>

using namespace std;

using ll = long long;

vector<ll> enumerate(vector<ll> as){
  vector<ll> res;
  for(int i=1;i<(1<<as.size());++i){
    ll sum = 0;
    for(int j=0;j<as.size();++j){
      if((1<<j)&i){
        sum += as[j];
      }else{
        sum -= as[j];
      }
    }
    res.push_back(sum);
  }
  return res;
}

bool func(){
  int n;
  cin >> n;
  vector<ll> as(n);
  if(n >= 40)return true;
  for(auto &i:as)cin >> i;
  set<ll> left;
  set<ll> right;
  {
    vector<ll> xs(as.begin(),as.begin()+min<int>(as.size(),20));
    vector<ll> ys=enumerate(xs);
    for(auto i:ys)left.insert(i);
  }
  {
    vector<ll> xs(as.begin()+min<int>(as.size(),20), as.begin()+min<int>(as.size(),40));
    vector<ll> ys=enumerate(xs);
    for(auto i:ys)right.insert(i);
  }
  if(left.count(0))return true;
  if(right.count(0))return true;
  for(auto i:left)if(right.count(-i))return true;
  return false;
}


int main(){
  cout << (func() ? "Yes" : "No") << endl;
}
accuracy: 0.06382978723404255
time_ms: 260
memory_kb: 60400
final_rank: 17

code_snippet: /* -*- coding: utf-8 -*-
 *
 * 3242.cc: +- Switch
 */

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

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef long long ll;
typedef set<ll,greater<ll> > slg;

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  slg ps;
  ps.insert(0);

  for (int i = 0; i < n; i++) {
    for (auto u: ps) {
      slg::iterator sit0 = ps.find(u + as[i]);
      if (sit0 != ps.end()) { puts("Yes"); return 0; }
      ps.insert(u + as[i]);
    }
  }

  puts("No");
  return 0;
}
accuracy: 1
time_ms: 410
memory_kb: 52328
final_rank: 10

code_snippet: #include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}


template<int mod>
struct ModInt{
	int x;
	ModInt () : x(0) {}
	ModInt (int64_t x) : x(x >= 0 ? x % mod : (mod - -x % mod) % mod) {}
	ModInt &operator += (const ModInt &p){
		if ((x += p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt &operator -= (const ModInt &p) {
		if ((x += mod - p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt &operator *= (const ModInt &p) {
		x = (int64_t) x * p.x % mod;
		return *this;
	}
	ModInt &operator /= (const ModInt &p) {
		*this *= p.inverse();
		return *this;
	}
	ModInt &operator ^= (int64_t p) {
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator - () const { return ModInt(-x); }
	ModInt operator + (const ModInt &p) const { return ModInt(*this) += p; }
	ModInt operator - (const ModInt &p) const { return ModInt(*this) -= p; }
	ModInt operator * (const ModInt &p) const { return ModInt(*this) *= p; }
	ModInt operator / (const ModInt &p) const { return ModInt(*this) /= p; }
	ModInt operator ^ (int64_t p) const { return ModInt(*this) ^= p; }
	bool operator == (const ModInt &p) const { return x == p.x; }
	bool operator != (const ModInt &p) const { return x != p.x; }
	explicit operator int() const { return x; }
	ModInt &operator = (const int p) { x = p; return *this;}
	ModInt inverse() const {
		int a = x, b = mod, u = 1, v = 0, t;
		while (b > 0) {
			t = a / b;
			a -= t * b;
			std::swap(a, b);
			u -= t * v;
			std::swap(u, v);
		}
		return ModInt(u);
	}
	friend std::ostream & operator << (std::ostream &stream, const ModInt<mod> &p) {
		return stream << p.x;
	}
	friend std::istream & operator >> (std::istream &stream, ModInt<mod> &a) {
		int64_t x;
		stream >> x;
		a = ModInt<mod>(x);
		return stream;
	}
};
typedef ModInt<998244353> mint;

template<int mod> struct MComb {
	using mint = ModInt<mod>;
	std::vector<mint> fact;
	std::vector<mint> inv;
	MComb (int n) { // O(n + log(mod))
		fact = std::vector<mint>(n + 1, 1);
		for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * mint(i);
		inv.resize(n + 1);
		inv[n] = fact[n] ^ (mod - 2);
		for (int i = n; i--; ) inv[i] = inv[i + 1] * mint(i + 1);
	}
	mint ncr(int n, int r) {
		return fact[n] * inv[r] * inv[n - r];
	}
	mint npr(int n, int r) {
		return fact[n] * inv[n - r];
	}
	mint nhr(int n, int r) {
		assert(n + r - 1 < (int) fact.size());
		return ncr(n + r - 1, r);
	}
};


int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	std::map<int, std::vector<int> > index;
	for (int i = 0; i < n; i++) index[a[i]].push_back(i);
	for (auto i : index) if (i.second.size() >= 2) {
		puts("Yes");
		return 0;
	}
	if (n >= 24) {
		puts("Yes");
		return 0;
	}
	std::set<int> used;
	for (int i = 0; i < 1 << n; i++) {
		int cur = 0;
		for (int j = 0; j < n; j++) if (i >> j & 1) cur += a[j];
		if (!used.insert(cur).second) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}
accuracy: 1
time_ms: 230
memory_kb: 52568
final_rank: 7

code_snippet: #include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include <string>


int main() {
	int n; std::cin >> n;
	if (n >= 25) {
		std::cout << "Yes\n";
		return 0;
	}
	std::vector<int> switches(n);
	for (auto& a : switches) {
		std::cin >> a;
	}
	std::unordered_set<int> appear;
	for (auto i = 0; i < (1 << n); ++i) {
		int v{ 0 };
		for (auto j = 0; j < n; ++j) {
			if (((i >> j) & 1) == 1) {
				v += switches[j];
			}
		}
		const auto [_, not_exist] = appear.insert(v);
		if (!not_exist) {
			std::cout << "Yes\n";
			return 0;
		}
	}
	std::cout << "No\n";
	return 0;
}
accuracy: 1
time_ms: 150
memory_kb: 52784
final_rank: 6

code_snippet: #include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
 
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
 
#define MOD 1000000007
 
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
const double EPS = 1e-8, PI = acos(-1);
const double pi = 3.141592653589793238462643383279;
//ここから編集    
typedef string::const_iterator State;
ll GCD(ll a, ll b){
  return (b==0)?a:GCD(b, a%b);
}
ll LCM(ll a, ll b){
  return a/GCD(a, b) * b;
}
template< int mod >
struct ModInt {
  int x;
 
  ModInt() : x(0) {}
 
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
 
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
 
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
 
  ModInt operator-() const { return ModInt(-x); }
 
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
 
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
 
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
 
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
 
  bool operator==(const ModInt &p) const { return x == p.x; }
 
  bool operator!=(const ModInt &p) const { return x != p.x; }
 
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
 
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
 
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
 
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
 
  static int get_mod() { return mod; }
};
 
using modint = ModInt< 998244353 >;
template< typename T >
struct Combination {
  vector< T > _fact, _rfact, _inv;
 
  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }
 
  inline T fact(int k) const { return _fact[k]; }
 
  inline T rfact(int k) const { return _rfact[k]; }
 
  inline T inv(int k) const { return _inv[k]; }
 
  T P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }
 
  T C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }
 
  T H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};
 
ll modpow(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  if(x == 0) return 0;
  while(n) {
    if(n&1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
} 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}
template<typename T> 
struct BIT{
  int N;
  std::vector<T> node;
  BIT(){}
  BIT(int n){
    N = n;
    node.resize(N+10);
  }
  void build(int n) {
    N = n;
    node.resize(N+10);
  }
  /* a: 1-indexed */
  void add(int a, T x){
    for(int i=a; i<(int)node.size(); i += i & -i) node[i] += x;
  }

  /* [1, a] */
  T sum(int a){
    T res = 0;
    for(int x=a; x>0; x -= x & -x) res += node[x];
    return res;
  }

  /* [l, r] */
  T rangesum(int l, int r){
    return sum(r) - sum(l-1);
  }

  /* 
    a1+a2+...+aw >= valとなるような最小のwを返す
    @verify https://codeforces.com/contest/992/problem/E
  */
  int lower_bound(T val) {
    if(val < 0) return 0;

    int res = 0;
    int n = 1; 
    while (n < N) n *= 2;

    T tv=0;
    for (int k = n; k > 0; k /= 2) {
      if(res + k < N && node[res + k] < val){
        val -= node[res+k];
        res += k;
      }
    }
    return res+1; 
  }
};
struct UnionFind{
  std::vector<int> par;
  std::vector<int> siz;

  UnionFind(int sz_): par(sz_), siz(sz_) {
    for(int i=0; i<sz_; ++i) par[i] = i, siz[i] = 1;
  }

  void init(int sz_){
    par.resize(sz_);
    siz.resize(sz_);
    for(int i=0; i<sz_; ++i) par[i] = i, siz[i] = 1;
  }

  int root(int x){
    if(x == par[x]) return x;
    return par[x] = root(par[x]);
  }

  bool merge(int x, int y){
    x = root(x), y = root(y);
    if(x == y) return false;
    if(siz[x] < siz[y]) std::swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

  bool issame(int x, int y){
    return root(x) == root(y);
  }

  int size(int x){
    return siz[root(x)];
  }
};
struct RollingHash{

    using ull = unsigned long long;
    const ull mod = (1ULL << 61) - 1;
    const ull MASK30 = (1ULL << 30) - 1;
    const ull MASK31 = (1ULL << 31) - 1;

    const ull MASK61 = mod;

    ull base;
    int n;
    vector<ull> hash, pow;

    RollingHash(const string &s)
    {
        random_device rnd;
        mt19937_64 mt(rnd());
        base = 1001;
        
        n = (int)s.size();
        hash.assign(n+1, 0);
        pow.assign(n+1, 1);
        
        for(int i=0; i<n; i++){
            hash[i+1] = calc_mod(mul(hash[i], base) + s[i]);
            pow[i+1] = calc_mod(mul(pow[i], base));
        }
    }

    ull calc_mod(ull x){
        ull xu = x >> 61;
        ull xd = x & MASK61;
        ull res = xu + xd;
        if(res >= mod) res -= mod;
        return res;
    }

    ull mul(ull a, ull b){
        ull au = a >> 31;
        ull ad = a & MASK31;
        ull bu = b >> 31;
        ull bd = b & MASK31;
        ull mid = ad * bu + au * bd;
        ull midu = mid >> 30;
        ull midd = mid & MASK30;
        return calc_mod(au * bu * 2 + midu + (midd << 31) + ad * bd);
    }

    //[l,r)のハッシュ値
    inline ull get(int l, int r){
        ull res = calc_mod(hash[r] + mod*3-mul(hash[l], pow[r-l]));
        return res;
    }
    //string tのハッシュ値
    inline ull get(string t){
        ull res = 0;
        for(int i=0; i<t.size(); i++){
            res = calc_mod(mul(res, base)+t[i]);
        }
        return res;
    }
    //string s中のtの数をカウント
    inline int count(string t) {
        if(t.size() > n) return 0;
        auto hs = get(t);
        int res = 0;
        for(int i=0; i<n-t.size()+1; i++){
            if(get(i, i+t.size()) == hs) res++; 
        }
        return res;
    }

    /* 
        concat 
        @verify https://codeforces.com/problemset/problem/514/C
    */
    inline ull concat(ull h1, ull h2, int h2len){
      return calc_mod(h2 + mul(h1, pow[h2len]));
    }

    // LCPを求める S[a:] T[b:]
    inline int LCP(int a, int b){
        int len = min((int)hash.size()-a, (int)hash.size()-b);
        
        int lb = -1, ub = len;
        while(ub-lb>1){
            int mid = (lb+ub)/2;

            if(get(a, a+mid) == get(b, b+mid)) lb = mid;
            else ub = mid;
        }
        return lb;
    }
};

int main() {  
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n; cin >> n;
    vector<ll> a(n);
    REP(i,n)cin >> a[i];
    if(n >= 25) {
      cout << "Yes" << endl;
    }else{
      unordered_map<ll,ll> mp;
      for(int i=0; i<(1<<n); i++) {
        ll sum = 0;
        for(int j=0; j<n; j++) {
          if(i >> j & 1) sum += a[j];
          else sum -= a[j];
        }
        mp[sum]++;
        if(mp[sum] >= 2) {
          cout << "Yes" << endl;
          return 0;
        }
      }
      cout << "No" << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 140
memory_kb: 52768
final_rank: 4

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001



#define MAX 25

int POW[MAX+1];
ll A[MAX+1];

int main(){

	POW[0] = 1;
	for(int i = 1; i <= MAX; i++){

		POW[i] = POW[i-1]*2;
	}

	int N;
	scanf("%d",&N);
	if(N >= MAX){

		printf("Yes\n");
		return 0;
	}

	for(int i = 0; i < N; i++){

		scanf("%lld",&A[i]);
	}

	map<ll,bool> MAP;

	for(int state = 0; state < POW[N]; state++){

		ll sum = 0;
		for(int loop = 0; loop < N; loop++){
			if(state&POW[loop]){

				sum += A[loop];

			}else{

				sum -= A[loop];
			}
		}

		auto at = MAP.find(sum);
		if(at != MAP.end()){

			printf("Yes\n");
			return 0;
		}
		MAP[sum] = true;
	}


	printf("No\n");

	return 0;
}
accuracy: 1
time_ms: 300
memory_kb: 69024
final_rank: 11

code_snippet: #include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
 
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
 
#define MOD 1000000007
 
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
const double EPS = 1e-8, PI = acos(-1);
const double pi = 3.141592653589793238462643383279;
//ここから編集    
typedef string::const_iterator State;
ll GCD(ll a, ll b){
  return (b==0)?a:GCD(b, a%b);
}
ll LCM(ll a, ll b){
  return a/GCD(a, b) * b;
}
template< int mod >
struct ModInt {
  int x;
 
  ModInt() : x(0) {}
 
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
 
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
 
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
 
  ModInt operator-() const { return ModInt(-x); }
 
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
 
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
 
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
 
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
 
  bool operator==(const ModInt &p) const { return x == p.x; }
 
  bool operator!=(const ModInt &p) const { return x != p.x; }
 
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
 
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
 
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
 
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
 
  static int get_mod() { return mod; }
};
 
using modint = ModInt< 998244353 >;
template< typename T >
struct Combination {
  vector< T > _fact, _rfact, _inv;
 
  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }
 
  inline T fact(int k) const { return _fact[k]; }
 
  inline T rfact(int k) const { return _rfact[k]; }
 
  inline T inv(int k) const { return _inv[k]; }
 
  T P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }
 
  T C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }
 
  T H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};
 
ll modpow(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  if(x == 0) return 0;
  while(n) {
    if(n&1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
} 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}
template<typename T> 
struct BIT{
  int N;
  std::vector<T> node;
  BIT(){}
  BIT(int n){
    N = n;
    node.resize(N+10);
  }
  void build(int n) {
    N = n;
    node.resize(N+10);
  }
  /* a: 1-indexed */
  void add(int a, T x){
    for(int i=a; i<(int)node.size(); i += i & -i) node[i] += x;
  }

  /* [1, a] */
  T sum(int a){
    T res = 0;
    for(int x=a; x>0; x -= x & -x) res += node[x];
    return res;
  }

  /* [l, r] */
  T rangesum(int l, int r){
    return sum(r) - sum(l-1);
  }

  /* 
    a1+a2+...+aw >= valとなるような最小のwを返す
    @verify https://codeforces.com/contest/992/problem/E
  */
  int lower_bound(T val) {
    if(val < 0) return 0;

    int res = 0;
    int n = 1; 
    while (n < N) n *= 2;

    T tv=0;
    for (int k = n; k > 0; k /= 2) {
      if(res + k < N && node[res + k] < val){
        val -= node[res+k];
        res += k;
      }
    }
    return res+1; 
  }
};
struct UnionFind{
  std::vector<int> par;
  std::vector<int> siz;

  UnionFind(int sz_): par(sz_), siz(sz_) {
    for(int i=0; i<sz_; ++i) par[i] = i, siz[i] = 1;
  }

  void init(int sz_){
    par.resize(sz_);
    siz.resize(sz_);
    for(int i=0; i<sz_; ++i) par[i] = i, siz[i] = 1;
  }

  int root(int x){
    if(x == par[x]) return x;
    return par[x] = root(par[x]);
  }

  bool merge(int x, int y){
    x = root(x), y = root(y);
    if(x == y) return false;
    if(siz[x] < siz[y]) std::swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

  bool issame(int x, int y){
    return root(x) == root(y);
  }

  int size(int x){
    return siz[root(x)];
  }
};
struct RollingHash{

    using ull = unsigned long long;
    const ull mod = (1ULL << 61) - 1;
    const ull MASK30 = (1ULL << 30) - 1;
    const ull MASK31 = (1ULL << 31) - 1;

    const ull MASK61 = mod;

    ull base;
    int n;
    vector<ull> hash, pow;

    RollingHash(const string &s)
    {
        random_device rnd;
        mt19937_64 mt(rnd());
        base = 1001;
        
        n = (int)s.size();
        hash.assign(n+1, 0);
        pow.assign(n+1, 1);
        
        for(int i=0; i<n; i++){
            hash[i+1] = calc_mod(mul(hash[i], base) + s[i]);
            pow[i+1] = calc_mod(mul(pow[i], base));
        }
    }

    ull calc_mod(ull x){
        ull xu = x >> 61;
        ull xd = x & MASK61;
        ull res = xu + xd;
        if(res >= mod) res -= mod;
        return res;
    }

    ull mul(ull a, ull b){
        ull au = a >> 31;
        ull ad = a & MASK31;
        ull bu = b >> 31;
        ull bd = b & MASK31;
        ull mid = ad * bu + au * bd;
        ull midu = mid >> 30;
        ull midd = mid & MASK30;
        return calc_mod(au * bu * 2 + midu + (midd << 31) + ad * bd);
    }

    //[l,r)のハッシュ値
    inline ull get(int l, int r){
        ull res = calc_mod(hash[r] + mod*3-mul(hash[l], pow[r-l]));
        return res;
    }
    //string tのハッシュ値
    inline ull get(string t){
        ull res = 0;
        for(int i=0; i<t.size(); i++){
            res = calc_mod(mul(res, base)+t[i]);
        }
        return res;
    }
    //string s中のtの数をカウント
    inline int count(string t) {
        if(t.size() > n) return 0;
        auto hs = get(t);
        int res = 0;
        for(int i=0; i<n-t.size()+1; i++){
            if(get(i, i+t.size()) == hs) res++; 
        }
        return res;
    }

    /* 
        concat 
        @verify https://codeforces.com/problemset/problem/514/C
    */
    inline ull concat(ull h1, ull h2, int h2len){
      return calc_mod(h2 + mul(h1, pow[h2len]));
    }

    // LCPを求める S[a:] T[b:]
    inline int LCP(int a, int b){
        int len = min((int)hash.size()-a, (int)hash.size()-b);
        
        int lb = -1, ub = len;
        while(ub-lb>1){
            int mid = (lb+ub)/2;

            if(get(a, a+mid) == get(b, b+mid)) lb = mid;
            else ub = mid;
        }
        return lb;
    }
};

int main() {  
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  
  int n; cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  ll sum = accumulate(all(a), 0LL);

  if(n >= 25) cout << "Yes" << endl;
  else{
    set<ll> st;
    for(int bit=0; bit<(1<<n); bit++) {
      ll t = 0;
      REP(j,n) {
        if(bit >> j & 1) {
          t += a[j];
        }else{
          t -= a[j];
        }
      }
      if(st.count(t)) {
        cout << "Yes" << endl;
        return 0;
      }
      st.insert(t);
    }
    cout << "No" << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 270
memory_kb: 52512
final_rank: 8

code_snippet: #include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
 
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
 
#define MOD 1000000007
 
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
const double EPS = 1e-8, PI = acos(-1);
const double pi = 3.141592653589793238462643383279;
//ここから編集    
typedef string::const_iterator State;
ll GCD(ll a, ll b){
  return (b==0)?a:GCD(b, a%b);
}
ll LCM(ll a, ll b){
  return a/GCD(a, b) * b;
}
template< int mod >
struct ModInt {
  int x;
 
  ModInt() : x(0) {}
 
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
 
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
 
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
 
  ModInt operator-() const { return ModInt(-x); }
 
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
 
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
 
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
 
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
 
  bool operator==(const ModInt &p) const { return x == p.x; }
 
  bool operator!=(const ModInt &p) const { return x != p.x; }
 
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
 
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
 
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
 
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
 
  static int get_mod() { return mod; }
};
 
using modint = ModInt< 998244353 >;
template< typename T >
struct Combination {
  vector< T > _fact, _rfact, _inv;
 
  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }
 
  inline T fact(int k) const { return _fact[k]; }
 
  inline T rfact(int k) const { return _rfact[k]; }
 
  inline T inv(int k) const { return _inv[k]; }
 
  T P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }
 
  T C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }
 
  T H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};
 
ll modpow(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  if(x == 0) return 0;
  while(n) {
    if(n&1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
} 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}
template<typename T> 
struct BIT{
  int N;
  std::vector<T> node;
  BIT(){}
  BIT(int n){
    N = n;
    node.resize(N+10);
  }
  void build(int n) {
    N = n;
    node.resize(N+10);
  }
  /* a: 1-indexed */
  void add(int a, T x){
    for(int i=a; i<(int)node.size(); i += i & -i) node[i] += x;
  }

  /* [1, a] */
  T sum(int a){
    T res = 0;
    for(int x=a; x>0; x -= x & -x) res += node[x];
    return res;
  }

  /* [l, r] */
  T rangesum(int l, int r){
    return sum(r) - sum(l-1);
  }

  /* 
    a1+a2+...+aw >= valとなるような最小のwを返す
    @verify https://codeforces.com/contest/992/problem/E
  */
  int lower_bound(T val) {
    if(val < 0) return 0;

    int res = 0;
    int n = 1; 
    while (n < N) n *= 2;

    T tv=0;
    for (int k = n; k > 0; k /= 2) {
      if(res + k < N && node[res + k] < val){
        val -= node[res+k];
        res += k;
      }
    }
    return res+1; 
  }
};
struct UnionFind{
  std::vector<int> par;
  std::vector<int> siz;

  UnionFind(int sz_): par(sz_), siz(sz_) {
    for(int i=0; i<sz_; ++i) par[i] = i, siz[i] = 1;
  }

  void init(int sz_){
    par.resize(sz_);
    siz.resize(sz_);
    for(int i=0; i<sz_; ++i) par[i] = i, siz[i] = 1;
  }

  int root(int x){
    if(x == par[x]) return x;
    return par[x] = root(par[x]);
  }

  bool merge(int x, int y){
    x = root(x), y = root(y);
    if(x == y) return false;
    if(siz[x] < siz[y]) std::swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

  bool issame(int x, int y){
    return root(x) == root(y);
  }

  int size(int x){
    return siz[root(x)];
  }
};
struct RollingHash{

    using ull = unsigned long long;
    const ull mod = (1ULL << 61) - 1;
    const ull MASK30 = (1ULL << 30) - 1;
    const ull MASK31 = (1ULL << 31) - 1;

    const ull MASK61 = mod;

    ull base;
    int n;
    vector<ull> hash, pow;

    RollingHash(const string &s)
    {
        random_device rnd;
        mt19937_64 mt(rnd());
        base = 1001;
        
        n = (int)s.size();
        hash.assign(n+1, 0);
        pow.assign(n+1, 1);
        
        for(int i=0; i<n; i++){
            hash[i+1] = calc_mod(mul(hash[i], base) + s[i]);
            pow[i+1] = calc_mod(mul(pow[i], base));
        }
    }

    ull calc_mod(ull x){
        ull xu = x >> 61;
        ull xd = x & MASK61;
        ull res = xu + xd;
        if(res >= mod) res -= mod;
        return res;
    }

    ull mul(ull a, ull b){
        ull au = a >> 31;
        ull ad = a & MASK31;
        ull bu = b >> 31;
        ull bd = b & MASK31;
        ull mid = ad * bu + au * bd;
        ull midu = mid >> 30;
        ull midd = mid & MASK30;
        return calc_mod(au * bu * 2 + midu + (midd << 31) + ad * bd);
    }

    //[l,r)のハッシュ値
    inline ull get(int l, int r){
        ull res = calc_mod(hash[r] + mod*3-mul(hash[l], pow[r-l]));
        return res;
    }
    //string tのハッシュ値
    inline ull get(string t){
        ull res = 0;
        for(int i=0; i<t.size(); i++){
            res = calc_mod(mul(res, base)+t[i]);
        }
        return res;
    }
    //string s中のtの数をカウント
    inline int count(string t) {
        if(t.size() > n) return 0;
        auto hs = get(t);
        int res = 0;
        for(int i=0; i<n-t.size()+1; i++){
            if(get(i, i+t.size()) == hs) res++; 
        }
        return res;
    }

    /* 
        concat 
        @verify https://codeforces.com/problemset/problem/514/C
    */
    inline ull concat(ull h1, ull h2, int h2len){
      return calc_mod(h2 + mul(h1, pow[h2len]));
    }

    // LCPを求める S[a:] T[b:]
    inline int LCP(int a, int b){
        int len = min((int)hash.size()-a, (int)hash.size()-b);
        
        int lb = -1, ub = len;
        while(ub-lb>1){
            int mid = (lb+ub)/2;

            if(get(a, a+mid) == get(b, b+mid)) lb = mid;
            else ub = mid;
        }
        return lb;
    }
};

int main() {  
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  
  int n; cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  ll sum = accumulate(all(a), 0LL);
  if(sum%2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  if(n >= 25) cout << "Yes" << endl;
  else{
    for(int bit=0; bit<(1<<n); bit++) {
      ll t = 0;
      REP(j,n) if(bit >> j & 1) t += a[j];
      if(t == sum/2) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
  }
  return 0;
}
accuracy: 0.06382978723404255
time_ms: 70
memory_kb: 3484
final_rank: 16

code_snippet: #pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <sstream>
#include <utility>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    set<int> st;
    st.insert(0);
    // sort(a.begin(), a.end());
    set<int> nst;
    nst.insert(0);
    for(int i=0;i<n;i++){
        for(int t:st){
            if(st.find(t+a[i])!=st.end()){
                cout << "Yes" << endl;
                return 0;
            }
            nst.insert(t+a[i]);
        }
        st = nst;
    }
    cout << "No" << endl;
}
accuracy: 1
time_ms: 220
memory_kb: 101708
final_rank: 13

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n-1);i>=0;i--)
#define ALL(v) v.begin(),v.end()

using ll=long long;

int main(){
  ll n;cin>>n;
  vector<ll> v(n);
  REP(i,n)cin>>v[i];
  if(n>=36){
    cout<<"Yes"<<endl;
    return 0;
  }
  REP(i,n)if(v[i]==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(n==1){
    cout<<"No"<<endl;
    return 0;
  }
  ll sum=0;REP(i,n)sum+=v[i];
  if((1LL<<n)-1>sum){
    cout<<"Yes"<<endl;
    return 0;
  }
  set<ll> se1{0},se2{0};
  int mid=n/2;
  REP(i,mid){
    set<ll> tmp;
    for(ll p:se1){
      if(p+v[i]==0){
        cout<<"Yes"<<endl;
        return 0;
      }
      if(p-v[i]==0){
        cout<<"Yes"<<endl;
        return 0;
      }
      tmp.insert(p+v[i]);
      tmp.insert(p-v[i]);
    }
    se1.insert(ALL(tmp));
  }
  for(int i=mid;i<n;i++){
    set<ll> tmp;
    for(ll p:se2){
      if(p+v[i]==0){
        cout<<"Yes"<<endl;
        return 0;
      }
      if(p-v[i]==0){
        cout<<"Yes"<<endl;
        return 0;
      }
      tmp.insert(p+v[i]);
      tmp.insert(p-v[i]);
    }
    se2.insert(ALL(tmp));
  }
  for(ll p:se1){
    if(p&&se2.count(p)){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}
accuracy: 1
time_ms: 60
memory_kb: 25076
final_rank: 2

code_snippet: #pragma region Macros
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define FOR(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void Case(int i) { cout << "Case #" << i << ": "; }
int popcount(int x) { return __builtin_popcount(x); }
ll popcount(ll x) { return __builtin_popcountll(x); }
#pragma endregion Macros

const int MAX = 500000 * 26;
int N;
int a[100001];
int dp[2][MAX + 1];

int main() {
    cin >> N;
    REP(i, N) cin >> a[i];
    if(N >= 24) {
        cout << "Yes\n";
        return 0;
    }
    int now = 0, nxt = 1;
    dp[now][0] = 1;
    REP(i, N) {
        REP(j, MAX + 1) if(dp[now][j] >= 2) {
            cout << "Yes\n";
            return 0;
        }
        REP(j, MAX + 1) {
            if(dp[now][j] == 0) continue;
            dp[nxt][j] += dp[now][j];
            if(j + a[i] <= MAX) dp[nxt][j + a[i]] += dp[now][j];
            dp[now][j] = 0;
        }
        swap(now, nxt);
    }
    REP(j, MAX + 1) if(dp[now][j] >= 2) {
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
}
accuracy: 1
time_ms: 300
memory_kb: 81308
final_rank: 12

code_snippet: #pragma region Macros
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define FOR(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void Case(int i) { cout << "Case #" << i << ": "; }
int popcount(int x) { return __builtin_popcount(x); }
ll popcount(ll x) { return __builtin_popcountll(x); }
#pragma endregion Macros

const int MAX = 500000 * 35;
int N;
int a[100001];
int dp[2][MAX + 1];

int main() {
    cin >> N;
    REP(i, N) cin >> a[i];
    if(N > 35) {
        cout << "No\n";
        return 0;
    }
    int now = 0, nxt = 1;
    dp[now][0] = 1;
    REP(i, N) {
        REP(j, MAX + 1) if(dp[now][j] >= 2) {
            cout << "Yes\n";
            return 0;
        }
        REP(j, MAX + 1) {
            dp[nxt][j] += dp[now][j];
            if(j + a[i] <= MAX) dp[nxt][j + a[i]] += dp[now][j];
            dp[now][j] = 0;
        }
        swap(now, nxt);
    }
    REP(j, MAX + 1) if(dp[now][j] >= 2) {
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
}
accuracy: 0.7021276595744681
time_ms: 570
memory_kb: 140156
final_rank: 15

code_snippet: #include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll mod = 1000000007;
const ll inf = 1000000000;
const ll INF = 1e9;


void pline(vector<ll> lis){
    rep(i,0,lis.size()){
        printf ("%lld",lis[i]);
        if (i != lis.size()-1) printf(" ");
        else printf("\n");
    }
}


int main(){

    ll TT = 1;
    
    rep(loop,0,TT){

        ll N;
        scanf ("%lld" , &N);

        vector<ll> A(N);
        rep(i,0,N){
            scanf ("%lld",&A[i]);
        }

        if (N >= 23){
            printf ("Yes\n");
            return 0;
        }

        unordered_set<ll> s;

        rep(i,0,1<<N){
            ll ns = 0;
            rep(j,0,N){
                if (((1<<j) & i) > 0){
                    ns += A[j];
                }
            }
            if (s.count(ns) != 0){
                printf ("Yes\n");
                return 0;
            }
            s.insert(ns);
        }

        printf ("No\n");


    }

}

/*

*/
accuracy: 1
time_ms: 150
memory_kb: 52772
final_rank: 5

code_snippet: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N; cin >> N;
    vector<int> A(N);
    bool ZERO = false, SAME = false;
    set<int> se;
    rep(i,N) {
        cin >> A[i];
        if(A[i] == 0) ZERO = true;
        if(se.count(A[i])) {
            SAME = true;
        } else {
            se.insert(A[i]);
        }
    }

    if(ZERO || SAME || N >= 25){
        cout << "Yes" << endl; return 0;
    }

    set<int> s;
    rep(i,1<<N) {
        int sum = 0;
        rep(j,N) if(i & (1 << j)) sum += A[j];
        if(s.count(sum)) {
            cout << "Yes" << endl; return 0;
        } else {
            s.insert(sum);
        }
    }

    cout << "No" << endl;
}
accuracy: 1
time_ms: 290
memory_kb: 52588
final_rank: 9