user_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
1 value
submission_id_v0
stringlengths
10
10
submission_id_v1
stringlengths
10
10
cpu_time_v0
int64
10
38.3k
cpu_time_v1
int64
0
24.7k
memory_v0
int64
2.57k
1.02M
memory_v1
int64
2.57k
869k
status_v0
stringclasses
1 value
status_v1
stringclasses
1 value
improvement_frac
float64
7.51
100
input
stringlengths
20
4.55k
target
stringlengths
17
3.34k
code_v0_loc
int64
1
148
code_v1_loc
int64
1
184
code_v0_num_chars
int64
13
4.55k
code_v1_num_chars
int64
14
3.34k
code_v0_no_empty_lines
stringlengths
21
6.88k
code_v1_no_empty_lines
stringlengths
20
4.93k
code_same
bool
1 class
relative_loc_diff_percent
float64
0
79.8
diff
list
diff_only_import_comment
bool
1 class
measured_runtime_v0
float64
0.01
4.45
measured_runtime_v1
float64
0.01
4.31
runtime_lift
float64
0
359
key
list
u708255304
p02807
python
s634821934
s950740171
700
218
74,656
26,748
Accepted
Accepted
68.86
# 二項係数を"やるだけ"にしてくれるライブラリ MAX = 510000 MOD = 1000000007 factrial = [0]*MAX inverse = [0]*MAX factrial_inverse = [0]*MAX # テーブルを作る前処理 def COMinit(): global factrial, inverse, factrial_inverse factrial[0] = 1 factrial[1] = 1 inverse[1] = 1 factrial_inverse[0] = 1 factrial_inverse[1...
# 二項係数を"やるだけ"にしてくれるライブラリ MAX = 100005 MOD = 1000000007 factrial = [0]*MAX inverse = [0]*MAX factrial_inverse = [0]*MAX # テーブルを作る前処理 def COMinit(): global factrial, inverse, factrial_inverse factrial[0] = 1 factrial[1] = 1 inverse[1] = 1 factrial_inverse[0] = 1 factrial_inverse[1...
50
49
1,123
1,087
# 二項係数を"やるだけ"にしてくれるライブラリ MAX = 510000 MOD = 1000000007 factrial = [0] * MAX inverse = [0] * MAX factrial_inverse = [0] * MAX # テーブルを作る前処理 def COMinit(): global factrial, inverse, factrial_inverse factrial[0] = 1 factrial[1] = 1 inverse[1] = 1 factrial_inverse[0] = 1 factrial_inverse[1] = 1 f...
# 二項係数を"やるだけ"にしてくれるライブラリ MAX = 100005 MOD = 1000000007 factrial = [0] * MAX inverse = [0] * MAX factrial_inverse = [0] * MAX # テーブルを作る前処理 def COMinit(): global factrial, inverse, factrial_inverse factrial[0] = 1 factrial[1] = 1 inverse[1] = 1 factrial_inverse[0] = 1 factrial_inverse[1] = 1 f...
false
2
[ "-MAX = 510000", "+MAX = 100005", "-# expected_value = [1]", "-# for i in range(2, N):", "-# expected_value.append(expected_value[-1]+(1/i))", "-f = factrial[N - 1]", "-c = 0", "-for i in range(1, N):", "- c += f * inverse[i]", "- c %= MOD", "- ans += c * (X[i] - X[i - 1])", "- ...
false
1.295694
0.195219
6.637121
[ "s634821934", "s950740171" ]
u747602774
p02754
python
s678727315
s379745745
19
17
3,064
2,940
Accepted
Accepted
10.53
N,A,B = list(map(int,input().split())) a = N//(A+B) ans = a*A + min((N-a*(A+B)),A) print(ans)
N,A,B = list(map(int,input().split())) print((N//(A+B)*A + min((N-N//(A+B)*(A+B)),A)))
4
2
91
80
N, A, B = list(map(int, input().split())) a = N // (A + B) ans = a * A + min((N - a * (A + B)), A) print(ans)
N, A, B = list(map(int, input().split())) print((N // (A + B) * A + min((N - N // (A + B) * (A + B)), A)))
false
50
[ "-a = N // (A + B)", "-ans = a * A + min((N - a * (A + B)), A)", "-print(ans)", "+print((N // (A + B) * A + min((N - N // (A + B) * (A + B)), A)))" ]
false
0.068197
0.070041
0.973675
[ "s678727315", "s379745745" ]
u853952087
p03221
python
s557518269
s293201884
1,039
923
43,172
43,172
Accepted
Accepted
11.16
a,b=list(map(int,input().split())) L=[[] for i in range(a)] u=0 for i in range(b): u+=1 c=list(map(int,input().split())) c.append(u) L[int(c[0])-1].append(c) for i in L: i.sort(key=lambda x:x[1]) for i in L: e=0 for j in i: e+=1 j.append(e) q=[] for w in L: ...
a,b=list(map(int,input().split())) L=[[] for i in range(a)] u=0 # i番目の県の情報([i,年,入力順])をLのi番目に入れる for i in range(b): u+=1 c=list(map(int,input().split())) c.append(u) L[int(c[0])-1].append(c) # Lの要素を年でソート for i in L: i.sort(key=lambda x:x[1]) # ソートしたので、要素ごとに何番目にできたかを末尾に付け加えておく for i in L:...
21
25
435
563
a, b = list(map(int, input().split())) L = [[] for i in range(a)] u = 0 for i in range(b): u += 1 c = list(map(int, input().split())) c.append(u) L[int(c[0]) - 1].append(c) for i in L: i.sort(key=lambda x: x[1]) for i in L: e = 0 for j in i: e += 1 j.append(e) q = [] for w in...
a, b = list(map(int, input().split())) L = [[] for i in range(a)] u = 0 # i番目の県の情報([i,年,入力順])をLのi番目に入れる for i in range(b): u += 1 c = list(map(int, input().split())) c.append(u) L[int(c[0]) - 1].append(c) # Lの要素を年でソート for i in L: i.sort(key=lambda x: x[1]) #  ソートしたので、要素ごとに何番目にできたかを末尾に付け加えておく for i i...
false
16
[ "+# i番目の県の情報([i,年,入力順])をLのi番目に入れる", "+# Lの要素を年でソート", "+#  ソートしたので、要素ごとに何番目にできたかを末尾に付け加えておく", "- q.extend(w)", "+ q.extend(w) # flatten", "+# 入力順に並べ替えて、入力した順に出力できるようにする", "- print((str(q[r][0]).zfill(6) + str(q[r][3]).zfill(6)))", "+ print((str(q[r][0]).zfill(6) + str(q[r][3]).zfill(6))) ...
false
0.04594
0.078486
0.585328
[ "s557518269", "s293201884" ]
u620084012
p03221
python
s191384351
s234611687
1,181
985
83,800
81,712
Accepted
Accepted
16.6
N, M = list(map(int,input().split())) L = [list(map(int,input().split())) for k in range(M)] for k in range(M): L[k].append(k) L = sorted(L) A = [[L[0][0],1,L[0][2]]] t = 1 for k in range(1,M): if L[k-1][0] != L[k][0]: t = 1 else: t += 1 A.append([L[k][0],t,L[k][2]]) ...
N, M = list(map(int,input().split())) P = [[] for k in range(N)] A = [0 for k in range(M)] for k in range(M): s, t = list(map(int,input().split())) P[s-1].append([t,k]) for k in range(N): P[k].sort() for l in range(len(P[k])): A[P[k][l][1]] = str(k+1).zfill(6) + str(l+1).zfill(6) ...
21
15
417
343
N, M = list(map(int, input().split())) L = [list(map(int, input().split())) for k in range(M)] for k in range(M): L[k].append(k) L = sorted(L) A = [[L[0][0], 1, L[0][2]]] t = 1 for k in range(1, M): if L[k - 1][0] != L[k][0]: t = 1 else: t += 1 A.append([L[k][0], t, L[k][2]]) A = sorted(...
N, M = list(map(int, input().split())) P = [[] for k in range(N)] A = [0 for k in range(M)] for k in range(M): s, t = list(map(int, input().split())) P[s - 1].append([t, k]) for k in range(N): P[k].sort() for l in range(len(P[k])): A[P[k][l][1]] = str(k + 1).zfill(6) + str(l + 1).zfill(6) for a ...
false
28.571429
[ "-L = [list(map(int, input().split())) for k in range(M)]", "+P = [[] for k in range(N)]", "+A = [0 for k in range(M)]", "- L[k].append(k)", "-L = sorted(L)", "-A = [[L[0][0], 1, L[0][2]]]", "-t = 1", "-for k in range(1, M):", "- if L[k - 1][0] != L[k][0]:", "- t = 1", "- else:",...
false
0.033524
0.033964
0.987025
[ "s191384351", "s234611687" ]
u688564053
p02712
python
s538201170
s741268441
132
120
179,368
141,900
Accepted
Accepted
9.09
N = int(eval(input())) l = [i for i in range(1, N + 1)] s = [] for i in l: if i % 3 != 0 and i % 5 != 0: s.append(i) print((sum(s)))
N = int(eval(input())) l = [i for i in range(1, N + 1)] s = 0 for i in l: if i % 3 != 0 and i % 5 != 0: s += i print(s)
7
8
143
133
N = int(eval(input())) l = [i for i in range(1, N + 1)] s = [] for i in l: if i % 3 != 0 and i % 5 != 0: s.append(i) print((sum(s)))
N = int(eval(input())) l = [i for i in range(1, N + 1)] s = 0 for i in l: if i % 3 != 0 and i % 5 != 0: s += i print(s)
false
12.5
[ "-s = []", "+s = 0", "- s.append(i)", "-print((sum(s)))", "+ s += i", "+print(s)" ]
false
0.49187
0.453377
1.084904
[ "s538201170", "s741268441" ]
u102126195
p03032
python
s114404201
s320615503
154
138
76,632
75,748
Accepted
Accepted
10.39
import heapq, copy n, k = list(map(int, input().split())) v = list(map(int, input().split())) ans = -10 ** 10 for a in range(min(n, k) + 1): have = [] for i in range(a): have.append(v[i]) o_have = copy.deepcopy(have) for b in range(min(n, k) - a + 1): for i in range(b): ...
import heapq, copy n, k = list(map(int, input().split())) v = list(map(int, input().split())) ans = -10 ** 10 for a in range(min(n, k) + 1): for b in range(min(n, k) - a + 1): have = [] for i in range(a): have.append(v[i]) for i in range(b): have.a...
30
25
779
636
import heapq, copy n, k = list(map(int, input().split())) v = list(map(int, input().split())) ans = -(10**10) for a in range(min(n, k) + 1): have = [] for i in range(a): have.append(v[i]) o_have = copy.deepcopy(have) for b in range(min(n, k) - a + 1): for i in range(b): have...
import heapq, copy n, k = list(map(int, input().split())) v = list(map(int, input().split())) ans = -(10**10) for a in range(min(n, k) + 1): for b in range(min(n, k) - a + 1): have = [] for i in range(a): have.append(v[i]) for i in range(b): have.append(v[n - i - 1])...
false
16.666667
[ "- have = []", "- for i in range(a):", "- have.append(v[i])", "- o_have = copy.deepcopy(have)", "+ have = []", "+ for i in range(a):", "+ have.append(v[i])", "- # print(1, have)", "- # print(c, item, have)", "- # print(2, have, ans,...
false
0.046857
0.043653
1.073415
[ "s114404201", "s320615503" ]
u891504219
p02773
python
s551093188
s285216352
597
397
45,288
45,288
Accepted
Accepted
33.5
def main(): import sys import collections input = sys.stdin.readline N = int(input()) S = [input() for i in range(N)] c = collections.Counter(S) max_num = c.most_common(1)[0][1] ss = [cc[0] for cc in c.most_common() if cc[1] == max_num] ss.sort() for s in ss: p...
def main(): import sys import collections input = sys.stdin.readline N = int(eval(input())) S = [eval(input()) for i in range(N)] c = collections.Counter(S) max_num = c.most_common(1)[0][1] ss = [cc[0] for cc in c.most_common() if cc[1] == max_num] ss.sort() print(("\n"...
15
14
377
359
def main(): import sys import collections input = sys.stdin.readline N = int(input()) S = [input() for i in range(N)] c = collections.Counter(S) max_num = c.most_common(1)[0][1] ss = [cc[0] for cc in c.most_common() if cc[1] == max_num] ss.sort() for s in ss: print(s, en...
def main(): import sys import collections input = sys.stdin.readline N = int(eval(input())) S = [eval(input()) for i in range(N)] c = collections.Counter(S) max_num = c.most_common(1)[0][1] ss = [cc[0] for cc in c.most_common() if cc[1] == max_num] ss.sort() print(("\n".join(ss)...
false
6.666667
[ "- N = int(input())", "- S = [input() for i in range(N)]", "+ N = int(eval(input()))", "+ S = [eval(input()) for i in range(N)]", "- for s in ss:", "- print(s, end=\"\")", "+ print((\"\\n\".join(ss)))" ]
false
0.041595
0.036332
1.144866
[ "s551093188", "s285216352" ]
u345966487
p03559
python
s802216252
s045786574
354
297
22,720
22,720
Accepted
Accepted
16.1
from bisect import* (N,),A,B,C=[sorted(map(int,input().split()))for _ in range(4)] w,i=[0]*(N+1),N while i:i-=1;w[i]=w[i+1]+N-bisect(C,B[i]) print((sum(w[bisect(B,a)]for a in A)))
from bisect import* (N,),A,B,C=[sorted(map(int,input().split()))for _ in[0]*4] print((sum(bisect_left(A,b)*(N-bisect(C,b))for b in B)))
5
3
181
135
from bisect import * (N,), A, B, C = [sorted(map(int, input().split())) for _ in range(4)] w, i = [0] * (N + 1), N while i: i -= 1 w[i] = w[i + 1] + N - bisect(C, B[i]) print((sum(w[bisect(B, a)] for a in A)))
from bisect import * (N,), A, B, C = [sorted(map(int, input().split())) for _ in [0] * 4] print((sum(bisect_left(A, b) * (N - bisect(C, b)) for b in B)))
false
40
[ "-(N,), A, B, C = [sorted(map(int, input().split())) for _ in range(4)]", "-w, i = [0] * (N + 1), N", "-while i:", "- i -= 1", "- w[i] = w[i + 1] + N - bisect(C, B[i])", "-print((sum(w[bisect(B, a)] for a in A)))", "+(N,), A, B, C = [sorted(map(int, input().split())) for _ in [0] * 4]", "+print(...
false
0.103691
0.047519
2.182114
[ "s802216252", "s045786574" ]
u201928947
p02768
python
s896015068
s498215386
148
126
3,064
9,188
Accepted
Accepted
14.86
def pow(a,b,c): ans = 1 while b > 0: if b & 1: ans = ans*a % c a = a*a % c b = b >> 1 return ans def cmb(a,b,c): b = min(b,a-b) num = 1 for i in range(b): num = num*(n-i) % c den = 1 for i in range(b): den = den*(i+1) % c...
def cmb(a,b,c): b = min(b,a-b) num = 1 for i in range(b): num = num*(n-i) % c den = 1 for i in range(b): den = den*(i+1) % c return num*pow(den,-1,c) % c mod = 10**9+7 n,a,b = list(map(int,input().split())) ans = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod if an...
23
15
507
353
def pow(a, b, c): ans = 1 while b > 0: if b & 1: ans = ans * a % c a = a * a % c b = b >> 1 return ans def cmb(a, b, c): b = min(b, a - b) num = 1 for i in range(b): num = num * (n - i) % c den = 1 for i in range(b): den = den * (i + ...
def cmb(a, b, c): b = min(b, a - b) num = 1 for i in range(b): num = num * (n - i) % c den = 1 for i in range(b): den = den * (i + 1) % c return num * pow(den, -1, c) % c mod = 10**9 + 7 n, a, b = list(map(int, input().split())) ans = (pow(2, n, mod) - cmb(n, a, mod) - cmb(n, b...
false
34.782609
[ "-def pow(a, b, c):", "- ans = 1", "- while b > 0:", "- if b & 1:", "- ans = ans * a % c", "- a = a * a % c", "- b = b >> 1", "- return ans", "-", "-", "- return num * pow(den, c - 2, c) % c", "+ return num * pow(den, -1, c) % c" ]
false
0.171099
0.221708
0.771731
[ "s896015068", "s498215386" ]
u918601425
p03416
python
s650044684
s487688493
46
17
2,940
3,060
Accepted
Accepted
63.04
def palindromeQ(num): if num%10==num//10000: if (num%100)//10==(num//1000)%10: return(1) else: return(0) else: return(0) ans=0 A,B=[int(s) for s in input().split()] for i in range(A,B+1): ans+=palindromeQ(i) print(ans)
A,B=[int(s) for s in input().split()] a=A//100 b=B//100 def pal(num): return num*101-num%10-(num//100)*99 ans=b-a-1 if pal(a)>=A: ans+=1 if pal(b)<=B: ans+=1 print(ans)
14
12
264
188
def palindromeQ(num): if num % 10 == num // 10000: if (num % 100) // 10 == (num // 1000) % 10: return 1 else: return 0 else: return 0 ans = 0 A, B = [int(s) for s in input().split()] for i in range(A, B + 1): ans += palindromeQ(i) print(ans)
A, B = [int(s) for s in input().split()] a = A // 100 b = B // 100 def pal(num): return num * 101 - num % 10 - (num // 100) * 99 ans = b - a - 1 if pal(a) >= A: ans += 1 if pal(b) <= B: ans += 1 print(ans)
false
14.285714
[ "-def palindromeQ(num):", "- if num % 10 == num // 10000:", "- if (num % 100) // 10 == (num // 1000) % 10:", "- return 1", "- else:", "- return 0", "- else:", "- return 0", "+A, B = [int(s) for s in input().split()]", "+a = A // 100", "+b = B // 1...
false
0.048218
0.039974
1.206232
[ "s650044684", "s487688493" ]
u415905784
p03816
python
s196520755
s403390873
56
50
11,820
11,196
Accepted
Accepted
10.71
import functools N = int(eval(input())) A = list(map(int, input().split())) d = [0 for i in range(10 ** 5 + 1)] for a in A: d[a] = 1 s = sum(d) print((s - (0 if s % 2 else 1)))
N = int(eval(input())) A = list(map(int, input().split())) d = [0 for i in range(10 ** 5 + 1)] for a in A: d[a] = 1 s = sum(d) print((s - (0 if s % 2 else 1)))
8
7
173
155
import functools N = int(eval(input())) A = list(map(int, input().split())) d = [0 for i in range(10**5 + 1)] for a in A: d[a] = 1 s = sum(d) print((s - (0 if s % 2 else 1)))
N = int(eval(input())) A = list(map(int, input().split())) d = [0 for i in range(10**5 + 1)] for a in A: d[a] = 1 s = sum(d) print((s - (0 if s % 2 else 1)))
false
12.5
[ "-import functools", "-" ]
false
0.04295
0.04366
0.983727
[ "s196520755", "s403390873" ]
u806403461
p03435
python
s169312152
s370898144
362
62
21,640
3,064
Accepted
Accepted
82.87
import numpy as np c = [[0]*3] * 3 for i in range(3): c[i] = list(map(int, input().split())) c = np.array(c) if len(set(c[0] - c[1])) == 1 and len(set(c[1] - c[2])) == 1 and len(set(c[:,0] - c[:,1])) == 1 and len(set(c[:,1] - c[:,2])) == 1: print("Yes") else: print("No")
grid = list() for a in range(3): a, b, c = list(map(int, input().split())) grid.append([a, b, c]) ans = 'No' for a1 in range(0, 101): for a2 in range(0, 101): b1 = grid[0][0] - a1 b2 = grid[1][1] - a2 a3 = grid[2][1] - b2 b3 = grid[2][2] - a3 a_list =...
15
27
304
611
import numpy as np c = [[0] * 3] * 3 for i in range(3): c[i] = list(map(int, input().split())) c = np.array(c) if ( len(set(c[0] - c[1])) == 1 and len(set(c[1] - c[2])) == 1 and len(set(c[:, 0] - c[:, 1])) == 1 and len(set(c[:, 1] - c[:, 2])) == 1 ): print("Yes") else: print("No")
grid = list() for a in range(3): a, b, c = list(map(int, input().split())) grid.append([a, b, c]) ans = "No" for a1 in range(0, 101): for a2 in range(0, 101): b1 = grid[0][0] - a1 b2 = grid[1][1] - a2 a3 = grid[2][1] - b2 b3 = grid[2][2] - a3 a_list = [a1, a2, a3] ...
false
44.444444
[ "-import numpy as np", "-", "-c = [[0] * 3] * 3", "-for i in range(3):", "- c[i] = list(map(int, input().split()))", "-c = np.array(c)", "-if (", "- len(set(c[0] - c[1])) == 1", "- and len(set(c[1] - c[2])) == 1", "- and len(set(c[:, 0] - c[:, 1])) == 1", "- and len(set(c[:, 1] - ...
false
0.420536
0.0802
5.243583
[ "s169312152", "s370898144" ]
u223646582
p02787
python
s259509895
s140623016
837
507
268,808
43,228
Accepted
Accepted
39.43
H, N = list(map(int, input().split())) INF = 10 ** 12 M = [] for i in range(N): A, B = list(map(int, input().split())) M.append((A, B)) dp = [[INF for j in range(H+10**4+1)] for i in range(N+1)] # for i in range(N+1): # dp[0][i] = 0 for i in range(N+1): dp[i][0] = 0 for i in ran...
H, N = list(map(int, input().split())) INF = 10 ** 12 M = [] for i in range(N): A, B = list(map(int, input().split())) M.append((A, B)) dp = [INF for j in range(H+10**4+1)] dp[0] = 0 for i in range(N): for j in range(1, H+10**4+1): if j - M[i][0] >= 0: dp[j] = min(dp[j],...
38
20
862
414
H, N = list(map(int, input().split())) INF = 10**12 M = [] for i in range(N): A, B = list(map(int, input().split())) M.append((A, B)) dp = [[INF for j in range(H + 10**4 + 1)] for i in range(N + 1)] # for i in range(N+1): # dp[0][i] = 0 for i in range(N + 1): dp[i][0] = 0 for i in range(1, N + 1): # 1<...
H, N = list(map(int, input().split())) INF = 10**12 M = [] for i in range(N): A, B = list(map(int, input().split())) M.append((A, B)) dp = [INF for j in range(H + 10**4 + 1)] dp[0] = 0 for i in range(N): for j in range(1, H + 10**4 + 1): if j - M[i][0] >= 0: dp[j] = min(dp[j], dp[j - M[i...
false
47.368421
[ "-dp = [[INF for j in range(H + 10**4 + 1)] for i in range(N + 1)]", "-# for i in range(N+1):", "-# dp[0][i] = 0", "-for i in range(N + 1):", "- dp[i][0] = 0", "-for i in range(1, N + 1): # 1<= i <= N", "- # for j in range(1, H+10**4+1): # 1 <= j <= H", "- for j in range(1, H + 1): # 1...
false
0.380125
0.280651
1.35444
[ "s259509895", "s140623016" ]
u725391514
p02400
python
s826928322
s097569471
40
20
7,512
7,432
Accepted
Accepted
50
import math r=float(eval(input())) print(('{:.5f} {:.5f}'.format(r*r*math.pi, 2*r*math.pi)))
import math r=float(eval(input())) print(('{:.5f}'.format(r*r*math.pi),'{:.5f}'.format(2*r*math.pi)))
3
3
86
95
import math r = float(eval(input())) print(("{:.5f} {:.5f}".format(r * r * math.pi, 2 * r * math.pi)))
import math r = float(eval(input())) print(("{:.5f}".format(r * r * math.pi), "{:.5f}".format(2 * r * math.pi)))
false
0
[ "-print((\"{:.5f} {:.5f}\".format(r * r * math.pi, 2 * r * math.pi)))", "+print((\"{:.5f}\".format(r * r * math.pi), \"{:.5f}\".format(2 * r * math.pi)))" ]
false
0.046574
0.04282
1.087686
[ "s826928322", "s097569471" ]
u116002573
p03379
python
s629631239
s301086368
355
323
25,556
26,772
Accepted
Accepted
9.01
def main(): N = int(eval(input())) X = [int(x) for x in input().split()] Xsort = sorted(X) for i in range(N): if X[i] <= Xsort[N//2-1]: print((Xsort[N//2])) else: print((Xsort[N//2-1])) if __name__ == '__main__': main()
def main(): N = int(eval(input())) X = list(map(int, input().split())) Y = sorted(X) for i in range(N): if X[i] < Y[N//2]: print((Y[N//2])) else: print((Y[N//2-1])) if __name__ == '__main__': # print(main()) main()
12
14
282
284
def main(): N = int(eval(input())) X = [int(x) for x in input().split()] Xsort = sorted(X) for i in range(N): if X[i] <= Xsort[N // 2 - 1]: print((Xsort[N // 2])) else: print((Xsort[N // 2 - 1])) if __name__ == "__main__": main()
def main(): N = int(eval(input())) X = list(map(int, input().split())) Y = sorted(X) for i in range(N): if X[i] < Y[N // 2]: print((Y[N // 2])) else: print((Y[N // 2 - 1])) if __name__ == "__main__": # print(main()) main()
false
14.285714
[ "- X = [int(x) for x in input().split()]", "- Xsort = sorted(X)", "+ X = list(map(int, input().split()))", "+ Y = sorted(X)", "- if X[i] <= Xsort[N // 2 - 1]:", "- print((Xsort[N // 2]))", "+ if X[i] < Y[N // 2]:", "+ print((Y[N // 2]))", "- ...
false
0.047457
0.044727
1.06104
[ "s629631239", "s301086368" ]
u893063840
p03108
python
s217098976
s431906238
1,054
880
40,940
38,132
Accepted
Accepted
16.51
n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(m)] class UnionFind: def __init__(self, n): self.n = n self.p = [e for e in range(n)] self.rank = [0] * n self.size = [1] * n def same(self, u, v): return self.find_set(u)...
n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(m)] class UnionFind: def __init__(self, n): self.n = n self.p = [e for e in range(n)] self.rank = [0] * n self.size = [1] * n def same(self, u, v): return self.find_set(u)...
60
54
1,426
1,289
n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(m)] class UnionFind: def __init__(self, n): self.n = n self.p = [e for e in range(n)] self.rank = [0] * n self.size = [1] * n def same(self, u, v): return self.find_set(u) == self.fin...
n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(m)] class UnionFind: def __init__(self, n): self.n = n self.p = [e for e in range(n)] self.rank = [0] * n self.size = [1] * n def same(self, u, v): return self.find_set(u) == self.fin...
false
10
[ "- def comb(self, u):", "- sz = self.get_size(u)", "- return sz * (sz - 1) // 2", "-", "-ans = [0]", "-sm = 0", "+sm = n * (n - 1) // 2", "+ans = [sm]", "- sm -= uf.comb(a) + uf.comb(b)", "+ sm -= uf.get_size(a) * uf.get_size(b)", "- sm += uf.comb(a)", "-a...
false
0.096691
0.040106
2.410861
[ "s217098976", "s431906238" ]
u606878291
p02669
python
s501672795
s374273875
360
244
27,600
20,540
Accepted
Accepted
32.22
import math from functools import lru_cache T = int(eval(input())) class Resolver: def __init__(self, a, b, c, d): self.a = a self.b = b self.c = c self.d = d @lru_cache(maxsize=None) def resolve(self, n): if n == 0: return 0 e...
from functools import lru_cache T = int(eval(input())) def resolver(a, b, c, d): @lru_cache(maxsize=None) def _resolver(n): if n == 0: return 0 elif n == 1: return d else: div5f = n // 5 div5c = (n + 4) // 5 di...
41
35
1,228
1,005
import math from functools import lru_cache T = int(eval(input())) class Resolver: def __init__(self, a, b, c, d): self.a = a self.b = b self.c = c self.d = d @lru_cache(maxsize=None) def resolve(self, n): if n == 0: return 0 elif n == 1: ...
from functools import lru_cache T = int(eval(input())) def resolver(a, b, c, d): @lru_cache(maxsize=None) def _resolver(n): if n == 0: return 0 elif n == 1: return d else: div5f = n // 5 div5c = (n + 4) // 5 div3f = n // 3 ...
false
14.634146
[ "-import math", "-class Resolver:", "- def __init__(self, a, b, c, d):", "- self.a = a", "- self.b = b", "- self.c = c", "- self.d = d", "-", "+def resolver(a, b, c, d):", "- def resolve(self, n):", "+ def _resolver(n):", "- return self.d", "+ ...
false
0.422926
0.213066
1.984952
[ "s501672795", "s374273875" ]
u186838327
p03030
python
s164572107
s145025586
182
74
38,384
62,852
Accepted
Accepted
59.34
n = int(eval(input())) X = [] for i in range(n): s, p = list(map(str, input().split())) p = int(p) X.append((s, p, i+1)) X.sort(key= lambda x: (x[0], -x[1])) for s, p, i in X: print(i)
n = int(eval(input())) SP = [] for i in range(n): s, p = list(map(str, input().split())) p = int(p) SP.append((s, p, i+1)) SP.sort(key=lambda x: (x[0], -x[1])) for s, p, j in SP: print(j)
10
9
199
200
n = int(eval(input())) X = [] for i in range(n): s, p = list(map(str, input().split())) p = int(p) X.append((s, p, i + 1)) X.sort(key=lambda x: (x[0], -x[1])) for s, p, i in X: print(i)
n = int(eval(input())) SP = [] for i in range(n): s, p = list(map(str, input().split())) p = int(p) SP.append((s, p, i + 1)) SP.sort(key=lambda x: (x[0], -x[1])) for s, p, j in SP: print(j)
false
10
[ "-X = []", "+SP = []", "- X.append((s, p, i + 1))", "-X.sort(key=lambda x: (x[0], -x[1]))", "-for s, p, i in X:", "- print(i)", "+ SP.append((s, p, i + 1))", "+SP.sort(key=lambda x: (x[0], -x[1]))", "+for s, p, j in SP:", "+ print(j)" ]
false
0.130094
0.076625
1.69779
[ "s164572107", "s145025586" ]
u609061751
p02703
python
s147526832
s287267533
1,542
1,420
188,732
180,136
Accepted
Accepted
7.91
import sys input = lambda: sys.stdin.readline().rstrip() n, m, s = list(map(int, input().split())) s = min(s, 2500) from collections import defaultdict # O(ElogV) import heapq def dijkstra(s, x): # 始点sから各頂点への最短距離 d = defaultdict(lambda: float("inf")) d[(s, x)] = 0 # 各頂点が訪問済みかどうか used =...
def main(): import sys input = lambda: sys.stdin.readline().rstrip() n, m, s = list(map(int, input().split())) s = min(s, 2500) from collections import defaultdict # O(ElogV) import heapq def dijkstra(s, x): # 始点sから各頂点への最短距離 d = defaultdict(lambda: float("inf...
55
57
1,361
1,586
import sys input = lambda: sys.stdin.readline().rstrip() n, m, s = list(map(int, input().split())) s = min(s, 2500) from collections import defaultdict # O(ElogV) import heapq def dijkstra(s, x): # 始点sから各頂点への最短距離 d = defaultdict(lambda: float("inf")) d[(s, x)] = 0 # 各頂点が訪問済みかどうか used = defaultdi...
def main(): import sys input = lambda: sys.stdin.readline().rstrip() n, m, s = list(map(int, input().split())) s = min(s, 2500) from collections import defaultdict # O(ElogV) import heapq def dijkstra(s, x): # 始点sから各頂点への最短距離 d = defaultdict(lambda: float("inf")) ...
false
3.508772
[ "-import sys", "+def main():", "+ import sys", "-input = lambda: sys.stdin.readline().rstrip()", "-n, m, s = list(map(int, input().split()))", "-s = min(s, 2500)", "-from collections import defaultdict", "+ input = lambda: sys.stdin.readline().rstrip()", "+ n, m, s = list(map(int, input().s...
false
0.282722
0.142794
1.979933
[ "s147526832", "s287267533" ]
u746419473
p03161
python
s722669323
s700421358
1,883
539
13,980
58,336
Accepted
Accepted
71.38
n, k = list(map(int, input().split())) *h, = list(map(int, input().split())) dp = [float("inf")]*(n+1) dp[0] = 0 for i in range(1, n): if i < k: dp[i] = min([dpj+abs(hj-h[i]) for dpj, hj in zip(dp[:i], h[:i])]) else: dp[i] = min([dpj+abs(hj-h[i]) for dpj, hj in zip(dp[i-k:i], h[i-k:i...
n, k = list(map(int, input().split())) *h, = list(map(int, input().split())) dp = [float("inf")]*n dp[0] = 0 for i in range(1, n): if i == 1: dp[1] = dp[0] + abs(h[0]-h[1]) continue dp[i] = min([dp[i-j] + abs(h[i-j]-h[i]) for j in range(1, k+1)]) print((dp[n-1]))
13
14
331
291
n, k = list(map(int, input().split())) (*h,) = list(map(int, input().split())) dp = [float("inf")] * (n + 1) dp[0] = 0 for i in range(1, n): if i < k: dp[i] = min([dpj + abs(hj - h[i]) for dpj, hj in zip(dp[:i], h[:i])]) else: dp[i] = min( [dpj + abs(hj - h[i]) for dpj, hj in zip(dp[...
n, k = list(map(int, input().split())) (*h,) = list(map(int, input().split())) dp = [float("inf")] * n dp[0] = 0 for i in range(1, n): if i == 1: dp[1] = dp[0] + abs(h[0] - h[1]) continue dp[i] = min([dp[i - j] + abs(h[i - j] - h[i]) for j in range(1, k + 1)]) print((dp[n - 1]))
false
7.142857
[ "-dp = [float(\"inf\")] * (n + 1)", "+dp = [float(\"inf\")] * n", "- if i < k:", "- dp[i] = min([dpj + abs(hj - h[i]) for dpj, hj in zip(dp[:i], h[:i])])", "- else:", "- dp[i] = min(", "- [dpj + abs(hj - h[i]) for dpj, hj in zip(dp[i - k : i], h[i - k : i])]", "- ...
false
0.039796
0.042446
0.937577
[ "s722669323", "s700421358" ]
u463864151
p02678
python
s099404526
s492816189
983
860
34,528
34,668
Accepted
Accepted
12.51
# -*- coding: utf-8 -*- """ @author: H_Hoshigi """ import queue def main(): N, M = list(map(int, input().split())) connedted_room_list = [ [] for i in range(N)] # ここでNとMを書き間違えていた。 for i in range(M): A, B = list(map(int, input().split())) connedted_room_list[A-1].append(B-1) ...
# -*- coding: utf-8 -*- """ @author: H_Hoshigi """ import queue def main(): N, M = list(map(int, input().split())) connedted_room_list = [ [] for i in range(N)] # ここでNとMを書き間違えていた。 for i in range(M): A, B = list(map(int, input().split())) connedted_room_list[A-1].append(B-1) ...
47
49
1,107
1,125
# -*- coding: utf-8 -*- """ @author: H_Hoshigi """ import queue def main(): N, M = list(map(int, input().split())) connedted_room_list = [[] for i in range(N)] # ここでNとMを書き間違えていた。 for i in range(M): A, B = list(map(int, input().split())) connedted_room_list[A - 1].append(B - 1) con...
# -*- coding: utf-8 -*- """ @author: H_Hoshigi """ import queue def main(): N, M = list(map(int, input().split())) connedted_room_list = [[] for i in range(N)] # ここでNとMを書き間違えていた。 for i in range(M): A, B = list(map(int, input().split())) connedted_room_list[A - 1].append(B - 1) con...
false
4.081633
[ "+ \"\"\"", "+ \"\"\"" ]
false
0.13235
0.033818
3.913573
[ "s099404526", "s492816189" ]
u729133443
p02555
python
s358073366
s861436631
85
52
77,736
22,236
Accepted
Accepted
38.82
a,b,c=1,0,0 exec('a,b,c=b,c,a+c;'*int(eval(input()))) print((a%(10**9+7)))
a=1 b=c=0 exec('a,b,c=b,c,a+c;'*int(eval(input()))) print((a%(10**9+7)))
3
4
68
67
a, b, c = 1, 0, 0 exec("a,b,c=b,c,a+c;" * int(eval(input()))) print((a % (10**9 + 7)))
a = 1 b = c = 0 exec("a,b,c=b,c,a+c;" * int(eval(input()))) print((a % (10**9 + 7)))
false
25
[ "-a, b, c = 1, 0, 0", "+a = 1", "+b = c = 0" ]
false
0.040899
0.086333
0.47373
[ "s358073366", "s861436631" ]
u934442292
p03163
python
s172560613
s573231018
1,195
727
192,500
189,884
Accepted
Accepted
39.16
import sys import numba as nb import numpy as np input = sys.stdin.readline @nb.njit("i8(i8, i8)") def chmax(a, b): if a > b: return a else: return b @nb.njit("i8(i8,i8,i8[:,:])") def solve(N, W, wv): dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(1, N...
import sys import numba as nb import numpy as np input = sys.stdin.readline @nb.njit("i8(i8, i8)") def chmax(a, b): if a > b: return a else: return b @nb.njit("i8(i8,i8,i8[:,:])") def solve(N, W, wv): dp = np.zeros(shape=(N + 1, W + 1), dtype=np.int64) for i in r...
42
42
845
854
import sys import numba as nb import numpy as np input = sys.stdin.readline @nb.njit("i8(i8, i8)") def chmax(a, b): if a > b: return a else: return b @nb.njit("i8(i8,i8,i8[:,:])") def solve(N, W, wv): dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(1, N + 1): w, v ...
import sys import numba as nb import numpy as np input = sys.stdin.readline @nb.njit("i8(i8, i8)") def chmax(a, b): if a > b: return a else: return b @nb.njit("i8(i8,i8,i8[:,:])") def solve(N, W, wv): dp = np.zeros(shape=(N + 1, W + 1), dtype=np.int64) for i in range(1, N + 1): ...
false
0
[ "- dp = [[0] * (W + 1) for _ in range(N + 1)]", "+ dp = np.zeros(shape=(N + 1, W + 1), dtype=np.int64)", "- dp[i][j] = dp[i - 1][j]", "+ dp[i, j] = dp[i - 1, j]", "- dp[i][j] = chmax(dp[i - 1][j - w] + v, dp[i - 1][j])", "- return dp[-1][-1]", "+ ...
false
0.132809
0.168341
0.788929
[ "s172560613", "s573231018" ]
u631277801
p03363
python
s318638287
s868597014
197
168
41,728
41,728
Accepted
Accepted
14.72
from collections import Counter from itertools import accumulate n = int(eval(input())) a = list(map(int, input().split())) a_cum = list(accumulate(a)) cnt = Counter(a_cum) ans = 0 for k, v in list(cnt.items()): if k == 0: ans += v + v*(v-1) // 2 elif v > 0: ans += v*(v-1) // 2 ...
from collections import Counter from itertools import accumulate n = int(eval(input())) a = list(map(int, input().split())) cnt = Counter(list(accumulate(a))) ans = 0 for k,v in list(cnt.items()): if k == 0: ans += v ans += v*(v-1)//2 print(ans)
17
14
329
265
from collections import Counter from itertools import accumulate n = int(eval(input())) a = list(map(int, input().split())) a_cum = list(accumulate(a)) cnt = Counter(a_cum) ans = 0 for k, v in list(cnt.items()): if k == 0: ans += v + v * (v - 1) // 2 elif v > 0: ans += v * (v - 1) // 2 print(an...
from collections import Counter from itertools import accumulate n = int(eval(input())) a = list(map(int, input().split())) cnt = Counter(list(accumulate(a))) ans = 0 for k, v in list(cnt.items()): if k == 0: ans += v ans += v * (v - 1) // 2 print(ans)
false
17.647059
[ "-a_cum = list(accumulate(a))", "-cnt = Counter(a_cum)", "+cnt = Counter(list(accumulate(a)))", "- ans += v + v * (v - 1) // 2", "- elif v > 0:", "- ans += v * (v - 1) // 2", "+ ans += v", "+ ans += v * (v - 1) // 2" ]
false
0.037685
0.037634
1.001341
[ "s318638287", "s868597014" ]
u374531474
p02804
python
s014570697
s397530708
831
168
14,040
14,040
Accepted
Accepted
79.78
N, K = list(map(int, input().split())) A = list(map(int, input().split())) MOD = 10 ** 9 + 7 def mpow(x, t): if t == 0: return 1 a = mpow(x, t >> 1) return a * a * (x ** (t & 1)) % MOD A.sort() ans = 0 C = 1 for i in range(K, N + 1): ans += (A[i - 1] - A[N - i]) * C ans ...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) MOD = 10 ** 9 + 7 inv_t = [0, 1] + [0] * (N - 1) for i in range(2, N + 1): inv_t[i] = inv_t[MOD % i] * (MOD - MOD // i) % MOD A.sort() ans = 0 C = 1 for i in range(K, N + 1): ans += (A[i - 1] - A[N - i]) * C ans %= MOD...
21
17
389
375
N, K = list(map(int, input().split())) A = list(map(int, input().split())) MOD = 10**9 + 7 def mpow(x, t): if t == 0: return 1 a = mpow(x, t >> 1) return a * a * (x ** (t & 1)) % MOD A.sort() ans = 0 C = 1 for i in range(K, N + 1): ans += (A[i - 1] - A[N - i]) * C ans %= MOD C = C * ...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) MOD = 10**9 + 7 inv_t = [0, 1] + [0] * (N - 1) for i in range(2, N + 1): inv_t[i] = inv_t[MOD % i] * (MOD - MOD // i) % MOD A.sort() ans = 0 C = 1 for i in range(K, N + 1): ans += (A[i - 1] - A[N - i]) * C ans %= MOD C = C * i * ...
false
19.047619
[ "-", "-", "-def mpow(x, t):", "- if t == 0:", "- return 1", "- a = mpow(x, t >> 1)", "- return a * a * (x ** (t & 1)) % MOD", "-", "-", "+inv_t = [0, 1] + [0] * (N - 1)", "+for i in range(2, N + 1):", "+ inv_t[i] = inv_t[MOD % i] * (MOD - MOD // i) % MOD", "- C = C * i ...
false
0.037037
0.035316
1.04873
[ "s014570697", "s397530708" ]
u102461423
p02937
python
s448212263
s753874268
161
142
7,864
9,004
Accepted
Accepted
11.8
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) from collections import defaultdict from bisect import bisect_left S = input().rstrip() T = input().rstrip() LS = len(S) index = defaultdict(list) # alphabet to indices for i,s in enumerate(S): index[s].append(i) index x ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from bisect import bisect_right S = [ord(x)-ord('a') for x in readline().rstrip().decode('utf-8')] T = [ord(x)-ord('a') for x in readline().rstrip().decode('utf-8')] index = [[] for _ in rang...
35
35
637
722
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import defaultdict from bisect import bisect_left S = input().rstrip() T = input().rstrip() LS = len(S) index = defaultdict(list) # alphabet to indices for i, s in enumerate(S): index[s].append(i) index x = -1 # 今見た場所。次はx+1以上からと...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from bisect import bisect_right S = [ord(x) - ord("a") for x in readline().rstrip().decode("utf-8")] T = [ord(x) - ord("a") for x in readline().rstrip().decode("utf-8")] index = [[] for _ in range(26)] ...
false
0
[ "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "-from collections import defaultdict", "-from bisect import bisect_left", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readlines", "+from bisect import bisect_right", "-S = in...
false
0.061391
0.043981
1.395836
[ "s448212263", "s753874268" ]
u256678932
p02261
python
s232421168
s054667790
30
20
7,828
5,616
Accepted
Accepted
33.33
from operator import lt def main(): N = int(eval(input())) A = list(input().split(' ')) Ab = bubbleSort(A[:], N, lambda a, b: int(a[1]) < int(b[1])) As = selectionSort(A[:], N, lambda a, b: int(a[1]) < int(b[1])) print((' '.join([str(a) for a in Ab]))) print('Stable') print((...
def bubble_sort(cards, n): for i in range(n): for j in range(n-1, i, -1): if cards[j][1] < cards[j-1][1]: cards[j], cards[j-1] = cards[j-1], cards[j] return cards def selection_sort(cards, n): for i in range(n): minj = i for j in range(i, n)...
43
59
956
1,370
from operator import lt def main(): N = int(eval(input())) A = list(input().split(" ")) Ab = bubbleSort(A[:], N, lambda a, b: int(a[1]) < int(b[1])) As = selectionSort(A[:], N, lambda a, b: int(a[1]) < int(b[1])) print((" ".join([str(a) for a in Ab]))) print("Stable") print((" ".join([str(...
def bubble_sort(cards, n): for i in range(n): for j in range(n - 1, i, -1): if cards[j][1] < cards[j - 1][1]: cards[j], cards[j - 1] = cards[j - 1], cards[j] return cards def selection_sort(cards, n): for i in range(n): minj = i for j in range(i, n): ...
false
27.118644
[ "-from operator import lt", "+def bubble_sort(cards, n):", "+ for i in range(n):", "+ for j in range(n - 1, i, -1):", "+ if cards[j][1] < cards[j - 1][1]:", "+ cards[j], cards[j - 1] = cards[j - 1], cards[j]", "+ return cards", "+", "+", "+def selection_sort(...
false
0.04226
0.04131
1.023003
[ "s232421168", "s054667790" ]
u721316601
p02773
python
s045095501
s177125443
869
447
36,032
38,364
Accepted
Accepted
48.56
from collections import * N = int(eval(input())) c = Counter() m = 0 for i in range(N): S = eval(input()) c[S] += 1 m = max(m, c[S]) ans = sorted([k for k, v in list(c.items()) if v == m]) print(('\n'.join(ans)))
from collections import * import sys input = sys.stdin.readline def main(): N = int(eval(input())) c = Counter() m = 0 S = [eval(input()) for i in range(N)] for s in S: c[s] += 1 m = max(m, c[s]) ans = sorted([k for k, v in list(c.items()) if v == m]) print(('...
12
17
217
355
from collections import * N = int(eval(input())) c = Counter() m = 0 for i in range(N): S = eval(input()) c[S] += 1 m = max(m, c[S]) ans = sorted([k for k, v in list(c.items()) if v == m]) print(("\n".join(ans)))
from collections import * import sys input = sys.stdin.readline def main(): N = int(eval(input())) c = Counter() m = 0 S = [eval(input()) for i in range(N)] for s in S: c[s] += 1 m = max(m, c[s]) ans = sorted([k for k, v in list(c.items()) if v == m]) print(("\n".join(ans)...
false
29.411765
[ "+import sys", "-N = int(eval(input()))", "-c = Counter()", "-m = 0", "-for i in range(N):", "- S = eval(input())", "- c[S] += 1", "- m = max(m, c[S])", "-ans = sorted([k for k, v in list(c.items()) if v == m])", "-print((\"\\n\".join(ans)))", "+input = sys.stdin.readline", "+", "+"...
false
0.03726
0.037538
0.992591
[ "s045095501", "s177125443" ]
u077291787
p03503
python
s426963250
s562886780
63
58
3,064
3,064
Accepted
Accepted
7.94
# ABC080C - Shopping Street import sys input = sys.stdin.readline def main(): N = int(eval(input())) F = tuple(int(input().replace(" ", ""), 2) for _ in range(N)) P = tuple(tuple(map(int, input().split())) for _ in range(N)) ans = [] for i in range(1, 2 ** 10): cnt = sum(p[bin(i &...
# ABC080C - Shopping Street # exhaustive search import sys input = sys.stdin.readline def main(): N = int(eval(input())) F = tuple(int(input().replace(" ", ""), 2) for _ in range(N)) # str -> bit -> int P = tuple(tuple(map(int, input().split())) for _ in range(N)) # set of sum of profit in ea...
17
18
439
504
# ABC080C - Shopping Street import sys input = sys.stdin.readline def main(): N = int(eval(input())) F = tuple(int(input().replace(" ", ""), 2) for _ in range(N)) P = tuple(tuple(map(int, input().split())) for _ in range(N)) ans = [] for i in range(1, 2**10): cnt = sum(p[bin(i & f).count(...
# ABC080C - Shopping Street # exhaustive search import sys input = sys.stdin.readline def main(): N = int(eval(input())) F = tuple(int(input().replace(" ", ""), 2) for _ in range(N)) # str -> bit -> int P = tuple(tuple(map(int, input().split())) for _ in range(N)) # set of sum of profit in each patt...
false
5.555556
[ "+# exhaustive search", "- F = tuple(int(input().replace(\" \", \"\"), 2) for _ in range(N))", "+ F = tuple(int(input().replace(\" \", \"\"), 2) for _ in range(N)) # str -> bit -> int", "- ans = []", "- for i in range(1, 2**10):", "- cnt = sum(p[bin(i & f).count(\"1\")] for f, p in zip...
false
0.041181
0.082039
0.501968
[ "s426963250", "s562886780" ]
u941047297
p03730
python
s647235303
s576880262
164
18
38,384
2,940
Accepted
Accepted
89.02
a, b, c = list(map(int, input().split())) d = [] for i in range(b): d.append(a * (i + 1) % b) d = set(d) if c in d: print('YES') else: print('NO')
a, b, c = list(map(int, input().split())) R = [(a * i) % b for i in range(b)] if c in R: print('YES') else: print('NO')
9
6
167
132
a, b, c = list(map(int, input().split())) d = [] for i in range(b): d.append(a * (i + 1) % b) d = set(d) if c in d: print("YES") else: print("NO")
a, b, c = list(map(int, input().split())) R = [(a * i) % b for i in range(b)] if c in R: print("YES") else: print("NO")
false
33.333333
[ "-d = []", "-for i in range(b):", "- d.append(a * (i + 1) % b)", "-d = set(d)", "-if c in d:", "+R = [(a * i) % b for i in range(b)]", "+if c in R:" ]
false
0.044869
0.037792
1.18726
[ "s647235303", "s576880262" ]
u347600233
p03062
python
s702237435
s029622989
86
66
14,224
14,284
Accepted
Accepted
23.26
n = int(eval(input())) a = [int(i) for i in input().split()] sum_abs, min_abs, cnt_minus = 0, 10**9, 0 for ai in a: if ai < 0: cnt_minus += 1 abs_ai = abs(ai) sum_abs += abs_ai if abs_ai < min_abs: min_abs = abs_ai if cnt_minus % 2 == 0 or 0 in a: print(sum_abs) else: ...
# knk_kei 0 in a の条件は不要 n = int(eval(input())) a = [int(i) for i in input().split()] if len([i for i in a if i < 0]) % 2 == 0: print((sum([abs(i) for i in a]))) else: print((sum([abs(i) for i in a]) - 2*min([abs(i) for i in a])))
14
7
342
235
n = int(eval(input())) a = [int(i) for i in input().split()] sum_abs, min_abs, cnt_minus = 0, 10**9, 0 for ai in a: if ai < 0: cnt_minus += 1 abs_ai = abs(ai) sum_abs += abs_ai if abs_ai < min_abs: min_abs = abs_ai if cnt_minus % 2 == 0 or 0 in a: print(sum_abs) else: print((sum_...
# knk_kei 0 in a の条件は不要 n = int(eval(input())) a = [int(i) for i in input().split()] if len([i for i in a if i < 0]) % 2 == 0: print((sum([abs(i) for i in a]))) else: print((sum([abs(i) for i in a]) - 2 * min([abs(i) for i in a])))
false
50
[ "+# knk_kei 0 in a の条件は不要", "-sum_abs, min_abs, cnt_minus = 0, 10**9, 0", "-for ai in a:", "- if ai < 0:", "- cnt_minus += 1", "- abs_ai = abs(ai)", "- sum_abs += abs_ai", "- if abs_ai < min_abs:", "- min_abs = abs_ai", "-if cnt_minus % 2 == 0 or 0 in a:", "- print(...
false
0.035292
0.036474
0.967609
[ "s702237435", "s029622989" ]
u312025627
p03000
python
s353502537
s283498849
179
64
38,256
62,000
Accepted
Accepted
64.25
def main(): N, X = (int(i) for i in input().split()) L = [int(i) for i in input().split()] from itertools import accumulate S = accumulate([0] + L) ans = 0 for s in S: if s <= X: ans += 1 else: break print(ans) if __name__ == '__main__'...
def main(): N, X = (int(i) for i in input().split()) L = [int(i) for i in input().split()] from itertools import accumulate S = list(accumulate([0] + L)) ans = 0 for s in S: if X < s: break ans += 1 print(ans) if __name__ == '__main__': main()
16
15
334
320
def main(): N, X = (int(i) for i in input().split()) L = [int(i) for i in input().split()] from itertools import accumulate S = accumulate([0] + L) ans = 0 for s in S: if s <= X: ans += 1 else: break print(ans) if __name__ == "__main__": main()
def main(): N, X = (int(i) for i in input().split()) L = [int(i) for i in input().split()] from itertools import accumulate S = list(accumulate([0] + L)) ans = 0 for s in S: if X < s: break ans += 1 print(ans) if __name__ == "__main__": main()
false
6.25
[ "- S = accumulate([0] + L)", "+ S = list(accumulate([0] + L))", "- if s <= X:", "- ans += 1", "- else:", "+ if X < s:", "+ ans += 1" ]
false
0.075869
0.076907
0.986503
[ "s353502537", "s283498849" ]
u442948527
p03777
python
s155841579
s501887571
28
21
8,916
9,020
Accepted
Accepted
25
a,b=input().split() print(('DH'[a==b]))
a,b=input().split() print((["D","H"][a==b]))
2
2
38
43
a, b = input().split() print(("DH"[a == b]))
a, b = input().split() print((["D", "H"][a == b]))
false
0
[ "-print((\"DH\"[a == b]))", "+print(([\"D\", \"H\"][a == b]))" ]
false
0.036455
0.037604
0.969441
[ "s155841579", "s501887571" ]
u485319545
p02720
python
s987276950
s470609565
90
55
12,720
13,344
Accepted
Accepted
38.89
k=int(eval(input())) if k<=9: print(k) exit(0) ans=[1,2,3,4,5,6,7,8,9] i=0 while len(ans)<k: v=str(ans[i]) n=len(v) #最後の桁 v_last=int(v[-1]) if v_last==0: ans.append(int(v+'0')) ans.append(int(v+'1')) elif v_last==9: ans.append(int(v+'8')) ...
k=int(eval(input())) if k<=9: print(k) exit(0) ans=[1,2,3,4,5,6,7,8,9] i=0 while len(ans)<k: v=ans[i] mod=v%10 if mod==0: ans.append(10*v+mod) ans.append(10*v+mod+1) elif mod==9: ans.append(10*v+mod-1) ans.append(10*v+mod) else: ...
33
31
518
447
k = int(eval(input())) if k <= 9: print(k) exit(0) ans = [1, 2, 3, 4, 5, 6, 7, 8, 9] i = 0 while len(ans) < k: v = str(ans[i]) n = len(v) # 最後の桁 v_last = int(v[-1]) if v_last == 0: ans.append(int(v + "0")) ans.append(int(v + "1")) elif v_last == 9: ans.append(int(...
k = int(eval(input())) if k <= 9: print(k) exit(0) ans = [1, 2, 3, 4, 5, 6, 7, 8, 9] i = 0 while len(ans) < k: v = ans[i] mod = v % 10 if mod == 0: ans.append(10 * v + mod) ans.append(10 * v + mod + 1) elif mod == 9: ans.append(10 * v + mod - 1) ans.append(10 * v ...
false
6.060606
[ "- v = str(ans[i])", "- n = len(v)", "- # 最後の桁", "- v_last = int(v[-1])", "- if v_last == 0:", "- ans.append(int(v + \"0\"))", "- ans.append(int(v + \"1\"))", "- elif v_last == 9:", "- ans.append(int(v + \"8\"))", "- ans.append(int(v + \"9\"))", "+ ...
false
0.10047
0.055186
1.820566
[ "s987276950", "s470609565" ]
u396890425
p03487
python
s449929095
s792599899
173
75
27,760
18,676
Accepted
Accepted
56.65
import collections N=int(eval(input())) List=sorted(list(map(int, input().split()))) c = collections.Counter(List) #要素と出現回数の辞書 value, count = list(zip(*c.most_common())) newList=[] for i in range(len(value)): if N-len(newList)>=value[i] and count[i]>=value[i]: for j in range(value[i]): ...
import collections N = int(eval(input())) A = list(map(int, input().split())) c = collections.Counter(A) #要素と出現回数の辞書 #print(c) ans = 0 for k,v in list(c.items()): ans += v if v<k else v-k print(ans)
22
12
432
204
import collections N = int(eval(input())) List = sorted(list(map(int, input().split()))) c = collections.Counter(List) # 要素と出現回数の辞書 value, count = list(zip(*c.most_common())) newList = [] for i in range(len(value)): if N - len(newList) >= value[i] and count[i] >= value[i]: for j in range(value[i]): ...
import collections N = int(eval(input())) A = list(map(int, input().split())) c = collections.Counter(A) # 要素と出現回数の辞書 # print(c) ans = 0 for k, v in list(c.items()): ans += v if v < k else v - k print(ans)
false
45.454545
[ "-List = sorted(list(map(int, input().split())))", "-c = collections.Counter(List) # 要素と出現回数の辞書", "-value, count = list(zip(*c.most_common()))", "-newList = []", "-for i in range(len(value)):", "- if N - len(newList) >= value[i] and count[i] >= value[i]:", "- for j in range(value[i]):", "- ...
false
0.039011
0.042447
0.919054
[ "s449929095", "s792599899" ]
u028973125
p02727
python
s822146941
s719293695
389
347
92,568
100,904
Accepted
Accepted
10.8
import sys X, Y, A, B, C = list(map(int, sys.stdin.readline().strip().split())) P = list(map(int, sys.stdin.readline().strip().split())) Q = list(map(int, sys.stdin.readline().strip().split())) R = list(map(int, sys.stdin.readline().strip().split())) P.sort(reverse=True) Q.sort(reverse=True) R.sort(reverse...
import sys X, Y, A, B, C = list(map(int, sys.stdin.readline().strip().split())) P = list(map(int, sys.stdin.readline().strip().split())) Q = list(map(int, sys.stdin.readline().strip().split())) R = list(map(int, sys.stdin.readline().strip().split())) P.sort(reverse=True) Q.sort(reverse=True) R.sort(reverse...
63
15
1,367
394
import sys X, Y, A, B, C = list(map(int, sys.stdin.readline().strip().split())) P = list(map(int, sys.stdin.readline().strip().split())) Q = list(map(int, sys.stdin.readline().strip().split())) R = list(map(int, sys.stdin.readline().strip().split())) P.sort(reverse=True) Q.sort(reverse=True) R.sort(reverse=True) P = P...
import sys X, Y, A, B, C = list(map(int, sys.stdin.readline().strip().split())) P = list(map(int, sys.stdin.readline().strip().split())) Q = list(map(int, sys.stdin.readline().strip().split())) R = list(map(int, sys.stdin.readline().strip().split())) P.sort(reverse=True) Q.sort(reverse=True) R.sort(reverse=True) ans =...
false
76.190476
[ "-P = P[:X]", "-P.sort()", "-Q = Q[:Y]", "-Q.sort()", "-ans = 0", "-i, j, k = 0, 0, 0", "-while C > k:", "- if X > i and Y > j:", "- if P[i] >= Q[j]:", "- if R[k] > Q[j] and Y > j:", "- Q[j] = R[k]", "- j += 1", "- k += 1", ...
false
0.033953
0.043602
0.778713
[ "s822146941", "s719293695" ]
u729133443
p02559
python
s010288445
s819089153
170
122
12,936
12,920
Accepted
Accepted
28.24
import sys if sys.argv[-1] == 'ONLINE_JUDGE': import os, zlib, base64 open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${@p+is&U5Pe7DA4Xbjg}0;ysg)|!>{s+H$^#gajF#A`FSPypj<G3D+MO57oWq$j<KY+Z4|`Oy0p8<;29?~tXeaV)(CQSyyK}4CaTFtPJe`%caMrCnETj=TerIft>I**z%a5%t;q2nU2-~@Vp0-!c<{9tB0HczJ-D5>j@1c)L&)?Nm...
import sys if sys.argv[-1] == 'ONLINE_JUDGE': import os, zlib, base64 open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${rg(Qbk;6n!V*A8xX2!mLJ;Em?@{EB5AmfVRNRYOAH7`}?&PrB3@)&N<wB?zw#e`fFMxbD#_d>`=+#OZPmEYOQu7x!jk!6oLz&xZ5jjV6RKrTtosZy6g-?b>$mwXj^Jxg(yuON0jjzgp$qXePvI!1vY|~x4+3G1*sYoc^rW~SE?dF...
6
6
768
644
import sys if sys.argv[-1] == "ONLINE_JUDGE": import os, zlib, base64 open("solve.pyx", "wb").write( zlib.decompress( base64.b85decode( "c${@p+is&U5Pe7DA4Xbjg}0;ysg)|!>{s+H$^#gajF#A`FSPypj<G3D+MO57oWq$j<KY+Z4|`Oy0p8<;29?~tXeaV)(CQSyyK}4CaTFtPJe`%caMrCnETj=TerIft>I**z%a5%t;q...
import sys if sys.argv[-1] == "ONLINE_JUDGE": import os, zlib, base64 open("solve.pyx", "wb").write( zlib.decompress( base64.b85decode( "c${rg(Qbk;6n!V*A8xX2!mLJ;Em?@{EB5AmfVRNRYOAH7`}?&PrB3@)&N<wB?zw#e`fFMxbD#_d>`=+#OZPmEYOQu7x!jk!6oLz&xZ5jjV6RKrTtosZy6g-?b>$mwXj^Jxg(yuON0...
false
0
[ "- \"c${@p+is&U5Pe7DA4Xbjg}0;ysg)|!>{s+H$^#gajF#A`FSPypj<G3D+MO57oWq$j<KY+Z4|`Oy0p8<;29?~tXeaV)(CQSyyK}4CaTFtPJe`%caMrCnETj=TerIft>I**z%a5%t;q2nU2-~@Vp0-!c<{9tB0HczJ-D5>j@1c)L&)?Nmh&|9(7r>)W<yp`xf?VlYEYeU~@*xWbQXOz?@(d`xpsoZCTc|?%?TDj*I+A>J1V;M>ThllY@(d484Rl(x|5n7Sargsu1-Hc65GR0ISf?fM=xb8g11GnIZyU^i{...
false
0.045669
0.048326
0.945012
[ "s010288445", "s819089153" ]
u794544096
p03000
python
s955217022
s785186691
76
66
61,868
61,840
Accepted
Accepted
13.16
n, x = list(map(int, input().split())) l = list(map(int, input().split())) count = 1 d = 0 for i in range(n): d += l[i] if d <= x: count += 1 print(count)
n, x = list(map(int, input().split())) l = list(map(int, input().split())) cnt = 1 z = 0 for i in range(n): z += l[i] if z <= x: cnt += 1 print(cnt)
11
12
184
180
n, x = list(map(int, input().split())) l = list(map(int, input().split())) count = 1 d = 0 for i in range(n): d += l[i] if d <= x: count += 1 print(count)
n, x = list(map(int, input().split())) l = list(map(int, input().split())) cnt = 1 z = 0 for i in range(n): z += l[i] if z <= x: cnt += 1 print(cnt)
false
8.333333
[ "-count = 1", "-d = 0", "+cnt = 1", "+z = 0", "- d += l[i]", "- if d <= x:", "- count += 1", "-print(count)", "+ z += l[i]", "+ if z <= x:", "+ cnt += 1", "+print(cnt)" ]
false
0.03138
0.036487
0.860012
[ "s955217022", "s785186691" ]
u905268546
p03767
python
s358768336
s016512278
264
203
37,084
39,492
Accepted
Accepted
23.11
print(sum(sorted(list([float(None==exec("N=int(input())"))] + list(map(int, input().split()))), reverse=True,key=lambda x: 10 ** 10 if type(x) == float else x)[2:2*N+1:2]))
print(sum(sorted(list(map(int,exec("N=int(input())")or input().split())))[-2:-2*N-1:-2]))
1
1
172
89
print( sum( sorted( list( [float(None == exec("N=int(input())"))] + list(map(int, input().split())) ), reverse=True, key=lambda x: 10**10 if type(x) == float else x, )[2 : 2 * N + 1 : 2] ) )
print( sum( sorted(list(map(int, exec("N=int(input())") or input().split())))[ -2 : -2 * N - 1 : -2 ] ) )
false
0
[ "- sorted(", "- list(", "- [float(None == exec(\"N=int(input())\"))]", "- + list(map(int, input().split()))", "- ),", "- reverse=True,", "- key=lambda x: 10**10 if type(x) == float else x,", "- )[2 : 2 * N + 1 : 2]...
false
0.045516
0.040172
1.133038
[ "s358768336", "s016512278" ]
u315078622
p02998
python
s571534326
s255920982
889
722
38,508
36,844
Accepted
Accepted
18.79
class UnionFindTree: """Disjoint-Set Data Structure Union-Find Tree complexity: init: O(n) find, unite, same: O(alpha(n)) used in SRM505 div.2 900, ATC001 A, DSL1A(AOJ) """ def __init__(self, n): self.par = list(range(n)) # parent self.rank...
class UnionFindTree: """Disjoint-Set Data Structure Union-Find Tree complexity: init: O(n) find, unite, same: O(alpha(n)) used in SRM505 div.2 900, ATC001 A, DSL1A(AOJ) """ def __init__(self, n): self.par = list(range(n)) # parent self.rank...
54
53
1,439
1,391
class UnionFindTree: """Disjoint-Set Data Structure Union-Find Tree complexity: init: O(n) find, unite, same: O(alpha(n)) used in SRM505 div.2 900, ATC001 A, DSL1A(AOJ) """ def __init__(self, n): self.par = list(range(n)) # parent self.rank = [0] * n # depth of t...
class UnionFindTree: """Disjoint-Set Data Structure Union-Find Tree complexity: init: O(n) find, unite, same: O(alpha(n)) used in SRM505 div.2 900, ATC001 A, DSL1A(AOJ) """ def __init__(self, n): self.par = list(range(n)) # parent self.rank = [0] * n # depth of t...
false
1.851852
[ "-uft = UnionFindTree(N + 2 * M)", "-for i in range(N):", "+uft = UnionFindTree(2 * M)", "+for _ in range(N):", "- uft.unite(i, x + N)", "- uft.unite(i, y + N + M)", "+ uft.unite(x, y + M)", "-for x in range(N, M + N):", "+for x in range(M):", "-for y in range(N + M, N + 2 * M):", "+for...
false
0.409898
0.283342
1.44665
[ "s571534326", "s255920982" ]
u077291787
p03495
python
s471139711
s768563323
98
79
41,500
35,996
Accepted
Accepted
19.39
# ARC086C - Not so Diverse (ABC081C) from collections import Counter def main(): n, k = list(map(int, input().rstrip().split())) A = sorted(list(Counter(list(map(int, input().split()))).values()), reverse=True) print((sum(A[k:]))) if __name__ == "__main__": main()
# ABC081C - Not so Diverse (ARC086C) from collections import Counter def main(): n, k = list(map(int, input().rstrip().split())) A = sorted(list(Counter(input().split()).values()), reverse=True) print((sum(A[k:]))) if __name__ == "__main__": main()
12
12
281
271
# ARC086C - Not so Diverse (ABC081C) from collections import Counter def main(): n, k = list(map(int, input().rstrip().split())) A = sorted(list(Counter(list(map(int, input().split()))).values()), reverse=True) print((sum(A[k:]))) if __name__ == "__main__": main()
# ABC081C - Not so Diverse (ARC086C) from collections import Counter def main(): n, k = list(map(int, input().rstrip().split())) A = sorted(list(Counter(input().split()).values()), reverse=True) print((sum(A[k:]))) if __name__ == "__main__": main()
false
0
[ "-# ARC086C - Not so Diverse (ABC081C)", "+# ABC081C - Not so Diverse (ARC086C)", "- A = sorted(list(Counter(list(map(int, input().split()))).values()), reverse=True)", "+ A = sorted(list(Counter(input().split()).values()), reverse=True)" ]
false
0.041247
0.121013
0.340846
[ "s471139711", "s768563323" ]
u790710233
p03157
python
s526345352
s203991966
989
700
130,808
273,928
Accepted
Accepted
29.22
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) h, w = list(map(int, input().split())) n = h*w fld = ''.join([input().rstrip()for _ in range(h)]) edges = [set() for _ in range(n)] def to_v(i, j): return i*w+j for i in range(h): for j in range(w): v = to_v(i, j) ...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) h, w = list(map(int, input().split())) n = h*w fld = ''.join([input().rstrip()for _ in range(h)]) def to_v(i, j): return i*w+j def generate_v2(v): i, j = divmod(v, w) if 0 < i: yield v-w if i < h-1: y...
45
44
931
751
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) h, w = list(map(int, input().split())) n = h * w fld = "".join([input().rstrip() for _ in range(h)]) edges = [set() for _ in range(n)] def to_v(i, j): return i * w + j for i in range(h): for j in range(w): v = to_v(i, j) dir...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) h, w = list(map(int, input().split())) n = h * w fld = "".join([input().rstrip() for _ in range(h)]) def to_v(i, j): return i * w + j def generate_v2(v): i, j = divmod(v, w) if 0 < i: yield v - w if i < h - 1: yield ...
false
2.222222
[ "-edges = [set() for _ in range(n)]", "-for i in range(h):", "- for j in range(w):", "- v = to_v(i, j)", "- dirc = [(-1, 0), (0, 1), (1, 0), (0, -1)]", "- for di, dj in dirc:", "- x, y = i + di, j + dj", "- if x < 0 or h <= x or y < 0 or w <= y:", "- ...
false
0.12222
0.077197
1.583227
[ "s526345352", "s203991966" ]
u778814286
p03403
python
s488520765
s974321423
276
249
14,172
13,920
Accepted
Accepted
9.78
n = int(eval(input())) tmpa = list(map(int, input().split())) A = [0] * (n+2) A[0] = 0 A[n+1] = 0 for i in range(1,n+1,1): A[i] = tmpa[i-1] #普通に総和を出す sum = 0 for i, a in enumerate(A): if i == n+1: break #n+1はゴールなので先に行かない sum += abs(a - A[i+1]) #a:A[i] #引いて足す for i in range(1, n+1, 1): #1~Nを省いたとき...
n = int(eval(input())) A = [0] + list(map(int, input().split())) + [0] #普通に総和を出す sum = 0 for i, a in enumerate(A): if i == n+1: break #n+1はゴールなので先に行かない sum += abs(a - A[i+1]) #a:A[i] #引いて足す for i in range(1, n+1, 1): #1~Nを省いたとき nowsum = sum nowsum -= abs(A[i-1]-A[i]) nowsum -= abs(A[i]-A[i+1]...
21
16
440
364
n = int(eval(input())) tmpa = list(map(int, input().split())) A = [0] * (n + 2) A[0] = 0 A[n + 1] = 0 for i in range(1, n + 1, 1): A[i] = tmpa[i - 1] # 普通に総和を出す sum = 0 for i, a in enumerate(A): if i == n + 1: break # n+1はゴールなので先に行かない sum += abs(a - A[i + 1]) # a:A[i] # 引いて足す for i in range(1, n +...
n = int(eval(input())) A = [0] + list(map(int, input().split())) + [0] # 普通に総和を出す sum = 0 for i, a in enumerate(A): if i == n + 1: break # n+1はゴールなので先に行かない sum += abs(a - A[i + 1]) # a:A[i] # 引いて足す for i in range(1, n + 1, 1): # 1~Nを省いたとき nowsum = sum nowsum -= abs(A[i - 1] - A[i]) nowsum...
false
23.809524
[ "-tmpa = list(map(int, input().split()))", "-A = [0] * (n + 2)", "-A[0] = 0", "-A[n + 1] = 0", "-for i in range(1, n + 1, 1):", "- A[i] = tmpa[i - 1]", "+A = [0] + list(map(int, input().split())) + [0]" ]
false
0.039261
0.038409
1.022174
[ "s488520765", "s974321423" ]
u098968285
p03639
python
s785065239
s719315810
230
71
63,472
11,480
Accepted
Accepted
69.13
# def makelist(n, m): # return [[0 for i in range(m)] for j in range(n)] # n = int(input()) # a, b = map(int, input().split()) # s = input() yes = "Yes" no = "No" N = int(eval(input())) a = list(map(int, input().split())) four = 0 two = 0 none = 0 for e in a: if e % 4 == 0: four += 1 eli...
N = int(eval(input())) four = 0 two = 0 one = 0 for e in map(int, input().split()): if e % 4 == 0: four += 1 elif e % 2 != 0: one += 1 else: two += 1 if four >= one: print("Yes") else: if two == 0 and four == one - 1: print("Yes") else: pr...
30
18
446
324
# def makelist(n, m): # return [[0 for i in range(m)] for j in range(n)] # n = int(input()) # a, b = map(int, input().split()) # s = input() yes = "Yes" no = "No" N = int(eval(input())) a = list(map(int, input().split())) four = 0 two = 0 none = 0 for e in a: if e % 4 == 0: four += 1 elif e % 2 != 0: ...
N = int(eval(input())) four = 0 two = 0 one = 0 for e in map(int, input().split()): if e % 4 == 0: four += 1 elif e % 2 != 0: one += 1 else: two += 1 if four >= one: print("Yes") else: if two == 0 and four == one - 1: print("Yes") else: print("No")
false
40
[ "-# def makelist(n, m):", "-# \treturn [[0 for i in range(m)] for j in range(n)]", "-# n = int(input())", "-# a, b = map(int, input().split())", "-# s = input()", "-yes = \"Yes\"", "-no = \"No\"", "-a = list(map(int, input().split()))", "-none = 0", "-for e in a:", "+one = 0", "+for e in map(i...
false
0.0569
0.042884
1.326851
[ "s785065239", "s719315810" ]
u022979415
p03504
python
s788163126
s305386778
459
326
35,388
28,608
Accepted
Accepted
28.98
from heapq import heappop, heappush def main(): n, c = list(map(int, input().split())) program = [[] for _ in range(c)] for _ in range(n): s, t, cc = list(map(int, input().split())) cc -= 1 s *= 2 t *= 2 program[cc].append([s - 1, t]) all_p = [] ...
from itertools import accumulate def main(): n, c = list(map(int, input().split())) p = [[] for _ in range(c + 1)] for _ in range(n): *st, cc = list(map(int, input().split())) p[cc].append(st) all_p = [0] * (10 ** 5 + 10) for pp in p: if len(pp) == 0: ...
39
29
1,096
775
from heapq import heappop, heappush def main(): n, c = list(map(int, input().split())) program = [[] for _ in range(c)] for _ in range(n): s, t, cc = list(map(int, input().split())) cc -= 1 s *= 2 t *= 2 program[cc].append([s - 1, t]) all_p = [] for i in ran...
from itertools import accumulate def main(): n, c = list(map(int, input().split())) p = [[] for _ in range(c + 1)] for _ in range(n): *st, cc = list(map(int, input().split())) p[cc].append(st) all_p = [0] * (10**5 + 10) for pp in p: if len(pp) == 0: continue ...
false
25.641026
[ "-from heapq import heappop, heappush", "+from itertools import accumulate", "- program = [[] for _ in range(c)]", "+ p = [[] for _ in range(c + 1)]", "- s, t, cc = list(map(int, input().split()))", "- cc -= 1", "- s *= 2", "- t *= 2", "- program[cc].append([...
false
0.041874
0.039517
1.059643
[ "s788163126", "s305386778" ]
u780475861
p02814
python
s789076430
s569117791
208
117
14,532
14,508
Accepted
Accepted
43.75
import sys readline = sys.stdin.buffer.readline from fractions import gcd from functools import reduce n,m = list(map(int,readline().split())) alst = list(map(int,readline().split())) def lcm(x,y): g=gcd(x,y) if x//g %2==0 or y//g%2==0: return 0 return x*y//g g=reduce(lcm,alst) if g==0: pri...
import sys read = sys.stdin.buffer.read from fractions import gcd from functools import reduce n,m,*alst = list(map(int,read().split())) mm=2*m def lcm(x,y): g=gcd(x,y) if x//g %2==0 or y//g%2==0: return 0 g=x*y//g if g>mm: return 0 return g g=reduce(lcm,alst) if g==0: print((0)) ...
20
22
375
372
import sys readline = sys.stdin.buffer.readline from fractions import gcd from functools import reduce n, m = list(map(int, readline().split())) alst = list(map(int, readline().split())) def lcm(x, y): g = gcd(x, y) if x // g % 2 == 0 or y // g % 2 == 0: return 0 return x * y // g g = reduce(l...
import sys read = sys.stdin.buffer.read from fractions import gcd from functools import reduce n, m, *alst = list(map(int, read().split())) mm = 2 * m def lcm(x, y): g = gcd(x, y) if x // g % 2 == 0 or y // g % 2 == 0: return 0 g = x * y // g if g > mm: return 0 return g g = re...
false
9.090909
[ "-readline = sys.stdin.buffer.readline", "+read = sys.stdin.buffer.read", "-n, m = list(map(int, readline().split()))", "-alst = list(map(int, readline().split()))", "+n, m, *alst = list(map(int, read().split()))", "+mm = 2 * m", "- return x * y // g", "+ g = x * y // g", "+ if g > mm:", ...
false
0.057574
0.04843
1.188795
[ "s789076430", "s569117791" ]
u645436608
p02721
python
s752593698
s106873241
525
363
20,612
20,616
Accepted
Accepted
30.86
n, k, c = list(map(int, input().split())) s = eval(input()) l = [-1] * k r = [-1] * k nowl = 0 indl = 0 while nowl < n and indl < k: for i in range(nowl, n): if s[i] == "o": l[indl] = i nowl = i + c + 1 indl += 1 break nowr = n - 1 indr = k - 1 ...
N, K, C = list(map(int, input().split())) S = eval(input()) L = [-1] * K R = [-1] * K L_index = 0 L_count = 0 R_index = N - 1 R_count = K - 1 while L_index < N and L_count < K: if S[L_index] == "o": L[L_count] = L_index L_index += (C + 1) L_count += 1 else: L_inde...
25
27
563
561
n, k, c = list(map(int, input().split())) s = eval(input()) l = [-1] * k r = [-1] * k nowl = 0 indl = 0 while nowl < n and indl < k: for i in range(nowl, n): if s[i] == "o": l[indl] = i nowl = i + c + 1 indl += 1 break nowr = n - 1 indr = k - 1 while nowr >= 0...
N, K, C = list(map(int, input().split())) S = eval(input()) L = [-1] * K R = [-1] * K L_index = 0 L_count = 0 R_index = N - 1 R_count = K - 1 while L_index < N and L_count < K: if S[L_index] == "o": L[L_count] = L_index L_index += C + 1 L_count += 1 else: L_index += 1 while R_ind...
false
7.407407
[ "-n, k, c = list(map(int, input().split()))", "-s = eval(input())", "-l = [-1] * k", "-r = [-1] * k", "-nowl = 0", "-indl = 0", "-while nowl < n and indl < k:", "- for i in range(nowl, n):", "- if s[i] == \"o\":", "- l[indl] = i", "- nowl = i + c + 1", "- ...
false
0.047051
0.039831
1.181246
[ "s752593698", "s106873241" ]
u680851063
p02995
python
s251321142
s382585600
39
35
5,104
5,104
Accepted
Accepted
10.26
a, b, c, d = list(map(int, input().split())) from fractions import gcd #lcm = c * d // gcd(c, d) lcm = int(c * d / gcd(c, d)) a_num = (a-1)//c + (a-1)//d - (a-1)//lcm b_num = (b)//c + (b)//d - (b)//lcm print((b-a+1 - (b_num - a_num)))
a, b, c, d = list(map(int, input().split())) from fractions import gcd lcm = c * d // gcd(c, d) #lcm = int(c * d / gcd(c, d)) a_num = (a-1)//c + (a-1)//d - (a-1)//lcm b_num = (b)//c + (b)//d - (b)//lcm print((b-a+1 - (b_num - a_num)))
10
10
238
238
a, b, c, d = list(map(int, input().split())) from fractions import gcd # lcm = c * d // gcd(c, d) lcm = int(c * d / gcd(c, d)) a_num = (a - 1) // c + (a - 1) // d - (a - 1) // lcm b_num = (b) // c + (b) // d - (b) // lcm print((b - a + 1 - (b_num - a_num)))
a, b, c, d = list(map(int, input().split())) from fractions import gcd lcm = c * d // gcd(c, d) # lcm = int(c * d / gcd(c, d)) a_num = (a - 1) // c + (a - 1) // d - (a - 1) // lcm b_num = (b) // c + (b) // d - (b) // lcm print((b - a + 1 - (b_num - a_num)))
false
0
[ "-# lcm = c * d // gcd(c, d)", "-lcm = int(c * d / gcd(c, d))", "+lcm = c * d // gcd(c, d)", "+# lcm = int(c * d / gcd(c, d))" ]
false
0.064088
0.063591
1.00782
[ "s251321142", "s382585600" ]
u893063840
p03327
python
s809521404
s927888464
19
17
3,316
2,940
Accepted
Accepted
10.53
n = int(eval(input())) if n <= 999: print("ABC") else: print("ABD")
n = int(eval(input())) if n < 1000: ans = "ABC" else: ans = "ABD" print(ans)
6
7
76
86
n = int(eval(input())) if n <= 999: print("ABC") else: print("ABD")
n = int(eval(input())) if n < 1000: ans = "ABC" else: ans = "ABD" print(ans)
false
14.285714
[ "-if n <= 999:", "- print(\"ABC\")", "+if n < 1000:", "+ ans = \"ABC\"", "- print(\"ABD\")", "+ ans = \"ABD\"", "+print(ans)" ]
false
0.043989
0.050967
0.86308
[ "s809521404", "s927888464" ]
u918601425
p03078
python
s491916630
s096477236
752
244
164,488
46,588
Accepted
Accepted
67.55
X,Y,Z,K=[int(s) for s in input().split()] xls=sorted([int(s) for s in input().split()],reverse=True) yls=sorted([int(s) for s in input().split()],reverse=True) zls=sorted([int(s) for s in input().split()],reverse=True) xyls=[] for x in xls[:K]: for y in yls[:K]: xyls.append(x+y) xyls=sorted(xyls,reverse=T...
X,Y,Z,K=[int(s) for s in input().split()] xls=sorted([int(s) for s in input().split()],reverse=True) yls=sorted([int(s) for s in input().split()],reverse=True) zls=sorted([int(s) for s in input().split()],reverse=True) cake=[] for a in range(X): for b in range(Y): ab=(a+1)*(b+1) for c in range(Z): ...
16
17
468
491
X, Y, Z, K = [int(s) for s in input().split()] xls = sorted([int(s) for s in input().split()], reverse=True) yls = sorted([int(s) for s in input().split()], reverse=True) zls = sorted([int(s) for s in input().split()], reverse=True) xyls = [] for x in xls[:K]: for y in yls[:K]: xyls.append(x + y) xyls = sor...
X, Y, Z, K = [int(s) for s in input().split()] xls = sorted([int(s) for s in input().split()], reverse=True) yls = sorted([int(s) for s in input().split()], reverse=True) zls = sorted([int(s) for s in input().split()], reverse=True) cake = [] for a in range(X): for b in range(Y): ab = (a + 1) * (b + 1) ...
false
5.882353
[ "-xyls = []", "-for x in xls[:K]:", "- for y in yls[:K]:", "- xyls.append(x + y)", "-xyls = sorted(xyls, reverse=True)", "-for xy in xyls[:K]:", "- for z in zls[:K]:", "- cake.append(xy + z)", "+for a in range(X):", "+ for b in range(Y):", "+ ab = (a + 1) * (b + 1)"...
false
0.036065
0.044502
0.810411
[ "s491916630", "s096477236" ]
u399298563
p04001
python
s134130410
s907493830
181
167
38,384
38,256
Accepted
Accepted
7.73
S = eval(input()) if len(S) == 1: print((int(S))) exit() else: def count(n): if len(n) == 1: return 0 else: a = 0 for i in range(1, len(n)): a += int(n[:i]) * 2 ** (len(n) - 1 - i) + int(n[i:]) + count(n[i:]) return a ans = int(S) + count(S) print(ans)
s=eval(input()) if len(s)==1: print((int(s))) else: def count(num): # basecase if len(num)==1: return 0 else: a=0 for j in range(1,len(num)): a+=int(num[:j])*2**(len(num[j:])-1)+int(num[j:])+count(num[j:]) ...
15
17
308
363
S = eval(input()) if len(S) == 1: print((int(S))) exit() else: def count(n): if len(n) == 1: return 0 else: a = 0 for i in range(1, len(n)): a += int(n[:i]) * 2 ** (len(n) - 1 - i) + int(n[i:]) + count(n[i:]) return a ans ...
s = eval(input()) if len(s) == 1: print((int(s))) else: def count(num): # basecase if len(num) == 1: return 0 else: a = 0 for j in range(1, len(num)): a += ( int(num[:j]) * 2 ** (len(num[j:]) - 1) ...
false
11.764706
[ "-S = eval(input())", "-if len(S) == 1:", "- print((int(S)))", "- exit()", "+s = eval(input())", "+if len(s) == 1:", "+ print((int(s)))", "- def count(n):", "- if len(n) == 1:", "+ def count(num):", "+ # basecase", "+ if len(num) == 1:", "- for ...
false
0.087963
0.090328
0.97381
[ "s134130410", "s907493830" ]
u387774811
p02684
python
s372789990
s340394791
751
448
310,180
217,248
Accepted
Accepted
40.35
N,K=list(map(int,input().split())) T=str(bin(K)) S=len(T)-2 A = list(map(int,input().split())) lst=[[0 for e in range(N+1)] for f in range(S)] for i in range(1,N+1): lst[0][i]=A[i-1] for j in range(1,S): for i in range(1,N+1): lst[j][i]=lst[j-1][lst[j-1][i]] ans=[[e for e in range(N+1)] for f in range(S+1...
N,K=list(map(int,input().split())) T=str(bin(K)) S=len(T)-2 A = list(map(int,input().split())) lst=[[0 for e in range(N+1)] for f in range(S)] for i in range(1,N+1): lst[0][i]=A[i-1] for j in range(1,S): for i in range(1,N+1): lst[j][i]=lst[j-1][lst[j-1][i]] ans=1 for k in range(S): if int(T[k+2])==1: ...
19
15
500
348
N, K = list(map(int, input().split())) T = str(bin(K)) S = len(T) - 2 A = list(map(int, input().split())) lst = [[0 for e in range(N + 1)] for f in range(S)] for i in range(1, N + 1): lst[0][i] = A[i - 1] for j in range(1, S): for i in range(1, N + 1): lst[j][i] = lst[j - 1][lst[j - 1][i]] ans = [[e for...
N, K = list(map(int, input().split())) T = str(bin(K)) S = len(T) - 2 A = list(map(int, input().split())) lst = [[0 for e in range(N + 1)] for f in range(S)] for i in range(1, N + 1): lst[0][i] = A[i - 1] for j in range(1, S): for i in range(1, N + 1): lst[j][i] = lst[j - 1][lst[j - 1][i]] ans = 1 for k...
false
21.052632
[ "-ans = [[e for e in range(N + 1)] for f in range(S + 1)]", "+ans = 1", "- for l in range(1, N + 1):", "- ans[k + 1][l] = lst[S - 1 - k][ans[k][l]]", "- else:", "- for l in range(1, N + 1):", "- ans[k + 1][l] = ans[k][l]", "-print((ans[S][1]))", "+ ans =...
false
0.079396
0.097792
0.811885
[ "s372789990", "s340394791" ]
u887207211
p03545
python
s622884472
s934290891
20
18
3,188
3,060
Accepted
Accepted
10
import itertools A, B, C, D = list(eval(input())) op = ['+','-'] for op1,op2,op3 in itertools.product(op,op,op): x = A + op1 + B + op2 + C + op3 + D if(eval(x) == 7): print((x + "=7")) break
N = eval(input()) A, B, C, D = N[0], N[1], N[2], N[3] ops = ['+','-'] for op1 in ops: for op2 in ops: for op3 in ops: if(eval(A + op1 + B + op2 + C + op3 + D) == 7): print((A + op1 + B + op2 + C + op3 + D + "=7")) exit()
10
10
205
250
import itertools A, B, C, D = list(eval(input())) op = ["+", "-"] for op1, op2, op3 in itertools.product(op, op, op): x = A + op1 + B + op2 + C + op3 + D if eval(x) == 7: print((x + "=7")) break
N = eval(input()) A, B, C, D = N[0], N[1], N[2], N[3] ops = ["+", "-"] for op1 in ops: for op2 in ops: for op3 in ops: if eval(A + op1 + B + op2 + C + op3 + D) == 7: print((A + op1 + B + op2 + C + op3 + D + "=7")) exit()
false
0
[ "-import itertools", "-", "-A, B, C, D = list(eval(input()))", "-op = [\"+\", \"-\"]", "-for op1, op2, op3 in itertools.product(op, op, op):", "- x = A + op1 + B + op2 + C + op3 + D", "- if eval(x) == 7:", "- print((x + \"=7\"))", "- break", "+N = eval(input())", "+A, B, C, D...
false
0.094366
0.0485
1.94569
[ "s622884472", "s934290891" ]
u353919145
p02622
python
s007571012
s810228613
63
47
9,276
9,340
Accepted
Accepted
25.4
S = eval(input()) T = eval(input()) if len(S) != len(T): quit() sum = 0 for i in range(len(S)): if T[i] != S[i]: sum = sum + 1 print(sum)
def main(): s = eval(input()) t = eval(input()) count = 0 for i in range(len(s)): if s[i] != t[i]: count += 1 print(count) if __name__ == "__main__": main()
8
16
144
233
S = eval(input()) T = eval(input()) if len(S) != len(T): quit() sum = 0 for i in range(len(S)): if T[i] != S[i]: sum = sum + 1 print(sum)
def main(): s = eval(input()) t = eval(input()) count = 0 for i in range(len(s)): if s[i] != t[i]: count += 1 print(count) if __name__ == "__main__": main()
false
50
[ "-S = eval(input())", "-T = eval(input())", "-if len(S) != len(T):", "- quit()", "-sum = 0", "-for i in range(len(S)):", "- if T[i] != S[i]:", "- sum = sum + 1", "-print(sum)", "+def main():", "+ s = eval(input())", "+ t = eval(input())", "+ count = 0", "+ for i in...
false
0.037783
0.03634
1.039711
[ "s007571012", "s810228613" ]
u709304134
p02713
python
s892619934
s256626023
1,887
1,181
9,176
9,184
Accepted
Accepted
37.41
from math import gcd K = int(eval(input())) ans = 0 for i in range(1,K+1): for j in range(1,K+1): for k in range(1,K+1): ans += gcd(gcd(i,j),k) print (ans)
from math import gcd K = int(eval(input())) ans = 0 for i in range(1,K+1): for j in range(1,K+1): gcd_ij = gcd(i, j) for k in range(1,K+1): ans += gcd(gcd_ij, k) print (ans)
8
9
180
207
from math import gcd K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): for k in range(1, K + 1): ans += gcd(gcd(i, j), k) print(ans)
from math import gcd K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): gcd_ij = gcd(i, j) for k in range(1, K + 1): ans += gcd(gcd_ij, k) print(ans)
false
11.111111
[ "+ gcd_ij = gcd(i, j)", "- ans += gcd(gcd(i, j), k)", "+ ans += gcd(gcd_ij, k)" ]
false
0.00819
0.192211
0.04261
[ "s892619934", "s256626023" ]
u756518877
p03012
python
s590138428
s637798696
20
17
3,064
3,060
Accepted
Accepted
15
# -*- coding: utf-8 -*- n=int(eval(input())) W=list(map(int,input().split())) t=0 while sum(W[:t])<sum(W[t:]) and t<n: t=t+1 print((min(abs(sum(W[:t])-sum(W[t:])),abs(sum(W[:t-1])-sum(W[t-1:])))))
# -*- coding: utf-8 -*- n=int(eval(input())) W=list(map(int,input().split())) for i in range(n): if sum(W[:i])>sum(W[i:]) or i==n-1: print((min(sum(W[i-1:])-sum(W[:i-1]),sum(W[:i])-sum(W[i:])))) break
7
7
196
218
# -*- coding: utf-8 -*- n = int(eval(input())) W = list(map(int, input().split())) t = 0 while sum(W[:t]) < sum(W[t:]) and t < n: t = t + 1 print((min(abs(sum(W[:t]) - sum(W[t:])), abs(sum(W[: t - 1]) - sum(W[t - 1 :])))))
# -*- coding: utf-8 -*- n = int(eval(input())) W = list(map(int, input().split())) for i in range(n): if sum(W[:i]) > sum(W[i:]) or i == n - 1: print((min(sum(W[i - 1 :]) - sum(W[: i - 1]), sum(W[:i]) - sum(W[i:])))) break
false
0
[ "-t = 0", "-while sum(W[:t]) < sum(W[t:]) and t < n:", "- t = t + 1", "-print((min(abs(sum(W[:t]) - sum(W[t:])), abs(sum(W[: t - 1]) - sum(W[t - 1 :])))))", "+for i in range(n):", "+ if sum(W[:i]) > sum(W[i:]) or i == n - 1:", "+ print((min(sum(W[i - 1 :]) - sum(W[: i - 1]), sum(W[:i]) - su...
false
0.03999
0.038664
1.034296
[ "s590138428", "s637798696" ]
u696444274
p03042
python
s606041956
s491936235
36
17
5,148
3,060
Accepted
Accepted
52.78
import math import itertools import statistics #n = int(input()) s=eval(input()) a = int(s[0])*10+int(s[1]) b = int(s[2])*10+int(s[3]) # yymm yy>12 and 12>=mm>=1 # mmyy 1<=mm<=12 and yy > 12 # doble 1<=yy<=12 and 1<=mm<=12 # na mm=0 and yy?12 if 0<a<13 and 0<b<13: print("AMBIGUOUS") elif a > 12 and 0<...
s = eval(input()) start = int(s[0]+s[1]) end = int(s[2]+s[3]) if 1 <= start <= 12 and 1 <= end <= 12: print("AMBIGUOUS") elif 1 <= start <= 12 and (end > 12 or end == 0): print("MMYY") elif (start > 12 or start == 0) and 1 <= end <= 12: print("YYMM") else: print("NA")
24
12
523
291
import math import itertools import statistics # n = int(input()) s = eval(input()) a = int(s[0]) * 10 + int(s[1]) b = int(s[2]) * 10 + int(s[3]) # yymm yy>12 and 12>=mm>=1 # mmyy 1<=mm<=12 and yy > 12 # doble 1<=yy<=12 and 1<=mm<=12 # na mm=0 and yy?12 if 0 < a < 13 and 0 < b < 13: print("AMBIGUOUS") elif a > 12...
s = eval(input()) start = int(s[0] + s[1]) end = int(s[2] + s[3]) if 1 <= start <= 12 and 1 <= end <= 12: print("AMBIGUOUS") elif 1 <= start <= 12 and (end > 12 or end == 0): print("MMYY") elif (start > 12 or start == 0) and 1 <= end <= 12: print("YYMM") else: print("NA")
false
50
[ "-import math", "-import itertools", "-import statistics", "-", "-# n = int(input())", "-a = int(s[0]) * 10 + int(s[1])", "-b = int(s[2]) * 10 + int(s[3])", "-# yymm yy>12 and 12>=mm>=1", "-# mmyy 1<=mm<=12 and yy > 12", "-# doble 1<=yy<=12 and 1<=mm<=12", "-# na mm=0 and yy?12", "-if 0 < a <...
false
0.03795
0.037078
1.023523
[ "s606041956", "s491936235" ]
u624475441
p03611
python
s117664322
s971609412
91
66
14,856
14,732
Accepted
Accepted
27.47
cnt = [0]*10**5; eval(input()) a = list(map(int,input().split())) for x in a:cnt[x]+=1 print((max(sum(cnt[i:i+3])for i in range(10**5))))
cnt = [0]*10**5; eval(input()) a = list(map(int,input().split())) for x in a:cnt[x]+=1 print((max(list(map(sum,list(zip(cnt,cnt[1:],cnt[2:])))))))
4
4
132
129
cnt = [0] * 10**5 eval(input()) a = list(map(int, input().split())) for x in a: cnt[x] += 1 print((max(sum(cnt[i : i + 3]) for i in range(10**5))))
cnt = [0] * 10**5 eval(input()) a = list(map(int, input().split())) for x in a: cnt[x] += 1 print((max(list(map(sum, list(zip(cnt, cnt[1:], cnt[2:])))))))
false
0
[ "-print((max(sum(cnt[i : i + 3]) for i in range(10**5))))", "+print((max(list(map(sum, list(zip(cnt, cnt[1:], cnt[2:])))))))" ]
false
0.087954
0.111419
0.789395
[ "s117664322", "s971609412" ]
u077898957
p03338
python
s224849126
s301976209
309
18
21,500
3,060
Accepted
Accepted
94.17
import numpy as np import sys n = int(eval(input())) s = eval(input()) ans = 0 for i in range(n-2): count = len(set(s[:i+1]))+len(set(s[i+1:]))-len(set(list(set(s[:i+1]))+list(set(s[i+1:])))) ans = max(ans,count) print(ans)
n=int(eval(input())) s=eval(input()) ans=0 for i in range(n): x=list(set(s[:i+1])) y=list(set(s[i+1:])) cnt=0 for j in range(min(len(x),len(y))): if i<=n//2: if x[j] in y: cnt+=1 else: if y[j] in x: cnt+=1 ans=max(...
9
16
228
329
import numpy as np import sys n = int(eval(input())) s = eval(input()) ans = 0 for i in range(n - 2): count = ( len(set(s[: i + 1])) + len(set(s[i + 1 :])) - len(set(list(set(s[: i + 1])) + list(set(s[i + 1 :])))) ) ans = max(ans, count) print(ans)
n = int(eval(input())) s = eval(input()) ans = 0 for i in range(n): x = list(set(s[: i + 1])) y = list(set(s[i + 1 :])) cnt = 0 for j in range(min(len(x), len(y))): if i <= n // 2: if x[j] in y: cnt += 1 else: if y[j] in x: cnt += 1...
false
43.75
[ "-import numpy as np", "-import sys", "-", "-for i in range(n - 2):", "- count = (", "- len(set(s[: i + 1]))", "- + len(set(s[i + 1 :]))", "- - len(set(list(set(s[: i + 1])) + list(set(s[i + 1 :]))))", "- )", "- ans = max(ans, count)", "+for i in range(n):", "+ ...
false
0.036459
0.039706
0.918224
[ "s224849126", "s301976209" ]
u498487134
p02821
python
s620591362
s579259734
1,112
700
55,892
33,548
Accepted
Accepted
37.05
N,M = list(map(int,input().split())) A = list(map(int,input().split())) A.sort(reverse=True) #幸福度をX以上増やせる手が何通りあるか?を二分探索. #左手で握る人は線形探索,右手が二分探索で探す #最後は累積和で計算 inf = 2*10**5+1 X_top = inf X_bot = 0 #M手以上の組み合わせが作れる最大値 #幸福度をX以上挙げられる手の通り数ががMになる境界を探す while X_top - X_bot !=1: X=(X_top+X_bot)//2 num=0...
import numpy as np N,M = list(map(int,input().split())) A = list(map(int,input().split())) Amax=max(A) n0 = 2**int(np.ceil(np.log2(2*Amax+1)))#Amax+1以上となる最小の2のべき乗数 Afre=np.zeros(n0).astype(int)#パワーの頻度(1~Amax+1) for i in range(N): Afre[A[i]]+=1 #astype(int)は切り捨てなので,rintで四捨五入してから. S = np.rint(np.fft....
65
23
1,243
590
N, M = list(map(int, input().split())) A = list(map(int, input().split())) A.sort(reverse=True) # 幸福度をX以上増やせる手が何通りあるか?を二分探索. # 左手で握る人は線形探索,右手が二分探索で探す # 最後は累積和で計算 inf = 2 * 10**5 + 1 X_top = inf X_bot = 0 # M手以上の組み合わせが作れる最大値 # 幸福度をX以上挙げられる手の通り数ががMになる境界を探す while X_top - X_bot != 1: X = (X_top + X_bot) // 2 num =...
import numpy as np N, M = list(map(int, input().split())) A = list(map(int, input().split())) Amax = max(A) n0 = 2 ** int(np.ceil(np.log2(2 * Amax + 1))) # Amax+1以上となる最小の2のべき乗数 Afre = np.zeros(n0).astype(int) # パワーの頻度(1~Amax+1) for i in range(N): Afre[A[i]] += 1 # astype(int)は切り捨てなので,rintで四捨五入してから. S = np.rint(n...
false
64.615385
[ "+import numpy as np", "+", "-A.sort(reverse=True)", "-# 幸福度をX以上増やせる手が何通りあるか?を二分探索.", "-# 左手で握る人は線形探索,右手が二分探索で探す", "-# 最後は累積和で計算", "-inf = 2 * 10**5 + 1", "-X_top = inf", "-X_bot = 0 # M手以上の組み合わせが作れる最大値", "-# 幸福度をX以上挙げられる手の通り数ががMになる境界を探す", "-while X_top - X_bot != 1:", "- X = (X_top + X_bo...
false
0.041448
0.209946
0.197422
[ "s620591362", "s579259734" ]
u899909022
p02972
python
s840966649
s181076958
1,078
958
12,088
10,612
Accepted
Accepted
11.13
N=int(eval(input())) A=list(map(int,input().split())) B=[0] * N ans = [] for i in reversed(list(range(1, N+1))): a = 0 for j in range(1, N+1): tmp = i * j if tmp > N: break a = (B[tmp-1] + a) % 2 if (A[i-1] + a) % 2 == 1: ans.append(i) B[i-1] = (A...
N=int(eval(input())) A=list(map(int,input().split())) ans = [] for i in reversed(list(range(1, N+1))): a = A[i-1] for j in range(2, N+1): tmp = i * j if tmp > N: break a += A[tmp-1] if a % 2 == 1: ans.append(i) A[i-1] = a % 2 print((len(ans))) fo...
16
16
363
331
N = int(eval(input())) A = list(map(int, input().split())) B = [0] * N ans = [] for i in reversed(list(range(1, N + 1))): a = 0 for j in range(1, N + 1): tmp = i * j if tmp > N: break a = (B[tmp - 1] + a) % 2 if (A[i - 1] + a) % 2 == 1: ans.append(i) B[i - 1] ...
N = int(eval(input())) A = list(map(int, input().split())) ans = [] for i in reversed(list(range(1, N + 1))): a = A[i - 1] for j in range(2, N + 1): tmp = i * j if tmp > N: break a += A[tmp - 1] if a % 2 == 1: ans.append(i) A[i - 1] = a % 2 print((len(ans))) f...
false
0
[ "-B = [0] * N", "- a = 0", "- for j in range(1, N + 1):", "+ a = A[i - 1]", "+ for j in range(2, N + 1):", "- a = (B[tmp - 1] + a) % 2", "- if (A[i - 1] + a) % 2 == 1:", "+ a += A[tmp - 1]", "+ if a % 2 == 1:", "- B[i - 1] = (A[i - 1] + a) % 2", "+ A[i - 1] ...
false
0.064524
0.062736
1.028501
[ "s840966649", "s181076958" ]
u662145476
p02923
python
s451756071
s120095464
86
79
14,252
14,252
Accepted
Accepted
8.14
import sys import math N = sys.stdin.readline() H = list(map(int, sys.stdin.readline().split(' '))) t = list(map(lambda x, y: 1 if x >= y else 0, H[:-1], H[1:])) m = 0 s = 0 for x in t: if x: s += 1 m = max(s, m) else: s = 0 print(m)
import sys import math N = sys.stdin.readline() H = list(map(int, sys.stdin.readline().split(' '))) m = 0 s = 0 for x, y in zip(H[:-1], H[1:]): if x >= y: s += 1 m = max(s, m) else: s = 0 print(m)
17
16
285
246
import sys import math N = sys.stdin.readline() H = list(map(int, sys.stdin.readline().split(" "))) t = list(map(lambda x, y: 1 if x >= y else 0, H[:-1], H[1:])) m = 0 s = 0 for x in t: if x: s += 1 m = max(s, m) else: s = 0 print(m)
import sys import math N = sys.stdin.readline() H = list(map(int, sys.stdin.readline().split(" "))) m = 0 s = 0 for x, y in zip(H[:-1], H[1:]): if x >= y: s += 1 m = max(s, m) else: s = 0 print(m)
false
5.882353
[ "-t = list(map(lambda x, y: 1 if x >= y else 0, H[:-1], H[1:]))", "-for x in t:", "- if x:", "+for x, y in zip(H[:-1], H[1:]):", "+ if x >= y:" ]
false
0.036919
0.035127
1.051034
[ "s451756071", "s120095464" ]
u966508131
p03455
python
s890762516
s401622552
173
17
38,256
2,940
Accepted
Accepted
90.17
a,b=list(map(int,input().split())) print(("Even" if a*b%2==0 else "Odd"))
a, b = list(map(int, input().split())) if a * b % 2 == 0: print('Even') else: print('Odd')
2
5
66
97
a, b = list(map(int, input().split())) print(("Even" if a * b % 2 == 0 else "Odd"))
a, b = list(map(int, input().split())) if a * b % 2 == 0: print("Even") else: print("Odd")
false
60
[ "-print((\"Even\" if a * b % 2 == 0 else \"Odd\"))", "+if a * b % 2 == 0:", "+ print(\"Even\")", "+else:", "+ print(\"Odd\")" ]
false
0.047052
0.042862
1.097747
[ "s890762516", "s401622552" ]
u391731808
p03480
python
s914907593
s208213361
37
19
3,188
3,188
Accepted
Accepted
48.65
S = eval(input()) l = len(S) i = 0 if l%2: c = S[l//2] for i in range(1,l//2+1): if S[l//2-i] != c or S[l//2 + i] != c: break else: i += 1 print((l//2+i)) else: c = S[l//2] for i in range(l//2): if S[l//2-1-i] != c or S[l//2 + i] != c: ...
S = eval(input()) N = len(S) def f(k): s = S[-k:k] if s == "":return False return s.count(s[0])!=len(s) def binary_search(l,r,func): if func(l):return l-1 if not func(r):return r while l+1<r: i = (l+r)//2 if func(i): r = i else: l...
20
20
382
363
S = eval(input()) l = len(S) i = 0 if l % 2: c = S[l // 2] for i in range(1, l // 2 + 1): if S[l // 2 - i] != c or S[l // 2 + i] != c: break else: i += 1 print((l // 2 + i)) else: c = S[l // 2] for i in range(l // 2): if S[l // 2 - 1 - i] != c or S[l // 2 + i]...
S = eval(input()) N = len(S) def f(k): s = S[-k:k] if s == "": return False return s.count(s[0]) != len(s) def binary_search(l, r, func): if func(l): return l - 1 if not func(r): return r while l + 1 < r: i = (l + r) // 2 if func(i): r = i ...
false
0
[ "-l = len(S)", "-i = 0", "-if l % 2:", "- c = S[l // 2]", "- for i in range(1, l // 2 + 1):", "- if S[l // 2 - i] != c or S[l // 2 + i] != c:", "- break", "- else:", "- i += 1", "- print((l // 2 + i))", "-else:", "- c = S[l // 2]", "- for i in range...
false
0.03866
0.036017
1.073382
[ "s914907593", "s208213361" ]
u798803522
p02376
python
s811579048
s793576132
1,270
90
8,352
6,224
Accepted
Accepted
92.91
from collections import defaultdict def dfs(source, sink, flow, connect): if source == sink: return flow used[source] = 1 for i, (target, cost, rev_i) in enumerate(connect[source]): if not used[target] and cost > 0: that_flow = dfs(target, sink, min(flow, cost), connect)...
from collections import defaultdict def bfs(start, end, connect, v_num, flow): level = [-1] * v_num level[start] = 0 queue = [start] while queue: v = queue.pop() for next_v in connect[v]: if flow[v][next_v] > 0 and level[next_v] < 0: level[next_v] =...
31
50
1,002
1,665
from collections import defaultdict def dfs(source, sink, flow, connect): if source == sink: return flow used[source] = 1 for i, (target, cost, rev_i) in enumerate(connect[source]): if not used[target] and cost > 0: that_flow = dfs(target, sink, min(flow, cost), connect) ...
from collections import defaultdict def bfs(start, end, connect, v_num, flow): level = [-1] * v_num level[start] = 0 queue = [start] while queue: v = queue.pop() for next_v in connect[v]: if flow[v][next_v] > 0 and level[next_v] < 0: level[next_v] = level[v]...
false
38
[ "-def dfs(source, sink, flow, connect):", "- if source == sink:", "- return flow", "- used[source] = 1", "- for i, (target, cost, rev_i) in enumerate(connect[source]):", "- if not used[target] and cost > 0:", "- that_flow = dfs(target, sink, min(flow, cost), connect)", ...
false
0.080451
0.036106
2.2282
[ "s811579048", "s793576132" ]
u997641430
p02659
python
s176632245
s452565771
60
22
61,812
9,148
Accepted
Accepted
63.33
a, b = input().split() a = int(a) b = b.split('.') b = int(b[0] + b[1]) ans = str(a * b) if len(ans) <= 2: print((0)) else: print((ans[:-2]))
a, b = input().split() a = int(a) b = int(b.replace('.', '')) print((a * b // 100))
9
4
154
85
a, b = input().split() a = int(a) b = b.split(".") b = int(b[0] + b[1]) ans = str(a * b) if len(ans) <= 2: print((0)) else: print((ans[:-2]))
a, b = input().split() a = int(a) b = int(b.replace(".", "")) print((a * b // 100))
false
55.555556
[ "-b = b.split(\".\")", "-b = int(b[0] + b[1])", "-ans = str(a * b)", "-if len(ans) <= 2:", "- print((0))", "-else:", "- print((ans[:-2]))", "+b = int(b.replace(\".\", \"\"))", "+print((a * b // 100))" ]
false
0.040798
0.040372
1.010539
[ "s176632245", "s452565771" ]
u263830634
p03426
python
s997432884
s239511813
996
459
17,800
26,760
Accepted
Accepted
53.92
H, W, D = list(map(int, input().split())) #盤面を取得 lst = [0] * (H * W + 1) for i in range(1, H + 1): tmp = list(map(int, input().split())) for j in range(1, W + 1): lst[tmp[j - 1]] = [i, j] #前処理 #xからyに移動するのにかかるコストを返す関数 def cost(x, y): return abs(lst[x][0] - lst[y][0]) + abs(lst[x][1] - ...
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 9) MOD = 10 ** 9 + 7 from collections import defaultdict H, W, D = list(map(int, input().split())) A = [list(map(int, input().split())) for _ in range(H)] dic = defaultdict(list) for h in range(H): for w in range(W): dic[A[...
31
32
766
724
H, W, D = list(map(int, input().split())) # 盤面を取得 lst = [0] * (H * W + 1) for i in range(1, H + 1): tmp = list(map(int, input().split())) for j in range(1, W + 1): lst[tmp[j - 1]] = [i, j] # 前処理 # xからyに移動するのにかかるコストを返す関数 def cost(x, y): return abs(lst[x][0] - lst[y][0]) + abs(lst[x][1] - lst[y][1]) ...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**9) MOD = 10**9 + 7 from collections import defaultdict H, W, D = list(map(int, input().split())) A = [list(map(int, input().split())) for _ in range(H)] dic = defaultdict(list) for h in range(H): for w in range(W): dic[A[h][w]] = [h, w] def...
false
3.125
[ "+import sys", "+", "+input = sys.stdin.readline", "+sys.setrecursionlimit(10**9)", "+MOD = 10**9 + 7", "+from collections import defaultdict", "+", "-# 盤面を取得", "-lst = [0] * (H * W + 1)", "-for i in range(1, H + 1):", "- tmp = list(map(int, input().split()))", "- for j in range(1, W + 1...
false
0.073063
0.078992
0.924938
[ "s997432884", "s239511813" ]
u813384600
p00036
python
s166889890
s029535198
20
10
4,212
4,208
Accepted
Accepted
50
import re while True: try: s = ''.join([input() for s in range(8)]) print(' C GAE D F B'[len(re.findall('1.*1', s)[0])]) input() except EOFError: break
import sys;import re for s in sys.stdin.read().split('\n\n'):print(' C GAE D F B'[len(re.findall('1.*1', s.replace('\n',''))[0])])
8
2
219
144
import re while True: try: s = "".join([input() for s in range(8)]) print(" C GAE D F B"[len(re.findall("1.*1", s)[0])]) input() except EOFError: break
import sys import re for s in sys.stdin.read().split("\n\n"): print(" C GAE D F B"[len(re.findall("1.*1", s.replace("\n", ""))[0])])
false
75
[ "+import sys", "-while True:", "- try:", "- s = \"\".join([input() for s in range(8)])", "- print(\" C GAE D F B\"[len(re.findall(\"1.*1\", s)[0])])", "- input()", "- except EOFError:", "- break", "+for s in sys.stdin.read().split(\"\\n\\n\"):", "+ ...
false
0.064239
0.06452
0.995655
[ "s166889890", "s029535198" ]
u296518383
p02695
python
s472030372
s418604671
239
180
93,700
84,668
Accepted
Accepted
24.69
import sys input = sys.stdin.buffer.readline from heapq import heappush, heappop from bisect import bisect_left, bisect_right from collections import deque, defaultdict from itertools import combinations, permutations from itertools import accumulate from math import ceil, sqrt, pi MOD = 10 ** 9 + 7 INF = ...
import sys input = sys.stdin.buffer.readline from itertools import combinations_with_replacement N, M, Q = list(map(int, input().split())) ABCD = [list(map(int, input().split())) for _ in range(Q)] lst = list(combinations_with_replacement(list(range(1, M + 1)), N)) ans = 0 for l in lst: tmp = 0 ...
40
19
826
437
import sys input = sys.stdin.buffer.readline from heapq import heappush, heappop from bisect import bisect_left, bisect_right from collections import deque, defaultdict from itertools import combinations, permutations from itertools import accumulate from math import ceil, sqrt, pi MOD = 10**9 + 7 INF = 10**18 N, M, ...
import sys input = sys.stdin.buffer.readline from itertools import combinations_with_replacement N, M, Q = list(map(int, input().split())) ABCD = [list(map(int, input().split())) for _ in range(Q)] lst = list(combinations_with_replacement(list(range(1, M + 1)), N)) ans = 0 for l in lst: tmp = 0 for a, b, c, d...
false
52.5
[ "-from heapq import heappush, heappop", "-from bisect import bisect_left, bisect_right", "-from collections import deque, defaultdict", "-from itertools import combinations, permutations", "-from itertools import accumulate", "-from math import ceil, sqrt, pi", "+from itertools import combinations_with_...
false
0.117697
0.050593
2.326339
[ "s472030372", "s418604671" ]
u186838327
p02813
python
s906282245
s908791583
217
83
43,504
79,264
Accepted
Accepted
61.75
n = int(eval(input())) P = list(map(int, input().split())) Q = list(map(int, input().split())) import itertools X= [] a = 0 b = 0 for p in itertools.permutations(list(range(1, n+1))): for i in range(n): if p[i] < P[i]: a += 1 break elif p[i] > P[i]: ...
n = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) ##print(P) #print(Q) import itertools X = [] for p in itertools.permutations(list(range(1, n+1))): X.append(p) #print(X) for i in range(len(X)): if P == X[i]: a = i break for i in range...
27
19
550
384
n = int(eval(input())) P = list(map(int, input().split())) Q = list(map(int, input().split())) import itertools X = [] a = 0 b = 0 for p in itertools.permutations(list(range(1, n + 1))): for i in range(n): if p[i] < P[i]: a += 1 break elif p[i] > P[i]: break ...
n = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) ##print(P) # print(Q) import itertools X = [] for p in itertools.permutations(list(range(1, n + 1))): X.append(p) # print(X) for i in range(len(X)): if P == X[i]: a = i break for i in range(len(X)):...
false
29.62963
[ "-P = list(map(int, input().split()))", "-Q = list(map(int, input().split()))", "+P = tuple(map(int, input().split()))", "+Q = tuple(map(int, input().split()))", "+##print(P)", "+# print(Q)", "-a = 0", "-b = 0", "- for i in range(n):", "- if p[i] < P[i]:", "- a += 1", "- ...
false
0.040243
0.131989
0.304895
[ "s906282245", "s908791583" ]
u736443076
p02687
python
s290999021
s577453232
24
22
9,012
9,092
Accepted
Accepted
8.33
def solve(): S = eval(input()) if S == "ABC": print("ARC") else: print("ABC") if __name__ == '__main__': solve()
def solve(): S = eval(input()) if S == "ABC": print("ARC") exit() else: print("ABC") if __name__ == '__main__': solve()
10
11
150
166
def solve(): S = eval(input()) if S == "ABC": print("ARC") else: print("ABC") if __name__ == "__main__": solve()
def solve(): S = eval(input()) if S == "ABC": print("ARC") exit() else: print("ABC") if __name__ == "__main__": solve()
false
9.090909
[ "+ exit()" ]
false
0.038025
0.03918
0.970517
[ "s290999021", "s577453232" ]
u179169725
p02573
python
s915532606
s972987501
291
146
44,232
20,256
Accepted
Accepted
49.83
mycode = r''' # distutils: language=c++ # cython: language_level=3, boundscheck=False, wraparound=False # cython: cdivision=True # False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。 ctypedef long lon...
mycode = r''' # distutils: language=c++ # cython: language_level=3, boundscheck=False, wraparound=False # cython: cdivision=True # False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。 ctypedef long l...
96
89
2,631
2,210
mycode = r""" # distutils: language=c++ # cython: language_level=3, boundscheck=False, wraparound=False # cython: cdivision=True # False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。 ctypedef long long LL ...
mycode = r""" # distutils: language=c++ # cython: language_level=3, boundscheck=False, wraparound=False # cython: cdivision=True # False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。 ctypedef long long LL ...
false
7.291667
[ "-import numpy as np", "-from functools import partial", "-array=partial(np.array, dtype=np.int64)", "-zeros=partial(np.zeros, dtype=np.int64)", "-full=partial(np.full, dtype=np.int64)", "+from libcpp.vector cimport vector", "+ctypedef vector[LL] vec", "-cdef ints(): return np.fromstring(readline(), s...
false
0.075986
0.07145
1.063485
[ "s915532606", "s972987501" ]
u261103969
p03798
python
s532010839
s795655065
875
93
109,844
77,476
Accepted
Accepted
89.37
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): n = int(readline()) s = eval(input()) if s[1] == "o": first = ((True, True, True), (False, True, False), (True, False, False),...
import sys from enum import Enum readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): from itertools import product n = int(readline()) s = eval(input()) for a, b in product(("S", "W"), repeat=2): kinds = [""] * n ...
64
58
1,656
1,569
import sys readline = sys.stdin.readline MOD = 10**9 + 7 INF = float("INF") sys.setrecursionlimit(10**5) def main(): n = int(readline()) s = eval(input()) if s[1] == "o": first = ( (True, True, True), (False, True, False), (True, False, False), (Fal...
import sys from enum import Enum readline = sys.stdin.readline MOD = 10**9 + 7 INF = float("INF") sys.setrecursionlimit(10**5) def main(): from itertools import product n = int(readline()) s = eval(input()) for a, b in product(("S", "W"), repeat=2): kinds = [""] * n kinds[0] = a ...
false
9.375
[ "+from enum import Enum", "+ from itertools import product", "+", "- if s[1] == \"o\":", "- first = (", "- (True, True, True),", "- (False, True, False),", "- (True, False, False),", "- (False, False, True),", "- )", "- else:", ...
false
0.096962
0.044066
2.200386
[ "s532010839", "s795655065" ]
u506858457
p03111
python
s853148868
s942936210
429
71
3,828
3,064
Accepted
Accepted
83.45
import itertools n,*abc=list(map(int,input().split())) l=[int(eval(input())) for i in range(n)] inf=100000000000000 mi=inf for i in list(itertools.product([i for i in range(3)],repeat=n)):#(1)↓ sub=[[] for j in range(3)] for j in range(n): sub[i[j]].append(j) mi_sub=0 for j in range(3)...
N, A, B, C = list(map(int, input().split())) l = [int(eval(input())) for i in range(N)] INF = 10 ** 9 def dfs(cur, a, b, c): ''' 深さがNだったら使用MPを評価 N本の竹を使うときに必要な合成回数はN-1のため,最後に-1*10*3(?) 1本も竹を使用していなかったら棄却→MPを無限に使うこととしている ''' if cur == N: return abs(a - A) + abs(b - B) + abs(c - ...
27
26
879
736
import itertools n, *abc = list(map(int, input().split())) l = [int(eval(input())) for i in range(n)] inf = 100000000000000 mi = inf for i in list(itertools.product([i for i in range(3)], repeat=n)): # (1)↓ sub = [[] for j in range(3)] for j in range(n): sub[i[j]].append(j) mi_sub = 0 for j in...
N, A, B, C = list(map(int, input().split())) l = [int(eval(input())) for i in range(N)] INF = 10**9 def dfs(cur, a, b, c): """ 深さがNだったら使用MPを評価 N本の竹を使うときに必要な合成回数はN-1のため,最後に-1*10*3(?) 1本も竹を使用していなかったら棄却→MPを無限に使うこととしている """ if cur == N: return abs(a - A) + abs(b - B) + abs(c - C) - 30 if m...
false
3.703704
[ "-import itertools", "+N, A, B, C = list(map(int, input().split()))", "+l = [int(eval(input())) for i in range(N)]", "+INF = 10**9", "-n, *abc = list(map(int, input().split()))", "-l = [int(eval(input())) for i in range(n)]", "-inf = 100000000000000", "-mi = inf", "-for i in list(itertools.product([...
false
0.659085
0.058267
11.311545
[ "s853148868", "s942936210" ]
u672475305
p03575
python
s261079212
s861243843
37
21
3,316
3,064
Accepted
Accepted
43.24
from collections import deque n,m = list(map(int,input().split())) G = [[0]*n for _ in range(n)] E = [] for i in range(m): a,b = list(map(int,input().split())) a,b = a-1, b-1 G[a][b] = 1 G[b][a] = 1 E.append((a,b)) ans = 0 for e in E: del_a, del_b = e #対象の辺を消す G[d...
class UnionFind: #要素数nで初期化 #インスタンス変数の初期化 def __init__(self, n): #root : 木の要素数 #rnk : 木の高さ(rank) self.n = n self.root = [-1]*(n+1) self.rnk = [0]*(n+1) """ノードxのrootノードを見つける""" def Find_Root(self, x): if self.root[x] < 0: re...
37
65
744
1,632
from collections import deque n, m = list(map(int, input().split())) G = [[0] * n for _ in range(n)] E = [] for i in range(m): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 G[a][b] = 1 G[b][a] = 1 E.append((a, b)) ans = 0 for e in E: del_a, del_b = e # 対象の辺を消す G[del_a][del_...
class UnionFind: # 要素数nで初期化 # インスタンス変数の初期化 def __init__(self, n): # root : 木の要素数 # rnk : 木の高さ(rank) self.n = n self.root = [-1] * (n + 1) self.rnk = [0] * (n + 1) """ノードxのrootノードを見つける""" def Find_Root(self, x): if self.root[x] < 0: return...
false
43.076923
[ "-from collections import deque", "+class UnionFind:", "+ # 要素数nで初期化", "+ # インスタンス変数の初期化", "+ def __init__(self, n):", "+ # root : 木の要素数", "+ # rnk : 木の高さ(rank)", "+ self.n = n", "+ self.root = [-1] * (n + 1)", "+ self.rnk = [0] * (n + 1)", "+", "+ ...
false
0.059795
0.038064
1.570905
[ "s261079212", "s861243843" ]
u832399163
p03478
python
s384085486
s281835330
46
34
3,060
3,064
Accepted
Accepted
26.09
from sys import stdin (n, a, b) = stdin.readline().rstrip().split() n = int(n) a = int(a) b = int(b) total=0 POW_MAX=4 for i in range(1, n+1): sub_total=0 for j in range(0, len(str(i))): #sub_total = sub_total + math.floor(i / (10 ** j) ) #sub_total = sub_total + i // (10 ** j) ...
from sys import stdin (n, a, b) = stdin.readline().rstrip().split() n = int(n) a = int(a) b = int(b) total=0 POW_MAX=4 for i in range(1, n+1): sub_total=0 num = i for j in range(0, POW_MAX+1): mod = num % 10 sub_total = sub_total + mod sho = num // 10 nu...
21
26
508
457
from sys import stdin (n, a, b) = stdin.readline().rstrip().split() n = int(n) a = int(a) b = int(b) total = 0 POW_MAX = 4 for i in range(1, n + 1): sub_total = 0 for j in range(0, len(str(i))): # sub_total = sub_total + math.floor(i / (10 ** j) ) # sub_total = sub_total + i // (10 ** j) ...
from sys import stdin (n, a, b) = stdin.readline().rstrip().split() n = int(n) a = int(a) b = int(b) total = 0 POW_MAX = 4 for i in range(1, n + 1): sub_total = 0 num = i for j in range(0, POW_MAX + 1): mod = num % 10 sub_total = sub_total + mod sho = num // 10 num = sho ...
false
19.230769
[ "- for j in range(0, len(str(i))):", "- # sub_total = sub_total + math.floor(i / (10 ** j) )", "- # sub_total = sub_total + i // (10 ** j)", "- sub_total = sub_total + int(str(i)[j])", "+ num = i", "+ for j in range(0, POW_MAX + 1):", "+ mod = num % 10", "+ ...
false
0.038095
0.036491
1.043959
[ "s384085486", "s281835330" ]
u427344224
p02991
python
s015495558
s666455003
1,543
871
151,988
79,644
Accepted
Accepted
43.55
import heapq class Dijkstra: def __init__(self, rote_map, start_point, goal_point=None): self.rote_map = rote_map self.start_point = start_point self.goal_point = goal_point def execute(self): num_of_city = 3 * 10 ** 5 + 10 dist = [float("inf") for _ in ra...
N, M = list(map(int, input().split())) from collections import defaultdict, deque graph = defaultdict(list) for i in range(M): u, v = list(map(int, input().split())) u -= 1 v -= 1 graph[u].append(v + N) graph[u + N].append(v + 2 * N) graph[u + 2 * N].append(v) S, T = list(map(int, in...
71
30
1,995
649
import heapq class Dijkstra: def __init__(self, rote_map, start_point, goal_point=None): self.rote_map = rote_map self.start_point = start_point self.goal_point = goal_point def execute(self): num_of_city = 3 * 10**5 + 10 dist = [float("inf") for _ in range(num_of_city...
N, M = list(map(int, input().split())) from collections import defaultdict, deque graph = defaultdict(list) for i in range(M): u, v = list(map(int, input().split())) u -= 1 v -= 1 graph[u].append(v + N) graph[u + N].append(v + 2 * N) graph[u + 2 * N].append(v) S, T = list(map(int, input().split...
false
57.746479
[ "-import heapq", "+N, M = list(map(int, input().split()))", "+from collections import defaultdict, deque", "-", "-class Dijkstra:", "- def __init__(self, rote_map, start_point, goal_point=None):", "- self.rote_map = rote_map", "- self.start_point = start_point", "- self.goal_...
false
0.479398
0.035432
13.529982
[ "s015495558", "s666455003" ]
u947883560
p02598
python
s790012681
s242611674
464
203
94,164
104,352
Accepted
Accepted
56.25
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) import math def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): return [LIST() for _ in range(n)] def...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) from bisect import bisect_left from itertools import product import math def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LI(): return list(map(int, input()....
44
60
923
1,389
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) import math def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): return [LIST() ...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) from bisect import bisect_left from itertools import product import math def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LI(): return list(m...
false
26.666667
[ "+from bisect import bisect_left", "+from itertools import product", "-def LIST():", "+def LI():", "-def ZIP(n):", "- return [LIST() for _ in range(n)]", "+def LI_():", "+ return list([int(x) - 1 for x in input().split()])", "+", "+", "+def LF():", "+ return list(map(float, input().sp...
false
0.036388
0.041948
0.867454
[ "s790012681", "s242611674" ]
u567380442
p02383
python
s502279503
s514943974
40
30
6,772
6,724
Accepted
Accepted
25
def get_dice(pips): return [[0, pips[4], 0, 0], [pips[3], pips[0], pips[2], pips[5]], [0, pips[1], 0, 0]] def move_e(dice): dice[1] = dice[1][3:] + dice[1][:3] return dice def move_n(dice): return [[0, dice[1][1], 0, 0], [dice[1][...
mask = {'N':(1, 5, 2, 3, 0, 4), 'E':(3, 1, 0, 5, 4, 2), 'S':(4, 0, 2, 3, 5, 1), 'W':(2, 1, 5, 0, 4,3)} dice = input().split() for c in eval(input()): dice = [dice[i] for i in mask[c]] print((dice[0]))
31
8
848
206
def get_dice(pips): return [ [0, pips[4], 0, 0], [pips[3], pips[0], pips[2], pips[5]], [0, pips[1], 0, 0], ] def move_e(dice): dice[1] = dice[1][3:] + dice[1][:3] return dice def move_n(dice): return [ [0, dice[1][1], 0, 0], [dice[1][0], dice[2][1], dice[1...
mask = { "N": (1, 5, 2, 3, 0, 4), "E": (3, 1, 0, 5, 4, 2), "S": (4, 0, 2, 3, 5, 1), "W": (2, 1, 5, 0, 4, 3), } dice = input().split() for c in eval(input()): dice = [dice[i] for i in mask[c]] print((dice[0]))
false
74.193548
[ "-def get_dice(pips):", "- return [", "- [0, pips[4], 0, 0],", "- [pips[3], pips[0], pips[2], pips[5]],", "- [0, pips[1], 0, 0],", "- ]", "-", "-", "-def move_e(dice):", "- dice[1] = dice[1][3:] + dice[1][:3]", "- return dice", "-", "-", "-def move_n(dice):...
false
0.108928
0.086837
1.254394
[ "s502279503", "s514943974" ]
u481942026
p03163
python
s573707940
s699360429
589
511
120,304
119,280
Accepted
Accepted
13.24
def knapsack(sizes, vals, volume): n = len(sizes) dp = [[0] * (volume+1) for _ in range(n)] # j is 0...volume for i in range(n): for j in range(volume+1): dp[i][j] = max(dp[i][j], dp[i-1][j]) if j - sizes[i] >= 0: dp[i][j] = max(dp[i][j], dp[i-1][j-...
def knapsack(sizes, vals, volume): n = len(sizes) dp = [[0] * (volume+1) for _ in range(n)] # j is 0...volume for i in range(n): for j in range(volume+1): dp[i][j] = max(dp[i][j], dp[i-1][j]) if j - sizes[i] >= 0: dp[i][j] = max(dp[i][j], dp[i-1][j-...
23
23
690
691
def knapsack(sizes, vals, volume): n = len(sizes) dp = [[0] * (volume + 1) for _ in range(n)] # j is 0...volume for i in range(n): for j in range(volume + 1): dp[i][j] = max(dp[i][j], dp[i - 1][j]) if j - sizes[i] >= 0: dp[i][j] = max(dp[i][j], dp[i - 1][j - ...
def knapsack(sizes, vals, volume): n = len(sizes) dp = [[0] * (volume + 1) for _ in range(n)] # j is 0...volume for i in range(n): for j in range(volume + 1): dp[i][j] = max(dp[i][j], dp[i - 1][j]) if j - sizes[i] >= 0: dp[i][j] = max(dp[i][j], dp[i - 1][j - ...
false
0
[ "- dp[i][j] = max(dp[i][j], dp[i - 1][j])", "+ # dp[i][j] = max(dp[i][j], dp[i-1][j])" ]
false
0.040251
0.082947
0.485257
[ "s573707940", "s699360429" ]
u905203728
p02781
python
s357582742
s550914206
202
21
40,944
3,064
Accepted
Accepted
89.6
n=eval(input()) K=int(eval(input())) m=len(n) DP=[[[0]*(K+2) for _ in range(2)] for _ in range(m+1)] DP[0][0][0]=1 for i in range(1,m+1): for flag in range(2): num=9 if flag else int(n[i-1]) for j in range(K+1): for k in range(num+1): if k==0:DP[i][flag or k...
n=eval(input()) K=int(eval(input())) m=len(n) DP=[[[0]*(K+2) for _ in range(2)] for _ in range(m+1)] DP[0][0][0]=1 for i in range(1,m+1): for flag in range(2): num=9 if flag else int(n[i-1]) for j in range(K+1): for k in range(num+1): if k==0:DP[i][flag or k...
16
16
438
436
n = eval(input()) K = int(eval(input())) m = len(n) DP = [[[0] * (K + 2) for _ in range(2)] for _ in range(m + 1)] DP[0][0][0] = 1 for i in range(1, m + 1): for flag in range(2): num = 9 if flag else int(n[i - 1]) for j in range(K + 1): for k in range(num + 1): if k == 0:...
n = eval(input()) K = int(eval(input())) m = len(n) DP = [[[0] * (K + 2) for _ in range(2)] for _ in range(m + 1)] DP[0][0][0] = 1 for i in range(1, m + 1): for flag in range(2): num = 9 if flag else int(n[i - 1]) for j in range(K + 1): for k in range(num + 1): if k == 0:...
false
0
[ "- DP[i][flag or k < num][j + 1] += DP[i - 1][flag][j]", "-print((DP[-1][0][K] + DP[-1][1][K]))", "+ DP[i][flag or k < num][j] += DP[i - 1][flag][j - 1]", "+print((DP[m][0][K] + DP[m][1][K]))" ]
false
0.035027
0.034271
1.022049
[ "s357582742", "s550914206" ]
u347640436
p03504
python
s251354781
s018920583
1,380
570
29,428
36,564
Accepted
Accepted
58.7
N, C = list(map(int, input().split())) tt = [[0] * (10 ** 5 + 1) for _ in range(C)] for _ in range(N): s, t, c = list(map(int, input().split())) for i in range(s - 1, t): tt[c - 1][i] = 1 ct = [0] * (10 ** 5 + 1) for i in range(C): for j in range(10 ** 5 + 1): ct[j] += tt[i][j] ...
# imos 法 from operator import itemgetter N, C = list(map(int, input().split())) stc = [list(map(int, input().split())) for _ in range(N)] stc.sort(key=itemgetter(2, 0)) cs = [0] * (10 ** 5 + 1) pt, pc = -1, -1 for s, t, c in stc: if pt == s and pc == c: cs[s] += 1 else: cs[s - 1] ...
14
21
326
431
N, C = list(map(int, input().split())) tt = [[0] * (10**5 + 1) for _ in range(C)] for _ in range(N): s, t, c = list(map(int, input().split())) for i in range(s - 1, t): tt[c - 1][i] = 1 ct = [0] * (10**5 + 1) for i in range(C): for j in range(10**5 + 1): ct[j] += tt[i][j] print((max(ct)))
# imos 法 from operator import itemgetter N, C = list(map(int, input().split())) stc = [list(map(int, input().split())) for _ in range(N)] stc.sort(key=itemgetter(2, 0)) cs = [0] * (10**5 + 1) pt, pc = -1, -1 for s, t, c in stc: if pt == s and pc == c: cs[s] += 1 else: cs[s - 1] += 1 cs[t] -...
false
33.333333
[ "+# imos 法", "+from operator import itemgetter", "+", "-tt = [[0] * (10**5 + 1) for _ in range(C)]", "-for _ in range(N):", "- s, t, c = list(map(int, input().split()))", "- for i in range(s - 1, t):", "- tt[c - 1][i] = 1", "-ct = [0] * (10**5 + 1)", "-for i in range(C):", "- for...
false
0.230706
0.065523
3.521
[ "s251354781", "s018920583" ]
u463655976
p03068
python
s419582553
s541680311
19
17
3,188
2,940
Accepted
Accepted
10.53
import re N = int(eval(input())) S = eval(input()) K = int(eval(input())) w = S[K-1] print((re.sub("[^#]", "*", S.replace(w, "#")).replace("#", w)))
eval(input()) s = list(eval(input())) print(("".join(("*" if x != y else x for x in s[int(eval(input()))-1] for y in s ))))
7
3
136
106
import re N = int(eval(input())) S = eval(input()) K = int(eval(input())) w = S[K - 1] print((re.sub("[^#]", "*", S.replace(w, "#")).replace("#", w)))
eval(input()) s = list(eval(input())) print(("".join(("*" if x != y else x for x in s[int(eval(input())) - 1] for y in s))))
false
57.142857
[ "-import re", "-", "-N = int(eval(input()))", "-S = eval(input())", "-K = int(eval(input()))", "-w = S[K - 1]", "-print((re.sub(\"[^#]\", \"*\", S.replace(w, \"#\")).replace(\"#\", w)))", "+eval(input())", "+s = list(eval(input()))", "+print((\"\".join((\"*\" if x != y else x for x in s[int(eval(i...
false
0.060842
0.052873
1.150712
[ "s419582553", "s541680311" ]
u753803401
p03591
python
s221816201
s563578158
184
169
38,384
38,256
Accepted
Accepted
8.15
def slove(): import sys input = sys.stdin.readline s = str(input().rstrip('\n')) print(("Yes" if s[:4] == "YAKI" else "No")) if __name__ == '__main__': slove()
import sys def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 s = str(readline().rstrip().decode('utf-8')) print(("Yes" if s[:4] == "YAKI" else "No")) if __name__ == '__main__': solve()
9
12
188
236
def slove(): import sys input = sys.stdin.readline s = str(input().rstrip("\n")) print(("Yes" if s[:4] == "YAKI" else "No")) if __name__ == "__main__": slove()
import sys def solve(): readline = sys.stdin.buffer.readline mod = 10**9 + 7 s = str(readline().rstrip().decode("utf-8")) print(("Yes" if s[:4] == "YAKI" else "No")) if __name__ == "__main__": solve()
false
25
[ "-def slove():", "- import sys", "+import sys", "- input = sys.stdin.readline", "- s = str(input().rstrip(\"\\n\"))", "+", "+def solve():", "+ readline = sys.stdin.buffer.readline", "+ mod = 10**9 + 7", "+ s = str(readline().rstrip().decode(\"utf-8\"))", "- slove()", "+ ...
false
0.09224
0.10402
0.886755
[ "s221816201", "s563578158" ]
u427984570
p03487
python
s502445112
s287346291
108
90
17,780
23,284
Accepted
Accepted
16.67
n = int(eval(input())) l = list(map(int, input().split())) dic = {} count = 0 for i in range(n): dic.setdefault(l[i],0) dic[l[i]] += 1 for x,y in list(dic.items()): if x <= y: count += y - x else: count += y print(count)
n = int(eval(input())) l = list(map(int,input().split())) d = {} ans = 0 for i in l: if i not in d: d[i] = 1 else: d[i] += 1 for k,v in list(d.items()): if k != v: if k < v: ans += v - k else: ans += v print(ans)
15
16
241
243
n = int(eval(input())) l = list(map(int, input().split())) dic = {} count = 0 for i in range(n): dic.setdefault(l[i], 0) dic[l[i]] += 1 for x, y in list(dic.items()): if x <= y: count += y - x else: count += y print(count)
n = int(eval(input())) l = list(map(int, input().split())) d = {} ans = 0 for i in l: if i not in d: d[i] = 1 else: d[i] += 1 for k, v in list(d.items()): if k != v: if k < v: ans += v - k else: ans += v print(ans)
false
6.25
[ "-dic = {}", "-count = 0", "-for i in range(n):", "- dic.setdefault(l[i], 0)", "- dic[l[i]] += 1", "-for x, y in list(dic.items()):", "- if x <= y:", "- count += y - x", "+d = {}", "+ans = 0", "+for i in l:", "+ if i not in d:", "+ d[i] = 1", "- count += y"...
false
0.044812
0.208828
0.214587
[ "s502445112", "s287346291" ]
u802963389
p03612
python
s853727854
s000849918
242
129
65,004
19,364
Accepted
Accepted
46.69
from itertools import groupby def ceil(x, y): return (x -1) // y + 1 eval(input()) li = list(map(int, input().split())) lii = [] for itr, val in enumerate(li): if itr + 1 == val: lii.append(True) else: lii.append(False) gbli = [[key, len(list(group))] for key, group in groupby(lii)] ans = ...
from itertools import groupby n = eval(input()) li = list(map(int, input().split())) lii = [val == (itr + 1) for itr, val in enumerate(li)] gbli = [[key, len(list(group))] for key, group in groupby(lii)] ans = 0 for key, val in gbli: if key: ans += (val - 1) // 2 + 1 print(ans)
20
13
388
299
from itertools import groupby def ceil(x, y): return (x - 1) // y + 1 eval(input()) li = list(map(int, input().split())) lii = [] for itr, val in enumerate(li): if itr + 1 == val: lii.append(True) else: lii.append(False) gbli = [[key, len(list(group))] for key, group in groupby(lii)] ans...
from itertools import groupby n = eval(input()) li = list(map(int, input().split())) lii = [val == (itr + 1) for itr, val in enumerate(li)] gbli = [[key, len(list(group))] for key, group in groupby(lii)] ans = 0 for key, val in gbli: if key: ans += (val - 1) // 2 + 1 print(ans)
false
35
[ "-", "-def ceil(x, y):", "- return (x - 1) // y + 1", "-", "-", "-eval(input())", "+n = eval(input())", "-lii = []", "-for itr, val in enumerate(li):", "- if itr + 1 == val:", "- lii.append(True)", "- else:", "- lii.append(False)", "+lii = [val == (itr + 1) for itr, ...
false
0.045145
0.045366
0.995129
[ "s853727854", "s000849918" ]
u057079894
p02868
python
s940687289
s555660151
1,214
969
58,540
93,600
Accepted
Accepted
20.18
import heapq import numpy as np import sys n,m = list(map(int,input().split())) da = [[] for i in range(n)] for i in range(1,n): da[i].append([i-1,0]) for i in range(m): l,r,c = list(map(int,input().split())) da[l-1].append([r-1,c]) pq=[] ju = np.zeros(n,dtype=bool) ju[0] = True for i in da[0...
import heapq import sys class rode(): def __init__(self,x,y): self.x = x self.y = y def __lt__(self, other): return self.y < other.y def __gt__(self, other): return other > self def __le__(self, other): return not(other > self) def __ge__(self, o...
29
41
648
970
import heapq import numpy as np import sys n, m = list(map(int, input().split())) da = [[] for i in range(n)] for i in range(1, n): da[i].append([i - 1, 0]) for i in range(m): l, r, c = list(map(int, input().split())) da[l - 1].append([r - 1, c]) pq = [] ju = np.zeros(n, dtype=bool) ju[0] = True for i in d...
import heapq import sys class rode: def __init__(self, x, y): self.x = x self.y = y def __lt__(self, other): return self.y < other.y def __gt__(self, other): return other > self def __le__(self, other): return not (other > self) def __ge__(self, other): ...
false
29.268293
[ "-import numpy as np", "+", "+", "+class rode:", "+ def __init__(self, x, y):", "+ self.x = x", "+ self.y = y", "+", "+ def __lt__(self, other):", "+ return self.y < other.y", "+", "+ def __gt__(self, other):", "+ return other > self", "+", "+ def ...
false
0.297815
0.045414
6.557736
[ "s940687289", "s555660151" ]
u113971909
p02991
python
s485774996
s293501264
518
477
47,284
47,240
Accepted
Accepted
7.92
#!/usr/bin python3 # -*- coding: utf-8 -*- # 双方向グラフで幅優先探索 from collections import deque n, m = list(map(int, input().split())) g = [set([]) for _ in range(n)] #隣接リストの作成 for i in range(m): a, b = list(map(int, input().split())) a, b = a-1, b-1 g[a].add(b) s, t = list(map(int, input().split...
#!/usr/bin python3 # -*- coding: utf-8 -*- # 双方向グラフで幅優先探索 from collections import deque n, m = list(map(int, input().split())) g = [set([]) for _ in range(n)] #隣接リストの作成 for i in range(m): a, b = list(map(int, input().split())) a, b = a-1, b-1 g[a].add(b) s, t = list(map(int, input().split...
32
33
665
667
#!/usr/bin python3 # -*- coding: utf-8 -*- # 双方向グラフで幅優先探索 from collections import deque n, m = list(map(int, input().split())) g = [set([]) for _ in range(n)] # 隣接リストの作成 for i in range(m): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 g[a].add(b) s, t = list(map(int, input().split())) s, t = s...
#!/usr/bin python3 # -*- coding: utf-8 -*- # 双方向グラフで幅優先探索 from collections import deque n, m = list(map(int, input().split())) g = [set([]) for _ in range(n)] # 隣接リストの作成 for i in range(m): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 g[a].add(b) s, t = list(map(int, input().split())) s, t = s...
false
3.030303
[ "- cur, hp = q.popleft()", "- lvl = level[hp][cur]", "+ cur, lvl = q.popleft()", "+ nxtl = lvl + 1", "+ nxthp = nxtl % 3", "- if level[(hp + 1) % 3][i] == -1:", "+ if level[nxthp][i] == -1:", "- level[(hp + 1) % 3][i] = lvl + 1", "- q.append((i, (hp...
false
0.042386
0.041134
1.030428
[ "s485774996", "s293501264" ]
u442877951
p02719
python
s764383630
s655145337
19
17
3,060
2,940
Accepted
Accepted
10.53
N,K = list(map(int,input().split())) print((min(N%K,abs(N%K-K))))
N,K = list(map(int,input().split())) ans = min(N%K, abs(N%K-K)) print(ans)
2
3
58
70
N, K = list(map(int, input().split())) print((min(N % K, abs(N % K - K))))
N, K = list(map(int, input().split())) ans = min(N % K, abs(N % K - K)) print(ans)
false
33.333333
[ "-print((min(N % K, abs(N % K - K))))", "+ans = min(N % K, abs(N % K - K))", "+print(ans)" ]
false
0.048053
0.045681
1.051908
[ "s764383630", "s655145337" ]
u964904181
p02725
python
s345961710
s146442508
144
122
36,140
34,752
Accepted
Accepted
15.28
K, N = list(map(int, input().split())) A = list(map(int, input().split())) A2 = [K+a for a in A] A3 = A + A2 dist = [0] * N for i in range(N): j = i + N - 1 dist[i] = A3[j] - A[i] print((min(dist)))
K, N = list(map(int, input().split())) A = list(map(int, input().split())) A3 = A + [K+a for a in A] dist = [A3[i+N-1] - A[i] for i in range(N)] print((min(dist)))
13
8
215
166
K, N = list(map(int, input().split())) A = list(map(int, input().split())) A2 = [K + a for a in A] A3 = A + A2 dist = [0] * N for i in range(N): j = i + N - 1 dist[i] = A3[j] - A[i] print((min(dist)))
K, N = list(map(int, input().split())) A = list(map(int, input().split())) A3 = A + [K + a for a in A] dist = [A3[i + N - 1] - A[i] for i in range(N)] print((min(dist)))
false
38.461538
[ "-A2 = [K + a for a in A]", "-A3 = A + A2", "-dist = [0] * N", "-for i in range(N):", "- j = i + N - 1", "- dist[i] = A3[j] - A[i]", "+A3 = A + [K + a for a in A]", "+dist = [A3[i + N - 1] - A[i] for i in range(N)]" ]
false
0.041803
0.032706
1.278153
[ "s345961710", "s146442508" ]
u691018832
p03363
python
s274477181
s761281509
211
145
42,852
42,852
Accepted
Accepted
31.28
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from collections import defaultdict from itertools import accumulate n, *a = list(map(int, read().split())) dict = defaultdict(int) ans = 0 for aa in list(accu...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from collections import Counter from itertools import accumulate n, *a = list(map(int, read().split())) ans = 0 for v in list(Counter([0] + list(accumulate(a)))...
17
14
417
361
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) from collections import defaultdict from itertools import accumulate n, *a = list(map(int, read().split())) dict = defaultdict(int) ans = 0 for aa in list(accumulate([0] + a...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) from collections import Counter from itertools import accumulate n, *a = list(map(int, read().split())) ans = 0 for v in list(Counter([0] + list(accumulate(a))).values()): ...
false
17.647059
[ "-from collections import defaultdict", "+from collections import Counter", "-dict = defaultdict(int)", "-for aa in list(accumulate([0] + a)):", "- dict[aa] += 1", "-for v in list(dict.values()):", "+for v in list(Counter([0] + list(accumulate(a))).values()):" ]
false
0.035976
0.134958
0.266574
[ "s274477181", "s761281509" ]
u076917070
p02995
python
s278906677
s085651263
42
35
5,432
5,104
Accepted
Accepted
16.67
import fractions def lcm(x, y): return (x * y) // fractions.gcd(x, y) a,b,c,d = list(map(int, input().split())) x = (b//c - (a-1)//c) + (b//d - (a-1)//d -(b//lcm(c,d)) + (a-1)//lcm(c,d)) print((b-a+1-x))
import sys input = sys.stdin.readline A, B, C, D = list(map(int, input().split())) import fractions def lcm(x, y): return (x * y) // fractions.gcd(x, y) def f(d): return B//d - (A-1)//d def main(): ans = (B-A+1) - f(C) - f(D) + f(lcm(C, D)) print(ans) if __name__ == '__mai...
9
23
211
332
import fractions def lcm(x, y): return (x * y) // fractions.gcd(x, y) a, b, c, d = list(map(int, input().split())) x = (b // c - (a - 1) // c) + ( b // d - (a - 1) // d - (b // lcm(c, d)) + (a - 1) // lcm(c, d) ) print((b - a + 1 - x))
import sys input = sys.stdin.readline A, B, C, D = list(map(int, input().split())) import fractions def lcm(x, y): return (x * y) // fractions.gcd(x, y) def f(d): return B // d - (A - 1) // d def main(): ans = (B - A + 1) - f(C) - f(D) + f(lcm(C, D)) print(ans) if __name__ == "__main__": ma...
false
60.869565
[ "+import sys", "+", "+input = sys.stdin.readline", "+A, B, C, D = list(map(int, input().split()))", "-a, b, c, d = list(map(int, input().split()))", "-x = (b // c - (a - 1) // c) + (", "- b // d - (a - 1) // d - (b // lcm(c, d)) + (a - 1) // lcm(c, d)", "-)", "-print((b - a + 1 - x))", "+def f(...
false
0.060372
0.048682
1.240137
[ "s278906677", "s085651263" ]
u852690916
p02762
python
s503286171
s407025351
1,061
626
68,528
62,296
Accepted
Accepted
41
#!/usr/bin/env python3 import sys input = sys.stdin.readline N, M, K=list(map(int, input().split())) class UnionFindTree: def __init__(self, n): self.parent = [-1] * n def root(self, x): p, s = self.parent[x], list() while p >= 0: s.append(x) x, p...
import sys input = sys.stdin.readline def main(): N, M, K=list(map(int, input().split())) friend_or_block = [0] * N friends_chain = UnionFindTree(N) for _ in range(M): a, b = list(map(int, input().split())) a, b = a-1, b-1 friends_chain.unite(a, b) friend_or_b...
47
49
1,303
1,346
#!/usr/bin/env python3 import sys input = sys.stdin.readline N, M, K = list(map(int, input().split())) class UnionFindTree: def __init__(self, n): self.parent = [-1] * n def root(self, x): p, s = self.parent[x], list() while p >= 0: s.append(x) x, p = p, self....
import sys input = sys.stdin.readline def main(): N, M, K = list(map(int, input().split())) friend_or_block = [0] * N friends_chain = UnionFindTree(N) for _ in range(M): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 friends_chain.unite(a, b) friend_or_bloc...
false
4.081633
[ "-#!/usr/bin/env python3", "-N, M, K = list(map(int, input().split()))", "+", "+", "+def main():", "+ N, M, K = list(map(int, input().split()))", "+ friend_or_block = [0] * N", "+ friends_chain = UnionFindTree(N)", "+ for _ in range(M):", "+ a, b = list(map(int, input().split())...
false
0.058023
0.041027
1.414285
[ "s503286171", "s407025351" ]
u519939795
p02641
python
s376147005
s332133634
24
20
9,176
9,260
Accepted
Accepted
16.67
import sys x,n=list(map(int,input().split())) ans=10000 ansaa=10000 ans1=[] ans2=[] ans3=[] if n>0: l=list(map(int,input().split())) else: print(x) sys.exit() for i in range(len(l)): if abs(ans-l[i])<ans: ans1.append(l[i]) ans1.append(l[i]-1) ans1.append(l[i]+1) ...
import sys x,n=list(map(int,input().split())) ans=10000 ans1=[] ans2=[] if n>0: l=list(map(int,input().split())) else: print(x) sys.exit() for i in range(len(l)): if abs(ans-l[i])<ans: ans1.append(l[i]) ans1.append(l[i]-1) ans1.append(l[i]+1) ans1=sorted(ans1) for...
23
21
488
466
import sys x, n = list(map(int, input().split())) ans = 10000 ansaa = 10000 ans1 = [] ans2 = [] ans3 = [] if n > 0: l = list(map(int, input().split())) else: print(x) sys.exit() for i in range(len(l)): if abs(ans - l[i]) < ans: ans1.append(l[i]) ans1.append(l[i] - 1) ans1.append...
import sys x, n = list(map(int, input().split())) ans = 10000 ans1 = [] ans2 = [] if n > 0: l = list(map(int, input().split())) else: print(x) sys.exit() for i in range(len(l)): if abs(ans - l[i]) < ans: ans1.append(l[i]) ans1.append(l[i] - 1) ans1.append(l[i] + 1) ans1 = sorted...
false
8.695652
[ "-ansaa = 10000", "-ans3 = []" ]
false
0.043453
0.039749
1.09318
[ "s376147005", "s332133634" ]
u766684188
p02901
python
s976274194
s206223910
476
250
141,020
43,628
Accepted
Accepted
47.48
import sys input=sys.stdin.readline def main(): n,m=list(map(int,input().split())) Cost=[0]*m Key=[0]*m for i in range(m): a,b=list(map(int,input().split())) C=tuple(map(int,input().split())) Cost[i]=a for c in C: Key[i]+=1<<(c-1) DP=[[float(...
import sys input=sys.stdin.readline def main(): inf=float('inf') n,m=list(map(int,input().split())) Cost=[0]*m Key=[0]*m for i in range(m): a,b=list(map(int,input().split())) C=tuple(map(int,input().split())) Cost[i]=a for c in C: Key[i]+=1<<...
23
23
639
533
import sys input = sys.stdin.readline def main(): n, m = list(map(int, input().split())) Cost = [0] * m Key = [0] * m for i in range(m): a, b = list(map(int, input().split())) C = tuple(map(int, input().split())) Cost[i] = a for c in C: Key[i] += 1 << (c - ...
import sys input = sys.stdin.readline def main(): inf = float("inf") n, m = list(map(int, input().split())) Cost = [0] * m Key = [0] * m for i in range(m): a, b = list(map(int, input().split())) C = tuple(map(int, input().split())) Cost[i] = a for c in C: ...
false
0
[ "+ inf = float(\"inf\")", "- DP = [[float(\"inf\")] * (1 << n) for _ in range(m + 1)]", "- DP[0][0] = 0", "- for i, (c, k) in enumerate(zip(Cost, Key)):", "- for j in range(1 << n):", "- DP[i + 1][j] = min(DP[i][j], DP[i + 1][j])", "- DP[i + 1][j | k] = min(DP[i ...
false
0.087423
0.042929
2.036464
[ "s976274194", "s206223910" ]
u600402037
p03103
python
s047599025
s361488859
418
347
27,840
27,788
Accepted
Accepted
16.99
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M = lr() AB = [lr() for _ in range(N)] AB.sort() drink = 0 answer = 0 for i in range(N): cost = AB[i][0] limit = AB[i][1] if drink + limit < M: ...
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M = lr() AB = [lr() for _ in range(N)] AB.sort() answer = 0 for cost, num in AB: if M - num > 0: answer += cost * num M -= num else: ...
24
20
461
372
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M = lr() AB = [lr() for _ in range(N)] AB.sort() drink = 0 answer = 0 for i in range(N): cost = AB[i][0] limit = AB[i][1] if drink + limit < M: answer += cost * ...
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M = lr() AB = [lr() for _ in range(N)] AB.sort() answer = 0 for cost, num in AB: if M - num > 0: answer += cost * num M -= num else: answer += cost *...
false
16.666667
[ "-drink = 0", "-for i in range(N):", "- cost = AB[i][0]", "- limit = AB[i][1]", "- if drink + limit < M:", "- answer += cost * limit", "- drink += limit", "+for cost, num in AB:", "+ if M - num > 0:", "+ answer += cost * num", "+ M -= num", "- x =...
false
0.076379
0.03552
2.150333
[ "s047599025", "s361488859" ]
u694810977
p03145
python
s340060350
s693128839
19
17
2,940
2,940
Accepted
Accepted
10.53
AB,BC,CA = list(map(int,input().split())) print(((AB*BC) // 2))
a,b,c = list(map(int,input().split())) menseki = (a * b) // 2 print(menseki)
2
3
56
72
AB, BC, CA = list(map(int, input().split())) print(((AB * BC) // 2))
a, b, c = list(map(int, input().split())) menseki = (a * b) // 2 print(menseki)
false
33.333333
[ "-AB, BC, CA = list(map(int, input().split()))", "-print(((AB * BC) // 2))", "+a, b, c = list(map(int, input().split()))", "+menseki = (a * b) // 2", "+print(menseki)" ]
false
0.057963
0.053191
1.089725
[ "s340060350", "s693128839" ]
u977661421
p02779
python
s650408654
s646530884
190
91
25,168
25,168
Accepted
Accepted
52.11
# -*- coding: utf-8 -*- n = int(eval(input())) a = [int(i) for i in input().split()] """ if len(set(a)) == len(a): print("YES") else: print("NO") """ flag = True a.sort() for i in range(n - 1): if a[i] == a[i + 1]: flag = False if flag: print("YES") else: print("NO")
# -*- coding: utf-8 -*- n = int(eval(input())) a = [int(i) for i in input().split()] if len(set(a)) == n: print("YES") else: print("NO")
20
8
311
148
# -*- coding: utf-8 -*- n = int(eval(input())) a = [int(i) for i in input().split()] """ if len(set(a)) == len(a): print("YES") else: print("NO") """ flag = True a.sort() for i in range(n - 1): if a[i] == a[i + 1]: flag = False if flag: print("YES") else: print("NO")
# -*- coding: utf-8 -*- n = int(eval(input())) a = [int(i) for i in input().split()] if len(set(a)) == n: print("YES") else: print("NO")
false
60
[ "-\"\"\"", "-if len(set(a)) == len(a):", "+if len(set(a)) == n:", "-\"\"\"", "-flag = True", "-a.sort()", "-for i in range(n - 1):", "- if a[i] == a[i + 1]:", "- flag = False", "-if flag:", "- print(\"YES\")", "-else:", "- print(\"NO\")" ]
false
0.043422
0.045423
0.955947
[ "s650408654", "s646530884" ]
u762420987
p03814
python
s217972763
s987173276
26
18
6,180
3,516
Accepted
Accepted
30.77
s = list(eval(input())) a_index = s.index("A") z_index = s[::-1].index("Z") print((len(s) - (z_index) - a_index))
s = eval(input()) A = s.index("A") Z = s[::-1].index("Z") print((len(s) - Z - A))
4
4
109
77
s = list(eval(input())) a_index = s.index("A") z_index = s[::-1].index("Z") print((len(s) - (z_index) - a_index))
s = eval(input()) A = s.index("A") Z = s[::-1].index("Z") print((len(s) - Z - A))
false
0
[ "-s = list(eval(input()))", "-a_index = s.index(\"A\")", "-z_index = s[::-1].index(\"Z\")", "-print((len(s) - (z_index) - a_index))", "+s = eval(input())", "+A = s.index(\"A\")", "+Z = s[::-1].index(\"Z\")", "+print((len(s) - Z - A))" ]
false
0.040723
0.041479
0.981768
[ "s217972763", "s987173276" ]
u218834617
p03341
python
s883557914
s636558262
253
110
32,872
9,752
Accepted
Accepted
56.52
N=int(eval(input())) S=eval(input()) l,r=[0]*N,[0]*N for i in range(N-1): l[i+1]+=l[i]+(S[i]=='W') for i in range(N-1,0,-1): r[i-1]+=r[i]+(S[i]=='E') ans=r[i] for i in range(1,N): ans=min(ans,l[i]+r[i]) print(ans)
N=int(eval(input())) S=eval(input()) ans=cur=S.count('W') for c in reversed(S): if c=='W': cur-=1 else: cur+=1 ans=min(ans,cur) print(ans)
11
10
224
164
N = int(eval(input())) S = eval(input()) l, r = [0] * N, [0] * N for i in range(N - 1): l[i + 1] += l[i] + (S[i] == "W") for i in range(N - 1, 0, -1): r[i - 1] += r[i] + (S[i] == "E") ans = r[i] for i in range(1, N): ans = min(ans, l[i] + r[i]) print(ans)
N = int(eval(input())) S = eval(input()) ans = cur = S.count("W") for c in reversed(S): if c == "W": cur -= 1 else: cur += 1 ans = min(ans, cur) print(ans)
false
9.090909
[ "-l, r = [0] * N, [0] * N", "-for i in range(N - 1):", "- l[i + 1] += l[i] + (S[i] == \"W\")", "-for i in range(N - 1, 0, -1):", "- r[i - 1] += r[i] + (S[i] == \"E\")", "-ans = r[i]", "-for i in range(1, N):", "- ans = min(ans, l[i] + r[i])", "+ans = cur = S.count(\"W\")", "+for c in reve...
false
0.13766
0.037076
3.712938
[ "s883557914", "s636558262" ]