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
u836737505
p03476
python
s683239167
s895653116
1,115
727
4,980
29,992
Accepted
Accepted
34.8
def prime(x): for i in range(2,int(x**0.5)+1): if x%i==0: return False return True pri = [0]*(100000+1) for j in range(2,100000+1): if prime(j): pri[j] = 1 c = [0]*(100000+1) for i in range(2,100000+1): if pri[i]==1 and pri[(i+1)//2]==1: c[i] = c[i-1]+1 else: ...
def prime(x): for i in range(2,int(x**0.5)+1): if x%i==0: return False return True c = [0]*100002 for k in range(2,100001): if prime(k): c[k]=1 pri = [0]*100002 for i in range(2,100001): if c[i]==1 and c[(i+1)//2]==1: pri[i] = pri[i-1] +1 else: pri[i]...
22
22
442
452
def prime(x): for i in range(2, int(x**0.5) + 1): if x % i == 0: return False return True pri = [0] * (100000 + 1) for j in range(2, 100000 + 1): if prime(j): pri[j] = 1 c = [0] * (100000 + 1) for i in range(2, 100000 + 1): if pri[i] == 1 and pri[(i + 1) // 2] == 1: ...
def prime(x): for i in range(2, int(x**0.5) + 1): if x % i == 0: return False return True c = [0] * 100002 for k in range(2, 100001): if prime(k): c[k] = 1 pri = [0] * 100002 for i in range(2, 100001): if c[i] == 1 and c[(i + 1) // 2] == 1: pri[i] = pri[i - 1] + 1 ...
false
0
[ "-pri = [0] * (100000 + 1)", "-for j in range(2, 100000 + 1):", "- if prime(j):", "- pri[j] = 1", "-c = [0] * (100000 + 1)", "-for i in range(2, 100000 + 1):", "- if pri[i] == 1 and pri[(i + 1) // 2] == 1:", "- c[i] = c[i - 1] + 1", "+c = [0] * 100002", "+for k in range(2, 1000...
false
0.301257
0.452662
0.665523
[ "s683239167", "s895653116" ]
u768993705
p02881
python
s171936177
s110644393
385
142
3,060
3,060
Accepted
Accepted
63.12
import math N = int(eval(input())) for i in range(int(math.sqrt(N)), 0, -1): if N / i == int(N / i): print((int(N / i + i - 2))) exit()
import math N = int(eval(input())) for i in range(int(math.sqrt(N)), 0, -1): if N % i == 0: print((int(N / i + i - 2))) exit()
6
6
146
137
import math N = int(eval(input())) for i in range(int(math.sqrt(N)), 0, -1): if N / i == int(N / i): print((int(N / i + i - 2))) exit()
import math N = int(eval(input())) for i in range(int(math.sqrt(N)), 0, -1): if N % i == 0: print((int(N / i + i - 2))) exit()
false
0
[ "- if N / i == int(N / i):", "+ if N % i == 0:" ]
false
0.044646
0.039367
1.134098
[ "s171936177", "s110644393" ]
u991567869
p02802
python
s235094395
s643606444
348
271
13,172
3,828
Accepted
Accepted
22.13
n, m = list(map(int, input().split())) l = [[0]*2 for _ in range(n + 1)] ac = 0 wa = 0 for i in range(m): p, s = input().split() p = int(p) if l[p][0] == 0: #ACが0の場合 if s == "AC": l[p][0] = 1 else: l[p][1] += 1 for i in range(1, n + 1): ac += int(...
n, m = list(map(int, input().split())) l = [0]*(n + 1) ac = 0 wa = 0 for i in range(m): p, s = input().split() p = int(p) if l[p] == -1: continue if s == "AC": ac += 1 wa += l[p] l[p] = -1 else: l[p] += 1 print((ac, wa))
19
18
392
291
n, m = list(map(int, input().split())) l = [[0] * 2 for _ in range(n + 1)] ac = 0 wa = 0 for i in range(m): p, s = input().split() p = int(p) if l[p][0] == 0: # ACが0の場合 if s == "AC": l[p][0] = 1 else: l[p][1] += 1 for i in range(1, n + 1): ac += int(l[i][0]) ...
n, m = list(map(int, input().split())) l = [0] * (n + 1) ac = 0 wa = 0 for i in range(m): p, s = input().split() p = int(p) if l[p] == -1: continue if s == "AC": ac += 1 wa += l[p] l[p] = -1 else: l[p] += 1 print((ac, wa))
false
5.263158
[ "-l = [[0] * 2 for _ in range(n + 1)]", "+l = [0] * (n + 1)", "- if l[p][0] == 0: # ACが0の場合", "- if s == \"AC\":", "- l[p][0] = 1", "- else:", "- l[p][1] += 1", "-for i in range(1, n + 1):", "- ac += int(l[i][0])", "- if int(l[i][0]) != 0:", "- ...
false
0.088075
0.04289
2.053516
[ "s235094395", "s643606444" ]
u067237725
p02586
python
s741523550
s515005405
1,414
1,203
469,260
463,456
Accepted
Accepted
14.92
import sys import numpy as np from numba import njit, void, i8 input = sys.stdin.buffer.readline def main(): R, C, K = list(map(int, input().split())) L_INF = int(1e17) dp = np.full((R+1, C+1, 4), -L_INF, dtype=np.int64) cell = np.full((R+1, C+1), 0, dtype=np.int64) for i in range(K):...
import sys import numpy as np from numba import njit, void, i8 input = sys.stdin.buffer.readline def main(): R, C, K = list(map(int, input().split())) L_INF = int(1e17) dp = np.full((R+1, C+1, 4), -L_INF, dtype=np.int64) cell = np.full((R+1, C+1), 0, dtype=np.int64) for i in range(K):...
36
36
1,060
1,060
import sys import numpy as np from numba import njit, void, i8 input = sys.stdin.buffer.readline def main(): R, C, K = list(map(int, input().split())) L_INF = int(1e17) dp = np.full((R + 1, C + 1, 4), -L_INF, dtype=np.int64) cell = np.full((R + 1, C + 1), 0, dtype=np.int64) for i in range(K): ...
import sys import numpy as np from numba import njit, void, i8 input = sys.stdin.buffer.readline def main(): R, C, K = list(map(int, input().split())) L_INF = int(1e17) dp = np.full((R + 1, C + 1, 4), -L_INF, dtype=np.int64) cell = np.full((R + 1, C + 1), 0, dtype=np.int64) for i in range(K): ...
false
0
[ "- cell[x - 1][y - 1] = c", "+ cell[x - 1, y - 1] = c", "- print((dp[R][C][3]))", "+ print((dp[R, C, 3]))", "- dp[0][1][0] = dp[1][0][0] = 0", "+ dp[0, 1, 0] = dp[1, 0, 0] = 0", "- dp[i][j][k] = max(dp[i][j][k], dp[i][j][k - 1])", "- dp[i][j]...
false
0.744941
0.008712
85.505886
[ "s741523550", "s515005405" ]
u539367121
p02990
python
s667900461
s252388491
64
54
11,580
11,244
Accepted
Accepted
15.62
def nCk(_n,_k): return (fact[_n]//(fact[_k]*fact[_n-_k]))%m fact=[1]*2005 for i in range(1,2004): fact[i]=fact[i-1]*i n,k=list(map(int,input().split())) r=n-k m=10**9+7 for i in range(1,k+1): if r<i-1: print((0)); continue; if i==1: print((r+i)); continue; else: ans=nCk(r+1,i)*nCk(k-1,i-...
def nCk(_n,_k): return fact[_n]*pow(fact[_k],m-2,m)*pow(fact[_n-_k],m-2,m)%m fact=[1]*2005 for i in range(1,2004): fact[i]=fact[i-1]*i n,k=list(map(int,input().split())) m=10**9+7 for i in range(1,k+1): print((nCk(n-k+1,i)*nCk(k-1,i-1)%m if n-k>=i-1 else 0))
17
12
331
271
def nCk(_n, _k): return (fact[_n] // (fact[_k] * fact[_n - _k])) % m fact = [1] * 2005 for i in range(1, 2004): fact[i] = fact[i - 1] * i n, k = list(map(int, input().split())) r = n - k m = 10**9 + 7 for i in range(1, k + 1): if r < i - 1: print((0)) continue if i == 1: print(...
def nCk(_n, _k): return fact[_n] * pow(fact[_k], m - 2, m) * pow(fact[_n - _k], m - 2, m) % m fact = [1] * 2005 for i in range(1, 2004): fact[i] = fact[i - 1] * i n, k = list(map(int, input().split())) m = 10**9 + 7 for i in range(1, k + 1): print((nCk(n - k + 1, i) * nCk(k - 1, i - 1) % m if n - k >= i -...
false
29.411765
[ "- return (fact[_n] // (fact[_k] * fact[_n - _k])) % m", "+ return fact[_n] * pow(fact[_k], m - 2, m) * pow(fact[_n - _k], m - 2, m) % m", "-r = n - k", "- if r < i - 1:", "- print((0))", "- continue", "- if i == 1:", "- print((r + i))", "- continue", "- ...
false
0.041286
0.051825
0.796648
[ "s667900461", "s252388491" ]
u968404618
p02720
python
s557028213
s661447891
127
116
11,028
17,972
Accepted
Accepted
8.66
k = int(eval(input())) A = [i for i in range(1, 10)] while k: if k <= len(A): print((A[k-1])) exit() k -= len(A) old = [] old, A = A, old for x in old: for i in range(-1, 2): d = (x % 10) + i if d < 0 or d > 9: continue ...
k = int(eval(input())) RunRun = [i for i in range(1, 10)] while True: if k <= len(RunRun): print((RunRun[k-1])) exit() k -= len(RunRun) now = [] now, RunRun = RunRun, now for r in now: for i in range(-1, 2): tmp = r % 10 + i ...
20
21
366
441
k = int(eval(input())) A = [i for i in range(1, 10)] while k: if k <= len(A): print((A[k - 1])) exit() k -= len(A) old = [] old, A = A, old for x in old: for i in range(-1, 2): d = (x % 10) + i if d < 0 or d > 9: continue nx...
k = int(eval(input())) RunRun = [i for i in range(1, 10)] while True: if k <= len(RunRun): print((RunRun[k - 1])) exit() k -= len(RunRun) now = [] now, RunRun = RunRun, now for r in now: for i in range(-1, 2): tmp = r % 10 + i if tmp < 0 or 9 < tmp: ...
false
4.761905
[ "-A = [i for i in range(1, 10)]", "-while k:", "- if k <= len(A):", "- print((A[k - 1]))", "+RunRun = [i for i in range(1, 10)]", "+while True:", "+ if k <= len(RunRun):", "+ print((RunRun[k - 1]))", "- k -= len(A)", "- old = []", "- old, A = A, old", "- for x i...
false
0.046187
0.059179
0.780457
[ "s557028213", "s661447891" ]
u597455618
p02630
python
s606119310
s112989699
192
172
23,480
21,176
Accepted
Accepted
10.42
import sys import collections def main(): n = int(eval(input())) a = collections.Counter(list(map(int, input().split()))) s = [0 for i in range(10**5+1)] sa = 0 for i in a: s[i] += a[i] sa += i*a[i] q = int(eval(input())) for x in sys.stdin.readlines(): b,...
import sys def main(): n = int(eval(input())) a = list(map(int, input().split())) s = [0 for i in range(10**5+1)] sa = sum(a) for i in a: s[i] += 1 q = int(eval(input())) for x in sys.stdin.readlines(): b, c = list(map(int, x.split())) s[c] += s[b] ...
19
17
436
370
import sys import collections def main(): n = int(eval(input())) a = collections.Counter(list(map(int, input().split()))) s = [0 for i in range(10**5 + 1)] sa = 0 for i in a: s[i] += a[i] sa += i * a[i] q = int(eval(input())) for x in sys.stdin.readlines(): b, c = l...
import sys def main(): n = int(eval(input())) a = list(map(int, input().split())) s = [0 for i in range(10**5 + 1)] sa = sum(a) for i in a: s[i] += 1 q = int(eval(input())) for x in sys.stdin.readlines(): b, c = list(map(int, x.split())) s[c] += s[b] sa = sa...
false
10.526316
[ "-import collections", "- a = collections.Counter(list(map(int, input().split())))", "+ a = list(map(int, input().split()))", "- sa = 0", "+ sa = sum(a)", "- s[i] += a[i]", "- sa += i * a[i]", "+ s[i] += 1", "- sa = sa + c * s[b] - b * s[b]", "+ sa = ...
false
0.042946
0.043756
0.981482
[ "s606119310", "s112989699" ]
u018679195
p03059
python
s718448085
s499477610
31
18
3,316
3,188
Accepted
Accepted
41.94
line = eval(input()) A, B, T = [int(n) for n in line.split()] T+=0.5 i = 0 while A*(i+1) <= T: i+=1 print((i*B))
numerosStr = input().split(" ") numeros=[] contador=0 i=0 for j in numerosStr: numeros.append(int(j)) A = numeros[0] B = numeros[1] T = numeros[2]+0.5 print((int(((T)//A)*B)))
7
12
114
190
line = eval(input()) A, B, T = [int(n) for n in line.split()] T += 0.5 i = 0 while A * (i + 1) <= T: i += 1 print((i * B))
numerosStr = input().split(" ") numeros = [] contador = 0 i = 0 for j in numerosStr: numeros.append(int(j)) A = numeros[0] B = numeros[1] T = numeros[2] + 0.5 print((int(((T) // A) * B)))
false
41.666667
[ "-line = eval(input())", "-A, B, T = [int(n) for n in line.split()]", "-T += 0.5", "+numerosStr = input().split(\" \")", "+numeros = []", "+contador = 0", "-while A * (i + 1) <= T:", "- i += 1", "-print((i * B))", "+for j in numerosStr:", "+ numeros.append(int(j))", "+A = numeros[0]", ...
false
0.045911
0.086313
0.531919
[ "s718448085", "s499477610" ]
u113971909
p03062
python
s497418301
s295900134
101
55
14,412
14,224
Accepted
Accepted
45.54
N = int(eval(input())) A=list(map(int,input().split())) cnt = 0 B=[None]*N C=10**9+1 for i in range(len(A)): B[i]=abs(A[i]) C=min(C,B[i]) if A[i]<0: cnt+=1 ret = sum(B)-C+C*(-1)**cnt print(ret)
N = int(eval(input())) A=list(map(int,input().split())) cnt=sum([1 for i in A if i<0]) A=list(map(abs,A)) ret = sum(A)-min(A)*(1-(-1)**cnt) print(ret)
12
6
208
149
N = int(eval(input())) A = list(map(int, input().split())) cnt = 0 B = [None] * N C = 10**9 + 1 for i in range(len(A)): B[i] = abs(A[i]) C = min(C, B[i]) if A[i] < 0: cnt += 1 ret = sum(B) - C + C * (-1) ** cnt print(ret)
N = int(eval(input())) A = list(map(int, input().split())) cnt = sum([1 for i in A if i < 0]) A = list(map(abs, A)) ret = sum(A) - min(A) * (1 - (-1) ** cnt) print(ret)
false
50
[ "-cnt = 0", "-B = [None] * N", "-C = 10**9 + 1", "-for i in range(len(A)):", "- B[i] = abs(A[i])", "- C = min(C, B[i])", "- if A[i] < 0:", "- cnt += 1", "-ret = sum(B) - C + C * (-1) ** cnt", "+cnt = sum([1 for i in A if i < 0])", "+A = list(map(abs, A))", "+ret = sum(A) - min(...
false
0.035422
0.035437
0.999582
[ "s497418301", "s295900134" ]
u790710233
p02695
python
s697379692
s699089708
1,543
1,018
15,324
9,116
Accepted
Accepted
34.02
n, m, q = list(map(int, input().split())) abcd = [tuple(map(int, input().split()))for _ in range(q)] ls = [] def dfs(x, s): if len(s) == n: ls.append(s) return 0 else: for y in range(x, m): dfs(y, s+str(y)) dfs(0, "") ans = 0 for x in ls: x = tuple([i...
from itertools import combinations_with_replacement n, m, q = list(map(int, input().split())) abcd = [tuple(map(int, input().split()))for _ in range(q)] ans = 0 for x in combinations_with_replacement(list(range(1, m+1)), n): cnt = 0 for a, b, c, d in abcd: if x[b-1]-x[a-1] == c: cnt ...
27
13
519
365
n, m, q = list(map(int, input().split())) abcd = [tuple(map(int, input().split())) for _ in range(q)] ls = [] def dfs(x, s): if len(s) == n: ls.append(s) return 0 else: for y in range(x, m): dfs(y, s + str(y)) dfs(0, "") ans = 0 for x in ls: x = tuple([int(x) + 1 for ...
from itertools import combinations_with_replacement n, m, q = list(map(int, input().split())) abcd = [tuple(map(int, input().split())) for _ in range(q)] ans = 0 for x in combinations_with_replacement(list(range(1, m + 1)), n): cnt = 0 for a, b, c, d in abcd: if x[b - 1] - x[a - 1] == c: cn...
false
51.851852
[ "+from itertools import combinations_with_replacement", "+", "-ls = []", "-", "-", "-def dfs(x, s):", "- if len(s) == n:", "- ls.append(s)", "- return 0", "- else:", "- for y in range(x, m):", "- dfs(y, s + str(y))", "-", "-", "-dfs(0, \"\")", "-fo...
false
0.093963
0.210187
0.447043
[ "s697379692", "s699089708" ]
u545368057
p02713
python
s741744542
s269080930
524
100
67,752
70,772
Accepted
Accepted
80.92
import math 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+=math.gcd(i,math.gcd(j,k)) print(ans)
import math # K = int(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+=math.gcd(i,math.gcd(j,k)) # print(ans) ans = 0 K = int(eval(input())) dp = [[1] * 220 for i in range(220)] for i in range(1,K+1): for j in r...
9
22
193
512
import math 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 += math.gcd(i, math.gcd(j, k)) print(ans)
import math # K = int(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+=math.gcd(i,math.gcd(j,k)) # print(ans) ans = 0 K = int(eval(input())) dp = [[1] * 220 for i in range(220)] for i in range(1, K + 1): for j in range(1, K + 1): d...
false
59.090909
[ "+# K = int(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+=math.gcd(i,math.gcd(j,k))", "+# print(ans)", "+ans = 0", "-ans = 0", "+dp = [[1] * 220 for i in range(220)]", "+for i in range(1, K + 1):",...
false
0.047288
0.185419
0.255036
[ "s741744542", "s269080930" ]
u133936772
p02585
python
s503497318
s416285664
2,034
563
467,196
84,100
Accepted
Accepted
72.32
INF=10**9 f=lambda:[*list(map(int,input().split()))] n,k=f() p,c=f(),f() p=[*[x-1 for x in p]] tp=[[*list(range(n))] for _ in range(n+1)] tc=[[0]*n for _ in range(n+1)] lt=[0]*n lc=[0]*n for i in range(n): for j in range(n): t=p[tp[i][j]] tp[i+1][j]=t tc[i+1][j]=tc[i][j]+c[t] if t==j and...
f=lambda:[*list(map(int,input().split()))] n,k=f() p,c=f(),f() p=[*[x-1 for x in p]] a=-10**9 for i in range(n): x=i l=[] s=0 while 1: x=p[x] l+=[c[x]] s+=c[x] if x==i: break m=len(l) t=0 for j in range(m): if j+1>k: break t+=l[j] a=max(a,t+(k-j-1)//m*s*(s>0)...
28
21
611
328
INF = 10**9 f = lambda: [*list(map(int, input().split()))] n, k = f() p, c = f(), f() p = [*[x - 1 for x in p]] tp = [[*list(range(n))] for _ in range(n + 1)] tc = [[0] * n for _ in range(n + 1)] lt = [0] * n lc = [0] * n for i in range(n): for j in range(n): t = p[tp[i][j]] tp[i + 1][j] = t ...
f = lambda: [*list(map(int, input().split()))] n, k = f() p, c = f(), f() p = [*[x - 1 for x in p]] a = -(10**9) for i in range(n): x = i l = [] s = 0 while 1: x = p[x] l += [c[x]] s += c[x] if x == i: break m = len(l) t = 0 for j in range(m): ...
false
25
[ "-INF = 10**9", "-tp = [[*list(range(n))] for _ in range(n + 1)]", "-tc = [[0] * n for _ in range(n + 1)]", "-lt = [0] * n", "-lc = [0] * n", "+a = -(10**9)", "- for j in range(n):", "- t = p[tp[i][j]]", "- tp[i + 1][j] = t", "- tc[i + 1][j] = tc[i][j] + c[t]", "- ...
false
0.035388
0.042863
0.82562
[ "s503497318", "s416285664" ]
u645250356
p02947
python
s442071480
s027604901
1,949
473
105,940
19,984
Accepted
Accepted
75.73
from collections import Counter,defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue sys.setrecursionlimit(10**8) mod = 10**9+7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin.readline().split()) de...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) ...
33
22
852
603
from collections import Counter, defaultdict, deque import sys, heapq, bisect, math, itertools, string, queue sys.setrecursionlimit(10**8) mod = 10**9 + 7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin....
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.read...
false
33.333333
[ "-import sys, heapq, bisect, math, itertools, string, queue", "+from heapq import heappop, heappush, heapify", "+import sys, bisect, math, itertools, fractions, pprint", "+INF = float(\"inf\")", "-def inpl_str():", "- return list(sys.stdin.readline().split())", "-", "-", "-def conb(n, r):", "- ...
false
0.042366
0.033917
1.249123
[ "s442071480", "s027604901" ]
u254871849
p03762
python
s809203985
s962902154
262
235
20,672
20,672
Accepted
Accepted
10.31
# 予めsx, syを全て計算しておく # このとき漸化式を使えば毎回全ての話を求める必要がない mod = int(1e9+7) n, m = [int(num) for num in input().split()] x = [int(x) for x in input().split()] y = [int(y) for y in input().split()] sx = [0] * n sx[0] = x[0] for i in range(n-1): sx[i+1] = sx[i] + x[i+1] sxd = 0 for i in range(n-1): sx...
# 予めsx, syを全て計算しておく # このとき漸化式を使えば毎回全ての話を求める必要がない mod = int(1e9+7) n, m = [int(num) for num in input().split()] x = [int(x) for x in input().split()] y = [int(y) for y in input().split()] sx = [0] * n sx[0] = x[0] for i in range(n-1): sx[i+1] = sx[i] + x[i+1] sxd = 0 for i in range(n-1): sx...
29
29
616
618
# 予めsx, syを全て計算しておく # このとき漸化式を使えば毎回全ての話を求める必要がない mod = int(1e9 + 7) n, m = [int(num) for num in input().split()] x = [int(x) for x in input().split()] y = [int(y) for y in input().split()] sx = [0] * n sx[0] = x[0] for i in range(n - 1): sx[i + 1] = sx[i] + x[i + 1] sxd = 0 for i in range(n - 1): sxd += ((sx[n ...
# 予めsx, syを全て計算しておく # このとき漸化式を使えば毎回全ての話を求める必要がない mod = int(1e9 + 7) n, m = [int(num) for num in input().split()] x = [int(x) for x in input().split()] y = [int(y) for y in input().split()] sx = [0] * n sx[0] = x[0] for i in range(n - 1): sx[i + 1] = sx[i] + x[i + 1] sxd = 0 for i in range(n - 1): sxd += (sx[n -...
false
0
[ "- sxd += ((sx[n - 1] - sx[i]) - x[i] * ((n - 1) - (i + 1) + 1)) % mod", "+ sxd += (sx[n - 1] - sx[i]) - x[i] * ((n - 1) - (i + 1) + 1) #% mod", "- syd += ((sy[m - 1] - sy[k]) - y[k] * ((m - 1) - (k + 1) + 1)) % mod", "+ syd += (sy[m - 1] - sy[k]) - y[k] * ((m - 1) - (k + 1) + 1) #% mod" ]
false
0.05027
0.050269
1.000025
[ "s809203985", "s962902154" ]
u638456847
p02762
python
s329065830
s232065972
753
695
58,608
46,580
Accepted
Accepted
7.7
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines class UnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.size = [1] * (n+1) def find(self, x): if self.par[x] == x: return x else: ...
# AC: 753 msec(Python3) import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines class UnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.size = [1] * (n+1) def find(self, x): if self.par[x] == x: ...
59
60
1,434
1,462
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines class UnionFind: def __init__(self, n): self.par = [i for i in range(n + 1)] self.size = [1] * (n + 1) def find(self, x): if self.par[x] == x: return x else: ...
# AC: 753 msec(Python3) import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines class UnionFind: def __init__(self, n): self.par = [i for i in range(n + 1)] self.size = [1] * (n + 1) def find(self, x): if self.par[x] == x: return x ...
false
1.666667
[ "+# AC: 753 msec(Python3)", "- friend = [set() for _ in range(N + 1)]", "+ friend = [[] for _ in range(N + 1)]", "- friend[a].add(b)", "- friend[b].add(a)", "+ friend[a].append(b)", "+ friend[b].append(a)" ]
false
0.047792
0.048043
0.994775
[ "s329065830", "s232065972" ]
u901447859
p03433
python
s059590922
s297308079
19
17
2,940
2,940
Accepted
Accepted
10.53
print(('No' if max(int(eval(input())) % 500 - int(eval(input())), 0) else 'Yes'))
print(('Yes' if int(eval(input())) % 500 <= int(eval(input())) else 'No'))
1
1
67
60
print(("No" if max(int(eval(input())) % 500 - int(eval(input())), 0) else "Yes"))
print(("Yes" if int(eval(input())) % 500 <= int(eval(input())) else "No"))
false
0
[ "-print((\"No\" if max(int(eval(input())) % 500 - int(eval(input())), 0) else \"Yes\"))", "+print((\"Yes\" if int(eval(input())) % 500 <= int(eval(input())) else \"No\"))" ]
false
0.066553
0.053904
1.234657
[ "s059590922", "s297308079" ]
u254871849
p03739
python
s142377069
s476342926
106
80
14,468
14,084
Accepted
Accepted
24.53
n = int(eval(input())) a = [int(a) for a in input().split()] def f(times, prefix_sum): for i in range(1, n): if prefix_sum < 0: if prefix_sum + a[i] > 0: prefix_sum += a[i] else: times += 1 - (prefix_sum + a[i]) prefix_sum = ...
import sys n, *a = list(map(int, sys.stdin.read().split())) def main(): s1 = s2 = c1 = c2 = 0 for i in range(n): s1 += a[i] s2 += a[i] if i & 1: if s1 >= 0: c1 += abs(-1 - s1) s1 = -1 if s2 <= 0: c2...
37
31
771
624
n = int(eval(input())) a = [int(a) for a in input().split()] def f(times, prefix_sum): for i in range(1, n): if prefix_sum < 0: if prefix_sum + a[i] > 0: prefix_sum += a[i] else: times += 1 - (prefix_sum + a[i]) prefix_sum = 1 ...
import sys n, *a = list(map(int, sys.stdin.read().split())) def main(): s1 = s2 = c1 = c2 = 0 for i in range(n): s1 += a[i] s2 += a[i] if i & 1: if s1 >= 0: c1 += abs(-1 - s1) s1 = -1 if s2 <= 0: c2 += 1 - s2 ...
false
16.216216
[ "-n = int(eval(input()))", "-a = [int(a) for a in input().split()]", "+import sys", "+", "+n, *a = list(map(int, sys.stdin.read().split()))", "-def f(times, prefix_sum):", "- for i in range(1, n):", "- if prefix_sum < 0:", "- if prefix_sum + a[i] > 0:", "- prefi...
false
0.069835
0.070994
0.983667
[ "s142377069", "s476342926" ]
u621935300
p02973
python
s359605696
s430308043
236
94
35,356
40,220
Accepted
Accepted
60.17
import sys from collections import deque from bisect import bisect_left, bisect_right N=eval(input()) A=[ int(sys.stdin.readline().strip()) for _ in range(N) ] q=deque() for x in A: i=bisect_left(q,x) if i==0: q.appendleft(x) else: q[i-1]=x print(len(q))
import sys from collections import deque from bisect import bisect_left, bisect_right N=eval(input()) seq=[ int(sys.stdin.readline().strip())*-1 for _ in range(N) ] LIS = [seq[0]] for i in range(len(seq)): if i==0: continue if seq[i] >= LIS[-1]: LIS.append(seq[i]) else: LIS[bisect_right(LIS, seq[...
17
16
275
346
import sys from collections import deque from bisect import bisect_left, bisect_right N = eval(input()) A = [int(sys.stdin.readline().strip()) for _ in range(N)] q = deque() for x in A: i = bisect_left(q, x) if i == 0: q.appendleft(x) else: q[i - 1] = x print(len(q))
import sys from collections import deque from bisect import bisect_left, bisect_right N = eval(input()) seq = [int(sys.stdin.readline().strip()) * -1 for _ in range(N)] LIS = [seq[0]] for i in range(len(seq)): if i == 0: continue if seq[i] >= LIS[-1]: LIS.append(seq[i]) else: LIS[bi...
false
5.882353
[ "-A = [int(sys.stdin.readline().strip()) for _ in range(N)]", "-q = deque()", "-for x in A:", "- i = bisect_left(q, x)", "+seq = [int(sys.stdin.readline().strip()) * -1 for _ in range(N)]", "+LIS = [seq[0]]", "+for i in range(len(seq)):", "- q.appendleft(x)", "+ continue", "+ i...
false
0.064934
0.080899
0.802646
[ "s359605696", "s430308043" ]
u237362582
p03601
python
s135910932
s832771471
98
22
10,672
3,064
Accepted
Accepted
77.55
A, B, C, D, E, F = list(map(int, input().split(' '))) water = [] for i in range(31): if A*i >= F: break for j in range(16): if 100 * (A*i + B*j) < F: water.append(100*(A*i+B*j)) else: break water = sorted(list(set(water))) sugar = [] for i in range(m...
A, B, C, D, E, F = list(map(int, input().split(' '))) max_sugar = 0 max_water = 100*A max_conc = 0.0 A_limit = F // (100*A) for i in range(A_limit + 1): B_limit = (F-100*A*i) // (100*B) for j in range(B_limit + 1): if i == 0 and j == 0: continue sugar_limit = min(E * (A*i...
37
24
940
774
A, B, C, D, E, F = list(map(int, input().split(" "))) water = [] for i in range(31): if A * i >= F: break for j in range(16): if 100 * (A * i + B * j) < F: water.append(100 * (A * i + B * j)) else: break water = sorted(list(set(water))) sugar = [] for i in range(m...
A, B, C, D, E, F = list(map(int, input().split(" "))) max_sugar = 0 max_water = 100 * A max_conc = 0.0 A_limit = F // (100 * A) for i in range(A_limit + 1): B_limit = (F - 100 * A * i) // (100 * B) for j in range(B_limit + 1): if i == 0 and j == 0: continue sugar_limit = min(E * (A *...
false
35.135135
[ "-water = []", "-for i in range(31):", "- if A * i >= F:", "- break", "- for j in range(16):", "- if 100 * (A * i + B * j) < F:", "- water.append(100 * (A * i + B * j))", "- else:", "- break", "-water = sorted(list(set(water)))", "-sugar = []", ...
false
0.120795
0.046256
2.61145
[ "s135910932", "s832771471" ]
u562935282
p03167
python
s078553500
s301467557
715
291
43,700
54,000
Accepted
Accepted
59.3
MOD = 10 ** 9 + 7 H, W = list(map(int, input().split())) a = [eval(input()) for _ in range(H)] dp = [[0] * (W + 1) for _ in range(H + 1)] dp[1][1] = 1 for r in range(1, H + 1): for c in range(1, W + 1): if r == 1 and c == 1: continue if a[r - 1][c - 1] == '#': ...
mod = 10 ** 9 + 7 h, w = list(map(int, input().split())) a = tuple(eval(input()) for _ in range(h)) dp = [[0] * w for _ in range(h)] dp[0][0] = 1 # 配る for r in range(h): for c in range(w): if a[r][c] == '#': continue if r + 1 < h and a[r + 1][c] == '.': dp[r ...
17
18
410
481
MOD = 10**9 + 7 H, W = list(map(int, input().split())) a = [eval(input()) for _ in range(H)] dp = [[0] * (W + 1) for _ in range(H + 1)] dp[1][1] = 1 for r in range(1, H + 1): for c in range(1, W + 1): if r == 1 and c == 1: continue if a[r - 1][c - 1] == "#": continue ...
mod = 10**9 + 7 h, w = list(map(int, input().split())) a = tuple(eval(input()) for _ in range(h)) dp = [[0] * w for _ in range(h)] dp[0][0] = 1 # 配る for r in range(h): for c in range(w): if a[r][c] == "#": continue if r + 1 < h and a[r + 1][c] == ".": dp[r + 1][c] = (dp[r + 1...
false
5.555556
[ "-MOD = 10**9 + 7", "-H, W = list(map(int, input().split()))", "-a = [eval(input()) for _ in range(H)]", "-dp = [[0] * (W + 1) for _ in range(H + 1)]", "-dp[1][1] = 1", "-for r in range(1, H + 1):", "- for c in range(1, W + 1):", "- if r == 1 and c == 1:", "+mod = 10**9 + 7", "+h, w = li...
false
0.092598
0.05617
1.648548
[ "s078553500", "s301467557" ]
u763177133
p02880
python
s789711183
s550916215
32
28
9,172
9,104
Accepted
Accepted
12.5
num = int(eval(input())) n = 1 while n < 10: if num % n == 0 and num // n < 10: print('Yes') break n += 1 if n == 10: print('No')
c = int(eval(input())) n = 0 for i in range(1,10): if c /i < 10 and c %i ==0: n += 1 ans = 'Yes' if n >= 1 else 'No' print(ans)
12
9
159
148
num = int(eval(input())) n = 1 while n < 10: if num % n == 0 and num // n < 10: print("Yes") break n += 1 if n == 10: print("No")
c = int(eval(input())) n = 0 for i in range(1, 10): if c / i < 10 and c % i == 0: n += 1 ans = "Yes" if n >= 1 else "No" print(ans)
false
25
[ "-num = int(eval(input()))", "-n = 1", "-while n < 10:", "- if num % n == 0 and num // n < 10:", "- print(\"Yes\")", "- break", "- n += 1", "-if n == 10:", "- print(\"No\")", "+c = int(eval(input()))", "+n = 0", "+for i in range(1, 10):", "+ if c / i < 10 and c % i ...
false
0.037738
0.044281
0.852231
[ "s789711183", "s550916215" ]
u490127109
p02707
python
s718816869
s817981624
159
135
32,132
32,344
Accepted
Accepted
15.09
N = int(eval(input())) A = list(map(int,input().split())) l = [0]*N for i in range(N-1): l[A[i]-1] += 1 for i in range(N): print((l[i]))
N = int(input()) A = list(map(int,input().split())) l = [0]*N for i in A: l[i-1] += 1 print(*l,sep="\n")
7
6
138
111
N = int(eval(input())) A = list(map(int, input().split())) l = [0] * N for i in range(N - 1): l[A[i] - 1] += 1 for i in range(N): print((l[i]))
N = int(input()) A = list(map(int, input().split())) l = [0] * N for i in A: l[i - 1] += 1 print(*l, sep="\n")
false
14.285714
[ "-N = int(eval(input()))", "+N = int(input())", "-for i in range(N - 1):", "- l[A[i] - 1] += 1", "-for i in range(N):", "- print((l[i]))", "+for i in A:", "+ l[i - 1] += 1", "+print(*l, sep=\"\\n\")" ]
false
0.031637
0.031527
1.003472
[ "s718816869", "s817981624" ]
u150984829
p00470
python
s773980275
s170604338
60
50
7,832
7,828
Accepted
Accepted
16.67
for e in iter(input,'0 0'): w,h=list(map(int,e.split())) M=[[[1,0]*2 for _ in[0]*h]for _ in[0]*w] for i in range(1,w): for j in range(1,h): a,b,c,d=[*M[i-1][j][:2],*M[i][j-1][2:]] M[i][j]=[d,a+b,b,c+d] print(((sum(M[w-2][h-1][:2])+sum(M[w-1][h-2][2:]))%10**5))
def s(): for e in iter(input,'0 0'): w,h=list(map(int,e.split())) M=[[[1,0]*2 for _ in[0]*h]for _ in[0]*w] for i in range(1,w): for j in range(1,h): a,b=M[i-1][j][:2] c,d=M[i][j-1][2:] M[i][j]=[d,a+b,b,c+d] print(((sum(M[w-2][h-1][:2])+sum(M[w-1][h-2][2:]))%10**5)) if'__main__'==__name...
8
11
272
319
for e in iter(input, "0 0"): w, h = list(map(int, e.split())) M = [[[1, 0] * 2 for _ in [0] * h] for _ in [0] * w] for i in range(1, w): for j in range(1, h): a, b, c, d = [*M[i - 1][j][:2], *M[i][j - 1][2:]] M[i][j] = [d, a + b, b, c + d] print(((sum(M[w - 2][h - 1][:2])...
def s(): for e in iter(input, "0 0"): w, h = list(map(int, e.split())) M = [[[1, 0] * 2 for _ in [0] * h] for _ in [0] * w] for i in range(1, w): for j in range(1, h): a, b = M[i - 1][j][:2] c, d = M[i][j - 1][2:] M[i][j] = [d, a + ...
false
27.272727
[ "-for e in iter(input, \"0 0\"):", "- w, h = list(map(int, e.split()))", "- M = [[[1, 0] * 2 for _ in [0] * h] for _ in [0] * w]", "- for i in range(1, w):", "- for j in range(1, h):", "- a, b, c, d = [*M[i - 1][j][:2], *M[i][j - 1][2:]]", "- M[i][j] = [d, a + b, b,...
false
0.043796
0.043009
1.018299
[ "s773980275", "s170604338" ]
u906501980
p02899
python
s646269109
s519175353
276
173
33,712
24,944
Accepted
Accepted
37.32
n, *a = list(map(int, open(0).read().split())) ans = {} for i, num in enumerate(a): ans[str(num)] = i+1 ans = sorted(list(ans.items()), key=lambda x: int(x[0])) for key, val in ans: print(val)
def main(): n = int(eval(input())) a = list(map(int, input().split())) ans = [k[0] for k in sorted(list({i:ai for i, ai in enumerate(a, 1)}.items()), key=lambda x: x[1])] print((*ans)) if __name__ == "__main__": main()
7
8
194
232
n, *a = list(map(int, open(0).read().split())) ans = {} for i, num in enumerate(a): ans[str(num)] = i + 1 ans = sorted(list(ans.items()), key=lambda x: int(x[0])) for key, val in ans: print(val)
def main(): n = int(eval(input())) a = list(map(int, input().split())) ans = [ k[0] for k in sorted( list({i: ai for i, ai in enumerate(a, 1)}.items()), key=lambda x: x[1] ) ] print((*ans)) if __name__ == "__main__": main()
false
12.5
[ "-n, *a = list(map(int, open(0).read().split()))", "-ans = {}", "-for i, num in enumerate(a):", "- ans[str(num)] = i + 1", "-ans = sorted(list(ans.items()), key=lambda x: int(x[0]))", "-for key, val in ans:", "- print(val)", "+def main():", "+ n = int(eval(input()))", "+ a = list(map(i...
false
0.037397
0.043903
0.851815
[ "s646269109", "s519175353" ]
u832039789
p04045
python
s093464212
s247637518
71
51
2,940
2,940
Accepted
Accepted
28.17
n,k = list(map(int,input().split())) d = list(map(int,input().split())) while 1: for c in str(n): if int(c) in d: break else: print(n) exit() n += 1
n,k=list(map(int,input().split()));d=input().split() while 1: for c in str(n): if c in d:break else: print(n) exit() n += 1
10
8
200
160
n, k = list(map(int, input().split())) d = list(map(int, input().split())) while 1: for c in str(n): if int(c) in d: break else: print(n) exit() n += 1
n, k = list(map(int, input().split())) d = input().split() while 1: for c in str(n): if c in d: break else: print(n) exit() n += 1
false
20
[ "-d = list(map(int, input().split()))", "+d = input().split()", "- if int(c) in d:", "+ if c in d:" ]
false
0.040415
0.039637
1.01962
[ "s093464212", "s247637518" ]
u905203728
p02891
python
s452417404
s090282300
22
18
3,064
3,064
Accepted
Accepted
18.18
s=list(eval(input())) k=int(eval(input())) test=s*3 for i in range(len(s)*3-1): if test[i]==test[i+1]: test[i+1]="A" A=test[:len(s)].count("A") B=test[len(s):len(s)*2].count("A") C=test[len(s)*2:len(s)*3].count("A") if s.count(s[0])==len(s): print(((len(s)*k)//2)) else: if k==1:print(A...
s=list(eval(input())) n=len(s) k=int(eval(input())) S=s*3 for i in range(n*3-1): if S[i]==S[i+1]:S[i+1]="A" A=S[:n].count("A") B=S[n:n*2].count("A") C=S[n*2:n*3].count("A") if s.count(s[0])==n:print((n*k//2)) else: if k==1:print(A) elif k==2:print((A+B)) else:print((A+B*(k-2)+C))
16
16
362
299
s = list(eval(input())) k = int(eval(input())) test = s * 3 for i in range(len(s) * 3 - 1): if test[i] == test[i + 1]: test[i + 1] = "A" A = test[: len(s)].count("A") B = test[len(s) : len(s) * 2].count("A") C = test[len(s) * 2 : len(s) * 3].count("A") if s.count(s[0]) == len(s): print(((len(s) * k) // ...
s = list(eval(input())) n = len(s) k = int(eval(input())) S = s * 3 for i in range(n * 3 - 1): if S[i] == S[i + 1]: S[i + 1] = "A" A = S[:n].count("A") B = S[n : n * 2].count("A") C = S[n * 2 : n * 3].count("A") if s.count(s[0]) == n: print((n * k // 2)) else: if k == 1: print(A) elif k ...
false
0
[ "+n = len(s)", "-test = s * 3", "-for i in range(len(s) * 3 - 1):", "- if test[i] == test[i + 1]:", "- test[i + 1] = \"A\"", "-A = test[: len(s)].count(\"A\")", "-B = test[len(s) : len(s) * 2].count(\"A\")", "-C = test[len(s) * 2 : len(s) * 3].count(\"A\")", "-if s.count(s[0]) == len(s):",...
false
0.058638
0.116503
0.503319
[ "s452417404", "s090282300" ]
u498487134
p02786
python
s289078077
s145256969
169
65
38,256
61,924
Accepted
Accepted
61.54
H=int(eval(input())) def rec(a): if a==1: return 1 else: return rec(a//2)*2+1 print((rec(H)))
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 H=I() ans=0 def f(x): if x==0: return 0 return f(x//2)*2 +1...
9
21
123
352
H = int(eval(input())) def rec(a): if a == 1: return 1 else: return rec(a // 2) * 2 + 1 print((rec(H)))
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 H = I() ans = 0 def f(x): if x == 0: return 0 return f(...
false
57.142857
[ "-H = int(eval(input()))", "+import sys", "+", "+input = sys.stdin.readline", "-def rec(a):", "- if a == 1:", "- return 1", "- else:", "- return rec(a // 2) * 2 + 1", "+def I():", "+ return int(eval(input()))", "-print((rec(H)))", "+def MI():", "+ return list(map(...
false
0.037943
0.047498
0.798828
[ "s289078077", "s145256969" ]
u729133443
p03378
python
s953741588
s797905752
184
30
38,384
9,024
Accepted
Accepted
83.7
I=lambda:list(map(int,input().split()));n,m,x=I();s=sum(a<x for a in I());print((min(s,m-s)))
n,m,*a=list(map(int,open(0).read().split()));print((min(c:=sorted(a).index(a[0]),m-c)))
1
1
85
79
I = lambda: list(map(int, input().split())) n, m, x = I() s = sum(a < x for a in I()) print((min(s, m - s)))
n, m, *a = list(map(int, open(0).read().split())) print((min(c := sorted(a).index(a[0]), m - c)))
false
0
[ "-I = lambda: list(map(int, input().split()))", "-n, m, x = I()", "-s = sum(a < x for a in I())", "-print((min(s, m - s)))", "+n, m, *a = list(map(int, open(0).read().split()))", "+print((min(c := sorted(a).index(a[0]), m - c)))" ]
false
0.042394
0.037672
1.125348
[ "s953741588", "s797905752" ]
u994988729
p03356
python
s491477423
s455592981
925
464
14,452
12,384
Accepted
Accepted
49.84
class UF_tree: def __init__(self, n): self.root = [-1] * (n + 1) # -1ならそのノードが根,で絶対値が木の要素数 self.rank = [0] * (n + 1) def find(self, x): # xの根となる要素番号を返す if self.root[x] < 0: return x else: self.root[x] = self.find(self.root[x]) retur...
import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) class UF_tree: def __init__(self, n): self.root = [-1] * (n + 1) # -1ならそのノードが根,で絶対値が木の要素数 self.rank = [0] * (n + 1) def find(self, x): # xの根となる要素番号を返す if self.root[x] < 0: return x ...
49
48
1,308
1,282
class UF_tree: def __init__(self, n): self.root = [-1] * (n + 1) # -1ならそのノードが根,で絶対値が木の要素数 self.rank = [0] * (n + 1) def find(self, x): # xの根となる要素番号を返す if self.root[x] < 0: return x else: self.root[x] = self.find(self.root[x]) return self.roo...
import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) class UF_tree: def __init__(self, n): self.root = [-1] * (n + 1) # -1ならそのノードが根,で絶対値が木の要素数 self.rank = [0] * (n + 1) def find(self, x): # xの根となる要素番号を返す if self.root[x] < 0: return x else: ...
false
2.040816
[ "+import sys", "+", "+input = sys.stdin.buffer.readline", "+sys.setrecursionlimit(10**7)", "+", "+", "- uf = UF_tree(2 * N)", "- for i, p in enumerate(P, start=1):", "- uf.unite(i, p + N)", "+ uf = UF_tree(N + 10)", "- uf.unite(x + N, y + N)", "- ans = 0", "- for...
false
0.049971
0.050132
0.996791
[ "s491477423", "s455592981" ]
u442948527
p04043
python
s495644447
s545353237
26
23
9,024
8,856
Accepted
Accepted
11.54
a,b,c=sorted(map(int,input().split())) print((["NO","YES"][a==b==5 and c==7]))
a,b,c=sorted(input().split()) print((["NO","YES"][a==b=="5" and c=="7"]))
2
2
77
72
a, b, c = sorted(map(int, input().split())) print((["NO", "YES"][a == b == 5 and c == 7]))
a, b, c = sorted(input().split()) print((["NO", "YES"][a == b == "5" and c == "7"]))
false
0
[ "-a, b, c = sorted(map(int, input().split()))", "-print(([\"NO\", \"YES\"][a == b == 5 and c == 7]))", "+a, b, c = sorted(input().split())", "+print(([\"NO\", \"YES\"][a == b == \"5\" and c == \"7\"]))" ]
false
0.041855
0.038292
1.093055
[ "s495644447", "s545353237" ]
u119148115
p02541
python
s029341052
s785060232
480
438
72,800
71,420
Accepted
Accepted
8.75
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし def ...
import sys from itertools import product def I(): return int(sys.stdin.readline().rstrip()) def ext_gcd(a, b): if b: d, y, x = ext_gcd(b, a % b) y -= (a // b) * x return d, x, y return a, 1, 0 # V = [(X_i, Y_i), ...]: X_i (mod Y_i) def remainder(V): x = 0; d = 1 ...
73
61
1,626
1,182
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり def LI2(): return list(map(int, sys.stdin.readline().r...
import sys from itertools import product def I(): return int(sys.stdin.readline().rstrip()) def ext_gcd(a, b): if b: d, y, x = ext_gcd(b, a % b) y -= (a // b) * x return d, x, y return a, 1, 0 # V = [(X_i, Y_i), ...]: X_i (mod Y_i) def remainder(V): x = 0 d = 1 for ...
false
16.438356
[ "-", "-sys.setrecursionlimit(10**7)", "+from itertools import product", "-def MI():", "- return list(map(int, sys.stdin.readline().rstrip().split()))", "-", "-", "-def LI():", "- return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり", "-", "-", "-def LI2():", "- retur...
false
0.080107
0.08396
0.954109
[ "s029341052", "s785060232" ]
u952900471
p03475
python
s936804503
s867622257
182
168
3,188
3,188
Accepted
Accepted
7.69
n = int(eval(input())) _list = [] for _ in range(n - 1): a, b, c = list(map(int, input().split())) _list.append([a, b, c]) for i in range(n - 1): num = i time = 0 while num < n - 1: c, s, f = _list[num] if num == i: time += s + c num += 1...
n = int(eval(input())) _list = [] for _ in range(n - 1): a, b, c = list(map(int, input().split())) _list.append([a, b, c]) for i in range(n - 1): num = i time = 0 while num < n - 1: c, s, f = _list[num] if num == i: time += s + c num += 1...
39
44
649
706
n = int(eval(input())) _list = [] for _ in range(n - 1): a, b, c = list(map(int, input().split())) _list.append([a, b, c]) for i in range(n - 1): num = i time = 0 while num < n - 1: c, s, f = _list[num] if num == i: time += s + c num += 1 continue ...
n = int(eval(input())) _list = [] for _ in range(n - 1): a, b, c = list(map(int, input().split())) _list.append([a, b, c]) for i in range(n - 1): num = i time = 0 while num < n - 1: c, s, f = _list[num] if num == i: time += s + c num += 1 continue ...
false
11.363636
[ "- while True:", "- wait = s - time", "- if wait >= 0:", "- time += wait + c", "- break", "- test = (wait * -1) // f", "- s += int(f * test)", "- if s - time < 0:", "- s += f", "+ wait...
false
0.095499
0.03704
2.578253
[ "s936804503", "s867622257" ]
u392319141
p02998
python
s997784667
s196553742
1,312
982
101,572
48,096
Accepted
Accepted
25.15
class UnionFind : def __init__(self, size) : self.parent = list(range(size)) self.height = [0] * size self.size = [1] * size self.component = size def root(self, index) : if self.parent[index] == index : # 根の場合 return index rootIndex = self...
class UnionFind: def __init__(self, size): self.parent = list(range(size)) self.height = [0] * size self.size = [1] * size self.componentCount = size def root(self, index): if self.parent[index] == index: # 根の場合 return index rootIndex = sel...
81
74
2,038
2,088
class UnionFind: def __init__(self, size): self.parent = list(range(size)) self.height = [0] * size self.size = [1] * size self.component = size def root(self, index): if self.parent[index] == index: # 根の場合 return index rootIndex = self.root(self.par...
class UnionFind: def __init__(self, size): self.parent = list(range(size)) self.height = [0] * size self.size = [1] * size self.componentCount = size def root(self, index): if self.parent[index] == index: # 根の場合 return index rootIndex = self.root(sel...
false
8.641975
[ "- self.component = size", "+ self.componentCount = size", "- self.component -= 1 # 連結成分を減らす", "+ self.componentCount -= 1 # 連結成分を減らす", "- def getComponent(self):", "- return self.component", "+from collections import defaultdict", "-R = 10**5 + 10", "-IXY = [...
false
0.32607
0.091497
3.563736
[ "s997784667", "s196553742" ]
u113971909
p02773
python
s304134926
s608870423
843
521
43,504
34,140
Accepted
Accepted
38.2
N=int(eval(input())) A=[eval(input()) for i in range(N)] from collections import Counter A=Counter(A) ret = [] a=((A.most_common(1))[0])[1] for i in A.most_common(): if i[1]==a: ret.append(i[0]) else: break ret.sort() for i in ret: print(i)
#!/usr/bin python3 # -*- coding: utf-8 -*- import sys #input = sys.stdin.readline def main(): N = int(eval(input())) mp = {} mx = 0 for i in range(N): s = eval(input()) if s in mp: mp[s] += 1 mx = max(mx, mp[s]) else: mp[s] = ...
14
26
256
485
N = int(eval(input())) A = [eval(input()) for i in range(N)] from collections import Counter A = Counter(A) ret = [] a = ((A.most_common(1))[0])[1] for i in A.most_common(): if i[1] == a: ret.append(i[0]) else: break ret.sort() for i in ret: print(i)
#!/usr/bin python3 # -*- coding: utf-8 -*- import sys # input = sys.stdin.readline def main(): N = int(eval(input())) mp = {} mx = 0 for i in range(N): s = eval(input()) if s in mp: mp[s] += 1 mx = max(mx, mp[s]) else: mp[s] = 0 ret = [] ...
false
46.153846
[ "-N = int(eval(input()))", "-A = [eval(input()) for i in range(N)]", "-from collections import Counter", "+#!/usr/bin python3", "+# -*- coding: utf-8 -*-", "+import sys", "-A = Counter(A)", "-ret = []", "-a = ((A.most_common(1))[0])[1]", "-for i in A.most_common():", "- if i[1] == a:", "- ...
false
0.037837
0.04268
0.886519
[ "s304134926", "s608870423" ]
u028973125
p02971
python
s410065196
s734942504
322
184
18,280
19,028
Accepted
Accepted
42.86
import sys def solve(n, d): d_sorted = sorted(d, reverse=True) for i in range(n): print(d_sorted[0] if d[i] != d_sorted[0] else d_sorted[1]) if __name__ == '__main__': n = int(sys.stdin.readline().strip()) d = [] for i in range(n): d.append(int(sys.stdin.readline().s...
import sys input = sys.stdin.readline N = int(eval(input())) A = [] for _ in range(N): A.append(int(eval(input()))) for i, a in enumerate(sorted(A, reverse=True)): if i == 0: first = a elif i == 1: second = a else: break # print(first, second) for a in A: ...
15
23
344
381
import sys def solve(n, d): d_sorted = sorted(d, reverse=True) for i in range(n): print(d_sorted[0] if d[i] != d_sorted[0] else d_sorted[1]) if __name__ == "__main__": n = int(sys.stdin.readline().strip()) d = [] for i in range(n): d.append(int(sys.stdin.readline().strip())) ...
import sys input = sys.stdin.readline N = int(eval(input())) A = [] for _ in range(N): A.append(int(eval(input()))) for i, a in enumerate(sorted(A, reverse=True)): if i == 0: first = a elif i == 1: second = a else: break # print(first, second) for a in A: if a == first: ...
false
34.782609
[ "-", "-def solve(n, d):", "- d_sorted = sorted(d, reverse=True)", "- for i in range(n):", "- print(d_sorted[0] if d[i] != d_sorted[0] else d_sorted[1])", "-", "-", "-if __name__ == \"__main__\":", "- n = int(sys.stdin.readline().strip())", "- d = []", "- for i in range(n):"...
false
0.035976
0.036508
0.985421
[ "s410065196", "s734942504" ]
u724687935
p02832
python
s605119702
s537446231
249
117
73,600
17,976
Accepted
Accepted
53.01
N = int(eval(input())) A = list(map(int, input().split())) pos = 1 for a in A: if a == pos: pos += 1 if pos == 1: print((-1)) else: print((N - pos + 1))
N = int(eval(input())) A = list(map(int, input().split())) k = 1 cnt = 0 for a in A: if a == k: cnt += 1 k += 1 ans = -1 if k == 1 else N - cnt print(ans)
12
12
170
176
N = int(eval(input())) A = list(map(int, input().split())) pos = 1 for a in A: if a == pos: pos += 1 if pos == 1: print((-1)) else: print((N - pos + 1))
N = int(eval(input())) A = list(map(int, input().split())) k = 1 cnt = 0 for a in A: if a == k: cnt += 1 k += 1 ans = -1 if k == 1 else N - cnt print(ans)
false
0
[ "-pos = 1", "+k = 1", "+cnt = 0", "- if a == pos:", "- pos += 1", "-if pos == 1:", "- print((-1))", "-else:", "- print((N - pos + 1))", "+ if a == k:", "+ cnt += 1", "+ k += 1", "+ans = -1 if k == 1 else N - cnt", "+print(ans)" ]
false
0.047905
0.047434
1.009931
[ "s605119702", "s537446231" ]
u281303342
p03633
python
s589501346
s985156187
45
18
5,432
3,060
Accepted
Accepted
60
from fractions import gcd N = int(eval(input())) T = [] for i in range(N): T.append(int(eval(input()))) Ans = T[0] for i in range(1,N): Ans = Ans*T[i]//gcd(Ans,T[i]) print(Ans)
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) N = int(eval(input())) T = [int(eval(input())) for _ in range(N)] Ans = T[0] for i in range(1,N): Ans //= gcd(Ans,T[i]) Ans *= T[i] print(Ans)
13
15
188
235
from fractions import gcd N = int(eval(input())) T = [] for i in range(N): T.append(int(eval(input()))) Ans = T[0] for i in range(1, N): Ans = Ans * T[i] // gcd(Ans, T[i]) print(Ans)
def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) N = int(eval(input())) T = [int(eval(input())) for _ in range(N)] Ans = T[0] for i in range(1, N): Ans //= gcd(Ans, T[i]) Ans *= T[i] print(Ans)
false
13.333333
[ "-from fractions import gcd", "+def gcd(a, b):", "+ if b == 0:", "+ return a", "+ else:", "+ return gcd(b, a % b)", "+", "-T = []", "-for i in range(N):", "- T.append(int(eval(input())))", "+T = [int(eval(input())) for _ in range(N)]", "- Ans = Ans * T[i] // gcd(Ans, ...
false
0.041582
0.117872
0.352772
[ "s589501346", "s985156187" ]
u508486691
p02651
python
s673958333
s676097424
187
92
69,724
69,212
Accepted
Accepted
50.8
import sys import math from collections import defaultdict from bisect import bisect_left, bisect_right sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(eval(input())) def LI(): return list(map(int, input().split())) def LIR(row,col): ...
import sys import math from collections import defaultdict from bisect import bisect_left, bisect_right sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(eval(input())) def LI(): return list(map(int, input().split())) def LIR(row,col): ...
78
57
1,862
1,283
import sys import math from collections import defaultdict from bisect import bisect_left, bisect_right sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(eval(input())) def LI(): return list(map(int, input().split())) def LIR(row, col):...
import sys import math from collections import defaultdict from bisect import bisect_left, bisect_right sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(eval(input())) def LI(): return list(map(int, input().split())) def LIR(row, col):...
false
26.923077
[ "-# 掃き出し法", "-# ex: [[1,1,0],[1,0,1],[1,1,1]] -> [[1,1,0],[0,1,1],[0,0,1]]", "-# 行ごとの二進数値で入力する.上の例だと A = [6,5,7] -> g = [6,3,1]", "-def F2_row_reduction(A):", "- n = len(A)", "- g = A[:]", "- rank = 0", "- max_digit = len(format(max(A), \"b\"))", "- for col in range(max_digit)[::-1]:"...
false
0.106274
0.042494
2.500921
[ "s673958333", "s676097424" ]
u753803401
p03627
python
s472641139
s063704019
412
377
72,704
72,832
Accepted
Accepted
8.5
def main(): import sys input = sys.stdin.readline n = int(input().rstrip('\n')) a = list(map(int, input().rstrip('\n').split())) import collections a = collections.Counter(a).most_common() a = sorted(a, key=lambda x: x[0], reverse=True) t = -1 for k, v in a: if v >=...
def slove(): import sys import collections input = sys.stdin.readline n = int(input().rstrip('\n')) a = list(map(int, input().rstrip('\n').split())) a = sorted(collections.Counter(a).most_common(), key=lambda x: x[0], reverse=True) ans = [] for k, v in a: if v >= 2: ...
27
20
676
530
def main(): import sys input = sys.stdin.readline n = int(input().rstrip("\n")) a = list(map(int, input().rstrip("\n").split())) import collections a = collections.Counter(a).most_common() a = sorted(a, key=lambda x: x[0], reverse=True) t = -1 for k, v in a: if v >= 4: ...
def slove(): import sys import collections input = sys.stdin.readline n = int(input().rstrip("\n")) a = list(map(int, input().rstrip("\n").split())) a = sorted(collections.Counter(a).most_common(), key=lambda x: x[0], reverse=True) ans = [] for k, v in a: if v >= 2: ...
false
25.925926
[ "-def main():", "+def slove():", "+ import collections", "- import collections", "-", "- a = collections.Counter(a).most_common()", "- a = sorted(a, key=lambda x: x[0], reverse=True)", "- t = -1", "+ a = sorted(collections.Counter(a).most_common(), key=lambda x: x[0], reverse=True)...
false
0.038855
0.076431
0.508369
[ "s472641139", "s063704019" ]
u996749146
p03341
python
s205027341
s478340587
511
458
27,380
27,332
Accepted
Accepted
10.37
# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a # C - Attention # C_Attention.py N = int(eval(input())) S = eval(input()) e = [0 for i in range(N)] w = [0 for i in range(N)] # 累積和を求める for i in range(N): # そこからE側の人で、Wを向くべきなのにEを向いている人 if i > 0: w[i] += w[i-1] if i < N-1: ...
# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a # C - Attention # C_Attention_beta.py N = int(eval(input())) S = eval(input()) e = [0 for i in range(N)] w = [0 for i in range(N)] # 累積和を求める # そこからE側の人で、Wを向くべきなのにEを向いている人 for i in range(N): if i > 0: w[i] += w[i-1] if i < N-1: ...
32
34
634
646
# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a # C - Attention # C_Attention.py N = int(eval(input())) S = eval(input()) e = [0 for i in range(N)] w = [0 for i in range(N)] # 累積和を求める for i in range(N): # そこからE側の人で、Wを向くべきなのにEを向いている人 if i > 0: w[i] += w[i - 1] if i < N - 1: if S[i] =...
# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a # C - Attention # C_Attention_beta.py N = int(eval(input())) S = eval(input()) e = [0 for i in range(N)] w = [0 for i in range(N)] # 累積和を求める # そこからE側の人で、Wを向くべきなのにEを向いている人 for i in range(N): if i > 0: w[i] += w[i - 1] if i < N - 1: if S[i] ...
false
5.882353
[ "-# C_Attention.py", "+# C_Attention_beta.py", "+# そこからE側の人で、Wを向くべきなのにEを向いている人", "- # そこからE側の人で、Wを向くべきなのにEを向いている人", "- # そこからW側の人で、Eを向くべきなのにWを向いている人", "+# そこからW側の人で、Eを向くべきなのにWを向いている人", "+for j in range(N):", "+ i = N - 1 - j", "+ if i < N - 1:", "+ e[i] += e[i + 1]", "- ...
false
0.074627
0.070737
1.054998
[ "s205027341", "s478340587" ]
u208216648
p03163
python
s808361700
s023824103
1,424
770
235,208
171,784
Accepted
Accepted
45.93
n,w = list(map(int,input().split())) weight = [0 for i in range(n)] value = [0 for i in range(n)] for i in range(n): weight[i],value[i] = list(map(int,input().split())) #dp[i][j]: i番目の品物までの中から選び、重さがj以下になる時の、価値の総和の最大値 dp = [[None for i in range(w+1)] for j in range(n+1)] dp[1][weight[0]] = value[0] ...
n,w = list(map(int,input().split())) weight = [0 for i in range(n)] value = [0 for i in range(n)] for i in range(n): weight[i],value[i] = list(map(int,input().split())) #dp[i][j]: i番目の品物までの中から選び、重さがj以下になる時の、価値の総和の最大値 dp = [[0 for i in range(w+1)] for j in range(n+1)] for i in range(1,n+1): for...
26
17
933
508
n, w = list(map(int, input().split())) weight = [0 for i in range(n)] value = [0 for i in range(n)] for i in range(n): weight[i], value[i] = list(map(int, input().split())) # dp[i][j]: i番目の品物までの中から選び、重さがj以下になる時の、価値の総和の最大値 dp = [[None for i in range(w + 1)] for j in range(n + 1)] dp[1][weight[0]] = value[0] for i in...
n, w = list(map(int, input().split())) weight = [0 for i in range(n)] value = [0 for i in range(n)] for i in range(n): weight[i], value[i] = list(map(int, input().split())) # dp[i][j]: i番目の品物までの中から選び、重さがj以下になる時の、価値の総和の最大値 dp = [[0 for i in range(w + 1)] for j in range(n + 1)] for i in range(1, n + 1): for j in ...
false
34.615385
[ "-dp = [[None for i in range(w + 1)] for j in range(n + 1)]", "-dp[1][weight[0]] = value[0]", "-for i in range(1, n):", "+dp = [[0 for i in range(w + 1)] for j in range(n + 1)]", "+for i in range(1, n + 1):", "- if j - weight[i] >= 0:", "- if dp[i][j - weight[i]] != None and dp[i][j] !...
false
0.038334
0.036506
1.05008
[ "s808361700", "s023824103" ]
u670180528
p03346
python
s020137451
s482858093
207
176
18,992
32,604
Accepted
Accepted
14.98
N,*P=list(map(int,open(0))) ids=[0]*N for i in range(N): ids[P[i]-1]=i tmp=inc=1 for i in range(N-1): if ids[i]<ids[i+1]: tmp+=1 inc=max(tmp,inc) else: tmp=1 print((N-inc))
d={} for x in map(int,open(0)):d[x]=d.get(x-1,0)+1 print((len(d)-max(d.values())))
12
3
184
82
N, *P = list(map(int, open(0))) ids = [0] * N for i in range(N): ids[P[i] - 1] = i tmp = inc = 1 for i in range(N - 1): if ids[i] < ids[i + 1]: tmp += 1 inc = max(tmp, inc) else: tmp = 1 print((N - inc))
d = {} for x in map(int, open(0)): d[x] = d.get(x - 1, 0) + 1 print((len(d) - max(d.values())))
false
75
[ "-N, *P = list(map(int, open(0)))", "-ids = [0] * N", "-for i in range(N):", "- ids[P[i] - 1] = i", "-tmp = inc = 1", "-for i in range(N - 1):", "- if ids[i] < ids[i + 1]:", "- tmp += 1", "- inc = max(tmp, inc)", "- else:", "- tmp = 1", "-print((N - inc))", "+d ...
false
0.008961
0.042659
0.210064
[ "s020137451", "s482858093" ]
u906428167
p03256
python
s837029808
s058940831
1,269
687
94,492
90,572
Accepted
Accepted
45.86
n, m = list(map(int, input().split())) s = eval(input()) g = [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) g[a-1].append(b-1) g[b-1].append(a-1) count = [[0, 0] for _ in range(n)] bad = [] for i in range(n): for v in g[i]: if s[v] == 'A': ...
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline n, m = list(map(int, input().split())) s = eval(input()) g = [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) g[a-1].append(b-1) g[b-1].append(a-1) count = [[0, 0] for _ in range(n)] bad =...
44
48
905
979
n, m = list(map(int, input().split())) s = eval(input()) g = [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) g[a - 1].append(b - 1) g[b - 1].append(a - 1) count = [[0, 0] for _ in range(n)] bad = [] for i in range(n): for v in g[i]: if s[v] == "A": co...
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline n, m = list(map(int, input().split())) s = eval(input()) g = [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) g[a - 1].append(b - 1) g[b - 1].append(a - 1) count = [[0, 0] for _ in range(n)] bad = [] for i in...
false
8.333333
[ "+import sys", "+", "+sys.setrecursionlimit(10**7)", "+input = sys.stdin.readline" ]
false
0.034023
0.040016
0.850231
[ "s837029808", "s058940831" ]
u785066634
p02766
python
s821117143
s681976102
19
17
2,940
2,940
Accepted
Accepted
10.53
a,b=list(map(int,input().split())) cnt=0 #if a%b==0: # cnt=0 while a>=b: a=a//b cnt+=1 print((cnt+1))
n,m=list(map(int,input().split())) cnt=0 while n>0: n//=m cnt+=1 print(cnt)
12
7
162
101
a, b = list(map(int, input().split())) cnt = 0 # if a%b==0: # cnt=0 while a >= b: a = a // b cnt += 1 print((cnt + 1))
n, m = list(map(int, input().split())) cnt = 0 while n > 0: n //= m cnt += 1 print(cnt)
false
41.666667
[ "-a, b = list(map(int, input().split()))", "+n, m = list(map(int, input().split()))", "-# if a%b==0:", "-# cnt=0", "-while a >= b:", "- a = a // b", "+while n > 0:", "+ n //= m", "-print((cnt + 1))", "+print(cnt)" ]
false
0.065319
0.067128
0.973046
[ "s821117143", "s681976102" ]
u624475441
p03201
python
s806588011
s576501994
503
365
33,888
31,576
Accepted
Accepted
27.44
from collections import Counter N, *A = list(map(int, open(0).read().split())) A.sort(reverse=True) C = Counter(A) ans = 0 for a in A: if C[a] == 0: continue C[a] -= 1 partner = (2 ** (a.bit_length())) - a if C[partner] > 0: ans += 1 C[partner] -= 1 print(ans)
def solve(C): ans = 0 for a in sorted(C, reverse=True): if C[a] <= 0: continue ma = 1 << a.bit_length() b = ma - a if b in C and C[b] > 0: if a == b: pair = C[a] // 2 else: pair = min(C[a], C[b]) ...
14
26
307
632
from collections import Counter N, *A = list(map(int, open(0).read().split())) A.sort(reverse=True) C = Counter(A) ans = 0 for a in A: if C[a] == 0: continue C[a] -= 1 partner = (2 ** (a.bit_length())) - a if C[partner] > 0: ans += 1 C[partner] -= 1 print(ans)
def solve(C): ans = 0 for a in sorted(C, reverse=True): if C[a] <= 0: continue ma = 1 << a.bit_length() b = ma - a if b in C and C[b] > 0: if a == b: pair = C[a] // 2 else: pair = min(C[a], C[b]) ...
false
46.153846
[ "-from collections import Counter", "+def solve(C):", "+ ans = 0", "+ for a in sorted(C, reverse=True):", "+ if C[a] <= 0:", "+ continue", "+ ma = 1 << a.bit_length()", "+ b = ma - a", "+ if b in C and C[b] > 0:", "+ if a == b:", "+ ...
false
0.036672
0.040724
0.900503
[ "s806588011", "s576501994" ]
u637170240
p03331
python
s041551048
s888329099
342
175
3,060
3,064
Accepted
Accepted
48.83
N = int(eval(input())) factor_a = [] factor_b = [] ans = N for a in range(1, N): sum_a = sum([int(i) for i in str(a)]) sum_b = sum([int(i) for i in str(N-a)]) if sum_a + sum_b < ans: ans = sum_a + sum_b print(ans)
N = int(eval(input())) ans = N def simulate(m): for a in range(1, m): global ans sum_a = sum([int(i) for i in str(a)]) sum_b = sum([int(i) for i in str(N-a)]) if sum_a + sum_b < ans: ans = sum_a + sum_b if N % 2 == 0: simulate(N//2+1) else: sim...
10
19
236
341
N = int(eval(input())) factor_a = [] factor_b = [] ans = N for a in range(1, N): sum_a = sum([int(i) for i in str(a)]) sum_b = sum([int(i) for i in str(N - a)]) if sum_a + sum_b < ans: ans = sum_a + sum_b print(ans)
N = int(eval(input())) ans = N def simulate(m): for a in range(1, m): global ans sum_a = sum([int(i) for i in str(a)]) sum_b = sum([int(i) for i in str(N - a)]) if sum_a + sum_b < ans: ans = sum_a + sum_b if N % 2 == 0: simulate(N // 2 + 1) else: simulate(N //...
false
47.368421
[ "-factor_a = []", "-factor_b = []", "-for a in range(1, N):", "- sum_a = sum([int(i) for i in str(a)])", "- sum_b = sum([int(i) for i in str(N - a)])", "- if sum_a + sum_b < ans:", "- ans = sum_a + sum_b", "+", "+", "+def simulate(m):", "+ for a in range(1, m):", "+ g...
false
0.090743
0.23916
0.379426
[ "s041551048", "s888329099" ]
u637918426
p02885
python
s815669239
s842741450
19
17
2,940
2,940
Accepted
Accepted
10.53
A, B = list(map(int, input().split())) if A <= B * 2: print('0') else: print((A - 2 * B))
A, B = list(map(int, input().split())) print((max(0, A - 2 * B)))
7
3
98
60
A, B = list(map(int, input().split())) if A <= B * 2: print("0") else: print((A - 2 * B))
A, B = list(map(int, input().split())) print((max(0, A - 2 * B)))
false
57.142857
[ "-if A <= B * 2:", "- print(\"0\")", "-else:", "- print((A - 2 * B))", "+print((max(0, A - 2 * B)))" ]
false
0.144965
0.145393
0.997059
[ "s815669239", "s842741450" ]
u481187938
p02727
python
s610443936
s772755365
249
179
108,348
108,588
Accepted
Accepted
28.11
#!usr/bin/env pypy3 from collections import defaultdict, deque from heapq import heappush, heappop, heapify from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) d...
#!usr/bin/env pypy3 from collections import defaultdict, deque from heapq import heappush, heappop, heapify from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) d...
75
52
1,475
954
#!usr/bin/env pypy3 from collections import defaultdict, deque from heapq import heappush, heappop, heapify from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS()...
#!usr/bin/env pypy3 from collections import defaultdict, deque from heapq import heappush, heappop, heapify from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS()...
false
30.666667
[ "- p = LI()", "- q = LI()", "- r = LI()", "- p = sorted(p, reverse=True)[:X]", "- q = sorted(q, reverse=True)[:Y]", "- heapify(p), heapify(q)", "- for ri in r:", "- if len(p) < X:", "- heappush(p, ri)", "- elif len(q) < Y:", "- heappush(q,...
false
0.09212
0.11795
0.781008
[ "s610443936", "s772755365" ]
u591503175
p03681
python
s648239155
s419840303
703
403
5,176
4,748
Accepted
Accepted
42.67
def resolve(): ''' code here ''' import math N, M = [int(item) for item in input().split()] deff = N - M if deff == 0: temp = math.factorial(N) res = (temp**2 * 2) % (10**9+7) elif abs(deff) == 1: res = (math.factorial(N) * math.factorial(M)) ...
def resolve(): ''' code here ''' import math N, M = [int(item) for item in input().split()] deff = N - M if deff == -1: N, M = M, N if deff == 0: temp = math.factorial(N) res = (temp**2 * 2) % (10**9+7) elif abs(deff) == 1: res...
25
28
429
462
def resolve(): """ code here """ import math N, M = [int(item) for item in input().split()] deff = N - M if deff == 0: temp = math.factorial(N) res = (temp**2 * 2) % (10**9 + 7) elif abs(deff) == 1: res = (math.factorial(N) * math.factorial(M)) % (10**9 + 7) ...
def resolve(): """ code here """ import math N, M = [int(item) for item in input().split()] deff = N - M if deff == -1: N, M = M, N if deff == 0: temp = math.factorial(N) res = (temp**2 * 2) % (10**9 + 7) elif abs(deff) == 1: res = (math.factorial(N) ...
false
10.714286
[ "+ if deff == -1:", "+ N, M = M, N", "- res = (math.factorial(N) * math.factorial(M)) % (10**9 + 7)", "+ res = (math.factorial(N) ** 2 // N) % (10**9 + 7)" ]
false
0.047266
0.04507
1.048729
[ "s648239155", "s419840303" ]
u941753895
p03715
python
s958321069
s428242336
406
159
5,204
10,636
Accepted
Accepted
60.84
# https://atcoder.jp/contests/arc026/tasks/arc026_2 import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdi...
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] # def LF(): return [float(x) f...
44
53
962
1,127
# https://atcoder.jp/contests/arc026/tasks/arc026_2 import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI(): ...
import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI(): return [int(x) for x in sys.stdin.readline().spl...
false
16.981132
[ "-# https://atcoder.jp/contests/arc026/tasks/arc026_2", "+# def LF(): return [float(x) for x in sys.stdin.readline().split()]", "+", "+", "+def F():", "+ return float(sys.stdin.readline())", "- ans = inf", "- for i in range(h + 1):", "- a = i * w", "- b = (h - i + 1) // 2 * ...
false
0.039467
0.041103
0.960203
[ "s958321069", "s428242336" ]
u059210959
p03061
python
s064256542
s862509571
356
230
16,560
16,560
Accepted
Accepted
35.39
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち import math import fractions from functools import reduce N = int(eval(input())) A = [int(i) for i in input().split()] def gcd(nums): return reduce(fractions.gcd,nums) ans = 1 A.sort...
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち import math import fractions from functools import reduce N = int(eval(input())) A = [int(i) for i in input().split()] L = [0 for i in range(N)] R = [0 for i in range(N)] L[0] = A[0] R...
36
69
632
1,059
# encoding:utf-8 import copy import random import bisect # bisect_left これで二部探索の大小検索が行える import fractions # 最小公倍数などはこっち import math import fractions from functools import reduce N = int(eval(input())) A = [int(i) for i in input().split()] def gcd(nums): return reduce(fractions.gcd, nums) ans = 1 A.sort() gcd1...
# encoding:utf-8 import copy import random import bisect # bisect_left これで二部探索の大小検索が行える import fractions # 最小公倍数などはこっち import math import fractions from functools import reduce N = int(eval(input())) A = [int(i) for i in input().split()] L = [0 for i in range(N)] R = [0 for i in range(N)] L[0] = A[0] R[-1] = A[-1] f...
false
47.826087
[ "-", "-", "+L = [0 for i in range(N)]", "+R = [0 for i in range(N)]", "+L[0] = A[0]", "+R[-1] = A[-1]", "+for i in range(N - 1):", "+ L[i + 1] = fractions.gcd(L[i], A[i + 1])", "+for j in reversed(list(range(N - 1))):", "+ R[j] = fractions.gcd(A[j], R[j + 1])", "+L.append(0)", "+L.insert...
false
0.057703
0.056462
1.021979
[ "s064256542", "s862509571" ]
u853185302
p03102
python
s036808215
s851893194
22
19
3,060
3,060
Accepted
Accepted
13.64
N,M,C = list(map(int,input().split())) B_ = list(map(int,input().split())) A_ = [list(map(int,input().split())) for i in range(N)] ans = 0 for i in range(N): sum_n = 0 for j in range(M): sum_n += A_[i][j]*B_[j] if sum_n+C > 0: ans += 1 print(ans)
N,M,C = list(map(int,input().split())) B = list(map(int,input().split())) A = [list(map(int,input().split())) for _ in range(N)] count = 0 for n in range(N): cost = 0 for m in range(M): cost += A[n][m]*B[m] if cost + C > 0: count += 1 print(count)
11
11
264
265
N, M, C = list(map(int, input().split())) B_ = list(map(int, input().split())) A_ = [list(map(int, input().split())) for i in range(N)] ans = 0 for i in range(N): sum_n = 0 for j in range(M): sum_n += A_[i][j] * B_[j] if sum_n + C > 0: ans += 1 print(ans)
N, M, C = list(map(int, input().split())) B = list(map(int, input().split())) A = [list(map(int, input().split())) for _ in range(N)] count = 0 for n in range(N): cost = 0 for m in range(M): cost += A[n][m] * B[m] if cost + C > 0: count += 1 print(count)
false
0
[ "-B_ = list(map(int, input().split()))", "-A_ = [list(map(int, input().split())) for i in range(N)]", "-ans = 0", "-for i in range(N):", "- sum_n = 0", "- for j in range(M):", "- sum_n += A_[i][j] * B_[j]", "- if sum_n + C > 0:", "- ans += 1", "-print(ans)", "+B = list(map...
false
0.107457
0.040101
2.679656
[ "s036808215", "s851893194" ]
u018679195
p03331
python
s028989762
s922422316
318
174
6,424
3,060
Accepted
Accepted
45.28
n = int(eval(input())) if n%10 == 0 and n != 10: print((10)) else: a,b = 1,0 sA, sB= 0,0 soma = [] while a<=n: b=n-a for i in str(a): sA+=int(i) for j in str(b): sB+=int(j) soma.append(sA+sB) a=a+1 print((...
def main(): n = int(eval(input())) a = n - 1 b = 1 menor = soma_digitos(a) + soma_digitos(b) temp = 0 for i in range(n-2): a -= 1 b += 1 temp = soma_digitos(a) + soma_digitos(b) if menor > temp: menor = temp print(menor) def soma_dig...
20
21
322
421
n = int(eval(input())) if n % 10 == 0 and n != 10: print((10)) else: a, b = 1, 0 sA, sB = 0, 0 soma = [] while a <= n: b = n - a for i in str(a): sA += int(i) for j in str(b): sB += int(j) soma.append(sA + sB) a = a + 1 print((min(s...
def main(): n = int(eval(input())) a = n - 1 b = 1 menor = soma_digitos(a) + soma_digitos(b) temp = 0 for i in range(n - 2): a -= 1 b += 1 temp = soma_digitos(a) + soma_digitos(b) if menor > temp: menor = temp print(menor) def soma_digitos(n): ...
false
4.761905
[ "-n = int(eval(input()))", "-if n % 10 == 0 and n != 10:", "- print((10))", "-else:", "- a, b = 1, 0", "- sA, sB = 0, 0", "- soma = []", "- while a <= n:", "- b = n - a", "- for i in str(a):", "- sA += int(i)", "- for j in str(b):", "- ...
false
0.035939
0.054406
0.660565
[ "s028989762", "s922422316" ]
u547608423
p03240
python
s387753389
s772123339
567
35
3,188
3,064
Accepted
Accepted
93.83
from operator import itemgetter N=int(eval(input())) xyh=[list(map(int,input().split())) for _ in range(N)] count=0 xyh.sort(key=itemgetter(2),reverse=True) for h in xyh: if h[2]==0: count+=1 for px in range(101): for py in range(101): judge=0 base=0 for i in xyh:...
from operator import itemgetter N = int(eval(input())) XYZ = [list(map(int, input().split())) for _ in range(N)] XYZ.sort(key=itemgetter(2), reverse=True) for x in range(101): for y in range(0, 101): H = XYZ[0][2]+abs(XYZ[0][0]-x)+abs(XYZ[0][1]-y) judge = True for xyz in XYZ[1:]:...
29
23
745
595
from operator import itemgetter N = int(eval(input())) xyh = [list(map(int, input().split())) for _ in range(N)] count = 0 xyh.sort(key=itemgetter(2), reverse=True) for h in xyh: if h[2] == 0: count += 1 for px in range(101): for py in range(101): judge = 0 base = 0 for i in xyh...
from operator import itemgetter N = int(eval(input())) XYZ = [list(map(int, input().split())) for _ in range(N)] XYZ.sort(key=itemgetter(2), reverse=True) for x in range(101): for y in range(0, 101): H = XYZ[0][2] + abs(XYZ[0][0] - x) + abs(XYZ[0][1] - y) judge = True for xyz in XYZ[1:]: ...
false
20.689655
[ "-xyh = [list(map(int, input().split())) for _ in range(N)]", "-count = 0", "-xyh.sort(key=itemgetter(2), reverse=True)", "-for h in xyh:", "- if h[2] == 0:", "- count += 1", "-for px in range(101):", "- for py in range(101):", "- judge = 0", "- base = 0", "- fo...
false
0.130697
0.039788
3.284838
[ "s387753389", "s772123339" ]
u159994501
p03457
python
s202715731
s889796975
409
355
11,716
3,060
Accepted
Accepted
13.2
import sys N = int(eval(input())) t, x, y = [], [], [] p_x, p_y = 0, 0 for i in range(N): t_t, x_t, y_t = list(map(int, input().split())) t.append(t_t) x.append(x_t) y.append(y_t) for i in range(N): if int(t[i]) < int(x[i]) + int(y[i]) or t[i] % 2 != (x[i] + y[i]) % 2: print("No")...
N = int(eval(input())) t, x, y = 0, 0, 0 for i in range(N): t_1, x_1, y_1 = list(map(int, input().split())) distance = abs(x - x_1) + abs(y - y_1) if distance > t_1 - t or (t_1 - t - distance) % 2 != 0: print("No") exit() print("Yes")
15
9
345
259
import sys N = int(eval(input())) t, x, y = [], [], [] p_x, p_y = 0, 0 for i in range(N): t_t, x_t, y_t = list(map(int, input().split())) t.append(t_t) x.append(x_t) y.append(y_t) for i in range(N): if int(t[i]) < int(x[i]) + int(y[i]) or t[i] % 2 != (x[i] + y[i]) % 2: print("No") s...
N = int(eval(input())) t, x, y = 0, 0, 0 for i in range(N): t_1, x_1, y_1 = list(map(int, input().split())) distance = abs(x - x_1) + abs(y - y_1) if distance > t_1 - t or (t_1 - t - distance) % 2 != 0: print("No") exit() print("Yes")
false
40
[ "-import sys", "-", "-t, x, y = [], [], []", "-p_x, p_y = 0, 0", "+t, x, y = 0, 0, 0", "- t_t, x_t, y_t = list(map(int, input().split()))", "- t.append(t_t)", "- x.append(x_t)", "- y.append(y_t)", "-for i in range(N):", "- if int(t[i]) < int(x[i]) + int(y[i]) or t[i] % 2 != (x[i] ...
false
0.092331
0.150952
0.611658
[ "s202715731", "s889796975" ]
u400765446
p02385
python
s928595554
s575550806
70
20
8,192
5,612
Accepted
Accepted
71.43
class Dice: def __init__(self): # 初期値がない場合 # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定 self.t = 1 self.s = 2 self.e = 3 self.w = 4 self.n = 5 self.b = 6 self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3} def __init__(self, t, s, e, ...
f = list(map(int, input().split())) s = list(map(int, input().split())) yes = 0 for _ in range(4): s[0],s[2],s[5],s[3] = s[2],s[5],s[3],s[0] for _ in range(4): s[1],s[2],s[4],s[3] = s[2],s[4],s[3],s[1] if f == s: yes = 1 for _ in range(4): s[0],s[1],s[5],s[4] = s[1]...
64
22
1,741
510
class Dice: def __init__(self): # 初期値がない場合 # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定 self.t = 1 self.s = 2 self.e = 3 self.w = 4 self.n = 5 self.b = 6 self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3} def __init__(self, t, s, e, w, n, b): ...
f = list(map(int, input().split())) s = list(map(int, input().split())) yes = 0 for _ in range(4): s[0], s[2], s[5], s[3] = s[2], s[5], s[3], s[0] for _ in range(4): s[1], s[2], s[4], s[3] = s[2], s[4], s[3], s[1] if f == s: yes = 1 for _ in range(4): s[0], s[1], s[5], s[4] = s[1...
false
65.625
[ "-class Dice:", "- def __init__(self):", "- # 初期値がない場合", "- # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定", "- self.t = 1", "- self.s = 2", "- self.e = 3", "- self.w = 4", "- self.n = 5", "- self.b = 6", "- self.rotway = {\"S\": 0, \"N...
false
0.052589
0.07895
0.666112
[ "s928595554", "s575550806" ]
u223133214
p02969
python
s991622484
s473220465
180
17
38,384
2,940
Accepted
Accepted
90.56
r = int(eval(input())) print((int(3*r**2)))
r = int(eval(input())) print(((r ** 2) *3))
2
2
37
36
r = int(eval(input())) print((int(3 * r**2)))
r = int(eval(input())) print(((r**2) * 3))
false
0
[ "-print((int(3 * r**2)))", "+print(((r**2) * 3))" ]
false
0.036048
0.03574
1.008637
[ "s991622484", "s473220465" ]
u477977638
p03221
python
s471465538
s816775791
808
654
41,012
41,012
Accepted
Accepted
19.06
import collections import bisect n,m=list(map(int,input().split())) a=collections.defaultdict(list) p=[[int(j) for j in input().split()] for i in range(m)] for x,y in sorted(p): a[x]+=[y] for x,y in p: z=bisect.bisect(a[x],y) print(("%06d%06d"%(x,z)))
import collections import bisect n,m=list(map(int,input().split())) p=[[int(j) for j in input().split()] for i in range(m)] a=collections.defaultdict(list) for x,y in sorted(p): a[x]+=[y] for x,y in p: z=bisect.bisect(a[x],y) print(("%06d%06d"%(x,z)))
11
12
260
262
import collections import bisect n, m = list(map(int, input().split())) a = collections.defaultdict(list) p = [[int(j) for j in input().split()] for i in range(m)] for x, y in sorted(p): a[x] += [y] for x, y in p: z = bisect.bisect(a[x], y) print(("%06d%06d" % (x, z)))
import collections import bisect n, m = list(map(int, input().split())) p = [[int(j) for j in input().split()] for i in range(m)] a = collections.defaultdict(list) for x, y in sorted(p): a[x] += [y] for x, y in p: z = bisect.bisect(a[x], y) print(("%06d%06d" % (x, z)))
false
8.333333
[ "+p = [[int(j) for j in input().split()] for i in range(m)]", "-p = [[int(j) for j in input().split()] for i in range(m)]" ]
false
0.046597
0.091606
0.508664
[ "s471465538", "s816775791" ]
u130900604
p02607
python
s810331683
s459462723
109
70
61,208
61,948
Accepted
Accepted
35.78
n=int(eval(input())) a=list(map(int,input().split())) ans=0 for i in a[0::2]: ans+=(i&1) print(ans)
n=int(eval(input())) a=list(map(int,input().split())) b=[i&1 for i in a[::2]] print((sum(b)))
6
4
100
88
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in a[0::2]: ans += i & 1 print(ans)
n = int(eval(input())) a = list(map(int, input().split())) b = [i & 1 for i in a[::2]] print((sum(b)))
false
33.333333
[ "-ans = 0", "-for i in a[0::2]:", "- ans += i & 1", "-print(ans)", "+b = [i & 1 for i in a[::2]]", "+print((sum(b)))" ]
false
0.037003
0.036534
1.01284
[ "s810331683", "s459462723" ]
u489959379
p02973
python
s991476263
s174098780
556
322
8,188
13,708
Accepted
Accepted
42.09
# 狭義単調増加部分列 import bisect from collections import deque n = int(eval(input())) A = [int(eval(input())) for _ in range(n)] que = deque() for i in range(n): if len(que) == 0: deque.appendleft(que, A[i]) else: idx = bisect.bisect_left(que, A[i]) if idx == 0: dequ...
import sys from collections import deque from bisect import bisect_left sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(eval(input())) A = list(int(eval(input())) for _ in range(n)) LIS = deque() for i in range(n)...
20
29
410
616
# 狭義単調増加部分列 import bisect from collections import deque n = int(eval(input())) A = [int(eval(input())) for _ in range(n)] que = deque() for i in range(n): if len(que) == 0: deque.appendleft(que, A[i]) else: idx = bisect.bisect_left(que, A[i]) if idx == 0: deque.appendleft(qu...
import sys from collections import deque from bisect import bisect_left sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 def resolve(): n = int(eval(input())) A = list(int(eval(input())) for _ in range(n)) LIS = deque() for i in range(n): if len(LIS...
false
31.034483
[ "-# 狭義単調増加部分列", "-import bisect", "+import sys", "+from bisect import bisect_left", "-n = int(eval(input()))", "-A = [int(eval(input())) for _ in range(n)]", "-que = deque()", "-for i in range(n):", "- if len(que) == 0:", "- deque.appendleft(que, A[i])", "- else:", "- idx =...
false
0.044714
0.038158
1.171811
[ "s991476263", "s174098780" ]
u790012205
p03044
python
s008306550
s368974442
1,141
948
145,296
86,368
Accepted
Accepted
16.91
import sys sys.setrecursionlimit(10 ** 6) N = int(eval(input())) uvw = [list(map(int, input().split())) for i in range(N - 1)] R = [-1] * N Q = [[] for i in range(N)] for i in range(N - 1): Q[uvw[i][0] - 1].append([uvw[i][1], uvw[i][2]]) Q[uvw[i][1] - 1].append([uvw[i][0], uvw[i][2]]) def func(i, s, ...
import sys sys.setrecursionlimit(10 ** 6) N = int(eval(input())) G = [[] for i in range(N)] for i in range(N - 1): a, b, w = list(map(int, input().split())) G[a - 1].append([b, w]) G[b - 1].append([a, w]) S = [-1] * N def func(x, w, c): if w % 2 != 0: c = 1 - c S[x] = c ...
29
25
681
536
import sys sys.setrecursionlimit(10**6) N = int(eval(input())) uvw = [list(map(int, input().split())) for i in range(N - 1)] R = [-1] * N Q = [[] for i in range(N)] for i in range(N - 1): Q[uvw[i][0] - 1].append([uvw[i][1], uvw[i][2]]) Q[uvw[i][1] - 1].append([uvw[i][0], uvw[i][2]]) def func(i, s, d, l): ...
import sys sys.setrecursionlimit(10**6) N = int(eval(input())) G = [[] for i in range(N)] for i in range(N - 1): a, b, w = list(map(int, input().split())) G[a - 1].append([b, w]) G[b - 1].append([a, w]) S = [-1] * N def func(x, w, c): if w % 2 != 0: c = 1 - c S[x] = c for i in range(l...
false
13.793103
[ "-uvw = [list(map(int, input().split())) for i in range(N - 1)]", "-R = [-1] * N", "-Q = [[] for i in range(N)]", "+G = [[] for i in range(N)]", "- Q[uvw[i][0] - 1].append([uvw[i][1], uvw[i][2]])", "- Q[uvw[i][1] - 1].append([uvw[i][0], uvw[i][2]])", "+ a, b, w = list(map(int, input().split()))...
false
0.036552
0.04223
0.865542
[ "s008306550", "s368974442" ]
u759412327
p03337
python
s091457393
s239597246
22
17
2,940
2,940
Accepted
Accepted
22.73
a = list(map(int,input().split())) b = [a[0]+a[1],a[0]-a[1],a[0]*a[1]] print((max(b)))
A,B = list(map(int,input().split())) print((max(A+B,A-B,A*B)))
3
2
86
61
a = list(map(int, input().split())) b = [a[0] + a[1], a[0] - a[1], a[0] * a[1]] print((max(b)))
A, B = list(map(int, input().split())) print((max(A + B, A - B, A * B)))
false
33.333333
[ "-a = list(map(int, input().split()))", "-b = [a[0] + a[1], a[0] - a[1], a[0] * a[1]]", "-print((max(b)))", "+A, B = list(map(int, input().split()))", "+print((max(A + B, A - B, A * B)))" ]
false
0.084579
0.044501
1.900615
[ "s091457393", "s239597246" ]
u816116805
p03768
python
s029608422
s965603993
1,895
1,737
53,600
53,508
Accepted
Accepted
8.34
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # """ agc012 C """ n, m = list(map(int, input().split())) graph = [[] for i in range(n+1)] for i in range(m): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) q = int(eval(input())) qlist = [t...
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # """ agc012 C """ n, m = list(map(int, input().split())) graph = [[] for i in range(n+1)] for i in range(m): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) q = int(eval(input())) qlist = [t...
43
44
757
794
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # """ agc012 C """ n, m = list(map(int, input().split())) graph = [[] for i in range(n + 1)] for i in range(m): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) q = int(eval(input())) qlist = [tuple(map(int, input()....
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # """ agc012 C """ n, m = list(map(int, input().split())) graph = [[] for i in range(n + 1)] for i in range(m): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) q = int(eval(input())) qlist = [tuple(map(int, input()....
false
2.272727
[ "- dp[v][d] = t", "+ for i in range(d + 1):", "+ if dp[v][i] == -1:", "+ dp[v][i] = t", "- updatedp(v, t, d - 1)" ]
false
0.036838
0.038166
0.965197
[ "s029608422", "s965603993" ]
u908984540
p02266
python
s626043678
s862616838
40
30
8,528
6,836
Accepted
Accepted
25
from collections import deque input_list = eval(input()) area = 0 depth_arr = deque() area_arr = deque() for i, input_str in enumerate(input_list): if "\\" == input_str: depth_arr.append(i) elif "/" == input_str: if len(depth_arr): position = depth_arr.pop() ...
from collections import deque if __name__ == "__main__": slopes = input() total_area = 0 slope_queue = deque() area_queue = deque() for i, slope in enumerate(slopes): if slope == '\\': slope_queue.append(i) elif slope == '/' and len(slope_queue) != 0: ...
30
41
827
1,391
from collections import deque input_list = eval(input()) area = 0 depth_arr = deque() area_arr = deque() for i, input_str in enumerate(input_list): if "\\" == input_str: depth_arr.append(i) elif "/" == input_str: if len(depth_arr): position = depth_arr.pop() pool = i - p...
from collections import deque if __name__ == "__main__": slopes = input() total_area = 0 slope_queue = deque() area_queue = deque() for i, slope in enumerate(slopes): if slope == "\\": slope_queue.append(i) elif slope == "/" and len(slope_queue) != 0: target ...
false
26.829268
[ "-input_list = eval(input())", "-area = 0", "-depth_arr = deque()", "-area_arr = deque()", "-for i, input_str in enumerate(input_list):", "- if \"\\\\\" == input_str:", "- depth_arr.append(i)", "- elif \"/\" == input_str:", "- if len(depth_arr):", "- position = depth...
false
0.039911
0.042413
0.941009
[ "s626043678", "s862616838" ]
u919734978
p03106
python
s688891982
s857471920
331
17
22,192
2,940
Accepted
Accepted
94.86
import numpy as np a,b,k = list(map(int,input().split())) c = np.array(list(range(1,min(a,b)+1))) #a,bのうち小さい方の数字までのリスト #両方が0のインデックスのリストを返して、後ろからk番目のインデックス番号のcをprint e = [f for f,g in enumerate(zip(a%c,b%c)) if g == (0,0)] print((c[e[-k]]))
a,b,k = list(map(int,input().split())) c = [] for i in range(min(a,b)): if a%(i+1) == 0 and b%(i+1) == 0: c.append(i+1) print((c[-k]))
6
6
236
143
import numpy as np a, b, k = list(map(int, input().split())) c = np.array(list(range(1, min(a, b) + 1))) # a,bのうち小さい方の数字までのリスト # 両方が0のインデックスのリストを返して、後ろからk番目のインデックス番号のcをprint e = [f for f, g in enumerate(zip(a % c, b % c)) if g == (0, 0)] print((c[e[-k]]))
a, b, k = list(map(int, input().split())) c = [] for i in range(min(a, b)): if a % (i + 1) == 0 and b % (i + 1) == 0: c.append(i + 1) print((c[-k]))
false
0
[ "-import numpy as np", "-", "-c = np.array(list(range(1, min(a, b) + 1))) # a,bのうち小さい方の数字までのリスト", "-# 両方が0のインデックスのリストを返して、後ろからk番目のインデックス番号のcをprint", "-e = [f for f, g in enumerate(zip(a % c, b % c)) if g == (0, 0)]", "-print((c[e[-k]]))", "+c = []", "+for i in range(min(a, b)):", "+ if a % (i + ...
false
0.489339
0.036182
13.52432
[ "s688891982", "s857471920" ]
u762540523
p02889
python
s803896705
s940980274
1,579
662
26,944
18,992
Accepted
Accepted
58.07
def resolve(): from scipy.sparse.csgraph import floyd_warshall import sys def input(): return sys.stdin.readline().rstrip() n, m, l = list(map(int, input().split())) inf = 10 ** 20 ar = [[0] * n for _ in range(n)] for _ in range(m): a, b, c = list(map(int, input().split())) ...
def resolve(): from scipy.sparse.csgraph import floyd_warshall import sys def input(): return sys.stdin.readline().rstrip() n, m, l = list(map(int, input().split())) inf = float("inf") ar = [[0] * n for _ in range(n)] for _ in range(m): a, b, c = list(map(int, input().split()...
26
25
820
795
def resolve(): from scipy.sparse.csgraph import floyd_warshall import sys def input(): return sys.stdin.readline().rstrip() n, m, l = list(map(int, input().split())) inf = 10**20 ar = [[0] * n for _ in range(n)] for _ in range(m): a, b, c = list(map(int, input().split())) ...
def resolve(): from scipy.sparse.csgraph import floyd_warshall import sys def input(): return sys.stdin.readline().rstrip() n, m, l = list(map(int, input().split())) inf = float("inf") ar = [[0] * n for _ in range(n)] for _ in range(m): a, b, c = list(map(int, input().split...
false
3.846154
[ "- inf = 10**20", "+ inf = float(\"inf\")", "- p = y[s - 1, t - 1]" ]
false
0.314719
0.406945
0.773369
[ "s803896705", "s940980274" ]
u311379832
p02960
python
s644633996
s932081339
305
246
95,744
74,136
Accepted
Accepted
19.34
MOD = 10 ** 9 + 7 S = eval(input()) dp = [[0] * 13 for _ in range(len(S) + 1)] dp[0][0] = 1 for i in range(len(S)): tmpS = 0 if S[i] == '?': tmpS = -1 else: tmpS = int(S[i]) for j in range(10): if tmpS != -1 and tmpS != j: continue for k in range(13): ...
MOD = 10 ** 9 + 7 S = eval(input()) dp = [0] * 13 dp[0] = 1 for i in range(len(S)): cdp = [0] * 13 tmpS = 0 if S[i] == '?': tmpS = -1 else: tmpS = int(S[i]) for j in range(10): if tmpS != -1 and tmpS != j: continue for k in range(13): cdp[(...
18
20
434
416
MOD = 10**9 + 7 S = eval(input()) dp = [[0] * 13 for _ in range(len(S) + 1)] dp[0][0] = 1 for i in range(len(S)): tmpS = 0 if S[i] == "?": tmpS = -1 else: tmpS = int(S[i]) for j in range(10): if tmpS != -1 and tmpS != j: continue for k in range(13): ...
MOD = 10**9 + 7 S = eval(input()) dp = [0] * 13 dp[0] = 1 for i in range(len(S)): cdp = [0] * 13 tmpS = 0 if S[i] == "?": tmpS = -1 else: tmpS = int(S[i]) for j in range(10): if tmpS != -1 and tmpS != j: continue for k in range(13): cdp[(k * 10...
false
10
[ "-dp = [[0] * 13 for _ in range(len(S) + 1)]", "-dp[0][0] = 1", "+dp = [0] * 13", "+dp[0] = 1", "+ cdp = [0] * 13", "- dp[i + 1][(k * 10 + j) % 13] += dp[i][k]", "- dp[i + 1][(k * 10 + j) % 13] %= MOD", "-print((dp[len(S)][5]))", "+ cdp[(k * 10 + j) % 13] += dp[k]...
false
0.036567
0.044221
0.826913
[ "s644633996", "s932081339" ]
u644907318
p03796
python
s827598828
s766705994
174
70
38,512
63,088
Accepted
Accepted
59.77
INFTY = 10**9 + 7 N = int(eval(input())) p = 1 for i in range(2,N+1): p = (p*i)%INFTY print(p)
p = 10**9+7 N = int(eval(input())) cnt = 1 for i in range(1,N+1): cnt = (cnt*i)%p print(cnt)
6
6
97
95
INFTY = 10**9 + 7 N = int(eval(input())) p = 1 for i in range(2, N + 1): p = (p * i) % INFTY print(p)
p = 10**9 + 7 N = int(eval(input())) cnt = 1 for i in range(1, N + 1): cnt = (cnt * i) % p print(cnt)
false
0
[ "-INFTY = 10**9 + 7", "+p = 10**9 + 7", "-p = 1", "-for i in range(2, N + 1):", "- p = (p * i) % INFTY", "-print(p)", "+cnt = 1", "+for i in range(1, N + 1):", "+ cnt = (cnt * i) % p", "+print(cnt)" ]
false
0.128941
0.044596
2.891295
[ "s827598828", "s766705994" ]
u157379742
p03013
python
s240304019
s228273694
234
77
45,148
9,164
Accepted
Accepted
67.09
import sys input=sys.stdin.readline from collections import deque from heapq import heappush,heappop import re def int_raw(): return int(eval(input())) def ss_raw(): return input().split() def ints_raw(): return tuple(map(int, ss_raw())) DIV=10**9+7 def mod_invs(n,mod=DIV): in...
import sys input=sys.stdin.readline from collections import deque from heapq import heappush,heappop import re def int_raw(): return int(eval(input())) def ss_raw(): return input().split() def ints_raw(): return tuple(map(int, ss_raw())) DIV = 10**9+7 def main(): N,M = ints_...
46
37
851
699
import sys input = sys.stdin.readline from collections import deque from heapq import heappush, heappop import re def int_raw(): return int(eval(input())) def ss_raw(): return input().split() def ints_raw(): return tuple(map(int, ss_raw())) DIV = 10**9 + 7 def mod_invs(n, mod=DIV): inv = [0] ...
import sys input = sys.stdin.readline from collections import deque from heapq import heappush, heappop import re def int_raw(): return int(eval(input())) def ss_raw(): return input().split() def ints_raw(): return tuple(map(int, ss_raw())) DIV = 10**9 + 7 def main(): N, M = ints_raw() As...
false
19.565217
[ "-def mod_invs(n, mod=DIV):", "- inv = [0] * (n + 1)", "- inv[0] = 1", "- inv[1] = 1", "- for i in range(2, n + 1):", "- inv[i] = (-(mod // i) * inv[mod % i]) % mod", "- return inv", "-", "-", "- continue", "+ memo[n] = 0" ]
false
0.062203
0.032434
1.91785
[ "s240304019", "s228273694" ]
u606045429
p02889
python
s818559679
s170212275
747
626
40,756
40,784
Accepted
Accepted
16.2
from scipy.sparse.csgraph import floyd_warshall N, M, L, *I = list(map(int, open(0).read().split())) ABC, ST = I[:3 * M], I[3 * M + 1:] E = [[0] * N for _ in range(N)] for a, b, c in zip(*[iter(ABC)] * 3): E[a - 1][b - 1] = E[b - 1][a - 1] = c E = floyd_warshall(E) for i, ei in enumerate(E): for...
from scipy.sparse.csgraph import floyd_warshall N, M, L, *I = list(map(int, open(0).read().split())) ABC, ST = I[:3 * M], I[3 * M + 1:] E = [[0] * N for _ in range(N)] for a, b, c in zip(*[iter(ABC)] * 3): E[a - 1][b - 1] = E[b - 1][a - 1] = c E = floyd_warshall(E) E = [[(eij <= L) for j, eij in enumer...
25
21
562
541
from scipy.sparse.csgraph import floyd_warshall N, M, L, *I = list(map(int, open(0).read().split())) ABC, ST = I[: 3 * M], I[3 * M + 1 :] E = [[0] * N for _ in range(N)] for a, b, c in zip(*[iter(ABC)] * 3): E[a - 1][b - 1] = E[b - 1][a - 1] = c E = floyd_warshall(E) for i, ei in enumerate(E): for j, eij in en...
from scipy.sparse.csgraph import floyd_warshall N, M, L, *I = list(map(int, open(0).read().split())) ABC, ST = I[: 3 * M], I[3 * M + 1 :] E = [[0] * N for _ in range(N)] for a, b, c in zip(*[iter(ABC)] * 3): E[a - 1][b - 1] = E[b - 1][a - 1] = c E = floyd_warshall(E) E = [[(eij <= L) for j, eij in enumerate(ei)] f...
false
16
[ "-for i, ei in enumerate(E):", "- for j, eij in enumerate(ei):", "- E[i][j] = eij <= L", "+E = [[(eij <= L) for j, eij in enumerate(ei)] for i, ei in enumerate(E)]" ]
false
0.51887
0.788349
0.658173
[ "s818559679", "s170212275" ]
u296518383
p02803
python
s123790105
s100592131
286
230
48,092
43,612
Accepted
Accepted
19.58
from collections import deque H, W = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] INF = 10**15 d = [(1, 0), (-1, 0), (0, 1), (0, -1)] answer = 0 for i in range(H): for j in range(W): if S[i][j] == "#": continue else: dist = [[INF for _ in range(W)] for ...
from collections import deque H, W = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] INF = 10**15 graph = [[] for _ in range(H * W)] for i in range(H): for j in range(W): for ni, nj in [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)]: if 0 <= ni < H and 0 <= nj < W and ...
38
34
1,027
892
from collections import deque H, W = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] INF = 10**15 d = [(1, 0), (-1, 0), (0, 1), (0, -1)] answer = 0 for i in range(H): for j in range(W): if S[i][j] == "#": continue else: dist = [[INF for _ in range(W)] f...
from collections import deque H, W = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] INF = 10**15 graph = [[] for _ in range(H * W)] for i in range(H): for j in range(W): for ni, nj in [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)]: if 0 <= ni < H and 0 <= nj < W and S[n...
false
10.526316
[ "-d = [(1, 0), (-1, 0), (0, 1), (0, -1)]", "+graph = [[] for _ in range(H * W)]", "+for i in range(H):", "+ for j in range(W):", "+ for ni, nj in [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)]:", "+ if 0 <= ni < H and 0 <= nj < W and S[ni][nj] != \"#\":", "+ graph[W...
false
0.045076
0.046936
0.960377
[ "s123790105", "s100592131" ]
u943057856
p02900
python
s943112343
s393716762
113
104
9,428
9,456
Accepted
Accepted
7.96
a,b=list(map(int,input().split())) #a,bの最大公約数 def gcd(a, b): while b: a, b = b, a % b return a #nを素因数分解したリストを返す def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: ...
import math a,b=list(map(int,input().split())) def factorization(n): arr=[] tmp=n for i in range(2,int(n**0.5)+1): while tmp%i==0: tmp//=i arr.append(i) if tmp!=1: arr.append(tmp) if arr==[]: arr.append(n) return list(set(arr)) an...
29
18
565
390
a, b = list(map(int, input().split())) # a,bの最大公約数 def gcd(a, b): while b: a, b = b, a % b return a # nを素因数分解したリストを返す def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: ...
import math a, b = list(map(int, input().split())) def factorization(n): arr = [] tmp = n for i in range(2, int(n**0.5) + 1): while tmp % i == 0: tmp //= i arr.append(i) if tmp != 1: arr.append(tmp) if arr == []: arr.append(n) return list(set(ar...
false
37.931034
[ "+import math", "+", "-# a,bの最大公約数", "-def gcd(a, b):", "- while b:", "- a, b = b, a % b", "- return a", "-# nを素因数分解したリストを返す", "- temp = n", "- for i in range(2, int(-(-(n**0.5) // 1)) + 1):", "- if temp % i == 0:", "- cnt = 0", "- while temp %...
false
0.04442
0.045362
0.979218
[ "s943112343", "s393716762" ]
u163320134
p02715
python
s993022535
s660648126
342
92
69,916
69,100
Accepted
Accepted
73.1
def divisors(n): ret=[] for i in range(1,int(n**0.5)+1): if n%i==0: ret.append(i) if i!=n//i: ret.append(n//i) return ret mod=10**9+7 n,k=list(map(int,input().split())) cnt=[0]*(k+1) for i in range(k,1,-1): divs=divisors(i) cnt[i]+=p...
mod=10**9+7 n,k=list(map(int,input().split())) cnt=[0]*(k+1) for i in range(k,0,-1): cnt[i]+=pow(k//i,n,mod) for j in range(2,k//i+1): cnt[i]-=cnt[i*j] ans=0 for i in range(1,k+1): ans+=i*(cnt[i])%mod ans%=mod print(ans)
26
12
541
251
def divisors(n): ret = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: ret.append(i) if i != n // i: ret.append(n // i) return ret mod = 10**9 + 7 n, k = list(map(int, input().split())) cnt = [0] * (k + 1) for i in range(k, 1, -1): divs = divisors(...
mod = 10**9 + 7 n, k = list(map(int, input().split())) cnt = [0] * (k + 1) for i in range(k, 0, -1): cnt[i] += pow(k // i, n, mod) for j in range(2, k // i + 1): cnt[i] -= cnt[i * j] ans = 0 for i in range(1, k + 1): ans += i * (cnt[i]) % mod ans %= mod print(ans)
false
53.846154
[ "-def divisors(n):", "- ret = []", "- for i in range(1, int(n**0.5) + 1):", "- if n % i == 0:", "- ret.append(i)", "- if i != n // i:", "- ret.append(n // i)", "- return ret", "-", "-", "-for i in range(k, 1, -1):", "- divs = divisors(i)"...
false
0.457445
0.153048
2.988891
[ "s993022535", "s660648126" ]
u562935282
p02639
python
s124731136
s557701558
21
19
9,144
9,156
Accepted
Accepted
9.52
def main(): *x, = list(map(int, input().split())) print((x.index(0) + 1)) if __name__ == '__main__': main() # import sys # input = sys.stdin.readline # # sys.setrecursionlimit(10 ** 7) # # (int(x)-1 for x in input().split()) # rstrip() # # def binary_search(*, ok, ng, func): # whil...
def main(): for i, x in enumerate(map(int, input().split()), start=1): if x == 0: print(i) return if __name__ == '__main__': main()
24
9
471
182
def main(): (*x,) = list(map(int, input().split())) print((x.index(0) + 1)) if __name__ == "__main__": main() # import sys # input = sys.stdin.readline # # sys.setrecursionlimit(10 ** 7) # # (int(x)-1 for x in input().split()) # rstrip() # # def binary_search(*, ok, ng, func): # while abs(ok - ng) > 1...
def main(): for i, x in enumerate(map(int, input().split()), start=1): if x == 0: print(i) return if __name__ == "__main__": main()
false
62.5
[ "- (*x,) = list(map(int, input().split()))", "- print((x.index(0) + 1))", "+ for i, x in enumerate(map(int, input().split()), start=1):", "+ if x == 0:", "+ print(i)", "+ return", "-# import sys", "-# input = sys.stdin.readline", "-#", "-# sys.setrecursionlimi...
false
0.072913
0.106611
0.683919
[ "s124731136", "s557701558" ]
u969850098
p03031
python
s174409784
s443316675
35
23
3,188
3,064
Accepted
Accepted
34.29
N, M = list(map(int, input().split())) lights = [list(map(int, input().split())) for _ in range(M)] p_values = list(map(int, input().split())) switch_conbs = [] for i in range(2 ** N): conb = bin(i)[2:].zfill(N) switch_conbs.append(list(map(int, list(conb)))) for i, light in enumerate(lights): t...
import sys readline = sys.stdin.readline def main(): N, M = list(map(int, readline().rstrip().split())) S = [] for _ in range(M): _, *s = list(map(int, readline().rstrip().split())) S.append(set(s)) P = list(map(int, readline().rstrip().split())) ans = 0 for i in ra...
22
27
616
662
N, M = list(map(int, input().split())) lights = [list(map(int, input().split())) for _ in range(M)] p_values = list(map(int, input().split())) switch_conbs = [] for i in range(2**N): conb = bin(i)[2:].zfill(N) switch_conbs.append(list(map(int, list(conb)))) for i, light in enumerate(lights): temp = [] f...
import sys readline = sys.stdin.readline def main(): N, M = list(map(int, readline().rstrip().split())) S = [] for _ in range(M): _, *s = list(map(int, readline().rstrip().split())) S.append(set(s)) P = list(map(int, readline().rstrip().split())) ans = 0 for i in range(2**N): ...
false
18.518519
[ "-N, M = list(map(int, input().split()))", "-lights = [list(map(int, input().split())) for _ in range(M)]", "-p_values = list(map(int, input().split()))", "-switch_conbs = []", "-for i in range(2**N):", "- conb = bin(i)[2:].zfill(N)", "- switch_conbs.append(list(map(int, list(conb))))", "-for i,...
false
0.042693
0.042952
0.99397
[ "s174409784", "s443316675" ]
u340781749
p03295
python
s248052739
s528048670
363
166
11,108
17,976
Accepted
Accepted
54.27
from collections import defaultdict n, m = list(map(int, input().split())) disputes = defaultdict(int) for i in range(m): a, b = list(map(int, input().split())) disputes[b] = max(disputes[b], a) ans = 0 most_right_bridge = 0 for b in sorted(disputes.keys()): if most_right_bridge <= disputes[b]: ...
import sys from collections import defaultdict n, m = list(map(int, input().split())) disputes = defaultdict(int) for line in sys.stdin.readlines(): a, b = list(map(int, line.split())) if disputes[b] < a: disputes[b] = a ans = 0 most_right_bridge = 0 for b in sorted(disputes.keys()): if...
14
16
368
404
from collections import defaultdict n, m = list(map(int, input().split())) disputes = defaultdict(int) for i in range(m): a, b = list(map(int, input().split())) disputes[b] = max(disputes[b], a) ans = 0 most_right_bridge = 0 for b in sorted(disputes.keys()): if most_right_bridge <= disputes[b]: ans...
import sys from collections import defaultdict n, m = list(map(int, input().split())) disputes = defaultdict(int) for line in sys.stdin.readlines(): a, b = list(map(int, line.split())) if disputes[b] < a: disputes[b] = a ans = 0 most_right_bridge = 0 for b in sorted(disputes.keys()): if most_right_...
false
12.5
[ "+import sys", "-for i in range(m):", "- a, b = list(map(int, input().split()))", "- disputes[b] = max(disputes[b], a)", "+for line in sys.stdin.readlines():", "+ a, b = list(map(int, line.split()))", "+ if disputes[b] < a:", "+ disputes[b] = a" ]
false
0.099295
0.046999
2.112693
[ "s248052739", "s528048670" ]
u226108478
p03325
python
s178497762
s261568858
118
86
4,148
4,148
Accepted
Accepted
27.12
# -*- coding: utf-8 -*- # AtCoder Beginner Contest if __name__ == '__main__': n = int(eval(input())) a = list(map(int, input().split())) count = 0 for ai in a: while True: if ai % 2 == 0: ai = ai / 2 count += 1 else: ...
# -*- coding: utf-8 -*- # AtCoder Beginner Contest if __name__ == '__main__': n = int(eval(input())) a = list(map(int, input().split())) count = 0 # See: # https://beta.atcoder.jp/contests/abc100/submissions/2675457 for ai in a: while ai % 2 == 0: ai //= 2 ...
18
17
351
355
# -*- coding: utf-8 -*- # AtCoder Beginner Contest if __name__ == "__main__": n = int(eval(input())) a = list(map(int, input().split())) count = 0 for ai in a: while True: if ai % 2 == 0: ai = ai / 2 count += 1 else: break ...
# -*- coding: utf-8 -*- # AtCoder Beginner Contest if __name__ == "__main__": n = int(eval(input())) a = list(map(int, input().split())) count = 0 # See: # https://beta.atcoder.jp/contests/abc100/submissions/2675457 for ai in a: while ai % 2 == 0: ai //= 2 count +...
false
5.555556
[ "+ # See:", "+ # https://beta.atcoder.jp/contests/abc100/submissions/2675457", "- while True:", "- if ai % 2 == 0:", "- ai = ai / 2", "- count += 1", "- else:", "- break", "+ while ai % 2 == 0:", "+ a...
false
0.033528
0.054884
0.610875
[ "s178497762", "s261568858" ]
u334712262
p03251
python
s179299169
s544816089
302
270
7,740
7,740
Accepted
Accepted
10.6
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
77
81
1,397
1,459
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
false
4.938272
[ "- if mx < my and (my > X and mx < Y):", "- return \"No War\"", "+ if mx >= my:", "+ return \"War\"", "+ for i in range(mx + 1, my + 1):", "+ if X < i <= Y:", "+ return \"No War\"" ]
false
0.041785
0.046662
0.895477
[ "s179299169", "s544816089" ]
u039189422
p02947
python
s712646253
s911409968
542
335
8,312
19,760
Accepted
Accepted
38.19
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101] n=int(eval(input())) A=[1]*n for i in range(n): s=eval(input()) for j in range(10): A[i] *= P[ord(s[j])-97] res=0 A.sort() cnt=0 for i in range(n-1): if A[i]==A[i+1]: cnt += 1 else: res += cnt*(cnt+1)//2 ...
import collections n=int(eval(input())) s=collections.Counter(["".join(sorted(eval(input()))) for _ in range(n)]) v=list(s.values()) res=0 for u in v: if u!=1: res += u*(u-1)//2 print(res)
22
9
364
187
P = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, ] n = int(eval(input())) A = [1] * n for i in range(n): s = eval(input()) for j in range(10): ...
import collections n = int(eval(input())) s = collections.Counter(["".join(sorted(eval(input()))) for _ in range(n)]) v = list(s.values()) res = 0 for u in v: if u != 1: res += u * (u - 1) // 2 print(res)
false
59.090909
[ "-P = [", "- 2,", "- 3,", "- 5,", "- 7,", "- 11,", "- 13,", "- 17,", "- 19,", "- 23,", "- 29,", "- 31,", "- 37,", "- 41,", "- 43,", "- 47,", "- 53,", "- 59,", "- 61,", "- 67,", "- 71,", "- 73,", "- 79,", ...
false
0.154932
0.046018
3.366802
[ "s712646253", "s911409968" ]
u714300041
p03160
python
s021731197
s349787192
132
121
13,980
13,980
Accepted
Accepted
8.33
""" dp[i] := 足場iまでにかかるコストの最小値 """ N = int(eval(input())) *h, = list(map(int, input().split())) dp = [0 for _ in range(N)] dp[1] = abs(h[0] - h[1]) # initialize dp for i in range(2, N): case1 = dp[i-1] + abs(h[i-1] - h[i]) case2 = dp[i-2] + abs(h[i-2] - h[i]) dp[i] = min(case1, case2) print((...
N = int(eval(input())) H = list(map(int, input().split())) cost = [0]*N cost[1] = abs(H[0] - H[1]) for k in range(2, N): cost[k] = min(cost[k-1] + abs(H[k-1] - H[k]), cost[k-2] + abs(H[k-2] - H[k])) print((cost[-1]))
14
11
314
226
""" dp[i] := 足場iまでにかかるコストの最小値 """ N = int(eval(input())) (*h,) = list(map(int, input().split())) dp = [0 for _ in range(N)] dp[1] = abs(h[0] - h[1]) # initialize dp for i in range(2, N): case1 = dp[i - 1] + abs(h[i - 1] - h[i]) case2 = dp[i - 2] + abs(h[i - 2] - h[i]) dp[i] = min(case1, case2) print((dp[-1...
N = int(eval(input())) H = list(map(int, input().split())) cost = [0] * N cost[1] = abs(H[0] - H[1]) for k in range(2, N): cost[k] = min( cost[k - 1] + abs(H[k - 1] - H[k]), cost[k - 2] + abs(H[k - 2] - H[k]) ) print((cost[-1]))
false
21.428571
[ "-\"\"\"", "-dp[i] := 足場iまでにかかるコストの最小値", "-\"\"\"", "-(*h,) = list(map(int, input().split()))", "-dp = [0 for _ in range(N)]", "-dp[1] = abs(h[0] - h[1]) # initialize dp", "-for i in range(2, N):", "- case1 = dp[i - 1] + abs(h[i - 1] - h[i])", "- case2 = dp[i - 2] + abs(h[i - 2] - h[i])", "...
false
0.115806
0.076871
1.506512
[ "s021731197", "s349787192" ]
u816587940
p03525
python
s601091502
s936970456
749
336
78,220
68,276
Accepted
Accepted
55.14
import random def ans_is_zero(): print((0)) exit(0) def solve(): n=int(eval(input())) if n > 23: ans_is_zero() d=list(map(int,input().split())) for num in d: if num == 0: ans_is_zero() ans=0 random.shuffle(d) N = 1 << n for i in range(N):#left o...
def ans_is_zero(): print((0)) exit(0) def solve(): n=int(eval(input())) if n > 23: ans_is_zero() d=list(map(int,input().split())) for num in d: if num == 0: ans_is_zero() ans=0 d.sort() N = 1 << n for i in range(N):#left or right t=1 ...
46
42
920
813
import random def ans_is_zero(): print((0)) exit(0) def solve(): n = int(eval(input())) if n > 23: ans_is_zero() d = list(map(int, input().split())) for num in d: if num == 0: ans_is_zero() ans = 0 random.shuffle(d) N = 1 << n for i in range(N): #...
def ans_is_zero(): print((0)) exit(0) def solve(): n = int(eval(input())) if n > 23: ans_is_zero() d = list(map(int, input().split())) for num in d: if num == 0: ans_is_zero() ans = 0 d.sort() N = 1 << n for i in range(N): # left or right t ...
false
8.695652
[ "-import random", "-", "-", "- random.shuffle(d)", "+ d.sort()", "- if bin(t).count(\"1\") < n + 1: # 重複あり", "- continue" ]
false
0.049932
0.20815
0.239886
[ "s601091502", "s936970456" ]
u513081876
p03309
python
s919923631
s541083015
286
246
26,016
27,844
Accepted
Accepted
13.99
N = int(eval(input())) A = [int(i) for i in input().split()] A = [A[_] - (_ + 1) for _ in range(N)] AA = sorted(A) ans = 0 ans1 = 0 center = N // 2 num = AA[center] if N % 2 != 0: for i in range(N): ans += abs(AA[i] - num) print(ans) else: center = len(AA) // 2 for i in range(N):...
N = int(eval(input())) A = [int(i) for i in input().split()] for i in range(N): A[i] -= (i+1) A.sort() if N % 2 != 0: num = A[N//2] A = [abs(i - num) for i in A] print((sum(A))) else: num1 = A[N//2] num2 = num1 -1 A1 = [abs(i - num1) for i in A] A2 = [abs(i - num2) for i...
19
17
416
352
N = int(eval(input())) A = [int(i) for i in input().split()] A = [A[_] - (_ + 1) for _ in range(N)] AA = sorted(A) ans = 0 ans1 = 0 center = N // 2 num = AA[center] if N % 2 != 0: for i in range(N): ans += abs(AA[i] - num) print(ans) else: center = len(AA) // 2 for i in range(N): ans += ...
N = int(eval(input())) A = [int(i) for i in input().split()] for i in range(N): A[i] -= i + 1 A.sort() if N % 2 != 0: num = A[N // 2] A = [abs(i - num) for i in A] print((sum(A))) else: num1 = A[N // 2] num2 = num1 - 1 A1 = [abs(i - num1) for i in A] A2 = [abs(i - num2) for i in A] p...
false
10.526316
[ "-A = [A[_] - (_ + 1) for _ in range(N)]", "-AA = sorted(A)", "-ans = 0", "-ans1 = 0", "-center = N // 2", "-num = AA[center]", "+for i in range(N):", "+ A[i] -= i + 1", "+A.sort()", "- for i in range(N):", "- ans += abs(AA[i] - num)", "- print(ans)", "+ num = A[N // 2]", ...
false
0.038994
0.047103
0.827839
[ "s919923631", "s541083015" ]
u729133443
p02735
python
s383934055
s780003727
43
29
3,064
3,188
Accepted
Accepted
32.56
h,*s=open(0) h,w=list(map(int,h.split())) dp=[[9e9]*w for _ in s] dp[0][0]=s[0][0]<'.' for i in range(h*w): i,j=i//w,i%w for y,x in((i+1,j),(i,j+1)): if y<h and x<w:dp[y][x]=min(dp[y][x],dp[i][j]+(s[i][j]=='.'>s[y][x])) print((dp[-1][-1]))
def main(): import sys input=sys.stdin.buffer.readline h,w=list(map(int,input().split())) s=[c<46and 1or 0for _ in range(h)for c in input()[:w]] dp=[10**9]*h*w dp[0]=s[0] for i in range(h*w): j,k=i//w,i%w for y,x in((j+1,k),(j,k+1)): if y<h and x<w: z=y*w+x t=dp[i...
9
16
247
385
h, *s = open(0) h, w = list(map(int, h.split())) dp = [[9e9] * w for _ in s] dp[0][0] = s[0][0] < "." for i in range(h * w): i, j = i // w, i % w for y, x in ((i + 1, j), (i, j + 1)): if y < h and x < w: dp[y][x] = min(dp[y][x], dp[i][j] + (s[i][j] == "." > s[y][x])) print((dp[-1][-1]))
def main(): import sys input = sys.stdin.buffer.readline h, w = list(map(int, input().split())) s = [c < 46 and 1 or 0 for _ in range(h) for c in input()[:w]] dp = [10**9] * h * w dp[0] = s[0] for i in range(h * w): j, k = i // w, i % w for y, x in ((j + 1, k), (j, k + 1)): ...
false
43.75
[ "-h, *s = open(0)", "-h, w = list(map(int, h.split()))", "-dp = [[9e9] * w for _ in s]", "-dp[0][0] = s[0][0] < \".\"", "-for i in range(h * w):", "- i, j = i // w, i % w", "- for y, x in ((i + 1, j), (i, j + 1)):", "- if y < h and x < w:", "- dp[y][x] = min(dp[y][x], dp[i][j...
false
0.054806
0.091016
0.602157
[ "s383934055", "s780003727" ]
u896741788
p03049
python
s458097547
s810590957
69
44
3,188
3,192
Accepted
Accepted
36.23
import re n=int(eval(input())) ans=0 a,b,ba=0,0,0 for i in range(n): s=eval(input()) ans+=len(re.sub("[A-Z]+","",s.replace("AB","s"))) if s[0]=="B" and s[-1]=="A":ba+=1 elif s[0]=="B":b+=1 elif s[-1]=="A":a+=1 ans+=max(ba-1,0) if ba: if a:ans+=1;a-=1 if b:ans+=1;b-=1 print((ans+min(a,b)))
n=int(eval(input())) l=[0,0,0,0]#non,~a,b~,b~a ans=0 for i in range(n): s=eval(input()) ans+=s.count("AB") l[2*int(s[0]=="B")+1*int(s[-1]=="A")]+=1 if l[-1]: ans+=l[-1]-1 if l[1]: l[1]-=1 ans+=1 if l[2]: l[2]-=1 ans+=1 print((ans+min(l[1:3])))
15
17
303
302
import re n = int(eval(input())) ans = 0 a, b, ba = 0, 0, 0 for i in range(n): s = eval(input()) ans += len(re.sub("[A-Z]+", "", s.replace("AB", "s"))) if s[0] == "B" and s[-1] == "A": ba += 1 elif s[0] == "B": b += 1 elif s[-1] == "A": a += 1 ans += max(ba - 1, 0) if ba: ...
n = int(eval(input())) l = [0, 0, 0, 0] # non,~a,b~,b~a ans = 0 for i in range(n): s = eval(input()) ans += s.count("AB") l[2 * int(s[0] == "B") + 1 * int(s[-1] == "A")] += 1 if l[-1]: ans += l[-1] - 1 if l[1]: l[1] -= 1 ans += 1 if l[2]: l[2] -= 1 ans += 1 print...
false
11.764706
[ "-import re", "-", "+l = [0, 0, 0, 0] # non,~a,b~,b~a", "-a, b, ba = 0, 0, 0", "- ans += len(re.sub(\"[A-Z]+\", \"\", s.replace(\"AB\", \"s\")))", "- if s[0] == \"B\" and s[-1] == \"A\":", "- ba += 1", "- elif s[0] == \"B\":", "- b += 1", "- elif s[-1] == \"A\":", "- ...
false
0.042617
0.03733
1.14161
[ "s458097547", "s810590957" ]
u391875425
p03112
python
s657213573
s898994959
1,940
1,079
78,296
14,080
Accepted
Accepted
44.38
import bisect A, B, Q = list(map(int, input().split())) INF = 10 ** 13 s = [-INF] + [int(eval(input())) for i in range(A)] + [INF] t = [-INF] + [int(eval(input())) for i in range(B)] + [INF] for q in range(Q): x = int(eval(input())) b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x) res = I...
import bisect import sys A, B, Q = list(map(int, input().split())) INF = 10 ** 13 s = [-INF] + [int(eval(input())) for i in range(A)] + [INF] t = [-INF] + [int(eval(input())) for i in range(B)] + [INF] for q in range(Q): x = int(sys.stdin.readline()) b, d = bisect.bisect_right(s, x), bisect.bisect_right...
14
15
489
515
import bisect A, B, Q = list(map(int, input().split())) INF = 10**13 s = [-INF] + [int(eval(input())) for i in range(A)] + [INF] t = [-INF] + [int(eval(input())) for i in range(B)] + [INF] for q in range(Q): x = int(eval(input())) b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x) res = INF fo...
import bisect import sys A, B, Q = list(map(int, input().split())) INF = 10**13 s = [-INF] + [int(eval(input())) for i in range(A)] + [INF] t = [-INF] + [int(eval(input())) for i in range(B)] + [INF] for q in range(Q): x = int(sys.stdin.readline()) b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x) ...
false
6.666667
[ "+import sys", "- x = int(eval(input()))", "+ x = int(sys.stdin.readline())" ]
false
0.037688
0.049264
0.76502
[ "s657213573", "s898994959" ]
u761989513
p03295
python
s309305108
s189744630
456
366
29,920
18,972
Accepted
Accepted
19.74
from operator import itemgetter n, m = list(map(int, input().split())) ab = sorted([list(map(int, input().split())) for i in range(m)], key=itemgetter(1)) removed = -1 ans = 0 for a, b in ab: if a > removed: removed = b - 1 ans += 1 print(ans)
from operator import itemgetter n, m = list(map(int, input().split())) ab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1)) removed = -1 ans = 0 for a, b in ab: if a > removed: removed = b - 1 ans += 1 print(ans)
11
11
268
269
from operator import itemgetter n, m = list(map(int, input().split())) ab = sorted([list(map(int, input().split())) for i in range(m)], key=itemgetter(1)) removed = -1 ans = 0 for a, b in ab: if a > removed: removed = b - 1 ans += 1 print(ans)
from operator import itemgetter n, m = list(map(int, input().split())) ab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1)) removed = -1 ans = 0 for a, b in ab: if a > removed: removed = b - 1 ans += 1 print(ans)
false
0
[ "-ab = sorted([list(map(int, input().split())) for i in range(m)], key=itemgetter(1))", "+ab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1))" ]
false
0.045777
0.046312
0.988448
[ "s309305108", "s189744630" ]
u671060652
p02848
python
s054360844
s134480509
191
71
40,412
73,332
Accepted
Accepted
62.83
n = int(eval(input())) s = eval(input()) ans = "" for i in range(len(s)): ans += chr(ord("A") +(((ord(s[i])+n)-ord("A")) % 26)) print(ans)
def main(): n = int(eval(input())) # n, k = map(int, input().split()) # h = list(map(int, input().split())) s = eval(input()) ans = "" for i in s: ans += chr((ord(i) - ord("A") + n)% 26 + ord("A")) print(ans) if __name__ == '__main__': main()
9
16
141
291
n = int(eval(input())) s = eval(input()) ans = "" for i in range(len(s)): ans += chr(ord("A") + (((ord(s[i]) + n) - ord("A")) % 26)) print(ans)
def main(): n = int(eval(input())) # n, k = map(int, input().split()) # h = list(map(int, input().split())) s = eval(input()) ans = "" for i in s: ans += chr((ord(i) - ord("A") + n) % 26 + ord("A")) print(ans) if __name__ == "__main__": main()
false
43.75
[ "-n = int(eval(input()))", "-s = eval(input())", "-ans = \"\"", "-for i in range(len(s)):", "- ans += chr(ord(\"A\") + (((ord(s[i]) + n) - ord(\"A\")) % 26))", "-print(ans)", "+def main():", "+ n = int(eval(input()))", "+ # n, k = map(int, input().split())", "+ # h = list(map(int, inpu...
false
0.054675
0.040327
1.355779
[ "s054360844", "s134480509" ]
u025501820
p02660
python
s128580961
s966625254
178
92
9,496
9,464
Accepted
Accepted
48.31
import sys N = int(sys.stdin.readline().rstrip()) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) divisors.sort() return divisors def prime_fac...
import sys N = int(sys.stdin.readline().rstrip()) def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.app...
40
33
820
584
import sys N = int(sys.stdin.readline().rstrip()) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) divisors.sort() return divisors def prime_factorize(n):...
import sys N = int(sys.stdin.readline().rstrip()) def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) ret...
false
17.5
[ "-", "-", "-def make_divisors(n):", "- divisors = []", "- for i in range(1, int(n**0.5) + 1):", "- if n % i == 0:", "- divisors.append(i)", "- if i != n // i:", "- divisors.append(n // i)", "- divisors.sort()", "- return divisors", "- ...
false
0.063597
0.079665
0.798311
[ "s128580961", "s966625254" ]
u744920373
p03295
python
s482067595
s507280345
317
246
31,000
31,784
Accepted
Accepted
22.4
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def dp2(ini, i, j): ret...
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def dp2(ini, i, j): ret...
60
48
1,357
1,160
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] de...
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] de...
false
20
[ "-Q = sorted(Q, key=lambda x: x[1])", "-# table = dp2(0, N, N)", "-# for i in range(M):", "-# s, t = mi()", "-# for i in range(t):", "-# table[s-1][t-1] = 1", "-# for i in reversed(range(N-1)):", "-# for j in range(i, N):", "-# table[i][j] = max(table[i+1][j], table[i][j])", "-# print(table)", "...
false
0.046733
0.046293
1.009503
[ "s482067595", "s507280345" ]
u912237403
p00131
python
s523172109
s144739130
640
380
4,296
4,296
Accepted
Accepted
40.62
def f(x,y): global B B[y][x]^=1 if y>0: B[y-1][x]^=1 if y<9: B[y+1][x]^=1 if x>0: B[y][x-1]^=1 if x<9: B[y][x+1]^=1 return (x,y) R=list(range(10)) n=eval(input()) for _ in [0]*n: A=[list(map(int,input().split())) for _ in R] for p in range(1024): B=[e[:] for e in A] x=[] for...
def f(x,y): global B B[y][x]^=1 if y>0: B[y-1][x]^=1 if y<9: B[y+1][x]^=1 if x>0: B[y][x-1]^=1 if x<9: B[y][x+1]^=1 return (x,y) R=list(range(10)) n=eval(input()) for _ in [0]*n: A=[list(map(int,input().split())) for _ in R] for p in range(1024): B=[e[:] for e in A] x=[] for...
22
23
524
540
def f(x, y): global B B[y][x] ^= 1 if y > 0: B[y - 1][x] ^= 1 if y < 9: B[y + 1][x] ^= 1 if x > 0: B[y][x - 1] ^= 1 if x < 9: B[y][x + 1] ^= 1 return (x, y) R = list(range(10)) n = eval(input()) for _ in [0] * n: A = [list(map(int, input().split())) for ...
def f(x, y): global B B[y][x] ^= 1 if y > 0: B[y - 1][x] ^= 1 if y < 9: B[y + 1][x] ^= 1 if x > 0: B[y][x - 1] ^= 1 if x < 9: B[y][x + 1] ^= 1 return (x, y) R = list(range(10)) n = eval(input()) for _ in [0] * n: A = [list(map(int, input().split())) for ...
false
4.347826
[ "- a = [list(map(int, list(format(p, \"010b\")))), B[j - 1]][j != 0]", "+ if j == 0:", "+ a = list(map(int, list(format(p, \"010b\"))))", "+ else:", "+ a = B[j - 1]" ]
false
0.08376
0.107375
0.780073
[ "s523172109", "s144739130" ]
u588341295
p03088
python
s745847100
s554235343
165
63
4,208
3,572
Accepted
Accepted
61.82
# -*- coding: utf-8 -*- """ 参考:https://img.atcoder.jp/abc122/editorial.pdf ・数え上げDP """ import sys from itertools import product from collections import Counter def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * ...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in ...
51
57
1,456
1,856
# -*- coding: utf-8 -*- """ 参考:https://img.atcoder.jp/abc122/editorial.pdf ・数え上げDP """ import sys from itertools import product from collections import Counter def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] ...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in rang...
false
10.526316
[ "-\"\"\"", "-参考:https://img.atcoder.jp/abc122/editorial.pdf", "-・数え上げDP", "-\"\"\"", "-from itertools import product", "-from collections import Counter", "+def list4d(a, b, c, d, e):", "+ return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]", "+", "+", "-def LIST():", ...
false
0.093568
0.073995
1.264518
[ "s745847100", "s554235343" ]
u935984175
p02889
python
s042524473
s295199377
1,749
652
21,224
93,272
Accepted
Accepted
62.72
from scipy.sparse import csr_matrix from scipy.sparse.csgraph import floyd_warshall def solve(): N, M, L = list(map(int, input().split())) dist = [[0 for _ in range(N)] for _ in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) dist[a-1][b-1] = c dist...
import sys sys.setrecursionlimit(10 ** 7) rl = sys.stdin.readline def solve(): N, M, L = map(int, rl().split()) INF = 10 ** 18 dist = [[INF] * N for _ in range(N)] for _ in range(M): a, b, c = map(int, rl().split()) a, b = a - 1, b - 1 dist[a][b] = dist[b][a] = c ...
31
42
826
1,105
from scipy.sparse import csr_matrix from scipy.sparse.csgraph import floyd_warshall def solve(): N, M, L = list(map(int, input().split())) dist = [[0 for _ in range(N)] for _ in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) dist[a - 1][b - 1] = c dist[b - 1...
import sys sys.setrecursionlimit(10**7) rl = sys.stdin.readline def solve(): N, M, L = map(int, rl().split()) INF = 10**18 dist = [[INF] * N for _ in range(N)] for _ in range(M): a, b, c = map(int, rl().split()) a, b = a - 1, b - 1 dist[a][b] = dist[b][a] = c for k in rang...
false
26.190476
[ "-from scipy.sparse import csr_matrix", "-from scipy.sparse.csgraph import floyd_warshall", "+import sys", "+", "+sys.setrecursionlimit(10**7)", "+rl = sys.stdin.readline", "- N, M, L = list(map(int, input().split()))", "- dist = [[0 for _ in range(N)] for _ in range(N)]", "- for i in range...
false
0.548957
0.043372
12.656823
[ "s042524473", "s295199377" ]
u089230684
p03607
python
s919576611
s555859697
799
534
13,884
61,784
Accepted
Accepted
33.17
n = eval(input()) d = {} for x in range(n): temp = eval(input()) try: d[temp] = (d[temp] + 1) % 2 except: d[temp] = 1 print(sum(d.values()))
from collections import Counter N=int(eval(input())) r=[] while N>0: N-=1 r.append(int(eval(input()))) a=Counter(r) count=0 for i in a: count+= a[i]%2 print(count)
9
12
164
176
n = eval(input()) d = {} for x in range(n): temp = eval(input()) try: d[temp] = (d[temp] + 1) % 2 except: d[temp] = 1 print(sum(d.values()))
from collections import Counter N = int(eval(input())) r = [] while N > 0: N -= 1 r.append(int(eval(input()))) a = Counter(r) count = 0 for i in a: count += a[i] % 2 print(count)
false
25
[ "-n = eval(input())", "-d = {}", "-for x in range(n):", "- temp = eval(input())", "- try:", "- d[temp] = (d[temp] + 1) % 2", "- except:", "- d[temp] = 1", "-print(sum(d.values()))", "+from collections import Counter", "+", "+N = int(eval(input()))", "+r = []", "+whil...
false
0.046295
0.047743
0.969677
[ "s919576611", "s555859697" ]
u644907318
p03352
python
s837667824
s954453281
66
29
62,124
9,284
Accepted
Accepted
56.06
X = int(eval(input())) if X==1: print((1)) else: cmax = 1 for i in range(2,int(X**0.5)+1): k = 2 while i**k<=X: cmax = max(cmax,i**k) k += 1 print(cmax)
X = int(eval(input())) n = 1 if X<=3: print((1)) elif X==4: print((4)) else: n = 4 for i in range(2,int(X**0.5)+1): b = i k = 1 while b**k<=X: k += 1 k -= 1 if k>=2: n = max(n,b**k) print(n)
11
17
210
280
X = int(eval(input())) if X == 1: print((1)) else: cmax = 1 for i in range(2, int(X**0.5) + 1): k = 2 while i**k <= X: cmax = max(cmax, i**k) k += 1 print(cmax)
X = int(eval(input())) n = 1 if X <= 3: print((1)) elif X == 4: print((4)) else: n = 4 for i in range(2, int(X**0.5) + 1): b = i k = 1 while b**k <= X: k += 1 k -= 1 if k >= 2: n = max(n, b**k) print(n)
false
35.294118
[ "-if X == 1:", "+n = 1", "+if X <= 3:", "+elif X == 4:", "+ print((4))", "- cmax = 1", "+ n = 4", "- k = 2", "- while i**k <= X:", "- cmax = max(cmax, i**k)", "+ b = i", "+ k = 1", "+ while b**k <= X:", "- print(cmax)", "+ ...
false
0.046669
0.038373
1.21619
[ "s837667824", "s954453281" ]
u788703383
p02757
python
s901037011
s836718373
221
167
11,024
3,500
Accepted
Accepted
24.43
n,p = list(map(int,input().split())) s = eval(input()) num = 0 s1 = [0]*(n+1) ans = 0 if p == 2 or p == 5: for i in range(len(s)): if int(s[i])%p == 0: ans += i+1 print(ans) exit() ans = 0 arr = [0]*p s = s[::-1] z = 1 for i in range(n): s1[i+1] = s1[i] + int(s[i])*z z = z * 10 %p s1[i+1] ...
n,p = list(map(int,input().split())) ans = 0 s = eval(input()) if p == 2 or p == 5: for i in range(len(s)): n = int(s[i]) if n%p == 0: ans += i+1 print(ans) exit() r = [0]*p r[0] = 1 t = 1 z = 0 for i in reversed(s): z = int(i) * t + z t *= 10 t %...
25
25
425
387
n, p = list(map(int, input().split())) s = eval(input()) num = 0 s1 = [0] * (n + 1) ans = 0 if p == 2 or p == 5: for i in range(len(s)): if int(s[i]) % p == 0: ans += i + 1 print(ans) exit() ans = 0 arr = [0] * p s = s[::-1] z = 1 for i in range(n): s1[i + 1] = s1[i] + int(s[i]) * z ...
n, p = list(map(int, input().split())) ans = 0 s = eval(input()) if p == 2 or p == 5: for i in range(len(s)): n = int(s[i]) if n % p == 0: ans += i + 1 print(ans) exit() r = [0] * p r[0] = 1 t = 1 z = 0 for i in reversed(s): z = int(i) * t + z t *= 10 t %= p z %= ...
false
0
[ "+ans = 0", "-num = 0", "-s1 = [0] * (n + 1)", "-ans = 0", "- if int(s[i]) % p == 0:", "+ n = int(s[i])", "+ if n % p == 0:", "-ans = 0", "-arr = [0] * p", "-s = s[::-1]", "-z = 1", "-for i in range(n):", "- s1[i + 1] = s1[i] + int(s[i]) * z", "- z = z * 10 % p",...
false
0.00769
0.037156
0.206969
[ "s901037011", "s836718373" ]
u308684517
p03944
python
s041290057
s996451043
78
18
3,064
3,064
Accepted
Accepted
76.92
w, h, n = list(map(int, input().split())) rect = [] for i in range(h): rect.append([0 for _ in range(w)]) for i in range(n): x, y, a = list(map(int, input().split())) if a == 1: for i in range(h): for j in range(x): rect[i][j] = 1 elif a == 2: for i...
W, H, N = list(map(int, input().split())) min_x = 0 min_y = 0 w = W h = H for i in range(N): x, y, a = list(map(int, input().split())) if a == 1: min_x = max(min_x, x) elif a == 2: w = min(w, x) elif a == 3: min_y = max(min_y, y) elif a == 4: h = min(h, y) print(((w-min_x)*(h-min_y) if (w...
28
12
734
340
w, h, n = list(map(int, input().split())) rect = [] for i in range(h): rect.append([0 for _ in range(w)]) for i in range(n): x, y, a = list(map(int, input().split())) if a == 1: for i in range(h): for j in range(x): rect[i][j] = 1 elif a == 2: for i in range(h...
W, H, N = list(map(int, input().split())) min_x = 0 min_y = 0 w = W h = H for i in range(N): x, y, a = list(map(int, input().split())) if a == 1: min_x = max(min_x, x) elif a == 2: w = min(w, x) elif a == 3: min_y = max(min_y, y) elif a == 4: h = min(h, y) print(((w -...
false
57.142857
[ "-w, h, n = list(map(int, input().split()))", "-rect = []", "-for i in range(h):", "- rect.append([0 for _ in range(w)])", "-for i in range(n):", "+W, H, N = list(map(int, input().split()))", "+min_x = 0", "+min_y = 0", "+w = W", "+h = H", "+for i in range(N):", "- for i in range(h):...
false
0.043768
0.038943
1.123902
[ "s041290057", "s996451043" ]
u021548497
p02861
python
s736497239
s832407560
362
17
3,064
3,064
Accepted
Accepted
95.3
import itertools n = int(eval(input())) s = [0]*n for i in range(n): s[i] = list(int(x) for x in input().split()) key = [[False]*n for i in range(n)] for i in range(n): for j in range(i+1, n): key[i][j] = ((s[i][0]-s[j][0])**2+(s[i][1]-s[j][1])**2)**0.5 ans = 0 key_permnutation = list(in...
n = int(eval(input())) s = [0]*n for i in range(n): s[i] = list(int(x) for x in input().split()) key = [[0]*n for i in range(n)] ans = 0 for i in range(n): for j in range(i+1, n): ans = ans + ((s[i][0]-s[j][0])**2+(s[i][1]-s[j][1])**2)**0.5 ans = ans * 2 / n print(ans)
23
14
585
295
import itertools n = int(eval(input())) s = [0] * n for i in range(n): s[i] = list(int(x) for x in input().split()) key = [[False] * n for i in range(n)] for i in range(n): for j in range(i + 1, n): key[i][j] = ((s[i][0] - s[j][0]) ** 2 + (s[i][1] - s[j][1]) ** 2) ** 0.5 ans = 0 key_permnutation = list...
n = int(eval(input())) s = [0] * n for i in range(n): s[i] = list(int(x) for x in input().split()) key = [[0] * n for i in range(n)] ans = 0 for i in range(n): for j in range(i + 1, n): ans = ans + ((s[i][0] - s[j][0]) ** 2 + (s[i][1] - s[j][1]) ** 2) ** 0.5 ans = ans * 2 / n print(ans)
false
39.130435
[ "-import itertools", "-", "-key = [[False] * n for i in range(n)]", "+key = [[0] * n for i in range(n)]", "+ans = 0", "- key[i][j] = ((s[i][0] - s[j][0]) ** 2 + (s[i][1] - s[j][1]) ** 2) ** 0.5", "-ans = 0", "-key_permnutation = list(int(x) for x in range(n))", "-for key_list in itertools.per...
false
0.074465
0.041605
1.789813
[ "s736497239", "s832407560" ]
u827202523
p02973
python
s912967464
s344468705
633
108
52,440
78,580
Accepted
Accepted
82.94
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) from bisect import bisect_right n = getN() mx = [] k = 0 for i in range(n): num = -(getN()) ins = bisect_right(mx, num) if ins == k: ...
import sys # from collections import defaultdict, deque # import math # import copy from bisect import bisect_left, bisect_right # import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(eval(input())) getList = lambda: ...
22
42
417
858
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) from bisect import bisect_right n = getN() mx = [] k = 0 for i in range(n): num = -(getN()) ins = bisect_right(mx, num) if ins == k: mx.a...
import sys # from collections import defaultdict, deque # import math # import copy from bisect import bisect_left, bisect_right # import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(eval(input())) getList = lambda: list(map(int, i...
false
47.619048
[ "-def getN():", "- return int(eval(input()))", "+import sys", "+", "+# from collections import defaultdict, deque", "+# import math", "+# import copy", "+from bisect import bisect_left, bisect_right", "+", "+# import heapq", "+# sys.setrecursionlimit(1000000)", "+# input aliases", "+input...
false
0.073133
0.037101
1.971149
[ "s912967464", "s344468705" ]
u520276780
p02913
python
s208178643
s861611577
941
812
245,768
51,408
Accepted
Accepted
13.71
def main(): n = int(eval(input())) s = eval(input()) dp = [[0 for i in range(n+1)] for j in range(n+1)] from itertools import product for i,j in product(reversed(list(range(n))),repeat=2):###for を置き換え if j>i: continue if s[i]!=s[j]: dp[i][j] = 0...
#z-algolithm n = int(eval(input())) s_ = eval(input()) ans = 0 for i in range(n-2): l = 1 #1から r = 1 s = s_[i:] z = [0]*(n-i) z[0] = n-i while l<n-i: while r<n-i and s[r] == s[r-l] : #r<n r += 1 if r == l: r+=1;l+=1;continue z[l] =...
34
26
872
527
def main(): n = int(eval(input())) s = eval(input()) dp = [[0 for i in range(n + 1)] for j in range(n + 1)] from itertools import product for i, j in product(reversed(list(range(n))), repeat=2): ###for を置き換え if j > i: continue if s[i] != s[j]: dp[i][j] = 0 ...
# z-algolithm n = int(eval(input())) s_ = eval(input()) ans = 0 for i in range(n - 2): l = 1 # 1から r = 1 s = s_[i:] z = [0] * (n - i) z[0] = n - i while l < n - i: while r < n - i and s[r] == s[r - l]: # r<n r += 1 if r == l: r += 1 l += 1 ...
false
23.529412
[ "-def main():", "- n = int(eval(input()))", "- s = eval(input())", "- dp = [[0 for i in range(n + 1)] for j in range(n + 1)]", "- from itertools import product", "-", "- for i, j in product(reversed(list(range(n))), repeat=2): ###for を置き換え", "- if j > i:", "+# z-algolithm", ...
false
0.044114
0.047091
0.936778
[ "s208178643", "s861611577" ]
u832039789
p03064
python
s494892828
s557337807
2,682
2,317
143,948
157,576
Accepted
Accepted
13.61
M,z,s=998244353,1,0 N,*A=open(0) d=[1]+[0]*7**6 e=[1]+[0]*7**6 for a in A: a=int(a);s+=a;i=s;z*=3 while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a]%M;i-=1 print(((z+~s%2*e[s//2]*3-3*sum(d[-~s//2:]))%M))
M,s=998244353,0 d=[1]+[0]*7**6 e=d[:] n=eval(input()) for _ in'_'*n: a=eval(input());s+=a;i=s while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a]%M;i-=1 print((3**n+~s%2*e[s//2]*3-3*sum(d[-~s//2:]))%M)
8
8
200
185
M, z, s = 998244353, 1, 0 N, *A = open(0) d = [1] + [0] * 7**6 e = [1] + [0] * 7**6 for a in A: a = int(a) s += a i = s z *= 3 while ~i: d[i] += d[i] + d[i - a] % M e[i] += e[i - a] % M i -= 1 print(((z + ~s % 2 * e[s // 2] * 3 - 3 * sum(d[-~s // 2 :])) % M))
M, s = 998244353, 0 d = [1] + [0] * 7**6 e = d[:] n = eval(input()) for _ in "_" * n: a = eval(input()) s += a i = s while ~i: d[i] += d[i] + d[i - a] % M e[i] += e[i - a] % M i -= 1 print((3**n + ~s % 2 * e[s // 2] * 3 - 3 * sum(d[-~s // 2 :])) % M)
false
0
[ "-M, z, s = 998244353, 1, 0", "-N, *A = open(0)", "+M, s = 998244353, 0", "-e = [1] + [0] * 7**6", "-for a in A:", "- a = int(a)", "+e = d[:]", "+n = eval(input())", "+for _ in \"_\" * n:", "+ a = eval(input())", "- z *= 3", "-print(((z + ~s % 2 * e[s // 2] * 3 - 3 * sum(d[-~s // 2 :]...
false
0.04933
0.049297
1.000667
[ "s494892828", "s557337807" ]