Problem:
Problem A:
Sum of Consecutive Prime Numbers
Some positive integers can be represented by a sum of one or more consecutive prime numbers.
How many such representations does a given positive integer have? For example, the integer 53
has two representations 5 + 7 + 11 + 13 + 17 and 53. The integer 41 has three representations
2 + 3 + 5 + 7 + 11 + 13, 11 + 13 + 17, and 41. The integer 3 has only one representation, which is
3. The integer 20 has no such representations. Note that summands must be consecutive prime
numbers, so neither 7 + 13 nor 3 + 5 + 5 + 7 is a valid representation for the integer 20.
Your mission is to write a program that reports the number of representations for the given
positive integer.
Input
The input is a sequence of positive integers each in a separate line. The integers are between 2
and 10 000, inclusive. The end of the input is indicated by a zero.
Output
The output should be composed of lines each corresponding to an input line except the last zero.
An output line includes the number of representations for the input integer as the sum of one
or more consecutive prime numbers. No other characters should be inserted in the output.
Sample Input
2
3
17
41
20
666
12
53
0
Output for the Sample Input
1
1
2
3
0
0
1
2

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
using namespace std;
set<int>primes;
int main(){
    int n;
    while(true){
        cin>>n;
        primes.clear();
        if(n==0)
            break;
        for(int i=2;i<=n;++i)
            primes.insert(i);
        for(auto i=primes.begin();i!=primes.end();++i){
            for(long j=(*i)*2;j<=n;j+=*i){
                if(primes.find(j)!=primes.end()){
                    primes.erase(j);
                }
            }
        }
        int c=0;
        for(auto it=primes.begin();it!=primes.end();++it){
                int sum=0;
                for(auto j=it;j!=primes.end();++j){
                    sum+=*j;
                    if(sum==n){
                        ++c;
                        break;
                    }
                    if(sum>n)
                        break;
                }
        }
        cout<<c<<endl;
    }
}
accuracy: 1
time_ms: 80
memory_kb: 3648
final_rank: 13

code_snippet: #include<bits/stdc++.h>
using namespace std;
set<int>primes;
int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0)
            break;
        primes.clear();
        for(int k=2;k<=n;++k)
            primes.insert(k);
        for(auto i=primes.begin();i!=primes.end();++i){
            for(long j=(*i)*2;j<=n;j+=*i){
                if(primes.find(j)!=primes.end()){
                    primes.erase(j);
                }
            }
        }
        long c=0;
        for(auto it=primes.begin();it!=primes.end();++it){
                int sum=0;
                for(auto j=it;j!=primes.end();++j){
                    sum+=*j;
                    if(sum==n){
                        ++c;
                        break;
                    }
                    if(sum>n)
                        break;
                }
        }
        cout<<c<<endl;
    }
}
accuracy: 1
time_ms: 80
memory_kb: 3912
final_rank: 14

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>
#include <array>
#include <bitset>
using namespace std;
typedef long long int ll;

