s_id
string
p_id
string
u_id
string
date
string
language
string
original_language
string
filename_ext
string
status
string
cpu_time
string
memory
string
code_size
string
code
string
error
string
stdout
string
s202958068
p04013
u950708010
1556204546
Python
Python (3.4.3)
py
Runtime Error
2107
57460
564
def solve(): n,a = (int(i) for i in input().split()) x = list(int(i) for i in input().split()) tp = max(x) dp = [[[0 for i in range(n*tp +1)] for j in range(n+1)] for k in range(n+1)] query = a*n dp[0][0][0] = 1 for i in range(1,n+1): for j in range(n+1): for k in range(n*tp +1): #選ばない dp[i][j][k] = dp[i-1][j][k] if x[i-1] <= k and j > 0: dp[i][j][k] += dp[i-1][j-1][k-x[i-1]] ans = 0 for j in range(1,n+1): ans += dp[n][j][j*a] #print(dp) print(ans) solve()
Traceback (most recent call last): File "/tmp/tmpfq71dmct/tmpio6km_ji.py", line 27, in <module> solve() File "/tmp/tmpfq71dmct/tmpio6km_ji.py", line 2, in solve n,a = (int(i) for i in input().split()) ^^^^^^^ EOFError: EOF when reading a line
s185093054
p04013
u619458041
1556069113
Python
Python (3.4.3)
py
Runtime Error
18
2940
160
import sys def main(): input = sys.stdin.readline n = int(input()) s = int(input()) return ans if __name__ == '__main__': print(main())
Traceback (most recent call last): File "/tmp/tmpxh5b9fe1/tmp877oxi9t.py", line 12, in <module> print(main()) ^^^^^^ File "/tmp/tmpxh5b9fe1/tmp877oxi9t.py", line 5, in main n = int(input()) ^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: ''
s882406396
p04013
u227082700
1555470657
Python
Python (3.4.3)
py
Runtime Error
2107
54004
395
n,a=map(int,input().split()) x=list(map(int,input().split())) X=sum(x) dp=[[[0]*(X+1)for j in range(n+1)]for i in range(n+1)] dp[0][0][0]=1 for i in range(1,n+1): xi=x[i-1] for j in range(n+1): for h in range(X+1): if h<xi:dp[i][j][h]=dp[i-1][j][h] if xi<=h and j>=1:dp[i][j][h]=dp[i-1][j][h]+dp[i-1][j-1][h-xi] ans=0 for j in range(1,n+1):ans+=dp[n][j][j*a] print(ans)
Traceback (most recent call last): File "/tmp/tmp94_qa0u4/tmprjcfkon3.py", line 1, in <module> n,a=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s252634381
p04013
u268516119
1555008362
Python
Python (3.4.3)
py
Runtime Error
757
55028
664
#x枚目まででy枚選んで合計がzになる場合の数dp[x][y][z] N,A=map(int,input().split()) x=[int(i) for i in input().split()] dp=[[[0]*(A*N+1) for i in range(N+1)]for k in range(N+2)] ans=0 dp[0][0][0]=1 for made,i in enumerate(dp): if made>N:break for maisu,j in enumerate(i): for wa,k in enumerate(j): if k and made<=N:#made枚目までにmaisu枚選んでwaになる場合の数 dp[made+1][maisu][wa]+=k newwa=wa+x[made-1] if newwa<=A*N: dp[made+1][maisu+1][newwa]+=k for mai in range(1,N+1): a=dp[N][mai][mai*A] if a: ans+=a print(ans)
Traceback (most recent call last): File "/tmp/tmp0k0n8pr_/tmpouti8hby.py", line 2, in <module> N,A=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s809370876
p04013
u268516119
1555007625
Python
Python (3.4.3)
py
Runtime Error
754
56052
587
#x枚目まででy枚選んで合計がzになる場合の数dp[x][y][z] N,A=map(int,input().split()) x=[int(i) for i in input().split()] dp=[[[0]*(A*50) for i in range(N+2)]for k in range(N+2)] ans=0 dp[0][0][0]=1 for made,i in enumerate(dp): if made>N:break for maisu,j in enumerate(i): for wa,k in enumerate(j): if k:#made枚目までにmaisu枚選んでwaになる場合の数 dp[made+1][maisu][wa]+=k dp[made+1][maisu+1][wa+x[made-1]]+=k for mai in range(1,N+1): a=dp[N][mai][mai*A] if a: ans+=a print(ans)
Traceback (most recent call last): File "/tmp/tmpb0ei3pnu/tmp9ambiyxs.py", line 2, in <module> N,A=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s039556758
p04013
u360090862
1554572838
Python
Python (3.4.3)
py
Runtime Error
2109
61672
497
import numpy as np N,A=map(lambda x:int(x),input().split()) x=[int(i) for i in input().split()] dp=np.zeros((N+1,N+1,sum(x)+1)) def solve(j,k,s): if k==0 and j==0 and s==0: return 1 elif j>=1 and s<x[j-1] : dp[j,k,s]=solve(j-1,k,s) return dp[j,k,s] elif j>=1 and k>=1 and s>=x[j-1]: dp[j,k,s]=solve(j-1,k,s)+solve(j-1,k-1,s-x[j-1]) return dp[j,k,s] else: return 0 res=0 for i in range(1,N): solve(N,i,i*A) for i in range(N): res+=dp[N,i,i*A] print(int(res))
Traceback (most recent call last): File "/tmp/tmp7kv81d0m/tmpm31rxc_y.py", line 2, in <module> N,A=map(lambda x:int(x),input().split()) ^^^^^^^ EOFError: EOF when reading a line
s996634679
p04013
u013408661
1554504330
Python
Python (3.4.3)
py
Runtime Error
21
3188
292
n,a=map(int,input().split()) x=list(map(int,input())) stack=[0]*5001 stack[2500-a]=1 ans=0 for i in x: i-=a for i in x: ans+=stack[2500-i+a] stack2=[i for i in stack] for j in range(5001): if 0<=j+i<=5000: stack2[j+i]+=stack[j] stack=[i for i in stack2] print(stack[2500])
Traceback (most recent call last): File "/tmp/tmpykh0_dmh/tmp4yj3en29.py", line 1, in <module> n,a=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s825980711
p04013
u279493135
1554412627
Python
Python (3.4.3)
py
Runtime Error
245
5360
1068
from sys import stdin input = stdin.readline N, A = [int(x) for x in input().rstrip().split()] x = [int(x) for x in input().rstrip().split()] X = max(max(x), A) # dp = [[[0]*(N*X+1) for _ in range(N+1)] for _ in range(N+1)] # for j in range(N+1): # for k in range(N+1): # for s in range(N*X+1): # if j == 0 and k == 0 and s == 0: # dp[j][k][s] = 1 # elif j >= 1 and s < x[j-1]: # 探索先が総和より大きい # dp[j][k][s] = dp[j-1][k][s] # elif j >= 1 and k >= 1 and s >= x[j-1]: # dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]] # else: # dp[j][k][s] = 0 # sum = 0 # for i in range(1, N+1): # sum += dp[N][i][i*A] # print(sum) dp = [[0]*(2*N*X+1) for _ in range(N+1)] y = [0] * len(x) for i in range(len(x)): y[i] = x[i]-A for j in range(N+1): for t in range(2*N*X+1): if j == 0 and t == N*X: dp[j][t] = 1 elif j >= 1 and (t-y[j-1] < 0 or t-y[j-1] > 2*N*X): dp[j][t] = dp[j-1][t] elif dp[j-1][t] + dp[j-1][t-y[j-1]]: dp[j][t] = dp[j-1][t] + dp[j-1][t-y[j-1]] else: dp[j][t] = 0 print(dp[N][N*X]-1)
Traceback (most recent call last): File "/tmp/tmpmb64bf_g/tmpvo1shddj.py", line 4, in <module> N, A = [int(x) for x in input().rstrip().split()] ^^^^ ValueError: not enough values to unpack (expected 2, got 0)
s605302876
p04013
u315485238
1553974107
Python
Python (3.4.3)
py
Runtime Error
180
14328
361
import numpy as np N, A = list(map(int, input().split())) X = list(map(int, input().split())) dp = [np.array([[0]*(N*A+1) for _ in range(N+1)])] #dp[0]: [0, 0]~[N, N*A] for x in X: new_dp = dp[-1] new_dp[1:, x:] += dp[-1][0:N, 0:N*A+1-x] new_dp[1, x] += 1 dp.append(new_dp) #print(dp[-1]) print(sum([dp[-1][i, i*A] for i in range(1, N+1)]))
Traceback (most recent call last): File "/tmp/tmp32_0scus/tmpg0jb5ddx.py", line 3, in <module> N, A = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s413703386
p04013
u315485238
1553974044
Python
Python (3.4.3)
py
Runtime Error
181
14336
360
import numpy as np N, A = list(map(int, input().split())) X = list(map(int, input().split())) dp = [np.array([[0]*(N*A+1) for _ in range(N+1)])] #dp[0]: [0, 0]~[N, N*A] for x in X: new_dp = dp[-1] new_dp[1:, x:] += dp[-1][0:N, 0:N*A+1-x] new_dp[1, x] += 1 dp.append(new_dp) print(dp[-1]) print(sum([dp[-1][i, i*A] for i in range(1, N+1)]))
Traceback (most recent call last): File "/tmp/tmp25t39657/tmpx1o2ezno.py", line 3, in <module> N, A = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s591536146
p04013
u315485238
1553973860
Python
Python (3.4.3)
py
Runtime Error
179
14328
361
import numpy as np N, A = list(map(int, input().split())) X = list(map(int, input().split())) dp = [np.array([[0]*(N*A+1) for _ in range(N+1)])] #dp[0]: [0, 0]~[N, N*A] for x in X: new_dp = dp[-1] new_dp[1:, x:] += dp[-1][0:N, 0:N*A+1-x] new_dp[1, x] += 1 dp.append(new_dp) #print(dp[-1]) print(sum([dp[-1][i][i*A] for i in range(1, N+1)]))
Traceback (most recent call last): File "/tmp/tmph7c9j19g/tmpbdxu2li2.py", line 3, in <module> N, A = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s797950516
p04013
u315485238
1553973078
Python
Python (3.4.3)
py
Runtime Error
1067
65468
396
import numpy as np from scipy.ndimage.interpolation import shift N, A = list(map(int, input().split())) X = list(map(int, input().split())) dp = [np.array([[0]*(N*A+1) for _ in range(N+1)])] #dp[0]: [0][0]~[N][N*A] for x in X: new_dp = dp[-1] + shift(dp[-1], [1, x], cval=0) new_dp[1][x] += 1 dp.append(new_dp) #print(dp[-1]) print(sum([dp[-1][i][i*A] for i in range(1, N+1)]))
/tmp/tmp8b4quti9/tmp97ij6f94.py:2: DeprecationWarning: Please use `shift` from the `scipy.ndimage` namespace, the `scipy.ndimage.interpolation` namespace is deprecated. from scipy.ndimage.interpolation import shift Traceback (most recent call last): File "/tmp/tmp8b4quti9/tmp97ij6f94.py", line 4, in <module> N, A = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s614258534
p04013
u315485238
1553972773
Python
Python (3.4.3)
py
Runtime Error
1040
64504
394
import numpy as np from scipy.ndimage.interpolation import shift N, A = list(map(int, input().split())) X = list(map(int, input().split())) dp = [np.array([[0]*(N*A+1) for _ in range(N)])] for i in range(N): new_dp = dp[-1]+ shift(dp[-1], [1, X[i]], cval=0) new_dp[0][X[i]]=new_dp[0][X[i]]+1 dp.append(new_dp) #print(dp[-1]) print(sum([dp[-1][i-1][i*A] for i in range(1,N+1)]))
/tmp/tmpl0s70a3t/tmpiulp1vi2.py:2: DeprecationWarning: Please use `shift` from the `scipy.ndimage` namespace, the `scipy.ndimage.interpolation` namespace is deprecated. from scipy.ndimage.interpolation import shift Traceback (most recent call last): File "/tmp/tmpl0s70a3t/tmpiulp1vi2.py", line 4, in <module> N, A = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s161630694
p04013
u543954314
1553289471
Python
Python (3.4.3)
py
Runtime Error
21
3828
260
n,a = map(int,input().split()) dp = [[0]*2000 for _ in range(n+1)] dp[0][1000] = 1 x = list(map(int,input().split())) for i in range(n): x[i] -= a for i in range(1,n+1): for j in range(2001): dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i-1]] print(dp[n][1000])
Traceback (most recent call last): File "/tmp/tmp649fp7bu/tmpyozpa8v0.py", line 1, in <module> n,a = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s256183479
p04013
u185034753
1552795180
Python
Python (3.4.3)
py
Runtime Error
17
2940
670
#include<iostream> #include<vector> using namespace std; unsigned long long dp[51][51][2501]; int main(int argc, char const *argv[]) { int N, A; cin>>N>>A; vector<int> x(N+1); for(int i=0; i<N; i++) { cin >> x[i+1]; } dp[0][0][0] = 1; for(int j=1; j<=N; j++) { for(int k=0; k<=N; k++) { for(int s=0; s<=k*A; s++) { dp[j][k][s] += dp[j-1][k][s]; if(s >= x[j]) dp[j][k][s] += dp[j-1][k-1][s-x[j]]; } } } unsigned long long ans = 0; for(int k=1; k<=N; k++) ans += dp[N][k][k*A]; cout << ans << endl; return 0; }
File "/tmp/tmpw1dbblbp/tmp17waq6pu.py", line 4 using namespace std; ^^^^^^^^^ SyntaxError: invalid syntax
s832871118
p04013
u185034753
1552752694
Python
Python (3.4.3)
py
Runtime Error
2105
30688
817
def zeros(*dim): import copy if len(dim)==0: return 0 else: d = dim[0] a = zeros(*dim[1:]) return [copy.deepcopy(a) for _ in range(d)] def solve(a, A): a = sorted(a) N = len(a) S = sum(a) dp = zeros(N+1, N+1, S+1) a.insert(0, float("inf")) # add dummy at the head dp[0][0][0] = 1 for j in range(1, N+1): for k in range(0, N+1): for s in range(0, S+1): dp[j][k][s] += dp[j-1][k][s] if s >= a[j]: dp[j][k][s] += dp[j-1][k-1][s-a[j]] ans = 0 for k in range(1, N+1): ans += dp[N][k][k*A] return ans def main(): N, A = map(int,input().split()) a = [int(x) for x in input().split()] print(solve(a,A)) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpkilygnr1/tmpsc94vr8b.py", line 39, in <module> main() File "/tmp/tmpkilygnr1/tmpsc94vr8b.py", line 33, in main N, A = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s420912209
p04013
u030626972
1551591788
Python
Python (3.4.3)
py
Runtime Error
2107
56308
781
def main(): #入力 n, a = map(int,input().split()) x = [0] + list(map(int,input().split())) sum_max = (n)*(max(x))+1 #dp[i][j][k]:x1-xiからj枚選んで、合計をkにする選び方の数 dp = [[[0]*sum_max for _ in range(n+1)] for _ in range(n+1)] dp[0][0][0] = 1 for i in range(n+1): for j in range(n+1): for k in range(sum_max): #xi>kのとき if x[i]>k: dp[i][j][k] = dp[i-1][j][k] elif k>=1 and x[i-1]<=k: #xi<=kのとき dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i]] count = 0 for j in range(0,n+1): count += dp[n][j][j*a] print(count) if __name__ == "__main__": main()
Traceback (most recent call last): File "/tmp/tmpfd_1ea49/tmppw_vstd4.py", line 31, in <module> main() File "/tmp/tmpfd_1ea49/tmppw_vstd4.py", line 3, in main n, a = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s590085780
p04013
u887207211
1550980435
Python
Python (3.4.3)
py
Runtime Error
18
3064
302
N, A = map(int,input().split()) X = list(map(int,input().split())) X = [int(x) - A for x in input().split()] dp = [[0 for _ in range(100*N+1)] for _ in range(N+1)] dp[0][50*N] = 1 for i in range(N): for j in range(50, 100*N+1-50): dp[i+1][j] = dp[i][j] + dp[i][j - X[i]] print(dp[N][50*N] - 1)
Traceback (most recent call last): File "/tmp/tmplf1io9hg/tmprge2pldr.py", line 1, in <module> N, A = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s614999193
p04013
u762955009
1550293688
Python
Python (3.4.3)
py
Runtime Error
131
5748
389
N, A = map(int, input().split()) x = list(map(int, input().split())) y = list(map(lambda n:n-A, x)) X = max(x) dp = [[0 for i in range(2*X*N + 1)] for j in range(N + 1)] for i in range(1, N + 1): dp[i][y[i - 1] + N*X] += 1 for j in range(len(dp[0])): dp[i][j] += dp[i - 1][j] if dp[i - 1][j] > 0: dp[i][j + y[i - 1]] += dp[i - 1][j] print(dp[N][N*X])
Traceback (most recent call last): File "/tmp/tmp26bmiajt/tmpgz0fjuwq.py", line 1, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s554567361
p04013
u367130284
1549819723
Python
Python (3.4.3)
py
Runtime Error
22
3316
204
import collections as c n,a=map(int,input().split()) X=[int(x)-a for x in input().split()] C=c.Counter([0]) for x in X: itiji=Counter() for i,c in C.items(): itiji[i+x]+=c C+=itiji print(C[0]-1)
Traceback (most recent call last): File "/tmp/tmp540xy43u/tmpjm_gc4v4.py", line 2, in <module> n,a=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s409891608
p04013
u690536347
1548774168
Python
PyPy3 (2.4.0)
py
Runtime Error
427
92764
510
n,a=map(int,input().split()) *x,=map(int,input().split()) b=max(x) dp=[[[0]*(n*b+1) for i in range(n+1)] for _ in range(n+1)] for i in range(n+1): for j in range(n+1): for k in range(n*b+1): if i==0 and j==0 and k==0: dp[i][j][k]=1 elif i and k<x[i-1]: dp[i][j][k]=dp[i-1][j][k] elif i and j and k>=x[i-1]: dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]] v=0 for i in range(1,n+1): v+=dp[n][i][i*a] print(v)
Traceback (most recent call last): File "/tmp/tmp5ha_b8tx/tmpm4rgu4xd.py", line 1, in <module> n,a=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s083476123
p04013
u166696759
1548566635
Python
Python (3.4.3)
py
Runtime Error
18
2940
662
#include <bits/stdc++.h> using namespace std; int main(){ int N, A; cin >> N >> A; vector<int> cards(N); int maxX = -1*(1<<30); for(int i=0; i<N; ++i){ cin >> cards[i]; maxX = max(maxX, cards[i]); cards[i] -= A; } const int M = N * maxX; vector<vector<long long> > DP(N+1, vector<long long>(2*M+1, 0)); DP[0][M] = 1; for(int i=1; i<=N; ++i){ for(int j=0; j<2*M+1; ++j){ DP[i][j] += DP[i-1][j]; if(j-cards[i-1]>=0 and j-cards[i-1]<=2*M){ DP[i][j] += DP[i-1][j-cards[i-1]]; } } } cout << DP[N][M] -1 << endl; return 0; }
File "/tmp/tmpki0578oo/tmpim_iskvg.py", line 2 using namespace std; ^^^^^^^^^ SyntaxError: invalid syntax
s012863654
p04013
u171366497
1547692162
Python
Python (3.4.3)
py
Runtime Error
85
3976
1225
N,A=map(int,input().split()) x=input().split() for i in range(N): x[i]=int(x[i]) ans=0 y=[0 for i in range(N)] def check(ans,y): ave=0 for i in range(N): ave+=x[i]*y[i] if sum(y)!=0: ave=ave/sum(y) if sum(y)==0: ave=0 if ave==A:ans+=1 return ans def branch(ans,now,pre,y): if now==0 and pre==-1: if y[now]==0: y[now]=1 now+=1 pre=1 ans,now,pre=branch(ans,now,pre,y) elif y[now]==1: return ans,now,pre elif now==N-1: ans,now,pre=last(ans,now,pre,y) ans,now,pre=branch(ans,now,pre,y) elif now!=0 and pre==-1: if y[now]==0: y[now]=1 pre=1 now+=1 ans,now,pre=branch(ans,now,pre,y) elif y[now]==1: y[now]=0 now-=1 ans,now,pre=branch(ans,now,pre,y) elif pre==1 and now!=N-1: now+=1 ans,now,pre=branch(ans,now,pre,y) return ans,now,pre def last(ans,now,pre,y): y[-1]=0 ans = check(ans,y) y[-1]=1 ans = check(ans,y) y[-1]=0 pre=-1 now-=1 return ans,now,pre now=0 pre=1 ans,now,pre=branch(ans,now,pre,y) print(ans)
Traceback (most recent call last): File "/tmp/tmpghk_fq2g/tmpd7z3m_yp.py", line 1, in <module> N,A=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s958671899
p04013
u550943777
1547615958
Python
Python (3.4.3)
py
Runtime Error
2108
54004
615
N,A = map(int,input().split()) x = [0] + list(map(int,input().split())) X = max(x) dp = [[[0]*(N*X+1) for k in range(N+1)] for j in range(N+1)] for j in range(N+1): for k in range(N+1): for s in range(N*X+1): if j == 0 and k == 0 and s == 0 : dp[j][k][s] = 1 elif j >= 1 and s < x[j]: dp[j][k][s] = dp[j-1][k][s] elif j >= 1 and k >= 1 and s >= x[j]: dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]] else: dp[j][k][s] = 0 ans = 0 for k in range(1,N+1): ans += dp[N][k][k*A] print(ans)
Traceback (most recent call last): File "/tmp/tmpd081yeak/tmpir0mikm9.py", line 1, in <module> N,A = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s503067161
p04013
u052332717
1545869973
Python
Python (3.4.3)
py
Runtime Error
1295
62960
429
n, a = map(int, input().split()) x = list(map(int, input().split())) M = max(x) dp = [[[0]*(n*M+1) for _ in range(n+1)] for _ in range(n+1)] dp[0][0][0] = 1 for j in range(n): for k in range(n+1): for s in range(n*M+1): if dp[j][k][s]: dp[j+1][k][s] += dp[j][k][s] dp[j+1][k+1][s + x[j]] += dp[j][k][s] ans = 0 for k in range(1, n+1): ans += dp[n][k][k*a] print(ans)
Traceback (most recent call last): File "/tmp/tmpayrorp4r/tmppbua7nzl.py", line 1, in <module> n, a = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s760675121
p04013
u052332717
1545869919
Python
Python (3.4.3)
py
Runtime Error
1431
62960
429
n, a = map(int, input().split()) x = list(map(int, input().split())) M = max(x) dp = [[[0]*(n*M+1) for _ in range(n+1)] for _ in range(n+1)] dp[0][0][0] = 1 for j in range(n): for k in range(n+1): for s in range(n*M+1): if dp[j][k][s]: dp[j+1][k][s] += dp[j][k][s] dp[j+1][k+1][s + x[j]] += dp[j][k][s] ans = 0 for k in range(1, n+1): ans += dp[n][k][k*a] print(ans)
Traceback (most recent call last): File "/tmp/tmpzb0jbykw/tmp0e1ntlym.py", line 1, in <module> n, a = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s878917025
p04013
u052332717
1545865235
Python
Python (3.4.3)
py
Runtime Error
219
5356
801
N, A = map(int, input().split()) X = list(map(lambda x: int(x) - A, input().split())) maxn = max(max(X), A) dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)] dp[0][N * maxn] = 1 for i in range(N): for k in range(2 * N * maxn + 1): dp[i + 1][k] = dp[i][k] if 0 <= k - X[i] <= 2 * N * maxn: dp[i + 1][k] += dp[i][k - X[i]] print(dp[N][N * maxn] - 1) N, A = map(int, input().split()) X = list(map(lambda x: int(x) - A, input().split())) maxn = max(max(X), A) dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)] dp[0][N * maxn] = 1 for i in range(N): for k in range(2 * N * maxn + 1): dp[i + 1][k] = dp[i][k] if 0 <= k - X[i] <= 2 * N * maxn: dp[i + 1][k] += dp[i][k - X[i]] print(dp[N][N * maxn] - 1)
Traceback (most recent call last): File "/tmp/tmp2ro8ehrb/tmp5h362i4k.py", line 1, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s875354580
p04013
u052332717
1545865199
Python
Python (3.4.3)
py
Runtime Error
221
7284
800
N, A = map(int, input().split()) X = list(map(lambda x: int(x) - A, input().split())) maxn = max(max(X), A) dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)] dp[0][N * maxn] = 1 for i in range(N): for k in range(2 * N * maxn + 1): dp[i + 1][k] = dp[i][k] if 0 <= k - X[i] <= 2 * N * maxn: dp[i + 1][k] += dp[i][k - X[i]] print(dp[N][N * maxn] - 1) N, A = map(int, input().split()) X = list(map(lambda x: int(x) - A, input().split())) maxn = max(max(X), A) dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)] dp[0][N * maxn] = 1 for i in range(N): for k in range(2 * N * maxn + 1): dp[i + 1][k] = dp[i][k] if 0 <= k - X[i] < 2 * N * maxn: dp[i + 1][k] += dp[i][k - X[i]] print(dp[N][N * maxn] - 1)
Traceback (most recent call last): File "/tmp/tmpjavidlf3/tmp4r7qp3n8.py", line 1, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s162041917
p04013
u643840641
1545572017
Python
Python (3.4.3)
py
Runtime Error
2107
56436
425
n, a = map(int, input().split()) x = list(map(int, input().split())) sum = sum(x) dp = [[[0 for s in range(sum+1)] for k in range(n+1)] for i in range(n+1)] dp[0][0][0] = 1 for i in range(1, n+1): for k in range(n+1): for s in range(sum+1): if s >= x[i-1]: dp[i][k][s] = dp[i-1][k][s] + dp[i-1][k-1][s-x[i-1]] else: dp[i][k][s] = dp[i-1][k][s] ans = 0 for k in range(1, n+1): ans += dp[n][k][k*a] print(ans)
Traceback (most recent call last): File "/tmp/tmpgj0fweon/tmph7yeg_kg.py", line 1, in <module> n, a = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s485028008
p04013
u782098901
1545404381
Python
Python (3.4.3)
py
Runtime Error
2107
58356
513
N, A = map(int, input().split()) # X = list(map(lambda x: int(x) - A, input().split())) X = list(map(int, input().split())) dp = [[[0 for _ in range(max(X) * N + 1)] for _ in range(N + 1)] for _ in range(N + 1)] dp[0][0][0] = 1 for i in range(N): for j in range(N): for k in range(max(X) * N + 1): dp[i + 1][j][k] += dp[i][j][k] if k >= X[i]: dp[i + 1][j + 1][k] += dp[i][j][k - X[i]] ans = 0 for j in range(1, N + 1): ans += dp[N][j][j * A] print(ans)
Traceback (most recent call last): File "/tmp/tmpilrwy26s/tmpt4h8sxl2.py", line 1, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s033000812
p04013
u140251125
1543514577
Python
Python (3.4.3)
py
Runtime Error
36
3444
592
import collections # input n, a = map(int, input().split()) X = [int(i) - a for i in input().split()] S = collections.Counter([0, X[0]]) # Xから1枚以上選んで作ることが可能な和:作り方の場合の数 # 1枚も選ばない=0:1通り # X[0]のみ選ぶ=X[0]:1通り for i in X[1:]: # 選べるカードを増やしていく (X[0] ~ X[i] から選ぶ) S_temp = collections.Counter() for s, c in S.items(): S_temp[s + i] += c # X[0] ~ X[i - 1] で作れる和に X[i] を足す sums += sums2 print(S[0] - 1) # 1枚も選ばないのはルール違反
Traceback (most recent call last): File "/tmp/tmpe_6tchsu/tmpgzos_mp7.py", line 4, in <module> n, a = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s774584993
p04013
u297109012
1540699413
Python
Python (3.4.3)
py
Runtime Error
2108
3064
963
import math from itertools import combinations def solve(N, A, Xs): diffs = [x - A for x in Xs] minus = [d for d in diffs if d < 0] minuses = {} plus = [d for d in diffs if d > 0] pluses = {} zero = [d for d in diffs if d == 0] for n in range(1, len(minus) + 1): for ns in combinations(minus, n): s = sum(ns) minuses.setdefault(s, 0) minuses[s] += 1 for n in range(1, len(plus) + 1): for ns in combinations(plus, n): s = sum(ns) pluses.setdefault(s, 0) pluses[s] += 1 def nCr(n, r): f = math.factorial return f(n) // f(r) // f(n - r) z = sum([nCr(len(zero), r) for r in range(len(zero))]) c = 0 for m in minuses: c += pluses[-m] * (z + 1) c += z return c if __name__ == "__main__": N, A = map(int, input().split(" ")) Xs = map(int, input().split(" ")) print(solve(N, A, Xs))
Traceback (most recent call last): File "/tmp/tmpe2fn3koh/tmp17v2t15s.py", line 38, in <module> N, A = map(int, input().split(" ")) ^^^^^^^ EOFError: EOF when reading a line
s274022112
p04013
u474270503
1538250242
Python
Python (3.4.3)
py
Runtime Error
18
3064
501
N,A=map(int, input().split()) x=[int(x) for x in input().split()] sort(x) W=sum(x) dp=[[[0]*(W+1) for _ in range(N+1)] for _ in range(N+1)] for j in range(N+1): dp[j][0][0]=1 for j in range(1,N+1): xj=x[j-1] for k in range(1, N+1): for s in range(1, W+1): if s<xj: dp[j][k][s]=dp[j-1][k][s] else: dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-xj] ans=0 for k in range(1,N+1): if k*A<=W: ans+=dp[N][k][k*A] print(ans)
Traceback (most recent call last): File "/tmp/tmp9snntd3z/tmpeufu02do.py", line 1, in <module> N,A=map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s587645999
p04013
u474270503
1538248868
Python
Python (3.4.3)
py
Runtime Error
2107
58484
618
N,A=map(int, input().split()) x=list(map(int, input().split())) dp=[] for _ in range(N+1): dp.append([[0 for _ in range(N*max(x)+1)] for _ in range(N+1)]) for j in range(0,N+1): for k in range(0, N+1): for s in range(0, N*max(x)+1): if j>=1 and s<x[j-1]: dp[j][k][s]=dp[j-1][k][s] elif j>=1 and k>=1 and s>=x[j-1]: dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j-1]] elif j==0 and k==0 and s==0: dp[0][0][0]=1 else: dp[j][k][s]=0 ans=0 for k in range(1,N+1): ans+=dp[N][k][k*A] print(ans)
Traceback (most recent call last): File "/tmp/tmpo6t__2w2/tmp06wnp75y.py", line 1, in <module> N,A=map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s567728053
p04013
u474270503
1538248645
Python
Python (3.4.3)
py
Runtime Error
2107
56436
614
N,A=map(int, input().split()) x=list(map(int, input().split())) dp=[] for _ in range(N+1): dp.append([[0 for _ in range(sum(x)+1)] for _ in range(N+1)]) for j in range(0,N+1): for k in range(0, N+1): for s in range(0, sum(x)+1): if j>=1 and s<x[j-1]: dp[j][k][s]=dp[j-1][k][s] elif j>=1 and k>=1 and s>=x[j-1]: dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j-1]] elif j==0 and k==0 and s==0: dp[0][0][0]=1 else: dp[j][k][s]=0 ans=0 for k in range(1,N+1): ans+=dp[N][k][k*A] print(ans)
Traceback (most recent call last): File "/tmp/tmpc2tetabo/tmpsan1wfc1.py", line 1, in <module> N,A=map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s799924492
p04013
u611249982
1537191911
Python
Python (3.4.3)
py
Runtime Error
2107
58484
472
n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] nx = n * max(max(x), a) dp = [[[0 for k in range(nx + 1)] for j in range(n + 1)] for i in range(n + 1)] dp[0][0][0] = 1 for i in range(n): for j in range(n): for k in range(nx): if k + x[j] <= n * a: dp[i + 1][j + 1][k + x[i]] += dp[i][j][k] dp[i + 1][j][k] += dp[i][j][k] ans = sum([dp[n][k][k * a] for k in range(1, n + 1)]) print(ans)
Traceback (most recent call last): File "/tmp/tmpmazqymlm/tmp6mjg275b.py", line 1, in <module> n, a = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s101066790
p04013
u957084285
1534446698
Python
Python (3.4.3)
py
Runtime Error
177
4980
358
n,a = map(int, input().split()) x = list(map(lambda x:int(x)-a, input().split())) y = max(x) dp = [[0]*(2*n*y+1) for _ in range(n+1)] dp[0][n*y] = 1 for k in range(n): for i in range(2*n*y+1): if i+x[k] < 0 or i+x[k] > 2*n*y: dp[k+1][i] = dp[k][i] else: dp[k+1][i] = dp[k][i] + dp[k][i+x[k]] print(dp[-1][n*y]-1)
Traceback (most recent call last): File "/tmp/tmp4ylrm48x/tmp5teqqi10.py", line 1, in <module> n,a = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s905167957
p04013
u690536347
1534265881
Python
Python (3.4.3)
py
Runtime Error
2107
58484
522
n,a=map(int,input().split()) l=list(map(int,input().split())) x=max(l) dp=[[[0 for _ in range(n*x+1)] for _ in range(n+1)] for _ in range(n+1)] for j in range(n+1): for k in range(n+1): for s in range(n*x+1): if j==0 and k==0 and s==0: dp[j][k][s]=1 elif j>=1 and s<l[j-1]: dp[j][k][s]=dp[j-1][k][s] elif j>=1 and k>=1 and s>=l[j-1]: dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-l[j-1]] else: dp[j][k][s]=0 s=0 for k in range(1,n+1): s+=dp[n][k][k*a] print(s)
Traceback (most recent call last): File "/tmp/tmpn01onvzt/tmp7isp8a61.py", line 1, in <module> n,a=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s627119270
p04013
u562935282
1534093390
Python
Python (3.4.3)
py
Runtime Error
2107
59760
662
def ary3(x, y, z, v): return [[[v for _ in range(z)] for _ in range(y)] for _ in range(x)] n, a = map(int, input().split()) x = list(map(int, input().split())) m = max(x) dp = ary3(n + 1, n + 1, m * n + 1, 0)#(選べる枚数(範囲)0 ~ n, 選んだ枚数0 ~ n, 合計0 ~ n * max(x)) = パターン数 for i in range(n + 1): dp[i][0][0] = 1 for i in range(1, n + 1): for j in range(1, i + 1): for s in range(m * n + 1): if s + x[i - 1] < m * n + 1: dp[i][j][s + x[i-1]] += dp[i - 1][j - 1][s] dp[i][j][s] += dp[i - 1][j][s] ans = 0 for j in range(1, n + 1): ans += dp[n][j][j * a] print(ans)
Traceback (most recent call last): File "/tmp/tmpdf2munrt/tmpb6cbtd0k.py", line 3, in <module> n, a = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s497314873
p04013
u439396449
1532405387
Python
Python (3.4.3)
py
Runtime Error
2109
58612
537
from itertools import product N, A = map(int, input().split()) x = [int(x) for x in input().split()] max_x = max(max(x), A) dp = [[[0 for _ in range(N * max_x)] for _ in range(N + 1)] for _ in range(N + 1)] dp[0][0][0] = 1 for j, k, s in product(range(1, N + 1), range(N + 1), range(N * max_x)): if s < x[j - 1]: dp[j][k][s] = dp[j - 1][k][s] elif k >= 1 and s >= x[j - 1]: dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]] ans = 0 for k in range(1, N + 1): ans += dp[N][k][k * A] print(ans)
Traceback (most recent call last): File "/tmp/tmp92tfhx3z/tmp36k1hr69.py", line 3, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s899198357
p04013
u439396449
1532404449
Python
Python (3.4.3)
py
Runtime Error
2107
56564
557
N, A = map(int, input().split()) x = [int(x) for x in input().split()] max_x = max(x) dp = [[[0 for _ in range((N + 1) * max_x)] for _ in range(N + 1)] for _ in range(N + 1)] dp[0][0][0] = 1 for j in range(1, N + 1): for k in range(N + 1): for s in range((N + 1) * max_x): if s < x[j - 1]: dp[j][k][s] = dp[j - 1][k][s] elif k >= 1 and s >= x[j - 1]: dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]] ans = 0 for k in range(1, N + 1): ans += dp[N][k][k * A] print(ans)
Traceback (most recent call last): File "/tmp/tmp4h9fcety/tmp49kymq03.py", line 1, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s096371942
p04013
u415905784
1532404188
Python
Python (3.4.3)
py
Runtime Error
18
3064
699
import heapq N, A = map(int, input().split()) X = [int(x) - A for x in input().split()] for x in X: if x > 0: Xp.append(x) elif x < 0: Xm.append(-x) else: X0.append(x) limit = min(sum(Xp), sum(Xm)) Xp = [x for x in Xp if x <= limit] Xm = [x for x in Xm if x <= limit] R = [[0, 0] for x in range(limit + 1)] def c(X, k): Q = [] heapq.heappush(Q, 0) for x in X: _Q = [] while Q: q = heapq.heappop(Q) if q > limit: break heapq.heappush(_Q, q) heapq.heappush(_Q, q + x) Q = _Q while Q: q = heapq.heappop(Q) if q > limit: break R[q][k] += 1 c(Xp, 0) c(Xm, 1) print(sum([r[0] * r[1] for r in R]) * (2 ** len(X0)) - 1)
Traceback (most recent call last): File "/tmp/tmpi7p6igon/tmprpz06k6w.py", line 2, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s557245995
p04013
u136090046
1532215255
Python
Python (3.4.3)
py
Runtime Error
17
2940
933
import itertools↲ ↲ n, a = map(int, input().split())↲ array = [int(x) for x in input().split()]↲ ↲ array2 = []↲ tmp = 0↲ for i in array:↲ tmp += i↲ array2.append(tmp)↲ ↲ ans = 0↲ for pickup in range(1, n+1):↲ tmp_gen = itertools.combinations(array, pickup)↲ for i in tmp_gen:↲ if sum(i) == a*pickup:↲ ans += 1↲ print(ans)↲
File "/tmp/tmptmlnpdyq/tmptuz4hxpg.py", line 1 import itertools↲ ^ SyntaxError: invalid character '↲' (U+21B2)
s905299871
p04013
u118605645
1531064254
Python
Python (3.4.3)
py
Runtime Error
2213
1810060
656
import itertools def get_all_comb(ary): r = [] for i in range(1, len(ary) + 1): r += list(itertools.combinations(ary, i)) return r N, A = (int(s) for s in input().split()) X = [int(s) for s in input().split()] lowers = [] i = 0 while X[i] < A: lowers.append((X[i])) i += 1 lowers = [x for x in X if x <= A] uppers = [x for x in X if x > A] sames = [x for x in X if x == A] lowers_comb = get_all_comb(lowers) uppers_comb = get_all_comb(uppers) cnt = 0 for l in lowers_comb: for u in uppers_comb: avg = (sum(l) + sum(u)) / (len(l) + len(u)) if avg == A: cnt += 1 cnt += len(sames) print(cnt)
Traceback (most recent call last): File "/tmp/tmpud9u4dj7/tmpryg3kzzt.py", line 9, in <module> N, A = (int(s) for s in input().split()) ^^^^^^^ EOFError: EOF when reading a line
s168093638
p04013
u559823804
1528951024
Python
Python (3.4.3)
py
Runtime Error
2107
56436
449
n,a=map(int,input().split()) x=list(map(int,input().split())) X=max(x) X=max(X,a) dp=[[[0 for _ in range(n*X+1)] for _ in range(51)] for _ in range(51)] dp[0][0][0]=1 for j in range(n): for k in range(n+1): for s in range(n*X+1): dp[j+1][k][s]+=dp[j][k][s] if x[j]+s<n*X+1: dp[j+1][k+1][s+x[j]]+=dp[j][k][s] ans=0 for k in range(1,n+1): ans+=dp[n][k][k*a] print(ans)
Traceback (most recent call last): File "/tmp/tmpjegfwsa2/tmp755wow7r.py", line 1, in <module> n,a=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s162908411
p04013
u846150137
1527121940
Python
Python (3.4.3)
py
Runtime Error
17
2940
375
n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] dp=[[0 for i in range(a*n+1)] for j in range(n+1)] dp[0][0]=1 ans=0 f=0 for k in range(1,n+1): kx=x[k-1] f+=kx for i in range(k,0,-1): for j in range(kx,a*n+1): dp[i][j] += dp[i-1][j-kx] if j > f: break for i in range(1,n+1): ans+=dp[i][a*i] print(ans)
File "/tmp/tmpmxx8jdxl/tmpze5fvtq6.py", line 1 n, a = [int(i) for i in input().split()] IndentationError: unexpected indent
s487406936
p04013
u846150137
1527121236
Python
Python (3.4.3)
py
Runtime Error
2109
14680
435
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] sx=sum(x) dp= np.zeros((n+1,sx+1),dtype='int32') #dp=[[0]*(n*a+1)]*(n+1) dp[0][0]=1 ans=0 f=0 for k in range(1,n+1): kx=x[k-1] f+=kx for i in range(k,0,-1): for j in range(kx,sx+1): dp[i][j] += dp[i-1][j-kx] if j > f: break for i in range(1,n+1): if i >=sx: break ans+=dp[i][a*i] print(ans)
Traceback (most recent call last): File "/tmp/tmpze9xtp72/tmp7gd1prmv.py", line 2, in <module> n, a = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s610245692
p04013
u846150137
1527111339
Python
Python (3.4.3)
py
Runtime Error
2109
14568
425
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] dp= np.zeros((n+1,n*a+1),dtype=int) dp[0][0]=1 ans=0 f=0 for k in range(1,n+1): f+=x[k-1] for i in range(k,-1,-1): for j in range(0, f + 1): if j>=x[k-1] and i>=1: dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]] else: dp[i][j]= dp[i][j] for i in range(1,n+1): ans+=dp[i][a*i] print(ans)
Traceback (most recent call last): File "/tmp/tmp4vg2s74h/tmp7lzdt8e9.py", line 2, in <module> n, a = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s883552179
p04013
u846150137
1527111045
Python
Python (3.4.3)
py
Runtime Error
1633
13160
428
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] sx=sum(x) dp= np.zeros((n+1,n*a+1),dtype=int) dp[0][0]=1 ans=0 f=0 for k in range(1,n+1): f+=k for i in range(k,-1,-1): for j in range(0, f + 1): if j>=x[k-1] and i>=1: dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]] else: dp[i][j]= dp[i][j] for i in range(1,n+1): ans+=dp[i][a*i] print(ans)
Traceback (most recent call last): File "/tmp/tmp_8v3ok1x/tmp95_gtjdq.py", line 2, in <module> n, a = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s102090630
p04013
u846150137
1527110933
Python
Python (3.4.3)
py
Runtime Error
2108
13040
422
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] sx=sum(x) dp= np.zeros((n+1,n*a+1),dtype=int) dp[0][0]=1 ans=0 for k in range(1,n+1): for i in range(k,-1,-1): for j in range(0, sx * n + 1): if j>=x[k-1] and i>=1: dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]] else: dp[i][j]= dp[i][j] for i in range(1,n+1): ans+=dp[i][a*i] print(ans)
Traceback (most recent call last): File "/tmp/tmpw_mhkvcf/tmp472qfh1z.py", line 2, in <module> n, a = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s067346679
p04013
u846150137
1527110137
Python
Python (3.4.3)
py
Runtime Error
18
3064
419
n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] dp= np.zeros((n+1,n+1,n*a+1),dtype=int) dp[0][0][0]=1 ans=0 for k in range(1,n+1): for i in range(0,k+1): for j in range(0,a * i+1): if j>=x[k-1] and i>=1: dp[k][i][j]= dp[k-1][i][j] + dp[k-1][i-1][j-x[k-1]] else: dp[k][i][j]= dp[k-1][i][j] for i in range(1,n+1): ans+=dp[n][i][a*i] print(ans)
Traceback (most recent call last): File "/tmp/tmpavstzl3u/tmpx7pjdrz5.py", line 1, in <module> n, a = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s212831457
p04013
u846150137
1527109788
Python
Python (3.4.3)
py
Runtime Error
151
12452
405
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] dp= np.zeros((n+1,s*n+1),dtype=int) dp[0][0]=1 ans=0 for k in range(1,n+1): for i in range(0,k+1): for j in range(0,s*n+1): if j>=x[k-1] and i>=1: dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]] else: dp[i][j]= dp[i][j] for i in range(1,n+1): ans+=dp[i][a*i] print(ans)
Traceback (most recent call last): File "/tmp/tmppg9pwu4f/tmpg9oiqrut.py", line 2, in <module> n, a = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s170046804
p04013
u846150137
1527109705
Python
Python (3.4.3)
py
Runtime Error
149
14500
419
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] xs=sum(x) dp= np.zeros((n+1,xs*n+1),dtype=int) dp[0][0][0]=1 ans=0 for k in range(1,n+1): for i in range(0,k+1): for j in range(0,xs*n+1): if j>=x[k-1] and i>=1: dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]] else: dp[i][j]= dp[i][j] for i in range(1,n+1): ans+=dp[i][a*i] print(ans)
Traceback (most recent call last): File "/tmp/tmp1cuzyiaz/tmpsgssq3r5.py", line 2, in <module> n, a = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s924128898
p04013
u846150137
1527109599
Python
Python (3.4.3)
py
Runtime Error
2108
37092
447
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] xs=sum(x) dp= np.zeros((n+1,n+1,xs*n+1),dtype=int) dp[0][0][0]=1 ans=0 for k in range(1,n+1): for i in range(0,k+1): for j in range(0,xs*n+1): if j>=x[k-1] and i>=1: dp[k][i][j]= dp[k-1][i][j] + dp[k-1][i-1][j-x[k-1]] else: dp[k][i][j]= dp[k-1][i][j] for i in range(1,n+1): ans+=dp[n][i][a*i] print(ans)
Traceback (most recent call last): File "/tmp/tmptbth7bmu/tmpyxx_447g.py", line 2, in <module> n, a = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s194897703
p04013
u846150137
1527109542
Python
Python (3.4.3)
py
Runtime Error
2108
36964
446
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] xs=sum(x) dp= np.zeros((n+1,n+1,n*a+1),dtype=int) dp[0][0][0]=1 ans=0 for k in range(1,n+1): for i in range(0,k+1): for j in range(0,xs*n+1): if j>=x[k-1] and i>=1: dp[k][i][j]= dp[k-1][i][j] + dp[k-1][i-1][j-x[k-1]] else: dp[k][i][j]= dp[k-1][i][j] for i in range(1,n+1): ans+=dp[n][i][a*i] print(ans)
Traceback (most recent call last): File "/tmp/tmpvgf6kci1/tmp9fn9i8l6.py", line 2, in <module> n, a = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s966918474
p04013
u503901534
1526621094
Python
Python (3.4.3)
py
Runtime Error
18
3064
758
s = int(input()) sl = list(str(s)) sl_n = len(sl) - 1 l = ['a','b'] def a_or_b(x): if len(list(str(x[0]))) == sl_n: return x else: ll = [] for i in range(len(x)): ll.append(x[i] + 'a') for i in range(len(x)): ll.append(x[i] + 'b') x = ll return a_or_b(x) lll = [] ans = 0 if len(sl) == 1: ans = s else: lll = a_or_b(l) kkk = [] for i in range(len(lll)): p = sl q = list(str(lll[i])) st = '' for j in range(len(p) - 1): if q[j] == 'a': st = st + p[j] +'+' else: st = st + p[j] + '' st = st + sl[-1] res = eval(st) ans += res print(ans)
Traceback (most recent call last): File "/tmp/tmpax0xmdzz/tmpsw__2pkw.py", line 1, in <module> s = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s536350045
p04013
u503901534
1525486911
Python
Python (3.4.3)
py
Runtime Error
17
2940
435
n, a = map(int,input().split()) x = list(map(int,input().split())) xx = [] for i in range(n): xx.append(x-a) X = max(xx) #dp def dp(j,t,l=xx): if j = 0 and t = n * X: return 1 elif j > 0 and t -l[j] < 0 or t- l[j] > 2* n * X: return dp(j-1,t,l=xx) elif j > 1 and 0 <= t-l[j] <= 2*n*X: return dp(j-1,t,l = xx) + dp(j-1,t-l[j],l = xx) else: return 0 print(dp(n,n*X,l=xx) - 1)
File "/tmp/tmphsyyvb6l/tmprlr_mkz1.py", line 10 if j = 0 and t = n * X: ^^^^^ SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
s559823355
p04013
u667024514
1524843790
Python
Python (3.4.3)
py
Runtime Error
17
3064
373
n = int(input()) a = sorted(map(int,input().split())) b = sorted(map(int,input().split())) c = sorted(map(int,input().split())) lis = [0] * n j = 0 for i in range(n): while j < n and a[j] < b[i]: j += 1 lis[i] = j li = [0] * n m = 0 j = 0 for i in range(n): while j < n and b[j] < c[i]: m += lis[j] j += 1 li[i] = m print(sum(li))
Traceback (most recent call last): File "/tmp/tmphlm4c828/tmpebniypfa.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s269193579
p04013
u125205981
1524438201
Python
Python (3.4.3)
py
Runtime Error
181
4980
568
def main(): N, A = map(int, input().split()) X = tuple(map(int, input().split())) x = [i - A for i in X] nx = max(x) * N dp = [[0] * (2 * nx + 1) for _ in [0] * (N + 1)] for i in range(N + 1): for j in range(2 * nx + 1): if not i: if j == nx: dp[i][j] = 1 elif j - x[i-1] < 0 or j - x[i-1] > 2 * nx: dp[i][j] = dp[i-1][j] elif 0 <= j - x[i-1] <= 2 * nx: dp[i][j] = dp[i-1][j] + dp[i-1][j - x[i-1]] print(dp[N][nx] - 1) main()
Traceback (most recent call last): File "/tmp/tmps3smv6t5/tmp4vmjlb8_.py", line 19, in <module> main() File "/tmp/tmps3smv6t5/tmp4vmjlb8_.py", line 2, in main N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s810024471
p04013
u281303342
1524340107
Python
Python (3.4.3)
py
Runtime Error
2107
58484
617
N,A = map(int,input().split()) X = [0]+list(map(int,input().split())) sumX = sum(X) dp = [[[0 for _ in range(sumX+1)] for _ in range(N+1)] for _ in range(N+1)] dp[0][0][0] = 1 for i in range(1,N+1): for j in range(0,i+1): for k in range(sum(X)+1): if j==0 and k==0: dp[i][j][k] = 1 elif k < X[i]: dp[i][j][k] = dp[i-1][j][k] elif j > 0 and k >= X[i]: dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i]] if max(X) < A: print(0) else: Ans = 0 for i in range(1,N+1): Ans += dp[N][i][A*i] print(Ans)
Traceback (most recent call last): File "/tmp/tmpqbmork48/tmpjj4iu05g.py", line 1, in <module> N,A = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s043980293
p04013
u281303342
1524339557
Python
Python (3.4.3)
py
Runtime Error
2107
61680
570
N,A = map(int,input().split()) X = [0]+list(map(int,input().split())) maxX = max(X) dp = [[[0 for _ in range(N*maxX+1)] for _ in range(N+1)] for _ in range(N+1)] dp[0][0][0] = 1 for i in range(1,N+1): for j in range(0,i+1): for k in range(N*maxX+1): if j==0 and k==0: dp[i][j][k] = 1 elif k < X[i]: dp[i][j][k] = dp[i-1][j][k] elif j > 0 and k >= X[i]: dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i]] Ans = 0 for i in range(1,N+1): Ans += dp[N][i][A*i] print(Ans)
Traceback (most recent call last): File "/tmp/tmpi_9t6fe3/tmpu7c0c83a.py", line 1, in <module> N,A = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s453971103
p04013
u075012704
1524276566
Python
Python (3.4.3)
py
Runtime Error
2108
54772
478
N, A = map(int, input().split()) X = list(map(int, input().split())) x_max = max(X) dp = [[[0]*(N*x_max+1) for i in range(N+1)] for i in range(N+1)] dp[0][0][0] = 1 for j in range(1, N+1): for k in range(N+1): for s in range(N*x_max+1): if X[j-1] <= s: dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-X[j-1]] else: dp[j][k][s] = dp[j-1][k][s] ans = 0 for i in range(1, N+1): ans += dp[N][i][A*i] print(ans)
Traceback (most recent call last): File "/tmp/tmp7fvqeqk0/tmp5m75e59m.py", line 1, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s535561228
p04013
u952708174
1522618062
Python
Python (3.4.3)
py
Runtime Error
18
3060
419
def c_atcodeer_and_election_report(N, R): from math import ceil t = 1 # 高橋の票数 a = 1 # 青木の票数 for x, y in R: # t<=nx ∧ a<=ny を満たす最小のnを求める n = max(ceil(t / x), ceil(a / y)) t = n * x a = n * y return t + a N = int(input()) R = [[int(i) for i in input().split()] for j in range(N)] print(c_atcodeer_and_election_report(N, R))
Traceback (most recent call last): File "/tmp/tmpx8xdrk2v/tmpsxclpkr7.py", line 11, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s186447755
p04013
u651925006
1520964525
Python
Python (3.4.3)
py
Runtime Error
17
2940
80
a, b, c = input().split() print('YES' if a[-1]==b[0] and b[-1]==c[0] else 'NO')
Traceback (most recent call last): File "/tmp/tmp6q9iky9t/tmpztvu0b91.py", line 1, in <module> a, b, c = input().split() ^^^^^^^ EOFError: EOF when reading a line
s250090165
p04013
u764600134
1518366974
Python
Python (3.4.3)
py
Runtime Error
2027
61772
1045
# -*- coding: utf-8 -*- """ https://beta.atcoder.jp/contests/abc044/tasks/arc060_a """ import sys from sys import stdin from copy import copy, deepcopy input = stdin.readline def solve(N, A, cards): ans = 0 cards.append(0) cards.sort() W = max(cards) * N # dp[j][k][s]: j番目までのカードをk枚使って合計をsにする組み合わせ dp = [[[0] * (W+1) for _ in range(N+1)] for _ in range(N+1)] for j in range(N+1): dp[j][0][0] = 1 for j in range(1, N+1): card = cards[j] for k in range(1, N+1): for s in range(1, W+1): if s < card: dp[j][k][s] = dp[j-1][k][s] else: dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-card] for k in range(1, N+1): ans += dp[N][k][k*A] return ans def main(args): N, A = map(int, input().split()) cards = [int(x) for x in input().split()] ans = solve(N, A, cards) print(ans) if __name__ == '__main__': main(sys.argv[1:])
Traceback (most recent call last): File "/tmp/tmp8fg0qder/tmpmmdq_6vw.py", line 45, in <module> main(sys.argv[1:]) File "/tmp/tmp8fg0qder/tmpmmdq_6vw.py", line 38, in main N, A = map(int, input().split()) ^^^^ ValueError: not enough values to unpack (expected 2, got 0)
s134611784
p04013
u952708174
1517167184
Python
Python (3.4.3)
py
Runtime Error
81
5748
418
def c_Tak_and_Cards(N, A, S): X = max(S) y = [x - A for x in S] dp = [[0 for _ in range(2 * N * X + 1)] for _ in range(N + 1)] dp[0][N * X] = 1 for j in range(N): for t in range(X, (2 * N - 1) * X): dp[j + 1][t] = dp[j][t] + dp[j][t - y[j]] return dp[N][N * X] - 1 N,A = [int(i) for i in input().split()] S = [int(i) for i in input().split()] print(c_Tak_and_Cards(N, A, S))
Traceback (most recent call last): File "/tmp/tmpwhr0nhax/tmpgdvu1udw.py", line 10, in <module> N,A = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s129682693
p04013
u621935300
1514013520
Python
Python (2.7.6)
py
Runtime Error
2107
55676
525
N,A=map(int,raw_input().split()) x=[0]+map(int,raw_input().split()) #print x max_n=max(x) dp=[[[0]*(N*max_n+1) for k in range(N + 1)] for j in range(N+1)] #print dp for j in range(N+1): for k in range(N+1): for s in range(N*max_n+1): if j==k==s==0: dp[j][k][s]=1 elif j>=1 and s<x[j]: dp[j][k][s]=dp[j-1][k][s] elif j>=1 and k>=1 and s>=x[j]: dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j]] else: dp[j][k][s]=0 #print dp ans=0 for k in range(1,N+1): ans+=dp[N][k][k*A] print ans
File "/tmp/tmpx3zewl1n/tmptxxubuho.py", line 29 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s093684778
p04013
u879309973
1495628106
Python
Python (2.7.6)
py
Runtime Error
1825
63360
408
import numpy as np N, A = map(int, raw_input().split()) x = map(int, raw_input().split()) dp = np.full((N+1, A+1, (N+1)*(A+1)), -1) def dfs(i, t, W): if t == 0: return int(W == 0) if i < 0: return 0 if dp[i, t, W] > -1: return dp[i, t, W] dp[i, t, W] = dfs(i-1, t, W) + dfs(i-1, t-1, W-x[i]) return dp[i, t, W] print sum([dfs(N-1, T, T*A) for T in range(1, N+1)])
File "/tmp/tmpmrcru1_j/tmpw6c65u9j.py", line 15 print sum([dfs(N-1, T, T*A) for T in range(1, N+1)]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s636976868
p04013
u332385682
1490738752
Python
Python (3.4.3)
py
Runtime Error
129
54004
560
N, A = map(int, input().split()) x = [int(i) for i in input().split()] # 3d DP max_x = max(x) dp = [[[0] * (max_x * N + 1) for j in range(N + 1)] for i in range(N + 1)] dp[0][0][0] = 1 for i in range(0, N): for k in range(0, N + 1): for y in range(max_x * N + 1): dp[i + 1][k][y] += dp[i][k][y] dp[i + 1][k + 1][y + x[i]] += dp[i][k][y] cnt = 0 for k in range(1, N + 1): for y in range(1, max_x * N + 1): if y // k == A and y % k == 0: cnt += dp[N][k][y] print(cnt)
Traceback (most recent call last): File "/tmp/tmp1epjrtyo/tmpuqi2gqvp.py", line 1, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s881571500
p04013
u481333386
1489285611
Python
Python (3.4.3)
py
Runtime Error
18
3060
390
n, a = [int(e) for e in input().split()] lst = [int(e) for e in input().split()] def main(n, a, lst): count = 0 lst_len = len(lst) for i in range(1, i + 1): for j, _ in enumerate(lst): if lst_len <= j + i: break e = lst[j:j + i] if e // i == a: count += 1 return count print(main(n, a, lst))
Traceback (most recent call last): File "/tmp/tmpgbbi1rmy/tmpecotlgmk.py", line 1, in <module> n, a = [int(e) for e in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s679741117
p04013
u332385682
1488400419
Python
Python (3.4.3)
py
Runtime Error
225
3444
612
import sys from collections import Counter def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def solve(): N, A = map(int, input().split()) assert N <= 16 x = [int(i) for i in input().split()] cnt = 0 for i in range(1, 2**N): bs = bin(i)[2:].zfill(N) bitpop = bs.count('1') tmp = sum(x[i] for i, b in enumerate(bs) if b == '1') cnt += (tmp // bitpop == A and tmp % bitpop == 0) print(cnt) if __name__ == '__main__': solve()
Traceback (most recent call last): File "/tmp/tmp4aztcwzo/tmp8cdoeicm.py", line 27, in <module> solve() File "/tmp/tmp4aztcwzo/tmp8cdoeicm.py", line 11, in solve N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s195187262
p04013
u614550445
1485640939
Python
Python (3.4.3)
py
Runtime Error
1021
4208
362
N, A = [int(_) for _ in input().split()] x = sorted([int(_) for _ in input().split()]) dp = [[0] * (sum(x)+1) for j in range(N+1)] dp[0][0] = 1 for i in range(1, N+1): for j in list(range(1, N+1))[::-1]: for k in list(range(x[i-1], sum(x[:i])+1))[::-1]: dp[j][k] += dp[j-1][k - x[i-1]] print(sum([dp[i][i*A] for i in range(1, N+1)]))
Traceback (most recent call last): File "/tmp/tmpl50z41s6/tmpfnmm7xvw.py", line 2, in <module> N, A = [int(_) for _ in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s240276578
p04013
u831695469
1478859316
Python
Python (3.4.3)
py
Runtime Error
22
3064
323
n, a = map(int, raw_input().split()) X = map(int, raw_input().split()) dp = [[0]*(n*a+1) for i in xrange(n+1)] dp[0][0] = 1 for i in xrange(n): for j in xrange(i, -1, -1): for k in xrange(n*a, X[i]+1, -1): dp[j+1][k] += dp[j][k-X[i]] ans = 0 for i in xrange(1, n+1): ans += dp[i][i*a] print ans
File "/tmp/tmptsc703pu/tmp3xn7zy75.py", line 12 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s605216610
p04013
u664481257
1478645487
Python
Python (3.4.3)
py
Runtime Error
45
5388
1278
# -*- coding: utf-8 -*- # !/usr/bin/env python # vim: set fileencoding=utf-8 : """ # # Author: Noname # URL: https://github.com/pettan0818 # License: MIT License # Created: 火 11/ 8 17:04:53 2016 # Usage # """ from itertools import repeat from itertools import combinations import sys from statistics import mean def read_input(): first = input().split(" ") N = int(first[0]) A = int(first[1]) x_list = [int(i) for i in input().splist(" ")] return N, A, x_list def naive_checker(num_list, target_mean): """ >>> naive_checker([7,9,8,9], 8) 5 >>> naive_checker([6,6,9], 8) 0 >>> naive_checker([3,6,2,8,7,6,5,9], 5) 19 """ ans = 0 for i in range(1, len(num_list)): for n in combinations(num_list, i): if mean(n) == target_mean: ans += 1 print(ans) # def dns_child(now_mean, target_mean, card_list: list): # """ # >>> dns_child(0, 8, [7,9,8,9]) # 5 # >>> dns_child(0, 8, [6,6,9]) # 0 # >>> dns_child(0, 5, [3,6,2,8,7,6,5,9]) # 19 # >>> dns_child(0, 3, repeat(3,33)) # 8589934591 # """ if __name__ == '__main__': # import doctest # doctest.testmod() N, A, x_list = read_input() naive_checker(x_list, A)
Traceback (most recent call last): File "/tmp/tmp34heyldn/tmpbc04ail7.py", line 66, in <module> N, A, x_list = read_input() ^^^^^^^^^^^^ File "/tmp/tmp34heyldn/tmpbc04ail7.py", line 23, in read_input first = input().split(" ") ^^^^^^^ EOFError: EOF when reading a line
s398568631
p04013
u065683101
1475679579
Python
Python (3.4.3)
py
Runtime Error
1080
38900
550
from array import array def read(): return int(input()) def reads(sep=None): return list(map(int, input().split(sep))) def main(): n, a = reads() x = reads() s = sum(x) dp = [[array('I', [0]*3500) for j in range(n+1)] for i in range(n+1)] dp[0][0][0] = 1 for i in range(n): for j in range(n): for k in range(s): dp[i][j+1][k] += dp[i][j][k] dp[i+1][j+1][k+x[j]] += dp[i][j][k] r = 0 for j in range(1, n+1): r += dp[j][n][j*a] print(r) main()
Traceback (most recent call last): File "/tmp/tmp7py_3uro/tmpw466wxwx.py", line 25, in <module> main() File "/tmp/tmp7py_3uro/tmpw466wxwx.py", line 10, in main n, a = reads() ^^^^^^^ File "/tmp/tmp7py_3uro/tmpw466wxwx.py", line 7, in reads return list(map(int, input().split(sep))) ^^^^^^^ EOFError: EOF when reading a line
s716220110
p04013
u343675824
1473557119
Python
Python (3.4.3)
py
Runtime Error
38
3064
1026
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--) #define REP(i,n) for(int i=0;i<(n);i++) #define RREP(i,n) for(int i=n-1;i>=0;i--) #define PB push_back #define MP make_pair #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define CLR(a) memset(a,0,sizeof(a)) #define SET(a,c) memset(a,c,sizeof(a)) #define DEBUG(x) cout<< #x <<": "<<x<<endl using namespace std; typedef long long int ll; typedef vector<int> vi; typedef vector<ll> vl; const ll INF = INT_MAX/3; const ll MOD = 1000000007; const double EPS = 1e-14; const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1}; ll dp[51][51][2601]; int main(){ int N,A,NX,x[51]; cin >> N >> A; REP(i,N) cin >> x[i]; NX = N * 50; dp[0][0][0] = 1; REP(i,N)REP(j,N)REP(k,NX){ dp[i+1][j+1][k+x[i]] += dp[i][j][k]; dp[i+1][j][k] += dp[i][j][k]; } ll ans = 0; FOR(i,1,N+1) ans += dp[N][i][A*i]; cout << ans << endl; return 0; }
File "/tmp/tmpm7u5vw43/tmp08_rtrot.py", line 16 using namespace std; ^^^^^^^^^ SyntaxError: invalid syntax
s662166796
p04013
u212829728
1473092318
Python
Python (3.4.3)
py
Runtime Error
41
3316
1042
def app(numlist, A ): counter = 0 N = len(numlist) for i in range(1,N): counter += f(numlist, i, A*i) return counter def f(numlist, rest, sum): result = 0 numset = set(numlist) if rest == 1: return numlist.count(sum) elif rest == 2: for big in numset: if (sum - big in numset) and (big >= sum - big): result += counter(numlist, big, sum-big) return result else: for i in numset: i_place = numlist.index(i) result += f(numlist[i_place+1:], rest-1, sum-i) return result def counter(numlist, big, small): hist = mkhist(numlist) if big == small: N = hist[big] return N * (N - 1) / 2 else: big_N = hist[big] small_N = hist[small] return big_N * small_N def mkhist(numlist): hist = dict() for char in numlist: if not char in hist.keys(): hist[char] = 1 else: hist[char] += 1 return hist N, A = input() inputs = input() inputnum = map(int, inputs.split(' ')) inputnum = sorted(list(inputnum)) print (app(inputnum, A))
Traceback (most recent call last): File "/tmp/tmpgmt5iisg/tmp58a4xvbn.py", line 46, in <module> N, A = input() ^^^^^^^ EOFError: EOF when reading a line
s138112581
p04013
u442810826
1472456886
Python
Python (2.7.6)
py
Runtime Error
30
2568
1438
rom itertools import combinations n,a=map(int,raw_input().split()) x=map(int,raw_input().split()) el_plus = [] el_minus = [] sum_plus_dict = {"def":None} sum_minus_dict = {"def":None} x = [el - a for el in x] count_zero = 0 count = 0 for i in range(len(x)): if x[i] > 0: el_plus.append(x[i]) elif x[i] < 0: el_minus.append(x[i]) else: count_zero += 1 print count_zero if (el_plus == [] or el_minus == []): if count_zero==0: print 0 else: print pow(2, count_zero) - 1 else: for i in range(len(el_minus)): el_minus[i] = el_minus[i] * (-1) for i in range(1, sum(el_plus)+1): sum_plus_dict.update({i:0}) for i in range(1, sum(el_minus)+1): sum_minus_dict.update({i:0}) for i in range(1, len(el_plus)+1,): comb_sum_plus = combinations(el_plus, i) for comb in comb_sum_plus: sum_plus = sum(list(comb)) sum_plus_dict[sum_plus] += 1 for i in range(1, len(el_minus)+1): comb_sum_minus = combinations(el_minus, i) for comb in comb_sum_minus: sum_minus = sum(list(comb)) sum_minus_dict[sum_minus] += 1 for key in range(1, min(sum(el_plus), sum(el_minus))+1): if sum_plus_dict[key] > 0 and sum_minus_dict[key] > 0: count += sum_plus_dict[key] * sum_minus_dict[key] * pow(2, count_zero) count += pow(2, count_zero)-1 print count
File "/tmp/tmp6ini412f/tmpliwkbf3t.py", line 1 rom itertools import combinations ^^^^^^^^^ SyntaxError: invalid syntax
s078914664
p04013
u442810826
1472455880
Python
Python (2.7.6)
py
Runtime Error
28
2696
1351
from itertools import combinations n,a=map(int,raw_input().split()) x=map(int,raw_input().split()) el_plus = [] el_minus = [] sum_plus_dict = {"def":None} sum_minus_dict = {"def":None} x = [el - a for el in x] count_zero = 0 count = 0 for i in range(len(x)): if x[i] > 0: el_plus.append(x[i]) elif x[i] < 0: el_minus.append(x[i]) else: count_zero += 1 if el_plus == [] or el_minus == []: print 0 else: for i in range(len(el_minus)): el_minus[i] = el_minus[i] * (-1) for i in range(1, sum(el_plus)+1): sum_plus_dict.update({i:0}) for i in range(1, sum(el_minus)+1): sum_minus_dict.update({i:0}) for i in range(1, len(el_plus)+1,): comb_sum_plus = combinations(el_plus, i) for comb in comb_sum_plus: sum_plus = sum(list(comb)) sum_plus_dict[sum_plus] += 1 for i in range(1, len(el_minus)+1): comb_sum_minus = combinations(el_minus, i) for comb in comb_sum_minus: sum_minus = sum(list(comb)) sum_minus_dict[sum_minus] += 1 for key in range(1, min(sum(el_plus), sum(el_minus))+1): if sum_plus_dict[key] > 0 and sum_minus_dict[key] > 0: count += sum_plus_dict[key] * sum_minus_dict[key] * pow(2, count_ze\ ro) count += pow(2, count_zero)-1 print count
File "/tmp/tmpvh275agn/tmp106avf2_.py", line 24 print 0 ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s849215541
p04013
u123756661
1472434241
Python
Python (2.7.6)
py
Runtime Error
473
4612
276
n,a=map(int,raw_input().split()) x=map(int,raw_input().split()) ans=0 for i in range(1<<n): chk=0 t=bin(i)[2:] t='0'*(n-len(t))+t for j,p in enumerate(t): if p=='1': chk+=x[j] if chk!=0 and chk==a*t.count('1'): ans+=1 print ans
File "/tmp/tmp5_bi2054/tmpvlkh_mfe.py", line 13 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s009355390
p04014
u825685913
1600745759
Python
Python (3.8.2)
py
Runtime Error
429
9380
508
#自分の回答 import math def digit(b, n): if n < b: return n else: return digit(b, math.floor(n/b)) + n % b n, s = int(input()), int(input()) if n == s: print(n+1) exit() if n < s: print(-1) exit() for i in range(2, int(math.sqrt(n)) + 2): if digit(i, n) == s: print(i) exit() else: continue for p in range(1,int(math.sqrt(n)))[::-1]: b = (n-s)//p +1 if digit(b, n) == s: print(b) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmpw9wycrf3/tmpxfsdilbw.py", line 9, in <module> n, s = int(input()), int(input()) ^^^^^^^ EOFError: EOF when reading a line
s100018785
p04014
u825685913
1600745317
Python
Python (3.8.2)
py
Runtime Error
433
9692
508
#自分の回答 import math def digit(b, n): if n < b: return n else: return digit(b, math.floor(n/b)) + n % b n, s = int(input()), int(input()) if n == s: print(n+1) exit() if n < s: print(-1) exit() for i in range(2, int(math.sqrt(n)) + 2): if digit(i, n) == s: print(i) exit() else: continue for p in range(1,int(math.sqrt(n)))[::-1]: b = (n-s)//p +1 if digit(b, n) == s: print(b) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmpv20xestp/tmpcp5ibx35.py", line 9, in <module> n, s = int(input()), int(input()) ^^^^^^^ EOFError: EOF when reading a line
s984660441
p04014
u825685913
1600744680
Python
Python (3.8.2)
py
Runtime Error
428
9392
506
#自分の回答 import math def digit(b, n): if n < b: return n else: return digit(b, math.floor(n/b)) + n % b n, s = int(input()), int(input()) if n == s: print(n+1) exit() if n < s: print(-1) exit() for i in range(2, int(math.sqrt(n) + 1)): if digit(i, n) == s: print(i) exit() else: continue for p in range(1,int(math.sqrt(n) +1)): b = (n-s)//p + 1 if digit(b, n) == s: print(b) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmpyevnduac/tmpyazd5bv1.py", line 9, in <module> n, s = int(input()), int(input()) ^^^^^^^ EOFError: EOF when reading a line
s401456114
p04014
u825685913
1600744464
Python
Python (3.8.2)
py
Runtime Error
431
9476
483
import math def digit(b, n): if n < b: return n else: return digit(b, math.floor(n/b)) + n % b n, s = int(input()), int(input()) if n == s: print(n+1) exit() if n < s: print(-1) exit() for i in range(2, int(math.sqrt(n))): if digit(i, n) == s: print(i) exit() else: continue for p in range(1,int(math.sqrt(n))): b = (n-s)//p + 1 if digit(b, n) == s: print(b) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmpir_ac5ye/tmpzb3xdsh1.py", line 8, in <module> n, s = int(input()), int(input()) ^^^^^^^ EOFError: EOF when reading a line
s407215184
p04014
u969708690
1599275046
Python
Python (3.8.2)
py
Runtime Error
27
9112
102
n=int(input()) s=int(input()) if n==s: print(n+1) exit() if (n+3)//2<=s: print(-1) exit() ewew
Traceback (most recent call last): File "/tmp/tmp1wn1_l84/tmp982z2egx.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s461030622
p04014
u074220993
1599106043
Python
Python (3.8.2)
py
Runtime Error
285
9612
496
n, s = int(input()), int(input()) f = lambda b,n:n if n < b else n%b + f(b,n//b) import math ans = n+2 for b in range(2,math.ceil(math.sqrt(n))): #O(√n)の全探索 if f(b,n) == s: ans = b; break else: for p in range(math.ceil(math.sqrt(n))): #n=pb+q (b>√n, p+q=s)に基づいたO(√n)の全探索 q = s-p if p > 0: b = (n-q)/p else: b = n+1 if b == int(b) and f(b,n) == s: ans = min(ans,int(b)) if ans == n+2: ans = -1 print(ans)
Traceback (most recent call last): File "/tmp/tmp657zp7fz/tmph_k79za1.py", line 1, in <module> n, s = int(input()), int(input()) ^^^^^^^ EOFError: EOF when reading a line
s533095829
p04014
u533039576
1597252447
Python
PyPy3 (7.3.0)
py
Runtime Error
2207
74736
539
def func(b, n): res = 0 while n > 0: res += n % b n //= b return res def solve(): n = int(input()) s = int(input()) if n == s: return n + 1 # elif n < s: # return -1 for b in range(2, n + 1): if b**2 > n: break if func(b, n) == s: return b for p in range(1, n + 1): if p**2 > n: break b = (n - s) // p + 1 if func(b, n) == s: return b return -1 ans = solve() print(ans)
Traceback (most recent call last): File "/tmp/tmpoofoid3l/tmp_tozwhc0.py", line 35, in <module> ans = solve() ^^^^^^^ File "/tmp/tmpoofoid3l/tmp_tozwhc0.py", line 10, in solve n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s950581888
p04014
u758815106
1595830542
Python
Python (3.8.2)
py
Runtime Error
388
9196
442
import math n = int(input()) s = int(input()) r = 0 if n == s: print(n + 1) exit() nn = int(math.sqrt(n)) + 1 for i in range(2, nn): nt = n st = 0 while nt > 0: st += nt % i nt //= i if st == s: print(i) exit() for i in range(nn, 0, -1): nt = n st = 0 b = (n - s) // i + 1 st = n % b + n // b if st == s: print(b) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmpzpr7t3m_/tmpw8y4uona.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s329214318
p04014
u758815106
1595830427
Python
PyPy3 (7.3.0)
py
Runtime Error
114
75104
480
import math n = int(input()) s = int(input()) r = 0 if n == s: print(n + 1) exit() elif n < s: print(-1) exit() nn = int(math.sqrt(n)) + 1 for i in range(2, nn): nt = n st = 0 while nt > 0: st += nt % i nt //= i if st == s: print(i) exit() for i in range(nn, -1, -1): nt = n st = 0 b = (n - s) // i + 1 st = n % b + n // b if st == s: print(b) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmp4s_644u3/tmp75789_ra.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s426873946
p04014
u758815106
1595829262
Python
Python (3.8.2)
py
Runtime Error
483
9188
554
import math n = int(input()) s = int(input()) r = 0 if n == s: print(n + 1) exit() elif n < s: print(-1) exit() elif s == 1: print(n) exit() nn = int(math.sqrt(n)) + 1 for i in range(2, nn): nt = n st = 0 while nt > 0: st += nt % i nt //= i if st == s: print(i) exit() for i in range(2, nn): nt = n st = 0 tt = (n - s) // (i + 1) while nt > 0: st += nt % tt nt //= tt if st == s: print(tt) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmpoalml2g0/tmpsp6_arxd.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s011869719
p04014
u726872801
1595660496
Python
Python (3.8.2)
py
Runtime Error
2206
9648
856
import sys import heapq, math from itertools import zip_longest, permutations, combinations, combinations_with_replacement from itertools import accumulate, dropwhile, takewhile, groupby from functools import lru_cache from copy import deepcopy N, S = [int(input()), int(input())] def solve1(): i = 2 while i * i <= N: s, n = 0, N while n > 0: s += n % i n //= i if s == S: return i i += 1 return 1 << 60 def solve2(): i = 1 ret = 1 << 60 while i * i <= N: b = (N - S) // i + 1 s, n = 0, N while n > 0: s += n % b n //= b if s == S: ret = min(ret, b) i += 1 return ret def solve(): ret = min(solve1(), solve2()) return ret if ret != 1 << 60 else -1 print(solve())
Traceback (most recent call last): File "/tmp/tmp47211n2u/tmpm_2ireiz.py", line 8, in <module> N, S = [int(input()), int(input())] ^^^^^^^ EOFError: EOF when reading a line
s232264597
p04014
u786020649
1594407897
Python
Python (3.8.2)
py
Runtime Error
59
9120
618
import sys import math def divlist(n): sl=[] ll=[] for x in range(1,int(math.sqrt(n))+1): if n%x==0: sl.append(x) ll.append(n//x) ll.reverse() sl.extend(ll) return sl def f(b,n): if n<b: return n else: return f(b,n//b)+(n%b) def main(n,s): if n<s: return print(-1) elif n==s: return prnit(n+1) else: dl=divlist(n-s) for x in dl: if s==f(x+1,n): return print(x+1) return print(-1) n=int(sys.stdin.readline().strip()) s=int(sys.stdin.readline().strip()) main(n,s)
Traceback (most recent call last): File "/tmp/tmpv0dnqml3/tmp_olchzdp.py", line 33, in <module> n=int(sys.stdin.readline().strip()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: ''
s410403577
p04014
u786020649
1594407539
Python
Python (3.8.2)
py
Runtime Error
28
9056
547
import sys import math n=int(sys.stdin.readline().strip()) s=int(sys.stdin.readline().strip()) def divlist(n): sl=[] ll=[] for x in range(1,int(math.sqrt(n))+1): if n%x==0: sl.append(x) ll.append(n//x) ll.reverse() sl.extend(ll) return sl def f(b,n): if n<b: return n else: return f(b,n//b)+(n%b) if n<s: print(-1 elif n==s: print(n+1) else: dl=divlist(n-s) for x in dl: if s==f(x+1,n): print(x+1) sys.exit() print(-1)
File "/tmp/tmpzc3_d7tb/tmplv84bkv4.py", line 25 print(-1 ^ SyntaxError: '(' was never closed
s636813106
p04014
u203843959
1590546623
Python
PyPy3 (2.4.0)
py
Runtime Error
240
40684
405
import sys n=int(input()) s=int(input()) if n==s: print(n+1) sys.exit(0) def f(b,n): ret=0 while n: ret+=n%b n//=b return ret for b in range(2,int(n**0.5)+1): ss=f(b,n) if ss==s: print(b) sys.exit(0) #n=pb+q for p in range(1,int(n**0.5)+1): q=s-p b=(n-q)//p if q<0 or (n-q)%p!=0: continue ss=f(b,n) if ss==s: print(b) sys.exit(0) print(-1)
Traceback (most recent call last): File "/tmp/tmp3a78on52/tmpb81vybhh.py", line 2, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s780288528
p04014
u888100977
1590112909
Python
Python (3.4.3)
py
Runtime Error
313
20884
615
n = int(input()) s = int(input()) import sys sys.setrecursionlimit(20000) import math def f(b, n): # print(b, n) if n<b: return n else: x = f(b, n//b) + n%b return x # print(f(100000000000,100000000000)) ans = 0 # if n<s: # print(-1) # exit() if n==s: print(n+1) exit() for b in range(2,int(math.sqrt(n))+500): if f(b, n) == s: ans = b print(ans) exit() for p in range(int(math.sqrt(n)), 0, -1): if (n+p-s) %p == 0: # print(p) if f((n+p-s)//p, n) == s: print((n+p-s)//p) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmpv4rswnlx/tmp7_0169tf.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s523173150
p04014
u888100977
1590112373
Python
Python (3.4.3)
py
Runtime Error
309
4020
504
n = int(input()) s = int(input()) import math def f(b, n): # print(b, n) if n<b: return n else: x = f(b, n//b) + n%b return x ans = 0 if n<s: print(-1) exit() for b in range(2,int(math.sqrt(n))+500): if f(b, n) == s: ans = b print(ans) exit() for p in range(int(math.sqrt(n)), 0, -1): if (n+p-s) %p == 0: # print(p) if f((n+p-s)/p, n) == s: print((n+p-s)//p) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmp6rlgvr8g/tmpcycxdgr7.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s704641649
p04014
u888100977
1590112350
Python
PyPy3 (2.4.0)
py
Runtime Error
360
52592
504
n = int(input()) s = int(input()) import math def f(b, n): # print(b, n) if n<b: return n else: x = f(b, n//b) + n%b return x ans = 0 if n<s: print(-1) exit() for b in range(2,int(math.sqrt(n))+500): if f(b, n) == s: ans = b print(ans) exit() for p in range(int(math.sqrt(n)), 0, -1): if (n+p-s) %p == 0: # print(p) if f((n+p-s)/p, n) == s: print((n+p-s)//p) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmpkjqt10z3/tmps8fcvf03.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s762984161
p04014
u915647268
1588667512
Python
Python (3.4.3)
py
Runtime Error
537
3188
355
n = int(input()) s = int(input()) sq = n**.5 ans = '-1' for b in range(2, int(sq)+1): sum = 0 tmp = n while tmp//b != 0: sum += tmp%b tmp //= b sum += tmp if sum == s: ans = b break if ans == '-1': for p in range(int(sq), 0, -1): b = (n-s+p)/p if b % 1 == 0: b = int(b) q = n%b if p+q == s: ans = b break print(ans)
Traceback (most recent call last): File "/tmp/tmpm3a8byqp/tmpl34daw01.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s427491459
p04014
u308918401
1588637868
Python
Python (3.4.3)
py
Runtime Error
18
2940
177
def f(b,n): if n<b: return(n) else: return(f(b,int(n/b))+n%b) n=int(input()) s=int(inout()) t=-1 for i in range(n-2): if f(i+2,n)==s: t=i+2 break print(t)
Traceback (most recent call last): File "/tmp/tmp1gb_gupr/tmp4dfrnldx.py", line 7, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s136893337
p04014
u915647268
1587822431
Python
Python (3.4.3)
py
Runtime Error
547
3064
360
n = int(input()) s = int(input()) sq = n**.5 ans = '-1' for b in range(2, int(sq)+1): sum = 0 tmp = n while tmp//b != 0: sum += tmp%b tmp //= b sum += tmp if sum == s: ans = b break if ans == '-1': for p in range(int(sq), 0, -1): b = (n-s+p)/p if b.is_integer(): b = int(b) q = n%b if p+q == s: ans = b break print(ans)
Traceback (most recent call last): File "/tmp/tmp722z31gc/tmpd27u0437.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line