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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u186838327 | p02947 | python | s993774951 | s486839038 | 1,040 | 583 | 124,760 | 72,792 | Accepted | Accepted | 43.94 | n = int(eval(input()))
D = {}
ans = 0
for i in range(n):
s = str(eval(input()))
d = [0]*26
for j in range(len(s)):
c = ord(s[j])-ord('a')
d[c] += 1
d = tuple(d)
if d in D:
ans += D[d]
D[d] += 1
else:
D[d] = 1
print(ans)
| n = int(eval(input()))
S = [str(eval(input())) for _ in range(n)]
d = {}
ans = 0
for i in range(n):
s = S[i]
s = list(s)
s.sort()
s = ''.join(s)
if s in d:
ans += d[s]
if s in d:
d[s] += 1
else:
d[s] = 1
print(ans)
| 16 | 17 | 287 | 272 | n = int(eval(input()))
D = {}
ans = 0
for i in range(n):
s = str(eval(input()))
d = [0] * 26
for j in range(len(s)):
c = ord(s[j]) - ord("a")
d[c] += 1
d = tuple(d)
if d in D:
ans += D[d]
D[d] += 1
else:
D[d] = 1
print(ans)
| n = int(eval(input()))
S = [str(eval(input())) for _ in range(n)]
d = {}
ans = 0
for i in range(n):
s = S[i]
s = list(s)
s.sort()
s = "".join(s)
if s in d:
ans += d[s]
if s in d:
d[s] += 1
else:
d[s] = 1
print(ans)
| false | 5.882353 | [
"-D = {}",
"+S = [str(eval(input())) for _ in range(n)]",
"+d = {}",
"- s = str(eval(input()))",
"- d = [0] * 26",
"- for j in range(len(s)):",
"- c = ord(s[j]) - ord(\"a\")",
"- d[c] += 1",
"- d = tuple(d)",
"- if d in D:",
"- ans += D[d]",
"- D[d] +... | false | 0.043177 | 0.106736 | 0.404525 | [
"s993774951",
"s486839038"
] |
u025616818 | p03030 | python | s867692295 | s039722667 | 32 | 26 | 9,056 | 8,996 | Accepted | Accepted | 18.75 | n=int(eval(input()))
res = []
for i in range(n):
s,p=list(map(str, input().split()))
res += [(s,int(p))]
res1=res
res = sorted(res, key=lambda x:(x[0],-x[1]))
for i in range(n):
print((res1.index(res[i])+1)) | n=int(eval(input()))
res=[]
for i in range(n):
s,p=list(map(str,input().split()))
res.append([s,int(p)])
res1=res
res=sorted(res,key=lambda x:(x[0], -x[1]))
for i in range(n):
print((res1.index(res[i])+1)) | 9 | 9 | 213 | 208 | n = int(eval(input()))
res = []
for i in range(n):
s, p = list(map(str, input().split()))
res += [(s, int(p))]
res1 = res
res = sorted(res, key=lambda x: (x[0], -x[1]))
for i in range(n):
print((res1.index(res[i]) + 1))
| n = int(eval(input()))
res = []
for i in range(n):
s, p = list(map(str, input().split()))
res.append([s, int(p)])
res1 = res
res = sorted(res, key=lambda x: (x[0], -x[1]))
for i in range(n):
print((res1.index(res[i]) + 1))
| false | 0 | [
"- res += [(s, int(p))]",
"+ res.append([s, int(p)])"
] | false | 0.036537 | 0.034609 | 1.055701 | [
"s867692295",
"s039722667"
] |
u545368057 | p02889 | python | s910858362 | s619254167 | 1,764 | 1,418 | 61,656 | 107,480 | Accepted | Accepted | 19.61 | N,M,L = list(map(int, input().split()))
INF = 10**18
# 初期化
d = [[INF]*N for i in range(N)]
for i in range(N):
d[i][i] = 0
for i in range(M):
a,b,c = list(map(int, input().split()))
a -= 1
b -= 1
# 多重辺の場合はMIN
d[a][b] = c
d[b][a] = c
# 最適化(わーしゃゆふよいど)
for k in range(N):
for i... | N,M,L = list(map(int, input().split()))
Edges = [list(map(int, input().split())) for i in range(M)]
Q = int(eval(input()))
Queries = [list(map(int, input().split())) for i in range(Q)]
INF = 10**18
# 初期化
d = [[INF]*N for i in range(N)]
for i in range(N):
d[i][i] = 0
for a,b,c in Edges:
a -= 1
b... | 48 | 49 | 1,051 | 1,090 | N, M, L = list(map(int, input().split()))
INF = 10**18
# 初期化
d = [[INF] * N for i in range(N)]
for i in range(N):
d[i][i] = 0
for i in range(M):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
# 多重辺の場合はMIN
d[a][b] = c
d[b][a] = c
# 最適化(わーしゃゆふよいど)
for k in range(N):
for i in range... | N, M, L = list(map(int, input().split()))
Edges = [list(map(int, input().split())) for i in range(M)]
Q = int(eval(input()))
Queries = [list(map(int, input().split())) for i in range(Q)]
INF = 10**18
# 初期化
d = [[INF] * N for i in range(N)]
for i in range(N):
d[i][i] = 0
for a, b, c in Edges:
a -= 1
b -= 1
... | false | 2.040816 | [
"+Edges = [list(map(int, input().split())) for i in range(M)]",
"+Q = int(eval(input()))",
"+Queries = [list(map(int, input().split())) for i in range(Q)]",
"-for i in range(M):",
"- a, b, c = list(map(int, input().split()))",
"+for a, b, c in Edges:",
"-Q = int(eval(input()))",
"-for i in range(Q)... | false | 0.036885 | 0.040604 | 0.908412 | [
"s910858362",
"s619254167"
] |
u409306788 | p02700 | python | s682339229 | s276796735 | 25 | 21 | 9,200 | 9,184 | Accepted | Accepted | 16 | import sys
input = sys.stdin.readline
# B - Battle
def takahashi_win():
A, B, C, D = list(map(int, input().split()))
i = 0
while True:
if i % 2 == 0:
if C-B <= 0:
return True
else:
C -= B
else:
if A-D <= 0:
return False
else:
A -= D
i += 1
if takahashi_... | import sys
input = sys.stdin.readline
# B - Battle
def win_takahashi(A, B, C, D):
for i in range(200):
if i % 2 == 0:
if B >= C:
return True
else:
C -= B
else:
if D >= A:
return False
else:
A -= D
A, B, C, D = list(map(int, input().split()))
if win_takahashi... | 27 | 25 | 356 | 364 | import sys
input = sys.stdin.readline
# B - Battle
def takahashi_win():
A, B, C, D = list(map(int, input().split()))
i = 0
while True:
if i % 2 == 0:
if C - B <= 0:
return True
else:
C -= B
else:
if A - D <= 0:
... | import sys
input = sys.stdin.readline
# B - Battle
def win_takahashi(A, B, C, D):
for i in range(200):
if i % 2 == 0:
if B >= C:
return True
else:
C -= B
else:
if D >= A:
return False
else:
... | false | 7.407407 | [
"-def takahashi_win():",
"- A, B, C, D = list(map(int, input().split()))",
"- i = 0",
"- while True:",
"+def win_takahashi(A, B, C, D):",
"+ for i in range(200):",
"- if C - B <= 0:",
"+ if B >= C:",
"- if A - D <= 0:",
"+ if D >= A:",
"- ... | false | 0.069952 | 0.035657 | 1.961787 | [
"s682339229",
"s276796735"
] |
u320511454 | p04030 | python | s324225493 | s748810701 | 20 | 18 | 3,316 | 2,940 | Accepted | Accepted | 10 | from collections import deque
S=eval(input())
d=deque()
for s in S:
if s == 'B':
if len(d) != 0:
d.pop()
else:
d.append(s)
print((''.join(d))) | S=eval(input())
d=[]
for s in S:
if s == 'B':
if d:
d.pop()
else:
d.append(s)
print((''.join(d))) | 11 | 9 | 163 | 115 | from collections import deque
S = eval(input())
d = deque()
for s in S:
if s == "B":
if len(d) != 0:
d.pop()
else:
d.append(s)
print(("".join(d)))
| S = eval(input())
d = []
for s in S:
if s == "B":
if d:
d.pop()
else:
d.append(s)
print(("".join(d)))
| false | 18.181818 | [
"-from collections import deque",
"-",
"-d = deque()",
"+d = []",
"- if len(d) != 0:",
"+ if d:"
] | false | 0.040088 | 0.039847 | 1.006046 | [
"s324225493",
"s748810701"
] |
u332906195 | p03107 | python | s407154187 | s593247886 | 32 | 18 | 3,188 | 3,188 | Accepted | Accepted | 43.75 | # -*- coding: utf-8 -*-
S = eval(input())
l0, l1 = 0, 0
for s in S:
if s == '0':
l0 += 1
elif s == '1':
l1 += 1
print((min(l0, l1) * 2))
| # -*- coding: utf-8 -*-
S = eval(input())
print((min(S.count('1'), S.count('0')) * 2))
| 12 | 4 | 167 | 83 | # -*- coding: utf-8 -*-
S = eval(input())
l0, l1 = 0, 0
for s in S:
if s == "0":
l0 += 1
elif s == "1":
l1 += 1
print((min(l0, l1) * 2))
| # -*- coding: utf-8 -*-
S = eval(input())
print((min(S.count("1"), S.count("0")) * 2))
| false | 66.666667 | [
"-l0, l1 = 0, 0",
"-for s in S:",
"- if s == \"0\":",
"- l0 += 1",
"- elif s == \"1\":",
"- l1 += 1",
"-print((min(l0, l1) * 2))",
"+print((min(S.count(\"1\"), S.count(\"0\")) * 2))"
] | false | 0.03578 | 0.034974 | 1.023038 | [
"s407154187",
"s593247886"
] |
u945181840 | p02845 | python | s468441220 | s831230911 | 285 | 148 | 20,384 | 13,956 | Accepted | Accepted | 48.07 | import sys
read = sys.stdin.read
N, *A = list(map(int, read().split()))
mod = 10 ** 9 + 7
hats = [[0] * 3 for _ in range(N + 1)]
answer = 1
for i in range(N):
answer *= hats[i].count(A[i])
answer %= mod
flag = True
for j in range(3):
if hats[i][j] == A[i] and flag:
... | import sys
read = sys.stdin.read
N, *A = list(map(int, read().split()))
mod = 10 ** 9 + 7
hats = [0] * 3
answer = 1
for i in range(N):
answer *= hats.count(A[i])
answer %= mod
for j in range(3):
if hats[j] == A[i]:
hats[j] += 1
break
print(answer) | 21 | 18 | 438 | 306 | import sys
read = sys.stdin.read
N, *A = list(map(int, read().split()))
mod = 10**9 + 7
hats = [[0] * 3 for _ in range(N + 1)]
answer = 1
for i in range(N):
answer *= hats[i].count(A[i])
answer %= mod
flag = True
for j in range(3):
if hats[i][j] == A[i] and flag:
hats[i + 1][j] = A[... | import sys
read = sys.stdin.read
N, *A = list(map(int, read().split()))
mod = 10**9 + 7
hats = [0] * 3
answer = 1
for i in range(N):
answer *= hats.count(A[i])
answer %= mod
for j in range(3):
if hats[j] == A[i]:
hats[j] += 1
break
print(answer)
| false | 14.285714 | [
"-hats = [[0] * 3 for _ in range(N + 1)]",
"+hats = [0] * 3",
"- answer *= hats[i].count(A[i])",
"+ answer *= hats.count(A[i])",
"- flag = True",
"- if hats[i][j] == A[i] and flag:",
"- hats[i + 1][j] = A[i] + 1",
"- flag = False",
"- else:",
"- ... | false | 0.047078 | 0.047015 | 1.001337 | [
"s468441220",
"s831230911"
] |
u766684188 | p02949 | python | s877153443 | s505580366 | 950 | 835 | 45,880 | 43,484 | Accepted | Accepted | 12.11 | import sys
input=sys.stdin.readline
def BellmanFord(Edges,num_v,source):
inf=float('inf')
dist=[inf for _ in range(num_v)]
dist[source]=0
for i in range(num_v):
for edge in Edges:
if edge[0]!=inf and dist[edge[1]]>dist[edge[0]]+edge[2]:
dist[edge[1]]=dist[e... | import sys
input=sys.stdin.readline
def BellmanFord(Edges,num_v,start,goal):
inf=float('inf')
Dist=[inf]*num_v
Dist[start]=0
for _ in range(num_v):
for fr,to,cost in Edges:
if Dist[fr]!=inf and Dist[to]>Dist[fr]+cost:
Dist[to]=Dist[fr]+cost
d=Dist[goal... | 29 | 28 | 974 | 754 | import sys
input = sys.stdin.readline
def BellmanFord(Edges, num_v, source):
inf = float("inf")
dist = [inf for _ in range(num_v)]
dist[source] = 0
for i in range(num_v):
for edge in Edges:
if edge[0] != inf and dist[edge[1]] > dist[edge[0]] + edge[2]:
dist[edge[1]... | import sys
input = sys.stdin.readline
def BellmanFord(Edges, num_v, start, goal):
inf = float("inf")
Dist = [inf] * num_v
Dist[start] = 0
for _ in range(num_v):
for fr, to, cost in Edges:
if Dist[fr] != inf and Dist[to] > Dist[fr] + cost:
Dist[to] = Dist[fr] + cost... | false | 3.448276 | [
"-def BellmanFord(Edges, num_v, source):",
"+def BellmanFord(Edges, num_v, start, goal):",
"- dist = [inf for _ in range(num_v)]",
"- dist[source] = 0",
"- for i in range(num_v):",
"- for edge in Edges:",
"- if edge[0] != inf and dist[edge[1]] > dist[edge[0]] + edge[2]:",
"-... | false | 0.037099 | 0.037727 | 0.983351 | [
"s877153443",
"s505580366"
] |
u875291233 | p02616 | python | s796297352 | s123181011 | 216 | 157 | 31,108 | 31,240 | Accepted | Accepted | 27.31 | # coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n,k,*a = list(map(int,read().split()))
pos = []
neg = []
#both = []
zero = 0
for i in a:
#if i!=0: both.append(i)
if i==0: zero += 1
elif i > 0: pos.append(i)
else: neg.append(-i)
... | # coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n,k,*a = list(map(int,read().split()))
pos = []
neg = []
MOD = 10**9+7
for i in a:
if i >= 0: pos.append(i)
else: neg.append(i)
if n==k:
ans = 1
for i in a:
ans *= i
a... | 119 | 62 | 2,459 | 1,126 | # coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n, k, *a = list(map(int, read().split()))
pos = []
neg = []
# both = []
zero = 0
for i in a:
# if i!=0: both.append(i)
if i == 0:
zero += 1
elif i > 0:
pos.append(i)
else:
neg.append... | # coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n, k, *a = list(map(int, read().split()))
pos = []
neg = []
MOD = 10**9 + 7
for i in a:
if i >= 0:
pos.append(i)
else:
neg.append(i)
if n == k:
ans = 1
for i in a:
ans *= i
a... | false | 47.89916 | [
"-# both = []",
"-zero = 0",
"+MOD = 10**9 + 7",
"- # if i!=0: both.append(i)",
"- if i == 0:",
"- zero += 1",
"- elif i > 0:",
"+ if i >= 0:",
"- neg.append(-i)",
"-# print(pos,neg,zero)",
"-MOD = 10**9 + 7",
"-if n - zero < k: # ゼロが多すぎる",
"- print((0))",
"-e... | false | 0.03792 | 0.09706 | 0.390685 | [
"s796297352",
"s123181011"
] |
u693378622 | p02837 | python | s390887073 | s855041348 | 853 | 243 | 3,064 | 3,064 | Accepted | Accepted | 71.51 | n = int(eval(input()))
a = []
x = [[] for _ in range(n)]
for i in range(n):
k = int(eval(input()))
a.append(k)
for j in range(k):
x[i].append(list(map(int,input().split())))
# print(x)
ans = 0
for i in range(1<<n):
cnt = bin(i).count("1")
if ans > cnt:
... | n = int(eval(input()))
a = []
x = [[] for _ in range(n)]
for i in range(n):
k = int(eval(input()))
a.append(k)
for j in range(k):
x[i].append(list(map(int,input().split())))
# print(x)
ans = 0
for i in range(1<<n):
cnt = bin(i).count("1")
if ans > cnt:
... | 44 | 42 | 965 | 901 | n = int(eval(input()))
a = []
x = [[] for _ in range(n)]
for i in range(n):
k = int(eval(input()))
a.append(k)
for j in range(k):
x[i].append(list(map(int, input().split())))
# print(x)
ans = 0
for i in range(1 << n):
cnt = bin(i).count("1")
if ans > cnt:
continue
flag = True
... | n = int(eval(input()))
a = []
x = [[] for _ in range(n)]
for i in range(n):
k = int(eval(input()))
a.append(k)
for j in range(k):
x[i].append(list(map(int, input().split())))
# print(x)
ans = 0
for i in range(1 << n):
cnt = bin(i).count("1")
if ans > cnt:
continue
flag = True
... | false | 4.545455 | [
"- # break",
"- # if flag == False:",
"- # break",
"+ break"
] | false | 0.040533 | 0.037748 | 1.073767 | [
"s390887073",
"s855041348"
] |
u686036872 | p03128 | python | s333468745 | s844162698 | 249 | 177 | 51,036 | 14,692 | Accepted | Accepted | 28.92 | N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1]*(N+1)
dp[0]=0
for i in range(N+1):
for j in A:
if i + B[j] <= N:
dp[i+B[j]]= max(dp[i]*10+j, dp[i+B[j]])
print((dp[N])) | N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
DP = [-1]*(N+1)
DP[0] = 0
for i in range(N):
for j in A:
if i+B[j] <= N:
DP[i+B[j]] = max(DP[i]*10+j, DP[i+B[j]])
print((DP[N])) | 10 | 14 | 266 | 273 | N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (N + 1)
dp[0] = 0
for i in range(N + 1):
for j in A:
if i + B[j] <= N:
dp[i + B[j]] = max(dp[i] * 10 + j, dp[i + B[j]])
print((dp[N]))
| N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
DP = [-1] * (N + 1)
DP[0] = 0
for i in range(N):
for j in A:
if i + B[j] <= N:
DP[i + B[j]] = max(DP[i] * 10 + j, DP[i + B[j]])
print((DP[N]))
| false | 28.571429 | [
"-dp = [-1] * (N + 1)",
"-dp[0] = 0",
"-for i in range(N + 1):",
"+DP = [-1] * (N + 1)",
"+DP[0] = 0",
"+for i in range(N):",
"- dp[i + B[j]] = max(dp[i] * 10 + j, dp[i + B[j]])",
"-print((dp[N]))",
"+ DP[i + B[j]] = max(DP[i] * 10 + j, DP[i + B[j]])",
"+print((DP[N]))"
] | false | 0.041006 | 0.042495 | 0.96497 | [
"s333468745",
"s844162698"
] |
u263830634 | p02837 | python | s471661705 | s586287110 | 348 | 143 | 3,064 | 3,064 | Accepted | Accepted | 58.91 | N = int(eval(input()))
lst = [[] for _ in range(N)]
for i in range(N):
A = int(eval(input()))
for _ in range(A):
x, y = list(map(int, input().split()))
lst[i].append([x - 1, y])
ans = 0
for i in range(2 ** N):
check = [-1] * N #1:正直者、0:不親切
count = 0 #カウント用
flag = True
... | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7
N = int(eval(input()))
lst = [[] for _ in range(N)]
for i in range(N):
A = int(eval(input()))
for _ in range(A):
XY = tuple(map(int, input().split()))
lst[i].append(XY)
ans = 0
for i in ran... | 57 | 43 | 1,421 | 958 | N = int(eval(input()))
lst = [[] for _ in range(N)]
for i in range(N):
A = int(eval(input()))
for _ in range(A):
x, y = list(map(int, input().split()))
lst[i].append([x - 1, y])
ans = 0
for i in range(2**N):
check = [-1] * N # 1:正直者、0:不親切
count = 0 # カウント用
flag = True
for j in ... | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9 + 7
N = int(eval(input()))
lst = [[] for _ in range(N)]
for i in range(N):
A = int(eval(input()))
for _ in range(A):
XY = tuple(map(int, input().split()))
lst[i].append(XY)
ans = 0
for i in range(2**N):
count = 0... | false | 24.561404 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"+sys.setrecursionlimit(10**9)",
"+MOD = 10**9 + 7",
"- x, y = list(map(int, input().split()))",
"- lst[i].append([x - 1, y])",
"+ XY = tuple(map(int, input().split()))",
"+ lst[i].append(XY)",
"- check = [-1] * N #... | false | 0.035976 | 0.054126 | 0.664669 | [
"s471661705",
"s586287110"
] |
u241159583 | p02881 | python | s467563127 | s002166186 | 265 | 143 | 3,060 | 3,060 | Accepted | Accepted | 46.04 | import math
N = int(eval(input()))
a = math.floor(N ** 0.5) + 1
ans = N + 1
for i in range(1, a):
j = N // i
if i * j == N and i + j - 2 < ans:
ans = i + j - 2
print(ans) | import math
N = int(eval(input()))
a = math.floor(N ** 0.5)
ans = N
for x in range(1, a + 1):
if N % x != 0: continue
y = N // x
if ans > x + y - 2:
ans = x + y - 2
print(ans) | 11 | 11 | 186 | 190 | import math
N = int(eval(input()))
a = math.floor(N**0.5) + 1
ans = N + 1
for i in range(1, a):
j = N // i
if i * j == N and i + j - 2 < ans:
ans = i + j - 2
print(ans)
| import math
N = int(eval(input()))
a = math.floor(N**0.5)
ans = N
for x in range(1, a + 1):
if N % x != 0:
continue
y = N // x
if ans > x + y - 2:
ans = x + y - 2
print(ans)
| false | 0 | [
"-a = math.floor(N**0.5) + 1",
"-ans = N + 1",
"-for i in range(1, a):",
"- j = N // i",
"- if i * j == N and i + j - 2 < ans:",
"- ans = i + j - 2",
"+a = math.floor(N**0.5)",
"+ans = N",
"+for x in range(1, a + 1):",
"+ if N % x != 0:",
"+ continue",
"+ y = N // x",... | false | 0.040595 | 0.036832 | 1.102183 | [
"s467563127",
"s002166186"
] |
u449473917 | p03221 | python | s735571905 | s934252303 | 629 | 431 | 33,684 | 31,084 | Accepted | Accepted | 31.48 | N,M = list(map(int, input().split()))
pref = [[0] for i in range(N+1)]
q=[]
for i in range(M):
p,y = list(map(int, input().split()))
pref[p].append(y)
q.append([p,y])
for p in pref:
p.sort()
import bisect
for p,y in q:
print(("%06d%06d" %(p, bisect.bisect_left(pref[p], y)))) | import sys
input=sys.stdin.readline
N,M = list(map(int, input().split()))
pref = [[0] for i in range(N+1)]
import collections
q = collections.deque()
for i in range(M):
p,y = list(map(int, input().split()))
pref[p].append(y)
q.append((p,y))
for p in pref:
p.sort()
import bisect
... | 15 | 19 | 300 | 381 | N, M = list(map(int, input().split()))
pref = [[0] for i in range(N + 1)]
q = []
for i in range(M):
p, y = list(map(int, input().split()))
pref[p].append(y)
q.append([p, y])
for p in pref:
p.sort()
import bisect
for p, y in q:
print(("%06d%06d" % (p, bisect.bisect_left(pref[p], y))))
| import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
pref = [[0] for i in range(N + 1)]
import collections
q = collections.deque()
for i in range(M):
p, y = list(map(int, input().split()))
pref[p].append(y)
q.append((p, y))
for p in pref:
p.sort()
import bisect
for p, y in q:
... | false | 21.052632 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"-q = []",
"+import collections",
"+",
"+q = collections.deque()",
"- q.append([p, y])",
"+ q.append((p, y))"
] | false | 0.046119 | 0.045793 | 1.007116 | [
"s735571905",
"s934252303"
] |
u163320134 | p03645 | python | s310679507 | s326988230 | 765 | 573 | 38,320 | 18,936 | Accepted | Accepted | 25.1 | n,m=list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for i in range(m):
a,b=list(map(int,input().split()))
g[a].append(b)
g[b].append(a)
flag=False
for i in g[1]:
for j in g[i]:
if j==n:
flag=True
if flag==True:
print('POSSIBLE')
else:
print('IMPOSSIBLE') | n,m=list(map(int,input().split()))
s1=set()
s2=set()
for _ in range(m):
a,b=list(map(int,input().split()))
if a==1:
s1.add(b)
if b==n:
s2.add(a)
if len(s1&s2)!=0:
print('POSSIBLE')
else:
print('IMPOSSIBLE') | 15 | 13 | 288 | 224 | n, m = list(map(int, input().split()))
g = [[] for _ in range(n + 1)]
for i in range(m):
a, b = list(map(int, input().split()))
g[a].append(b)
g[b].append(a)
flag = False
for i in g[1]:
for j in g[i]:
if j == n:
flag = True
if flag == True:
print("POSSIBLE")
else:
print("IMPO... | n, m = list(map(int, input().split()))
s1 = set()
s2 = set()
for _ in range(m):
a, b = list(map(int, input().split()))
if a == 1:
s1.add(b)
if b == n:
s2.add(a)
if len(s1 & s2) != 0:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| false | 13.333333 | [
"-g = [[] for _ in range(n + 1)]",
"-for i in range(m):",
"+s1 = set()",
"+s2 = set()",
"+for _ in range(m):",
"- g[a].append(b)",
"- g[b].append(a)",
"-flag = False",
"-for i in g[1]:",
"- for j in g[i]:",
"- if j == n:",
"- flag = True",
"-if flag == True:",
"+... | false | 0.073583 | 0.041435 | 1.775856 | [
"s310679507",
"s326988230"
] |
u600402037 | p02788 | python | s278773929 | s000966281 | 1,051 | 795 | 67,692 | 52,936 | Accepted | Accepted | 24.36 | import sys
sys.setrecursionlimit(10 ** 7)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def main():
N, D, A = lr()
XH = [lr() for _ in range(N)]
XH.sort()
over = [N] * N # over[i]はi番目のモンスターを攻撃した時影響のないモンスターの最小値(最大はNで対象なし)
c... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
N,D,A = list(map(int,readline().split()))
m = list(map(int,read().split()))
X,H = list(zip(*sorted(zip(m,m))))
over = [-1]*N
tmp=0
for i in range(N):
... | 36 | 35 | 867 | 749 | import sys
sys.setrecursionlimit(10**7)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def main():
N, D, A = lr()
XH = [lr() for _ in range(N)]
XH.sort()
over = [N] * N # over[i]はi番目のモンスターを攻撃した時影響のないモンスターの最小値(最大はNで対象なし)
cur = 1
for... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
N, D, A = list(map(int, readline().split()))
m = list(map(int, read().split()))
X, H = list(zip(*sorted(zip(m, m))))
over = [-1] * N
tmp = 0
for i in range(N):
... | false | 2.777778 | [
"-sys.setrecursionlimit(10**7)",
"-sr = lambda: sys.stdin.readline().rstrip()",
"-ir = lambda: int(sr())",
"-lr = lambda: list(map(int, sr().split()))",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"- N, D, A = lr()",
"- X... | false | 0.122799 | 0.141448 | 0.868154 | [
"s278773929",
"s000966281"
] |
u801049006 | p02684 | python | s103125989 | s602133000 | 161 | 133 | 32,376 | 32,100 | Accepted | Accepted | 17.39 | N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
s = [0] * (N+1)
p = 1
h = []
for i in range(K):
h.append(p)
s[p] = 1
p = A[p]
if s[p] != 0:
break
if i == K-1:
print(p)
exit()
else:
period = len(h) - h.index(p)
rem = (K - h.... | n, k = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
seen = [False] * (n+1)
visited = []
nxt = 1
cnt = 0
while not seen[nxt] and cnt != k:
seen[nxt] = True
visited.append(nxt)
nxt = a[nxt]
cnt += 1
if cnt == k:
print(nxt)
exit()
idx = visited.i... | 21 | 19 | 365 | 374 | N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
s = [0] * (N + 1)
p = 1
h = []
for i in range(K):
h.append(p)
s[p] = 1
p = A[p]
if s[p] != 0:
break
if i == K - 1:
print(p)
exit()
else:
period = len(h) - h.index(p)
rem = (K - h.index(p)) % period
... | n, k = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
seen = [False] * (n + 1)
visited = []
nxt = 1
cnt = 0
while not seen[nxt] and cnt != k:
seen[nxt] = True
visited.append(nxt)
nxt = a[nxt]
cnt += 1
if cnt == k:
print(nxt)
exit()
idx = visited.index(nxt)
print((visit... | false | 9.52381 | [
"-N, K = list(map(int, input().split()))",
"-A = [0] + list(map(int, input().split()))",
"-s = [0] * (N + 1)",
"-p = 1",
"-h = []",
"-for i in range(K):",
"- h.append(p)",
"- s[p] = 1",
"- p = A[p]",
"- if s[p] != 0:",
"- break",
"-if i == K - 1:",
"- print(p)",
"+n, ... | false | 0.044133 | 0.03755 | 1.175308 | [
"s103125989",
"s602133000"
] |
u371763408 | p03353 | python | s566650455 | s119501599 | 1,770 | 36 | 3,956 | 5,068 | Accepted | Accepted | 97.97 | s = eval(input())
k = int(eval(input()))
#正解(全列挙してソートしてる)
sub_string=[]
for i in range(len(s)):
for j in range(1,k+1):
string = s[i:i+j]
if string not in sub_string:
sub_string.append(string)
sub_string.sort()
print((sub_string[k-1])) | s = eval(input())
k = int(eval(input()))
#正解(全列挙してソートしてる)
sub_string=[]
for i in range(len(s)):
for j in range(1,k+1):
sub_string.append(s[i:i+j])
sub_string=list(set(sub_string))
sub_string.sort()
print((sub_string[k-1])) | 12 | 11 | 248 | 225 | s = eval(input())
k = int(eval(input()))
# 正解(全列挙してソートしてる)
sub_string = []
for i in range(len(s)):
for j in range(1, k + 1):
string = s[i : i + j]
if string not in sub_string:
sub_string.append(string)
sub_string.sort()
print((sub_string[k - 1]))
| s = eval(input())
k = int(eval(input()))
# 正解(全列挙してソートしてる)
sub_string = []
for i in range(len(s)):
for j in range(1, k + 1):
sub_string.append(s[i : i + j])
sub_string = list(set(sub_string))
sub_string.sort()
print((sub_string[k - 1]))
| false | 8.333333 | [
"- string = s[i : i + j]",
"- if string not in sub_string:",
"- sub_string.append(string)",
"+ sub_string.append(s[i : i + j])",
"+sub_string = list(set(sub_string))"
] | false | 0.071398 | 0.038729 | 1.843505 | [
"s566650455",
"s119501599"
] |
u798260206 | p03611 | python | s088275525 | s251468187 | 184 | 137 | 14,564 | 27,876 | Accepted | Accepted | 25.54 | from collections import Counter
N = int(eval(input()))
A = list(map(int,input().split()))
C = Counter(A)
ans = 0
for i in range(10**5):
c = C[i-1] + C[i] + C[i+1]
ans = max(c,ans)
print(ans) | import collections
n = int(eval(input()))
a = list(map(int,input().split()))
lst = collections.defaultdict(int)
for i in a:
lst[i] += 1
lst[i-1] += 1
lst[i+1] += 1
lst = sorted(list(lst.items()),reverse=True,key=lambda x:x[1])
print((lst[0][1])) | 11 | 11 | 203 | 250 | from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
for i in range(10**5):
c = C[i - 1] + C[i] + C[i + 1]
ans = max(c, ans)
print(ans)
| import collections
n = int(eval(input()))
a = list(map(int, input().split()))
lst = collections.defaultdict(int)
for i in a:
lst[i] += 1
lst[i - 1] += 1
lst[i + 1] += 1
lst = sorted(list(lst.items()), reverse=True, key=lambda x: x[1])
print((lst[0][1]))
| false | 0 | [
"-from collections import Counter",
"+import collections",
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-C = Counter(A)",
"-ans = 0",
"-for i in range(10**5):",
"- c = C[i - 1] + C[i] + C[i + 1]",
"- ans = max(c, ans)",
"-print(ans)",
"+n = int(eval(input()))",
"+a... | false | 0.151763 | 0.047461 | 3.197657 | [
"s088275525",
"s251468187"
] |
u670180528 | p03972 | python | s748817734 | s254047178 | 399 | 237 | 27,692 | 26,468 | Accepted | Accepted | 40.6 | w,h,*L=list(map(int,open(0).read().split()))
P=L[:w];Q=L[w:]
x,y=w,h
sss=[]
for i,pi in enumerate(P):
sss.append((pi,1))
for j,qj in enumerate(Q):
sss.append((qj,0))
sss.sort()
ans=0
for c,f in sss:
if f and x:
x-=1
ans+=c*(y+1)
elif not f and y:
y-=1
ans+=c*(x+1)
print(ans)
| w,h,*L=list(map(int,open(0).read().split()))
P=L[:w];Q=[-qj for qj in L[w:]]
x,y,ans=w,h,0
for c in sorted(P+Q,key=abs):
if c>0:
if x:ans+=c*(y+1);x-=1
else:
if y:ans-=c*(x+1);y-=1
print(ans) | 21 | 9 | 305 | 199 | w, h, *L = list(map(int, open(0).read().split()))
P = L[:w]
Q = L[w:]
x, y = w, h
sss = []
for i, pi in enumerate(P):
sss.append((pi, 1))
for j, qj in enumerate(Q):
sss.append((qj, 0))
sss.sort()
ans = 0
for c, f in sss:
if f and x:
x -= 1
ans += c * (y + 1)
elif not f and y:
y -... | w, h, *L = list(map(int, open(0).read().split()))
P = L[:w]
Q = [-qj for qj in L[w:]]
x, y, ans = w, h, 0
for c in sorted(P + Q, key=abs):
if c > 0:
if x:
ans += c * (y + 1)
x -= 1
else:
if y:
ans -= c * (x + 1)
y -= 1
print(ans)
| false | 57.142857 | [
"-Q = L[w:]",
"-x, y = w, h",
"-sss = []",
"-for i, pi in enumerate(P):",
"- sss.append((pi, 1))",
"-for j, qj in enumerate(Q):",
"- sss.append((qj, 0))",
"-sss.sort()",
"-ans = 0",
"-for c, f in sss:",
"- if f and x:",
"- x -= 1",
"- ans += c * (y + 1)",
"- elif ... | false | 0.059531 | 0.099251 | 0.599801 | [
"s748817734",
"s254047178"
] |
u633068244 | p00725 | python | s423294611 | s956608035 | 2,320 | 850 | 4,284 | 4,276 | Accepted | Accepted | 63.36 | def rec(x,y,t):
global ans
if t >= ans: return
if field[y][x] == 3: ans = min(ans,t)
for dx,dy in zip([1,0,-1,0],[0,1,0,-1]):
nx,ny = x+dx,y+dy
while 0 <= nx < W and 0 <= ny < H:
if field[ny][nx] == 3:
rec(nx,ny,t+1)
if field[ny][nx] == 1:... | dxy = list(zip([1,0,-1,0],[0,1,0,-1]))
def rec(x,y,t):
global ans
if t >= ans: return
if field[y][x] == 3: ans = min(ans,t)
for dx,dy in dxy:
nx,ny = x+dx,y+dy
while 0 <= nx < W and 0 <= ny < H:
if field[ny][nx] == 3: ans = t
elif field[ny][nx] == 1:
... | 27 | 27 | 837 | 828 | def rec(x, y, t):
global ans
if t >= ans:
return
if field[y][x] == 3:
ans = min(ans, t)
for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):
nx, ny = x + dx, y + dy
while 0 <= nx < W and 0 <= ny < H:
if field[ny][nx] == 3:
rec(nx, ny, t + 1)
... | dxy = list(zip([1, 0, -1, 0], [0, 1, 0, -1]))
def rec(x, y, t):
global ans
if t >= ans:
return
if field[y][x] == 3:
ans = min(ans, t)
for dx, dy in dxy:
nx, ny = x + dx, y + dy
while 0 <= nx < W and 0 <= ny < H:
if field[ny][nx] == 3:
ans = t... | false | 0 | [
"+dxy = list(zip([1, 0, -1, 0], [0, 1, 0, -1]))",
"+",
"+",
"- for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):",
"+ for dx, dy in dxy:",
"- rec(nx, ny, t + 1)",
"- if field[ny][nx] == 1:",
"+ ans = t",
"+ elif field[ny][nx] == 1:",
"- r... | false | 0.036779 | 0.112782 | 0.32611 | [
"s423294611",
"s956608035"
] |
u017810624 | p03055 | python | s487617134 | s492421515 | 1,344 | 728 | 123,428 | 121,092 | Accepted | Accepted | 45.83 | n=int(eval(input()))
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
connection[l[i][0]-1].append(l[i][1]-1)
connection[l[i][1]-1].append(l[i][0]-1)
distance1=[-1 for i in range(n)]
distance1[0]=0
next=connection[0]
next2=[]
check=[-1 for i ... | import sys
input=sys.stdin.readline
n=int(eval(input()))
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
connection[l[i][0]-1].append(l[i][1]-1)
connection[l[i][1]-1].append(l[i][0]-1)
distance1=[-1 for i in range(n)]
distance1[0]=0
next=con... | 54 | 56 | 1,217 | 1,255 | n = int(eval(input()))
l = [list(map(int, input().split())) for i in range(n - 1)]
connection = [[] for i in range(n)]
for i in range(n - 1):
connection[l[i][0] - 1].append(l[i][1] - 1)
connection[l[i][1] - 1].append(l[i][0] - 1)
distance1 = [-1 for i in range(n)]
distance1[0] = 0
next = connection[0]
next2 = [... | import sys
input = sys.stdin.readline
n = int(eval(input()))
l = [list(map(int, input().split())) for i in range(n - 1)]
connection = [[] for i in range(n)]
for i in range(n - 1):
connection[l[i][0] - 1].append(l[i][1] - 1)
connection[l[i][1] - 1].append(l[i][0] - 1)
distance1 = [-1 for i in range(n)]
distance... | false | 3.571429 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.039144 | 0.034442 | 1.136515 | [
"s487617134",
"s492421515"
] |
u029918772 | p02595 | python | s235316019 | s584830614 | 617 | 483 | 40,632 | 9,116 | Accepted | Accepted | 21.72 | n, d = list(map(int, input().split()))
xy = []
for i in range(n):
a, b = list(map(int, input().split()))
xy.append([a, b])
count = [xi**2 + yi**2 <= d**2 for xi, yi in xy]
print((sum(count))) | n, d = list(map(int, input().split()))
xy = 0
for i in range(n):
xi, yi = list(map(int, input().split()))
xy += xi**2 + yi**2 <= d**2
print(xy) | 9 | 7 | 193 | 143 | n, d = list(map(int, input().split()))
xy = []
for i in range(n):
a, b = list(map(int, input().split()))
xy.append([a, b])
count = [xi**2 + yi**2 <= d**2 for xi, yi in xy]
print((sum(count)))
| n, d = list(map(int, input().split()))
xy = 0
for i in range(n):
xi, yi = list(map(int, input().split()))
xy += xi**2 + yi**2 <= d**2
print(xy)
| false | 22.222222 | [
"-xy = []",
"+xy = 0",
"- a, b = list(map(int, input().split()))",
"- xy.append([a, b])",
"-count = [xi**2 + yi**2 <= d**2 for xi, yi in xy]",
"-print((sum(count)))",
"+ xi, yi = list(map(int, input().split()))",
"+ xy += xi**2 + yi**2 <= d**2",
"+print(xy)"
] | false | 0.03477 | 0.042169 | 0.82452 | [
"s235316019",
"s584830614"
] |
u671060652 | p03042 | python | s619723984 | s851542570 | 293 | 65 | 65,772 | 61,500 | Accepted | Accepted | 77.82 | import itertools
import math
import fractions
import functools
import copy
s = eval(input())
front = int(s[0]+s[1])
back = int(s[2]+s[3])
if (1 <= front and front <= 12) and (1 <= back and back <= 12):
print("AMBIGUOUS")
quit()
if (1 <= front and front <= 12):
print("MMYY")
quit()
if (... | import math
def main():
# n = int(input())
# n, k = map(int, input().split())
# h = list(map(int, input().split()))
s = eval(input())
# h = [int(input()) for _ in rane(n)]
f = int(s[:2])
b = int(s[2:])
if 1 <= f and f <= 12 and 1 <= b and b <= 12:
print("AMBIGUOUS")... | 21 | 23 | 386 | 543 | import itertools
import math
import fractions
import functools
import copy
s = eval(input())
front = int(s[0] + s[1])
back = int(s[2] + s[3])
if (1 <= front and front <= 12) and (1 <= back and back <= 12):
print("AMBIGUOUS")
quit()
if 1 <= front and front <= 12:
print("MMYY")
quit()
if 1 <= back and ba... | import math
def main():
# n = int(input())
# n, k = map(int, input().split())
# h = list(map(int, input().split()))
s = eval(input())
# h = [int(input()) for _ in rane(n)]
f = int(s[:2])
b = int(s[2:])
if 1 <= f and f <= 12 and 1 <= b and b <= 12:
print("AMBIGUOUS")
elif 0 ... | false | 8.695652 | [
"-import itertools",
"-import fractions",
"-import functools",
"-import copy",
"-s = eval(input())",
"-front = int(s[0] + s[1])",
"-back = int(s[2] + s[3])",
"-if (1 <= front and front <= 12) and (1 <= back and back <= 12):",
"- print(\"AMBIGUOUS\")",
"- quit()",
"-if 1 <= front and front ... | false | 0.04101 | 0.040037 | 1.024282 | [
"s619723984",
"s851542570"
] |
u924406834 | p02916 | python | s273406899 | s986198434 | 174 | 17 | 38,384 | 3,064 | Accepted | Accepted | 90.23 | n = int(eval(input()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
check = 0
for i in range(n):
tabe = a[i]
check += b[tabe - 1]
if i < n -1 :
if (a[i+1] - a[i]) == 1:
check += c[a[i]-1]
print(check) | n = int(eval(input()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
ans += b[i]
if i == 0:continue
if a[i] - a[i-1] == 1:
ans += c[a[i-1]-1]
print(ans) | 12 | 12 | 297 | 264 | n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
check = 0
for i in range(n):
tabe = a[i]
check += b[tabe - 1]
if i < n - 1:
if (a[i + 1] - a[i]) == 1:
check += c[a[i] - 1]
print(check)
| n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
ans += b[i]
if i == 0:
continue
if a[i] - a[i - 1] == 1:
ans += c[a[i - 1] - 1]
print(ans)
| false | 0 | [
"-check = 0",
"+ans = 0",
"- tabe = a[i]",
"- check += b[tabe - 1]",
"- if i < n - 1:",
"- if (a[i + 1] - a[i]) == 1:",
"- check += c[a[i] - 1]",
"-print(check)",
"+ ans += b[i]",
"+ if i == 0:",
"+ continue",
"+ if a[i] - a[i - 1] == 1:",
"+ ... | false | 0.043321 | 0.070484 | 0.61462 | [
"s273406899",
"s986198434"
] |
u306142032 | p02786 | python | s163442033 | s359967517 | 17 | 10 | 2,940 | 2,568 | Accepted | Accepted | 41.18 | print((~-2**int(eval(input())).bit_length())) | print(~-2**input().bit_length()) | 1 | 1 | 37 | 30 | print((~-(2 ** int(eval(input())).bit_length())))
| print(~-(2 ** input().bit_length()))
| false | 0 | [
"-print((~-(2 ** int(eval(input())).bit_length())))",
"+print(~-(2 ** input().bit_length()))"
] | false | 0.043239 | 0.08197 | 0.527494 | [
"s163442033",
"s359967517"
] |
u731896389 | p02407 | python | s328959065 | s642686834 | 30 | 20 | 7,632 | 7,656 | Accepted | Accepted | 33.33 | n = int(input())
a = list(map(int,input().split()))
a.reverse()
for i in range(n-1):
print(a[i],end = " ")
print(a[n-1])
| n =int(input())
a = list(map(int,input().split()))
a.reverse()
for i in range(n):
if i!=n-1:
print(a[i],end=" ")
else:
print(a[i])
| 6 | 8 | 129 | 161 | n = int(input())
a = list(map(int, input().split()))
a.reverse()
for i in range(n - 1):
print(a[i], end=" ")
print(a[n - 1])
| n = int(input())
a = list(map(int, input().split()))
a.reverse()
for i in range(n):
if i != n - 1:
print(a[i], end=" ")
else:
print(a[i])
| false | 25 | [
"-for i in range(n - 1):",
"- print(a[i], end=\" \")",
"-print(a[n - 1])",
"+for i in range(n):",
"+ if i != n - 1:",
"+ print(a[i], end=\" \")",
"+ else:",
"+ print(a[i])"
] | false | 0.035578 | 0.054663 | 0.650858 | [
"s328959065",
"s642686834"
] |
u562935282 | p02954 | python | s827190479 | s394719779 | 136 | 108 | 8,288 | 6,400 | Accepted | Accepted | 20.59 | def main():
from bisect import bisect_left
s = eval(input())
n = len(s)
RL = []
for i in range(n - 1):
pair = s[i:i + 2]
if pair == 'RL':
RL.append(i)
cnt = [0] * n
for i, c in enumerate(s):
if c == 'R':
j = bisect_left(RL, i)... | def main():
from itertools import chain, tee
s = eval(input())
n = len(s)
a = (-1 if c == 'L' else 1 for c in s)
p = -1
RL = 1
ctr = [0] * n
it = chain(a, (1,))
g1, g2 = tee(it, 2)
next(g2)
for i, (x1, x2) in enumerate(zip(g1, g2)):
if x1 + x2 == 0:
... | 43 | 40 | 866 | 844 | def main():
from bisect import bisect_left
s = eval(input())
n = len(s)
RL = []
for i in range(n - 1):
pair = s[i : i + 2]
if pair == "RL":
RL.append(i)
cnt = [0] * n
for i, c in enumerate(s):
if c == "R":
j = bisect_left(RL, i)
j ... | def main():
from itertools import chain, tee
s = eval(input())
n = len(s)
a = (-1 if c == "L" else 1 for c in s)
p = -1
RL = 1
ctr = [0] * n
it = chain(a, (1,))
g1, g2 = tee(it, 2)
next(g2)
for i, (x1, x2) in enumerate(zip(g1, g2)):
if x1 + x2 == 0:
if RL... | false | 6.976744 | [
"- from bisect import bisect_left",
"+ from itertools import chain, tee",
"- RL = []",
"- for i in range(n - 1):",
"- pair = s[i : i + 2]",
"- if pair == \"RL\":",
"- RL.append(i)",
"- cnt = [0] * n",
"- for i, c in enumerate(s):",
"- if c == \"R\"... | false | 0.043854 | 0.0839 | 0.522698 | [
"s827190479",
"s394719779"
] |
u550943777 | p03579 | python | s631313988 | s293652718 | 608 | 559 | 22,064 | 31,188 | Accepted | Accepted | 8.06 | N,M = list(map(int,input().split()))
e_list = [[] for i in range(N)]
for i in range(M):
a,b = [int(x)-1 for x in input().split()]
e_list[a].append(b)
e_list[b].append(a)
bin_or_not = True
ans = (N-1)*N//2 - M
w_or_b = [-1]*N
stack = [0]
w_or_b[0] = 0
while stack:
x = stack.pop()
for i i... | import sys
sys.setrecursionlimit(10**7)
class BinPartite:
def __init__(self, N, es):
self.colors = [0 for i in range(N)]
self.es = es
def dfs(self, v, color):
self.colors[v] = color
for to in self.es[v]:
if self.colors[to] == color:
return ... | 28 | 37 | 675 | 932 | N, M = list(map(int, input().split()))
e_list = [[] for i in range(N)]
for i in range(M):
a, b = [int(x) - 1 for x in input().split()]
e_list[a].append(b)
e_list[b].append(a)
bin_or_not = True
ans = (N - 1) * N // 2 - M
w_or_b = [-1] * N
stack = [0]
w_or_b[0] = 0
while stack:
x = stack.pop()
for i i... | import sys
sys.setrecursionlimit(10**7)
class BinPartite:
def __init__(self, N, es):
self.colors = [0 for i in range(N)]
self.es = es
def dfs(self, v, color):
self.colors[v] = color
for to in self.es[v]:
if self.colors[to] == color:
return False
... | false | 24.324324 | [
"+import sys",
"+",
"+sys.setrecursionlimit(10**7)",
"+",
"+",
"+class BinPartite:",
"+ def __init__(self, N, es):",
"+ self.colors = [0 for i in range(N)]",
"+ self.es = es",
"+",
"+ def dfs(self, v, color):",
"+ self.colors[v] = color",
"+ for to in self.e... | false | 0.07773 | 0.034773 | 2.23537 | [
"s631313988",
"s293652718"
] |
u102461423 | p03823 | python | s746666454 | s317872315 | 381 | 144 | 23,620 | 35,972 | Accepted | Accepted | 62.2 | import sys
input = sys.stdin.readline
from bisect import bisect_left, bisect_right
INF = 10**18 + 100
N,A,B = list(map(int,input().split()))
S = [-INF] + [int(x) for x in sys.stdin.read().split()]
MOD = 10**9 + 7
dpX = [0] * (N+1) # 最後にYを選んだとして、直前に選んだXがどこにあるか
dpY = [0] * (N+1) # 最後にXを選んだとして、直前に選んだYがどこにあ... | import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9 + 7
def main(N, A, B, S):
if N == 1:
return 2
INF = 1 << 62
S = np.append(S, INF)
if A > B:
A, B = B, A
if np.min(S[2:... | 42 | 57 | 1,144 | 1,377 | import sys
input = sys.stdin.readline
from bisect import bisect_left, bisect_right
INF = 10**18 + 100
N, A, B = list(map(int, input().split()))
S = [-INF] + [int(x) for x in sys.stdin.read().split()]
MOD = 10**9 + 7
dpX = [0] * (N + 1) # 最後にYを選んだとして、直前に選んだXがどこにあるか
dpY = [0] * (N + 1) # 最後にXを選んだとして、直前に選んだYがどこにあるか
dp... | import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9 + 7
def main(N, A, B, S):
if N == 1:
return 2
INF = 1 << 62
S = np.append(S, INF)
if A > B:
A, B = B, A
if np.min(S[2:] - S[:-2]) < A:... | false | 26.315789 | [
"+import numpy as np",
"-input = sys.stdin.readline",
"-from bisect import bisect_left, bisect_right",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+MOD = 10**9 + 7",
"-INF = 10**18 + 100",
"-N, A, B = list(map(int, input().spl... | false | 0.035216 | 0.181329 | 0.194211 | [
"s746666454",
"s317872315"
] |
u298297089 | p03285 | python | s623031513 | s482405722 | 180 | 17 | 38,384 | 3,060 | Accepted | Accepted | 90.56 |
n = int(eval(input()))
for i in range(n//4+1):
for j in range(n//7+1):
if 4 * i + 7 * j == n:
print('Yes')
exit()
print('No')
| n = int(eval(input()))
for i in range((n+3)//4+1):
if (n - i * 4 ) % 7 == 0:
print('Yes')
break
else:
print('No') | 8 | 7 | 164 | 137 | n = int(eval(input()))
for i in range(n // 4 + 1):
for j in range(n // 7 + 1):
if 4 * i + 7 * j == n:
print("Yes")
exit()
print("No")
| n = int(eval(input()))
for i in range((n + 3) // 4 + 1):
if (n - i * 4) % 7 == 0:
print("Yes")
break
else:
print("No")
| false | 12.5 | [
"-for i in range(n // 4 + 1):",
"- for j in range(n // 7 + 1):",
"- if 4 * i + 7 * j == n:",
"- print(\"Yes\")",
"- exit()",
"-print(\"No\")",
"+for i in range((n + 3) // 4 + 1):",
"+ if (n - i * 4) % 7 == 0:",
"+ print(\"Yes\")",
"+ break",
"+els... | false | 0.046902 | 0.046036 | 1.018793 | [
"s623031513",
"s482405722"
] |
u729133443 | p02641 | python | s925181150 | s114572687 | 62 | 23 | 62,396 | 9,152 | Accepted | Accepted | 62.9 | x,n,*p=list(map(int,open(0).read().split()))
print((min({*list(range(999))}-{*p},key=lambda y:abs(y-x)))) | x,n,*p=list(map(int,open(i:=0).read().split()))
while x in p:x+=(-1)**i*i;i+=1
print(x) | 2 | 3 | 92 | 83 | x, n, *p = list(map(int, open(0).read().split()))
print((min({*list(range(999))} - {*p}, key=lambda y: abs(y - x))))
| x, n, *p = list(map(int, open(i := 0).read().split()))
while x in p:
x += (-1) ** i * i
i += 1
print(x)
| false | 33.333333 | [
"-x, n, *p = list(map(int, open(0).read().split()))",
"-print((min({*list(range(999))} - {*p}, key=lambda y: abs(y - x))))",
"+x, n, *p = list(map(int, open(i := 0).read().split()))",
"+while x in p:",
"+ x += (-1) ** i * i",
"+ i += 1",
"+print(x)"
] | false | 0.036261 | 0.036825 | 0.98468 | [
"s925181150",
"s114572687"
] |
u550061714 | p03172 | python | s919481540 | s395373683 | 741 | 467 | 174,728 | 92,968 | Accepted | Accepted | 36.98 | import itertools
N, K = list(map(int, input().split()))
A = tuple(map(int, input().split()))
MOD = 10 ** 9 + 7
dp = [[0] * (K + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(1, N + 1):
S = [0] + list(itertools.accumulate(dp[i - 1]))
for j in range(K + 1):
dp[i][j] = (S[j + 1] - S[... | import numpy as np
N, K = list(map(int, input().split()))
A = tuple(map(int, input().split()))
MOD = 10 ** 9 + 7
dp = np.zeros((N + 1, K + 1), dtype=np.int64)
dp[0][0] = 1
for i in range(1, N + 1):
S = np.cumsum(dp[i - 1]) % MOD
dp[i][:A[i - 1] + 1] = S[:A[i - 1] + 1] % MOD
dp[i][A[i - 1] + 1... | 14 | 14 | 360 | 390 | import itertools
N, K = list(map(int, input().split()))
A = tuple(map(int, input().split()))
MOD = 10**9 + 7
dp = [[0] * (K + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(1, N + 1):
S = [0] + list(itertools.accumulate(dp[i - 1]))
for j in range(K + 1):
dp[i][j] = (S[j + 1] - S[max(0, j - A[i -... | import numpy as np
N, K = list(map(int, input().split()))
A = tuple(map(int, input().split()))
MOD = 10**9 + 7
dp = np.zeros((N + 1, K + 1), dtype=np.int64)
dp[0][0] = 1
for i in range(1, N + 1):
S = np.cumsum(dp[i - 1]) % MOD
dp[i][: A[i - 1] + 1] = S[: A[i - 1] + 1] % MOD
dp[i][A[i - 1] + 1 : K + 1] = (S... | false | 0 | [
"-import itertools",
"+import numpy as np",
"-dp = [[0] * (K + 1) for _ in range(N + 1)]",
"+dp = np.zeros((N + 1, K + 1), dtype=np.int64)",
"- S = [0] + list(itertools.accumulate(dp[i - 1]))",
"- for j in range(K + 1):",
"- dp[i][j] = (S[j + 1] - S[max(0, j - A[i - 1])]) % MOD",
"+ S ... | false | 0.290111 | 0.268569 | 1.080211 | [
"s919481540",
"s395373683"
] |
u561231954 | p02792 | python | s498640437 | s366516209 | 197 | 145 | 3,064 | 3,064 | Accepted | Accepted | 26.4 | n = int(eval(input()))
c=[[0]*10 for i in range(10)]
for k in range(1,n+1):
k=str(k)
i=int(k[0])
j=int(k[-1])
c[i][j]+=1
ans=0
for i in range(10):
for j in range(10):
ans+=c[i][j]*c[j][i]
print(ans) | MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)
def main():
N = int(eval(input()))
presuf = [[0] * 10 for _ in range(10)]
for i in range(1,N + 1):
pre = int(str(i)[0])
suf = i%10
presuf[pre][suf] += 1
ans = 0
for i in range(10)... | 14 | 20 | 223 | 447 | n = int(eval(input()))
c = [[0] * 10 for i in range(10)]
for k in range(1, n + 1):
k = str(k)
i = int(k[0])
j = int(k[-1])
c[i][j] += 1
ans = 0
for i in range(10):
for j in range(10):
ans += c[i][j] * c[j][i]
print(ans)
| MOD = 10**9 + 7
INF = 10**11
import sys
sys.setrecursionlimit(100000000)
def main():
N = int(eval(input()))
presuf = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
pre = int(str(i)[0])
suf = i % 10
presuf[pre][suf] += 1
ans = 0
for i in range(10):
for j in... | false | 30 | [
"-n = int(eval(input()))",
"-c = [[0] * 10 for i in range(10)]",
"-for k in range(1, n + 1):",
"- k = str(k)",
"- i = int(k[0])",
"- j = int(k[-1])",
"- c[i][j] += 1",
"-ans = 0",
"-for i in range(10):",
"- for j in range(10):",
"- ans += c[i][j] * c[j][i]",
"-print(ans)"... | false | 0.049528 | 0.051462 | 0.96243 | [
"s498640437",
"s366516209"
] |
u057964173 | p02689 | python | s269613871 | s457516619 | 247 | 210 | 29,336 | 89,892 | Accepted | Accepted | 14.98 | import sys
def input(): return sys.stdin.readline().strip()
def resolve():
N,M=list(map(int, input().split())) # 頂点の数、辺の数
H=list(map(int,input().split()))
edge = [[] for i in range(N)]
for i in range(M):
x, y = list(map(int, input().split()))
x, y = x - 1, y - 1
edge[x... | import sys
def input(): return sys.stdin.readline().strip()
def resolve():
N,M=list(map(int, input().split()))
H=list(map(int,input().split()))
edge = [[] for i in range(N)]
for i in range(M):
x, y = list(map(int, input().split()))
x, y = x - 1, y - 1
edge[x].append(y)... | 26 | 22 | 664 | 551 | import sys
def input():
return sys.stdin.readline().strip()
def resolve():
N, M = list(map(int, input().split())) # 頂点の数、辺の数
H = list(map(int, input().split()))
edge = [[] for i in range(N)]
for i in range(M):
x, y = list(map(int, input().split()))
x, y = x - 1, y - 1
ed... | import sys
def input():
return sys.stdin.readline().strip()
def resolve():
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
edge = [[] for i in range(N)]
for i in range(M):
x, y = list(map(int, input().split()))
x, y = x - 1, y - 1
edge[x].append... | false | 15.384615 | [
"- N, M = list(map(int, input().split())) # 頂点の数、辺の数",
"+ N, M = list(map(int, input().split()))",
"- edge[y].append(x) # 有向なら#つける",
"+ edge[y].append(x)",
"- num = 0",
"- for j in edge[i]:",
"- if val > H[j]:",
"- num += 1"... | false | 0.07269 | 0.08143 | 0.892664 | [
"s269613871",
"s457516619"
] |
u553919982 | p03478 | python | s443965693 | s881923077 | 37 | 26 | 3,060 | 3,064 | Accepted | Accepted | 29.73 | def sm(x):
xls = list(str(x))
a = 0
for i in range(len(xls)):
a += int(xls[i])
return a
N, A, B = list(map(int,input().split()))
ans = 0
for i in range(1, N+1):
if A <= sm(i) <= B:
ans += i
print(ans)
| def sm(x):
a = 0
a += (x%10)
a += (x//10)%10
a += ((x//10)//10)%10
a += (((x//10)//10)//10)%10
a += ((((x//10)//10)//10)//10)%10
return a
N, A, B = list(map(int,input().split()))
ans = 0
for i in range(1, N+1):
if A <= sm(i) <= B:
ans += i
print(ans) | 13 | 15 | 244 | 299 | def sm(x):
xls = list(str(x))
a = 0
for i in range(len(xls)):
a += int(xls[i])
return a
N, A, B = list(map(int, input().split()))
ans = 0
for i in range(1, N + 1):
if A <= sm(i) <= B:
ans += i
print(ans)
| def sm(x):
a = 0
a += x % 10
a += (x // 10) % 10
a += ((x // 10) // 10) % 10
a += (((x // 10) // 10) // 10) % 10
a += ((((x // 10) // 10) // 10) // 10) % 10
return a
N, A, B = list(map(int, input().split()))
ans = 0
for i in range(1, N + 1):
if A <= sm(i) <= B:
ans += i
print(a... | false | 13.333333 | [
"- xls = list(str(x))",
"- for i in range(len(xls)):",
"- a += int(xls[i])",
"+ a += x % 10",
"+ a += (x // 10) % 10",
"+ a += ((x // 10) // 10) % 10",
"+ a += (((x // 10) // 10) // 10) % 10",
"+ a += ((((x // 10) // 10) // 10) // 10) % 10"
] | false | 0.063168 | 0.061982 | 1.019129 | [
"s443965693",
"s881923077"
] |
u498487134 | p02820 | python | s002975608 | s563930694 | 196 | 86 | 49,520 | 79,876 | Accepted | Accepted | 56.12 | N,K = list(map(int,input().split()))
R,S,P = list(map(int,input().split()))
T =list(eval(input()))
ans =0
for i in range(N):
if i<K:
if T[i]=="r":
ans+=P
elif T[i]=="s":
ans+=R
else:
ans+=S
else:
if T[i]=="r":
... |
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
N,K=MI()
R,S,P=MI()
T=eval(input())
L=[]
ans=0
for i in range(N):
pre="z"
if i-K>=0:
... | 32 | 44 | 685 | 878 | N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = list(eval(input()))
ans = 0
for i in range(N):
if i < K:
if T[i] == "r":
ans += P
elif T[i] == "s":
ans += R
else:
ans += S
else:
if T[i] == "r":
i... | def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
def main():
mod = 10**9 + 7
N, K = MI()
R, S, P = MI()
T = eval(input())
L = []
ans = 0
for i in range(N):
pre = "z"
if i - K... | false | 27.272727 | [
"-N, K = list(map(int, input().split()))",
"-R, S, P = list(map(int, input().split()))",
"-T = list(eval(input()))",
"-ans = 0",
"-for i in range(N):",
"- if i < K:",
"+def I():",
"+ return int(eval(input()))",
"+",
"+",
"+def MI():",
"+ return list(map(int, input().split()))",
"+",... | false | 0.047099 | 0.037122 | 1.268773 | [
"s002975608",
"s563930694"
] |
u543954314 | p02936 | python | s880808156 | s764557364 | 1,695 | 961 | 92,416 | 56,144 | Accepted | Accepted | 43.3 | n,q = list(map(int, input().split()))
tree = [set() for i in range(n+1)]
for _ in range(n-1):
a,b = list(map(int, input().split()))
tree[a].add(b)
tree[b].add(a)
lazy = [0]*(n+1)
cnt = 0
for _ in range(q):
x,v = list(map(int, input().split()))
lazy[x] += v
que = [(1,0)]
while que:
v,p = que... | import sys
from collections import deque
readline = sys.stdin.buffer.readline
ni = lambda: int(readline().rstrip())
nm = lambda: list(map(int, readline().split()))
nl = lambda: list(map(int, readline().split()))
def solve():
n, Q = nm()
G = [list() for _ in range(n)]
for _ in range(n-1):
... | 23 | 39 | 446 | 815 | n, q = list(map(int, input().split()))
tree = [set() for i in range(n + 1)]
for _ in range(n - 1):
a, b = list(map(int, input().split()))
tree[a].add(b)
tree[b].add(a)
lazy = [0] * (n + 1)
cnt = 0
for _ in range(q):
x, v = list(map(int, input().split()))
lazy[x] += v
que = [(1, 0)]
while que:
v,... | import sys
from collections import deque
readline = sys.stdin.buffer.readline
ni = lambda: int(readline().rstrip())
nm = lambda: list(map(int, readline().split()))
nl = lambda: list(map(int, readline().split()))
def solve():
n, Q = nm()
G = [list() for _ in range(n)]
for _ in range(n - 1):
u, v =... | false | 41.025641 | [
"-n, q = list(map(int, input().split()))",
"-tree = [set() for i in range(n + 1)]",
"-for _ in range(n - 1):",
"- a, b = list(map(int, input().split()))",
"- tree[a].add(b)",
"- tree[b].add(a)",
"-lazy = [0] * (n + 1)",
"-cnt = 0",
"-for _ in range(q):",
"- x, v = list(map(int, input()... | false | 0.077692 | 0.090297 | 0.860404 | [
"s880808156",
"s764557364"
] |
u212437180 | p02657 | python | s112687013 | s566354957 | 1,369 | 39 | 196,040 | 10,204 | Accepted | Accepted | 97.15 | from subprocess import run
with open("./tmp215378912379.cpp", mode='w') as f:
f.write("""
#include <bits/stdc++.h>
template <class T>
concept Integral = std::is_integral_v<T>;
int main() {
auto f = []<Integral T>(T a, T b) { return a * b; };
int a, b;
std::cin >> a >> b;
std::cout << f(a, b) << ... | from subprocess import run
from os import path
if not path.exists("./tmp215378912379"):
with open("./tmp215378912379.cpp", mode='w') as f:
f.write("""
#include <bits/stdc++.h>
template <class T>
concept Integral = std::is_integral_v<T>;
int main() {
auto f = []<Integral T>(T a, T b) { ret... | 17 | 21 | 453 | 549 | from subprocess import run
with open("./tmp215378912379.cpp", mode="w") as f:
f.write(
"""
#include <bits/stdc++.h>
template <class T>
concept Integral = std::is_integral_v<T>;
int main() {
auto f = []<Integral T>(T a, T b) { return a * b; };
int a, b;
std::cin >> a >> b;
std::cout << f(a, b) << st... | from subprocess import run
from os import path
if not path.exists("./tmp215378912379"):
with open("./tmp215378912379.cpp", mode="w") as f:
f.write(
"""
#include <bits/stdc++.h>
template <class T>
concept Integral = std::is_integral_v<T>;
int main() {
auto f = []<Integral T>(T a, T b... | false | 19.047619 | [
"+from os import path",
"-with open(\"./tmp215378912379.cpp\", mode=\"w\") as f:",
"- f.write(",
"- \"\"\"",
"-#include <bits/stdc++.h>",
"-template <class T>",
"-concept Integral = std::is_integral_v<T>;",
"-int main() {",
"- auto f = []<Integral T>(T a, T b) { return a * b; };",
"- i... | false | 2.521744 | 0.043917 | 57.421055 | [
"s112687013",
"s566354957"
] |
u426534722 | p02371 | python | s130732534 | s399238821 | 790 | 710 | 55,500 | 55,628 | Accepted | Accepted | 10.13 | import sys
readline = sys.stdin.readline
from collections import deque
from math import isinf
INF = float("inf")
sys.setrecursionlimit(200000)
n = int(readline())
G = [[] for _ in range(n)]
D = [INF] * n
for _ in [0] * (n - 1):
s, t, w = list(map(int, readline().split()))
G[s].append([t, w])
G[t... | import sys
readline = sys.stdin.readline
from collections import deque
from math import isinf
INF = float("inf")
sys.setrecursionlimit(200000)
n = int(readline())
G = [[] for _ in range(n)]
D = [INF] * n
for _ in [0] * (n - 1):
s, t, w = list(map(int, readline().split()))
G[s].append([t, w])
G[t... | 39 | 35 | 881 | 835 | import sys
readline = sys.stdin.readline
from collections import deque
from math import isinf
INF = float("inf")
sys.setrecursionlimit(200000)
n = int(readline())
G = [[] for _ in range(n)]
D = [INF] * n
for _ in [0] * (n - 1):
s, t, w = list(map(int, readline().split()))
G[s].append([t, w])
G[t].append([... | import sys
readline = sys.stdin.readline
from collections import deque
from math import isinf
INF = float("inf")
sys.setrecursionlimit(200000)
n = int(readline())
G = [[] for _ in range(n)]
D = [INF] * n
for _ in [0] * (n - 1):
s, t, w = list(map(int, readline().split()))
G[s].append([t, w])
G[t].append([... | false | 10.25641 | [
"-maxv = 0",
"-for i in range(n):",
"- if isinf(D[i]):",
"- continue",
"- maxv = max(maxv, D[i])",
"-print(maxv)",
"+print((max(D[i] for i in range(n) if not isinf(D[i]))))"
] | false | 0.047563 | 0.037585 | 1.265496 | [
"s130732534",
"s399238821"
] |
u707124227 | p02586 | python | s292150125 | s535890768 | 992 | 909 | 177,880 | 188,056 | Accepted | Accepted | 8.37 | import sys
input = sys.stdin.readline
def main(R,C,K,rcv):
inf=float('inf')
dp0=[[-inf,-inf,-inf,0] for _ in range(C)]
item=[[0]*C for _ in range(R)]
for r,c,v in rcv:
item[r-1][c-1]=v
# dp0[c][j]:c列目の時点で残りちょうどj個取れる時の最大値
for i in range(R):
# i+1行目に対する操作
# 遷移
for j in range(C):
... | R,C,K=list(map(int,input().split()))
rcv=[list(map(int,input().split())) for _ in range(K)]
mat=[[0]*C for _ in range(R)]
for r,c,v in rcv:
mat[r-1][c-1]=v
dp=[0]*C
for i in range(R):
ndp=[0]*C
wdp=[0]*4
for j in range(C):
wdp[0]=max(wdp[0],dp[j])
if mat[i][j]>0:
v=mat[i][j]
wdp... | 33 | 19 | 918 | 463 | import sys
input = sys.stdin.readline
def main(R, C, K, rcv):
inf = float("inf")
dp0 = [[-inf, -inf, -inf, 0] for _ in range(C)]
item = [[0] * C for _ in range(R)]
for r, c, v in rcv:
item[r - 1][c - 1] = v
# dp0[c][j]:c列目の時点で残りちょうどj個取れる時の最大値
for i in range(R):
# i+1行目に対する操作
... | R, C, K = list(map(int, input().split()))
rcv = [list(map(int, input().split())) for _ in range(K)]
mat = [[0] * C for _ in range(R)]
for r, c, v in rcv:
mat[r - 1][c - 1] = v
dp = [0] * C
for i in range(R):
ndp = [0] * C
wdp = [0] * 4
for j in range(C):
wdp[0] = max(wdp[0], dp[j])
if ma... | false | 42.424242 | [
"-import sys",
"-",
"-input = sys.stdin.readline",
"-",
"-",
"-def main(R, C, K, rcv):",
"- inf = float(\"inf\")",
"- dp0 = [[-inf, -inf, -inf, 0] for _ in range(C)]",
"- item = [[0] * C for _ in range(R)]",
"- for r, c, v in rcv:",
"- item[r - 1][c - 1] = v",
"- # dp0[c]... | false | 0.174085 | 0.037072 | 4.695819 | [
"s292150125",
"s535890768"
] |
u852690916 | p03559 | python | s074818728 | s184914780 | 478 | 317 | 107,108 | 23,168 | Accepted | Accepted | 33.68 | import bisect
N = int(eval(input()))
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
ans = 0
for b in B:
ai = bisect.bisect_left(A, b)
ci = bisect.bisect_right(C, b)
ans += ai * (N-ci)
#print(b,ai,ci)
print(a... | N=int(eval(input()))
*A,=list(map(int, input().split()))
*B,=list(map(int, input().split()))
*C,=list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
from bisect import bisect_left, bisect_right
for b in B:
ac = bisect_left(A,b)
cc = N - bisect_right(C,b)
ans += ac * cc
print(... | 14 | 16 | 317 | 300 | import bisect
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for b in B:
ai = bisect.bisect_left(A, b)
ci = bisect.bisect_right(C, b)
ans += ai * (N - ci)
# print(b,ai,ci)
print(ans)
| N = int(eval(input()))
(*A,) = list(map(int, input().split()))
(*B,) = list(map(int, input().split()))
(*C,) = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
from bisect import bisect_left, bisect_right
for b in B:
ac = bisect_left(A, b)
cc = N - bisect_right(C, b)
ans += ac * cc
print(... | false | 12.5 | [
"-import bisect",
"+N = int(eval(input()))",
"+(*A,) = list(map(int, input().split()))",
"+(*B,) = list(map(int, input().split()))",
"+(*C,) = list(map(int, input().split()))",
"+A.sort()",
"+B.sort()",
"+C.sort()",
"+ans = 0",
"+from bisect import bisect_left, bisect_right",
"-N = int(eval(inpu... | false | 0.163652 | 0.038302 | 4.272658 | [
"s074818728",
"s184914780"
] |
u940342887 | p03160 | python | s271008341 | s466445724 | 254 | 148 | 53,440 | 20,616 | Accepted | Accepted | 41.73 | # dp[i]: i+1にくるまでにかかったコストの最小値
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N-1):
dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
if i < N-2:
dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]))
print((dp[-1])) | N = int(eval(input()))
h = list(map(int, input().split(" ")))
dp = [float("inf")]*(N)
dp[0] = 0
for i in range(N-1):
dp[i + 1] = min(dp[i + 1], abs(h[i + 1] - h[i]) + dp[i])
if i + 2 < N:
dp[i + 2] = min(dp[i + 2], abs(h[i + 2] - h[i]) + dp[i])
print((dp[-1])) | 10 | 12 | 296 | 282 | # dp[i]: i+1にくるまでにかかったコストの最小値
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N - 1):
dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
if i < N - 2:
dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))
print((dp[-1]))
| N = int(eval(input()))
h = list(map(int, input().split(" ")))
dp = [float("inf")] * (N)
dp[0] = 0
for i in range(N - 1):
dp[i + 1] = min(dp[i + 1], abs(h[i + 1] - h[i]) + dp[i])
if i + 2 < N:
dp[i + 2] = min(dp[i + 2], abs(h[i + 2] - h[i]) + dp[i])
print((dp[-1]))
| false | 16.666667 | [
"-# dp[i]: i+1にくるまでにかかったコストの最小値",
"-h = list(map(int, input().split()))",
"-dp = [float(\"inf\") for _ in range(N)]",
"+h = list(map(int, input().split(\" \")))",
"+dp = [float(\"inf\")] * (N)",
"- dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))",
"- if i < N - 2:",
"- dp[i + 2] ... | false | 0.044528 | 0.042331 | 1.05189 | [
"s271008341",
"s466445724"
] |
u597374218 | p03363 | python | s499767384 | s035799673 | 194 | 144 | 38,676 | 35,712 | Accepted | Accepted | 25.77 | N=int(eval(input()))
A=list(map(int,input().split()))
cumulative_sum=0
count=0
counter={0:1}
for a in A:
cumulative_sum+=a
if cumulative_sum not in counter:
counter[cumulative_sum]=0
count+=counter[cumulative_sum]
counter[cumulative_sum]+=1
print(count) | import itertools
import collections
N=int(eval(input()))
A=list(itertools.accumulate(list(map(int,input().split()))))
count=0
for s in list(collections.Counter(A+[0]).values()):
count+=s*(s-1)//2
print(count) | 12 | 8 | 282 | 201 | N = int(eval(input()))
A = list(map(int, input().split()))
cumulative_sum = 0
count = 0
counter = {0: 1}
for a in A:
cumulative_sum += a
if cumulative_sum not in counter:
counter[cumulative_sum] = 0
count += counter[cumulative_sum]
counter[cumulative_sum] += 1
print(count)
| import itertools
import collections
N = int(eval(input()))
A = list(itertools.accumulate(list(map(int, input().split()))))
count = 0
for s in list(collections.Counter(A + [0]).values()):
count += s * (s - 1) // 2
print(count)
| false | 33.333333 | [
"+import itertools",
"+import collections",
"+",
"-A = list(map(int, input().split()))",
"-cumulative_sum = 0",
"+A = list(itertools.accumulate(list(map(int, input().split()))))",
"-counter = {0: 1}",
"-for a in A:",
"- cumulative_sum += a",
"- if cumulative_sum not in counter:",
"- ... | false | 0.039676 | 0.035114 | 1.129919 | [
"s499767384",
"s035799673"
] |
u063052907 | p03013 | python | s317033016 | s436918174 | 510 | 198 | 460,020 | 13,212 | Accepted | Accepted | 61.18 | N, M = list(map(int, input().split()))
set_a = set([int(eval(input())) for _ in range(M)])
MOD = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 0 if 1 in set_a else 1
for i in range(2, N+1):
dp[i] = 0 if i in set_a else dp[i-1] + dp[i-2]
ans = dp[N] % MOD
print(ans) | N, M = list(map(int, input().split()))
set_a = set([int(eval(input())) for _ in range(M)])
MOD = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 0 if 1 in set_a else 1
for i in range(2, N+1):
dp[i] = 0 if i in set_a else dp[i-1] + dp[i-2]
dp[i] %= MOD
ans = dp[N] % MOD
print(ans) | 12 | 13 | 271 | 289 | N, M = list(map(int, input().split()))
set_a = set([int(eval(input())) for _ in range(M)])
MOD = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 0 if 1 in set_a else 1
for i in range(2, N + 1):
dp[i] = 0 if i in set_a else dp[i - 1] + dp[i - 2]
ans = dp[N] % MOD
print(ans)
| N, M = list(map(int, input().split()))
set_a = set([int(eval(input())) for _ in range(M)])
MOD = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 0 if 1 in set_a else 1
for i in range(2, N + 1):
dp[i] = 0 if i in set_a else dp[i - 1] + dp[i - 2]
dp[i] %= MOD
ans = dp[N] % MOD
print(ans)
| false | 7.692308 | [
"+ dp[i] %= MOD"
] | false | 0.042463 | 0.036909 | 1.150478 | [
"s317033016",
"s436918174"
] |
u678167152 | p02768 | python | s598204475 | s004502386 | 968 | 489 | 47,452 | 38,768 | Accepted | Accepted | 49.48 | n,a,b = [int(i) for i in input().split()]
mod = 10**9+7
def mpow(a,n):
if n == 1:
return a
x = mpow(a,n//2)
ans = x*x%mod
if n%2==1:
ans *= a
return ans
def comb(n,a,b):
if a < b:
s, l = a, b
else:
s, l = b, a
rs = 1
for i in range(s):
rs = rs*(n-i)%mod
rl =... | def comb_mod(n,r):
mod = 10**9+7
ans = 1
for i in range(r):
ans *= n-i
ans %= mod
for i in range(1,r+1):
ans *= pow(i,mod-2,mod)
ans %= mod
return ans
def solve():
n, a, b = list(map(int, input().split()))
mod = 10**9+7
ans = pow(2,n,mod)-co... | 38 | 18 | 690 | 389 | n, a, b = [int(i) for i in input().split()]
mod = 10**9 + 7
def mpow(a, n):
if n == 1:
return a
x = mpow(a, n // 2)
ans = x * x % mod
if n % 2 == 1:
ans *= a
return ans
def comb(n, a, b):
if a < b:
s, l = a, b
else:
s, l = b, a
rs = 1
for i in rang... | def comb_mod(n, r):
mod = 10**9 + 7
ans = 1
for i in range(r):
ans *= n - i
ans %= mod
for i in range(1, r + 1):
ans *= pow(i, mod - 2, mod)
ans %= mod
return ans
def solve():
n, a, b = list(map(int, input().split()))
mod = 10**9 + 7
ans = pow(2, n, mod)... | false | 52.631579 | [
"-n, a, b = [int(i) for i in input().split()]",
"-mod = 10**9 + 7",
"-",
"-",
"-def mpow(a, n):",
"- if n == 1:",
"- return a",
"- x = mpow(a, n // 2)",
"- ans = x * x % mod",
"- if n % 2 == 1:",
"- ans *= a",
"+def comb_mod(n, r):",
"+ mod = 10**9 + 7",
"+ ... | false | 1.473078 | 0.951969 | 1.547402 | [
"s598204475",
"s004502386"
] |
u279546122 | p02362 | python | s574224786 | s947320958 | 1,400 | 550 | 8,900 | 8,624 | Accepted | Accepted | 60.71 | from sys import stdin
from collections import deque
V, E, R = [int(x) for x in stdin.readline().split()]
d = {}
tick = False
INF = float('inf')
for i in range(V):
d[i] = INF
d[R] = 0
weight = {}
st = []
for i in range(1, V+1):
for j in range(E):
if i == 1:
s, t, w = [int(x) f... | from collections import defaultdict
from collections import deque
from sys import stdin
def sp(G,R,V):
d = {}
INF = float('inf')
for i in range(V):
d[i] = INF
d[R] = 0
for i in range(1, V+1):
for ((u, v), c) in list(G.items()):
if d[v] > d[u] + c:
... | 30 | 33 | 719 | 765 | from sys import stdin
from collections import deque
V, E, R = [int(x) for x in stdin.readline().split()]
d = {}
tick = False
INF = float("inf")
for i in range(V):
d[i] = INF
d[R] = 0
weight = {}
st = []
for i in range(1, V + 1):
for j in range(E):
if i == 1:
s, t, w = [int(x) for x in stdin... | from collections import defaultdict
from collections import deque
from sys import stdin
def sp(G, R, V):
d = {}
INF = float("inf")
for i in range(V):
d[i] = INF
d[R] = 0
for i in range(1, V + 1):
for ((u, v), c) in list(G.items()):
if d[v] > d[u] + c:
d[... | false | 9.090909 | [
"+from collections import defaultdict",
"+from collections import deque",
"-from collections import deque",
"+",
"+",
"+def sp(G, R, V):",
"+ d = {}",
"+ INF = float(\"inf\")",
"+ for i in range(V):",
"+ d[i] = INF",
"+ d[R] = 0",
"+ for i in range(1, V + 1):",
"+ ... | false | 0.038486 | 0.085387 | 0.450723 | [
"s574224786",
"s947320958"
] |
u810356688 | p02959 | python | s242304200 | s252153363 | 298 | 179 | 74,596 | 19,376 | Accepted | Accepted | 39.93 | def main():
import sys
input = sys.stdin.readline #文字列をsplit()しない場合s=s[:-2]が必要
n=int(eval(input()))
A=[int(_) for _ in input().split()]
sum_a=sum(A)
B=[int(_) for _ in input().split()]
for i in range(n):
s=max(B[i]-A[i],0)
A[i]-=min(A[i],B[i])
A[i+1]-=min(... | from sys import stdin
def main():
input=stdin.readline
n=int(eval(input()))
A=[int(_) for _ in input().split()]
sum_a=sum(A)
B=[int(_) for _ in input().split()]
for i in range(n):
s=max(B[i]-A[i],0)
A[i]-=min(A[i],B[i])
A[i+1]-=min(A[i+1],s)
print((sum_a... | 16 | 16 | 388 | 361 | def main():
import sys
input = sys.stdin.readline # 文字列をsplit()しない場合s=s[:-2]が必要
n = int(eval(input()))
A = [int(_) for _ in input().split()]
sum_a = sum(A)
B = [int(_) for _ in input().split()]
for i in range(n):
s = max(B[i] - A[i], 0)
A[i] -= min(A[i], B[i])
A[i +... | from sys import stdin
def main():
input = stdin.readline
n = int(eval(input()))
A = [int(_) for _ in input().split()]
sum_a = sum(A)
B = [int(_) for _ in input().split()]
for i in range(n):
s = max(B[i] - A[i], 0)
A[i] -= min(A[i], B[i])
A[i + 1] -= min(A[i + 1], s)
... | false | 0 | [
"+from sys import stdin",
"+",
"+",
"- import sys",
"-",
"- input = sys.stdin.readline # 文字列をsplit()しない場合s=s[:-2]が必要",
"+ input = stdin.readline"
] | false | 0.040256 | 0.03955 | 1.017863 | [
"s242304200",
"s252153363"
] |
u078042885 | p00071 | python | s466805530 | s904394157 | 30 | 20 | 7,608 | 7,604 | Accepted | Accepted | 33.33 | d=[[-3,0],[-2,0],[-1,0],[1,0],[2,0],[3,0],[0,-3],[0,-2],[0,-1],[0,1],[0,2],[0,3]]
def f(x,y,a):
a[y][x]='0'
for dx,dy in d:
if 0<=x+dx<8 and 0<=y+dy<8 and a[y+dy][x+dx]=='1':f(x+dx,y+dy,a)
return a
for i in range(int(eval(input()))):
print(('Data %d:'%(i+1)))
eval(input())
a=[... | def f(x,y,a):
a[y][x]='0'
for dx,dy in [[-3,0],[-2,0],[-1,0],[1,0],[2,0],[3,0],[0,-3],[0,-2],[0,-1],[0,1],[0,2],[0,3]]:
if 0<=x+dx<8 and 0<=y+dy<8 and a[y+dy][x+dx]=='1':f(x+dx,y+dy,a)
return a
for i in range(int(input())):
print('Data %d:'%(i+1))
input()
a=[list(input()) for _... | 12 | 11 | 402 | 397 | d = [
[-3, 0],
[-2, 0],
[-1, 0],
[1, 0],
[2, 0],
[3, 0],
[0, -3],
[0, -2],
[0, -1],
[0, 1],
[0, 2],
[0, 3],
]
def f(x, y, a):
a[y][x] = "0"
for dx, dy in d:
if 0 <= x + dx < 8 and 0 <= y + dy < 8 and a[y + dy][x + dx] == "1":
f(x + dx, y + dy... | def f(x, y, a):
a[y][x] = "0"
for dx, dy in [
[-3, 0],
[-2, 0],
[-1, 0],
[1, 0],
[2, 0],
[3, 0],
[0, -3],
[0, -2],
[0, -1],
[0, 1],
[0, 2],
[0, 3],
]:
if 0 <= x + dx < 8 and 0 <= y + dy < 8 and a[y + dy][... | false | 8.333333 | [
"-d = [",
"- [-3, 0],",
"- [-2, 0],",
"- [-1, 0],",
"- [1, 0],",
"- [2, 0],",
"- [3, 0],",
"- [0, -3],",
"- [0, -2],",
"- [0, -1],",
"- [0, 1],",
"- [0, 2],",
"- [0, 3],",
"-]",
"-",
"-",
"- for dx, dy in d:",
"+ for dx, dy in [",
"+ ... | false | 0.045487 | 0.049896 | 0.911631 | [
"s466805530",
"s904394157"
] |
u977389981 | p03317 | python | s833438109 | s971802150 | 52 | 46 | 13,880 | 13,880 | Accepted | Accepted | 11.54 | n, k = list(map(int, input().split()))
A = [int(i) for i in input().split()]
n -= k
count = 1
while n > 0:
n -= (k - 1)
count += 1
print(count) | n, k = list(map(int, input().split()))
A = [int(i) for i in input().split()]
ans = 1
ans += (n - k) // (k - 1)
if (n - k) % (k - 1) != 0:
ans += 1
print(ans) | 11 | 9 | 162 | 165 | n, k = list(map(int, input().split()))
A = [int(i) for i in input().split()]
n -= k
count = 1
while n > 0:
n -= k - 1
count += 1
print(count)
| n, k = list(map(int, input().split()))
A = [int(i) for i in input().split()]
ans = 1
ans += (n - k) // (k - 1)
if (n - k) % (k - 1) != 0:
ans += 1
print(ans)
| false | 18.181818 | [
"-n -= k",
"-count = 1",
"-while n > 0:",
"- n -= k - 1",
"- count += 1",
"-print(count)",
"+ans = 1",
"+ans += (n - k) // (k - 1)",
"+if (n - k) % (k - 1) != 0:",
"+ ans += 1",
"+print(ans)"
] | false | 0.045282 | 0.039172 | 1.155975 | [
"s833438109",
"s971802150"
] |
u150984829 | p00447 | python | s773622518 | s953822077 | 70 | 50 | 5,904 | 6,096 | Accepted | Accepted | 28.57 | def f(e):
a=list([*map(int,input().split())]for _ in range(int(e)))
s,t=a[0]
b={tuple(map(int,input().split()))for _ in range(int(input()))}
for x,y in b:
for u,v in a[1:]:
if(x+u-s,y+v-t)not in b:break
else:return print(x-s,y-t)
for e in iter(input,'0'):f(e)
| import operator
for e in iter(input,'0'):
target = [[*list(map(int,input().split()))]for _ in[0]*int(e)]
bx, by = min(target)
target = {(x - bx, y - by) for x, y in target}
max_tx = max(list(map(operator.itemgetter(0), target)))
b = {tuple(map(int,input().split()))for _ in[0]*int(eval(input())... | 9 | 16 | 279 | 577 | def f(e):
a = list([*map(int, input().split())] for _ in range(int(e)))
s, t = a[0]
b = {tuple(map(int, input().split())) for _ in range(int(input()))}
for x, y in b:
for u, v in a[1:]:
if (x + u - s, y + v - t) not in b:
break
else:
return print(x... | import operator
for e in iter(input, "0"):
target = [[*list(map(int, input().split()))] for _ in [0] * int(e)]
bx, by = min(target)
target = {(x - bx, y - by) for x, y in target}
max_tx = max(list(map(operator.itemgetter(0), target)))
b = {tuple(map(int, input().split())) for _ in [0] * int(eval(in... | false | 43.75 | [
"-def f(e):",
"- a = list([*map(int, input().split())] for _ in range(int(e)))",
"- s, t = a[0]",
"- b = {tuple(map(int, input().split())) for _ in range(int(input()))}",
"+import operator",
"+",
"+for e in iter(input, \"0\"):",
"+ target = [[*list(map(int, input().split()))] for _ in [0] ... | false | 0.037263 | 0.035569 | 1.047627 | [
"s773622518",
"s953822077"
] |
u282228874 | p03273 | python | s380604442 | s728665769 | 30 | 21 | 4,468 | 3,064 | Accepted | Accepted | 30 | h,w = map(int,input().split())
A = [input() for i in range(h)]
AnsH=[]
for i in range(h):
if "#" in A[i]:
AnsH.append(i)
AnsW=[]
for i in range(w):
c = 0
for j in range(h):
if A[j][i]=="#":
c = 1
if c == 1:
AnsW.append(i)
for i in AnsH:
for j in Ans... | h,w = list(map(int,input().split()))
A = [list(eval(input())) for i in range(h)]
AH = []
AW = []
for i in range(h):
if '#' in A[i]:
AH.append(i)
for j in range(w):
flag = 0
for i in range(h):
if A[i][j]=='#':
flag = 1
if flag:
AW.append(j)
for i in AH:
... | 19 | 19 | 368 | 392 | h, w = map(int, input().split())
A = [input() for i in range(h)]
AnsH = []
for i in range(h):
if "#" in A[i]:
AnsH.append(i)
AnsW = []
for i in range(w):
c = 0
for j in range(h):
if A[j][i] == "#":
c = 1
if c == 1:
AnsW.append(i)
for i in AnsH:
for j in AnsW:
... | h, w = list(map(int, input().split()))
A = [list(eval(input())) for i in range(h)]
AH = []
AW = []
for i in range(h):
if "#" in A[i]:
AH.append(i)
for j in range(w):
flag = 0
for i in range(h):
if A[i][j] == "#":
flag = 1
if flag:
AW.append(j)
for i in AH:
res = [... | false | 0 | [
"-h, w = map(int, input().split())",
"-A = [input() for i in range(h)]",
"-AnsH = []",
"+h, w = list(map(int, input().split()))",
"+A = [list(eval(input())) for i in range(h)]",
"+AH = []",
"+AW = []",
"- AnsH.append(i)",
"-AnsW = []",
"-for i in range(w):",
"- c = 0",
"- for j in... | false | 0.077786 | 0.086109 | 0.90335 | [
"s380604442",
"s728665769"
] |
u614181788 | p02596 | python | s652902975 | s933965592 | 1,910 | 223 | 9,184 | 9,156 | Accepted | Accepted | 88.32 | k = int(eval(input()))
if k%2 == 0:
ans = -1
else:
x = 0
ans = -1
for i in range(10**6+1):
x += 7*pow(10, i, k)
x %= k
if x%k == 0:
ans = i+1
break
print(ans) | k = int(eval(input()))
x = 0
ans = -1
for i in range(10**6+1):
x = 10*x + 7
x %= k
if x == 0:
ans = i+1
break
print(ans)
| 13 | 10 | 228 | 152 | k = int(eval(input()))
if k % 2 == 0:
ans = -1
else:
x = 0
ans = -1
for i in range(10**6 + 1):
x += 7 * pow(10, i, k)
x %= k
if x % k == 0:
ans = i + 1
break
print(ans)
| k = int(eval(input()))
x = 0
ans = -1
for i in range(10**6 + 1):
x = 10 * x + 7
x %= k
if x == 0:
ans = i + 1
break
print(ans)
| false | 23.076923 | [
"-if k % 2 == 0:",
"- ans = -1",
"-else:",
"- x = 0",
"- ans = -1",
"- for i in range(10**6 + 1):",
"- x += 7 * pow(10, i, k)",
"- x %= k",
"- if x % k == 0:",
"- ans = i + 1",
"- break",
"+x = 0",
"+ans = -1",
"+for i in range(10**6 +... | false | 0.389507 | 0.144089 | 2.703234 | [
"s652902975",
"s933965592"
] |
u645250356 | p03363 | python | s346075320 | s252935630 | 1,490 | 867 | 42,172 | 111,668 | Accepted | Accepted | 41.81 | from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def conb(n,r): return math.factorial(n... | from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpl... | 18 | 19 | 613 | 678 | from collections import Counter, defaultdict
import sys, heapq, bisect, math, itertools, string, queue
mod = 10**9 + 7
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
def inpl_str():
return list(sys.stdin.readline().split())
def conb(n, r)... | from collections import Counter, defaultdict
import sys, heapq, bisect, math, itertools, string, queue
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
def inpl_str():
return list(sys.stdin.readlin... | false | 5.263158 | [
"+sys.setrecursionlimit(10**8)",
"+def inpln(n):",
"+ return list(int(sys.stdin.readline()) for i in range(n))",
"+",
"+",
"-cntsum = list(itertools.accumulate(a))",
"+cntsum = list(itertools.accumulate(a)) + [0]",
"- if key == 0:",
"- res += cntcol[key]"
] | false | 0.038586 | 0.045189 | 0.853893 | [
"s346075320",
"s252935630"
] |
u145231176 | p02787 | python | s048179705 | s470864323 | 392 | 219 | 42,348 | 83,976 | Accepted | Accepted | 44.13 | def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(eval(input())) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
from collections import d... | def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(eval(input())) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
... | 41 | 72 | 930 | 1,850 | def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(eval(input())) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
from collections import def... | def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(eval(input())) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
... | false | 43.055556 | [
"+def rand_N(ran1, ran2):",
"+ return random.randint(ran1, ran2)",
"+",
"+",
"+def rand_List(ran1, ran2, rantime):",
"+ return [random.randint(ran1, ran2) for i in range(rantime)]",
"+",
"+",
"+def rand_ints_nodup(ran1, ran2, rantime):",
"+ ns = []",
"+ while len(ns) < rantime:",
"... | false | 0.132749 | 0.07549 | 1.758491 | [
"s048179705",
"s470864323"
] |
u359358631 | p02712 | python | s233467694 | s568616141 | 80 | 65 | 72,668 | 61,860 | Accepted | Accepted | 18.75 | def main():
n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
if i % 3 != 0 and i % 5 != 0:
ans += i
print(ans)
if __name__ == "__main__":
main()
| def main():
n = int(input())
ans = n * (n + 1) // 2 - 3 * (n // 3) * (n // 3 + 1) // 2 - 5 * \
(n // 5) * (n // 5 + 1) // 2 + 15 * (n // 15) * (n // 15 + 1) // 2
print(ans)
if __name__ == "__main__":
main()
| 13 | 11 | 203 | 245 | def main():
n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
if i % 3 != 0 and i % 5 != 0:
ans += i
print(ans)
if __name__ == "__main__":
main()
| def main():
n = int(input())
ans = (
n * (n + 1) // 2
- 3 * (n // 3) * (n // 3 + 1) // 2
- 5 * (n // 5) * (n // 5 + 1) // 2
+ 15 * (n // 15) * (n // 15 + 1) // 2
)
print(ans)
if __name__ == "__main__":
main()
| false | 15.384615 | [
"- n = int(eval(input()))",
"- ans = 0",
"- for i in range(1, n + 1):",
"- if i % 3 != 0 and i % 5 != 0:",
"- ans += i",
"+ n = int(input())",
"+ ans = (",
"+ n * (n + 1) // 2",
"+ - 3 * (n // 3) * (n // 3 + 1) // 2",
"+ - 5 * (n // 5) * (n // ... | false | 0.090121 | 0.094504 | 0.953623 | [
"s233467694",
"s568616141"
] |
u879674287 | p03221 | python | s131809432 | s588505298 | 1,030 | 868 | 49,536 | 35,548 | Accepted | Accepted | 15.73 | debug = 0
"""
N: state num
M: city num
"""
if debug:
N = 2
m = 10
else:
(N, M) = list(map(int, input().split()))
if debug:
p_y_list = [
[1, 30]
,[1, 20]
,[1, 10]
,[1, 3]
,[2, 63]
,[2, 33]
,[2, 23]
,[3, 21]
... | N, M = list(map(int, input().split(' ')))
cities = []
for i in range(M):
p, y = list(map(int, input().split(' ')))
cities.append([p, y, i])
cities = sorted(cities, key=lambda x: x[1])
cities = sorted(cities, key=lambda x: x[0])
p = cities[0][0]
cnt = 1
for i in range(M):
if (cities[i][0] =... | 52 | 27 | 994 | 624 | debug = 0
"""
N: state num
M: city num
"""
if debug:
N = 2
m = 10
else:
(N, M) = list(map(int, input().split()))
if debug:
p_y_list = [
[1, 30],
[1, 20],
[1, 10],
[1, 3],
[2, 63],
[2, 33],
[2, 23],
[3, 21],
[3, 7],
]
city_id_lis... | N, M = list(map(int, input().split(" ")))
cities = []
for i in range(M):
p, y = list(map(int, input().split(" ")))
cities.append([p, y, i])
cities = sorted(cities, key=lambda x: x[1])
cities = sorted(cities, key=lambda x: x[0])
p = cities[0][0]
cnt = 1
for i in range(M):
if cities[i][0] == p:
cities... | false | 48.076923 | [
"-debug = 0",
"-\"\"\"",
"-N: state num",
"-M: city num",
"-\"\"\"",
"-if debug:",
"- N = 2",
"- m = 10",
"-else:",
"- (N, M) = list(map(int, input().split()))",
"-if debug:",
"- p_y_list = [",
"- [1, 30],",
"- [1, 20],",
"- [1, 10],",
"- [1, 3],... | false | 0.040853 | 0.041348 | 0.988016 | [
"s131809432",
"s588505298"
] |
u285891772 | p02730 | python | s982482274 | s636173662 | 156 | 38 | 13,680 | 5,196 | Accepted | Accepted | 75.64 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ... | 41 | 29 | 1,088 | 938 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_... | false | 29.268293 | [
"-import numpy as np",
"-",
"-T = S[: len(S) // 2]",
"-U = S[len(S) // 2 + 1 :]",
"-c = 3",
"-",
"-",
"-def kaibun(L, c):",
"- for i in range(len(L) // 2):",
"- if L[i] != L[-(i + 1)]:",
"- c -= 1",
"- print(\"No\")",
"- exit()",
"-",
"-",
"-k... | false | 0.105456 | 0.037182 | 2.836218 | [
"s982482274",
"s636173662"
] |
u207241407 | p03971 | python | s335165937 | s946133645 | 62 | 42 | 5,108 | 5,108 | Accepted | Accepted | 32.26 | n, a, b = list(map(int, input().split()))
s = eval(input())
ans = ["No"] * n
success = 0
foreigner = 0
for i in range(n):
if s[i] == "a":
ans[i] = "Yes"
success += 1
elif s[i] == "b" and foreigner < b:
ans[i] = "Yes"
success += 1
foreigner += 1
if suc... | import sys
def main():
n, a, b = list(map(int, sys.stdin.readline().split()))
s = sys.stdin.readline().rstrip()
ans = ["No"] * n
success = 0
foreigner = 0
for i in range(n):
if s[i] == "a":
ans[i] = "Yes"
success += 1
elif s[i] == "b" an... | 19 | 28 | 362 | 546 | n, a, b = list(map(int, input().split()))
s = eval(input())
ans = ["No"] * n
success = 0
foreigner = 0
for i in range(n):
if s[i] == "a":
ans[i] = "Yes"
success += 1
elif s[i] == "b" and foreigner < b:
ans[i] = "Yes"
success += 1
foreigner += 1
if success == a + b:
... | import sys
def main():
n, a, b = list(map(int, sys.stdin.readline().split()))
s = sys.stdin.readline().rstrip()
ans = ["No"] * n
success = 0
foreigner = 0
for i in range(n):
if s[i] == "a":
ans[i] = "Yes"
success += 1
elif s[i] == "b" and foreigner < b:
... | false | 32.142857 | [
"-n, a, b = list(map(int, input().split()))",
"-s = eval(input())",
"-ans = [\"No\"] * n",
"-success = 0",
"-foreigner = 0",
"-for i in range(n):",
"- if s[i] == \"a\":",
"- ans[i] = \"Yes\"",
"- success += 1",
"- elif s[i] == \"b\" and foreigner < b:",
"- ans[i] = \"Y... | false | 0.036589 | 0.036136 | 1.012523 | [
"s335165937",
"s946133645"
] |
u539692012 | p02689 | python | s351034349 | s816865296 | 265 | 141 | 20,140 | 44,096 | Accepted | Accepted | 46.79 | n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ans = [1] * n
for _ in range(m):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
if h[a] <= h[b]:
ans[a] = 0
if h[b] <= h[a]:
ans[b] = 0
print((sum(ans)))
| n,*t=list(map(int,open(0).read().split()))
r=[0]+[1]*n
for a,b in zip(t[n+1::2],t[n+2::2]):r[a]&=t[a]>t[b];r[b]&=t[b]>t[a]
print((sum(r))) | 12 | 4 | 268 | 133 | n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ans = [1] * n
for _ in range(m):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
if h[a] <= h[b]:
ans[a] = 0
if h[b] <= h[a]:
ans[b] = 0
print((sum(ans)))
| n, *t = list(map(int, open(0).read().split()))
r = [0] + [1] * n
for a, b in zip(t[n + 1 :: 2], t[n + 2 :: 2]):
r[a] &= t[a] > t[b]
r[b] &= t[b] > t[a]
print((sum(r)))
| false | 66.666667 | [
"-n, m = list(map(int, input().split()))",
"-h = list(map(int, input().split()))",
"-ans = [1] * n",
"-for _ in range(m):",
"- a, b = list(map(int, input().split()))",
"- a -= 1",
"- b -= 1",
"- if h[a] <= h[b]:",
"- ans[a] = 0",
"- if h[b] <= h[a]:",
"- ans[b] = 0",... | false | 0.040874 | 0.040748 | 1.003093 | [
"s351034349",
"s816865296"
] |
u994988729 | p03017 | python | s243504743 | s740425289 | 86 | 18 | 3,572 | 3,572 | Accepted | Accepted | 79.07 | def cd(a, b, c, d, s):
for i in range(b, d + 1):
if s[i] + s[i + 1] == "##":
return "No"
for i in range(a, c + 1):
if s[i] + s[i + 1] == "##":
return "No"
return "Yes"
def dc(a, b, c, d, s):
flag = False
for i in range(b, d + 1):
if s[i]... | N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
if "##" in S[B: D - 1]:
print("No")
exit()
elif "##" in S[A: C - 1]:
print("No")
exit()
if D < C:
if not "..." in S[B - 2: D + 1]:
print("No")
exit()
print("Yes") | 39 | 16 | 860 | 270 | def cd(a, b, c, d, s):
for i in range(b, d + 1):
if s[i] + s[i + 1] == "##":
return "No"
for i in range(a, c + 1):
if s[i] + s[i + 1] == "##":
return "No"
return "Yes"
def dc(a, b, c, d, s):
flag = False
for i in range(b, d + 1):
if s[i] + s[i + 1] =... | N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
if "##" in S[B : D - 1]:
print("No")
exit()
elif "##" in S[A : C - 1]:
print("No")
exit()
if D < C:
if not "..." in S[B - 2 : D + 1]:
print("No")
exit()
print("Yes")
| false | 58.974359 | [
"-def cd(a, b, c, d, s):",
"- for i in range(b, d + 1):",
"- if s[i] + s[i + 1] == \"##\":",
"- return \"No\"",
"- for i in range(a, c + 1):",
"- if s[i] + s[i + 1] == \"##\":",
"- return \"No\"",
"- return \"Yes\"",
"-",
"-",
"-def dc(a, b, c, d, s):... | false | 0.036856 | 0.035539 | 1.037043 | [
"s243504743",
"s740425289"
] |
u994988729 | p02936 | python | s797215505 | s521328105 | 1,921 | 1,300 | 69,992 | 104,472 | Accepted | Accepted | 32.33 | n,q=map(int,input().split())
link=[[] for _ in range(n)]
for _ in range(n-1):
a,b=map(int,input().split())
link[a-1].append(b-1)
under=[[] for i in range(n)]
for i in range(n-1, -1, -1):
l=link[i]
for j in l:
under[i].append(j)
#for i in link:
# print(i)
#print()
#for i in un... | from collections import deque
import sys
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b = list(map(int, input().split()))
edge[a].append(b)
edge[b].append(a)
query = [list(map(int, input().split())) for _ in range(Q)... | 30 | 28 | 555 | 623 | n, q = map(int, input().split())
link = [[] for _ in range(n)]
for _ in range(n - 1):
a, b = map(int, input().split())
link[a - 1].append(b - 1)
under = [[] for i in range(n)]
for i in range(n - 1, -1, -1):
l = link[i]
for j in l:
under[i].append(j)
# for i in link:
# print(i)
# print()
# for... | from collections import deque
import sys
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b = list(map(int, input().split()))
edge[a].append(b)
edge[b].append(a)
query = [list(map(int, input().split())) for _ in range(Q)]
score = ... | false | 6.666667 | [
"-n, q = map(int, input().split())",
"-link = [[] for _ in range(n)]",
"-for _ in range(n - 1):",
"- a, b = map(int, input().split())",
"- link[a - 1].append(b - 1)",
"-under = [[] for i in range(n)]",
"-for i in range(n - 1, -1, -1):",
"- l = link[i]",
"- for j in l:",
"- under... | false | 0.052868 | 0.036045 | 1.466735 | [
"s797215505",
"s521328105"
] |
u054514819 | p03426 | python | s877514159 | s122007966 | 758 | 250 | 116,488 | 105,568 | Accepted | Accepted | 67.02 | import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
H, W, d = mapint()
As = [list(mapint()) for _ in range(H)]
Q = int(eval(input()))
from collections import defaultdict
from itertools import accumulate
from bisect im... | import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
H, W, d = mapint()
As = [list(mapint()) for _ in range(H)]
Q = int(eval(input()))
from collections import defaultdict
dic = {}
for h in range(H):
for w in range... | 34 | 25 | 926 | 593 | import sys
def input():
return sys.stdin.readline().strip()
def mapint():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
H, W, d = mapint()
As = [list(mapint()) for _ in range(H)]
Q = int(eval(input()))
from collections import defaultdict
from itertools import accumulate
from bisect i... | import sys
def input():
return sys.stdin.readline().strip()
def mapint():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
H, W, d = mapint()
As = [list(mapint()) for _ in range(H)]
Q = int(eval(input()))
from collections import defaultdict
dic = {}
for h in range(H):
for w in rang... | false | 26.470588 | [
"-from itertools import accumulate",
"-from bisect import bisect_left",
"-dic = defaultdict(list)",
"+dic = {}",
"- dic[a % d].append((a, h, w))",
"-cost_dic = {}",
"-for m in list(dic.keys()):",
"- dic[m].sort()",
"- sa, sh, sw = dic[m][0]",
"- cost_dic[m] = [0]",
"- for a, h... | false | 0.041524 | 0.055599 | 0.746838 | [
"s877514159",
"s122007966"
] |
u707808519 | p02641 | python | s640094974 | s531880167 | 22 | 20 | 9,176 | 9,168 | Accepted | Accepted | 9.09 | x, n = list(map(int, input().split()))
p = [int(y) for y in input().split()]
for i in range(200):
if x-i not in p:
print((x-i))
break
if x+i not in p:
print((x+i))
break | x, n = list(map(int, input().split()))
p = {int(i) for i in input().split()}
for i in range(55):
if x-i not in p:
print((x-i))
break
if x+i not in p:
print((x+i))
break | 10 | 10 | 209 | 209 | x, n = list(map(int, input().split()))
p = [int(y) for y in input().split()]
for i in range(200):
if x - i not in p:
print((x - i))
break
if x + i not in p:
print((x + i))
break
| x, n = list(map(int, input().split()))
p = {int(i) for i in input().split()}
for i in range(55):
if x - i not in p:
print((x - i))
break
if x + i not in p:
print((x + i))
break
| false | 0 | [
"-p = [int(y) for y in input().split()]",
"-for i in range(200):",
"+p = {int(i) for i in input().split()}",
"+for i in range(55):"
] | false | 0.032409 | 0.041991 | 0.771802 | [
"s640094974",
"s531880167"
] |
u254871849 | p03353 | python | s567186658 | s885893620 | 34 | 31 | 4,464 | 4,464 | Accepted | Accepted | 8.82 | import sys
s = sys.stdin.readline().rstrip()
k = int(sys.stdin.readline().rstrip())
n = len(s)
def main():
res = set()
for l in range(n):
for r in range(l, min(l+k, n)):
res.add(s[l:r+1])
return sorted(res)[k-1]
if __name__ == '__main__':
ans = main()
print(an... | import sys
s, k = sys.stdin.read().split()
k = int(k)
def main():
cand = set()
for j in range(1, k + 1):
for i in range(len(s) - j + 1):
cand.add(s[i:i+j])
print((sorted(cand)[k-1]))
if __name__ == '__main__':
main() | 17 | 14 | 322 | 267 | import sys
s = sys.stdin.readline().rstrip()
k = int(sys.stdin.readline().rstrip())
n = len(s)
def main():
res = set()
for l in range(n):
for r in range(l, min(l + k, n)):
res.add(s[l : r + 1])
return sorted(res)[k - 1]
if __name__ == "__main__":
ans = main()
print(ans)
| import sys
s, k = sys.stdin.read().split()
k = int(k)
def main():
cand = set()
for j in range(1, k + 1):
for i in range(len(s) - j + 1):
cand.add(s[i : i + j])
print((sorted(cand)[k - 1]))
if __name__ == "__main__":
main()
| false | 17.647059 | [
"-s = sys.stdin.readline().rstrip()",
"-k = int(sys.stdin.readline().rstrip())",
"-n = len(s)",
"+s, k = sys.stdin.read().split()",
"+k = int(k)",
"- res = set()",
"- for l in range(n):",
"- for r in range(l, min(l + k, n)):",
"- res.add(s[l : r + 1])",
"- return sorted(... | false | 0.037927 | 0.039292 | 0.965259 | [
"s567186658",
"s885893620"
] |
u402629484 | p03111 | python | s220385824 | s486168825 | 249 | 72 | 3,064 | 3,064 | Accepted | Accepted | 71.08 | N,A,B,C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(N)]
INF = 1<<20
score = INF
import itertools
for ms in itertools.product(list(range(-1,3)), repeat=N):
lens = [0]*3
tmp_score = -30
for i, group in enumerate(ms):
if group>=0:
lens[group] += l[... | def main():
N,A,B,C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(N)]
INF = 1<<20
def perm(n, a, b, c):
if n == N:
if all([a, b, c]):
return abs(A-a)+abs(B-b)+abs(C-c)-30
else:
return INF
... | 18 | 22 | 455 | 524 | N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(N)]
INF = 1 << 20
score = INF
import itertools
for ms in itertools.product(list(range(-1, 3)), repeat=N):
lens = [0] * 3
tmp_score = -30
for i, group in enumerate(ms):
if group >= 0:
lens[group] += l[i]
... | def main():
N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(N)]
INF = 1 << 20
def perm(n, a, b, c):
if n == N:
if all([a, b, c]):
return abs(A - a) + abs(B - b) + abs(C - c) - 30
else:
return INF
... | false | 18.181818 | [
"-N, A, B, C = list(map(int, input().split()))",
"-l = [int(eval(input())) for _ in range(N)]",
"-INF = 1 << 20",
"-score = INF",
"-import itertools",
"+def main():",
"+ N, A, B, C = list(map(int, input().split()))",
"+ l = [int(eval(input())) for _ in range(N)]",
"+ INF = 1 << 20",
"-for... | false | 0.274589 | 0.077786 | 3.53007 | [
"s220385824",
"s486168825"
] |
u691018832 | p02687 | python | s053441601 | s614933009 | 64 | 21 | 61,516 | 9,032 | Accepted | Accepted | 67.19 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
s = readline().rstrip().decode()
if s[1] == 'B':
print('ARC')
else:
print('ABC')
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
s = read().rstrip().decode()
if s[1] == 'B':
print('ARC')
else:
print('ABC')
| 11 | 11 | 247 | 243 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
s = readline().rstrip().decode()
if s[1] == "B":
print("ARC")
else:
print("ABC")
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
s = read().rstrip().decode()
if s[1] == "B":
print("ARC")
else:
print("ABC")
| false | 0 | [
"-s = readline().rstrip().decode()",
"+s = read().rstrip().decode()"
] | false | 0.0412 | 0.040429 | 1.019073 | [
"s053441601",
"s614933009"
] |
u163320134 | p02948 | python | s618138469 | s676853381 | 780 | 696 | 44,996 | 43,664 | Accepted | Accepted | 10.77 | import heapq
n,m=list(map(int,input().split()))
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[[i,0] for i in range(1,m+2)]
arr.extend(arr2)
arr=sorted(arr,reverse=True,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
q=[]
ans=0
pos=0
while 1:
a,b=arr[pos]
if a>m:
break
if a=... | import heapq
n,m=list(map(int,input().split()))
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[[i,0] for i in range(1,m+2)]
arr.extend(arr2)
arr=sorted(arr,key=lambda x:x[0])
q=[]
ans=0
pos=0
while 1:
a,b=arr[pos]
if a>m:
break
if a==arr[pos+1][0]:
heapq.heappush(q,-b)
els... | 22 | 21 | 439 | 391 | import heapq
n, m = list(map(int, input().split()))
arr = [list(map(int, input().split())) for _ in range(n)]
arr2 = [[i, 0] for i in range(1, m + 2)]
arr.extend(arr2)
arr = sorted(arr, reverse=True, key=lambda x: x[1])
arr = sorted(arr, key=lambda x: x[0])
q = []
ans = 0
pos = 0
while 1:
a, b = arr[pos]
if a ... | import heapq
n, m = list(map(int, input().split()))
arr = [list(map(int, input().split())) for _ in range(n)]
arr2 = [[i, 0] for i in range(1, m + 2)]
arr.extend(arr2)
arr = sorted(arr, key=lambda x: x[0])
q = []
ans = 0
pos = 0
while 1:
a, b = arr[pos]
if a > m:
break
if a == arr[pos + 1][0]:
... | false | 4.545455 | [
"-arr = sorted(arr, reverse=True, key=lambda x: x[1])"
] | false | 0.03594 | 0.097476 | 0.368712 | [
"s618138469",
"s676853381"
] |
u680851063 | p03712 | python | s242794380 | s968070590 | 19 | 17 | 3,060 | 3,060 | Accepted | Accepted | 10.53 | h,w = list(map(int, input().split()))
l = [eval(input()) for _ in range(h)]
l.insert(0,'#'*(w+2))
l.append('#'*(w+2))
for i in range(1,h+1):
x = list(l.pop(i))
x.insert(0,'#')
x.append('#')
l.insert(i,''.join(x))
for j in range(h+2):
print((l[j]))
| h,w = list(map(int, input().split()))
l = [eval(input()) for _ in range(h)]
l.insert(0,'#'*(w+2))
l.append('#'*(w+2))
for i in range(1,h+1):
l[i] = '#' +l[i] + '#'
for j in range(h+2):
print((l[j]))
| 13 | 10 | 268 | 204 | h, w = list(map(int, input().split()))
l = [eval(input()) for _ in range(h)]
l.insert(0, "#" * (w + 2))
l.append("#" * (w + 2))
for i in range(1, h + 1):
x = list(l.pop(i))
x.insert(0, "#")
x.append("#")
l.insert(i, "".join(x))
for j in range(h + 2):
print((l[j]))
| h, w = list(map(int, input().split()))
l = [eval(input()) for _ in range(h)]
l.insert(0, "#" * (w + 2))
l.append("#" * (w + 2))
for i in range(1, h + 1):
l[i] = "#" + l[i] + "#"
for j in range(h + 2):
print((l[j]))
| false | 23.076923 | [
"- x = list(l.pop(i))",
"- x.insert(0, \"#\")",
"- x.append(\"#\")",
"- l.insert(i, \"\".join(x))",
"+ l[i] = \"#\" + l[i] + \"#\""
] | false | 0.038021 | 0.039049 | 0.973661 | [
"s242794380",
"s968070590"
] |
u391875425 | p03137 | python | s502400613 | s467021709 | 234 | 113 | 22,980 | 13,960 | Accepted | Accepted | 51.71 | import numpy as np
n,m = list(map(int,input().split()))
x = np.array(list(map(int, input().split())))
if n>= m:
print((0))
exit()
x.sort()
xd = sorted(np.diff(x))
print((sum(xd[:m-n]))) | n, m = list(map(int,input().split()))
x = sorted(list(map(int, input().split())))
if n >= m:
print((0))
exit()
xd = []
for i in range(m-1):
xd.append(x[i+1]-x[i])
xd.sort()
print((sum(xd[:m-n]))) | 9 | 10 | 191 | 206 | import numpy as np
n, m = list(map(int, input().split()))
x = np.array(list(map(int, input().split())))
if n >= m:
print((0))
exit()
x.sort()
xd = sorted(np.diff(x))
print((sum(xd[: m - n])))
| n, m = list(map(int, input().split()))
x = sorted(list(map(int, input().split())))
if n >= m:
print((0))
exit()
xd = []
for i in range(m - 1):
xd.append(x[i + 1] - x[i])
xd.sort()
print((sum(xd[: m - n])))
| false | 10 | [
"-import numpy as np",
"-",
"-x = np.array(list(map(int, input().split())))",
"+x = sorted(list(map(int, input().split())))",
"-x.sort()",
"-xd = sorted(np.diff(x))",
"+xd = []",
"+for i in range(m - 1):",
"+ xd.append(x[i + 1] - x[i])",
"+xd.sort()"
] | false | 0.254856 | 0.036184 | 7.043323 | [
"s502400613",
"s467021709"
] |
u455809703 | p02708 | python | s556594961 | s942599623 | 59 | 20 | 9,164 | 9,116 | Accepted | Accepted | 66.1 | N, K = list(map(int, input().split()))
ans = 0
for i in range(K, N+2):
ans += i*(N-i+1)+1
print((ans%1000000007)) | N, K = list(map(int, input().split()))
print((int(((N*(N+1)*(N+2) - K*(K-1)*(3*N-2*K+4))/6 + N - K + 2)%1000000007))) | 6 | 3 | 115 | 112 | N, K = list(map(int, input().split()))
ans = 0
for i in range(K, N + 2):
ans += i * (N - i + 1) + 1
print((ans % 1000000007))
| N, K = list(map(int, input().split()))
print(
(
int(
(
(N * (N + 1) * (N + 2) - K * (K - 1) * (3 * N - 2 * K + 4)) / 6
+ N
- K
+ 2
)
% 1000000007
)
)
)
| false | 50 | [
"-ans = 0",
"-for i in range(K, N + 2):",
"- ans += i * (N - i + 1) + 1",
"-print((ans % 1000000007))",
"+print(",
"+ (",
"+ int(",
"+ (",
"+ (N * (N + 1) * (N + 2) - K * (K - 1) * (3 * N - 2 * K + 4)) / 6",
"+ + N",
"+ - K",
... | false | 0.054736 | 0.086921 | 0.629717 | [
"s556594961",
"s942599623"
] |
u138013242 | p03295 | python | s558924439 | s266683537 | 774 | 662 | 60,376 | 56,964 | Accepted | Accepted | 14.47 | """
区間スケジューリング
終端で降順にソートすれば良い
"""
n, m=list(map(int, input().split()))
hope=[]
for i in range(m):
a, b=list(map(int, input().split()))
hope.append((a, b))
hope.sort(reverse=True, key=lambda x: x[0])
hope.sort(reverse=True, key=lambda x: x[1])
ans=0
for i in range(m-1):
if i==0:
target=... | """
区間スケジューリング
終端で降順にソートすれば良い
最適解は,貪欲法で,1つ次の区間を通るように串刺すこと
終端で降順にソートしているので,1本で区間を刺せる条件はi<jのとき,a[i]<b[j]
さらにその後,刺せる範囲が狭まる場合(a[i]>b[i])は,狭めて次の区間に行く
"""
n, m=list(map(int, input().split()))
hope=[]
for i in range(m):
a, b=list(map(int, input().split()))
hope.append((a, b))
hope.sort(reverse=True, key=la... | 22 | 24 | 487 | 560 | """
区間スケジューリング
終端で降順にソートすれば良い
"""
n, m = list(map(int, input().split()))
hope = []
for i in range(m):
a, b = list(map(int, input().split()))
hope.append((a, b))
hope.sort(reverse=True, key=lambda x: x[0])
hope.sort(reverse=True, key=lambda x: x[1])
ans = 0
for i in range(m - 1):
if i == 0:
target = ... | """
区間スケジューリング
終端で降順にソートすれば良い
最適解は,貪欲法で,1つ次の区間を通るように串刺すこと
終端で降順にソートしているので,1本で区間を刺せる条件はi<jのとき,a[i]<b[j]
さらにその後,刺せる範囲が狭まる場合(a[i]>b[i])は,狭めて次の区間に行く
"""
n, m = list(map(int, input().split()))
hope = []
for i in range(m):
a, b = list(map(int, input().split()))
hope.append((a, b))
hope.sort(reverse=True, key=lambda x... | false | 8.333333 | [
"+最適解は,貪欲法で,1つ次の区間を通るように串刺すこと",
"+終端で降順にソートしているので,1本で区間を刺せる条件はi<jのとき,a[i]<b[j]",
"+さらにその後,刺せる範囲が狭まる場合(a[i]>b[i])は,狭めて次の区間に行く",
"-hope.sort(reverse=True, key=lambda x: x[0])"
] | false | 0.170495 | 0.034967 | 4.875925 | [
"s558924439",
"s266683537"
] |
u761320129 | p03372 | python | s847536638 | s553129817 | 623 | 303 | 32,704 | 45,428 | Accepted | Accepted | 51.36 | N,C = list(map(int,input().split()))
src = [tuple(map(int,input().split())) for i in range(N)]
cumsumr = [0]
cummaxr = [0]
cummaxr2 = [0]
px = 0
for x,v in src:
cumsumr.append(cumsumr[-1] + v-(x-px))
cummaxr.append(max(cummaxr[-1], cumsumr[-1]))
cummaxr2.append(max(cummaxr2[-1], cumsumr[-1]-x))
... | import sys
input = sys.stdin.readline
N,C = list(map(int,input().split()))
XV = [tuple(map(int,input().split())) for i in range(N)]
rcum1 = [0]
rcum2 = [0]
rcummx = [0]
px = 0
for x,v in XV:
d = x - px
rcum1.append(rcum1[-1] + v - d)
rcum2.append(rcum2[-1] + v - 2*d)
rcummx.append(max(rcum... | 28 | 36 | 736 | 780 | N, C = list(map(int, input().split()))
src = [tuple(map(int, input().split())) for i in range(N)]
cumsumr = [0]
cummaxr = [0]
cummaxr2 = [0]
px = 0
for x, v in src:
cumsumr.append(cumsumr[-1] + v - (x - px))
cummaxr.append(max(cummaxr[-1], cumsumr[-1]))
cummaxr2.append(max(cummaxr2[-1], cumsumr[-1] - x))
... | import sys
input = sys.stdin.readline
N, C = list(map(int, input().split()))
XV = [tuple(map(int, input().split())) for i in range(N)]
rcum1 = [0]
rcum2 = [0]
rcummx = [0]
px = 0
for x, v in XV:
d = x - px
rcum1.append(rcum1[-1] + v - d)
rcum2.append(rcum2[-1] + v - 2 * d)
rcummx.append(max(rcummx[-1],... | false | 22.222222 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"-src = [tuple(map(int, input().split())) for i in range(N)]",
"-cumsumr = [0]",
"-cummaxr = [0]",
"-cummaxr2 = [0]",
"+XV = [tuple(map(int, input().split())) for i in range(N)]",
"+rcum1 = [0]",
"+rcum2 = [0]",
"+rcummx = [0]",
"-for x, v in ... | false | 0.054141 | 0.063253 | 0.855953 | [
"s847536638",
"s553129817"
] |
u741801763 | p01314 | python | s537196587 | s579346266 | 310 | 190 | 7,796 | 7,640 | Accepted | Accepted | 38.71 | if __name__ == "__main__":
while True:
n = int(eval(input()))
if n ==0:break
nline = [i for i in range(1,n+1)]
count = 0
for i in range(n):
for j in range(i+1,n):
if sum(nline[i:j]) > n:break
if sum(nline[i:j]) == n:count ... | if __name__ == "__main__":
while True:
n = int(eval(input()))
if n ==0:break
count = 0
for i in range(1,n):
for j in range(i+1,n):
sum = (i+j)*(j-i+1)/2
if sum> n:break
if sum == n:count +=1
print(count) | 12 | 12 | 341 | 313 | if __name__ == "__main__":
while True:
n = int(eval(input()))
if n == 0:
break
nline = [i for i in range(1, n + 1)]
count = 0
for i in range(n):
for j in range(i + 1, n):
if sum(nline[i:j]) > n:
break
... | if __name__ == "__main__":
while True:
n = int(eval(input()))
if n == 0:
break
count = 0
for i in range(1, n):
for j in range(i + 1, n):
sum = (i + j) * (j - i + 1) / 2
if sum > n:
break
if su... | false | 0 | [
"- nline = [i for i in range(1, n + 1)]",
"- for i in range(n):",
"+ for i in range(1, n):",
"- if sum(nline[i:j]) > n:",
"+ sum = (i + j) * (j - i + 1) / 2",
"+ if sum > n:",
"- if sum(nline[i:j]) == n:",
"+ ... | false | 0.09366 | 0.091974 | 1.018322 | [
"s537196587",
"s579346266"
] |
u968166680 | p02901 | python | s958052222 | s997421842 | 116 | 107 | 74,396 | 68,496 | Accepted | Accepted | 7.76 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, M = list(map(int, readline().split()))
A = [0] * M
C = [0] * M
for i in range(M):
A[i], b = list(map(int, ... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, M = list(map(int, readline().split()))
A = [0] * M
C = [0] * M
for i in range(M):
A[i], b = list(map(int, ... | 35 | 35 | 752 | 751 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
N, M = list(map(int, readline().split()))
A = [0] * M
C = [0] * M
for i in range(M):
A[i], b = list(map(int, readline().split(... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
N, M = list(map(int, readline().split()))
A = [0] * M
C = [0] * M
for i in range(M):
A[i], b = list(map(int, readline().split(... | false | 0 | [
"- C[i] = sum(1 << (int(s) - 1) for s in readline().split())",
"+ C[i] = ~sum(1 << (int(s) - 1) for s in readline().split())",
"- if dp[bit & ~c] < INF:",
"- dp[bit] = min(dp[bit], dp[bit & ~c] + a)",
"+ if dp[bit & c] < INF:",
"+ dp[bit] =... | false | 0.042925 | 0.041269 | 1.040112 | [
"s958052222",
"s997421842"
] |
u509739538 | p03373 | python | s977757747 | s228199161 | 354 | 138 | 3,952 | 4,080 | Accepted | Accepted | 61.02 | import math
import queue
from collections import defaultdict
def readInt():
return int(eval(input()))
def readInts():
return list(map(int, input().split()))
def readChar():
return eval(input())
def readChars():
return input().split()
def factorization(n):
res = []
if n%2==0:
res.append(2)
for... | import math
import queue
from collections import defaultdict
def readInt():
return int(eval(input()))
def readInts():
return list(map(int, input().split()))
def readChar():
return eval(input())
def readChars():
return input().split()
def factorization(n):
res = []
if n%2==0:
res.append(2)
for... | 144 | 134 | 2,616 | 2,390 | import math
import queue
from collections import defaultdict
def readInt():
return int(eval(input()))
def readInts():
return list(map(int, input().split()))
def readChar():
return eval(input())
def readChars():
return input().split()
def factorization(n):
res = []
if n % 2 == 0:
... | import math
import queue
from collections import defaultdict
def readInt():
return int(eval(input()))
def readInts():
return list(map(int, input().split()))
def readChar():
return eval(input())
def readChars():
return input().split()
def factorization(n):
res = []
if n % 2 == 0:
... | false | 6.944444 | [
"-for i in range(0, x + 1):",
"- B = max(y - (x - i), 0)",
"- AB = max(2 * (x - i), 0)",
"- money = i * a + B * b + AB * c",
"- ans = min(ans, money)",
"-for i in range(0, y + 1):",
"- A = max(x - (y - i), 0)",
"- AB = max(2 * (y - i), 0)",
"- money = A * a + b * i + AB * c",
... | false | 0.046773 | 0.060694 | 0.770627 | [
"s977757747",
"s228199161"
] |
u968166680 | p02814 | python | s148548390 | s969096007 | 559 | 68 | 16,104 | 16,108 | Accepted | Accepted | 87.84 | import sys
from fractions import gcd
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
def lcm(a, b):
return a // gcd(a, b) * b
def main():
N, M, *A = list(map(int, read().split()))
A = [a // 2 for a in A]
... | import sys
from fractions import gcd
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
def lcm(a, b):
return a * b // gcd(a, b)
def main():
N, M, *A = list(map(int, read().split()))
A = list({a // 2 for a in ... | 42 | 42 | 727 | 733 | import sys
from fractions import gcd
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
def lcm(a, b):
return a // gcd(a, b) * b
def main():
N, M, *A = list(map(int, read().split()))
A = [a // 2 for a in A]
power = 1
wh... | import sys
from fractions import gcd
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
def lcm(a, b):
return a * b // gcd(a, b)
def main():
N, M, *A = list(map(int, read().split()))
A = list({a // 2 for a in A})
power = 1
... | false | 0 | [
"- return a // gcd(a, b) * b",
"+ return a * b // gcd(a, b)",
"- A = [a // 2 for a in A]",
"+ A = list({a // 2 for a in A})"
] | false | 0.085876 | 0.052243 | 1.64376 | [
"s148548390",
"s969096007"
] |
u013629972 | p03013 | python | s822625615 | s962987502 | 480 | 364 | 54,940 | 79,316 | Accepted | Accepted | 24.17 | # -*- coding: utf-8 -*-
import sys
mod = 10 ** 9 + 7
def get_nums(n):
res = [0 for _ in range(n)]
for i in range(n):
res[i] = int(eval(input()))
return res
def get_numbers():
return list(map(int, input().split()))
n, m = get_numbers()
a = set(get_nums(m))
dp = [0 for _ ... | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
d... | 30 | 66 | 494 | 1,799 | # -*- coding: utf-8 -*-
import sys
mod = 10**9 + 7
def get_nums(n):
res = [0 for _ in range(n)]
for i in range(n):
res[i] = int(eval(input()))
return res
def get_numbers():
return list(map(int, input().split()))
n, m = get_numbers()
a = set(get_nums(m))
dp = [0 for _ in range(n + 1)]
dp[0... | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI... | false | 54.545455 | [
"-# -*- coding: utf-8 -*-",
"-import sys",
"+import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools",
"+sys.setrecursionlimit(10**7)",
"+inf = 10**20",
"+eps = 1.0 / 10**10",
"+dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]",
"+ddn = [(-1, 0), (-1... | false | 0.116023 | 0.181658 | 0.638686 | [
"s822625615",
"s962987502"
] |
u585482323 | p04046 | python | s921971259 | s727928694 | 386 | 224 | 53,232 | 44,524 | Accepted | Accepted | 41.97 | #!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))... | #!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))... | 93 | 88 | 1,374 | 1,398 | #!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI():
return list(map(int, sys.stdin.readline().split()))
def I():
return int(sys.stdin.readline())
def LS():
return list(map(list, sys.stdin.readline().... | #!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI():
return list(map(int, sys.stdin.readline().split()))
def I():
return int(sys.stdin.readline())
def LS():
return list(map(list, sys.stdin.readline().... | false | 5.376344 | [
"+def f(x, y):",
"+ return (",
"+ fact[x - 1 + h - y]",
"+ * fact[y - 1 + w - x]",
"+ * inv_fact[x - 1]",
"+ * inv_fact[y - 1]",
"+ * inv_fact[w - x]",
"+ * inv_fact[h - y]",
"+ % mod",
"+ )",
"+",
"+",
"+fact = [1] * (h + w + 1)",
"+f... | false | 0.046327 | 0.091415 | 0.50678 | [
"s921971259",
"s727928694"
] |
u691501673 | p02837 | python | s945029893 | s711133489 | 492 | 244 | 3,064 | 44,140 | Accepted | Accepted | 50.41 | N = int(eval(input()))
# 証言者ごとに整理する
testimony_list = []
for i in range(N):
array = [-1] * N
testimony_list.append(array)
for i in range(N):
A = int(eval(input()))
for j in range(A):
x, y = list(map(int, input().split()))
# iさんの、xさんへの証言
testimony_list[i][x - 1] = y
... | N = int(eval(input()))
# 証言者ごとに整理する
testimony_list = []
for i in range(N):
array = [-1] * N
testimony_list.append(array)
for i in range(N):
A = int(eval(input()))
for j in range(A):
x, y = list(map(int, input().split()))
# iさんの、xさんへの証言
testimony_list[i][x - 1] = y
... | 28 | 31 | 718 | 823 | N = int(eval(input()))
# 証言者ごとに整理する
testimony_list = []
for i in range(N):
array = [-1] * N
testimony_list.append(array)
for i in range(N):
A = int(eval(input()))
for j in range(A):
x, y = list(map(int, input().split()))
# iさんの、xさんへの証言
testimony_list[i][x - 1] = y
max_count = 0
f... | N = int(eval(input()))
# 証言者ごとに整理する
testimony_list = []
for i in range(N):
array = [-1] * N
testimony_list.append(array)
for i in range(N):
A = int(eval(input()))
for j in range(A):
x, y = list(map(int, input().split()))
# iさんの、xさんへの証言
testimony_list[i][x - 1] = y
max_count = 0
f... | false | 9.677419 | [
"- if array[k] != -1 and (i >> k & 1) != array[k]:",
"+ if array[k] == -1:",
"+ continue",
"+ if (i >> k & 1) != array[k]: # 正直者に対して不親切 or 不親切に対して正直者と証言",
"- if failed is False:",
"+ if not failed:",
"+ # 「0b010110」の「0b」を除外して1の数をカウント"
] | false | 0.078857 | 0.077205 | 1.021406 | [
"s945029893",
"s711133489"
] |
u020962106 | p03524 | python | s707748537 | s302064391 | 25 | 18 | 3,444 | 3,188 | Accepted | Accepted | 28 | from collections import Counter
s = eval(input())
dic = dict(Counter(s))
if len(dic)==1:
for v in list(dic.values()):
if v==1:
print('YES')
else:
print('NO')
elif len(dic)==2:
for v in list(dic.values()):
if v>=2:
print('NO')
b... | s = eval(input())
na = s.count('a')
nb = s.count('b')
nc = len(s) - na - nb
if max(na,nb,nc)-min(na,nb,nc)<=1:
print('YES')
else:
print('NO') | 30 | 8 | 633 | 150 | from collections import Counter
s = eval(input())
dic = dict(Counter(s))
if len(dic) == 1:
for v in list(dic.values()):
if v == 1:
print("YES")
else:
print("NO")
elif len(dic) == 2:
for v in list(dic.values()):
if v >= 2:
print("NO")
break... | s = eval(input())
na = s.count("a")
nb = s.count("b")
nc = len(s) - na - nb
if max(na, nb, nc) - min(na, nb, nc) <= 1:
print("YES")
else:
print("NO")
| false | 73.333333 | [
"-from collections import Counter",
"-",
"-dic = dict(Counter(s))",
"-if len(dic) == 1:",
"- for v in list(dic.values()):",
"- if v == 1:",
"- print(\"YES\")",
"- else:",
"- print(\"NO\")",
"-elif len(dic) == 2:",
"- for v in list(dic.values()):",
"- ... | false | 0.050189 | 0.008466 | 5.928312 | [
"s707748537",
"s302064391"
] |
u777923818 | p03639 | python | s157649041 | s199443928 | 85 | 65 | 14,252 | 14,636 | Accepted | Accepted | 23.53 | # -*- coding: utf-8 -*-
N = int(eval(input()))
A = [int(n) for n in input().split()]
x2 = sum([a%2!=0 for a in A])
o2x4 = sum([(a%2==0)&(a%4!=0) for a in A])
o4 = sum([a%4==0 for a in A])
if o2x4 == 0:
if o4 + 1 >= x2:
print("Yes")
else:
print("No")
else:
if o4 >= x2:
... | # -*- coding: utf-8 -*-
from collections import Counter
def inpl(): return list(map(int, input().split()))
N = int(eval(input()))
a, b, c = 0, 0, 0
for x in inpl():
if x%4 == 0:
a += 1
elif x%2 == 0:
b += 1
else:
c += 1
if a+(b==0) >= c:
print("Yes")
else:
... | 19 | 18 | 362 | 325 | # -*- coding: utf-8 -*-
N = int(eval(input()))
A = [int(n) for n in input().split()]
x2 = sum([a % 2 != 0 for a in A])
o2x4 = sum([(a % 2 == 0) & (a % 4 != 0) for a in A])
o4 = sum([a % 4 == 0 for a in A])
if o2x4 == 0:
if o4 + 1 >= x2:
print("Yes")
else:
print("No")
else:
if o4 >= x2:
... | # -*- coding: utf-8 -*-
from collections import Counter
def inpl():
return list(map(int, input().split()))
N = int(eval(input()))
a, b, c = 0, 0, 0
for x in inpl():
if x % 4 == 0:
a += 1
elif x % 2 == 0:
b += 1
else:
c += 1
if a + (b == 0) >= c:
print("Yes")
else:
pri... | false | 5.263158 | [
"+from collections import Counter",
"+",
"+",
"+def inpl():",
"+ return list(map(int, input().split()))",
"+",
"+",
"-A = [int(n) for n in input().split()]",
"-x2 = sum([a % 2 != 0 for a in A])",
"-o2x4 = sum([(a % 2 == 0) & (a % 4 != 0) for a in A])",
"-o4 = sum([a % 4 == 0 for a in A])",
... | false | 0.109685 | 0.046082 | 2.380224 | [
"s157649041",
"s199443928"
] |
u039623862 | p03830 | python | s372106862 | s595677399 | 112 | 28 | 3,572 | 3,440 | Accepted | Accepted | 75 | import collections
MOD = (10 ** 9 + 7)
n = int(eval(input()))
p = [True for i in range(n+1)]
p[0] = False
p[1] = False
pf = collections.defaultdict(int)
for i in range(2, n+1):
if not p[i]:
continue
j = i * i
while j <= n:
p[j] = False
j += i
cnt = 1
v = i
... | import collections
MOD = 10**9+7
def list_prime(n):
if n < 2:
return []
elif n == 2:
return [2]
is_prime = [True for i in range(n+1)]
is_prime[0] = False
is_prime[1] = False
for i in range(2, n):
for j in range(i*i, n+1, i):
is_prime[j] = False
... | 27 | 33 | 467 | 683 | import collections
MOD = 10**9 + 7
n = int(eval(input()))
p = [True for i in range(n + 1)]
p[0] = False
p[1] = False
pf = collections.defaultdict(int)
for i in range(2, n + 1):
if not p[i]:
continue
j = i * i
while j <= n:
p[j] = False
j += i
cnt = 1
v = i
while v <= n:
... | import collections
MOD = 10**9 + 7
def list_prime(n):
if n < 2:
return []
elif n == 2:
return [2]
is_prime = [True for i in range(n + 1)]
is_prime[0] = False
is_prime[1] = False
for i in range(2, n):
for j in range(i * i, n + 1, i):
is_prime[j] = False
... | false | 18.181818 | [
"+",
"+",
"+def list_prime(n):",
"+ if n < 2:",
"+ return []",
"+ elif n == 2:",
"+ return [2]",
"+ is_prime = [True for i in range(n + 1)]",
"+ is_prime[0] = False",
"+ is_prime[1] = False",
"+ for i in range(2, n):",
"+ for j in range(i * i, n + 1, i):"... | false | 0.04433 | 0.045718 | 0.969643 | [
"s372106862",
"s595677399"
] |
u540877546 | p03293 | python | s290654751 | s711008273 | 20 | 17 | 2,940 | 2,940 | Accepted | Accepted | 15 | s = str(eval(input()))
t = str(eval(input()))
for i in range(len(s)):
for j in s:
if(t == s[i:]+s[:i]):
print('Yes')
exit()
print('No')
| s = str(eval(input()))
t = str(eval(input()))
for i in range(len(s)):
if(t == s[i:]+s[:i]):
print('Yes')
exit()
print('No')
| 11 | 9 | 173 | 142 | s = str(eval(input()))
t = str(eval(input()))
for i in range(len(s)):
for j in s:
if t == s[i:] + s[:i]:
print("Yes")
exit()
print("No")
| s = str(eval(input()))
t = str(eval(input()))
for i in range(len(s)):
if t == s[i:] + s[:i]:
print("Yes")
exit()
print("No")
| false | 18.181818 | [
"- for j in s:",
"- if t == s[i:] + s[:i]:",
"- print(\"Yes\")",
"- exit()",
"+ if t == s[i:] + s[:i]:",
"+ print(\"Yes\")",
"+ exit()"
] | false | 0.046293 | 0.042727 | 1.083459 | [
"s290654751",
"s711008273"
] |
u088552457 | p03785 | python | s397650400 | s222586422 | 333 | 95 | 27,972 | 77,360 | Accepted | Accepted | 71.47 | n, c, k = list(map(int, input().split()))
t = []
for _ in range(n):
t.append(int(eval(input())))
st = sorted(t)
time = 0
limit = st[0]+k
d = {}
d[limit] = []
ans = 1
for i, p in enumerate(st):
if p <= limit and len(d[limit]) < c:
d[limit].append(p)
else:
limit = p + k
ans += 1
... | import sys
input = sys.stdin.readline
def main():
n, c, k = input_list()
arrivals = []
for _ in range(n):
arrivals.append(int(eval(input())))
arrivals.sort()
count = 0
limit = 0
ans = 0
for i, a in enumerate(arrivals):
if limit and limit < a:
li... | 22 | 39 | 340 | 790 | n, c, k = list(map(int, input().split()))
t = []
for _ in range(n):
t.append(int(eval(input())))
st = sorted(t)
time = 0
limit = st[0] + k
d = {}
d[limit] = []
ans = 1
for i, p in enumerate(st):
if p <= limit and len(d[limit]) < c:
d[limit].append(p)
else:
limit = p + k
ans += 1
... | import sys
input = sys.stdin.readline
def main():
n, c, k = input_list()
arrivals = []
for _ in range(n):
arrivals.append(int(eval(input())))
arrivals.sort()
count = 0
limit = 0
ans = 0
for i, a in enumerate(arrivals):
if limit and limit < a:
limit = 0
... | false | 43.589744 | [
"-n, c, k = list(map(int, input().split()))",
"-t = []",
"-for _ in range(n):",
"- t.append(int(eval(input())))",
"-st = sorted(t)",
"-time = 0",
"-limit = st[0] + k",
"-d = {}",
"-d[limit] = []",
"-ans = 1",
"-for i, p in enumerate(st):",
"- if p <= limit and len(d[limit]) < c:",
"- ... | false | 0.037729 | 0.039462 | 0.956085 | [
"s397650400",
"s222586422"
] |
u588341295 | p03762 | python | s761501614 | s035283990 | 281 | 210 | 25,212 | 19,580 | Accepted | Accepted | 25.27 | # -*- coding: utf-8 -*-
import sys
from itertools import accumulate
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 rang... | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in ... | 53 | 42 | 1,304 | 1,047 | # -*- coding: utf-8 -*-
import sys
from itertools import accumulate
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
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in rang... | false | 20.754717 | [
"-from itertools import accumulate",
"-# データの持ち方を座標から区間長にして累積和",
"-A2 = []",
"-for i in range(N - 1):",
"- A2.append(A[i + 1] - A[i])",
"-B2 = []",
"-for i in range(M - 1):",
"- B2.append(B[i + 1] - B[i])",
"-A2 = [0] + list(accumulate(A2))",
"-B2 = [0] + list(accumulate(B2))",
"-# 縦横独立に、累... | false | 0.038296 | 0.037622 | 1.017927 | [
"s761501614",
"s035283990"
] |
u437632122 | p03470 | python | s875101072 | s845179540 | 187 | 164 | 38,256 | 38,384 | Accepted | Accepted | 12.3 | N = int(eval(input()))
d = list()
for n in range(N):
d.append(int(eval(input())))
d = sorted(d, reverse=True)
ans = 1
for i, n in enumerate(d):
if i == len(d) - 1:
break
if n > d[i + 1]:
ans += 1
print(ans)
| N = int(eval(input()))
d = list()
for n in range(N):
d.append(int(eval(input())))
print((len(set(d))))
| 12 | 6 | 234 | 99 | N = int(eval(input()))
d = list()
for n in range(N):
d.append(int(eval(input())))
d = sorted(d, reverse=True)
ans = 1
for i, n in enumerate(d):
if i == len(d) - 1:
break
if n > d[i + 1]:
ans += 1
print(ans)
| N = int(eval(input()))
d = list()
for n in range(N):
d.append(int(eval(input())))
print((len(set(d))))
| false | 50 | [
"-d = sorted(d, reverse=True)",
"-ans = 1",
"-for i, n in enumerate(d):",
"- if i == len(d) - 1:",
"- break",
"- if n > d[i + 1]:",
"- ans += 1",
"-print(ans)",
"+print((len(set(d))))"
] | false | 0.044024 | 0.045584 | 0.965763 | [
"s875101072",
"s845179540"
] |
u799443198 | p03319 | python | s104644767 | s832029377 | 40 | 17 | 13,852 | 2,940 | Accepted | Accepted | 57.5 | import math
N, K, *A = list(map(int, open(0).read().split()))
I = A.index(1)
print((math.ceil((N-1)/(K-1)))) | N, K = list(map(int, input().split()))
print(((N+K-3)//(K-1)))
| 4 | 2 | 103 | 56 | import math
N, K, *A = list(map(int, open(0).read().split()))
I = A.index(1)
print((math.ceil((N - 1) / (K - 1))))
| N, K = list(map(int, input().split()))
print(((N + K - 3) // (K - 1)))
| false | 50 | [
"-import math",
"-",
"-N, K, *A = list(map(int, open(0).read().split()))",
"-I = A.index(1)",
"-print((math.ceil((N - 1) / (K - 1))))",
"+N, K = list(map(int, input().split()))",
"+print(((N + K - 3) // (K - 1)))"
] | false | 0.080563 | 0.146856 | 0.548586 | [
"s104644767",
"s832029377"
] |
u353895424 | p03723 | python | s470028447 | s026575556 | 184 | 166 | 40,300 | 38,384 | Accepted | Accepted | 9.78 | a, b, c = list(map(int, input().split()))
cnt = 0
while cnt <= 10**6:
if a%2 != 0 or b%2 != 0 or c%2 != 0:
print(cnt)
exit()
a_ = b//2 + c//2
b_ = a//2 + c//2
c_ = a//2 + b//2
a = a_
b = b_
c = c_
cnt += 1
print((-1)) | a, b, c = list(map(int, input().split()))
cnt = 0
while cnt <= 10**6:
if (a%2 != 0 or b%2 != 0 or c%2 != 0):
print(cnt)
exit()
if a==b==c:
print((-1))
exit()
a_ = b//2 + c//2
b_ = a//2 + c//2
c_ = a//2 + b//2
a = a_
b = b_
c =... | 18 | 21 | 282 | 331 | a, b, c = list(map(int, input().split()))
cnt = 0
while cnt <= 10**6:
if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
print(cnt)
exit()
a_ = b // 2 + c // 2
b_ = a // 2 + c // 2
c_ = a // 2 + b // 2
a = a_
b = b_
c = c_
cnt += 1
print((-1))
| a, b, c = list(map(int, input().split()))
cnt = 0
while cnt <= 10**6:
if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
print(cnt)
exit()
if a == b == c:
print((-1))
exit()
a_ = b // 2 + c // 2
b_ = a // 2 + c // 2
c_ = a // 2 + b // 2
a = a_
b = b_
c = c_
cn... | false | 14.285714 | [
"+ exit()",
"+ if a == b == c:",
"+ print((-1))",
"-print((-1))"
] | false | 0.194855 | 0.038847 | 5.015953 | [
"s470028447",
"s026575556"
] |
u906428167 | p02936 | python | s543365237 | s248449175 | 1,821 | 829 | 107,136 | 92,876 | Accepted | Accepted | 54.48 | n,qq = list(map(int,input().split()))
g = [[] for _ in range(n)]
for i in range(n-1):
a,b = list(map(int,input().split()))
g[a-1].append(b-1)
g[b-1].append(a-1)
l = [0]*n
count = [0]*n
for _ in range(qq):
p,x = list(map(int,input().split()))
l[p-1] += x
p = [True]*n
p[0] = Fa... | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
n, q = list(map(int, input().split()))
g = [[] for _ in range(n)]
for i in range(n-1):
a, b = list(map(int, input().split()))
g[a-1].append(b-1)
g[b-1].append(a-1)
l = [0]*n
for _ in range(q):
p, x = list(map(int, ... | 32 | 33 | 475 | 562 | n, qq = list(map(int, input().split()))
g = [[] for _ in range(n)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
l = [0] * n
count = [0] * n
for _ in range(qq):
p, x = list(map(int, input().split()))
l[p - 1] += x
p = [True] * n
p[0] = Fa... | import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n, q = list(map(int, input().split()))
g = [[] for _ in range(n)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
l = [0] * n
for _ in range(q):
p, x = list(map(int, input().sp... | false | 3.030303 | [
"-n, qq = list(map(int, input().split()))",
"+import sys",
"+",
"+sys.setrecursionlimit(10**7)",
"+input = sys.stdin.readline",
"+n, q = list(map(int, input().split()))",
"-count = [0] * n",
"-for _ in range(qq):",
"+for _ in range(q):",
"-p = [True] * n",
"-p[0] = False",
"+visited = [False] ... | false | 0.03549 | 0.046238 | 0.767556 | [
"s543365237",
"s248449175"
] |
u241159583 | p03197 | python | s332281082 | s052863238 | 185 | 143 | 7,072 | 9,812 | Accepted | Accepted | 22.7 | N = int(eval(input()))
a = [int(eval(input())) for _ in range(N)]
print(("second" if all(a[i] % 2 == 0 for i in range(N)) else "first")) | n = int(eval(input()))
a = list(int(eval(input()))%2 for _ in range(n))
a = list(set(a))
print(("second" if a == [0] else "first")) | 4 | 4 | 126 | 120 | N = int(eval(input()))
a = [int(eval(input())) for _ in range(N)]
print(("second" if all(a[i] % 2 == 0 for i in range(N)) else "first"))
| n = int(eval(input()))
a = list(int(eval(input())) % 2 for _ in range(n))
a = list(set(a))
print(("second" if a == [0] else "first"))
| false | 0 | [
"-N = int(eval(input()))",
"-a = [int(eval(input())) for _ in range(N)]",
"-print((\"second\" if all(a[i] % 2 == 0 for i in range(N)) else \"first\"))",
"+n = int(eval(input()))",
"+a = list(int(eval(input())) % 2 for _ in range(n))",
"+a = list(set(a))",
"+print((\"second\" if a == [0] else \"first\"))... | false | 0.082272 | 0.04389 | 1.874511 | [
"s332281082",
"s052863238"
] |
u489959379 | p03420 | python | s316737842 | s965948062 | 112 | 75 | 3,316 | 9,068 | Accepted | Accepted | 33.04 | import math
n, k = list(map(int, input().split()))
res = 0
for b in range(1, n + 1):
res += math.floor(n / b) * max(0, b - k) + max(0, n % b - k + 1)
if k == 0:
res = n ** 2
print(res)
| import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n, k = list(map(int, input().split()))
if k == 0:
print((n ** 2))
exit()
res = 0
for b in range(1, n + 1):
res += n // b * max(0, b - k... | 11 | 24 | 200 | 415 | import math
n, k = list(map(int, input().split()))
res = 0
for b in range(1, n + 1):
res += math.floor(n / b) * max(0, b - k) + max(0, n % b - k + 1)
if k == 0:
res = n**2
print(res)
| import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n, k = list(map(int, input().split()))
if k == 0:
print((n**2))
exit()
res = 0
for b in range(1, n + 1):
res += n // b * max(0, b - k)
res += max(0, n... | false | 54.166667 | [
"-import math",
"+import sys",
"-n, k = list(map(int, input().split()))",
"-res = 0",
"-for b in range(1, n + 1):",
"- res += math.floor(n / b) * max(0, b - k) + max(0, n % b - k + 1)",
"-if k == 0:",
"- res = n**2",
"-print(res)",
"+sys.setrecursionlimit(10**7)",
"+input = sys.stdin.readl... | false | 0.050357 | 0.143263 | 0.351503 | [
"s316737842",
"s965948062"
] |
u564902833 | p03107 | python | s246571311 | s150879762 | 41 | 18 | 3,188 | 3,188 | Accepted | Accepted | 56.1 | S = eval(input())
k = 0
ans = 0
for s in S:
if s == '1':
if k <= -1:
ans += 2
k += 1
else:
if k >= 1:
ans += 2
k -= 1
print(ans)
| # 入力
S = eval(input())
# 適当に取り除く操作を繰り返せばよい
ans = 2 * min(S.count('0'), S.count('1'))
# 出力
print(ans)
| 13 | 8 | 199 | 104 | S = eval(input())
k = 0
ans = 0
for s in S:
if s == "1":
if k <= -1:
ans += 2
k += 1
else:
if k >= 1:
ans += 2
k -= 1
print(ans)
| # 入力
S = eval(input())
# 適当に取り除く操作を繰り返せばよい
ans = 2 * min(S.count("0"), S.count("1"))
# 出力
print(ans)
| false | 38.461538 | [
"+# 入力",
"-k = 0",
"-ans = 0",
"-for s in S:",
"- if s == \"1\":",
"- if k <= -1:",
"- ans += 2",
"- k += 1",
"- else:",
"- if k >= 1:",
"- ans += 2",
"- k -= 1",
"+# 適当に取り除く操作を繰り返せばよい",
"+ans = 2 * min(S.count(\"0\"), S.count(\"1\"))... | false | 0.03764 | 0.036614 | 1.028009 | [
"s246571311",
"s150879762"
] |
u439063038 | p02573 | python | s574210838 | s119225243 | 820 | 613 | 14,756 | 13,268 | Accepted | Accepted | 25.24 | N, M = list(map(int, input().split()))
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self... | import sys
sys.setrecursionlimit(10 ** 9)
N, M = list(map(int, input().split()))
root = [-1] * N
def r(x):
if root[x] < 0:
return x
else:
root[x] = r(root[x])
return root[x]
def unite(x, y):
x = r(x)
y = r(y)
if x == y:
return
root... | 56 | 38 | 1,412 | 527 | N, M = list(map(int, input().split()))
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
... | import sys
sys.setrecursionlimit(10**9)
N, M = list(map(int, input().split()))
root = [-1] * N
def r(x):
if root[x] < 0:
return x
else:
root[x] = r(root[x])
return root[x]
def unite(x, y):
x = r(x)
y = r(y)
if x == y:
return
root[x] += root[y]
root[y] = x... | false | 32.142857 | [
"+import sys",
"+",
"+sys.setrecursionlimit(10**9)",
"+root = [-1] * N",
"-class UnionFind:",
"- def __init__(self, n):",
"- self.n = n",
"- self.parents = [-1] * n",
"-",
"- def find(self, x):",
"- if self.parents[x] < 0:",
"- return x",
"- else:... | false | 0.038807 | 0.085489 | 0.453937 | [
"s574210838",
"s119225243"
] |
u141786930 | p02679 | python | s600958229 | s631125896 | 1,654 | 835 | 92,552 | 95,936 | Accepted | Accepted | 49.52 | # E - ∙ (Bullet)
import sys
from collections import defaultdict
readline = sys.stdin.readline
MOD = 1000000007
N = int(readline())
# イワシの傾きをA/Bとする。
# A/Bは予めgcdで割って約分し、同じ傾きのものを揃えておく。
# このとき、仲の悪い組合せは(A, B)に対して(B, -A)となるもの。
# 前者をS、後者をTとして考える。
d_S = defaultdict(int)
d_T = defaultdict(int)
def gcd(x, y):
... | # E - ∙ (Bullet)
import sys
from collections import defaultdict
from math import gcd
readline = sys.stdin.readline
MOD = 1000000007
N = int(readline())
# イワシの傾きをA/Bとする。
# A/Bは予めgcdで割って約分し、同じ傾きのものを揃えておく。
# このとき、仲の悪い組合せは(A, B)に対して(B, -A)となるもの。
# 前者をS、後者をTとして考える。
d_S = defaultdict(int)
d_T = defaultdict(i... | 71 | 70 | 1,657 | 1,555 | # E - ∙ (Bullet)
import sys
from collections import defaultdict
readline = sys.stdin.readline
MOD = 1000000007
N = int(readline())
# イワシの傾きをA/Bとする。
# A/Bは予めgcdで割って約分し、同じ傾きのものを揃えておく。
# このとき、仲の悪い組合せは(A, B)に対して(B, -A)となるもの。
# 前者をS、後者をTとして考える。
d_S = defaultdict(int)
d_T = defaultdict(int)
def gcd(x, y):
if x == 0:
... | # E - ∙ (Bullet)
import sys
from collections import defaultdict
from math import gcd
readline = sys.stdin.readline
MOD = 1000000007
N = int(readline())
# イワシの傾きをA/Bとする。
# A/Bは予めgcdで割って約分し、同じ傾きのものを揃えておく。
# このとき、仲の悪い組合せは(A, B)に対して(B, -A)となるもの。
# 前者をS、後者をTとして考える。
d_S = defaultdict(int)
d_T = defaultdict(int)
"""
def gcd(... | false | 1.408451 | [
"+from math import gcd",
"-",
"-",
"+\"\"\"",
"- return gcd(y % x, x)",
"-",
"-",
"+ return gcd(y%x, x)",
"+\"\"\"",
"- # いずれもマイナスの場合、傾きはプラスになる",
"- if A < 0 and B < 0:",
"+ if A < 0:",
"- # 片方がマイナスの場合、必ずAがマイナスになるよう揃える",
"- if A > B:",
... | false | 0.041049 | 0.041972 | 0.978009 | [
"s600958229",
"s631125896"
] |
u588341295 | p02803 | python | s183797955 | s676859550 | 329 | 258 | 3,440 | 3,828 | Accepted | Accepted | 21.58 | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in ... | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in ... | 75 | 76 | 2,209 | 2,245 | # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in rang... | # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in rang... | false | 1.315789 | [
"- dist = list2d(H + 2, W + 2, -1)",
"+ dist = list2d(H, W, -1)",
"+ dist[h][w] = 0",
"- if dist[h][w] != -1:",
"- continue",
"- dist[h][w] = c",
"+ if dist[h2][w2] != -1:",
"+ continue",
"+ dist[h2][w2] = c + 1"
] | false | 0.04624 | 0.046139 | 1.002187 | [
"s183797955",
"s676859550"
] |
u312025627 | p03371 | python | s419396854 | s584620829 | 165 | 17 | 38,256 | 3,060 | Accepted | Accepted | 89.7 | def main():
a, b, c, x, y = (int(i) for i in input().split())
ans = a*x + b*y
cur = 2*c*min(x, y) + (a*(x-y) if x > y else b*(y-x))
ans = min(ans, cur)
cur = 2*c*max(x, y)
ans = min(ans, cur)
print(ans)
if __name__ == '__main__':
main()
| def main():
a, b, c, x, y = (int(i) for i in input().split())
ans = a*x + b*y
ans = min(ans, 2*c*max(x, y))
if x < y:
d = y-x
d *= b
else:
d = x-y
d *= a
ans = min(ans, 2*c*min(x, y) + d)
print(ans)
if __name__ == '__main__':
main()
| 12 | 16 | 282 | 314 | def main():
a, b, c, x, y = (int(i) for i in input().split())
ans = a * x + b * y
cur = 2 * c * min(x, y) + (a * (x - y) if x > y else b * (y - x))
ans = min(ans, cur)
cur = 2 * c * max(x, y)
ans = min(ans, cur)
print(ans)
if __name__ == "__main__":
main()
| def main():
a, b, c, x, y = (int(i) for i in input().split())
ans = a * x + b * y
ans = min(ans, 2 * c * max(x, y))
if x < y:
d = y - x
d *= b
else:
d = x - y
d *= a
ans = min(ans, 2 * c * min(x, y) + d)
print(ans)
if __name__ == "__main__":
main()
| false | 25 | [
"- cur = 2 * c * min(x, y) + (a * (x - y) if x > y else b * (y - x))",
"- ans = min(ans, cur)",
"- cur = 2 * c * max(x, y)",
"- ans = min(ans, cur)",
"+ ans = min(ans, 2 * c * max(x, y))",
"+ if x < y:",
"+ d = y - x",
"+ d *= b",
"+ else:",
"+ d = x - y",... | false | 0.044462 | 0.042447 | 1.047479 | [
"s419396854",
"s584620829"
] |
u729133443 | p02538 | python | s612785031 | s736213419 | 321 | 280 | 23,484 | 23,416 | Accepted | Accepted | 12.77 | code = r"""
# distutils: language=c++
# distutils: include_dirs=/opt/ac-library
# cython: cdivision=True
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/lazysegtree>" namespace "atcoder" nogil:
cdef cppclass lazy_segtree[S, OP, E, F, mapping, composition, id]:
l... | code = r"""
# distutils: language=c++
# distutils: include_dirs=/opt/ac-library
# cython: cdivision=True
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/lazysegtree>" namespace "atcoder":
cdef cppclass lazy_segtree[S, OP, E, F, mapping, composition, id]:
lazy_se... | 78 | 67 | 2,310 | 2,099 | code = r"""
# distutils: language=c++
# distutils: include_dirs=/opt/ac-library
# cython: cdivision=True
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/lazysegtree>" namespace "atcoder" nogil:
cdef cppclass lazy_segtree[S, OP, E, F, mapping, composition, id]:
lazy_segt... | code = r"""
# distutils: language=c++
# distutils: include_dirs=/opt/ac-library
# cython: cdivision=True
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/lazysegtree>" namespace "atcoder":
cdef cppclass lazy_segtree[S, OP, E, F, mapping, composition, id]:
lazy_segtree(ve... | false | 14.102564 | [
"-cdef extern from \"<atcoder/lazysegtree>\" namespace \"atcoder\" nogil:",
"+cdef extern from \"<atcoder/lazysegtree>\" namespace \"atcoder\":",
"+DEF mod = 998244353",
"- cdef s_t myop(s_t a, s_t b) nogil",
"- cdef s_t mye() nogil",
"- cdef s_t mymapping(f_t f, s_t x) nogil",
"- cdef f_t m... | false | 0.127388 | 0.046163 | 2.759542 | [
"s612785031",
"s736213419"
] |
u159994501 | p02755 | python | s577839762 | s474072892 | 20 | 18 | 3,188 | 2,940 | Accepted | Accepted | 10 | import math
A, B = list(map(int, input().split()))
A_min = math.ceil(A * 12.5)
A_max = math.ceil((A + 1) * 12.5) - 1
B_min = math.ceil(B * 10)
B_max = math.ceil((B + 1) * 10) - 1
# print(A_min, A_max, B_min, B_max)
candidate = max(A_min, B_min)
if candidate < min(A_max, B_max):
print(candidate)
else... | import math
A, B = list(map(int, input().split()))
for i in range(1, 1001):
if math.floor(0.08 * i) == A and math.floor(0.1 * i) == B:
print(i)
exit()
print((-1))
| 15 | 8 | 333 | 183 | import math
A, B = list(map(int, input().split()))
A_min = math.ceil(A * 12.5)
A_max = math.ceil((A + 1) * 12.5) - 1
B_min = math.ceil(B * 10)
B_max = math.ceil((B + 1) * 10) - 1
# print(A_min, A_max, B_min, B_max)
candidate = max(A_min, B_min)
if candidate < min(A_max, B_max):
print(candidate)
else:
print("-1... | import math
A, B = list(map(int, input().split()))
for i in range(1, 1001):
if math.floor(0.08 * i) == A and math.floor(0.1 * i) == B:
print(i)
exit()
print((-1))
| false | 46.666667 | [
"-A_min = math.ceil(A * 12.5)",
"-A_max = math.ceil((A + 1) * 12.5) - 1",
"-B_min = math.ceil(B * 10)",
"-B_max = math.ceil((B + 1) * 10) - 1",
"-# print(A_min, A_max, B_min, B_max)",
"-candidate = max(A_min, B_min)",
"-if candidate < min(A_max, B_max):",
"- print(candidate)",
"-else:",
"- p... | false | 0.228833 | 0.203424 | 1.12491 | [
"s577839762",
"s474072892"
] |
u245870380 | p02802 | python | s966365972 | s249779544 | 397 | 348 | 36,156 | 3,828 | Accepted | Accepted | 12.34 | N, M = list(map(int, input().split()))
lis = [list(input().split()) for _ in range(M)]
AC = [[0] * 2 for i in range(N)]
for i in range(M):
if lis[i][1] == "AC":
AC[int(lis[i][0])-1][1] = 1
elif AC[int(lis[i][0])-1][1] == 0:
AC[int(lis[i][0])-1][0] += 1
a = 0
w = 0
for i in range(N):
... | N, M = list(map(int, input().split()))
P = [0] * 10**5
score, penalty = 0, 0
for i in range(M):
p, s = list(map(str, input().split()))
p = int(p)
if s == 'AC' and P[p-1] != -1:
penalty += P[p-1]
score += 1
P[p-1] = -1
elif P[p-1] != -1:
P[p-1] += 1
print((scor... | 15 | 13 | 387 | 319 | N, M = list(map(int, input().split()))
lis = [list(input().split()) for _ in range(M)]
AC = [[0] * 2 for i in range(N)]
for i in range(M):
if lis[i][1] == "AC":
AC[int(lis[i][0]) - 1][1] = 1
elif AC[int(lis[i][0]) - 1][1] == 0:
AC[int(lis[i][0]) - 1][0] += 1
a = 0
w = 0
for i in range(N):
if... | N, M = list(map(int, input().split()))
P = [0] * 10**5
score, penalty = 0, 0
for i in range(M):
p, s = list(map(str, input().split()))
p = int(p)
if s == "AC" and P[p - 1] != -1:
penalty += P[p - 1]
score += 1
P[p - 1] = -1
elif P[p - 1] != -1:
P[p - 1] += 1
print((score,... | false | 13.333333 | [
"-lis = [list(input().split()) for _ in range(M)]",
"-AC = [[0] * 2 for i in range(N)]",
"+P = [0] * 10**5",
"+score, penalty = 0, 0",
"- if lis[i][1] == \"AC\":",
"- AC[int(lis[i][0]) - 1][1] = 1",
"- elif AC[int(lis[i][0]) - 1][1] == 0:",
"- AC[int(lis[i][0]) - 1][0] += 1",
"-a... | false | 0.062835 | 0.037692 | 1.667079 | [
"s966365972",
"s249779544"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.