user_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 1
value | submission_id_v0 stringlengths 10 10 | submission_id_v1 stringlengths 10 10 | cpu_time_v0 int64 10 38.3k | cpu_time_v1 int64 0 24.7k | memory_v0 int64 2.57k 1.02M | memory_v1 int64 2.57k 869k | status_v0 stringclasses 1
value | status_v1 stringclasses 1
value | improvement_frac float64 7.51 100 | input stringlengths 20 4.55k | target stringlengths 17 3.34k | code_v0_loc int64 1 148 | code_v1_loc int64 1 184 | code_v0_num_chars int64 13 4.55k | code_v1_num_chars int64 14 3.34k | code_v0_no_empty_lines stringlengths 21 6.88k | code_v1_no_empty_lines stringlengths 20 4.93k | code_same bool 1
class | relative_loc_diff_percent float64 0 79.8 | diff list | diff_only_import_comment bool 1
class | measured_runtime_v0 float64 0.01 4.45 | measured_runtime_v1 float64 0.01 4.31 | runtime_lift float64 0 359 | key list |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u226108478 | p02684 | python | s654894784 | s266584497 | 147 | 129 | 31,200 | 31,412 | Accepted | Accepted | 12.24 | # -*- coding: utf-8 -*-
def main():
import sys
input = sys.stdin.readline
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# See:
# https://www.youtube.com/watch?v=ENSOy8u9K9I&feature=youtu.be
path = list()
order = [-1 for _ in range(n + 1)]
... | # -*- coding: utf-8 -*-
def main():
import sys
input = sys.stdin.readline
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# See:
# https://www.youtube.com/watch?v=ENSOy8u9K9I&feature=youtu.be
# KeyInsight:
# ็งปๅ: ๅจๆ็ใงใฏใชใ + ๅจๆ็ใซ็นฐใ่ฟใใฎๅ่จ
# ๅฎ่ฃ
ไธ... | 34 | 41 | 743 | 1,019 | # -*- coding: utf-8 -*-
def main():
import sys
input = sys.stdin.readline
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# See:
# https://www.youtube.com/watch?v=ENSOy8u9K9I&feature=youtu.be
path = list()
order = [-1 for _ in range(n + 1)]
place = 1
w... | # -*- coding: utf-8 -*-
def main():
import sys
input = sys.stdin.readline
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# See:
# https://www.youtube.com/watch?v=ENSOy8u9K9I&feature=youtu.be
# KeyInsight:
# ็งปๅ: ๅจๆ็ใงใฏใชใ + ๅจๆ็ใซ็นฐใ่ฟใใฎๅ่จ
# ๅฎ่ฃ
ไธใฎใใคใณใ
# ็ต่ทฏใจ้ ็ช... | false | 17.073171 | [
"+ # KeyInsight:",
"+ # ็งปๅ: ๅจๆ็ใงใฏใชใ + ๅจๆ็ใซ็นฐใ่ฟใใฎๅ่จ",
"+ # ๅฎ่ฃ
ไธใฎใใคใณใ",
"+ # ็ต่ทฏใจ้ ็ชใๅฅใ
ใซ็ฎก็ใใ",
"- order = [-1 for _ in range(n + 1)]",
"+ order = [-1 for _ in range(n + 1)] # -1: ๅฐ้ใใฆใใชใ",
"+ # ๅฐ้ใใฆใใชใ็นใใใ้ใใใซใผใใ็นฐใ่ฟใ",
"+ # = ๅใ็นใ2ๅ้ใใพใง็นฐใ่ฟใ",
"- order[place] = len(path)",
... | false | 0.039727 | 0.039474 | 1.006409 | [
"s654894784",
"s266584497"
] |
u163320134 | p02947 | python | s898495572 | s440890484 | 1,388 | 1,044 | 43,376 | 120,452 | Accepted | Accepted | 24.78 | import collections
n=int(eval(input()))
arr=[eval(input()) for _ in range(n)]
dic={}
for s in arr:
count=[0]*26
tmp=collections.Counter(s)
for char in list(tmp.keys()):
count[ord(char)-ord('a')]+=tmp[char]
count=tuple(count)
if count not in dic:
dic[count]=1
else:
dic[count]+=1
a... | n=int(eval(input()))
arr=[eval(input()) for _ in range(n)]
dic={}
alphabet='abcdefghijklmnopqrstuvwxyz'
for s in arr:
count=[0]*26
for i in range(10):
for j in range(26):
if s[i]==alphabet[j]:
count[j]+=1
break
count=tuple(count)
if count not in dic:
dic[count]=1
el... | 19 | 20 | 367 | 398 | import collections
n = int(eval(input()))
arr = [eval(input()) for _ in range(n)]
dic = {}
for s in arr:
count = [0] * 26
tmp = collections.Counter(s)
for char in list(tmp.keys()):
count[ord(char) - ord("a")] += tmp[char]
count = tuple(count)
if count not in dic:
dic[count] = 1
... | n = int(eval(input()))
arr = [eval(input()) for _ in range(n)]
dic = {}
alphabet = "abcdefghijklmnopqrstuvwxyz"
for s in arr:
count = [0] * 26
for i in range(10):
for j in range(26):
if s[i] == alphabet[j]:
count[j] += 1
break
count = tuple(count)
if c... | false | 5 | [
"-import collections",
"-",
"+alphabet = \"abcdefghijklmnopqrstuvwxyz\"",
"- tmp = collections.Counter(s)",
"- for char in list(tmp.keys()):",
"- count[ord(char) - ord(\"a\")] += tmp[char]",
"+ for i in range(10):",
"+ for j in range(26):",
"+ if s[i] == alphabet[j]... | false | 0.046028 | 0.038621 | 1.19178 | [
"s898495572",
"s440890484"
] |
u046158516 | p02846 | python | s596765990 | s909885486 | 179 | 71 | 38,384 | 61,244 | Accepted | Accepted | 60.34 | t1,t2=list(map(int,input().split()))
a1,a2=list(map(int,input().split()))
b1,b2=list(map(int,input().split()))
n1=(b1-a1)*t1
n2=(b2-a2)*t2
if n1*n2>0 or abs(n1)>abs(n2):
print((0))
elif abs(n1)==abs(n2):
print('infinity')
else:
c=abs(n1)//abs(n1+n2)
while (c+1)*abs(n1+n2)<=abs(n1):
c+=1
ans=2... | import sys
t1,t2=list(map(int,input().split()))
a1,a2=list(map(int,input().split()))
b1,b2=list(map(int,input().split()))
n1=(b1-a1)*t1
n2=(b2-a2)*t2
if n1*n2>0 or abs(n1)>abs(n2):
print((0))
sys.exit()
if abs(n1)==abs(n2):
print('infinity')
sys.exit()
c=abs(n1)//abs(n1+n2)
while (c+1)*abs(n1+n2)<=... | 17 | 19 | 359 | 377 | t1, t2 = list(map(int, input().split()))
a1, a2 = list(map(int, input().split()))
b1, b2 = list(map(int, input().split()))
n1 = (b1 - a1) * t1
n2 = (b2 - a2) * t2
if n1 * n2 > 0 or abs(n1) > abs(n2):
print((0))
elif abs(n1) == abs(n2):
print("infinity")
else:
c = abs(n1) // abs(n1 + n2)
while (c + 1) * ... | import sys
t1, t2 = list(map(int, input().split()))
a1, a2 = list(map(int, input().split()))
b1, b2 = list(map(int, input().split()))
n1 = (b1 - a1) * t1
n2 = (b2 - a2) * t2
if n1 * n2 > 0 or abs(n1) > abs(n2):
print((0))
sys.exit()
if abs(n1) == abs(n2):
print("infinity")
sys.exit()
c = abs(n1) // abs... | false | 10.526316 | [
"+import sys",
"+",
"-elif abs(n1) == abs(n2):",
"+ sys.exit()",
"+if abs(n1) == abs(n2):",
"-else:",
"- c = abs(n1) // abs(n1 + n2)",
"- while (c + 1) * abs(n1 + n2) <= abs(n1):",
"- c += 1",
"- ans = 2 * c",
"- if abs(n1) % (abs(n1 + n2)) != 0:",
"- ans += 1",
... | false | 0.043091 | 0.036743 | 1.172786 | [
"s596765990",
"s909885486"
] |
u814986259 | p03436 | python | s525692324 | s263473002 | 31 | 24 | 3,316 | 3,316 | Accepted | Accepted | 22.58 | from collections import deque
H, W = list(map(int, input().split()))
s = [list(eval(input())) for i in range(H)]
white = 0
for i in range(H):
white += s[i].count(".")
q = deque()
q.append((0, 0))
g = [[10**9]*W for i in range(H)]
g[0][0] = 0
for i in range(H*W):
if len(q) == 0:
break... | import collections
H, W = list(map(int, input().split()))
s = [list(eval(input())) for i in range(H)]
ans = H*W - 2
for i in range(H):
for j in range(W):
if s[i][j] == "#":
ans -= 1
q = collections.deque()
q.append((0, 0, 0))
flag = False
while(q):
x, y, d = q.popleft()
if... | 41 | 35 | 1,129 | 826 | from collections import deque
H, W = list(map(int, input().split()))
s = [list(eval(input())) for i in range(H)]
white = 0
for i in range(H):
white += s[i].count(".")
q = deque()
q.append((0, 0))
g = [[10**9] * W for i in range(H)]
g[0][0] = 0
for i in range(H * W):
if len(q) == 0:
break
x, y = q.p... | import collections
H, W = list(map(int, input().split()))
s = [list(eval(input())) for i in range(H)]
ans = H * W - 2
for i in range(H):
for j in range(W):
if s[i][j] == "#":
ans -= 1
q = collections.deque()
q.append((0, 0, 0))
flag = False
while q:
x, y, d = q.popleft()
if x == W - 1 a... | false | 14.634146 | [
"-from collections import deque",
"+import collections",
"-white = 0",
"+ans = H * W - 2",
"- white += s[i].count(\".\")",
"-q = deque()",
"-q.append((0, 0))",
"-g = [[10**9] * W for i in range(H)]",
"-g[0][0] = 0",
"-for i in range(H * W):",
"- if len(q) == 0:",
"+ for j in range(W):... | false | 0.034679 | 0.062224 | 0.55732 | [
"s525692324",
"s263473002"
] |
u403301154 | p03095 | python | s717709073 | s561000456 | 36 | 25 | 3,888 | 3,444 | Accepted | Accepted | 30.56 | n = int(eval(input()))
s = eval(input())
MOD = 10**9+7
from collections import defaultdict
import string
d = defaultdict(int)
let = string.ascii_lowercase
for ele in s:
d[ele] += 1
ans = 1
for i in range(26):
if d[let[i]]>0:
ans = (ans * (d[let[i]]+1))%MOD
print((ans-1)) | n = int(eval(input()))
s = eval(input())
from collections import Counter
c = Counter(s)
ans = 0
mod = 10**9+7
for k, v in list(c.items()):
if ans == 0:
ans = v+1
else:
ans = (ans * (v+1)) % mod
print((ans-1)) | 17 | 12 | 284 | 211 | n = int(eval(input()))
s = eval(input())
MOD = 10**9 + 7
from collections import defaultdict
import string
d = defaultdict(int)
let = string.ascii_lowercase
for ele in s:
d[ele] += 1
ans = 1
for i in range(26):
if d[let[i]] > 0:
ans = (ans * (d[let[i]] + 1)) % MOD
print((ans - 1))
| n = int(eval(input()))
s = eval(input())
from collections import Counter
c = Counter(s)
ans = 0
mod = 10**9 + 7
for k, v in list(c.items()):
if ans == 0:
ans = v + 1
else:
ans = (ans * (v + 1)) % mod
print((ans - 1))
| false | 29.411765 | [
"-MOD = 10**9 + 7",
"-from collections import defaultdict",
"-import string",
"+from collections import Counter",
"-d = defaultdict(int)",
"-let = string.ascii_lowercase",
"-for ele in s:",
"- d[ele] += 1",
"-ans = 1",
"-for i in range(26):",
"- if d[let[i]] > 0:",
"- ans = (ans *... | false | 0.038115 | 0.036927 | 1.032158 | [
"s717709073",
"s561000456"
] |
u796878730 | p02641 | python | s402467128 | s539928826 | 24 | 21 | 9,112 | 9,044 | Accepted | Accepted | 12.5 | X,N = list(map(int,input().split()))
P = list(map(int,input().split()))
P_n = [i for i in range(110) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]
import sys
min_abs = min(abs_value)
for k in range(len(abs_value)):
if abs_value[k] == min_abs:
print((P_n[k]))
sys.... | X,N = list(map(int,input().split()))
P = list(map(int,input().split()))
P_n = [i for i in range(110) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]
min_abs = min(abs_value)
for k in range(len(abs_value)):
if abs_value[k] == min_abs:
print((P_n[k]))
break | 13 | 13 | 318 | 303 | X, N = list(map(int, input().split()))
P = list(map(int, input().split()))
P_n = [i for i in range(110) if i not in P]
abs_value = [abs(X - P_n[j]) for j in range(len(P_n))]
import sys
min_abs = min(abs_value)
for k in range(len(abs_value)):
if abs_value[k] == min_abs:
print((P_n[k]))
sys.exit()
| X, N = list(map(int, input().split()))
P = list(map(int, input().split()))
P_n = [i for i in range(110) if i not in P]
abs_value = [abs(X - P_n[j]) for j in range(len(P_n))]
min_abs = min(abs_value)
for k in range(len(abs_value)):
if abs_value[k] == min_abs:
print((P_n[k]))
break
| false | 0 | [
"-import sys",
"-",
"- sys.exit()",
"+ break"
] | false | 0.04451 | 0.037508 | 1.186658 | [
"s402467128",
"s539928826"
] |
u522140891 | p03044 | python | s802730249 | s962646135 | 520 | 442 | 198,152 | 184,032 | Accepted | Accepted | 15 | import sys
sys.setrecursionlimit(20000000)
def dfs(node, distance):
for next_node, edge_size in G[node]:
if ans[next_node] == -1:
ans[next_node] = ((distance+edge_size) % 2)
dfs(next_node, distance+edge_size)
N = int(input())
G = [[] for i in range(N)]
for i in ran... | import sys
from sys import stdin
input = stdin.readline
sys.setrecursionlimit(20000000)
def main():
N = int(eval(input()))
G = [[] for _ in range(N+1)]
for i in range(N-1):
u, v, w = list(map(int, input().split()))
G[u].append((v, w))
G[v].append((u, w))
color = [-1]*(N+1)
color[... | 22 | 41 | 477 | 810 | import sys
sys.setrecursionlimit(20000000)
def dfs(node, distance):
for next_node, edge_size in G[node]:
if ans[next_node] == -1:
ans[next_node] = (distance + edge_size) % 2
dfs(next_node, distance + edge_size)
N = int(input())
G = [[] for i in range(N)]
for i in range(N - 1):
... | import sys
from sys import stdin
input = stdin.readline
sys.setrecursionlimit(20000000)
def main():
N = int(eval(input()))
G = [[] for _ in range(N + 1)]
for i in range(N - 1):
u, v, w = list(map(int, input().split()))
G[u].append((v, w))
G[v].append((u, w))
color = [-1] * (N ... | false | 46.341463 | [
"+from sys import stdin",
"+input = stdin.readline",
"-def dfs(node, distance):",
"- for next_node, edge_size in G[node]:",
"- if ans[next_node] == -1:",
"- ans[next_node] = (distance + edge_size) % 2",
"- dfs(next_node, distance + edge_size)",
"+def main():",
"+ N... | false | 0.062907 | 0.038765 | 1.622811 | [
"s802730249",
"s962646135"
] |
u848535504 | p02583 | python | s644531324 | s842489706 | 116 | 86 | 9,164 | 9,184 | Accepted | Accepted | 25.86 | import itertools
N = int(eval(input()))
l = list(map(int,input().split()))
cnt = 0
for a,b,c in itertools.combinations(l,3):
if abs(a-b) < c < a+b and len(set([a,b,c])) == 3:
cnt += 1
print(cnt) | import itertools
N = int(eval(input()))
l = list(map(int,input().split()))
cnt = 0
for a,b,c in itertools.combinations(l,3):
if abs(a-b) < c < a+b and a != b and b != c and a != c:
cnt += 1
print(cnt) | 10 | 10 | 205 | 211 | import itertools
N = int(eval(input()))
l = list(map(int, input().split()))
cnt = 0
for a, b, c in itertools.combinations(l, 3):
if abs(a - b) < c < a + b and len(set([a, b, c])) == 3:
cnt += 1
print(cnt)
| import itertools
N = int(eval(input()))
l = list(map(int, input().split()))
cnt = 0
for a, b, c in itertools.combinations(l, 3):
if abs(a - b) < c < a + b and a != b and b != c and a != c:
cnt += 1
print(cnt)
| false | 0 | [
"- if abs(a - b) < c < a + b and len(set([a, b, c])) == 3:",
"+ if abs(a - b) < c < a + b and a != b and b != c and a != c:"
] | false | 0.03522 | 0.035163 | 1.001624 | [
"s644531324",
"s842489706"
] |
u241190159 | p03645 | python | s503251570 | s534479928 | 633 | 577 | 28,916 | 18,892 | Accepted | Accepted | 8.85 | import sys
from collections import defaultdict
N, M = list(map(int, input().split()))
inter = []
goalable = defaultdict(lambda: False)
for i in range(M):
start, end = list(map(int, input().split()))
if start == 1:
inter.append(end)
else:
if end == N:
goalable[start] = True
... | N, M = list(map(int, input().split()))
inter, goalable = set(), set()
for i in range(M):
a, b = list(map(int, input().split()))
if a == 1:
inter.add(b)
if b == N:
goalable.add(a)
flag = inter & goalable
print(("POSSIBLE" if flag else "IMPOSSIBLE")) | 22 | 13 | 409 | 274 | import sys
from collections import defaultdict
N, M = list(map(int, input().split()))
inter = []
goalable = defaultdict(lambda: False)
for i in range(M):
start, end = list(map(int, input().split()))
if start == 1:
inter.append(end)
else:
if end == N:
goalable[start] = True
for i... | N, M = list(map(int, input().split()))
inter, goalable = set(), set()
for i in range(M):
a, b = list(map(int, input().split()))
if a == 1:
inter.add(b)
if b == N:
goalable.add(a)
flag = inter & goalable
print(("POSSIBLE" if flag else "IMPOSSIBLE"))
| false | 40.909091 | [
"-import sys",
"-from collections import defaultdict",
"-",
"-inter = []",
"-goalable = defaultdict(lambda: False)",
"+inter, goalable = set(), set()",
"- start, end = list(map(int, input().split()))",
"- if start == 1:",
"- inter.append(end)",
"- else:",
"- if end == N:",... | false | 0.049098 | 0.049801 | 0.98588 | [
"s503251570",
"s534479928"
] |
u411203878 | p03379 | python | s551868052 | s326593045 | 418 | 212 | 93,128 | 104,404 | Accepted | Accepted | 49.28 | import copy
n=int(eval(input()))
t1 = list(map(int,input().split()))
t2 = copy.copy(t1)
t2.sort()
for i in t1:
if i <= t2[(n//2)-1]:
print((t2[(n//2)]))
else:
print((t2[(n//2)-1])) | import copy
n=int(eval(input()))
x = list(map(int,input().split()))
x2 = copy.copy(x)
x2.sort()
ans = [x2[n//2-1],x2[n//2]]
for xx in x:
if xx <= ans[0]:
print((ans[1]))
else:
print((ans[0])) | 14 | 17 | 211 | 227 | import copy
n = int(eval(input()))
t1 = list(map(int, input().split()))
t2 = copy.copy(t1)
t2.sort()
for i in t1:
if i <= t2[(n // 2) - 1]:
print((t2[(n // 2)]))
else:
print((t2[(n // 2) - 1]))
| import copy
n = int(eval(input()))
x = list(map(int, input().split()))
x2 = copy.copy(x)
x2.sort()
ans = [x2[n // 2 - 1], x2[n // 2]]
for xx in x:
if xx <= ans[0]:
print((ans[1]))
else:
print((ans[0]))
| false | 17.647059 | [
"-t1 = list(map(int, input().split()))",
"-t2 = copy.copy(t1)",
"-t2.sort()",
"-for i in t1:",
"- if i <= t2[(n // 2) - 1]:",
"- print((t2[(n // 2)]))",
"+x = list(map(int, input().split()))",
"+x2 = copy.copy(x)",
"+x2.sort()",
"+ans = [x2[n // 2 - 1], x2[n // 2]]",
"+for xx in x:",
... | false | 0.038498 | 0.072496 | 0.531034 | [
"s551868052",
"s326593045"
] |
u992465933 | p03307 | python | s101890981 | s342643138 | 274 | 172 | 63,980 | 38,384 | Accepted | Accepted | 37.23 | import fractions
def main():
n = int(eval(input()))
if n%2 == 0:
print(n)
else:
print((2*n))
if __name__ == '__main__':
main()
| def main():
n = int(eval(input()))
if n%2 == 0:
print(n)
else:
print((2*n))
if __name__ == '__main__':
main() | 12 | 10 | 165 | 144 | import fractions
def main():
n = int(eval(input()))
if n % 2 == 0:
print(n)
else:
print((2 * n))
if __name__ == "__main__":
main()
| def main():
n = int(eval(input()))
if n % 2 == 0:
print(n)
else:
print((2 * n))
if __name__ == "__main__":
main()
| false | 16.666667 | [
"-import fractions",
"-",
"-"
] | false | 0.037088 | 0.041048 | 0.90352 | [
"s101890981",
"s342643138"
] |
u634079249 | p02713 | python | s606706730 | s474368057 | 1,825 | 880 | 9,188 | 9,244 | Accepted | Accepted | 51.78 | import sys
import os
import math
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambd... | import sys
import os
import math
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambd... | 38 | 32 | 998 | 902 | import sys
import os
import math
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.std... | import sys
import os
import math
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.std... | false | 15.789474 | [
"-def fb(i):",
"- if i % 15 == 0 or i % 3 == 0 or i % 5 == 0:",
"- return True",
"- else:",
"- return False",
"-",
"-",
"- for n in range(1, N + 1):",
"- for m in range(1, N + 1):",
"- for l in range(1, N + 1):",
"- ret += math.gcd(math.gcd... | false | 0.184472 | 0.102829 | 1.793968 | [
"s606706730",
"s474368057"
] |
u150984829 | p02270 | python | s359082182 | s838441187 | 960 | 880 | 16,424 | 16,424 | Accepted | Accepted | 8.33 | import sys
def f(P):
i=0
for _ in[0]*k:
s=0
while s+w[i]<=P:
s+=w[i];i+=1
if i==n: return n
return i
n,k=list(map(int,input().split()))
w=list(map(int,sys.stdin.read().splitlines()))
l=0;r=n*100000
while r-l>1:
m=(l+r)//2
if f(m)>=n:r=m
else:l=m
print(r)
| import sys
def f(P):
i=0
for _ in[0]*k:
s=0
while s+w[i]<=P:
s+=w[i];i+=1
if i==n: return n
return i
n,k=list(map(int,input().split()))
w=list(map(int,sys.stdin.read().splitlines()))
l=0;r=sum(w)
while r-l>1:
m=(l+r)//2
if f(m)>=n:r=m
else:l=m
print(r)
| 17 | 17 | 281 | 279 | import sys
def f(P):
i = 0
for _ in [0] * k:
s = 0
while s + w[i] <= P:
s += w[i]
i += 1
if i == n:
return n
return i
n, k = list(map(int, input().split()))
w = list(map(int, sys.stdin.read().splitlines()))
l = 0
r = n * 100000
while r ... | import sys
def f(P):
i = 0
for _ in [0] * k:
s = 0
while s + w[i] <= P:
s += w[i]
i += 1
if i == n:
return n
return i
n, k = list(map(int, input().split()))
w = list(map(int, sys.stdin.read().splitlines()))
l = 0
r = sum(w)
while r - l ... | false | 0 | [
"-r = n * 100000",
"+r = sum(w)"
] | false | 0.071757 | 0.084029 | 0.85395 | [
"s359082182",
"s838441187"
] |
u150984829 | p00468 | python | s667129096 | s012849283 | 90 | 60 | 6,292 | 6,300 | Accepted | Accepted | 33.33 | for e in iter(input,'0'):
R=[[]for _ in[0]*-~int(e)]
for _ in[0]*int(eval(input())):
a,b=list(map(int,input().split()))
R[a]+=[b];R[b]+=[a]
for m in R[1][:]:R[1]+=R[m]
print((len({*R[1]}-{1})))
| import sys
r=sys.stdin.readline
for e in iter(r,'0\n'):
R=[[]for _ in[0]*-~int(e)]
for _ in[0]*int(r()):
a,b=list(map(int,r().split()))
R[a]+=[b];R[b]+=[a]
for m in R[1][:]:R[1]+=R[m]
print((len({*R[1]}-{1})))
| 7 | 9 | 194 | 218 | for e in iter(input, "0"):
R = [[] for _ in [0] * -~int(e)]
for _ in [0] * int(eval(input())):
a, b = list(map(int, input().split()))
R[a] += [b]
R[b] += [a]
for m in R[1][:]:
R[1] += R[m]
print((len({*R[1]} - {1})))
| import sys
r = sys.stdin.readline
for e in iter(r, "0\n"):
R = [[] for _ in [0] * -~int(e)]
for _ in [0] * int(r()):
a, b = list(map(int, r().split()))
R[a] += [b]
R[b] += [a]
for m in R[1][:]:
R[1] += R[m]
print((len({*R[1]} - {1})))
| false | 22.222222 | [
"-for e in iter(input, \"0\"):",
"+import sys",
"+",
"+r = sys.stdin.readline",
"+for e in iter(r, \"0\\n\"):",
"- for _ in [0] * int(eval(input())):",
"- a, b = list(map(int, input().split()))",
"+ for _ in [0] * int(r()):",
"+ a, b = list(map(int, r().split()))"
] | false | 0.124485 | 0.117347 | 1.060829 | [
"s667129096",
"s012849283"
] |
u554784585 | p03331 | python | s618190917 | s061765295 | 286 | 242 | 9,184 | 9,100 | Accepted | Accepted | 15.38 | N=int(eval(input()))
ans=100000000000
for A in range(1,N):
B=N-A
sa=0
sb=0
for i in range(len(str(A))):
sa+=A%10
A=(A-A%10)//10
for j in range(len(str(B))):
sb+=B%10
B=(B-B%10)//10
if sa+sb<ans:
ans=sa+sb
print(ans)
| N=int(eval(input()))
ans=100000000000
for a in range(1,N):
b=N-a
tempa=0
tempb=0
for i in range(len(str(a))):
tempa+=a%10
a=a//10
for j in range(len(str(b))):
tempb+=b%10
b=b//10
if tempa+tempb<ans:
ans=tempa+tempb
print(ans)
| 16 | 16 | 290 | 300 | N = int(eval(input()))
ans = 100000000000
for A in range(1, N):
B = N - A
sa = 0
sb = 0
for i in range(len(str(A))):
sa += A % 10
A = (A - A % 10) // 10
for j in range(len(str(B))):
sb += B % 10
B = (B - B % 10) // 10
if sa + sb < ans:
ans = sa + sb
print(... | N = int(eval(input()))
ans = 100000000000
for a in range(1, N):
b = N - a
tempa = 0
tempb = 0
for i in range(len(str(a))):
tempa += a % 10
a = a // 10
for j in range(len(str(b))):
tempb += b % 10
b = b // 10
if tempa + tempb < ans:
ans = tempa + tempb
prin... | false | 0 | [
"-for A in range(1, N):",
"- B = N - A",
"- sa = 0",
"- sb = 0",
"- for i in range(len(str(A))):",
"- sa += A % 10",
"- A = (A - A % 10) // 10",
"- for j in range(len(str(B))):",
"- sb += B % 10",
"- B = (B - B % 10) // 10",
"- if sa + sb < ans:",
... | false | 0.460668 | 0.168833 | 2.728548 | [
"s618190917",
"s061765295"
] |
u729133443 | p03339 | python | s392572354 | s213918928 | 346 | 241 | 19,944 | 46,572 | Accepted | Accepted | 30.35 | n=int(eval(input()))
s=list(eval(input()))
a=[0]*(n+1)
b=[0]*(n+2)
for i in range(n):
a[i+1]=a[i]
b[n-i]=b[n-i+1]
if s[i]=='W':
a[i+1]+=1
if s[n-i-1]=='E':
b[n-i]+=1
print((min(a[i]+b[i]-1for i in range(1,n+1)))) | n,s=open(0)
n=int(n)
a=[0]*(n+1)
b=[0]*(n+2)
for i in range(n):
a[i+1]=a[i]
b[n-i]=b[n-i+1]
if s[i]=='W':
a[i+1]+=1
if s[n-i-1]=='E':
b[n-i]+=1
print((min(a[i]+b[i]-1for i in range(1,n+1)))) | 12 | 12 | 225 | 215 | n = int(eval(input()))
s = list(eval(input()))
a = [0] * (n + 1)
b = [0] * (n + 2)
for i in range(n):
a[i + 1] = a[i]
b[n - i] = b[n - i + 1]
if s[i] == "W":
a[i + 1] += 1
if s[n - i - 1] == "E":
b[n - i] += 1
print((min(a[i] + b[i] - 1 for i in range(1, n + 1))))
| n, s = open(0)
n = int(n)
a = [0] * (n + 1)
b = [0] * (n + 2)
for i in range(n):
a[i + 1] = a[i]
b[n - i] = b[n - i + 1]
if s[i] == "W":
a[i + 1] += 1
if s[n - i - 1] == "E":
b[n - i] += 1
print((min(a[i] + b[i] - 1 for i in range(1, n + 1))))
| false | 0 | [
"-n = int(eval(input()))",
"-s = list(eval(input()))",
"+n, s = open(0)",
"+n = int(n)"
] | false | 0.039839 | 0.040416 | 0.985732 | [
"s392572354",
"s213918928"
] |
u494927057 | p03339 | python | s306489045 | s491043078 | 238 | 70 | 17,568 | 3,700 | Accepted | Accepted | 70.59 | N = int(eval(input()))
S = eval(input())
W_cnt_array = [0] * N
E_cnt_array = [0] * N
W_cnt = 0
E_cnt = 0
for i in range(N):
if S[i] == 'W':
W_cnt += 1
elif S[i] == 'E':
E_cnt += 1
W_cnt_array[i] = W_cnt
E_cnt_array[i] = E_cnt
prev_dir = S[0]
num = min(max(E_cnt_array)... | N = int(eval(input()))
S = eval(input())
cost = S.count('E')
ans = N
for c in S:
if c == 'E':
cost -= 1
else:
if ans > cost:
ans = cost
cost += 1
else:
if ans > cost:
ans = cost
print(ans) | 23 | 17 | 504 | 250 | N = int(eval(input()))
S = eval(input())
W_cnt_array = [0] * N
E_cnt_array = [0] * N
W_cnt = 0
E_cnt = 0
for i in range(N):
if S[i] == "W":
W_cnt += 1
elif S[i] == "E":
E_cnt += 1
W_cnt_array[i] = W_cnt
E_cnt_array[i] = E_cnt
prev_dir = S[0]
num = min(max(E_cnt_array), max(W_cnt_array))
... | N = int(eval(input()))
S = eval(input())
cost = S.count("E")
ans = N
for c in S:
if c == "E":
cost -= 1
else:
if ans > cost:
ans = cost
cost += 1
else:
if ans > cost:
ans = cost
print(ans)
| false | 26.086957 | [
"-W_cnt_array = [0] * N",
"-E_cnt_array = [0] * N",
"-W_cnt = 0",
"-E_cnt = 0",
"-for i in range(N):",
"- if S[i] == \"W\":",
"- W_cnt += 1",
"- elif S[i] == \"E\":",
"- E_cnt += 1",
"- W_cnt_array[i] = W_cnt",
"- E_cnt_array[i] = E_cnt",
"-prev_dir = S[0]",
"-num =... | false | 0.040214 | 0.038254 | 1.051241 | [
"s306489045",
"s491043078"
] |
u095021077 | p02989 | python | s428708988 | s961613044 | 218 | 75 | 52,780 | 14,428 | Accepted | Accepted | 65.6 | N=int(eval(input()))
temp=input().split()
d=[int(temp[i]) for i in range(N)]
d.sort()
print((d[int(N/2)]-d[int(N/2-1)])) | n=int(eval(input()))
d=list(map(int, input().split()))
d.sort()
print((int(d[int(n/2)]-d[int(n/2-1)]))) | 6 | 6 | 118 | 102 | N = int(eval(input()))
temp = input().split()
d = [int(temp[i]) for i in range(N)]
d.sort()
print((d[int(N / 2)] - d[int(N / 2 - 1)]))
| n = int(eval(input()))
d = list(map(int, input().split()))
d.sort()
print((int(d[int(n / 2)] - d[int(n / 2 - 1)])))
| false | 0 | [
"-N = int(eval(input()))",
"-temp = input().split()",
"-d = [int(temp[i]) for i in range(N)]",
"+n = int(eval(input()))",
"+d = list(map(int, input().split()))",
"-print((d[int(N / 2)] - d[int(N / 2 - 1)]))",
"+print((int(d[int(n / 2)] - d[int(n / 2 - 1)])))"
] | false | 0.075354 | 0.082612 | 0.912141 | [
"s428708988",
"s961613044"
] |
u044964932 | p03127 | python | s835932080 | s055525606 | 85 | 78 | 16,280 | 20,376 | Accepted | Accepted | 8.24 | from fractions import gcd
def main():
n = int(eval(input()))
As = list(map(int, input().split()))
ans = gcd(As[0], As[1])
for i in range(2, n):
ans = gcd(ans, As[i])
print(ans)
if __name__ == "__main__":
main()
| import math
def main():
n = int(eval(input()))
As = sorted(list(map(int, input().split())))
ans = math.gcd(As[0], As[1])
for i in range(2, n):
ans = math.gcd(ans, As[i])
print(ans)
if __name__ == "__main__":
main()
| 14 | 15 | 254 | 260 | from fractions import gcd
def main():
n = int(eval(input()))
As = list(map(int, input().split()))
ans = gcd(As[0], As[1])
for i in range(2, n):
ans = gcd(ans, As[i])
print(ans)
if __name__ == "__main__":
main()
| import math
def main():
n = int(eval(input()))
As = sorted(list(map(int, input().split())))
ans = math.gcd(As[0], As[1])
for i in range(2, n):
ans = math.gcd(ans, As[i])
print(ans)
if __name__ == "__main__":
main()
| false | 6.666667 | [
"-from fractions import gcd",
"+import math",
"- As = list(map(int, input().split()))",
"- ans = gcd(As[0], As[1])",
"+ As = sorted(list(map(int, input().split())))",
"+ ans = math.gcd(As[0], As[1])",
"- ans = gcd(ans, As[i])",
"+ ans = math.gcd(ans, As[i])"
] | false | 0.054353 | 0.033803 | 1.607954 | [
"s835932080",
"s055525606"
] |
u814781830 | p03167 | python | s842119277 | s225598181 | 755 | 357 | 168,456 | 89,712 | Accepted | Accepted | 52.72 | import sys
sys.setrecursionlimit(10**9)
H, W = list(map(int, input().split()))
field = [list(eval(input())) for _ in range(H)]
MOD = 10 ** 9 + 7
count = [0]
dp = [[-1] * W for _ in range(H)]
def dfs(x, y):
if x == W-1 and y == H-1:
return 1
ret = 0
for nx, ny in ((1,0), (0,1)):
nx += x
... | H, W = list(map(int, input().split()))
#field = [list(input()) for _ in range(H)]
field = []
for _ in range(H):
tmp = list(eval(input()))
tmp.append("#")
field.append(tmp)
field.append(["#"] * (W))
dp = [[0] * (W+1) for _ in range(H+1)]
dp[0][0] = 1
mod = 10 ** 9 + 7
for h in range(H):
for w... | 27 | 25 | 537 | 643 | import sys
sys.setrecursionlimit(10**9)
H, W = list(map(int, input().split()))
field = [list(eval(input())) for _ in range(H)]
MOD = 10**9 + 7
count = [0]
dp = [[-1] * W for _ in range(H)]
def dfs(x, y):
if x == W - 1 and y == H - 1:
return 1
ret = 0
for nx, ny in ((1, 0), (0, 1)):
nx += ... | H, W = list(map(int, input().split()))
# field = [list(input()) for _ in range(H)]
field = []
for _ in range(H):
tmp = list(eval(input()))
tmp.append("#")
field.append(tmp)
field.append(["#"] * (W))
dp = [[0] * (W + 1) for _ in range(H + 1)]
dp[0][0] = 1
mod = 10**9 + 7
for h in range(H):
for w in range... | false | 7.407407 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**9)",
"-field = [list(eval(input())) for _ in range(H)]",
"-MOD = 10**9 + 7",
"-count = [0]",
"-dp = [[-1] * W for _ in range(H)]",
"-",
"-",
"-def dfs(x, y):",
"- if x == W - 1 and y == H - 1:",
"- return 1",
"- ret = 0",
"- f... | false | 0.047327 | 0.037174 | 1.27312 | [
"s842119277",
"s225598181"
] |
u732061897 | p03075 | python | s081168320 | s901071790 | 19 | 17 | 3,064 | 3,064 | Accepted | Accepted | 10.53 | a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
e = int(eval(input()))
k = int(eval(input()))
city = [e,d, c, b, a]
result = 'Yay!'
for i, c in enumerate(city):
for cC in city[i + 1:len(city)]:
if (c - cC) > k:
result = ':('
b... | a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
e = int(eval(input()))
k = int(eval(input()))
city = [e, d, c, b, a]
result = 'Yay!'
for i, c in enumerate(city):
for u in city[i + 1:len(city)]:
if (c - u) > k:
result = ':('
br... | 15 | 15 | 305 | 303 | a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
e = int(eval(input()))
k = int(eval(input()))
city = [e, d, c, b, a]
result = "Yay!"
for i, c in enumerate(city):
for cC in city[i + 1 : len(city)]:
if (c - cC) > k:
result = ":("
break
print(... | a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
e = int(eval(input()))
k = int(eval(input()))
city = [e, d, c, b, a]
result = "Yay!"
for i, c in enumerate(city):
for u in city[i + 1 : len(city)]:
if (c - u) > k:
result = ":("
break
print(re... | false | 0 | [
"- for cC in city[i + 1 : len(city)]:",
"- if (c - cC) > k:",
"+ for u in city[i + 1 : len(city)]:",
"+ if (c - u) > k:"
] | false | 0.043639 | 0.04483 | 0.973443 | [
"s081168320",
"s901071790"
] |
u505420467 | p02845 | python | s337927740 | s446183220 | 167 | 108 | 14,308 | 14,396 | Accepted | Accepted | 35.33 | if __name__ == '__main__':
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
x, y, z = [0], [0], [0]
for i in range(n):
if a[i] == 0:
if x[-1] == 0:
x.append(1)
y.append(y[-1])
z.append(z[-1])
... | if __name__ == '__main__':
n = int(eval(input()))
a = list([int(x) + 1 for x in input().split()])
counts = [0] * (n + 1)
counts[0] = 3
ans = 1
for i in range(n):
ans *= counts[a[i] - 1]
ans %= (10 ** 9 + 7)
counts[a[i] - 1] -= 1
counts[a[i]] += 1
pr... | 39 | 12 | 1,082 | 328 | if __name__ == "__main__":
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
x, y, z = [0], [0], [0]
for i in range(n):
if a[i] == 0:
if x[-1] == 0:
x.append(1)
y.append(y[-1])
z.append(z[-1])
elif y[-1]... | if __name__ == "__main__":
n = int(eval(input()))
a = list([int(x) + 1 for x in input().split()])
counts = [0] * (n + 1)
counts[0] = 3
ans = 1
for i in range(n):
ans *= counts[a[i] - 1]
ans %= 10**9 + 7
counts[a[i] - 1] -= 1
counts[a[i]] += 1
print(ans)
| false | 69.230769 | [
"- a = list(map(int, input().split()))",
"- ans = 0",
"- x, y, z = [0], [0], [0]",
"- for i in range(n):",
"- if a[i] == 0:",
"- if x[-1] == 0:",
"- x.append(1)",
"- y.append(y[-1])",
"- z.append(z[-1])",
"- elif... | false | 0.058008 | 0.033746 | 1.718939 | [
"s337927740",
"s446183220"
] |
u072053884 | p02414 | python | s689951770 | s061797363 | 360 | 300 | 8,476 | 8,948 | Accepted | Accepted | 16.67 | n, m, l = list(map(int, input().split()))
A = []
B = []
C = [[] for i in range(n)]
for i in range(n):
tmp_row = list(map(int, input().split()))
A.append(tmp_row)
for i in range(m):
tmp_row = list(map(int, input().split()))
B.append(tmp_row)
for i in range(n):
line = ""
for j ... | n, m, l = list(map(int, input().split()))
A = []
B = []
C = [[] for i in range(n)]
for i in range(n):
tmp_row = list(map(int, input().split()))
A.append(tmp_row)
for i in range(m):
tmp_row = list(map(int, input().split()))
B.append(tmp_row)
for i in range(n):
for j in range(l):
... | 20 | 21 | 439 | 442 | n, m, l = list(map(int, input().split()))
A = []
B = []
C = [[] for i in range(n)]
for i in range(n):
tmp_row = list(map(int, input().split()))
A.append(tmp_row)
for i in range(m):
tmp_row = list(map(int, input().split()))
B.append(tmp_row)
for i in range(n):
line = ""
for j in range(l):
... | n, m, l = list(map(int, input().split()))
A = []
B = []
C = [[] for i in range(n)]
for i in range(n):
tmp_row = list(map(int, input().split()))
A.append(tmp_row)
for i in range(m):
tmp_row = list(map(int, input().split()))
B.append(tmp_row)
for i in range(n):
for j in range(l):
ab = sum([A[i... | false | 4.761905 | [
"- line = \"\"",
"- line += \" {0}\".format(ab)",
"- print((line[1:]))",
"+ C[i].append(ab)",
"+for i in C:",
"+ print((\" \".join(map(str, i))))"
] | false | 0.068197 | 0.036756 | 1.855414 | [
"s689951770",
"s061797363"
] |
u187205913 | p03370 | python | s550199305 | s557748478 | 20 | 18 | 2,940 | 2,940 | Accepted | Accepted | 10 | n,x = list(map(int,input().split()))
m = [int(eval(input())) for i in range(n)]
x -= sum(m)
print((x//min(m)+n)) | n, x = list(map(int, input().split()))
m = [int(eval(input())) for _ in range(n)]
x -= sum(m)
print((n + x // min(m))) | 4 | 4 | 101 | 107 | n, x = list(map(int, input().split()))
m = [int(eval(input())) for i in range(n)]
x -= sum(m)
print((x // min(m) + n))
| n, x = list(map(int, input().split()))
m = [int(eval(input())) for _ in range(n)]
x -= sum(m)
print((n + x // min(m)))
| false | 0 | [
"-m = [int(eval(input())) for i in range(n)]",
"+m = [int(eval(input())) for _ in range(n)]",
"-print((x // min(m) + n))",
"+print((n + x // min(m)))"
] | false | 0.040395 | 0.038277 | 1.055332 | [
"s550199305",
"s557748478"
] |
u691018832 | p03319 | python | s895980254 | s701773641 | 38 | 17 | 11,624 | 2,940 | Accepted | Accepted | 55.26 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
n, k = list(map(int, readline().split()))
a = list(map(int, readline().split()))
print(((n - 2) // (k - 1) + 1))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
n, k, *a = list(map(int, readline().split()))
print(((n - 2) // (k - 1) + 1))
| 9 | 8 | 263 | 225 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
n, k = list(map(int, readline().split()))
a = list(map(int, readline().split()))
print(((n - 2) // (k - 1) + 1))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
n, k, *a = list(map(int, readline().split()))
print(((n - 2) // (k - 1) + 1))
| false | 11.111111 | [
"-n, k = list(map(int, readline().split()))",
"-a = list(map(int, readline().split()))",
"+n, k, *a = list(map(int, readline().split()))"
] | false | 0.047191 | 0.037648 | 1.253492 | [
"s895980254",
"s701773641"
] |
u280978334 | p03103 | python | s264635007 | s106838088 | 542 | 419 | 28,652 | 29,032 | Accepted | Accepted | 22.69 | n,m = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(n)]
cost = 0
temp = 0
s_AB = sorted(AB)
for ab in s_AB:
cost += ab[0]*ab[1]
temp += ab[1]
if(temp > m):
cost -= ab[0]*(temp - m)
break
elif(temp == m):
break
print(cost)
| n,m = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(n)]
from operator import itemgetter
def main():
AB.sort(key = itemgetter(0))
cnt = 0
ans = 0
for a,b in AB:
if b + cnt < m:
cnt += b
ans += b*a
else:
... | 15 | 22 | 311 | 426 | n, m = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(n)]
cost = 0
temp = 0
s_AB = sorted(AB)
for ab in s_AB:
cost += ab[0] * ab[1]
temp += ab[1]
if temp > m:
cost -= ab[0] * (temp - m)
break
elif temp == m:
break
print(cost)
| n, m = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(n)]
from operator import itemgetter
def main():
AB.sort(key=itemgetter(0))
cnt = 0
ans = 0
for a, b in AB:
if b + cnt < m:
cnt += b
ans += b * a
else:
ans += ... | false | 31.818182 | [
"-cost = 0",
"-temp = 0",
"-s_AB = sorted(AB)",
"-for ab in s_AB:",
"- cost += ab[0] * ab[1]",
"- temp += ab[1]",
"- if temp > m:",
"- cost -= ab[0] * (temp - m)",
"- break",
"- elif temp == m:",
"- break",
"-print(cost)",
"+from operator import itemgetter",
... | false | 0.039704 | 0.047548 | 0.835031 | [
"s264635007",
"s106838088"
] |
u988912858 | p02924 | python | s458343300 | s527992970 | 17 | 11 | 2,940 | 2,568 | Accepted | Accepted | 35.29 | n = int(eval(input()))
tmp = n*(n-1)
print((tmp//2)) | n = int(eval(input()))
tmp = n*(n-1)
print((tmp/2)) | 3 | 3 | 46 | 45 | n = int(eval(input()))
tmp = n * (n - 1)
print((tmp // 2))
| n = int(eval(input()))
tmp = n * (n - 1)
print((tmp / 2))
| false | 0 | [
"-print((tmp // 2))",
"+print((tmp / 2))"
] | false | 0.046136 | 0.044691 | 1.032331 | [
"s458343300",
"s527992970"
] |
u169350228 | p02913 | python | s806565306 | s012903461 | 745 | 503 | 47,960 | 74,556 | Accepted | Accepted | 32.48 | import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n = int(ipt())
s = e... | '''
่ชๅฎ
็จPCใงใฎ่งฃ็ญ
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecurs... | 44 | 56 | 1,014 | 1,203 | import math
# import numpy as np
import queue
from collections import deque, defaultdict
import heapq
from sys import stdin, setrecursionlimit
# from scipy.sparse.csgraph import dijkstra
# from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n = int(ipt())
s = eval(i... | """
่ชๅฎ
็จPCใงใฎ่งฃ็ญ
"""
import math
# import numpy as np
import itertools
import queue
import bisect
from collections import deque, defaultdict
import heapq as hpq
from sys import stdin, setrecursionlimit
# from scipy.sparse.csgraph import dijkstra
# from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimi... | false | 21.428571 | [
"+\"\"\"",
"+่ชๅฎ
็จPCใงใฎ่งฃ็ญ",
"+\"\"\"",
"+import itertools",
"+import bisect",
"-import heapq",
"+import heapq as hpq",
"-",
"-",
"-def main():",
"- n = int(ipt())",
"- s = eval(input())",
"- ma = 0",
"- for i in range(n):",
"- pf = z_algorithm(s[i::])",
"- if pf ... | false | 0.081799 | 0.092738 | 0.88205 | [
"s806565306",
"s012903461"
] |
u279493135 | p02935 | python | s303612947 | s844749195 | 57 | 40 | 5,712 | 5,156 | Accepted | Accepted | 29.82 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upp... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digi... | 28 | 26 | 767 | 721 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
fro... | false | 7.142857 | [
"-from itertools import permutations, combinations, product, accumulate",
"+from itertools import permutations, combinations, product",
"+from bisect import bisect",
"-ans = (v[0] + v[1]) / 2",
"-for i in range(N):",
"- if i == 0 or i == 1:",
"- continue",
"- else:",
"- ans = (an... | false | 0.060303 | 0.043606 | 1.382923 | [
"s303612947",
"s844749195"
] |
u411203878 | p03472 | python | s091510209 | s480312540 | 774 | 228 | 74,328 | 81,436 | Accepted | Accepted | 70.54 | n,h = list(map(int,input().split()))
ab = []
for _ in range(n):
a, b = (int(x) for x in input().split())
ab.append([a, b])
ab = sorted(ab, key=lambda x: -x[0])
x,y = ab.pop(0)
ab.append([x,y])
ab = sorted(ab, key=lambda x: -x[1])
count = 0
for i ,j in ab:
if x <= j:
h -= j
count... | N,H = list(map(int,input().split()))
B = []
max_attack = 0
for i in range(N):
a,b = list(map(int,input().split()))
max_attack = max(a,max_attack)
B.append(b)
B.sort(reverse=True)
ans = 0
for b in B:
if max_attack <= b:
H -= b
ans += 1
if H <= 0:
brea... | 24 | 26 | 480 | 461 | n, h = list(map(int, input().split()))
ab = []
for _ in range(n):
a, b = (int(x) for x in input().split())
ab.append([a, b])
ab = sorted(ab, key=lambda x: -x[0])
x, y = ab.pop(0)
ab.append([x, y])
ab = sorted(ab, key=lambda x: -x[1])
count = 0
for i, j in ab:
if x <= j:
h -= j
count += 1
... | N, H = list(map(int, input().split()))
B = []
max_attack = 0
for i in range(N):
a, b = list(map(int, input().split()))
max_attack = max(a, max_attack)
B.append(b)
B.sort(reverse=True)
ans = 0
for b in B:
if max_attack <= b:
H -= b
ans += 1
if H <= 0:
break
else:
... | false | 7.692308 | [
"-n, h = list(map(int, input().split()))",
"-ab = []",
"-for _ in range(n):",
"- a, b = (int(x) for x in input().split())",
"- ab.append([a, b])",
"-ab = sorted(ab, key=lambda x: -x[0])",
"-x, y = ab.pop(0)",
"-ab.append([x, y])",
"-ab = sorted(ab, key=lambda x: -x[1])",
"-count = 0",
"-fo... | false | 0.133856 | 0.037457 | 3.573632 | [
"s091510209",
"s480312540"
] |
u535803878 | p02623 | python | s897615812 | s561167500 | 171 | 147 | 118,040 | 118,068 | Accepted | Accepted | 14.04 | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
def cumsum(a):
"""l[i] = sum(a[:i]) ใชใlใ่ฟใ
sum(a[i:j]) == l[j+1] - l[i]
"""
c = 0
l = [None] * (len(a)+1)
for i,num in enumerate(a):
... | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
def cumsum(a):
"""l[i] = sum(a[:i]) ใชใlใ่ฟใ
sum(a[i:j]) == l[j+1] - l[i]
"""
c = 0
l = [None] * (len(a)+1)
for i,num in enumerate(a):
... | 41 | 42 | 817 | 813 | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
def cumsum(a):
"""l[i] = sum(a[:i]) ใชใlใ่ฟใ
sum(a[i:j]) == l[j+1] - l[i]
"""
c = 0
l = [None] * (len(a) + 1)
for i, num in enumerate(a):
l[i] = ... | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
def cumsum(a):
"""l[i] = sum(a[:i]) ใชใlใ่ฟใ
sum(a[i:j]) == l[j+1] - l[i]
"""
c = 0
l = [None] * (len(a) + 1)
for i, num in enumerate(a):
l[i] = ... | false | 2.380952 | [
"-ca = cumsum(a)",
"-cb = cumsum(b)",
"-",
"-",
"-def sub(x):",
"- res = float(\"inf\")",
"- for i in range(x + 1):",
"- if i > n or (x - i) > m:",
"- continue",
"- res = min(res, ca[i] + cb[x - i])",
"- return res <= k",
"-",
"-",
"-l = 0",
"-r = n + m ... | false | 0.042684 | 0.042227 | 1.010811 | [
"s897615812",
"s561167500"
] |
u290211456 | p03658 | python | s669654063 | s246729871 | 20 | 17 | 3,060 | 2,940 | Accepted | Accepted | 15 | n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort(reverse = True)
print((sum(l[:k]))) | n,k = list(map(int, input().split()))
ll = list(map(int, input().split()))
ll.sort()
print((sum(ll[len(ll)-k:]))) | 5 | 4 | 120 | 108 | n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort(reverse=True)
print((sum(l[:k])))
| n, k = list(map(int, input().split()))
ll = list(map(int, input().split()))
ll.sort()
print((sum(ll[len(ll) - k :])))
| false | 20 | [
"-l = list(map(int, input().split()))",
"-l.sort(reverse=True)",
"-print((sum(l[:k])))",
"+ll = list(map(int, input().split()))",
"+ll.sort()",
"+print((sum(ll[len(ll) - k :])))"
] | false | 0.099333 | 0.049608 | 2.002348 | [
"s669654063",
"s246729871"
] |
u160414758 | p03634 | python | s769566519 | s636647871 | 1,740 | 987 | 152,180 | 153,088 | Accepted | Accepted | 43.28 | import sys;sys.setrecursionlimit(int(1e7))
class edge():
def __init__(self,_to,_cost):
self.to = _to;
self.cost = _cost;
N = int(eval(input()))
tree = [[] for i in range(N+1)]
for i in range(N-1):
a,b,c = list(map(int,input().split()))
a = a - 1
b = b - 1
tree[a].app... | import sys;sys.setrecursionlimit(int(1e7))
N = int(eval(input()))
tree = [[] for _ in range(N+1)]
depth = [None]*(N+1)
ABC = [ tuple(map(int,input().split())) for _ in range(N-1)]
Q,K = list(map(int,input().split()))
XY = [tuple(map(int,input().split())) for _ in range(Q)]
for abc in ABC:
tree[abc[0... | 33 | 25 | 688 | 577 | import sys
sys.setrecursionlimit(int(1e7))
class edge:
def __init__(self, _to, _cost):
self.to = _to
self.cost = _cost
N = int(eval(input()))
tree = [[] for i in range(N + 1)]
for i in range(N - 1):
a, b, c = list(map(int, input().split()))
a = a - 1
b = b - 1
tree[a].append(edg... | import sys
sys.setrecursionlimit(int(1e7))
N = int(eval(input()))
tree = [[] for _ in range(N + 1)]
depth = [None] * (N + 1)
ABC = [tuple(map(int, input().split())) for _ in range(N - 1)]
Q, K = list(map(int, input().split()))
XY = [tuple(map(int, input().split())) for _ in range(Q)]
for abc in ABC:
tree[abc[0]].a... | false | 24.242424 | [
"-",
"-",
"-class edge:",
"- def __init__(self, _to, _cost):",
"- self.to = _to",
"- self.cost = _cost",
"-",
"-",
"-tree = [[] for i in range(N + 1)]",
"-for i in range(N - 1):",
"- a, b, c = list(map(int, input().split()))",
"- a = a - 1",
"- b = b - 1",
"- t... | false | 0.041964 | 0.038117 | 1.100936 | [
"s769566519",
"s636647871"
] |
u525065967 | p02659 | python | s299024643 | s757059445 | 25 | 22 | 10,012 | 9,164 | Accepted | Accepted | 12 | from decimal import *
s,t =input().split()
a = int(s)
b = int(float(t)*1000)
ans = Decimal(0)
for si in s:
ai = int(si)
ans = ans * 10 + ai*b
print((ans//1000))
| s,t =input().split()
a = int(s)
b = int(float(t)*1000)
ans = a*b
print((ans//1000))
| 10 | 5 | 177 | 86 | from decimal import *
s, t = input().split()
a = int(s)
b = int(float(t) * 1000)
ans = Decimal(0)
for si in s:
ai = int(si)
ans = ans * 10 + ai * b
print((ans // 1000))
| s, t = input().split()
a = int(s)
b = int(float(t) * 1000)
ans = a * b
print((ans // 1000))
| false | 50 | [
"-from decimal import *",
"-",
"-ans = Decimal(0)",
"-for si in s:",
"- ai = int(si)",
"- ans = ans * 10 + ai * b",
"+ans = a * b"
] | false | 0.05343 | 0.049822 | 1.072423 | [
"s299024643",
"s757059445"
] |
u644907318 | p02702 | python | s877449689 | s123799367 | 126 | 98 | 83,552 | 100,824 | Accepted | Accepted | 22.22 | S = input().strip()
A = [0 for _ in range(len(S))]
A[-1] = int(S[-1])%3
for i in range(2,len(S)+1):
A[-i] = (A[-i+1]+int(S[-i]))%3
B = [0 for _ in range(len(S))]
B[-1] = int(S[-1])%673
a = 1
for i in range(2,len(S)+1):
a = (a*10)%673
B[-i] = (int(S[-i])*a+B[-i+1])%673
C = {}
for i in range(len(S... | S = input().strip()
N = len(S)
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
B[0] = 1
for i in range(1,N):
B[i] = (B[i-1]*10)%2019
a = 0
for i in range(N-1,-1,-1):
a = (int(S[i])*B[N-1-i]+a)%2019
A[i] = a
C = {i:0 for i in range(2019)}
for i in range(N):
C[A[i]] += 1
cnt = C[0]
for ... | 25 | 18 | 524 | 380 | S = input().strip()
A = [0 for _ in range(len(S))]
A[-1] = int(S[-1]) % 3
for i in range(2, len(S) + 1):
A[-i] = (A[-i + 1] + int(S[-i])) % 3
B = [0 for _ in range(len(S))]
B[-1] = int(S[-1]) % 673
a = 1
for i in range(2, len(S) + 1):
a = (a * 10) % 673
B[-i] = (int(S[-i]) * a + B[-i + 1]) % 673
C = {}
for ... | S = input().strip()
N = len(S)
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
B[0] = 1
for i in range(1, N):
B[i] = (B[i - 1] * 10) % 2019
a = 0
for i in range(N - 1, -1, -1):
a = (int(S[i]) * B[N - 1 - i] + a) % 2019
A[i] = a
C = {i: 0 for i in range(2019)}
for i in range(N):
C[A[i]] += 1
cnt = C[... | false | 28 | [
"-A = [0 for _ in range(len(S))]",
"-A[-1] = int(S[-1]) % 3",
"-for i in range(2, len(S) + 1):",
"- A[-i] = (A[-i + 1] + int(S[-i])) % 3",
"-B = [0 for _ in range(len(S))]",
"-B[-1] = int(S[-1]) % 673",
"-a = 1",
"-for i in range(2, len(S) + 1):",
"- a = (a * 10) % 673",
"- B[-i] = (int(S... | false | 0.079548 | 0.060468 | 1.31555 | [
"s877449689",
"s123799367"
] |
u790710233 | p03846 | python | s418974335 | s021235261 | 96 | 47 | 15,200 | 14,008 | Accepted | Accepted | 51.04 | from collections import defaultdict
n = int(eval(input()))
a = list(map(int, input().split()))
d = defaultdict(int)
for x in a:
d[x] += 1
b = [i for i in range(n)[::-1]]
if not all([d[i] == 2, d[i] == 1][n % 2 and i == 0] for i in b[::2]):
print((0))
else:
ans = 1
for v in list(d.values()):
... | N = int(eval(input()))
A = list(map(int, input().split()))
flag = True
if N % 2 == 0:
if 0 in A or len(set(A)) != N//2:
flag = False
else:
if len([0 for a in A if a == 0]) != 1 or len(set(A)) != N//2+1:
flag = False
if flag:
print((2**(N//2) % (10**9+7)))
else:
print((0)) | 14 | 13 | 355 | 306 | from collections import defaultdict
n = int(eval(input()))
a = list(map(int, input().split()))
d = defaultdict(int)
for x in a:
d[x] += 1
b = [i for i in range(n)[::-1]]
if not all([d[i] == 2, d[i] == 1][n % 2 and i == 0] for i in b[::2]):
print((0))
else:
ans = 1
for v in list(d.values()):
ans... | N = int(eval(input()))
A = list(map(int, input().split()))
flag = True
if N % 2 == 0:
if 0 in A or len(set(A)) != N // 2:
flag = False
else:
if len([0 for a in A if a == 0]) != 1 or len(set(A)) != N // 2 + 1:
flag = False
if flag:
print((2 ** (N // 2) % (10**9 + 7)))
else:
print((0))
| false | 7.142857 | [
"-from collections import defaultdict",
"-",
"-n = int(eval(input()))",
"-a = list(map(int, input().split()))",
"-d = defaultdict(int)",
"-for x in a:",
"- d[x] += 1",
"-b = [i for i in range(n)[::-1]]",
"-if not all([d[i] == 2, d[i] == 1][n % 2 and i == 0] for i in b[::2]):",
"+N = int(eval(in... | false | 0.039578 | 0.039882 | 0.992374 | [
"s418974335",
"s021235261"
] |
u636683284 | p02713 | python | s686040222 | s861349557 | 1,094 | 511 | 69,560 | 67,916 | Accepted | Accepted | 53.29 | import math
from functools import reduce
def gcd(*numbers):
return reduce(math.gcd, numbers)
k = int(eval(input()))
s = 0
for a in range(1,k+1):
for b in range(1,k+1):
for c in range(1,k+1):
s += gcd(a,b,c)
print(s)
| from math import gcd
k = int(eval(input()))
count = 0
for a in range(1,k+1):
for b in range(1,k+1):
for c in range(1,k+1):
count += gcd(gcd(a,b),c)
print(count) | 13 | 8 | 245 | 173 | import math
from functools import reduce
def gcd(*numbers):
return reduce(math.gcd, numbers)
k = int(eval(input()))
s = 0
for a in range(1, k + 1):
for b in range(1, k + 1):
for c in range(1, k + 1):
s += gcd(a, b, c)
print(s)
| from math import gcd
k = int(eval(input()))
count = 0
for a in range(1, k + 1):
for b in range(1, k + 1):
for c in range(1, k + 1):
count += gcd(gcd(a, b), c)
print(count)
| false | 38.461538 | [
"-import math",
"-from functools import reduce",
"-",
"-",
"-def gcd(*numbers):",
"- return reduce(math.gcd, numbers)",
"-",
"+from math import gcd",
"-s = 0",
"+count = 0",
"- s += gcd(a, b, c)",
"-print(s)",
"+ count += gcd(gcd(a, b), c)",
"+print(count)"
] | false | 0.049154 | 0.008769 | 5.605572 | [
"s686040222",
"s861349557"
] |
u348805958 | p02632 | python | s154933760 | s827152991 | 262 | 235 | 106,680 | 102,972 | Accepted | Accepted | 10.31 | #!python3
import sys
iim = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
def _cmb(N, mod):
N1 = N + 1
fact = [1] * N1
inv = [1] * N1
for i in range(2, N1):
fact[i] = fact[i-1] * i % mod
inv[N] = pow(fact[N], mod-2, mod)
for i in range(N-1, 1, -1):
... | #!python3
import sys
iim = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
def _cmb(N, mod):
N1 = N + 1
fact = [1] * N1
inv = [1] * N1
for i in range(2, N1):
fact[i] = fact[i-1] * i % mod
inv[N] = pow(fact[N], mod-2, mod)
for i in range(N-1, 1, -1):
... | 41 | 41 | 874 | 886 | #!python3
import sys
iim = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
def _cmb(N, mod):
N1 = N + 1
fact = [1] * N1
inv = [1] * N1
for i in range(2, N1):
fact[i] = fact[i - 1] * i % mod
inv[N] = pow(fact[N], mod - 2, mod)
for i in range(N - 1, 1, -1):
inv[i] ... | #!python3
import sys
iim = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
def _cmb(N, mod):
N1 = N + 1
fact = [1] * N1
inv = [1] * N1
for i in range(2, N1):
fact[i] = fact[i - 1] * i % mod
inv[N] = pow(fact[N], mod - 2, mod)
for i in range(N - 1, 1, -1):
inv[i] ... | false | 0 | [
"- ans = (ans + cmb(ls + i, ls) * p25 * p26) % mod",
"+ ans = (ans + cmb(ls + i, ls) * p25 % mod * p26 % mod) % mod"
] | false | 0.036568 | 0.048595 | 0.7525 | [
"s154933760",
"s827152991"
] |
u614181788 | p02912 | python | s231862949 | s959492553 | 872 | 194 | 14,480 | 19,952 | Accepted | Accepted | 77.75 | n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
M = max(a)
a = sorted(a,reverse=True)
t = 0
while M > 1:
M = -(-M//2)
t += 1
z = [[] for i in range(t+2)]
for i in range(n):
s = 0
b = a[i]
while b > 1:
b = -(-b//2)
s += 1
z[t-s].append(a[i])
... | n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
import heapq
q = [0]*n
for i in range(n):
q[i] = -a[i]
heapq.heapify(q)
for i in range(m):
x = heapq.heappop(q)
heapq.heappush(q,-(-x//2))
ans = 0
for i in range(n):
x = heapq.heappop(q)
ans += x
print((-ans)) | 31 | 15 | 591 | 309 | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
M = max(a)
a = sorted(a, reverse=True)
t = 0
while M > 1:
M = -(-M // 2)
t += 1
z = [[] for i in range(t + 2)]
for i in range(n):
s = 0
b = a[i]
while b > 1:
b = -(-b // 2)
s += 1
z[t - s].append(a[i])
cou... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
import heapq
q = [0] * n
for i in range(n):
q[i] = -a[i]
heapq.heapify(q)
for i in range(m):
x = heapq.heappop(q)
heapq.heappush(q, -(-x // 2))
ans = 0
for i in range(n):
x = heapq.heappop(q)
ans += x
print((-ans))
| false | 51.612903 | [
"-M = max(a)",
"-a = sorted(a, reverse=True)",
"-t = 0",
"-while M > 1:",
"- M = -(-M // 2)",
"- t += 1",
"-z = [[] for i in range(t + 2)]",
"+import heapq",
"+",
"+q = [0] * n",
"- s = 0",
"- b = a[i]",
"- while b > 1:",
"- b = -(-b // 2)",
"- s += 1",
"- ... | false | 0.11147 | 0.076755 | 1.452283 | [
"s231862949",
"s959492553"
] |
u361381049 | p03141 | python | s211068082 | s347251964 | 646 | 421 | 113,360 | 107,992 | Accepted | Accepted | 34.83 | from collections import deque
N = int(eval(input()))
taka = []
ao = []
A = []
B = []
for i in range(N):
Ain,Bin = list(map(int,input().split()))
A.append(Ain)
B.append(Bin)
taka.append((Bin+Ain,i))
ao.append((Ain+Bin,i))
taka.sort()
taka.reverse()
ao.sort()
ao.reverse()
taka = deque(... | from collections import deque
N = int(eval(input()))
lis = []
A = []
B = []
for i in range(N):
Ain,Bin = list(map(int,input().split()))
A.append(Ain)
B.append(Bin)
lis.append((Ain+Bin,i))
lis.sort()
lis.reverse()
lis = deque(lis)
takacnt = 0
aocnt = 0
st = set()
# print(taka)
# pr... | 41 | 38 | 799 | 719 | from collections import deque
N = int(eval(input()))
taka = []
ao = []
A = []
B = []
for i in range(N):
Ain, Bin = list(map(int, input().split()))
A.append(Ain)
B.append(Bin)
taka.append((Bin + Ain, i))
ao.append((Ain + Bin, i))
taka.sort()
taka.reverse()
ao.sort()
ao.reverse()
taka = deque(taka)
a... | from collections import deque
N = int(eval(input()))
lis = []
A = []
B = []
for i in range(N):
Ain, Bin = list(map(int, input().split()))
A.append(Ain)
B.append(Bin)
lis.append((Ain + Bin, i))
lis.sort()
lis.reverse()
lis = deque(lis)
takacnt = 0
aocnt = 0
st = set()
# print(taka)
# print(ao)
for i in ... | false | 7.317073 | [
"-taka = []",
"-ao = []",
"+lis = []",
"- taka.append((Bin + Ain, i))",
"- ao.append((Ain + Bin, i))",
"-taka.sort()",
"-taka.reverse()",
"-ao.sort()",
"-ao.reverse()",
"-taka = deque(taka)",
"-ao = deque(ao)",
"+ lis.append((Ain + Bin, i))",
"+lis.sort()",
"+lis.reverse()",
"+l... | false | 0.0837 | 0.110759 | 0.755697 | [
"s211068082",
"s347251964"
] |
u162612857 | p02623 | python | s961849603 | s353477773 | 310 | 240 | 40,776 | 41,128 | Accepted | Accepted | 22.58 | # AใใใใใซๅฏพใใฆBใไบๅๆข็ดขโM(็ดฏ็ฉๅๆงๆ) + NlogM
# Aใๆ้ ใBใ้้ ใซๅใใโO(N+M)
import bisect
n, m, k = list(map(int, input().split()))
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
# ็ดฏ็ฉๅใไฝใ
b_cumsum = [0] * (m+1)
for i in range(m):
b_cumsum[i+1] = b_cumsum[i] + bb[i]
ans = 0
a_sum = 0
b_res... | # ไบ้ใใฎใใๆนใง่งฃใใฆใฟใใใ
# AใใใใใซๅฏพใใฆBใไบๅๆข็ดขโM(็ดฏ็ฉๅๆงๆ) + NlogM
# Aใๆ้ ใBใ้้ ใซๅใใโO(N+M) ใใฎใณใผใใฏใใฃใกโ
n, m, k = list(map(int, input().split()))
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
time_sum = sum(bb)
a_idx = 0
b_idx = m-1
ans = 0
# ๆๅใฏA็กใใBๅ
จ้จใใในใฟใผใ
book_num = m
while True:
... | 29 | 35 | 591 | 663 | # AใใใใใซๅฏพใใฆBใไบๅๆข็ดขโM(็ดฏ็ฉๅๆงๆ) + NlogM
# Aใๆ้ ใBใ้้ ใซๅใใโO(N+M)
import bisect
n, m, k = list(map(int, input().split()))
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
# ็ดฏ็ฉๅใไฝใ
b_cumsum = [0] * (m + 1)
for i in range(m):
b_cumsum[i + 1] = b_cumsum[i] + bb[i]
ans = 0
a_sum = 0
b_rest = k
temp = ... | # ไบ้ใใฎใใๆนใง่งฃใใฆใฟใใใ
# AใใใใใซๅฏพใใฆBใไบๅๆข็ดขโM(็ดฏ็ฉๅๆงๆ) + NlogM
# Aใๆ้ ใBใ้้ ใซๅใใโO(N+M) ใใฎใณใผใใฏใใฃใกโ
n, m, k = list(map(int, input().split()))
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
time_sum = sum(bb)
a_idx = 0
b_idx = m - 1
ans = 0
# ๆๅใฏA็กใใBๅ
จ้จใใในใฟใผใ
book_num = m
while True:
if time_sum > k:
... | false | 17.142857 | [
"+# ไบ้ใใฎใใๆนใง่งฃใใฆใฟใใใ",
"-# Aใๆ้ ใBใ้้ ใซๅใใโO(N+M)",
"-import bisect",
"-",
"+# Aใๆ้ ใBใ้้ ใซๅใใโO(N+M) ใใฎใณใผใใฏใใฃใกโ
",
"-# ็ดฏ็ฉๅใไฝใ",
"-b_cumsum = [0] * (m + 1)",
"-for i in range(m):",
"- b_cumsum[i + 1] = b_cumsum[i] + bb[i]",
"+time_sum = sum(bb)",
"+a_idx = 0",
"+b_idx = m - 1",
"-a_sum = 0",
... | false | 0.042245 | 0.040973 | 1.031056 | [
"s961849603",
"s353477773"
] |
u636775911 | p03352 | python | s200604617 | s334697939 | 23 | 18 | 2,940 | 3,060 | Accepted | Accepted | 21.74 | n=int(eval(input()))
max=0
if(n==1):
print((1))
else:
for i in range(n):
for j in range(2,10):
if(max<=i**j and i**j<=n):
max=i**j
print(max) | import math
n = int(eval(input()))
j = 2
tmp = 0
Max = 1
for i in range(2,n):
while(n > tmp):
tmp = i**j
j+=1
if(Max < tmp and n >= tmp):
Max = tmp
j = 2
tmp = 0
print(Max) | 10 | 14 | 166 | 203 | n = int(eval(input()))
max = 0
if n == 1:
print((1))
else:
for i in range(n):
for j in range(2, 10):
if max <= i**j and i**j <= n:
max = i**j
print(max)
| import math
n = int(eval(input()))
j = 2
tmp = 0
Max = 1
for i in range(2, n):
while n > tmp:
tmp = i**j
j += 1
if Max < tmp and n >= tmp:
Max = tmp
j = 2
tmp = 0
print(Max)
| false | 28.571429 | [
"+import math",
"+",
"-max = 0",
"-if n == 1:",
"- print((1))",
"-else:",
"- for i in range(n):",
"- for j in range(2, 10):",
"- if max <= i**j and i**j <= n:",
"- max = i**j",
"- print(max)",
"+j = 2",
"+tmp = 0",
"+Max = 1",
"+for i in range(2,... | false | 0.038227 | 0.068277 | 0.559874 | [
"s200604617",
"s334697939"
] |
u630511239 | p02756 | python | s848130195 | s833702954 | 385 | 323 | 15,856 | 14,192 | Accepted | Accepted | 16.1 | S = list(eval(input()))
Q = int(eval(input()))
a = 0
A = []
B = []
for i in range(Q):
q = list(input().split())
q[0] = int(q[0])
if q[0] == 1:
if a == 0:
a = 1
else:
a = 0
else:
q[1] = int(q[1])
if (q[1] == 1 and a == 0) or (q[1] == 2 and a == 1):
B.append(q[2])... | S = list(eval(input()))
Q = int(eval(input()))
A = []
a = 0
for i in range(Q):
q = list(input().split())
if q[0] == '1':
a += 1
else:
if (q[1] == '1' and a % 2 == 0) or (q[1] == '2' and a % 2 == 1):
A.append(q[2])
else:
S.append(q[2])
A = A[::-1]
S = A + S
if a % 2 == 1:
... | 25 | 21 | 434 | 361 | S = list(eval(input()))
Q = int(eval(input()))
a = 0
A = []
B = []
for i in range(Q):
q = list(input().split())
q[0] = int(q[0])
if q[0] == 1:
if a == 0:
a = 1
else:
a = 0
else:
q[1] = int(q[1])
if (q[1] == 1 and a == 0) or (q[1] == 2 and a == 1):
... | S = list(eval(input()))
Q = int(eval(input()))
A = []
a = 0
for i in range(Q):
q = list(input().split())
if q[0] == "1":
a += 1
else:
if (q[1] == "1" and a % 2 == 0) or (q[1] == "2" and a % 2 == 1):
A.append(q[2])
else:
S.append(q[2])
A = A[::-1]
S = A + S
if ... | false | 16 | [
"+A = []",
"-A = []",
"-B = []",
"- q[0] = int(q[0])",
"- if q[0] == 1:",
"- if a == 0:",
"- a = 1",
"+ if q[0] == \"1\":",
"+ a += 1",
"+ else:",
"+ if (q[1] == \"1\" and a % 2 == 0) or (q[1] == \"2\" and a % 2 == 1):",
"+ A.append(q[2])"... | false | 0.007405 | 0.036922 | 0.200547 | [
"s848130195",
"s833702954"
] |
u384793271 | p03814 | python | s732684029 | s027917885 | 49 | 27 | 9,132 | 9,228 | Accepted | Accepted | 44.9 | s = eval(input())
ind_A = 0
while s[ind_A] != 'A':
ind_A += 1
ind_Z = len(s)
while s[ind_Z - 1] != 'Z':
ind_Z -= 1
print((ind_Z - ind_A)) | s = eval(input())
a = s.index('A')
z = len(s) - s[-1::-1].index('Z')
print((z - a)) | 10 | 5 | 148 | 80 | s = eval(input())
ind_A = 0
while s[ind_A] != "A":
ind_A += 1
ind_Z = len(s)
while s[ind_Z - 1] != "Z":
ind_Z -= 1
print((ind_Z - ind_A))
| s = eval(input())
a = s.index("A")
z = len(s) - s[-1::-1].index("Z")
print((z - a))
| false | 50 | [
"-ind_A = 0",
"-while s[ind_A] != \"A\":",
"- ind_A += 1",
"-ind_Z = len(s)",
"-while s[ind_Z - 1] != \"Z\":",
"- ind_Z -= 1",
"-print((ind_Z - ind_A))",
"+a = s.index(\"A\")",
"+z = len(s) - s[-1::-1].index(\"Z\")",
"+print((z - a))"
] | false | 0.038091 | 0.037425 | 1.017801 | [
"s732684029",
"s027917885"
] |
u033606236 | p03699 | python | s544571318 | s729354111 | 282 | 17 | 11,508 | 3,060 | Accepted | Accepted | 93.97 | n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
dp = [[] for _ in range(n+1)]
for i in range(n+1):
dp[i] += [-1 for _ in range(10010)]
dp[0][0] = 1
for i in range(n):
for j in range(10010):
if dp[i][j] == 1:
dp[i+1][j] = 1
dp[i+1][j+a[i]] = 1
ans = 0
... | n = int(eval(input()))
ary = [int(eval(input())) for _ in range(n)]
total = sum(ary)
ans = 0
if total % 10 != 0:
print(total)
exit()
for i in ary:
a = total - i
if a % 10 != 0:
ans = max(ans,a)
print(ans) | 17 | 12 | 421 | 227 | n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
dp = [[] for _ in range(n + 1)]
for i in range(n + 1):
dp[i] += [-1 for _ in range(10010)]
dp[0][0] = 1
for i in range(n):
for j in range(10010):
if dp[i][j] == 1:
dp[i + 1][j] = 1
dp[i + 1][j + a[i]] = 1
ans = 0
f... | n = int(eval(input()))
ary = [int(eval(input())) for _ in range(n)]
total = sum(ary)
ans = 0
if total % 10 != 0:
print(total)
exit()
for i in ary:
a = total - i
if a % 10 != 0:
ans = max(ans, a)
print(ans)
| false | 29.411765 | [
"-a = [int(eval(input())) for _ in range(n)]",
"-dp = [[] for _ in range(n + 1)]",
"-for i in range(n + 1):",
"- dp[i] += [-1 for _ in range(10010)]",
"-dp[0][0] = 1",
"-for i in range(n):",
"- for j in range(10010):",
"- if dp[i][j] == 1:",
"- dp[i + 1][j] = 1",
"- ... | false | 0.056388 | 0.037398 | 1.507789 | [
"s544571318",
"s729354111"
] |
u797673668 | p02273 | python | s658299541 | s783217074 | 60 | 30 | 8,704 | 7,804 | Accepted | Accepted | 50 | from math import sqrt
from collections import deque
sin30 = 1 / 2
cos30 = sqrt(3) / 2
""" Direct length p1-u when p1-p2 is 1 """
p1_to_u = 1 / sqrt(3)
def koch(xy1, xy2):
global sin30, cos30, p1_to_u
(x1, y1) = xy1
(x2, y2) = xy2
dx, dy = x2 - x1, y2 - y1
dx3, dy3 = dx / 3, dy / 3
... | from math import sqrt
n = int(eval(input()))
sin60 = sqrt(3) / 2
cos60 = 1 / 2
def koch(x1, y1, x2, y2, depth):
global sin60, cos60, n
if depth > n:
return
dx, dy = x2 - x1, y2 - y1
dx3, dy3 = dx / 3, dy / 3
xs, ys = x1 + dx3, y1 + dy3
xt, yt = x2 - dx3, y2 - dy3
xu... | 36 | 34 | 826 | 805 | from math import sqrt
from collections import deque
sin30 = 1 / 2
cos30 = sqrt(3) / 2
""" Direct length p1-u when p1-p2 is 1 """
p1_to_u = 1 / sqrt(3)
def koch(xy1, xy2):
global sin30, cos30, p1_to_u
(x1, y1) = xy1
(x2, y2) = xy2
dx, dy = x2 - x1, y2 - y1
dx3, dy3 = dx / 3, dy / 3
yield (x1 +... | from math import sqrt
n = int(eval(input()))
sin60 = sqrt(3) / 2
cos60 = 1 / 2
def koch(x1, y1, x2, y2, depth):
global sin60, cos60, n
if depth > n:
return
dx, dy = x2 - x1, y2 - y1
dx3, dy3 = dx / 3, dy / 3
xs, ys = x1 + dx3, y1 + dy3
xt, yt = x2 - dx3, y2 - dy3
xu, yu = xs + cos... | false | 5.555556 | [
"-from collections import deque",
"-sin30 = 1 / 2",
"-cos30 = sqrt(3) / 2",
"-\"\"\" Direct length p1-u when p1-p2 is 1 \"\"\"",
"-p1_to_u = 1 / sqrt(3)",
"+n = int(eval(input()))",
"+sin60 = sqrt(3) / 2",
"+cos60 = 1 / 2",
"-def koch(xy1, xy2):",
"- global sin30, cos30, p1_to_u",
"- (x1, ... | false | 0.039693 | 0.041821 | 0.949128 | [
"s658299541",
"s783217074"
] |
u347640436 | p03503 | python | s795880217 | s692350862 | 441 | 157 | 3,064 | 9,224 | Accepted | Accepted | 64.4 | N = int(eval(input()))
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
result = -float('inf')
for i in range(1, 1024):
t = 0
for j in range(N):
c = 0
for k in range(10):
c += (i >> k & 1) & F[j][k]
t ... | # ใใใๅ
จๆข็ดข
from itertools import product
N = int(eval(input()))
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
result = -float('inf')
for i in product([True, False], repeat=10):
if i.count(False) == 10:
continue
t = 0
for j... | 14 | 16 | 369 | 436 | N = int(eval(input()))
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
result = -float("inf")
for i in range(1, 1024):
t = 0
for j in range(N):
c = 0
for k in range(10):
c += (i >> k & 1) & F[j][k]
t += P[j][c]
... | # ใใใๅ
จๆข็ดข
from itertools import product
N = int(eval(input()))
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
result = -float("inf")
for i in product([True, False], repeat=10):
if i.count(False) == 10:
continue
t = 0
for j in range(N):... | false | 12.5 | [
"+# ใใใๅ
จๆข็ดข",
"+from itertools import product",
"+",
"-for i in range(1, 1024):",
"+for i in product([True, False], repeat=10):",
"+ if i.count(False) == 10:",
"+ continue",
"- c = 0",
"- for k in range(10):",
"- c += (i >> k & 1) & F[j][k]",
"- t += P[j]... | false | 0.053361 | 0.124015 | 0.430277 | [
"s795880217",
"s692350862"
] |
u757919796 | p03371 | python | s930566672 | s704850294 | 21 | 17 | 3,064 | 3,060 | Accepted | Accepted | 19.05 | a, b, c, x, y = tuple([int(i) for i in input().split()])
# ๅๅฅ่ฒทใ
p1 = a * x + b * y
# ใปใใ๏ผๆฎใใๅๅฅ
p2 = c * min(x, y) * 2 + (a * (x - y) if x > y else b * (y - x))
# ใปใใใฎใฟ
p3 = c*(x+y) * 2
p4 = c*max(x, y)*2
print((min(p1, p2, p3, p4))) | a, b, c, x, y = tuple([int(i) for i in input().split()])
# ๅๅฅ่ฒทใ
p1 = a * x + b * y
# ใปใใ๏ผๆฎใใๅๅฅ
p2 = c * min(x, y) * 2 + (a * (x - y) if x > y else b * (y - x))
# ใปใใใฎใฟ
p3 = c*max(x, y)*2
print((min(p1, p2, p3))) | 13 | 12 | 251 | 229 | a, b, c, x, y = tuple([int(i) for i in input().split()])
# ๅๅฅ่ฒทใ
p1 = a * x + b * y
# ใปใใ๏ผๆฎใใๅๅฅ
p2 = c * min(x, y) * 2 + (a * (x - y) if x > y else b * (y - x))
# ใปใใใฎใฟ
p3 = c * (x + y) * 2
p4 = c * max(x, y) * 2
print((min(p1, p2, p3, p4)))
| a, b, c, x, y = tuple([int(i) for i in input().split()])
# ๅๅฅ่ฒทใ
p1 = a * x + b * y
# ใปใใ๏ผๆฎใใๅๅฅ
p2 = c * min(x, y) * 2 + (a * (x - y) if x > y else b * (y - x))
# ใปใใใฎใฟ
p3 = c * max(x, y) * 2
print((min(p1, p2, p3)))
| false | 7.692308 | [
"-p3 = c * (x + y) * 2",
"-p4 = c * max(x, y) * 2",
"-print((min(p1, p2, p3, p4)))",
"+p3 = c * max(x, y) * 2",
"+print((min(p1, p2, p3)))"
] | false | 0.095298 | 0.094147 | 1.012231 | [
"s930566672",
"s704850294"
] |
u017415492 | p03786 | python | s531781755 | s345129504 | 102 | 91 | 20,500 | 20,364 | Accepted | Accepted | 10.78 | n=int(eval(input()))
a=list(map(int,input().split()))
wa=0
a.sort()
count=0
for i in range(n-1):
if 2*(wa+a[i])>=a[i+1]:
count+=1
else:
count=0
wa+=a[i]
print((count+1)) | n=int(eval(input()))
a=list(map(int,input().split()))
a.sort(reverse=True)
ssum=sum(a)
ans=1
for i in range(n):
ssum-=a[i]
if 2*ssum<a[i]:
break
else:
ans+=1
print(ans) | 12 | 12 | 186 | 187 | n = int(eval(input()))
a = list(map(int, input().split()))
wa = 0
a.sort()
count = 0
for i in range(n - 1):
if 2 * (wa + a[i]) >= a[i + 1]:
count += 1
else:
count = 0
wa += a[i]
print((count + 1))
| n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
ssum = sum(a)
ans = 1
for i in range(n):
ssum -= a[i]
if 2 * ssum < a[i]:
break
else:
ans += 1
print(ans)
| false | 0 | [
"-wa = 0",
"-a.sort()",
"-count = 0",
"-for i in range(n - 1):",
"- if 2 * (wa + a[i]) >= a[i + 1]:",
"- count += 1",
"+a.sort(reverse=True)",
"+ssum = sum(a)",
"+ans = 1",
"+for i in range(n):",
"+ ssum -= a[i]",
"+ if 2 * ssum < a[i]:",
"+ break",
"- count =... | false | 0.058996 | 0.079998 | 0.737471 | [
"s531781755",
"s345129504"
] |
u078042885 | p00992 | python | s040791242 | s915465988 | 30 | 20 | 7,648 | 7,652 | Accepted | Accepted | 33.33 | a=sorted([int(eval(input())) for _ in [0]*int(eval(input()))])
c=b=0
for i in range(len(a)-1,-1,-1):
if a[i]<c//4:continue
else:b+=a[i]-c//4
c+=1
print((b+1)) | a=sorted([int(eval(input())) for _ in [0]*int(eval(input()))])
c=b=0
for i in range(len(a)-1,-1,-1):
if a[i]>=c//4:b+=a[i]-c//4
c+=1
print((b+1)) | 7 | 6 | 162 | 144 | a = sorted([int(eval(input())) for _ in [0] * int(eval(input()))])
c = b = 0
for i in range(len(a) - 1, -1, -1):
if a[i] < c // 4:
continue
else:
b += a[i] - c // 4
c += 1
print((b + 1))
| a = sorted([int(eval(input())) for _ in [0] * int(eval(input()))])
c = b = 0
for i in range(len(a) - 1, -1, -1):
if a[i] >= c // 4:
b += a[i] - c // 4
c += 1
print((b + 1))
| false | 14.285714 | [
"- if a[i] < c // 4:",
"- continue",
"- else:",
"+ if a[i] >= c // 4:"
] | false | 0.035604 | 0.035704 | 0.997209 | [
"s040791242",
"s915465988"
] |
u254871849 | p03699 | python | s956432045 | s829185642 | 21 | 17 | 3,316 | 3,064 | Accepted | Accepted | 19.05 | import sys
n, *s = list(map(int, sys.stdin.read().split()))
def main():
res = sum(s)
if res % 10:
return res
else:
not_multiple_of_10 = [x for x in s if x % 10]
if not_multiple_of_10:
return res - min(not_multiple_of_10)
else:
return 0
... | import sys
n, *a = list(map(int, sys.stdin.read().split()))
def main():
s = sum(a)
if s % 10: ans = s
else:
m = min([101] + [x for x in a if x % 10])
if m == 101: ans = 0
else: ans = s - m
print(ans)
if __name__ == '__main__':
main() | 18 | 15 | 376 | 267 | import sys
n, *s = list(map(int, sys.stdin.read().split()))
def main():
res = sum(s)
if res % 10:
return res
else:
not_multiple_of_10 = [x for x in s if x % 10]
if not_multiple_of_10:
return res - min(not_multiple_of_10)
else:
return 0
if __name__... | import sys
n, *a = list(map(int, sys.stdin.read().split()))
def main():
s = sum(a)
if s % 10:
ans = s
else:
m = min([101] + [x for x in a if x % 10])
if m == 101:
ans = 0
else:
ans = s - m
print(ans)
if __name__ == "__main__":
main()
| false | 16.666667 | [
"-n, *s = list(map(int, sys.stdin.read().split()))",
"+n, *a = list(map(int, sys.stdin.read().split()))",
"- res = sum(s)",
"- if res % 10:",
"- return res",
"+ s = sum(a)",
"+ if s % 10:",
"+ ans = s",
"- not_multiple_of_10 = [x for x in s if x % 10]",
"- i... | false | 0.065759 | 0.036104 | 1.821385 | [
"s956432045",
"s829185642"
] |
u057109575 | p03087 | python | s634804703 | s689301987 | 654 | 403 | 69,080 | 78,056 | Accepted | Accepted | 38.38 | N, Q = list(map(int, input().split()))
S = eval(input())
X = [list(map(int, input().split())) for _ in range(Q)]
cnt = [0] * (N + 1)
for i in range(N - 1):
cnt[i + 1] = int(S[i] == "A" and S[i + 1] == "C") + cnt[i]
for l, r in X:
print((cnt[r - 1] - cnt[l - 1]))
|
N, Q = list(map(int, input().split()))
S = eval(input())
n = len(S)
ctr = [0] * n
for i in range(n):
if i > 0 and S[i - 1] == "A" and S[i] == "C":
ctr[i] = 1
cumsum = [0] * (n + 1)
for i in range(n):
cumsum[i + 1] = cumsum[i] + ctr[i]
for _ in range(Q):
l, r = list(map(int, input(... | 10 | 17 | 268 | 365 | N, Q = list(map(int, input().split()))
S = eval(input())
X = [list(map(int, input().split())) for _ in range(Q)]
cnt = [0] * (N + 1)
for i in range(N - 1):
cnt[i + 1] = int(S[i] == "A" and S[i + 1] == "C") + cnt[i]
for l, r in X:
print((cnt[r - 1] - cnt[l - 1]))
| N, Q = list(map(int, input().split()))
S = eval(input())
n = len(S)
ctr = [0] * n
for i in range(n):
if i > 0 and S[i - 1] == "A" and S[i] == "C":
ctr[i] = 1
cumsum = [0] * (n + 1)
for i in range(n):
cumsum[i + 1] = cumsum[i] + ctr[i]
for _ in range(Q):
l, r = list(map(int, input().split()))
pri... | false | 41.176471 | [
"-X = [list(map(int, input().split())) for _ in range(Q)]",
"-cnt = [0] * (N + 1)",
"-for i in range(N - 1):",
"- cnt[i + 1] = int(S[i] == \"A\" and S[i + 1] == \"C\") + cnt[i]",
"-for l, r in X:",
"- print((cnt[r - 1] - cnt[l - 1]))",
"+n = len(S)",
"+ctr = [0] * n",
"+for i in range(n):",
... | false | 0.109685 | 0.040292 | 2.722288 | [
"s634804703",
"s689301987"
] |
u620084012 | p03986 | python | s050738926 | s245399741 | 287 | 186 | 3,768 | 46,944 | Accepted | Accepted | 35.19 | X = eval(input())
A = ""
for x in X:
if x == "T" and A != "" and A[-1] == "S":
A = A[:-1]
else:
A = A + x
print((len(A)))
| from collections import deque
X = eval(input())
L = deque([])
for e in X:
if e == "T" and len(L) > 0 and L[-1] == "S":
L.pop()
else:
L.append(e)
print((len(L)))
| 10 | 10 | 149 | 187 | X = eval(input())
A = ""
for x in X:
if x == "T" and A != "" and A[-1] == "S":
A = A[:-1]
else:
A = A + x
print((len(A)))
| from collections import deque
X = eval(input())
L = deque([])
for e in X:
if e == "T" and len(L) > 0 and L[-1] == "S":
L.pop()
else:
L.append(e)
print((len(L)))
| false | 0 | [
"+from collections import deque",
"+",
"-A = \"\"",
"-for x in X:",
"- if x == \"T\" and A != \"\" and A[-1] == \"S\":",
"- A = A[:-1]",
"+L = deque([])",
"+for e in X:",
"+ if e == \"T\" and len(L) > 0 and L[-1] == \"S\":",
"+ L.pop()",
"- A = A + x",
"-print((len(A... | false | 0.043448 | 0.046199 | 0.940462 | [
"s050738926",
"s245399741"
] |
u417169160 | p03160 | python | s200506998 | s047502526 | 134 | 106 | 13,800 | 13,976 | Accepted | Accepted | 20.9 | N = int(eval(input()))
h = [int(i) for i in input().split()]
c = [0]*N
c[0]=0
c[1]=abs(h[1]-h[0])
for i in range(2,N):
c[i] = min(abs(h[i]-h[i-1])+c[i-1],abs(h[i]-h[i-2])+c[i-2])
print((c[N-1])) | def main():
N = int(eval(input()))
h = [int(i) for i in input().split()]
c = [0]*N
c[0]=0
c[1]=abs(h[1]-h[0])
for i in range(2,N):
c[i] = min(abs(h[i]-h[i-1])+c[i-1],abs(h[i]-h[i-2])+c[i-2])
print((c[N-1]))
main() | 10 | 13 | 201 | 256 | N = int(eval(input()))
h = [int(i) for i in input().split()]
c = [0] * N
c[0] = 0
c[1] = abs(h[1] - h[0])
for i in range(2, N):
c[i] = min(abs(h[i] - h[i - 1]) + c[i - 1], abs(h[i] - h[i - 2]) + c[i - 2])
print((c[N - 1]))
| def main():
N = int(eval(input()))
h = [int(i) for i in input().split()]
c = [0] * N
c[0] = 0
c[1] = abs(h[1] - h[0])
for i in range(2, N):
c[i] = min(abs(h[i] - h[i - 1]) + c[i - 1], abs(h[i] - h[i - 2]) + c[i - 2])
print((c[N - 1]))
main()
| false | 23.076923 | [
"-N = int(eval(input()))",
"-h = [int(i) for i in input().split()]",
"-c = [0] * N",
"-c[0] = 0",
"-c[1] = abs(h[1] - h[0])",
"-for i in range(2, N):",
"- c[i] = min(abs(h[i] - h[i - 1]) + c[i - 1], abs(h[i] - h[i - 2]) + c[i - 2])",
"-print((c[N - 1]))",
"+def main():",
"+ N = int(eval(inpu... | false | 0.035475 | 0.033392 | 1.062367 | [
"s200506998",
"s047502526"
] |
u588341295 | p03660 | python | s118744521 | s591670291 | 944 | 452 | 137,204 | 29,092 | Accepted | Accepted | 52.12 | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 9)
N = int(eval(input()))
nodes = [[] for _ in range(N+1)]
for i in range(N-1):
a, b = list(map(int, input().split()))
# nodes[ๅบ็บใใผใ](ๅฐ็ใใผใ, ใณในใ))
nodes[a].append((b, 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 ... | 40 | 55 | 920 | 1,420 | # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
sys.setrecursionlimit(10**9)
N = int(eval(input()))
nodes = [[] for _ in range(N + 1)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
# nodes[ๅบ็บใใผใ](ๅฐ็ใใผใ, ใณในใ))
nodes[a].append((b, 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 rang... | false | 27.272727 | [
"-sys.setrecursionlimit(10**9)",
"-N = int(eval(input()))",
"-nodes = [[] for _ in range(N + 1)]",
"-for i in range(N - 1):",
"- a, b = list(map(int, input().split()))",
"- # nodes[ๅบ็บใใผใ](ๅฐ็ใใผใ, ใณในใ))",
"- nodes[a].append((b, 1))",
"- # ็กๅใฐใฉใใชใฎใงใใฃใกใๅ
ฅใใ",
"- nodes[b].append((a, 1))",
... | false | 0.043622 | 0.040114 | 1.08745 | [
"s118744521",
"s591670291"
] |
u382748202 | p03127 | python | s060503857 | s078651714 | 835 | 81 | 15,020 | 14,252 | Accepted | Accepted | 90.3 | N = int(eval(input()))
A = list(map(int, input().split()))
ans = 10 ** 10
while min(A) != ans:
ans = min(A)
for i, a_i in enumerate(A):
if a_i > ans:
A[i] = a_i % ans
if A[i] == 0:
del A[i]
print(ans) | N = int(eval(input()))
A = list(map(int, input().split()))
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def gcd_arr(a):
ans = a[0]
for i, a_i in enumerate(a):
ans = gcd(ans, a_i)
return ans
print((gcd_arr(A))) | 13 | 17 | 264 | 269 | N = int(eval(input()))
A = list(map(int, input().split()))
ans = 10**10
while min(A) != ans:
ans = min(A)
for i, a_i in enumerate(A):
if a_i > ans:
A[i] = a_i % ans
if A[i] == 0:
del A[i]
print(ans)
| N = int(eval(input()))
A = list(map(int, input().split()))
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def gcd_arr(a):
ans = a[0]
for i, a_i in enumerate(a):
ans = gcd(ans, a_i)
return ans
print((gcd_arr(A)))
| false | 23.529412 | [
"-ans = 10**10",
"-while min(A) != ans:",
"- ans = min(A)",
"- for i, a_i in enumerate(A):",
"- if a_i > ans:",
"- A[i] = a_i % ans",
"- if A[i] == 0:",
"- del A[i]",
"-print(ans)",
"+",
"+",
"+def gcd(a, b):",
"+ if b == 0:",
"+ ... | false | 0.047409 | 0.039143 | 1.211169 | [
"s060503857",
"s078651714"
] |
u707498674 | p03805 | python | s784944812 | s139167162 | 29 | 26 | 3,064 | 3,064 | Accepted | Accepted | 10.34 | import itertools
N, M = list(map(int, input().split()))
E = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
E[a].append(b)
E[b].append(a)
count = 0
for V in itertools.permutations(list(range(1, N))):
if V[0] in E[0] and all(V[i] in E[... | from itertools import permutations
def int0(s):
return int(s) - 1
def main():
N, M = list(map(int, input().split()))
edges = [tuple(map(int0, input().split())) for _ in range(M)]
to = [[False]*N for _ in range(N)]
for a, b in edges:
to[a][b] = True
to[b][a] = True
... | 16 | 22 | 369 | 520 | import itertools
N, M = list(map(int, input().split()))
E = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
E[a].append(b)
E[b].append(a)
count = 0
for V in itertools.permutations(list(range(1, N))):
if V[0] in E[0] and all(V[i] in E[V[i - 1]] for ... | from itertools import permutations
def int0(s):
return int(s) - 1
def main():
N, M = list(map(int, input().split()))
edges = [tuple(map(int0, input().split())) for _ in range(M)]
to = [[False] * N for _ in range(N)]
for a, b in edges:
to[a][b] = True
to[b][a] = True
ans = 0
... | false | 27.272727 | [
"-import itertools",
"+from itertools import permutations",
"-N, M = list(map(int, input().split()))",
"-E = [[] for i in range(N)]",
"-for i in range(M):",
"- a, b = list(map(int, input().split()))",
"- a -= 1",
"- b -= 1",
"- E[a].append(b)",
"- E[b].append(a)",
"-count = 0",
... | false | 0.042109 | 0.095481 | 0.44102 | [
"s784944812",
"s139167162"
] |
u803848678 | p03262 | python | s725415774 | s865358337 | 322 | 105 | 23,124 | 16,280 | Accepted | Accepted | 67.39 | import math
import numpy as np
def yakusu(num):
top = []
bot = []
for i in range(int(math.sqrt(num))):
k = i+1
if num%k == 0:
top.append(num//k)
bot.append(k)
return top + bot[::-1]
n, X = list(map(int, input().split()))
x = list(map(int, input().spl... | from fractions import gcd
n, x = list(map(int, input().split()))
xi = list(map(int, input().split()))
ans = None
for i in xi:
distance = abs(i-x)
if ans is None:
ans = distance
else:
ans = gcd(ans, distance)
print(ans) | 33 | 13 | 630 | 260 | import math
import numpy as np
def yakusu(num):
top = []
bot = []
for i in range(int(math.sqrt(num))):
k = i + 1
if num % k == 0:
top.append(num // k)
bot.append(k)
return top + bot[::-1]
n, X = list(map(int, input().split()))
x = list(map(int, input().split()... | from fractions import gcd
n, x = list(map(int, input().split()))
xi = list(map(int, input().split()))
ans = None
for i in xi:
distance = abs(i - x)
if ans is None:
ans = distance
else:
ans = gcd(ans, distance)
print(ans)
| false | 60.606061 | [
"-import math",
"-import numpy as np",
"+from fractions import gcd",
"-",
"-def yakusu(num):",
"- top = []",
"- bot = []",
"- for i in range(int(math.sqrt(num))):",
"- k = i + 1",
"- if num % k == 0:",
"- top.append(num // k)",
"- bot.append(k)",
... | false | 0.29482 | 0.080555 | 3.659886 | [
"s725415774",
"s865358337"
] |
u981931040 | p03329 | python | s341420757 | s447342384 | 790 | 398 | 71,176 | 16,728 | Accepted | Accepted | 49.62 | import sys
sys.setrecursionlimit(10**6)
from functools import lru_cache
@lru_cache(maxsize=None)
def solve(val , now):
if val < 6 or now == 0:
ret_val = val
# ไฝใใใชใ
elif val < counts[now]:
ret_val = solve(val , now - 1)
# ไฝใใใชใ or ๆใๅ ใใใฎๅฐใใๆน
else:
ret_val = min(... | N = int(eval(input()))
dp = [0] * 10 ** 6
for i in range(1, N + 1):
power = 6
dp[i] = i
while power <= i:
dp[i] = min(dp[i], dp[i - power] + 1)
power *= 6
power = 9
while power <= i:
dp[i] = min(dp[i], dp[i - power] + 1)
power *= 9
print((dp[N])) | 27 | 13 | 656 | 302 | import sys
sys.setrecursionlimit(10**6)
from functools import lru_cache
@lru_cache(maxsize=None)
def solve(val, now):
if val < 6 or now == 0:
ret_val = val
# ไฝใใใชใ
elif val < counts[now]:
ret_val = solve(val, now - 1)
# ไฝใใใชใ or ๆใๅ ใใใฎๅฐใใๆน
else:
ret_val = min(solve(val, no... | N = int(eval(input()))
dp = [0] * 10**6
for i in range(1, N + 1):
power = 6
dp[i] = i
while power <= i:
dp[i] = min(dp[i], dp[i - power] + 1)
power *= 6
power = 9
while power <= i:
dp[i] = min(dp[i], dp[i - power] + 1)
power *= 9
print((dp[N]))
| false | 51.851852 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**6)",
"-from functools import lru_cache",
"-",
"-",
"-@lru_cache(maxsize=None)",
"-def solve(val, now):",
"- if val < 6 or now == 0:",
"- ret_val = val",
"- # ไฝใใใชใ",
"- elif val < counts[now]:",
"- ret_val = solve(val, no... | false | 0.07288 | 0.339721 | 0.21453 | [
"s341420757",
"s447342384"
] |
u204883389 | p02418 | python | s242715854 | s761368644 | 40 | 30 | 7,456 | 7,448 | Accepted | Accepted | 25 | s = eval(input())
p = eval(input())
s += s
if p in s:
print('Yes')
else:
print('No') | s = eval(input())
p = eval(input())
s *= 2
if s.find(p) != -1:
print("Yes")
else:
print("No") | 7 | 9 | 86 | 99 | s = eval(input())
p = eval(input())
s += s
if p in s:
print("Yes")
else:
print("No")
| s = eval(input())
p = eval(input())
s *= 2
if s.find(p) != -1:
print("Yes")
else:
print("No")
| false | 22.222222 | [
"-s += s",
"-if p in s:",
"+s *= 2",
"+if s.find(p) != -1:"
] | false | 0.038216 | 0.039782 | 0.960639 | [
"s242715854",
"s761368644"
] |
u133805688 | p03814 | python | s397334593 | s083401218 | 81 | 59 | 4,840 | 3,516 | Accepted | Accepted | 27.16 | S = list(eval(input()))
st = len(S)
ed = 0
for i in range(len(S)):
if (S[i] == 'A'):
st = min(i, st)
if (S[i] == 'Z'):
ed = i
ans = ed - st + 1
print(ans) | s = eval(input())
p = -1
for i in range(len(s)) :
if s[i] == 'A' and p == -1:
p = i
if s[i] == 'Z':
q = i
print((q - p + 1))
| 10 | 10 | 181 | 156 | S = list(eval(input()))
st = len(S)
ed = 0
for i in range(len(S)):
if S[i] == "A":
st = min(i, st)
if S[i] == "Z":
ed = i
ans = ed - st + 1
print(ans)
| s = eval(input())
p = -1
for i in range(len(s)):
if s[i] == "A" and p == -1:
p = i
if s[i] == "Z":
q = i
print((q - p + 1))
| false | 0 | [
"-S = list(eval(input()))",
"-st = len(S)",
"-ed = 0",
"-for i in range(len(S)):",
"- if S[i] == \"A\":",
"- st = min(i, st)",
"- if S[i] == \"Z\":",
"- ed = i",
"-ans = ed - st + 1",
"-print(ans)",
"+s = eval(input())",
"+p = -1",
"+for i in range(len(s)):",
"+ if s... | false | 0.031718 | 0.044524 | 0.712381 | [
"s397334593",
"s083401218"
] |
u323045245 | p02658 | python | s275654326 | s466064540 | 89 | 53 | 84,572 | 21,664 | Accepted | Accepted | 40.45 | n=int(eval(input()))
a=list(map(int, input().split()))
ans = 1
if a.count(0)>0:
print((0))
exit()
for i in range(n):
l = len(str(ans))
L = len(str(a[i]))
if a[i] > 10**18:
print((-1))
exit()
elif l+L > 20:
print((-1))
exit()
ans *= a[i]
if ... | n = int(eval(input()))
l= list(map(int,input().split()))
if 0 in l:
print((0))
exit()
ans = 1
for i in l:
ans *= i
if ans > 10**18:
print((-1))
exit()
print(ans) | 20 | 12 | 368 | 178 | n = int(eval(input()))
a = list(map(int, input().split()))
ans = 1
if a.count(0) > 0:
print((0))
exit()
for i in range(n):
l = len(str(ans))
L = len(str(a[i]))
if a[i] > 10**18:
print((-1))
exit()
elif l + L > 20:
print((-1))
exit()
ans *= a[i]
if ans > 10... | n = int(eval(input()))
l = list(map(int, input().split()))
if 0 in l:
print((0))
exit()
ans = 1
for i in l:
ans *= i
if ans > 10**18:
print((-1))
exit()
print(ans)
| false | 40 | [
"-a = list(map(int, input().split()))",
"-ans = 1",
"-if a.count(0) > 0:",
"+l = list(map(int, input().split()))",
"+if 0 in l:",
"-for i in range(n):",
"- l = len(str(ans))",
"- L = len(str(a[i]))",
"- if a[i] > 10**18:",
"- print((-1))",
"- exit()",
"- elif l + L > ... | false | 0.038822 | 0.007062 | 5.49756 | [
"s275654326",
"s466064540"
] |
u633068244 | p01522 | python | s840269585 | s562365455 | 30 | 20 | 4,336 | 4,336 | Accepted | Accepted | 33.33 | n,k = list(map(int,input().split()))
boats = [list(map(int,input().split())) for i in range(k)]
r = eval(input())
hate = [list(map(int,input().split())) for i in range(r)]
blue = [0]*51
for i,j in hate:
for boat in boats:
if i in boat[1:] and j in boat[1:]:
blue[i] = 1
blue[j] = 1
print(sum(blue)) | n,k = list(map(int,input().split()))
boats = [list(map(int,input().split()))[1:] for i in range(k)]
r = eval(input())
hate = [list(map(int,input().split())) for i in range(r)]
blue = [0]*51
for i,j in hate:
for boat in boats:
if i in boat and j in boat:
blue[i] = 1
blue[j] = 1
print(sum(blue)) | 11 | 11 | 304 | 300 | n, k = list(map(int, input().split()))
boats = [list(map(int, input().split())) for i in range(k)]
r = eval(input())
hate = [list(map(int, input().split())) for i in range(r)]
blue = [0] * 51
for i, j in hate:
for boat in boats:
if i in boat[1:] and j in boat[1:]:
blue[i] = 1
blue[j]... | n, k = list(map(int, input().split()))
boats = [list(map(int, input().split()))[1:] for i in range(k)]
r = eval(input())
hate = [list(map(int, input().split())) for i in range(r)]
blue = [0] * 51
for i, j in hate:
for boat in boats:
if i in boat and j in boat:
blue[i] = 1
blue[j] = 1... | false | 0 | [
"-boats = [list(map(int, input().split())) for i in range(k)]",
"+boats = [list(map(int, input().split()))[1:] for i in range(k)]",
"- if i in boat[1:] and j in boat[1:]:",
"+ if i in boat and j in boat:"
] | false | 0.038975 | 0.046092 | 0.845608 | [
"s840269585",
"s562365455"
] |
u475584892 | p02936 | python | s337029198 | s511346396 | 1,689 | 1,132 | 98,244 | 141,684 | Accepted | Accepted | 32.98 | def slove():
import sys
import collections
input = sys.stdin.readline
n, qq = list(map(int, input().rstrip('\n').split()))
ls = collections.defaultdict(list)
ls[1]
for i in range(n-1):
a, b = list(map(int, input().rstrip('\n').split()))
ls[a] += [b]
ls[b] ... | def slove():
import sys
import collections
input = sys.stdin.readline
n, q = list(map(int, input().rstrip('\n').split()))
d = collections.defaultdict(list)
for i in range(n-1):
a, b = list(map(int, input().rstrip('\n').split()))
d[a] += [b]
d[b] += [a]
sco... | 36 | 35 | 856 | 928 | def slove():
import sys
import collections
input = sys.stdin.readline
n, qq = list(map(int, input().rstrip("\n").split()))
ls = collections.defaultdict(list)
ls[1]
for i in range(n - 1):
a, b = list(map(int, input().rstrip("\n").split()))
ls[a] += [b]
ls[b] += [a]
... | def slove():
import sys
import collections
input = sys.stdin.readline
n, q = list(map(int, input().rstrip("\n").split()))
d = collections.defaultdict(list)
for i in range(n - 1):
a, b = list(map(int, input().rstrip("\n").split()))
d[a] += [b]
d[b] += [a]
score = coll... | false | 2.777778 | [
"- n, qq = list(map(int, input().rstrip(\"\\n\").split()))",
"- ls = collections.defaultdict(list)",
"- ls[1]",
"+ n, q = list(map(int, input().rstrip(\"\\n\").split()))",
"+ d = collections.defaultdict(list)",
"- ls[a] += [b]",
"- ls[b] += [a]",
"- ans = [0] * n",
"-... | false | 0.079709 | 0.040439 | 1.971101 | [
"s337029198",
"s511346396"
] |
u151625340 | p02936 | python | s003540959 | s039127637 | 1,861 | 1,701 | 105,236 | 232,984 | Accepted | Accepted | 8.6 | from collections import deque
N,Q = list(map(int, input().split()))
G = [[] for _ in range(N)]
count = [0]*N
for i in range(N-1):
a,b = list(map(int, input().split()))
G[a-1].append(b-1)
G[b-1].append(a-1)
for i in range(Q):
p,x = list(map(int, input().split()))
count[p-1]+=x
q = deque([0... | import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # ๆๅญๅใฎๅ
ฅๅใฎใจใ'/n'ใพใงๅใๅใใฎใงๆณจๆ!!!
sys.setrecursionlimit(500000)
N,Q = list(map(int,input().split()))
d = [[] for i in range(N)]
for i in range(N-1):
a,b = list(m... | 22 | 27 | 497 | 641 | from collections import deque
N, Q = list(map(int, input().split()))
G = [[] for _ in range(N)]
count = [0] * N
for i in range(N - 1):
a, b = list(map(int, input().split()))
G[a - 1].append(b - 1)
G[b - 1].append(a - 1)
for i in range(Q):
p, x = list(map(int, input().split()))
count[p - 1] += x
q =... | import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # ๆๅญๅใฎๅ
ฅๅใฎใจใ'/n'ใพใงๅใๅใใฎใงๆณจๆ!!!
sys.setrecursionlimit(500000)
N, Q = list(map(int, input().split()))
d = [[] for i in range(N)]
for i in range(N - 1):
a, b = list(map(... | false | 18.518519 | [
"-from collections import deque",
"+import sys, copy, math, heapq, bisect",
"+from itertools import accumulate",
"+from collections import deque, defaultdict, Counter",
"+input = sys.stdin.readline # ๆๅญๅใฎๅ
ฅๅใฎใจใ'/n'ใพใงๅใๅใใฎใงๆณจๆ!!!",
"+sys.setrecursionlimit(500000)",
"-G = [[] for _ in range(N)]",
"-count... | false | 0.120358 | 0.162436 | 0.740958 | [
"s003540959",
"s039127637"
] |
u559367141 | p02629 | python | s705330900 | s204280288 | 31 | 27 | 9,072 | 9,020 | Accepted | Accepted | 12.9 | n = int(eval(input()))
chars = "Xabcdefghijklmnopqrstuvwxyz"
n_rem = n
res = ""
while True:
x = n_rem % 26
if x == 0:
x = 26
res += chars[x]
n_rem -= x
if n_rem == 0:
break
n_rem //= 26
print((res[::-1])) | N = int(eval(input()))
chars = "Xabcdefghijklmnopqrstuvwxyz"
result = ""
n_1 = N
while True:
x = n_1 % 26
if x == 0:
x = 26
result += chars[x]
n_1 -= x
if n_1 == 0:
break
n_1 //= 26
print((result[::-1]))
| 24 | 21 | 284 | 263 | n = int(eval(input()))
chars = "Xabcdefghijklmnopqrstuvwxyz"
n_rem = n
res = ""
while True:
x = n_rem % 26
if x == 0:
x = 26
res += chars[x]
n_rem -= x
if n_rem == 0:
break
n_rem //= 26
print((res[::-1]))
| N = int(eval(input()))
chars = "Xabcdefghijklmnopqrstuvwxyz"
result = ""
n_1 = N
while True:
x = n_1 % 26
if x == 0:
x = 26
result += chars[x]
n_1 -= x
if n_1 == 0:
break
n_1 //= 26
print((result[::-1]))
| false | 12.5 | [
"-n = int(eval(input()))",
"+N = int(eval(input()))",
"-n_rem = n",
"-res = \"\"",
"+result = \"\"",
"+n_1 = N",
"- x = n_rem % 26",
"+ x = n_1 % 26",
"- res += chars[x]",
"- n_rem -= x",
"- if n_rem == 0:",
"+ result += chars[x]",
"+ n_1 -= x",
"+ if n_1 == 0:",
... | false | 0.034528 | 0.034229 | 1.008751 | [
"s705330900",
"s204280288"
] |
u905203728 | p02580 | python | s342399822 | s648253522 | 577 | 518 | 169,200 | 130,180 | Accepted | Accepted | 10.23 | h,w,m=list(map(int,input().split()))
HW=[list(map(int,input().split())) for _ in range(m)]
H,W=[0 for _ in range(h)],[0 for _ in range(w)]
for i,j in HW:
i,j=i-1,j-1
H[i] +=1
W[j] +=1
max_h,max_w=max(H),max(W)
ans=max_h+max_w
cnt=H.count(max_h)*W.count(max_w)
for i,j in HW:
if H[i-1]==max... | h,w,m=list(map(int,input().split()))
HW=[list(map(int,input().split())) for _ in range(m)]
H,W=[0]*h,[0]*w
for i,j in HW:
H[i-1] +=1
W[j-1] +=1
max_h,max_w=max(H),max(W)
ans=max_h+max_w
cnt=H.count(max_h)*W.count(max_w)
for i,j in HW:
if H[i-1]==max_h and W[j-1]==max_w:
cnt -=1
print... | 16 | 15 | 385 | 340 | h, w, m = list(map(int, input().split()))
HW = [list(map(int, input().split())) for _ in range(m)]
H, W = [0 for _ in range(h)], [0 for _ in range(w)]
for i, j in HW:
i, j = i - 1, j - 1
H[i] += 1
W[j] += 1
max_h, max_w = max(H), max(W)
ans = max_h + max_w
cnt = H.count(max_h) * W.count(max_w)
for i, j in H... | h, w, m = list(map(int, input().split()))
HW = [list(map(int, input().split())) for _ in range(m)]
H, W = [0] * h, [0] * w
for i, j in HW:
H[i - 1] += 1
W[j - 1] += 1
max_h, max_w = max(H), max(W)
ans = max_h + max_w
cnt = H.count(max_h) * W.count(max_w)
for i, j in HW:
if H[i - 1] == max_h and W[j - 1] == ... | false | 6.25 | [
"-H, W = [0 for _ in range(h)], [0 for _ in range(w)]",
"+H, W = [0] * h, [0] * w",
"- i, j = i - 1, j - 1",
"- H[i] += 1",
"- W[j] += 1",
"+ H[i - 1] += 1",
"+ W[j - 1] += 1"
] | false | 0.03957 | 0.037753 | 1.048139 | [
"s342399822",
"s648253522"
] |
u179169725 | p03283 | python | s643338071 | s576727676 | 1,471 | 575 | 20,276 | 59,356 | Accepted | Accepted | 60.91 | # https://atcoder.jp/contests/abc106/tasks/abc106_d
# ไฝใ่ฆใใซใใ็ดใใฆใฟใ
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
N, M, Q = read_ints()
# ๅ่ปใไบๆฌกๅ
ๅบงๆจใซไปฃๅ
ฅ
table = [[0] * N for _ in range(N)] # ้ฝๅธใฏใใใใ-1ๆฑใ
for _ in range(M)... | # https://atcoder.jp/contests/abc106/tasks/abc106_d
# ไฝใ่ฆใใซใใ็ดใใฆใฟใ
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
class cumsum2d: # ไบๆฌกๅ
็ดฏ็ฉๅใฏใฉใน pypyใงใไฝฟใใใ
def __init__(self, ls: list):
'''
2ๆฌกๅ
ใฎใชในใใๅใๅใ... | 32 | 58 | 704 | 1,471 | # https://atcoder.jp/contests/abc106/tasks/abc106_d
# ไฝใ่ฆใใซใใ็ดใใฆใฟใ
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
N, M, Q = read_ints()
# ๅ่ปใไบๆฌกๅ
ๅบงๆจใซไปฃๅ
ฅ
table = [[0] * N for _ in range(N)] # ้ฝๅธใฏใใใใ-1ๆฑใ
for _ in range(M):
L, R = read... | # https://atcoder.jp/contests/abc106/tasks/abc106_d
# ไฝใ่ฆใใซใใ็ดใใฆใฟใ
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
class cumsum2d: # ไบๆฌกๅ
็ดฏ็ฉๅใฏใฉใน pypyใงใไฝฟใใใ
def __init__(self, ls: list):
"""
2ๆฌกๅ
ใฎใชในใใๅใๅใ
"""
... | false | 44.827586 | [
"+class cumsum2d: # ไบๆฌกๅ
็ดฏ็ฉๅใฏใฉใน pypyใงใไฝฟใใใ",
"+ def __init__(self, ls: list):",
"+ \"\"\"",
"+ 2ๆฌกๅ
ใฎใชในใใๅใๅใ",
"+ \"\"\"",
"+ from itertools import product",
"+",
"+ H = len(ls)",
"+ W = len(ls[0])",
"+ self.ls_accum = [[0] * (W + 1)]",
"+ ... | false | 0.385581 | 0.084458 | 4.565348 | [
"s643338071",
"s576727676"
] |
u606045429 | p03639 | python | s101446830 | s392854782 | 65 | 52 | 14,252 | 11,096 | Accepted | Accepted | 20 | N = int(eval(input()))
A = [int(i) for i in input().split()]
f, t = 0, 0
for a in A:
if a % 4 == 0:
f += 1
elif a % 2 == 0:
t += 1
if N - f - t <= f + (t == 0):
print("Yes")
else:
print("No")
| N = int(eval(input()))
A = [int(i) % 4 for i in input().split()]
f, t = A.count(0), A.count(2)
if N - f - t <= f + (t == 0):
print("Yes")
else:
print("No")
| 14 | 8 | 233 | 166 | N = int(eval(input()))
A = [int(i) for i in input().split()]
f, t = 0, 0
for a in A:
if a % 4 == 0:
f += 1
elif a % 2 == 0:
t += 1
if N - f - t <= f + (t == 0):
print("Yes")
else:
print("No")
| N = int(eval(input()))
A = [int(i) % 4 for i in input().split()]
f, t = A.count(0), A.count(2)
if N - f - t <= f + (t == 0):
print("Yes")
else:
print("No")
| false | 42.857143 | [
"-A = [int(i) for i in input().split()]",
"-f, t = 0, 0",
"-for a in A:",
"- if a % 4 == 0:",
"- f += 1",
"- elif a % 2 == 0:",
"- t += 1",
"+A = [int(i) % 4 for i in input().split()]",
"+f, t = A.count(0), A.count(2)"
] | false | 0.040588 | 0.042606 | 0.952625 | [
"s101446830",
"s392854782"
] |
u562016607 | p02975 | python | s441395881 | s248187234 | 217 | 61 | 60,784 | 14,212 | Accepted | Accepted | 71.89 | N=int(eval(input()))
a=[int(i) for i in input().split()]
b=list(set(a))
if len(b)==1:
if b[0]==0:
print("Yes")
else:
print("No")
else:
if N%3==0 and len(b)==3:
D={b[0]:0,b[1]:0,b[2]:0}
for i in range(N):
D[a[i]]+=1
if D[b[0]]==D[b[1]] and D[b[... | N=int(eval(input()))
A=[int(i) for i in input().split()]
tmp=0
for i in range(N):
tmp=tmp^A[i]
if tmp==0:
print("Yes")
else:
print("No")
| 36 | 9 | 966 | 151 | N = int(eval(input()))
a = [int(i) for i in input().split()]
b = list(set(a))
if len(b) == 1:
if b[0] == 0:
print("Yes")
else:
print("No")
else:
if N % 3 == 0 and len(b) == 3:
D = {b[0]: 0, b[1]: 0, b[2]: 0}
for i in range(N):
D[a[i]] += 1
if D[b[0]] == D[... | N = int(eval(input()))
A = [int(i) for i in input().split()]
tmp = 0
for i in range(N):
tmp = tmp ^ A[i]
if tmp == 0:
print("Yes")
else:
print("No")
| false | 75 | [
"-a = [int(i) for i in input().split()]",
"-b = list(set(a))",
"-if len(b) == 1:",
"- if b[0] == 0:",
"- print(\"Yes\")",
"- else:",
"- print(\"No\")",
"+A = [int(i) for i in input().split()]",
"+tmp = 0",
"+for i in range(N):",
"+ tmp = tmp ^ A[i]",
"+if tmp == 0:",
"... | false | 0.119188 | 0.110413 | 1.079467 | [
"s441395881",
"s248187234"
] |
u334712262 | p03090 | python | s306095168 | s062336165 | 61 | 45 | 7,216 | 5,980 | Accepted | Accepted | 26.23 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, produc... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, produc... | 82 | 73 | 1,493 | 1,346 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permut... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permut... | false | 10.97561 | [
"- E = []",
"- for i in range(1, N + 1):",
"- for j in range(i + 1, N + 1):",
"- if N % 2 == 0 and i + j == N + 1:",
"- continue",
"- if N % 2 == 1 and i + j == N:",
"- continue",
"- E.append((i, j))",
"- return E",
"+ ... | false | 0.076098 | 0.076029 | 1.000912 | [
"s306095168",
"s062336165"
] |
u462329577 | p03779 | python | s978984432 | s302024400 | 19 | 17 | 3,188 | 2,940 | Accepted | Accepted | 10.53 | #!/usr/bin/env python3
n = int(eval(input()))
#for i in range(10**5):
for i in range(int((2*n)**(1/2))-1,int((2*n)**(1/2))+2) :
if n <= i*(i+1)/2:
print(i)
break | #!/usr/bin/env python3
n = int(eval(input()))
#for i in range(10**5):
s = int((2*n)**(1/2))
for i in range(s-1,s+2):
if n <= i*(i+1)/2:
print(i)
break | 7 | 8 | 182 | 172 | #!/usr/bin/env python3
n = int(eval(input()))
# for i in range(10**5):
for i in range(int((2 * n) ** (1 / 2)) - 1, int((2 * n) ** (1 / 2)) + 2):
if n <= i * (i + 1) / 2:
print(i)
break
| #!/usr/bin/env python3
n = int(eval(input()))
# for i in range(10**5):
s = int((2 * n) ** (1 / 2))
for i in range(s - 1, s + 2):
if n <= i * (i + 1) / 2:
print(i)
break
| false | 12.5 | [
"-for i in range(int((2 * n) ** (1 / 2)) - 1, int((2 * n) ** (1 / 2)) + 2):",
"+s = int((2 * n) ** (1 / 2))",
"+for i in range(s - 1, s + 2):"
] | false | 0.038959 | 0.043155 | 0.902775 | [
"s978984432",
"s302024400"
] |
u893063840 | p02982 | python | s228678870 | s657630304 | 20 | 18 | 3,064 | 3,064 | Accepted | Accepted | 10 | n, d = list(map(int, input().split()))
x = [list(map(int, input().split())) for _ in range(n)]
def dist(a, b):
sm = 0
for ea, eb in zip(a, b):
sm += (ea - eb) ** 2
return sm ** 0.5
ans = 0
for i in range(n):
for j in range(i + 1, n):
dst = dist(x[i], x[j])
fo... | n, d = list(map(int, input().split()))
x = [list(map(int, input().split())) for _ in range(n)]
def dist(a, b):
sm = 0
for ea, eb in zip(a, b):
sm += (ea - eb) ** 2
return sm
ans = 0
for i in range(n):
for j in range(i + 1, n):
dst = dist(x[i], x[j])
for k in ... | 22 | 22 | 440 | 436 | n, d = list(map(int, input().split()))
x = [list(map(int, input().split())) for _ in range(n)]
def dist(a, b):
sm = 0
for ea, eb in zip(a, b):
sm += (ea - eb) ** 2
return sm**0.5
ans = 0
for i in range(n):
for j in range(i + 1, n):
dst = dist(x[i], x[j])
for k in range(int(16... | n, d = list(map(int, input().split()))
x = [list(map(int, input().split())) for _ in range(n)]
def dist(a, b):
sm = 0
for ea, eb in zip(a, b):
sm += (ea - eb) ** 2
return sm
ans = 0
for i in range(n):
for j in range(i + 1, n):
dst = dist(x[i], x[j])
for k in range(int(dst**0.... | false | 0 | [
"- return sm**0.5",
"+ return sm",
"- for k in range(int(16000**0.5) + 1):",
"- if k == dst:",
"+ for k in range(int(dst**0.5) + 1):",
"+ if k**2 == dst:"
] | false | 0.04282 | 0.036401 | 1.176351 | [
"s228678870",
"s657630304"
] |
u727148417 | p02735 | python | s155597755 | s166131735 | 195 | 29 | 12,512 | 3,064 | Accepted | Accepted | 85.13 | import numpy as np
H, W = list(map(int, input().split()))
masu = [eval(input()) for i in range(H)]
#temp = [list(input().replace("#","0").replace(".","1")) for i in range(H)]
#masu = [[int(temp[i][j]) for j in range(W)] for i in range(H)]
dp = np.zeros((H, W))
if masu[0][0] == "#":
dp[0][0] = 1
for i ... | #import numpy as np
H, W = list(map(int, input().split()))
masu = [eval(input()) for i in range(H)]
#temp = [list(input().replace("#","0").replace(".","1")) for i in range(H)]
#masu = [[int(temp[i][j]) for j in range(W)] for i in range(H)]
#dp = np.zeros((H, W))
dp = [[0]*W for i in range(H)]
if masu[0][0] =... | 30 | 31 | 861 | 895 | import numpy as np
H, W = list(map(int, input().split()))
masu = [eval(input()) for i in range(H)]
# temp = [list(input().replace("#","0").replace(".","1")) for i in range(H)]
# masu = [[int(temp[i][j]) for j in range(W)] for i in range(H)]
dp = np.zeros((H, W))
if masu[0][0] == "#":
dp[0][0] = 1
for i in range(0,... | # import numpy as np
H, W = list(map(int, input().split()))
masu = [eval(input()) for i in range(H)]
# temp = [list(input().replace("#","0").replace(".","1")) for i in range(H)]
# masu = [[int(temp[i][j]) for j in range(W)] for i in range(H)]
# dp = np.zeros((H, W))
dp = [[0] * W for i in range(H)]
if masu[0][0] == "#"... | false | 3.225806 | [
"-import numpy as np",
"-",
"+# import numpy as np",
"-dp = np.zeros((H, W))",
"+# dp = np.zeros((H, W))",
"+dp = [[0] * W for i in range(H)]"
] | false | 0.465186 | 0.043513 | 10.690866 | [
"s155597755",
"s166131735"
] |
u588341295 | p03575 | python | s610126757 | s982219520 | 27 | 23 | 3,064 | 3,424 | Accepted | Accepted | 14.81 | # -*- coding: utf-8 -*-
N, M = list(map(int, input().split()))
# ๅ
ฅๅๅคใฎ้ ็นใใข(่พบ)ใๆ ผ็ดใใ้
ๅ
a = [0] * 50
b = [0] * 50
# ้ ็นใใขใ้ฃๆฅใใฆใใใใฉใใใๆ ผ็ดใใ้
ๅ
graph = [[False for i in range(50)] for j in range(50)]
# ใใ้ ็นใ่จชๅๆธใใฉใใใๆ ผ็ดใใ้
ๅ
visited = [False] * N
# ๅ
ฅๅๅคใฎ้ ็นใใข(่พบ)ใๆ ผ็ดใใฆใใใซใผใ
for i in range(M):
a[i], b[i] = list(map... | # -*- coding: utf-8 -*-
import sys
from collections import deque
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... | 60 | 56 | 1,402 | 1,456 | # -*- coding: utf-8 -*-
N, M = list(map(int, input().split()))
# ๅ
ฅๅๅคใฎ้ ็นใใข(่พบ)ใๆ ผ็ดใใ้
ๅ
a = [0] * 50
b = [0] * 50
# ้ ็นใใขใ้ฃๆฅใใฆใใใใฉใใใๆ ผ็ดใใ้
ๅ
graph = [[False for i in range(50)] for j in range(50)]
# ใใ้ ็นใ่จชๅๆธใใฉใใใๆ ผ็ดใใ้
ๅ
visited = [False] * N
# ๅ
ฅๅๅคใฎ้ ็นใใข(่พบ)ใๆ ผ็ดใใฆใใใซใผใ
for i in range(M):
a[i], b[i] = list(map(int, input().spl... | # -*- coding: utf-8 -*-
import sys
from collections import deque
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 fo... | false | 6.666667 | [
"-N, M = list(map(int, input().split()))",
"-# ๅ
ฅๅๅคใฎ้ ็นใใข(่พบ)ใๆ ผ็ดใใ้
ๅ",
"-a = [0] * 50",
"-b = [0] * 50",
"-# ้ ็นใใขใ้ฃๆฅใใฆใใใใฉใใใๆ ผ็ดใใ้
ๅ",
"-graph = [[False for i in range(50)] for j in range(50)]",
"-# ใใ้ ็นใ่จชๅๆธใใฉใใใๆ ผ็ดใใ้
ๅ",
"-visited = [False] * N",
"-# ๅ
ฅๅๅคใฎ้ ็นใใข(่พบ)ใๆ ผ็ดใใฆใใใซใผใ",
"+import sys",
"+from col... | false | 0.079651 | 0.04053 | 1.965226 | [
"s610126757",
"s982219520"
] |
u562935282 | p03128 | python | s993129697 | s939732654 | 1,549 | 62 | 197,340 | 3,436 | Accepted | Accepted | 96 | import sys
sys.setrecursionlimit(10 ** 6)
inf = 10 ** 4
def larger(x, y):
lx, ly = len(x), len(y)
if lx > ly:
return x
elif lx < ly:
return y
else:
x.sort(reverse=True)
y.sort(reverse=True)
for xx, yy in zip(x, y):
if xx > yy:
... | from operator import itemgetter
inf = 10 ** 4
n, m = list(map(int, input().split()))
a = tuple(map(int, input().split()))
use = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]
# use[i] : ๆฐๅญiใไฝใใฎใซๅฟ
่ฆใชใใใใฎๆฌๆฐ
use_num = {use[i]: i for i in range(1, 10) if i in a}
use_num = tuple(sorted(use_num.items()))
# ๆฌๆฐๆ้
# print(us... | 66 | 39 | 1,319 | 853 | import sys
sys.setrecursionlimit(10**6)
inf = 10**4
def larger(x, y):
lx, ly = len(x), len(y)
if lx > ly:
return x
elif lx < ly:
return y
else:
x.sort(reverse=True)
y.sort(reverse=True)
for xx, yy in zip(x, y):
if xx > yy:
return x
... | from operator import itemgetter
inf = 10**4
n, m = list(map(int, input().split()))
a = tuple(map(int, input().split()))
use = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]
# use[i] : ๆฐๅญiใไฝใใฎใซๅฟ
่ฆใชใใใใฎๆฌๆฐ
use_num = {use[i]: i for i in range(1, 10) if i in a}
use_num = tuple(sorted(use_num.items()))
# ๆฌๆฐๆ้
# print(use_num)
dp = [-inf]... | false | 40.909091 | [
"-import sys",
"+from operator import itemgetter",
"-sys.setrecursionlimit(10**6)",
"-",
"-",
"-def larger(x, y):",
"- lx, ly = len(x), len(y)",
"- if lx > ly:",
"- return x",
"- elif lx < ly:",
"- return y",
"- else:",
"- x.sort(reverse=True)",
"- y... | false | 0.040914 | 0.043699 | 0.936273 | [
"s993129697",
"s939732654"
] |
u111365362 | p03038 | python | s940673731 | s476289089 | 848 | 731 | 42,452 | 42,452 | Accepted | Accepted | 13.8 | n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
p = [[aa,1] for aa in a]
for _ in range(m):
b = list(map(int,input().split()))
b.reverse()
p.append(b)
p.sort()
p.reverse()
rest = n
score = 0
for pp in p:
use = min(pp[1],rest)
rest -= use
score += pp[0] * use
print(scor... | n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
p = [[aa,1] for aa in a]
for _ in range(m):
b = list(map(int,input().split()))
b.reverse()
p.append(b)
p.sort()
p.reverse()
rest = n
score = 0
for pp in p:
use = min(pp[1],rest)
rest -= use
score += pp[0] * use
if rest=... | 16 | 17 | 316 | 337 | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
p = [[aa, 1] for aa in a]
for _ in range(m):
b = list(map(int, input().split()))
b.reverse()
p.append(b)
p.sort()
p.reverse()
rest = n
score = 0
for pp in p:
use = min(pp[1], rest)
rest -= use
score += pp[0] * use
print(s... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
p = [[aa, 1] for aa in a]
for _ in range(m):
b = list(map(int, input().split()))
b.reverse()
p.append(b)
p.sort()
p.reverse()
rest = n
score = 0
for pp in p:
use = min(pp[1], rest)
rest -= use
score += pp[0] * use
if ... | false | 5.882353 | [
"+ if rest == 0:",
"+ break"
] | false | 0.064096 | 0.036635 | 1.74956 | [
"s940673731",
"s476289089"
] |
u250664216 | p02948 | python | s220735737 | s206763106 | 593 | 442 | 26,708 | 26,872 | Accepted | Accepted | 25.46 | import heapq
n,m = list(map(int, input().split()))
job_list = []
for i in range(n):
a,b = list(map(int, input().split()))
job_list.append((a,b))
job_list.sort(key=lambda x:x[0])
# print(job_list)
hq = []
max_income = 0
j = 0
for i in range(1,m+1):
while j < n and job_list[j][0] <= i:
... | import sys
import heapq
input = sys.stdin.readline
n,m = list(map(int, input().split()))
job_list = []
for i in range(n):
a,b = list(map(int, input().split()))
job_list.append((a,b))
job_list.sort(key=lambda x:x[0])
# print(job_list)
hq = []
max_income = 0
j = 0
for i in range(1,m+1):
while ... | 22 | 24 | 494 | 534 | import heapq
n, m = list(map(int, input().split()))
job_list = []
for i in range(n):
a, b = list(map(int, input().split()))
job_list.append((a, b))
job_list.sort(key=lambda x: x[0])
# print(job_list)
hq = []
max_income = 0
j = 0
for i in range(1, m + 1):
while j < n and job_list[j][0] <= i:
heapq.h... | import sys
import heapq
input = sys.stdin.readline
n, m = list(map(int, input().split()))
job_list = []
for i in range(n):
a, b = list(map(int, input().split()))
job_list.append((a, b))
job_list.sort(key=lambda x: x[0])
# print(job_list)
hq = []
max_income = 0
j = 0
for i in range(1, m + 1):
while j < n an... | false | 8.333333 | [
"+import sys",
"+input = sys.stdin.readline"
] | false | 0.042161 | 0.043463 | 0.970035 | [
"s220735737",
"s206763106"
] |
u347640436 | p02660 | python | s167450477 | s246457709 | 110 | 70 | 9,224 | 9,216 | Accepted | Accepted | 36.36 | from math import sqrt
def prime_factorize(n):
result = []
for i in range(2, int(sqrt(n)) + 1):
if n % i != 0:
continue
t = 0
while n % i == 0:
n //= i
t += 1
result.append((i, t))
if n == 1:
break
if n !... | from math import sqrt
def prime_factorize(n):
result = []
if n % 2 == 0:
t = 0
while n % 2 == 0:
n //= 2
t += 1
result.append((2, t))
for i in range(3, int(sqrt(n)) + 1, 2):
if n % i != 0:
continue
t = 0
whi... | 30 | 36 | 542 | 679 | from math import sqrt
def prime_factorize(n):
result = []
for i in range(2, int(sqrt(n)) + 1):
if n % i != 0:
continue
t = 0
while n % i == 0:
n //= i
t += 1
result.append((i, t))
if n == 1:
break
if n != 1:
re... | from math import sqrt
def prime_factorize(n):
result = []
if n % 2 == 0:
t = 0
while n % 2 == 0:
n //= 2
t += 1
result.append((2, t))
for i in range(3, int(sqrt(n)) + 1, 2):
if n % i != 0:
continue
t = 0
while n % i == 0:
... | false | 16.666667 | [
"- for i in range(2, int(sqrt(n)) + 1):",
"+ if n % 2 == 0:",
"+ t = 0",
"+ while n % 2 == 0:",
"+ n //= 2",
"+ t += 1",
"+ result.append((2, t))",
"+ for i in range(3, int(sqrt(n)) + 1, 2):"
] | false | 0.050589 | 0.067208 | 0.752723 | [
"s167450477",
"s246457709"
] |
u919633157 | p03379 | python | s511447820 | s516665253 | 534 | 442 | 25,228 | 25,224 | Accepted | Accepted | 17.23 | # 2019/08/08
from bisect import bisect_left,bisect_right
n=int(eval(input()))
x=list(map(int,input().split()))
xx=sorted(x)
mid=n//2
for i in range(n):
if bisect_left(xx,x[i])<mid:
print((xx[mid]))
else:
print((xx[mid-1])) | # 2019/08/08
from bisect import bisect_left,bisect_right
n=int(input())
x=list(map(int,input().split()))
xx=sorted(x)
mid=n//2
ans=[]
for i in range(n):
if bisect_left(xx,x[i])<mid:
ans.append(xx[mid])
else:
ans.append(xx[mid-1])
print(*ans,sep='\n')
| 14 | 15 | 252 | 290 | # 2019/08/08
from bisect import bisect_left, bisect_right
n = int(eval(input()))
x = list(map(int, input().split()))
xx = sorted(x)
mid = n // 2
for i in range(n):
if bisect_left(xx, x[i]) < mid:
print((xx[mid]))
else:
print((xx[mid - 1]))
| # 2019/08/08
from bisect import bisect_left, bisect_right
n = int(input())
x = list(map(int, input().split()))
xx = sorted(x)
mid = n // 2
ans = []
for i in range(n):
if bisect_left(xx, x[i]) < mid:
ans.append(xx[mid])
else:
ans.append(xx[mid - 1])
print(*ans, sep="\n")
| false | 6.666667 | [
"-n = int(eval(input()))",
"+n = int(input())",
"+ans = []",
"- print((xx[mid]))",
"+ ans.append(xx[mid])",
"- print((xx[mid - 1]))",
"+ ans.append(xx[mid - 1])",
"+print(*ans, sep=\"\\n\")"
] | false | 0.040089 | 0.035909 | 1.11642 | [
"s511447820",
"s516665253"
] |
u859987056 | p02732 | python | s918224869 | s377261915 | 664 | 414 | 40,768 | 40,972 | Accepted | Accepted | 37.65 | from operator import mul
from functools import reduce
def cmb(n,r):
if n < r:
return 0
else:
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, list(range(n, n - r, -1)))
under = reduce(mul, list(range(1,r + 1)))
return over // under
N = int(eval... | def cmb(n):
if n < 2:
return 0
else:
return (n*(n-1)/2)
N = int(eval(input()))
A = list(map(int,input().split()))
num_dict = {i:0 for i in range(1,N+1)}
for i in range(N):
num_dict[A[i]] += 1
S = 0
for i in range(1,N+1):
S += cmb(num_dict[i])
for i in range(N):
... | 29 | 22 | 630 | 420 | from operator import mul
from functools import reduce
def cmb(n, r):
if n < r:
return 0
else:
r = min(n - r, r)
if r == 0:
return 1
over = reduce(mul, list(range(n, n - r, -1)))
under = reduce(mul, list(range(1, r + 1)))
return over // under
N = in... | def cmb(n):
if n < 2:
return 0
else:
return n * (n - 1) / 2
N = int(eval(input()))
A = list(map(int, input().split()))
num_dict = {i: 0 for i in range(1, N + 1)}
for i in range(N):
num_dict[A[i]] += 1
S = 0
for i in range(1, N + 1):
S += cmb(num_dict[i])
for i in range(N):
tmp = 0
... | false | 24.137931 | [
"-from operator import mul",
"-from functools import reduce",
"-",
"-",
"-def cmb(n, r):",
"- if n < r:",
"+def cmb(n):",
"+ if n < 2:",
"- r = min(n - r, r)",
"- if r == 0:",
"- return 1",
"- over = reduce(mul, list(range(n, n - r, -1)))",
"- und... | false | 0.111512 | 0.041349 | 2.696856 | [
"s918224869",
"s377261915"
] |
u633068244 | p00222 | python | s532864054 | s212590590 | 3,620 | 2,540 | 280,952 | 160,492 | Accepted | Accepted | 29.83 | ref = [[[10,8],[4,4]],[[10,2],[4,2]]]
r =10000001
p = [1]*r
p[0]= p[1] = 0
for i in range(int(r**0.5)):
if p[i]:
p[2*i::i] = [0 for j in range(2*i,r,i)]
while 1:
try:
n = eval(input())
if n == 0: break
n -= 1-n%2
while any(not p[n-i] for i in [0,2,6,8]):
n -= ref[p[n-2]][p[n-6]][p[n-8]]
... | ref = [[[10,8],[4,4]],[[10,2],[4,2]]]
r =10000001
p = [1]*r
p[0]= p[1] = 0
for i in range(int(r**0.5)):
if p[i]:
p[2*i::i] = [0]*len(p[2*i::i])
while 1:
try:
n = eval(input())
if n == 0: break
n -= 1-n%2
while any(not p[n-i] for i in [0,2,6,8]):
n -= ref[p[n-2]][p[n-6]][p[n-8]]
print(... | 18 | 18 | 342 | 333 | ref = [[[10, 8], [4, 4]], [[10, 2], [4, 2]]]
r = 10000001
p = [1] * r
p[0] = p[1] = 0
for i in range(int(r**0.5)):
if p[i]:
p[2 * i :: i] = [0 for j in range(2 * i, r, i)]
while 1:
try:
n = eval(input())
if n == 0:
break
n -= 1 - n % 2
while any(not p[n - i] f... | ref = [[[10, 8], [4, 4]], [[10, 2], [4, 2]]]
r = 10000001
p = [1] * r
p[0] = p[1] = 0
for i in range(int(r**0.5)):
if p[i]:
p[2 * i :: i] = [0] * len(p[2 * i :: i])
while 1:
try:
n = eval(input())
if n == 0:
break
n -= 1 - n % 2
while any(not p[n - i] for i in... | false | 0 | [
"- p[2 * i :: i] = [0 for j in range(2 * i, r, i)]",
"+ p[2 * i :: i] = [0] * len(p[2 * i :: i])"
] | false | 2.661862 | 1.642252 | 1.620861 | [
"s532864054",
"s212590590"
] |
u991542950 | p02573 | python | s966843490 | s799563245 | 671 | 473 | 16,356 | 83,924 | Accepted | Accepted | 29.51 | class UnionFind:
def __init__(self, n):
self.parent = [-1] * n
self.rank = [1] * n
self.count = [1] * n
def get_root(self, i):
while self.parent[i] != -1:
i = self.parent[i]
return i
def is_same_tree(self, i, j):
return self.get_root(i) == self.get_root(j)
def merg... | class UnionFind:
def __init__(self, n):
self.parent = [-1] * n
self.rank = [1] * n
self.count = [1] * n
def get_root(self, i):
if self.parent[i] < 0:
return i
else:
self.parent[i] = self.get_root(self.parent[i])
return self.parent[i]
#while self.parent[i] != -1... | 36 | 41 | 876 | 1,017 | class UnionFind:
def __init__(self, n):
self.parent = [-1] * n
self.rank = [1] * n
self.count = [1] * n
def get_root(self, i):
while self.parent[i] != -1:
i = self.parent[i]
return i
def is_same_tree(self, i, j):
return self.get_root(i) == self.g... | class UnionFind:
def __init__(self, n):
self.parent = [-1] * n
self.rank = [1] * n
self.count = [1] * n
def get_root(self, i):
if self.parent[i] < 0:
return i
else:
self.parent[i] = self.get_root(self.parent[i])
return self.parent[i]
... | false | 12.195122 | [
"- while self.parent[i] != -1:",
"- i = self.parent[i]",
"- return i",
"+ if self.parent[i] < 0:",
"+ return i",
"+ else:",
"+ self.parent[i] = self.get_root(self.parent[i])",
"+ return self.parent[i]",
"+ # while self.pa... | false | 0.054932 | 0.042987 | 1.277881 | [
"s966843490",
"s799563245"
] |
u479638406 | p03730 | python | s522813039 | s699900880 | 19 | 17 | 2,940 | 3,060 | Accepted | Accepted | 10.53 | a, b, c = list(map(int, input().split()))
ans = 'NO'
if a < b and c%a == 0:
ans = 'YES'
else:
for i in range(1, 1000):
if (b*i + c)%a == 0:
ans = 'YES'
break
print(ans) | a, b, c = list(map(int, input().split()))
ans = 'NO'
if a < b and c%a == 0:
ans = 'YES'
else:
for i in range(1, 100):
if (b*i + c)%a == 0:
ans = 'YES'
break
print(ans) | 12 | 12 | 197 | 196 | a, b, c = list(map(int, input().split()))
ans = "NO"
if a < b and c % a == 0:
ans = "YES"
else:
for i in range(1, 1000):
if (b * i + c) % a == 0:
ans = "YES"
break
print(ans)
| a, b, c = list(map(int, input().split()))
ans = "NO"
if a < b and c % a == 0:
ans = "YES"
else:
for i in range(1, 100):
if (b * i + c) % a == 0:
ans = "YES"
break
print(ans)
| false | 0 | [
"- for i in range(1, 1000):",
"+ for i in range(1, 100):"
] | false | 0.043813 | 0.043478 | 1.007708 | [
"s522813039",
"s699900880"
] |
u067299340 | p00010 | python | s989196126 | s090858081 | 20 | 10 | 4,376 | 4,336 | Accepted | Accepted | 50 | def calc(l):
A1=2*(l[1][0]-l[0][0])
B1=2*(l[1][1]-l[0][1])
C1=l[0][0]**2-l[1][0]**2+l[0][1]**2-l[1][1]**2
A2=2*(l[2][0]-l[0][0])
B2=2*(l[2][1]-l[0][1])
C2=l[0][0]**2-l[2][0]**2+l[0][1]**2-l[2][1]**2
X=(B1*C2-B2*C1)/(A1*B2-A2*B1)
Y=(C1*A2-C2*A1)/(A1*B2-A2*B1)
R=((X-l[0][0])**2+(Y-l[0][1])**2)**0.5
re... | def calc(a,b,c,d,e,f):
A1=2*(c-a)
B1=2*(d-b)
C1=a**2-c**2+b**2-d**2
A2=2*(e-a)
B2=2*(f-b)
C2=a*a-e*e+b*b-f*f
X=(B1*C2-B2*C1)/(A1*B2-A2*B1)
Y=(C1*A2-C2*A1)/(A1*B2-A2*B1)
R=((X-a)**2+(Y-b)**2)**0.5
return tuple(map(round, [X,Y,R], [3]*3))
l=[list(map(float,input().split())) for i in range(eval(input(... | 14 | 14 | 484 | 367 | def calc(l):
A1 = 2 * (l[1][0] - l[0][0])
B1 = 2 * (l[1][1] - l[0][1])
C1 = l[0][0] ** 2 - l[1][0] ** 2 + l[0][1] ** 2 - l[1][1] ** 2
A2 = 2 * (l[2][0] - l[0][0])
B2 = 2 * (l[2][1] - l[0][1])
C2 = l[0][0] ** 2 - l[2][0] ** 2 + l[0][1] ** 2 - l[2][1] ** 2
X = (B1 * C2 - B2 * C1) / (A1 * B2 - ... | def calc(a, b, c, d, e, f):
A1 = 2 * (c - a)
B1 = 2 * (d - b)
C1 = a**2 - c**2 + b**2 - d**2
A2 = 2 * (e - a)
B2 = 2 * (f - b)
C2 = a * a - e * e + b * b - f * f
X = (B1 * C2 - B2 * C1) / (A1 * B2 - A2 * B1)
Y = (C1 * A2 - C2 * A1) / (A1 * B2 - A2 * B1)
R = ((X - a) ** 2 + (Y - b) **... | false | 0 | [
"-def calc(l):",
"- A1 = 2 * (l[1][0] - l[0][0])",
"- B1 = 2 * (l[1][1] - l[0][1])",
"- C1 = l[0][0] ** 2 - l[1][0] ** 2 + l[0][1] ** 2 - l[1][1] ** 2",
"- A2 = 2 * (l[2][0] - l[0][0])",
"- B2 = 2 * (l[2][1] - l[0][1])",
"- C2 = l[0][0] ** 2 - l[2][0] ** 2 + l[0][1] ** 2 - l[2][1] ** 2... | false | 0.047505 | 0.037878 | 1.254155 | [
"s989196126",
"s090858081"
] |
u304630225 | p03814 | python | s167260862 | s897348935 | 43 | 25 | 4,840 | 6,180 | Accepted | Accepted | 41.86 | N=list(eval(input()))
n=len(N)
X=0
for i in range(n):
if N[i]=="A" :
X=i
break
for i in range(n):
if N[-(i+1)]=="Z" :
X+=i
break
print((n-X))
| N=list(eval(input()))
n=len(N)
A=N.index("A")
N=N[::-1]
Z=N.index("Z")
print((n-A-Z)) | 13 | 6 | 173 | 82 | N = list(eval(input()))
n = len(N)
X = 0
for i in range(n):
if N[i] == "A":
X = i
break
for i in range(n):
if N[-(i + 1)] == "Z":
X += i
break
print((n - X))
| N = list(eval(input()))
n = len(N)
A = N.index("A")
N = N[::-1]
Z = N.index("Z")
print((n - A - Z))
| false | 53.846154 | [
"-X = 0",
"-for i in range(n):",
"- if N[i] == \"A\":",
"- X = i",
"- break",
"-for i in range(n):",
"- if N[-(i + 1)] == \"Z\":",
"- X += i",
"- break",
"-print((n - X))",
"+A = N.index(\"A\")",
"+N = N[::-1]",
"+Z = N.index(\"Z\")",
"+print((n - A - Z))"... | false | 0.080042 | 0.047099 | 1.699434 | [
"s167260862",
"s897348935"
] |
u368796742 | p03855 | python | s226407520 | s723308671 | 1,407 | 1,261 | 91,252 | 125,560 | Accepted | Accepted | 10.38 | from collections import deque
n,k,l = list(map(int,input().split()))
ep = [[] for i in range(n)]
er = [[] for i in range(n)]
gp = [-1]*n
gr = [-1]*n
for i in range(k):
a,b = list(map(int,input().split()))
a -= 1
b -= 1
ep[a].append(b)
ep[b].append(a)
for i in range(l):
a,b = l... | from collections import deque
n,k,l = list(map(int,input().split()))
ep = [[] for i in range(n)]
er = [[] for i in range(n)]
gp = [-1]*n
gr = [-1]*n
for i in range(k):
a,b = list(map(int,input().split()))
a -= 1
b -= 1
ep[a].append(b)
ep[b].append(a)
for i in range(l):
a,b = l... | 56 | 55 | 1,060 | 1,058 | from collections import deque
n, k, l = list(map(int, input().split()))
ep = [[] for i in range(n)]
er = [[] for i in range(n)]
gp = [-1] * n
gr = [-1] * n
for i in range(k):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
ep[a].append(b)
ep[b].append(a)
for i in range(l):
a, b = list(map(... | from collections import deque
n, k, l = list(map(int, input().split()))
ep = [[] for i in range(n)]
er = [[] for i in range(n)]
gp = [-1] * n
gr = [-1] * n
for i in range(k):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
ep[a].append(b)
ep[b].append(a)
for i in range(l):
a, b = list(map(... | false | 1.785714 | [
"-ans = [0] * n",
"+ans = []",
"- ans[i] = dic[l[i]]",
"+ ans.append(dic[l[i]])"
] | false | 0.094059 | 0.059302 | 1.586096 | [
"s226407520",
"s723308671"
] |
u227082700 | p02762 | python | s050055276 | s881409583 | 1,379 | 1,200 | 59,812 | 59,712 | Accepted | Accepted | 12.98 | n,m,k=list(map(int,input().split()))
ab=[list(map(int,input().split()))for _ in range(m)]
cd=[list(map(int,input().split()))for _ in range(k)]
import sys;sys.setrecursionlimit(10**9)
class UnionFind():
def __init__(self,n):
self.n=[-1]*n
self.r=[0]*n
def Find_Root(self,x):
if self.n[x]<0:
... | import sys;sys.setrecursionlimit(10**9)
class UnionFind:
def __init__(self,n):
self.n=[-1]*n
self.r=[0]*n
def find_root(self,x):
if self.n[x]<0:
return x
else:
self.n[x]=self.find_root(self.n[x])
return self.n[x]
def unite(self,x,y):
x=self.find_root(x)
y=sel... | 42 | 41 | 1,078 | 1,045 | n, m, k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(k)]
import sys
sys.setrecursionlimit(10**9)
class UnionFind:
def __init__(self, n):
self.n = [-1] * n
self.r = [0] * n
def Find_Root(self, x... | import sys
sys.setrecursionlimit(10**9)
class UnionFind:
def __init__(self, n):
self.n = [-1] * n
self.r = [0] * n
def find_root(self, x):
if self.n[x] < 0:
return x
else:
self.n[x] = self.find_root(self.n[x])
return self.n[x]
def unit... | false | 2.380952 | [
"-n, m, k = list(map(int, input().split()))",
"-ab = [list(map(int, input().split())) for _ in range(m)]",
"-cd = [list(map(int, input().split())) for _ in range(k)]",
"- def Find_Root(self, x):",
"+ def find_root(self, x):",
"- self.n[x] = self.Find_Root(self.n[x])",
"+ self... | false | 0.041511 | 0.042443 | 0.978024 | [
"s050055276",
"s881409583"
] |
u183422236 | p02689 | python | s228756766 | s021559341 | 396 | 247 | 29,392 | 20,044 | Accepted | Accepted | 37.63 | n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
path = [[] for i in range(n)]
ans = 0
for i in range(m):
a, b = list(map(int, input().split()))
path[a - 1].append(b - 1)
path[b - 1].append(a - 1)
for i in range(n):
if len(path[i]) == 0:
ans += 1
for j ... | n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ok = [1] * n
for i in range(m):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
if h[a] <= h[b]: ok[a] = 0
if h[b] <= h[a]: ok[b] = 0
print((sum(ok)))
| 18 | 11 | 454 | 248 | n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
path = [[] for i in range(n)]
ans = 0
for i in range(m):
a, b = list(map(int, input().split()))
path[a - 1].append(b - 1)
path[b - 1].append(a - 1)
for i in range(n):
if len(path[i]) == 0:
ans += 1
for j in range(len(... | n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ok = [1] * n
for i in range(m):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
if h[a] <= h[b]:
ok[a] = 0
if h[b] <= h[a]:
ok[b] = 0
print((sum(ok)))
| false | 38.888889 | [
"-path = [[] for i in range(n)]",
"-ans = 0",
"+ok = [1] * n",
"- path[a - 1].append(b - 1)",
"- path[b - 1].append(a - 1)",
"-for i in range(n):",
"- if len(path[i]) == 0:",
"- ans += 1",
"- for j in range(len(path[i])):",
"- if h[path[i][j]] >= h[i]:",
"- b... | false | 0.066592 | 0.042595 | 1.563387 | [
"s228756766",
"s021559341"
] |
u473952728 | p03325 | python | s977860796 | s986781051 | 53 | 25 | 3,828 | 3,828 | Accepted | Accepted | 52.83 | def cnt(n):
c = 0
while True:
n, flag = n >> 1, n & 1
if flag: break
c = c + 1
return c
eval(input())
xs = list(map(int, input().split()))
print((sum(cnt(x) for x in xs))) | eval(input())
xs = list(map(int, input().split()))
cnt = lambda n: bin(n)[::-1].find('1')
print((sum(cnt(x) for x in xs))) | 11 | 4 | 186 | 111 | def cnt(n):
c = 0
while True:
n, flag = n >> 1, n & 1
if flag:
break
c = c + 1
return c
eval(input())
xs = list(map(int, input().split()))
print((sum(cnt(x) for x in xs)))
| eval(input())
xs = list(map(int, input().split()))
cnt = lambda n: bin(n)[::-1].find("1")
print((sum(cnt(x) for x in xs)))
| false | 63.636364 | [
"-def cnt(n):",
"- c = 0",
"- while True:",
"- n, flag = n >> 1, n & 1",
"- if flag:",
"- break",
"- c = c + 1",
"- return c",
"-",
"-",
"+cnt = lambda n: bin(n)[::-1].find(\"1\")"
] | false | 0.041806 | 0.041054 | 1.018325 | [
"s977860796",
"s986781051"
] |
u691018832 | p02707 | python | s447691998 | s678846189 | 152 | 120 | 27,836 | 27,760 | Accepted | Accepted | 21.05 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
n = int(readline())
a = list(map(int, readline().split()))
ans = [0] * n
for aa in a:
ans[aa - 1] += 1
for i in range(n):
print((ans[i]))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
n, *a = list(map(int, read().split()))
ans = [0] * n
for i in a:
ans[i - 1] += 1
print((*ans))
| 13 | 11 | 304 | 249 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
n = int(readline())
a = list(map(int, readline().split()))
ans = [0] * n
for aa in a:
ans[aa - 1] += 1
for i in range(n):
print((ans[i]))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
n, *a = list(map(int, read().split()))
ans = [0] * n
for i in a:
ans[i - 1] += 1
print((*ans))
| false | 15.384615 | [
"-n = int(readline())",
"-a = list(map(int, readline().split()))",
"+n, *a = list(map(int, read().split()))",
"-for aa in a:",
"- ans[aa - 1] += 1",
"-for i in range(n):",
"- print((ans[i]))",
"+for i in a:",
"+ ans[i - 1] += 1",
"+print((*ans))"
] | false | 0.044065 | 0.039064 | 1.128019 | [
"s447691998",
"s678846189"
] |
u576917603 | p03087 | python | s009117575 | s241623215 | 1,041 | 844 | 52,568 | 6,060 | Accepted | Accepted | 18.92 | n,q=list(map(int,input().split()))
s=eval(input())
b=[0]*(n+1)
y=0
for x,i in enumerate(s):
if i=="A" and x!=n-1 and s[x+1]=="C":
y+=1
b[x+1]=y
for i in range(q):
a0,a1=list(map(int,input().split()))
print((b[a1-1]-b[a0-1]))
| n,k=list(map(int,input().split()))
a=eval(input())
ac=[0]*n
x=0
for i in range(n-1):
if a[i]=='A' and a[i+1]=='C':
x+=1
ac[i+1]=x
ac[-1]=x
for i in range(k):
l,r=list(map(int,input().split()))
print((ac[r-1]-ac[l-1])) | 11 | 12 | 239 | 232 | n, q = list(map(int, input().split()))
s = eval(input())
b = [0] * (n + 1)
y = 0
for x, i in enumerate(s):
if i == "A" and x != n - 1 and s[x + 1] == "C":
y += 1
b[x + 1] = y
for i in range(q):
a0, a1 = list(map(int, input().split()))
print((b[a1 - 1] - b[a0 - 1]))
| n, k = list(map(int, input().split()))
a = eval(input())
ac = [0] * n
x = 0
for i in range(n - 1):
if a[i] == "A" and a[i + 1] == "C":
x += 1
ac[i + 1] = x
ac[-1] = x
for i in range(k):
l, r = list(map(int, input().split()))
print((ac[r - 1] - ac[l - 1]))
| false | 8.333333 | [
"-n, q = list(map(int, input().split()))",
"-s = eval(input())",
"-b = [0] * (n + 1)",
"-y = 0",
"-for x, i in enumerate(s):",
"- if i == \"A\" and x != n - 1 and s[x + 1] == \"C\":",
"- y += 1",
"- b[x + 1] = y",
"-for i in range(q):",
"- a0, a1 = list(map(int, input().split()))",... | false | 0.04317 | 0.142504 | 0.302935 | [
"s009117575",
"s241623215"
] |
u729133443 | p02860 | python | s716876149 | s397207067 | 173 | 18 | 38,384 | 2,940 | Accepted | Accepted | 89.6 | n,a=open(0);n=int(n);print(("YNeos"[a[:n//2]!=a[n//2:n]::2])) | n,a=open(0);n=int(n)//2;print(("YNeos"[a[:n]!=a[n:-1]::2])) | 1 | 1 | 59 | 57 | n, a = open(0)
n = int(n)
print(("YNeos"[a[: n // 2] != a[n // 2 : n] :: 2]))
| n, a = open(0)
n = int(n) // 2
print(("YNeos"[a[:n] != a[n:-1] :: 2]))
| false | 0 | [
"-n = int(n)",
"-print((\"YNeos\"[a[: n // 2] != a[n // 2 : n] :: 2]))",
"+n = int(n) // 2",
"+print((\"YNeos\"[a[:n] != a[n:-1] :: 2]))"
] | false | 0.09446 | 0.035469 | 2.663148 | [
"s716876149",
"s397207067"
] |
u278057806 | p02947 | python | s540371990 | s718347906 | 475 | 407 | 24,652 | 39,428 | Accepted | Accepted | 14.32 | N = int(eval(input()))
S = [list(eval(input())) for i in range(N)]
for s in S:
s.sort()
S.sort()
cnt = 1
ans = 0
tmp = []
for s in S:
if s == tmp:
cnt += 1
else:
tmp = s
ans += cnt * (cnt - 1) // 2
cnt = 1
ans += cnt * (cnt - 1) // 2
print(ans)
| from collections import defaultdict
N = int(eval(input()))
S = [list(eval(input())) for i in range(N)]
d = defaultdict(int)
for s in S:
s.sort()
s = "".join(s)
d[s] += 1
ans = 0
for key in list(d):
ans += d[key] * (d[key] - 1) // 2
print(ans)
| 23 | 18 | 305 | 270 | N = int(eval(input()))
S = [list(eval(input())) for i in range(N)]
for s in S:
s.sort()
S.sort()
cnt = 1
ans = 0
tmp = []
for s in S:
if s == tmp:
cnt += 1
else:
tmp = s
ans += cnt * (cnt - 1) // 2
cnt = 1
ans += cnt * (cnt - 1) // 2
print(ans)
| from collections import defaultdict
N = int(eval(input()))
S = [list(eval(input())) for i in range(N)]
d = defaultdict(int)
for s in S:
s.sort()
s = "".join(s)
d[s] += 1
ans = 0
for key in list(d):
ans += d[key] * (d[key] - 1) // 2
print(ans)
| false | 21.73913 | [
"+from collections import defaultdict",
"+",
"+d = defaultdict(int)",
"-S.sort()",
"-cnt = 1",
"+ s = \"\".join(s)",
"+ d[s] += 1",
"-tmp = []",
"-for s in S:",
"- if s == tmp:",
"- cnt += 1",
"- else:",
"- tmp = s",
"- ans += cnt * (cnt - 1) // 2",
"- ... | false | 0.04406 | 0.045257 | 0.973557 | [
"s540371990",
"s718347906"
] |
u203222829 | p02408 | python | s429423402 | s004557900 | 30 | 20 | 5,624 | 5,628 | Accepted | Accepted | 33.33 | # coding: utf-8
'''
S 1
H 3
H 7
C 12
D 8
'''
cards = ['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'S10', 'S11', 'S12', 'S13',
'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'H10', 'H11', 'H12', 'H13',
'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10', 'C11', 'C12', 'C13',
'D1',... | # coding: utf-8
'''
S 1
H 3
H 7
C 12
D 8
'''
cards = ['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'S10', 'S11', 'S12', 'S13',
'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'H10', 'H11', 'H12', 'H13',
'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10', 'C11', 'C12', 'C13',
'D1',... | 24 | 23 | 606 | 558 | # coding: utf-8
"""
S 1
H 3
H 7
C 12
D 8
"""
cards = [
"S1",
"S2",
"S3",
"S4",
"S5",
"S6",
"S7",
"S8",
"S9",
"S10",
"S11",
"S12",
"S13",
"H1",
"H2",
"H3",
"H4",
"H5",
"H6",
"H7",
"H8",
"H9",
"H10",
"H11",
"H12",
"H13... | # coding: utf-8
"""
S 1
H 3
H 7
C 12
D 8
"""
cards = [
"S1",
"S2",
"S3",
"S4",
"S5",
"S6",
"S7",
"S8",
"S9",
"S10",
"S11",
"S12",
"S13",
"H1",
"H2",
"H3",
"H4",
"H5",
"H6",
"H7",
"H8",
"H9",
"H10",
"H11",
"H12",
"H13... | false | 4.166667 | [
"- # suit, number = input().split()",
"- suit, number = list(map(str, input().split()))",
"+ suit, number = input().split()"
] | false | 0.099084 | 0.042979 | 2.305428 | [
"s429423402",
"s004557900"
] |
u808429775 | p00184 | python | s256945007 | s020497152 | 2,940 | 2,040 | 13,520 | 13,524 | Accepted | Accepted | 30.61 | judge = [10, 20, 30, 40, 50, 60, 121]
while True:
input_count = int(eval(input()))
if input_count == 0:
break
data = [int(eval(input())) for _ in range(input_count)]
counter = [0] * 7
for item in data:
for index, j in enumerate(judge):
if item < j:
... | while True:
input_count = int(eval(input()))
if input_count == 0:
break
data = [int(eval(input())) for _ in range(input_count)]
counter = [0] * 12
for item in data:
counter[item // 10] += 1
counter[6] = sum(counter[6:])
counter = counter[:7]
counte... | 22 | 20 | 448 | 377 | judge = [10, 20, 30, 40, 50, 60, 121]
while True:
input_count = int(eval(input()))
if input_count == 0:
break
data = [int(eval(input())) for _ in range(input_count)]
counter = [0] * 7
for item in data:
for index, j in enumerate(judge):
if item < j:
counter... | while True:
input_count = int(eval(input()))
if input_count == 0:
break
data = [int(eval(input())) for _ in range(input_count)]
counter = [0] * 12
for item in data:
counter[item // 10] += 1
counter[6] = sum(counter[6:])
counter = counter[:7]
counter = [str(item) for item ... | false | 9.090909 | [
"-judge = [10, 20, 30, 40, 50, 60, 121]",
"- counter = [0] * 7",
"+ counter = [0] * 12",
"- for index, j in enumerate(judge):",
"- if item < j:",
"- counter[index] += 1",
"- break",
"+ counter[item // 10] += 1",
"+ counter[6] = sum(coun... | false | 0.045818 | 0.044534 | 1.028822 | [
"s256945007",
"s020497152"
] |
u017810624 | p02599 | python | s931526439 | s503061429 | 1,684 | 1,543 | 232,316 | 181,648 | Accepted | Accepted | 8.37 | import sys
input=sys.stdin.readline
from operator import itemgetter
n,q=list(map(int,input().split()))
c=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(q)]
for i in range(q):
l[i].append(i)
l.sort(key=lambda x:x[1])
L=[-1]*(5*10**5+1)
class Bit:
def __init__(self,n):
... | import sys
input=sys.stdin.readline
n,q=list(map(int,input().split()))
c=list(map(int,input().split()))
l=[]
for i in range(q):
L,R=list(map(int,input().split()))
l.append([L,R,i])
l.sort(key=lambda x:x[1])
L=[-1]*(5*10**5+1)
class Bit:
def __init__(self,n):
self.size=n
self.tree=[0]*(n +... | 45 | 45 | 845 | 809 | import sys
input = sys.stdin.readline
from operator import itemgetter
n, q = list(map(int, input().split()))
c = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(q)]
for i in range(q):
l[i].append(i)
l.sort(key=lambda x: x[1])
L = [-1] * (5 * 10**5 + 1)
class Bit:
def __in... | import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
c = list(map(int, input().split()))
l = []
for i in range(q):
L, R = list(map(int, input().split()))
l.append([L, R, i])
l.sort(key=lambda x: x[1])
L = [-1] * (5 * 10**5 + 1)
class Bit:
def __init__(self, n):
self.size =... | false | 0 | [
"-from operator import itemgetter",
"-",
"-l = [list(map(int, input().split())) for i in range(q)]",
"+l = []",
"- l[i].append(i)",
"+ L, R = list(map(int, input().split()))",
"+ l.append([L, R, i])",
"-for i in ans:",
"- print(i)",
"+for i in range(q):",
"+ print((ans[i]))"
] | false | 0.04562 | 0.047888 | 0.952651 | [
"s931526439",
"s503061429"
] |
u780475861 | p02971 | python | s939492064 | s938590178 | 276 | 230 | 25,036 | 25,036 | Accepted | Accepted | 16.67 | import sys
n, *lst = list(map(int, sys.stdin.read().split()))
copy = sorted(lst)
max1, max2 = copy[-1], copy[-2]
if max2 < max1:
for j in lst:
if j != max1:
print(max1)
else:
print(max2)
else:
for j in lst:
print(max1) | import sys
def main():
n, *lst = map(int, sys.stdin.read().split())
copy = sorted(lst)
max1, max2 = copy[-1], copy[-2]
if max2 < max1:
print(*[max1 if j != max1 else max2 for j in lst], sep='\n')
else:
print(*[max1]*n, sep='\n')
if __name__ == '__main__':
main()
| 14 | 15 | 254 | 304 | import sys
n, *lst = list(map(int, sys.stdin.read().split()))
copy = sorted(lst)
max1, max2 = copy[-1], copy[-2]
if max2 < max1:
for j in lst:
if j != max1:
print(max1)
else:
print(max2)
else:
for j in lst:
print(max1)
| import sys
def main():
n, *lst = map(int, sys.stdin.read().split())
copy = sorted(lst)
max1, max2 = copy[-1], copy[-2]
if max2 < max1:
print(*[max1 if j != max1 else max2 for j in lst], sep="\n")
else:
print(*[max1] * n, sep="\n")
if __name__ == "__main__":
main()
| false | 6.666667 | [
"-n, *lst = list(map(int, sys.stdin.read().split()))",
"-copy = sorted(lst)",
"-max1, max2 = copy[-1], copy[-2]",
"-if max2 < max1:",
"- for j in lst:",
"- if j != max1:",
"- print(max1)",
"- else:",
"- print(max2)",
"-else:",
"- for j in lst:",
"- ... | false | 0.008164 | 0.046977 | 0.17379 | [
"s939492064",
"s938590178"
] |
u968404618 | p03807 | python | s853051698 | s412859700 | 59 | 50 | 14,112 | 14,108 | Accepted | Accepted | 15.25 | n = int(eval(input()))
A = list(map(int, input().split()))
e = []
o = []
e_append = e.append
o_append = o.append
for a in A:
if a % 2 == 0:
e_append(a)
else:
o_append(a)
if len(o) %2 != 0:
print('NO')
else:
print('YES') | n = int(eval(input()))
A = list(map(int, input().split()))
o = [a for a in A if a % 2 != 0]
if len(o) %2 != 0:
print('NO')
else:
print('YES') | 17 | 9 | 263 | 153 | n = int(eval(input()))
A = list(map(int, input().split()))
e = []
o = []
e_append = e.append
o_append = o.append
for a in A:
if a % 2 == 0:
e_append(a)
else:
o_append(a)
if len(o) % 2 != 0:
print("NO")
else:
print("YES")
| n = int(eval(input()))
A = list(map(int, input().split()))
o = [a for a in A if a % 2 != 0]
if len(o) % 2 != 0:
print("NO")
else:
print("YES")
| false | 47.058824 | [
"-e = []",
"-o = []",
"-e_append = e.append",
"-o_append = o.append",
"-for a in A:",
"- if a % 2 == 0:",
"- e_append(a)",
"- else:",
"- o_append(a)",
"+o = [a for a in A if a % 2 != 0]"
] | false | 0.008051 | 0.036179 | 0.22254 | [
"s853051698",
"s412859700"
] |
u653041271 | p02773 | python | s313507987 | s151905679 | 1,549 | 584 | 89,588 | 56,508 | Accepted | Accepted | 62.3 | import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod... | import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod... | 48 | 29 | 1,347 | 995 | import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter, defaultdict, deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10*... | import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter, defaultdict, deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10*... | false | 39.583333 | [
"-s = sorted(inplL(n))",
"-tmp = \"\"",
"-ans = []",
"-anscnt = -1",
"+d = defaultdict(int)",
"- if tmp == s[i]:",
"- ans[anscnt][1] += 1",
"- else:",
"- ans.append([s[i], 1])",
"- anscnt += 1",
"- tmp = s[i]",
"-ans.sort(key=lambda x: x[1], reverse=True)",
"-tm... | false | 0.038304 | 0.046929 | 0.816222 | [
"s313507987",
"s151905679"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.