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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u342869120 | p02625 | python | s028248376 | s634428052 | 89 | 67 | 102,856 | 64,032 | Accepted | Accepted | 24.72 | '''
完全順列(derangement)
モンモール数(Montmort number)
'''
MOD = 10**9+7
N, M = list(map(int, input().split()))
# 片方の順列の総数を求める
ans = 1
for i in range(N):
ans *= M-i
ans %= MOD
# M枚からN枚選ぶ完全順列を計算
d = [1, M-N]
for i in range(2, N+1):
# 1がk番目にある
# 1番目にkがある
t = (i-1)*d[-2] % MOD
# 1番目にk... | '''
完全順列(derangement)
モンモール数(Montmort number)
'''
MOD = 10**9+7
N, M = list(map(int, input().split()))
# 片方の順列の総数を求める
ans = 1
for i in range(N):
ans *= M-i
ans %= MOD
# M枚からN枚選ぶ完全順列を計算
d2, d1 = 1, M-N
d0 = d1
for i in range(2, N+1):
# 1がk番目にある
# 1番目にkがある
d0 = (i-1)*d2 % MOD
... | 25 | 27 | 393 | 411 | """
完全順列(derangement)
モンモール数(Montmort number)
"""
MOD = 10**9 + 7
N, M = list(map(int, input().split()))
# 片方の順列の総数を求める
ans = 1
for i in range(N):
ans *= M - i
ans %= MOD
# M枚からN枚選ぶ完全順列を計算
d = [1, M - N]
for i in range(2, N + 1):
# 1がk番目にある
# 1番目にkがある
t = (i - 1) * d[-2] % MOD
# 1番目にkがない
t +... | """
完全順列(derangement)
モンモール数(Montmort number)
"""
MOD = 10**9 + 7
N, M = list(map(int, input().split()))
# 片方の順列の総数を求める
ans = 1
for i in range(N):
ans *= M - i
ans %= MOD
# M枚からN枚選ぶ完全順列を計算
d2, d1 = 1, M - N
d0 = d1
for i in range(2, N + 1):
# 1がk番目にある
# 1番目にkがある
d0 = (i - 1) * d2 % MOD
# 1番目にkがな... | false | 7.407407 | [
"-d = [1, M - N]",
"+d2, d1 = 1, M - N",
"+d0 = d1",
"- t = (i - 1) * d[-2] % MOD",
"+ d0 = (i - 1) * d2 % MOD",
"- t += (M - N + i - 1) * d[-1] % MOD",
"- d.append(t)",
"-print((ans * d[-1] % MOD))",
"+ d0 += (M - N + i - 1) * d1",
"+ d0 %= MOD",
"+ d2, d1 = d1, d0",
"+pr... | false | 0.103423 | 0.067802 | 1.525356 | [
"s028248376",
"s634428052"
] |
u054514819 | p03112 | python | s007914891 | s981895170 | 997 | 754 | 115,324 | 101,872 | Accepted | Accepted | 24.37 | import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
A, B, Q = mapint()
Ss = [-10**20]+[int(eval(input())) for _ in range(A)]+[10**20]
Ts = [-10**20]+[int(eval(input())) for _ in range(B)]+[10**20]
Ss.sort()
Ts.sort()
fr... | import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
A, B, Q = mapint()
Ss = [-10**18]+[int(eval(input())) for _ in range(A)]+[10**18]
Ts = [-10**18]+[int(eval(input())) for _ in range(B)]+[10**18]
from bisect import bisec... | 22 | 17 | 698 | 588 | import sys
def input():
return sys.stdin.readline().strip()
def mapint():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
A, B, Q = mapint()
Ss = [-(10**20)] + [int(eval(input())) for _ in range(A)] + [10**20]
Ts = [-(10**20)] + [int(eval(input())) for _ in range(B)] + [10**20]
Ss.sort... | import sys
def input():
return sys.stdin.readline().strip()
def mapint():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
A, B, Q = mapint()
Ss = [-(10**18)] + [int(eval(input())) for _ in range(A)] + [10**18]
Ts = [-(10**18)] + [int(eval(input())) for _ in range(B)] + [10**18]
from bi... | false | 22.727273 | [
"-Ss = [-(10**20)] + [int(eval(input())) for _ in range(A)] + [10**20]",
"-Ts = [-(10**20)] + [int(eval(input())) for _ in range(B)] + [10**20]",
"-Ss.sort()",
"-Ts.sort()",
"+Ss = [-(10**18)] + [int(eval(input())) for _ in range(A)] + [10**18]",
"+Ts = [-(10**18)] + [int(eval(input())) for _ in range(B)]... | false | 0.042228 | 0.039442 | 1.070635 | [
"s007914891",
"s981895170"
] |
u532966492 | p02736 | python | s695814341 | s705516573 | 866 | 783 | 30,640 | 28,896 | Accepted | Accepted | 9.58 | def main():
n = int(eval(input()))
a = list([int(x)-1 for x in list(eval(input()))])
b = [i % 2 for i in a]
def all_a(x):
ans = 0
for j, i in enumerate(x):
ans ^= (n-1 | j == n-1)*i
return ans
all_b = all_a(b)
if all_b == 1:
print((1))
... | n,a=int(eval(input()))-1,list([int(x)-1 for x in list(eval(input()))]);b=[i%2for i in a]
def c(x):
a=0
for j,i in enumerate(x):a^=(n|j==n)*i
return a
if c(b):k=1
elif 1in a:k=0
else:k=c([i//2for i in a])*2
print(k) | 23 | 9 | 437 | 216 | def main():
n = int(eval(input()))
a = list([int(x) - 1 for x in list(eval(input()))])
b = [i % 2 for i in a]
def all_a(x):
ans = 0
for j, i in enumerate(x):
ans ^= (n - 1 | j == n - 1) * i
return ans
all_b = all_a(b)
if all_b == 1:
print((1))
... | n, a = int(eval(input())) - 1, list([int(x) - 1 for x in list(eval(input()))])
b = [i % 2 for i in a]
def c(x):
a = 0
for j, i in enumerate(x):
a ^= (n | j == n) * i
return a
if c(b):
k = 1
elif 1 in a:
k = 0
else:
k = c([i // 2 for i in a]) * 2
print(k)
| false | 60.869565 | [
"-def main():",
"- n = int(eval(input()))",
"- a = list([int(x) - 1 for x in list(eval(input()))])",
"- b = [i % 2 for i in a]",
"-",
"- def all_a(x):",
"- ans = 0",
"- for j, i in enumerate(x):",
"- ans ^= (n - 1 | j == n - 1) * i",
"- return ans",
"-... | false | 0.036564 | 0.03559 | 1.027358 | [
"s695814341",
"s705516573"
] |
u718949306 | p03281 | python | s807265674 | s687586582 | 22 | 19 | 2,940 | 2,940 | Accepted | Accepted | 13.64 | N = int(eval(input()))
ans = 0
for i in range(1, N + 1):
res = 0
for q in range(1, N + 1):
if i % 2 != 0:
if i % q == 0:
res += 1
if res == 8:
ans += 1
print(ans) | N = int(eval(input()))
ans = 0
for n in range(1, N+1):
cnt = 0
if n % 2 == 1:
for i in range(1, N+1):
if n % i == 0:
cnt += 1
if cnt == 8:
ans += 1
print(ans) | 13 | 11 | 226 | 218 | N = int(eval(input()))
ans = 0
for i in range(1, N + 1):
res = 0
for q in range(1, N + 1):
if i % 2 != 0:
if i % q == 0:
res += 1
if res == 8:
ans += 1
print(ans)
| N = int(eval(input()))
ans = 0
for n in range(1, N + 1):
cnt = 0
if n % 2 == 1:
for i in range(1, N + 1):
if n % i == 0:
cnt += 1
if cnt == 8:
ans += 1
print(ans)
| false | 15.384615 | [
"-for i in range(1, N + 1):",
"- res = 0",
"- for q in range(1, N + 1):",
"- if i % 2 != 0:",
"- if i % q == 0:",
"- res += 1",
"- if res == 8:",
"+for n in range(1, N + 1):",
"+ cnt = 0",
"+ if n % 2 == 1:",
"+ for i in range(1, N + 1):",
... | false | 0.084876 | 0.038131 | 2.225933 | [
"s807265674",
"s687586582"
] |
u998741086 | p03807 | python | s997228128 | s991998403 | 65 | 54 | 19,932 | 19,964 | Accepted | Accepted | 16.92 | #!/usr/bin/env python
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
if a[i]%2 == 1:
cnt += 1
if cnt%2 == 0:
print('YES')
else:
print('NO')
| #!/usr/bin/env python
n = int(eval(input()))
a = list(map(int, input().split()))
if sum(a)%2 == 0:
print('YES')
else:
print('NO')
| 15 | 9 | 212 | 142 | #!/usr/bin/env python
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
if a[i] % 2 == 1:
cnt += 1
if cnt % 2 == 0:
print("YES")
else:
print("NO")
| #!/usr/bin/env python
n = int(eval(input()))
a = list(map(int, input().split()))
if sum(a) % 2 == 0:
print("YES")
else:
print("NO")
| false | 40 | [
"-cnt = 0",
"-for i in range(n):",
"- if a[i] % 2 == 1:",
"- cnt += 1",
"-if cnt % 2 == 0:",
"+if sum(a) % 2 == 0:"
] | false | 0.104052 | 0.076557 | 1.359144 | [
"s997228128",
"s991998403"
] |
u536600145 | p02629 | python | s403055205 | s585719106 | 81 | 67 | 61,780 | 61,812 | Accepted | Accepted | 17.28 | N = int(eval(input()))
alphabets = {i: chr(i + 96) for i in range(1, 26)}
alphabets[0] = 'z'
queue = []
if N <= 26:
print((alphabets[N]))
else:
while N > 0:
queue.insert(0, alphabets[N % 26])
N -= 1
N //= 26
print((''.join(queue))) | N = int(eval(input()))
alphabets = {i: chr(i + 96) for i in range(1, 26)}
alphabets[0] = 'z'
queue = []
while N > 0:
queue.insert(0, alphabets[N % 26])
N -= 1
N //= 26
print((''.join(queue))) | 14 | 12 | 272 | 209 | N = int(eval(input()))
alphabets = {i: chr(i + 96) for i in range(1, 26)}
alphabets[0] = "z"
queue = []
if N <= 26:
print((alphabets[N]))
else:
while N > 0:
queue.insert(0, alphabets[N % 26])
N -= 1
N //= 26
print(("".join(queue)))
| N = int(eval(input()))
alphabets = {i: chr(i + 96) for i in range(1, 26)}
alphabets[0] = "z"
queue = []
while N > 0:
queue.insert(0, alphabets[N % 26])
N -= 1
N //= 26
print(("".join(queue)))
| false | 14.285714 | [
"-if N <= 26:",
"- print((alphabets[N]))",
"-else:",
"- while N > 0:",
"- queue.insert(0, alphabets[N % 26])",
"- N -= 1",
"- N //= 26",
"- print((\"\".join(queue)))",
"+while N > 0:",
"+ queue.insert(0, alphabets[N % 26])",
"+ N -= 1",
"+ N //= 26",
"+... | false | 0.045112 | 0.03871 | 1.165374 | [
"s403055205",
"s585719106"
] |
u047796752 | p03628 | python | s138932495 | s884647785 | 182 | 97 | 38,256 | 61,836 | Accepted | Accepted | 46.7 | import sys
input = sys.stdin.readline
from collections import *
N = int(eval(input()))
S1 = input()[:-1]
S2 = input()[:-1]
i = 0
ans = 1
MOD = 10**9+7
while i<N:
if S1[i]==S2[i]:
if i==0:
ans *= 3
ans %= MOD
else:
if flag==0:
an... | N = int(eval(input()))
S1 = eval(input())
S2 = eval(input())
ans = 1
MOD = 10**9+7
i = 0
flag = True
while i<N:
if S1[i]==S2[i]:
if i==0:
ans *= 3
else:
if flag:
ans *= 2
i += 1
flag = True
else:
if i==0... | 38 | 33 | 668 | 517 | import sys
input = sys.stdin.readline
from collections import *
N = int(eval(input()))
S1 = input()[:-1]
S2 = input()[:-1]
i = 0
ans = 1
MOD = 10**9 + 7
while i < N:
if S1[i] == S2[i]:
if i == 0:
ans *= 3
ans %= MOD
else:
if flag == 0:
ans *= 2
... | N = int(eval(input()))
S1 = eval(input())
S2 = eval(input())
ans = 1
MOD = 10**9 + 7
i = 0
flag = True
while i < N:
if S1[i] == S2[i]:
if i == 0:
ans *= 3
else:
if flag:
ans *= 2
i += 1
flag = True
else:
if i == 0:
ans *... | false | 13.157895 | [
"-import sys",
"-",
"-input = sys.stdin.readline",
"-from collections import *",
"-",
"-S1 = input()[:-1]",
"-S2 = input()[:-1]",
"-i = 0",
"+S1 = eval(input())",
"+S2 = eval(input())",
"+i = 0",
"+flag = True",
"- ans %= MOD",
"- if flag == 0:",
"+ if fl... | false | 0.047595 | 0.046109 | 1.032208 | [
"s138932495",
"s884647785"
] |
u325227960 | p02781 | python | s841931257 | s434067881 | 193 | 166 | 38,384 | 38,356 | Accepted | Accepted | 13.99 | n = eval(input())
kk = int(eval(input()))
mod = 10**9 + 7
l = 2*10**2
M = [1] # i!のmod
m = 1
for i in range(1, l):
m = (m * i) % mod
M.append(m)
def pow(x, y, mod): # x**y の mod を返す関数
ans = 1
while y > 0:
if y % 2 == 1:
ans = (ans * x) % mod
x = (x**2) %... | n = eval(input())
k = int(eval(input()))
D = [[[0] * (k+1) for i in range(len(n))] for j in range(2)]
D[0][0][0] = 1
D[0][0][1] = int(n[0]) - 1
D[1][0][1] = 1
kk = 1
for i in range(1, len(n)):
D[0][i][0] = D[0][i-1][0]
for j in range(1, k+1):
D[0][i][j] += D[0][i-1][j-1] * 9 + D[0][i-1][... | 50 | 27 | 1,000 | 667 | n = eval(input())
kk = int(eval(input()))
mod = 10**9 + 7
l = 2 * 10**2
M = [1] # i!のmod
m = 1
for i in range(1, l):
m = (m * i) % mod
M.append(m)
def pow(x, y, mod): # x**y の mod を返す関数
ans = 1
while y > 0:
if y % 2 == 1:
ans = (ans * x) % mod
x = (x**2) % mod
y /... | n = eval(input())
k = int(eval(input()))
D = [[[0] * (k + 1) for i in range(len(n))] for j in range(2)]
D[0][0][0] = 1
D[0][0][1] = int(n[0]) - 1
D[1][0][1] = 1
kk = 1
for i in range(1, len(n)):
D[0][i][0] = D[0][i - 1][0]
for j in range(1, k + 1):
D[0][i][j] += D[0][i - 1][j - 1] * 9 + D[0][i - 1][j]
... | false | 46 | [
"-kk = int(eval(input()))",
"-mod = 10**9 + 7",
"-l = 2 * 10**2",
"-M = [1] # i!のmod",
"-m = 1",
"-for i in range(1, l):",
"- m = (m * i) % mod",
"- M.append(m)",
"-",
"-",
"-def pow(x, y, mod): # x**y の mod を返す関数",
"- ans = 1",
"- while y > 0:",
"- if y % 2 == 1:",
... | false | 0.039266 | 0.0418 | 0.939374 | [
"s841931257",
"s434067881"
] |
u164474813 | p03062 | python | s510146712 | s605022457 | 95 | 87 | 14,332 | 14,332 | Accepted | Accepted | 8.42 | n = int(eval(input()))
A = list(map(int, input().split()))
mina = abs(A[0])
minus = 0
sumA = 0
for a in A:
if a < 0:
minus += 1
a = -a
sumA += a
mina = min(a, mina)
if minus % 2 == 1:
sumA -= 2 * mina
print(sumA) | n = int(eval(input()))
A = list(map(int, input().split()))
mina = 10**9
minus = 0
sumA = 0
for a in A:
if a < 0:
minus += 1
a = -a
sumA += a
mina = min(a, mina)
if minus % 2 == 1:
sumA -= 2 * mina
print(sumA) | 14 | 14 | 251 | 247 | n = int(eval(input()))
A = list(map(int, input().split()))
mina = abs(A[0])
minus = 0
sumA = 0
for a in A:
if a < 0:
minus += 1
a = -a
sumA += a
mina = min(a, mina)
if minus % 2 == 1:
sumA -= 2 * mina
print(sumA)
| n = int(eval(input()))
A = list(map(int, input().split()))
mina = 10**9
minus = 0
sumA = 0
for a in A:
if a < 0:
minus += 1
a = -a
sumA += a
mina = min(a, mina)
if minus % 2 == 1:
sumA -= 2 * mina
print(sumA)
| false | 0 | [
"-mina = abs(A[0])",
"+mina = 10**9"
] | false | 0.088145 | 0.156615 | 0.562812 | [
"s510146712",
"s605022457"
] |
u585482323 | p03298 | python | s860877956 | s035892734 | 2,618 | 657 | 102,028 | 113,884 | Accepted | Accepted | 74.9 | #!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline()... | #!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline()... | 96 | 92 | 1,793 | 1,690 | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
return [list(x) for x in sys.stdin... | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
return [list(x) for x in sys.stdin... | false | 4.166667 | [
"- d = defaultdict(lambda: 0)",
"- alp = list(\"abcdefghijklmnopqrstuvwxyz\")",
"- f = {}",
"- for i in range(26):",
"- f[alp[i]] = i + 1",
"- s[i] = f[s[i]]",
"+ s[i] = ord(s[i]) - 96",
"+ d = defaultdict(lambda: 0)"
] | false | 0.236556 | 0.424699 | 0.556998 | [
"s860877956",
"s035892734"
] |
u549211107 | p02887 | python | s409446118 | s142110731 | 34 | 24 | 3,316 | 3,316 | Accepted | Accepted | 29.41 | N=int(eval(input()))
S=str(eval(input()))
c=''
t=0
for s in S:
if s==c:continue
t+=1
c=s
print(t) | def T():
N=int(eval(input()))
S=eval(input())
c=''
t=0
for s in S:
if s==c:
t+=1
c=s
return(N-t)
print((T())) | 9 | 11 | 105 | 157 | N = int(eval(input()))
S = str(eval(input()))
c = ""
t = 0
for s in S:
if s == c:
continue
t += 1
c = s
print(t)
| def T():
N = int(eval(input()))
S = eval(input())
c = ""
t = 0
for s in S:
if s == c:
t += 1
c = s
return N - t
print((T()))
| false | 18.181818 | [
"-N = int(eval(input()))",
"-S = str(eval(input()))",
"-c = \"\"",
"-t = 0",
"-for s in S:",
"- if s == c:",
"- continue",
"- t += 1",
"- c = s",
"-print(t)",
"+def T():",
"+ N = int(eval(input()))",
"+ S = eval(input())",
"+ c = \"\"",
"+ t = 0",
"+ for ... | false | 0.079504 | 0.056862 | 1.398186 | [
"s409446118",
"s142110731"
] |
u790710233 | p03681 | python | s706642791 | s064891307 | 63 | 36 | 3,064 | 3,060 | Accepted | Accepted | 42.86 | n, m = list(map(int, input().split()))
INF = 10**9+7
if abs(n-m) > 1:
print((0))
else:
nf = 1
for i in range(1, n+1):
nf *= i
nf %= INF
mf = 1
for i in range(1, m+1):
mf *= i
mf %= INF
if n == m:
print((nf * mf * 2 % INF))
else:
... | n, m = list(map(int, input().split()))
MOD = 10**9+7
if abs(n-m) > 1:
print((0))
else:
nf, mf = 1, 1
for i in range(1, min(n, m)+1):
nf = (nf*i) % MOD
if n != m:
mf = max(n, m) * nf
else:
mf = nf
if n == m:
print((nf * mf * 2 % MOD))
else:
... | 20 | 19 | 337 | 339 | n, m = list(map(int, input().split()))
INF = 10**9 + 7
if abs(n - m) > 1:
print((0))
else:
nf = 1
for i in range(1, n + 1):
nf *= i
nf %= INF
mf = 1
for i in range(1, m + 1):
mf *= i
mf %= INF
if n == m:
print((nf * mf * 2 % INF))
else:
print((... | n, m = list(map(int, input().split()))
MOD = 10**9 + 7
if abs(n - m) > 1:
print((0))
else:
nf, mf = 1, 1
for i in range(1, min(n, m) + 1):
nf = (nf * i) % MOD
if n != m:
mf = max(n, m) * nf
else:
mf = nf
if n == m:
print((nf * mf * 2 % MOD))
else:
prin... | false | 5 | [
"-INF = 10**9 + 7",
"+MOD = 10**9 + 7",
"- nf = 1",
"- for i in range(1, n + 1):",
"- nf *= i",
"- nf %= INF",
"- mf = 1",
"- for i in range(1, m + 1):",
"- mf *= i",
"- mf %= INF",
"+ nf, mf = 1, 1",
"+ for i in range(1, min(n, m) + 1):",
"+ ... | false | 0.039847 | 0.063127 | 0.631216 | [
"s706642791",
"s064891307"
] |
u852690916 | p03356 | python | s531103615 | s296007967 | 699 | 490 | 88,812 | 13,876 | Accepted | Accepted | 29.9 | N,M=list(map(int, input().split()))
P=[0]+list(map(int, input().split()))
E=[[] for _ in range(N+1)]
for _ in range(M):
x,y=list(map(int, input().split()))
E[x].append(y)
E[y].append(x)
ans=[0]*(N+1)
parent=[0]*(N+1)
for root in range(1,N+1):
if parent[root]: continue
parent[root]=roo... | import sys
def main():
input = sys.stdin.readline
N, M = list(map(int, input().split()))
P = list([int(x)-1 for x in input().split()])
uf = UnionFindTree(N)
for _ in range(M):
x,y = list(map(int, input().split()))
uf.union(x-1,y-1)
ind = [-1] * N
for i in ra... | 29 | 42 | 649 | 1,032 | N, M = list(map(int, input().split()))
P = [0] + list(map(int, input().split()))
E = [[] for _ in range(N + 1)]
for _ in range(M):
x, y = list(map(int, input().split()))
E[x].append(y)
E[y].append(x)
ans = [0] * (N + 1)
parent = [0] * (N + 1)
for root in range(1, N + 1):
if parent[root]:
continu... | import sys
def main():
input = sys.stdin.readline
N, M = list(map(int, input().split()))
P = list([int(x) - 1 for x in input().split()])
uf = UnionFindTree(N)
for _ in range(M):
x, y = list(map(int, input().split()))
uf.union(x - 1, y - 1)
ind = [-1] * N
for i in range(N):
... | false | 30.952381 | [
"-N, M = list(map(int, input().split()))",
"-P = [0] + list(map(int, input().split()))",
"-E = [[] for _ in range(N + 1)]",
"-for _ in range(M):",
"- x, y = list(map(int, input().split()))",
"- E[x].append(y)",
"- E[y].append(x)",
"-ans = [0] * (N + 1)",
"-parent = [0] * (N + 1)",
"-for r... | false | 0.039573 | 0.088023 | 0.449573 | [
"s531103615",
"s296007967"
] |
u941438707 | p03625 | python | s681510580 | s708961766 | 110 | 100 | 14,052 | 14,052 | Accepted | Accepted | 9.09 | n,*a=list(map(int,open(0).read().split()))
a.sort(reverse=True)
for i in range(1,n):
if a[i]==a[i-1]:
a[i]=0
else:
a[i-1]=0
a.sort()
print((a[-1]*a[-2])) | n,*a=list(map(int,open(0).read().split()))
a.sort()
x,y,i=0,0,0
while i<n:
if a[i-1]==a[i]:
x,y=y,a[i]
i+=1
i+=1
print((x*y)) | 9 | 9 | 177 | 137 | n, *a = list(map(int, open(0).read().split()))
a.sort(reverse=True)
for i in range(1, n):
if a[i] == a[i - 1]:
a[i] = 0
else:
a[i - 1] = 0
a.sort()
print((a[-1] * a[-2]))
| n, *a = list(map(int, open(0).read().split()))
a.sort()
x, y, i = 0, 0, 0
while i < n:
if a[i - 1] == a[i]:
x, y = y, a[i]
i += 1
i += 1
print((x * y))
| false | 0 | [
"-a.sort(reverse=True)",
"-for i in range(1, n):",
"- if a[i] == a[i - 1]:",
"- a[i] = 0",
"- else:",
"- a[i - 1] = 0",
"-print((a[-1] * a[-2]))",
"+x, y, i = 0, 0, 0",
"+while i < n:",
"+ if a[i - 1] == a[i]:",
"+ x, y = y, a[i]",
"+ i += 1",
"+ i += ... | false | 0.038253 | 0.104928 | 0.364569 | [
"s681510580",
"s708961766"
] |
u345966487 | p03986 | python | s028141425 | s419050910 | 196 | 47 | 61,808 | 4,840 | Accepted | Accepted | 76.02 | X = list(eval(input()))
N = len(X)
NHALF = N // 2
def solve():
nt, ns = 0, 0
for i in range(N):
if X[i] == 'S':
ns += 1
elif ns > 0:
ns -= 1
else:
nt += 1
return nt + ns
print((solve())) | X = list(eval(input()))
nt, ns = 0, 0
for x in X:
if x == 'S':
ns += 1
elif ns > 0:
ns -= 1
else:
nt += 1
print((nt+ns))
| 17 | 10 | 269 | 158 | X = list(eval(input()))
N = len(X)
NHALF = N // 2
def solve():
nt, ns = 0, 0
for i in range(N):
if X[i] == "S":
ns += 1
elif ns > 0:
ns -= 1
else:
nt += 1
return nt + ns
print((solve()))
| X = list(eval(input()))
nt, ns = 0, 0
for x in X:
if x == "S":
ns += 1
elif ns > 0:
ns -= 1
else:
nt += 1
print((nt + ns))
| false | 41.176471 | [
"-N = len(X)",
"-NHALF = N // 2",
"-",
"-",
"-def solve():",
"- nt, ns = 0, 0",
"- for i in range(N):",
"- if X[i] == \"S\":",
"- ns += 1",
"- elif ns > 0:",
"- ns -= 1",
"- else:",
"- nt += 1",
"- return nt + ns",
"-",
"-"... | false | 0.036628 | 0.08606 | 0.425614 | [
"s028141425",
"s419050910"
] |
u729133443 | p03287 | python | s473826022 | s030995031 | 408 | 99 | 16,100 | 16,100 | Accepted | Accepted | 75.74 | import math
n,m=list(map(int,input().split()))
b=0
c={}
for a in input().split():
b+=int(a)
c[b%m]=c.get(b%m,0)+1
print((sum([math.factorial(x)//(math.factorial(x-2)*math.factorial(2))if x>1else 0 for x in list(c.values())])+c.get(0,0))) | n,m=list(map(int,input().split()));d={0:1};r=s=0
for i in input().split():s+=int(i);s%=m;x=d.get(s,0);r+=x;d[s]=x+1
print(r) | 8 | 3 | 237 | 120 | import math
n, m = list(map(int, input().split()))
b = 0
c = {}
for a in input().split():
b += int(a)
c[b % m] = c.get(b % m, 0) + 1
print(
(
sum(
[
math.factorial(x) // (math.factorial(x - 2) * math.factorial(2))
if x > 1
else 0
... | n, m = list(map(int, input().split()))
d = {0: 1}
r = s = 0
for i in input().split():
s += int(i)
s %= m
x = d.get(s, 0)
r += x
d[s] = x + 1
print(r)
| false | 62.5 | [
"-import math",
"-",
"-b = 0",
"-c = {}",
"-for a in input().split():",
"- b += int(a)",
"- c[b % m] = c.get(b % m, 0) + 1",
"-print(",
"- (",
"- sum(",
"- [",
"- math.factorial(x) // (math.factorial(x - 2) * math.factorial(2))",
"- if... | false | 0.038071 | 0.036133 | 1.053653 | [
"s473826022",
"s030995031"
] |
u864197622 | p02793 | python | s812125070 | s334323554 | 810 | 290 | 42,332 | 48,988 | Accepted | Accepted | 64.2 | from functools import reduce
def gcd(a, b):
while b: a, b = b, a % b
return a
def lcm(a, b):
return b//gcd(a, b)*a
P = 10**9+7
N = int(eval(input()))
A = [int(a) for a in input().split()]
print((reduce(lcm, A) % P * sum([pow(a, P-2, P) for a in A]) % P)) | def primeFactor(N):
i, n, ret, d, sq = 2, N, {}, 2, 99
while i <= sq:
k = 0
while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
if i < 4: i = i * 2 - 1
else: i, d = i+d, d^6
if n > 1: ret[n] = 1
return ret
P = 10... | 11 | 28 | 269 | 649 | from functools import reduce
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return b // gcd(a, b) * a
P = 10**9 + 7
N = int(eval(input()))
A = [int(a) for a in input().split()]
print((reduce(lcm, A) % P * sum([pow(a, P - 2, P) for a in A]) % P))
| def primeFactor(N):
i, n, ret, d, sq = 2, N, {}, 2, 99
while i <= sq:
k = 0
while n % i == 0:
n, k, ret[i] = n // i, k + 1, k + 1
if k > 0 or i == 97:
sq = int(n ** (1 / 2) + 0.5)
if i < 4:
i = i * 2 - 1
else:
i, d = i + d, ... | false | 60.714286 | [
"-from functools import reduce",
"-",
"-",
"-def gcd(a, b):",
"- while b:",
"- a, b = b, a % b",
"- return a",
"-",
"-",
"-def lcm(a, b):",
"- return b // gcd(a, b) * a",
"+def primeFactor(N):",
"+ i, n, ret, d, sq = 2, N, {}, 2, 99",
"+ while i <= sq:",
"+ k... | false | 0.034876 | 0.070198 | 0.496816 | [
"s812125070",
"s334323554"
] |
u835482198 | p03814 | python | s257990302 | s630842136 | 35 | 18 | 3,516 | 3,500 | Accepted | Accepted | 48.57 | # https://atcoder.jp/contests/abc053/tasks/abc053_b
s = eval(input())
n = len(s)
for i in range(n):
if s[i] == 'A':
start = i
break
for i in range(n - 1, -1, -1):
if s[i] == 'Z':
end = i
break
print((end + 1 - start))
| s = eval(input())
n = len(s)
start = s.index('A')
end = n - s[::-1].index('Z')
print((len(s[start:end])))
| 15 | 5 | 267 | 102 | # https://atcoder.jp/contests/abc053/tasks/abc053_b
s = eval(input())
n = len(s)
for i in range(n):
if s[i] == "A":
start = i
break
for i in range(n - 1, -1, -1):
if s[i] == "Z":
end = i
break
print((end + 1 - start))
| s = eval(input())
n = len(s)
start = s.index("A")
end = n - s[::-1].index("Z")
print((len(s[start:end])))
| false | 66.666667 | [
"-# https://atcoder.jp/contests/abc053/tasks/abc053_b",
"-for i in range(n):",
"- if s[i] == \"A\":",
"- start = i",
"- break",
"-for i in range(n - 1, -1, -1):",
"- if s[i] == \"Z\":",
"- end = i",
"- break",
"-print((end + 1 - start))",
"+start = s.index(\"A\"... | false | 0.086028 | 0.086587 | 0.993545 | [
"s257990302",
"s630842136"
] |
u427344224 | p03221 | python | s035562042 | s282900407 | 1,023 | 683 | 52,288 | 36,180 | Accepted | Accepted | 33.24 | N, M = list(map(int, input().split()))
shi_map = []
for i in range(M):
p, y = list(map(int, input().split()))
shi_map.append([i, p, y])
shi_map = sorted(shi_map, key=lambda x: (x[1], x[2]))
result = {}
shi_count = {}
for i, p, y in shi_map:
if p in shi_count:
c = shi_count[p]
... | N, M = list(map(int, input().split()))
items = []
for i in range(M):
p, y = list(map(int, input().split()))
items.append((p, y, i))
items = sorted(items, key=lambda x:(x[0], x[1]))
ans = {}
ken = -1
cnt = 1
for item in items:
if item[0] != ken:
cnt = 1
ans[item[2]] = str(it... | 31 | 23 | 612 | 503 | N, M = list(map(int, input().split()))
shi_map = []
for i in range(M):
p, y = list(map(int, input().split()))
shi_map.append([i, p, y])
shi_map = sorted(shi_map, key=lambda x: (x[1], x[2]))
result = {}
shi_count = {}
for i, p, y in shi_map:
if p in shi_count:
c = shi_count[p]
count = c + 1
... | N, M = list(map(int, input().split()))
items = []
for i in range(M):
p, y = list(map(int, input().split()))
items.append((p, y, i))
items = sorted(items, key=lambda x: (x[0], x[1]))
ans = {}
ken = -1
cnt = 1
for item in items:
if item[0] != ken:
cnt = 1
ans[item[2]] = str(item[0]).zfill(6) +... | false | 25.806452 | [
"-shi_map = []",
"+items = []",
"- shi_map.append([i, p, y])",
"-shi_map = sorted(shi_map, key=lambda x: (x[1], x[2]))",
"-result = {}",
"-shi_count = {}",
"-for i, p, y in shi_map:",
"- if p in shi_count:",
"- c = shi_count[p]",
"- count = c + 1",
"- shi_count[p] = co... | false | 0.049339 | 0.048548 | 1.016288 | [
"s035562042",
"s282900407"
] |
u588341295 | p03946 | python | s728689098 | s759482629 | 152 | 91 | 15,164 | 15,020 | Accepted | Accepted | 40.13 | # -*- coding: utf-8 -*-
import sys
import re
from collections import deque, Counter, defaultdict
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, product, com... | # -*- coding: utf-8 -*-
"""
参考:https://atcoder.jp/contests/abc047/submissions/4077573
"""
import sys
import re
from collections import deque, Counter, defaultdict
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bise... | 44 | 44 | 1,210 | 1,173 | # -*- coding: utf-8 -*-
import sys
import re
from collections import deque, Counter, defaultdict
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, product, combinations... | # -*- coding: utf-8 -*-
"""
参考:https://atcoder.jp/contests/abc047/submissions/4077573
"""
import sys
import re
from collections import deque, Counter, defaultdict
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bise... | false | 0 | [
"+\"\"\"",
"+参考:https://atcoder.jp/contests/abc047/submissions/4077573",
"+\"\"\"",
"-l, r = 0, 1",
"+l = aN[0]",
"-# 外ループで左を動かす",
"-while l < N:",
"- # 内ループは条件を満たす限り右を動かす",
"- while r < N and aN[l] < aN[r]:",
"+for i in range(1, N):",
"+ # 最低値更新なら始点を動かす",
"+ if aN[i] < l:",
"+ ... | false | 0.054533 | 0.039283 | 1.388192 | [
"s728689098",
"s759482629"
] |
u645250356 | p03221 | python | s640607435 | s972526917 | 838 | 682 | 104,988 | 37,312 | Accepted | Accepted | 18.62 | 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
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.rea... | 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
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.rea... | 32 | 31 | 854 | 810 | 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
mod2 = 998244353
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(in... | 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
mod2 = 998244353
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(in... | false | 3.125 | [
"-p.sort(key=lambda x: x[1])",
"-p.sort(key=lambda x: x[0])",
"+p.sort()"
] | false | 0.146398 | 0.195886 | 0.747362 | [
"s640607435",
"s972526917"
] |
u150984829 | p00506 | python | s667124829 | s152148653 | 1,010 | 20 | 5,604 | 5,600 | Accepted | Accepted | 98.02 | input()
n=list(map(int,input().split()))
[print(x)for x in range(1,min(n)+1)if sum(m%x for m in n)==0]
| n=int(input())
s=list(map(int,input().split()))
a,b=s[:2]
while b:a,b=b,a%b
if n-2:
b=s[2]
while b:a,b=b,a%b
[print(x)for x in range(1,a+1)if a%x==0]
| 3 | 8 | 105 | 159 | input()
n = list(map(int, input().split()))
[print(x) for x in range(1, min(n) + 1) if sum(m % x for m in n) == 0]
| n = int(input())
s = list(map(int, input().split()))
a, b = s[:2]
while b:
a, b = b, a % b
if n - 2:
b = s[2]
while b:
a, b = b, a % b
[print(x) for x in range(1, a + 1) if a % x == 0]
| false | 62.5 | [
"-input()",
"-n = list(map(int, input().split()))",
"-[print(x) for x in range(1, min(n) + 1) if sum(m % x for m in n) == 0]",
"+n = int(input())",
"+s = list(map(int, input().split()))",
"+a, b = s[:2]",
"+while b:",
"+ a, b = b, a % b",
"+if n - 2:",
"+ b = s[2]",
"+ while b:",
"+ ... | false | 0.08105 | 0.038578 | 2.100915 | [
"s667124829",
"s152148653"
] |
u905203728 | p03835 | python | s691402242 | s794231783 | 1,578 | 1,233 | 3,060 | 2,940 | Accepted | Accepted | 21.86 | k,s=list(map(int,input().split()))
cnt=0
for x in range(k+1):
for y in range(k+1):
z=s-x-y
if 0<=z<=k:
cnt +=1
print(cnt) | k,s=list(map(int,input().split()))
cnt=0
for i in range(k+1):
for j in range(k+1):
if 0<=(s-i-j)<=k:cnt +=1
print(cnt) | 8 | 6 | 154 | 129 | k, s = list(map(int, input().split()))
cnt = 0
for x in range(k + 1):
for y in range(k + 1):
z = s - x - y
if 0 <= z <= k:
cnt += 1
print(cnt)
| k, s = list(map(int, input().split()))
cnt = 0
for i in range(k + 1):
for j in range(k + 1):
if 0 <= (s - i - j) <= k:
cnt += 1
print(cnt)
| false | 25 | [
"-for x in range(k + 1):",
"- for y in range(k + 1):",
"- z = s - x - y",
"- if 0 <= z <= k:",
"+for i in range(k + 1):",
"+ for j in range(k + 1):",
"+ if 0 <= (s - i - j) <= k:"
] | false | 0.082861 | 0.045905 | 1.805043 | [
"s691402242",
"s794231783"
] |
u156815136 | p02947 | python | s591371104 | s315167552 | 674 | 432 | 61,272 | 19,940 | Accepted | Accepted | 35.91 | #from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict(list)
#import bisect
#
# d = m - k[i] - k[j]
# if kk[bis... | from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] -... | 51 | 38 | 1,171 | 821 | # from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
# from itertools import combinations # (string,3) 3回
# from collections import deque
# import collections.defaultdict(list)
# import bisect
#
# d = m - k[i] - k[j]
# if kk[bisec... | from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] - k[j... | false | 25.490196 | [
"-# from statistics import median",
"+from statistics import median",
"+",
"-# from itertools import combinations # (string,3) 3回",
"-# from collections import deque",
"-# import collections.defaultdict(list)",
"-# import bisect",
"+from fractions import gcd",
"+from itertools import combinations #... | false | 0.042923 | 0.042941 | 0.999574 | [
"s591371104",
"s315167552"
] |
u415905784 | p04046 | python | s128137736 | s927199611 | 1,489 | 912 | 12,952 | 18,904 | Accepted | Accepted | 38.75 | import math
H, W, A, B = list(map(int, input().split()))
p = 10 ** 9 + 7
F = [1 for i in range(H + W + 1)]
for i in range(1, H + W + 1):
F[i] = F[i - 1] * i % p
def fac(a, b):
a = F[a + b] * pow(F[a], p - 2, p) * pow(F[b], p - 2, p)
return a % p
ans = 0
for h in range(H - A):
ans += fac(h, B - 1) * f... | H, W, A, B = list(map(int, input().split()))
p = 10 ** 9 + 7
F = [1 for i in range(H + W + 1)]
for i in range(1, H + W + 1):
F[i] = F[i - 1] * i % p
Fi = [pow(f, p - 2, p) for f in F]
def fac(a, b):
a = F[a + b] * Fi[a] * Fi[b]
return a % p
if H - A < B:
ans = 0
for h in range(H - A):
ans += f... | 13 | 18 | 358 | 487 | import math
H, W, A, B = list(map(int, input().split()))
p = 10**9 + 7
F = [1 for i in range(H + W + 1)]
for i in range(1, H + W + 1):
F[i] = F[i - 1] * i % p
def fac(a, b):
a = F[a + b] * pow(F[a], p - 2, p) * pow(F[b], p - 2, p)
return a % p
ans = 0
for h in range(H - A):
ans += fac(h, B - 1) * f... | H, W, A, B = list(map(int, input().split()))
p = 10**9 + 7
F = [1 for i in range(H + W + 1)]
for i in range(1, H + W + 1):
F[i] = F[i - 1] * i % p
Fi = [pow(f, p - 2, p) for f in F]
def fac(a, b):
a = F[a + b] * Fi[a] * Fi[b]
return a % p
if H - A < B:
ans = 0
for h in range(H - A):
ans ... | false | 27.777778 | [
"-import math",
"-",
"+Fi = [pow(f, p - 2, p) for f in F]",
"- a = F[a + b] * pow(F[a], p - 2, p) * pow(F[b], p - 2, p)",
"+ a = F[a + b] * Fi[a] * Fi[b]",
"-ans = 0",
"-for h in range(H - A):",
"- ans += fac(h, B - 1) * fac(H - h - 1, W - B - 1) % p",
"+if H - A < B:",
"+ ans = 0",
... | false | 0.047643 | 0.048107 | 0.99037 | [
"s128137736",
"s927199611"
] |
u408071652 | p02598 | python | s017356189 | s422955829 | 361 | 246 | 219,128 | 104,148 | Accepted | Accepted | 31.86 | import sys
import math
def input():
return sys.stdin.readline().rstrip()
def main():
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
ng = 0
ok = 10 ** 9 + 1
while ok - ng > 1:
mid = (ok + ng) // 2
ans = sum(list([math.ceil(x / mid... | import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
ng = 0
ok = 10 ** 9 + 1
A.sort(reverse=True)
while ok - ng > 1:
mid = (ok + ng) // 2
ans =0
fo... | 34 | 36 | 609 | 610 | import sys
import math
def input():
return sys.stdin.readline().rstrip()
def main():
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
ng = 0
ok = 10**9 + 1
while ok - ng > 1:
mid = (ok + ng) // 2
ans = sum(list([math.ceil(x / mid) - 1 for x in A]))
... | import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
ng = 0
ok = 10**9 + 1
A.sort(reverse=True)
while ok - ng > 1:
mid = (ok + ng) // 2
ans = 0
for i in range(N):
... | false | 5.555556 | [
"-import math",
"+ A.sort(reverse=True)",
"- ans = sum(list([math.ceil(x / mid) - 1 for x in A]))",
"- # for i in range(N):",
"- # ans += A[i]//mid -1",
"- # if A[i]%mid !=0:",
"- # ans +=1",
"+ ans = 0",
"+ for i in range(N):",
"... | false | 0.115093 | 0.037627 | 3.058792 | [
"s017356189",
"s422955829"
] |
u497596438 | p03608 | python | s246111991 | s125853979 | 557 | 481 | 69,336 | 47,960 | Accepted | Accepted | 13.64 | from itertools import permutations
from heapq import *
N,M,R=list(map(int,input().split()))
r=list(map(int,input().split()))
INF=float("inf")
G=[[INF]*N for i in range(N)]
for i in range(M):
A,B,C=list(map(int,input().split()))
A,B=A-1,B-1
G[A][B]=C
G[B][A]=C
def distance(a,b):
stack=[... | from itertools import permutations
N,M,R=list(map(int,input().split()))
INF=10**9
d=[[INF]*N for i in range(N)]
r=list(map(int,input().split()))
for i in range(M):
A,B,C=list(map(int,input().split()))
d[A-1][B-1]=C
d[B-1][A-1]=C
for k in range(N):
for i in range(N):
for j in range(N):
d[i]... | 46 | 20 | 1,109 | 477 | from itertools import permutations
from heapq import *
N, M, R = list(map(int, input().split()))
r = list(map(int, input().split()))
INF = float("inf")
G = [[INF] * N for i in range(N)]
for i in range(M):
A, B, C = list(map(int, input().split()))
A, B = A - 1, B - 1
G[A][B] = C
G[B][A] = C
def distan... | from itertools import permutations
N, M, R = list(map(int, input().split()))
INF = 10**9
d = [[INF] * N for i in range(N)]
r = list(map(int, input().split()))
for i in range(M):
A, B, C = list(map(int, input().split()))
d[A - 1][B - 1] = C
d[B - 1][A - 1] = C
for k in range(N):
for i in range(N):
... | false | 56.521739 | [
"-from heapq import *",
"+INF = 10**9",
"+d = [[INF] * N for i in range(N)]",
"-INF = float(\"inf\")",
"-G = [[INF] * N for i in range(N)]",
"- A, B = A - 1, B - 1",
"- G[A][B] = C",
"- G[B][A] = C",
"-",
"-",
"-def distance(a, b):",
"- stack = [(G[a][i], i) for i in range(N) if G[... | false | 0.046445 | 0.043032 | 1.079308 | [
"s246111991",
"s125853979"
] |
u922449550 | p03426 | python | s536713846 | s491086928 | 642 | 502 | 44,568 | 37,516 | Accepted | Accepted | 21.81 | H, W, D = map(int, input().split())
M = H * W
A = [list(map(int, input().split())) for i in range(H)]
a_to_ij = {}
for i, aa in enumerate(A):
for j, a in enumerate(aa):
a_to_ij[a] = (i, j)
cost = {}
def calc_cost(s):
global cost
t = s
pre_i, pre_j = a_to_ij[s]
c = cost[(s, s)] = 0
while... | H, W, D = map(int, input().split())
M = H * W
A = [list(map(int, input().split())) for i in range(H)]
a_to_ij = {}
for i, aa in enumerate(A):
for j, a in enumerate(aa):
a_to_ij[a] = (i, j)
cost = {}
def calc_cost(s):
global cost
t = s
pre_i, pre_j = a_to_ij[s]
c = cost[s] = 0
while t + ... | 35 | 32 | 687 | 629 | H, W, D = map(int, input().split())
M = H * W
A = [list(map(int, input().split())) for i in range(H)]
a_to_ij = {}
for i, aa in enumerate(A):
for j, a in enumerate(aa):
a_to_ij[a] = (i, j)
cost = {}
def calc_cost(s):
global cost
t = s
pre_i, pre_j = a_to_ij[s]
c = cost[(s, s)] = 0
whil... | H, W, D = map(int, input().split())
M = H * W
A = [list(map(int, input().split())) for i in range(H)]
a_to_ij = {}
for i, aa in enumerate(A):
for j, a in enumerate(aa):
a_to_ij[a] = (i, j)
cost = {}
def calc_cost(s):
global cost
t = s
pre_i, pre_j = a_to_ij[s]
c = cost[s] = 0
while t +... | false | 8.571429 | [
"- c = cost[(s, s)] = 0",
"+ c = cost[s] = 0",
"- cost[(s, t)] = c",
"+ cost[t] = c",
"- s = L % D",
"- if s == 0:",
"- s = D",
"- ans.append(cost[(s, R)] - cost[(s, L)])",
"+ ans.append(cost[R] - cost[L])"
] | false | 0.051174 | 0.007861 | 6.510011 | [
"s536713846",
"s491086928"
] |
u414980766 | p02861 | python | s770175100 | s667496350 | 567 | 18 | 12,388 | 3,064 | Accepted | Accepted | 96.83 | from itertools import permutations as perm
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
XY = list(map(int, read().split()))
X = XY[0::2]
Y = XY[1::2]
res = 0
cnt = 0
for p in perm(list(range(N))):... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
XY = list(map(int, read().split()))
X = XY[0::2]
Y = XY[1::2]
t = 0
for i in range(N):
for j in range(i, N):
t += ((X[i] - X[j])**2 + (Y[i] - Y[j])**2)**0.5
p... | 18 | 14 | 455 | 331 | from itertools import permutations as perm
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
XY = list(map(int, read().split()))
X = XY[0::2]
Y = XY[1::2]
res = 0
cnt = 0
for p in perm(list(range(N))):
for i in... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
XY = list(map(int, read().split()))
X = XY[0::2]
Y = XY[1::2]
t = 0
for i in range(N):
for j in range(i, N):
t += ((X[i] - X[j]) ** 2 + (Y[i] - Y[j]) ** 2) ** 0.5
print((2... | false | 22.222222 | [
"-from itertools import permutations as perm",
"-import numpy as np",
"-res = 0",
"-cnt = 0",
"-for p in perm(list(range(N))):",
"- for i in range(N - 1):",
"- res += ((X[p[i + 1]] - X[p[i]]) ** 2 + (Y[p[i + 1]] - Y[p[i]]) ** 2) ** 0.5",
"- cnt += 1",
"-print((res / cnt))",
"+t = 0",
... | false | 0.11371 | 0.038886 | 2.924197 | [
"s770175100",
"s667496350"
] |
u348805958 | p02691 | python | s592517032 | s365672138 | 220 | 105 | 57,644 | 33,908 | Accepted | Accepted | 52.27 | #!python3
from collections import defaultdict
iim = lambda: list(map(int, input().rstrip().split()))
def resolve():
N = int(eval(input()))
A = list(iim())
d1 = defaultdict(int)
d2 = defaultdict(int)
for i, ai in enumerate(A):
d1[i+ai] += 1
d2[i-ai] += 1
ans =... | #!python3
from collections import defaultdict
iim = lambda: list(map(int, input().rstrip().split()))
def resolve():
N = int(eval(input()))
A = list(iim())
ans = 0
dp = [0]*N
for i, ai in enumerate(A):
x = i + ai
if x < N:
dp[x] += 1
x = i - ai
... | 25 | 24 | 454 | 417 | #!python3
from collections import defaultdict
iim = lambda: list(map(int, input().rstrip().split()))
def resolve():
N = int(eval(input()))
A = list(iim())
d1 = defaultdict(int)
d2 = defaultdict(int)
for i, ai in enumerate(A):
d1[i + ai] += 1
d2[i - ai] += 1
ans = 0
for k, ... | #!python3
from collections import defaultdict
iim = lambda: list(map(int, input().rstrip().split()))
def resolve():
N = int(eval(input()))
A = list(iim())
ans = 0
dp = [0] * N
for i, ai in enumerate(A):
x = i + ai
if x < N:
dp[x] += 1
x = i - ai
if x >=... | false | 4 | [
"- d1 = defaultdict(int)",
"- d2 = defaultdict(int)",
"+ ans = 0",
"+ dp = [0] * N",
"- d1[i + ai] += 1",
"- d2[i - ai] += 1",
"- ans = 0",
"- for k, v in list(d1.items()):",
"- if k in d2:",
"- ans += v * d2[k]",
"+ x = i + ai",
"+ ... | false | 0.045275 | 0.04777 | 0.94777 | [
"s592517032",
"s365672138"
] |
u076917070 | p02837 | python | s077533405 | s423161264 | 408 | 350 | 3,064 | 3,064 | Accepted | Accepted | 14.22 | import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = [[set(), set()] for _ in range(N)]
for i in range(N):
m = int(eval(input()))
for j in range(m):
x, y = list(map(int, input().split()))
A[i][y].add(x)
ans = 0
for i in... | import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = [[set(), set()] for _ in range(N)]
for i in range(N):
m = int(eval(input()))
for j in range(m):
x, y = list(map(int, input().split()))
A[i][y].add(x)
ans = 0
for i in... | 36 | 36 | 826 | 778 | import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = [[set(), set()] for _ in range(N)]
for i in range(N):
m = int(eval(input()))
for j in range(m):
x, y = list(map(int, input().split()))
A[i][y].add(x)
ans = 0
for i in range(1 << N)... | import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = [[set(), set()] for _ in range(N)]
for i in range(N):
m = int(eval(input()))
for j in range(m):
x, y = list(map(int, input().split()))
A[i][y].add(x)
ans = 0
for i in range(1 << N)... | false | 0 | [
"- for j in range(N):",
"- if (i >> j) & 1:",
"- h |= A[j][1]",
"- u |= A[j][0]",
"- if u & A[j][1] or h & A[j][0]:",
"- b = False",
"+ for k in list(h):",
"+ k -= 1",
"+ h |= A[k][1]",
"... | false | 0.042222 | 0.043097 | 0.979705 | [
"s077533405",
"s423161264"
] |
u417365712 | p02775 | python | s321502795 | s437306607 | 1,024 | 854 | 21,096 | 13,504 | Accepted | Accepted | 16.6 | n = list(map(int, reversed(list(eval(input())))))
a , b = 0, 9999
for x in n:
a, b = min(a+x, b+x), min(a+10-x+1, b+10-x-1)
print((min(a, b))) | n = reversed(list(map(int, eval(input()))))
a, b = 0, 30
for x in n:
a, b = min(a+x, b+x), min(a-x+11, b-x+9)
print((min(a, b))) | 5 | 5 | 142 | 128 | n = list(map(int, reversed(list(eval(input())))))
a, b = 0, 9999
for x in n:
a, b = min(a + x, b + x), min(a + 10 - x + 1, b + 10 - x - 1)
print((min(a, b)))
| n = reversed(list(map(int, eval(input()))))
a, b = 0, 30
for x in n:
a, b = min(a + x, b + x), min(a - x + 11, b - x + 9)
print((min(a, b)))
| false | 0 | [
"-n = list(map(int, reversed(list(eval(input())))))",
"-a, b = 0, 9999",
"+n = reversed(list(map(int, eval(input()))))",
"+a, b = 0, 30",
"- a, b = min(a + x, b + x), min(a + 10 - x + 1, b + 10 - x - 1)",
"+ a, b = min(a + x, b + x), min(a - x + 11, b - x + 9)"
] | false | 0.080861 | 0.049492 | 1.633824 | [
"s321502795",
"s437306607"
] |
u254871849 | p03478 | python | s909344631 | s221008346 | 47 | 33 | 3,064 | 3,060 | Accepted | Accepted | 29.79 | n, a, b = list(map(int, input().split()))
total = 0
def sum_digits(digits):
return sum(int(digit) for digit in str(digits))
for i in range(1, n+1):
if sum_digits(i) >= a and sum_digits(i) <= b:
total += i
print(total) | n, a, b = list(map(int, input().split()))
total = 0
def sum_digits(digits):
return sum(int(digit) for digit in str(digits))
for i in range(1, n+1):
total_digits = sum_digits(i)
if total_digits >= a and total_digits <= b:
total += i
print(total) | 11 | 12 | 236 | 266 | n, a, b = list(map(int, input().split()))
total = 0
def sum_digits(digits):
return sum(int(digit) for digit in str(digits))
for i in range(1, n + 1):
if sum_digits(i) >= a and sum_digits(i) <= b:
total += i
print(total)
| n, a, b = list(map(int, input().split()))
total = 0
def sum_digits(digits):
return sum(int(digit) for digit in str(digits))
for i in range(1, n + 1):
total_digits = sum_digits(i)
if total_digits >= a and total_digits <= b:
total += i
print(total)
| false | 8.333333 | [
"- if sum_digits(i) >= a and sum_digits(i) <= b:",
"+ total_digits = sum_digits(i)",
"+ if total_digits >= a and total_digits <= b:"
] | false | 0.037765 | 0.063546 | 0.594295 | [
"s909344631",
"s221008346"
] |
u386819480 | p02988 | python | s708135971 | s584048719 | 20 | 17 | 3,316 | 3,064 | Accepted | Accepted | 15 | #!/usr/bin/env python3
import sys
def solve(n: int, p: "List[int]"):
ans = 0
for i in range(1,n-1):
if((p[i-1] < p[i] < p[i+1]) or (p[i-1] > p[i] > p[i+1])):
ans += 1
print(ans)
return
# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (ti... | #!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32
def solve(n: int, p: "List[int]"):
ans = 0
for i in range(1, n-1):
if sorted([p[i-1], p[i], p[i+1]])[1] == p[i]:
ans += 1
print(ans)
return
def main():
def iterate_tokens():
... | 27 | 29 | 753 | 613 | #!/usr/bin/env python3
import sys
def solve(n: int, p: "List[int]"):
ans = 0
for i in range(1, n - 1):
if (p[i - 1] < p[i] < p[i + 1]) or (p[i - 1] > p[i] > p[i + 1]):
ans += 1
print(ans)
return
# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use t... | #!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1 << 32
def solve(n: int, p: "List[int]"):
ans = 0
for i in range(1, n - 1):
if sorted([p[i - 1], p[i], p[i + 1]])[1] == p[i]:
ans += 1
print(ans)
return
def main():
def iterate_tokens():
for lin... | false | 6.896552 | [
"+",
"+sys.setrecursionlimit(10000000)",
"+INF = 1 << 32",
"- if (p[i - 1] < p[i] < p[i + 1]) or (p[i - 1] > p[i] > p[i + 1]):",
"+ if sorted([p[i - 1], p[i], p[i + 1]])[1] == p[i]:",
"-# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template n... | false | 0.050238 | 0.050644 | 0.991981 | [
"s708135971",
"s584048719"
] |
u162612857 | p03087 | python | s812640248 | s409570810 | 1,072 | 878 | 5,768 | 6,104 | Accepted | Accepted | 18.1 | import bisect
N,Q = list(map(int, input().split()))
S = eval(input())
start = []
# end = []
for i in range(N-1):
if S[i] == "A" and S[i+1] == "C":
start.append(i)
# end.append(i+1)
length = len(start)
for _ in range(Q):
left, right = list(map(int, input().split()))
left -= 1
right -= 1
... | # クエリが複数回与えられて、毎回のクエリに対する回答をする必要がある
# という時点で累積和を意識するべきだった……
# 競技中に一瞬思いついたが、10万の配列を作ったときにメモリが足りるかを懸念して避けてしまった
# 10万くらいなら余裕で足りるよ
# printしてみた配列の大きさ:
# 提出時の表示: URLを張る
N,Q = list(map(int, input().split()))
S = eval(input())
cumsum = []
# cumsum[i] := (0-indexで)0文字目からi文字目までに含まれる部分列"AC"の個数
# (0-indexで)l文字目か... | 63 | 30 | 924 | 680 | import bisect
N, Q = list(map(int, input().split()))
S = eval(input())
start = []
# end = []
for i in range(N - 1):
if S[i] == "A" and S[i + 1] == "C":
start.append(i)
# end.append(i+1)
length = len(start)
for _ in range(Q):
left, right = list(map(int, input().split()))
left -= 1
right -= 1
... | # クエリが複数回与えられて、毎回のクエリに対する回答をする必要がある
# という時点で累積和を意識するべきだった……
# 競技中に一瞬思いついたが、10万の配列を作ったときにメモリが足りるかを懸念して避けてしまった
# 10万くらいなら余裕で足りるよ
# printしてみた配列の大きさ:
# 提出時の表示: URLを張る
N, Q = list(map(int, input().split()))
S = eval(input())
cumsum = []
# cumsum[i] := (0-indexで)0文字目からi文字目までに含まれる部分列"AC"の個数
# (0-indexで)l文字目からr文字目までに含まれる部分列"AC... | false | 52.380952 | [
"-import bisect",
"-",
"+# クエリが複数回与えられて、毎回のクエリに対する回答をする必要がある",
"+# という時点で累積和を意識するべきだった……",
"+# 競技中に一瞬思いついたが、10万の配列を作ったときにメモリが足りるかを懸念して避けてしまった",
"+# 10万くらいなら余裕で足りるよ",
"+# printしてみた配列の大きさ:",
"+# 提出時の表示: URLを張る",
"-start = []",
"-# end = []",
"-for i in range(N - 1):",
"- if S[i] == \"A\" and ... | false | 0.037659 | 0.036274 | 1.038176 | [
"s812640248",
"s409570810"
] |
u539692012 | p02571 | python | s069276244 | s273974097 | 79 | 40 | 67,728 | 9,004 | Accepted | Accepted | 49.37 | s = eval(input())
t = eval(input())
ans = len(t)
for i in range(len(s) - len(t) + 1):
ans = min(ans, sum(si != ti for si, ti in zip(s[i:], t)))
print(ans) | s,t=eval(input()),eval(input())
print((min(sum(a!=b for a,b in zip(s[i:],t))for i in range(len(s)-len(t)+1)))) | 6 | 2 | 151 | 97 | s = eval(input())
t = eval(input())
ans = len(t)
for i in range(len(s) - len(t) + 1):
ans = min(ans, sum(si != ti for si, ti in zip(s[i:], t)))
print(ans)
| s, t = eval(input()), eval(input())
print((min(sum(a != b for a, b in zip(s[i:], t)) for i in range(len(s) - len(t) + 1))))
| false | 66.666667 | [
"-s = eval(input())",
"-t = eval(input())",
"-ans = len(t)",
"-for i in range(len(s) - len(t) + 1):",
"- ans = min(ans, sum(si != ti for si, ti in zip(s[i:], t)))",
"-print(ans)",
"+s, t = eval(input()), eval(input())",
"+print((min(sum(a != b for a, b in zip(s[i:], t)) for i in range(len(s) - len(... | false | 0.04705 | 0.154777 | 0.303986 | [
"s069276244",
"s273974097"
] |
u564902833 | p02959 | python | s774268244 | s617446593 | 217 | 186 | 18,624 | 19,248 | Accepted | Accepted | 14.29 | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
ans += min(B[i], A[i])
B[i] -= min(B[i], A[i])
ans += min(B[i], A[i + 1])
A[i + 1] -= min(B[i], A[i + 1])
print(ans)
| from functools import reduce
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# 小さい番号の勇者から順に小さい番号の街のモンスターを優先して倒す
ans, _ = reduce(
lambda acc, i: (
acc[0] + min(acc[1] + A[i + 1], B[i]),
max(0, A[i + 1] - max(0, B[i] - acc[1]))
),
li... | 12 | 17 | 262 | 354 | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
ans += min(B[i], A[i])
B[i] -= min(B[i], A[i])
ans += min(B[i], A[i + 1])
A[i + 1] -= min(B[i], A[i + 1])
print(ans)
| from functools import reduce
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# 小さい番号の勇者から順に小さい番号の街のモンスターを優先して倒す
ans, _ = reduce(
lambda acc, i: (
acc[0] + min(acc[1] + A[i + 1], B[i]),
max(0, A[i + 1] - max(0, B[i] - acc[1])),
),
list(range(N))... | false | 29.411765 | [
"+from functools import reduce",
"+",
"-ans = 0",
"-for i in range(N):",
"- ans += min(B[i], A[i])",
"- B[i] -= min(B[i], A[i])",
"- ans += min(B[i], A[i + 1])",
"- A[i + 1] -= min(B[i], A[i + 1])",
"+# 小さい番号の勇者から順に小さい番号の街のモンスターを優先して倒す",
"+ans, _ = reduce(",
"+ lambda acc, i: (",
... | false | 0.043989 | 0.082635 | 0.532324 | [
"s774268244",
"s617446593"
] |
u740767776 | p03293 | python | s469965585 | s963567450 | 19 | 17 | 3,064 | 2,940 | Accepted | Accepted | 10.53 | s = list(eval(input()))
t = eval(input())
n = len(s)
f = False
for i in range(n):
tmp = s[n-1]
for j in range(n-1,-1,-1):
s[j] = s[j-1]
s[0] = tmp
if t == "".join(s):
print("Yes")
f = True
break
if not f:
print("No") | s = eval(input())
t = eval(input())
n = len(s)
f = False
for i in range(n):
if s == t:
f = True
break
else:
s = s[n-1] + s[:n-1]
if f:
print("Yes")
else:
print("No")
| 15 | 15 | 270 | 217 | s = list(eval(input()))
t = eval(input())
n = len(s)
f = False
for i in range(n):
tmp = s[n - 1]
for j in range(n - 1, -1, -1):
s[j] = s[j - 1]
s[0] = tmp
if t == "".join(s):
print("Yes")
f = True
break
if not f:
print("No")
| s = eval(input())
t = eval(input())
n = len(s)
f = False
for i in range(n):
if s == t:
f = True
break
else:
s = s[n - 1] + s[: n - 1]
if f:
print("Yes")
else:
print("No")
| false | 0 | [
"-s = list(eval(input()))",
"+s = eval(input())",
"- tmp = s[n - 1]",
"- for j in range(n - 1, -1, -1):",
"- s[j] = s[j - 1]",
"- s[0] = tmp",
"- if t == \"\".join(s):",
"- print(\"Yes\")",
"+ if s == t:",
"-if not f:",
"+ else:",
"+ s = s[n - 1] + s[: n ... | false | 0.050125 | 0.037007 | 1.354469 | [
"s469965585",
"s963567450"
] |
u957872856 | p03574 | python | s067786551 | s496676799 | 30 | 24 | 3,060 | 3,572 | Accepted | Accepted | 20 | h, w = list(map(int,input().split()))
s = [eval(input()) for i in range(h)]
for i in range(h):
l = ""
for j in range(w):
if s[i][j] == "#":
l += "#"
else:
l += str(sum([t[max(0,j-1):min(w,j+2)].count("#") for t in s[max(0,i-1):min(h,i+2)]]))
print(l)
| H, W = map(int,input().split())
S = [list(input()) for i in range(H)]
arr = [[0]*W for i in range(H)]
for i in range(H):
for j in range(W):
if S[i][j] == "#":
if i-1 >= 0 and S[i-1][j] == ".":
arr[i-1][j] += 1
if i+1 < H and S[i+1][j] == ".":
arr[i+1][j] += 1
if j-1 >= ... | 11 | 25 | 279 | 836 | h, w = list(map(int, input().split()))
s = [eval(input()) for i in range(h)]
for i in range(h):
l = ""
for j in range(w):
if s[i][j] == "#":
l += "#"
else:
l += str(
sum(
[
t[max(0, j - 1) : min(w, j + 2)].count(... | H, W = map(int, input().split())
S = [list(input()) for i in range(H)]
arr = [[0] * W for i in range(H)]
for i in range(H):
for j in range(W):
if S[i][j] == "#":
if i - 1 >= 0 and S[i - 1][j] == ".":
arr[i - 1][j] += 1
if i + 1 < H and S[i + 1][j] == ".":
... | false | 56 | [
"-h, w = list(map(int, input().split()))",
"-s = [eval(input()) for i in range(h)]",
"-for i in range(h):",
"- l = \"\"",
"- for j in range(w):",
"- if s[i][j] == \"#\":",
"- l += \"#\"",
"- else:",
"- l += str(",
"- sum(",
"- ... | false | 0.116819 | 0.040605 | 2.876959 | [
"s067786551",
"s496676799"
] |
u724687935 | p02609 | python | s069504706 | s992889188 | 588 | 246 | 12,720 | 96,900 | Accepted | Accepted | 58.16 | from collections import Counter
import sys
sys.setrecursionlimit(10 ** 6)
def dfs(n):
if memo[n] >= 0:
rst = memo[n]
else:
tmp = n
one = 0
while tmp > 0:
one += tmp & 1
tmp >>= 1
m = n % one
rst = 1 if m == 0 else 1 + dfs(m... | from collections import Counter
import sys
sys.setrecursionlimit(10 ** 6)
# パート2 の解法
def dfs(n):
if memo[n] >= 0:
rst = memo[n]
else:
tmp = n
one = 0
while tmp > 0:
one += tmp & 1
tmp >>= 1
m = n % one
rst = 1 if m == 0 el... | 59 | 66 | 1,059 | 1,210 | from collections import Counter
import sys
sys.setrecursionlimit(10**6)
def dfs(n):
if memo[n] >= 0:
rst = memo[n]
else:
tmp = n
one = 0
while tmp > 0:
one += tmp & 1
tmp >>= 1
m = n % one
rst = 1 if m == 0 else 1 + dfs(m)
memo[n... | from collections import Counter
import sys
sys.setrecursionlimit(10**6)
# パート2 の解法
def dfs(n):
if memo[n] >= 0:
rst = memo[n]
else:
tmp = n
one = 0
while tmp > 0:
one += tmp & 1
tmp >>= 1
m = n % one
rst = 1 if m == 0 else 1 + dfs(m)
... | false | 10.606061 | [
"-",
"-",
"+# パート2 の解法",
"+# パート1の解法.",
"+# Xがオール0のとき, 1が一つしか含まれないとき、を場合分けする",
"+ # 解法パート1",
"- else:",
"+ else: # X[i] == 1 かつ 全体で1が一つしかない 場合 は必ず0になる",
"- print((1 + dfs(m)))",
"+ cnt = 1",
"+ # 解法パート2",
"+ cnt += dfs(m)",
"+ print(cnt)"
] | false | 0.115751 | 0.036811 | 3.144469 | [
"s069504706",
"s992889188"
] |
u994988729 | p02558 | python | s329606550 | s303131064 | 396 | 76 | 13,640 | 10,672 | Accepted | Accepted | 80.81 | import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
class UF_tree:
def __init__(self, n):
self.root = [-1] * (n + 1)
self.rank = [0] * (n + 1)
def find(self, x):
if self.root[x] < 0:
return x
else:
self.root[x] = se... | code = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/dsu.hpp" namespace "atcoder":
cdef cppclass dsu:
dsu(int n)
... | 49 | 34 | 1,181 | 914 | import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
class UF_tree:
def __init__(self, n):
self.root = [-1] * (n + 1)
self.rank = [0] * (n + 1)
def find(self, x):
if self.root[x] < 0:
return x
else:
self.root[x] = self.find(self.ro... | code = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/dsu.hpp" namespace "atcoder":
cdef cppclass dsu:
dsu(int n)
int... | false | 30.612245 | [
"+code = r\"\"\"",
"+# distutils: language=c++",
"+# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include",
"+from libcpp cimport bool",
"+from libcpp.vector cimport vector",
"+cdef extern from \"/opt/atcoder-stl/atcoder/dsu.hpp\" namespace \"atcoder\":",
"+ ... | false | 0.040215 | 0.063017 | 0.638162 | [
"s329606550",
"s303131064"
] |
u102461423 | p02972 | python | s302876764 | s706319292 | 271 | 158 | 18,920 | 18,428 | Accepted | Accepted | 41.7 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from functools import reduce
from operator import xor
N = int(readline())
A = [0] + list(map(int,read().split()))
for n in range(N//2,0,-1):
A[n] = reduce(xor,A[n::n],0)
I = [i for i... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = [0] + list(map(int,read().split()))
for n in range(N//2,0,-1):
A[n] = sum(A[n::n])&1
I = [i for i,x in enumerate(A) if x]
print((len(I)))
if len(I) > 0:
... | 19 | 16 | 410 | 345 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from functools import reduce
from operator import xor
N = int(readline())
A = [0] + list(map(int, read().split()))
for n in range(N // 2, 0, -1):
A[n] = reduce(xor, A[n::n], 0)
I = [i for i, x in en... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = [0] + list(map(int, read().split()))
for n in range(N // 2, 0, -1):
A[n] = sum(A[n::n]) & 1
I = [i for i, x in enumerate(A) if x]
print((len(I)))
if len(I) > 0:
print((" "... | false | 15.789474 | [
"-from functools import reduce",
"-from operator import xor",
"-",
"- A[n] = reduce(xor, A[n::n], 0)",
"+ A[n] = sum(A[n::n]) & 1"
] | false | 0.044247 | 0.07269 | 0.608714 | [
"s302876764",
"s706319292"
] |
u681444474 | p02702 | python | s965347615 | s496161699 | 470 | 126 | 16,388 | 9,160 | Accepted | Accepted | 73.19 | # coding: utf-8
s=eval(input())
ans=0
p = 2019
n = len(s)
s=s[::-1]
accum=[0]*n
d=dict()
for i in range(n):
accum[i]=int(s[i])*pow(10,i,p)%p
for i in range(n-1):
accum[i+1]+=accum[i]
accum[i+1]%=p
accum[-1]%=p
#print(accum)
for i in range(n):
if accum[i] not in d:
if accum... | # coding: utf-8
S = eval(input())
P = 2019
N = len(S)
num = [0] * P
num[0] = 1
c = 0
ans = 0
dgt = 1
for i in range(N-1, -1, -1):
c = (c + int(S[i]) * dgt) % P
dgt *= 10
dgt %= P
ans += num[c]
num[c] += 1
print(ans) | 28 | 18 | 498 | 249 | # coding: utf-8
s = eval(input())
ans = 0
p = 2019
n = len(s)
s = s[::-1]
accum = [0] * n
d = dict()
for i in range(n):
accum[i] = int(s[i]) * pow(10, i, p) % p
for i in range(n - 1):
accum[i + 1] += accum[i]
accum[i + 1] %= p
accum[-1] %= p
# print(accum)
for i in range(n):
if accum[i] not in d:
... | # coding: utf-8
S = eval(input())
P = 2019
N = len(S)
num = [0] * P
num[0] = 1
c = 0
ans = 0
dgt = 1
for i in range(N - 1, -1, -1):
c = (c + int(S[i]) * dgt) % P
dgt *= 10
dgt %= P
ans += num[c]
num[c] += 1
print(ans)
| false | 35.714286 | [
"-s = eval(input())",
"+S = eval(input())",
"+P = 2019",
"+N = len(S)",
"+num = [0] * P",
"+num[0] = 1",
"+c = 0",
"-p = 2019",
"-n = len(s)",
"-s = s[::-1]",
"-accum = [0] * n",
"-d = dict()",
"-for i in range(n):",
"- accum[i] = int(s[i]) * pow(10, i, p) % p",
"-for i in range(n - 1... | false | 0.03592 | 0.035809 | 1.003096 | [
"s965347615",
"s496161699"
] |
u606033239 | p03352 | python | s212476895 | s272446901 | 20 | 18 | 2,940 | 2,940 | Accepted | Accepted | 10 | x = int(eval(input()))
a = 0
for i in range(1,x+1):
for j in range(2,10):
if i**j <= x:
a = max(a,i**j)
print(a) | x = int(eval(input()))
a = 1
for i in range(1,x):
for j in range(2,x):
if i**j <= x:
a = max(a,i**j)
else:
break
print(a) | 7 | 9 | 136 | 165 | x = int(eval(input()))
a = 0
for i in range(1, x + 1):
for j in range(2, 10):
if i**j <= x:
a = max(a, i**j)
print(a)
| x = int(eval(input()))
a = 1
for i in range(1, x):
for j in range(2, x):
if i**j <= x:
a = max(a, i**j)
else:
break
print(a)
| false | 22.222222 | [
"-a = 0",
"-for i in range(1, x + 1):",
"- for j in range(2, 10):",
"+a = 1",
"+for i in range(1, x):",
"+ for j in range(2, x):",
"+ else:",
"+ break"
] | false | 0.04187 | 0.03953 | 1.059199 | [
"s212476895",
"s272446901"
] |
u572142121 | p02804 | python | s571235645 | s896885706 | 1,623 | 365 | 129,120 | 22,548 | Accepted | Accepted | 77.51 | N,K=list(map(int, input().split()))
AA=list(map(int, input().split()))
A=sorted(AA)
B=sorted(AA)[::-1]
mod=10**9+7
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
n = 10**6+1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テ... | N,K=list(map(int, input().split()))
AA=list(map(int, input().split()))
A=sorted(AA)
B=sorted(AA)[::-1]
mod=10**9+7
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
n = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブ... | 29 | 29 | 682 | 680 | N, K = list(map(int, input().split()))
AA = list(map(int, input().split()))
A = sorted(AA)
B = sorted(AA)[::-1]
mod = 10**9 + 7
def cmb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
mod = 10**9 + 7 # 出力の制限
n = 10**6 + 1
g1 = [1, 1] # 元テーブル
g2 ... | N, K = list(map(int, input().split()))
AA = list(map(int, input().split()))
A = sorted(AA)
B = sorted(AA)[::-1]
mod = 10**9 + 7
def cmb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
mod = 10**9 + 7 # 出力の制限
n = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1... | false | 0 | [
"-n = 10**6 + 1",
"+n = 10**5"
] | false | 1.596017 | 0.199925 | 7.983071 | [
"s571235645",
"s896885706"
] |
u730769327 | p03283 | python | s153558616 | s815199954 | 935 | 626 | 18,716 | 78,264 | Accepted | Accepted | 33.05 | n,m,q=list(map(int,input().split()))
a=[[0 for _ in range(n+1)]for _ in range(n+1)]
for _ in range(m):
l,r=list(map(int,input().split()))
a[l][r]+=1
for i in range(n+1):
for j in range(n):
a[i][j+1]+=a[i][j]
for i in range(n):
for j in range(n+1):
a[i+1][j]+=a[i][j]
for _ in range(q):
l,r=... | n,m,q=list(map(int,input().split()))
a=[[0]*(n+1) for _ in range(n+1)]
for _ in range(m):
l,r=list(map(int,input().split()))
a[l][r]+=1
for i in range(n+1):
for j in range(n):
a[i][j+1]+=a[i][j]
for i in range(n):
for j in range(n+1):
a[i+1][j]+=a[i][j]
for _ in range(q):
q,p=list(map(int,... | 14 | 14 | 382 | 369 | n, m, q = list(map(int, input().split()))
a = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for _ in range(m):
l, r = list(map(int, input().split()))
a[l][r] += 1
for i in range(n + 1):
for j in range(n):
a[i][j + 1] += a[i][j]
for i in range(n):
for j in range(n + 1):
a[i + 1][j] +=... | n, m, q = list(map(int, input().split()))
a = [[0] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
l, r = list(map(int, input().split()))
a[l][r] += 1
for i in range(n + 1):
for j in range(n):
a[i][j + 1] += a[i][j]
for i in range(n):
for j in range(n + 1):
a[i + 1][j] += a[i][j]
for... | false | 0 | [
"-a = [[0 for _ in range(n + 1)] for _ in range(n + 1)]",
"+a = [[0] * (n + 1) for _ in range(n + 1)]",
"- l, r = list(map(int, input().split()))",
"- print((a[r][r] - a[r][l - 1] - a[l - 1][r] + a[l - 1][l - 1]))",
"+ q, p = list(map(int, input().split()))",
"+ print((a[p][p] - a[p][q - 1] - ... | false | 0.045024 | 0.043491 | 1.035242 | [
"s153558616",
"s815199954"
] |
u936985471 | p03488 | python | s223066181 | s673748314 | 885 | 809 | 10,352 | 10,536 | Accepted | Accepted | 8.59 | import sys
readline = sys.stdin.readline
S = readline().rstrip()
gx,gy = list(map(int,readline().split()))
C = []
import itertools
for key,g in itertools.groupby(S):
C.append([key,len(list(g))])
x,y = 0,0
ind = 0
if C[0][0] == "F":
x += C[0][1]
ind = 1
# Xの方向を向いている
dirX = True
now_x = {... | S = eval(input())
X,Y = list(map(int,input().split()))
# [文字,その文字が連続する数]
from collections import deque
sumS = deque()
import itertools
for key,g in itertools.groupby(S):
sumS.append([key,len(list(g))])
startx = 0 # Fで始まる場合はX軸の正の方向にあらかじめ進めて置く
# 最初のTが出るまではX軸正の方向に進む
if sumS[0][0] == "F":
startx = sumS... | 45 | 47 | 804 | 1,027 | import sys
readline = sys.stdin.readline
S = readline().rstrip()
gx, gy = list(map(int, readline().split()))
C = []
import itertools
for key, g in itertools.groupby(S):
C.append([key, len(list(g))])
x, y = 0, 0
ind = 0
if C[0][0] == "F":
x += C[0][1]
ind = 1
# Xの方向を向いている
dirX = True
now_x = {x}
now_y = {y... | S = eval(input())
X, Y = list(map(int, input().split()))
# [文字,その文字が連続する数]
from collections import deque
sumS = deque()
import itertools
for key, g in itertools.groupby(S):
sumS.append([key, len(list(g))])
startx = 0 # Fで始まる場合はX軸の正の方向にあらかじめ進めて置く
# 最初のTが出るまではX軸正の方向に進む
if sumS[0][0] == "F":
startx = sumS[0][1]... | false | 4.255319 | [
"-import sys",
"+S = eval(input())",
"+X, Y = list(map(int, input().split()))",
"+# [文字,その文字が連続する数]",
"+from collections import deque",
"-readline = sys.stdin.readline",
"-S = readline().rstrip()",
"-gx, gy = list(map(int, readline().split()))",
"-C = []",
"+sumS = deque()",
"- C.append([key,... | false | 0.037455 | 0.041402 | 0.904674 | [
"s223066181",
"s673748314"
] |
u837673618 | p02709 | python | s475911594 | s220889870 | 1,139 | 963 | 9,948 | 9,840 | Accepted | Accepted | 15.45 | from collections import *
from itertools import *
N = int(eval(input()))
A = list(map(int, input().split()))
SA = SB = 0
ABI = sorted(((b:=max(N-i, i-1)*a, SA:=SA+a, SB:=SB+b) and (a, b, i) for i, a in enumerate(A, 1)), reverse=True)
prev = {0:0}
prev_max = 0
for k, (a, b, i) in enumerate(ABI):
curr = ... | from collections import *
from itertools import *
N = int(eval(input()))
A = list(map(int, input().split()))
SA = SB = 0
ABI = sorted(((b:=max(N-i, i-1)*a, SA:=SA+a, SB:=SB+b) and (a, b, i) for i, a in enumerate(A, 1)), reverse=True)
prev = {0:0}
prev_max = 0
for k, (a, b, i) in enumerate(ABI):
curr = ... | 27 | 25 | 645 | 589 | from collections import *
from itertools import *
N = int(eval(input()))
A = list(map(int, input().split()))
SA = SB = 0
ABI = sorted(
(
(b := max(N - i, i - 1) * a, SA := SA + a, SB := SB + b) and (a, b, i)
for i, a in enumerate(A, 1)
),
reverse=True,
)
prev = {0: 0}
prev_max = 0
for k, (a... | from collections import *
from itertools import *
N = int(eval(input()))
A = list(map(int, input().split()))
SA = SB = 0
ABI = sorted(
(
(b := max(N - i, i - 1) * a, SA := SA + a, SB := SB + b) and (a, b, i)
for i, a in enumerate(A, 1)
),
reverse=True,
)
prev = {0: 0}
prev_max = 0
for k, (a... | false | 7.407407 | [
"- curr_max = 0",
"- curr_max = max(curr_max, curr[l], curr[l + 1])",
"- prev_max = curr_max",
"-print(curr_max)",
"+ prev_max = max(prev.values())",
"+print(prev_max)"
] | false | 0.170879 | 0.153878 | 1.110482 | [
"s475911594",
"s220889870"
] |
u106297876 | p02554 | python | s418249732 | s602984792 | 392 | 63 | 89,772 | 61,772 | Accepted | Accepted | 83.93 | N = int(eval(input()))
ans = 10**N - (9**N + 9**N - 8**N)
ans %= 10**9 + 7
print(ans) | N = int(eval(input()))
mod = 10**9 + 7
ans = pow(10,N,mod)
ans -= pow(9,N,mod)
ans -= pow(9,N,mod)
ans += pow(8,N,mod)
ans %= mod
print(ans) | 4 | 8 | 82 | 141 | N = int(eval(input()))
ans = 10**N - (9**N + 9**N - 8**N)
ans %= 10**9 + 7
print(ans)
| N = int(eval(input()))
mod = 10**9 + 7
ans = pow(10, N, mod)
ans -= pow(9, N, mod)
ans -= pow(9, N, mod)
ans += pow(8, N, mod)
ans %= mod
print(ans)
| false | 50 | [
"-ans = 10**N - (9**N + 9**N - 8**N)",
"-ans %= 10**9 + 7",
"+mod = 10**9 + 7",
"+ans = pow(10, N, mod)",
"+ans -= pow(9, N, mod)",
"+ans -= pow(9, N, mod)",
"+ans += pow(8, N, mod)",
"+ans %= mod"
] | false | 0.506971 | 0.037806 | 13.409861 | [
"s418249732",
"s602984792"
] |
u729133443 | p03221 | python | s813517543 | s350330047 | 941 | 611 | 49,684 | 32,612 | Accepted | Accepted | 35.07 | I=lambda:list(map(int,input().split()));n,m=I();l=[[]for _ in[0]*-~n];a=[]
for i in range(m):p,y=I();l[p].append([y,i])
for p in range(1,n+1):
for i,t in enumerate(sorted(l[p])):a.append([t[1],'%06d'%p+'%06d'%-~i])
for t in sorted(a):print((t[1])) | I=lambda:list(map(int,input().split()));n,m=I();l=[I()+[i]for i in range(m)];c=[0]*-~n;a=[0]*m
for p,y,i in sorted(l,key=lambda x:x[1]):c[p]+=1;a[i]='%06d'%p+'%06d'%c[p]
for t in a:print(t) | 5 | 3 | 244 | 191 | I = lambda: list(map(int, input().split()))
n, m = I()
l = [[] for _ in [0] * -~n]
a = []
for i in range(m):
p, y = I()
l[p].append([y, i])
for p in range(1, n + 1):
for i, t in enumerate(sorted(l[p])):
a.append([t[1], "%06d" % p + "%06d" % -~i])
for t in sorted(a):
print((t[1]))
| I = lambda: list(map(int, input().split()))
n, m = I()
l = [I() + [i] for i in range(m)]
c = [0] * -~n
a = [0] * m
for p, y, i in sorted(l, key=lambda x: x[1]):
c[p] += 1
a[i] = "%06d" % p + "%06d" % c[p]
for t in a:
print(t)
| false | 40 | [
"-l = [[] for _ in [0] * -~n]",
"-a = []",
"-for i in range(m):",
"- p, y = I()",
"- l[p].append([y, i])",
"-for p in range(1, n + 1):",
"- for i, t in enumerate(sorted(l[p])):",
"- a.append([t[1], \"%06d\" % p + \"%06d\" % -~i])",
"-for t in sorted(a):",
"- print((t[1]))",
"+... | false | 0.098106 | 0.059522 | 1.648237 | [
"s813517543",
"s350330047"
] |
u573754721 | p02900 | python | s158428130 | s306196377 | 258 | 130 | 5,304 | 5,084 | Accepted | Accepted | 49.61 | import fractions
a,b=list(map(int,input().split()))
g=fractions.gcd(a,b)
#print(g)
ans=1
i=2
while i*i<=g:
if(g%i==0):
ans+=1
while g%i==0:
g/=i
i=i+1
if(g!=1):ans+=1
print(ans) | from fractions import gcd
a,b=list(map(int,input().split()))
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:
cnt+=1
temp //= i
arr.append([i, cnt]... | 15 | 27 | 222 | 509 | import fractions
a, b = list(map(int, input().split()))
g = fractions.gcd(a, b)
# print(g)
ans = 1
i = 2
while i * i <= g:
if g % i == 0:
ans += 1
while g % i == 0:
g /= i
i = i + 1
if g != 1:
ans += 1
print(ans)
| from fractions import gcd
a, b = list(map(int, input().split()))
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:
cnt += 1
temp //= i
arr.append... | false | 44.444444 | [
"-import fractions",
"+from fractions import gcd",
"-g = fractions.gcd(a, b)",
"-# print(g)",
"-ans = 1",
"-i = 2",
"-while i * i <= g:",
"- if g % i == 0:",
"- ans += 1",
"- while g % i == 0:",
"- g /= i",
"- i = i + 1",
"-if g != 1:",
"- ans += 1",
"-p... | false | 0.077323 | 0.054137 | 1.428271 | [
"s158428130",
"s306196377"
] |
u840579553 | p02726 | python | s936960497 | s460958569 | 488 | 280 | 49,372 | 46,172 | Accepted | Accepted | 42.62 | """
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools impo... | """
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools impo... | 134 | 112 | 2,748 | 2,305 | """
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations... | """
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations... | false | 16.41791 | [
"- g = [[] for _ in range(n)]",
"- for i in range(n - 1):",
"- g[i].append(i + 1)",
"- g[i + 1].append(i)",
"- x -= 1",
"- y -= 1",
"- g[x].append(y)",
"- g[y].append(x)",
"- d = {}",
"- for i in range(n):",
"- d[i] = 0",
"- for i in range(n):",
... | false | 0.096183 | 0.073612 | 1.306628 | [
"s936960497",
"s460958569"
] |
u445404615 | p03220 | python | s542950228 | s105764362 | 185 | 171 | 38,696 | 38,256 | Accepted | Accepted | 7.57 | n = int(eval(input()))
t,a = list(map(int,input().split()))
l = []
m = []
ans = []
l = list(map(int,input().split()))
for i in range(n):
m.append(t - (l[i] * 0.006))
for i in range(n):
ans.append(a - m[i])
print((ans.index(min(ans,key=abs))+1)) | n = int(eval(input()))
t,a = list(map(int,input().split()))
ans = []
l = list(map(int,input().split()))
for i in l:
ans.append(abs(a - (t - (i * 0.006))))
print((ans.index(min(ans))+1)) | 15 | 10 | 260 | 191 | n = int(eval(input()))
t, a = list(map(int, input().split()))
l = []
m = []
ans = []
l = list(map(int, input().split()))
for i in range(n):
m.append(t - (l[i] * 0.006))
for i in range(n):
ans.append(a - m[i])
print((ans.index(min(ans, key=abs)) + 1))
| n = int(eval(input()))
t, a = list(map(int, input().split()))
ans = []
l = list(map(int, input().split()))
for i in l:
ans.append(abs(a - (t - (i * 0.006))))
print((ans.index(min(ans)) + 1))
| false | 33.333333 | [
"-l = []",
"-m = []",
"-for i in range(n):",
"- m.append(t - (l[i] * 0.006))",
"-for i in range(n):",
"- ans.append(a - m[i])",
"-print((ans.index(min(ans, key=abs)) + 1))",
"+for i in l:",
"+ ans.append(abs(a - (t - (i * 0.006))))",
"+print((ans.index(min(ans)) + 1))"
] | false | 0.036195 | 0.049576 | 0.730099 | [
"s542950228",
"s105764362"
] |
u526582609 | p02693 | python | s928309722 | s357668409 | 26 | 24 | 9,020 | 9,168 | Accepted | Accepted | 7.69 | k = int(eval(input()))
a,b = [int(a) for a in input().split()]
c=0
for i in range (a,b+1):
if i%k!=0:
continue
else:
c+=1
break
if c==1:
print("OK")
else:
print("NG")
| k = int(eval(input()))
a,b = [int(a) for a in input().split()]
c=0
for i in range (a,b+1):
if i%k!=0:
c+=1
if c==b-a+1:
print("NG")
else:
print("OK") | 14 | 10 | 209 | 168 | k = int(eval(input()))
a, b = [int(a) for a in input().split()]
c = 0
for i in range(a, b + 1):
if i % k != 0:
continue
else:
c += 1
break
if c == 1:
print("OK")
else:
print("NG")
| k = int(eval(input()))
a, b = [int(a) for a in input().split()]
c = 0
for i in range(a, b + 1):
if i % k != 0:
c += 1
if c == b - a + 1:
print("NG")
else:
print("OK")
| false | 28.571429 | [
"- continue",
"- else:",
"- break",
"-if c == 1:",
"+if c == b - a + 1:",
"+ print(\"NG\")",
"+else:",
"-else:",
"- print(\"NG\")"
] | false | 0.040809 | 0.112917 | 0.361406 | [
"s928309722",
"s357668409"
] |
u325227960 | p02778 | python | s350954390 | s958836275 | 177 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.4 |
s = eval(input())
print(("x"*len(s))) | from sys import stdin
def ans(aa):
return "x" * len(aa[0])
s = list(map(str, stdin.readline().rstrip().split(" ")))
# n = len(s[0])
# print(s)
# print("x" * n)
print((ans(s))) | 3 | 10 | 32 | 188 | s = eval(input())
print(("x" * len(s)))
| from sys import stdin
def ans(aa):
return "x" * len(aa[0])
s = list(map(str, stdin.readline().rstrip().split(" ")))
# n = len(s[0])
# print(s)
# print("x" * n)
print((ans(s)))
| false | 70 | [
"-s = eval(input())",
"-print((\"x\" * len(s)))",
"+from sys import stdin",
"+",
"+",
"+def ans(aa):",
"+ return \"x\" * len(aa[0])",
"+",
"+",
"+s = list(map(str, stdin.readline().rstrip().split(\" \")))",
"+# n = len(s[0])",
"+# print(s)",
"+# print(\"x\" * n)",
"+print((ans(s)))"
] | false | 0.096701 | 0.037625 | 2.570094 | [
"s350954390",
"s958836275"
] |
u137226361 | p02707 | python | s893432778 | s354925701 | 147 | 120 | 30,904 | 32,920 | Accepted | Accepted | 18.37 | import sys
n = int(eval(input()))
A = list(map(int, sys.stdin.readline().split()))
ans = [0] * n
for i in A:
ans[i-1] += 1
for j in ans:
print(j) | import sys
n = int(eval(input()))
A = list(map(int, sys.stdin.readline().split()))
ans = [0] * n
for i in A:
ans[i-1] += 1
print(('\n'.join(map(str, ans)))) | 12 | 11 | 162 | 166 | import sys
n = int(eval(input()))
A = list(map(int, sys.stdin.readline().split()))
ans = [0] * n
for i in A:
ans[i - 1] += 1
for j in ans:
print(j)
| import sys
n = int(eval(input()))
A = list(map(int, sys.stdin.readline().split()))
ans = [0] * n
for i in A:
ans[i - 1] += 1
print(("\n".join(map(str, ans))))
| false | 8.333333 | [
"-for j in ans:",
"- print(j)",
"+print((\"\\n\".join(map(str, ans))))"
] | false | 0.112527 | 0.145663 | 0.772513 | [
"s893432778",
"s354925701"
] |
u077291787 | p03601 | python | s791792492 | s928266359 | 367 | 240 | 3,064 | 3,064 | Accepted | Accepted | 34.6 | # ARC083C - Sugar Water (ABC074C)
# input
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100
# default values
x, y = min(a, b) * 100, 0 # density may be 0%
dens = y / x
# exhaustive search
for i in range(f // A + 1):
for j in range(((f - A * i) // B) + 1):
... | # ARC083C - Sugar Water (ABC074C)
def main():
# input
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100
# default values
x, y = min(a, b) * 100, 0 # density may be 0%
dens = y / x
# exhaustive search
for i in range(f // A + 1):
... | 30 | 34 | 879 | 1,034 | # ARC083C - Sugar Water (ABC074C)
# input
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100
# default values
x, y = min(a, b) * 100, 0 # density may be 0%
dens = y / x
# exhaustive search
for i in range(f // A + 1):
for j in range(((f - A * i) // B) + 1):
if i == 0 and j =... | # ARC083C - Sugar Water (ABC074C)
def main():
# input
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100
# default values
x, y = min(a, b) * 100, 0 # density may be 0%
dens = y / x
# exhaustive search
for i in range(f // A + 1):
for j in rang... | false | 11.764706 | [
"-# input",
"-a, b, c, d, e, f = list(map(int, input().rstrip().split()))",
"-A = a * 100",
"-B = b * 100",
"-# default values",
"-x, y = min(a, b) * 100, 0 # density may be 0%",
"-dens = y / x",
"-# exhaustive search",
"-for i in range(f // A + 1):",
"- for j in range(((f - A * i) // B) + 1):... | false | 0.076577 | 0.040548 | 1.888556 | [
"s791792492",
"s928266359"
] |
u506858457 | p03160 | python | s187914967 | s828603591 | 139 | 121 | 13,928 | 13,976 | Accepted | Accepted | 12.95 | N=int(eval(input()))
H=[int(i) for i in input().split()]
dp=[0]*(N+5)
dp[0]=0
dp[1]=abs(H[1]-H[0])
for i in range(2,N):
dp[i]=min(dp[i-2]+abs(H[i-2]-H[i]),dp[i-1]+abs(H[i-1]-H[i]))
print((dp[N-1])) | N = int(eval(input()))
H=list(map(int,input().split()))
#print(H)
INF=1000000000
dp=[INF]*(N+1)
#print(dp)
dp[0]=0
#print(dp[0])
#print(H[1],H[0])
dp[1]=dp[0]+abs(H[1]-H[0])
for i in range(2,N):
dp[i]=min(dp[i-2]+abs(H[i-2]-H[i]),dp[i-1]+abs(H[i-1]-H[i]))
print((dp[N-1]))
| 8 | 14 | 198 | 282 | N = int(eval(input()))
H = [int(i) for i in input().split()]
dp = [0] * (N + 5)
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
dp[i] = min(dp[i - 2] + abs(H[i - 2] - H[i]), dp[i - 1] + abs(H[i - 1] - H[i]))
print((dp[N - 1]))
| N = int(eval(input()))
H = list(map(int, input().split()))
# print(H)
INF = 1000000000
dp = [INF] * (N + 1)
# print(dp)
dp[0] = 0
# print(dp[0])
# print(H[1],H[0])
dp[1] = dp[0] + abs(H[1] - H[0])
for i in range(2, N):
dp[i] = min(dp[i - 2] + abs(H[i - 2] - H[i]), dp[i - 1] + abs(H[i - 1] - H[i]))
print((dp[N - 1])... | false | 42.857143 | [
"-H = [int(i) for i in input().split()]",
"-dp = [0] * (N + 5)",
"+H = list(map(int, input().split()))",
"+# print(H)",
"+INF = 1000000000",
"+dp = [INF] * (N + 1)",
"+# print(dp)",
"-dp[1] = abs(H[1] - H[0])",
"+# print(dp[0])",
"+# print(H[1],H[0])",
"+dp[1] = dp[0] + abs(H[1] - H[0])"
] | false | 0.034884 | 0.04358 | 0.800446 | [
"s187914967",
"s828603591"
] |
u476604182 | p03142 | python | s764095133 | s171816393 | 290 | 253 | 43,508 | 37,140 | Accepted | Accepted | 12.76 | from collections import defaultdict, deque
def main():
N, M, *L = list(map(int, open(0).read().split()))
dic = defaultdict(list)
par = [0]*N
cnt = [0]*N
for a,b in zip(*[iter(L)]*2):
dic[a-1] += [b-1]
cnt[b-1] += 1
for i in range(N):
if cnt[i]==0:
q = deque([i])
par[i]... | from collections import defaultdict, deque
def main():
N, M, *L = list(map(int, open(0).read().split()))
dic = defaultdict(list)
par = [None]*N
cnt = [0]*(N+1)
for a,b in zip(*[iter(L)]*2):
dic[a] += [b]
cnt[b] += 1
for i in range(1,N+1):
if cnt[i]==0:
q = deque([i])
p... | 29 | 29 | 559 | 566 | from collections import defaultdict, deque
def main():
N, M, *L = list(map(int, open(0).read().split()))
dic = defaultdict(list)
par = [0] * N
cnt = [0] * N
for a, b in zip(*[iter(L)] * 2):
dic[a - 1] += [b - 1]
cnt[b - 1] += 1
for i in range(N):
if cnt[i] == 0:
... | from collections import defaultdict, deque
def main():
N, M, *L = list(map(int, open(0).read().split()))
dic = defaultdict(list)
par = [None] * N
cnt = [0] * (N + 1)
for a, b in zip(*[iter(L)] * 2):
dic[a] += [b]
cnt[b] += 1
for i in range(1, N + 1):
if cnt[i] == 0:
... | false | 0 | [
"- par = [0] * N",
"- cnt = [0] * N",
"+ par = [None] * N",
"+ cnt = [0] * (N + 1)",
"- dic[a - 1] += [b - 1]",
"- cnt[b - 1] += 1",
"- for i in range(N):",
"+ dic[a] += [b]",
"+ cnt[b] += 1",
"+ for i in range(1, N + 1):",
"- par[i] = \"0... | false | 0.069861 | 0.068143 | 1.025204 | [
"s764095133",
"s171816393"
] |
u063052907 | p03212 | python | s880730271 | s684166210 | 93 | 82 | 2,940 | 3,060 | Accepted | Accepted | 11.83 | # coding: utf-8
N = int(eval(input()))
def dfs(s):
if int(s) > N:
return 0
ret = 1 if all(s.count(c) > 0 for c in "753") else 0
for c in "753":
ret += dfs(s + c)
return ret
print((dfs("0"))) | # coding: utf-8
import itertools
N = int(eval(input()))
ans = 0
for i in range(3, len(str(N))+1):
for ptn in itertools.product((3,5,7), repeat=i):
if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):
continue
a = int("".join(list(map(str, ptn))))
if a <= N:
... | 12 | 13 | 227 | 338 | # coding: utf-8
N = int(eval(input()))
def dfs(s):
if int(s) > N:
return 0
ret = 1 if all(s.count(c) > 0 for c in "753") else 0
for c in "753":
ret += dfs(s + c)
return ret
print((dfs("0")))
| # coding: utf-8
import itertools
N = int(eval(input()))
ans = 0
for i in range(3, len(str(N)) + 1):
for ptn in itertools.product((3, 5, 7), repeat=i):
if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):
continue
a = int("".join(list(map(str, ptn))))
if a <= N:
ans... | false | 7.692308 | [
"+import itertools",
"+",
"-",
"-",
"-def dfs(s):",
"- if int(s) > N:",
"- return 0",
"- ret = 1 if all(s.count(c) > 0 for c in \"753\") else 0",
"- for c in \"753\":",
"- ret += dfs(s + c)",
"- return ret",
"-",
"-",
"-print((dfs(\"0\")))",
"+ans = 0",
"+for ... | false | 0.140013 | 0.067534 | 2.07322 | [
"s880730271",
"s684166210"
] |
u044220565 | p02803 | python | s896878485 | s831588800 | 225 | 160 | 9,384 | 9,472 | Accepted | Accepted | 28.89 | # coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#im... | # coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#im... | 67 | 66 | 1,788 | 1,717 | # coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
# from heapq import heappop, heappush
# from collections import defaultdict
sys.setrecursionlimit(10**7)
# import math
# from itertools import product, accumulate, combinations, product
# impor... | # coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
# from heapq import heappop, heappush
# from collections import defaultdict
sys.setrecursionlimit(10**7)
# import math
# from itertools import product, accumulate, combinations, product
# impor... | false | 1.492537 | [
"-def bfs(MAZE, start, seen):",
"- queue = deque([start + (0,)])",
"+def bfs(MAZE, start):",
"+ s = start + (0,)",
"+ queue = deque([s])",
"+ seen = set()",
"+ seen.add(start)",
"- if (y, x) in seen:",
"- continue",
"- seen.add((y, x))",
"- ... | false | 0.089032 | 0.085461 | 1.041782 | [
"s896878485",
"s831588800"
] |
u197300773 | p03039 | python | s805425225 | s728682737 | 81 | 62 | 3,064 | 3,064 | Accepted | Accepted | 23.46 | def comb(n, k):
x, y = 1, 1
k = min(k, n-k)
for i in range(k):
x *= n - i
x %= MOD
y *= i + 1
y %= MOD
return x*modinv(y) % MOD
def modinv(a):
b=MOD
(x, lastx) = (0, 1)
(y, lasty) = (1, 0)
while b != 0:
q = a // b
(a, b) = ... | def comb(n, k):
x, y = 1, 1
k = min(k, n-k)
for i in range(k):
x *= n - i
x %= MOD
y *= i + 1
y %= MOD
return x*modinv(y) % MOD
def modinv(a):
b=MOD
(x, lastx) = (0, 1)
(y, lasty) = (1, 0)
while b != 0:
q = a // b
... | 37 | 38 | 653 | 694 | def comb(n, k):
x, y = 1, 1
k = min(k, n - k)
for i in range(k):
x *= n - i
x %= MOD
y *= i + 1
y %= MOD
return x * modinv(y) % MOD
def modinv(a):
b = MOD
(x, lastx) = (0, 1)
(y, lasty) = (1, 0)
while b != 0:
q = a // b
(a, b) = (b, a % b... | def comb(n, k):
x, y = 1, 1
k = min(k, n - k)
for i in range(k):
x *= n - i
x %= MOD
y *= i + 1
y %= MOD
return x * modinv(y) % MOD
def modinv(a):
b = MOD
(x, lastx) = (0, 1)
(y, lasty) = (1, 0)
while b != 0:
q = a // b
(a, b) = (b, a % b... | false | 2.631579 | [
"-for i in range(1, N):",
"- x = x + i * (N - i)",
"-x = (x * M * M) % MOD",
"+for i in range(1, N // 2 + 1):",
"+ x += 2 * i * (N - i)",
"+if N % 2 == 0:",
"+ x -= N * N // 4",
"-for j in range(1, M):",
"- y = y + j * (M - j)",
"-y = (y * N * N) % MOD",
"-ans = comb(N * M - 2, K - 2... | false | 0.12571 | 0.037194 | 3.379871 | [
"s805425225",
"s728682737"
] |
u588341295 | p04013 | python | s785077744 | s464986085 | 409 | 276 | 94,556 | 5,604 | Accepted | Accepted | 32.52 | # -*- coding: utf-8 -*-
""" 3次元DP """
N,A = list(map(int, input().split()))
xN = list(map(int, input().split()))
X = max(max(xN), A)
# i(=xNリストからどこまでを選べる範囲とするか)からj(=0~N)枚選んで、選んだ値の合計をkにするような選び方の総数
dp = [[[0] * (N*X+1) for j in range(N+1)] for i in range(N+1)]
dp[0][0][0] = 1
ans = 0
for i in range(1,N+1... | # -*- coding: utf-8 -*-
""" 2次元DP """
N,A = list(map(int, input().split()))
xN = list(map(int, input().split()))
X = max(max(xN), A)
# 全てのxから-Aすることで、合計=0,平均=0を求める形にする
yN = [int(i)-A for i in xN]
# 二つ目の添え字はマイナスを取りうるので工夫する
dp = [[0] * (2*N*X+1) for j in range(N+1)]
# 基準点を0じゃなくて真ん中(N*X)にする
dp[0][N*X] = 1
... | 33 | 26 | 990 | 646 | # -*- coding: utf-8 -*-
""" 3次元DP """
N, A = list(map(int, input().split()))
xN = list(map(int, input().split()))
X = max(max(xN), A)
# i(=xNリストからどこまでを選べる範囲とするか)からj(=0~N)枚選んで、選んだ値の合計をkにするような選び方の総数
dp = [[[0] * (N * X + 1) for j in range(N + 1)] for i in range(N + 1)]
dp[0][0][0] = 1
ans = 0
for i in range(1, N + 1):
... | # -*- coding: utf-8 -*-
""" 2次元DP """
N, A = list(map(int, input().split()))
xN = list(map(int, input().split()))
X = max(max(xN), A)
# 全てのxから-Aすることで、合計=0,平均=0を求める形にする
yN = [int(i) - A for i in xN]
# 二つ目の添え字はマイナスを取りうるので工夫する
dp = [[0] * (2 * N * X + 1) for j in range(N + 1)]
# 基準点を0じゃなくて真ん中(N*X)にする
dp[0][N * X] = 1
ans ... | false | 21.212121 | [
"-\"\"\" 3次元DP \"\"\"",
"+\"\"\" 2次元DP \"\"\"",
"-# i(=xNリストからどこまでを選べる範囲とするか)からj(=0~N)枚選んで、選んだ値の合計をkにするような選び方の総数",
"-dp = [[[0] * (N * X + 1) for j in range(N + 1)] for i in range(N + 1)]",
"-dp[0][0][0] = 1",
"+# 全てのxから-Aすることで、合計=0,平均=0を求める形にする",
"+yN = [int(i) - A for i in xN]",
"+# 二つ目の添え字はマイナスを取りう... | false | 0.034096 | 0.03969 | 0.859047 | [
"s785077744",
"s464986085"
] |
u102461423 | p02873 | python | s274551946 | s555384001 | 359 | 153 | 31,656 | 12,828 | Accepted | Accepted | 57.38 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
S = readline().rstrip().decode('utf-8')
N = len(S)+1
from_left = [0]*N
from_right = [0]*N
for i,s in enumerate(S,1):
if s == '>':
from_left[i] = 0
else:
from_le... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
S = read().rstrip().decode('utf-8')
S = S.replace('><','>,<').split(',')
answer = 0
for T in S:
# <<<< >>>> の形
a = T.count('<')
b = T.count('>')
x = a * (a-1) // 2 + b * (... | 29 | 18 | 592 | 374 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
S = readline().rstrip().decode("utf-8")
N = len(S) + 1
from_left = [0] * N
from_right = [0] * N
for i, s in enumerate(S, 1):
if s == ">":
from_left[i] = 0
else:
from_left[i] = fro... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
S = read().rstrip().decode("utf-8")
S = S.replace("><", ">,<").split(",")
answer = 0
for T in S:
# <<<< >>>> の形
a = T.count("<")
b = T.count(">")
x = a * (a - 1) // 2 + b * (b - 1) // 2 +... | false | 37.931034 | [
"-S = readline().rstrip().decode(\"utf-8\")",
"-N = len(S) + 1",
"-from_left = [0] * N",
"-from_right = [0] * N",
"-for i, s in enumerate(S, 1):",
"- if s == \">\":",
"- from_left[i] = 0",
"- else:",
"- from_left[i] = from_left[i - 1] + 1",
"-for i, s in enumerate(S[::-1]):",
... | false | 0.141601 | 0.037526 | 3.773439 | [
"s274551946",
"s555384001"
] |
u150984829 | p00425 | python | s056096838 | s194128399 | 70 | 50 | 5,660 | 5,660 | Accepted | Accepted | 28.57 | while 1:
n=int(eval(input()))
if n==0:break
a=1;s='123456'
for _ in[0]*n:
s=[s[int(e)]for e in{'N':"152304",'E':"310542",'W':"215043",'S':"402351",'R':"024135",'L':"031425"}[input()[0]]]
a+=int(s[0])
print(a)
| import sys
d=sys.stdin
while 1:
n=int(d.readline())
if n==0:break
a=1;s='123456'
for _ in[0]*n:
s=[s[int(e)]for e in{'N':"152304",'E':"310542",'W':"215043",'S':"402351",'R':"024135",'L':"031425"}[d.readline()[0]]]
a+=int(s[0])
print(a)
| 8 | 10 | 219 | 254 | while 1:
n = int(eval(input()))
if n == 0:
break
a = 1
s = "123456"
for _ in [0] * n:
s = [
s[int(e)]
for e in {
"N": "152304",
"E": "310542",
"W": "215043",
"S": "402351",
"R": "0... | import sys
d = sys.stdin
while 1:
n = int(d.readline())
if n == 0:
break
a = 1
s = "123456"
for _ in [0] * n:
s = [
s[int(e)]
for e in {
"N": "152304",
"E": "310542",
"W": "215043",
"S": "402351"... | false | 20 | [
"+import sys",
"+",
"+d = sys.stdin",
"- n = int(eval(input()))",
"+ n = int(d.readline())",
"- }[input()[0]]",
"+ }[d.readline()[0]]"
] | false | 0.092221 | 0.163174 | 0.565166 | [
"s056096838",
"s194128399"
] |
u373047809 | p03440 | python | s745316650 | s983466131 | 327 | 276 | 34,080 | 42,492 | Accepted | Accepted | 15.6 | #!/usr/bin/env python3
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
... | from collections import*
from heapq import*
(n,m),a,*q=[[*map(int,o.split())]for o in open(0)]
t=[-1]*n
def r(x):
while t[x]>=0:x=t[x]
return x
def u(x,y):
x,y=r(x),r(y)
if x!=y:
if t[x]>t[y]:x,y=y,x
t[x]+=t[y];t[y]=x
d=defaultdict(list)
for x,y in q:u(x,y)
i=0
for v in a:d[r(i)]+=v,;i+=1
if len... | 66 | 23 | 1,547 | 487 | #!/usr/bin/env python3
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self... | from collections import *
from heapq import *
(n, m), a, *q = [[*map(int, o.split())] for o in open(0)]
t = [-1] * n
def r(x):
while t[x] >= 0:
x = t[x]
return x
def u(x, y):
x, y = r(x), r(y)
if x != y:
if t[x] > t[y]:
x, y = y, x
t[x] += t[y]
t[y] = x
... | false | 65.151515 | [
"-#!/usr/bin/env python3",
"-class UnionFind:",
"- def __init__(self, n):",
"- self.n = n",
"- self.parents = [-1] * n",
"+from collections import *",
"+from heapq import *",
"- def find(self, x):",
"- if self.parents[x] < 0:",
"- return x",
"- else:"... | false | 0.068477 | 0.073119 | 0.936523 | [
"s745316650",
"s983466131"
] |
u016302627 | p03164 | python | s846969412 | s469715860 | 456 | 260 | 120,812 | 152,120 | Accepted | Accepted | 42.98 | n, w = list(map(int, input().split()))
V, W = [], []
for i in range(n):
wi, vi = list(map(int, input().split()))
W.append(wi)
V.append(vi)
max_sumv = sum(V)
# dp[i][sum_v] := i-1 番目までの品物から価値がsum_v以上を達成するように選んだときの、重さの総和の最小値
dp = [[10 ** 9] * (max_sumv + 1) for _ in range(n+1)]
dp[0][0] =... | n, w = list(map(int, input().split()))
W, V = [], []
sum_v = 0
for i in range(n):
wi, vi = list(map(int ,input().split()))
W.append(wi)
V.append(vi)
sum_v += vi
memo = [[10**9] * (sum_v + 1) for _ in range(n+1)]
memo[0][0] = 0
for i in range(n):
for v_i in range(sum_v + 1):
memo[i+1][v_i] ... | 24 | 23 | 676 | 526 | n, w = list(map(int, input().split()))
V, W = [], []
for i in range(n):
wi, vi = list(map(int, input().split()))
W.append(wi)
V.append(vi)
max_sumv = sum(V)
# dp[i][sum_v] := i-1 番目までの品物から価値がsum_v以上を達成するように選んだときの、重さの総和の最小値
dp = [[10**9] * (max_sumv + 1) for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n):... | n, w = list(map(int, input().split()))
W, V = [], []
sum_v = 0
for i in range(n):
wi, vi = list(map(int, input().split()))
W.append(wi)
V.append(vi)
sum_v += vi
memo = [[10**9] * (sum_v + 1) for _ in range(n + 1)]
memo[0][0] = 0
for i in range(n):
for v_i in range(sum_v + 1):
memo[i + 1][v_i... | false | 4.166667 | [
"-V, W = [], []",
"+W, V = [], []",
"+sum_v = 0",
"-max_sumv = sum(V)",
"-# dp[i][sum_v] := i-1 番目までの品物から価値がsum_v以上を達成するように選んだときの、重さの総和の最小値",
"-dp = [[10**9] * (max_sumv + 1) for _ in range(n + 1)]",
"-dp[0][0] = 0",
"+ sum_v += vi",
"+memo = [[10**9] * (sum_v + 1) for _ in range(n + 1)]",
"+me... | false | 0.037483 | 0.036034 | 1.040213 | [
"s846969412",
"s469715860"
] |
u644907318 | p03372 | python | s477678769 | s529956414 | 702 | 427 | 73,048 | 123,084 | Accepted | Accepted | 39.17 | N,C = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]
V = [0 for _ in range(N)]
Vm = [0 for _ in range(N)]
V[0] = A[0][1]-A[0][0]
Vm[0] = V[0]
for i in range(1,N):
V[i] = V[i-1]+A[i][1]-(A[i][0]-A[i-1][0])
Vm[i] = max(V[i],Vm[i-1])
U = [0 for _ in range(N)]
Um = [... | import heapq
N,C = list(map(int,input().split()))
X = [list(map(int,input().split())) for _ in range(N)]
X.insert(0,[0,0])
A = [0 for _ in range(N+1)]
for i in range(1,N+1):
A[i] = A[i-1]+X[i][1]
A = [A[i]-X[i][0] for i in range(N+1)]
B = [0 for _ in range(N+1)]
B[N] = X[N][1]
for i in range(N-1,0,-1):
... | 23 | 47 | 696 | 1,110 | N, C = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
V = [0 for _ in range(N)]
Vm = [0 for _ in range(N)]
V[0] = A[0][1] - A[0][0]
Vm[0] = V[0]
for i in range(1, N):
V[i] = V[i - 1] + A[i][1] - (A[i][0] - A[i - 1][0])
Vm[i] = max(V[i], Vm[i - 1])
U = [0 for _ in range(N... | import heapq
N, C = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N)]
X.insert(0, [0, 0])
A = [0 for _ in range(N + 1)]
for i in range(1, N + 1):
A[i] = A[i - 1] + X[i][1]
A = [A[i] - X[i][0] for i in range(N + 1)]
B = [0 for _ in range(N + 1)]
B[N] = X[N][1]
for i in range(N ... | false | 51.06383 | [
"+import heapq",
"+",
"-A = [list(map(int, input().split())) for _ in range(N)]",
"-V = [0 for _ in range(N)]",
"-Vm = [0 for _ in range(N)]",
"-V[0] = A[0][1] - A[0][0]",
"-Vm[0] = V[0]",
"+X = [list(map(int, input().split())) for _ in range(N)]",
"+X.insert(0, [0, 0])",
"+A = [0 for _ in range(N... | false | 0.048425 | 0.091271 | 0.530559 | [
"s477678769",
"s529956414"
] |
u491763171 | p00009 | python | s796668380 | s426174246 | 2,760 | 210 | 27,908 | 27,992 | Accepted | Accepted | 92.39 | def sieve(n):
prime = [True] * n
prime[0] = prime[1] = False
for i in range(2, int(n ** 0.5) + 1):
if prime[i]:
for j in range(i * i, n, i):
prime[j] = False
return [i for i in range(2, n) if prime[i]]
while 1:
try:
print(len(sieve(eval(input()... | from bisect import bisect
def sieve(n):
prime = [True] * n
prime[0] = prime[1] = False
for i in range(2, int(n ** 0.5) + 1):
if prime[i]:
for j in range(i * i, n, i):
prime[j] = False
return [i for i in range(2, n) if prime[i]]
primes = sieve(999999)
w... | 14 | 18 | 351 | 406 | def sieve(n):
prime = [True] * n
prime[0] = prime[1] = False
for i in range(2, int(n**0.5) + 1):
if prime[i]:
for j in range(i * i, n, i):
prime[j] = False
return [i for i in range(2, n) if prime[i]]
while 1:
try:
print(len(sieve(eval(input()) + 1)))
... | from bisect import bisect
def sieve(n):
prime = [True] * n
prime[0] = prime[1] = False
for i in range(2, int(n**0.5) + 1):
if prime[i]:
for j in range(i * i, n, i):
prime[j] = False
return [i for i in range(2, n) if prime[i]]
primes = sieve(999999)
while 1:
tr... | false | 22.222222 | [
"+from bisect import bisect",
"+",
"+",
"+primes = sieve(999999)",
"- print(len(sieve(eval(input()) + 1)))",
"+ print(bisect(primes, eval(input())))"
] | false | 0.133427 | 0.311452 | 0.428404 | [
"s796668380",
"s426174246"
] |
u787456042 | p03317 | python | s367170782 | s088764578 | 42 | 17 | 13,812 | 3,060 | Accepted | Accepted | 59.52 | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
print((-((1-n)//(k-1)))) | print((eval("-(-~-"+input().replace(" ","//~-")+")"))) | 3 | 1 | 93 | 52 | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
print((-((1 - n) // (k - 1))))
| print((eval("-(-~-" + input().replace(" ", "//~-") + ")")))
| false | 66.666667 | [
"-n, k = list(map(int, input().split()))",
"-a = list(map(int, input().split()))",
"-print((-((1 - n) // (k - 1))))",
"+print((eval(\"-(-~-\" + input().replace(\" \", \"//~-\") + \")\")))"
] | false | 0.047793 | 0.036094 | 1.324098 | [
"s367170782",
"s088764578"
] |
u133936772 | p03695 | python | s326305511 | s733303686 | 29 | 25 | 9,124 | 9,096 | Accepted | Accepted | 13.79 | n,*l=list(map(int,open(0).read().split()))
c=[0]*13
for i in l: c[i//400]+=1
a=8-c[:8].count(0)
print((max(1,a),a+sum(c[8:]))) | n,*a=list(map(int,open(0).read().split()))
l=[i//400 for i in a if i<3200]
c=len(set(l))
print((max(1,c),c+n-len(l))) | 5 | 4 | 122 | 112 | n, *l = list(map(int, open(0).read().split()))
c = [0] * 13
for i in l:
c[i // 400] += 1
a = 8 - c[:8].count(0)
print((max(1, a), a + sum(c[8:])))
| n, *a = list(map(int, open(0).read().split()))
l = [i // 400 for i in a if i < 3200]
c = len(set(l))
print((max(1, c), c + n - len(l)))
| false | 20 | [
"-n, *l = list(map(int, open(0).read().split()))",
"-c = [0] * 13",
"-for i in l:",
"- c[i // 400] += 1",
"-a = 8 - c[:8].count(0)",
"-print((max(1, a), a + sum(c[8:])))",
"+n, *a = list(map(int, open(0).read().split()))",
"+l = [i // 400 for i in a if i < 3200]",
"+c = len(set(l))",
"+print((m... | false | 0.047613 | 0.043785 | 1.087446 | [
"s326305511",
"s733303686"
] |
u999529302 | p02657 | python | s433586120 | s492555059 | 65 | 29 | 61,768 | 9,128 | Accepted | Accepted | 55.38 | A, B = list(map(float,input().split()))
result = int(A * B)
print(result) | x, y = list(map(int, input().split()))
result = x * y
print(result)
| 5 | 5 | 79 | 69 | A, B = list(map(float, input().split()))
result = int(A * B)
print(result)
| x, y = list(map(int, input().split()))
result = x * y
print(result)
| false | 0 | [
"-A, B = list(map(float, input().split()))",
"-result = int(A * B)",
"+x, y = list(map(int, input().split()))",
"+result = x * y"
] | false | 0.043125 | 0.072115 | 0.597997 | [
"s433586120",
"s492555059"
] |
u418149936 | p02623 | python | s643958049 | s344891616 | 304 | 278 | 39,912 | 42,932 | Accepted | Accepted | 8.55 | N, M, K = list(map(int, input().split(' ')))
A_ls = [0] + list(map(int, input().split(' ')))
B_ls = [0] + list(map(int, input().split(' ')))
for i in range(1, N+1):
A_ls[i] += A_ls[i - 1]
for i in range(1, M+1):
B_ls[i] += B_ls[i - 1]
a_cnt, b_cnt, rst = 0, M, 0
while a_cnt < N + 1:
if A_ls[a... | N, M, K = list(map(int, input().split(' ')))
A_ls = [0] + list(map(int, input().split(' ')))
for i in range(N):
A_ls[i + 1] += A_ls[i]
B_ls = [0] + list(map(int, input().split(' ')))
for i in range(M):
B_ls[i + 1] += B_ls[i]
a_cnt, b_cnt, rst = 0, M, 0
for a_cnt in range(N + 1):
if A_ls[a_cnt] > ... | 19 | 16 | 478 | 439 | N, M, K = list(map(int, input().split(" ")))
A_ls = [0] + list(map(int, input().split(" ")))
B_ls = [0] + list(map(int, input().split(" ")))
for i in range(1, N + 1):
A_ls[i] += A_ls[i - 1]
for i in range(1, M + 1):
B_ls[i] += B_ls[i - 1]
a_cnt, b_cnt, rst = 0, M, 0
while a_cnt < N + 1:
if A_ls[a_cnt] > K:
... | N, M, K = list(map(int, input().split(" ")))
A_ls = [0] + list(map(int, input().split(" ")))
for i in range(N):
A_ls[i + 1] += A_ls[i]
B_ls = [0] + list(map(int, input().split(" ")))
for i in range(M):
B_ls[i + 1] += B_ls[i]
a_cnt, b_cnt, rst = 0, M, 0
for a_cnt in range(N + 1):
if A_ls[a_cnt] > K:
... | false | 15.789474 | [
"+for i in range(N):",
"+ A_ls[i + 1] += A_ls[i]",
"-for i in range(1, N + 1):",
"- A_ls[i] += A_ls[i - 1]",
"-for i in range(1, M + 1):",
"- B_ls[i] += B_ls[i - 1]",
"+for i in range(M):",
"+ B_ls[i + 1] += B_ls[i]",
"-while a_cnt < N + 1:",
"+for a_cnt in range(N + 1):",
"- whil... | false | 0.036518 | 0.035014 | 1.042951 | [
"s643958049",
"s344891616"
] |
u580093517 | p03160 | python | s608143219 | s802233332 | 139 | 127 | 13,928 | 13,928 | Accepted | Accepted | 8.63 | n = int(eval(input()))
H = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2,n):
dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]),dp[i-1]+abs(H[i]-H[i-1]))
print((dp[-1])) | N = int(eval(input()))
H = list(map(int,input().split()))
dp = [0]*N
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
print((dp[-1])) | 8 | 7 | 206 | 193 | n = int(eval(input()))
H = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, n):
dp[i] = min(dp[i - 2] + abs(H[i] - H[i - 2]), dp[i - 1] + abs(H[i] - H[i - 1]))
print((dp[-1]))
| N = int(eval(input()))
H = list(map(int, input().split()))
dp = [0] * N
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))
print((dp[-1]))
| false | 12.5 | [
"-n = int(eval(input()))",
"+N = int(eval(input()))",
"-dp = [0] * n",
"-dp[0] = 0",
"+dp = [0] * N",
"-for i in range(2, n):",
"- dp[i] = min(dp[i - 2] + abs(H[i] - H[i - 2]), dp[i - 1] + abs(H[i] - H[i - 1]))",
"+for i in range(2, N):",
"+ dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i -... | false | 0.040284 | 0.039687 | 1.015037 | [
"s608143219",
"s802233332"
] |
u309120194 | p02753 | python | s243022027 | s744030376 | 30 | 25 | 9,028 | 9,096 | Accepted | Accepted | 16.67 | S = eval(input())
if S == 'AAA' or S == 'BBB': print('No')
else: print('Yes') | S = eval(input())
# AAAかBBBならNo、それ以外でYes
if S[0] == S[1] and S[1] == S[2]: print('No')
else: print('Yes') | 4 | 5 | 76 | 105 | S = eval(input())
if S == "AAA" or S == "BBB":
print("No")
else:
print("Yes")
| S = eval(input())
# AAAかBBBならNo、それ以外でYes
if S[0] == S[1] and S[1] == S[2]:
print("No")
else:
print("Yes")
| false | 20 | [
"-if S == \"AAA\" or S == \"BBB\":",
"+# AAAかBBBならNo、それ以外でYes",
"+if S[0] == S[1] and S[1] == S[2]:"
] | false | 0.040635 | 0.047014 | 0.86433 | [
"s243022027",
"s744030376"
] |
u636683284 | p03166 | python | s626998210 | s849814549 | 564 | 277 | 201,196 | 97,612 | Accepted | Accepted | 50.89 | import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict
n,m = list(map(int,input().split()))
d = defaultdict(list)
for i in range(m):
x,y = list(map(int,input().split()))
d[x-1].append(y-1)
dp = [-1]*n
def rec(v):
if dp[v] != -1:
return dp[v]
res = 0
fo... | from collections import defaultdict, deque
n,m = list(map(int,input().split()))
d = defaultdict(list)
deg = [0]*n # 各頂点の入次数
for i in range(m):
x,y = list(map(int,input().split()))
d[x-1].append(y-1)
deg[y-1] += 1
que = deque([])
for v in range(n):
if deg[v] == 0:
que.append(v)
... | 25 | 29 | 458 | 626 | import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict
n, m = list(map(int, input().split()))
d = defaultdict(list)
for i in range(m):
x, y = list(map(int, input().split()))
d[x - 1].append(y - 1)
dp = [-1] * n
def rec(v):
if dp[v] != -1:
return dp[v]
res = 0
for nv ... | from collections import defaultdict, deque
n, m = list(map(int, input().split()))
d = defaultdict(list)
deg = [0] * n # 各頂点の入次数
for i in range(m):
x, y = list(map(int, input().split()))
d[x - 1].append(y - 1)
deg[y - 1] += 1
que = deque([])
for v in range(n):
if deg[v] == 0:
que.append(v)
dp =... | false | 13.793103 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**9)",
"-from collections import defaultdict",
"+from collections import defaultdict, deque",
"+deg = [0] * n # 各頂点の入次数",
"-dp = [-1] * n",
"-",
"-",
"-def rec(v):",
"- if dp[v] != -1:",
"- return dp[v]",
"- res = 0",
"+ deg[y ... | false | 0.033443 | 0.078914 | 0.423791 | [
"s626998210",
"s849814549"
] |
u466335531 | p03307 | python | s108773503 | s103223992 | 20 | 17 | 3,316 | 2,940 | Accepted | Accepted | 15 | N=int(eval(input()))
if N%2: print((N*2))
else: print(N) | N=int(eval(input()))
print(((N%2+1)*N)) | 3 | 2 | 50 | 32 | N = int(eval(input()))
if N % 2:
print((N * 2))
else:
print(N)
| N = int(eval(input()))
print(((N % 2 + 1) * N))
| false | 33.333333 | [
"-if N % 2:",
"- print((N * 2))",
"-else:",
"- print(N)",
"+print(((N % 2 + 1) * N))"
] | false | 0.06319 | 0.061805 | 1.022406 | [
"s108773503",
"s103223992"
] |
u125545880 | p03031 | python | s437215004 | s347776737 | 27 | 22 | 3,064 | 3,064 | Accepted | Accepted | 18.52 | import sys
readline = sys.stdin.readline
def main():
N, M = list(map(int, readline().split()))
S = []
for i in range(M):
k, *tmp = [int(i) for i in readline().split()]
S.append(tmp)
p = list(map(int, readline().split()))
# bit
ans = 0
for i in range(2... | import sys
readline = sys.stdin.readline
def main():
N, M = list(map(int, readline().split()))
s = []
for _ in range(M):
k, *stmp = list(map(int, readline().split()))
s.append(set(stmp))
p = list(map(int, readline().split()))
ans = 0
for i in range(2**N):
... | 35 | 34 | 723 | 719 | import sys
readline = sys.stdin.readline
def main():
N, M = list(map(int, readline().split()))
S = []
for i in range(M):
k, *tmp = [int(i) for i in readline().split()]
S.append(tmp)
p = list(map(int, readline().split()))
# bit
ans = 0
for i in range(2**N):
select =... | import sys
readline = sys.stdin.readline
def main():
N, M = list(map(int, readline().split()))
s = []
for _ in range(M):
k, *stmp = list(map(int, readline().split()))
s.append(set(stmp))
p = list(map(int, readline().split()))
ans = 0
for i in range(2**N):
flag = True
... | false | 2.857143 | [
"- S = []",
"- for i in range(M):",
"- k, *tmp = [int(i) for i in readline().split()]",
"- S.append(tmp)",
"+ s = []",
"+ for _ in range(M):",
"+ k, *stmp = list(map(int, readline().split()))",
"+ s.append(set(stmp))",
"- # bit",
"- select = []",
... | false | 0.042661 | 0.044184 | 0.965526 | [
"s437215004",
"s347776737"
] |
u139112865 | p03317 | python | s433495402 | s340061343 | 40 | 18 | 13,880 | 4,724 | Accepted | Accepted | 55 | #101_C
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
print((-(-(N-1)//(K-1)))) | #101_C
N,K=list(map(int,input().split()))
A=eval(input())
print((-(-(N-1)//(K-1)))) | 4 | 4 | 95 | 72 | # 101_C
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
print((-(-(N - 1) // (K - 1))))
| # 101_C
N, K = list(map(int, input().split()))
A = eval(input())
print((-(-(N - 1) // (K - 1))))
| false | 0 | [
"-A = list(map(int, input().split()))",
"+A = eval(input())"
] | false | 0.104758 | 0.070973 | 1.476037 | [
"s433495402",
"s340061343"
] |
u645250356 | p03329 | python | s112194503 | s762908231 | 704 | 333 | 5,928 | 70,092 | Accepted | Accepted | 52.7 | from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
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())
n = inp()
dp = [mod for i ... | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
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()))
n = ... | 31 | 27 | 698 | 648 | from collections import Counter, defaultdict
import sys, heapq, bisect, math, itertools, string, queue, datetime
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())
n = ... | from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions
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().s... | false | 12.903226 | [
"-from collections import Counter, defaultdict",
"-import sys, heapq, bisect, math, itertools, string, queue, datetime",
"+from collections import Counter, defaultdict, deque",
"+from heapq import heappop, heappush, heapify",
"+import sys, bisect, math, itertools, fractions",
"+sys.setrecursionlimit(10**8... | false | 0.148865 | 0.131564 | 1.131502 | [
"s112194503",
"s762908231"
] |
u062691227 | p03162 | python | s190886508 | s666315992 | 733 | 623 | 84,568 | 47,320 | Accepted | Accepted | 15.01 | from copy import deepcopy
n = int(eval(input()))
eff = [list(map(int, input().split())) for _ in range(n)]
dp = [[float('-inf')] * 3 for _ in range(n)]
dp[0] = deepcopy(eff[0])
for i in range(1, n):
for yi in range(3):
for ti in range(3):
if yi != ti:
dp[i][ti] = m... | n = int(eval(input()))
da = db = dc = 0
for i in range(n):
a, b, c = list(map(int, input().split()))
da, db, dc = max(db, dc) + a, max(da, dc) + b, max(da, db) + c
print((max(da, db, dc))) | 15 | 8 | 375 | 191 | from copy import deepcopy
n = int(eval(input()))
eff = [list(map(int, input().split())) for _ in range(n)]
dp = [[float("-inf")] * 3 for _ in range(n)]
dp[0] = deepcopy(eff[0])
for i in range(1, n):
for yi in range(3):
for ti in range(3):
if yi != ti:
dp[i][ti] = max(dp[i][ti], ... | n = int(eval(input()))
da = db = dc = 0
for i in range(n):
a, b, c = list(map(int, input().split()))
da, db, dc = max(db, dc) + a, max(da, dc) + b, max(da, db) + c
print((max(da, db, dc)))
| false | 46.666667 | [
"-from copy import deepcopy",
"-",
"-eff = [list(map(int, input().split())) for _ in range(n)]",
"-dp = [[float(\"-inf\")] * 3 for _ in range(n)]",
"-dp[0] = deepcopy(eff[0])",
"-for i in range(1, n):",
"- for yi in range(3):",
"- for ti in range(3):",
"- if yi != ti:",
"- ... | false | 0.040045 | 0.036402 | 1.100072 | [
"s190886508",
"s666315992"
] |
u078349616 | p02659 | python | s865211767 | s102556044 | 27 | 22 | 10,068 | 9,104 | Accepted | Accepted | 18.52 | from decimal import Decimal, ROUND_FLOOR
A, B = input().split()
A = int(A)
B = Decimal(B)
ans = Decimal(str(A*B)).quantize(Decimal('0'), rounding=ROUND_FLOOR)
print(ans) | A, B = input().split()
A = int(A)
B = int(float(B)*1000)
ans = A*B//1000
print(ans) | 8 | 5 | 178 | 87 | from decimal import Decimal, ROUND_FLOOR
A, B = input().split()
A = int(A)
B = Decimal(B)
ans = Decimal(str(A * B)).quantize(Decimal("0"), rounding=ROUND_FLOOR)
print(ans)
| A, B = input().split()
A = int(A)
B = int(float(B) * 1000)
ans = A * B // 1000
print(ans)
| false | 37.5 | [
"-from decimal import Decimal, ROUND_FLOOR",
"-",
"-B = Decimal(B)",
"-ans = Decimal(str(A * B)).quantize(Decimal(\"0\"), rounding=ROUND_FLOOR)",
"+B = int(float(B) * 1000)",
"+ans = A * B // 1000"
] | false | 0.039766 | 0.037326 | 1.065379 | [
"s865211767",
"s102556044"
] |
u963402991 | p02265 | python | s161055073 | s668150249 | 4,940 | 3,930 | 557,100 | 71,928 | Accepted | Accepted | 20.45 | # -*- coding:utf-8 -*-
import collections
n = int(eval(input()))
command = [input().split() for i in range(n)]
ans = collections.deque()
for i in range(n):
if command[i][0] == "insert":
ans.appendleft(command[i][1])
elif ans == []:
continue
elif command[i][0] == "delete":
... | # -*- coding:utf-8 -*-
import collections
n = int(eval(input()))
ans = collections.deque()
for i in range(n):
command = input().split()
if command[0] == "insert":
ans.appendleft(command[1])
elif ans == []:
continue
elif command[0] == "delete":
try:
ans.r... | 22 | 22 | 518 | 483 | # -*- coding:utf-8 -*-
import collections
n = int(eval(input()))
command = [input().split() for i in range(n)]
ans = collections.deque()
for i in range(n):
if command[i][0] == "insert":
ans.appendleft(command[i][1])
elif ans == []:
continue
elif command[i][0] == "delete":
try:
... | # -*- coding:utf-8 -*-
import collections
n = int(eval(input()))
ans = collections.deque()
for i in range(n):
command = input().split()
if command[0] == "insert":
ans.appendleft(command[1])
elif ans == []:
continue
elif command[0] == "delete":
try:
ans.remove(command... | false | 0 | [
"-command = [input().split() for i in range(n)]",
"- if command[i][0] == \"insert\":",
"- ans.appendleft(command[i][1])",
"+ command = input().split()",
"+ if command[0] == \"insert\":",
"+ ans.appendleft(command[1])",
"- elif command[i][0] == \"delete\":",
"+ elif command... | false | 0.03774 | 0.106115 | 0.355651 | [
"s161055073",
"s668150249"
] |
u227082700 | p02793 | python | s188387891 | s371743732 | 1,934 | 951 | 4,084 | 4,084 | Accepted | Accepted | 50.83 | def gcd(a,b):
while b:a,b=b,a%b
return a
def lcm(a,b):return a*b//gcd(a,b)
n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
mod=10**9+7
l=a[0]
for i in range(1,n):l=lcm(l,a[i])
for i in a:
ans+=l*pow(i,mod-2,mod)%mod
ans%=mod
print(ans) | def gcd(a,b):
while b:a,b=b,a%b
return a
def lcm(a,b):return a*b//gcd(a,b)
n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
mod=10**9+7
l=a[0]
for i in range(1,n):l=lcm(l,a[i])
l%=mod
for i in a:
ans+=l*pow(i,mod-2,mod)%mod
ans%=mod
print(ans) | 14 | 15 | 262 | 270 | def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd(a, b)
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
l = a[0]
for i in range(1, n):
l = lcm(l, a[i])
for i in a:
ans += l * pow(i, mod - 2, mod) % mod
ans %= mod
pr... | def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd(a, b)
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
l = a[0]
for i in range(1, n):
l = lcm(l, a[i])
l %= mod
for i in a:
ans += l * pow(i, mod - 2, mod) % mod
ans ... | false | 6.666667 | [
"+l %= mod"
] | false | 0.041816 | 0.035533 | 1.176801 | [
"s188387891",
"s371743732"
] |
u247922466 | p03042 | python | s931056066 | s752853143 | 22 | 17 | 3,188 | 3,064 | Accepted | Accepted | 22.73 | import re
s = list(eval(input()))
match_MMYY = re.match(r'0[1-9]|1[0-2]', "".join(s[:2]))
match_YYMM = re.match(r'0[1-9]|1[0-2]', "".join(s[2:]))
if (match_YYMM and match_MMYY):
answer = 'AMBIGUOUS'
elif(match_YYMM):
answer = 'YYMM'
elif(match_MMYY):
answer = 'MMYY'
else:
answer = 'NA'
pri... | s = list(eval(input()))
MMYY = False
YYMM = False
for x in range(1,13):
MMYY = MMYY or (x == int(''.join(s[:2])))
YYMM = YYMM or (x == int(''.join(s[2:])))
if MMYY and YYMM:
ans = 'AMBIGUOUS'
elif(YYMM):
ans = 'YYMM'
elif(MMYY):
ans = 'MMYY'
else:
ans = 'NA'
print(ans) | 14 | 16 | 324 | 303 | import re
s = list(eval(input()))
match_MMYY = re.match(r"0[1-9]|1[0-2]", "".join(s[:2]))
match_YYMM = re.match(r"0[1-9]|1[0-2]", "".join(s[2:]))
if match_YYMM and match_MMYY:
answer = "AMBIGUOUS"
elif match_YYMM:
answer = "YYMM"
elif match_MMYY:
answer = "MMYY"
else:
answer = "NA"
print(answer)
| s = list(eval(input()))
MMYY = False
YYMM = False
for x in range(1, 13):
MMYY = MMYY or (x == int("".join(s[:2])))
YYMM = YYMM or (x == int("".join(s[2:])))
if MMYY and YYMM:
ans = "AMBIGUOUS"
elif YYMM:
ans = "YYMM"
elif MMYY:
ans = "MMYY"
else:
ans = "NA"
print(ans)
| false | 12.5 | [
"-import re",
"-",
"-match_MMYY = re.match(r\"0[1-9]|1[0-2]\", \"\".join(s[:2]))",
"-match_YYMM = re.match(r\"0[1-9]|1[0-2]\", \"\".join(s[2:]))",
"-if match_YYMM and match_MMYY:",
"- answer = \"AMBIGUOUS\"",
"-elif match_YYMM:",
"- answer = \"YYMM\"",
"-elif match_MMYY:",
"- answer = \"M... | false | 0.041011 | 0.046469 | 0.882552 | [
"s931056066",
"s752853143"
] |
u440180827 | p02396 | python | s737766875 | s475611346 | 120 | 60 | 7,396 | 7,420 | Accepted | Accepted | 50 | i = 1
x = eval(input())
while x != '0':
print(('Case {0}: {1}'.format(i, x)))
x = eval(input())
i += 1 | import sys
x = sys.stdin.readline().strip()
i = 1
while x != '0':
print(('Case {0}: {1}'.format(i, x)))
x = sys.stdin.readline().strip()
i += 1 | 6 | 7 | 105 | 159 | i = 1
x = eval(input())
while x != "0":
print(("Case {0}: {1}".format(i, x)))
x = eval(input())
i += 1
| import sys
x = sys.stdin.readline().strip()
i = 1
while x != "0":
print(("Case {0}: {1}".format(i, x)))
x = sys.stdin.readline().strip()
i += 1
| false | 14.285714 | [
"+import sys",
"+",
"+x = sys.stdin.readline().strip()",
"-x = eval(input())",
"- x = eval(input())",
"+ x = sys.stdin.readline().strip()"
] | false | 0.045971 | 0.046873 | 0.980756 | [
"s737766875",
"s475611346"
] |
u902151549 | p03835 | python | s795108858 | s162945673 | 1,579 | 1,393 | 5,812 | 5,556 | Accepted | Accepted | 11.78 | # coding: utf-8
import time
import re
import math
import fractions
def main():
K,S=list(map(int,input().split()))
count=0
for x in range(0,K+1):
for y in range(0,K+1):
if(x+y>S):break
if S-x-y<=K and S-x-y>=0:
count+=1
print(count)
start=ti... | # coding: utf-8
import time
import re
import math
import fractions
def main():
K,S=list(map(int,input().split()))
count=0
for x in range(0,K+1):
for y in range(0,K+1):
if S-x-y<=K and S-x-y>=0:
count+=1
print(count)
start=time.time()
main()
#print("処理... | 22 | 21 | 467 | 438 | # coding: utf-8
import time
import re
import math
import fractions
def main():
K, S = list(map(int, input().split()))
count = 0
for x in range(0, K + 1):
for y in range(0, K + 1):
if x + y > S:
break
if S - x - y <= K and S - x - y >= 0:
coun... | # coding: utf-8
import time
import re
import math
import fractions
def main():
K, S = list(map(int, input().split()))
count = 0
for x in range(0, K + 1):
for y in range(0, K + 1):
if S - x - y <= K and S - x - y >= 0:
count += 1
print(count)
start = time.time()
ma... | false | 4.545455 | [
"- if x + y > S:",
"- break"
] | false | 0.036692 | 0.069339 | 0.529164 | [
"s795108858",
"s162945673"
] |
u403331159 | p02785 | python | s628865162 | s669544643 | 217 | 158 | 26,564 | 26,024 | Accepted | Accepted | 27.19 | n,k=list(map(int,input().split()))
h=list(map(int,input().split()))
s=sorted(h,reverse=True)
cnt=0
for i in range(n):
cnt+=s[i]
if k>=n:
print((0))
exit()
else:
for i in range(k):
cnt-=s[i]
print(cnt) | n,k=list(map(int,input().split()))
h=list(map(int,input().split()))
s=sorted(h)
s.reverse()
print((sum(s[k:]))) | 13 | 5 | 218 | 107 | n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
s = sorted(h, reverse=True)
cnt = 0
for i in range(n):
cnt += s[i]
if k >= n:
print((0))
exit()
else:
for i in range(k):
cnt -= s[i]
print(cnt)
| n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
s = sorted(h)
s.reverse()
print((sum(s[k:])))
| false | 61.538462 | [
"-s = sorted(h, reverse=True)",
"-cnt = 0",
"-for i in range(n):",
"- cnt += s[i]",
"-if k >= n:",
"- print((0))",
"- exit()",
"-else:",
"- for i in range(k):",
"- cnt -= s[i]",
"-print(cnt)",
"+s = sorted(h)",
"+s.reverse()",
"+print((sum(s[k:])))"
] | false | 0.037018 | 0.038637 | 0.958096 | [
"s628865162",
"s669544643"
] |
u367701763 | p03371 | python | s242313636 | s791722840 | 114 | 65 | 3,060 | 64,812 | Accepted | Accepted | 42.98 | a, b, c, x, y = list(map(int, input().split()))
res = a * x + b * y
for i in range(1, max(x, y) + 1):
res = min(res, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i)
print(res) | A, B, C, X, Y = list(map(int, input().split()))
res = A*X + B*Y
for i in range(max(X,Y)):
if i >= X:
res = min(res-B+2*C,res)
elif i >= Y:
res = min(res-A+2*C,res)
else:
res = min(res-A-B+2*C,res)
print(res) | 5 | 10 | 186 | 246 | a, b, c, x, y = list(map(int, input().split()))
res = a * x + b * y
for i in range(1, max(x, y) + 1):
res = min(res, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i)
print(res)
| A, B, C, X, Y = list(map(int, input().split()))
res = A * X + B * Y
for i in range(max(X, Y)):
if i >= X:
res = min(res - B + 2 * C, res)
elif i >= Y:
res = min(res - A + 2 * C, res)
else:
res = min(res - A - B + 2 * C, res)
print(res)
| false | 50 | [
"-a, b, c, x, y = list(map(int, input().split()))",
"-res = a * x + b * y",
"-for i in range(1, max(x, y) + 1):",
"- res = min(res, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i)",
"+A, B, C, X, Y = list(map(int, input().split()))",
"+res = A * X + B * Y",
"+for i in range(max(X, Y)):",
"+ i... | false | 0.079044 | 0.046161 | 1.712355 | [
"s242313636",
"s791722840"
] |
u778878014 | p03073 | python | s096498911 | s546673428 | 38 | 35 | 4,640 | 4,640 | Accepted | Accepted | 7.89 | tiles = list(map(int, eval(input())))
even = tiles[0::2]
odd = tiles[1::2]
if even.count(0) >= even.count(1):
ans1 = even.count(1) + odd.count(0)
else:
ans1 = even.count(0) + odd.count(1)
if odd.count(0) >= odd.count(1):
ans2 = odd.count(1) + even.count(0)
else:
ans2 = odd.coun... | tiles = list(map(int, eval(input())))
even = tiles[0::2]
odd = tiles[1::2]
even0 = even.count(0)
even1 = even.count(1)
odd0 = odd.count(0)
odd1 = odd.count(1)
if even0 >= max(even1, odd0, odd1) or odd1 >= max(even0, even1, odd0):
print((even1 + odd0))
elif even1 >= max(even0, odd0, odd1) or odd0 >=... | 18 | 15 | 361 | 364 | tiles = list(map(int, eval(input())))
even = tiles[0::2]
odd = tiles[1::2]
if even.count(0) >= even.count(1):
ans1 = even.count(1) + odd.count(0)
else:
ans1 = even.count(0) + odd.count(1)
if odd.count(0) >= odd.count(1):
ans2 = odd.count(1) + even.count(0)
else:
ans2 = odd.count(0) + even.count(1)
print... | tiles = list(map(int, eval(input())))
even = tiles[0::2]
odd = tiles[1::2]
even0 = even.count(0)
even1 = even.count(1)
odd0 = odd.count(0)
odd1 = odd.count(1)
if even0 >= max(even1, odd0, odd1) or odd1 >= max(even0, even1, odd0):
print((even1 + odd0))
elif even1 >= max(even0, odd0, odd1) or odd0 >= max(even0, even1... | false | 16.666667 | [
"-if even.count(0) >= even.count(1):",
"- ans1 = even.count(1) + odd.count(0)",
"-else:",
"- ans1 = even.count(0) + odd.count(1)",
"-if odd.count(0) >= odd.count(1):",
"- ans2 = odd.count(1) + even.count(0)",
"-else:",
"- ans2 = odd.count(0) + even.count(1)",
"-print((min(ans1, ans2)))",... | false | 0.041566 | 0.04195 | 0.990842 | [
"s096498911",
"s546673428"
] |
u400765446 | p02394 | python | s001194919 | s300614071 | 40 | 20 | 7,816 | 5,596 | Accepted | Accepted | 50 | def main():
x = eval(input())
x1, x2, x3, x4, x5 = x.split(' ')
W = int(x1)
H = int(x2)
x = int(x3)
y = int(x4)
r = int(x5)
if r <= x <= W-r and r <= y <= H-r:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main() | W, H, x, y, r = list(map(int, input().split()))
chk1 = r <= x <= W - r
chk2 = r <= y <= H - r
chk0 = "Yes" if (chk1 == True and chk2 == True) else "No"
print(chk0)
| 16 | 6 | 300 | 164 | def main():
x = eval(input())
x1, x2, x3, x4, x5 = x.split(" ")
W = int(x1)
H = int(x2)
x = int(x3)
y = int(x4)
r = int(x5)
if r <= x <= W - r and r <= y <= H - r:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
| W, H, x, y, r = list(map(int, input().split()))
chk1 = r <= x <= W - r
chk2 = r <= y <= H - r
chk0 = "Yes" if (chk1 == True and chk2 == True) else "No"
print(chk0)
| false | 62.5 | [
"-def main():",
"- x = eval(input())",
"- x1, x2, x3, x4, x5 = x.split(\" \")",
"- W = int(x1)",
"- H = int(x2)",
"- x = int(x3)",
"- y = int(x4)",
"- r = int(x5)",
"- if r <= x <= W - r and r <= y <= H - r:",
"- print(\"Yes\")",
"- else:",
"- print(\"N... | false | 0.035223 | 0.035434 | 0.994061 | [
"s001194919",
"s300614071"
] |
u631277801 | p03785 | python | s146047258 | s323786539 | 770 | 394 | 59,096 | 19,384 | Accepted | Accepted | 48.83 | from collections import deque
n,c,k = list(map(int, input().split()))
t = [int(eval(input())) for _ in range(n)]
tk = [(ti, ti+k) for ti in t]
tk.sort(key=lambda x:x[1])
tk = deque(tk)
#print(tk)
ans = 0
# tkが尽きるまで
while tk:
_, bus = tk[0]
# バスの時刻より早く来ている客をカウント
cnt = 0
while (... | from collections import deque
n,c,k = list(map(int, input().split()))
t = [int(eval(input())) for _ in range(n)]
tk = [(ti, ti+k) for ti in t]
tk.sort(key=lambda x:x[1])
tk = deque(tk)
#print(tk)
ans = 0
# tkが尽きるまで
while tk:
_, bus = tk[0]
# バスの時刻より早く来ている客をカウント
cnt = 0
while (... | 33 | 32 | 552 | 560 | from collections import deque
n, c, k = list(map(int, input().split()))
t = [int(eval(input())) for _ in range(n)]
tk = [(ti, ti + k) for ti in t]
tk.sort(key=lambda x: x[1])
tk = deque(tk)
# print(tk)
ans = 0
# tkが尽きるまで
while tk:
_, bus = tk[0]
# バスの時刻より早く来ている客をカウント
cnt = 0
while tk[cnt][0] <= bus:
... | from collections import deque
n, c, k = list(map(int, input().split()))
t = [int(eval(input())) for _ in range(n)]
tk = [(ti, ti + k) for ti in t]
tk.sort(key=lambda x: x[1])
tk = deque(tk)
# print(tk)
ans = 0
# tkが尽きるまで
while tk:
_, bus = tk[0]
# バスの時刻より早く来ている客をカウント
cnt = 0
while (tk[cnt][0] <= bus) a... | false | 3.030303 | [
"- while tk[cnt][0] <= bus:",
"+ while (tk[cnt][0] <= bus) and (cnt < c):"
] | false | 0.072636 | 0.086454 | 0.840173 | [
"s146047258",
"s323786539"
] |
u375616706 | p02984 | python | s751072886 | s742516771 | 126 | 106 | 14,316 | 102,328 | Accepted | Accepted | 15.87 | import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
sum_odd = sum([v for v in A[1::2]])
x0 = sum(A)-2*sum_odd
ans = [x0]
x = x0
for a in A:
nex = 2*a-x
ans.append(nex)
x = nex
print((*ans[:-1]))
| N=int(eval(input()))
A=list(map(int,input().split()))
low=0
high=10**10
#binary search the value of rain onto Mountain1
while low<=high:
mid=(low+high)//2
cur=mid
for i,a in enumerate(A):
cur=a-cur
if cur<0:#途中で足りなくなったら、midが大きすぎ
break
#break
if cur... | 17 | 33 | 292 | 539 | import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
sum_odd = sum([v for v in A[1::2]])
x0 = sum(A) - 2 * sum_odd
ans = [x0]
x = x0
for a in A:
nex = 2 * a - x
ans.append(nex)
x = nex
print((*ans[:-1]))
| N = int(eval(input()))
A = list(map(int, input().split()))
low = 0
high = 10**10
# binary search the value of rain onto Mountain1
while low <= high:
mid = (low + high) // 2
cur = mid
for i, a in enumerate(A):
cur = a - cur
if cur < 0: # 途中で足りなくなったら、midが大きすぎ
break
# break
... | false | 48.484848 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**9)",
"-input = sys.stdin.readline",
"-sum_odd = sum([v for v in A[1::2]])",
"-x0 = sum(A) - 2 * sum_odd",
"-ans = [x0]",
"-x = x0",
"+low = 0",
"+high = 10**10",
"+# binary search the value of rain onto Mountain1",
"+while low <= high:",
"+ ... | false | 0.096303 | 0.036093 | 2.668149 | [
"s751072886",
"s742516771"
] |
u859125915 | p02811 | python | s805806997 | s958178994 | 174 | 160 | 38,384 | 38,384 | Accepted | Accepted | 8.05 | K, X = list(map(int,input().split()))
if 500*K >=X:
print("Yes")
else:
print("No") | K, X = list(map(int,input().split()))
if(K*500 >= X):
print("Yes")
else:
print("No") | 6 | 5 | 90 | 90 | K, X = list(map(int, input().split()))
if 500 * K >= X:
print("Yes")
else:
print("No")
| K, X = list(map(int, input().split()))
if K * 500 >= X:
print("Yes")
else:
print("No")
| false | 16.666667 | [
"-if 500 * K >= X:",
"+if K * 500 >= X:"
] | false | 0.10865 | 0.042517 | 2.555439 | [
"s805806997",
"s958178994"
] |
u934442292 | p03163 | python | s214894825 | s050431729 | 671 | 227 | 189,992 | 106,352 | Accepted | Accepted | 66.17 | import sys
import numba as nb
import numpy as np
input = sys.stdin.readline
@nb.njit("i8(i8,i8,i8[:,:])")
def solve(N, W, wv):
dp = np.zeros(shape=(N + 1, W + 1), dtype=np.int64)
for i in range(1, N + 1):
w, v = wv[i - 1]
for j in range(1, W + 1):
if j < w:
... | import sys
import numpy as np
input = sys.stdin.readline
def main():
N, W = list(map(int, input().split()))
w = [0] * N
v = [0] * N
for i in range(N):
w[i], v[i] = list(map(int, input().split()))
dp = np.zeros(shape=(N + 1, W + 1), dtype=np.int64)
for i, (w_, v_) in e... | 34 | 25 | 744 | 518 | import sys
import numba as nb
import numpy as np
input = sys.stdin.readline
@nb.njit("i8(i8,i8,i8[:,:])")
def solve(N, W, wv):
dp = np.zeros(shape=(N + 1, W + 1), dtype=np.int64)
for i in range(1, N + 1):
w, v = wv[i - 1]
for j in range(1, W + 1):
if j < w:
dp[i, j... | import sys
import numpy as np
input = sys.stdin.readline
def main():
N, W = list(map(int, input().split()))
w = [0] * N
v = [0] * N
for i in range(N):
w[i], v[i] = list(map(int, input().split()))
dp = np.zeros(shape=(N + 1, W + 1), dtype=np.int64)
for i, (w_, v_) in enumerate(zip(w, v... | false | 26.470588 | [
"-import numba as nb",
"-@nb.njit(\"i8(i8,i8,i8[:,:])\")",
"-def solve(N, W, wv):",
"- dp = np.zeros(shape=(N + 1, W + 1), dtype=np.int64)",
"- for i in range(1, N + 1):",
"- w, v = wv[i - 1]",
"- for j in range(1, W + 1):",
"- if j < w:",
"- dp[i, j] = ... | false | 0.038372 | 0.213788 | 0.179485 | [
"s214894825",
"s050431729"
] |
u888092736 | p02862 | python | s115688217 | s235008788 | 162 | 119 | 9,208 | 9,140 | Accepted | Accepted | 26.54 | MOD = 10 ** 9 + 7
X, Y = list(map(int, input().split()))
if (X + Y) % 3 or Y > 2 * X or Y < X // 2:
print((0))
exit()
n = (X + Y) // 3
r = X - (X + Y) // 3
num, den = 1, 1
if n - r < r:
r = n - r
for i in range(1, r + 1):
num *= n - i + 1
num %= MOD
den *= i
den %= MOD
p... | def ncr(n, r):
num, den = 1, 1
if n - r < r:
r = n - r
for i in range(1, r + 1):
num *= n - i + 1
num %= MOD
den *= i
den %= MOD
return num * pow(den, MOD - 2, MOD) % MOD
MOD = 10 ** 9 + 7
X, Y = list(map(int, input().split()))
Z = X + Y
if Z % ... | 19 | 21 | 354 | 403 | MOD = 10**9 + 7
X, Y = list(map(int, input().split()))
if (X + Y) % 3 or Y > 2 * X or Y < X // 2:
print((0))
exit()
n = (X + Y) // 3
r = X - (X + Y) // 3
num, den = 1, 1
if n - r < r:
r = n - r
for i in range(1, r + 1):
num *= n - i + 1
num %= MOD
den *= i
den %= MOD
print(((num * pow(den, M... | def ncr(n, r):
num, den = 1, 1
if n - r < r:
r = n - r
for i in range(1, r + 1):
num *= n - i + 1
num %= MOD
den *= i
den %= MOD
return num * pow(den, MOD - 2, MOD) % MOD
MOD = 10**9 + 7
X, Y = list(map(int, input().split()))
Z = X + Y
if Z % 3 or Y > 2 * X or Y... | false | 9.52381 | [
"+def ncr(n, r):",
"+ num, den = 1, 1",
"+ if n - r < r:",
"+ r = n - r",
"+ for i in range(1, r + 1):",
"+ num *= n - i + 1",
"+ num %= MOD",
"+ den *= i",
"+ den %= MOD",
"+ return num * pow(den, MOD - 2, MOD) % MOD",
"+",
"+",
"-if (X + Y) % ... | false | 0.064688 | 0.082463 | 0.784453 | [
"s115688217",
"s235008788"
] |
u411544692 | p03478 | python | s504489901 | s192864040 | 39 | 29 | 3,188 | 2,940 | Accepted | Accepted | 25.64 | n = list(map(int, input().split()))
total = 0
for i in range(1, n[0]+1):
sum = 0
number = str(i)
for k in range(len(number)):
sum += int(number[k])
if n[1] <= sum <= n[2]:
total += i
print(total)
| N, A, B = list(map(int, input().split()))
ans = 0
for n in range(1, N+1):
s = 0
N = n
while n>0:
s += n%10
n //= 10
if A <= s <= B:
ans += N
print(ans) | 11 | 12 | 239 | 177 | n = list(map(int, input().split()))
total = 0
for i in range(1, n[0] + 1):
sum = 0
number = str(i)
for k in range(len(number)):
sum += int(number[k])
if n[1] <= sum <= n[2]:
total += i
print(total)
| N, A, B = list(map(int, input().split()))
ans = 0
for n in range(1, N + 1):
s = 0
N = n
while n > 0:
s += n % 10
n //= 10
if A <= s <= B:
ans += N
print(ans)
| false | 8.333333 | [
"-n = list(map(int, input().split()))",
"-total = 0",
"-for i in range(1, n[0] + 1):",
"- sum = 0",
"- number = str(i)",
"- for k in range(len(number)):",
"- sum += int(number[k])",
"- if n[1] <= sum <= n[2]:",
"- total += i",
"-print(total)",
"+N, A, B = list(map(int, ... | false | 0.03897 | 0.039107 | 0.996503 | [
"s504489901",
"s192864040"
] |
u594956556 | p03816 | python | s113908850 | s023123195 | 119 | 67 | 14,396 | 21,724 | Accepted | Accepted | 43.7 | n=int(eval(input()))
a=list(map(int,input().split()))
a.sort()
eq={}
for i in range(n-1):
if a[i]==a[i+1]:
if a[i] in eq:
eq[a[i]]+=1
else:
eq[a[i]]=1
sousa=0
for i in list(eq.values()):
sousa+=i
if sousa%2==0:
print((n-sousa))
else:
print((n-sousa-1)) | from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
d = dict(Counter(A))
kaburi = 0
for key in d:
kaburi += d[key]-1
print((N - (kaburi%2 + kaburi))) | 17 | 9 | 280 | 193 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
eq = {}
for i in range(n - 1):
if a[i] == a[i + 1]:
if a[i] in eq:
eq[a[i]] += 1
else:
eq[a[i]] = 1
sousa = 0
for i in list(eq.values()):
sousa += i
if sousa % 2 == 0:
print((n - sousa))
else:
pri... | from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
d = dict(Counter(A))
kaburi = 0
for key in d:
kaburi += d[key] - 1
print((N - (kaburi % 2 + kaburi)))
| false | 47.058824 | [
"-n = int(eval(input()))",
"-a = list(map(int, input().split()))",
"-a.sort()",
"-eq = {}",
"-for i in range(n - 1):",
"- if a[i] == a[i + 1]:",
"- if a[i] in eq:",
"- eq[a[i]] += 1",
"- else:",
"- eq[a[i]] = 1",
"-sousa = 0",
"-for i in list(eq.values())... | false | 0.043818 | 0.04511 | 0.971367 | [
"s113908850",
"s023123195"
] |
u576432509 | p03696 | python | s960084564 | s508869117 | 29 | 25 | 9,212 | 9,204 | Accepted | Accepted | 13.79 |
icase=0
if icase==0:
n=int(eval(input()))
s=eval(input())
elif icase==1:
n=3
s="())"
elif icase==2:
n=6
s=")))())"
elif icase==3:
n=8
s="))))(((("
l=[]
r=[]
sim=s[0]
if sim=="(":
lidx=0
l.append(1)
ridx=-1
elif sim==")":
lidx=0
l.append(0)
... | icase=0
if icase==0:
n=int(eval(input()))
s=eval(input())
elif icase==1:
n=3
s="())"
elif icase==2:
n=6
s=")))())"
elif icase==3:
n=8
s="))))(((("
l=[]
r=[]
sim=s[0]
if sim=="(":
lidx=0
l.append(1)
ridx=-1
elif sim==")":
lidx=0
l.append(0)
... | 59 | 54 | 903 | 838 | icase = 0
if icase == 0:
n = int(eval(input()))
s = eval(input())
elif icase == 1:
n = 3
s = "())"
elif icase == 2:
n = 6
s = ")))())"
elif icase == 3:
n = 8
s = "))))(((("
l = []
r = []
sim = s[0]
if sim == "(":
lidx = 0
l.append(1)
ridx = -1
elif sim == ")":
lidx = 0
... | icase = 0
if icase == 0:
n = int(eval(input()))
s = eval(input())
elif icase == 1:
n = 3
s = "())"
elif icase == 2:
n = 6
s = ")))())"
elif icase == 3:
n = 8
s = "))))(((("
l = []
r = []
sim = s[0]
if sim == "(":
lidx = 0
l.append(1)
ridx = -1
elif sim == ")":
lidx = 0
... | false | 8.474576 | [
"-elif len(l) < len(r):",
"- l.append(0)",
"-xmin = 100",
"+xmin = 0",
"-if xmin > 0:",
"- xmin = 0"
] | false | 0.038702 | 0.040927 | 0.945622 | [
"s960084564",
"s508869117"
] |
u790710233 | p02641 | python | s664946490 | s157462287 | 24 | 21 | 9,180 | 9,200 | Accepted | Accepted | 12.5 | X, n = list(map(int, input().split()))
P = list(map(int, input().split()))
ls = [0]*(102)
for p in P:
ls[p] = 1
# xとのさがi
for i in range(101):
L, R = X-i, X+i
if ls[L] == 0:
print(L)
break
if ls[R] == 0:
print(R)
break
| x, n = list(map(int, input().split()))
Ps = list(map(int, input().split()))
line = [0]*(102)
for p in Ps:
line[p] = 1
for i in range(101):
L, R = x-i, x+i
if line[L] == 0:
print(L)
break
if line[R] == 0:
print(R)
break
| 16 | 15 | 277 | 277 | X, n = list(map(int, input().split()))
P = list(map(int, input().split()))
ls = [0] * (102)
for p in P:
ls[p] = 1
# xとのさがi
for i in range(101):
L, R = X - i, X + i
if ls[L] == 0:
print(L)
break
if ls[R] == 0:
print(R)
break
| x, n = list(map(int, input().split()))
Ps = list(map(int, input().split()))
line = [0] * (102)
for p in Ps:
line[p] = 1
for i in range(101):
L, R = x - i, x + i
if line[L] == 0:
print(L)
break
if line[R] == 0:
print(R)
break
| false | 6.25 | [
"-X, n = list(map(int, input().split()))",
"-P = list(map(int, input().split()))",
"-ls = [0] * (102)",
"-for p in P:",
"- ls[p] = 1",
"-# xとのさがi",
"+x, n = list(map(int, input().split()))",
"+Ps = list(map(int, input().split()))",
"+line = [0] * (102)",
"+for p in Ps:",
"+ line[p] = 1",
... | false | 0.043168 | 0.043255 | 0.997993 | [
"s664946490",
"s157462287"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.