const int N = 4000001;
bool is_not_prime[N];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    is_not_prime[0] = is_not_prime[1] = true;
    vector<int> p;
    for(int i=2;i<N;i++){
        if(!is_not_prime[i]){
            p.push_back(i);
            for(int j=i+i;j<N;j+=i){
                is_not_prime[j] = true;
            }
        }
    }
    int n;
    while(cin >> n,n){
        int res = 0;
        int sum = 0;
        int r = 0;
        for(int i=0;i<p.size();i++){
            if(p[i] > n) break;
            while(r<p.size() and sum < n){
                sum += p[r]; r++;
            }
            if(sum == n) res++;
            sum -= p[i];
        }
        cout << res << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 8896
final_rank: 12

code_snippet: #include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
    vector<int> prime;
    bool prime_judgement[10000] = {false};
    prime_judgement[0] = true;
    prime_judgement[1] = true;
    for (int i=2; i<10000; i++){
        if (prime_judgement[i] == false) {
            prime.push_back(i);
            for (int j=i+1; j<10000; j++){
                if (j % i == 0) prime_judgement[j] = true;
                }
        }
    }
    int N;
    while (cin >> N && N > 0){
        queue<int> Q;
        int num = 0;
        int sum = 0;
        int count = 0;
        while(true){
            if (sum < N){
                if (num == prime.size()) break;
                Q.push(prime[num]);
                sum += Q.back();
                num += 1;
            }
            else if (sum >= N) {
                if (sum == N) count += 1;
                sum -= Q.front();
                Q.pop();
            }
        }
        cout << count << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3088
final_rank: 4

code_snippet: #include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
    vector<int> prime;
    bool prime_judgement[10000] = {false};
    prime_judgement[0] = true;
    prime_judgement[1] = true;
    for (int i=2; i<10000; i++){
        if (prime_judgement[i] == false) {
            prime.push_back(i);
            for (int j=i+1; j<10000; j++){
                if (j % i == 0) prime_judgement[j] = true;
                }
        }
    }
    int N;
    while (cin >> N && N > 0){
        queue<int> Q;
        int num = 0;
        int sum = 0;
        int count = 0;
        while(true){
            if (sum < N){
                if (num == prime.size()) break;
                Q.push(prime[num]);
                sum += prime[num];
                num += 1;
            }
            else if (sum >= N) {
                if (sum == N) count += 1;
                sum -= Q.front();
                Q.pop();
            }
        }
        cout << count << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3144
final_rank: 6

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

bool isPrime(int n){
    for(int i=2; i<n; i++){
        if((n%i)==0) return false;
    }
    return true;
}

int main() {
    int n; cin>>n;
    while(n != 0){
        //素数列挙
        vector<int> prime;
        for(int i=2; i<=n; i++){
            if(isPrime(i)) prime.push_back(i);
        }

        //累積和
        vector<int> c(prime.size()+1);
        for(int i=1; i<c.size(); i++){
            c[i] = c[i-1] + prime[i-1];
        }

        int count = 0;

        //二分探索
        for(int i=0; i<c.size(); i++){
            int left = i, right = c.size();
            while(left < right){
                int mid = (left+right)/2;
                int sum = c[mid]-c[i];
                if(sum > n) right = mid;
                else left = mid+1;
                if(sum == n){
                    count++;
                }
            }
        }
        cout << count << endl;
        cin>>n;
    }
}
accuracy: 1
time_ms: 360
memory_kb: 3092
final_rank: 18

code_snippet: #include<iostream>
#include<list>
#include<algorithm>
using namespace std;

list<long> L;

bool isprime(long n){
    if (n == 2) return true;
    if (n == 1 || n % 2 == 0) return false;
    long k = 3;
    while( k * k <= n ){
        if (n % k == 0) return false;
        k = k + 2;
    }
    return true;
}

void setprime(){
    L.push_back(2);
    long n = 3;
    while (n < 10010){
        if (isprime(n)) L.push_back(n);
        n += 2;
    }
    return;
}

int main(){
    setprime();
    long D[L.size() + 2];
    D[0] = 0;
    int i = 1;
    while (!(L.empty())) {
        D[i] = D[i - 1] + *(L.begin());
        L.pop_front(); i++;
    }
    long k;
    while(cin >> k) {
        if (k == 0) return 0;
        int i = 1, x = 0;
        while( D[i] - D[i - 1] <= k ) {
            int j = 0;
            while(j < i){
                if (D[i] - D[j] == k) x++;
                j++;
            }
            i++;
        }
        cout << x << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3064
final_rank: 3

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#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 sz(x) (int)(x).size()



typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 100000000;

struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

class UnionFind {
public:
    vector <ll> par; 
    vector <ll> siz; 

    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }

    ll root(ll x) { 
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

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

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

    ll size(ll x) { 
        return siz[root(x)];
    }
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    bool c = false;
    while(n){
        if(n&1) res = res * x;

        if(res > mod){
            c = true;
            res %= mod;
        }
        x = x * x %mod;
        n >>= 1;
    }
    if(c) return mod;
    return res;
}

#define SIEVE_SIZE 5000000+10
bool sieve[SIEVE_SIZE];
void make_sieve(){
    for(int i=0; i<SIEVE_SIZE; ++i) sieve[i] = true;
    sieve[0] = sieve[1] = false;
    for(int i=2; i*i<SIEVE_SIZE; ++i) if(sieve[i]) for(int j=2; i*j<SIEVE_SIZE; ++j) sieve[i*j] = false;
}

bool isprime(ll n){
    if(n == 0 || n == 1) return false;
    for(ll i=2; i*i<=n; ++i) if(n%i==0) return false;
    return true;
}

template<typename T>
vector<T> gauss_jordan(const vector<vector<T>>& A, const vector<T>& b){
    int n = A.size();
    vector<vector<T>> B(n, vector<T>(n+1));

    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            B[i][j] = A[i][j];
        }
    }

    for(int i=0; i<n; ++i) B[i][n] = b[i];

    for(int i=0; i<n; ++i){
        int pivot = i;
        for(int j=i; j<n; ++j){
            if(abs(B[j][i]) > abs(B[pivot][i])) pivot = j;
        }
        swap(B[i], B[pivot]);

        if(abs(B[i][i]) < EPS) return vector<T>(); //解なし

        for(int j=i+1; j<=n; ++j) B[i][j] /= B[i][i];
        for(int j=0; j<n; ++j){
            if(i != j){
                for(int k=i+1; k<=n; ++k) B[j][k] -= B[i][j] * B[i][k];
            }
        }
    }

    vector<T> x(n);

    for(int i=0; i<n; ++i) x[i] = B[i][n];
    return x;
    
}

ll GCD(ll a, ll b){
    if(a<b) swap(a,b);
    if(b == 0) return a;
    return GCD(b, a%b);
}


typedef vector<ll> vec;
typedef vector<vec> mat;

mat mul(mat &A, mat &B) {
    mat C(A.size(), vec((int)B[0].size()));
    for(int i=0; i<A.size(); ++i){
        for(int k=0; k<B.size(); ++k){
            for(int j=0; j<B[0].size(); ++j){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j] %MOD) % MOD;
            }
        }
    }
    return C;
}
mat mat_pow(mat A, ll n) {
    mat B(A.size(), vec((int)A.size()));

    for(int i=0; i<A.size(); ++i){
        B[i][i] = 1;
    }

    while(n > 0) {
        if(n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

bool operator<(const pii& a, const pii& b){
    if(a.first == b.first) return a.second < b.second;
    return a.first < b.first;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int bit[1000010];
int sum(int i){
    int s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}
void add(int i, int x){
    while(i <= 1000010){
        bit[i] += x;
        i += i & -i;
    }
}
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

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

    make_sieve();
    vector<int> primes;
    for(int i=0; i<=10000; i++) if(sieve[i]) primes.PB(i);

    int len = primes.size();

    int n;
    while(cin >> n, n){
        int left = 0, right = 0;
        int sum = 0;

        int ans = 0;
        for(; left <len; left++){
            while(right < len && sum < n){
                sum += primes[right];
                right++;
            }

            if(sum == n) ans++;

            if(right == left) right++;
            else{
                sum -= primes[left];
            }
        }
        cout << ans << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 8044
final_rank: 11

code_snippet: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#define int long long
using namespace std;
vector<int>p, ps;
bool b[5736397];
void f(int k) {
	p.push_back(k);
	ps.push_back(ps.back() + k);
	b[ps.back()] = 1;
	return;
}
signed main() {
	ps.push_back(0); b[0] = 1;
	f(2);
	for (int i = 3; i <= 10000; i += 2) {
		bool b00l = 1;
		for (int j = 0; j < p.size(); j++) 
			if (i%p[j] == 0)b00l = 0;
		if (b00l)f(i);
	}
	int n;
	while (cin >> n, n) {
		int ans = 0;
		for (int i = 0; i < ps.size(); i++) {
			if (ps[i] - n < 0)continue;
			if (b[ps[i] - n])ans++;
		}
		cout << ans << endl;
	}
}
accuracy: 1
time_ms: 20
memory_kb: 6888
final_rank: 10

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
using namespace std;

bool judgePrimeNumber( int a )
{
    for( int i = 2; i <= sqrt(a); i++ )
        if( a % i == 0 )
            return false;
    return true;
}

int main()
{
    int n, a[10001];
    vector<int> p;

    for( int i = 2; i < 10000; i++ )
        if( judgePrimeNumber(i) )
            p.push_back(i);

    for( int i = 0; i < 10001; i++ )
        a[i] = 0;

    int pluscnt = 1;
    while( pluscnt <= p.size() )
    {
        for( int i = 0; i < p.size(); i++ )
        {
            int sum = 0;
            for( int j = i; j < p.size() && j < pluscnt + i; j++ )
                sum += p[j];
            if( sum <= 10000 )
                a[sum]++;
        }
        pluscnt++;
    }

    while( cin >> n )
    {
        if( n == 0 )
            break;
        cout << a[n] << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 270
memory_kb: 3192
final_rank: 17

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool is_prime(int n){
	if(n <= 1) return false;
	if(n == 2) return true;
	if(n % 2 == 0) return false;
	for(int i = 3; i * i <= n; i++){
		if(n % i == 0) return false;
	}
	return true;
}
int main(){
	int n;
	vector<int> prime_numbers;
	for(int i = 1; i < 10000; i++){
		if(is_prime(i)) prime_numbers.push_back(i);
	}
	vector<ll> cumulative_sum;
	ll sum = 0;
	for(int i = 0; i < prime_numbers.size(); i++){
		cumulative_sum.push_back(sum);
		sum += prime_numbers[i];
	}
	cumulative_sum.push_back(sum);
	for(;;){
		cin >> n;
		if(n == 0) break;
		int ans = 0;
		for(int i = 0; i < cumulative_sum.size(); i++){
			for(int j = 0; j <= i; j++){
				if(cumulative_sum[i] - cumulative_sum[j] == n) ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3128
final_rank: 9

code_snippet: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

vector<int> v;

bool isPrime(int n) {
    for (int i = 0; i < v.size() && v[i] * v[i] <= n; i++) {
        if (n % v[i] == 0) return false;
    }
    return true;
}

int main() {
    v.push_back(2);
    v.push_back(3);
    for (int i = 5; i <= 10000; i += 2) {
        if (isPrime(i)) {
            v.push_back(i);
        }
    }
    
    int sum[v.size() + 1];
    fill(sum, sum + v.size() + 1, 0);
    for (int i = 1; i < v.size() + 1; i++) {
        sum[i] = sum[i - 1] + v[i - 1];
    }
    
    while (true) {
        int n;
        cin >> n;
        if (n == 0) return 0;
        int count = 0;
        for (int i = 1; i < v.size() + 1; i++) {
            if (v[i - 1] > n) break;
            for (int j = 0; j <= i; j++) {
                if (sum[i] - sum[j] == n) {
                    count++;
                }
            }
        }
        cout << count << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3052
final_rank: 2

code_snippet: #include<stdio.h>
#include<vector>
#include<queue>
#include<iostream>

using namespace std;

int main() {
  int numbers[10010];
  vector<int> prime_number;
  int num, sum = 0;
  for(int i = 2; i <= 10000; i++) numbers[i-2] = i;
  for(int i = 2; i <= 10000; i++) {
    int p = numbers[i-2];
    if(p != 0) {
      for(int j = i+1; j <= 10000; j++) if(numbers[j-2]%p == 0) numbers[j-2] = 0;
    }
  }
  for(int i = 2; i <= 10000; i++) {
    if(numbers[i-2] != 0) prime_number.push_back(numbers[i-2]);
  }
  while(true) {
    int ans = 0;
    sum = 0;
    scanf("%d", &num);
    if(num == 0) break;
    queue<int> q;
    int i = 0;
    do {
      if(sum < num) {
	q.push(prime_number[i]);
	sum += prime_number[i];
	i++;
      }
      else if(sum > num) {
	sum -= q.front();
	q.pop();
      }
      else {
	ans++;
	sum -= q.front();
	q.pop();
	q.push(prime_number[i]);
	sum += prime_number[i];
	i++;
      }
    }while(prime_number[i-1] <= num || i <= prime_number.size()-1);
    printf("%d\n", ans);
  }

  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3224
final_rank: 7

code_snippet: #include<bits/stdc++.h>
using namespace std;
bool s[10000000];
int main(){
  s[0]=s[1]=1;
  for(int i=2;i<10000000;i++)if(!s[i])
    for(int j=i+i;j<10000000;j+=i)s[j]=1;
  int n;
  while(cin>>n,n){
    int sum=0,c=0;
    for(int i=0;i<=n;i++){
      sum=0;
      if(!s[i])for(int j=i;j<n*10;j++){
        if(!s[j])sum+=j;
        if(sum==n)c++;
        if(sum>=n)break;
      }
    }
    cout<<c<<endl;
  }
}
accuracy: 1
time_ms: 90
memory_kb: 12844
final_rank: 16

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

int a[10009];
vector<int> p;
map<int,int> m;

void sieve()
{
    int i,j,t1,t2;
    for(i=0;i<10003;i++)
        a[i]=1;
    a[0]=a[1]=0;
    for(i=2;i<=10000;i++)
    {
        if(a[i]==1)
        {
            p.push_back(i);
            for(j=2*i;j<=10000;j+=i)
            {
                a[j]=0;
            }
        }
    }
    for(i=0;i<p.size();i++)
    {
        t1=0;
        for(j=i;j<p.size();j++)
        {
            t1+=p[j];
            m[t1]++;
        }
    }
    return;
}


int main()
{
    int i,j,t1,t2,n,ans;
    sieve();
    while(1)
    {
        scanf("%d",&n);
        if(n==0)
            break;
        ans=m[n];
        printf("%d\n",ans);
    }
    return 0;
}
accuracy: 1
time_ms: 270
memory_kb: 35720
final_rank: 19

code_snippet: #include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

#define NUM 11000

int main(){
	int table[NUM],limit,numTable[10001] = {0};

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int index = 0,primeTable[1230];

	for(int i = 2; i <= 9997; i++){
		if(table[i] == 1)primeTable[index++] = i;	//?´???°????¨????
	}

	int sum;
	for(int left = 0; left <= index-1; left++){ //??????????????????
		for(int div = 0; left + div <= index-1; div++){ //?????????????¶?????´???°????????°????????????
			sum = 0;
			for(int p = 0; p <= div; p++){
				sum += primeTable[left+p];
			}
			if(sum <= 10000)numTable[sum]++;
		}
	}

	int n;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		printf("%d\n",numTable[n]);
	}
	return 0;
}
accuracy: 1
time_ms: 110
memory_kb: 3280
final_rank: 15

code_snippet: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

bool era[100001]={false};

void makeERA(){
	for(int i=2;i<100001;i++){
		if(era[i]==true){
			int x=100000/i;
			for(int j=2;j<=x;j++){
				era[i*j]=false;
			}
		}
	}
	era[2]=true;
}


int main(){
	for(int i=0;i<100001;i++)era[i]=true;
	era[0]=false;era[1]=false;
	makeERA();
	
	vector<int> pr;
	pr.pb(0);
	rep(i,10001)if(era[i])pr.pb(i);

	for(int i=1;i<pr.size();i++){
		pr[i] +=pr[i-1];
	}

	int n;
	while(cin>>n&&n){
		int ans=0;
		rep(i,pr.size()){
			for(int j=i+1;j<pr.size();j++){
				if( pr[j]-pr[i]==n )ans++;
			}
		}
		cout<<ans<<endl;
	}
}
accuracy: 1
time_ms: 40
memory_kb: 3112
final_rank: 8

code_snippet: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

const int kN = 11000;

void primeNumber(bool prime[kN], vector<int> &p){
    rep(i,kN) prime[i] = 1;
    prime[0] = prime[1] = 0;
    rep(i,kN){
        if(prime[i]){
            p.push_back(i);
            for(int j = i + i; j < kN; j+=i){
                prime[j] = 0;
            }
        }
    }
}

int main(){
    bool prime[kN];
    vector<int> p;
    primeNumber(prime, p);

    int n;
    while(cin >> n, n){
        int ans = 0;
        for(int i = 0; p[i] <= n; i++){
            int sum = 0;
            for(int j = i; p[j] <= n; j++){
                sum+=p[j];
                if(sum == n){
                    ans++;
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 1240
final_rank: 1

code_snippet: #include<iostream>
#include<algorithm>
using namespace std;
int prime[2000];
int main(){
	int top=0;
	for(int i=2;i<10000;i++){
		bool ok=true;
		for(int j=0;j<top;j++)if(i%prime[j]==0)ok=false;
		if(ok){
			prime[top]=i;
			top++;
		}
	}
	int n;
	while(true){
		cin>>n;
		if(n==0)break;
		int ans=0;
		for(int i=0;i<top;i++){
			int cnt=prime[i];
			int k=i+1;
			while(true){
				if(cnt==n)ans++;
				if(cnt>=n)break;
				if(k==top)break;
				cnt+=prime[k];
				k++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 1164
final_rank: 5

code_snippet: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int sosu[10010]={1,1,0};
	for(int i=2;i<10010;i++)if(sosu[i]==0)
	for(int j=i*2;j<10010;j+=i)sosu[j]=true;
	
	vi dp(1);
	rep(i,10010)if(sosu[i]==0)dp.pb(i);
	rep(i,dp.size())dp[i+1]+=dp[i];
	map<int,int>m;
	rep(i,dp.size())loop(j,i+1,dp.size())m[dp[j]-dp[i]]++;
	int n;
	while(cin>>n,n){
		cout<<m[n]<<endl;
	}
}
accuracy: 1
time_ms: 290
memory_kb: 33760
final_rank: 20