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
sequence | 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
sequence |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u170183831 | p03425 | python | s878257334 | s730640411 | 169 | 155 | 9,772 | 16,236 | Accepted | Accepted | 8.28 | import itertools
def solve(n, S):
initials = ('M', 'A', 'R', 'C', 'H')
d = {}
for s in S:
if s[0] in initials:
d[s[0]] = d.get(s[0], 0) + 1
return sum(d[x] * d[y] * d[z] for x, y, z in itertools.combinations(list(d.keys()), 3))
_n = int(eval(input()))
_S = [eval(input()) for _ in range(_n)]
print((solve(_n, _S))) | from itertools import combinations
n = int(eval(input()))
S = [eval(input()) for _ in range(n)]
initials = ('M', 'A', 'R', 'C', 'H')
d = {}
for s in S:
if s[0] in initials:
d[s[0]] = d.get(s[0], 0) + 1
print((sum(d[x] * d[y] * d[z] for x, y, z in combinations(list(d.keys()), 3)))) | 13 | 11 | 344 | 279 | import itertools
def solve(n, S):
initials = ("M", "A", "R", "C", "H")
d = {}
for s in S:
if s[0] in initials:
d[s[0]] = d.get(s[0], 0) + 1
return sum(
d[x] * d[y] * d[z] for x, y, z in itertools.combinations(list(d.keys()), 3)
)
_n = int(eval(input()))
_S = [eval(input()) for _ in range(_n)]
print((solve(_n, _S)))
| from itertools import combinations
n = int(eval(input()))
S = [eval(input()) for _ in range(n)]
initials = ("M", "A", "R", "C", "H")
d = {}
for s in S:
if s[0] in initials:
d[s[0]] = d.get(s[0], 0) + 1
print((sum(d[x] * d[y] * d[z] for x, y, z in combinations(list(d.keys()), 3))))
| false | 15.384615 | [
"-import itertools",
"+from itertools import combinations",
"-",
"-def solve(n, S):",
"- initials = (\"M\", \"A\", \"R\", \"C\", \"H\")",
"- d = {}",
"- for s in S:",
"- if s[0] in initials:",
"- d[s[0]] = d.get(s[0], 0) + 1",
"- return sum(",
"- d[x] * d[y] * d[z] for x, y, z in itertools.combinations(list(d.keys()), 3)",
"- )",
"-",
"-",
"-_n = int(eval(input()))",
"-_S = [eval(input()) for _ in range(_n)]",
"-print((solve(_n, _S)))",
"+n = int(eval(input()))",
"+S = [eval(input()) for _ in range(n)]",
"+initials = (\"M\", \"A\", \"R\", \"C\", \"H\")",
"+d = {}",
"+for s in S:",
"+ if s[0] in initials:",
"+ d[s[0]] = d.get(s[0], 0) + 1",
"+print((sum(d[x] * d[y] * d[z] for x, y, z in combinations(list(d.keys()), 3))))"
] | false | 0.037917 | 0.032989 | 1.149382 | [
"s878257334",
"s730640411"
] |
u764956288 | p02689 | python | s147136676 | s940800028 | 245 | 139 | 20,132 | 20,220 | Accepted | Accepted | 43.27 | # import numpy as np
# import queue
# import heapq
def main():
N, M = list(map(int, input().split()))
heights = list(map(int, input().split()))
towers = [True for _ in range(N)]
pathes = (list(map(int, input().split())) for _ in range(M))
for path in pathes:
a = path[0] - 1
b = path[1] - 1
ha = heights[a]
hb = heights[b]
if ha > hb:
towers[b] = False
elif ha < hb:
towers[a] = False
else:
towers[a] = False
towers[b] = False
print((sum(towers)))
if __name__ == "__main__":
main()
| import sys
input = sys.stdin.readline
def main():
n_obss, n_roads = list(map(int, input().split()))
elevations = list(map(int, input().split()))
is_good_obs = [True for _ in range(n_obss)]
roads = (list(map(int, input().split())) for _ in range(n_roads))
for road in roads:
idx_a = road[0] - 1
idx_b = road[1] - 1
e_a = elevations[idx_a]
e_b = elevations[idx_b]
if e_a > e_b:
is_good_obs[idx_b] = False
elif e_a < e_b:
is_good_obs[idx_a] = False
else:
is_good_obs[idx_a] = False
is_good_obs[idx_b] = False
print((sum(is_good_obs)))
if __name__ == "__main__":
main()
| 34 | 33 | 650 | 741 | # import numpy as np
# import queue
# import heapq
def main():
N, M = list(map(int, input().split()))
heights = list(map(int, input().split()))
towers = [True for _ in range(N)]
pathes = (list(map(int, input().split())) for _ in range(M))
for path in pathes:
a = path[0] - 1
b = path[1] - 1
ha = heights[a]
hb = heights[b]
if ha > hb:
towers[b] = False
elif ha < hb:
towers[a] = False
else:
towers[a] = False
towers[b] = False
print((sum(towers)))
if __name__ == "__main__":
main()
| import sys
input = sys.stdin.readline
def main():
n_obss, n_roads = list(map(int, input().split()))
elevations = list(map(int, input().split()))
is_good_obs = [True for _ in range(n_obss)]
roads = (list(map(int, input().split())) for _ in range(n_roads))
for road in roads:
idx_a = road[0] - 1
idx_b = road[1] - 1
e_a = elevations[idx_a]
e_b = elevations[idx_b]
if e_a > e_b:
is_good_obs[idx_b] = False
elif e_a < e_b:
is_good_obs[idx_a] = False
else:
is_good_obs[idx_a] = False
is_good_obs[idx_b] = False
print((sum(is_good_obs)))
if __name__ == "__main__":
main()
| false | 2.941176 | [
"-# import numpy as np",
"-# import queue",
"-# import heapq",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+",
"+",
"- N, M = list(map(int, input().split()))",
"- heights = list(map(int, input().split()))",
"- towers = [True for _ in range(N)]",
"- pathes = (list(map(int, input().split())) for _ in range(M))",
"- for path in pathes:",
"- a = path[0] - 1",
"- b = path[1] - 1",
"- ha = heights[a]",
"- hb = heights[b]",
"- if ha > hb:",
"- towers[b] = False",
"- elif ha < hb:",
"- towers[a] = False",
"+ n_obss, n_roads = list(map(int, input().split()))",
"+ elevations = list(map(int, input().split()))",
"+ is_good_obs = [True for _ in range(n_obss)]",
"+ roads = (list(map(int, input().split())) for _ in range(n_roads))",
"+ for road in roads:",
"+ idx_a = road[0] - 1",
"+ idx_b = road[1] - 1",
"+ e_a = elevations[idx_a]",
"+ e_b = elevations[idx_b]",
"+ if e_a > e_b:",
"+ is_good_obs[idx_b] = False",
"+ elif e_a < e_b:",
"+ is_good_obs[idx_a] = False",
"- towers[a] = False",
"- towers[b] = False",
"- print((sum(towers)))",
"+ is_good_obs[idx_a] = False",
"+ is_good_obs[idx_b] = False",
"+ print((sum(is_good_obs)))"
] | false | 0.046206 | 0.078165 | 0.59113 | [
"s147136676",
"s940800028"
] |
u629540524 | p03416 | python | s783576660 | s017717829 | 72 | 52 | 9,052 | 9,108 | Accepted | Accepted | 27.78 | a,b = list(map(int, input().split()))
c = 0
while a <= b:
if str(a)[::-1] == str(a):
c += 1
a += 1
print(c) | a,b = list(map(int, input().split()))
c = 0
for i in map(str,list(range(a,b+1))):
if i==i[::-1]:
c += 1
print(c) | 7 | 6 | 123 | 117 | a, b = list(map(int, input().split()))
c = 0
while a <= b:
if str(a)[::-1] == str(a):
c += 1
a += 1
print(c)
| a, b = list(map(int, input().split()))
c = 0
for i in map(str, list(range(a, b + 1))):
if i == i[::-1]:
c += 1
print(c)
| false | 14.285714 | [
"-while a <= b:",
"- if str(a)[::-1] == str(a):",
"+for i in map(str, list(range(a, b + 1))):",
"+ if i == i[::-1]:",
"- a += 1"
] | false | 0.049585 | 0.044279 | 1.119825 | [
"s783576660",
"s017717829"
] |
u323680411 | p03030 | python | s511951542 | s012684086 | 23 | 18 | 3,064 | 3,064 | Accepted | Accepted | 21.74 | n = int(eval(input()))
dic = [[x for x in input().split()] for i in range(n)]
for i in range(n):
dic[i][1] = int(dic[i][1])
dic[i].append(i + 1)
dic.sort(key= lambda x: x[1], reverse= True)
dic.sort(key= lambda x: x[0])
for i in range(n):
print((dic[i][2])) | n = int(eval(input()))
dic = []
for i in range(n):
tmp = input().split()
dic.append([tmp[0], int(tmp[1]), i + 1])
dic.sort(key= lambda x: x[1], reverse= True)
dic.sort(key= lambda x: x[0])
for i in range(n):
print((dic[i][2])) | 12 | 12 | 275 | 245 | n = int(eval(input()))
dic = [[x for x in input().split()] for i in range(n)]
for i in range(n):
dic[i][1] = int(dic[i][1])
dic[i].append(i + 1)
dic.sort(key=lambda x: x[1], reverse=True)
dic.sort(key=lambda x: x[0])
for i in range(n):
print((dic[i][2]))
| n = int(eval(input()))
dic = []
for i in range(n):
tmp = input().split()
dic.append([tmp[0], int(tmp[1]), i + 1])
dic.sort(key=lambda x: x[1], reverse=True)
dic.sort(key=lambda x: x[0])
for i in range(n):
print((dic[i][2]))
| false | 0 | [
"-dic = [[x for x in input().split()] for i in range(n)]",
"+dic = []",
"- dic[i][1] = int(dic[i][1])",
"- dic[i].append(i + 1)",
"+ tmp = input().split()",
"+ dic.append([tmp[0], int(tmp[1]), i + 1])"
] | false | 0.0364 | 0.042386 | 0.85877 | [
"s511951542",
"s012684086"
] |
u768256617 | p02678 | python | s221359166 | s654527213 | 705 | 636 | 33,876 | 34,080 | Accepted | Accepted | 9.79 | from collections import deque
n,m=list(map(int,input().split()))
adjacent_list=[[] for i in range(n+1)]
for i in range(m):
a,b=list(map(int,input().split()))
adjacent_list[a].append(b)
adjacent_list[b].append(a)
#print(adjacent_list)
visited=[0]*(n+1)
que=deque()
que.append(1)
while que:
node=que.popleft()
for i in adjacent_list[node]:
if visited[i]==0:
visited[i]=node
que.append(i)
print('Yes')
for i in range(2,n+1):
print((visited[i])) | def mi(): return list(map(int,input().split()))
def lmi(): return list(map(int,input().split()))
def ii(): return int(eval(input()))
def isp(): return input().split()
from collections import deque
n,m=mi()
adjacent_list=[[] for i in range(n+1)]
for i in range(m):
a,b=mi()
adjacent_list[a].append(b)
adjacent_list[b].append(a)
#print(adjacent_list)
dp=[0]*(n+1)
que=deque()
que.append(1)
while que:
p=que.popleft()
for i in adjacent_list[p]:
if dp[i]==0:
dp[i]=p
que.append(i)
print('Yes')
for i in range(2,n+1):
print((dp[i])) | 22 | 27 | 484 | 576 | from collections import deque
n, m = list(map(int, input().split()))
adjacent_list = [[] for i in range(n + 1)]
for i in range(m):
a, b = list(map(int, input().split()))
adjacent_list[a].append(b)
adjacent_list[b].append(a)
# print(adjacent_list)
visited = [0] * (n + 1)
que = deque()
que.append(1)
while que:
node = que.popleft()
for i in adjacent_list[node]:
if visited[i] == 0:
visited[i] = node
que.append(i)
print("Yes")
for i in range(2, n + 1):
print((visited[i]))
| def mi():
return list(map(int, input().split()))
def lmi():
return list(map(int, input().split()))
def ii():
return int(eval(input()))
def isp():
return input().split()
from collections import deque
n, m = mi()
adjacent_list = [[] for i in range(n + 1)]
for i in range(m):
a, b = mi()
adjacent_list[a].append(b)
adjacent_list[b].append(a)
# print(adjacent_list)
dp = [0] * (n + 1)
que = deque()
que.append(1)
while que:
p = que.popleft()
for i in adjacent_list[p]:
if dp[i] == 0:
dp[i] = p
que.append(i)
print("Yes")
for i in range(2, n + 1):
print((dp[i]))
| false | 18.518519 | [
"+def mi():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def lmi():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def ii():",
"+ return int(eval(input()))",
"+",
"+",
"+def isp():",
"+ return input().split()",
"+",
"+",
"-n, m = list(map(int, input().split()))",
"+n, m = mi()",
"- a, b = list(map(int, input().split()))",
"+ a, b = mi()",
"-visited = [0] * (n + 1)",
"+dp = [0] * (n + 1)",
"- node = que.popleft()",
"- for i in adjacent_list[node]:",
"- if visited[i] == 0:",
"- visited[i] = node",
"+ p = que.popleft()",
"+ for i in adjacent_list[p]:",
"+ if dp[i] == 0:",
"+ dp[i] = p",
"- print((visited[i]))",
"+ print((dp[i]))"
] | false | 0.043292 | 0.042009 | 1.03054 | [
"s221359166",
"s654527213"
] |
u567380442 | p02361 | python | s819849449 | s222166278 | 3,580 | 2,910 | 110,172 | 108,588 | Accepted | Accepted | 18.72 | from sys import stdin
from collections import defaultdict, deque
import math
readline = stdin.readline
v, e, r = list(map(int, readline().split()))
g = defaultdict(list)
for i in range(e):
s, t, length = list(map(int, readline().split()))
g[s].append((length, t))
d = [float('inf')] * v
d[r] = 0
que = deque([(d[r], r)])
while que:
du, u = que.popleft()
for length, v in g[u]:
if d[v] > du + length:
d[v] = du + length
que.append((d[v], v))
for di in d:
print(('INF' if math.isinf(di) else di)) | from sys import stdin
from collections import defaultdict
from heapq import heappush, heappop
import math
readline = stdin.readline
v, e, r = list(map(int, readline().split()))
g = defaultdict(list)
for i in range(e):
s, t, length = list(map(int, readline().split()))
g[s].append((length, t))
d = [float('inf')] * v
d[r] = 0
heap = [(d[r], r)]
while heap:
du, u = heappop(heap)
for length, v in g[u]:
if d[v] > du + length:
d[v] = du + length
heappush(heap,(d[v], v))
for di in d:
print(('INF' if math.isinf(di) else di)) | 24 | 24 | 559 | 585 | from sys import stdin
from collections import defaultdict, deque
import math
readline = stdin.readline
v, e, r = list(map(int, readline().split()))
g = defaultdict(list)
for i in range(e):
s, t, length = list(map(int, readline().split()))
g[s].append((length, t))
d = [float("inf")] * v
d[r] = 0
que = deque([(d[r], r)])
while que:
du, u = que.popleft()
for length, v in g[u]:
if d[v] > du + length:
d[v] = du + length
que.append((d[v], v))
for di in d:
print(("INF" if math.isinf(di) else di))
| from sys import stdin
from collections import defaultdict
from heapq import heappush, heappop
import math
readline = stdin.readline
v, e, r = list(map(int, readline().split()))
g = defaultdict(list)
for i in range(e):
s, t, length = list(map(int, readline().split()))
g[s].append((length, t))
d = [float("inf")] * v
d[r] = 0
heap = [(d[r], r)]
while heap:
du, u = heappop(heap)
for length, v in g[u]:
if d[v] > du + length:
d[v] = du + length
heappush(heap, (d[v], v))
for di in d:
print(("INF" if math.isinf(di) else di))
| false | 0 | [
"-from collections import defaultdict, deque",
"+from collections import defaultdict",
"+from heapq import heappush, heappop",
"-que = deque([(d[r], r)])",
"-while que:",
"- du, u = que.popleft()",
"+heap = [(d[r], r)]",
"+while heap:",
"+ du, u = heappop(heap)",
"- que.append((d[v], v))",
"+ heappush(heap, (d[v], v))"
] | false | 0.007661 | 0.117191 | 0.065371 | [
"s819849449",
"s222166278"
] |
u416011173 | p03281 | python | s677982448 | s380989578 | 29 | 25 | 9,064 | 9,212 | Accepted | Accepted | 13.79 | # -*- coding: utf-8 -*-
# ๆจๆบๅ
ฅๅใๅๅพ
N = int(eval(input()))
# ๆฑ่งฃๅฆ็
ans = 0
for n in range(1, N + 1, 2):
divisors_count = 0
for i in range(1, n + 1):
if n % i == 0:
divisors_count += 1
if divisors_count == 8:
ans += 1
# ็ตๆๅบๅ
print(ans)
| # -*- coding: utf-8 -*-
def get_input() -> int:
"""
ๆจๆบๅ
ฅๅใๅๅพใใ.
Returns:\n
int: ๆจๆบๅ
ฅๅ
"""
N = int(eval(input()))
return N
def main(N: int) -> None:
"""
ใกใคใณๅฆ็.
Args:\n
N (int): 1ไปฅไธ200ไปฅไธใฎๆดๆฐ
"""
# ๆฑ่งฃๅฆ็
ans = 0
for n in range(1, N + 1, 2):
divisors_count = 0
for i in range(1, n + 1):
if n % i == 0:
divisors_count += 1
if divisors_count == 8:
ans += 1
# ็ตๆๅบๅ
print(ans)
if __name__ == "__main__":
# ๆจๆบๅ
ฅๅใๅๅพ
N = get_input()
# ใกใคใณๅฆ็
main(N)
| 16 | 41 | 283 | 634 | # -*- coding: utf-8 -*-
# ๆจๆบๅ
ฅๅใๅๅพ
N = int(eval(input()))
# ๆฑ่งฃๅฆ็
ans = 0
for n in range(1, N + 1, 2):
divisors_count = 0
for i in range(1, n + 1):
if n % i == 0:
divisors_count += 1
if divisors_count == 8:
ans += 1
# ็ตๆๅบๅ
print(ans)
| # -*- coding: utf-8 -*-
def get_input() -> int:
"""
ๆจๆบๅ
ฅๅใๅๅพใใ.
Returns:\n
int: ๆจๆบๅ
ฅๅ
"""
N = int(eval(input()))
return N
def main(N: int) -> None:
"""
ใกใคใณๅฆ็.
Args:\n
N (int): 1ไปฅไธ200ไปฅไธใฎๆดๆฐ
"""
# ๆฑ่งฃๅฆ็
ans = 0
for n in range(1, N + 1, 2):
divisors_count = 0
for i in range(1, n + 1):
if n % i == 0:
divisors_count += 1
if divisors_count == 8:
ans += 1
# ็ตๆๅบๅ
print(ans)
if __name__ == "__main__":
# ๆจๆบๅ
ฅๅใๅๅพ
N = get_input()
# ใกใคใณๅฆ็
main(N)
| false | 60.97561 | [
"-# ๆจๆบๅ
ฅๅใๅๅพ",
"-N = int(eval(input()))",
"-# ๆฑ่งฃๅฆ็",
"-ans = 0",
"-for n in range(1, N + 1, 2):",
"- divisors_count = 0",
"- for i in range(1, n + 1):",
"- if n % i == 0:",
"- divisors_count += 1",
"- if divisors_count == 8:",
"- ans += 1",
"-# ็ตๆๅบๅ",
"-print(ans)",
"+def get_input() -> int:",
"+ \"\"\"",
"+ ๆจๆบๅ
ฅๅใๅๅพใใ.",
"+ Returns:\\n",
"+ int: ๆจๆบๅ
ฅๅ",
"+ \"\"\"",
"+ N = int(eval(input()))",
"+ return N",
"+",
"+",
"+def main(N: int) -> None:",
"+ \"\"\"",
"+ ใกใคใณๅฆ็.",
"+ Args:\\n",
"+ N (int): 1ไปฅไธ200ไปฅไธใฎๆดๆฐ",
"+ \"\"\"",
"+ # ๆฑ่งฃๅฆ็",
"+ ans = 0",
"+ for n in range(1, N + 1, 2):",
"+ divisors_count = 0",
"+ for i in range(1, n + 1):",
"+ if n % i == 0:",
"+ divisors_count += 1",
"+ if divisors_count == 8:",
"+ ans += 1",
"+ # ็ตๆๅบๅ",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ # ๆจๆบๅ
ฅๅใๅๅพ",
"+ N = get_input()",
"+ # ใกใคใณๅฆ็",
"+ main(N)"
] | false | 0.04099 | 0.038747 | 1.057889 | [
"s677982448",
"s380989578"
] |
u818349438 | p03240 | python | s538880241 | s417921063 | 234 | 46 | 43,888 | 3,064 | Accepted | Accepted | 80.34 | n = int(eval(input()))
xyh = [list(map(int,input().split())) for _ in range(n)]
for i in range(n):
if(xyh[i][2]!= 0):
x = xyh[i][0]
h = xyh[i][2]
y = xyh[i][1]
break
for i in range(101):
for j in range(101):
H = h+ abs(x - i)+abs(y - j)
ok = True
for k in range(n):
nowx = xyh[k][0]
nowy = xyh[k][1]
nowh = xyh[k][2]
if nowh != max(H - abs(nowx - i) - abs(nowy - j),0):
ok = False
break
if ok :
print((i,j,H))
break
| n = int(eval(input()))
xyh = [list(map(int,input().split())) for _ in range(n)]
#h != 0 ใงใใใใใช๏ฝใใใใใใใฎใจใใฎx,y.hใๅคๆฐใซไฟๅญ(ใใฎใใใช๏ฝใๅฐใชใใจใไธใคๅญๅจ)
for i in range(n):
if(xyh[i][2]!= 0):
x = xyh[i][0]
h = xyh[i][2]
y = xyh[i][1]
break
for i in range(101):
for j in range(101):
#ไธญๅฟๅบงๆจใ(i,j)ใงๆฑบใๆใค
H = h+ abs(x - i)+abs(y - j)#ใใฃใใฎ(x,y,h)ใใคใใใจใใใฉใใใใฎ้ซใใฏใใใชใ
ok = True#ใใฉใฐใTrueใงๅๆๅใใใๆกไปถใๆบใใใชใใใฎใไธใคใงใใใใฐใใกใชใฎใงใok= Falseใใฆbreak
#ใในใฆใฎ(x,y,h)ใๆกไปถใๆบใใใใฎใใใใฐใใใใ็ญใใๅบๅใใฆbreak
for k in range(n):
nowx = xyh[k][0]
nowy = xyh[k][1]
nowh = xyh[k][2]
if nowh != max(H - abs(nowx - i) - abs(nowy - j),0):
ok = False
break
if ok :
print((i,j,H))
break
| 24 | 27 | 624 | 844 | n = int(eval(input()))
xyh = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
if xyh[i][2] != 0:
x = xyh[i][0]
h = xyh[i][2]
y = xyh[i][1]
break
for i in range(101):
for j in range(101):
H = h + abs(x - i) + abs(y - j)
ok = True
for k in range(n):
nowx = xyh[k][0]
nowy = xyh[k][1]
nowh = xyh[k][2]
if nowh != max(H - abs(nowx - i) - abs(nowy - j), 0):
ok = False
break
if ok:
print((i, j, H))
break
| n = int(eval(input()))
xyh = [list(map(int, input().split())) for _ in range(n)]
# h != 0 ใงใใใใใช๏ฝใใใใใใใฎใจใใฎx,y.hใๅคๆฐใซไฟๅญ(ใใฎใใใช๏ฝใๅฐใชใใจใไธใคๅญๅจ)
for i in range(n):
if xyh[i][2] != 0:
x = xyh[i][0]
h = xyh[i][2]
y = xyh[i][1]
break
for i in range(101):
for j in range(101):
# ไธญๅฟๅบงๆจใ(i,j)ใงๆฑบใๆใค
H = h + abs(x - i) + abs(y - j) # ใใฃใใฎ(x,y,h)ใใคใใใจใใใฉใใใใฎ้ซใใฏใใใชใ
ok = True # ใใฉใฐใTrueใงๅๆๅใใใๆกไปถใๆบใใใชใใใฎใไธใคใงใใใใฐใใกใชใฎใงใok= Falseใใฆbreak
# ใในใฆใฎ(x,y,h)ใๆกไปถใๆบใใใใฎใใใใฐใใใใ็ญใใๅบๅใใฆbreak
for k in range(n):
nowx = xyh[k][0]
nowy = xyh[k][1]
nowh = xyh[k][2]
if nowh != max(H - abs(nowx - i) - abs(nowy - j), 0):
ok = False
break
if ok:
print((i, j, H))
break
| false | 11.111111 | [
"+# h != 0 ใงใใใใใช๏ฝใใใใใใใฎใจใใฎx,y.hใๅคๆฐใซไฟๅญ(ใใฎใใใช๏ฝใๅฐใชใใจใไธใคๅญๅจ)",
"- H = h + abs(x - i) + abs(y - j)",
"- ok = True",
"+ # ไธญๅฟๅบงๆจใ(i,j)ใงๆฑบใๆใค",
"+ H = h + abs(x - i) + abs(y - j) # ใใฃใใฎ(x,y,h)ใใคใใใจใใใฉใใใใฎ้ซใใฏใใใชใ",
"+ ok = True # ใใฉใฐใTrueใงๅๆๅใใใๆกไปถใๆบใใใชใใใฎใไธใคใงใใใใฐใใกใชใฎใงใok= Falseใใฆbreak",
"+ # ใในใฆใฎ(x,y,h)ใๆกไปถใๆบใใใใฎใใใใฐใใใใ็ญใใๅบๅใใฆbreak"
] | false | 0.068688 | 0.151946 | 0.452057 | [
"s538880241",
"s417921063"
] |
u649373416 | p03283 | python | s231229453 | s483126940 | 2,662 | 1,802 | 57,048 | 113,880 | Accepted | Accepted | 32.31 | N,M,Q = [ int(it) for it in input().split()]
grid = [ [0]*N for i in range(N) ]
gridsml = [ [0]*N for i in range(N) ]
for i in range(M):
s,g = [ int(it)-1 for it in input().split()]
grid[s][g]+=1
for i in range(N):
gridsml[i][0]=grid[i][0]
for j in range(1,N):
gridsml[i][j]+=gridsml[i][j-1]+grid[i][j]
for i in range(Q):
s,g = [ int(it)-1 for it in input().split()]
m = 0
for i in range(s,N):
m += gridsml[i][g]
print (m) | N,M,Q = [ int(it) for it in input().split() ]
lit = [ [ int(it)-1 for it in input().split() ] for i in range(M) ]
liq = [ [ int(it)-1 for it in input().split() ] for i in range(Q) ]
li = [[0]*(N+1) for i in range(N+1)]
for p,q in lit:
li[p+1][q+1]+=1
for i in range(N+1):
for j in range(N):
li[i][j+1] += li[i][j]
for p,q in liq:
s = 0
for i in range(p+1,N+1):
s += li[i][q+1]
print (s)
| 21 | 20 | 471 | 439 | N, M, Q = [int(it) for it in input().split()]
grid = [[0] * N for i in range(N)]
gridsml = [[0] * N for i in range(N)]
for i in range(M):
s, g = [int(it) - 1 for it in input().split()]
grid[s][g] += 1
for i in range(N):
gridsml[i][0] = grid[i][0]
for j in range(1, N):
gridsml[i][j] += gridsml[i][j - 1] + grid[i][j]
for i in range(Q):
s, g = [int(it) - 1 for it in input().split()]
m = 0
for i in range(s, N):
m += gridsml[i][g]
print(m)
| N, M, Q = [int(it) for it in input().split()]
lit = [[int(it) - 1 for it in input().split()] for i in range(M)]
liq = [[int(it) - 1 for it in input().split()] for i in range(Q)]
li = [[0] * (N + 1) for i in range(N + 1)]
for p, q in lit:
li[p + 1][q + 1] += 1
for i in range(N + 1):
for j in range(N):
li[i][j + 1] += li[i][j]
for p, q in liq:
s = 0
for i in range(p + 1, N + 1):
s += li[i][q + 1]
print(s)
| false | 4.761905 | [
"-grid = [[0] * N for i in range(N)]",
"-gridsml = [[0] * N for i in range(N)]",
"-for i in range(M):",
"- s, g = [int(it) - 1 for it in input().split()]",
"- grid[s][g] += 1",
"-for i in range(N):",
"- gridsml[i][0] = grid[i][0]",
"- for j in range(1, N):",
"- gridsml[i][j] += gridsml[i][j - 1] + grid[i][j]",
"-for i in range(Q):",
"- s, g = [int(it) - 1 for it in input().split()]",
"- m = 0",
"- for i in range(s, N):",
"- m += gridsml[i][g]",
"- print(m)",
"+lit = [[int(it) - 1 for it in input().split()] for i in range(M)]",
"+liq = [[int(it) - 1 for it in input().split()] for i in range(Q)]",
"+li = [[0] * (N + 1) for i in range(N + 1)]",
"+for p, q in lit:",
"+ li[p + 1][q + 1] += 1",
"+for i in range(N + 1):",
"+ for j in range(N):",
"+ li[i][j + 1] += li[i][j]",
"+for p, q in liq:",
"+ s = 0",
"+ for i in range(p + 1, N + 1):",
"+ s += li[i][q + 1]",
"+ print(s)"
] | false | 0.036719 | 0.08006 | 0.458641 | [
"s231229453",
"s483126940"
] |
u785578220 | p02546 | python | s886567319 | s464094049 | 29 | 26 | 9,088 | 9,024 | Accepted | Accepted | 10.34 | a = eval(input())
if a[-1] == "s" :print((a+"es"))
else :print((a+"s")) | a = eval(input())
print((a + "e"*(a[-1]=='s') + 's')) | 3 | 2 | 63 | 46 | a = eval(input())
if a[-1] == "s":
print((a + "es"))
else:
print((a + "s"))
| a = eval(input())
print((a + "e" * (a[-1] == "s") + "s"))
| false | 33.333333 | [
"-if a[-1] == \"s\":",
"- print((a + \"es\"))",
"-else:",
"- print((a + \"s\"))",
"+print((a + \"e\" * (a[-1] == \"s\") + \"s\"))"
] | false | 0.075795 | 0.089838 | 0.843689 | [
"s886567319",
"s464094049"
] |
u076503518 | p03221 | python | s096518887 | s084036010 | 728 | 612 | 31,180 | 38,444 | Accepted | Accepted | 15.93 | N, M = list(map(int, input().split()))
A = []
B = []
for i in range(M):
p, y = list(map(int, input().split()))
A.append([p, y, i])
A.sort()
cur = 1
cnt = 1
for i in range(M):
if A[i][0] == cur:
A[i].append(cnt)
cnt += 1
else:
cur = A[i][0]
cnt = 1
A[i].append(cnt)
cnt += 1
A.sort(key=lambda x: x[2])
for a in A:
print(("%06d%06d" % (a[0], a[3]))) | from collections import defaultdict
from bisect import bisect_left
N, M = list(map(int, input().split()))
A = []
B = defaultdict(list)
for i in range(M):
p, y = list(map(int, input().split()))
A.append([p, y])
B[p].append(y)
for key in list(B.keys()):
B[key].sort()
for a in A:
print(("%06d%06d" % (a[0], bisect_left(B[a[0]], a[1])+1))) | 23 | 17 | 425 | 356 | N, M = list(map(int, input().split()))
A = []
B = []
for i in range(M):
p, y = list(map(int, input().split()))
A.append([p, y, i])
A.sort()
cur = 1
cnt = 1
for i in range(M):
if A[i][0] == cur:
A[i].append(cnt)
cnt += 1
else:
cur = A[i][0]
cnt = 1
A[i].append(cnt)
cnt += 1
A.sort(key=lambda x: x[2])
for a in A:
print(("%06d%06d" % (a[0], a[3])))
| from collections import defaultdict
from bisect import bisect_left
N, M = list(map(int, input().split()))
A = []
B = defaultdict(list)
for i in range(M):
p, y = list(map(int, input().split()))
A.append([p, y])
B[p].append(y)
for key in list(B.keys()):
B[key].sort()
for a in A:
print(("%06d%06d" % (a[0], bisect_left(B[a[0]], a[1]) + 1)))
| false | 26.086957 | [
"+from collections import defaultdict",
"+from bisect import bisect_left",
"+",
"-B = []",
"+B = defaultdict(list)",
"- A.append([p, y, i])",
"-A.sort()",
"-cur = 1",
"-cnt = 1",
"-for i in range(M):",
"- if A[i][0] == cur:",
"- A[i].append(cnt)",
"- cnt += 1",
"- else:",
"- cur = A[i][0]",
"- cnt = 1",
"- A[i].append(cnt)",
"- cnt += 1",
"-A.sort(key=lambda x: x[2])",
"+ A.append([p, y])",
"+ B[p].append(y)",
"+for key in list(B.keys()):",
"+ B[key].sort()",
"- print((\"%06d%06d\" % (a[0], a[3])))",
"+ print((\"%06d%06d\" % (a[0], bisect_left(B[a[0]], a[1]) + 1)))"
] | false | 0.037435 | 0.037496 | 0.998358 | [
"s096518887",
"s084036010"
] |
u707187541 | p02584 | python | s995060504 | s902411009 | 72 | 27 | 61,960 | 9,152 | Accepted | Accepted | 62.5 | def pm(x):
if X>=0:
return 1
else:
return -1
X,K,D=list(map(int,input().split()))
if (abs(X))<D :
if K%2==0:
print((int(abs(X))))
else:
a=X-pm(X)*D
print((int(abs(a))))
else:
if abs(X)//D>=K:
a=X-(pm(X))*D*K
print((int(abs(a))))
else:
K=K-int(abs(X)//D)
X=X-(pm(X))*D*int(abs(X)//D)
if (abs(X))<D :
if K%2==0:
print((int(abs(X))))
else:
a=X-(pm(X))*D
print((int(abs(a)))) | def pm(x):
if x>=0:
return 1
else:
return -1
X,K,D=list(map(int,input().split()))
if (abs(X))<D :
if K%2==0:
print((int(abs(X))))
else:
a=X-pm(X)*D
print((int(abs(a))))
else:
if abs(X)//D>=K:
a=X-(pm(X))*D*K
print((int(abs(a))))
else:
K=K-int(abs(X)//D)
X=X-(pm(X))*D*int(abs(X)//D)
if (abs(X))<D :
if K%2==0:
print((int(abs(X))))
else:
a=X-(pm(X))*D
print((int(abs(a)))) | 25 | 25 | 467 | 467 | def pm(x):
if X >= 0:
return 1
else:
return -1
X, K, D = list(map(int, input().split()))
if (abs(X)) < D:
if K % 2 == 0:
print((int(abs(X))))
else:
a = X - pm(X) * D
print((int(abs(a))))
else:
if abs(X) // D >= K:
a = X - (pm(X)) * D * K
print((int(abs(a))))
else:
K = K - int(abs(X) // D)
X = X - (pm(X)) * D * int(abs(X) // D)
if (abs(X)) < D:
if K % 2 == 0:
print((int(abs(X))))
else:
a = X - (pm(X)) * D
print((int(abs(a))))
| def pm(x):
if x >= 0:
return 1
else:
return -1
X, K, D = list(map(int, input().split()))
if (abs(X)) < D:
if K % 2 == 0:
print((int(abs(X))))
else:
a = X - pm(X) * D
print((int(abs(a))))
else:
if abs(X) // D >= K:
a = X - (pm(X)) * D * K
print((int(abs(a))))
else:
K = K - int(abs(X) // D)
X = X - (pm(X)) * D * int(abs(X) // D)
if (abs(X)) < D:
if K % 2 == 0:
print((int(abs(X))))
else:
a = X - (pm(X)) * D
print((int(abs(a))))
| false | 0 | [
"- if X >= 0:",
"+ if x >= 0:"
] | false | 0.096782 | 0.115742 | 0.836192 | [
"s995060504",
"s902411009"
] |
u969190727 | p03476 | python | s611697077 | s829905530 | 1,980 | 319 | 6,716 | 5,476 | Accepted | Accepted | 83.89 | q=int(eval(input()))
P2017=[]
def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return [i for i in range(n + 1) if is_prime[i]]
P=primes(10**5)
for p in P:
if (p+1)//2 in P:
P2017.append(p)
LR=[0]*(10**5)
for p in P2017:
LR[p]+=1
for i in range(10**5-1):
LR[i+1]+=LR[i]
for i in range(q):
l,r=list(map(int,input().split()))
print((LR[r]-LR[l-1])) | import sys
input=lambda: sys.stdin.readline().rstrip()
n=10**5
is_prime=[True]*(n+1)
is_prime[0]=False
is_prime[1]=False
for i in range(2,int(n**0.5)+1):
if not is_prime[i]:
continue
for j in range(i*2,n+1,i):
is_prime[j]=False
A=[0]*n
def f(x):
return is_prime[x] and is_prime[(x+1)//2]
for i in range(3,n,2):
if f(i):
A[i]=A[i-2]+1
else:
A[i]=A[i-2]
A=[0]+A
q=int(eval(input()))
for _ in range(q):
l,r=list(map(int,input().split()))
print((A[r+1]-A[l-1]))
| 24 | 25 | 580 | 499 | q = int(eval(input()))
P2017 = []
def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return [i for i in range(n + 1) if is_prime[i]]
P = primes(10**5)
for p in P:
if (p + 1) // 2 in P:
P2017.append(p)
LR = [0] * (10**5)
for p in P2017:
LR[p] += 1
for i in range(10**5 - 1):
LR[i + 1] += LR[i]
for i in range(q):
l, r = list(map(int, input().split()))
print((LR[r] - LR[l - 1]))
| import sys
input = lambda: sys.stdin.readline().rstrip()
n = 10**5
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
A = [0] * n
def f(x):
return is_prime[x] and is_prime[(x + 1) // 2]
for i in range(3, n, 2):
if f(i):
A[i] = A[i - 2] + 1
else:
A[i] = A[i - 2]
A = [0] + A
q = int(eval(input()))
for _ in range(q):
l, r = list(map(int, input().split()))
print((A[r + 1] - A[l - 1]))
| false | 4 | [
"-q = int(eval(input()))",
"-P2017 = []",
"+import sys",
"+",
"+input = lambda: sys.stdin.readline().rstrip()",
"+n = 10**5",
"+is_prime = [True] * (n + 1)",
"+is_prime[0] = False",
"+is_prime[1] = False",
"+for i in range(2, int(n**0.5) + 1):",
"+ if not is_prime[i]:",
"+ continue",
"+ for j in range(i * 2, n + 1, i):",
"+ is_prime[j] = False",
"+A = [0] * n",
"-def primes(n):",
"- is_prime = [True] * (n + 1)",
"- is_prime[0] = False",
"- is_prime[1] = False",
"- for i in range(2, int(n**0.5) + 1):",
"- if not is_prime[i]:",
"- continue",
"- for j in range(i * 2, n + 1, i):",
"- is_prime[j] = False",
"- return [i for i in range(n + 1) if is_prime[i]]",
"+def f(x):",
"+ return is_prime[x] and is_prime[(x + 1) // 2]",
"-P = primes(10**5)",
"-for p in P:",
"- if (p + 1) // 2 in P:",
"- P2017.append(p)",
"-LR = [0] * (10**5)",
"-for p in P2017:",
"- LR[p] += 1",
"-for i in range(10**5 - 1):",
"- LR[i + 1] += LR[i]",
"-for i in range(q):",
"+for i in range(3, n, 2):",
"+ if f(i):",
"+ A[i] = A[i - 2] + 1",
"+ else:",
"+ A[i] = A[i - 2]",
"+A = [0] + A",
"+q = int(eval(input()))",
"+for _ in range(q):",
"- print((LR[r] - LR[l - 1]))",
"+ print((A[r + 1] - A[l - 1]))"
] | false | 1.090478 | 0.133095 | 8.19323 | [
"s611697077",
"s829905530"
] |
u297574184 | p02912 | python | s324742195 | s456136889 | 302 | 147 | 14,184 | 14,180 | Accepted | Accepted | 51.32 | from heapq import heapify, heappush, heappop
N, M = list(map(int, input().split()))
As = list(map(int, input().split()))
PQ = [-A for A in As]
heapify(PQ)
for _ in range(M):
A = -heappop(PQ)
heappush(PQ, -A/2)
ans = 0
while PQ:
A = -heappop(PQ)
ans += int(A)
print(ans)
| from heapq import heapify, heappush, heappop
N, M = list(map(int, input().split()))
As = list(map(int, input().split()))
PQ = [-A for A in As]
heapify(PQ)
for _ in range(M):
A = -heappop(PQ)
heappush(PQ, -(A//2))
#print('PQ:', PQ)
print((-sum(PQ)))
| 18 | 15 | 302 | 268 | from heapq import heapify, heappush, heappop
N, M = list(map(int, input().split()))
As = list(map(int, input().split()))
PQ = [-A for A in As]
heapify(PQ)
for _ in range(M):
A = -heappop(PQ)
heappush(PQ, -A / 2)
ans = 0
while PQ:
A = -heappop(PQ)
ans += int(A)
print(ans)
| from heapq import heapify, heappush, heappop
N, M = list(map(int, input().split()))
As = list(map(int, input().split()))
PQ = [-A for A in As]
heapify(PQ)
for _ in range(M):
A = -heappop(PQ)
heappush(PQ, -(A // 2))
# print('PQ:', PQ)
print((-sum(PQ)))
| false | 16.666667 | [
"- heappush(PQ, -A / 2)",
"-ans = 0",
"-while PQ:",
"- A = -heappop(PQ)",
"- ans += int(A)",
"-print(ans)",
"+ heappush(PQ, -(A // 2))",
"+# print('PQ:', PQ)",
"+print((-sum(PQ)))"
] | false | 0.054006 | 0.139273 | 0.38777 | [
"s324742195",
"s456136889"
] |
u133936772 | p03087 | python | s599386779 | s261607670 | 1,047 | 892 | 52,204 | 7,748 | Accepted | Accepted | 14.8 | f = lambda : list(map(int,input().split()))
n, q = f()
s = eval(input())
cnt = 0
ln = [0]*n
for i in range(1,n):
if s[i-1:i+1] == 'AC':
cnt += 1
ln[i] = cnt
for _ in range(q):
l, r = f()
print((ln[r-1]-ln[l-1])) | f = lambda : list(map(int,input().split()))
n, q = f()
s = eval(input())
ln = [0]*n
for i in range(1,n):
ln[i] = ln[i-1] + (s[i-1:i+1]=='AC')
for _ in range(q):
l, r = f()
print((ln[r-1]-ln[l-1])) | 14 | 12 | 224 | 202 | f = lambda: list(map(int, input().split()))
n, q = f()
s = eval(input())
cnt = 0
ln = [0] * n
for i in range(1, n):
if s[i - 1 : i + 1] == "AC":
cnt += 1
ln[i] = cnt
for _ in range(q):
l, r = f()
print((ln[r - 1] - ln[l - 1]))
| f = lambda: list(map(int, input().split()))
n, q = f()
s = eval(input())
ln = [0] * n
for i in range(1, n):
ln[i] = ln[i - 1] + (s[i - 1 : i + 1] == "AC")
for _ in range(q):
l, r = f()
print((ln[r - 1] - ln[l - 1]))
| false | 14.285714 | [
"-cnt = 0",
"- if s[i - 1 : i + 1] == \"AC\":",
"- cnt += 1",
"- ln[i] = cnt",
"+ ln[i] = ln[i - 1] + (s[i - 1 : i + 1] == \"AC\")"
] | false | 0.041776 | 0.038151 | 1.095028 | [
"s599386779",
"s261607670"
] |
u561231954 | p03142 | python | s205771303 | s170211228 | 600 | 449 | 48,972 | 30,096 | Accepted | Accepted | 25.17 | INF = 10 ** 15
MOD = 10 ** 9 + 7
from collections import deque
def main():
N,M = list(map(int,input().split()))
G = [[] for _ in range(N)]
G_inv = [[] for _ in range(N)]
deg = [0] * N
for _ in range(N + M - 1):
a,b = list(map(int,input().split()))
a -= 1
b -= 1
deg[b] += 1
G[a].append(b)
G_inv[b].append(a)
for i in range(N):
if deg[i] == 0:
root = i
break
q = deque([root])
dist = [0] * N
while q:
v = q.popleft()
for e in G[v]:
dist[e] = dist[v] + 1
deg[e] -= 1
if deg[e] == 0:
q.append(e)
parents = [0] * N
for i in range(N):
if i == root:
continue
for e in G_inv[i]:
if dist[e] + 1 == dist[i]:
parents[i] = e + 1
break
print(('\n'.join(map(str,parents))))
if __name__ == '__main__':
main() | import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
from collections import deque,defaultdict,Counter
def main():
N,M = list(map(int,input().split()))
G = [[] for _ in range(N)]
deg = [0] * N
for _ in range(M + N - 1):
a,b = list(map(int,input().split()))
a -= 1
b -= 1
deg[b] += 1
G[a].append(b)
ans = [-1] * N
for i in range(N):
if deg[i] == 0:
root = i
ans[root] = 0
break
q = deque([root])
while q:
v = q.popleft()
for e in G[v]:
deg[e] -= 1
if deg[e] == 0:
ans[e] = v + 1
q.append(e)
print(('\n'.join(map(str,ans))))
if __name__ == '__main__':
main() | 43 | 35 | 1,004 | 806 | INF = 10**15
MOD = 10**9 + 7
from collections import deque
def main():
N, M = list(map(int, input().split()))
G = [[] for _ in range(N)]
G_inv = [[] for _ in range(N)]
deg = [0] * N
for _ in range(N + M - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
deg[b] += 1
G[a].append(b)
G_inv[b].append(a)
for i in range(N):
if deg[i] == 0:
root = i
break
q = deque([root])
dist = [0] * N
while q:
v = q.popleft()
for e in G[v]:
dist[e] = dist[v] + 1
deg[e] -= 1
if deg[e] == 0:
q.append(e)
parents = [0] * N
for i in range(N):
if i == root:
continue
for e in G_inv[i]:
if dist[e] + 1 == dist[i]:
parents[i] = e + 1
break
print(("\n".join(map(str, parents))))
if __name__ == "__main__":
main()
| import sys
sys.setrecursionlimit(10000000)
MOD = 10**9 + 7
INF = 10**15
from collections import deque, defaultdict, Counter
def main():
N, M = list(map(int, input().split()))
G = [[] for _ in range(N)]
deg = [0] * N
for _ in range(M + N - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
deg[b] += 1
G[a].append(b)
ans = [-1] * N
for i in range(N):
if deg[i] == 0:
root = i
ans[root] = 0
break
q = deque([root])
while q:
v = q.popleft()
for e in G[v]:
deg[e] -= 1
if deg[e] == 0:
ans[e] = v + 1
q.append(e)
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| false | 18.604651 | [
"+import sys",
"+",
"+sys.setrecursionlimit(10000000)",
"+MOD = 10**9 + 7",
"-MOD = 10**9 + 7",
"-from collections import deque",
"+from collections import deque, defaultdict, Counter",
"- G_inv = [[] for _ in range(N)]",
"- for _ in range(N + M - 1):",
"+ for _ in range(M + N - 1):",
"- G_inv[b].append(a)",
"+ ans = [-1] * N",
"+ ans[root] = 0",
"- dist = [0] * N",
"- dist[e] = dist[v] + 1",
"+ ans[e] = v + 1",
"- parents = [0] * N",
"- for i in range(N):",
"- if i == root:",
"- continue",
"- for e in G_inv[i]:",
"- if dist[e] + 1 == dist[i]:",
"- parents[i] = e + 1",
"- break",
"- print((\"\\n\".join(map(str, parents))))",
"+ print((\"\\n\".join(map(str, ans))))"
] | false | 0.08136 | 0.081885 | 0.993589 | [
"s205771303",
"s170211228"
] |
u077898957 | p03012 | python | s542664262 | s400438979 | 395 | 18 | 21,180 | 3,064 | Accepted | Accepted | 95.44 | import numpy as np
import sys
n = int(eval(input()))
w = list(map(int,input().split()))
print((min(abs(sum(w[:i+1])-sum(w[i+1:])) for i in range(n-1))))
| n=int(eval(input()))
W=list(map(int,input().split()))
ans=100
for i in range(n):
lw=sum(W[:i+1])
rw=sum(W[i+1:])
ans=min(ans,abs(lw-rw))
print(ans) | 5 | 8 | 149 | 160 | import numpy as np
import sys
n = int(eval(input()))
w = list(map(int, input().split()))
print((min(abs(sum(w[: i + 1]) - sum(w[i + 1 :])) for i in range(n - 1))))
| n = int(eval(input()))
W = list(map(int, input().split()))
ans = 100
for i in range(n):
lw = sum(W[: i + 1])
rw = sum(W[i + 1 :])
ans = min(ans, abs(lw - rw))
print(ans)
| false | 37.5 | [
"-import numpy as np",
"-import sys",
"-",
"-w = list(map(int, input().split()))",
"-print((min(abs(sum(w[: i + 1]) - sum(w[i + 1 :])) for i in range(n - 1))))",
"+W = list(map(int, input().split()))",
"+ans = 100",
"+for i in range(n):",
"+ lw = sum(W[: i + 1])",
"+ rw = sum(W[i + 1 :])",
"+ ans = min(ans, abs(lw - rw))",
"+print(ans)"
] | false | 0.107902 | 0.035276 | 3.05878 | [
"s542664262",
"s400438979"
] |
u767821815 | p02608 | python | s714285234 | s431318717 | 826 | 250 | 9,256 | 9,224 | Accepted | Accepted | 69.73 | n = int(eval(input()))
A = [0]*(n+1)
for x in range(1,101):
for y in range(1,101):
for z in range(1,101):
a = x**2+y**2+z**2+x*y+y*z+z*x
if a <= n:
A[a] += 1
for i in range(n):
print((A[i+1]))
| n = int(eval(input()))
A = [0]*(n+1)
for x in range(1,101):
for y in range(1,101):
for z in range(1,101):
a = x**2+y**2+z**2+x*y+y*z+z*x
if a <= n:
A[a] += 1
else:
break
for i in range(n):
print((A[i+1]))
| 13 | 16 | 280 | 336 | n = int(eval(input()))
A = [0] * (n + 1)
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
a = x**2 + y**2 + z**2 + x * y + y * z + z * x
if a <= n:
A[a] += 1
for i in range(n):
print((A[i + 1]))
| n = int(eval(input()))
A = [0] * (n + 1)
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
a = x**2 + y**2 + z**2 + x * y + y * z + z * x
if a <= n:
A[a] += 1
else:
break
for i in range(n):
print((A[i + 1]))
| false | 18.75 | [
"+ else:",
"+ break"
] | false | 1.961049 | 0.107595 | 18.22623 | [
"s714285234",
"s431318717"
] |
u745087332 | p03112 | python | s657836813 | s637452242 | 1,084 | 929 | 82,012 | 12,812 | Accepted | Accepted | 14.3 | # coding:utf-8
import sys
import bisect
# from collections import Counter, defaultdict
INF = float('inf')
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())
a, b, q = LI()
A = [-INF] + [II() for _ in range(a)] + [INF]
B = [-INF] + [II() for _ in range(b)] + [INF]
for _ in range(q):
x = II()
ans = INF
x_a = bisect.bisect_left(A, x)
for k in [-1, 0]:
tmp = abs(x - A[x_a + k])
x_b = bisect.bisect_left(B, A[x_a + k])
tmp += min(abs(B[x_b] - A[x_a + k]), abs(B[x_b - 1] - A[x_a + k]))
ans = min(ans, tmp)
x_b = bisect.bisect_left(B, x)
for k in [-1, 0]:
tmp = abs(x - B[x_b + k])
x_a = bisect.bisect_left(A, B[x_b + k])
tmp += min(abs(A[x_a] - B[x_b + k]), abs(A[x_a - 1] - B[x_b + k]))
ans = min(ans, tmp)
print(ans)
| # coding:utf-8
import sys
from bisect import bisect_left
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())
a, b, q = LI()
A = [-INF] + [II() for _ in range(a)] + [INF]
B = [-INF] + [II() for _ in range(b)] + [INF]
for _ in range(q):
x = II()
s = bisect_left(A, x)
t = bisect_left(B, x)
res = INF
for aa in [A[s - 1], A[s]]:
for bb in [B[t - 1], B[t]]:
d1 = abs(x - aa) + abs(aa - bb)
d2 = abs(x - bb) + abs(bb - aa)
res = min(res, d1, d2)
print(res)
| 38 | 32 | 1,068 | 787 | # coding:utf-8
import sys
import bisect
# from collections import Counter, defaultdict
INF = float("inf")
MOD = 10**9 + 7
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline().split()
def II():
return int(sys.stdin.readline())
def SI():
return eval(input())
a, b, q = LI()
A = [-INF] + [II() for _ in range(a)] + [INF]
B = [-INF] + [II() for _ in range(b)] + [INF]
for _ in range(q):
x = II()
ans = INF
x_a = bisect.bisect_left(A, x)
for k in [-1, 0]:
tmp = abs(x - A[x_a + k])
x_b = bisect.bisect_left(B, A[x_a + k])
tmp += min(abs(B[x_b] - A[x_a + k]), abs(B[x_b - 1] - A[x_a + k]))
ans = min(ans, tmp)
x_b = bisect.bisect_left(B, x)
for k in [-1, 0]:
tmp = abs(x - B[x_b + k])
x_a = bisect.bisect_left(A, B[x_b + k])
tmp += min(abs(A[x_a] - B[x_b + k]), abs(A[x_a - 1] - B[x_b + k]))
ans = min(ans, tmp)
print(ans)
| # coding:utf-8
import sys
from bisect import bisect_left
INF = 10**18
MOD = 10**9 + 7
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline().split()
def II():
return int(sys.stdin.readline())
def SI():
return eval(input())
a, b, q = LI()
A = [-INF] + [II() for _ in range(a)] + [INF]
B = [-INF] + [II() for _ in range(b)] + [INF]
for _ in range(q):
x = II()
s = bisect_left(A, x)
t = bisect_left(B, x)
res = INF
for aa in [A[s - 1], A[s]]:
for bb in [B[t - 1], B[t]]:
d1 = abs(x - aa) + abs(aa - bb)
d2 = abs(x - bb) + abs(bb - aa)
res = min(res, d1, d2)
print(res)
| false | 15.789474 | [
"-import bisect",
"+from bisect import bisect_left",
"-# from collections import Counter, defaultdict",
"-INF = float(\"inf\")",
"+INF = 10**18",
"- ans = INF",
"- x_a = bisect.bisect_left(A, x)",
"- for k in [-1, 0]:",
"- tmp = abs(x - A[x_a + k])",
"- x_b = bisect.bisect_left(B, A[x_a + k])",
"- tmp += min(abs(B[x_b] - A[x_a + k]), abs(B[x_b - 1] - A[x_a + k]))",
"- ans = min(ans, tmp)",
"- x_b = bisect.bisect_left(B, x)",
"- for k in [-1, 0]:",
"- tmp = abs(x - B[x_b + k])",
"- x_a = bisect.bisect_left(A, B[x_b + k])",
"- tmp += min(abs(A[x_a] - B[x_b + k]), abs(A[x_a - 1] - B[x_b + k]))",
"- ans = min(ans, tmp)",
"- print(ans)",
"+ s = bisect_left(A, x)",
"+ t = bisect_left(B, x)",
"+ res = INF",
"+ for aa in [A[s - 1], A[s]]:",
"+ for bb in [B[t - 1], B[t]]:",
"+ d1 = abs(x - aa) + abs(aa - bb)",
"+ d2 = abs(x - bb) + abs(bb - aa)",
"+ res = min(res, d1, d2)",
"+ print(res)"
] | false | 0.12184 | 0.204698 | 0.59522 | [
"s657836813",
"s637452242"
] |
u301461168 | p02271 | python | s522282617 | s889154247 | 5,820 | 630 | 79,524 | 58,252 | Accepted | Accepted | 89.18 | import itertools
numA = int(input().rstrip())
listA = list(map(int,input().rstrip().split(" ")))
numQ = int(input().rstrip())
listQ = list(map(int,input().rstrip().split(" ")))
sumA = []
cnt = 0
for i in range(1,numA+1):
tmpComb = list(itertools.combinations(listA, i))
for nums in tmpComb:
sumA.append(sum(nums))
for i in range(numQ):
if sumA.count(listQ[i]) > 0:
print("yes")
else:
print("no") | import itertools
numA = int(input().rstrip())
listA = list(map(int,input().rstrip().split(" ")))
numQ = int(input().rstrip())
listQ = list(map(int,input().rstrip().split(" ")))
sumA = set([])
cnt = 0
for i in range(1,numA+1):
tmpComb = list(itertools.combinations(listA, i))
for nums in tmpComb:
sumA.add(sum(nums))
for i in range(numQ):
if listQ[i] in sumA:
print("yes")
else:
print("no") | 22 | 22 | 462 | 462 | import itertools
numA = int(input().rstrip())
listA = list(map(int, input().rstrip().split(" ")))
numQ = int(input().rstrip())
listQ = list(map(int, input().rstrip().split(" ")))
sumA = []
cnt = 0
for i in range(1, numA + 1):
tmpComb = list(itertools.combinations(listA, i))
for nums in tmpComb:
sumA.append(sum(nums))
for i in range(numQ):
if sumA.count(listQ[i]) > 0:
print("yes")
else:
print("no")
| import itertools
numA = int(input().rstrip())
listA = list(map(int, input().rstrip().split(" ")))
numQ = int(input().rstrip())
listQ = list(map(int, input().rstrip().split(" ")))
sumA = set([])
cnt = 0
for i in range(1, numA + 1):
tmpComb = list(itertools.combinations(listA, i))
for nums in tmpComb:
sumA.add(sum(nums))
for i in range(numQ):
if listQ[i] in sumA:
print("yes")
else:
print("no")
| false | 0 | [
"-sumA = []",
"+sumA = set([])",
"- sumA.append(sum(nums))",
"+ sumA.add(sum(nums))",
"- if sumA.count(listQ[i]) > 0:",
"+ if listQ[i] in sumA:"
] | false | 0.035791 | 0.035747 | 1.001231 | [
"s522282617",
"s889154247"
] |
u576432509 | p03557 | python | s307283266 | s355966111 | 379 | 334 | 22,720 | 23,232 | Accepted | Accepted | 11.87 | icase=0
if icase==0:
n=int(eval(input())) #ๆฐๅคๅ
ฅๅ ใNใใ ใใฎๅ
ฅๅใฎใจใ
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
elif icase==1:
n=2
a=[1,5]
b=[2,4]
c=[3,6]
elif icase==2:
n=6
a=[3, 14, 159, 2, 6, 53]
b=[58, 9, 79, 323, 84, 6]
c=[2643, 383, 2, 79, 50, 288]
a.sort()
b.sort()
c.sort()
icnt=0
ast=0
cst=0
for i in range(n):
if a[n-1]<=b[i]:
ast=n
# print("a1:",ast-1,a[ast-1],i,b[i])
elif a[0]>=b[i]:
ast=0
# print("a1:",ast-1,a[ast-1],i,b[i])
else:
while a[ast]<b[i] and ast<n-1:
ast=ast+1
# print("a2:",ast-1,a[ast-1],i,b[i])
if b[i]<c[0]:
cst=0
elif b[i]>=c[n-1]:
cst=n
# print("c1:",cst,c[cst],i,b[i])
else:
while b[i]>=c[cst] and cst<n-1:
cst=cst+1
# print("c2:",cst-1,c[cst-1],i,b[i])
# print(ast,i,n-cst)
icnt=icnt+(ast)*(n-cst)
print(icnt) | from bisect import bisect_left,bisect
n=int(eval(input()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
lenc=len(c)
a.sort()
b.sort()
c.sort()
jsum=0
for j in b:
ai=bisect(a,j-1)
ci=lenc-bisect_left(c,j+1)
# print(j,ai,ci)
jsum+=ai*ci
print(jsum) | 48 | 20 | 1,045 | 333 | icase = 0
if icase == 0:
n = int(eval(input())) # ๆฐๅคๅ
ฅๅ ใNใใ ใใฎๅ
ฅๅใฎใจใ
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
elif icase == 1:
n = 2
a = [1, 5]
b = [2, 4]
c = [3, 6]
elif icase == 2:
n = 6
a = [3, 14, 159, 2, 6, 53]
b = [58, 9, 79, 323, 84, 6]
c = [2643, 383, 2, 79, 50, 288]
a.sort()
b.sort()
c.sort()
icnt = 0
ast = 0
cst = 0
for i in range(n):
if a[n - 1] <= b[i]:
ast = n
# print("a1:",ast-1,a[ast-1],i,b[i])
elif a[0] >= b[i]:
ast = 0
# print("a1:",ast-1,a[ast-1],i,b[i])
else:
while a[ast] < b[i] and ast < n - 1:
ast = ast + 1
# print("a2:",ast-1,a[ast-1],i,b[i])
if b[i] < c[0]:
cst = 0
elif b[i] >= c[n - 1]:
cst = n
# print("c1:",cst,c[cst],i,b[i])
else:
while b[i] >= c[cst] and cst < n - 1:
cst = cst + 1
# print("c2:",cst-1,c[cst-1],i,b[i])
# print(ast,i,n-cst)
icnt = icnt + (ast) * (n - cst)
print(icnt)
| from bisect import bisect_left, bisect
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
lenc = len(c)
a.sort()
b.sort()
c.sort()
jsum = 0
for j in b:
ai = bisect(a, j - 1)
ci = lenc - bisect_left(c, j + 1)
# print(j,ai,ci)
jsum += ai * ci
print(jsum)
| false | 58.333333 | [
"-icase = 0",
"-if icase == 0:",
"- n = int(eval(input())) # ๆฐๅคๅ
ฅๅ ใNใใ ใใฎๅ
ฅๅใฎใจใ",
"- a = list(map(int, input().split()))",
"- b = list(map(int, input().split()))",
"- c = list(map(int, input().split()))",
"-elif icase == 1:",
"- n = 2",
"- a = [1, 5]",
"- b = [2, 4]",
"- c = [3, 6]",
"-elif icase == 2:",
"- n = 6",
"- a = [3, 14, 159, 2, 6, 53]",
"- b = [58, 9, 79, 323, 84, 6]",
"- c = [2643, 383, 2, 79, 50, 288]",
"+from bisect import bisect_left, bisect",
"+",
"+n = int(eval(input()))",
"+a = list(map(int, input().split()))",
"+b = list(map(int, input().split()))",
"+c = list(map(int, input().split()))",
"+lenc = len(c)",
"-icnt = 0",
"-ast = 0",
"-cst = 0",
"-for i in range(n):",
"- if a[n - 1] <= b[i]:",
"- ast = n",
"- # print(\"a1:\",ast-1,a[ast-1],i,b[i])",
"- elif a[0] >= b[i]:",
"- ast = 0",
"- # print(\"a1:\",ast-1,a[ast-1],i,b[i])",
"- else:",
"- while a[ast] < b[i] and ast < n - 1:",
"- ast = ast + 1",
"- # print(\"a2:\",ast-1,a[ast-1],i,b[i])",
"- if b[i] < c[0]:",
"- cst = 0",
"- elif b[i] >= c[n - 1]:",
"- cst = n",
"- # print(\"c1:\",cst,c[cst],i,b[i])",
"- else:",
"- while b[i] >= c[cst] and cst < n - 1:",
"- cst = cst + 1",
"- # print(\"c2:\",cst-1,c[cst-1],i,b[i])",
"- # print(ast,i,n-cst)",
"- icnt = icnt + (ast) * (n - cst)",
"-print(icnt)",
"+jsum = 0",
"+for j in b:",
"+ ai = bisect(a, j - 1)",
"+ ci = lenc - bisect_left(c, j + 1)",
"+ # print(j,ai,ci)",
"+ jsum += ai * ci",
"+print(jsum)"
] | false | 0.040057 | 0.048805 | 0.820766 | [
"s307283266",
"s355966111"
] |
u197237612 | p02570 | python | s827571926 | s881632839 | 34 | 26 | 9,144 | 9,104 | Accepted | Accepted | 23.53 | d, t, s = list(map(int, input().split()))
ans = d / s
if t >= ans:
print("Yes")
else:
print("No")
| D, T, S = list(map(int, input().split()))
if D/S <= T:
print("Yes")
else:
print("No") | 8 | 6 | 111 | 89 | d, t, s = list(map(int, input().split()))
ans = d / s
if t >= ans:
print("Yes")
else:
print("No")
| D, T, S = list(map(int, input().split()))
if D / S <= T:
print("Yes")
else:
print("No")
| false | 25 | [
"-d, t, s = list(map(int, input().split()))",
"-ans = d / s",
"-if t >= ans:",
"+D, T, S = list(map(int, input().split()))",
"+if D / S <= T:"
] | false | 0.067167 | 0.037506 | 1.790822 | [
"s827571926",
"s881632839"
] |
u996672406 | p03069 | python | s961470465 | s951804177 | 95 | 77 | 3,500 | 3,500 | Accepted | Accepted | 18.95 | n = int(eval(input()))
minv = res = rd = 0
for e in eval(input()):
if e == ".":
res += 1
rd -= 1
minv = min(minv, rd)
else:
rd += 1
print((res + minv))
| eval(input())
minv = res = rd = 0
for e in eval(input()):
if e == ".":
res += 1
rd -= 1
if rd < minv:
minv = rd
else:
rd += 1
print((res + minv))
| 12 | 13 | 191 | 198 | n = int(eval(input()))
minv = res = rd = 0
for e in eval(input()):
if e == ".":
res += 1
rd -= 1
minv = min(minv, rd)
else:
rd += 1
print((res + minv))
| eval(input())
minv = res = rd = 0
for e in eval(input()):
if e == ".":
res += 1
rd -= 1
if rd < minv:
minv = rd
else:
rd += 1
print((res + minv))
| false | 7.692308 | [
"-n = int(eval(input()))",
"+eval(input())",
"- minv = min(minv, rd)",
"+ if rd < minv:",
"+ minv = rd"
] | false | 0.049895 | 0.048791 | 1.02262 | [
"s961470465",
"s951804177"
] |
u188827677 | p02702 | python | s002316497 | s649060911 | 138 | 111 | 16,924 | 9,368 | Accepted | Accepted | 19.57 | import collections
s = eval(input())
n = len(s)
m = [0]
mod = 0
ten = 1
for i in s[::-1]:
mod += (int(i)*ten)%2019
mod %= 2019
m.append(mod)
ten *= 10
ten %= 2019
count = collections.Counter(m)
print((sum([c*(c-1)//2 for c in list(count.values())])))
| s = input()[::-1]
counts = [0]*2019 # ๅฐไฝใฎไฝใใฎๅๆฐใไฟๅญ
counts[0] = 1 # 0%2019ใ็ดฏ็ฉๅใจใใฆๅซใใใใจใๆณๅฎ
num, d = 0,1 # numใฏไฝใใฎ็ดฏ็ฉๅใdใฏcharใฎๆกๆฐ
'''
charใซไธๆกใใคๅใๅบใใใใฎmod2019ใ่ใใ็ดฏ็ฉๅใใจใใ
ใใใใใใใใใฎๆฐๅญใซใฏ10ใฎ็ดฏไนใใใใฃใฆใใใฎใงใใใใซใคใใฆใฏๅฅ้dใ็จๆใใฆmod2019ใใจใ
ใคใพใใnumใฏ1ๆก็ฎใฎmod2019ใ2ๆก็ฎใฎmod2019ใซ1ๆก็ฎใฎmod2019ใๅ ใใ
'''
for char in s:
num += int(char) * d
num %= 2019
d *= 10
d %= 2019
counts[num] += 1
ans = 0
for c in counts:
ans += c*(c-1)//2
print(ans) | 17 | 23 | 268 | 445 | import collections
s = eval(input())
n = len(s)
m = [0]
mod = 0
ten = 1
for i in s[::-1]:
mod += (int(i) * ten) % 2019
mod %= 2019
m.append(mod)
ten *= 10
ten %= 2019
count = collections.Counter(m)
print((sum([c * (c - 1) // 2 for c in list(count.values())])))
| s = input()[::-1]
counts = [0] * 2019 # ๅฐไฝใฎไฝใใฎๅๆฐใไฟๅญ
counts[0] = 1 # 0%2019ใ็ดฏ็ฉๅใจใใฆๅซใใใใจใๆณๅฎ
num, d = 0, 1 # numใฏไฝใใฎ็ดฏ็ฉๅใdใฏcharใฎๆกๆฐ
"""
charใซไธๆกใใคๅใๅบใใใใฎmod2019ใ่ใใ็ดฏ็ฉๅใใจใใ
ใใใใใใใใใฎๆฐๅญใซใฏ10ใฎ็ดฏไนใใใใฃใฆใใใฎใงใใใใซใคใใฆใฏๅฅ้dใ็จๆใใฆmod2019ใใจใ
ใคใพใใnumใฏ1ๆก็ฎใฎmod2019ใ2ๆก็ฎใฎmod2019ใซ1ๆก็ฎใฎmod2019ใๅ ใใ
"""
for char in s:
num += int(char) * d
num %= 2019
d *= 10
d %= 2019
counts[num] += 1
ans = 0
for c in counts:
ans += c * (c - 1) // 2
print(ans)
| false | 26.086957 | [
"-import collections",
"-",
"-s = eval(input())",
"-n = len(s)",
"-m = [0]",
"-mod = 0",
"-ten = 1",
"-for i in s[::-1]:",
"- mod += (int(i) * ten) % 2019",
"- mod %= 2019",
"- m.append(mod)",
"- ten *= 10",
"- ten %= 2019",
"-count = collections.Counter(m)",
"-print((sum([c * (c - 1) // 2 for c in list(count.values())])))",
"+s = input()[::-1]",
"+counts = [0] * 2019 # ๅฐไฝใฎไฝใใฎๅๆฐใไฟๅญ",
"+counts[0] = 1 # 0%2019ใ็ดฏ็ฉๅใจใใฆๅซใใใใจใๆณๅฎ",
"+num, d = 0, 1 # numใฏไฝใใฎ็ดฏ็ฉๅใdใฏcharใฎๆกๆฐ",
"+\"\"\"",
"+charใซไธๆกใใคๅใๅบใใใใฎmod2019ใ่ใใ็ดฏ็ฉๅใใจใใ",
"+ใใใใใใใใใฎๆฐๅญใซใฏ10ใฎ็ดฏไนใใใใฃใฆใใใฎใงใใใใซใคใใฆใฏๅฅ้dใ็จๆใใฆmod2019ใใจใ",
"+ใคใพใใnumใฏ1ๆก็ฎใฎmod2019ใ2ๆก็ฎใฎmod2019ใซ1ๆก็ฎใฎmod2019ใๅ ใใ",
"+\"\"\"",
"+for char in s:",
"+ num += int(char) * d",
"+ num %= 2019",
"+ d *= 10",
"+ d %= 2019",
"+ counts[num] += 1",
"+ans = 0",
"+for c in counts:",
"+ ans += c * (c - 1) // 2",
"+print(ans)"
] | false | 0.036459 | 0.036354 | 1.002882 | [
"s002316497",
"s649060911"
] |
u080986047 | p03835 | python | s813231000 | s542422009 | 280 | 257 | 40,940 | 40,940 | Accepted | Accepted | 8.21 | k,s = list(map(int,input().split()))
count = 0
for x in range(k+1):
for y in range(k+1):
if 0<=s-x-y<=k:
count+=1
print(count)
| k,s = list(map(int,input().split()))
count = 0
for x in range(min(s+1,k+1)):
for y in range(min(s+1-x,k+1)):
if 0<=s-x-y<=k:
count+=1
print(count) | 7 | 7 | 151 | 170 | k, s = list(map(int, input().split()))
count = 0
for x in range(k + 1):
for y in range(k + 1):
if 0 <= s - x - y <= k:
count += 1
print(count)
| k, s = list(map(int, input().split()))
count = 0
for x in range(min(s + 1, k + 1)):
for y in range(min(s + 1 - x, k + 1)):
if 0 <= s - x - y <= k:
count += 1
print(count)
| false | 0 | [
"-for x in range(k + 1):",
"- for y in range(k + 1):",
"+for x in range(min(s + 1, k + 1)):",
"+ for y in range(min(s + 1 - x, k + 1)):"
] | false | 0.049486 | 0.045991 | 1.075988 | [
"s813231000",
"s542422009"
] |
u361826811 | p02898 | python | s831511962 | s845761615 | 180 | 46 | 19,464 | 10,344 | Accepted | Accepted | 74.44 | """
author : halo2halo
date : 9, Jan, 2020
"""
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
# N = int(readline())
# D = [int(d) for d in readline().split()]
import numpy as np
N, K = list(map(int, readline().split()))
h = [int(x) for x in readline().split()]
print((len([x for x in h if x-K >= 0])))
| """
author : halo2halo
date : 9, Jan, 2020
"""
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
N, K, *H = list(map(int, read().split()))
print((sum(x >= K for x in H)))
| 21 | 14 | 420 | 276 | """
author : halo2halo
date : 9, Jan, 2020
"""
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
# N = int(readline())
# D = [int(d) for d in readline().split()]
import numpy as np
N, K = list(map(int, readline().split()))
h = [int(x) for x in readline().split()]
print((len([x for x in h if x - K >= 0])))
| """
author : halo2halo
date : 9, Jan, 2020
"""
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
N, K, *H = list(map(int, read().split()))
print((sum(x >= K for x in H)))
| false | 33.333333 | [
"-# N = int(readline())",
"-# D = [int(d) for d in readline().split()]",
"-import numpy as np",
"-",
"-N, K = list(map(int, readline().split()))",
"-h = [int(x) for x in readline().split()]",
"-print((len([x for x in h if x - K >= 0])))",
"+N, K, *H = list(map(int, read().split()))",
"+print((sum(x >= K for x in H)))"
] | false | 0.066481 | 0.03832 | 1.73489 | [
"s831511962",
"s845761615"
] |
u371132735 | p03208 | python | s869215714 | s475564185 | 514 | 238 | 50,392 | 11,036 | Accepted | Accepted | 53.7 | N, K = list(map(int,input().split()))
a = []
for i in range(N):
a.append(int(eval(input())))
a.sort()
ans = 10**9 + 7
for i in range(N-K+1):
if ans > a[K-1+i] - a[i]:
ans = a[K-1+i] - a[i]
print(ans) | # 20200612_yorukatsu_c.py
N, K = list(map(int,input().split()))
M = [int(eval(input())) for i in range(N)]
M.sort()
lis = [0]*(N-K+1)
for i in range(N-K+1):
lis[i] = abs(M[i]-M[i+K-1])
print((min(lis)))
| 10 | 8 | 212 | 200 | N, K = list(map(int, input().split()))
a = []
for i in range(N):
a.append(int(eval(input())))
a.sort()
ans = 10**9 + 7
for i in range(N - K + 1):
if ans > a[K - 1 + i] - a[i]:
ans = a[K - 1 + i] - a[i]
print(ans)
| # 20200612_yorukatsu_c.py
N, K = list(map(int, input().split()))
M = [int(eval(input())) for i in range(N)]
M.sort()
lis = [0] * (N - K + 1)
for i in range(N - K + 1):
lis[i] = abs(M[i] - M[i + K - 1])
print((min(lis)))
| false | 20 | [
"+# 20200612_yorukatsu_c.py",
"-a = []",
"-for i in range(N):",
"- a.append(int(eval(input())))",
"-a.sort()",
"-ans = 10**9 + 7",
"+M = [int(eval(input())) for i in range(N)]",
"+M.sort()",
"+lis = [0] * (N - K + 1)",
"- if ans > a[K - 1 + i] - a[i]:",
"- ans = a[K - 1 + i] - a[i]",
"-print(ans)",
"+ lis[i] = abs(M[i] - M[i + K - 1])",
"+print((min(lis)))"
] | false | 0.044507 | 0.044511 | 0.999905 | [
"s869215714",
"s475564185"
] |
u919633157 | p03424 | python | s708341457 | s001035570 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | eval(input())
s=input().split()
print(('Four' if 'Y' in s else 'Three')) | n=int(eval(input()))
s=set(input().split())
print(('Three' if len(s)==3 else 'Four')) | 3 | 4 | 66 | 81 | eval(input())
s = input().split()
print(("Four" if "Y" in s else "Three"))
| n = int(eval(input()))
s = set(input().split())
print(("Three" if len(s) == 3 else "Four"))
| false | 25 | [
"-eval(input())",
"-s = input().split()",
"-print((\"Four\" if \"Y\" in s else \"Three\"))",
"+n = int(eval(input()))",
"+s = set(input().split())",
"+print((\"Three\" if len(s) == 3 else \"Four\"))"
] | false | 0.050531 | 0.048831 | 1.034818 | [
"s708341457",
"s001035570"
] |
u077291787 | p03221 | python | s556277436 | s649087156 | 647 | 430 | 46,100 | 30,600 | Accepted | Accepted | 33.54 | # ABC113C - ID
import sys
input = sys.stdin.readline
def main():
N, M = tuple(map(int, input().split()))
P = [[] for _ in range(N + 1)] # prefectures
for num in range(M):
pref, year = tuple(map(int, input().split()))
P[pref] += [(year, num)]
ans = []
P = [sorted(p) for p in P]
for pref_idx, pref in enumerate(P[1:], 1):
if pref:
for city_idx, (_, num) in enumerate(pref, 1):
x = "{:06}{:06}".format(pref_idx, city_idx)
ans += [(num, x)]
print(*[i[1] for i in sorted(ans)], sep="\n")
if __name__ == "__main__":
main()
| # ABC113C - ID
import sys
input = sys.stdin.readline
def main():
N, M = map(int, input().split())
ans, A, cnt = [""] * M, [], 1
for i in range(M):
p, y = map(int, input().split())
A += [(p, y, i)]
A.sort()
ans[A[0][2]] = "{:06}{:06}".format(A[0][0], cnt)
for i in range(1, M):
if A[i - 1][0] == A[i][0]:
cnt += 1
else:
cnt = 1
ans[A[i][2]] = "{:06}{:06}".format(A[i][0], cnt)
print(*ans, sep="\n")
if __name__ == "__main__":
main()
| 21 | 24 | 640 | 554 | # ABC113C - ID
import sys
input = sys.stdin.readline
def main():
N, M = tuple(map(int, input().split()))
P = [[] for _ in range(N + 1)] # prefectures
for num in range(M):
pref, year = tuple(map(int, input().split()))
P[pref] += [(year, num)]
ans = []
P = [sorted(p) for p in P]
for pref_idx, pref in enumerate(P[1:], 1):
if pref:
for city_idx, (_, num) in enumerate(pref, 1):
x = "{:06}{:06}".format(pref_idx, city_idx)
ans += [(num, x)]
print(*[i[1] for i in sorted(ans)], sep="\n")
if __name__ == "__main__":
main()
| # ABC113C - ID
import sys
input = sys.stdin.readline
def main():
N, M = map(int, input().split())
ans, A, cnt = [""] * M, [], 1
for i in range(M):
p, y = map(int, input().split())
A += [(p, y, i)]
A.sort()
ans[A[0][2]] = "{:06}{:06}".format(A[0][0], cnt)
for i in range(1, M):
if A[i - 1][0] == A[i][0]:
cnt += 1
else:
cnt = 1
ans[A[i][2]] = "{:06}{:06}".format(A[i][0], cnt)
print(*ans, sep="\n")
if __name__ == "__main__":
main()
| false | 12.5 | [
"- N, M = tuple(map(int, input().split()))",
"- P = [[] for _ in range(N + 1)] # prefectures",
"- for num in range(M):",
"- pref, year = tuple(map(int, input().split()))",
"- P[pref] += [(year, num)]",
"- ans = []",
"- P = [sorted(p) for p in P]",
"- for pref_idx, pref in enumerate(P[1:], 1):",
"- if pref:",
"- for city_idx, (_, num) in enumerate(pref, 1):",
"- x = \"{:06}{:06}\".format(pref_idx, city_idx)",
"- ans += [(num, x)]",
"- print(*[i[1] for i in sorted(ans)], sep=\"\\n\")",
"+ N, M = map(int, input().split())",
"+ ans, A, cnt = [\"\"] * M, [], 1",
"+ for i in range(M):",
"+ p, y = map(int, input().split())",
"+ A += [(p, y, i)]",
"+ A.sort()",
"+ ans[A[0][2]] = \"{:06}{:06}\".format(A[0][0], cnt)",
"+ for i in range(1, M):",
"+ if A[i - 1][0] == A[i][0]:",
"+ cnt += 1",
"+ else:",
"+ cnt = 1",
"+ ans[A[i][2]] = \"{:06}{:06}\".format(A[i][0], cnt)",
"+ print(*ans, sep=\"\\n\")"
] | false | 0.073662 | 0.160799 | 0.458099 | [
"s556277436",
"s649087156"
] |
u638456847 | p02763 | python | s352739765 | s742006213 | 593 | 540 | 47,400 | 46,628 | Accepted | Accepted | 8.94 | # AC: 577 msec (Python3)
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def string_to_number(a):
return 1 << (ord(a) - 97)
class SegmentTree:
def __init__(self, A):
self.n = 2**(len(A)-1).bit_length()
self.identity = 0
self.seg = [self.identity] * (2 * self.n)
for i, a in enumerate(A):
self.seg[self.n-1+i] = string_to_number(a)
for i in range(self.n-2,-1,-1):
self.seg[i] = self.seg[2*i+1] | self.seg[2*i+2]
def update(self, k, a):
k += self.n - 1
self.seg[k] = string_to_number(a)
while k:
k = (k - 1) // 2
self.seg[k] = self.seg[k*2+1] | self.seg[k*2+2]
def query(self, a, b):
if b == a:
return 1
a += self.n - 1
b += self.n - 2
res = self.identity
while b - a > 1:
if not a & 1:
res |= self.seg[a]
if b & 1:
res |= self.seg[b]
b -= 2
a >>= 1
b -= 1
b >>= 1
if a == b:
res |= self.seg[a]
else:
res |= (self.seg[a] | self.seg[b])
return bin(res).count("1")
def main():
N = int(readline())
s = readline().strip()
seg = SegmentTree(list(s))
Q = int(readline())
q = list(map(str, read().split()))
ans = []
for t, a, b in zip(*[iter(q)]*3):
if t == "1":
seg.update(int(a)-1, b)
else:
ans.append(seg.query(int(a)-1, int(b)))
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def string_to_number(a):
return 1 << (ord(a) - 97)
class SegmentTree:
"""
ใปใฐๆจใฏ 1-indexed
"""
def __init__(self, n, initial=0):
self.offset = 2**(n-1).bit_length()
self.initial = initial
self.seg = [self.initial] * (2 * self.offset)
def build(self, A):
"""
A: ๅฆ็ใใใ้
ๅ
"""
for i, a in enumerate(A, start=self.offset):
self.seg[i] = string_to_number(a)
for i in range(self.offset-1,0,-1):
self.seg[i] = self.seg[i<<1] | self.seg[(i<<1)+1]
def update(self, k, a):
k += self.offset
self.seg[k] = string_to_number(a)
while k:
k >>= 1
self.seg[k] = self.seg[k<<1] | self.seg[(k<<1)+1]
def query(self, a, b):
a += self.offset
b += self.offset
res = self.initial
while a < b:
if a & 1:
res |= self.seg[a]
a += 1
if b & 1:
res |= self.seg[b-1]
a >>= 1
b >>= 1
return bin(res).count("1")
def main():
N,s,Q,*q = read().split()
seg = SegmentTree(int(N))
seg.build(s)
#print(seg.seg)
for t, a, b in zip(*[iter(q)]*3):
if t == "1":
seg.update(int(a)-1, b)
else:
print((seg.query(int(a)-1, int(b))))
if __name__ == "__main__":
main()
| 72 | 68 | 1,770 | 1,593 | # AC: 577 msec (Python3)
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def string_to_number(a):
return 1 << (ord(a) - 97)
class SegmentTree:
def __init__(self, A):
self.n = 2 ** (len(A) - 1).bit_length()
self.identity = 0
self.seg = [self.identity] * (2 * self.n)
for i, a in enumerate(A):
self.seg[self.n - 1 + i] = string_to_number(a)
for i in range(self.n - 2, -1, -1):
self.seg[i] = self.seg[2 * i + 1] | self.seg[2 * i + 2]
def update(self, k, a):
k += self.n - 1
self.seg[k] = string_to_number(a)
while k:
k = (k - 1) // 2
self.seg[k] = self.seg[k * 2 + 1] | self.seg[k * 2 + 2]
def query(self, a, b):
if b == a:
return 1
a += self.n - 1
b += self.n - 2
res = self.identity
while b - a > 1:
if not a & 1:
res |= self.seg[a]
if b & 1:
res |= self.seg[b]
b -= 2
a >>= 1
b -= 1
b >>= 1
if a == b:
res |= self.seg[a]
else:
res |= self.seg[a] | self.seg[b]
return bin(res).count("1")
def main():
N = int(readline())
s = readline().strip()
seg = SegmentTree(list(s))
Q = int(readline())
q = list(map(str, read().split()))
ans = []
for t, a, b in zip(*[iter(q)] * 3):
if t == "1":
seg.update(int(a) - 1, b)
else:
ans.append(seg.query(int(a) - 1, int(b)))
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def string_to_number(a):
return 1 << (ord(a) - 97)
class SegmentTree:
"""
ใปใฐๆจใฏ 1-indexed
"""
def __init__(self, n, initial=0):
self.offset = 2 ** (n - 1).bit_length()
self.initial = initial
self.seg = [self.initial] * (2 * self.offset)
def build(self, A):
"""
A: ๅฆ็ใใใ้
ๅ
"""
for i, a in enumerate(A, start=self.offset):
self.seg[i] = string_to_number(a)
for i in range(self.offset - 1, 0, -1):
self.seg[i] = self.seg[i << 1] | self.seg[(i << 1) + 1]
def update(self, k, a):
k += self.offset
self.seg[k] = string_to_number(a)
while k:
k >>= 1
self.seg[k] = self.seg[k << 1] | self.seg[(k << 1) + 1]
def query(self, a, b):
a += self.offset
b += self.offset
res = self.initial
while a < b:
if a & 1:
res |= self.seg[a]
a += 1
if b & 1:
res |= self.seg[b - 1]
a >>= 1
b >>= 1
return bin(res).count("1")
def main():
N, s, Q, *q = read().split()
seg = SegmentTree(int(N))
seg.build(s)
# print(seg.seg)
for t, a, b in zip(*[iter(q)] * 3):
if t == "1":
seg.update(int(a) - 1, b)
else:
print((seg.query(int(a) - 1, int(b))))
if __name__ == "__main__":
main()
| false | 5.555556 | [
"-# AC: 577 msec (Python3)",
"- def __init__(self, A):",
"- self.n = 2 ** (len(A) - 1).bit_length()",
"- self.identity = 0",
"- self.seg = [self.identity] * (2 * self.n)",
"- for i, a in enumerate(A):",
"- self.seg[self.n - 1 + i] = string_to_number(a)",
"- for i in range(self.n - 2, -1, -1):",
"- self.seg[i] = self.seg[2 * i + 1] | self.seg[2 * i + 2]",
"+ \"\"\"",
"+ ใปใฐๆจใฏ 1-indexed",
"+ \"\"\"",
"+",
"+ def __init__(self, n, initial=0):",
"+ self.offset = 2 ** (n - 1).bit_length()",
"+ self.initial = initial",
"+ self.seg = [self.initial] * (2 * self.offset)",
"+",
"+ def build(self, A):",
"+ \"\"\"",
"+ A: ๅฆ็ใใใ้
ๅ",
"+ \"\"\"",
"+ for i, a in enumerate(A, start=self.offset):",
"+ self.seg[i] = string_to_number(a)",
"+ for i in range(self.offset - 1, 0, -1):",
"+ self.seg[i] = self.seg[i << 1] | self.seg[(i << 1) + 1]",
"- k += self.n - 1",
"+ k += self.offset",
"- k = (k - 1) // 2",
"- self.seg[k] = self.seg[k * 2 + 1] | self.seg[k * 2 + 2]",
"+ k >>= 1",
"+ self.seg[k] = self.seg[k << 1] | self.seg[(k << 1) + 1]",
"- if b == a:",
"- return 1",
"- a += self.n - 1",
"- b += self.n - 2",
"- res = self.identity",
"- while b - a > 1:",
"- if not a & 1:",
"+ a += self.offset",
"+ b += self.offset",
"+ res = self.initial",
"+ while a < b:",
"+ if a & 1:",
"+ a += 1",
"- res |= self.seg[b]",
"- b -= 2",
"+ res |= self.seg[b - 1]",
"- b -= 1",
"- if a == b:",
"- res |= self.seg[a]",
"- else:",
"- res |= self.seg[a] | self.seg[b]",
"- N = int(readline())",
"- s = readline().strip()",
"- seg = SegmentTree(list(s))",
"- Q = int(readline())",
"- q = list(map(str, read().split()))",
"- ans = []",
"+ N, s, Q, *q = read().split()",
"+ seg = SegmentTree(int(N))",
"+ seg.build(s)",
"+ # print(seg.seg)",
"- ans.append(seg.query(int(a) - 1, int(b)))",
"- print((\"\\n\".join(map(str, ans))))",
"+ print((seg.query(int(a) - 1, int(b))))"
] | false | 0.147586 | 0.043757 | 3.372874 | [
"s352739765",
"s742006213"
] |
u281303342 | p03137 | python | s408096333 | s801279049 | 124 | 111 | 13,968 | 13,188 | Accepted | Accepted | 10.48 | N,M = list(map(int,input().split()))
X = list(map(int,input().split()))
if N >= M:
print((0))
else:
X.sort()
D = []
for i in range(M-1):
D.append(X[i+1]-X[i])
D.sort()
print((sum(D[0:M-N]))) | # Python3 (3.4.3)
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = list(map(int,input().split()))
X = list(map(int,input().split()))
if N >= M:
print((0))
else:
X.sort()
D = []
for i in range(M-1):
D.append(X[i+1]-X[i])
D.sort()
print((sum(D[0:M-N]))) | 12 | 24 | 224 | 569 | N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
if N >= M:
print((0))
else:
X.sort()
D = []
for i in range(M - 1):
D.append(X[i + 1] - X[i])
D.sort()
print((sum(D[0 : M - N])))
| # Python3 (3.4.3)
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
if N >= M:
print((0))
else:
X.sort()
D = []
for i in range(M - 1):
D.append(X[i + 1] - X[i])
D.sort()
print((sum(D[0 : M - N])))
| false | 50 | [
"+# Python3 (3.4.3)",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+# function",
"+# main"
] | false | 0.065984 | 0.040528 | 1.628122 | [
"s408096333",
"s801279049"
] |
u624475441 | p03147 | python | s949947459 | s874142347 | 20 | 18 | 2,940 | 2,940 | Accepted | Accepted | 10 | N, *H = list(map(int, open(0).read().split()))
cnt = 0
prv = 0
for h in H:
cnt += max(0, h - prv)
prv = h
print(cnt) | N, *H = list(map(int, open(0).read().split()))
diff = [H[0]] + [abs(prv - cur) for prv, cur in zip(H, H[1:])] + [H[-1]]
print((sum(diff) // 2)) | 7 | 3 | 124 | 137 | N, *H = list(map(int, open(0).read().split()))
cnt = 0
prv = 0
for h in H:
cnt += max(0, h - prv)
prv = h
print(cnt)
| N, *H = list(map(int, open(0).read().split()))
diff = [H[0]] + [abs(prv - cur) for prv, cur in zip(H, H[1:])] + [H[-1]]
print((sum(diff) // 2))
| false | 57.142857 | [
"-cnt = 0",
"-prv = 0",
"-for h in H:",
"- cnt += max(0, h - prv)",
"- prv = h",
"-print(cnt)",
"+diff = [H[0]] + [abs(prv - cur) for prv, cur in zip(H, H[1:])] + [H[-1]]",
"+print((sum(diff) // 2))"
] | false | 0.068447 | 0.036543 | 1.873072 | [
"s949947459",
"s874142347"
] |
u023515228 | p04013 | python | s071054716 | s944201294 | 212 | 27 | 8,688 | 3,572 | Accepted | Accepted | 87.26 | import collections
N, A = list(map(int, input().split()))
xs = list(map(int, input().split()))
dp = collections.defaultdict(lambda: 0)
dp[(0, 0)] = 1
for n, x in enumerate(xs, start=1):
for (k, accum), count in list(dp.items()):
dp[(k + 1, accum + x)] += count
found = 0
for (k, accum), count in list(dp.items()):
if k > 0 and k * A == accum:
found += count
print(found) | import collections
N, A = list(map(int, input().split()))
ys = [int(x) - A for x in input().split()]
dp = collections.defaultdict(lambda: 0)
dp[0] = 1
for y in ys:
for accum, count in list(dp.items()):
dp[accum + y] += count
found = -1 # for dp[0]
for accum, count in list(dp.items()):
if accum == 0:
found += count
print(found) | 14 | 14 | 396 | 354 | import collections
N, A = list(map(int, input().split()))
xs = list(map(int, input().split()))
dp = collections.defaultdict(lambda: 0)
dp[(0, 0)] = 1
for n, x in enumerate(xs, start=1):
for (k, accum), count in list(dp.items()):
dp[(k + 1, accum + x)] += count
found = 0
for (k, accum), count in list(dp.items()):
if k > 0 and k * A == accum:
found += count
print(found)
| import collections
N, A = list(map(int, input().split()))
ys = [int(x) - A for x in input().split()]
dp = collections.defaultdict(lambda: 0)
dp[0] = 1
for y in ys:
for accum, count in list(dp.items()):
dp[accum + y] += count
found = -1 # for dp[0]
for accum, count in list(dp.items()):
if accum == 0:
found += count
print(found)
| false | 0 | [
"-xs = list(map(int, input().split()))",
"+ys = [int(x) - A for x in input().split()]",
"-dp[(0, 0)] = 1",
"-for n, x in enumerate(xs, start=1):",
"- for (k, accum), count in list(dp.items()):",
"- dp[(k + 1, accum + x)] += count",
"-found = 0",
"-for (k, accum), count in list(dp.items()):",
"- if k > 0 and k * A == accum:",
"+dp[0] = 1",
"+for y in ys:",
"+ for accum, count in list(dp.items()):",
"+ dp[accum + y] += count",
"+found = -1 # for dp[0]",
"+for accum, count in list(dp.items()):",
"+ if accum == 0:"
] | false | 0.084459 | 0.039583 | 2.133745 | [
"s071054716",
"s944201294"
] |
u523743252 | p02389 | python | s213403675 | s041425645 | 30 | 20 | 7,648 | 7,664 | Accepted | Accepted | 33.33 | input = list([int(n) for n in input().split(' ')])
a = int(input[0])
b = int(input[1])
x = a * b
y = (a + b) * 2
print(("{} {}".format(x, y))) | input = list([int(n) for n in input().split(' ')])
a = input[0]
b = input[1]
x = a * b
y = (a + b) * 2
print(("{} {}".format(x, y))) | 6 | 6 | 150 | 140 | input = list([int(n) for n in input().split(" ")])
a = int(input[0])
b = int(input[1])
x = a * b
y = (a + b) * 2
print(("{} {}".format(x, y)))
| input = list([int(n) for n in input().split(" ")])
a = input[0]
b = input[1]
x = a * b
y = (a + b) * 2
print(("{} {}".format(x, y)))
| false | 0 | [
"-a = int(input[0])",
"-b = int(input[1])",
"+a = input[0]",
"+b = input[1]"
] | false | 0.088858 | 0.037407 | 2.375455 | [
"s213403675",
"s041425645"
] |
u071680334 | p02773 | python | s823989193 | s550730262 | 795 | 627 | 46,556 | 32,988 | Accepted | Accepted | 21.13 | def main():
dic = {}
n = int(eval(input()))
for i in range(n):
s = input().rstrip()
if s in list(dic.keys()):
dic[s] += 1
else:
dic[s] = 1
m = 0
for v in list(dic.values()):
if m < v:
m = v
s_dic = sorted(list(dic.items()), key=lambda x:x[0])
for k, v in s_dic:
if v == m:
print(k)
if __name__ == "__main__":
main() | def main():
dic = {}
n = int(eval(input()))
for _ in range(n):
s = input().rstrip()
if s in list(dic.keys()):
dic[s] += 1
else:
dic[s] = 1
m = max(dic.values())
ans = [key for key, val in list(dic.items()) if val == m]
for a in sorted(ans):
print(a)
if __name__ == "__main__":
main() | 20 | 16 | 432 | 366 | def main():
dic = {}
n = int(eval(input()))
for i in range(n):
s = input().rstrip()
if s in list(dic.keys()):
dic[s] += 1
else:
dic[s] = 1
m = 0
for v in list(dic.values()):
if m < v:
m = v
s_dic = sorted(list(dic.items()), key=lambda x: x[0])
for k, v in s_dic:
if v == m:
print(k)
if __name__ == "__main__":
main()
| def main():
dic = {}
n = int(eval(input()))
for _ in range(n):
s = input().rstrip()
if s in list(dic.keys()):
dic[s] += 1
else:
dic[s] = 1
m = max(dic.values())
ans = [key for key, val in list(dic.items()) if val == m]
for a in sorted(ans):
print(a)
if __name__ == "__main__":
main()
| false | 20 | [
"- for i in range(n):",
"+ for _ in range(n):",
"- m = 0",
"- for v in list(dic.values()):",
"- if m < v:",
"- m = v",
"- s_dic = sorted(list(dic.items()), key=lambda x: x[0])",
"- for k, v in s_dic:",
"- if v == m:",
"- print(k)",
"+ m = max(dic.values())",
"+ ans = [key for key, val in list(dic.items()) if val == m]",
"+ for a in sorted(ans):",
"+ print(a)"
] | false | 0.06116 | 0.040984 | 1.492279 | [
"s823989193",
"s550730262"
] |
u509516894 | p02748 | python | s296481984 | s223586126 | 339 | 155 | 25,108 | 97,592 | Accepted | Accepted | 54.28 | na, nb, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min_a = min_b = 10**9
for i in range(na):
min_a = min(min_a, a[i])
for i in range(nb):
min_b = min(min_b, b[i])
ans = min_a + min_b
for i in range(m):
x, y, c = list(map(int, input().split()))
x -= 1
y -= 1
ans = min(ans, a[x] + b[y] - c)
print(ans)
| from sys import stdin
input = lambda: stdin.readline().rstrip()
na, nb, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for i in range(m):
x, y, c = list(map(int, input().split()))
x -= 1
y -= 1
ans = min(ans, a[x] + b[y] - c)
print(ans)
| 15 | 12 | 392 | 335 | na, nb, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min_a = min_b = 10**9
for i in range(na):
min_a = min(min_a, a[i])
for i in range(nb):
min_b = min(min_b, b[i])
ans = min_a + min_b
for i in range(m):
x, y, c = list(map(int, input().split()))
x -= 1
y -= 1
ans = min(ans, a[x] + b[y] - c)
print(ans)
| from sys import stdin
input = lambda: stdin.readline().rstrip()
na, nb, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for i in range(m):
x, y, c = list(map(int, input().split()))
x -= 1
y -= 1
ans = min(ans, a[x] + b[y] - c)
print(ans)
| false | 20 | [
"+from sys import stdin",
"+",
"+input = lambda: stdin.readline().rstrip()",
"-min_a = min_b = 10**9",
"-for i in range(na):",
"- min_a = min(min_a, a[i])",
"-for i in range(nb):",
"- min_b = min(min_b, b[i])",
"-ans = min_a + min_b",
"+ans = min(a) + min(b)"
] | false | 0.041406 | 0.042907 | 0.965028 | [
"s296481984",
"s223586126"
] |
u796842765 | p02772 | python | s440298953 | s262371407 | 20 | 18 | 3,316 | 2,940 | Accepted | Accepted | 10 | N = int(eval(input()))
A = list(map(int, input().split()))
for a in A:
if a % 2 == 1:
continue
if a % 3 == 0 or a % 5 == 0:
continue
print("DENIED")
exit()
print("APPROVED")
| N = int(eval(input()))
A = list(map(int, input().split()))
for a in A:
if a % 2 == 1:
continue
if a % 3 == 0:
continue
if a % 5 == 0:
continue
print("DENIED")
exit()
print("APPROVED") | 10 | 14 | 193 | 260 | N = int(eval(input()))
A = list(map(int, input().split()))
for a in A:
if a % 2 == 1:
continue
if a % 3 == 0 or a % 5 == 0:
continue
print("DENIED")
exit()
print("APPROVED")
| N = int(eval(input()))
A = list(map(int, input().split()))
for a in A:
if a % 2 == 1:
continue
if a % 3 == 0:
continue
if a % 5 == 0:
continue
print("DENIED")
exit()
print("APPROVED")
| false | 28.571429 | [
"- if a % 3 == 0 or a % 5 == 0:",
"+ if a % 3 == 0:",
"+ continue",
"+ if a % 5 == 0:"
] | false | 0.040433 | 0.039942 | 1.012274 | [
"s440298953",
"s262371407"
] |
u782098901 | p02837 | python | s820971643 | s507089735 | 788 | 683 | 3,064 | 3,064 | Accepted | Accepted | 13.32 | N = int(eval(input()))
A = [[list(map(int, input().split())) for _ in range(int(eval(input())))] for _ in range(N)]
res = 0
for k in range(1 << N):
bits = [(k >> i) & 1 for i in range(N)]
flag = True
for i, a in enumerate(A):
if bits[i] == 0:
continue
for x, y in a:
if bits[x - 1] == y:
continue
flag = False
if flag:
res = max(res, sum(bits))
print(res)
| N = int(eval(input()))
XY = [[list(map(int, input().split())) for _ in range(int(eval(input())))] for _ in range(N)]
res = 0
for k in range(1 << N):
bits = [(k >> i) & 1 for i in range(N)]
flag = True
for i in range(N):
if (k >> i) & 1 == 0:
continue
for x, y in XY[i]:
if bits[x - 1] == y:
continue
flag = False
if flag:
res = max(res, sum(bits))
print(res)
| 18 | 17 | 455 | 456 | N = int(eval(input()))
A = [
[list(map(int, input().split())) for _ in range(int(eval(input())))]
for _ in range(N)
]
res = 0
for k in range(1 << N):
bits = [(k >> i) & 1 for i in range(N)]
flag = True
for i, a in enumerate(A):
if bits[i] == 0:
continue
for x, y in a:
if bits[x - 1] == y:
continue
flag = False
if flag:
res = max(res, sum(bits))
print(res)
| N = int(eval(input()))
XY = [
[list(map(int, input().split())) for _ in range(int(eval(input())))]
for _ in range(N)
]
res = 0
for k in range(1 << N):
bits = [(k >> i) & 1 for i in range(N)]
flag = True
for i in range(N):
if (k >> i) & 1 == 0:
continue
for x, y in XY[i]:
if bits[x - 1] == y:
continue
flag = False
if flag:
res = max(res, sum(bits))
print(res)
| false | 5.555556 | [
"-A = [",
"+XY = [",
"- for i, a in enumerate(A):",
"- if bits[i] == 0:",
"+ for i in range(N):",
"+ if (k >> i) & 1 == 0:",
"- for x, y in a:",
"+ for x, y in XY[i]:"
] | false | 0.035225 | 0.033794 | 1.042354 | [
"s820971643",
"s507089735"
] |
u729133443 | p03408 | python | s920533597 | s429221605 | 168 | 17 | 38,384 | 2,940 | Accepted | Accepted | 89.88 | I=lambda:[eval(input())for _ in[0]*int(eval(input()))];s=I();t=I();print((max(0,*[s.count(i)-t.count(i)for i in s]))) | n,*s=open(0).read().split();n=int(n);print((max(0,*[s[:n].count(i)-s[n:].count(i)for i in s[:n]]))) | 1 | 1 | 103 | 97 | I = lambda: [eval(input()) for _ in [0] * int(eval(input()))]
s = I()
t = I()
print((max(0, *[s.count(i) - t.count(i) for i in s])))
| n, *s = open(0).read().split()
n = int(n)
print((max(0, *[s[:n].count(i) - s[n:].count(i) for i in s[:n]])))
| false | 0 | [
"-I = lambda: [eval(input()) for _ in [0] * int(eval(input()))]",
"-s = I()",
"-t = I()",
"-print((max(0, *[s.count(i) - t.count(i) for i in s])))",
"+n, *s = open(0).read().split()",
"+n = int(n)",
"+print((max(0, *[s[:n].count(i) - s[n:].count(i) for i in s[:n]])))"
] | false | 0.064616 | 0.04566 | 1.415143 | [
"s920533597",
"s429221605"
] |
u392319141 | p02873 | python | s953390037 | s023648231 | 535 | 442 | 23,352 | 31,516 | Accepted | Accepted | 17.38 | S = eval(input())
N = len(S)
A = [0] * (N + 1)
left = 0
while left < N and S[left] == '<':
A[left + 1] = A[left] + 1
left += 1
while left < N:
mid = left + 1
while mid < N and S[mid] == '>':
mid += 1
right = mid
while right < N and S[right] == '<':
right += 1
for l in range(left, mid)[:: -1]:
A[l] = max(A[l], A[l + 1] + 1)
for r in range(mid + 1, right + 1):
A[r] = max(A[r], A[r - 1] + 1)
left = right
ans = sum(A)
print(ans) | S = eval(input())
N = len(S)
A = [0] * (N + 1)
now = 0
for i, s in enumerate(S, start=1):
if s == '<':
now += 1
else:
now = 0
A[i] = now
B = [0] * (N + 1)
now = 0
for i, s in enumerate(S[::-1], start=1):
if s == '>':
now += 1
else:
now = 0
B[i] = now
B = B[::-1]
ans = [10**18] * (N + 1)
for i in range(N + 1):
ans[i] = max(A[i], B[i])
print((sum(ans)))
| 27 | 26 | 522 | 434 | S = eval(input())
N = len(S)
A = [0] * (N + 1)
left = 0
while left < N and S[left] == "<":
A[left + 1] = A[left] + 1
left += 1
while left < N:
mid = left + 1
while mid < N and S[mid] == ">":
mid += 1
right = mid
while right < N and S[right] == "<":
right += 1
for l in range(left, mid)[::-1]:
A[l] = max(A[l], A[l + 1] + 1)
for r in range(mid + 1, right + 1):
A[r] = max(A[r], A[r - 1] + 1)
left = right
ans = sum(A)
print(ans)
| S = eval(input())
N = len(S)
A = [0] * (N + 1)
now = 0
for i, s in enumerate(S, start=1):
if s == "<":
now += 1
else:
now = 0
A[i] = now
B = [0] * (N + 1)
now = 0
for i, s in enumerate(S[::-1], start=1):
if s == ">":
now += 1
else:
now = 0
B[i] = now
B = B[::-1]
ans = [10**18] * (N + 1)
for i in range(N + 1):
ans[i] = max(A[i], B[i])
print((sum(ans)))
| false | 3.703704 | [
"-left = 0",
"-while left < N and S[left] == \"<\":",
"- A[left + 1] = A[left] + 1",
"- left += 1",
"-while left < N:",
"- mid = left + 1",
"- while mid < N and S[mid] == \">\":",
"- mid += 1",
"- right = mid",
"- while right < N and S[right] == \"<\":",
"- right += 1",
"- for l in range(left, mid)[::-1]:",
"- A[l] = max(A[l], A[l + 1] + 1)",
"- for r in range(mid + 1, right + 1):",
"- A[r] = max(A[r], A[r - 1] + 1)",
"- left = right",
"-ans = sum(A)",
"-print(ans)",
"+now = 0",
"+for i, s in enumerate(S, start=1):",
"+ if s == \"<\":",
"+ now += 1",
"+ else:",
"+ now = 0",
"+ A[i] = now",
"+B = [0] * (N + 1)",
"+now = 0",
"+for i, s in enumerate(S[::-1], start=1):",
"+ if s == \">\":",
"+ now += 1",
"+ else:",
"+ now = 0",
"+ B[i] = now",
"+B = B[::-1]",
"+ans = [10**18] * (N + 1)",
"+for i in range(N + 1):",
"+ ans[i] = max(A[i], B[i])",
"+print((sum(ans)))"
] | false | 0.045472 | 0.047551 | 0.956266 | [
"s953390037",
"s023648231"
] |
u270825463 | p03206 | python | s964394702 | s869400612 | 17 | 11 | 2,940 | 2,568 | Accepted | Accepted | 35.29 | D = int(input())
D -= 25
print('Christmas',end='')
while D<0:
print(' Eve',end='')
D += 1
| import sys
D = int(eval(input()))
D -= 25
sys.stdout.write('Christmas')
while D<0:
sys.stdout.write(' Eve')
D += 1 | 6 | 7 | 102 | 122 | D = int(input())
D -= 25
print("Christmas", end="")
while D < 0:
print(" Eve", end="")
D += 1
| import sys
D = int(eval(input()))
D -= 25
sys.stdout.write("Christmas")
while D < 0:
sys.stdout.write(" Eve")
D += 1
| false | 14.285714 | [
"-D = int(input())",
"+import sys",
"+",
"+D = int(eval(input()))",
"-print(\"Christmas\", end=\"\")",
"+sys.stdout.write(\"Christmas\")",
"- print(\" Eve\", end=\"\")",
"+ sys.stdout.write(\" Eve\")"
] | false | 0.039702 | 0.044043 | 0.901424 | [
"s964394702",
"s869400612"
] |
u641406334 | p03401 | python | s626953136 | s661040901 | 1,367 | 231 | 13,760 | 14,048 | Accepted | Accepted | 83.1 | from collections import deque
n = int(eval(input()))
A = deque(list(map(int, input().split())))
A.appendleft(0)
A.append(0)
ans = 0
for i in range(1, n+2):
ans+=abs(A[i]-A[i-1])
for i in range(1, n+1):
d = abs(A[i]-A[i-1])+abs(A[i+1]-A[i])
print((ans-d+abs(A[i-1]-A[i+1])))
| n = int(eval(input()))
A = list(map(int, input().split()))
A.append(0)
A.insert(0, 0)
ans = 0
for i in range(1, n+2):
ans+=abs(A[i]-A[i-1])
for i in range(1, n+1):
d = abs(A[i]-A[i-1])+abs(A[i+1]-A[i])
print((ans-d+abs(A[i-1]-A[i+1])))
| 11 | 10 | 282 | 249 | from collections import deque
n = int(eval(input()))
A = deque(list(map(int, input().split())))
A.appendleft(0)
A.append(0)
ans = 0
for i in range(1, n + 2):
ans += abs(A[i] - A[i - 1])
for i in range(1, n + 1):
d = abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i])
print((ans - d + abs(A[i - 1] - A[i + 1])))
| n = int(eval(input()))
A = list(map(int, input().split()))
A.append(0)
A.insert(0, 0)
ans = 0
for i in range(1, n + 2):
ans += abs(A[i] - A[i - 1])
for i in range(1, n + 1):
d = abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i])
print((ans - d + abs(A[i - 1] - A[i + 1])))
| false | 9.090909 | [
"-from collections import deque",
"-",
"-A = deque(list(map(int, input().split())))",
"-A.appendleft(0)",
"+A = list(map(int, input().split()))",
"+A.insert(0, 0)"
] | false | 0.047957 | 0.047281 | 1.014298 | [
"s626953136",
"s661040901"
] |
u998733244 | p02743 | python | s992529297 | s286042301 | 35 | 17 | 5,076 | 2,940 | Accepted | Accepted | 51.43 | #!/usr/bin/env python3
from decimal import *
a, b, c = list(map(int, input().split()))
if a+b>c:
print('No')
exit()
X = (a+b-c)**2
Y = a*b*4
if (Y<X):
print('Yes')
else:
print('No')
| #!/usr/bin/env python3
a, b, c = list(map(int, input().split()))
if a+b>c:
print('No')
exit()
f1 = 4*a*b - 2*a*b + 2*c*a + 2*b*c
f2 = c**2 + b**2 + a**2
if f1 < f2:
print('Yes')
else:
print('No')
| 14 | 16 | 207 | 226 | #!/usr/bin/env python3
from decimal import *
a, b, c = list(map(int, input().split()))
if a + b > c:
print("No")
exit()
X = (a + b - c) ** 2
Y = a * b * 4
if Y < X:
print("Yes")
else:
print("No")
| #!/usr/bin/env python3
a, b, c = list(map(int, input().split()))
if a + b > c:
print("No")
exit()
f1 = 4 * a * b - 2 * a * b + 2 * c * a + 2 * b * c
f2 = c**2 + b**2 + a**2
if f1 < f2:
print("Yes")
else:
print("No")
| false | 12.5 | [
"-from decimal import *",
"-",
"-X = (a + b - c) ** 2",
"-Y = a * b * 4",
"-if Y < X:",
"+f1 = 4 * a * b - 2 * a * b + 2 * c * a + 2 * b * c",
"+f2 = c**2 + b**2 + a**2",
"+if f1 < f2:"
] | false | 0.091446 | 0.078134 | 1.17037 | [
"s992529297",
"s286042301"
] |
u887207211 | p03086 | python | s894483305 | s916999030 | 23 | 19 | 3,316 | 3,188 | Accepted | Accepted | 17.39 | import re
ptn = re.compile(r"(A|C|T|G)*")
S = eval(input())
T = set()
xx=ptn.match("FAFA")
for i in range(len(S)):
for j in range(len(S)):
x = ptn.match(S[i:i+j+1])
if(x.group(0)):
T.add(len(x.group(0)))
try:
print((max(T)))
except:
print((0)) | import re
ptn = re.compile(r"(A|C|G|T)*")
S = eval(input())
ans = 0
for i in range(len(S)):
for j in range(len(S)):
x = ptn.match(S[i:i+j+1]).group(0)
if(x):
ans = max(ans, len(x))
print(ans) | 15 | 12 | 268 | 214 | import re
ptn = re.compile(r"(A|C|T|G)*")
S = eval(input())
T = set()
xx = ptn.match("FAFA")
for i in range(len(S)):
for j in range(len(S)):
x = ptn.match(S[i : i + j + 1])
if x.group(0):
T.add(len(x.group(0)))
try:
print((max(T)))
except:
print((0))
| import re
ptn = re.compile(r"(A|C|G|T)*")
S = eval(input())
ans = 0
for i in range(len(S)):
for j in range(len(S)):
x = ptn.match(S[i : i + j + 1]).group(0)
if x:
ans = max(ans, len(x))
print(ans)
| false | 20 | [
"-ptn = re.compile(r\"(A|C|T|G)*\")",
"+ptn = re.compile(r\"(A|C|G|T)*\")",
"-T = set()",
"-xx = ptn.match(\"FAFA\")",
"+ans = 0",
"- x = ptn.match(S[i : i + j + 1])",
"- if x.group(0):",
"- T.add(len(x.group(0)))",
"-try:",
"- print((max(T)))",
"-except:",
"- print((0))",
"+ x = ptn.match(S[i : i + j + 1]).group(0)",
"+ if x:",
"+ ans = max(ans, len(x))",
"+print(ans)"
] | false | 0.054024 | 0.053656 | 1.006862 | [
"s894483305",
"s916999030"
] |
u936985471 | p02792 | python | s923145262 | s920280872 | 172 | 155 | 3,316 | 9,444 | Accepted | Accepted | 9.88 | from collections import defaultdict as d
dic=d(int)
for i in range(1,int(eval(input()))+1):
dic[(int(str(i)[0]),i%10)]+=1
ans=0
for i in range(10):
for j in range(10):
ans+=dic[(i,j)]*dic[(j,i)]
print(ans) | import sys
readline = sys.stdin.readline
N = int(readline())
from collections import defaultdict
dic = defaultdict(int)
for i in range(1, N + 1):
s = str(i)
dic[(int(s[0]),int(s[-1]))] += 1
ans = 0
for i in range(1, 10):
for j in range(1, 10):
ans += dic[(i,j)] * dic[(j,i)]
print(ans) | 9 | 18 | 215 | 323 | from collections import defaultdict as d
dic = d(int)
for i in range(1, int(eval(input())) + 1):
dic[(int(str(i)[0]), i % 10)] += 1
ans = 0
for i in range(10):
for j in range(10):
ans += dic[(i, j)] * dic[(j, i)]
print(ans)
| import sys
readline = sys.stdin.readline
N = int(readline())
from collections import defaultdict
dic = defaultdict(int)
for i in range(1, N + 1):
s = str(i)
dic[(int(s[0]), int(s[-1]))] += 1
ans = 0
for i in range(1, 10):
for j in range(1, 10):
ans += dic[(i, j)] * dic[(j, i)]
print(ans)
| false | 50 | [
"-from collections import defaultdict as d",
"+import sys",
"-dic = d(int)",
"-for i in range(1, int(eval(input())) + 1):",
"- dic[(int(str(i)[0]), i % 10)] += 1",
"+readline = sys.stdin.readline",
"+N = int(readline())",
"+from collections import defaultdict",
"+",
"+dic = defaultdict(int)",
"+for i in range(1, N + 1):",
"+ s = str(i)",
"+ dic[(int(s[0]), int(s[-1]))] += 1",
"-for i in range(10):",
"- for j in range(10):",
"+for i in range(1, 10):",
"+ for j in range(1, 10):"
] | false | 0.070873 | 0.07362 | 0.962691 | [
"s923145262",
"s920280872"
] |
u945181840 | p03971 | python | s760069981 | s999492400 | 100 | 85 | 4,016 | 4,016 | Accepted | Accepted | 15 | N, A, B = list(map(int, input().split()))
S = eval(input())
total = A + B
domestic = 0
overseas = 0
for i in S:
if i == 'a':
if domestic + overseas < total:
print('Yes')
domestic += 1
continue
elif i == 'b':
if domestic + overseas < total and overseas < B:
print('Yes')
overseas += 1
continue
print('No') | def main():
N, A, B = list(map(int, input().split()))
S = eval(input())
total = A + B
domestic = 0
overseas = 0
for i in S:
if i == 'a':
if domestic + overseas < total:
print('Yes')
domestic += 1
continue
elif i == 'b':
if domestic + overseas < total and overseas < B:
print('Yes')
overseas += 1
continue
print('No')
if __name__ == '__main__':
main() | 20 | 25 | 414 | 539 | N, A, B = list(map(int, input().split()))
S = eval(input())
total = A + B
domestic = 0
overseas = 0
for i in S:
if i == "a":
if domestic + overseas < total:
print("Yes")
domestic += 1
continue
elif i == "b":
if domestic + overseas < total and overseas < B:
print("Yes")
overseas += 1
continue
print("No")
| def main():
N, A, B = list(map(int, input().split()))
S = eval(input())
total = A + B
domestic = 0
overseas = 0
for i in S:
if i == "a":
if domestic + overseas < total:
print("Yes")
domestic += 1
continue
elif i == "b":
if domestic + overseas < total and overseas < B:
print("Yes")
overseas += 1
continue
print("No")
if __name__ == "__main__":
main()
| false | 20 | [
"-N, A, B = list(map(int, input().split()))",
"-S = eval(input())",
"-total = A + B",
"-domestic = 0",
"-overseas = 0",
"-for i in S:",
"- if i == \"a\":",
"- if domestic + overseas < total:",
"- print(\"Yes\")",
"- domestic += 1",
"- continue",
"- elif i == \"b\":",
"- if domestic + overseas < total and overseas < B:",
"- print(\"Yes\")",
"- overseas += 1",
"- continue",
"- print(\"No\")",
"+def main():",
"+ N, A, B = list(map(int, input().split()))",
"+ S = eval(input())",
"+ total = A + B",
"+ domestic = 0",
"+ overseas = 0",
"+ for i in S:",
"+ if i == \"a\":",
"+ if domestic + overseas < total:",
"+ print(\"Yes\")",
"+ domestic += 1",
"+ continue",
"+ elif i == \"b\":",
"+ if domestic + overseas < total and overseas < B:",
"+ print(\"Yes\")",
"+ overseas += 1",
"+ continue",
"+ print(\"No\")",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.04347 | 0.044425 | 0.978506 | [
"s760069981",
"s999492400"
] |
u914198331 | p02659 | python | s965543441 | s544904682 | 24 | 21 | 10,012 | 9,172 | Accepted | Accepted | 12.5 | from decimal import Decimal
a, b = list(map(Decimal, input().split()))
print((int(a*b))) | a, b = list(map(int, input().replace('.', '').split()))
print((a*b//100)) | 3 | 2 | 82 | 66 | from decimal import Decimal
a, b = list(map(Decimal, input().split()))
print((int(a * b)))
| a, b = list(map(int, input().replace(".", "").split()))
print((a * b // 100))
| false | 33.333333 | [
"-from decimal import Decimal",
"-",
"-a, b = list(map(Decimal, input().split()))",
"-print((int(a * b)))",
"+a, b = list(map(int, input().replace(\".\", \"\").split()))",
"+print((a * b // 100))"
] | false | 0.039798 | 0.109294 | 0.364139 | [
"s965543441",
"s544904682"
] |
u677267454 | p02675 | python | s664751689 | s437402109 | 23 | 21 | 9,164 | 9,164 | Accepted | Accepted | 8.7 | N = int(eval(input()))
amari = N % 10
if amari in [2, 4, 5, 7, 9]:
print('hon')
elif amari in [0, 1, 6, 8]:
print('pon')
else:
print('bon')
| N = int(eval(input()))
amari = N % 10
if amari in {2, 4, 5, 7, 9}:
print('hon')
elif amari in {0, 1, 6, 8}:
print('pon')
else:
print('bon')
| 9 | 9 | 155 | 155 | N = int(eval(input()))
amari = N % 10
if amari in [2, 4, 5, 7, 9]:
print("hon")
elif amari in [0, 1, 6, 8]:
print("pon")
else:
print("bon")
| N = int(eval(input()))
amari = N % 10
if amari in {2, 4, 5, 7, 9}:
print("hon")
elif amari in {0, 1, 6, 8}:
print("pon")
else:
print("bon")
| false | 0 | [
"-if amari in [2, 4, 5, 7, 9]:",
"+if amari in {2, 4, 5, 7, 9}:",
"-elif amari in [0, 1, 6, 8]:",
"+elif amari in {0, 1, 6, 8}:"
] | false | 0.035463 | 0.041948 | 0.845424 | [
"s664751689",
"s437402109"
] |
u499381410 | p03553 | python | s248368340 | s367618878 | 224 | 172 | 44,652 | 83,416 | Accepted | Accepted | 23.21 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007
class Dinic():
def __init__(self, source, sink):
self.G = defaultdict(lambda:defaultdict(int))
self.sink = sink
self.source = source
def add_edge(self, u, v, cap):
self.G[u][v] = cap
self.G[v][u] = 0
def bfs(self):
level = defaultdict(int)
q = [self.source]
level[self.source] = 1
d = 1
while q:
if level[self.sink]:
break
qq = []
d += 1
for u in q:
for v, cap in list(self.G[u].items()):
if cap == 0:
continue
if level[v]:
continue
level[v] = d
qq += [v]
q = qq
self.level = level
def dfs(self, u, f):
if u == self.sink:
return f
for v, cap in self.iter[u]:
if cap == 0 or self.level[v] != self.level[u] + 1:
continue
d = self.dfs(v, min(f, cap))
if d:
self.G[u][v] -= d
self.G[v][u] += d
return d
return 0
def max_flow(self):
flow = 0
while True:
self.bfs()
if self.level[self.sink] == 0:
break
self.iter = {u: iter(list(self.G[u].items())) for u in self.G}
while True:
f = self.dfs(self.source, INF)
if f == 0:
break
flow += f
return flow
n = I()
A = LI()
score = 0
s = 0
t = n + 1
dinic = Dinic(s, t)
for i in range(1, n + 1):
if A[i - 1] > 0:
score += A[i - 1]
dinic.add_edge(s, i, 0)
dinic.add_edge(i, t, A[i - 1])
else:
dinic.add_edge(s, i, -A[i - 1])
dinic.add_edge(i, t, 0)
ret = i
while ret + i <= n:
ret += i
dinic.add_edge(i, ret, INF)
print((score - dinic.max_flow())) | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007
class Dinic():
def __init__(self, source, sink):
self.G = defaultdict(lambda:defaultdict(int))
self.sink = sink
self.source = source
def add_edge(self, u, v, cap):
self.G[u][v] = cap
self.G[v][u] = 0
def bfs(self):
level = defaultdict(int)
q = [self.source]
level[self.source] = 1
d = 1
while q:
if level[self.sink]:
break
qq = []
d += 1
for u in q:
for v, cap in list(self.G[u].items()):
if cap == 0:
continue
if level[v]:
continue
level[v] = d
qq += [v]
q = qq
self.level = level
def dfs(self, u, f):
if u == self.sink:
return f
for v, cap in self.iter[u]:
if cap == 0 or self.level[v] != self.level[u] + 1:
continue
d = self.dfs(v, min(f, cap))
if d:
self.G[u][v] -= d
self.G[v][u] += d
return d
return 0
def max_flow(self):
flow = 0
while True:
self.bfs()
if self.level[self.sink] == 0:
break
self.iter = {u: iter(list(self.G[u].items())) for u in self.G}
while True:
f = self.dfs(self.source, INF)
if f == 0:
break
flow += f
return flow
n = I()
s = 0
t = n + 1
dinic = Dinic(s, t)
A = LI()
total = 0
for i in range(1, n + 1):
if A[i - 1] >= 0:
total += A[i - 1]
dinic.add_edge(s, i, 0)
dinic.add_edge(i, t, A[i - 1])
else:
dinic.add_edge(s, i, -A[i - 1])
dinic.add_edge(i, t, 0)
for j in range(i * 2, n + 1, i):
dinic.add_edge(i, j, INF)
print((total - dinic.max_flow()))
| 107 | 105 | 3,066 | 3,048 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(2147483647)
INF = 10**20
def LI():
return list(map(int, sys.stdin.buffer.readline().split()))
def I():
return int(sys.stdin.buffer.readline())
def LS():
return sys.stdin.buffer.readline().rstrip().decode("utf-8").split()
def S():
return sys.stdin.buffer.readline().rstrip().decode("utf-8")
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
def SRL(n):
return [list(S()) for i in range(n)]
def MSRL(n):
return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007
class Dinic:
def __init__(self, source, sink):
self.G = defaultdict(lambda: defaultdict(int))
self.sink = sink
self.source = source
def add_edge(self, u, v, cap):
self.G[u][v] = cap
self.G[v][u] = 0
def bfs(self):
level = defaultdict(int)
q = [self.source]
level[self.source] = 1
d = 1
while q:
if level[self.sink]:
break
qq = []
d += 1
for u in q:
for v, cap in list(self.G[u].items()):
if cap == 0:
continue
if level[v]:
continue
level[v] = d
qq += [v]
q = qq
self.level = level
def dfs(self, u, f):
if u == self.sink:
return f
for v, cap in self.iter[u]:
if cap == 0 or self.level[v] != self.level[u] + 1:
continue
d = self.dfs(v, min(f, cap))
if d:
self.G[u][v] -= d
self.G[v][u] += d
return d
return 0
def max_flow(self):
flow = 0
while True:
self.bfs()
if self.level[self.sink] == 0:
break
self.iter = {u: iter(list(self.G[u].items())) for u in self.G}
while True:
f = self.dfs(self.source, INF)
if f == 0:
break
flow += f
return flow
n = I()
A = LI()
score = 0
s = 0
t = n + 1
dinic = Dinic(s, t)
for i in range(1, n + 1):
if A[i - 1] > 0:
score += A[i - 1]
dinic.add_edge(s, i, 0)
dinic.add_edge(i, t, A[i - 1])
else:
dinic.add_edge(s, i, -A[i - 1])
dinic.add_edge(i, t, 0)
ret = i
while ret + i <= n:
ret += i
dinic.add_edge(i, ret, INF)
print((score - dinic.max_flow()))
| from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(2147483647)
INF = 10**20
def LI():
return list(map(int, sys.stdin.buffer.readline().split()))
def I():
return int(sys.stdin.buffer.readline())
def LS():
return sys.stdin.buffer.readline().rstrip().decode("utf-8").split()
def S():
return sys.stdin.buffer.readline().rstrip().decode("utf-8")
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
def SRL(n):
return [list(S()) for i in range(n)]
def MSRL(n):
return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007
class Dinic:
def __init__(self, source, sink):
self.G = defaultdict(lambda: defaultdict(int))
self.sink = sink
self.source = source
def add_edge(self, u, v, cap):
self.G[u][v] = cap
self.G[v][u] = 0
def bfs(self):
level = defaultdict(int)
q = [self.source]
level[self.source] = 1
d = 1
while q:
if level[self.sink]:
break
qq = []
d += 1
for u in q:
for v, cap in list(self.G[u].items()):
if cap == 0:
continue
if level[v]:
continue
level[v] = d
qq += [v]
q = qq
self.level = level
def dfs(self, u, f):
if u == self.sink:
return f
for v, cap in self.iter[u]:
if cap == 0 or self.level[v] != self.level[u] + 1:
continue
d = self.dfs(v, min(f, cap))
if d:
self.G[u][v] -= d
self.G[v][u] += d
return d
return 0
def max_flow(self):
flow = 0
while True:
self.bfs()
if self.level[self.sink] == 0:
break
self.iter = {u: iter(list(self.G[u].items())) for u in self.G}
while True:
f = self.dfs(self.source, INF)
if f == 0:
break
flow += f
return flow
n = I()
s = 0
t = n + 1
dinic = Dinic(s, t)
A = LI()
total = 0
for i in range(1, n + 1):
if A[i - 1] >= 0:
total += A[i - 1]
dinic.add_edge(s, i, 0)
dinic.add_edge(i, t, A[i - 1])
else:
dinic.add_edge(s, i, -A[i - 1])
dinic.add_edge(i, t, 0)
for j in range(i * 2, n + 1, i):
dinic.add_edge(i, j, INF)
print((total - dinic.max_flow()))
| false | 1.869159 | [
"-A = LI()",
"-score = 0",
"+A = LI()",
"+total = 0",
"- if A[i - 1] > 0:",
"- score += A[i - 1]",
"+ if A[i - 1] >= 0:",
"+ total += A[i - 1]",
"- ret = i",
"- while ret + i <= n:",
"- ret += i",
"- dinic.add_edge(i, ret, INF)",
"-print((score - dinic.max_flow()))",
"+ for j in range(i * 2, n + 1, i):",
"+ dinic.add_edge(i, j, INF)",
"+print((total - dinic.max_flow()))"
] | false | 0.038178 | 0.048511 | 0.787004 | [
"s248368340",
"s367618878"
] |
u218834617 | p02947 | python | s532340004 | s126060155 | 150 | 138 | 22,080 | 22,032 | Accepted | Accepted | 8 | import sys
N=int(eval(input()))
ans,c=0,{}
for _ in range(N):
s=''.join(sorted(next(sys.stdin)))
if s not in c:
c[s]=0
ans+=c[s]
c[s]+=1
print(ans)
| import sys
eval(input())
ans,c=0,{}
for ln in sys.stdin:
s=''.join(sorted(ln))
ans+=c.setdefault(s,0)
c[s]+=1
print(ans)
| 10 | 8 | 176 | 134 | import sys
N = int(eval(input()))
ans, c = 0, {}
for _ in range(N):
s = "".join(sorted(next(sys.stdin)))
if s not in c:
c[s] = 0
ans += c[s]
c[s] += 1
print(ans)
| import sys
eval(input())
ans, c = 0, {}
for ln in sys.stdin:
s = "".join(sorted(ln))
ans += c.setdefault(s, 0)
c[s] += 1
print(ans)
| false | 20 | [
"-N = int(eval(input()))",
"+eval(input())",
"-for _ in range(N):",
"- s = \"\".join(sorted(next(sys.stdin)))",
"- if s not in c:",
"- c[s] = 0",
"- ans += c[s]",
"+for ln in sys.stdin:",
"+ s = \"\".join(sorted(ln))",
"+ ans += c.setdefault(s, 0)"
] | false | 0.059842 | 0.100312 | 0.596559 | [
"s532340004",
"s126060155"
] |
u311379832 | p03317 | python | s151680046 | s044802743 | 47 | 40 | 13,812 | 13,812 | Accepted | Accepted | 14.89 | import math
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
tmp = a.index(min(a))
amri = ((tmp) % (K - 1))
if amri == 0:
ans = math.ceil(tmp / (K - 1)) + math.ceil((N - tmp - 1) / (K - 1))
else:
ans = math.floor(tmp / (K - 1)) + math.ceil((N - tmp - (K- amri)) / (K - 1)) + 1
print(ans) | import math
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = math.ceil((N - 1)/ (K - 1))
print(ans) | 11 | 5 | 326 | 129 | import math
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
tmp = a.index(min(a))
amri = (tmp) % (K - 1)
if amri == 0:
ans = math.ceil(tmp / (K - 1)) + math.ceil((N - tmp - 1) / (K - 1))
else:
ans = math.floor(tmp / (K - 1)) + math.ceil((N - tmp - (K - amri)) / (K - 1)) + 1
print(ans)
| import math
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = math.ceil((N - 1) / (K - 1))
print(ans)
| false | 54.545455 | [
"-tmp = a.index(min(a))",
"-amri = (tmp) % (K - 1)",
"-if amri == 0:",
"- ans = math.ceil(tmp / (K - 1)) + math.ceil((N - tmp - 1) / (K - 1))",
"-else:",
"- ans = math.floor(tmp / (K - 1)) + math.ceil((N - tmp - (K - amri)) / (K - 1)) + 1",
"+ans = math.ceil((N - 1) / (K - 1))"
] | false | 0.073804 | 0.07334 | 1.006321 | [
"s151680046",
"s044802743"
] |
u692336506 | p03160 | python | s220073194 | s089963810 | 193 | 151 | 95,376 | 20,556 | Accepted | Accepted | 21.76 | import sys
sys.setrecursionlimit(10**6)
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [-1] * (N+1)
def rec(i):
if i == 0:
return 0
if dp[i] != -1:
return dp[i]
dp[i] = 2**60 # ๅๅๅคงใใชๅค
if i - 1 >= 0:
dp[i] = min(dp[i], rec(i - 1) + abs(h[i - 1] - h[i]))
if i - 2 >= 0:
dp[i] = min(dp[i], rec(i - 2) + abs(h[i - 2] - h[i]))
return dp[i]
print((rec(N-1)))
| N = int(eval(input()))
h = list(map(int, input().split()))
dp = [2**60] * N
dp[0] = 0
for i in range(N):
if i - 1 >= 0:
dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
if i - 2 >= 0:
dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
print((dp[N-1]))
| 20 | 10 | 440 | 275 | import sys
sys.setrecursionlimit(10**6)
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [-1] * (N + 1)
def rec(i):
if i == 0:
return 0
if dp[i] != -1:
return dp[i]
dp[i] = 2**60 # ๅๅๅคงใใชๅค
if i - 1 >= 0:
dp[i] = min(dp[i], rec(i - 1) + abs(h[i - 1] - h[i]))
if i - 2 >= 0:
dp[i] = min(dp[i], rec(i - 2) + abs(h[i - 2] - h[i]))
return dp[i]
print((rec(N - 1)))
| N = int(eval(input()))
h = list(map(int, input().split()))
dp = [2**60] * N
dp[0] = 0
for i in range(N):
if i - 1 >= 0:
dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
if i - 2 >= 0:
dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[N - 1]))
| false | 50 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**6)",
"-dp = [-1] * (N + 1)",
"-",
"-",
"-def rec(i):",
"- if i == 0:",
"- return 0",
"- if dp[i] != -1:",
"- return dp[i]",
"- dp[i] = 2**60 # ๅๅๅคงใใชๅค",
"+dp = [2**60] * N",
"+dp[0] = 0",
"+for i in range(N):",
"- dp[i] = min(dp[i], rec(i - 1) + abs(h[i - 1] - h[i]))",
"+ dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))",
"- dp[i] = min(dp[i], rec(i - 2) + abs(h[i - 2] - h[i]))",
"- return dp[i]",
"-",
"-",
"-print((rec(N - 1)))",
"+ dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))",
"+print((dp[N - 1]))"
] | false | 0.046075 | 0.047391 | 0.972231 | [
"s220073194",
"s089963810"
] |
u297046168 | p02713 | python | s424998860 | s506447354 | 1,362 | 629 | 135,400 | 69,588 | Accepted | Accepted | 53.82 | import math
K = int(eval(input()))
ans = 0
result = 0
dp = [[[0 for i in range(K+1)] for i in range(K+1)]for i in range(K+1)]
for i in range(1,K+1):
for j in range(1,K+1):
for k in range(1,K+1):
if dp[i][j][k] == 0:
x = math.gcd(i,j)
y = math.gcd(j,k)
ans = math.gcd(x,y)
dp[i][j][k] = ans
dp[j][i][k] = ans
dp[k][i][j] = ans
dp[k][j][i] = ans
result += ans
else:
result += max(dp[i][j][k],dp[j][i][k],dp[k][i][j],dp[k][j][i])
print(result) | import math
K = int(eval(input()))
ans = 0
for i in range(1,K+1):
for j in range(1,K+1):
for k in range(1,K+1):
x = math.gcd(i,j)
y = math.gcd(j,k)
ans += math.gcd(x,y)
print(ans) | 20 | 10 | 633 | 230 | import math
K = int(eval(input()))
ans = 0
result = 0
dp = [[[0 for i in range(K + 1)] for i in range(K + 1)] for i in range(K + 1)]
for i in range(1, K + 1):
for j in range(1, K + 1):
for k in range(1, K + 1):
if dp[i][j][k] == 0:
x = math.gcd(i, j)
y = math.gcd(j, k)
ans = math.gcd(x, y)
dp[i][j][k] = ans
dp[j][i][k] = ans
dp[k][i][j] = ans
dp[k][j][i] = ans
result += ans
else:
result += max(dp[i][j][k], dp[j][i][k], dp[k][i][j], dp[k][j][i])
print(result)
| import math
K = int(eval(input()))
ans = 0
for i in range(1, K + 1):
for j in range(1, K + 1):
for k in range(1, K + 1):
x = math.gcd(i, j)
y = math.gcd(j, k)
ans += math.gcd(x, y)
print(ans)
| false | 50 | [
"-result = 0",
"-dp = [[[0 for i in range(K + 1)] for i in range(K + 1)] for i in range(K + 1)]",
"- if dp[i][j][k] == 0:",
"- x = math.gcd(i, j)",
"- y = math.gcd(j, k)",
"- ans = math.gcd(x, y)",
"- dp[i][j][k] = ans",
"- dp[j][i][k] = ans",
"- dp[k][i][j] = ans",
"- dp[k][j][i] = ans",
"- result += ans",
"- else:",
"- result += max(dp[i][j][k], dp[j][i][k], dp[k][i][j], dp[k][j][i])",
"-print(result)",
"+ x = math.gcd(i, j)",
"+ y = math.gcd(j, k)",
"+ ans += math.gcd(x, y)",
"+print(ans)"
] | false | 0.054223 | 0.038312 | 1.415292 | [
"s424998860",
"s506447354"
] |
u887207211 | p03606 | python | s571661677 | s884102251 | 21 | 19 | 3,060 | 3,060 | Accepted | Accepted | 9.52 | N = int(eval(input()))
ans = 0
for i in range(N):
l, r = list(map(int,input().split()))
ans += r - l + 1
print(ans) | N = int(eval(input()))
cnt = 0
for i in range(N):
l, r = list(map(int,input().split()))
cnt += r - l + 1
print(cnt) | 6 | 7 | 112 | 114 | N = int(eval(input()))
ans = 0
for i in range(N):
l, r = list(map(int, input().split()))
ans += r - l + 1
print(ans)
| N = int(eval(input()))
cnt = 0
for i in range(N):
l, r = list(map(int, input().split()))
cnt += r - l + 1
print(cnt)
| false | 14.285714 | [
"-ans = 0",
"+cnt = 0",
"- ans += r - l + 1",
"-print(ans)",
"+ cnt += r - l + 1",
"+print(cnt)"
] | false | 0.035596 | 0.035806 | 0.994125 | [
"s571661677",
"s884102251"
] |
u373047809 | p03565 | python | s591493841 | s870697523 | 37 | 27 | 9,688 | 9,120 | Accepted | Accepted | 27.03 | import re
s,t=input().replace(*"?."),eval(input())
l,m,*c=len(s),len(t)
for i in range(l-m+1):
if re.match(s[i:i+m],t):c+=(s[:i]+t+s[i+m:]).replace(*".a"),
print((c and min(c)or"UNRESTORABLE")) | s,t=input(),input();l,m=len(s),len(t)
for i in range(l-m+1):
if all(c in"?"+d for c,d in zip(s[-i-m:],t)):s=s.replace(*"?a");exit(print(s[:-i-m]+t+s[l-i:]))
print("UNRESTORABLE")
| 6 | 4 | 191 | 182 | import re
s, t = input().replace(*"?."), eval(input())
l, m, *c = len(s), len(t)
for i in range(l - m + 1):
if re.match(s[i : i + m], t):
c += ((s[:i] + t + s[i + m :]).replace(*".a"),)
print((c and min(c) or "UNRESTORABLE"))
| s, t = input(), input()
l, m = len(s), len(t)
for i in range(l - m + 1):
if all(c in "?" + d for c, d in zip(s[-i - m :], t)):
s = s.replace(*"?a")
exit(print(s[: -i - m] + t + s[l - i :]))
print("UNRESTORABLE")
| false | 33.333333 | [
"-import re",
"-",
"-s, t = input().replace(*\"?.\"), eval(input())",
"-l, m, *c = len(s), len(t)",
"+s, t = input(), input()",
"+l, m = len(s), len(t)",
"- if re.match(s[i : i + m], t):",
"- c += ((s[:i] + t + s[i + m :]).replace(*\".a\"),)",
"-print((c and min(c) or \"UNRESTORABLE\"))",
"+ if all(c in \"?\" + d for c, d in zip(s[-i - m :], t)):",
"+ s = s.replace(*\"?a\")",
"+ exit(print(s[: -i - m] + t + s[l - i :]))",
"+print(\"UNRESTORABLE\")"
] | false | 0.039301 | 0.036869 | 1.065973 | [
"s591493841",
"s870697523"
] |
u978313283 | p03164 | python | s530826250 | s806296245 | 736 | 312 | 171,656 | 14,988 | Accepted | Accepted | 57.61 | N,W=list(map(int,input().split()))
WV=[]
for i in range(N):
WV.append(list(map(int,input().split())))
dp=[[0 for i in range(10**5+1)] for j in range(N+1)]
dp[0][1:]=[10**18 for i in range(10**5)]
for i in range(N+1):
for j in range(10**5+1):
if i>0:
if j-WV[i-1][1]>=0:
dp[i][j]=min(dp[i-1][j],dp[i-1][j-WV[i-1][1]]+WV[i-1][0])
else:
dp[i][j]=dp[i-1][j]
for i in reversed(list(range(10**5+1))):
if dp[N][i]<=W:
print(i)
break | import numpy as np
MaxW=int(1e5)
N,W=list(map(int,input().split()))
WV=[]
for i in range(N):
WV.append(list(map(int,input().split())))
dp=[1e30 for i in range(MaxW+1)]
dp[0]=0
dp=np.array(dp)
for i in range(N):
dp[WV[i][1]:]=np.minimum(dp[WV[i][1]:],dp[:MaxW-WV[i][1]+1]+WV[i][0])
for i in reversed(list(range(MaxW+1))):
if dp[i]<=W:
print(i)
break
| 17 | 16 | 522 | 388 | N, W = list(map(int, input().split()))
WV = []
for i in range(N):
WV.append(list(map(int, input().split())))
dp = [[0 for i in range(10**5 + 1)] for j in range(N + 1)]
dp[0][1:] = [10**18 for i in range(10**5)]
for i in range(N + 1):
for j in range(10**5 + 1):
if i > 0:
if j - WV[i - 1][1] >= 0:
dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - WV[i - 1][1]] + WV[i - 1][0])
else:
dp[i][j] = dp[i - 1][j]
for i in reversed(list(range(10**5 + 1))):
if dp[N][i] <= W:
print(i)
break
| import numpy as np
MaxW = int(1e5)
N, W = list(map(int, input().split()))
WV = []
for i in range(N):
WV.append(list(map(int, input().split())))
dp = [1e30 for i in range(MaxW + 1)]
dp[0] = 0
dp = np.array(dp)
for i in range(N):
dp[WV[i][1] :] = np.minimum(dp[WV[i][1] :], dp[: MaxW - WV[i][1] + 1] + WV[i][0])
for i in reversed(list(range(MaxW + 1))):
if dp[i] <= W:
print(i)
break
| false | 5.882353 | [
"+import numpy as np",
"+",
"+MaxW = int(1e5)",
"-dp = [[0 for i in range(10**5 + 1)] for j in range(N + 1)]",
"-dp[0][1:] = [10**18 for i in range(10**5)]",
"-for i in range(N + 1):",
"- for j in range(10**5 + 1):",
"- if i > 0:",
"- if j - WV[i - 1][1] >= 0:",
"- dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - WV[i - 1][1]] + WV[i - 1][0])",
"- else:",
"- dp[i][j] = dp[i - 1][j]",
"-for i in reversed(list(range(10**5 + 1))):",
"- if dp[N][i] <= W:",
"+dp = [1e30 for i in range(MaxW + 1)]",
"+dp[0] = 0",
"+dp = np.array(dp)",
"+for i in range(N):",
"+ dp[WV[i][1] :] = np.minimum(dp[WV[i][1] :], dp[: MaxW - WV[i][1] + 1] + WV[i][0])",
"+for i in reversed(list(range(MaxW + 1))):",
"+ if dp[i] <= W:"
] | false | 0.857304 | 0.007764 | 110.42049 | [
"s530826250",
"s806296245"
] |
u493520238 | p02579 | python | s541625971 | s431098592 | 1,068 | 779 | 171,000 | 151,532 | Accepted | Accepted | 27.06 | from collections import deque
def bfs(sl, visited, sy, sx, gy, gx, h, w):
q = deque([[sy,sx]])
visited[sy][sx] = 0
qn = deque([[sy,sx]])
while q:
# print('---q')
while q:
y, x = q.popleft()
qn.append([y,x])
if [y, x] == [gy, gx]:
return visited[gy][gx]
for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
ny, nx = y+j, x+k
if ny >= h or nx >= w or ny < 0 or nx < 0:
continue
if sl[ny][nx] == '.' and visited[ny][nx] == -1:
visited[ny][nx] = visited[y][x]
q.append([ny,nx])
qn.append([ny,nx])
# print(q)
# print(qn)
# print()
# print('---------qn')
next_qnl = []
while qn:
y, x = qn.popleft()
# q.append([y,x])
for j in range(-2,3):
for k in range(-2,3):
ny, nx = y+j, x+k
if ny >= h or nx >= w or ny < 0 or nx < 0: continue
if sl[ny][nx] == '.' and visited[ny][nx] == -1:
visited[ny][nx] = visited[y][x] + 1
# qn.append([ny,nx])
q.append([ny,nx])
# print(q)
# print(qn)
# print()
return -1
h, w = list(map(int, input().split()))
ch,cw = list(map(int, input().split()))
dh,dw = list(map(int, input().split()))
sl = [list(eval(input())) for _ in range(h)]
visited = [ [-1]*w for i in range(h)]
ans = bfs(sl,visited,ch-1,cw-1,dh-1,dw-1,h,w)
print(ans) | from collections import deque
def bfs(sl, visited, sy, sx, gy, gx, h, w):
q = deque([[sy,sx]])
q_warp = deque([])
# q_warp = deque([[sy,sx]])
visited[sy][sx] = 0
while q:
while q:
y, x = q.popleft()
q_warp.append([y,x])
if [y, x] == [gy, gx]:
return visited[gy][gx]
for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
ny, nx = y+j, x+k
if ny >= h or nx >= w or ny < 0 or nx < 0:
continue
if sl[ny][nx] == '.' and visited[ny][nx] == -1:
visited[ny][nx] = visited[y][x]
q.append([ny,nx])
while q_warp:
y, x = q_warp.popleft()
for j in range(-2,3):
for k in range(-2,3):
ny, nx = y+j, x+k
if ny >= h or nx >= w or ny < 0 or nx < 0: continue
if sl[ny][nx] == '.' and visited[ny][nx] == -1:
visited[ny][nx] = visited[y][x] + 1
q.append([ny,nx])
return -1
h, w = list(map(int, input().split()))
ch,cw = list(map(int, input().split()))
dh,dw = list(map(int, input().split()))
sl = [list(eval(input())) for _ in range(h)]
visited = [ [-1]*w for i in range(h)]
ans = bfs(sl,visited,ch-1,cw-1,dh-1,dw-1,h,w)
print(ans) | 52 | 41 | 1,697 | 1,386 | from collections import deque
def bfs(sl, visited, sy, sx, gy, gx, h, w):
q = deque([[sy, sx]])
visited[sy][sx] = 0
qn = deque([[sy, sx]])
while q:
# print('---q')
while q:
y, x = q.popleft()
qn.append([y, x])
if [y, x] == [gy, gx]:
return visited[gy][gx]
for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
ny, nx = y + j, x + k
if ny >= h or nx >= w or ny < 0 or nx < 0:
continue
if sl[ny][nx] == "." and visited[ny][nx] == -1:
visited[ny][nx] = visited[y][x]
q.append([ny, nx])
qn.append([ny, nx])
# print(q)
# print(qn)
# print()
# print('---------qn')
next_qnl = []
while qn:
y, x = qn.popleft()
# q.append([y,x])
for j in range(-2, 3):
for k in range(-2, 3):
ny, nx = y + j, x + k
if ny >= h or nx >= w or ny < 0 or nx < 0:
continue
if sl[ny][nx] == "." and visited[ny][nx] == -1:
visited[ny][nx] = visited[y][x] + 1
# qn.append([ny,nx])
q.append([ny, nx])
# print(q)
# print(qn)
# print()
return -1
h, w = list(map(int, input().split()))
ch, cw = list(map(int, input().split()))
dh, dw = list(map(int, input().split()))
sl = [list(eval(input())) for _ in range(h)]
visited = [[-1] * w for i in range(h)]
ans = bfs(sl, visited, ch - 1, cw - 1, dh - 1, dw - 1, h, w)
print(ans)
| from collections import deque
def bfs(sl, visited, sy, sx, gy, gx, h, w):
q = deque([[sy, sx]])
q_warp = deque([])
# q_warp = deque([[sy,sx]])
visited[sy][sx] = 0
while q:
while q:
y, x = q.popleft()
q_warp.append([y, x])
if [y, x] == [gy, gx]:
return visited[gy][gx]
for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
ny, nx = y + j, x + k
if ny >= h or nx >= w or ny < 0 or nx < 0:
continue
if sl[ny][nx] == "." and visited[ny][nx] == -1:
visited[ny][nx] = visited[y][x]
q.append([ny, nx])
while q_warp:
y, x = q_warp.popleft()
for j in range(-2, 3):
for k in range(-2, 3):
ny, nx = y + j, x + k
if ny >= h or nx >= w or ny < 0 or nx < 0:
continue
if sl[ny][nx] == "." and visited[ny][nx] == -1:
visited[ny][nx] = visited[y][x] + 1
q.append([ny, nx])
return -1
h, w = list(map(int, input().split()))
ch, cw = list(map(int, input().split()))
dh, dw = list(map(int, input().split()))
sl = [list(eval(input())) for _ in range(h)]
visited = [[-1] * w for i in range(h)]
ans = bfs(sl, visited, ch - 1, cw - 1, dh - 1, dw - 1, h, w)
print(ans)
| false | 21.153846 | [
"+ q_warp = deque([])",
"+ # q_warp = deque([[sy,sx]])",
"- qn = deque([[sy, sx]])",
"- qn.append([y, x])",
"+ q_warp.append([y, x])",
"- qn.append([ny, nx])",
"- # print(q)",
"- # print(qn)",
"- # print()",
"- next_qnl = []",
"- while qn:",
"- y, x = qn.popleft()",
"- # q.append([y,x])",
"+ while q_warp:",
"+ y, x = q_warp.popleft()",
"- # qn.append([ny,nx])",
"- # print(q)",
"- # print(qn)",
"- # print()"
] | false | 0.129063 | 0.033528 | 3.849367 | [
"s541625971",
"s431098592"
] |
u811733736 | p00436 | python | s451649244 | s600604529 | 70 | 30 | 7,776 | 7,796 | Accepted | Accepted | 57.14 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0513
AC
"""
import sys
from sys import stdin
from itertools import chain
input = stdin.readline
def flatten(listOfLists):
"Flatten one level of nesting"
return chain.from_iterable(listOfLists)
def main(args):
global cards
n = int(eval(input()))
m = int(eval(input()))
cards = [x for x in range(1, (2*n)+1)]
for _ in range(m):
op = int(eval(input()))
if op == 0:
# shuffle()
temp = [[y, b] for y, b in zip(cards[:n], cards[n:])]
cards = list(flatten(temp))
else:
# cut(k)
cards = cards[op:] + cards[:op]
print(('\n'.join(map(str, cards))))
if __name__ == '__main__':
main(sys.argv[1:])
| # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0513
AC
"""
import sys
from sys import stdin
from itertools import chain
input = stdin.readline
def flatten(listOfLists):
"Flatten one level of nesting"
return chain.from_iterable(listOfLists)
cards = []
def main(args):
global cards
n = int(eval(input()))
m = int(eval(input()))
cards = [x for x in range(1, (2*n)+1)]
for _ in range(m):
op = int(eval(input()))
if op == 0:
# shuffle()
temp = [[y, b] for y, b in zip(cards[:n], cards[n:])]
cards = list(flatten(temp))
else:
# cut(k)
cards = cards[op:] + cards[:op]
print(('\n'.join(map(str, cards))))
if __name__ == '__main__':
main(sys.argv[1:])
| 38 | 39 | 819 | 831 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0513
AC
"""
import sys
from sys import stdin
from itertools import chain
input = stdin.readline
def flatten(listOfLists):
"Flatten one level of nesting"
return chain.from_iterable(listOfLists)
def main(args):
global cards
n = int(eval(input()))
m = int(eval(input()))
cards = [x for x in range(1, (2 * n) + 1)]
for _ in range(m):
op = int(eval(input()))
if op == 0:
# shuffle()
temp = [[y, b] for y, b in zip(cards[:n], cards[n:])]
cards = list(flatten(temp))
else:
# cut(k)
cards = cards[op:] + cards[:op]
print(("\n".join(map(str, cards))))
if __name__ == "__main__":
main(sys.argv[1:])
| # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0513
AC
"""
import sys
from sys import stdin
from itertools import chain
input = stdin.readline
def flatten(listOfLists):
"Flatten one level of nesting"
return chain.from_iterable(listOfLists)
cards = []
def main(args):
global cards
n = int(eval(input()))
m = int(eval(input()))
cards = [x for x in range(1, (2 * n) + 1)]
for _ in range(m):
op = int(eval(input()))
if op == 0:
# shuffle()
temp = [[y, b] for y, b in zip(cards[:n], cards[n:])]
cards = list(flatten(temp))
else:
# cut(k)
cards = cards[op:] + cards[:op]
print(("\n".join(map(str, cards))))
if __name__ == "__main__":
main(sys.argv[1:])
| false | 2.564103 | [
"+",
"+",
"+cards = []"
] | false | 0.079006 | 0.07203 | 1.096843 | [
"s451649244",
"s600604529"
] |
u620084012 | p03599 | python | s360653226 | s702405879 | 1,930 | 166 | 12,552 | 12,528 | Accepted | Accepted | 91.4 | A,B,C,D,E,F = list(map(int,input().split()))
M = []
S = []
for a in range(1+F//100):
for b in range(1+F//100):
if 100*(a*A+b*B)<=F:
M.append(100*(a*A+b*B))
for c in range(1+F//C):
for d in range(1+F//D):
if c*C+d*D<=F:
S.append(c*C+d*D)
ans1 = 0
ans2 = 0
t = -1
for m in M:
for s in S:
if m==s==0:
pass
elif m+s<=F and s<=E*m//100 and t<(100*s)/(s+m):
t = (100*s)/(s+m)
ans1 = m+s
ans2 = s
print((ans1, ans2)) | A,B,C,D,E,F = list(map(int,input().split()))
M = []
S = []
for a in range(1+F//100):
for b in range(1+F//100):
if 100*(a*A+b*B)<=F:
M.append(100*(a*A+b*B))
for c in range(F//C):
for d in range(F//D):
if c*C+d*D<=F:
S.append(c*C+d*D)
M = set(M)
S = set(S)
t = -1
ans1 = 0
ans2 = 0
for m in M:
for s in S:
if m==s==0:
pass
elif s<=E*m//100 and m+s<=F and t<(s*100)/(m+s):
t = (s*100)/(m+s)
ans1 = m+s
ans2 = s
print((ans1, ans2)) | 27 | 28 | 547 | 565 | A, B, C, D, E, F = list(map(int, input().split()))
M = []
S = []
for a in range(1 + F // 100):
for b in range(1 + F // 100):
if 100 * (a * A + b * B) <= F:
M.append(100 * (a * A + b * B))
for c in range(1 + F // C):
for d in range(1 + F // D):
if c * C + d * D <= F:
S.append(c * C + d * D)
ans1 = 0
ans2 = 0
t = -1
for m in M:
for s in S:
if m == s == 0:
pass
elif m + s <= F and s <= E * m // 100 and t < (100 * s) / (s + m):
t = (100 * s) / (s + m)
ans1 = m + s
ans2 = s
print((ans1, ans2))
| A, B, C, D, E, F = list(map(int, input().split()))
M = []
S = []
for a in range(1 + F // 100):
for b in range(1 + F // 100):
if 100 * (a * A + b * B) <= F:
M.append(100 * (a * A + b * B))
for c in range(F // C):
for d in range(F // D):
if c * C + d * D <= F:
S.append(c * C + d * D)
M = set(M)
S = set(S)
t = -1
ans1 = 0
ans2 = 0
for m in M:
for s in S:
if m == s == 0:
pass
elif s <= E * m // 100 and m + s <= F and t < (s * 100) / (m + s):
t = (s * 100) / (m + s)
ans1 = m + s
ans2 = s
print((ans1, ans2))
| false | 3.571429 | [
"-for c in range(1 + F // C):",
"- for d in range(1 + F // D):",
"+for c in range(F // C):",
"+ for d in range(F // D):",
"+M = set(M)",
"+S = set(S)",
"+t = -1",
"-t = -1",
"- elif m + s <= F and s <= E * m // 100 and t < (100 * s) / (s + m):",
"- t = (100 * s) / (s + m)",
"+ elif s <= E * m // 100 and m + s <= F and t < (s * 100) / (m + s):",
"+ t = (s * 100) / (m + s)"
] | false | 0.499394 | 0.068183 | 7.324301 | [
"s360653226",
"s702405879"
] |
u620084012 | p02990 | python | s851613268 | s469256356 | 831 | 289 | 3,316 | 27,160 | Accepted | Accepted | 65.22 | import math
N, K = list(map(int,input().split()))
MOD = 10**9 + 7
def nCr(n,r):
if n <= 0 or r <= 0:
return 1
elif n-r < 0:
return 0
else:
return (math.factorial(n)//(math.factorial(r)*math.factorial(n-r)))%MOD
for i in range(1,K+1):
ans = 1
b = K-i
ans *= nCr(K-1,i-1)
ans *= nCr(N-K+1,i)
print((ans%MOD))
| N, K = list(map(int,input().split()))
MOD = 10**9 + 7
fac = [1 for k in range(200010)]
inv = [1 for k in range(200010)]
finv = [1 for k in range(200010)]
for k in range(2,200010):
fac[k] = (fac[k-1]*k)%MOD
inv[k] = (MOD - inv[MOD%k] * (MOD // k))%MOD
finv[k] = (finv[k - 1] * inv[k]) % MOD;
def nCr(n,r):
return (fac[n]*finv[r]*finv[n-r])%MOD
for k in range(1,K+1):
if k <= N-K+1:
print(((nCr(N-K+1,k)*nCr(K-1,k-1))%MOD))
else:
print((0))
| 18 | 17 | 374 | 486 | import math
N, K = list(map(int, input().split()))
MOD = 10**9 + 7
def nCr(n, r):
if n <= 0 or r <= 0:
return 1
elif n - r < 0:
return 0
else:
return (math.factorial(n) // (math.factorial(r) * math.factorial(n - r))) % MOD
for i in range(1, K + 1):
ans = 1
b = K - i
ans *= nCr(K - 1, i - 1)
ans *= nCr(N - K + 1, i)
print((ans % MOD))
| N, K = list(map(int, input().split()))
MOD = 10**9 + 7
fac = [1 for k in range(200010)]
inv = [1 for k in range(200010)]
finv = [1 for k in range(200010)]
for k in range(2, 200010):
fac[k] = (fac[k - 1] * k) % MOD
inv[k] = (MOD - inv[MOD % k] * (MOD // k)) % MOD
finv[k] = (finv[k - 1] * inv[k]) % MOD
def nCr(n, r):
return (fac[n] * finv[r] * finv[n - r]) % MOD
for k in range(1, K + 1):
if k <= N - K + 1:
print(((nCr(N - K + 1, k) * nCr(K - 1, k - 1)) % MOD))
else:
print((0))
| false | 5.555556 | [
"-import math",
"-",
"+fac = [1 for k in range(200010)]",
"+inv = [1 for k in range(200010)]",
"+finv = [1 for k in range(200010)]",
"+for k in range(2, 200010):",
"+ fac[k] = (fac[k - 1] * k) % MOD",
"+ inv[k] = (MOD - inv[MOD % k] * (MOD // k)) % MOD",
"+ finv[k] = (finv[k - 1] * inv[k]) % MOD",
"- if n <= 0 or r <= 0:",
"- return 1",
"- elif n - r < 0:",
"- return 0",
"- else:",
"- return (math.factorial(n) // (math.factorial(r) * math.factorial(n - r))) % MOD",
"+ return (fac[n] * finv[r] * finv[n - r]) % MOD",
"-for i in range(1, K + 1):",
"- ans = 1",
"- b = K - i",
"- ans *= nCr(K - 1, i - 1)",
"- ans *= nCr(N - K + 1, i)",
"- print((ans % MOD))",
"+for k in range(1, K + 1):",
"+ if k <= N - K + 1:",
"+ print(((nCr(N - K + 1, k) * nCr(K - 1, k - 1)) % MOD))",
"+ else:",
"+ print((0))"
] | false | 0.042129 | 0.629528 | 0.066922 | [
"s851613268",
"s469256356"
] |
u340781749 | p03395 | python | s840509996 | s227523963 | 430 | 241 | 26,624 | 15,400 | Accepted | Accepted | 43.95 | from scipy.sparse.csgraph import dijkstra
def make_graph(m, subset):
matrix = [[0] * (m + 1) for _ in range(m + 1)]
for k in subset:
for s in range(k, m + 1):
matrix[s][s % k] = 1
return dijkstra(matrix)
def solve(n, aaa, bbb):
for a, b in zip(aaa, bbb):
if a < b:
return -1
m = max(aaa)
subset = set(range(1, m + 1))
sp = make_graph(m, subset)
if any(sp[a, b] > 50 for a, b in zip(aaa, bbb)):
return -1
for k in range(m, 0, -1):
subset.remove(k)
sp = make_graph(m, subset)
if any(sp[a, b] > 50 for a, b in zip(aaa, bbb)):
subset.add(k)
return sum(1 << k for k in subset)
n = int(eval(input()))
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
print((solve(n, aaa, bbb)))
| from scipy.sparse.csgraph import floyd_warshall
import numpy as np
def make_graph(m):
matrix = np.zeros([m + 1, m + 1, m + 1])
for k in range(1, m + 1):
for s in range(k, m + 1):
matrix[k, s, s % k] = 1
return matrix
def is_disable(matrix, subset, aaa, bbb):
if subset:
sub_matrix = matrix[list(subset)].max(axis=0)
else:
sub_matrix = matrix[0]
sp = floyd_warshall(sub_matrix)
return any(sp[a, b] > 50 for a, b in zip(aaa, bbb))
def solve(aaa, bbb):
for a, b in zip(aaa, bbb):
if a < b:
return -1
m = max(aaa)
matrix = make_graph(m)
subset = set(range(1, m + 1))
if is_disable(matrix, subset, aaa, bbb):
return -1
for k in range(m, 0, -1):
subset.remove(k)
if is_disable(matrix, subset, aaa, bbb):
subset.add(k)
return sum(1 << k for k in subset)
n = int(eval(input()))
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
print((solve(aaa, bbb)))
| 33 | 42 | 854 | 1,061 | from scipy.sparse.csgraph import dijkstra
def make_graph(m, subset):
matrix = [[0] * (m + 1) for _ in range(m + 1)]
for k in subset:
for s in range(k, m + 1):
matrix[s][s % k] = 1
return dijkstra(matrix)
def solve(n, aaa, bbb):
for a, b in zip(aaa, bbb):
if a < b:
return -1
m = max(aaa)
subset = set(range(1, m + 1))
sp = make_graph(m, subset)
if any(sp[a, b] > 50 for a, b in zip(aaa, bbb)):
return -1
for k in range(m, 0, -1):
subset.remove(k)
sp = make_graph(m, subset)
if any(sp[a, b] > 50 for a, b in zip(aaa, bbb)):
subset.add(k)
return sum(1 << k for k in subset)
n = int(eval(input()))
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
print((solve(n, aaa, bbb)))
| from scipy.sparse.csgraph import floyd_warshall
import numpy as np
def make_graph(m):
matrix = np.zeros([m + 1, m + 1, m + 1])
for k in range(1, m + 1):
for s in range(k, m + 1):
matrix[k, s, s % k] = 1
return matrix
def is_disable(matrix, subset, aaa, bbb):
if subset:
sub_matrix = matrix[list(subset)].max(axis=0)
else:
sub_matrix = matrix[0]
sp = floyd_warshall(sub_matrix)
return any(sp[a, b] > 50 for a, b in zip(aaa, bbb))
def solve(aaa, bbb):
for a, b in zip(aaa, bbb):
if a < b:
return -1
m = max(aaa)
matrix = make_graph(m)
subset = set(range(1, m + 1))
if is_disable(matrix, subset, aaa, bbb):
return -1
for k in range(m, 0, -1):
subset.remove(k)
if is_disable(matrix, subset, aaa, bbb):
subset.add(k)
return sum(1 << k for k in subset)
n = int(eval(input()))
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
print((solve(aaa, bbb)))
| false | 21.428571 | [
"-from scipy.sparse.csgraph import dijkstra",
"+from scipy.sparse.csgraph import floyd_warshall",
"+import numpy as np",
"-def make_graph(m, subset):",
"- matrix = [[0] * (m + 1) for _ in range(m + 1)]",
"- for k in subset:",
"+def make_graph(m):",
"+ matrix = np.zeros([m + 1, m + 1, m + 1])",
"+ for k in range(1, m + 1):",
"- matrix[s][s % k] = 1",
"- return dijkstra(matrix)",
"+ matrix[k, s, s % k] = 1",
"+ return matrix",
"-def solve(n, aaa, bbb):",
"+def is_disable(matrix, subset, aaa, bbb):",
"+ if subset:",
"+ sub_matrix = matrix[list(subset)].max(axis=0)",
"+ else:",
"+ sub_matrix = matrix[0]",
"+ sp = floyd_warshall(sub_matrix)",
"+ return any(sp[a, b] > 50 for a, b in zip(aaa, bbb))",
"+",
"+",
"+def solve(aaa, bbb):",
"+ matrix = make_graph(m)",
"- sp = make_graph(m, subset)",
"- if any(sp[a, b] > 50 for a, b in zip(aaa, bbb)):",
"+ if is_disable(matrix, subset, aaa, bbb):",
"- sp = make_graph(m, subset)",
"- if any(sp[a, b] > 50 for a, b in zip(aaa, bbb)):",
"+ if is_disable(matrix, subset, aaa, bbb):",
"-print((solve(n, aaa, bbb)))",
"+print((solve(aaa, bbb)))"
] | false | 0.591643 | 0.796142 | 0.743137 | [
"s840509996",
"s227523963"
] |
u152283104 | p02983 | python | s323022089 | s241496180 | 592 | 428 | 75,432 | 3,064 | Accepted | Accepted | 27.7 | L, R = list(map(int, (input().split())))
Lmod, Rmod = L%2019, R%2019
if Lmod < Rmod and (R - L >= 2019):
print((0))
elif Lmod < Rmod and (R - L < 2019):
ch_list =[]
for i in range(L,R,1):
for j in range(i+1, R+1, 1):
ch_list.append((i*j)%2019)
print((min(ch_list)))
elif Lmod > Rmod:
print((0)) | L, R = list(map(int, (input().split())))
Lmod, Rmod = L%2019, R%2019
result = 2019
if Lmod < Rmod and (R - L >= 2019):
print((0))
elif Lmod < Rmod and (R - L < 2019):
for i in range(L,R,1):
for j in range(i+1, R+1, 1):
if result > (i*j)%2019:
result = (i*j)%2019
print(result)
elif Lmod > Rmod:
print((0)) | 12 | 13 | 333 | 359 | L, R = list(map(int, (input().split())))
Lmod, Rmod = L % 2019, R % 2019
if Lmod < Rmod and (R - L >= 2019):
print((0))
elif Lmod < Rmod and (R - L < 2019):
ch_list = []
for i in range(L, R, 1):
for j in range(i + 1, R + 1, 1):
ch_list.append((i * j) % 2019)
print((min(ch_list)))
elif Lmod > Rmod:
print((0))
| L, R = list(map(int, (input().split())))
Lmod, Rmod = L % 2019, R % 2019
result = 2019
if Lmod < Rmod and (R - L >= 2019):
print((0))
elif Lmod < Rmod and (R - L < 2019):
for i in range(L, R, 1):
for j in range(i + 1, R + 1, 1):
if result > (i * j) % 2019:
result = (i * j) % 2019
print(result)
elif Lmod > Rmod:
print((0))
| false | 7.692308 | [
"+result = 2019",
"- ch_list = []",
"- ch_list.append((i * j) % 2019)",
"- print((min(ch_list)))",
"+ if result > (i * j) % 2019:",
"+ result = (i * j) % 2019",
"+ print(result)"
] | false | 0.116541 | 0.114245 | 1.020091 | [
"s323022089",
"s241496180"
] |
u573754721 | p02958 | python | s119271483 | s817150075 | 179 | 18 | 38,384 | 3,060 | Accepted | Accepted | 89.94 | N = int(eval(input()))
lis_p = list(map(int, input().split()))
lis_ans = sorted(lis_p)
count = 0
for i in range(N):
if lis_p[i] != lis_ans[i]:
count += 1
if count == 2 or count == 0:
print("YES")
else:
print("NO") | n=int(eval(input()))
p=list(map(int,input().split()))
g=sum((1 for i in range(n) if i+1 !=p[i]))
print(("YNEOS"[::2] if g==2 or g==0 else "YNEOS"[1::2])) | 14 | 4 | 243 | 148 | N = int(eval(input()))
lis_p = list(map(int, input().split()))
lis_ans = sorted(lis_p)
count = 0
for i in range(N):
if lis_p[i] != lis_ans[i]:
count += 1
if count == 2 or count == 0:
print("YES")
else:
print("NO")
| n = int(eval(input()))
p = list(map(int, input().split()))
g = sum((1 for i in range(n) if i + 1 != p[i]))
print(("YNEOS"[::2] if g == 2 or g == 0 else "YNEOS"[1::2]))
| false | 71.428571 | [
"-N = int(eval(input()))",
"-lis_p = list(map(int, input().split()))",
"-lis_ans = sorted(lis_p)",
"-count = 0",
"-for i in range(N):",
"- if lis_p[i] != lis_ans[i]:",
"- count += 1",
"-if count == 2 or count == 0:",
"- print(\"YES\")",
"-else:",
"- print(\"NO\")",
"+n = int(eval(input()))",
"+p = list(map(int, input().split()))",
"+g = sum((1 for i in range(n) if i + 1 != p[i]))",
"+print((\"YNEOS\"[::2] if g == 2 or g == 0 else \"YNEOS\"[1::2]))"
] | false | 0.041682 | 0.066241 | 0.629253 | [
"s119271483",
"s817150075"
] |
u284854859 | p04049 | python | s377776494 | s144673676 | 1,421 | 1,165 | 126,680 | 124,380 | Accepted | Accepted | 18.02 | import sys
#input = sys.stdin.readline
n,k = list(map(int,input().split()))
edge = [[] for i in range(n)]
alledge = []
for i in range(n-1):
a,b = list(map(int,input().split()))
edge[a-1].append(b-1)
edge[b-1].append(a-1)
alledge.append((a-1,b-1))
def f(x,y,c):
global tmp
c += 1
for e in edge[x]:
if e == y:
continue
if c > d:
tmp +=1
f(e,x,c)
sys.setrecursionlimit(4100000)
if k % 2 == 0:
d = k//2
ass = 2001
for i in range(n):
tmp = 0
f(i,-1,0)
ass = min(ass,tmp)
print(ass)
else:
d = (k-1)//2
ass = 2001
for e1 in alledge:
tmp = 0
f(e1[0],e1[1],0)
f(e1[1],e1[0],0)
ass = min(ass,tmp)
print(ass)
| import sys
input = sys.stdin.readline
n,k = list(map(int,input().split()))
edge = [[] for i in range(n)]
alledge = []
for i in range(n-1):
a,b = list(map(int,input().split()))
edge[a-1].append(b-1)
edge[b-1].append(a-1)
alledge.append((a-1,b-1))
def f(x,y,c):
global tmp
c += 1
for e in edge[x]:
if e == y:
continue
if c > d:
tmp +=1
f(e,x,c)
sys.setrecursionlimit(4100000)
if k % 2 == 0:
d = k//2
ass = 2001
for i in range(n):
tmp = 0
f(i,-1,0)
ass = min(ass,tmp)
print(ass)
else:
d = (k-1)//2
ass = 2001
for e1 in alledge:
tmp = 0
f(e1[0],e1[1],0)
f(e1[1],e1[0],0)
ass = min(ass,tmp)
print(ass)
| 40 | 40 | 792 | 791 | import sys
# input = sys.stdin.readline
n, k = list(map(int, input().split()))
edge = [[] for i in range(n)]
alledge = []
for i in range(n - 1):
a, b = list(map(int, input().split()))
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
alledge.append((a - 1, b - 1))
def f(x, y, c):
global tmp
c += 1
for e in edge[x]:
if e == y:
continue
if c > d:
tmp += 1
f(e, x, c)
sys.setrecursionlimit(4100000)
if k % 2 == 0:
d = k // 2
ass = 2001
for i in range(n):
tmp = 0
f(i, -1, 0)
ass = min(ass, tmp)
print(ass)
else:
d = (k - 1) // 2
ass = 2001
for e1 in alledge:
tmp = 0
f(e1[0], e1[1], 0)
f(e1[1], e1[0], 0)
ass = min(ass, tmp)
print(ass)
| import sys
input = sys.stdin.readline
n, k = list(map(int, input().split()))
edge = [[] for i in range(n)]
alledge = []
for i in range(n - 1):
a, b = list(map(int, input().split()))
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
alledge.append((a - 1, b - 1))
def f(x, y, c):
global tmp
c += 1
for e in edge[x]:
if e == y:
continue
if c > d:
tmp += 1
f(e, x, c)
sys.setrecursionlimit(4100000)
if k % 2 == 0:
d = k // 2
ass = 2001
for i in range(n):
tmp = 0
f(i, -1, 0)
ass = min(ass, tmp)
print(ass)
else:
d = (k - 1) // 2
ass = 2001
for e1 in alledge:
tmp = 0
f(e1[0], e1[1], 0)
f(e1[1], e1[0], 0)
ass = min(ass, tmp)
print(ass)
| false | 0 | [
"-# input = sys.stdin.readline",
"+input = sys.stdin.readline"
] | false | 0.084821 | 0.177257 | 0.478519 | [
"s377776494",
"s144673676"
] |
u028973125 | p02806 | python | s540024591 | s408659426 | 178 | 24 | 38,384 | 9,168 | Accepted | Accepted | 86.52 | import sys
from pprint import pprint
def solve(n, s, t, x):
ans = 0
slept = False
for i in range(n):
if slept:
ans += t[i]
if s[i] == x:
slept = True
print(ans)
if __name__ == '__main__':
n = int(sys.stdin.readline().strip())
s = [""] * n
t = [0] * n
for i in range(n):
s[i], tmp = sys.stdin.readline().strip().split(" ")
t[i] = int(tmp)
x = sys.stdin.readline().strip()
solve(n, s, t, x) | import sys
input = sys.stdin.readline
N = int(eval(input()))
musics = []
for _ in range(N):
s, t = input().split()
musics.append((s.strip(), int(t)))
X = input().strip()
ans = 0
flag = False
for s, t in musics:
if flag:
ans += t
if s == X:
flag = True
print(ans) | 22 | 19 | 507 | 309 | import sys
from pprint import pprint
def solve(n, s, t, x):
ans = 0
slept = False
for i in range(n):
if slept:
ans += t[i]
if s[i] == x:
slept = True
print(ans)
if __name__ == "__main__":
n = int(sys.stdin.readline().strip())
s = [""] * n
t = [0] * n
for i in range(n):
s[i], tmp = sys.stdin.readline().strip().split(" ")
t[i] = int(tmp)
x = sys.stdin.readline().strip()
solve(n, s, t, x)
| import sys
input = sys.stdin.readline
N = int(eval(input()))
musics = []
for _ in range(N):
s, t = input().split()
musics.append((s.strip(), int(t)))
X = input().strip()
ans = 0
flag = False
for s, t in musics:
if flag:
ans += t
if s == X:
flag = True
print(ans)
| false | 13.636364 | [
"-from pprint import pprint",
"-",
"-def solve(n, s, t, x):",
"- ans = 0",
"- slept = False",
"- for i in range(n):",
"- if slept:",
"- ans += t[i]",
"- if s[i] == x:",
"- slept = True",
"- print(ans)",
"-",
"-",
"-if __name__ == \"__main__\":",
"- n = int(sys.stdin.readline().strip())",
"- s = [\"\"] * n",
"- t = [0] * n",
"- for i in range(n):",
"- s[i], tmp = sys.stdin.readline().strip().split(\" \")",
"- t[i] = int(tmp)",
"- x = sys.stdin.readline().strip()",
"- solve(n, s, t, x)",
"+input = sys.stdin.readline",
"+N = int(eval(input()))",
"+musics = []",
"+for _ in range(N):",
"+ s, t = input().split()",
"+ musics.append((s.strip(), int(t)))",
"+X = input().strip()",
"+ans = 0",
"+flag = False",
"+for s, t in musics:",
"+ if flag:",
"+ ans += t",
"+ if s == X:",
"+ flag = True",
"+print(ans)"
] | false | 0.051059 | 0.036183 | 1.411151 | [
"s540024591",
"s408659426"
] |
u585482323 | p02924 | python | s576484172 | s984939076 | 203 | 183 | 38,384 | 38,384 | Accepted | Accepted | 9.85 | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
n = I()
print((n*(n-1)>>1))
return
#Solve
if __name__ == "__main__":
solve()
| #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
n = I()
print((n*(n-1)>>1))
return
#Solve
if __name__ == "__main__":
solve()
| 35 | 35 | 841 | 855 | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
n = I()
print((n * (n - 1) >> 1))
return
# Solve
if __name__ == "__main__":
solve()
| #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI():
return [int(x) for x in sys.stdin.buffer.readline().split()]
def I():
return int(sys.stdin.buffer.readline())
def LS():
return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
n = I()
print((n * (n - 1) >> 1))
return
# Solve
if __name__ == "__main__":
solve()
| false | 0 | [
"- return [int(x) for x in sys.stdin.readline().split()]",
"+ return [int(x) for x in sys.stdin.buffer.readline().split()]",
"- return int(sys.stdin.readline())",
"+ return int(sys.stdin.buffer.readline())"
] | false | 0.092656 | 0.039336 | 2.355472 | [
"s576484172",
"s984939076"
] |
u935558307 | p03452 | python | s385437420 | s023553215 | 932 | 857 | 89,376 | 88,224 | Accepted | Accepted | 8.05 | """
unionFindๆจใไฝฟใใ
ๆ นใซๅฏพใใ่ท้ขใ่จ้ฒใใฆใใใ
"""
import sys
sys.setrecursionlimit(2000000)
input = sys.stdin.readline
class UnionFind():
def __init__(self,n):
self.n=n
self.parents = [i for i in range(n+1)]
self.distance = [0]*(n+1)
def find(self,x):
if self.parents[x]==x:
return x,0
else:
self.parents[x],dist2=self.find(self.parents[x])
self.distance[x] += dist2
return self.parents[x],self.distance[x]
def union(self,l,r,dist):
lRoot,lDist = self.find(l)
rRoot,rDist = self.find(r)
#ใพใใไฝ็ฝฎ้ขไฟใซ็็พใใชใใใ่ชฟในใ
#lRootใฏlใใlDistๅณใซใใ
#rRootใฏrใใrDistๅณใซใใ
#lRoot=rRootใฎใจใใlDist-rDist != distใชใ็็พใ
if lRoot==rRoot and lDist-rDist != dist:
print("No")
exit()
#ใใๅทฆใซใใๆ นใๅณใซใใๆ นใซใใผใธใใ
if lDist < dist+rDist:
#lRootใrRootใใใๅทฆใฎๅ ดๅ
self.parents[lRoot]=rRoot
self.distance[lRoot]=(dist+rDist)-lDist
else:
self.parents[rRoot]=lRoot
self.distance[rRoot]=lDist-(dist+rDist)
N,M = list(map(int,input().split()))
tree = UnionFind(N)
for i in range(M):
L,R,D = list(map(int,input().split()))
tree.union(L,R,D)
print('Yes') | import sys
sys.setrecursionlimit(2000000)
input = sys.stdin.readline
class UnionFind():
def __init__(self,n):
self.n=n
self.parents = [i for i in range(n+1)]
#dist[x]ใฏxใจใใฎ่ฆชใจใฎ้ใฎ่ท้ขใไฟๆใใฆใใ
self.dist = [0]*(n+1)
def find(self,x):
if self.parents[x]==x:
return x
else:
a = self.parents[x]
self.parents[x]=self.find(self.parents[x])
self.dist[x] += self.dist[a]
return self.parents[x]
def unite(self,l,r,d):
rRoot = self.find(r)
lRoot = self.find(l)
if rRoot == lRoot:
if self.dist[l] - self.dist[r] != d:
print("No")
exit()
else:
#rRootใจlRootใใฉใกใใ่ฆชใซใชใในใใๆฑบใใ
newLDist = d + self.dist[r]
if newLDist>=self.dist[l]:
self.parents[lRoot] = rRoot
self.dist[lRoot] = newLDist-self.dist[l]
else:
self.parents[rRoot] = lRoot
self.dist[rRoot] = self.dist[l]-newLDist
N,M = list(map(int,input().split()))
tree = UnionFind(N)
for _ in range(M):
l,r,d = list(map(int,input().split()))
tree.unite(l,r,d)
print("Yes") | 48 | 40 | 1,296 | 1,241 | """
unionFindๆจใไฝฟใใ
ๆ นใซๅฏพใใ่ท้ขใ่จ้ฒใใฆใใใ
"""
import sys
sys.setrecursionlimit(2000000)
input = sys.stdin.readline
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [i for i in range(n + 1)]
self.distance = [0] * (n + 1)
def find(self, x):
if self.parents[x] == x:
return x, 0
else:
self.parents[x], dist2 = self.find(self.parents[x])
self.distance[x] += dist2
return self.parents[x], self.distance[x]
def union(self, l, r, dist):
lRoot, lDist = self.find(l)
rRoot, rDist = self.find(r)
# ใพใใไฝ็ฝฎ้ขไฟใซ็็พใใชใใใ่ชฟในใ
# lRootใฏlใใlDistๅณใซใใ
# rRootใฏrใใrDistๅณใซใใ
# lRoot=rRootใฎใจใใlDist-rDist != distใชใ็็พใ
if lRoot == rRoot and lDist - rDist != dist:
print("No")
exit()
# ใใๅทฆใซใใๆ นใๅณใซใใๆ นใซใใผใธใใ
if lDist < dist + rDist:
# lRootใrRootใใใๅทฆใฎๅ ดๅ
self.parents[lRoot] = rRoot
self.distance[lRoot] = (dist + rDist) - lDist
else:
self.parents[rRoot] = lRoot
self.distance[rRoot] = lDist - (dist + rDist)
N, M = list(map(int, input().split()))
tree = UnionFind(N)
for i in range(M):
L, R, D = list(map(int, input().split()))
tree.union(L, R, D)
print("Yes")
| import sys
sys.setrecursionlimit(2000000)
input = sys.stdin.readline
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [i for i in range(n + 1)]
# dist[x]ใฏxใจใใฎ่ฆชใจใฎ้ใฎ่ท้ขใไฟๆใใฆใใ
self.dist = [0] * (n + 1)
def find(self, x):
if self.parents[x] == x:
return x
else:
a = self.parents[x]
self.parents[x] = self.find(self.parents[x])
self.dist[x] += self.dist[a]
return self.parents[x]
def unite(self, l, r, d):
rRoot = self.find(r)
lRoot = self.find(l)
if rRoot == lRoot:
if self.dist[l] - self.dist[r] != d:
print("No")
exit()
else:
# rRootใจlRootใใฉใกใใ่ฆชใซใชใในใใๆฑบใใ
newLDist = d + self.dist[r]
if newLDist >= self.dist[l]:
self.parents[lRoot] = rRoot
self.dist[lRoot] = newLDist - self.dist[l]
else:
self.parents[rRoot] = lRoot
self.dist[rRoot] = self.dist[l] - newLDist
N, M = list(map(int, input().split()))
tree = UnionFind(N)
for _ in range(M):
l, r, d = list(map(int, input().split()))
tree.unite(l, r, d)
print("Yes")
| false | 16.666667 | [
"-\"\"\"",
"-unionFindๆจใไฝฟใใ",
"-ๆ นใซๅฏพใใ่ท้ขใ่จ้ฒใใฆใใใ",
"-\"\"\"",
"- self.distance = [0] * (n + 1)",
"+ # dist[x]ใฏxใจใใฎ่ฆชใจใฎ้ใฎ่ท้ขใไฟๆใใฆใใ",
"+ self.dist = [0] * (n + 1)",
"- return x, 0",
"+ return x",
"- self.parents[x], dist2 = self.find(self.parents[x])",
"- self.distance[x] += dist2",
"- return self.parents[x], self.distance[x]",
"+ a = self.parents[x]",
"+ self.parents[x] = self.find(self.parents[x])",
"+ self.dist[x] += self.dist[a]",
"+ return self.parents[x]",
"- def union(self, l, r, dist):",
"- lRoot, lDist = self.find(l)",
"- rRoot, rDist = self.find(r)",
"- # ใพใใไฝ็ฝฎ้ขไฟใซ็็พใใชใใใ่ชฟในใ",
"- # lRootใฏlใใlDistๅณใซใใ",
"- # rRootใฏrใใrDistๅณใซใใ",
"- # lRoot=rRootใฎใจใใlDist-rDist != distใชใ็็พใ",
"- if lRoot == rRoot and lDist - rDist != dist:",
"- print(\"No\")",
"- exit()",
"- # ใใๅทฆใซใใๆ นใๅณใซใใๆ นใซใใผใธใใ",
"- if lDist < dist + rDist:",
"- # lRootใrRootใใใๅทฆใฎๅ ดๅ",
"- self.parents[lRoot] = rRoot",
"- self.distance[lRoot] = (dist + rDist) - lDist",
"+ def unite(self, l, r, d):",
"+ rRoot = self.find(r)",
"+ lRoot = self.find(l)",
"+ if rRoot == lRoot:",
"+ if self.dist[l] - self.dist[r] != d:",
"+ print(\"No\")",
"+ exit()",
"- self.parents[rRoot] = lRoot",
"- self.distance[rRoot] = lDist - (dist + rDist)",
"+ # rRootใจlRootใใฉใกใใ่ฆชใซใชใในใใๆฑบใใ",
"+ newLDist = d + self.dist[r]",
"+ if newLDist >= self.dist[l]:",
"+ self.parents[lRoot] = rRoot",
"+ self.dist[lRoot] = newLDist - self.dist[l]",
"+ else:",
"+ self.parents[rRoot] = lRoot",
"+ self.dist[rRoot] = self.dist[l] - newLDist",
"-for i in range(M):",
"- L, R, D = list(map(int, input().split()))",
"- tree.union(L, R, D)",
"+for _ in range(M):",
"+ l, r, d = list(map(int, input().split()))",
"+ tree.unite(l, r, d)"
] | false | 0.125961 | 0.037297 | 3.377276 | [
"s385437420",
"s023553215"
] |
u623819879 | p02745 | python | s213327674 | s736298773 | 756 | 515 | 51,308 | 51,804 | Accepted | Accepted | 31.88 | from itertools import permutations
def chk(a,b):
A,B=len(a),len(b)
rt=[0]*A
for i in range(A):
f=1
for j in range(min(A-i,B)):
if a[i+j]!=b[j] and a[i+j]!='?' and b[j]!='?':
f=0;break
rt[i]=f
return rt+[1]
def tri_chk(ix):
i1,i2,i3=ix
a,b,c=[S[i] for i in ix]
ab,bc,ac=M[i1][i2],M[i2][i3],M[i1][i3]
A,B,C=list(map(len,(a,b,c)))
rt=A+B+C
for l in range(A+1):
for r in range(l,A+B+1):
if ab[l]==1 and (B<r-l or bc[r-l]==1) and ac[min(A,r)]==1:
alt=max(A,l+B,r+C)
if alt<rt:
rt=alt
return rt
S=[eval(input())for i in'abc']
A,B,C=list(map(len,S))
L=10**5
M=[[chk(S[i],S[j]) if i!=j else []for j in range(3)]for i in range(3)]
for i in permutations(list(range(3))):
L=min(L,tri_chk(i))
print(L) | from itertools import permutations
def chk(a,b):
A,B=len(a),len(b)
rt=[0]*A
for i in range(A):
f=1
for j in range(min(A-i,B)):
if a[i+j]!=b[j] and a[i+j]!='?' and b[j]!='?':
f=0;break
rt[i]=f
return rt+[1]
def tri_chk(ix):
i1,i2,i3=ix
a,b,c=[S[i] for i in ix]
ab,bc,ac=M[i1][i2],M[i2][i3],M[i1][i3]
A,B,C=list(map(len,(a,b,c)))
rt=A+B+C
for l in range(A+1):
if ab[l]==0:
continue
for r in range(l,A+B+1):
if (B<r-l or bc[r-l]==1) and ac[min(A,r)]==1:
alt=max(A,l+B,r+C)
if alt<rt:
rt=alt
return rt
S=[eval(input())for i in'abc']
A,B,C=list(map(len,S))
L=10**5
M=[[chk(S[i],S[j]) if i!=j else []for j in range(3)]for i in range(3)]
for i in permutations(list(range(3))):
L=min(L,tri_chk(i))
print(L) | 35 | 38 | 899 | 908 | from itertools import permutations
def chk(a, b):
A, B = len(a), len(b)
rt = [0] * A
for i in range(A):
f = 1
for j in range(min(A - i, B)):
if a[i + j] != b[j] and a[i + j] != "?" and b[j] != "?":
f = 0
break
rt[i] = f
return rt + [1]
def tri_chk(ix):
i1, i2, i3 = ix
a, b, c = [S[i] for i in ix]
ab, bc, ac = M[i1][i2], M[i2][i3], M[i1][i3]
A, B, C = list(map(len, (a, b, c)))
rt = A + B + C
for l in range(A + 1):
for r in range(l, A + B + 1):
if ab[l] == 1 and (B < r - l or bc[r - l] == 1) and ac[min(A, r)] == 1:
alt = max(A, l + B, r + C)
if alt < rt:
rt = alt
return rt
S = [eval(input()) for i in "abc"]
A, B, C = list(map(len, S))
L = 10**5
M = [[chk(S[i], S[j]) if i != j else [] for j in range(3)] for i in range(3)]
for i in permutations(list(range(3))):
L = min(L, tri_chk(i))
print(L)
| from itertools import permutations
def chk(a, b):
A, B = len(a), len(b)
rt = [0] * A
for i in range(A):
f = 1
for j in range(min(A - i, B)):
if a[i + j] != b[j] and a[i + j] != "?" and b[j] != "?":
f = 0
break
rt[i] = f
return rt + [1]
def tri_chk(ix):
i1, i2, i3 = ix
a, b, c = [S[i] for i in ix]
ab, bc, ac = M[i1][i2], M[i2][i3], M[i1][i3]
A, B, C = list(map(len, (a, b, c)))
rt = A + B + C
for l in range(A + 1):
if ab[l] == 0:
continue
for r in range(l, A + B + 1):
if (B < r - l or bc[r - l] == 1) and ac[min(A, r)] == 1:
alt = max(A, l + B, r + C)
if alt < rt:
rt = alt
return rt
S = [eval(input()) for i in "abc"]
A, B, C = list(map(len, S))
L = 10**5
M = [[chk(S[i], S[j]) if i != j else [] for j in range(3)] for i in range(3)]
for i in permutations(list(range(3))):
L = min(L, tri_chk(i))
print(L)
| false | 7.894737 | [
"+ if ab[l] == 0:",
"+ continue",
"- if ab[l] == 1 and (B < r - l or bc[r - l] == 1) and ac[min(A, r)] == 1:",
"+ if (B < r - l or bc[r - l] == 1) and ac[min(A, r)] == 1:"
] | false | 0.036797 | 0.034481 | 1.067178 | [
"s213327674",
"s736298773"
] |
u679520304 | p02900 | python | s374385739 | s982102568 | 305 | 131 | 65,640 | 77,824 | Accepted | Accepted | 57.05 | import fractions
import collections
A,B = list(map(int,input().split()))
p = fractions.gcd(A,B)
#print(p)
num = []
for i in range(2,int(p**0.5)+1):
while p%i==0:
num.append(i)
p //= i
if p != 1:
num.append(p)
#print(num)
pp = collections.Counter(num)
print((len(pp)+1)) | A,B = list(map(int,input().split()))
from fractions import gcd
C = gcd(A,B)
num = []
for i in range(2,int(C**0.5)+1):
while C%i==0:
num.append(i)
C //= i
if C != 1:
num.append(C)
from collections import Counter
CC = Counter(num)
print((len(CC)+1)) | 15 | 13 | 299 | 275 | import fractions
import collections
A, B = list(map(int, input().split()))
p = fractions.gcd(A, B)
# print(p)
num = []
for i in range(2, int(p**0.5) + 1):
while p % i == 0:
num.append(i)
p //= i
if p != 1:
num.append(p)
# print(num)
pp = collections.Counter(num)
print((len(pp) + 1))
| A, B = list(map(int, input().split()))
from fractions import gcd
C = gcd(A, B)
num = []
for i in range(2, int(C**0.5) + 1):
while C % i == 0:
num.append(i)
C //= i
if C != 1:
num.append(C)
from collections import Counter
CC = Counter(num)
print((len(CC) + 1))
| false | 13.333333 | [
"-import fractions",
"-import collections",
"+A, B = list(map(int, input().split()))",
"+from fractions import gcd",
"-A, B = list(map(int, input().split()))",
"-p = fractions.gcd(A, B)",
"-# print(p)",
"+C = gcd(A, B)",
"-for i in range(2, int(p**0.5) + 1):",
"- while p % i == 0:",
"+for i in range(2, int(C**0.5) + 1):",
"+ while C % i == 0:",
"- p //= i",
"-if p != 1:",
"- num.append(p)",
"-# print(num)",
"-pp = collections.Counter(num)",
"-print((len(pp) + 1))",
"+ C //= i",
"+if C != 1:",
"+ num.append(C)",
"+from collections import Counter",
"+",
"+CC = Counter(num)",
"+print((len(CC) + 1))"
] | false | 0.047159 | 0.046361 | 1.017218 | [
"s374385739",
"s982102568"
] |
u627600101 | p02598 | python | s519146553 | s610471301 | 664 | 399 | 64,408 | 58,064 | Accepted | Accepted | 39.91 | import math
from collections import deque
import numpy as np
N, K = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.int64)
S = np.sum(A)
cut = K*A//S
length = []
for k in range(N):
length.append([A[k] / (cut[k]+1), k])
length.sort(key = lambda x: x[0], reverse=True)
def nibun_insert(lis, item):
end = len(lis)
start = 0
now = (end+start)//2
while end > start+1:
if lis[now][0] > item[0]:
start = 0 + now
now = (now + end)//2
else:
end = 0 + now
now = (now + start)//2
lis.insert(now+1, item)
return lis
C = np.sum(cut)
res = K - C
length = length[:res+1]
length = deque(length)
for _ in range(res):
a = length.popleft()
cut[a[1]] += 1
a[0] = a[0]*cut[a[1]]/(cut[a[1]]+1)
if a[0] <= length[-1][0]:
continue
elif a[0] >= length[0][0]:
length.appendleft(a)
else:
length = nibun_insert(length, a)
length.pop()
print((math.ceil(length.popleft()[0]))) | import math
from collections import deque
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
S = sum(A)
cut = []
for k in range(N):
cut.append(K*A[k]//S)
length = []
for k in range(N):
length.append([A[k] / (cut[k]+1), k])
length.sort(key = lambda x: x[0], reverse=True)
def nibun_insert(lis, item):
end = len(lis)
start = 0
now = (end+start)//2
while end > start+1:
if lis[now][0] > item[0]:
start = 0 + now
now = (now + end)//2
else:
end = 0 + now
now = (now + start)//2
lis.insert(now+1, item)
return lis
C = sum(cut)
res = K - C
length = length[:res+1]
length = deque(length)
for _ in range(res):
a = length.popleft()
cut[a[1]] += 1
a[0] = a[0]*cut[a[1]]/(cut[a[1]]+1)
if a[0] <= length[-1][0]:
continue
elif a[0] >= length[0][0]:
length.appendleft(a)
else:
length = nibun_insert(length, a)
length.pop()
print((math.ceil(length.popleft()[0]))) | 45 | 46 | 982 | 987 | import math
from collections import deque
import numpy as np
N, K = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.int64)
S = np.sum(A)
cut = K * A // S
length = []
for k in range(N):
length.append([A[k] / (cut[k] + 1), k])
length.sort(key=lambda x: x[0], reverse=True)
def nibun_insert(lis, item):
end = len(lis)
start = 0
now = (end + start) // 2
while end > start + 1:
if lis[now][0] > item[0]:
start = 0 + now
now = (now + end) // 2
else:
end = 0 + now
now = (now + start) // 2
lis.insert(now + 1, item)
return lis
C = np.sum(cut)
res = K - C
length = length[: res + 1]
length = deque(length)
for _ in range(res):
a = length.popleft()
cut[a[1]] += 1
a[0] = a[0] * cut[a[1]] / (cut[a[1]] + 1)
if a[0] <= length[-1][0]:
continue
elif a[0] >= length[0][0]:
length.appendleft(a)
else:
length = nibun_insert(length, a)
length.pop()
print((math.ceil(length.popleft()[0])))
| import math
from collections import deque
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
S = sum(A)
cut = []
for k in range(N):
cut.append(K * A[k] // S)
length = []
for k in range(N):
length.append([A[k] / (cut[k] + 1), k])
length.sort(key=lambda x: x[0], reverse=True)
def nibun_insert(lis, item):
end = len(lis)
start = 0
now = (end + start) // 2
while end > start + 1:
if lis[now][0] > item[0]:
start = 0 + now
now = (now + end) // 2
else:
end = 0 + now
now = (now + start) // 2
lis.insert(now + 1, item)
return lis
C = sum(cut)
res = K - C
length = length[: res + 1]
length = deque(length)
for _ in range(res):
a = length.popleft()
cut[a[1]] += 1
a[0] = a[0] * cut[a[1]] / (cut[a[1]] + 1)
if a[0] <= length[-1][0]:
continue
elif a[0] >= length[0][0]:
length.appendleft(a)
else:
length = nibun_insert(length, a)
length.pop()
print((math.ceil(length.popleft()[0])))
| false | 2.173913 | [
"-import numpy as np",
"-A = np.array(input().split(), dtype=np.int64)",
"-S = np.sum(A)",
"-cut = K * A // S",
"+A = list(map(int, input().split()))",
"+S = sum(A)",
"+cut = []",
"+for k in range(N):",
"+ cut.append(K * A[k] // S)",
"-C = np.sum(cut)",
"+C = sum(cut)"
] | false | 0.630617 | 0.096522 | 6.533397 | [
"s519146553",
"s610471301"
] |
u107639613 | p04045 | python | s714478346 | s489115036 | 83 | 67 | 73,480 | 73,252 | Accepted | Accepted | 19.28 | import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()
def main():
N, K = list(map(int, input().split()))
D = set(map(int, input().split()))
while True:
check = True
for c in str(N):
if int(c) in D:
check = False
if check:
print(N)
return
N += 1
if __name__ == "__main__":
main()
| import sys
from itertools import product
def input(): return sys.stdin.readline().strip()
def main():
"""
itertools.productใไฝฟใใจ้ซ้ใชใใใชใฎใงๅ็ต
ๅ่๏ผhttps://atcoder.jp/contests/abc042/submissions/16188969
"""
N, K = list(map(int, input().split()))
D = set(map(int, input().split()))
ok = [i for i in range(10) if i not in D]
l = len(str(N))
if int(str(ok[-1]) * l) < N:
if ok[0] == 0:
print((ok[1] * 10 ** l))
else:
print((str(ok[0]) * (l + 1)))
else:
for x in product(ok, repeat=l):
x = int("".join(map(str, x)))
if x >= N:
print(x)
return
if __name__ == "__main__":
main()
| 20 | 29 | 432 | 737 | import sys
from bisect import bisect_left
def input():
return sys.stdin.readline().strip()
def main():
N, K = list(map(int, input().split()))
D = set(map(int, input().split()))
while True:
check = True
for c in str(N):
if int(c) in D:
check = False
if check:
print(N)
return
N += 1
if __name__ == "__main__":
main()
| import sys
from itertools import product
def input():
return sys.stdin.readline().strip()
def main():
"""
itertools.productใไฝฟใใจ้ซ้ใชใใใชใฎใงๅ็ต
ๅ่๏ผhttps://atcoder.jp/contests/abc042/submissions/16188969
"""
N, K = list(map(int, input().split()))
D = set(map(int, input().split()))
ok = [i for i in range(10) if i not in D]
l = len(str(N))
if int(str(ok[-1]) * l) < N:
if ok[0] == 0:
print((ok[1] * 10**l))
else:
print((str(ok[0]) * (l + 1)))
else:
for x in product(ok, repeat=l):
x = int("".join(map(str, x)))
if x >= N:
print(x)
return
if __name__ == "__main__":
main()
| false | 31.034483 | [
"-from bisect import bisect_left",
"+from itertools import product",
"+ \"\"\"",
"+ itertools.productใไฝฟใใจ้ซ้ใชใใใชใฎใงๅ็ต",
"+ ๅ่๏ผhttps://atcoder.jp/contests/abc042/submissions/16188969",
"+ \"\"\"",
"- while True:",
"- check = True",
"- for c in str(N):",
"- if int(c) in D:",
"- check = False",
"- if check:",
"- print(N)",
"- return",
"- N += 1",
"+ ok = [i for i in range(10) if i not in D]",
"+ l = len(str(N))",
"+ if int(str(ok[-1]) * l) < N:",
"+ if ok[0] == 0:",
"+ print((ok[1] * 10**l))",
"+ else:",
"+ print((str(ok[0]) * (l + 1)))",
"+ else:",
"+ for x in product(ok, repeat=l):",
"+ x = int(\"\".join(map(str, x)))",
"+ if x >= N:",
"+ print(x)",
"+ return"
] | false | 0.132379 | 0.049667 | 2.6653 | [
"s714478346",
"s489115036"
] |
u803848678 | p03164 | python | s499632746 | s542664623 | 1,574 | 317 | 14,216 | 14,820 | Accepted | Accepted | 79.86 | n, ww = list(map(int, input().split()))
wv = [list(map(int, input().split())) for i in range(n)]
wv.sort(key=lambda x:x[1])
dp = {0:0}
for w, v in wv:
dp_next = dp.copy()
for key in dp:
dp_next[key+v] = min(dp[key]+ w, dp.get(key+v, float("inf")))
dp = dp_next
for key in sorted(list(dp.keys()), reverse=True):
if dp[key] <= ww:
print(key)
exit() | import numpy as np
n, ww = list(map(int, input().split()))
wv = [list(map(int, input().split())) for i in range(n)]
dp = np.full(n*10**3+1, np.inf)
dp[0] = 0
for w, v in wv:
dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
for i in range(n*10**3+1)[::-1]:
if dp[i] <= ww:
print(i)
exit() | 14 | 16 | 388 | 315 | n, ww = list(map(int, input().split()))
wv = [list(map(int, input().split())) for i in range(n)]
wv.sort(key=lambda x: x[1])
dp = {0: 0}
for w, v in wv:
dp_next = dp.copy()
for key in dp:
dp_next[key + v] = min(dp[key] + w, dp.get(key + v, float("inf")))
dp = dp_next
for key in sorted(list(dp.keys()), reverse=True):
if dp[key] <= ww:
print(key)
exit()
| import numpy as np
n, ww = list(map(int, input().split()))
wv = [list(map(int, input().split())) for i in range(n)]
dp = np.full(n * 10**3 + 1, np.inf)
dp[0] = 0
for w, v in wv:
dp[v:] = np.minimum(dp[v:], dp[:-v] + w)
for i in range(n * 10**3 + 1)[::-1]:
if dp[i] <= ww:
print(i)
exit()
| false | 12.5 | [
"+import numpy as np",
"+",
"-wv.sort(key=lambda x: x[1])",
"-dp = {0: 0}",
"+dp = np.full(n * 10**3 + 1, np.inf)",
"+dp[0] = 0",
"- dp_next = dp.copy()",
"- for key in dp:",
"- dp_next[key + v] = min(dp[key] + w, dp.get(key + v, float(\"inf\")))",
"- dp = dp_next",
"-for key in sorted(list(dp.keys()), reverse=True):",
"- if dp[key] <= ww:",
"- print(key)",
"+ dp[v:] = np.minimum(dp[v:], dp[:-v] + w)",
"+for i in range(n * 10**3 + 1)[::-1]:",
"+ if dp[i] <= ww:",
"+ print(i)"
] | false | 0.037284 | 0.372031 | 0.100218 | [
"s499632746",
"s542664623"
] |
u832039789 | p02999 | python | s690961787 | s913041931 | 38 | 18 | 5,368 | 2,940 | Accepted | Accepted | 52.63 | import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
if f:
print('Yes')
else:
print('No')
def Y(f):
if f:
print('YES')
else:
print('NO')
x, a = list(map(int,input().split()))
if x < a:
print((0))
else:
print((10)) | x,a = list(map(int,input().split()))
if x < a:
print((0))
elif x >= a:
print((10))
| 24 | 5 | 507 | 85 | import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
if f:
print("Yes")
else:
print("No")
def Y(f):
if f:
print("YES")
else:
print("NO")
x, a = list(map(int, input().split()))
if x < a:
print((0))
else:
print((10))
| x, a = list(map(int, input().split()))
if x < a:
print((0))
elif x >= a:
print((10))
| false | 79.166667 | [
"-import sys",
"-from fractions import gcd",
"-from itertools import groupby as gb",
"-from itertools import permutations as perm",
"-from itertools import combinations as comb",
"-from collections import Counter as C",
"-from collections import defaultdict as dd",
"-",
"-sys.setrecursionlimit(10**5)",
"-",
"-",
"-def y(f):",
"- if f:",
"- print(\"Yes\")",
"- else:",
"- print(\"No\")",
"-",
"-",
"-def Y(f):",
"- if f:",
"- print(\"YES\")",
"- else:",
"- print(\"NO\")",
"-",
"-",
"-else:",
"+elif x >= a:"
] | false | 0.034909 | 0.04024 | 0.867513 | [
"s690961787",
"s913041931"
] |
u991134049 | p02694 | python | s546506289 | s970746845 | 61 | 55 | 63,832 | 63,592 | Accepted | Accepted | 9.84 | X = int(eval(input()))
y = 100
flag = 1
con = 0
while flag:
y *= 1.01
y = int(y)
con += 1
if y >= X:
flag = 0
print(con)
| X = int(eval(input()))
money = 100
ans = 0
while money < X:
ans += 1
money = int(money*1.01)
print(ans) | 12 | 7 | 140 | 107 | X = int(eval(input()))
y = 100
flag = 1
con = 0
while flag:
y *= 1.01
y = int(y)
con += 1
if y >= X:
flag = 0
print(con)
| X = int(eval(input()))
money = 100
ans = 0
while money < X:
ans += 1
money = int(money * 1.01)
print(ans)
| false | 41.666667 | [
"-y = 100",
"-flag = 1",
"-con = 0",
"-while flag:",
"- y *= 1.01",
"- y = int(y)",
"- con += 1",
"- if y >= X:",
"- flag = 0",
"-print(con)",
"+money = 100",
"+ans = 0",
"+while money < X:",
"+ ans += 1",
"+ money = int(money * 1.01)",
"+print(ans)"
] | false | 0.048201 | 0.046965 | 1.026313 | [
"s546506289",
"s970746845"
] |
u971091945 | p02819 | python | s218664189 | s653819308 | 147 | 18 | 2,940 | 3,064 | Accepted | Accepted | 87.76 | x = int(eval(input()))
num = 0
for i in range(x,x*2):
for j in range(2,x//2):
if i%j == 0:
num += 1
continue
if num == 0:
print(i)
exit(0)
num = 0 | import math
x = int(eval(input()))
for i in range(x, x * 2):
flag = True
for j in range(2, math.floor(math.sqrt(x))+1):
if i % j == 0:
flag = False
break
if flag:
print(i)
exit(0) | 12 | 11 | 212 | 243 | x = int(eval(input()))
num = 0
for i in range(x, x * 2):
for j in range(2, x // 2):
if i % j == 0:
num += 1
continue
if num == 0:
print(i)
exit(0)
num = 0
| import math
x = int(eval(input()))
for i in range(x, x * 2):
flag = True
for j in range(2, math.floor(math.sqrt(x)) + 1):
if i % j == 0:
flag = False
break
if flag:
print(i)
exit(0)
| false | 8.333333 | [
"+import math",
"+",
"-num = 0",
"- for j in range(2, x // 2):",
"+ flag = True",
"+ for j in range(2, math.floor(math.sqrt(x)) + 1):",
"- num += 1",
"- continue",
"- if num == 0:",
"+ flag = False",
"+ break",
"+ if flag:",
"- num = 0"
] | false | 0.076146 | 0.036998 | 2.058084 | [
"s218664189",
"s653819308"
] |
u576335153 | p02616 | python | s712326737 | s666600517 | 194 | 156 | 31,720 | 30,776 | Accepted | Accepted | 19.59 | MOD = 10 ** 9 + 7
ans = 1
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == k:
for x in a:
ans *= x
ans %= MOD
print((ans % MOD))
exit()
pos = []
neg = []
for x in a:
if x >= 0:
pos.append(x)
else:
neg.append(x)
pos.sort(reverse=True)
neg.sort()
if len(pos) == 0 and k % 2:
for i in range(1, k+1):
ans *= neg[-i]
ans %= MOD
print((ans % MOD))
exit()
pi = 0
ni = 0
if k % 2:
ans *= pos[pi]
pi += 1
k -= 1
while k > 0:
if pi < len(pos) - 1:
sp = pos[pi] * pos[pi + 1]
else:
sp = 0
if ni < len(neg) - 1:
sn = neg[ni] * neg[ni + 1]
else:
sn = 0
if sp > sn:
ans *= sp
pi += 2
else:
ans *= sn
ni += 2
ans %= MOD
k -= 2
print((ans % MOD))
| MOD = 10 ** 9 + 7
ans = 1
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == k:
for x in a:
ans *= x
ans %= MOD
print((ans % MOD))
exit()
pos = []
neg = []
for x in a:
if x >= 0:
pos.append(x)
else:
neg.append(x)
pos.sort(reverse=True)
neg.sort()
if len(pos) == 0 and k % 2:
for i in range(1, k+1):
ans *= neg[-i]
ans %= MOD
print((ans % MOD))
exit()
if k % 2:
ans *= pos.pop(0)
k -= 1
l = []
for i in range(1, len(pos), 2):
l.append(pos[i] * pos[i - 1])
for i in range(1, len(neg), 2):
l.append(neg[i] * neg[i - 1])
l.sort(reverse=True)
for i in range(k // 2):
ans *= l[i]
ans %= MOD
print((ans % MOD))
| 61 | 52 | 925 | 793 | MOD = 10**9 + 7
ans = 1
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == k:
for x in a:
ans *= x
ans %= MOD
print((ans % MOD))
exit()
pos = []
neg = []
for x in a:
if x >= 0:
pos.append(x)
else:
neg.append(x)
pos.sort(reverse=True)
neg.sort()
if len(pos) == 0 and k % 2:
for i in range(1, k + 1):
ans *= neg[-i]
ans %= MOD
print((ans % MOD))
exit()
pi = 0
ni = 0
if k % 2:
ans *= pos[pi]
pi += 1
k -= 1
while k > 0:
if pi < len(pos) - 1:
sp = pos[pi] * pos[pi + 1]
else:
sp = 0
if ni < len(neg) - 1:
sn = neg[ni] * neg[ni + 1]
else:
sn = 0
if sp > sn:
ans *= sp
pi += 2
else:
ans *= sn
ni += 2
ans %= MOD
k -= 2
print((ans % MOD))
| MOD = 10**9 + 7
ans = 1
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == k:
for x in a:
ans *= x
ans %= MOD
print((ans % MOD))
exit()
pos = []
neg = []
for x in a:
if x >= 0:
pos.append(x)
else:
neg.append(x)
pos.sort(reverse=True)
neg.sort()
if len(pos) == 0 and k % 2:
for i in range(1, k + 1):
ans *= neg[-i]
ans %= MOD
print((ans % MOD))
exit()
if k % 2:
ans *= pos.pop(0)
k -= 1
l = []
for i in range(1, len(pos), 2):
l.append(pos[i] * pos[i - 1])
for i in range(1, len(neg), 2):
l.append(neg[i] * neg[i - 1])
l.sort(reverse=True)
for i in range(k // 2):
ans *= l[i]
ans %= MOD
print((ans % MOD))
| false | 14.754098 | [
"-pi = 0",
"-ni = 0",
"- ans *= pos[pi]",
"- pi += 1",
"+ ans *= pos.pop(0)",
"-while k > 0:",
"- if pi < len(pos) - 1:",
"- sp = pos[pi] * pos[pi + 1]",
"- else:",
"- sp = 0",
"- if ni < len(neg) - 1:",
"- sn = neg[ni] * neg[ni + 1]",
"- else:",
"- sn = 0",
"- if sp > sn:",
"- ans *= sp",
"- pi += 2",
"- else:",
"- ans *= sn",
"- ni += 2",
"+l = []",
"+for i in range(1, len(pos), 2):",
"+ l.append(pos[i] * pos[i - 1])",
"+for i in range(1, len(neg), 2):",
"+ l.append(neg[i] * neg[i - 1])",
"+l.sort(reverse=True)",
"+for i in range(k // 2):",
"+ ans *= l[i]",
"- k -= 2"
] | false | 0.034376 | 0.03888 | 0.884158 | [
"s712326737",
"s666600517"
] |
u997521090 | p03209 | python | s937351331 | s938010171 | 13 | 11 | 2,936 | 2,568 | Accepted | Accepted | 15.38 | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
import math
sys.setrecursionlimit(1000000)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def func(lv, id):
sz = 4 * 2 ** lv - 3
num = 2 * 2 ** lv - 1
mid = (sz + 1) / 2
if lv == 0:
return 1
if id == 1:
return 0
if id == mid:
return (num - 1) / 2 + 1
if id == sz:
return num
if 1 < id < mid:
return func(lv - 1, id - 1)
if mid < id < sz:
return func(lv - 1, id - (sz - 3) / 2 - 2) + (num - 1) / 2 + 1
print(func(*list(map(int, input().split()))))
| def func(lv, id):
sz = 4 * 2 ** lv - 3
num = 2 * 2 ** lv - 1
mid = (sz + 1) / 2
if lv == 0:
return 1
if id == 1:
return 0
if id == mid:
return (num - 1) / 2 + 1
if id == sz:
return num
if 1 < id < mid:
return func(lv - 1, id - 1)
if mid < id < sz:
return func(lv - 1, id - (sz - 3) / 2 - 2) + (num - 1) / 2 + 1
print(func(*list(map(int, input().split()))))
| 30 | 18 | 634 | 456 | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
import math
sys.setrecursionlimit(1000000)
INF = 10**18
MOD = 10**9 + 7
def func(lv, id):
sz = 4 * 2**lv - 3
num = 2 * 2**lv - 1
mid = (sz + 1) / 2
if lv == 0:
return 1
if id == 1:
return 0
if id == mid:
return (num - 1) / 2 + 1
if id == sz:
return num
if 1 < id < mid:
return func(lv - 1, id - 1)
if mid < id < sz:
return func(lv - 1, id - (sz - 3) / 2 - 2) + (num - 1) / 2 + 1
print(func(*list(map(int, input().split()))))
| def func(lv, id):
sz = 4 * 2**lv - 3
num = 2 * 2**lv - 1
mid = (sz + 1) / 2
if lv == 0:
return 1
if id == 1:
return 0
if id == mid:
return (num - 1) / 2 + 1
if id == sz:
return num
if 1 < id < mid:
return func(lv - 1, id - 1)
if mid < id < sz:
return func(lv - 1, id - (sz - 3) / 2 - 2) + (num - 1) / 2 + 1
print(func(*list(map(int, input().split()))))
| false | 40 | [
"-#!/usr/bin/env python",
"-from collections import deque",
"-import itertools as it",
"-import sys",
"-import math",
"-",
"-sys.setrecursionlimit(1000000)",
"-INF = 10**18",
"-MOD = 10**9 + 7",
"-",
"-"
] | false | 0.032624 | 0.03745 | 0.871137 | [
"s937351331",
"s938010171"
] |
u837673618 | p02746 | python | s990725450 | s475624479 | 726 | 514 | 3,316 | 3,316 | Accepted | Accepted | 29.2 | def solve(a, b, c, d):
for k in range(29, -1, -1):
block_size = 3**k
box_size = block_size * 3
x1, y1, x2, y2 = [x//block_size for x in (a, b, c, d)]
x1, x2 = sorted([x1, x2])
y1, y2 = sorted([y1, y2])
if x1!=x2 and y1!=y2:
return abs(a-c)+abs(b-d)
if x1==x2 and x1%3==1 and (y1+1)//3*3+1<y2:
a, c = [x%box_size for x in (a, c)]
return min(a+c-2*block_size+2, 4*block_size-a-c)+abs(b-d)
elif y1==y2 and y1%3==1 and (x1+1)//3*3+1<x2:
b, d = [x%box_size for x in (b, d)]
return min(b+d-2*block_size+2, 4*block_size-b-d)+abs(a-c)
return abs(a-c)+abs(b-d)
for i in range(int(eval(input()))):
print((solve(*[int(x)-1 for x in input().split()])))
| def solve(a, b, c, d):
a, c = sorted([a, c])
b, d = sorted([b, d])
for k in range(30, 0, -1):
block_size = 3**k
box_size = block_size // 3
x1, y1, x2, y2 = [x//box_size for x in (a, b, c, d)]
if x1 != x2 and y1 != y2:
return c-a + d-b
elif x1 == x2 and x1%3 == 1 and (y1+1)//3*3+1 < y2:
shifted = (a+c) % (2*block_size)
return min(shifted-2*box_size+2, 4*box_size-shifted) + d-b
elif y1 == y2 and y1%3 == 1 and (x1+1)//3*3+1 < x2:
shifted = (b+d) % (2*block_size)
return min(shifted-2*box_size+2, 4*box_size-shifted) + c-a
return c-a + d-b
for i in range(int(eval(input()))):
print((solve(*[int(x)-1 for x in input().split()])))
| 19 | 19 | 736 | 712 | def solve(a, b, c, d):
for k in range(29, -1, -1):
block_size = 3**k
box_size = block_size * 3
x1, y1, x2, y2 = [x // block_size for x in (a, b, c, d)]
x1, x2 = sorted([x1, x2])
y1, y2 = sorted([y1, y2])
if x1 != x2 and y1 != y2:
return abs(a - c) + abs(b - d)
if x1 == x2 and x1 % 3 == 1 and (y1 + 1) // 3 * 3 + 1 < y2:
a, c = [x % box_size for x in (a, c)]
return min(a + c - 2 * block_size + 2, 4 * block_size - a - c) + abs(b - d)
elif y1 == y2 and y1 % 3 == 1 and (x1 + 1) // 3 * 3 + 1 < x2:
b, d = [x % box_size for x in (b, d)]
return min(b + d - 2 * block_size + 2, 4 * block_size - b - d) + abs(a - c)
return abs(a - c) + abs(b - d)
for i in range(int(eval(input()))):
print((solve(*[int(x) - 1 for x in input().split()])))
| def solve(a, b, c, d):
a, c = sorted([a, c])
b, d = sorted([b, d])
for k in range(30, 0, -1):
block_size = 3**k
box_size = block_size // 3
x1, y1, x2, y2 = [x // box_size for x in (a, b, c, d)]
if x1 != x2 and y1 != y2:
return c - a + d - b
elif x1 == x2 and x1 % 3 == 1 and (y1 + 1) // 3 * 3 + 1 < y2:
shifted = (a + c) % (2 * block_size)
return min(shifted - 2 * box_size + 2, 4 * box_size - shifted) + d - b
elif y1 == y2 and y1 % 3 == 1 and (x1 + 1) // 3 * 3 + 1 < x2:
shifted = (b + d) % (2 * block_size)
return min(shifted - 2 * box_size + 2, 4 * box_size - shifted) + c - a
return c - a + d - b
for i in range(int(eval(input()))):
print((solve(*[int(x) - 1 for x in input().split()])))
| false | 0 | [
"- for k in range(29, -1, -1):",
"+ a, c = sorted([a, c])",
"+ b, d = sorted([b, d])",
"+ for k in range(30, 0, -1):",
"- box_size = block_size * 3",
"- x1, y1, x2, y2 = [x // block_size for x in (a, b, c, d)]",
"- x1, x2 = sorted([x1, x2])",
"- y1, y2 = sorted([y1, y2])",
"+ box_size = block_size // 3",
"+ x1, y1, x2, y2 = [x // box_size for x in (a, b, c, d)]",
"- return abs(a - c) + abs(b - d)",
"- if x1 == x2 and x1 % 3 == 1 and (y1 + 1) // 3 * 3 + 1 < y2:",
"- a, c = [x % box_size for x in (a, c)]",
"- return min(a + c - 2 * block_size + 2, 4 * block_size - a - c) + abs(b - d)",
"+ return c - a + d - b",
"+ elif x1 == x2 and x1 % 3 == 1 and (y1 + 1) // 3 * 3 + 1 < y2:",
"+ shifted = (a + c) % (2 * block_size)",
"+ return min(shifted - 2 * box_size + 2, 4 * box_size - shifted) + d - b",
"- b, d = [x % box_size for x in (b, d)]",
"- return min(b + d - 2 * block_size + 2, 4 * block_size - b - d) + abs(a - c)",
"- return abs(a - c) + abs(b - d)",
"+ shifted = (b + d) % (2 * block_size)",
"+ return min(shifted - 2 * box_size + 2, 4 * box_size - shifted) + c - a",
"+ return c - a + d - b"
] | false | 0.037701 | 0.038433 | 0.980944 | [
"s990725450",
"s475624479"
] |
u294485299 | p02684 | python | s059741224 | s958452329 | 181 | 154 | 102,980 | 125,800 | Accepted | Accepted | 14.92 | import math
def fact(n):
ans = 1
for i in range(2, n+1):
ans*= i
return ans
def comb(n, c):
return fact(n)//(fact(n-c)*c)
'''
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt= 0
i = 1
cycle = ['1']
for c in range(n):
i = a[i-1]
if(i in cycle):
break
else:
cycle.append(i)
ind = cycle.index(i)
k-= ind
rcycle = cycle[ind:]
if(k <= 0):
print(cycle[k+ind])
else:
now = (k+1)%len(rcycle)
print(rcycle[now-1])
'''
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
already = ["1"]
set = {"1"}
now = 1
for i in range(n):
now = str(a[int(now)-1])
if now in set:
break
else:
already.append(now)
set.add(now)
ind = already.index(now)
k -= ind
cycle = already[ind:]
if k <= 0:
print((already[k+ind]))
else:
now = (k+1) % len(cycle)
print((cycle[now-1])) | import math
def fact(n):
ans = 1
for i in range(2, n+1):
ans*= i
return ans
def comb(n, c):
return fact(n)//(fact(n-c)*c)
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt= 0
i = 1
cycle = ['1']
set = {'1'}
for c in range(n):
i = a[i-1]
if(i in set):
break
else:
cycle.append(i)
set.add(i)
ind = cycle.index(i)
k-= ind
rcycle = cycle[ind:]
if(k <= 0):
print((cycle[k+ind]))
else:
now = (k+1)%len(rcycle)
print((rcycle[now-1])) | 55 | 30 | 955 | 548 | import math
def fact(n):
ans = 1
for i in range(2, n + 1):
ans *= i
return ans
def comb(n, c):
return fact(n) // (fact(n - c) * c)
"""
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt= 0
i = 1
cycle = ['1']
for c in range(n):
i = a[i-1]
if(i in cycle):
break
else:
cycle.append(i)
ind = cycle.index(i)
k-= ind
rcycle = cycle[ind:]
if(k <= 0):
print(cycle[k+ind])
else:
now = (k+1)%len(rcycle)
print(rcycle[now-1])
"""
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
already = ["1"]
set = {"1"}
now = 1
for i in range(n):
now = str(a[int(now) - 1])
if now in set:
break
else:
already.append(now)
set.add(now)
ind = already.index(now)
k -= ind
cycle = already[ind:]
if k <= 0:
print((already[k + ind]))
else:
now = (k + 1) % len(cycle)
print((cycle[now - 1]))
| import math
def fact(n):
ans = 1
for i in range(2, n + 1):
ans *= i
return ans
def comb(n, c):
return fact(n) // (fact(n - c) * c)
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = 0
i = 1
cycle = ["1"]
set = {"1"}
for c in range(n):
i = a[i - 1]
if i in set:
break
else:
cycle.append(i)
set.add(i)
ind = cycle.index(i)
k -= ind
rcycle = cycle[ind:]
if k <= 0:
print((cycle[k + ind]))
else:
now = (k + 1) % len(rcycle)
print((rcycle[now - 1]))
| false | 45.454545 | [
"-\"\"\"",
"-n, k = map(int, input().split())",
"+n, k = list(map(int, input().split()))",
"-cnt= 0",
"+cnt = 0",
"-cycle = ['1']",
"+cycle = [\"1\"]",
"+set = {\"1\"}",
"- i = a[i-1]",
"- if(i in cycle):",
"+ i = a[i - 1]",
"+ if i in set:",
"+ set.add(i)",
"-k-= ind",
"+k -= ind",
"-if(k <= 0):",
"- print(cycle[k+ind])",
"+if k <= 0:",
"+ print((cycle[k + ind]))",
"- now = (k+1)%len(rcycle)",
"- print(rcycle[now-1])",
"-\"\"\"",
"-n, k = list(map(int, input().split()))",
"-a = list(map(int, input().split()))",
"-already = [\"1\"]",
"-set = {\"1\"}",
"-now = 1",
"-for i in range(n):",
"- now = str(a[int(now) - 1])",
"- if now in set:",
"- break",
"- else:",
"- already.append(now)",
"- set.add(now)",
"-ind = already.index(now)",
"-k -= ind",
"-cycle = already[ind:]",
"-if k <= 0:",
"- print((already[k + ind]))",
"-else:",
"- now = (k + 1) % len(cycle)",
"- print((cycle[now - 1]))",
"+ now = (k + 1) % len(rcycle)",
"+ print((rcycle[now - 1]))"
] | false | 0.041414 | 0.039889 | 1.038228 | [
"s059741224",
"s958452329"
] |
u968404618 | p03476 | python | s272812932 | s261577639 | 688 | 453 | 21,120 | 22,036 | Accepted | Accepted | 34.16 | import math
from itertools import accumulate
def is_prime(n):
if n == 1: return False
for k in range(2, int(math.sqrt(n))+1):
if n % k == 0: return False
return True
MAX = (10**5)+1
q = int(eval(input()))
A = [1 if is_prime(i)and is_prime((i + 1)//2) else 0 for i in range(MAX) ]
S = [0] + list(accumulate(A))
Q =[]
Q_append = Q.append
for _ in range(q):
l, r = list(map(int, input().split()))
Q_append((l, r))
for qi in Q:
print((S[qi[1]+1]-S[qi[0]])) | from itertools import accumulate
def primes(n):
prime = ([False]*2) + ([True]*(n-2))
for i in range(2, n):
if prime[i]:
for j in range(i*2, n, i):
prime[j] = False
return prime
MAX = (10**5)+1
is_prime = primes(MAX)
q = int(eval(input()))
A = [1 if is_prime[i] and is_prime[(i + 1)//2] else 0 for i in range(MAX)]
S = [0] + list(accumulate(A))
Q = []
Q_append = Q.append
for _ in range(q):
l, r = list(map(int, input().split()))
Q_append((l, r))
for qi in Q:
print((S[qi[1]+1]-S[qi[0]])) | 22 | 24 | 487 | 536 | import math
from itertools import accumulate
def is_prime(n):
if n == 1:
return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
MAX = (10**5) + 1
q = int(eval(input()))
A = [1 if is_prime(i) and is_prime((i + 1) // 2) else 0 for i in range(MAX)]
S = [0] + list(accumulate(A))
Q = []
Q_append = Q.append
for _ in range(q):
l, r = list(map(int, input().split()))
Q_append((l, r))
for qi in Q:
print((S[qi[1] + 1] - S[qi[0]]))
| from itertools import accumulate
def primes(n):
prime = ([False] * 2) + ([True] * (n - 2))
for i in range(2, n):
if prime[i]:
for j in range(i * 2, n, i):
prime[j] = False
return prime
MAX = (10**5) + 1
is_prime = primes(MAX)
q = int(eval(input()))
A = [1 if is_prime[i] and is_prime[(i + 1) // 2] else 0 for i in range(MAX)]
S = [0] + list(accumulate(A))
Q = []
Q_append = Q.append
for _ in range(q):
l, r = list(map(int, input().split()))
Q_append((l, r))
for qi in Q:
print((S[qi[1] + 1] - S[qi[0]]))
| false | 8.333333 | [
"-import math",
"-def is_prime(n):",
"- if n == 1:",
"- return False",
"- for k in range(2, int(math.sqrt(n)) + 1):",
"- if n % k == 0:",
"- return False",
"- return True",
"+def primes(n):",
"+ prime = ([False] * 2) + ([True] * (n - 2))",
"+ for i in range(2, n):",
"+ if prime[i]:",
"+ for j in range(i * 2, n, i):",
"+ prime[j] = False",
"+ return prime",
"+is_prime = primes(MAX)",
"-A = [1 if is_prime(i) and is_prime((i + 1) // 2) else 0 for i in range(MAX)]",
"+A = [1 if is_prime[i] and is_prime[(i + 1) // 2] else 0 for i in range(MAX)]"
] | false | 0.48553 | 0.100211 | 4.845068 | [
"s272812932",
"s261577639"
] |
u306773664 | p02898 | python | s870038066 | s836133110 | 177 | 47 | 20,896 | 11,908 | Accepted | Accepted | 73.45 | import numpy as np
N , K = list(map(int,input().split()))
h = list(map(int,input().split()))
print((sum(x >= K for x in h))) | N , K = list(map(int,input().split()))
h = list(map(int,input().split()))
print((sum(x >= K for x in h))) | 4 | 3 | 119 | 99 | import numpy as np
N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
print((sum(x >= K for x in h)))
| N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
print((sum(x >= K for x in h)))
| false | 25 | [
"-import numpy as np",
"-"
] | false | 0.040744 | 0.035911 | 1.134579 | [
"s870038066",
"s836133110"
] |
u314050667 | p02781 | python | s800113847 | s732591133 | 149 | 18 | 12,484 | 3,064 | Accepted | Accepted | 87.92 | import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(eval(input()))
K = int(eval(input()))
if int('1' * K) > N:
print((0))
sys.exit()
N = str(N)
L = len(N)
def C(a,b):
out = 1
for _ in range(b):
out *= a
a -= 1
for bb in range(1,b+1):
out //= bb
return out
def solve(N,n,K):
if K == 0:
return 1
if int('1' * K) > int(N):
return 0
ans = 0
#ๆกใๅฐใใๆ
for i in range(1,n):
if K - 1 > i - 1:
continue
else:
ans += 9 * C(i-1, K-1) * (9 ** (K-1))
#ๆกใๅใใงใๅ
้ ญใๅฐใใๆ
head = int(N[0])
ans += (head - 1) * C(n-1, K-1) * (9 ** (K-1))
#ๆกใๅใใงๅ
้ ญใไธ็ท
sh_N = ''
for i in range(1,n):
if N[i] != '0':
sh_N = N[i:]
break
if sh_N != '':
sh_n = len(sh_N)
ans += solve(sh_N, sh_n, K-1)
else:
if K == 1:
ans += 1
return ans
answer = solve(N,L,K)
print(answer)
| N = list(map(int, eval(input())))
K = int(eval(input()))
DP_conf = [[0] * (K+1) for _ in range(len(N))]
DP_unco = [[0] * (K+1) for _ in range(len(N))]
DP_conf[0][0] = 1
DP_conf[0][1] = N[0] - 1
DP_unco[0][0] = 0
DP_unco[0][1] = 1
for i in range(1,len(N)):
for j in range(K+1):
if j > i+1:
break
if j == 0:
DP_conf[i][j] = 1
DP_unco[i][j] = 0
else:
DP_conf[i][j] = DP_conf[i-1][j] + DP_conf[i-1][j-1] * 9
if N[i] > 0:
DP_conf[i][j] += DP_unco[i-1][j] + DP_unco[i-1][j-1] * (N[i] - 1)
DP_unco[i][j] = DP_unco[i-1][j-1]
else:
DP_unco[i][j] = DP_unco[i-1][j]
print((DP_conf[-1][K] + DP_unco[-1][K]))
| 63 | 30 | 942 | 660 | import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(eval(input()))
K = int(eval(input()))
if int("1" * K) > N:
print((0))
sys.exit()
N = str(N)
L = len(N)
def C(a, b):
out = 1
for _ in range(b):
out *= a
a -= 1
for bb in range(1, b + 1):
out //= bb
return out
def solve(N, n, K):
if K == 0:
return 1
if int("1" * K) > int(N):
return 0
ans = 0
# ๆกใๅฐใใๆ
for i in range(1, n):
if K - 1 > i - 1:
continue
else:
ans += 9 * C(i - 1, K - 1) * (9 ** (K - 1))
# ๆกใๅใใงใๅ
้ ญใๅฐใใๆ
head = int(N[0])
ans += (head - 1) * C(n - 1, K - 1) * (9 ** (K - 1))
# ๆกใๅใใงๅ
้ ญใไธ็ท
sh_N = ""
for i in range(1, n):
if N[i] != "0":
sh_N = N[i:]
break
if sh_N != "":
sh_n = len(sh_N)
ans += solve(sh_N, sh_n, K - 1)
else:
if K == 1:
ans += 1
return ans
answer = solve(N, L, K)
print(answer)
| N = list(map(int, eval(input())))
K = int(eval(input()))
DP_conf = [[0] * (K + 1) for _ in range(len(N))]
DP_unco = [[0] * (K + 1) for _ in range(len(N))]
DP_conf[0][0] = 1
DP_conf[0][1] = N[0] - 1
DP_unco[0][0] = 0
DP_unco[0][1] = 1
for i in range(1, len(N)):
for j in range(K + 1):
if j > i + 1:
break
if j == 0:
DP_conf[i][j] = 1
DP_unco[i][j] = 0
else:
DP_conf[i][j] = DP_conf[i - 1][j] + DP_conf[i - 1][j - 1] * 9
if N[i] > 0:
DP_conf[i][j] += DP_unco[i - 1][j] + DP_unco[i - 1][j - 1] * (N[i] - 1)
DP_unco[i][j] = DP_unco[i - 1][j - 1]
else:
DP_unco[i][j] = DP_unco[i - 1][j]
print((DP_conf[-1][K] + DP_unco[-1][K]))
| false | 52.380952 | [
"-import numpy as np",
"-import sys",
"-",
"-read = sys.stdin.buffer.read",
"-readline = sys.stdin.buffer.readline",
"-readlines = sys.stdin.buffer.readlines",
"-N = int(eval(input()))",
"+N = list(map(int, eval(input())))",
"-if int(\"1\" * K) > N:",
"- print((0))",
"- sys.exit()",
"-N = str(N)",
"-L = len(N)",
"-",
"-",
"-def C(a, b):",
"- out = 1",
"- for _ in range(b):",
"- out *= a",
"- a -= 1",
"- for bb in range(1, b + 1):",
"- out //= bb",
"- return out",
"-",
"-",
"-def solve(N, n, K):",
"- if K == 0:",
"- return 1",
"- if int(\"1\" * K) > int(N):",
"- return 0",
"- ans = 0",
"- # ๆกใๅฐใใๆ",
"- for i in range(1, n):",
"- if K - 1 > i - 1:",
"- continue",
"+DP_conf = [[0] * (K + 1) for _ in range(len(N))]",
"+DP_unco = [[0] * (K + 1) for _ in range(len(N))]",
"+DP_conf[0][0] = 1",
"+DP_conf[0][1] = N[0] - 1",
"+DP_unco[0][0] = 0",
"+DP_unco[0][1] = 1",
"+for i in range(1, len(N)):",
"+ for j in range(K + 1):",
"+ if j > i + 1:",
"+ break",
"+ if j == 0:",
"+ DP_conf[i][j] = 1",
"+ DP_unco[i][j] = 0",
"- ans += 9 * C(i - 1, K - 1) * (9 ** (K - 1))",
"- # ๆกใๅใใงใๅ
้ ญใๅฐใใๆ",
"- head = int(N[0])",
"- ans += (head - 1) * C(n - 1, K - 1) * (9 ** (K - 1))",
"- # ๆกใๅใใงๅ
้ ญใไธ็ท",
"- sh_N = \"\"",
"- for i in range(1, n):",
"- if N[i] != \"0\":",
"- sh_N = N[i:]",
"- break",
"- if sh_N != \"\":",
"- sh_n = len(sh_N)",
"- ans += solve(sh_N, sh_n, K - 1)",
"- else:",
"- if K == 1:",
"- ans += 1",
"- return ans",
"-",
"-",
"-answer = solve(N, L, K)",
"-print(answer)",
"+ DP_conf[i][j] = DP_conf[i - 1][j] + DP_conf[i - 1][j - 1] * 9",
"+ if N[i] > 0:",
"+ DP_conf[i][j] += DP_unco[i - 1][j] + DP_unco[i - 1][j - 1] * (N[i] - 1)",
"+ DP_unco[i][j] = DP_unco[i - 1][j - 1]",
"+ else:",
"+ DP_unco[i][j] = DP_unco[i - 1][j]",
"+print((DP_conf[-1][K] + DP_unco[-1][K]))"
] | false | 0.043471 | 0.037327 | 1.164606 | [
"s800113847",
"s732591133"
] |
u695811449 | p02956 | python | s075566723 | s909329172 | 1,782 | 1,470 | 125,796 | 126,848 | Accepted | Accepted | 17.51 | import sys
input = sys.stdin.readline
N=int(eval(input()))
POINT=[list(map(int,input().split())) for i in range(N)]
mod=998244353
PX=[p[0] for p in POINT]
PY=[p[1] for p in POINT]
compression_dict_x={a: ind for ind, a in enumerate(sorted(set(PX)))}
compression_dict_y={a: ind for ind, a in enumerate(sorted(set(PY)))}
for i in range(N):
POINT[i]=[compression_dict_x[POINT[i][0]]+1,compression_dict_y[POINT[i][1]]+1]
P_Y=sorted(POINT,key=lambda x:x[1])
# BIT(BIT-indexed tree)
LEN=len(compression_dict_x)# ๅฟ
่ฆใชใๅบงๆจๅง็ธฎใใ
BIT=[0]*(LEN+1)# 1-indexedใชtree
def update(v,w):# vใซwใๅ ใใ
while v<=LEN:
BIT[v]+=w
v+=(v&(-v))# ่ชๅใๅซใๅคงใใชใใผใใธ. ใใจใใฐv=3โv=4
def getvalue(v):# [1,v]ใฎๅบ้ใฎๅใๆฑใใ
ANS=0
while v!=0:
ANS+=BIT[v]
v-=(v&(-v))# ่ชๅใใๅฐใใ2ใใญใฎใใผใใธ. ใใจใใฐv=3โv=2ใธ
return ANS
ALL = pow(2,N,mod)-1
ANS= ALL*N%mod
for i in range(N):
ANS = (ANS - (pow(2,i,mod) -1)*4)%mod
for i in range(N):
x,y=P_Y[i]
up=getvalue(x)
ANS=(ANS+pow(2,up,mod)+pow(2,i-up,mod)-2)%mod
update(x,1)
P_Y2=P_Y[::-1]
BIT=[0]*(LEN+1)
for i in range(N):
x,y=P_Y2[i]
down=getvalue(x)
ANS=(ANS+pow(2,down,mod)+pow(2,i-down,mod)-2)%mod
update(x,1)
print(ANS)
| import sys
input = sys.stdin.readline
N=int(eval(input()))
POINT=[list(map(int,input().split())) for i in range(N)]
mod=998244353
compression_dict_x={a: ind for ind, a in enumerate(sorted(set([p[0] for p in POINT])))}
POINT=[[compression_dict_x[x]+1,y] for x,y in POINT]
P_Y=sorted(POINT,key=lambda x:x[1])
# BIT(BIT-indexed tree)
LEN=len(compression_dict_x)
BIT=[0]*(LEN+1)# 1-indexedใชtree
def update(v,w):# vใซwใๅ ใใ
while v<=LEN:
BIT[v]+=w
v+=(v&(-v))# ่ชๅใๅซใๅคงใใชใใผใใธ. ใใจใใฐv=3โv=4
def getvalue(v):# [1,v]ใฎๅบ้ใฎๅใๆฑใใ
ANS=0
while v!=0:
ANS+=BIT[v]
v-=(v&(-v))# ่ชๅใใๅฐใใ2ใใญใฎใใผใใธ. ใใจใใฐv=3โv=2ใธ
return ANS
ANS= 4*N+(pow(2,N,mod)-1)*(N-4)%mod
for i in range(N):
x,y=P_Y[i]
left=getvalue(x)
ANS=(ANS+pow(2,left,mod)+pow(2,i-left,mod)-2)%mod
update(x,1)
P_Y.reverse()
BIT=[0]*(LEN+1)
for i in range(N):
x,y=P_Y[i]
left=getvalue(x)
ANS=(ANS+pow(2,left,mod)+pow(2,i-left,mod)-2)%mod
update(x,1)
print(ANS)
| 66 | 47 | 1,273 | 1,024 | import sys
input = sys.stdin.readline
N = int(eval(input()))
POINT = [list(map(int, input().split())) for i in range(N)]
mod = 998244353
PX = [p[0] for p in POINT]
PY = [p[1] for p in POINT]
compression_dict_x = {a: ind for ind, a in enumerate(sorted(set(PX)))}
compression_dict_y = {a: ind for ind, a in enumerate(sorted(set(PY)))}
for i in range(N):
POINT[i] = [
compression_dict_x[POINT[i][0]] + 1,
compression_dict_y[POINT[i][1]] + 1,
]
P_Y = sorted(POINT, key=lambda x: x[1])
# BIT(BIT-indexed tree)
LEN = len(compression_dict_x) # ๅฟ
่ฆใชใๅบงๆจๅง็ธฎใใ
BIT = [0] * (LEN + 1) # 1-indexedใชtree
def update(v, w): # vใซwใๅ ใใ
while v <= LEN:
BIT[v] += w
v += v & (-v) # ่ชๅใๅซใๅคงใใชใใผใใธ. ใใจใใฐv=3โv=4
def getvalue(v): # [1,v]ใฎๅบ้ใฎๅใๆฑใใ
ANS = 0
while v != 0:
ANS += BIT[v]
v -= v & (-v) # ่ชๅใใๅฐใใ2ใใญใฎใใผใใธ. ใใจใใฐv=3โv=2ใธ
return ANS
ALL = pow(2, N, mod) - 1
ANS = ALL * N % mod
for i in range(N):
ANS = (ANS - (pow(2, i, mod) - 1) * 4) % mod
for i in range(N):
x, y = P_Y[i]
up = getvalue(x)
ANS = (ANS + pow(2, up, mod) + pow(2, i - up, mod) - 2) % mod
update(x, 1)
P_Y2 = P_Y[::-1]
BIT = [0] * (LEN + 1)
for i in range(N):
x, y = P_Y2[i]
down = getvalue(x)
ANS = (ANS + pow(2, down, mod) + pow(2, i - down, mod) - 2) % mod
update(x, 1)
print(ANS)
| import sys
input = sys.stdin.readline
N = int(eval(input()))
POINT = [list(map(int, input().split())) for i in range(N)]
mod = 998244353
compression_dict_x = {
a: ind for ind, a in enumerate(sorted(set([p[0] for p in POINT])))
}
POINT = [[compression_dict_x[x] + 1, y] for x, y in POINT]
P_Y = sorted(POINT, key=lambda x: x[1])
# BIT(BIT-indexed tree)
LEN = len(compression_dict_x)
BIT = [0] * (LEN + 1) # 1-indexedใชtree
def update(v, w): # vใซwใๅ ใใ
while v <= LEN:
BIT[v] += w
v += v & (-v) # ่ชๅใๅซใๅคงใใชใใผใใธ. ใใจใใฐv=3โv=4
def getvalue(v): # [1,v]ใฎๅบ้ใฎๅใๆฑใใ
ANS = 0
while v != 0:
ANS += BIT[v]
v -= v & (-v) # ่ชๅใใๅฐใใ2ใใญใฎใใผใใธ. ใใจใใฐv=3โv=2ใธ
return ANS
ANS = 4 * N + (pow(2, N, mod) - 1) * (N - 4) % mod
for i in range(N):
x, y = P_Y[i]
left = getvalue(x)
ANS = (ANS + pow(2, left, mod) + pow(2, i - left, mod) - 2) % mod
update(x, 1)
P_Y.reverse()
BIT = [0] * (LEN + 1)
for i in range(N):
x, y = P_Y[i]
left = getvalue(x)
ANS = (ANS + pow(2, left, mod) + pow(2, i - left, mod) - 2) % mod
update(x, 1)
print(ANS)
| false | 28.787879 | [
"-PX = [p[0] for p in POINT]",
"-PY = [p[1] for p in POINT]",
"-compression_dict_x = {a: ind for ind, a in enumerate(sorted(set(PX)))}",
"-compression_dict_y = {a: ind for ind, a in enumerate(sorted(set(PY)))}",
"-for i in range(N):",
"- POINT[i] = [",
"- compression_dict_x[POINT[i][0]] + 1,",
"- compression_dict_y[POINT[i][1]] + 1,",
"- ]",
"+compression_dict_x = {",
"+ a: ind for ind, a in enumerate(sorted(set([p[0] for p in POINT])))",
"+}",
"+POINT = [[compression_dict_x[x] + 1, y] for x, y in POINT]",
"-LEN = len(compression_dict_x) # ๅฟ
่ฆใชใๅบงๆจๅง็ธฎใใ",
"+LEN = len(compression_dict_x)",
"-ALL = pow(2, N, mod) - 1",
"-ANS = ALL * N % mod",
"-for i in range(N):",
"- ANS = (ANS - (pow(2, i, mod) - 1) * 4) % mod",
"+ANS = 4 * N + (pow(2, N, mod) - 1) * (N - 4) % mod",
"- up = getvalue(x)",
"- ANS = (ANS + pow(2, up, mod) + pow(2, i - up, mod) - 2) % mod",
"+ left = getvalue(x)",
"+ ANS = (ANS + pow(2, left, mod) + pow(2, i - left, mod) - 2) % mod",
"-P_Y2 = P_Y[::-1]",
"+P_Y.reverse()",
"- x, y = P_Y2[i]",
"- down = getvalue(x)",
"- ANS = (ANS + pow(2, down, mod) + pow(2, i - down, mod) - 2) % mod",
"+ x, y = P_Y[i]",
"+ left = getvalue(x)",
"+ ANS = (ANS + pow(2, left, mod) + pow(2, i - left, mod) - 2) % mod"
] | false | 0.063466 | 0.051213 | 1.239251 | [
"s075566723",
"s909329172"
] |
u141610915 | p02724 | python | s113751692 | s697721661 | 176 | 62 | 38,256 | 61,924 | Accepted | Accepted | 64.77 | import sys
input = sys.stdin.readline
X = int(eval(input()))
print((X // 500 * 1000 + (X % 500) // 5 * 5)) | import sys
input = sys.stdin.readline
X = int(eval(input()))
res = X // 500 * 1000
print((res + (X % 500) // 5 * 5)) | 4 | 5 | 101 | 112 | import sys
input = sys.stdin.readline
X = int(eval(input()))
print((X // 500 * 1000 + (X % 500) // 5 * 5))
| import sys
input = sys.stdin.readline
X = int(eval(input()))
res = X // 500 * 1000
print((res + (X % 500) // 5 * 5))
| false | 20 | [
"-print((X // 500 * 1000 + (X % 500) // 5 * 5))",
"+res = X // 500 * 1000",
"+print((res + (X % 500) // 5 * 5))"
] | false | 0.057483 | 0.035202 | 1.632953 | [
"s113751692",
"s697721661"
] |
u753803401 | p03147 | python | s275083764 | s511954355 | 210 | 168 | 40,944 | 38,384 | Accepted | Accepted | 20 | n = int(eval(input()))
h = list(map(int, input().split()))
h.insert(0, 0)
h.append(0)
cnt = 0
while True:
s = -1
e = -1
m_n = 10 ** 10
for i in range(1, n + 2):
if h[i] != 0 and h[i-1] == 0:
s = i
m_n = min(m_n, h[i])
for j in range(i + 1, n + 2):
if h[j] == 0 and h[j - 1] != 0:
e = j - 1
break
else:
m_n = min(m_n, h[j])
if s == -1 and e == -1:
print(cnt)
exit()
else:
cnt += m_n
for i in range(s, e + 1):
h[i] -= m_n
| def slove():
import sys
input = sys.stdin.readline
n = int(input().rstrip('\n'))
h = list(map(int, input().rstrip('\n').split()))
l = 0
cnt = 0
for i in range(n):
if l < h[i]:
cnt += h[i] - l
l = h[i]
print(cnt)
if __name__ == '__main__':
slove()
| 27 | 16 | 645 | 328 | n = int(eval(input()))
h = list(map(int, input().split()))
h.insert(0, 0)
h.append(0)
cnt = 0
while True:
s = -1
e = -1
m_n = 10**10
for i in range(1, n + 2):
if h[i] != 0 and h[i - 1] == 0:
s = i
m_n = min(m_n, h[i])
for j in range(i + 1, n + 2):
if h[j] == 0 and h[j - 1] != 0:
e = j - 1
break
else:
m_n = min(m_n, h[j])
if s == -1 and e == -1:
print(cnt)
exit()
else:
cnt += m_n
for i in range(s, e + 1):
h[i] -= m_n
| def slove():
import sys
input = sys.stdin.readline
n = int(input().rstrip("\n"))
h = list(map(int, input().rstrip("\n").split()))
l = 0
cnt = 0
for i in range(n):
if l < h[i]:
cnt += h[i] - l
l = h[i]
print(cnt)
if __name__ == "__main__":
slove()
| false | 40.740741 | [
"-n = int(eval(input()))",
"-h = list(map(int, input().split()))",
"-h.insert(0, 0)",
"-h.append(0)",
"-cnt = 0",
"-while True:",
"- s = -1",
"- e = -1",
"- m_n = 10**10",
"- for i in range(1, n + 2):",
"- if h[i] != 0 and h[i - 1] == 0:",
"- s = i",
"- m_n = min(m_n, h[i])",
"- for j in range(i + 1, n + 2):",
"- if h[j] == 0 and h[j - 1] != 0:",
"- e = j - 1",
"- break",
"- else:",
"- m_n = min(m_n, h[j])",
"- if s == -1 and e == -1:",
"- print(cnt)",
"- exit()",
"- else:",
"- cnt += m_n",
"- for i in range(s, e + 1):",
"- h[i] -= m_n",
"+def slove():",
"+ import sys",
"+",
"+ input = sys.stdin.readline",
"+ n = int(input().rstrip(\"\\n\"))",
"+ h = list(map(int, input().rstrip(\"\\n\").split()))",
"+ l = 0",
"+ cnt = 0",
"+ for i in range(n):",
"+ if l < h[i]:",
"+ cnt += h[i] - l",
"+ l = h[i]",
"+ print(cnt)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ slove()"
] | false | 0.042896 | 0.035218 | 1.218007 | [
"s275083764",
"s511954355"
] |
u345966487 | p02629 | python | s519021576 | s657680079 | 33 | 28 | 9,212 | 9,216 | Accepted | Accepted | 15.15 | import sys
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)
N = ini()
def solve():
k = 26
a = k
p = k
l = 1
while a < N:
p *= 26
a += p
l += 1
b = 1
x = N - 1
name = [None] * l
for i in range(l):
c = x % 26
name[l - 1 - i] = chr(ord("a") + c)
x //= 26
x -= 1
return "".join(name)
print(solve())
| import sys
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)
N = ini()
def solve():
k = 26
a = k
p = k
l = 1
while a < N:
p *= 26
a += p
l += 1
x = N - (a - p) - 1
name = [None] * l
for i in range(l):
c = x % 26
name[i] = chr(ord("a") + c)
x //= 26
return "".join(reversed(name))
print(solve())
| 33 | 31 | 632 | 617 | import sys
sys.setrecursionlimit(10**8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)
N = ini()
def solve():
k = 26
a = k
p = k
l = 1
while a < N:
p *= 26
a += p
l += 1
b = 1
x = N - 1
name = [None] * l
for i in range(l):
c = x % 26
name[l - 1 - i] = chr(ord("a") + c)
x //= 26
x -= 1
return "".join(name)
print(solve())
| import sys
sys.setrecursionlimit(10**8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)
N = ini()
def solve():
k = 26
a = k
p = k
l = 1
while a < N:
p *= 26
a += p
l += 1
x = N - (a - p) - 1
name = [None] * l
for i in range(l):
c = x % 26
name[i] = chr(ord("a") + c)
x //= 26
return "".join(reversed(name))
print(solve())
| false | 6.060606 | [
"- b = 1",
"- x = N - 1",
"+ x = N - (a - p) - 1",
"- name[l - 1 - i] = chr(ord(\"a\") + c)",
"+ name[i] = chr(ord(\"a\") + c)",
"- x -= 1",
"- return \"\".join(name)",
"+ return \"\".join(reversed(name))"
] | false | 0.035464 | 0.034296 | 1.034033 | [
"s519021576",
"s657680079"
] |
u336564899 | p03844 | python | s486234140 | s063761859 | 27 | 23 | 9,172 | 9,016 | Accepted | Accepted | 14.81 | '''
ABC050 A - Addition and Subtraction Easy
https://atcoder.jp/contests/abc050/tasks/abc050_a
'''
a, op, b = input().split()
a, b = int(a), int(b)
if op == '+':
ans = a+b
elif op == '-':
ans = a-b
print(ans)
| '''
ABC050 A - Addition and Subtraction Easy
https://atcoder.jp/contests/abc050/tasks/abc050_a
'''
def main():
a, op, b = input().split()
a, b = int(a), int(b)
if op == '+':
ans = a+b
elif op == '-':
ans = a-b
print(ans)
if __name__ == '__main__':
main()
| 12 | 16 | 229 | 312 | """
ABC050 A - Addition and Subtraction Easy
https://atcoder.jp/contests/abc050/tasks/abc050_a
"""
a, op, b = input().split()
a, b = int(a), int(b)
if op == "+":
ans = a + b
elif op == "-":
ans = a - b
print(ans)
| """
ABC050 A - Addition and Subtraction Easy
https://atcoder.jp/contests/abc050/tasks/abc050_a
"""
def main():
a, op, b = input().split()
a, b = int(a), int(b)
if op == "+":
ans = a + b
elif op == "-":
ans = a - b
print(ans)
if __name__ == "__main__":
main()
| false | 25 | [
"-a, op, b = input().split()",
"-a, b = int(a), int(b)",
"-if op == \"+\":",
"- ans = a + b",
"-elif op == \"-\":",
"- ans = a - b",
"-print(ans)",
"+",
"+",
"+def main():",
"+ a, op, b = input().split()",
"+ a, b = int(a), int(b)",
"+ if op == \"+\":",
"+ ans = a + b",
"+ elif op == \"-\":",
"+ ans = a - b",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.070613 | 0.074806 | 0.943954 | [
"s486234140",
"s063761859"
] |
u130900604 | p02971 | python | s662809886 | s877891819 | 527 | 282 | 14,208 | 25,156 | Accepted | Accepted | 46.49 | n=int(eval(input()))
a=[int(eval(input())) for i in range(n)]
b=sorted(a)
m1=b[-1]
m2=b[-2]
for c in a:
if c == m1:
print(m2)
else:
print(m1)
| n,*a=list(map(int,open(0).read().split()))
b=sorted(a)[::-1]
ma1=b[0]
ma2=b[1]
for i in a:
if ma1==i:
print(ma2)
else:
print(ma1)
| 11 | 10 | 154 | 149 | n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
b = sorted(a)
m1 = b[-1]
m2 = b[-2]
for c in a:
if c == m1:
print(m2)
else:
print(m1)
| n, *a = list(map(int, open(0).read().split()))
b = sorted(a)[::-1]
ma1 = b[0]
ma2 = b[1]
for i in a:
if ma1 == i:
print(ma2)
else:
print(ma1)
| false | 9.090909 | [
"-n = int(eval(input()))",
"-a = [int(eval(input())) for i in range(n)]",
"-b = sorted(a)",
"-m1 = b[-1]",
"-m2 = b[-2]",
"-for c in a:",
"- if c == m1:",
"- print(m2)",
"+n, *a = list(map(int, open(0).read().split()))",
"+b = sorted(a)[::-1]",
"+ma1 = b[0]",
"+ma2 = b[1]",
"+for i in a:",
"+ if ma1 == i:",
"+ print(ma2)",
"- print(m1)",
"+ print(ma1)"
] | false | 0.111244 | 0.124714 | 0.891992 | [
"s662809886",
"s877891819"
] |
u116002573 | p02790 | python | s265391769 | s460230107 | 188 | 64 | 38,256 | 61,820 | Accepted | Accepted | 65.96 | def main():
a, b = input().split()
aa = a*int(b)
bb = b*int(a)
if aa < bb:
return aa
return bb
if __name__ == '__main__':
print((main()))
| def main():
a, b = input().split()
s = a * int(b)
t = b * int(a)
if s < t:
return s
return t
if __name__ == '__main__':
print((main()))
| 12 | 12 | 182 | 180 | def main():
a, b = input().split()
aa = a * int(b)
bb = b * int(a)
if aa < bb:
return aa
return bb
if __name__ == "__main__":
print((main()))
| def main():
a, b = input().split()
s = a * int(b)
t = b * int(a)
if s < t:
return s
return t
if __name__ == "__main__":
print((main()))
| false | 0 | [
"- aa = a * int(b)",
"- bb = b * int(a)",
"- if aa < bb:",
"- return aa",
"- return bb",
"+ s = a * int(b)",
"+ t = b * int(a)",
"+ if s < t:",
"+ return s",
"+ return t"
] | false | 0.035443 | 0.0327 | 1.083889 | [
"s265391769",
"s460230107"
] |
u143509139 | p03151 | python | s568215316 | s812027409 | 150 | 113 | 19,188 | 19,536 | Accepted | Accepted | 24.67 | from bisect import bisect_right
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if sum(a) == sum(b):
print(n)
mp = 0
ans = 0
l = []
for i in range(n):
if a[i] < b[i]:
mp -= b[i] - a[i]
elif a[i] >= b[i]:
mp += a[i] - b[i]
l.append(a[i] - b[i])
l.sort()
if mp < 0:
print((-1))
else:
for i in range(len(l) - 1):
l[i + 1] += l[i]
print((n - bisect_right(l, mp))) | n=int(eval(input()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(a)<sum(b):
print((-1))
exit(0)
t=sum(a)-sum(b)
l=[]
for i in range(n):
if a[i] >= b[i]:
l.append(a[i]-b[i])
l.sort()
ans=0
for x in l:
t-=x
if t<0:
break
ans+=1
print((n-ans)) | 22 | 19 | 473 | 297 | from bisect import bisect_right
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if sum(a) == sum(b):
print(n)
mp = 0
ans = 0
l = []
for i in range(n):
if a[i] < b[i]:
mp -= b[i] - a[i]
elif a[i] >= b[i]:
mp += a[i] - b[i]
l.append(a[i] - b[i])
l.sort()
if mp < 0:
print((-1))
else:
for i in range(len(l) - 1):
l[i + 1] += l[i]
print((n - bisect_right(l, mp)))
| n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if sum(a) < sum(b):
print((-1))
exit(0)
t = sum(a) - sum(b)
l = []
for i in range(n):
if a[i] >= b[i]:
l.append(a[i] - b[i])
l.sort()
ans = 0
for x in l:
t -= x
if t < 0:
break
ans += 1
print((n - ans))
| false | 13.636364 | [
"-from bisect import bisect_right",
"-",
"-if sum(a) == sum(b):",
"- print(n)",
"-mp = 0",
"-ans = 0",
"+if sum(a) < sum(b):",
"+ print((-1))",
"+ exit(0)",
"+t = sum(a) - sum(b)",
"- if a[i] < b[i]:",
"- mp -= b[i] - a[i]",
"- elif a[i] >= b[i]:",
"- mp += a[i] - b[i]",
"+ if a[i] >= b[i]:",
"-if mp < 0:",
"- print((-1))",
"-else:",
"- for i in range(len(l) - 1):",
"- l[i + 1] += l[i]",
"- print((n - bisect_right(l, mp)))",
"+ans = 0",
"+for x in l:",
"+ t -= x",
"+ if t < 0:",
"+ break",
"+ ans += 1",
"+print((n - ans))"
] | false | 0.038964 | 0.042597 | 0.914711 | [
"s568215316",
"s812027409"
] |
u600402037 | p02793 | python | s204474557 | s454972479 | 1,478 | 1,080 | 6,136 | 6,136 | Accepted | Accepted | 26.93 | import sys
from fractions import gcd
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10 ** 9 + 7
N = ir()
A = lr()
# lcm
lcm = 1
answer = 0
for a in A:
coef = a // gcd(lcm, a)
answer *= coef
lcm *= coef
answer += lcm // a
answer %= MOD
print((answer%MOD))
| import sys
from fractions import gcd
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10 ** 9 + 7
N = ir()
A = lr()
lcm = 1
answer = 0
for a in A:
coef = a // gcd(lcm, a)
answer *= coef
lcm *= coef
answer += lcm // a
print((answer%MOD))
| 21 | 19 | 364 | 338 | import sys
from fractions import gcd
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10**9 + 7
N = ir()
A = lr()
# lcm
lcm = 1
answer = 0
for a in A:
coef = a // gcd(lcm, a)
answer *= coef
lcm *= coef
answer += lcm // a
answer %= MOD
print((answer % MOD))
| import sys
from fractions import gcd
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10**9 + 7
N = ir()
A = lr()
lcm = 1
answer = 0
for a in A:
coef = a // gcd(lcm, a)
answer *= coef
lcm *= coef
answer += lcm // a
print((answer % MOD))
| false | 9.52381 | [
"-# lcm",
"- answer %= MOD"
] | false | 0.046747 | 0.045568 | 1.025872 | [
"s204474557",
"s454972479"
] |
u588341295 | p02901 | python | s398265620 | s950444620 | 380 | 309 | 49,500 | 46,044 | Accepted | Accepted | 18.68 | # -*- 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 range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
N, M = MAP()
# (้ตใฎ่ณผๅ
ฅใณในใ, ้ใใใใๅฎ็ฎฑ)
keys = [None] * M
for i in range(M):
c, _ = MAP()
# ใฉใฎๅฎ็ฎฑใ้ใใใใใฎใใbitใงๆใฃใฆใใ
s = 0
for a in [a-1 for a in LIST()]:
s += 1 << a
keys[i] = (c, s)
# dp[i][j] := iๅ็ฎใฎ้ตใพใง่ฆใฆใ้ๅjใฎๅฎ็ฎฑใ้ใใใใใฎๆๅฐใณในใ
dp = list2d(2, 1<<N, INF)
dp[0][0] = 0
cur = 0
nxt = 1
for i in range(M):
# ไปๅใฎ้ตใง้ใใใใๅฎ็ฎฑใฎ้ๅs
s = keys[i][1]
c = keys[i][0]
for j in range(1<<N):
# ไปๅใฎ้ตใ่ฒทใใชใ้ท็งป
dp[nxt][j] = min(dp[nxt][j], dp[cur][j])
if dp[cur][j] != INF:
m = j | s
# ่ฒทใ้ท็งป๏ผ้ท็งปๅ
ใฎ้ใใใใๅฎ็ฎฑใฎ้ๅj | ไปๅใฎ้ตใง้ใใใใๅฎ็ฎฑใฎ้ๅs
dp[nxt][m] = min(dp[nxt][m], dp[cur][j]+c)
cur, nxt = nxt, cur
ans = dp[M%2][-1]
if ans != INF:
print(ans)
else:
print((-1))
| # -*- 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 range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
N, M = MAP()
# (้ตใฎ่ณผๅ
ฅใณในใ, ้ใใใใๅฎ็ฎฑ)
keys = [None] * M
for i in range(M):
c, _ = MAP()
# ใฉใฎๅฎ็ฎฑใ้ใใใใใฎใใbitใงๆใฃใฆใใ
s = 0
for a in [a-1 for a in LIST()]:
s += 1 << a
keys[i] = (c, s)
# dp[i][j] := iๅ็ฎใฎ้ตใพใง่ฆใฆใ้ๅjใฎๅฎ็ฎฑใ้ใใใใใฎๆๅฐใณในใ
dp = list2d(2, 1<<N, INF)
dp[0][0] = 0
for i in range(M):
# ไปๅใฎ้ตใง้ใใใใๅฎ็ฎฑใฎ้ๅs
s = keys[i][1]
c = keys[i][0]
cur = i % 2
nxt = (i+1) % 2
# ไปๅใฎ้ตใ่ฒทใใชใ้ท็งป
dp[nxt] = dp[cur][:]
for j in range(1<<N):
if dp[cur][j] != INF:
m = j | s
# ่ฒทใ้ท็งป๏ผ้ท็งปๅ
ใฎ้ใใใใๅฎ็ฎฑใฎ้ๅj | ไปๅใฎ้ตใง้ใใใใๅฎ็ฎฑใฎ้ๅs
dp[nxt][m] = min(dp[nxt][m], dp[cur][j]+c)
ans = dp[M%2][-1]
if ans != INF:
print(ans)
else:
print((-1))
| 55 | 54 | 1,470 | 1,437 | # -*- 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 range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9 + 7
N, M = MAP()
# (้ตใฎ่ณผๅ
ฅใณในใ, ้ใใใใๅฎ็ฎฑ)
keys = [None] * M
for i in range(M):
c, _ = MAP()
# ใฉใฎๅฎ็ฎฑใ้ใใใใใฎใใbitใงๆใฃใฆใใ
s = 0
for a in [a - 1 for a in LIST()]:
s += 1 << a
keys[i] = (c, s)
# dp[i][j] := iๅ็ฎใฎ้ตใพใง่ฆใฆใ้ๅjใฎๅฎ็ฎฑใ้ใใใใใฎๆๅฐใณในใ
dp = list2d(2, 1 << N, INF)
dp[0][0] = 0
cur = 0
nxt = 1
for i in range(M):
# ไปๅใฎ้ตใง้ใใใใๅฎ็ฎฑใฎ้ๅs
s = keys[i][1]
c = keys[i][0]
for j in range(1 << N):
# ไปๅใฎ้ตใ่ฒทใใชใ้ท็งป
dp[nxt][j] = min(dp[nxt][j], dp[cur][j])
if dp[cur][j] != INF:
m = j | s
# ่ฒทใ้ท็งป๏ผ้ท็งปๅ
ใฎ้ใใใใๅฎ็ฎฑใฎ้ๅj | ไปๅใฎ้ตใง้ใใใใๅฎ็ฎฑใฎ้ๅs
dp[nxt][m] = min(dp[nxt][m], dp[cur][j] + c)
cur, nxt = nxt, cur
ans = dp[M % 2][-1]
if ans != INF:
print(ans)
else:
print((-1))
| # -*- 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 range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9 + 7
N, M = MAP()
# (้ตใฎ่ณผๅ
ฅใณในใ, ้ใใใใๅฎ็ฎฑ)
keys = [None] * M
for i in range(M):
c, _ = MAP()
# ใฉใฎๅฎ็ฎฑใ้ใใใใใฎใใbitใงๆใฃใฆใใ
s = 0
for a in [a - 1 for a in LIST()]:
s += 1 << a
keys[i] = (c, s)
# dp[i][j] := iๅ็ฎใฎ้ตใพใง่ฆใฆใ้ๅjใฎๅฎ็ฎฑใ้ใใใใใฎๆๅฐใณในใ
dp = list2d(2, 1 << N, INF)
dp[0][0] = 0
for i in range(M):
# ไปๅใฎ้ตใง้ใใใใๅฎ็ฎฑใฎ้ๅs
s = keys[i][1]
c = keys[i][0]
cur = i % 2
nxt = (i + 1) % 2
# ไปๅใฎ้ตใ่ฒทใใชใ้ท็งป
dp[nxt] = dp[cur][:]
for j in range(1 << N):
if dp[cur][j] != INF:
m = j | s
# ่ฒทใ้ท็งป๏ผ้ท็งปๅ
ใฎ้ใใใใๅฎ็ฎฑใฎ้ๅj | ไปๅใฎ้ตใง้ใใใใๅฎ็ฎฑใฎ้ๅs
dp[nxt][m] = min(dp[nxt][m], dp[cur][j] + c)
ans = dp[M % 2][-1]
if ans != INF:
print(ans)
else:
print((-1))
| false | 1.818182 | [
"-cur = 0",
"-nxt = 1",
"+ cur = i % 2",
"+ nxt = (i + 1) % 2",
"+ # ไปๅใฎ้ตใ่ฒทใใชใ้ท็งป",
"+ dp[nxt] = dp[cur][:]",
"- # ไปๅใฎ้ตใ่ฒทใใชใ้ท็งป",
"- dp[nxt][j] = min(dp[nxt][j], dp[cur][j])",
"- cur, nxt = nxt, cur"
] | false | 0.03347 | 0.035767 | 0.935763 | [
"s398265620",
"s950444620"
] |
u609061751 | p03481 | python | s445183826 | s246904396 | 180 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.56 | import sys
input = sys.stdin.readline
x, y = [int(x) for x in input().split()]
ans = 0
while x <= y:
x *= 2
ans += 1
print(ans)
| import sys
input = lambda: sys.stdin.readline().rstrip()
x, y = list(map(int, input().split()))
cnt = 1
while True:
if x*2 <= y:
cnt += 1
x *= 2
else:
break
print(cnt)
| 13 | 14 | 153 | 211 | import sys
input = sys.stdin.readline
x, y = [int(x) for x in input().split()]
ans = 0
while x <= y:
x *= 2
ans += 1
print(ans)
| import sys
input = lambda: sys.stdin.readline().rstrip()
x, y = list(map(int, input().split()))
cnt = 1
while True:
if x * 2 <= y:
cnt += 1
x *= 2
else:
break
print(cnt)
| false | 7.142857 | [
"-input = sys.stdin.readline",
"-x, y = [int(x) for x in input().split()]",
"-ans = 0",
"-while x <= y:",
"- x *= 2",
"- ans += 1",
"-print(ans)",
"+input = lambda: sys.stdin.readline().rstrip()",
"+x, y = list(map(int, input().split()))",
"+cnt = 1",
"+while True:",
"+ if x * 2 <= y:",
"+ cnt += 1",
"+ x *= 2",
"+ else:",
"+ break",
"+print(cnt)"
] | false | 0.041413 | 0.039903 | 1.037835 | [
"s445183826",
"s246904396"
] |
u284854859 | p03162 | python | s940719649 | s835933156 | 503 | 324 | 24,332 | 27,492 | Accepted | Accepted | 35.59 | n = int(eval(input()))
a,b,c = list(map(int,input().split()))
dp = [0,0,0] * n
dp[0] = [a,b,c]
for i in range(1,n):
a,b,c = list(map(int,input().split()))
dp[i] = [max(dp[i-1][1],dp[i-1][2])+a,max(dp[i-1][0],dp[i-1][2])+b,max(dp[i-1][0],dp[i-1][1])+c]
print((max(dp[n-1]))) | import sys
input = sys.stdin.readline
n = int(eval(input()))
a = [0]*n
b = [0]*n
c = [0]*n
for i in range(n):
a[i],b[i],c[i] = list(map(int,input().split()))
dpa = [a[0]]+[0]*(n-1)
dpb = [b[0]]+[0]*(n-1)
dpc = [c[0]]+[0]*(n-1)
for i in range(1,n):
dpa[i] = max(dpb[i-1],dpc[i-1]) + a[i]
dpb[i] = max(dpc[i-1],dpa[i-1]) + b[i]
dpc[i] = max(dpa[i-1],dpb[i-1]) + c[i]
print((max(dpa[-1],dpb[-1],dpc[-1])))
| 9 | 17 | 270 | 422 | n = int(eval(input()))
a, b, c = list(map(int, input().split()))
dp = [0, 0, 0] * n
dp[0] = [a, b, c]
for i in range(1, n):
a, b, c = list(map(int, input().split()))
dp[i] = [
max(dp[i - 1][1], dp[i - 1][2]) + a,
max(dp[i - 1][0], dp[i - 1][2]) + b,
max(dp[i - 1][0], dp[i - 1][1]) + c,
]
print((max(dp[n - 1])))
| import sys
input = sys.stdin.readline
n = int(eval(input()))
a = [0] * n
b = [0] * n
c = [0] * n
for i in range(n):
a[i], b[i], c[i] = list(map(int, input().split()))
dpa = [a[0]] + [0] * (n - 1)
dpb = [b[0]] + [0] * (n - 1)
dpc = [c[0]] + [0] * (n - 1)
for i in range(1, n):
dpa[i] = max(dpb[i - 1], dpc[i - 1]) + a[i]
dpb[i] = max(dpc[i - 1], dpa[i - 1]) + b[i]
dpc[i] = max(dpa[i - 1], dpb[i - 1]) + c[i]
print((max(dpa[-1], dpb[-1], dpc[-1])))
| false | 47.058824 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"-a, b, c = list(map(int, input().split()))",
"-dp = [0, 0, 0] * n",
"-dp[0] = [a, b, c]",
"+a = [0] * n",
"+b = [0] * n",
"+c = [0] * n",
"+for i in range(n):",
"+ a[i], b[i], c[i] = list(map(int, input().split()))",
"+dpa = [a[0]] + [0] * (n - 1)",
"+dpb = [b[0]] + [0] * (n - 1)",
"+dpc = [c[0]] + [0] * (n - 1)",
"- a, b, c = list(map(int, input().split()))",
"- dp[i] = [",
"- max(dp[i - 1][1], dp[i - 1][2]) + a,",
"- max(dp[i - 1][0], dp[i - 1][2]) + b,",
"- max(dp[i - 1][0], dp[i - 1][1]) + c,",
"- ]",
"-print((max(dp[n - 1])))",
"+ dpa[i] = max(dpb[i - 1], dpc[i - 1]) + a[i]",
"+ dpb[i] = max(dpc[i - 1], dpa[i - 1]) + b[i]",
"+ dpc[i] = max(dpa[i - 1], dpb[i - 1]) + c[i]",
"+print((max(dpa[-1], dpb[-1], dpc[-1])))"
] | false | 0.036706 | 0.035852 | 1.023809 | [
"s940719649",
"s835933156"
] |
u837286475 | p03014 | python | s934974659 | s216944238 | 1,987 | 742 | 184,196 | 179,844 | Accepted | Accepted | 62.66 |
import copy
h, w = list(map(int , input().split() ))
board = [eval(input()) for _ in range(h)]
left = [ [0]*w for _ in range(h)]
right = copy.deepcopy(left ) #ใใใคๅณใฎใในใ็
งใใใใ
down = copy.deepcopy(left)
up = copy.deepcopy(left)
for hi in range(h):
for wi in range(w):
if board[hi][wi] == '.':
left[hi][wi] = 1
up[hi][wi] = 1
if 1 <= wi:
left[hi][wi] += left[hi][wi-1]
if 1 <= hi:
up[hi][wi] += up[hi-1][wi]
if board[hi][w-wi-1] =='.':
right[hi][w-wi-1] = 1
if 1<=wi:
right[hi][w-wi-1] += right[hi][w-wi]
if board[h-hi-1][wi] == '.':
down[h-hi-1][wi] = 1
if 1 <= hi:
down[h-hi-1][wi] += down[h-hi][wi]
def dbcheck():
print()
tag = ["r","l","d","u"]
for t,x in zip(tag,[right,left,down,up]):
print(t)
for row in x:
print(row)
print()
#dbcheck()
ans = 0
for i in range(h):
for j in range(w):
t = right[i][j] + left[i][j] + up[i][j] + down[i][j]
t -= 3
ans = max(ans,t)
print(ans) |
import copy
h, w = list(map(int , input().split() ))
board = [eval(input()) for _ in range(h)]
left = [ [0]*w for _ in range(h)]
right = [ [0]*w for _ in range(h)] #ใใใคๅณใฎใในใ็
งใใใใ
down = [ [0]*w for _ in range(h)]
up = [ [0]*w for _ in range(h)]
for hi in range(h):
for wi in range(w):
if board[hi][wi] == '.':
left[hi][wi] = 1
up[hi][wi] = 1
if 1 <= wi:
left[hi][wi] += left[hi][wi-1]
if 1 <= hi:
up[hi][wi] += up[hi-1][wi]
if board[hi][w-wi-1] =='.':
right[hi][w-wi-1] = 1
if 1<=wi:
right[hi][w-wi-1] += right[hi][w-wi]
if board[h-hi-1][wi] == '.':
down[h-hi-1][wi] = 1
if 1 <= hi:
down[h-hi-1][wi] += down[h-hi][wi]
def dbcheck():
print()
tag = ["r","l","d","u"]
for t,x in zip(tag,[right,left,down,up]):
print(t)
for row in x:
print(row)
print()
#dbcheck()
ans = 0
for i in range(h):
for j in range(w):
t = right[i][j] + left[i][j] + up[i][j] + down[i][j]
t -= 3
ans = max(ans,t)
print(ans) | 61 | 61 | 1,215 | 1,235 | import copy
h, w = list(map(int, input().split()))
board = [eval(input()) for _ in range(h)]
left = [[0] * w for _ in range(h)]
right = copy.deepcopy(left) # ใใใคๅณใฎใในใ็
งใใใใ
down = copy.deepcopy(left)
up = copy.deepcopy(left)
for hi in range(h):
for wi in range(w):
if board[hi][wi] == ".":
left[hi][wi] = 1
up[hi][wi] = 1
if 1 <= wi:
left[hi][wi] += left[hi][wi - 1]
if 1 <= hi:
up[hi][wi] += up[hi - 1][wi]
if board[hi][w - wi - 1] == ".":
right[hi][w - wi - 1] = 1
if 1 <= wi:
right[hi][w - wi - 1] += right[hi][w - wi]
if board[h - hi - 1][wi] == ".":
down[h - hi - 1][wi] = 1
if 1 <= hi:
down[h - hi - 1][wi] += down[h - hi][wi]
def dbcheck():
print()
tag = ["r", "l", "d", "u"]
for t, x in zip(tag, [right, left, down, up]):
print(t)
for row in x:
print(row)
print()
# dbcheck()
ans = 0
for i in range(h):
for j in range(w):
t = right[i][j] + left[i][j] + up[i][j] + down[i][j]
t -= 3
ans = max(ans, t)
print(ans)
| import copy
h, w = list(map(int, input().split()))
board = [eval(input()) for _ in range(h)]
left = [[0] * w for _ in range(h)]
right = [[0] * w for _ in range(h)] # ใใใคๅณใฎใในใ็
งใใใใ
down = [[0] * w for _ in range(h)]
up = [[0] * w for _ in range(h)]
for hi in range(h):
for wi in range(w):
if board[hi][wi] == ".":
left[hi][wi] = 1
up[hi][wi] = 1
if 1 <= wi:
left[hi][wi] += left[hi][wi - 1]
if 1 <= hi:
up[hi][wi] += up[hi - 1][wi]
if board[hi][w - wi - 1] == ".":
right[hi][w - wi - 1] = 1
if 1 <= wi:
right[hi][w - wi - 1] += right[hi][w - wi]
if board[h - hi - 1][wi] == ".":
down[h - hi - 1][wi] = 1
if 1 <= hi:
down[h - hi - 1][wi] += down[h - hi][wi]
def dbcheck():
print()
tag = ["r", "l", "d", "u"]
for t, x in zip(tag, [right, left, down, up]):
print(t)
for row in x:
print(row)
print()
# dbcheck()
ans = 0
for i in range(h):
for j in range(w):
t = right[i][j] + left[i][j] + up[i][j] + down[i][j]
t -= 3
ans = max(ans, t)
print(ans)
| false | 0 | [
"-right = copy.deepcopy(left) # ใใใคๅณใฎใในใ็
งใใใใ",
"-down = copy.deepcopy(left)",
"-up = copy.deepcopy(left)",
"+right = [[0] * w for _ in range(h)] # ใใใคๅณใฎใในใ็
งใใใใ",
"+down = [[0] * w for _ in range(h)]",
"+up = [[0] * w for _ in range(h)]"
] | false | 0.044231 | 0.041722 | 1.060132 | [
"s934974659",
"s216944238"
] |
u298297089 | p03329 | python | s825804214 | s244418630 | 400 | 189 | 7,064 | 44,784 | Accepted | Accepted | 52.75 | N = int(eval(input()))
A = []
for i in range(1, N+1):
if 6**i > N:
break
else:
A.append(6**i)
if 9**i <= N:
A.append(9**i)
A.sort(reverse=True)
money = [i for i in range(N+1)]
for i in A:
for j in range(i,N+1):
money[j] = min(money[j], money[j-i]+1)
print((money[N]))
| n = int(eval(input()))
ans = float('INF')
hand = []
tmp = 1
while tmp * 6 <= n:
tmp *= 6
hand.append(tmp)
tmp = 1
while tmp * 9 <= n:
tmp *= 9
hand.append(tmp)
hand.sort()
hand = hand[::-1]
dp = [i for i in range(n+1)]
for v in hand:
for i in range(n+1-v):
if dp[i] + 1 < dp[i+v]:
dp[i+v] = dp[i] + 1
print((dp[n]))
| 17 | 20 | 326 | 369 | N = int(eval(input()))
A = []
for i in range(1, N + 1):
if 6**i > N:
break
else:
A.append(6**i)
if 9**i <= N:
A.append(9**i)
A.sort(reverse=True)
money = [i for i in range(N + 1)]
for i in A:
for j in range(i, N + 1):
money[j] = min(money[j], money[j - i] + 1)
print((money[N]))
| n = int(eval(input()))
ans = float("INF")
hand = []
tmp = 1
while tmp * 6 <= n:
tmp *= 6
hand.append(tmp)
tmp = 1
while tmp * 9 <= n:
tmp *= 9
hand.append(tmp)
hand.sort()
hand = hand[::-1]
dp = [i for i in range(n + 1)]
for v in hand:
for i in range(n + 1 - v):
if dp[i] + 1 < dp[i + v]:
dp[i + v] = dp[i] + 1
print((dp[n]))
| false | 15 | [
"-N = int(eval(input()))",
"-A = []",
"-for i in range(1, N + 1):",
"- if 6**i > N:",
"- break",
"- else:",
"- A.append(6**i)",
"- if 9**i <= N:",
"- A.append(9**i)",
"-A.sort(reverse=True)",
"-money = [i for i in range(N + 1)]",
"-for i in A:",
"- for j in range(i, N + 1):",
"- money[j] = min(money[j], money[j - i] + 1)",
"-print((money[N]))",
"+n = int(eval(input()))",
"+ans = float(\"INF\")",
"+hand = []",
"+tmp = 1",
"+while tmp * 6 <= n:",
"+ tmp *= 6",
"+ hand.append(tmp)",
"+tmp = 1",
"+while tmp * 9 <= n:",
"+ tmp *= 9",
"+ hand.append(tmp)",
"+hand.sort()",
"+hand = hand[::-1]",
"+dp = [i for i in range(n + 1)]",
"+for v in hand:",
"+ for i in range(n + 1 - v):",
"+ if dp[i] + 1 < dp[i + v]:",
"+ dp[i + v] = dp[i] + 1",
"+print((dp[n]))"
] | false | 0.072959 | 0.071858 | 1.015327 | [
"s825804214",
"s244418630"
] |
u469254913 | p02624 | python | s840586097 | s555630302 | 1,415 | 783 | 9,160 | 108,856 | Accepted | Accepted | 44.66 | # import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
def main():
N = int(eval(input()))
res = 0
for i in range(1,N+1):
end = N // i
res += end * (end + 1) * i // 2
print(res)
main()
| # import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
from numba import njit
@njit
def sum_g(N):
res = 0
for i in range(1,N+1):
end = N // i
res += end * (end + 1) * i // 2
return res
def main():
N = int(eval(input()))
res = sum_g(N)
print(res)
main()
| 24 | 28 | 338 | 418 | # import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
def main():
N = int(eval(input()))
res = 0
for i in range(1, N + 1):
end = N // i
res += end * (end + 1) * i // 2
print(res)
main()
| # import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
from numba import njit
@njit
def sum_g(N):
res = 0
for i in range(1, N + 1):
end = N // i
res += end * (end + 1) * i // 2
return res
def main():
N = int(eval(input()))
res = sum_g(N)
print(res)
main()
| false | 14.285714 | [
"-def main():",
"- N = int(eval(input()))",
"+from numba import njit",
"+",
"+",
"+@njit",
"+def sum_g(N):",
"+ return res",
"+",
"+",
"+def main():",
"+ N = int(eval(input()))",
"+ res = sum_g(N)"
] | false | 1.01977 | 0.038373 | 26.575207 | [
"s840586097",
"s555630302"
] |
u013513417 | p03163 | python | s869207544 | s105310544 | 450 | 405 | 180,504 | 181,976 | Accepted | Accepted | 10 | N,W=list(map(int,input().split()))
S = [[0 for j in range(2)] for i in range(N+1)]
DP= [[0 for j in range(100010)] for i in range(110)]
def chmax(a,b):
if a>b:
return a
else:
return b
for i in range(N):
w,v=list(map(int,input().split()))
S[i][0]=w
S[i][1]=v
for i in range(N):
for j in range(W+1):
if j-S[i][0]>=0:
DP[i+1][j]=chmax(DP[i][j],DP[i][j-S[i][0]]+S[i][1])
else:
DP[i+1][j]=DP[i][j]
print((DP[N][W]))
|
N,W=list(map(int,input().split()))
w=[]
v=[]
jmax=100010
nmax=110
for i in range(N):
a,b=list(map(int,input().split()))
w.append(a)
v.append(b)
DP= [[0 for j in range(jmax)] for i in range(nmax)]
def chmax(a,b):
if a>b:
return a
else:
return b
for i in range(N):
for j in range(jmax):
if j-w[i]>=0:
DP[i+1][j]=chmax(DP[i][j],DP[i][j-w[i]]+v[i])
else:
DP[i+1][j]=DP[i][j]
print((DP[N][W])) | 27 | 31 | 539 | 510 | N, W = list(map(int, input().split()))
S = [[0 for j in range(2)] for i in range(N + 1)]
DP = [[0 for j in range(100010)] for i in range(110)]
def chmax(a, b):
if a > b:
return a
else:
return b
for i in range(N):
w, v = list(map(int, input().split()))
S[i][0] = w
S[i][1] = v
for i in range(N):
for j in range(W + 1):
if j - S[i][0] >= 0:
DP[i + 1][j] = chmax(DP[i][j], DP[i][j - S[i][0]] + S[i][1])
else:
DP[i + 1][j] = DP[i][j]
print((DP[N][W]))
| N, W = list(map(int, input().split()))
w = []
v = []
jmax = 100010
nmax = 110
for i in range(N):
a, b = list(map(int, input().split()))
w.append(a)
v.append(b)
DP = [[0 for j in range(jmax)] for i in range(nmax)]
def chmax(a, b):
if a > b:
return a
else:
return b
for i in range(N):
for j in range(jmax):
if j - w[i] >= 0:
DP[i + 1][j] = chmax(DP[i][j], DP[i][j - w[i]] + v[i])
else:
DP[i + 1][j] = DP[i][j]
print((DP[N][W]))
| false | 12.903226 | [
"-S = [[0 for j in range(2)] for i in range(N + 1)]",
"-DP = [[0 for j in range(100010)] for i in range(110)]",
"+w = []",
"+v = []",
"+jmax = 100010",
"+nmax = 110",
"+for i in range(N):",
"+ a, b = list(map(int, input().split()))",
"+ w.append(a)",
"+ v.append(b)",
"+DP = [[0 for j in range(jmax)] for i in range(nmax)]",
"- w, v = list(map(int, input().split()))",
"- S[i][0] = w",
"- S[i][1] = v",
"-for i in range(N):",
"- for j in range(W + 1):",
"- if j - S[i][0] >= 0:",
"- DP[i + 1][j] = chmax(DP[i][j], DP[i][j - S[i][0]] + S[i][1])",
"+ for j in range(jmax):",
"+ if j - w[i] >= 0:",
"+ DP[i + 1][j] = chmax(DP[i][j], DP[i][j - w[i]] + v[i])"
] | false | 0.578722 | 0.007419 | 78.004717 | [
"s869207544",
"s105310544"
] |
u596276291 | p03612 | python | s255611442 | s177261401 | 67 | 54 | 14,196 | 14,196 | Accepted | Accepted | 19.4 | from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10
def main():
N = int(eval(input()))
p_list = list(map(int, input().split()))
a_list = list(range(1, N + 1))
ans = 0
i = 0
while i < N:
if i + 1 < N and p_list[i] == a_list[i] and p_list[i + 1] == a_list[i + 1]:
ans += 1
i += 2
elif p_list[i] == a_list[i]:
ans += 1
i += 2
else:
i += 1
print(ans)
if __name__ == '__main__':
main()
| from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10
def main():
N = int(eval(input()))
p_list = list(map(int, input().split()))
ans = 0
i = 0
while i < N:
if p_list[i] == i + 1:
ans += 1
i += 2
else:
i += 1
print(ans)
if __name__ == '__main__':
main()
| 27 | 23 | 661 | 492 | from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10**10
def main():
N = int(eval(input()))
p_list = list(map(int, input().split()))
a_list = list(range(1, N + 1))
ans = 0
i = 0
while i < N:
if i + 1 < N and p_list[i] == a_list[i] and p_list[i + 1] == a_list[i + 1]:
ans += 1
i += 2
elif p_list[i] == a_list[i]:
ans += 1
i += 2
else:
i += 1
print(ans)
if __name__ == "__main__":
main()
| from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10**10
def main():
N = int(eval(input()))
p_list = list(map(int, input().split()))
ans = 0
i = 0
while i < N:
if p_list[i] == i + 1:
ans += 1
i += 2
else:
i += 1
print(ans)
if __name__ == "__main__":
main()
| false | 14.814815 | [
"- a_list = list(range(1, N + 1))",
"- if i + 1 < N and p_list[i] == a_list[i] and p_list[i + 1] == a_list[i + 1]:",
"- ans += 1",
"- i += 2",
"- elif p_list[i] == a_list[i]:",
"+ if p_list[i] == i + 1:"
] | false | 0.038866 | 0.073935 | 0.525681 | [
"s255611442",
"s177261401"
] |
u296518383 | p03476 | python | s499149594 | s808282499 | 967 | 672 | 9,344 | 70,488 | Accepted | Accepted | 30.51 | # -*- coding:utf-8 -*-
import math
def get_sieve_of_eratosthenes(n):
if not isinstance(n, int):
raise TypeError('n is int type.')
if n < 2:
raise ValueError('n is more than 2')
prime = []
limit = math.sqrt(n)
data = [i + 1 for i in range(1, n)]
while True:
p = data[0]
if limit <= p:
return prime + data
prime.append(p)
data = [e for e in data if e % p != 0]
if __name__ == '__main__':
data = get_sieve_of_eratosthenes(100001)
#print(data[:10])
cnt=len(data)
SS=[0]*(10**5+1)
S=[0]*(10**5+1)
T=[0]*(10**5+1)
for d in data:
SS[d]=1
for i in range(3,len(S)):
if SS[i] and SS[(i+1)//2]: S[i]=1
for i in range(len(T)):
T[i]=cnt
cnt-=S[i]
#print(T[:10])
Q=int(eval(input()))
for i in range(Q):
l,r=list(map(int,input().split()))
print((T[l]-T[r]+S[r])) | Q = int(eval(input()))
LR = [list(map(int, input().split())) for _ in range(Q)]
SIZE = 10 ** 5
P = [-1] * (SIZE + 1)
P[0], P[1] = 0, 0
for i in range(2, SIZE + 1):
if P[i] == -1:
P[i] = 1
k = 2
while i * k <= SIZE:
P[i * k] = 0
k += 1
PP = [0] * (SIZE + 1)
for i in range(3, SIZE + 1):
if P[i] and P[(i + 1) // 2]:
PP[i] = 1
#print(PP)
Acum = [0]
for i in range(SIZE + 1):
Acum.append(Acum[-1] + PP[i])
#print(Acum)
for l, r in LR:
print((Acum[r + 1] - Acum[l]))
| 41 | 29 | 955 | 532 | # -*- coding:utf-8 -*-
import math
def get_sieve_of_eratosthenes(n):
if not isinstance(n, int):
raise TypeError("n is int type.")
if n < 2:
raise ValueError("n is more than 2")
prime = []
limit = math.sqrt(n)
data = [i + 1 for i in range(1, n)]
while True:
p = data[0]
if limit <= p:
return prime + data
prime.append(p)
data = [e for e in data if e % p != 0]
if __name__ == "__main__":
data = get_sieve_of_eratosthenes(100001)
# print(data[:10])
cnt = len(data)
SS = [0] * (10**5 + 1)
S = [0] * (10**5 + 1)
T = [0] * (10**5 + 1)
for d in data:
SS[d] = 1
for i in range(3, len(S)):
if SS[i] and SS[(i + 1) // 2]:
S[i] = 1
for i in range(len(T)):
T[i] = cnt
cnt -= S[i]
# print(T[:10])
Q = int(eval(input()))
for i in range(Q):
l, r = list(map(int, input().split()))
print((T[l] - T[r] + S[r]))
| Q = int(eval(input()))
LR = [list(map(int, input().split())) for _ in range(Q)]
SIZE = 10**5
P = [-1] * (SIZE + 1)
P[0], P[1] = 0, 0
for i in range(2, SIZE + 1):
if P[i] == -1:
P[i] = 1
k = 2
while i * k <= SIZE:
P[i * k] = 0
k += 1
PP = [0] * (SIZE + 1)
for i in range(3, SIZE + 1):
if P[i] and P[(i + 1) // 2]:
PP[i] = 1
# print(PP)
Acum = [0]
for i in range(SIZE + 1):
Acum.append(Acum[-1] + PP[i])
# print(Acum)
for l, r in LR:
print((Acum[r + 1] - Acum[l]))
| false | 29.268293 | [
"-# -*- coding:utf-8 -*-",
"-import math",
"-",
"-",
"-def get_sieve_of_eratosthenes(n):",
"- if not isinstance(n, int):",
"- raise TypeError(\"n is int type.\")",
"- if n < 2:",
"- raise ValueError(\"n is more than 2\")",
"- prime = []",
"- limit = math.sqrt(n)",
"- data = [i + 1 for i in range(1, n)]",
"- while True:",
"- p = data[0]",
"- if limit <= p:",
"- return prime + data",
"- prime.append(p)",
"- data = [e for e in data if e % p != 0]",
"-",
"-",
"-if __name__ == \"__main__\":",
"- data = get_sieve_of_eratosthenes(100001)",
"- # print(data[:10])",
"- cnt = len(data)",
"- SS = [0] * (10**5 + 1)",
"- S = [0] * (10**5 + 1)",
"- T = [0] * (10**5 + 1)",
"- for d in data:",
"- SS[d] = 1",
"- for i in range(3, len(S)):",
"- if SS[i] and SS[(i + 1) // 2]:",
"- S[i] = 1",
"- for i in range(len(T)):",
"- T[i] = cnt",
"- cnt -= S[i]",
"- # print(T[:10])",
"- Q = int(eval(input()))",
"- for i in range(Q):",
"- l, r = list(map(int, input().split()))",
"- print((T[l] - T[r] + S[r]))",
"+Q = int(eval(input()))",
"+LR = [list(map(int, input().split())) for _ in range(Q)]",
"+SIZE = 10**5",
"+P = [-1] * (SIZE + 1)",
"+P[0], P[1] = 0, 0",
"+for i in range(2, SIZE + 1):",
"+ if P[i] == -1:",
"+ P[i] = 1",
"+ k = 2",
"+ while i * k <= SIZE:",
"+ P[i * k] = 0",
"+ k += 1",
"+PP = [0] * (SIZE + 1)",
"+for i in range(3, SIZE + 1):",
"+ if P[i] and P[(i + 1) // 2]:",
"+ PP[i] = 1",
"+# print(PP)",
"+Acum = [0]",
"+for i in range(SIZE + 1):",
"+ Acum.append(Acum[-1] + PP[i])",
"+# print(Acum)",
"+for l, r in LR:",
"+ print((Acum[r + 1] - Acum[l]))"
] | false | 0.265955 | 0.217448 | 1.223074 | [
"s499149594",
"s808282499"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.