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
s436577427
p04030
u632369368
1520753068
Python
Python (3.4.3)
py
Runtime Error
18
2940
160
S = list(input()) L = [] for i, ch in enumerate(S): if ch != 'B': L.append(ch) elif len(L) > 0: del L[i - 1] R = ''.join(L) print(R)
Traceback (most recent call last): File "/tmp/tmpa5lm0vam/tmpsao88iy5.py", line 1, in <module> S = list(input()) ^^^^^^^ EOFError: EOF when reading a line
s761294359
p04030
u632369368
1520752941
Python
Python (3.4.3)
py
Runtime Error
17
2940
155
S = list(input()) R = [] for i, ch in enumerate(S): if ch != 'B': R.append(ch) elif len(R) > 0: del R[i - 1] print(''.join(R))
Traceback (most recent call last): File "/tmp/tmpqmju7vcd/tmpc9gjcwjv.py", line 1, in <module> S = list(input()) ^^^^^^^ EOFError: EOF when reading a line
s968314311
p04030
u942033906
1514337161
Python
Python (3.4.3)
py
Runtime Error
17
3060
138
S = input() s = "" i = 0 for c in S: if c == '0' or c == '1': s[i] = c i += 1 else: if i > 0: s[i] = '' i -= 1
Traceback (most recent call last): File "/tmp/tmphz6um30_/tmpx08r9p49.py", line 1, in <module> S = input() ^^^^^^^ EOFError: EOF when reading a line
s421055895
p04030
u663710122
1506619297
Python
Python (3.4.3)
py
Runtime Error
19
2940
130
S = input() ret = [] for s in S: if s == 'B' and len(s): ret.pop() else: ret.append(s) print(''.join(ret))
Traceback (most recent call last): File "/tmp/tmp34zrjuwf/tmpci6hctkr.py", line 1, in <module> S = input() ^^^^^^^ EOFError: EOF when reading a line
s538059046
p04030
u667084803
1503490015
Python
Python (3.4.3)
py
Runtime Error
19
2940
116
s=str(input()) while "B" in s: if s[0] == "B": del s[0] s=s.replace("0B","") s=s.replace("1B","") print(s)
Traceback (most recent call last): File "/tmp/tmpdsi1fk9s/tmpo4vfl9a9.py", line 1, in <module> s=str(input()) ^^^^^^^ EOFError: EOF when reading a line
s329709837
p04030
u481333386
1493348195
Python
Python (3.4.3)
py
Runtime Error
18
2940
384
# -*- coding: utf-8 -*- def list_n(): return [int(e) for e in input().split()] def list_s(): return [s for e in input().split()] def main(s): ret = [] for c in s: if c in ['0', '1']: ret.append(c) else: if c: ret.pop() return ''.join(ret) if __name__ == '__main__': s = input() print(main(s))
Traceback (most recent call last): File "/tmp/tmp0aq_ux3k/tmpdfmpu9mu.py", line 23, in <module> s = input() ^^^^^^^ EOFError: EOF when reading a line
s523420461
p04030
u083668616
1477940810
Python
Python (2.7.6)
py
Runtime Error
17
2568
175
def keyb(s): ans = "" for i in range(0, len(s)): if s[i] == 'B': ans.pop() else: ans.append(s[i]) return ans def main(): s = raw_input() print keyb(s) main()
File "/tmp/tmpxqv_zk5l/tmp_ihoop75.py", line 12 print keyb(s) ^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s040883605
p04030
u354630369
1477811217
Python
Python (2.7.6)
py
Runtime Error
16
2568
331
s = raw_input() if 'B' not in s: print s else: str_list = list(s) output_list = [] for i, c in enumerate(str_list): if c != 'B': output_list.append(c) else: # if output_list: if len(output_list) > 0: output_list.pop() print ''.join(output_list)
File "/tmp/tmpgwmuchnb/tmp2i2q_dcy.py", line 4 print s ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s349755114
p04030
u354630369
1477811052
Python
Python (2.7.6)
py
Runtime Error
16
2568
292
s = raw_input() if 'B' not in s: print s else: str_list = list(s) output_list = [] for i, c in enumerate(str_list): if c != 'B': output_list.append(c) else: if output_list: output_list.pop() print ''.join(output_list)
File "/tmp/tmpqaubi5sh/tmp7f2r_gqk.py", line 4 print s ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s111175125
p04030
u712335892
1472961815
Python
Python (3.4.3)
py
Runtime Error
39
3064
229
s = list(map(str, input())) display = [] for action in s: if action == '0': display.append('0') elif action == '1': display.append('1') elif action == 'B': display.pop() print(''.join(display))
Traceback (most recent call last): File "/tmp/tmp73za_w6b/tmp6yf7tju_.py", line 1, in <module> s = list(map(str, input())) ^^^^^^^ EOFError: EOF when reading a line
s395858188
p04030
u438131499
1471901627
Python
Python (2.7.6)
py
Runtime Error
25
2568
162
s=input() a="" for k in range(len(s)): if s[k]=="0": a=a+"0" elif s[k]=="1": a=a+"1" elif s[k]=="b": a=a.rstrip(a[-1]) print a
File "/tmp/tmpptr596ge/tmp537lc7xz.py", line 10 print a ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s738179922
p04030
u039623862
1471732784
Python
Python (3.4.3)
py
Runtime Error
38
3064
146
s =input() ary = [] for c in s: if c == 'B': if len(ary) > 0: ary.pop() else: ary.append(c) print(''join(ary))
File "/tmp/tmp3_vvx0sn/tmpxn_tufqm.py", line 9 print(''join(ary)) ^^^^^^^^^^^ SyntaxError: invalid syntax. Perhaps you forgot a comma?
s087851951
p04030
u965266315
1471140246
Python
Python (3.4.3)
py
Runtime Error
38
3064
370
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; int main(int argc, char const* argv[]) { string s; cin >> s; deque<char> q; rep(i, s.length()){ if(s[i] == 'B' && !q.empty()){ q.pop_back(); } else if(s[i] != 'B'){ q.push_back(s[i]); } } rep(i, q.size()){ cout << q[i]; } cout << endl; return 0; }
File "/tmp/tmpm8d9yjte/tmplzkufzgv.py", line 4 using namespace std; ^^^^^^^^^ SyntaxError: invalid syntax
s963854378
p04030
u277373937
1471139891
Python
Python (2.7.6)
py
Runtime Error
27
2568
136
s = raw_input() words = [] for c in list(s): if c == 'B': words.pop() else: words.append(c) print ''.join(words)
File "/tmp/tmpmydf90fm/tmpltk5xnva.py", line 8 print ''.join(words) ^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s363034738
p04030
u952939556
1471139822
Python
Python (3.4.3)
py
Runtime Error
38
3064
301
string = input() result = [] j=0 for i in range(len(string)): if string[i]=='0': result.append('0') elif string[i]=='1': result.append('1') elif string[i]=='B' and len(result)>1 and result[-1] in ['0','1'] result[-1]="" str_result="".join(result) print(str_result)
File "/tmp/tmp0i9e6oit/tmpn9p9xy0b.py", line 9 elif string[i]=='B' and len(result)>1 and result[-1] in ['0','1'] ^ SyntaxError: expected ':'
s743561762
p04030
u869328641
1471136897
Python
Python (3.4.3)
py
Runtime Error
38
3064
106
S = input() A = [] for l in S: if l == '0' or l == '1': A.append(l) else: A.pop() print("".join(A))
Traceback (most recent call last): File "/tmp/tmpk_nk563v/tmp2odx_puv.py", line 1, in <module> S = input() ^^^^^^^ EOFError: EOF when reading a line
s493095796
p04031
u021548497
1599439926
Python
Python (3.8.2)
py
Runtime Error
25
9164
157
n = int(input()) a = list(map(int, input(split()))) ans = 1e9 for p in a: sub = 0 for q in a: sub += pow(p - q, 2) ans = min(ans, sub) print(ans)
Traceback (most recent call last): File "/tmp/tmp15dq3_1t/tmpfykb4_5z.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s374091003
p04031
u272457181
1598145427
Python
Python (3.8.2)
py
Runtime Error
28
9196
222
N = int(input()) a = list(map(int,input().split())) b,c= 0,0 s =[] a.sort() for i in range(0,N): b += a[i] for i in range(0,N): c += a[i]**2 for i in range(a[0],a[N-1]): s.append(N*(i**2)-2*b*i+c) m = min(s) print(m)
Traceback (most recent call last): File "/tmp/tmp2irevc3n/tmpnpktnrua.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s876462738
p04031
u272457181
1598145371
Python
Python (3.8.2)
py
Runtime Error
30
9192
222
N = int(input()) a = list(map(int,input().split())) b,c= 0,0 s =[] a.sort() for i in range(0,N): b += a[i] for i in range(0,N): c += a[i]**2 for i in range(a[0],a[N-1]): s.append(N*(i**2)-2*b*i+c) m = min(s) print(m)
Traceback (most recent call last): File "/tmp/tmpho3qgo06/tmpx9pwk7i7.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s317326449
p04031
u272457181
1598145341
Python
Python (3.8.2)
py
Runtime Error
34
9196
222
N = int(input()) a = list(map(int,input().split())) b,c= 0,0 s =[] a.sort() for i in range(0,N): b += a[i] for i in range(0,N): c += a[i]**2 for i in range(a[0],a[N-1]): s.append(N*(i**2)-2*b*i+c) m = min(s) print(m)
Traceback (most recent call last): File "/tmp/tmpzm_2drxh/tmp3glacmgu.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s155513473
p04031
u272457181
1598144924
Python
Python (3.8.2)
py
Runtime Error
30
8988
213
N = input() a = list(map(int,input().split())) b,c= 0,0 s =[] a.sort() for i in range(0,N): b += a[i] for i in range(0,N): c += a[i]**2 for i in range(a[0]a[N]): s.append = 3*(i**2)-2*b+c m = min(s) print(m)
File "/tmp/tmpfmctcq_o/tmpxnrecfhd.py", line 10 for i in range(a[0]a[N]): ^^^^^^^^ SyntaxError: invalid syntax. Perhaps you forgot a comma?
s158004777
p04031
u739843002
1597643475
Python
Python (3.8.2)
py
Runtime Error
25
9208
242
import math N = int(input()) A = [int(a) for a in input().split(" ")] ave = sum(A) / N can1 = math.floor(ave) can2 = math.ceil(ave) cost1 = sum([(a - can1) ** 2 for a in A]) cost2 = sum([(a - can2) ** 2 for a in A]) print(min[cost1, cost2])
Traceback (most recent call last): File "/tmp/tmpaqnrdyvq/tmpj40b2nft.py", line 3, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s840578778
p04031
u372303722
1596384818
Python
Python (3.8.2)
py
Runtime Error
21
9028
347
N = int(input()) list = [int(a) for a in input().split()] A = sum(list)//N for k in range(N): ans = (list[j] - A) ** 2 for i in range(-100,100): sum = 0 sum_new = 0 for j in range(N): sum = sum + (list[j] - A) ** 2 sum_new = sum_new + (list[j] - i) ** 2 if(sum > sum_new): ans = sum_new print(ans)
Traceback (most recent call last): File "/tmp/tmpk6obfyh7/tmpqyuqzmhb.py", line 2, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s273243488
p04031
u123107676
1596384798
Python
Python (3.8.2)
py
Runtime Error
30
9096
204
N = int(input()) a = list(map(int, input().split())) avg = round(sum(a)/N) sums = [] for i in range(1, avg+1): s = 0 for j in range(N): s += (i-a[j])**2 sums.append(s) print(min(sums))
Traceback (most recent call last): File "/tmp/tmp7bsguaft/tmpfifup011.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s878946200
p04031
u372303722
1596384722
Python
Python (3.8.2)
py
Runtime Error
26
8884
354
N = int(input()) list = [int(a) for a in input().split()] A = sum(list)//N for k in rang(N): ans = (list[j] - A) ** 2 for i in range(-100:100): for j in range(N): sum = 0 sum_new = 0 sum = sum + (list[j] - A) ** 2 sum_new = sum_new + (list[j] - i) ** 2 if(sum > sum_new): ans = sum_new print(ans)
File "/tmp/tmpthh4re9q/tmp176huasd.py", line 10 for i in range(-100:100): ^ SyntaxError: invalid syntax
s776441413
p04031
u123107676
1596384662
Python
Python (3.8.2)
py
Runtime Error
24
9132
204
N = int(input()) a = list(map(int, input().split())) avg = round(sum(a)/N) sums = [] for i in range(1, avg+1): s = 0 for j in range(N): s += (i-a[j])**2 sums.append(s) print(min(sums))
Traceback (most recent call last): File "/tmp/tmpzhac43so/tmptn2m7stw.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s692264209
p04031
u123107676
1596384464
Python
Python (3.8.2)
py
Runtime Error
23
9224
209
N = int(input()) a = list(map(int, input().split())) avg = round(sum(a)/len(a)) sums = [] for i in range(1, avg+1): s = 0 for j in range(N): s += (a[j]-i)**2 sums.append(s) print(min(sums))
Traceback (most recent call last): File "/tmp/tmpoyfk69s2/tmpk8pmgtsq.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s908605384
p04031
u123107676
1596384410
Python
Python (3.8.2)
py
Runtime Error
27
9052
208
N = int(input()) a = list(map(int, input().split())) avg = round(sum(a)/len(a)) sums = [] for i in range(1, avg+1): s = 0 for j in range(N): s += (a[j]-avg)**2 sums[i] = s print(min(sums))
Traceback (most recent call last): File "/tmp/tmpdr2d_2_k/tmpkpy5iwma.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s717609511
p04031
u372303722
1596384385
Python
Python (3.8.2)
py
Runtime Error
26
8932
313
N = int(input()) list = [int(a) for a in input().split()] A = sum(list)//N for i in range(-100:100): for j in range(N): sum = 0 sum_new = 0 sum = sum + (list[j] - A) ** 2 sum_new = sum_new + (list[j] - i) ** 2 if(sum > sum_new): sum = sum_new print(sum)
File "/tmp/tmpkv82v6f_/tmp8m4ulm6p.py", line 7 for i in range(-100:100): ^ SyntaxError: invalid syntax
s580611057
p04031
u123107676
1596384276
Python
Python (3.8.2)
py
Runtime Error
27
9176
224
import math N = int(input()) a = list(map(int, input().split())) avg = round(sum(a)/len(a)) sums = [] for i in range(1, avg+1): s = 0 for j in range(N): s += (a[j]-avg)**2 sums.append(s) print(min(sums))
Traceback (most recent call last): File "/tmp/tmpswmmmg4u/tmp4kuplf1b.py", line 3, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s553861703
p04031
u372303722
1596384203
Python
Python (3.8.2)
py
Runtime Error
24
8972
297
N = int(input()) list = [int(a) for a in input().split()] A = sum(list)//N sum = 0 sum_new = 0 for i in range(-100:100): for j in range(N): sum = sum + (list[j] - A) ** 2 sum_new = sum_new + (list[j] - i) ** 2 if(sum > sum_new): sum = sum_new print(sum)
File "/tmp/tmpzz6wu22q/tmpl1f78som.py", line 9 for i in range(-100:100): ^ SyntaxError: invalid syntax
s127585555
p04031
u372303722
1596384148
Python
Python (3.8.2)
py
Runtime Error
24
9020
287
N = int(input()) list = [int(a) for a in input().split()] A = sum(list)//N sum = 0 sum_new = 0 for i in range(-100:100): for j in range(N): sum = sum + (list[j] - A) ** 2 sum_new = (list[j] - i) ** 2 if(sum > sum_new): sum = sum_new print(sum)
File "/tmp/tmpawa9sf_1/tmpn0yn550g.py", line 9 for i in range(-100:100): ^ SyntaxError: invalid syntax
s469128712
p04031
u123107676
1596383964
Python
Python (3.8.2)
py
Runtime Error
30
9172
236
import math N = int(input()) a = list(map(int, input().split())) avg = math.floor(sum(a)/len(a)) sums = [] for i in range(1, avg+1): sum = 0 for j in range(N): sum += (a[j]-avg)**2 sums.append(sum) print(min(sums))
Traceback (most recent call last): File "/tmp/tmpbzx_xy2h/tmpbylj18ey.py", line 3, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s421207641
p04031
u372303722
1596383940
Python
Python (3.8.2)
py
Runtime Error
27
8940
259
N = int(input()) list = [int(a) for a in input().split()] A = sum(list)//N for i in range(-100:100): for j in range(N): sum = (list[j] - A) ** 2 sum_new = (list[j] - i) ** 2 if(sum > sum_new): sum = sum_new print(sum)
File "/tmp/tmp9usl97y8/tmpi9oq8ka1.py", line 9 for i in range(-100:100): ^ SyntaxError: invalid syntax
s751420525
p04031
u123107676
1596383923
Python
Python (3.8.2)
py
Runtime Error
31
9184
237
import math N = int(input()) a = list(map(int, input().split())) avg = math.floor(sum(a)/len(a)) sums = [] for i in range(1, avg+1): sum = 0; for j in range(N): sum += (a[j]-avg)**2 sums.append(sum) print(min(sums))
Traceback (most recent call last): File "/tmp/tmpr5lvv49t/tmpcs0a97rm.py", line 3, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s452979062
p04031
u123107676
1596383891
Python
Python (3.8.2)
py
Runtime Error
23
8832
237
import math N = int(input()) a = list(map(int, input().split()))2 avg = math.floor(sum(a)/len(a)) sums = [] for i in range(1, avg+1): sum = 0; for j in range(N): sum += (a[j]-avg)**2 sums.append(sum) print(min(sums))
File "/tmp/tmpq7xxzr1m/tmphk6zq_he.py", line 4 a = list(map(int, input().split()))2 ^ SyntaxError: invalid syntax
s461117161
p04031
u372303722
1596383823
Python
Python (3.8.2)
py
Runtime Error
26
8936
222
N = int(input()) list = [int(a) for a in input().split()] A = sum(list)//N for i in range(-100:100): sum = (list[i] - A) ** 2 sum_new = (list[i] - i) ** 2 if(sum > sum_new): sum = sum_new print(sum)
File "/tmp/tmpim90mr5h/tmppp_ijndn.py", line 7 for i in range(-100:100): ^ SyntaxError: invalid syntax
s597488464
p04031
u123107676
1596383650
Python
Python (3.8.2)
py
Runtime Error
24
9152
268
import math N = int(input()) a = map(int, input().split()) avg = math.floor(sum(a)/len(a)) pattern = [] for i in range(1, avg+1): pattern[i] = [] for j in range(N): pattern[i].append((a[j]-avg)**2) pattern[i] = sum(pattern[i]) print(min(pattern))
Traceback (most recent call last): File "/tmp/tmp_prk7ze2/tmp67tba8qf.py", line 3, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s698579549
p04031
u671454079
1596382630
Python
Python (3.8.2)
py
Runtime Error
33
9188
235
N = int(input()) l = list(map(int,input().split())) l_ans = [[] for _ in range(200)] for i in range(-100,101): sum = 0 for j in range(N): sum = sum + (i-l[j])**2 l_ans[i+100] = sum print(l_ans) print(min(l_ans))
Traceback (most recent call last): File "/tmp/tmpxakuaou8/tmpwpm5kfl9.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s213536321
p04031
u671454079
1596382292
Python
Python (3.8.2)
py
Runtime Error
26
9184
189
N = int(input()) l = list(map(int,input().split())) l_ans = [] for i in range(1,101): sum = 0 for j in range(N): sum = sum + (i-l[j])**2 l_ans[i] = sum print(min(l))
Traceback (most recent call last): File "/tmp/tmptwoagqyv/tmpopggzpa9.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s732450706
p04031
u875113233
1595803453
Python
Python (3.8.2)
py
Runtime Error
36
9184
317
def main(): n = int(input()) a = list(map(int,input().split())) listcost = [] for i in range(min(a),max(a)): cost = 0 for j in a: if i != j: cost += (i-j) ** 2 listcost.append(cost) print(min(listcost)) if __name__=='__main__': main()
Traceback (most recent call last): File "/tmp/tmpvjcvyktb/tmpk57jmjzp.py", line 16, in <module> main() File "/tmp/tmpvjcvyktb/tmpk57jmjzp.py", line 2, in main n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s283103077
p04031
u543373102
1594874531
Python
Python (3.8.2)
py
Runtime Error
25
8888
181
N = int(input()) an = list(map(int, input())) cost = 10000*3 ans = 10000*3 for i in range(-100,100+1): cost = sum([(j - i)**2 for j in an]) ans = min(ans, cost) print(ans)
Traceback (most recent call last): File "/tmp/tmpt0ef80k1/tmpocz4xxe2.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s151570470
p04031
u543373102
1594874470
Python
Python (3.8.2)
py
Runtime Error
25
9128
177
N = int(input()) an = list(map(int, input())) cost = 10000 ans = 10000 for i in range(-100,100+1): cost = sum([(j - i)**2 for j in an]) ans = min(ans, cost) print(ans)
Traceback (most recent call last): File "/tmp/tmpchlijlc3/tmpdmoowed6.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s619979029
p04031
u543373102
1594874343
Python
Python (3.8.2)
py
Runtime Error
24
9208
188
N = int(input()) an = list(map(int, input())) cost = 10000 ans = 10000 for i in range(-100,100+1): cost = sum([(j - i)**2 for j in range(1, N+1)]) ans = min(ans, cost) print(ans)
Traceback (most recent call last): File "/tmp/tmpz8zpufpz/tmpwyvv8oyz.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s228248453
p04031
u543373102
1594874274
Python
Python (3.8.2)
py
Runtime Error
27
9148
180
N = int(input()) an = list(map(int, input())) cost = 0 ans = 0 for i in range(-100,100+1): cost = sum([(j - i)**2 for j in range(1, N+1)]) ans = min(ans, cost) print(ans)
Traceback (most recent call last): File "/tmp/tmp9q5vc__v/tmp0hpg47sb.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s539909184
p04031
u036104576
1594097593
Python
Python (3.8.2)
py
Runtime Error
26
9140
181
N = int(input()) A = list(map(int, input().split())) ans = INF for i in range(-100, 101): val = 0 for a in A: val += (a - i) ** 2 ans = min(ans, val) print(ans)
Traceback (most recent call last): File "/tmp/tmptyos_zb2/tmppqrok1zt.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s226351470
p04031
u679817762
1593378003
Python
Python (3.8.2)
py
Runtime Error
35
8992
462
#入力 N = int(input()) lst = input().split() #整数値化 for i in range(len(lst)): lst[i] = int(lst[i]) #ソート lst.sort() #コスト計算関数 def get_cost(x, y): return (x - y) ** 2 costs = [] #コスト計算 for i in range(lst[0], lst[-1]): #入力値の最小値から最大値まで cost = 0 for j in lst: cost = cost + get_cost(j, i) costs.append(cost) #ソート costs.sort() #最小コストを出力 print(costs[0])
Traceback (most recent call last): File "/tmp/tmpno6iy6rn/tmpf08wo3x_.py", line 2, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s632659416
p04031
u697615293
1593093977
Python
Python (3.8.2)
py
Runtime Error
23
9100
128
a = int(input()) b = list(map(int,input().split())) c = int(input()) d = 0 for i in b: d += (int(i) - int(c)) ** 2 print(d)
Traceback (most recent call last): File "/tmp/tmpfv5v2b3o/tmpda1g5ijk.py", line 1, in <module> a = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s422331783
p04031
u679089074
1589744997
Python
Python (3.4.3)
py
Runtime Error
17
2940
142
N = int(input()) an = list(map(int,input().split())) ave = round((sum(an)/N),0) ans = 0 for i in an: ans += (i-ave)**2 print(inst(ans))
Traceback (most recent call last): File "/tmp/tmp3xevhlo4/tmpxkezuajo.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s911681694
p04031
u679089074
1589744959
Python
Python (3.4.3)
py
Runtime Error
18
3060
153
N = int(input()) an = list(map(int,input().split())) ave = round((sum(an)/N),0) print(ave) ans = 0 for i in an: ans += (i-ave)**2 print(inst(ans))
Traceback (most recent call last): File "/tmp/tmpkpdft4fz/tmpsvg4t5uz.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s321113679
p04031
u161857411
1589328139
Python
Python (3.4.3)
py
Runtime Error
17
3064
286
garbage = input() num = list(map(int, input().split())) cost = [] for i in range(0,100): plus_val = (num[0]-i)**2+(num[1]-i)**2+(num[2]-i)**2 minus_val = (num[0]+i)**2+(num[1]+i)**2+(num[2]+i)**2 cost.append(plus_val) cost.append(minus_val) min_val = min(cost) print(min_val)
Traceback (most recent call last): File "/tmp/tmpjeql88sf/tmp5oam7e7r.py", line 1, in <module> garbage = input() ^^^^^^^ EOFError: EOF when reading a line
s410015200
p04031
u161857411
1589328067
Python
Python (3.4.3)
py
Runtime Error
18
3064
286
garbage = input() num = list(map(int, input().split())) cost = [] for i in range(0,100): plus_val = (num[0]-i)**2+(num[1]-i)**2+(num[2]-i)**2 minus_val = (num[0]-i)**2+(num[1]-i)**2+(num[2]-i)**2 cost.append(plus_val) cost.append(minus_val) min_val = min(cost) print(min_val)
Traceback (most recent call last): File "/tmp/tmp2vga3vk_/tmpazxwmhfn.py", line 1, in <module> garbage = input() ^^^^^^^ EOFError: EOF when reading a line
s099321713
p04031
u161857411
1589327809
Python
Python (3.4.3)
py
Runtime Error
17
3064
323
garbage = input() num = list(map(int, input().split())) d = [] for n in num: d.append((n-num[0])**2) if(sum(d)==0): print(0) else: max_num = max(num) min_num = min(num) cost = [] for i in range(min_num,max(num)): cost.append((num[0]-i)**2+(num[1]-i)**2+(num[2]-i)**2) min_val = min(cost) print(min_val)
Traceback (most recent call last): File "/tmp/tmp12u_wkxx/tmp7ztj0m32.py", line 1, in <module> garbage = input() ^^^^^^^ EOFError: EOF when reading a line
s612827512
p04031
u161857411
1589327329
Python
Python (3.4.3)
py
Runtime Error
17
3064
318
garbage = input() num = list(map(int, input().split())) d = [] for n in num: d.append(n-num[0]) if(sum(d)==0): print(0) else: max_num = max(num) min_num = min(num) cost = [] for i in range(min_num,max(num)): cost.append((num[0]-i)**2+(num[1]-i)**2+(num[2]-i)**2) min_val = min(cost) print(min_val)
Traceback (most recent call last): File "/tmp/tmp5ebizbvn/tmprfxnpeav.py", line 1, in <module> garbage = input() ^^^^^^^ EOFError: EOF when reading a line
s916716465
p04031
u586206420
1588694700
Python
Python (3.4.3)
py
Runtime Error
36
5148
251
import statistics as st import math int(input()) s = list(map(int, input().split())) md = math.floor(st.mean(s)) mu = avedown + 1 sd = 0 su = 0 for i in range(0, len(s)): sd = sd + (s[i] - md) ** 2 su = su + (s[i] - mu) ** 2 print(min(sd, su))
Traceback (most recent call last): File "/tmp/tmpax3g5v9m/tmp_xr9u4rh.py", line 3, in <module> int(input()) ^^^^^^^ EOFError: EOF when reading a line
s428118841
p04031
u308918401
1587940387
Python
Python (3.4.3)
py
Runtime Error
18
3064
201
n=int(input()) a=input() b=[] for i in range(n): b.append(int(a[i*2])) ave=sum(b)/n if ave<int(ave)+0.5: ave=int(ave) else: ave=int(ave)+1 ans=0 for i in range(n): ans+=(b[i]-ave)**2 print(ans)
Traceback (most recent call last): File "/tmp/tmpwaqknm_3/tmp2ycbfkax.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s410992423
p04031
u308918401
1587940296
Python
Python (3.4.3)
py
Runtime Error
18
3064
196
n=int(input()) a=input() b=[] for i in range(n): b.append(a[i*2]) ave=sum(b)/n if ave<int(ave)+0.5: ave=int(ave) else: ave=int(ave)+1 ans=0 for i in range(n): ans+=(b[i]-ave)**2 print(ans)
Traceback (most recent call last): File "/tmp/tmp3waai_hw/tmpk0not3cf.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s159874648
p04031
u870518235
1587521762
Python
Python (3.4.3)
py
Runtime Error
25
2940
198
N = int(input()) A = list(map(int,input().split())) R = [] for i in range(min(A), max(A)): cost = 0 for j in range(len(A)): cost += (i - A[j])**2 R.append(cost) print(min(R))
Traceback (most recent call last): File "/tmp/tmpr9gp84aj/tmpyuzzqfzi.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s947939470
p04031
u423665486
1587010509
Python
PyPy3 (2.4.0)
py
Runtime Error
168
38256
213
import math def resolve(): _ = int(input()) a = list(map(int, input().split())) ans = math.inf for i in range(-100, 101): s = 0 for j in a: s += (i-j)**2 if ans > s: ans = s print(ans) resolve()
Traceback (most recent call last): File "/tmp/tmp4k4ufbu4/tmpcfqztpmi.py", line 14, in <module> resolve() File "/tmp/tmp4k4ufbu4/tmpcfqztpmi.py", line 4, in resolve _ = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s404177338
p04031
u342456871
1586990407
Python
Python (3.4.3)
py
Runtime Error
17
2940
167
import statistics n = int(input()) a = list(map(int, input().split()) me = statistics.median(a) ans = 0 for i in range(n): ans += (abs(me, a[i]))**2 print(ans)
File "/tmp/tmp6oe7awlg/tmpv2gof7vk.py", line 4 a = list(map(int, input().split()) ^ SyntaxError: '(' was never closed
s281293712
p04031
u060736237
1586387253
Python
Python (3.4.3)
py
Runtime Error
17
3060
161
import math n = int(input()) a = list(map(int, input().split())) work = math.round(sum(a)/n, 0) result = 0 for el in a: result += (work-el)**2 print(result)
Traceback (most recent call last): File "/tmp/tmp5mh6o8nc/tmpis8n9x96.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s688618002
p04031
u520276780
1584334543
Python
PyPy3 (2.4.0)
py
Runtime Error
185
38640
206
#numpy使ってみる import numpy as np n = int(input()) a = np.array(list(map(int, input().split( )))) ans = 10**10 for i in range(-100,101): tmp = ((a-i)**2).sum() ans = min(tmp,ans) print(ans)
Traceback (most recent call last): File "/tmp/tmpvecz69mz/tmpucwbe9eh.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s738384778
p04031
u738341948
1583236772
Python
Python (3.4.3)
py
Runtime Error
17
3060
181
n = int(input()) a = list(map(int,input().split())) ans = 10**9 for ai in range(min(a),max(a)+1): w = 0 for aj in ai: w += (ai-aj)**2 ans = min(w,ans) print(ans)
Traceback (most recent call last): File "/tmp/tmpkufyzl60/tmp5y8gym5x.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s700183523
p04031
u738341948
1583236727
Python
Python (3.4.3)
py
Runtime Error
17
3060
187
n = int(input()) a = list(map(int,input().split().strip())) ans =10**9 for ai in range(min(a),max(a)+1): w = 0 for aj in a: w += (ai-aj)**2 ans = min(w,ans) print(ans)
Traceback (most recent call last): File "/tmp/tmpkuw0mz6e/tmpcyj077s_.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s862808757
p04031
u738341948
1583236583
Python
Python (3.4.3)
py
Runtime Error
17
3060
185
n = int(input()) a = list(map(int,input().split().strip())) ans =10**9 for ai in range(min(a),max(a)): w = 0 for aj in a: w += (ai-aj)**2 ans = min(w,ans) print(ans)
Traceback (most recent call last): File "/tmp/tmp2fn8rs85/tmpb3ggcn3w.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s399725401
p04031
u738341948
1583236551
Python
Python (3.4.3)
py
Runtime Error
18
3060
186
n = int(input()) a = list(map(int,input().split().strip())) ans =10**9 for ai in range(min(a),max(a)): w = 0 for aj in ai: w += (ai-aj)**2 ans = min(w,ans) print(ans)
Traceback (most recent call last): File "/tmp/tmpbv0x46w9/tmp2oquoz51.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s459202690
p04031
u068584789
1582495740
Python
Python (3.4.3)
py
Runtime Error
17
2940
353
def main(): n = int(input()) nums = list(map(int, input())) cmin = 0 for x in nums: cmin += (x - min(nums)) ** 2 for i in range(min(nums), max(nums)+1): c = getcost(i, nums) if c < cmin: cmin = c print(cmin) def getcost(x, nums): c = 0 for n in nums: c += (n - x) ** 2 return c if __name__ == '__main__': main()
File "/tmp/tmpvai55zpn/tmps_i47s7b.py", line 6 cmin += (x - min(nums)) ** 2 TabError: inconsistent use of tabs and spaces in indentation
s891298719
p04031
u881116515
1582240741
Python
Python (3.4.3)
py
Runtime Error
34
5076
234
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN n = int(input()) a = list(map(int,input().split())) h = Decimal(str(sum(a)/n).quantize(Decimal('0'), rounding=ROUND_HALF_UP)) a = list(map(lambda x:(x-h)**2,a)) print(sum(a))
Traceback (most recent call last): File "/tmp/tmpfp0jrjwg/tmpxw3c8n6d.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s972841752
p04031
u995861601
1582172526
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38256
227
n = int(input()) l = list(map(int, input().split())) mn = min(l) mx = max(l) ms = 10**9 ll = [0]*n for j in range(mn, mx+1): for i in range(n): ll[i] = (l[i] - j)**2 s = sum(ll) ms = min(ms, s) print(ms)
File "/tmp/tmpmpxgj58n/tmpbw8ec4b_.py", line 11 ll[i] = (l[i] - j)**2 ^ IndentationError: unindent does not match any outer indentation level
s054275488
p04031
u269408023
1581711886
Python
Python (3.4.3)
py
Runtime Error
17
3064
382
#include<bits/stdc++.h> using namespace std; int S(vector<int> a,int N,int M){ int S=0; for(int i=0;i<N;i++){ S+=(a.at(i)-M)*(a.at(i)-M); } return S; } int main(){ int N,V; cin >> N; vector<int> a(N); for(int i=0;i<N;i++){ cin >> a.at(i); } V=S(a,N,-100); for(int i=0;i<201;i++){ if(S(a,N,-100+i)<V) V=S(a,N,-100+i); } cout << V << endl; }
File "/tmp/tmpcfwxg9ah/tmpiv3umrq7.py", line 2 using namespace std; ^^^^^^^^^ SyntaxError: invalid syntax
s270973474
p04031
u953794676
1581709127
Python
Python (3.4.3)
py
Runtime Error
25
3060
222
n = int(input()) a = [int(e) for e in input().split()] ans = float("inf") MIN, MAX = min(a), max(a) for i in range(MIN, MAX): cost = 0 for j in a: cost = cost + (i-j)**2 ans = min(ans, cost) print(cost)
Traceback (most recent call last): File "/tmp/tmpgcjd6a9f/tmpof40duw1.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s641109706
p04031
u736995123
1580444082
Python
Python (3.4.3)
py
Runtime Error
17
3060
241
n = int(input()) s = map(int, input().split()) def solution(s): cost = 0 mean = round(sum(s)/len(s)) for i in s: cost += abs(i-mean) ** 2 #print(f"DEBUG >> {mean} {i} {cost}") return cost print(solution(s))
Traceback (most recent call last): File "/tmp/tmpontxl2b7/tmp44owsfy7.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s399975804
p04031
u857070771
1580233652
Python
Python (3.4.3)
py
Runtime Error
152
13288
161
import numpy as np n=int(input()) a=np.array([int(x) for x in input().split()]) x=[] for i in range(np.max(a)): s=np.sum((a-i)*(a-i)) x.append(s) print(min(x))
Traceback (most recent call last): File "/tmp/tmpmud1rdll/tmpx65kqn14.py", line 2, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s537937852
p04031
u867848444
1579058255
Python
Python (3.4.3)
py
Runtime Error
17
3064
197
a=list(map(int,input().split())) a=sorted(a) a_ave=a[0]+a[-1] num1=a_ave//2 num2=a_ave//2+1 ans1=0 ans2=0 for i in range(n): ans1+=(num1-a[i])**2 ans2+=(num2-a[i])**2 print(min(ans1,ans2))
Traceback (most recent call last): File "/tmp/tmp1idlxlmx/tmpw2i2dkmi.py", line 1, in <module> a=list(map(int,input().split())) ^^^^^^^ EOFError: EOF when reading a line
s558907564
p04031
u898967808
1578370502
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38512
184
import numpy as np n = int(input()) aa = np.array(list(map(int,input().split()))) ans = float('inf') for i in range(min(aa),max(aa)+1): ans = min(ans,sum((aa-i)**2)) print(ans)
Traceback (most recent call last): File "/tmp/tmpcnaa4o4x/tmpyigfuj70.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s515394074
p04031
u327532412
1577474235
Python
Python (3.4.3)
py
Runtime Error
21
3316
172
import math n = int(input()) *a, = map(int, input()) atai = math.ceil(sum(a) / n) ans = 0 for x in a: if x == atai: pass else: ans += (x - atai) ** 2 print(ans)
Traceback (most recent call last): File "/tmp/tmpipxbg523/tmp1qepqzn7.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s868185045
p04031
u810457760
1577324046
Python
Python (3.4.3)
py
Runtime Error
17
3060
113
n = int(input()) a = list(map(int, input())) s = round(sum(a)/n) ans = 0 for i in a: ans += (i-s)**2 print(ans)
Traceback (most recent call last): File "/tmp/tmpi29sg4fb/tmpr9z84iqa.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s581680180
p04031
u688375653
1576377011
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38384
505
def two_int(): N, K = map(int, input().split()) return N,K def one_int(): return int(input()) def one_str(): return input() def many_int(): return list(map(int, input().split())) N=one_int() X=many_int() sort_X=sorted(X) min_X = sort_X[0] max_X = sort_X[1] min_num = 0 min_sum = 99999999999 for i in range(min_X, max_X+1): temp_sum = 0 for j in X: temp_sum += (j-i)**2 if temp_sum < min_sum: min_sum = temp_sum min_num = i print(min_num)
Traceback (most recent call last): File "/tmp/tmpfzpgc5v2/tmp93g3hr70.py", line 14, in <module> N=one_int() ^^^^^^^^^ File "/tmp/tmpfzpgc5v2/tmp93g3hr70.py", line 6, in one_int return int(input()) ^^^^^^^ EOFError: EOF when reading a line
s061118622
p04031
u875600867
1576340506
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38256
305
import sys # N個の整数 N = int(input()) a = list(map(int, input().split())) ans = 10**18 # いくつに書き換えるか for i in range(min(a),max(a)): tmp=0 for j in range(N): # 書き換える or 書き換えない tmp += (a[j]-i)**2 ans=min(cost,tmp) print(ans)
Traceback (most recent call last): File "/tmp/tmp9ipz6cav/tmp7d_a7fbb.py", line 4, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s111565158
p04031
u159290087
1574987916
Python
Python (3.4.3)
py
Runtime Error
17
3060
451
import math n = int(input()) nums = list(map(int, input().split())) avg_ceil = math.ceil(sum(nums) / len(nums)) avg_floor = math.floor(sum(nums) / len(nums)) cost_ceil = 0 cost_floor = 0 for x in nums: if x == avg_ceil: continue cost_ceil += (x - avg_ceil)**2 for x in nums: if x == avg_floor: continue cost_floor += (x - avg_floor)**2 if cost_ceil <= cost_floor: print(cost_ceil) else print(cost_floor)
File "/tmp/tmp0arxjrg5/tmpvs9r5u7p.py", line 24 else ^ SyntaxError: expected ':'
s146290970
p04031
u172569352
1574346861
Python
Python (3.4.3)
py
Runtime Error
17
2940
135
import math N = int(input()) a = [int(i) for i in input().split()] b = math.round(sum(a)/N) c = sum([(i - b)**2 for i in a]) print(c)
Traceback (most recent call last): File "/tmp/tmpmkwht0oe/tmpzdvi71ze.py", line 3, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s442278338
p04031
u248670337
1573831788
Python
Python (3.4.3)
py
Runtime Error
17
2940
132
n=int(input()) A=list(map(int,input().split())) m=sum(A)//n print(max(sum(map(lambda x:(x-m)**2,A)),sum(map(lambda x:(x-m-1)**2,A)))
File "/tmp/tmpxv5s8shn/tmpslcebs_c.py", line 4 print(max(sum(map(lambda x:(x-m)**2,A)),sum(map(lambda x:(x-m-1)**2,A))) ^ SyntaxError: '(' was never closed
s288904312
p04031
u779728630
1573624864
Python
Python (3.4.3)
py
Runtime Error
17
2940
178
N = int(input()) L = [int(input()) for i in range(N)] r = 200*100 for i in range(-100,101): res = 0 for j in range(N): res += (L[j] - i) ** 2 r = min(r, res) print(r)
Traceback (most recent call last): File "/tmp/tmpzxtu6odw/tmps01w1zhx.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s778290795
p04031
u638795007
1573276017
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38640
471
def examC(): N = I() a = LI() lower = min(a) L = (max(a)-min(a)) cur = [0]*L for i in range(L): for j in range(N): cur[i] +=(a[j]-(i+lower))**2 ans = min(cur) print(ans) import sys def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) def LS(): return sys.stdin.readline().split() def S(): return sys.stdin.readline().strip() mod = 10**9 + 7 inf = float('inf') examC()
Traceback (most recent call last): File "/tmp/tmpj82d7uj1/tmpczorbfjn.py", line 21, in <module> examC() File "/tmp/tmpj82d7uj1/tmpczorbfjn.py", line 2, in examC N = I() ^^^ File "/tmp/tmpj82d7uj1/tmpczorbfjn.py", line 14, in I def I(): return int(sys.stdin.readline()) ^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: ''
s974309191
p04031
u021759654
1573269996
Python
Python (3.4.3)
py
Runtime Error
17
3060
309
n = int(input()) a_list = list(map(int, input().split())) b = sum(a_list)//n def temp(a): return (a-b)^2 def temp2(a): return (a-b-1)^2 ans1 = sum(list(map(temp, a))) ans2 = sum(list(map(temp2, a))) #ans1 = sum([(a-b)^2 for a in a_list]) #ans2 = sum([(a-b-1)^2 for a in a_list]) print(min(ans1,ans2))
Traceback (most recent call last): File "/tmp/tmp5phdspki/tmpx7q643le.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s664758582
p04031
u755616667
1572727633
Python
PyPy3 (2.4.0)
py
Runtime Error
160
38256
173
from statistics import mean N = int(input()) a = list(map(int, input().split())) target = round(mean(a)) cost = 0 for num in a: cost += (num - target)**2 print(cost)
Traceback (most recent call last): File "/tmp/tmprjfn05kj/tmpymmg68i4.py", line 3, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s154272517
p04031
u557494880
1572523158
Python
Python (3.4.3)
py
Runtime Error
17
2940
213
import math N = int(input()) a = list(map(int,input().split()) s = 0 t = 0 for i in range(N): s += a[i] t += (a[i])**2 a = math.floor(s/N) if (s/N) - a > 0.5: a += 1 ans = N*a**2 - 2*s*a + t print(ans)
File "/tmp/tmpb0mma7g4/tmpb2wli37r.py", line 3 a = list(map(int,input().split()) ^ SyntaxError: '(' was never closed
s493949232
p04031
u100418016
1572330703
Python
Python (3.4.3)
py
Runtime Error
17
3060
161
l_si = input().split(" ") l_si_i = [int(s) for s in l_si] sm = sum(l_si_i) av = round(sm /dv) ret = 0 for it in l_si_i: ret = ret + (it -av) **2 print(ret)
Traceback (most recent call last): File "/tmp/tmpgzzzv505/tmpcansjq8z.py", line 1, in <module> l_si = input().split(" ") ^^^^^^^ EOFError: EOF when reading a line
s389849626
p04031
u136090046
1571608600
Python
Python (3.4.3)
py
Runtime Error
17
3064
670
n = int(input()) a_array = [int(x) for x in input().split()] sum_a = sum(a_array) if sum_a % 2 == 0: sum_a = int(sum_a/len(a_array)) ans = 0 for a in a_array: ans += abs(sum_a-a)**2 print(sum_a) print(int(ans)) else: sum_a1 = int(sum_a/len(a_array)) sum_a2 = int(sum_a/len(a_array))+1 ans1 = 0 ans2 = 0 for a in a_array: ans1 += abs(sum_a1-a)**2 ans2 += abs(sum_a2-a)**2 print(int(min(ans1, ans2))) n = int(input()) a_array = [int(x) for x in input().split()] ans = float("inf") for i in range(-100, 101): tmp = 0 for a in a_array: tmp += abs(a-i)**2 ans = min(ans, tmp) print(ans)
Traceback (most recent call last): File "/tmp/tmp11lc5ebx/tmp9cmc7z3u.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s613985643
p04031
u606878291
1571288016
Python
Python (3.4.3)
py
Runtime Error
23
3664
785
import math from functools import lru_cache # from decimal import Decimal, ROUND_HALF_UP # def quantize(f): # return int(Decimal(str(f)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)) @lru_cache(maxsize=4096) def get_cost(x, y): if x == y: return 0 else: return int(math.pow((x - y), 2)) def get_costs(target, numbers): return sum([get_cost(target, n) for n in numbers]) def check(n, numbers): n_max = max(numbers) n_min = min(numbers) costs = [] for target in range(n_min, n_max + 1): costs.append(get_costs(target=target, numbers=numbers)) return min(costs) def main(): N = int(input()) numbers = map(int, input().split()) print(check(n=N, numbers=numbers)) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmp9bkacoh5/tmpde0n7mdg.py", line 40, in <module> main() File "/tmp/tmp9bkacoh5/tmpde0n7mdg.py", line 34, in main N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s046774743
p04031
u606878291
1571287896
Python
Python (3.4.3)
py
Runtime Error
18
3064
741
import math # from functools import lru_cache # from decimal import Decimal, ROUND_HALF_UP # def quantize(f): # return int(Decimal(str(f)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)) # @lru_cache(maxsize=4096) def get_cost(x, y): return int(math.pow(x - y, 2)) def get_costs(target, numbers): return sum([get_cost(target, n) for n in numbers]) def check(n, numbers): n_max = max(numbers) n_min = min(numbers) costs = [] for target in range(n_min, n_max + 1): costs.append(get_costs(target=target, numbers=numbers)) return min(costs) def main(): N = int(input()) numbers = map(int, input().split()) print(check(n=N, numbers=numbers)) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpv8anzwpp/tmpljua13os.py", line 37, in <module> main() File "/tmp/tmpv8anzwpp/tmpljua13os.py", line 31, in main N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s811299199
p04031
u606878291
1571287802
Python
Python (3.4.3)
py
Runtime Error
23
3664
737
import math from functools import lru_cache # from decimal import Decimal, ROUND_HALF_UP # def quantize(f): # return int(Decimal(str(f)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)) @lru_cache(maxsize=4096) def get_cost(x, y): return int(math.pow(x - y, 2)) def get_costs(target, numbers): return sum([get_cost(target, n) for n in numbers]) def check(n, numbers): n_max = max(numbers) n_min = min(numbers) costs = [] for target in range(n_min, n_max + 1): costs.append(get_costs(target=target, numbers=numbers)) return min(costs) def main(): N = int(input()) numbers = map(int, input().split()) print(check(n=N, numbers=numbers)) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmp3f7fu7gk/tmpmh33ujrl.py", line 37, in <module> main() File "/tmp/tmp3f7fu7gk/tmpmh33ujrl.py", line 31, in main N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s576460845
p04031
u606878291
1571287695
Python
Python (3.4.3)
py
Runtime Error
36
5204
721
import math from decimal import Decimal, ROUND_HALF_UP from functools import lru_cache def quantize(f): return int(Decimal(str(f)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)) @lru_cache(maxsize=4096) def get_cost(x, y): return int(math.pow(x - y, 2)) def get_costs(target, numbers): return sum([get_cost(target, n) for n in numbers]) def check(n, numbers): n_max = max(numbers) n_min = min(numbers) costs = [] for n in range(n_min, n_max + 1): costs.append(get_costs(target=n, numbers=numbers)) return min(costs) def main(): N = int(input()) numbers = map(int, input().split()) print(check(n=N, numbers=numbers)) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpo8kk4_hd/tmp1qha32va.py", line 37, in <module> main() File "/tmp/tmpo8kk4_hd/tmp1qha32va.py", line 31, in main N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s728726780
p04031
u670180528
1568960202
Python
Python (3.4.3)
py
Runtime Error
409
25088
119
from scipy.optimize import*;n,a=open(0) print(round(minimize(lambda x:sum((x-int(b))**2 for b in a.split()),0)["fun"]))
Traceback (most recent call last): File "/tmp/tmpz7a8b8f8/tmprujrbkex.py", line 1, in <module> from scipy.optimize import*;n,a=open(0) ^^^ ValueError: not enough values to unpack (expected 2, got 0)
s461047419
p04031
u760767494
1568604800
Python
Python (3.4.3)
py
Runtime Error
17
3064
288
import sympy as sym N = int(input()) l = list(map(int, input().split())) expr = 0 x = sym.symbols("x") for i in range(N): expr = expr + (l[i] - x)**2 eq = sym.Eq(sym.Derivative(expr).doit()) a = sym.solve(eq, x) # print(a) a = a[0] a = round(a) # print(a) a = expr.subs(x, a) print(a)
Traceback (most recent call last): File "/tmp/tmptbwm8fl8/tmpifdyvig8.py", line 2, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s496088379
p04031
u897328029
1567791880
Python
PyPy3 (2.4.0)
py
Runtime Error
179
38256
455
# https://atcoder.jp/contests/abc043/tasks/arc059_a # C - いっしょ / Be Together import statistics N = int(input().split()[0]) a_list = list(map(int, input().split())) min_a, max_a = min(a_list), max(a_list) w_list = list(range(min_a, max_a+1)) m1 = statistics.median_low(w_list) m2 = statistics.median_high(w_list) cost_1 = 0 cost_2 = 0 for a in a_list: cost_1 += (a - m1) ** 2 cost_2 += (a - m2) ** 2 ans = min(cost_1, cost_2) print(ans)
Traceback (most recent call last): File "/tmp/tmp9wl7swh5/tmpk2bvo5we.py", line 4, in <module> N = int(input().split()[0]) ^^^^^^^ EOFError: EOF when reading a line
s755987762
p04031
u181195295
1567731368
Python
Python (3.4.3)
py
Runtime Error
17
3060
208
def cul(li,s): for i in li: a += (i - s)^2 return a N = int(input()) li = list(map(int,input().split())) s1 = sum(li)//len(li) s2 = s1 + 1 ans1 = cul(li,s1) ans2 = cul(li,s2) print(min(ans1,ans2))
Traceback (most recent call last): File "/tmp/tmpa9go78q2/tmpvsai5sjj.py", line 6, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s344986826
p04031
u652057333
1566991928
Python
PyPy3 (2.4.0)
py
Runtime Error
178
38256
278
from math import ceil n = int(input()) a = list(map(int, input().split())) ans = 10**10 m1 = a[ceil(n/2)] m2 = int(sum(a) / n) m3 = ceil(sum(a) / n) for v in [m1, m2, m3]: cost = 0 for i in range(n): cost += (a[i] - v) ** 2 ans = min(cost, ans) print(ans)
Traceback (most recent call last): File "/tmp/tmpxir6_3l4/tmpucc1a3uj.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s371044852
p04031
u536377809
1565483791
Python
PyPy3 (2.4.0)
py
Runtime Error
176
38768
124
n=int(input()) print(min([sum([(x-item)**2 for x in [int(x) for x in input().split()]]) for item in list(range(-100,101))]))
Traceback (most recent call last): File "/tmp/tmp57l04tie/tmpk6h_w391.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s545367690
p04031
u366959492
1563550608
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38896
164
n=int(input()) a=list(map(int,input().split())) l=[] for x in range(-100,101): c=0 for i in range(n): c+=(a[i]-x)**2 l.append(c) print(min(c))
Traceback (most recent call last): File "/tmp/tmpous458f4/tmpn5w2iip2.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line