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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u731368968 | p03846 | python | s052059355 | s349703918 | 74 | 66 | 14,008 | 14,008 | Accepted | Accepted | 10.81 | n = int(eval(input()))
a = list(map(int, input().split()))
l=[0 for i in range(n)]
for x in a:
l[x] += 1
p = [(0 if i % 2 == 0 else 2) for i in range(n // 2 * 2)]
if n % 2 == 1: p = [1] + p
if l != p:
print((0))
import sys
sys.exit()
def mod_power(x, a, p):
if a == 0:
return... | n = int(eval(input()))
a = list(map(int, input().split()))
l=[0 for i in range(n)]
for x in a:
l[x] += 1
p = [(0 if i % 2 == 0 else 2) for i in range(n // 2 * 2)]
if n % 2 == 1: p = [1] + p
if l != p:
print((0))
import sys
sys.exit()
def mod_power(x, a, p):
if a == 0:
return... | 28 | 28 | 553 | 563 | n = int(eval(input()))
a = list(map(int, input().split()))
l = [0 for i in range(n)]
for x in a:
l[x] += 1
p = [(0 if i % 2 == 0 else 2) for i in range(n // 2 * 2)]
if n % 2 == 1:
p = [1] + p
if l != p:
print((0))
import sys
sys.exit()
def mod_power(x, a, p):
if a == 0:
return 1
t... | n = int(eval(input()))
a = list(map(int, input().split()))
l = [0 for i in range(n)]
for x in a:
l[x] += 1
p = [(0 if i % 2 == 0 else 2) for i in range(n // 2 * 2)]
if n % 2 == 1:
p = [1] + p
if l != p:
print((0))
import sys
sys.exit()
def mod_power(x, a, p):
if a == 0:
return 1
t... | false | 0 | [
"- return t * t",
"+ return t * t % p",
"- return x * t % p * t",
"+ return x * t * t % p",
"-for i in range(n // 2):",
"- ans *= 2",
"- ans %= 10**9 + 7",
"-print(ans)",
"-# print(mod_power(2,n//2,10**9+7))",
"+# for i in range(n // 2):",
"+# ans *= 2",
"... | false | 0.04575 | 0.034835 | 1.313344 | [
"s052059355",
"s349703918"
] |
u241159583 | p03937 | python | s709527422 | s579696163 | 20 | 17 | 3,060 | 2,940 | Accepted | Accepted | 15 | H, W = list(map(int, input().split()))
A = [list(eval(input())) for _ in range(H)]
cnt = 0
for i in range(H):
cnt += A[i].count("#")
print(("Possible" if cnt == H + W - 1 else "Impossible")) | H,W = list(map(int, input().split()))
A = [eval(input()) for _ in range(H)]
cnt = 0
for a in A:
cnt += a.count("#")
print(("Possible" if cnt == W + (H-1) else "Impossible")) | 7 | 7 | 185 | 170 | H, W = list(map(int, input().split()))
A = [list(eval(input())) for _ in range(H)]
cnt = 0
for i in range(H):
cnt += A[i].count("#")
print(("Possible" if cnt == H + W - 1 else "Impossible"))
| H, W = list(map(int, input().split()))
A = [eval(input()) for _ in range(H)]
cnt = 0
for a in A:
cnt += a.count("#")
print(("Possible" if cnt == W + (H - 1) else "Impossible"))
| false | 0 | [
"-A = [list(eval(input())) for _ in range(H)]",
"+A = [eval(input()) for _ in range(H)]",
"-for i in range(H):",
"- cnt += A[i].count(\"#\")",
"-print((\"Possible\" if cnt == H + W - 1 else \"Impossible\"))",
"+for a in A:",
"+ cnt += a.count(\"#\")",
"+print((\"Possible\" if cnt == W + (H - 1) ... | false | 0.034503 | 0.048184 | 0.716083 | [
"s709527422",
"s579696163"
] |
u541055501 | p02586 | python | s942681998 | s496711970 | 1,884 | 1,734 | 428,600 | 428,412 | Accepted | Accepted | 7.96 | f,g,h=range,max,input
R,C,K=list(map(int,h().split()))
G=[[0]*-~C for i in f(R+1)]
for i in'_'*K:r,c,v=list(map(int,h().split()));G[r][c]=v
F=[[[0]*-~C for i in f(R+1)]for i in f(4)]
for r in f(1,R+1):
for x in f(1,4):
for c in f(1,C+1):F[x][r][c]=g(F[x-1][r][c],F[x-1][r][c-1]+G[r][c],F[x][r][c-1],(x<2)*(G[r]... | f,h=range,input
R,C,K=list(map(int,h().split()))
G=[[0]*-~C for i in f(R+1)]
for i in'_'*K:r,c,v=list(map(int,h().split()));G[r][c]=v
F=[[[0]*-~C for i in f(R+1)]for i in f(4)]
for r in f(1,R+1):
for x in f(1,4):
for c in f(1,C+1):F[x][r][c]=max(F[x-1][r][c],max(F[x-1][r][c-1],(x<2)*F[3][r-1][c])+G[r][c],F[x]... | 9 | 9 | 345 | 336 | f, g, h = range, max, input
R, C, K = list(map(int, h().split()))
G = [[0] * -~C for i in f(R + 1)]
for i in "_" * K:
r, c, v = list(map(int, h().split()))
G[r][c] = v
F = [[[0] * -~C for i in f(R + 1)] for i in f(4)]
for r in f(1, R + 1):
for x in f(1, 4):
for c in f(1, C + 1):
F[x][r][... | f, h = range, input
R, C, K = list(map(int, h().split()))
G = [[0] * -~C for i in f(R + 1)]
for i in "_" * K:
r, c, v = list(map(int, h().split()))
G[r][c] = v
F = [[[0] * -~C for i in f(R + 1)] for i in f(4)]
for r in f(1, R + 1):
for x in f(1, 4):
for c in f(1, C + 1):
F[x][r][c] = max... | false | 0 | [
"-f, g, h = range, max, input",
"+f, h = range, input",
"- F[x][r][c] = g(",
"+ F[x][r][c] = max(",
"- F[x - 1][r][c - 1] + G[r][c],",
"+ max(F[x - 1][r][c - 1], (x < 2) * F[3][r - 1][c]) + G[r][c],",
"- (x < 2) * (G[r][c] + F[3][r - 1][... | false | 0.042796 | 0.04963 | 0.862312 | [
"s942681998",
"s496711970"
] |
u724687935 | p02850 | python | s728712765 | s500713057 | 674 | 526 | 40,128 | 75,112 | Accepted | Accepted | 21.96 | from collections import deque
N = int(eval(input()))
edge = [[] for _ in range(N)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
edge[a - 1].append((b - 1, i))
edge[b - 1].append((a - 1, i))
ec = [0] * (N - 1)
def bfs():
q = deque()
q.append((0, 0))
while len(q... | import sys
sys.setrecursionlimit(10 ** 6)
def dfs(v, c):
nc = 0
k = 0
for nv, idx in edge[v]:
if status[nv] == 0:
nc = nc + 1 + ((nc + 1) == c)
color[idx] = nc
status[nv] = 1
k = max(k, dfs(nv, nc))
return max(nc, k)
N = int(eva... | 33 | 31 | 636 | 637 | from collections import deque
N = int(eval(input()))
edge = [[] for _ in range(N)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
edge[a - 1].append((b - 1, i))
edge[b - 1].append((a - 1, i))
ec = [0] * (N - 1)
def bfs():
q = deque()
q.append((0, 0))
while len(q):
v, pc... | import sys
sys.setrecursionlimit(10**6)
def dfs(v, c):
nc = 0
k = 0
for nv, idx in edge[v]:
if status[nv] == 0:
nc = nc + 1 + ((nc + 1) == c)
color[idx] = nc
status[nv] = 1
k = max(k, dfs(nv, nc))
return max(nc, k)
N = int(eval(input()))
edge ... | false | 6.060606 | [
"-from collections import deque",
"+import sys",
"+",
"+sys.setrecursionlimit(10**6)",
"+",
"+",
"+def dfs(v, c):",
"+ nc = 0",
"+ k = 0",
"+ for nv, idx in edge[v]:",
"+ if status[nv] == 0:",
"+ nc = nc + 1 + ((nc + 1) == c)",
"+ color[idx] = nc",
"+ ... | false | 0.105563 | 0.064177 | 1.64487 | [
"s728712765",
"s500713057"
] |
u645250356 | p03644 | python | s889022944 | s378803489 | 173 | 36 | 38,384 | 5,076 | Accepted | Accepted | 79.19 | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.st... | 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 = ... | 25 | 17 | 624 | 418 | from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
def inpln(n):
r... | 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 | 32 | [
"-import sys, bisect, math, itertools",
"+import sys, bisect, math, itertools, fractions",
"+INF = float(\"inf\")",
"-def inpln(n):",
"- return list(int(sys.stdin.readline()) for i in range(n))",
"-",
"-",
"-res = 0",
"-cc = 0",
"-for i in range(1, n + 1):",
"- tmp = i",
"- cnt = 0",
... | false | 0.04477 | 0.03769 | 1.187849 | [
"s889022944",
"s378803489"
] |
u123756661 | p03038 | python | s689476413 | s026740259 | 1,274 | 642 | 101,400 | 20,724 | Accepted | Accepted | 49.61 | import heapq
def sol():
n,m=list(map(int,input().split()))
a=[int(i) for i in input().split()]
d={}
w=[]
q=[]
for i in a:
if i in d:
d[i]+=1
else:
d[i]=1
w.append(i)
for i in w: heapq.heappush(q, i)
for i in range(m):
... | import heapq
n,m=list(map(int,input().split()))
a=[int(i) for i in input().split()]
d={}
w=[]
q=[]
for i in a:
if i in d:
d[i]+=1
else:
d[i]=1
w.append(i)
for i in w: heapq.heappush(q, i)
for i in range(m):
b,c=list(map(int,input().split()))
while b:
if c>... | 41 | 37 | 994 | 799 | import heapq
def sol():
n, m = list(map(int, input().split()))
a = [int(i) for i in input().split()]
d = {}
w = []
q = []
for i in a:
if i in d:
d[i] += 1
else:
d[i] = 1
w.append(i)
for i in w:
heapq.heappush(q, i)
for i in ra... | import heapq
n, m = list(map(int, input().split()))
a = [int(i) for i in input().split()]
d = {}
w = []
q = []
for i in a:
if i in d:
d[i] += 1
else:
d[i] = 1
w.append(i)
for i in w:
heapq.heappush(q, i)
for i in range(m):
b, c = list(map(int, input().split()))
while b:
... | false | 9.756098 | [
"-",
"-def sol():",
"- n, m = list(map(int, input().split()))",
"- a = [int(i) for i in input().split()]",
"- d = {}",
"- w = []",
"- q = []",
"- for i in a:",
"- if i in d:",
"- d[i] += 1",
"+n, m = list(map(int, input().split()))",
"+a = [int(i) for i in i... | false | 0.037468 | 0.057343 | 0.653398 | [
"s689476413",
"s026740259"
] |
u708255304 | p02696 | python | s336975188 | s544568963 | 25 | 20 | 9,160 | 9,072 | Accepted | Accepted | 20 | import math
A, B, N = list(map(int, input().split()))
ans = math.floor(A*min(N, B-1)/B) - A*math.floor(min(N, B-1)/B)
print(ans)
| A, B, N = list(map(int, input().split()))
ans = int(A*(min(N, B-1)/B))-A*int(min(N, B-1)/B)
print(ans)
| 4 | 3 | 126 | 99 | import math
A, B, N = list(map(int, input().split()))
ans = math.floor(A * min(N, B - 1) / B) - A * math.floor(min(N, B - 1) / B)
print(ans)
| A, B, N = list(map(int, input().split()))
ans = int(A * (min(N, B - 1) / B)) - A * int(min(N, B - 1) / B)
print(ans)
| false | 25 | [
"-import math",
"-",
"-ans = math.floor(A * min(N, B - 1) / B) - A * math.floor(min(N, B - 1) / B)",
"+ans = int(A * (min(N, B - 1) / B)) - A * int(min(N, B - 1) / B)"
] | false | 0.046334 | 0.044585 | 1.039216 | [
"s336975188",
"s544568963"
] |
u706414019 | p02848 | python | s235201529 | s974745080 | 47 | 36 | 9,176 | 9,188 | Accepted | Accepted | 23.4 | N = int(input())
S = input()
alfa = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
lis = []
for s in S:
for i in range(26):
if s == alfa[i]:
lis.append((i+N)%26)
break
for i in range(len(S)):
print(alfa[lis[i]],end = '')
| N = int(input())
S = input()
for i in range(len(S)):
a = ord(S[i])+N
if a > ord('Z'):
a -= 26
print(chr(a),end ='')
| 11 | 7 | 253 | 142 | N = int(input())
S = input()
alfa = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
lis = []
for s in S:
for i in range(26):
if s == alfa[i]:
lis.append((i + N) % 26)
break
for i in range(len(S)):
print(alfa[lis[i]], end="")
| N = int(input())
S = input()
for i in range(len(S)):
a = ord(S[i]) + N
if a > ord("Z"):
a -= 26
print(chr(a), end="")
| false | 36.363636 | [
"-alfa = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"",
"-lis = []",
"-for s in S:",
"- for i in range(26):",
"- if s == alfa[i]:",
"- lis.append((i + N) % 26)",
"- break",
"- print(alfa[lis[i]], end=\"\")",
"+ a = ord(S[i]) + N",
"+ if a > ord(\"Z\"):",
"+ a -=... | false | 0.040948 | 0.039261 | 1.042976 | [
"s235201529",
"s974745080"
] |
u528470578 | p03163 | python | s367843011 | s545956390 | 570 | 471 | 217,844 | 172,868 | Accepted | Accepted | 17.37 | N, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(N)]
# DP
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
for j in range(W+1):
if wv[i][0] <= j:
dp[i+1][j] = max(dp[i][j - wv[i][0]] + wv[i][1], dp[i][j])
else:
... | # Knapsack 1
N, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [[0 for i in range(W + 1)] for j in range(N + 1)]
for n in range(N):
for w in range(W + 1):
if wv[n][0] <= w:
dp[n+1][w] = max(dp[n][w], dp[n][w - wv[n][0]] + wv[n][1])
... | 12 | 11 | 362 | 374 | N, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(N)]
# DP
dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]
for i in range(N):
for j in range(W + 1):
if wv[i][0] <= j:
dp[i + 1][j] = max(dp[i][j - wv[i][0]] + wv[i][1], dp[i][j])
else:
... | # Knapsack 1
N, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [[0 for i in range(W + 1)] for j in range(N + 1)]
for n in range(N):
for w in range(W + 1):
if wv[n][0] <= w:
dp[n + 1][w] = max(dp[n][w], dp[n][w - wv[n][0]] + wv[n][1])
els... | false | 8.333333 | [
"+# Knapsack 1",
"-# DP",
"-dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]",
"-for i in range(N):",
"- for j in range(W + 1):",
"- if wv[i][0] <= j:",
"- dp[i + 1][j] = max(dp[i][j - wv[i][0]] + wv[i][1], dp[i][j])",
"+dp = [[0 for i in range(W + 1)] for j in range(N + 1)]... | false | 0.047452 | 0.046813 | 1.013645 | [
"s367843011",
"s545956390"
] |
u761989513 | p03262 | python | s221422158 | s093736633 | 111 | 90 | 14,596 | 14,748 | Accepted | Accepted | 18.92 | from functools import reduce
n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
for i in range(n):
x[i] -= X
x[i] = abs(x[i])
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def gcd_list(n):
return reduce(gcd, n)
print((gcd_list(x))) | from functools import reduce
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def gcd_list(n):
return reduce(gcd, n)
n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
dx = [abs(X - i) for i in x]
print((gcd_list(dx))) | 17 | 14 | 305 | 277 | from functools import reduce
n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
for i in range(n):
x[i] -= X
x[i] = abs(x[i])
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def gcd_list(n):
return reduce(gcd, n)
print((gcd_list(x)))
| from functools import reduce
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def gcd_list(n):
return reduce(gcd, n)
n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
dx = [abs(X - i) for i in x]
print((gcd_list(dx)))
| false | 17.647059 | [
"-",
"-n, X = list(map(int, input().split()))",
"-x = list(map(int, input().split()))",
"-for i in range(n):",
"- x[i] -= X",
"- x[i] = abs(x[i])",
"-print((gcd_list(x)))",
"+n, X = list(map(int, input().split()))",
"+x = list(map(int, input().split()))",
"+dx = [abs(X - i) for i in x]",
"... | false | 0.043794 | 0.042122 | 1.039689 | [
"s221422158",
"s093736633"
] |
u803617136 | p03425 | python | s145319642 | s585243697 | 474 | 203 | 45,160 | 3,316 | Accepted | Accepted | 57.17 | N = int(eval(input()))
names = [0] * 5
pattern = []
def make_pattern(arr, cnt):
if len(arr) == 5:
if cnt == 3 :
pattern.append(arr)
return
make_pattern(arr + '1', cnt + 1)
make_pattern(arr + '0', cnt)
for _ in range(N):
name = eval(input())
initial = name[... | from collections import defaultdict
n = int(eval(input()))
h = 'MARCH'
d = [0] * 5
for _ in range(n):
s = eval(input())
if s[0] in h:
d[h.find(s[0])] += 1
ans = 0
for i in range(5):
for j in range(i, 5):
if i == j:
continue
for k in range(j, 5):
... | 38 | 19 | 756 | 408 | N = int(eval(input()))
names = [0] * 5
pattern = []
def make_pattern(arr, cnt):
if len(arr) == 5:
if cnt == 3:
pattern.append(arr)
return
make_pattern(arr + "1", cnt + 1)
make_pattern(arr + "0", cnt)
for _ in range(N):
name = eval(input())
initial = name[0]
if "M"... | from collections import defaultdict
n = int(eval(input()))
h = "MARCH"
d = [0] * 5
for _ in range(n):
s = eval(input())
if s[0] in h:
d[h.find(s[0])] += 1
ans = 0
for i in range(5):
for j in range(i, 5):
if i == j:
continue
for k in range(j, 5):
if i == k or ... | false | 50 | [
"-N = int(eval(input()))",
"-names = [0] * 5",
"-pattern = []",
"+from collections import defaultdict",
"-",
"-def make_pattern(arr, cnt):",
"- if len(arr) == 5:",
"- if cnt == 3:",
"- pattern.append(arr)",
"- return",
"- make_pattern(arr + \"1\", cnt + 1)",
"- ... | false | 0.059993 | 0.038474 | 1.559311 | [
"s145319642",
"s585243697"
] |
u023958502 | p02757 | python | s047152503 | s222955602 | 486 | 251 | 6,560 | 3,500 | Accepted | Accepted | 48.35 | n, p = list(map(int, input().split()))
s = list(map(int, list(eval(input()))))[::-1]
sum = 0
cnt = [0] * p
cnt[0] = 1
ans = 0
if p in [2, 5]:
if p == 2:
ok_list = [0, 2, 4, 6, 8]
if p == 5:
ok_list = [0, 5]
for i in range(n):
d = s[i]
if d in ok_list:
... | n, P = list(map(int, input().split()))
S = eval(input())
ans = 0
#----------------------------------------------
# 1.
# int(S[a:b]) * 10 ** (n - b) == (int(S[a: n]) - int(S[b: n])) で表される
# 例
# S = 1234
# a = 1, b = 3 のとき
# 23 = (234 - 4) // 10 ** (4 - 3)
# = 230 // 10
# = 23
#
# 2.
# Pは素数のため P = 2... | 27 | 68 | 525 | 1,932 | n, p = list(map(int, input().split()))
s = list(map(int, list(eval(input()))))[::-1]
sum = 0
cnt = [0] * p
cnt[0] = 1
ans = 0
if p in [2, 5]:
if p == 2:
ok_list = [0, 2, 4, 6, 8]
if p == 5:
ok_list = [0, 5]
for i in range(n):
d = s[i]
if d in ok_list:
ans += n - i... | n, P = list(map(int, input().split()))
S = eval(input())
ans = 0
# ----------------------------------------------
# 1.
# int(S[a:b]) * 10 ** (n - b) == (int(S[a: n]) - int(S[b: n])) で表される
# 例
# S = 1234
# a = 1, b = 3 のとき
# 23 = (234 - 4) // 10 ** (4 - 3)
# = 230 // 10
# = 23
#
# 2.
# Pは素数のため P = 2, 5 のとき以外は 10... | false | 60.294118 | [
"-n, p = list(map(int, input().split()))",
"-s = list(map(int, list(eval(input()))))[::-1]",
"-sum = 0",
"-cnt = [0] * p",
"-cnt[0] = 1",
"+n, P = list(map(int, input().split()))",
"+S = eval(input())",
"-if p in [2, 5]:",
"- if p == 2:",
"- ok_list = [0, 2, 4, 6, 8]",
"- if p == 5:... | false | 0.077777 | 0.085868 | 0.905774 | [
"s047152503",
"s222955602"
] |
u864197622 | p03450 | python | s946129013 | s266033680 | 1,657 | 1,121 | 108,704 | 79,904 | Accepted | Accepted | 32.35 | N, M = list(map(int, input().split()))
P = [i for i in range(N)]
D = [0] * N
C = [1] * N
def par(a):
if a == P[a]:
return a
p = par(P[a])
d = D[P[a]]
P[a] = p
D[a] += d
return p
def dist(a, b):
pa = par(a)
pb = par(b)
if pa == pb:
return D[b] - D[a... | from collections import deque
N, M = list(map(int, input().split()))
X = [[] for _ in range(N)]
for _ in range(M):
l, r, d = list(map(int, input().split()))
X[l-1].append((r-1, d))
X[r-1].append((l-1, -d))
done = [0] * N
dist = [0] * N
def BFS(i):
Q = deque([i])
done[i] = 1
while Q... | 42 | 32 | 781 | 728 | N, M = list(map(int, input().split()))
P = [i for i in range(N)]
D = [0] * N
C = [1] * N
def par(a):
if a == P[a]:
return a
p = par(P[a])
d = D[P[a]]
P[a] = p
D[a] += d
return p
def dist(a, b):
pa = par(a)
pb = par(b)
if pa == pb:
return D[b] - D[a]
return 1 <... | from collections import deque
N, M = list(map(int, input().split()))
X = [[] for _ in range(N)]
for _ in range(M):
l, r, d = list(map(int, input().split()))
X[l - 1].append((r - 1, d))
X[r - 1].append((l - 1, -d))
done = [0] * N
dist = [0] * N
def BFS(i):
Q = deque([i])
done[i] = 1
while Q:
... | false | 23.809524 | [
"+from collections import deque",
"+",
"-P = [i for i in range(N)]",
"-D = [0] * N",
"-C = [1] * N",
"+X = [[] for _ in range(N)]",
"+for _ in range(M):",
"+ l, r, d = list(map(int, input().split()))",
"+ X[l - 1].append((r - 1, d))",
"+ X[r - 1].append((l - 1, -d))",
"+done = [0] * N",... | false | 0.05929 | 0.074729 | 0.793411 | [
"s946129013",
"s266033680"
] |
u535803878 | p02579 | python | s226237237 | s103206465 | 1,784 | 1,463 | 98,736 | 104,504 | Accepted | Accepted | 17.99 | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
h,w = list(map(int, input().split()))
ch,cw = list(map(int, input().split()))
dh,dw = list(map(int, input().split()))
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,... | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
h,w = list(map(int, input().split()))
ch,cw = list(map(int, input().split()))
dh,dw = list(map(int, input().split()))
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,... | 72 | 72 | 1,572 | 1,555 | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
h, w = list(map(int, input().split()))
ch, cw = list(map(int, input().split()))
dh, dw = list(map(int, input().split()))
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows, cols = h, w
OK = "... | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
h, w = list(map(int, input().split()))
ch, cw = list(map(int, input().split()))
dh, dw = list(map(int, input().split()))
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows, cols = h, w
OK = "... | false | 0 | [
"-from collections import defaultdict",
"+from collections import defaultdict, deque",
"-from queue import deque",
"-"
] | false | 0.044743 | 0.105249 | 0.425121 | [
"s226237237",
"s103206465"
] |
u971811058 | p03730 | python | s124312915 | s461573744 | 33 | 30 | 9,516 | 9,388 | Accepted | Accepted | 9.09 | # Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, ... | # Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, ... | 18 | 17 | 605 | 605 | # Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import (
accumulate,
product,
permu... | # Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import (
accumulate,
product,
permu... | false | 5.555556 | [
"-i = 1",
"-while i <= b:",
"- if (a * i - c) % b != 0:",
"+for i in range(1, b + 1):",
"+ if (a * i - c) % b:"
] | false | 0.069346 | 0.0376 | 1.844292 | [
"s124312915",
"s461573744"
] |
u347640436 | p02732 | python | s776941160 | s209291604 | 384 | 344 | 25,716 | 26,140 | Accepted | Accepted | 10.42 | N = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for a in A:
if a in d:
d[a] += 1
else:
d[a] = 1
s = 0
for k in d:
s += d[k] * (d[k] - 1) // 2
for i in range(N):
t = d[A[i]]
print((s - t * (t - 1) // 2 + (t - 1) * (t - 2) // 2))
| N = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for a in A:
if a in d:
d[a] += 1
else:
d[a] = 1
s = 0
for k in d:
s += d[k] * (d[k] - 1) // 2
for i in range(N):
print((s - d[A[i]] + 1))
| 17 | 16 | 293 | 246 | N = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for a in A:
if a in d:
d[a] += 1
else:
d[a] = 1
s = 0
for k in d:
s += d[k] * (d[k] - 1) // 2
for i in range(N):
t = d[A[i]]
print((s - t * (t - 1) // 2 + (t - 1) * (t - 2) // 2))
| N = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for a in A:
if a in d:
d[a] += 1
else:
d[a] = 1
s = 0
for k in d:
s += d[k] * (d[k] - 1) // 2
for i in range(N):
print((s - d[A[i]] + 1))
| false | 5.882353 | [
"- t = d[A[i]]",
"- print((s - t * (t - 1) // 2 + (t - 1) * (t - 2) // 2))",
"+ print((s - d[A[i]] + 1))"
] | false | 0.038749 | 0.102584 | 0.377733 | [
"s776941160",
"s209291604"
] |
u553987207 | p02756 | python | s552809961 | s419483126 | 395 | 126 | 5,736 | 14,128 | Accepted | Accepted | 68.1 | S = eval(input())
Q = int(eval(input()))
f = True
l = []
r = []
for _ in range(Q):
q = eval(input())
if q == "1":
f = not f
else:
_, F, C = q.split()
if F == "1":
t = l if f else r
t.append(C)
else:
t = r if f else l
... | import sys
from collections import deque
S = deque(eval(input()))
Q = int(eval(input()))
reverse = False
for _ in range(Q):
q = sys.stdin.readline()
if q[0] == "1":
reverse = not reverse
else:
_, f, c = q.split()
if f == "1":
if reverse:
S.a... | 24 | 26 | 462 | 549 | S = eval(input())
Q = int(eval(input()))
f = True
l = []
r = []
for _ in range(Q):
q = eval(input())
if q == "1":
f = not f
else:
_, F, C = q.split()
if F == "1":
t = l if f else r
t.append(C)
else:
t = r if f else l
t.append(C)... | import sys
from collections import deque
S = deque(eval(input()))
Q = int(eval(input()))
reverse = False
for _ in range(Q):
q = sys.stdin.readline()
if q[0] == "1":
reverse = not reverse
else:
_, f, c = q.split()
if f == "1":
if reverse:
S.append(c)
... | false | 7.692308 | [
"-S = eval(input())",
"+import sys",
"+from collections import deque",
"+",
"+S = deque(eval(input()))",
"-f = True",
"-l = []",
"-r = []",
"+reverse = False",
"- q = eval(input())",
"- if q == \"1\":",
"- f = not f",
"+ q = sys.stdin.readline()",
"+ if q[0] == \"1\":",
... | false | 0.079698 | 0.037974 | 2.098735 | [
"s552809961",
"s419483126"
] |
u636683284 | p02573 | python | s735631318 | s238502255 | 1,367 | 504 | 133,748 | 90,392 | Accepted | Accepted | 63.13 | from collections import defaultdict,deque
n,m = list(map(int,input().split()))
d = defaultdict(list)
if m==0:
print((1))
exit()
visited = [-1] + [False]*n
for i in range(m):
a,b = list(map(int,input().split()))
d[a].append(b)
d[b].append(a)
maxi = 1
for i in range(1,n+1):
if v... | class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n+1)]
self.rank = [0] * (n+1)
self.size = [1] * (n+1)
# 検索
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
... | 30 | 40 | 615 | 1,004 | from collections import defaultdict, deque
n, m = list(map(int, input().split()))
d = defaultdict(list)
if m == 0:
print((1))
exit()
visited = [-1] + [False] * n
for i in range(m):
a, b = list(map(int, input().split()))
d[a].append(b)
d[b].append(a)
maxi = 1
for i in range(1, n + 1):
if visited... | class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n + 1)]
self.rank = [0] * (n + 1)
self.size = [1] * (n + 1)
# 検索
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
retur... | false | 25 | [
"-from collections import defaultdict, deque",
"+class UnionFind:",
"+ def __init__(self, n):",
"+ self.par = [i for i in range(n + 1)]",
"+ self.rank = [0] * (n + 1)",
"+ self.size = [1] * (n + 1)",
"+",
"+ # 検索",
"+ def find(self, x):",
"+ if self.par[x] == x... | false | 0.036588 | 0.035134 | 1.041372 | [
"s735631318",
"s238502255"
] |
u844196583 | p02784 | python | s673886731 | s972617681 | 60 | 47 | 20,480 | 20,488 | Accepted | Accepted | 21.67 | H,N = list(map(int, input().split()))
data = list(map(int, input().split()))
S = 0
for i in range(0,len(data)):
S += data[i]
if H > S:
print("No")
else:
print("Yes") | H,N = list(map(int, input().split()))
data = list(map(int,input().split()))
if H <= sum(data):
print('Yes')
else:
print('No') | 10 | 8 | 181 | 136 | H, N = list(map(int, input().split()))
data = list(map(int, input().split()))
S = 0
for i in range(0, len(data)):
S += data[i]
if H > S:
print("No")
else:
print("Yes")
| H, N = list(map(int, input().split()))
data = list(map(int, input().split()))
if H <= sum(data):
print("Yes")
else:
print("No")
| false | 20 | [
"-S = 0",
"-for i in range(0, len(data)):",
"- S += data[i]",
"-if H > S:",
"+if H <= sum(data):",
"+ print(\"Yes\")",
"+else:",
"-else:",
"- print(\"Yes\")"
] | false | 0.039245 | 0.039133 | 1.002862 | [
"s673886731",
"s972617681"
] |
u499381410 | p03988 | python | s519658176 | s553289448 | 163 | 144 | 81,460 | 81,516 | Accepted | Accepted | 11.66 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, ... | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, ... | 67 | 61 | 1,429 | 1,339 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, asin, at... | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, asin, at... | false | 8.955224 | [
"-if D[min_a] > 2:",
"+if D[min_a] > 2 or max(A) > max_a:",
"-flg = 0",
"- D[i] -= 2",
"-for k in list(D.keys()):",
"- if k > max_a:",
"- print(\"Impossible\")",
"- exit()"
] | false | 0.0475 | 0.040839 | 1.163102 | [
"s519658176",
"s553289448"
] |
u599114793 | p03013 | python | s587694112 | s759991233 | 477 | 199 | 50,136 | 7,824 | Accepted | Accepted | 58.28 | n,m = list(map(int,input().split()))
stair = []
mod = int(1e9+7)
ans = 1
for i in range(m):
stair.append(int(eval(input())))
dp = [0] * (n+1)
dp[0] = dp[1] = 1
stair.append(int(1e10))
if n == 1:
print((1))
exit()
k = 0
for i in range(1, n+1):
if i == stair[k]:
dp[i] = 0
k... | n,m = list(map(int,input().split()))
stair = []
mod = int(1e9+7)
for i in range(m):
stair.append(int(eval(input())))
dp = [0] * (n+1)
dp[0] = 1
stair.append(int(1e10))
k = 0
for i in range(1, n+1):
if i == stair[k]:
dp[i] = 0
k += 1
elif i == 1:
dp[1] = 1
else:
... | 25 | 21 | 422 | 367 | n, m = list(map(int, input().split()))
stair = []
mod = int(1e9 + 7)
ans = 1
for i in range(m):
stair.append(int(eval(input())))
dp = [0] * (n + 1)
dp[0] = dp[1] = 1
stair.append(int(1e10))
if n == 1:
print((1))
exit()
k = 0
for i in range(1, n + 1):
if i == stair[k]:
dp[i] = 0
k += 1
... | n, m = list(map(int, input().split()))
stair = []
mod = int(1e9 + 7)
for i in range(m):
stair.append(int(eval(input())))
dp = [0] * (n + 1)
dp[0] = 1
stair.append(int(1e10))
k = 0
for i in range(1, n + 1):
if i == stair[k]:
dp[i] = 0
k += 1
elif i == 1:
dp[1] = 1
else:
dp... | false | 16 | [
"-ans = 1",
"-dp[0] = dp[1] = 1",
"+dp[0] = 1",
"-if n == 1:",
"- print((1))",
"- exit()"
] | false | 0.035729 | 0.038209 | 0.935086 | [
"s587694112",
"s759991233"
] |
u627417051 | p02693 | python | s244061888 | s001026062 | 82 | 71 | 64,688 | 64,936 | Accepted | Accepted | 13.41 | #設定
import sys
input = sys.stdin.buffer.readline
#ライブラリインポート
from collections import defaultdict
con = 10 ** 9 + 7
#入力受け取り
def getlist():
return list(map(int, input().split()))
#処理内容
def main():
K = int(eval(input()))
A, B = getlist()
for i in range(1001):
if A <= K * i and K * i <= B:
pri... | import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7
def getlist():
return list(map(int, input().split()))
def main():
K = int(eval(input()))
A, B = getlist()
for i in range(1001):
if A <= K * i and K * i <= B:
print("OK")
return
print("NG")
... | 27 | 21 | 393 | 357 | # 設定
import sys
input = sys.stdin.buffer.readline
# ライブラリインポート
from collections import defaultdict
con = 10**9 + 7
# 入力受け取り
def getlist():
return list(map(int, input().split()))
# 処理内容
def main():
K = int(eval(input()))
A, B = getlist()
for i in range(1001):
if A <= K * i and K * i <= B:
... | import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10**9 + 7
def getlist():
return list(map(int, input().split()))
def main():
K = int(eval(input()))
A, B = getlist()
for i in range(1001):
if A <= K * i and K * i <= B:
print("OK")
... | false | 22.222222 | [
"-# 設定",
"-# ライブラリインポート",
"-# 入力受け取り",
"+",
"+",
"-# 処理内容"
] | false | 0.037125 | 0.03682 | 1.008273 | [
"s244061888",
"s001026062"
] |
u994988729 | p03038 | python | s635181510 | s274948268 | 513 | 304 | 20,984 | 22,080 | Accepted | Accepted | 40.74 | import heapq
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
heapq.heapify(a)
CB=[]
for _ in range(m):
b, c = list(map(int, input().split()))
CB.append((c, b))
CB.sort(reverse=True)
for c, b in CB:
if a[0] >= c:
break
for _ in range(b):
if a[0] >... | from operator import itemgetter
import heapq
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
heapq.heapify(A)
BC = [tuple(map(int, input().split())) for _ in range(M)]
BC.sort(reverse=True, key=itemgetter... | 19 | 22 | 381 | 473 | import heapq
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
heapq.heapify(a)
CB = []
for _ in range(m):
b, c = list(map(int, input().split()))
CB.append((c, b))
CB.sort(reverse=True)
for c, b in CB:
if a[0] >= c:
break
for _ in range(b):
if a[0] >= c:
... | from operator import itemgetter
import heapq
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
heapq.heapify(A)
BC = [tuple(map(int, input().split())) for _ in range(M)]
BC.sort(reverse=True, key=itemgetter(1))
for b, c ... | false | 13.636364 | [
"+from operator import itemgetter",
"+import sys",
"-n, m = list(map(int, input().split()))",
"-a = list(map(int, input().split()))",
"-heapq.heapify(a)",
"-CB = []",
"-for _ in range(m):",
"- b, c = list(map(int, input().split()))",
"- CB.append((c, b))",
"-CB.sort(reverse=True)",
"-for c... | false | 0.046536 | 0.15281 | 0.304535 | [
"s635181510",
"s274948268"
] |
u729133443 | p02574 | python | s128096912 | s849978739 | 1,480 | 1,224 | 234,532 | 100,916 | Accepted | Accepted | 17.3 | n,*a=list(map(int,open(0).read().split()))
m=6**8
c=[0]*m
p=[1,1]+c[:]
for i in range(m):
if p[i]<1:
for j in range(i,m,i):p[j]=i
for a in a:
s={a}
while a!=p[a]:
s|={p[a]}
a//=p[a]
s|={a}
for i in s:c[i]+=1
print((('not','psaeitr'[max(c[2:])>1::2]+'wise')[max(c[2:])<n],'coprime')) | import math
m=6**8
c=[g:=0]*m
for a in[*open(0)][1].split():g=math.gcd(g,a:=int(a));c[a]+=1
print((('not','psaeitr'[any(sum(c[i::i])>1for i in range(2,m))::2]+'wise')[g<2],'coprime')) | 15 | 5 | 312 | 185 | n, *a = list(map(int, open(0).read().split()))
m = 6**8
c = [0] * m
p = [1, 1] + c[:]
for i in range(m):
if p[i] < 1:
for j in range(i, m, i):
p[j] = i
for a in a:
s = {a}
while a != p[a]:
s |= {p[a]}
a //= p[a]
s |= {a}
for i in s:
c[i] += 1
print((("... | import math
m = 6**8
c = [g := 0] * m
for a in [*open(0)][1].split():
g = math.gcd(g, a := int(a))
c[a] += 1
print(
(
("not", "psaeitr"[any(sum(c[i::i]) > 1 for i in range(2, m)) :: 2] + "wise")[
g < 2
],
"coprime",
)
)
| false | 66.666667 | [
"-n, *a = list(map(int, open(0).read().split()))",
"+import math",
"+",
"-c = [0] * m",
"-p = [1, 1] + c[:]",
"-for i in range(m):",
"- if p[i] < 1:",
"- for j in range(i, m, i):",
"- p[j] = i",
"-for a in a:",
"- s = {a}",
"- while a != p[a]:",
"- s |= {p[a... | false | 1.676046 | 1.0819 | 1.549168 | [
"s128096912",
"s849978739"
] |
u844005364 | p03329 | python | s334859652 | s839172487 | 242 | 194 | 46,168 | 42,200 | Accepted | Accepted | 19.83 | import bisect
x = int(eval(input()))
six_list = [6 ** i for i in range(7)]
nine_list = [9 ** i for i in range(6)]
def six_nine(n):
if n == 0:
return 0
else:
six = six_list[bisect.bisect_right(six_list, n) - 1]
nine = nine_list[bisect.bisect_right(nine_list, n) - 1]
... | import bisect
x = int(eval(input()))
six_list = [6 ** i for i in range(7)]
nine_list = [9 ** i for i in range(6)]
def six_nine(n):
if n < 6:
return n
else:
six = six_list[bisect.bisect_right(six_list, n) - 1]
nine = nine_list[bisect.bisect_right(nine_list, n) - 1]
... | 17 | 17 | 405 | 404 | import bisect
x = int(eval(input()))
six_list = [6**i for i in range(7)]
nine_list = [9**i for i in range(6)]
def six_nine(n):
if n == 0:
return 0
else:
six = six_list[bisect.bisect_right(six_list, n) - 1]
nine = nine_list[bisect.bisect_right(nine_list, n) - 1]
return min(n //... | import bisect
x = int(eval(input()))
six_list = [6**i for i in range(7)]
nine_list = [9**i for i in range(6)]
def six_nine(n):
if n < 6:
return n
else:
six = six_list[bisect.bisect_right(six_list, n) - 1]
nine = nine_list[bisect.bisect_right(nine_list, n) - 1]
return min(n // ... | false | 0 | [
"- if n == 0:",
"- return 0",
"+ if n < 6:",
"+ return n"
] | false | 0.052537 | 0.049968 | 1.051417 | [
"s334859652",
"s839172487"
] |
u090649502 | p02820 | python | s725591353 | s873230762 | 56 | 49 | 4,212 | 4,084 | Accepted | Accepted | 12.5 | #!/usr/bin/env python3
import sys
def solve(N: int, K: int, R: int, S: int, P: int, T: str):
ans=0
flag=[False]*N
for i in range(N):
if i<K:
ans+=P if T[i]=='r' else S if T[i]=='p' else R
flag[i]=True
for i in range(K, N):
if T[i]!=T[i-K] or (not fla... | #!/usr/bin/env python3
import sys
def solve(N: int, K: int, R: int, S: int, P: int, T: str):
ans=0
flag=[False]*N
for i in range(N):
if i<K or T[i]!=T[i-K] or (not flag[i-K]):
ans+=P if T[i]=='r' else S if T[i]=='p' else R
flag[i]=True
print(ans)
... | 38 | 34 | 1,102 | 979 | #!/usr/bin/env python3
import sys
def solve(N: int, K: int, R: int, S: int, P: int, T: str):
ans = 0
flag = [False] * N
for i in range(N):
if i < K:
ans += P if T[i] == "r" else S if T[i] == "p" else R
flag[i] = True
for i in range(K, N):
if T[i] != T[i - K] or ... | #!/usr/bin/env python3
import sys
def solve(N: int, K: int, R: int, S: int, P: int, T: str):
ans = 0
flag = [False] * N
for i in range(N):
if i < K or T[i] != T[i - K] or (not flag[i - K]):
ans += P if T[i] == "r" else S if T[i] == "p" else R
flag[i] = True
print(ans)
... | false | 10.526316 | [
"- if i < K:",
"- ans += P if T[i] == \"r\" else S if T[i] == \"p\" else R",
"- flag[i] = True",
"- for i in range(K, N):",
"- if T[i] != T[i - K] or (not flag[i - K]):",
"+ if i < K or T[i] != T[i - K] or (not flag[i - K]):"
] | false | 0.007649 | 0.091669 | 0.083444 | [
"s725591353",
"s873230762"
] |
u045909335 | p03220 | python | s163954294 | s937758561 | 150 | 18 | 12,492 | 3,060 | Accepted | Accepted | 88 | import numpy as np
def main():
N = int(eval(input()))
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))
for i in range(N):
H[i] = T- H[i] * 0.006
print((np.abs(np.asarray(H) - A).argmin()+1))
if __name__ == '__main__':
main() | def main():
N = int(eval(input()))
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))
for i in range(N):
H[i] = abs(A - (T- H[i] * 0.006))
print((H.index(min(H))+1))
if __name__ == '__main__':
main() | 11 | 10 | 283 | 255 | import numpy as np
def main():
N = int(eval(input()))
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))
for i in range(N):
H[i] = T - H[i] * 0.006
print((np.abs(np.asarray(H) - A).argmin() + 1))
if __name__ == "__main__":
main()
| def main():
N = int(eval(input()))
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))
for i in range(N):
H[i] = abs(A - (T - H[i] * 0.006))
print((H.index(min(H)) + 1))
if __name__ == "__main__":
main()
| false | 9.090909 | [
"-import numpy as np",
"-",
"-",
"- H[i] = T - H[i] * 0.006",
"- print((np.abs(np.asarray(H) - A).argmin() + 1))",
"+ H[i] = abs(A - (T - H[i] * 0.006))",
"+ print((H.index(min(H)) + 1))"
] | false | 0.174059 | 0.054582 | 3.188937 | [
"s163954294",
"s937758561"
] |
u075304271 | p03086 | python | s455997209 | s545030381 | 152 | 121 | 12,500 | 77,372 | Accepted | Accepted | 20.39 | import math
import itertools
import numpy as np
def solve():
s = eval(input())
le = len(s)
ans = 0
for i in range(le):
for j in range(i, le):
if all("AGCT".count(k) == 1 for k in s[i:j+1]):
ans = max(ans, j-i+1)
print(ans)
return 0
if __name__... | import math
import collections
import fractions
import itertools
import functools
import operator
def solve():
s = eval(input())
size = len(s)
ans = 0
for beg in range(size):
for end in range(beg+1, size+1):
if all('ACGT'.count(c) == 1 for c in s[beg:end]):
... | 17 | 20 | 343 | 416 | import math
import itertools
import numpy as np
def solve():
s = eval(input())
le = len(s)
ans = 0
for i in range(le):
for j in range(i, le):
if all("AGCT".count(k) == 1 for k in s[i : j + 1]):
ans = max(ans, j - i + 1)
print(ans)
return 0
if __name__ == "... | import math
import collections
import fractions
import itertools
import functools
import operator
def solve():
s = eval(input())
size = len(s)
ans = 0
for beg in range(size):
for end in range(beg + 1, size + 1):
if all("ACGT".count(c) == 1 for c in s[beg:end]):
ans ... | false | 15 | [
"+import collections",
"+import fractions",
"-import numpy as np",
"+import functools",
"+import operator",
"- le = len(s)",
"+ size = len(s)",
"- for i in range(le):",
"- for j in range(i, le):",
"- if all(\"AGCT\".count(k) == 1 for k in s[i : j + 1]):",
"- ... | false | 0.103124 | 0.037054 | 2.783048 | [
"s455997209",
"s545030381"
] |
u046187684 | p03503 | python | s152998980 | s282162126 | 71 | 65 | 3,188 | 3,188 | Accepted | Accepted | 8.45 | def solve(string):
n, *fp = string.split()
n = int(n)
f = fp[:10 * n]
p = list(map(int, fp[10 * n:]))
int_f = [int("".join(f[10 * i:10 * (i + 1)]), 2) for i in range(n)]
return str(
max(
sum([p[11 * i + bin(o & _f).count("1")]
for i, _f in enumerate(... | def solve(string):
n, *fp = list(map(int, string.split()))
f = "".join(map(str, fp[:10 * n]))
p = fp[10 * n:]
int_f = [int(f[10 * i:10 * (i + 1)], 2) for i in range(n)]
return str(
max(
sum([p[11 * i + bin(o & _f).count("1")]
for i, _f in enumerate(int_f)... | 16 | 15 | 504 | 492 | def solve(string):
n, *fp = string.split()
n = int(n)
f = fp[: 10 * n]
p = list(map(int, fp[10 * n :]))
int_f = [int("".join(f[10 * i : 10 * (i + 1)]), 2) for i in range(n)]
return str(
max(
sum([p[11 * i + bin(o & _f).count("1")] for i, _f in enumerate(int_f)])
f... | def solve(string):
n, *fp = list(map(int, string.split()))
f = "".join(map(str, fp[: 10 * n]))
p = fp[10 * n :]
int_f = [int(f[10 * i : 10 * (i + 1)], 2) for i in range(n)]
return str(
max(
sum([p[11 * i + bin(o & _f).count("1")] for i, _f in enumerate(int_f)])
for o ... | false | 6.25 | [
"- n, *fp = string.split()",
"- n = int(n)",
"- f = fp[: 10 * n]",
"- p = list(map(int, fp[10 * n :]))",
"- int_f = [int(\"\".join(f[10 * i : 10 * (i + 1)]), 2) for i in range(n)]",
"+ n, *fp = list(map(int, string.split()))",
"+ f = \"\".join(map(str, fp[: 10 * n]))",
"+ p = f... | false | 0.086876 | 0.04078 | 2.130383 | [
"s152998980",
"s282162126"
] |
u753803401 | p03700 | python | s633675245 | s522856029 | 676 | 356 | 44,892 | 46,300 | Accepted | Accepted | 47.34 | import sys
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n, a, b = list(map(int, input().rstrip('\n').split()))
h = [int(input().rstrip('\n')) for _ in range(n)]
cor_v = 10 ** 20
inc_v = -1
while cor_v - inc_v > 1:
bin_v = (cor_v + inc_v) // 2
cost... | import sys
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n, a, b = list(map(int, input().rstrip('\n').split()))
h = [int(input().rstrip('\n')) for _ in range(n)]
cor_v = 10 ** 16
inc_v = -1
while cor_v - inc_v > 1:
bin_v = (cor_v + inc_v) // 2
cost =... | 28 | 28 | 650 | 672 | import sys
def solve():
input = sys.stdin.readline
mod = 10**9 + 7
n, a, b = list(map(int, input().rstrip("\n").split()))
h = [int(input().rstrip("\n")) for _ in range(n)]
cor_v = 10**20
inc_v = -1
while cor_v - inc_v > 1:
bin_v = (cor_v + inc_v) // 2
cost = 0
# 条件を... | import sys
def solve():
input = sys.stdin.readline
mod = 10**9 + 7
n, a, b = list(map(int, input().rstrip("\n").split()))
h = [int(input().rstrip("\n")) for _ in range(n)]
cor_v = 10**16
inc_v = -1
while cor_v - inc_v > 1:
bin_v = (cor_v + inc_v) // 2
cost = 0
# 条件を... | false | 0 | [
"- cor_v = 10**20",
"+ cor_v = 10**16",
"- for v in h:",
"- if v > bin_v * b:",
"- cost += (v - bin_v * b + (a - b) - 1) // (a - b)",
"+ for i in range(n):",
"+ hp = h[i] - bin_v * b",
"+ if hp > 0:",
"+ cost += (hp +... | false | 0.044364 | 0.108769 | 0.407871 | [
"s633675245",
"s522856029"
] |
u473433753 | p03013 | python | s291829655 | s627537356 | 450 | 366 | 463,712 | 465,836 | Accepted | Accepted | 18.67 | import math
def fib(q):
fibonacci = [0,1]
for i in range(2,q):
fibonacci.append(fibonacci[i-2]+fibonacci[i-1])
return fibonacci[q-1]
n,m = list(map(int, input("").split()))
a=[]
a.append(-1)
for i in range(m):
a.append(int(eval(input())))
a.append(n+1)
out=1
c=10**9+7
for i in range... | import math
def fib(q):
fibonacci = [0,1]
for i in range(2,q):
fibonacci.append(fibonacci[i-2]+fibonacci[i-1])
return fibonacci[q-1]
n,m = list(map(int, input("").split()))
a=[]
a.append(-1)
for i in range(m):
a.append(int(eval(input())))
a.append(n+1)
out=1
c=10**9+7
for i in range... | 18 | 18 | 372 | 376 | import math
def fib(q):
fibonacci = [0, 1]
for i in range(2, q):
fibonacci.append(fibonacci[i - 2] + fibonacci[i - 1])
return fibonacci[q - 1]
n, m = list(map(int, input("").split()))
a = []
a.append(-1)
for i in range(m):
a.append(int(eval(input())))
a.append(n + 1)
out = 1
c = 10**9 + 7
fo... | import math
def fib(q):
fibonacci = [0, 1]
for i in range(2, q):
fibonacci.append(fibonacci[i - 2] + fibonacci[i - 1])
return fibonacci[q - 1]
n, m = list(map(int, input("").split()))
a = []
a.append(-1)
for i in range(m):
a.append(int(eval(input())))
a.append(n + 1)
out = 1
c = 10**9 + 7
fo... | false | 0 | [
"-out %= c",
"+ out %= c"
] | false | 0.037305 | 0.036524 | 1.021398 | [
"s291829655",
"s627537356"
] |
u588341295 | p02747 | python | s277857197 | s921866653 | 122 | 19 | 3,444 | 3,188 | Accepted | Accepted | 84.43 | # -*- coding: utf-8 -*-
import sys
from collections import Counter
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range... | # -*- coding: utf-8 -*-
import sys
import re
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)... | 33 | 28 | 897 | 791 | # -*- coding: utf-8 -*-
import sys
from collections import Counter
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d ... | # -*- coding: utf-8 -*-
import sys
import re
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for... | false | 15.151515 | [
"-from collections import Counter",
"+import re",
"-if N % 2 == 1:",
"+if re.match(r\"^(hi)+$\", S):",
"+ Yes()",
"+else:",
"- exit()",
"-for i in range(0, N, 2):",
"- if S[i] != \"h\" or S[i + 1] != \"i\":",
"- No()",
"- exit()",
"-Yes()"
] | false | 0.036406 | 0.095877 | 0.379718 | [
"s277857197",
"s921866653"
] |
u744920373 | p02936 | python | s333966540 | s198365608 | 1,791 | 1,563 | 313,852 | 89,008 | Accepted | Accepted | 12.73 | import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return list(map(int, sys.stdin.readline().split()))
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): ret... | import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
de... | 51 | 50 | 1,257 | 1,288 | import sys
sys.setrecursionlimit(10**8)
def ii():
return int(sys.stdin.readline())
def mi():
return list(map(int, sys.stdin.readline().split()))
def li():
return list(map(int, sys.stdin.readline().split()))
def li2(N):
return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
de... | import sys
def ii():
return int(sys.stdin.readline())
def mi():
return map(int, sys.stdin.readline().split())
def li():
return list(map(int, sys.stdin.readline().split()))
def li2(N):
return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j):
return [[ini] ... | false | 1.960784 | [
"-",
"-sys.setrecursionlimit(10**8)",
"- return list(map(int, sys.stdin.readline().split()))",
"+ return map(int, sys.stdin.readline().split())",
"-## DFS",
"+## BFS",
"+from collections import deque",
"+",
"+",
"- # x[i][0] -= 1",
"- # x[i][1] -= 1",
"- adj[x[i][0] ... | false | 0.10751 | 0.060872 | 1.766158 | [
"s333966540",
"s198365608"
] |
u451012573 | p03031 | python | s087952159 | s640294339 | 194 | 25 | 40,336 | 3,064 | Accepted | Accepted | 87.11 | def main():
N, M = list(map(int, input().split()))
S = []
for i in range(M):
S.append(list([int(x) - 1 for x in input().split()])[1:])
P = list(map(int, input().split()))
ans = 0
for bit in range(1 << N):
for i in range(M):
on = 0
for j in S[i]... | def main():
N, M = list(map(int, input().split()))
S = [list([int(x) - 1 for x in input().split()])[1:] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for bit in range(1 << N):
for i in range(M):
on = 0
for j in S[i]:
if bit ... | 23 | 21 | 538 | 512 | def main():
N, M = list(map(int, input().split()))
S = []
for i in range(M):
S.append(list([int(x) - 1 for x in input().split()])[1:])
P = list(map(int, input().split()))
ans = 0
for bit in range(1 << N):
for i in range(M):
on = 0
for j in S[i]:
... | def main():
N, M = list(map(int, input().split()))
S = [list([int(x) - 1 for x in input().split()])[1:] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for bit in range(1 << N):
for i in range(M):
on = 0
for j in S[i]:
if bit & (1 << j):... | false | 8.695652 | [
"- S = []",
"- for i in range(M):",
"- S.append(list([int(x) - 1 for x in input().split()])[1:])",
"+ S = [list([int(x) - 1 for x in input().split()])[1:] for _ in range(M)]"
] | false | 0.075972 | 0.037283 | 2.0377 | [
"s087952159",
"s640294339"
] |
u849029577 | p03835 | python | s801606234 | s156200827 | 452 | 261 | 120,392 | 40,684 | Accepted | Accepted | 42.26 | k, s = list(map(int, input().split()))
ans = []
for x in range(k+1):
for y in range(k+1):
z = s-(x+y)
if 0 <= z <= k:
ans.append(0)
print((len(ans))) | k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
for y in range(k+1):
z = s-(x+y)
if 0 <= z <= k:
count += 1
print(count) | 8 | 8 | 180 | 175 | k, s = list(map(int, input().split()))
ans = []
for x in range(k + 1):
for y in range(k + 1):
z = s - (x + y)
if 0 <= z <= k:
ans.append(0)
print((len(ans)))
| k, s = list(map(int, input().split()))
count = 0
for x in range(k + 1):
for y in range(k + 1):
z = s - (x + y)
if 0 <= z <= k:
count += 1
print(count)
| false | 0 | [
"-ans = []",
"+count = 0",
"- ans.append(0)",
"-print((len(ans)))",
"+ count += 1",
"+print(count)"
] | false | 0.077873 | 0.060561 | 1.285858 | [
"s801606234",
"s156200827"
] |
u014268998 | p03031 | python | s810142631 | s369685085 | 44 | 35 | 3,064 | 3,064 | Accepted | Accepted | 20.45 |
n,m = list(map(int,input().split()))
a = [list(map(int,input().split())) for i in range(m)]
target = list(map(int,input().split()))
#n,m = 2,3
#a = [[2,1,2], [1,1],[1,2]]
#target = [0,0,1]
ans = 0
s = [0] * n
for i in range(2**n):
x = format(i,'b').zfill(n)
for num,j in enumerate(x):
s[num] =... | # n個のスイッチ
# m個の電球
n,m = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
#n,m = 2,2
#a = [[2,1,2],[1,2]]
#p = [0,1]
#n,m = 10,10
#a = [[4, 6, 3, 7, 5], [3, 1, 10, 5], [4, 8, 7, 1, 2], [5, 5, 10, 2, 7, 8], [6, 3, 1, 6, 8, 2, 5], [5, 6... | 27 | 32 | 521 | 784 | n, m = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(m)]
target = list(map(int, input().split()))
# n,m = 2,3
# a = [[2,1,2], [1,1],[1,2]]
# target = [0,0,1]
ans = 0
s = [0] * n
for i in range(2**n):
x = format(i, "b").zfill(n)
for num, j in enumerate(x):
s[num] = i... | # n個のスイッチ
# m個の電球
n, m = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
# n,m = 2,2
# a = [[2,1,2],[1,2]]
# p = [0,1]
# n,m = 10,10
# a = [[4, 6, 3, 7, 5], [3, 1, 10, 5], [4, 8, 7, 1, 2], [5, 5, 10, 2, 7, 8], [6, 3, 1, 6, 8, 2, 5], [5, 6, 10, ... | false | 15.625 | [
"+# n個のスイッチ",
"+# m個の電球",
"-a = [list(map(int, input().split())) for i in range(m)]",
"-target = list(map(int, input().split()))",
"-# n,m = 2,3",
"-# a = [[2,1,2], [1,1],[1,2]]",
"-# target = [0,0,1]",
"+a = [list(map(int, input().split())) for _ in range(m)]",
"+p = list(map(int, input().split()))... | false | 0.125601 | 0.042395 | 2.962666 | [
"s810142631",
"s369685085"
] |
u509739538 | p02678 | python | s969002408 | s629496477 | 831 | 596 | 35,128 | 34,796 | Accepted | Accepted | 28.28 | import queue
n,m = list(map(int, input().split()))
puted = [1]*(n+1)
ab = [[] for i in range(n+1)]
for i in range(m):
a,b = list(map(int, input().split()))
ab[a].append(b)
ab[b].append(a)
q = queue.Queue()
flg = [-1]*n
flg[0] = 0
q.put(1)
while not q.empty():
item = q.get()
for i in ab[item]:... | from collections import deque
n,m = list(map(int, input().split()))
puted = [1]*(n+1)
ab = [[] for i in range(n+1)]
for i in range(m):
a,b = list(map(int, input().split()))
ab[a].append(b)
ab[b].append(a)
q = deque([1])
flg = [-1]*n
flg[0] = 0
while q:
item = q.popleft()
for i in ab[item]:
... | 31 | 30 | 478 | 477 | import queue
n, m = list(map(int, input().split()))
puted = [1] * (n + 1)
ab = [[] for i in range(n + 1)]
for i in range(m):
a, b = list(map(int, input().split()))
ab[a].append(b)
ab[b].append(a)
q = queue.Queue()
flg = [-1] * n
flg[0] = 0
q.put(1)
while not q.empty():
item = q.get()
for i in ab[it... | from collections import deque
n, m = list(map(int, input().split()))
puted = [1] * (n + 1)
ab = [[] for i in range(n + 1)]
for i in range(m):
a, b = list(map(int, input().split()))
ab[a].append(b)
ab[b].append(a)
q = deque([1])
flg = [-1] * n
flg[0] = 0
while q:
item = q.popleft()
for i in ab[item]... | false | 3.225806 | [
"-import queue",
"+from collections import deque",
"-q = queue.Queue()",
"+q = deque([1])",
"-q.put(1)",
"-while not q.empty():",
"- item = q.get()",
"+while q:",
"+ item = q.popleft()",
"- q.put(i)",
"+ q.append(i)"
] | false | 0.108662 | 0.096968 | 1.120593 | [
"s969002408",
"s629496477"
] |
u494058663 | p02983 | python | s020690943 | s594622159 | 748 | 538 | 3,064 | 9,176 | Accepted | Accepted | 28.07 | import sys
L,R = list(map(int,input().split()))
mod = 2019
cnt = 0
ans = float('inf')
List = [False for i in range(2019)]
for i in range(L,R):
for j in range(i+1,R+1):
tmp = (i*j)%mod
List[tmp] = True
ans = min(tmp,L*R,ans)
if cnt>=10**6 or all(List)==True:
pr... | def main():
mod = 2019
l,r = list(map(int,input().split()))
ans = 10**9
for i in range(l,min(l+2020,r+1)):
for j in range(i+1,min(l+2020,r+1)):
ans = min(ans,(i*j)%mod)
print(ans)
main() | 16 | 9 | 375 | 228 | import sys
L, R = list(map(int, input().split()))
mod = 2019
cnt = 0
ans = float("inf")
List = [False for i in range(2019)]
for i in range(L, R):
for j in range(i + 1, R + 1):
tmp = (i * j) % mod
List[tmp] = True
ans = min(tmp, L * R, ans)
if cnt >= 10**6 or all(List) == True:
... | def main():
mod = 2019
l, r = list(map(int, input().split()))
ans = 10**9
for i in range(l, min(l + 2020, r + 1)):
for j in range(i + 1, min(l + 2020, r + 1)):
ans = min(ans, (i * j) % mod)
print(ans)
main()
| false | 43.75 | [
"-import sys",
"+def main():",
"+ mod = 2019",
"+ l, r = list(map(int, input().split()))",
"+ ans = 10**9",
"+ for i in range(l, min(l + 2020, r + 1)):",
"+ for j in range(i + 1, min(l + 2020, r + 1)):",
"+ ans = min(ans, (i * j) % mod)",
"+ print(ans)",
"-L, R = l... | false | 0.040535 | 0.177052 | 0.228947 | [
"s020690943",
"s594622159"
] |
u562935282 | p03039 | python | s518768180 | s089281414 | 205 | 185 | 11,384 | 54,128 | Accepted | Accepted | 9.76 | from collections import defaultdict
mod = 10 ** 9 + 7
memo = defaultdict(int)
def cmb(n, r):
if (n, r) in memo:
return memo[(n, r)]
if n < r or r < 0:
return 0
if r > n - r:
return cmb(n, n - r)
res = f[n] * pow(f[n - r], mod - 2, mod) * pow(f[r], mod - 2,... | def solve():
mod = 10 ** 9 + 7
def cmb(n, r):
def build():
fs = [1]
t = 1
for x in range(1, h * w):
t = (t * x) % mod
fs.append(t)
invs = [1] * (h * w)
t = pow(t, mod - 2, mod)
invs[-1]... | 41 | 40 | 707 | 990 | from collections import defaultdict
mod = 10**9 + 7
memo = defaultdict(int)
def cmb(n, r):
if (n, r) in memo:
return memo[(n, r)]
if n < r or r < 0:
return 0
if r > n - r:
return cmb(n, n - r)
res = f[n] * pow(f[n - r], mod - 2, mod) * pow(f[r], mod - 2, mod) % mod
memo[(n... | def solve():
mod = 10**9 + 7
def cmb(n, r):
def build():
fs = [1]
t = 1
for x in range(1, h * w):
t = (t * x) % mod
fs.append(t)
invs = [1] * (h * w)
t = pow(t, mod - 2, mod)
invs[-1] = t
... | false | 2.439024 | [
"-from collections import defaultdict",
"+def solve():",
"+ mod = 10**9 + 7",
"-mod = 10**9 + 7",
"-memo = defaultdict(int)",
"+ def cmb(n, r):",
"+ def build():",
"+ fs = [1]",
"+ t = 1",
"+ for x in range(1, h * w):",
"+ t = (t * x) ... | false | 0.146628 | 0.128957 | 1.137033 | [
"s518768180",
"s089281414"
] |
u189023301 | p02984 | python | s127370694 | s940782390 | 201 | 123 | 18,496 | 14,124 | Accepted | Accepted | 38.81 | import sys
input = sys.stdin.readline
n = int(eval(input()))
lis = list(map(int, input().split()))
res = sum(lis)
su = [0] * n
for i in range(n):
if i < 2:
su[i] = lis[i]
else:
su[i] = su[i-2] + lis[i]
ans = []
ans_a = ans.append
for i in range(n):
if i == 0:
b... | import sys
input = sys.stdin.readline
n = int(eval(input()))
lis = list(map(int, input().split()))
su1 = sum(lis)
su2 = sum(lis[1::2])
ans = [0] * n
ans[0] = su1 - 2 * su2
for i in range(1, n):
ans[i] = 2 * lis[i - 1] - ans[i - 1]
print((*ans))
| 34 | 16 | 666 | 261 | import sys
input = sys.stdin.readline
n = int(eval(input()))
lis = list(map(int, input().split()))
res = sum(lis)
su = [0] * n
for i in range(n):
if i < 2:
su[i] = lis[i]
else:
su[i] = su[i - 2] + lis[i]
ans = []
ans_a = ans.append
for i in range(n):
if i == 0:
b = su[-2]
an... | import sys
input = sys.stdin.readline
n = int(eval(input()))
lis = list(map(int, input().split()))
su1 = sum(lis)
su2 = sum(lis[1::2])
ans = [0] * n
ans[0] = su1 - 2 * su2
for i in range(1, n):
ans[i] = 2 * lis[i - 1] - ans[i - 1]
print((*ans))
| false | 52.941176 | [
"-res = sum(lis)",
"-su = [0] * n",
"-for i in range(n):",
"- if i < 2:",
"- su[i] = lis[i]",
"- else:",
"- su[i] = su[i - 2] + lis[i]",
"-ans = []",
"-ans_a = ans.append",
"-for i in range(n):",
"- if i == 0:",
"- b = su[-2]",
"- ans_a(res - 2 * b)",
"... | false | 0.036107 | 0.037365 | 0.966344 | [
"s127370694",
"s940782390"
] |
u562935282 | p03355 | python | s849975387 | s983615215 | 35 | 30 | 4,592 | 4,464 | Accepted | Accepted | 14.29 | # 解説
s = eval(input())
k = int(eval(input()))
st = set()
for start in range(len(s)):
for len_ in range(1, k + 1):
st.add(s[start:start + len_])
*a, = sorted(st)
print((a[k - 1]))
# 高々k文字
# kが小さいので
# 全列挙してソート
| def main():
S = eval(input())
N = len(S)
K = int(eval(input()))
tank = set()
for k in range(1, K + 1):
for i in range(N - k + 1):
t = S[i:i + k]
tank.add(t)
ans = sorted(tank)[K - 1]
print(ans)
if __name__ == '__main__':
main()
# imp... | 15 | 34 | 223 | 651 | # 解説
s = eval(input())
k = int(eval(input()))
st = set()
for start in range(len(s)):
for len_ in range(1, k + 1):
st.add(s[start : start + len_])
(*a,) = sorted(st)
print((a[k - 1]))
# 高々k文字
# kが小さいので
# 全列挙してソート
| def main():
S = eval(input())
N = len(S)
K = int(eval(input()))
tank = set()
for k in range(1, K + 1):
for i in range(N - k + 1):
t = S[i : i + k]
tank.add(t)
ans = sorted(tank)[K - 1]
print(ans)
if __name__ == "__main__":
main()
# import sys
# input = s... | false | 55.882353 | [
"-# 解説",
"-s = eval(input())",
"-k = int(eval(input()))",
"-st = set()",
"-for start in range(len(s)):",
"- for len_ in range(1, k + 1):",
"- st.add(s[start : start + len_])",
"-(*a,) = sorted(st)",
"-print((a[k - 1]))",
"-# 高々k文字",
"-# kが小さいので",
"-# 全列挙してソート",
"+def main():",
"+... | false | 0.049902 | 0.082713 | 0.60332 | [
"s849975387",
"s983615215"
] |
u475503988 | p03212 | python | s754301705 | s517549864 | 95 | 40 | 3,060 | 3,060 | Accepted | Accepted | 57.89 | 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"))) | N = int(eval(input()))
ans = 0
def dfs(x, a, b, c):
global ans
if x > N:
return
if (a & b & c):
ans += 1
dfs(10 * x + 3, 1, b, c)
dfs(10 * x + 5, a, 1, c)
dfs(10 * x + 7, a, b, 1)
dfs(0, 0, 0, 0)
print(ans) | 9 | 15 | 206 | 256 | 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")))
| N = int(eval(input()))
ans = 0
def dfs(x, a, b, c):
global ans
if x > N:
return
if a & b & c:
ans += 1
dfs(10 * x + 3, 1, b, c)
dfs(10 * x + 5, a, 1, c)
dfs(10 * x + 7, a, b, 1)
dfs(0, 0, 0, 0)
print(ans)
| false | 40 | [
"+ans = 0",
"-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",
"+def dfs(x, a, b, c):",
"+ global ans",
"+ if x > N:",
"+ return",
"... | false | 0.070358 | 0.056648 | 1.242014 | [
"s754301705",
"s517549864"
] |
u227082700 | p03775 | python | s263506709 | s029854067 | 34 | 30 | 3,060 | 3,060 | Accepted | Accepted | 11.76 | n=int(eval(input()));ans=10
for i in range(min(10**5,n)):
if n%(i+1)==0:ans=min(ans,max(len(str(i+1)),len(str(n//(i+1)))))
print(ans) | n=int(eval(input()))
ans=inf=float('inf')
for i in range(1,int(n**0.5)+1):
if n%i:continue
ans=max(len(str(n%i)),len(str(n//i)))
print(ans) | 4 | 6 | 132 | 142 | n = int(eval(input()))
ans = 10
for i in range(min(10**5, n)):
if n % (i + 1) == 0:
ans = min(ans, max(len(str(i + 1)), len(str(n // (i + 1)))))
print(ans)
| n = int(eval(input()))
ans = inf = float("inf")
for i in range(1, int(n**0.5) + 1):
if n % i:
continue
ans = max(len(str(n % i)), len(str(n // i)))
print(ans)
| false | 33.333333 | [
"-ans = 10",
"-for i in range(min(10**5, n)):",
"- if n % (i + 1) == 0:",
"- ans = min(ans, max(len(str(i + 1)), len(str(n // (i + 1)))))",
"+ans = inf = float(\"inf\")",
"+for i in range(1, int(n**0.5) + 1):",
"+ if n % i:",
"+ continue",
"+ ans = max(len(str(n % i)), len(str... | false | 0.144424 | 0.042941 | 3.363281 | [
"s263506709",
"s029854067"
] |
u762420987 | p03945 | python | s812420221 | s588145576 | 37 | 18 | 4,652 | 3,188 | Accepted | Accepted | 51.35 | S = list(eval(input()))
now = S[0]
ans = 0
for c in S[1:]:
if c != now:
ans += 1
now = c
print(ans)
| S = eval(input())
print((S.count("BW") + S.count("WB")))
| 8 | 2 | 121 | 50 | S = list(eval(input()))
now = S[0]
ans = 0
for c in S[1:]:
if c != now:
ans += 1
now = c
print(ans)
| S = eval(input())
print((S.count("BW") + S.count("WB")))
| false | 75 | [
"-S = list(eval(input()))",
"-now = S[0]",
"-ans = 0",
"-for c in S[1:]:",
"- if c != now:",
"- ans += 1",
"- now = c",
"-print(ans)",
"+S = eval(input())",
"+print((S.count(\"BW\") + S.count(\"WB\")))"
] | false | 0.049406 | 0.04403 | 1.122102 | [
"s812420221",
"s588145576"
] |
u254871849 | p03633 | python | s763828496 | s006950054 | 25 | 17 | 3,572 | 3,188 | Accepted | Accepted | 32 | import sys
from functools import reduce
def gcd(a, b):
while b:
a, b = b, a % b
return abs(a)
def lcm(a, b):
return abs(a // gcd(a, b) * b)
n, *t = list(map(int, sys.stdin.read().split()))
def main():
return reduce(lcm, t)
if __name__ == '__main__':
ans = main()
pr... | import sys
def gcd(a, b): return gcd(b, a % b) if b else abs(a)
def lcm(a, b): return abs(a // gcd(a, b) * b)
n, *t = list(map(int, sys.stdin.read().split()))
def main():
res = 1
for x in t:
res = lcm(res, x)
print(res)
if __name__ == '__main__':
main() | 19 | 15 | 322 | 290 | import sys
from functools import reduce
def gcd(a, b):
while b:
a, b = b, a % b
return abs(a)
def lcm(a, b):
return abs(a // gcd(a, b) * b)
n, *t = list(map(int, sys.stdin.read().split()))
def main():
return reduce(lcm, t)
if __name__ == "__main__":
ans = main()
print(ans)
| import sys
def gcd(a, b):
return gcd(b, a % b) if b else abs(a)
def lcm(a, b):
return abs(a // gcd(a, b) * b)
n, *t = list(map(int, sys.stdin.read().split()))
def main():
res = 1
for x in t:
res = lcm(res, x)
print(res)
if __name__ == "__main__":
main()
| false | 21.052632 | [
"-from functools import reduce",
"- while b:",
"- a, b = b, a % b",
"- return abs(a)",
"+ return gcd(b, a % b) if b else abs(a)",
"- return reduce(lcm, t)",
"+ res = 1",
"+ for x in t:",
"+ res = lcm(res, x)",
"+ print(res)",
"- ans = main()",
"- print(... | false | 0.034885 | 0.035994 | 0.96917 | [
"s763828496",
"s006950054"
] |
u021086907 | p02729 | python | s783785860 | s738074852 | 27 | 24 | 9,176 | 9,164 | Accepted | Accepted | 11.11 | N,M = list(map(int,input().split()))
if N ==1 and M ==1:
print((0))
elif N ==1 and M != 1:
print((int(M*(M-1)/2)))
elif N != 1 and M ==1:
print((int(N*(N-1)/2)))
else:
a = N*(N-1)
b = M*(M-1)
print((int((a+b)/2))) | N,M = list(map(int,input().split()))
a = N*(N-1)
b = M*(M-1)
print((int((a+b)/2))) | 11 | 4 | 237 | 78 | N, M = list(map(int, input().split()))
if N == 1 and M == 1:
print((0))
elif N == 1 and M != 1:
print((int(M * (M - 1) / 2)))
elif N != 1 and M == 1:
print((int(N * (N - 1) / 2)))
else:
a = N * (N - 1)
b = M * (M - 1)
print((int((a + b) / 2)))
| N, M = list(map(int, input().split()))
a = N * (N - 1)
b = M * (M - 1)
print((int((a + b) / 2)))
| false | 63.636364 | [
"-if N == 1 and M == 1:",
"- print((0))",
"-elif N == 1 and M != 1:",
"- print((int(M * (M - 1) / 2)))",
"-elif N != 1 and M == 1:",
"- print((int(N * (N - 1) / 2)))",
"-else:",
"- a = N * (N - 1)",
"- b = M * (M - 1)",
"- print((int((a + b) / 2)))",
"+a = N * (N - 1)",
"+b =... | false | 0.040601 | 0.03906 | 1.03946 | [
"s783785860",
"s738074852"
] |
u270681687 | p03363 | python | s724693338 | s227808245 | 269 | 244 | 25,976 | 26,136 | Accepted | Accepted | 9.29 | n = int(eval(input()))
a = list(map(int, input().split()))
b = []
bn = 0
for i in range(n):
bn += a[i]
b.append(bn)
b.append(0)
b.sort()
num = []
i = 0
count = 0
for j in range(1, n+1):
if b[i] == b[j]:
count += 1
if j == n:
num.append(count)
else:
... | n = int(eval(input()))
a = list(map(int, input().split()))
cum = [0] * (n+1)
for i in range(n):
cum[i+1] = cum[i] + a[i]
cum.sort()
num = cum[0]
count = 1
ans = 0
for i in range(n):
if cum[i+1] == num:
count += 1
else:
ans += count * (count - 1) // 2
num = cum[i+1]
... | 28 | 25 | 435 | 405 | n = int(eval(input()))
a = list(map(int, input().split()))
b = []
bn = 0
for i in range(n):
bn += a[i]
b.append(bn)
b.append(0)
b.sort()
num = []
i = 0
count = 0
for j in range(1, n + 1):
if b[i] == b[j]:
count += 1
if j == n:
num.append(count)
else:
i = j
num... | n = int(eval(input()))
a = list(map(int, input().split()))
cum = [0] * (n + 1)
for i in range(n):
cum[i + 1] = cum[i] + a[i]
cum.sort()
num = cum[0]
count = 1
ans = 0
for i in range(n):
if cum[i + 1] == num:
count += 1
else:
ans += count * (count - 1) // 2
num = cum[i + 1]
co... | false | 10.714286 | [
"-b = []",
"-bn = 0",
"+cum = [0] * (n + 1)",
"- bn += a[i]",
"- b.append(bn)",
"-b.append(0)",
"-b.sort()",
"-num = []",
"-i = 0",
"-count = 0",
"-for j in range(1, n + 1):",
"- if b[i] == b[j]:",
"+ cum[i + 1] = cum[i] + a[i]",
"+cum.sort()",
"+num = cum[0]",
"+count = 1"... | false | 0.047315 | 0.109428 | 0.432388 | [
"s724693338",
"s227808245"
] |
u038676814 | p03137 | python | s016434720 | s776380076 | 146 | 111 | 13,968 | 19,868 | Accepted | Accepted | 23.97 | N,M = list(map(int, input().split(" ")))
XList = list(map(int,input().split()))
XList = sorted(XList)
deltaList = [0]
for i in range(M-1) :
deltaList.append(XList[i+1] - XList[i])
deltaList = sorted(deltaList, reverse=True)
for i in range(N-1) :
deltaList[i] = 0
if i == len(deltaList)-1 :
... | n,m = list(map(int, input().split(" ")))
xList = [int(i) for i in input().split(" ")]
xList = sorted(xList)
dList = [0]
for i in range(len(xList) -1) :
dList.append(xList[i+1] - xList[i])
dList = sorted(dList, reverse=True)
for i in range(n-1) :
dList[i] = 0
if(i == len(dList) -1) :
... | 16 | 13 | 350 | 338 | N, M = list(map(int, input().split(" ")))
XList = list(map(int, input().split()))
XList = sorted(XList)
deltaList = [0]
for i in range(M - 1):
deltaList.append(XList[i + 1] - XList[i])
deltaList = sorted(deltaList, reverse=True)
for i in range(N - 1):
deltaList[i] = 0
if i == len(deltaList) - 1:
bre... | n, m = list(map(int, input().split(" ")))
xList = [int(i) for i in input().split(" ")]
xList = sorted(xList)
dList = [0]
for i in range(len(xList) - 1):
dList.append(xList[i + 1] - xList[i])
dList = sorted(dList, reverse=True)
for i in range(n - 1):
dList[i] = 0
if i == len(dList) - 1:
break
print((... | false | 18.75 | [
"-N, M = list(map(int, input().split(\" \")))",
"-XList = list(map(int, input().split()))",
"-XList = sorted(XList)",
"-deltaList = [0]",
"-for i in range(M - 1):",
"- deltaList.append(XList[i + 1] - XList[i])",
"-deltaList = sorted(deltaList, reverse=True)",
"-for i in range(N - 1):",
"- delt... | false | 0.035593 | 0.036446 | 0.976601 | [
"s016434720",
"s776380076"
] |
u691018832 | p02850 | python | s634317911 | s933105721 | 514 | 412 | 44,764 | 45,704 | Accepted | Accepted | 19.84 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
ab = [list(map(int, readline().split())) for i in range(n - 1)]
gragh = [[] for j in range(n + 1)]
for a, b in ab:
gragh[a].append(b)
gragh[b].append(a)
root = 1
p... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
from collections import deque
n = int(readline())
graph = [[] for _ in range(n + 1)]
for i in range(n - 1):
a, b = list(map(int, readline().split()))
g... | 46 | 37 | 973 | 862 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
ab = [list(map(int, readline().split())) for i in range(n - 1)]
gragh = [[] for j in range(n + 1)]
for a, b in ab:
gragh[a].append(b)
gragh[b].append(a)
root = 1
parent = [0] ... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
from collections import deque
n = int(readline())
graph = [[] for _ in range(n + 1)]
for i in range(n - 1):
a, b = list(map(int, readline().split()))
graph[a].append... | false | 19.565217 | [
"+sys.setrecursionlimit(10**7)",
"+from collections import deque",
"+",
"-ab = [list(map(int, readline().split())) for i in range(n - 1)]",
"-gragh = [[] for j in range(n + 1)]",
"-for a, b in ab:",
"- gragh[a].append(b)",
"- gragh[b].append(a)",
"-root = 1",
"-parent = [0] * (n + 1)",
"-s... | false | 0.009744 | 0.043865 | 0.222128 | [
"s634317911",
"s933105721"
] |
u684241248 | p02241 | python | s959168566 | s603362835 | 370 | 320 | 6,472 | 6,472 | Accepted | Accepted | 13.51 | # -*- coding: utf-8 -*-
def prim(edges, *, start=0, adj_matrix=False, default_value=float('inf')):
'''
Returns the Minimum Spanning Tree(MST) of a given graph
# sample input when given as adjacency matrix
edges = [[0, 2, 5, 4, inf, inf], # node 0
[2, 0, inf, 3, 6, inf], ... | # -*- coding: utf-8 -*-
def prim(edges, *, start=0, adj_matrix=False, default_value=float('inf')):
'''
Returns the Minimum Spanning Tree(MST) of a given graph
# sample input when given not as adjacency list (generally works faster)
edges = [[(1, 2), (2, 5), (3, 4)], # node 0
... | 62 | 62 | 2,096 | 2,119 | # -*- coding: utf-8 -*-
def prim(edges, *, start=0, adj_matrix=False, default_value=float("inf")):
"""
Returns the Minimum Spanning Tree(MST) of a given graph
# sample input when given as adjacency matrix
edges = [[0, 2, 5, 4, inf, inf], # node 0
[2, 0, inf, 3, 6, inf], ... | # -*- coding: utf-8 -*-
def prim(edges, *, start=0, adj_matrix=False, default_value=float("inf")):
"""
Returns the Minimum Spanning Tree(MST) of a given graph
# sample input when given not as adjacency list (generally works faster)
edges = [[(1, 2), (2, 5), (3, 4)], # node 0
[(0, 2)... | false | 0 | [
"+ # sample input when given not as adjacency list (generally works faster)",
"+ edges = [[(1, 2), (2, 5), (3, 4)], # node 0",
"+ [(0, 2), (3, 3), (4, 6)], # node 1",
"+ [(0, 5), (3, 2), (5, 6)], # node 2",
"+ [(0, 4), (1, 3), (2, 2), (4, 2)]... | false | 0.03956 | 0.03849 | 1.027798 | [
"s959168566",
"s603362835"
] |
u088751997 | p03485 | python | s667562652 | s974140512 | 25 | 19 | 9,152 | 9,152 | Accepted | Accepted | 24 | a,b = list(map(int,input().split()))
c = int((a+b+1)/2)
print(c) | a,b = list(map(int,input().split()))
print(((a+b+1)//2)) | 3 | 2 | 60 | 49 | a, b = list(map(int, input().split()))
c = int((a + b + 1) / 2)
print(c)
| a, b = list(map(int, input().split()))
print(((a + b + 1) // 2))
| false | 33.333333 | [
"-c = int((a + b + 1) / 2)",
"-print(c)",
"+print(((a + b + 1) // 2))"
] | false | 0.039424 | 0.039233 | 1.004851 | [
"s667562652",
"s974140512"
] |
u242679311 | p03550 | python | s885822776 | s761610788 | 1,527 | 19 | 3,188 | 3,188 | Accepted | Accepted | 98.76 | n,z,w = list(map(int,input().split()))
a = list(map(int,input().split()))
xp = [0]*(n)
yp = [10000000000]*(n)
xp[0] = abs(a[n-1]-w)
for i in reversed(list(range(n))):
for j in range(i+1,n):
xp[i] = max(xp[i], yp[j])
yp[i] = min(yp[i], xp[j])
xp[i] = max(xp[i], abs(a[i-1]-a[n-1]))
y... | n,z,w = list(map(int,input().split()))
a = list(map(int,input().split()))
if n == 1:
print((abs(a[0]-w)))
else:
print((max(abs(a[n-1]-w),abs(a[n-1]-a[n-2])))) | 12 | 6 | 359 | 161 | n, z, w = list(map(int, input().split()))
a = list(map(int, input().split()))
xp = [0] * (n)
yp = [10000000000] * (n)
xp[0] = abs(a[n - 1] - w)
for i in reversed(list(range(n))):
for j in range(i + 1, n):
xp[i] = max(xp[i], yp[j])
yp[i] = min(yp[i], xp[j])
xp[i] = max(xp[i], abs(a[i - 1] - a[n -... | n, z, w = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == 1:
print((abs(a[0] - w)))
else:
print((max(abs(a[n - 1] - w), abs(a[n - 1] - a[n - 2]))))
| false | 50 | [
"-xp = [0] * (n)",
"-yp = [10000000000] * (n)",
"-xp[0] = abs(a[n - 1] - w)",
"-for i in reversed(list(range(n))):",
"- for j in range(i + 1, n):",
"- xp[i] = max(xp[i], yp[j])",
"- yp[i] = min(yp[i], xp[j])",
"- xp[i] = max(xp[i], abs(a[i - 1] - a[n - 1]))",
"- yp[i] = min(yp... | false | 0.08346 | 0.048249 | 1.729785 | [
"s885822776",
"s761610788"
] |
u160244242 | p03275 | python | s427511941 | s176510106 | 1,417 | 951 | 133,356 | 131,384 | Accepted | Accepted | 32.89 | from itertools import accumulate
from math import ceil
N = int(eval(input()))
A = list(map(int, input().split()))
if N == 1:
print((A[0]))
exit()
class BinaryIndexedTree:
def __init__(self, n):
self.size = n
self.bit = [0] * (n + 1)
def sum(self, i):
s ... | import math
n = int(input())
lst = list(map(int, input().split()))
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def... | 60 | 60 | 1,258 | 1,357 | from itertools import accumulate
from math import ceil
N = int(eval(input()))
A = list(map(int, input().split()))
if N == 1:
print((A[0]))
exit()
class BinaryIndexedTree:
def __init__(self, n):
self.size = n
self.bit = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0... | import math
n = int(input())
lst = list(map(int, input().split()))
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
... | false | 0 | [
"-from itertools import accumulate",
"-from math import ceil",
"+import math",
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-if N == 1:",
"- print((A[0]))",
"- exit()",
"+n = int(input())",
"+lst = list(map(int, input().split()))",
"-class BinaryIndexedTree:",
"+cl... | false | 0.101156 | 0.08033 | 1.259266 | [
"s427511941",
"s176510106"
] |
u332385682 | p03807 | python | s198917764 | s080367161 | 77 | 71 | 14,108 | 14,232 | Accepted | Accepted | 7.79 | import sys
def debug(x, table):
for name, val in table.items():
if x is val:
print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
return None
def solve():
N = int(input())
A = [int(i) for i in input().split()]
num_ev = 0
num_od = 0
for a i... | import sys
def debug(x, table):
for name, val in table.items():
if x is val:
print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
return None
def solve():
N = int(input())
A = [int(i) for i in input().split()]
yes = 'YES'
no = 'NO'
num_od = ... | 34 | 27 | 660 | 509 | import sys
def debug(x, table):
for name, val in table.items():
if x is val:
print("DEBUG:{} -> {}".format(name, val), file=sys.stderr)
return None
def solve():
N = int(input())
A = [int(i) for i in input().split()]
num_ev = 0
num_od = 0
for a in A:
if... | import sys
def debug(x, table):
for name, val in table.items():
if x is val:
print("DEBUG:{} -> {}".format(name, val), file=sys.stderr)
return None
def solve():
N = int(input())
A = [int(i) for i in input().split()]
yes = "YES"
no = "NO"
num_od = 0
for a i... | false | 20.588235 | [
"- num_ev = 0",
"+ yes = \"YES\"",
"+ no = \"NO\"",
"- if a % 2 == 0:",
"- num_ev += 1",
"- else:",
"+ if a % 2 == 1:",
"- print(\"NO\")",
"- return None",
"+ print(no)",
"- num_ev += num_od // 2",
"- if num_ev >= 1:",... | false | 0.171546 | 0.074466 | 2.303666 | [
"s198917764",
"s080367161"
] |
u340781749 | p03431 | python | s774005063 | s944030791 | 682 | 360 | 44,908 | 22,772 | Accepted | Accepted | 47.21 | def solve(n, k):
MOD = 998244353
if n > k:
return 0
if n == 1:
return pow(2, k - 1, MOD)
invs = [1] * (k + 1)
pf, kf = 1, 1
for m in range(2, k + 1):
pf = kf
kf *= m
kf %= MOD
invs[m] = pow(kf, MOD - 2, MOD)
ans = 0
if k... | def solve(n, k):
MOD = 998244353
if n > k:
return 0
if n == 1:
return pow(2, k - 1, MOD)
pf, kf = 1, 1
for m in range(2, k + 1):
pf = kf
kf *= m
kf %= MOD
inv = pow(kf, MOD - 2, MOD)
invs = [1] * (k + 1)
invs[k] = inv
for m in... | 33 | 39 | 770 | 879 | def solve(n, k):
MOD = 998244353
if n > k:
return 0
if n == 1:
return pow(2, k - 1, MOD)
invs = [1] * (k + 1)
pf, kf = 1, 1
for m in range(2, k + 1):
pf = kf
kf *= m
kf %= MOD
invs[m] = pow(kf, MOD - 2, MOD)
ans = 0
if k & 1 == 0:
r... | def solve(n, k):
MOD = 998244353
if n > k:
return 0
if n == 1:
return pow(2, k - 1, MOD)
pf, kf = 1, 1
for m in range(2, k + 1):
pf = kf
kf *= m
kf %= MOD
inv = pow(kf, MOD - 2, MOD)
invs = [1] * (k + 1)
invs[k] = inv
for m in range(k, 1, -1):
... | false | 15.384615 | [
"- invs = [1] * (k + 1)",
"- invs[m] = pow(kf, MOD - 2, MOD)",
"+ inv = pow(kf, MOD - 2, MOD)",
"+ invs = [1] * (k + 1)",
"+ invs[k] = inv",
"+ for m in range(k, 1, -1):",
"+ inv *= m",
"+ inv %= MOD",
"+ invs[m - 1] = inv"
] | false | 0.285918 | 0.056096 | 5.096923 | [
"s774005063",
"s944030791"
] |
u914797917 | p02725 | python | s730884954 | s059947876 | 271 | 118 | 26,444 | 26,060 | Accepted | Accepted | 56.46 | K,N = list(map(int, input().split()))
A=[]
A=list(map(int, input().split()))
D=[]
for i in range(N-1):
D.append(int(A[i+1])-int(A[i]))
D.append(K-int(A[N-1])+int(A[0]))
Dmax=0
Sum=0
for i in range(N):
if int(D[i])>Dmax:
Dmax=int(D[i])
Sum=Sum+int(D[i])
print((Sum-Dmax)) | K,N=list(map(int, input().split()))
A=list(map(int, input().split()))
D=[]
for i in range(1,N):
D.append(A[i]-A[i-1])
D.append(A[0]+K-A[N-1])
print((sum(D)-max(D))) | 20 | 9 | 304 | 168 | K, N = list(map(int, input().split()))
A = []
A = list(map(int, input().split()))
D = []
for i in range(N - 1):
D.append(int(A[i + 1]) - int(A[i]))
D.append(K - int(A[N - 1]) + int(A[0]))
Dmax = 0
Sum = 0
for i in range(N):
if int(D[i]) > Dmax:
Dmax = int(D[i])
Sum = Sum + int(D[i])
print((Sum - Dma... | K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
D = []
for i in range(1, N):
D.append(A[i] - A[i - 1])
D.append(A[0] + K - A[N - 1])
print((sum(D) - max(D)))
| false | 55 | [
"-A = []",
"-for i in range(N - 1):",
"- D.append(int(A[i + 1]) - int(A[i]))",
"-D.append(K - int(A[N - 1]) + int(A[0]))",
"-Dmax = 0",
"-Sum = 0",
"-for i in range(N):",
"- if int(D[i]) > Dmax:",
"- Dmax = int(D[i])",
"- Sum = Sum + int(D[i])",
"-print((Sum - Dmax))",
"+for i ... | false | 0.036033 | 0.039568 | 0.910668 | [
"s730884954",
"s059947876"
] |
u686230543 | p02662 | python | s161068900 | s809927052 | 323 | 279 | 97,452 | 27,464 | Accepted | Accepted | 13.62 | import numpy as np
mod = 998244353
n, s = list(map(int, input().split()))
dp = np.zeros((n+1, s+1), dtype=int)
dp[0, 0] = 1
for i, a in enumerate(map(int, input().split())):
dp[i+1] = dp[i] * 2 % mod
dp[i+1][a:] = (dp[i+1][a:] + dp[i][:-a]) % mod
print((dp[-1, -1])) | import numpy as np
mod = 998244353
n, s = list(map(int, input().split()))
dp = np.zeros(s+1, dtype=int)
dp[0] = 1
for a in map(int, input().split()):
pre_dp = dp
dp = pre_dp * 2 % mod
dp[a:] = (dp[a:] + pre_dp[:-a]) % mod
print((dp[-1])) | 10 | 11 | 272 | 246 | import numpy as np
mod = 998244353
n, s = list(map(int, input().split()))
dp = np.zeros((n + 1, s + 1), dtype=int)
dp[0, 0] = 1
for i, a in enumerate(map(int, input().split())):
dp[i + 1] = dp[i] * 2 % mod
dp[i + 1][a:] = (dp[i + 1][a:] + dp[i][:-a]) % mod
print((dp[-1, -1]))
| import numpy as np
mod = 998244353
n, s = list(map(int, input().split()))
dp = np.zeros(s + 1, dtype=int)
dp[0] = 1
for a in map(int, input().split()):
pre_dp = dp
dp = pre_dp * 2 % mod
dp[a:] = (dp[a:] + pre_dp[:-a]) % mod
print((dp[-1]))
| false | 9.090909 | [
"-dp = np.zeros((n + 1, s + 1), dtype=int)",
"-dp[0, 0] = 1",
"-for i, a in enumerate(map(int, input().split())):",
"- dp[i + 1] = dp[i] * 2 % mod",
"- dp[i + 1][a:] = (dp[i + 1][a:] + dp[i][:-a]) % mod",
"-print((dp[-1, -1]))",
"+dp = np.zeros(s + 1, dtype=int)",
"+dp[0] = 1",
"+for a in map(... | false | 0.240996 | 0.250379 | 0.962525 | [
"s161068900",
"s809927052"
] |
u061916079 | p03986 | python | s792416259 | s087725242 | 227 | 83 | 14,436 | 3,500 | Accepted | Accepted | 63.44 | # -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
r = range
s = eval(input())
ret = 0
tmp = 0
for c in s:
tmp += 1 if c == 'S' else -1
ret = min(ret, tmp)
print((-ret*2)) | s = eval(input())
ret = 0
tmp = 0
for c in s:
tmp += 1 if c == 'S' else -1
ret = min(ret, tmp)
print((-ret*2)) | 18 | 8 | 274 | 118 | # -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
r = range
s = eval(input())
ret = 0
tmp = 0
for c in s:
tmp += 1 if c == "S" else -1
ret = min(ret, tmp)
print((-ret * 2))
| s = eval(input())
ret = 0
tmp = 0
for c in s:
tmp += 1 if c == "S" else -1
ret = min(ret, tmp)
print((-ret * 2))
| false | 55.555556 | [
"-# -*- coding: utf-8 -*-",
"-import math",
"-import sys",
"-import itertools",
"-import numpy as np",
"-import functools",
"-import collections",
"-",
"-mo = 1000000007",
"-r = range"
] | false | 0.036327 | 0.040741 | 0.891662 | [
"s792416259",
"s087725242"
] |
u700805562 | p02597 | python | s727713400 | s116581402 | 33 | 30 | 9,228 | 9,268 | Accepted | Accepted | 9.09 | n,c=eval(input()),eval(input());print((c[:c.count('R')].count('W'))) | i=input;n,c=i(),i();print((c[:c.count('R')].count('W'))) | 1 | 1 | 54 | 54 | n, c = eval(input()), eval(input())
print((c[: c.count("R")].count("W")))
| i = input
n, c = i(), i()
print((c[: c.count("R")].count("W")))
| false | 0 | [
"-n, c = eval(input()), eval(input())",
"+i = input",
"+n, c = i(), i()"
] | false | 0.04236 | 0.040142 | 1.05525 | [
"s727713400",
"s116581402"
] |
u618306958 | p02713 | python | s126940161 | s955080478 | 478 | 59 | 68,856 | 62,492 | Accepted | Accepted | 87.66 | import math
k = int(eval(input()))
sum = 0
for i in range(1,k+1):
for j in range(1,k+1):
for l in range(1,k+1):
sum+=math.gcd(math.gcd(i,j),l)
print(sum) | k = int(eval(input()))
arr = [0]*(k+1)
count = [0]*(k+1)
sum = 0
n = 3
for i in range(k,1,-1):
x = k//i
p = int(pow(x,n))
arr[i]=i*p
count[i]=p
for j in range(x-1):
arr[i]-=i*count[i*(j+2)]
count[i]-=count[i*(j+2)]
csum = 0
for i in range(2,k+1):
sum+=arr[i]
... | 8 | 20 | 178 | 386 | import math
k = int(eval(input()))
sum = 0
for i in range(1, k + 1):
for j in range(1, k + 1):
for l in range(1, k + 1):
sum += math.gcd(math.gcd(i, j), l)
print(sum)
| k = int(eval(input()))
arr = [0] * (k + 1)
count = [0] * (k + 1)
sum = 0
n = 3
for i in range(k, 1, -1):
x = k // i
p = int(pow(x, n))
arr[i] = i * p
count[i] = p
for j in range(x - 1):
arr[i] -= i * count[i * (j + 2)]
count[i] -= count[i * (j + 2)]
csum = 0
for i in range(2, k + 1):... | false | 60 | [
"-import math",
"-",
"+arr = [0] * (k + 1)",
"+count = [0] * (k + 1)",
"-for i in range(1, k + 1):",
"- for j in range(1, k + 1):",
"- for l in range(1, k + 1):",
"- sum += math.gcd(math.gcd(i, j), l)",
"-print(sum)",
"+n = 3",
"+for i in range(k, 1, -1):",
"+ x = k // ... | false | 0.061853 | 0.036621 | 1.688982 | [
"s126940161",
"s955080478"
] |
u394482932 | p03813 | python | s899831238 | s903833316 | 162 | 17 | 38,256 | 2,940 | Accepted | Accepted | 89.51 | print(("AARBCC"[1200>int(eval(input()))::2])) | print(("AARBCC"["1200">eval(input())::2])) | 1 | 1 | 37 | 34 | print(("AARBCC"[1200 > int(eval(input())) :: 2]))
| print(("AARBCC"["1200" > eval(input()) :: 2]))
| false | 0 | [
"-print((\"AARBCC\"[1200 > int(eval(input())) :: 2]))",
"+print((\"AARBCC\"[\"1200\" > eval(input()) :: 2]))"
] | false | 0.110763 | 0.108096 | 1.024672 | [
"s899831238",
"s903833316"
] |
u977389981 | p03212 | python | s023681201 | s444616340 | 930 | 92 | 4,072 | 4,060 | Accepted | Accepted | 90.11 | N = int(eval(input()))
A = []
def f(s):
if s != '' and eval(s) > N:
return 0
if all(s.count(i) >= 1 for i in '753'):
A.append(eval(s))
for i in '753':
f(s + i)
f('')
print((len(A)))
# print(sorted(A)) | N = int(eval(input()))
A = []
def f(s):
if int(s) > N:
return 0
if all(s.count(i) >= 1 for i in '753'):
A.append(int(s))
for i in '753':
f(s + i)
f('0')
print((len(A)))
# print(sorted(A)) | 14 | 14 | 243 | 230 | N = int(eval(input()))
A = []
def f(s):
if s != "" and eval(s) > N:
return 0
if all(s.count(i) >= 1 for i in "753"):
A.append(eval(s))
for i in "753":
f(s + i)
f("")
print((len(A)))
# print(sorted(A))
| N = int(eval(input()))
A = []
def f(s):
if int(s) > N:
return 0
if all(s.count(i) >= 1 for i in "753"):
A.append(int(s))
for i in "753":
f(s + i)
f("0")
print((len(A)))
# print(sorted(A))
| false | 0 | [
"- if s != \"\" and eval(s) > N:",
"+ if int(s) > N:",
"- A.append(eval(s))",
"+ A.append(int(s))",
"-f(\"\")",
"+f(\"0\")"
] | false | 0.496378 | 0.06006 | 8.264665 | [
"s023681201",
"s444616340"
] |
u075303794 | p02928 | python | s166915315 | s668695446 | 860 | 29 | 3,316 | 3,564 | Accepted | Accepted | 96.63 | N,K = list(map(int,input().split()))
A = list(map(int,input().split()*2))
base1 = 0
base2 = 0
for i in range(N):
count1=0
count2=0
for j in range(i+1,i+N+1):
if A[i] > A[j]:
if j < N:
count1+=1
else:
count2+=1
base1+=count1
base2+=count2
ans = (base1*K*(K+1) + ... | from collections import Counter
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
... | 19 | 39 | 364 | 720 | N, K = list(map(int, input().split()))
A = list(map(int, input().split() * 2))
base1 = 0
base2 = 0
for i in range(N):
count1 = 0
count2 = 0
for j in range(i + 1, i + N + 1):
if A[i] > A[j]:
if j < N:
count1 += 1
else:
count2 += 1
base1 += c... | from collections import Counter
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
... | false | 51.282051 | [
"-N, K = list(map(int, input().split()))",
"-A = list(map(int, input().split() * 2))",
"-base1 = 0",
"-base2 = 0",
"-for i in range(N):",
"- count1 = 0",
"- count2 = 0",
"- for j in range(i + 1, i + N + 1):",
"- if A[i] > A[j]:",
"- if j < N:",
"- count1... | false | 0.103812 | 0.040175 | 2.584007 | [
"s166915315",
"s668695446"
] |
u905203728 | p02631 | python | s453316098 | s162885038 | 298 | 189 | 50,068 | 105,612 | Accepted | Accepted | 36.58 | import numpy as np
n=int(eval(input()))
A=list(map(int,input().split()))
C=A
A=np.array(A)
length=len(format(max(A),"b"))
B=""
for i in range(length):
cnt=np.count_nonzero(A&1)
if cnt%2==0:B +="0"
else:B +="1"
A >>=1
B=int(B[::-1],2)
D=[]
for i in C:
D.append(B^i)
print((*D)) | n=int(input())
A=list(map(int,input().split()))
num=0
for i in A:num ^=i
for i in A:print(num^i,end=" ")
| 19 | 6 | 308 | 110 | import numpy as np
n = int(eval(input()))
A = list(map(int, input().split()))
C = A
A = np.array(A)
length = len(format(max(A), "b"))
B = ""
for i in range(length):
cnt = np.count_nonzero(A & 1)
if cnt % 2 == 0:
B += "0"
else:
B += "1"
A >>= 1
B = int(B[::-1], 2)
D = []
for i in C:
... | n = int(input())
A = list(map(int, input().split()))
num = 0
for i in A:
num ^= i
for i in A:
print(num ^ i, end=" ")
| false | 68.421053 | [
"-import numpy as np",
"-",
"-n = int(eval(input()))",
"+n = int(input())",
"-C = A",
"-A = np.array(A)",
"-length = len(format(max(A), \"b\"))",
"-B = \"\"",
"-for i in range(length):",
"- cnt = np.count_nonzero(A & 1)",
"- if cnt % 2 == 0:",
"- B += \"0\"",
"- else:",
"- ... | false | 0.198635 | 0.036848 | 5.390641 | [
"s453316098",
"s162885038"
] |
u017810624 | p03660 | python | s873482695 | s762636296 | 733 | 440 | 82,388 | 77,656 | Accepted | Accepted | 39.97 | def bfs(v):
distance=[-1]*n
distance[v]=0
next=connection[v]
next2=set()
visited=[-1]*n
visited[v]=1
visitct=1
ct=0
while visitct!=n:
ct+=1
for i in range(len(next)):
distance[next[i]]=ct
visited[next[i]]=1
visitct+=1
for j in range(len(connection[next[i]... | def bfs(v):
distance=[-1]*n
distance[v]=0
next=connection[v]
next2=set()
visited=[-1]*n
visited[v]=1
visitct=1
ct=0
while visitct!=n:
ct+=1
for i in range(len(next)):
distance[next[i]]=ct
visited[next[i]]=1
visitct+=1
for j in range(len(connection[next[i]... | 42 | 44 | 865 | 905 | def bfs(v):
distance = [-1] * n
distance[v] = 0
next = connection[v]
next2 = set()
visited = [-1] * n
visited[v] = 1
visitct = 1
ct = 0
while visitct != n:
ct += 1
for i in range(len(next)):
distance[next[i]] = ct
visited[next[i]] = 1
... | def bfs(v):
distance = [-1] * n
distance[v] = 0
next = connection[v]
next2 = set()
visited = [-1] * n
visited[v] = 1
visitct = 1
ct = 0
while visitct != n:
ct += 1
for i in range(len(next)):
distance[next[i]] = ct
visited[next[i]] = 1
... | false | 4.545455 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.045401 | 0.04468 | 1.016126 | [
"s873482695",
"s762636296"
] |
u533883485 | p02271 | python | s919755875 | s611322200 | 6,350 | 20 | 7,952 | 8,024 | Accepted | Accepted | 99.69 | # coding=utf-8
def solve(i, m):
global A
if m == 0:
ever_calc[i][m] = True
return True
elif m < 0:
ever_calc[i][m] = False
return False
elif i == n:
ever_calc[i][m] = False
return False
else:
result = (solve(i+1, m) or solve(i+1,... | # coding=utf-8
def solve(i, m):
global A
if ever_calc[i][m] != None:
return ever_calc[i][m]
if m == 0:
ever_calc[i][m] = True
return True
elif m < 0:
ever_calc[i][m] = False
return False
elif i == n:
ever_calc[i][m] = False
retur... | 32 | 34 | 697 | 762 | # coding=utf-8
def solve(i, m):
global A
if m == 0:
ever_calc[i][m] = True
return True
elif m < 0:
ever_calc[i][m] = False
return False
elif i == n:
ever_calc[i][m] = False
return False
else:
result = solve(i + 1, m) or solve(i + 1, m - A[i])
... | # coding=utf-8
def solve(i, m):
global A
if ever_calc[i][m] != None:
return ever_calc[i][m]
if m == 0:
ever_calc[i][m] = True
return True
elif m < 0:
ever_calc[i][m] = False
return False
elif i == n:
ever_calc[i][m] = False
return False
els... | false | 5.882353 | [
"+ if ever_calc[i][m] != None:",
"+ return ever_calc[i][m]"
] | false | 0.051629 | 0.050507 | 1.0222 | [
"s919755875",
"s611322200"
] |
u201234972 | p03331 | python | s462584019 | s725742665 | 436 | 17 | 2,940 | 3,060 | Accepted | Accepted | 96.1 | def kakuwa(S):
A = list(str(S))
B = [int(x) for x in A]
return sum(B)
N = int(eval(input()))
ans = 50
for i in range(1,N):
ans = min(ans, kakuwa(i) + kakuwa(N-i))
print(ans) | def kakuwa(S):
A = list(str(S))
B = [int(x) for x in A]
return sum(B)
N = int(eval(input()))
for i in range(1,5):
if N%(10**i) == 0:
ans = 10
break
else:
ans = kakuwa(N)
print(ans) | 10 | 13 | 197 | 227 | def kakuwa(S):
A = list(str(S))
B = [int(x) for x in A]
return sum(B)
N = int(eval(input()))
ans = 50
for i in range(1, N):
ans = min(ans, kakuwa(i) + kakuwa(N - i))
print(ans)
| def kakuwa(S):
A = list(str(S))
B = [int(x) for x in A]
return sum(B)
N = int(eval(input()))
for i in range(1, 5):
if N % (10**i) == 0:
ans = 10
break
else:
ans = kakuwa(N)
print(ans)
| false | 23.076923 | [
"-ans = 50",
"-for i in range(1, N):",
"- ans = min(ans, kakuwa(i) + kakuwa(N - i))",
"+for i in range(1, 5):",
"+ if N % (10**i) == 0:",
"+ ans = 10",
"+ break",
"+else:",
"+ ans = kakuwa(N)"
] | false | 0.248556 | 0.036999 | 6.717829 | [
"s462584019",
"s725742665"
] |
u729133443 | p04048 | python | s755419303 | s830726603 | 263 | 20 | 64,620 | 9,164 | Accepted | Accepted | 92.4 | from fractions import*
n,x=list(map(int,input().split()))
print((3*(n-gcd(n,x)))) | import math
n,x=list(map(int,input().split()))
print((3*(n-math.gcd(n,x)))) | 3 | 3 | 75 | 69 | from fractions import *
n, x = list(map(int, input().split()))
print((3 * (n - gcd(n, x))))
| import math
n, x = list(map(int, input().split()))
print((3 * (n - math.gcd(n, x))))
| false | 0 | [
"-from fractions import *",
"+import math",
"-print((3 * (n - gcd(n, x))))",
"+print((3 * (n - math.gcd(n, x))))"
] | false | 0.166344 | 0.036022 | 4.61791 | [
"s755419303",
"s830726603"
] |
u945200821 | p02713 | python | s088503553 | s051681144 | 963 | 338 | 143,128 | 26,936 | Accepted | Accepted | 64.9 | import math
from typing import List, NoReturn
def sum_gcd(k: int) -> int:
cache: List[List[List[int]]] = [[[0] * (k + 1) for i in range(k + 1)] for j in range(k + 1)]
def cached_gcd(a: int, b: int, c: int) -> int:
k0: int
k1: int
k2: int
k0, k1, k2 = sorted([a, b, c... | from math import gcd
import numpy as np
def sum_gcd(k: int) -> int:
# a > b > c
sum_p1 = 0
for h in range(1, k + 1):
for i in range(1, h):
for j in range(1, i):
sum_p1 += gcd(gcd(h, i), j)
# a = b > c and a > b = c
sum_p2 = 0
f... | 37 | 34 | 880 | 649 | import math
from typing import List, NoReturn
def sum_gcd(k: int) -> int:
cache: List[List[List[int]]] = [
[[0] * (k + 1) for i in range(k + 1)] for j in range(k + 1)
]
def cached_gcd(a: int, b: int, c: int) -> int:
k0: int
k1: int
k2: int
k0, k1, k2 = sorted([a, b... | from math import gcd
import numpy as np
def sum_gcd(k: int) -> int:
# a > b > c
sum_p1 = 0
for h in range(1, k + 1):
for i in range(1, h):
for j in range(1, i):
sum_p1 += gcd(gcd(h, i), j)
# a = b > c and a > b = c
sum_p2 = 0
for h in range(1, k + 1):
... | false | 8.108108 | [
"-import math",
"-from typing import List, NoReturn",
"+from math import gcd",
"+import numpy as np",
"- cache: List[List[List[int]]] = [",
"- [[0] * (k + 1) for i in range(k + 1)] for j in range(k + 1)",
"- ]",
"-",
"- def cached_gcd(a: int, b: int, c: int) -> int:",
"- k0:... | false | 0.047881 | 0.047504 | 1.007942 | [
"s088503553",
"s051681144"
] |
u627803856 | p02613 | python | s981134002 | s305688548 | 200 | 163 | 79,512 | 74,456 | Accepted | Accepted | 18.5 | n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
from collections import Counter
c = Counter(s)
if 'AC' in list(c.keys()):
print(('AC x', c['AC']))
else:
print('AC x 0')
if 'WA' in list(c.keys()):
print(('WA x', c['WA']))
else:
print('WA x 0')
if 'TLE' in list(c.keys()):
p... | from collections import defaultdict
n = int(eval(input()))
d = defaultdict(int)
for i in range(n):
d[eval(input())] += 1
for v in ['AC', 'WA', 'TLE', 'RE']:
print((v, 'x', d[v])) | 21 | 7 | 417 | 178 | n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
from collections import Counter
c = Counter(s)
if "AC" in list(c.keys()):
print(("AC x", c["AC"]))
else:
print("AC x 0")
if "WA" in list(c.keys()):
print(("WA x", c["WA"]))
else:
print("WA x 0")
if "TLE" in list(c.keys()):
print(("TLE x",... | from collections import defaultdict
n = int(eval(input()))
d = defaultdict(int)
for i in range(n):
d[eval(input())] += 1
for v in ["AC", "WA", "TLE", "RE"]:
print((v, "x", d[v]))
| false | 66.666667 | [
"+from collections import defaultdict",
"+",
"-s = [eval(input()) for _ in range(n)]",
"-from collections import Counter",
"-",
"-c = Counter(s)",
"-if \"AC\" in list(c.keys()):",
"- print((\"AC x\", c[\"AC\"]))",
"-else:",
"- print(\"AC x 0\")",
"-if \"WA\" in list(c.keys()):",
"- pr... | false | 0.124678 | 0.079 | 1.578192 | [
"s981134002",
"s305688548"
] |
u028973125 | p02837 | python | s191068161 | s566498760 | 298 | 237 | 45,164 | 44,140 | Accepted | Accepted | 20.47 | import sys
from pprint import pprint
def solve(n, info):
ans = 0
for i in range(2 ** n):
true_info = {}
p_info = [0] * n
for j in range(n):
if (i >> j) & 1:
true_info[j] = info[j]
for x, y in info[j]:
if y == 1:... | import sys
from pprint import pprint
def solve(n, info):
ans = 0
for i in range(2 ** n):
true_info = {}
p_info = [0] * n
for j in range(n):
if (i >> j) & 1:
true_info[j] = info[j]
# pprint(info[j])
p_info[j] = 1
... | 47 | 44 | 1,279 | 1,157 | import sys
from pprint import pprint
def solve(n, info):
ans = 0
for i in range(2**n):
true_info = {}
p_info = [0] * n
for j in range(n):
if (i >> j) & 1:
true_info[j] = info[j]
for x, y in info[j]:
if y == 1:
... | import sys
from pprint import pprint
def solve(n, info):
ans = 0
for i in range(2**n):
true_info = {}
p_info = [0] * n
for j in range(n):
if (i >> j) & 1:
true_info[j] = info[j]
# pprint(info[j])
p_info[j] = 1
# print(... | false | 6.382979 | [
"- for x, y in info[j]:",
"- if y == 1:",
"- true_info[x - 1] = info[x - 1]"
] | false | 0.043396 | 0.041334 | 1.049889 | [
"s191068161",
"s566498760"
] |
u314050667 | p02688 | python | s742101004 | s097557123 | 58 | 21 | 67,856 | 9,168 | Accepted | Accepted | 63.79 | N, K = list(map(int, input().split()))
q = set([])
for _ in range(K):
d = int(eval(input()))
tmp = list(map(int, input().split()))
for i in range(d):
q.add(tmp[i])
ans = N - len(q)
print(ans) | N, K = list(map(int, input().split()))
q = set([])
for _ in range(K):
tmp = int(eval(input()))
A = list(map(int, input().split()))
for a in A:
q.add(a)
print((N - len(q))) | 11 | 9 | 211 | 186 | N, K = list(map(int, input().split()))
q = set([])
for _ in range(K):
d = int(eval(input()))
tmp = list(map(int, input().split()))
for i in range(d):
q.add(tmp[i])
ans = N - len(q)
print(ans)
| N, K = list(map(int, input().split()))
q = set([])
for _ in range(K):
tmp = int(eval(input()))
A = list(map(int, input().split()))
for a in A:
q.add(a)
print((N - len(q)))
| false | 18.181818 | [
"- d = int(eval(input()))",
"- tmp = list(map(int, input().split()))",
"- for i in range(d):",
"- q.add(tmp[i])",
"-ans = N - len(q)",
"-print(ans)",
"+ tmp = int(eval(input()))",
"+ A = list(map(int, input().split()))",
"+ for a in A:",
"+ q.add(a)",
"+print((N -... | false | 0.038847 | 0.035899 | 1.082116 | [
"s742101004",
"s097557123"
] |
u729133443 | p03128 | python | s509102132 | s893478407 | 206 | 164 | 14,444 | 15,268 | Accepted | Accepted | 20.39 | n,m,*a=list(map(int,open(0).read().split()))
d=[0]*-~n
for i in range(1,n+1):
for j,k in zip(list(range(9)),(2,5,5,4,5,6,3,7,6)):
if i-k>=0and(i-k<1or d[i-k])and j+1in a:d[i]=max(d[i],d[i-k]*10+j+1)
print((d[n])) | n,m,*a=list(map(int,open(0).read().split()))
c=(0,2,5,5,4,5,6,3,7,6)
d=[0]+[-1]*n*9
for i in range(n):
for j in a:
if d[i]>=0:d[i+c[j]]=max(d[i+c[j]],d[i]*10+j)
print((d[n])) | 6 | 7 | 206 | 175 | n, m, *a = list(map(int, open(0).read().split()))
d = [0] * -~n
for i in range(1, n + 1):
for j, k in zip(list(range(9)), (2, 5, 5, 4, 5, 6, 3, 7, 6)):
if i - k >= 0 and (i - k < 1 or d[i - k]) and j + 1 in a:
d[i] = max(d[i], d[i - k] * 10 + j + 1)
print((d[n]))
| n, m, *a = list(map(int, open(0).read().split()))
c = (0, 2, 5, 5, 4, 5, 6, 3, 7, 6)
d = [0] + [-1] * n * 9
for i in range(n):
for j in a:
if d[i] >= 0:
d[i + c[j]] = max(d[i + c[j]], d[i] * 10 + j)
print((d[n]))
| false | 14.285714 | [
"-d = [0] * -~n",
"-for i in range(1, n + 1):",
"- for j, k in zip(list(range(9)), (2, 5, 5, 4, 5, 6, 3, 7, 6)):",
"- if i - k >= 0 and (i - k < 1 or d[i - k]) and j + 1 in a:",
"- d[i] = max(d[i], d[i - k] * 10 + j + 1)",
"+c = (0, 2, 5, 5, 4, 5, 6, 3, 7, 6)",
"+d = [0] + [-1] * n ... | false | 0.089328 | 0.0337 | 2.650702 | [
"s509102132",
"s893478407"
] |
u010870870 | p02714 | python | s179190349 | s033419867 | 1,535 | 1,384 | 9,176 | 9,084 | Accepted | Accepted | 9.84 | N = int(eval(input()))
S = eval(input())
sum = 0
r = 0
g = 0
b = 0
for i in range(N):
if S[i] == "R":
r+=1
elif S[i] == "G":
g+=1
else:
b+=1
sum = r*g*b
for i in range(N):
for j in range((N-i)//2 +1):
try:
a = S[i]
b = S[i+j... | N = int(eval(input()))
S = eval(input())
sum = 0
r = 0
g = 0
b = 0
for i in range(N):
if S[i] == "R":
r+=1
elif S[i] == "G":
g+=1
else:
b+=1
sum = r*g*b
for i in range(N):
for j in range(N):
try:
a = S[i]
b = S[i+j]
... | 29 | 29 | 454 | 442 | N = int(eval(input()))
S = eval(input())
sum = 0
r = 0
g = 0
b = 0
for i in range(N):
if S[i] == "R":
r += 1
elif S[i] == "G":
g += 1
else:
b += 1
sum = r * g * b
for i in range(N):
for j in range((N - i) // 2 + 1):
try:
a = S[i]
b = S[i + j]
... | N = int(eval(input()))
S = eval(input())
sum = 0
r = 0
g = 0
b = 0
for i in range(N):
if S[i] == "R":
r += 1
elif S[i] == "G":
g += 1
else:
b += 1
sum = r * g * b
for i in range(N):
for j in range(N):
try:
a = S[i]
b = S[i + j]
c = S[i ... | false | 0 | [
"- for j in range((N - i) // 2 + 1):",
"+ for j in range(N):",
"- continue",
"+ break"
] | false | 0.089238 | 0.046665 | 1.912288 | [
"s179190349",
"s033419867"
] |
u678167152 | p02603 | python | s531039473 | s489479300 | 63 | 29 | 62,120 | 9,204 | Accepted | Accepted | 53.97 | def solve():
ans = 0
N = int(eval(input()))
A = [float('inf')]+list(map(int, input().split()))+[-float('inf')]
UD = [0]*(N+1)
for i in range(N+1):
if A[i]>A[i+1]:
UD[i] = -1
elif A[i]<A[i+1]:
UD[i] = 1
else:
UD[i] = UD[i-1]
UD2 = [0]*N
for i in range(N):
if ... | N = int(eval(input()))
A = list(map(int, input().split()))
def sell(money,stock,price):
money += price*stock
stock = 0
return money, stock
def buy(money,price):
stock,money = divmod(money,price)
return money,stock
money = 1000
stock = 0
for i in range(N):
money, stock = sell(money,stock,A[... | 34 | 19 | 716 | 396 | def solve():
ans = 0
N = int(eval(input()))
A = [float("inf")] + list(map(int, input().split())) + [-float("inf")]
UD = [0] * (N + 1)
for i in range(N + 1):
if A[i] > A[i + 1]:
UD[i] = -1
elif A[i] < A[i + 1]:
UD[i] = 1
else:
UD[i] = UD[i -... | N = int(eval(input()))
A = list(map(int, input().split()))
def sell(money, stock, price):
money += price * stock
stock = 0
return money, stock
def buy(money, price):
stock, money = divmod(money, price)
return money, stock
money = 1000
stock = 0
for i in range(N):
money, stock = sell(money,... | false | 44.117647 | [
"-def solve():",
"- ans = 0",
"- N = int(eval(input()))",
"- A = [float(\"inf\")] + list(map(int, input().split())) + [-float(\"inf\")]",
"- UD = [0] * (N + 1)",
"- for i in range(N + 1):",
"- if A[i] > A[i + 1]:",
"- UD[i] = -1",
"- elif A[i] < A[i + 1]:",
... | false | 0.055658 | 0.045313 | 1.228313 | [
"s531039473",
"s489479300"
] |
u818349438 | p02852 | python | s792782025 | s895604838 | 236 | 201 | 50,672 | 10,232 | Accepted | Accepted | 14.83 | n,m = list(map(int,input().split()))
s = eval(input())
cnt = [0]*(n+1)
r = n
for i in range(n-1,-1,-1):
if s[i] == '1':
cnt[i] = -1
continue
while r > i+m:r -=1
while cnt[r] == -1:r -= 1
if i == r:
print((-1))
exit(0)
cnt[i] =cnt[r]+1
now = 0
ans = []
... | n,m = list(map(int,input().split()))
s = eval(input())
dp = [0]*(n+1)
r = n
for i in range(n-1,-1,-1):
if int(s[i]) == 1:
dp[i] = -1
continue
while r > i+m:r-=1
while dp[r] == -1:r -= 1
if r == i:
print((-1))
exit(0)
dp[i] = dp[r]+1
now = 0
ans = []
... | 28 | 26 | 495 | 460 | n, m = list(map(int, input().split()))
s = eval(input())
cnt = [0] * (n + 1)
r = n
for i in range(n - 1, -1, -1):
if s[i] == "1":
cnt[i] = -1
continue
while r > i + m:
r -= 1
while cnt[r] == -1:
r -= 1
if i == r:
print((-1))
exit(0)
cnt[i] = cnt[r] + 1... | n, m = list(map(int, input().split()))
s = eval(input())
dp = [0] * (n + 1)
r = n
for i in range(n - 1, -1, -1):
if int(s[i]) == 1:
dp[i] = -1
continue
while r > i + m:
r -= 1
while dp[r] == -1:
r -= 1
if r == i:
print((-1))
exit(0)
dp[i] = dp[r] + 1
n... | false | 7.142857 | [
"-cnt = [0] * (n + 1)",
"+dp = [0] * (n + 1)",
"- if s[i] == \"1\":",
"- cnt[i] = -1",
"+ if int(s[i]) == 1:",
"+ dp[i] = -1",
"- while cnt[r] == -1:",
"+ while dp[r] == -1:",
"- if i == r:",
"+ if r == i:",
"- cnt[i] = cnt[r] + 1",
"+ dp[i] = dp[r] + 1",
... | false | 0.044548 | 0.044697 | 0.996649 | [
"s792782025",
"s895604838"
] |
u761320129 | p02615 | python | s018474682 | s397043162 | 162 | 134 | 31,340 | 31,584 | Accepted | Accepted | 17.28 | N = int(eval(input()))
A = list(map(int,input().split()))
A.sort()
if N==2:
print((max(A)))
exit()
ans = A.pop()
n = N-2
while A:
a = A.pop()
for _ in range(2):
n -= 1
ans += a
if n==0:
print(ans)
exit() | N = int(eval(input()))
A = list(map(int,input().split()))
A.sort(reverse=True)
ans = 0
for i in range(1,N):
ans += A[i//2]
print(ans) | 17 | 8 | 276 | 139 | N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
if N == 2:
print((max(A)))
exit()
ans = A.pop()
n = N - 2
while A:
a = A.pop()
for _ in range(2):
n -= 1
ans += a
if n == 0:
print(ans)
exit()
| N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
for i in range(1, N):
ans += A[i // 2]
print(ans)
| false | 52.941176 | [
"-A.sort()",
"-if N == 2:",
"- print((max(A)))",
"- exit()",
"-ans = A.pop()",
"-n = N - 2",
"-while A:",
"- a = A.pop()",
"- for _ in range(2):",
"- n -= 1",
"- ans += a",
"- if n == 0:",
"- print(ans)",
"- exit()",
"+A.sort(reverse... | false | 0.039848 | 0.043847 | 0.908793 | [
"s018474682",
"s397043162"
] |
u325492232 | p02583 | python | s425585066 | s285515724 | 1,009 | 89 | 115,828 | 9,168 | Accepted | Accepted | 91.18 | from numba import jit
@jit
def abc175_b():
n = int(eval(input()))
l = list(map(int, input().split(' ')))
cnt = 0
for i in range(0, n - 2):
for j in range(i + 1, n):
for k in range(j + 1, n):
# 辺の長さが同じ場合は却下
if l[i] == l[j] or l[j] == l[k... | def abc175_b():
n = int(eval(input()))
l = list(map(int, input().split(' ')))
cnt = 0
for i in range(0, n - 2):
for j in range(i + 1, n - 1):
for k in range(j + 1, n):
# 辺の長さが同じ場合は却下
if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
... | 22 | 19 | 591 | 564 | from numba import jit
@jit
def abc175_b():
n = int(eval(input()))
l = list(map(int, input().split(" ")))
cnt = 0
for i in range(0, n - 2):
for j in range(i + 1, n):
for k in range(j + 1, n):
# 辺の長さが同じ場合は却下
if l[i] == l[j] or l[j] == l[k] or l[k] == l... | def abc175_b():
n = int(eval(input()))
l = list(map(int, input().split(" ")))
cnt = 0
for i in range(0, n - 2):
for j in range(i + 1, n - 1):
for k in range(j + 1, n):
# 辺の長さが同じ場合は却下
if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
... | false | 13.636364 | [
"-from numba import jit",
"-",
"-",
"-@jit",
"- for j in range(i + 1, n):",
"+ for j in range(i + 1, n - 1):"
] | false | 0.111454 | 0.074998 | 1.486086 | [
"s425585066",
"s285515724"
] |
u406158207 | p03109 | python | s959142653 | s262000769 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | Y,M,D=list(map(int,input().split("/")))
if M<=4:
print("Heisei")
else:
print("TBD")
| X=eval(input())
A,B,C=(X.split('/'))
B=int(B)
C=int(C)
if B<=4:
print("Heisei")
else:
print("TBD") | 5 | 9 | 86 | 109 | Y, M, D = list(map(int, input().split("/")))
if M <= 4:
print("Heisei")
else:
print("TBD")
| X = eval(input())
A, B, C = X.split("/")
B = int(B)
C = int(C)
if B <= 4:
print("Heisei")
else:
print("TBD")
| false | 44.444444 | [
"-Y, M, D = list(map(int, input().split(\"/\")))",
"-if M <= 4:",
"+X = eval(input())",
"+A, B, C = X.split(\"/\")",
"+B = int(B)",
"+C = int(C)",
"+if B <= 4:"
] | false | 0.118185 | 0.04459 | 2.650484 | [
"s959142653",
"s262000769"
] |
u254871849 | p03212 | python | s657273047 | s999612077 | 61 | 43 | 4,212 | 4,212 | Accepted | Accepted | 29.51 | import sys
from itertools import product
from bisect import bisect_right as bi_r
shichigosan = set('357')
cand = []
for i in range(3, 10):
for x in product('357', repeat=i):
x = ''.join(x)
if set(x) == shichigosan:
cand.append(int(''.join(x)))
n = int(sys.stdin.readline()... | import sys
from itertools import product
from bisect import bisect_right as bi_r
cand = [int(''.join(p)) for i in range(3, 10) for p in product('357', repeat=i) if len(set(p)) == 3]
n = int(sys.stdin.readline().rstrip())
def main():
print((bi_r(cand, n)))
if __name__ == '__main__':
main() | 21 | 13 | 435 | 312 | import sys
from itertools import product
from bisect import bisect_right as bi_r
shichigosan = set("357")
cand = []
for i in range(3, 10):
for x in product("357", repeat=i):
x = "".join(x)
if set(x) == shichigosan:
cand.append(int("".join(x)))
n = int(sys.stdin.readline().rstrip())
de... | import sys
from itertools import product
from bisect import bisect_right as bi_r
cand = [
int("".join(p))
for i in range(3, 10)
for p in product("357", repeat=i)
if len(set(p)) == 3
]
n = int(sys.stdin.readline().rstrip())
def main():
print((bi_r(cand, n)))
if __name__ == "__main__":
main()... | false | 38.095238 | [
"-shichigosan = set(\"357\")",
"-cand = []",
"-for i in range(3, 10):",
"- for x in product(\"357\", repeat=i):",
"- x = \"\".join(x)",
"- if set(x) == shichigosan:",
"- cand.append(int(\"\".join(x)))",
"+cand = [",
"+ int(\"\".join(p))",
"+ for i in range(3, 10)"... | false | 0.07758 | 0.059772 | 1.297918 | [
"s657273047",
"s999612077"
] |
u333945892 | p03261 | python | s236757463 | s625866841 | 38 | 31 | 4,456 | 4,332 | Accepted | Accepted | 18.42 | from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
N = int(eval(input()))
ww = [eval(inpu... | from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())
N = int(eval(input()))
li = []
start = T... | 22 | 28 | 496 | 585 | from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, datetime
sys.setrecursionlimit(10**8)
INF = float("inf")
mod = 10**9 + 7
eps = 10**-7
def inpl():
return list(map(int, input().split()))
def inpls():
return list(input().split())
N = int(eval(input()))
w... | from collections import defaultdict
import sys, heapq, bisect, math, itertools, string, queue, datetime
sys.setrecursionlimit(10**8)
INF = float("inf")
mod = 10**9 + 7
eps = 10**-7
def inpl():
return list(map(int, input().split()))
def inpl_str():
return list(input().split())
N = int(eval(input()))
li = ... | false | 21.428571 | [
"-from collections import defaultdict, deque",
"+from collections import defaultdict",
"-def inpls():",
"+def inpl_str():",
"-ww = [eval(input()) for i in range(N)]",
"-if len(set(ww)) != N:",
"- print(\"No\")",
"-else:",
"- for i in range(N - 1):",
"- a = ww[i]",
"- b = ww[i... | false | 0.03543 | 0.037071 | 0.955723 | [
"s236757463",
"s625866841"
] |
u945359338 | p02595 | python | s492315713 | s600709561 | 1,512 | 840 | 57,420 | 57,424 | Accepted | Accepted | 44.44 | from decimal import *
getcontext().prec = 50
N, D = list(map(int, input().split()))
def distance(x1, x2, y1, y2):
dx = x2-x1
dy = y2-y1
return (dx*dx + dy*dy).sqrt()
X = [0] * N
Y = [0] * N
for i in range(N):
X[i], Y[i] = list(map(Decimal, input().split()))
ans = 0
for i in range(N... | from decimal import *
getcontext().prec = 14
N, D = list(map(int, input().split()))
def distance(x1, x2, y1, y2):
dx = x2-x1
dy = y2-y1
return (dx*dx + dy*dy).sqrt()
X = [0] * N
Y = [0] * N
ans = 0
for i in range(N):
X[i], Y[i] = list(map(Decimal, input().split()))
if (distance... | 22 | 21 | 386 | 366 | from decimal import *
getcontext().prec = 50
N, D = list(map(int, input().split()))
def distance(x1, x2, y1, y2):
dx = x2 - x1
dy = y2 - y1
return (dx * dx + dy * dy).sqrt()
X = [0] * N
Y = [0] * N
for i in range(N):
X[i], Y[i] = list(map(Decimal, input().split()))
ans = 0
for i in range(N):
if... | from decimal import *
getcontext().prec = 14
N, D = list(map(int, input().split()))
def distance(x1, x2, y1, y2):
dx = x2 - x1
dy = y2 - y1
return (dx * dx + dy * dy).sqrt()
X = [0] * N
Y = [0] * N
ans = 0
for i in range(N):
X[i], Y[i] = list(map(Decimal, input().split()))
if distance(0, X[i], ... | false | 4.545455 | [
"-getcontext().prec = 50",
"+getcontext().prec = 14",
"+ans = 0",
"-ans = 0",
"-for i in range(N):"
] | false | 0.038882 | 0.105668 | 0.367961 | [
"s492315713",
"s600709561"
] |
u600402037 | p03464 | python | s829499626 | s895064691 | 119 | 108 | 14,252 | 14,224 | Accepted | Accepted | 9.24 | K = int(eval(input()))
A = list(map(int, input().split()))
min = 2
max = 2
for i in range(K-1, -1, -1):
if max < A[i]:
print((-1))
exit()
min += (-min) % A[i]
max -= max % A[i]
max += A[i] - 1
if max < min:
print((-1))
exit()
print((min, max))
| K = int(eval(input()))
A = list(map(int, input().split()))
min = 2
max = 2
for i in range(K-1, -1, -1):
min += (-min) % A[i]
max -= max % A[i]
max += A[i] - 1
if max < min:
print((-1))
exit()
print((min, max))
| 15 | 12 | 298 | 227 | K = int(eval(input()))
A = list(map(int, input().split()))
min = 2
max = 2
for i in range(K - 1, -1, -1):
if max < A[i]:
print((-1))
exit()
min += (-min) % A[i]
max -= max % A[i]
max += A[i] - 1
if max < min:
print((-1))
exit()
print((min, max))
| K = int(eval(input()))
A = list(map(int, input().split()))
min = 2
max = 2
for i in range(K - 1, -1, -1):
min += (-min) % A[i]
max -= max % A[i]
max += A[i] - 1
if max < min:
print((-1))
exit()
print((min, max))
| false | 20 | [
"- if max < A[i]:",
"- print((-1))",
"- exit()",
"- if max < min:",
"- print((-1))",
"- exit()",
"+if max < min:",
"+ print((-1))",
"+ exit()"
] | false | 0.106579 | 0.086469 | 1.23257 | [
"s829499626",
"s895064691"
] |
u966695411 | p03817 | python | s676996836 | s551474392 | 24 | 21 | 3,188 | 3,064 | Accepted | Accepted | 12.5 | N = int(eval(input()))
if N < 11:
d, m = divmod(N, 6)
print((d + (m>0)))
else:
d, m = divmod(N, 11)
a = (1 if m else 0) if m < 7 else 2
print((d * 2 + a)) | N = int(eval(input()))
d, m = divmod(N, 11)
a = (1 if m else 0) if m < 7 else 2
print((d * 2 + a)) | 9 | 4 | 173 | 93 | N = int(eval(input()))
if N < 11:
d, m = divmod(N, 6)
print((d + (m > 0)))
else:
d, m = divmod(N, 11)
a = (1 if m else 0) if m < 7 else 2
print((d * 2 + a))
| N = int(eval(input()))
d, m = divmod(N, 11)
a = (1 if m else 0) if m < 7 else 2
print((d * 2 + a))
| false | 55.555556 | [
"-if N < 11:",
"- d, m = divmod(N, 6)",
"- print((d + (m > 0)))",
"-else:",
"- d, m = divmod(N, 11)",
"- a = (1 if m else 0) if m < 7 else 2",
"- print((d * 2 + a))",
"+d, m = divmod(N, 11)",
"+a = (1 if m else 0) if m < 7 else 2",
"+print((d * 2 + a))"
] | false | 0.041738 | 0.040286 | 1.036034 | [
"s676996836",
"s551474392"
] |
u580697892 | p02681 | python | s551603047 | s463807794 | 21 | 19 | 9,096 | 9,052 | Accepted | Accepted | 9.52 | #coding: utf-8
S = eval(input())
T = eval(input())
if S == T[:-1]:
print("Yes")
else:
print("No") | s = eval(input())
t = eval(input())
print(("Yes" if s == t[:-1] else "No")) | 7 | 3 | 99 | 63 | # coding: utf-8
S = eval(input())
T = eval(input())
if S == T[:-1]:
print("Yes")
else:
print("No")
| s = eval(input())
t = eval(input())
print(("Yes" if s == t[:-1] else "No"))
| false | 57.142857 | [
"-# coding: utf-8",
"-S = eval(input())",
"-T = eval(input())",
"-if S == T[:-1]:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+s = eval(input())",
"+t = eval(input())",
"+print((\"Yes\" if s == t[:-1] else \"No\"))"
] | false | 0.036739 | 0.035956 | 1.021776 | [
"s551603047",
"s463807794"
] |
u392319141 | p02900 | python | s540307001 | s209756887 | 367 | 239 | 135,800 | 99,040 | Accepted | Accepted | 34.88 | import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')
def primeCount(N):
R = int(N**(0.5)... | A, B = list(map(int, input().split()))
def primeCount(N):
R = int(N**(0.5)) + 1 # 素数の範囲
primes = {} # 素数のリスト
n = N
for num in range(2, R):
primes[num] = 0
while n % num == 0:
n //= num
primes[num] += 1
if n > 1 :
primes[n] = 1
retur... | 37 | 23 | 855 | 546 | import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
INF = float("inf")
def primeCount(N):
R = int(N ** (0.5)) + 1 # ... | A, B = list(map(int, input().split()))
def primeCount(N):
R = int(N ** (0.5)) + 1 # 素数の範囲
primes = {} # 素数のリスト
n = N
for num in range(2, R):
primes[num] = 0
while n % num == 0:
n //= num
primes[num] += 1
if n > 1:
primes[n] = 1
return {key: val... | false | 37.837838 | [
"-import sys",
"-from heapq import heappop, heappush",
"-from operator import itemgetter",
"-from collections import deque, defaultdict, Counter",
"-from bisect import bisect_left, bisect_right",
"-",
"-input = sys.stdin.readline",
"-sys.setrecursionlimit(10**7)",
"-MOD = 10**9 + 7",
"-INF = float... | false | 0.035288 | 0.035535 | 0.993049 | [
"s540307001",
"s209756887"
] |
u620868411 | p03634 | python | s151220546 | s230006320 | 1,418 | 1,004 | 47,040 | 48,196 | Accepted | Accepted | 29.2 | # coding=utf-8
N = int(eval(input()))
tree = [[]for x in range(N)]
depth = [0 for x in range(N)]
for _ in range(N-1):
line = input().split(" ")
a = int(line[0])-1
b = int(line[1])-1
c = int(line[2])
tree[a].append((b, c))
tree[b].append((a, c))
line = input().split(" ")
Q = int(l... | # -*- coding: utf-8 -*-
inf = 10**16
n = int(eval(input()))
edge = [[] for _ in range(n)]
for _ in range(n-1):
a,b,c = list(map(int, input().split()))
a -= 1
b -= 1
edge[a].append((b,c))
edge[b].append((a,c))
q,k = list(map(int, input().split()))
k -= 1
d = [inf for _ in range(n)]
d... | 40 | 33 | 830 | 620 | # coding=utf-8
N = int(eval(input()))
tree = [[] for x in range(N)]
depth = [0 for x in range(N)]
for _ in range(N - 1):
line = input().split(" ")
a = int(line[0]) - 1
b = int(line[1]) - 1
c = int(line[2])
tree[a].append((b, c))
tree[b].append((a, c))
line = input().split(" ")
Q = int(line[0])
K... | # -*- coding: utf-8 -*-
inf = 10**16
n = int(eval(input()))
edge = [[] for _ in range(n)]
for _ in range(n - 1):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
edge[a].append((b, c))
edge[b].append((a, c))
q, k = list(map(int, input().split()))
k -= 1
d = [inf for _ in range(n)]
d[k] = 0
st... | false | 17.5 | [
"-# coding=utf-8",
"-N = int(eval(input()))",
"-tree = [[] for x in range(N)]",
"-depth = [0 for x in range(N)]",
"-for _ in range(N - 1):",
"- line = input().split(\" \")",
"- a = int(line[0]) - 1",
"- b = int(line[1]) - 1",
"- c = int(line[2])",
"- tree[a].append((b, c))",
"- ... | false | 0.045336 | 0.083964 | 0.539942 | [
"s151220546",
"s230006320"
] |
u677523557 | p02992 | python | s621450244 | s177384141 | 491 | 236 | 91,372 | 148,100 | Accepted | Accepted | 51.93 | N, K = list(map(int, input().split()))
mod = 10**9+7
n = 1
A = []
while True:
A.append(N//n)
if N//(n+1) < n+1: break
n += 1
A.append(n)
L = 2*n
dp = [[0]*L for _ in range(K)]
for l in range(n):
dp[0][l] = 1
i = 0
for l in reversed(list(range(n, L))):
dp[0][l] = A[i] - A[i+1]
... | import sys
input = sys.stdin.readline
import math
mod = 10**9+7
N, K = list(map(int, input().split()))
K -= 1
P = set()
inv = {}
for i in range(1, int(math.sqrt(N)+2)):
if i**2 > N: break
P.add(i)
P.add(N//i)
if i not in inv:
inv[i] = N//i
if N//i not in inv:
inv[N... | 32 | 56 | 545 | 956 | N, K = list(map(int, input().split()))
mod = 10**9 + 7
n = 1
A = []
while True:
A.append(N // n)
if N // (n + 1) < n + 1:
break
n += 1
A.append(n)
L = 2 * n
dp = [[0] * L for _ in range(K)]
for l in range(n):
dp[0][l] = 1
i = 0
for l in reversed(list(range(n, L))):
dp[0][l] = A[i] - A[i + 1]... | import sys
input = sys.stdin.readline
import math
mod = 10**9 + 7
N, K = list(map(int, input().split()))
K -= 1
P = set()
inv = {}
for i in range(1, int(math.sqrt(N) + 2)):
if i**2 > N:
break
P.add(i)
P.add(N // i)
if i not in inv:
inv[i] = N // i
if N // i not in inv:
inv[... | false | 42.857143 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"+import math",
"+",
"+mod = 10**9 + 7",
"-mod = 10**9 + 7",
"-n = 1",
"-A = []",
"-while True:",
"- A.append(N // n)",
"- if N // (n + 1) < n + 1:",
"+K -= 1",
"+P = set()",
"+inv = {}",
"+for i in range(1, int(math.sqrt(N) + 2)... | false | 0.251241 | 0.34327 | 0.731907 | [
"s621450244",
"s177384141"
] |
u631277801 | p03503 | python | s482203051 | s658968331 | 254 | 224 | 3,064 | 3,064 | Accepted | Accepted | 11.81 | N = int(eval(input()))
F = []
P = []
for i in range(N):
F.append(list(map(int, input().split())))
for i in range(N):
P.append(list(map(int, input().split())))
TIME = 10
prof_cand = []
for bit in range(1,1<<TIME):
onBiz = []
with_n = []
for t in range(TIME):
if bit & (1<<t):
... | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.rea... | 27 | 40 | 609 | 1,103 | N = int(eval(input()))
F = []
P = []
for i in range(N):
F.append(list(map(int, input().split())))
for i in range(N):
P.append(list(map(int, input().split())))
TIME = 10
prof_cand = []
for bit in range(1, 1 << TIME):
onBiz = []
with_n = []
for t in range(TIME):
if bit & (1 << t):
... | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
... | false | 32.5 | [
"-N = int(eval(input()))",
"-F = []",
"-P = []",
"-for i in range(N):",
"- F.append(list(map(int, input().split())))",
"-for i in range(N):",
"- P.append(list(map(int, input().split())))",
"-TIME = 10",
"-prof_cand = []",
"-for bit in range(1, 1 << TIME):",
"- onBiz = []",
"- with_... | false | 0.095621 | 0.041836 | 2.285581 | [
"s482203051",
"s658968331"
] |
u767664985 | p02996 | python | s416765949 | s816851916 | 1,241 | 1,043 | 93,912 | 55,264 | Accepted | Accepted | 15.95 | N = int(eval(input()))
X = [list(map(int, input().split())) for _ in range(N)]
X = sorted(X, key = lambda x: x[1])
# a[i]はA[i]まで終わらせるためにかかる累積時間
a = [0] * N
a[0] = X[0][0]
for i in range(1, N):
a[i] = a[i - 1] + X[i][0]
for j in range(N):
if a[j] > X[j][1]:
print("No")
exit()
print("Yes")
| # 締切の早いものから順番に見ていくのが最適戦略
N = int(eval(input()))
X = [list(map(int, input().split())) for _ in range(N)]
X = sorted(X, key=lambda x: x[1]) # B (締切の早い順にソート)
res = 0
for i in range(N):
res += X[i][0]
if res > X[i][1]:
print("No")
exit()
print("Yes")
| 15 | 12 | 305 | 278 | N = int(eval(input()))
X = [list(map(int, input().split())) for _ in range(N)]
X = sorted(X, key=lambda x: x[1])
# a[i]はA[i]まで終わらせるためにかかる累積時間
a = [0] * N
a[0] = X[0][0]
for i in range(1, N):
a[i] = a[i - 1] + X[i][0]
for j in range(N):
if a[j] > X[j][1]:
print("No")
exit()
print("Yes")
| # 締切の早いものから順番に見ていくのが最適戦略
N = int(eval(input()))
X = [list(map(int, input().split())) for _ in range(N)]
X = sorted(X, key=lambda x: x[1]) # B (締切の早い順にソート)
res = 0
for i in range(N):
res += X[i][0]
if res > X[i][1]:
print("No")
exit()
print("Yes")
| false | 20 | [
"+# 締切の早いものから順番に見ていくのが最適戦略",
"-X = sorted(X, key=lambda x: x[1])",
"-# a[i]はA[i]まで終わらせるためにかかる累積時間",
"-a = [0] * N",
"-a[0] = X[0][0]",
"-for i in range(1, N):",
"- a[i] = a[i - 1] + X[i][0]",
"-for j in range(N):",
"- if a[j] > X[j][1]:",
"+X = sorted(X, key=lambda x: x[1]) # B (締切の早い順にソート)... | false | 0.036259 | 0.035402 | 1.024201 | [
"s416765949",
"s816851916"
] |
u529787332 | p03448 | python | s083926388 | s349758339 | 143 | 121 | 21,992 | 21,992 | Accepted | Accepted | 15.38 | cnt500 = int(eval(input()))
cnt100 = int(eval(input()))
cnt50 = int(eval(input()))
X = int(eval(input()))
all_set = set([])
for i,a in enumerate(range(cnt500+1)):
tmp500 = i*500
if tmp500 > X:
break
all_set.add((tmp500, 0, 0))
for i,b in enumerate(range(cnt100+1)):
tmp100 ... | cnt500 = int(eval(input()))
cnt100 = int(eval(input()))
cnt50 = int(eval(input()))
X = int(eval(input()))
all_set = set([])
for a in range(cnt500+1):
tmp500 = a*500
if tmp500 > X:
break
all_set.add((tmp500, 0, 0))
for b in range(cnt100+1):
tmp100 = b*100
if tmp100... | 27 | 27 | 637 | 598 | cnt500 = int(eval(input()))
cnt100 = int(eval(input()))
cnt50 = int(eval(input()))
X = int(eval(input()))
all_set = set([])
for i, a in enumerate(range(cnt500 + 1)):
tmp500 = i * 500
if tmp500 > X:
break
all_set.add((tmp500, 0, 0))
for i, b in enumerate(range(cnt100 + 1)):
tmp100 = i * 1... | cnt500 = int(eval(input()))
cnt100 = int(eval(input()))
cnt50 = int(eval(input()))
X = int(eval(input()))
all_set = set([])
for a in range(cnt500 + 1):
tmp500 = a * 500
if tmp500 > X:
break
all_set.add((tmp500, 0, 0))
for b in range(cnt100 + 1):
tmp100 = b * 100
if tmp100 > X:
... | false | 0 | [
"-for i, a in enumerate(range(cnt500 + 1)):",
"- tmp500 = i * 500",
"+for a in range(cnt500 + 1):",
"+ tmp500 = a * 500",
"- for i, b in enumerate(range(cnt100 + 1)):",
"- tmp100 = i * 100",
"+ for b in range(cnt100 + 1):",
"+ tmp100 = b * 100",
"- for i, c in enumer... | false | 0.058746 | 0.137082 | 0.428546 | [
"s083926388",
"s349758339"
] |
u867848444 | p03559 | python | s779515170 | s912886810 | 997 | 472 | 24,052 | 106,340 | Accepted | Accepted | 52.66 | n=int(eval(input()))
a=sorted(list(map(int,input().split())))
b=list(map(int,input().split()))
c=sorted(list(map(int,input().split())))
def bin_a(list,bi):
ok=-1
ng=n
while abs(ok-ng)>1:
mid=(ok+ng)//2
if bi>list[mid]:
ok=mid
else:
ng=mid
re... | from bisect import *
n = int(eval(input()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a = sorted(a)
c = sorted(c)
rec = 0
for i in range(n):
temp = b[i]
l = bisect_left(a, temp)
r = bisect_right(c, temp)
rec += l * (n - r)
p... | 31 | 16 | 632 | 323 | n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))
def bin_a(list, bi):
ok = -1
ng = n
while abs(ok - ng) > 1:
mid = (ok + ng) // 2
if bi > list[mid]:
ok = mid
else:
... | from bisect import *
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a)
c = sorted(c)
rec = 0
for i in range(n):
temp = b[i]
l = bisect_left(a, temp)
r = bisect_right(c, temp)
rec += l * (n - r)
print(rec)
| false | 48.387097 | [
"+from bisect import *",
"+",
"-a = sorted(list(map(int, input().split())))",
"+a = list(map(int, input().split()))",
"-c = sorted(list(map(int, input().split())))",
"-",
"-",
"-def bin_a(list, bi):",
"- ok = -1",
"- ng = n",
"- while abs(ok - ng) > 1:",
"- mid = (ok + ng) // 2... | false | 0.053633 | 0.06758 | 0.793618 | [
"s779515170",
"s912886810"
] |
u631277801 | p03688 | python | s576831075 | s132141107 | 72 | 46 | 13,304 | 13,964 | Accepted | Accepted | 36.11 | import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(n... | n = int(eval(input()))
a = list(map(int, input().split()))
unum = min(a)
vnum = max(a)
u = a.count(unum)
v = a.count(vnum)
exist = False
if vnum-unum == 1:
if u+1 <= vnum <= u+v//2:
exist = True
elif vnum == unum:
if vnum == n-1 or vnum <= n//2:
exist = True
print(("Yes" if ... | 36 | 20 | 890 | 330 | import sys
stdin = sys.stdin
def li():
return map(int, stdin.readline().split())
def li_():
return map(lambda x: int(x) - 1, stdin.readline().split())
def lf():
return map(float, stdin.readline().split())
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()... | n = int(eval(input()))
a = list(map(int, input().split()))
unum = min(a)
vnum = max(a)
u = a.count(unum)
v = a.count(vnum)
exist = False
if vnum - unum == 1:
if u + 1 <= vnum <= u + v // 2:
exist = True
elif vnum == unum:
if vnum == n - 1 or vnum <= n // 2:
exist = True
print(("Yes" if exist els... | false | 44.444444 | [
"-import sys",
"-",
"-stdin = sys.stdin",
"-",
"-",
"-def li():",
"- return map(int, stdin.readline().split())",
"-",
"-",
"-def li_():",
"- return map(lambda x: int(x) - 1, stdin.readline().split())",
"-",
"-",
"-def lf():",
"- return map(float, stdin.readline().split())",
"-... | false | 0.09026 | 0.105387 | 0.856457 | [
"s576831075",
"s132141107"
] |
u270144704 | p02837 | python | s741274041 | s781046790 | 302 | 266 | 43,116 | 43,256 | Accepted | Accepted | 11.92 | n = int(eval(input()))
xy = [[] for _ in range(n)]
ans = -float("inf")
for i in range(n):
a = int(eval(input()))
for _ in range(a):
xy[i].append(tuple(map(int, input().split())))
for i in range(1 << n):
true_or_false = [0] * n
flag = False
for j in range(n):
if (i>>j)&1:
true_or_false[n-1-j]... | n = int(eval(input()))
xy = [[] for _ in range(n)]
ans = -float("inf")
for i in range(n):
a = int(eval(input()))
for _ in range(a):
x, y = list(map(int, input().split()))
xy[i].append(tuple([x-1, y]))
for i in range(2**n):
flag = False
cnt = 0
for j in range(n):
if (i >> j) & 1:
cnt += 1
... | 23 | 26 | 529 | 502 | n = int(eval(input()))
xy = [[] for _ in range(n)]
ans = -float("inf")
for i in range(n):
a = int(eval(input()))
for _ in range(a):
xy[i].append(tuple(map(int, input().split())))
for i in range(1 << n):
true_or_false = [0] * n
flag = False
for j in range(n):
if (i >> j) & 1:
... | n = int(eval(input()))
xy = [[] for _ in range(n)]
ans = -float("inf")
for i in range(n):
a = int(eval(input()))
for _ in range(a):
x, y = list(map(int, input().split()))
xy[i].append(tuple([x - 1, y]))
for i in range(2**n):
flag = False
cnt = 0
for j in range(n):
if (i >> j)... | false | 11.538462 | [
"- xy[i].append(tuple(map(int, input().split())))",
"-for i in range(1 << n):",
"- true_or_false = [0] * n",
"+ x, y = list(map(int, input().split()))",
"+ xy[i].append(tuple([x - 1, y]))",
"+for i in range(2**n):",
"+ cnt = 0",
"- true_or_false[n - 1 - j] = 1",
... | false | 0.080962 | 0.135625 | 0.596958 | [
"s741274041",
"s781046790"
] |
u558242240 | p03164 | python | s835165701 | s773975872 | 322 | 290 | 43,332 | 41,452 | Accepted | Accepted | 9.94 | n, w = list(map(int, input().split()))
wv = [tuple(map(int, input().split())) for _ in range(n)]
INF = 10**9 + 100
MAX_V = 10**5 + 100
dp = [INF] * (MAX_V + 1)
dp[0] = 0
for wi, vi in wv:
for sum_v in reversed(list(range(vi, MAX_V+1))):
dp[sum_v] = min(dp[sum_v - vi] + wi, dp[sum_v])
#print(dp)
... | n, w = list(map(int, input().split()))
wv = [tuple(map(int, input().split())) for _ in range(n)]
INF = 10**9 + 100
MAX_V = 10**5 + 100
dp = [INF] * (MAX_V + 1)
dp[0] = 0
for wi, vi in wv:
for sum_v in reversed(list(range(vi, MAX_V+1))):
dp[sum_v] = min(dp[sum_v - vi] + wi, dp[sum_v])
#print(dp)
... | 17 | 17 | 415 | 419 | n, w = list(map(int, input().split()))
wv = [tuple(map(int, input().split())) for _ in range(n)]
INF = 10**9 + 100
MAX_V = 10**5 + 100
dp = [INF] * (MAX_V + 1)
dp[0] = 0
for wi, vi in wv:
for sum_v in reversed(list(range(vi, MAX_V + 1))):
dp[sum_v] = min(dp[sum_v - vi] + wi, dp[sum_v])
# print(dp)
ans = 0
f... | n, w = list(map(int, input().split()))
wv = [tuple(map(int, input().split())) for _ in range(n)]
INF = 10**9 + 100
MAX_V = 10**5 + 100
dp = [INF] * (MAX_V + 1)
dp[0] = 0
for wi, vi in wv:
for sum_v in reversed(list(range(vi, MAX_V + 1))):
dp[sum_v] = min(dp[sum_v - vi] + wi, dp[sum_v])
# print(dp)
ans = 0
f... | false | 0 | [
"-for i in range(MAX_V, -1, -1):",
"+for i in reversed(list(range(MAX_V + 1))):"
] | false | 0.219043 | 0.258083 | 0.84873 | [
"s835165701",
"s773975872"
] |
u186838327 | p02744 | python | s025663026 | s201596120 | 347 | 135 | 61,020 | 83,264 | Accepted | Accepted | 61.1 | n = int(eval(input()))
L = [0]*n
for i in range(n):
L[i] = chr(i+ord('a'))
#print(L)_
ans = []
def dfs(A):
if len(A) == n:
ans.append(''.join(A))
return
for v in L[0:len(set(A))+1]:
A.append(v)
dfs(A)
A.pop()
dfs([])
ans.sort()
for i in range(len... | n = int(eval(input()))
ans = []
def dfs(A):
if len(A) == n:
ans.append(''.join(A))
return
for i in range(len(set(A))+1):
v = chr(i+ord('a'))
A.append(v)
dfs(A)
A.pop()
dfs([])
ans.sort()
for i in range(len(ans)):
print((ans[i]))
| 21 | 17 | 341 | 299 | n = int(eval(input()))
L = [0] * n
for i in range(n):
L[i] = chr(i + ord("a"))
# print(L)_
ans = []
def dfs(A):
if len(A) == n:
ans.append("".join(A))
return
for v in L[0 : len(set(A)) + 1]:
A.append(v)
dfs(A)
A.pop()
dfs([])
ans.sort()
for i in range(len(ans)):
... | n = int(eval(input()))
ans = []
def dfs(A):
if len(A) == n:
ans.append("".join(A))
return
for i in range(len(set(A)) + 1):
v = chr(i + ord("a"))
A.append(v)
dfs(A)
A.pop()
dfs([])
ans.sort()
for i in range(len(ans)):
print((ans[i]))
| false | 19.047619 | [
"-L = [0] * n",
"-for i in range(n):",
"- L[i] = chr(i + ord(\"a\"))",
"-# print(L)_",
"- for v in L[0 : len(set(A)) + 1]:",
"+ for i in range(len(set(A)) + 1):",
"+ v = chr(i + ord(\"a\"))"
] | false | 0.043095 | 0.042447 | 1.015275 | [
"s025663026",
"s201596120"
] |
u779805689 | p03151 | python | s773941454 | s909955898 | 693 | 229 | 97,808 | 97,576 | Accepted | Accepted | 66.96 | import sys
N=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
if sum(A)<=sum(B):
print((-1))
sys.exit()
Y=0
K=0
Q=[]
for i in range(N):
k=A[i]-B[i]
if k>0:
Q.append(k)
elif k<0:
K+=1
Y+=-k
Q.sort(reverse=True)
... | import sys
N=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
if sum(A)<=sum(B):
print((-1))
sys.exit()
Y=0
K=0
Q=[]
for i in range(N):
k=A[i]-B[i]
if k>0:
Q.append(k)
elif k<0:
K+=1
Y+=-k
Q.sort()
while Y>0:
... | 30 | 30 | 375 | 362 | import sys
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(A) <= sum(B):
print((-1))
sys.exit()
Y = 0
K = 0
Q = []
for i in range(N):
k = A[i] - B[i]
if k > 0:
Q.append(k)
elif k < 0:
K += 1
Y += -k
Q.sort(reverse=True)
w... | import sys
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(A) <= sum(B):
print((-1))
sys.exit()
Y = 0
K = 0
Q = []
for i in range(N):
k = A[i] - B[i]
if k > 0:
Q.append(k)
elif k < 0:
K += 1
Y += -k
Q.sort()
while Y > 0:
... | false | 0 | [
"-Q.sort(reverse=True)",
"+Q.sort()",
"- q = Q.pop(0)",
"+ q = Q.pop()"
] | false | 0.043033 | 0.041642 | 1.033389 | [
"s773941454",
"s909955898"
] |
u638033979 | p02702 | python | s931547212 | s002085092 | 330 | 119 | 9,324 | 10,920 | Accepted | Accepted | 63.94 | S=eval(input())
N=len(S)
M=2019
remainder=[0]*M
val=0
for i in range(N):
val=(int(S[N-1-i])*pow(10,i,M)+val)%M
remainder[val]+=1
ans=remainder[0]
for i in range(2019):
ans+=remainder[i]*(remainder[i]-1)//2
print(ans) | from collections import deque
s = deque(eval(input()))
n = len(s)
temp = [0]*2019
t = 1
num = 0
for i in range(n):
num += int(s.pop())*t
temp[num % 2019] += 1
t = t*10 % 2019
ans = temp[0]
for t in temp:
if t > 1:
ans += t*(t-1)/2
print((int(ans))) | 14 | 18 | 231 | 286 | S = eval(input())
N = len(S)
M = 2019
remainder = [0] * M
val = 0
for i in range(N):
val = (int(S[N - 1 - i]) * pow(10, i, M) + val) % M
remainder[val] += 1
ans = remainder[0]
for i in range(2019):
ans += remainder[i] * (remainder[i] - 1) // 2
print(ans)
| from collections import deque
s = deque(eval(input()))
n = len(s)
temp = [0] * 2019
t = 1
num = 0
for i in range(n):
num += int(s.pop()) * t
temp[num % 2019] += 1
t = t * 10 % 2019
ans = temp[0]
for t in temp:
if t > 1:
ans += t * (t - 1) / 2
print((int(ans)))
| false | 22.222222 | [
"-S = eval(input())",
"-N = len(S)",
"-M = 2019",
"-remainder = [0] * M",
"-val = 0",
"-for i in range(N):",
"- val = (int(S[N - 1 - i]) * pow(10, i, M) + val) % M",
"- remainder[val] += 1",
"-ans = remainder[0]",
"-for i in range(2019):",
"- ans += remainder[i] * (remainder[i] - 1) // ... | false | 0.036157 | 0.0354 | 1.021381 | [
"s931547212",
"s002085092"
] |
u179169725 | p02788 | python | s347201764 | s672519725 | 1,120 | 977 | 48,636 | 48,656 | Accepted | Accepted | 12.77 | # https://atcoder.jp/contests/abc153/tasks/abc153_f
# 座標圧縮、貪欲法、imos法
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
def read_tuple(H):
'''
H is number of rows
'''
ret = []
for _ in range(H):
ret.append(tuple(map(int, re... | # https://atcoder.jp/contests/abc153/tasks/abc153_f
# 座標圧縮、貪欲法、imos法
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
def read_tuple(H):
'''
H is number of rows
'''
ret = []
for _ in range(H):
ret.append(tuple(map(int, re... | 58 | 62 | 1,339 | 1,454 | # https://atcoder.jp/contests/abc153/tasks/abc153_f
# 座標圧縮、貪欲法、imos法
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
def read_tuple(H):
"""
H is number of rows
"""
ret = []
for _ in range(H):
ret.append(tuple(map(int, read().split())))
... | # https://atcoder.jp/contests/abc153/tasks/abc153_f
# 座標圧縮、貪欲法、imos法
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
def read_tuple(H):
"""
H is number of rows
"""
ret = []
for _ in range(H):
ret.append(tuple(map(int, read().split())))
... | false | 6.451613 | [
"-N, D, A = read_ints()",
"-XH = read_tuple(N)",
"-XH.sort() # 座標でソート",
"-n_atk = [] # 何回攻撃するのが必要か",
"-X = [] # 座標アクセス用配列",
"-for x, h in XH:",
"- n_atk.append((h - 1) // A + 1)",
"- X.append(x)",
"-damege = [0] * (N + 10) # ダメージ管理用、配列外アクセスがめんどくさいので長めに取る",
"-ans = 0",
"-# j = 0 # 次のxが... | false | 0.036996 | 0.045374 | 0.815344 | [
"s347201764",
"s672519725"
] |
u987164499 | p03555 | python | s827099892 | s560161145 | 158 | 17 | 12,052 | 2,940 | Accepted | Accepted | 89.24 | from sys import stdin
import math
import bisect
import heapq
import numpy as np
from math import factorial
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
if s[::-1] == t:
print("YES")
else:
print("NO") | from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)
s = eval(input())
t = input()[::-1]
if s == t:
print("YES")
else:
print("NO") | 14 | 11 | 237 | 174 | from sys import stdin
import math
import bisect
import heapq
import numpy as np
from math import factorial
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
if s[::-1] == t:
print("YES")
else:
print("NO")
| from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10**7)
s = eval(input())
t = input()[::-1]
if s == t:
print("YES")
else:
print("NO")
| false | 21.428571 | [
"-import math",
"-import bisect",
"-import heapq",
"-import numpy as np",
"-from math import factorial",
"+from sys import setrecursionlimit",
"-s = stdin.readline().rstrip()",
"-t = stdin.readline().rstrip()",
"-if s[::-1] == t:",
"+setrecursionlimit(10**7)",
"+s = eval(input())",
"+t = input... | false | 0.12351 | 0.044526 | 2.77385 | [
"s827099892",
"s560161145"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.