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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u022979415 | p03821 | python | s792090465 | s760865759 | 410 | 335 | 15,016 | 11,048 | Accepted | Accepted | 18.29 | from math import ceil
def main():
length = int(eval(input()))
sequence = [0 for _ in range(length)]
target = [0 for _ in range(length)]
for i in range(length):
a, b = list(map(int, input().split()))
sequence[i] = a
target[i] = b
answer = 0
cumulative_push = ... | from math import ceil
def main():
n = int(eval(input()))
a = [0 for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(n):
a[i], b[i] = list(map(int, input().split()))
added = 0
for i in range(n - 1, -1, -1):
added += ceil((a[i] + added) / b[i]) * b[i] - (a[i] +... | 24 | 18 | 598 | 380 | from math import ceil
def main():
length = int(eval(input()))
sequence = [0 for _ in range(length)]
target = [0 for _ in range(length)]
for i in range(length):
a, b = list(map(int, input().split()))
sequence[i] = a
target[i] = b
answer = 0
cumulative_push = 0
for i ... | from math import ceil
def main():
n = int(eval(input()))
a = [0 for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(n):
a[i], b[i] = list(map(int, input().split()))
added = 0
for i in range(n - 1, -1, -1):
added += ceil((a[i] + added) / b[i]) * b[i] - (a[i] + added)
... | false | 25 | [
"- length = int(eval(input()))",
"- sequence = [0 for _ in range(length)]",
"- target = [0 for _ in range(length)]",
"- for i in range(length):",
"- a, b = list(map(int, input().split()))",
"- sequence[i] = a",
"- target[i] = b",
"- answer = 0",
"- cumulative_p... | false | 0.038397 | 0.038776 | 0.990236 | [
"s792090465",
"s760865759"
] |
u312025627 | p03319 | python | s984933777 | s168131614 | 218 | 189 | 52,476 | 52,464 | Accepted | Accepted | 13.3 | def main():
N, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
mi = min(A)
idx = A.index(mi)
h1 = idx
h2 = N - idx - 1
ans = N
for k in range(K):
cur = (max(0, (h1 - k))+(K-1)-1)//(K-1) + \
(max(0, (h2 - ((K-1) - k)))+(K-1)-1)//(K... | def main():
import sys
input = sys.stdin.buffer.readline
N, K = (int(i)-1 for i in input().split())
_ = [int(i) for i in input().split()]
print(((N + K - 1)//K))
if __name__ == '__main__':
main()
| 17 | 10 | 417 | 229 | def main():
N, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
mi = min(A)
idx = A.index(mi)
h1 = idx
h2 = N - idx - 1
ans = N
for k in range(K):
cur = (
(max(0, (h1 - k)) + (K - 1) - 1) // (K - 1)
+ (max(0, (h2 - ((K - 1) - k))... | def main():
import sys
input = sys.stdin.buffer.readline
N, K = (int(i) - 1 for i in input().split())
_ = [int(i) for i in input().split()]
print(((N + K - 1) // K))
if __name__ == "__main__":
main()
| false | 41.176471 | [
"- N, K = (int(i) for i in input().split())",
"- A = [int(i) for i in input().split()]",
"- mi = min(A)",
"- idx = A.index(mi)",
"- h1 = idx",
"- h2 = N - idx - 1",
"- ans = N",
"- for k in range(K):",
"- cur = (",
"- (max(0, (h1 - k)) + (K - 1) - 1) // (K... | false | 0.039195 | 0.040788 | 0.960929 | [
"s984933777",
"s168131614"
] |
u933096856 | p02419 | python | s902100891 | s609198708 | 60 | 30 | 7,640 | 7,544 | Accepted | Accepted | 50 | import re
c=0
p=input().upper()
ptn=re.compile(r'^'+p+r'$')
while True:
s=eval(input())
if s =='END_OF_TEXT':
break
a=s.upper().split()
for i in a:
if re.match(ptn, i):
c+=1
print(c) | import re
c=0
ptn=re.compile(r'^'+input().upper()+r'$')
while True:
s=eval(input())
if s =='END_OF_TEXT':
break
a=s.upper().split()
for i in a:
if re.match(ptn, i):
c+=1
print(c) | 15 | 14 | 236 | 231 | import re
c = 0
p = input().upper()
ptn = re.compile(r"^" + p + r"$")
while True:
s = eval(input())
if s == "END_OF_TEXT":
break
a = s.upper().split()
for i in a:
if re.match(ptn, i):
c += 1
print(c)
| import re
c = 0
ptn = re.compile(r"^" + input().upper() + r"$")
while True:
s = eval(input())
if s == "END_OF_TEXT":
break
a = s.upper().split()
for i in a:
if re.match(ptn, i):
c += 1
print(c)
| false | 6.666667 | [
"-p = input().upper()",
"-ptn = re.compile(r\"^\" + p + r\"$\")",
"+ptn = re.compile(r\"^\" + input().upper() + r\"$\")"
] | false | 0.040326 | 0.039894 | 1.01082 | [
"s902100891",
"s609198708"
] |
u863442865 | p02725 | python | s417803983 | s269773418 | 186 | 141 | 25,432 | 25,432 | Accepted | Accepted | 24.19 | #どっちで出すか注意, rstrip注意
#提出前に見返すこと!
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate
#from itertools import product
... | #どっちで出すか注意, rstrip注意
#提出前に見返すこと!
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate
#from itertools import product
... | 31 | 28 | 832 | 749 | # どっちで出すか注意, rstrip注意
# 提出前に見返すこと!
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations, permutations, accumulate
# from itertools import product
f... | # どっちで出すか注意, rstrip注意
# 提出前に見返すこと!
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations, permutations, accumulate
# from itertools import product
f... | false | 9.677419 | [
"- K, N = list(map(int, input().split()))",
"+ k, n = list(map(int, input().split()))",
"- res = 10**20",
"- for i in range(1, N - 1):",
"- res = min(K - (a[i + 1] - a[i]), K - (a[i] - a[i - 1]), res)",
"- res = min(K - (a[1] - a[0]), res, a[N - 1] - a[0])",
"- res = min(res, K ... | false | 0.04148 | 0.047462 | 0.873971 | [
"s417803983",
"s269773418"
] |
u200887663 | p02785 | python | s257496182 | s804068874 | 169 | 151 | 26,764 | 26,024 | Accepted | Accepted | 10.65 | n,k=list(map(int,input().split()))
hl=list(map(int,input().split()))
ans=0
if n<=k:
print((0))
else:
hl.sort(reverse=True)
temp=hl[(k+1)-1:n]
for v in temp:
ans+=v
print(ans)
| #n=int(input())
n,k=list(map(int,input().split()))
l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
if n<=k:
print((0))
else:
l.sort(reverse=True)
print((sum(l[k:n])))
| 11 | 10 | 205 | 218 | n, k = list(map(int, input().split()))
hl = list(map(int, input().split()))
ans = 0
if n <= k:
print((0))
else:
hl.sort(reverse=True)
temp = hl[(k + 1) - 1 : n]
for v in temp:
ans += v
print(ans)
| # n=int(input())
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
if n <= k:
print((0))
else:
l.sort(reverse=True)
print((sum(l[k:n])))
| false | 9.090909 | [
"+# n=int(input())",
"-hl = list(map(int, input().split()))",
"-ans = 0",
"+l = list(map(int, input().split()))",
"+# l=[list(map(int,input().split())) for i in range(n)]",
"- hl.sort(reverse=True)",
"- temp = hl[(k + 1) - 1 : n]",
"- for v in temp:",
"- ans += v",
"- print(ans)... | false | 0.043908 | 0.044103 | 0.995589 | [
"s257496182",
"s804068874"
] |
u094191970 | p02845 | python | s211219060 | s952171561 | 105 | 89 | 14,364 | 14,072 | Accepted | Accepted | 15.24 | n=int(eval(input()))
a=list(map(int,input().split()))
mod=1000000007
ans=1
r,b,g=0,0,0
r2,b2,g2=-1,-1,-1
for i in a:
if r2==r and b2==b and g2==g:
print((0))
exit()
r2=r
b2=b
g2=g
if i==r and i==b and i==g:
ans*=3
ans%=mod
r+=1
elif (i==... | n=int(eval(input()))
a=list(map(int,input().split()))
mod=1000000007
ans=1
r,b,g=0,0,0
for i in a:
if i==r and i==b and i==g:
ans*=3
ans%=mod
r+=1
elif (i==r and i==b) or (i==g and i==r):
ans*=2
ans%=mod
r+=1
elif i==b and i==g:
ans*=2... | 38 | 29 | 615 | 493 | n = int(eval(input()))
a = list(map(int, input().split()))
mod = 1000000007
ans = 1
r, b, g = 0, 0, 0
r2, b2, g2 = -1, -1, -1
for i in a:
if r2 == r and b2 == b and g2 == g:
print((0))
exit()
r2 = r
b2 = b
g2 = g
if i == r and i == b and i == g:
ans *= 3
ans %= mod
... | n = int(eval(input()))
a = list(map(int, input().split()))
mod = 1000000007
ans = 1
r, b, g = 0, 0, 0
for i in a:
if i == r and i == b and i == g:
ans *= 3
ans %= mod
r += 1
elif (i == r and i == b) or (i == g and i == r):
ans *= 2
ans %= mod
r += 1
elif i == ... | false | 23.684211 | [
"-r2, b2, g2 = -1, -1, -1",
"- if r2 == r and b2 == b and g2 == g:",
"- print((0))",
"- exit()",
"- r2 = r",
"- b2 = b",
"- g2 = g"
] | false | 0.037779 | 0.038399 | 0.983848 | [
"s211219060",
"s952171561"
] |
u514401521 | p03290 | python | s009676493 | s499427701 | 177 | 158 | 3,064 | 3,064 | Accepted | Accepted | 10.73 | D, G = list(map(int, input().split()))
P = []
C = []
for i in range(D):
p, c = list(map(int, input().split()))
P.append(p)
C.append(c)
ans = 100000000
for i in range(2 ** D):
a = 0
b = 0
for j in range(D):
if i >> j & 1:
a += 100 * P[j] * (j + 1) + C[j]
... | """
bit全探索
"""
D, G = list(map(int, input().split()))
P = []
C = []
for i in range(D):
p, c = list(map(int, input().split()))
P.append(p)
C.append(c)
ans = 100000000
for i in range(2 ** D):
a = 0
b = 0
for j in range(D):
if i >> j & 1:
a += 100 * P[j] * (j... | 28 | 33 | 607 | 651 | D, G = list(map(int, input().split()))
P = []
C = []
for i in range(D):
p, c = list(map(int, input().split()))
P.append(p)
C.append(c)
ans = 100000000
for i in range(2**D):
a = 0
b = 0
for j in range(D):
if i >> j & 1:
a += 100 * P[j] * (j + 1) + C[j]
b += P[j]
... | """
bit全探索
"""
D, G = list(map(int, input().split()))
P = []
C = []
for i in range(D):
p, c = list(map(int, input().split()))
P.append(p)
C.append(c)
ans = 100000000
for i in range(2**D):
a = 0
b = 0
for j in range(D):
if i >> j & 1:
a += 100 * P[j] * (j + 1) + C[j]
... | false | 15.151515 | [
"+\"\"\"",
"+bit全探索",
"+\"\"\"",
"- for l in range(P[k]):",
"+ for l in range(P[k] - 1):",
"- ans = min(ans, b)",
"+ if a >= G:",
"+ ans = min(ans, b)"
] | false | 0.045423 | 0.076073 | 0.597103 | [
"s009676493",
"s499427701"
] |
u301624971 | p02773 | python | s837558084 | s356518857 | 904 | 795 | 44,248 | 47,248 | Accepted | Accepted | 12.06 |
N = int(eval(input()))
C = dict()
for i in range(N):
a = eval(input())
if(a not in list(C.keys())):
C[a] = 1
else:
val = C[a]
C[a] = val + 1
m=0
for i in list(C.values()):
if(i > m):
m=i
ans = sorted(C.items())
for i in ans:
if(m==i[1]):
... | def myAnswer(N:int,S:list) -> None:
dic = {}
for s in S:
if(s in list(dic.keys())):
dic[s]+=1
else:
dic[s]=1
MAX = max(dic.values())
dic2 = sorted(dic.items())
for key,value in dic2:
if(MAX == value):
print(key)
def modelAnswer():
tmp=1
... | 22 | 24 | 312 | 466 | N = int(eval(input()))
C = dict()
for i in range(N):
a = eval(input())
if a not in list(C.keys()):
C[a] = 1
else:
val = C[a]
C[a] = val + 1
m = 0
for i in list(C.values()):
if i > m:
m = i
ans = sorted(C.items())
for i in ans:
if m == i[1]:
print((i[0]))
| def myAnswer(N: int, S: list) -> None:
dic = {}
for s in S:
if s in list(dic.keys()):
dic[s] += 1
else:
dic[s] = 1
MAX = max(dic.values())
dic2 = sorted(dic.items())
for key, value in dic2:
if MAX == value:
print(key)
def modelAnswer():
... | false | 8.333333 | [
"-N = int(eval(input()))",
"-C = dict()",
"-for i in range(N):",
"- a = eval(input())",
"- if a not in list(C.keys()):",
"- C[a] = 1",
"- else:",
"- val = C[a]",
"- C[a] = val + 1",
"-m = 0",
"-for i in list(C.values()):",
"- if i > m:",
"- m = i",
"... | false | 0.09852 | 0.042185 | 2.335409 | [
"s837558084",
"s356518857"
] |
u644907318 | p03005 | python | s740375757 | s400069525 | 178 | 64 | 38,384 | 61,808 | Accepted | Accepted | 64.04 | N,K = list(map(int,input().split()))
if K>1:
print((N-K))
else:
print((0)) | N,K = list(map(int,input().split()))
if K==1:
print((0))
else:
print((N-K)) | 5 | 5 | 76 | 77 | N, K = list(map(int, input().split()))
if K > 1:
print((N - K))
else:
print((0))
| N, K = list(map(int, input().split()))
if K == 1:
print((0))
else:
print((N - K))
| false | 0 | [
"-if K > 1:",
"+if K == 1:",
"+ print((0))",
"+else:",
"-else:",
"- print((0))"
] | false | 0.059085 | 0.035942 | 1.643905 | [
"s740375757",
"s400069525"
] |
u496744988 | p03575 | python | s125119170 | s617358894 | 73 | 63 | 6,972 | 6,208 | Accepted | Accepted | 13.7 | from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import random
import pprint
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().sp... | from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import random
import pprint
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().sp... | 90 | 81 | 2,051 | 1,939 | from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import random
import pprint
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
def LI():
return [int(x) for x in sys.stdin.readline().split()]
d... | from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import random
import pprint
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
def LI():
return [int(x) for x in sys.stdin.readline().split()]
d... | false | 10 | [
"-visited = [False] * n",
"-graph = [[False] * n for _ in range(n)]",
"-# 初期化、graph[i-1][j-1] = 1ならば頂点i,jは連結している",
"-for a, b in sides:",
"- graph[a - 1][b - 1] = True",
"- graph[b - 1][a - 1] = True",
"-# pprint.pprint(graph)",
"-for a, b in sides:",
"- # 辺の削除",
"- graph[a - 1][b - 1]... | false | 0.056497 | 0.047088 | 1.199823 | [
"s125119170",
"s617358894"
] |
u152992875 | p02950 | python | s769810473 | s119193196 | 864 | 768 | 175,004 | 174,748 | Accepted | Accepted | 11.11 | p = eval(input())
a = list(map(int, input().strip().split()))
b = [0] * p
p2 = p * p
s = []
for i in range(p):
if a[i]: s.append(i)
ncr = [[0 for i in range(p)] for j in range(p)]
for i in range(p):
ncr[i][0] = ncr[i][i] = 1
ncr[i][1] = i
for n in range(2, p):
for r in range(2, n):... | p = eval(input())
a = list(map(int, input().strip().split()))
b = [0] * p
p2 = p * p
s = []
for i in range(p):
if a[i]: s.append(i)
ncr = [[0 for i in range(p)] for j in range(p)]
for i in range(p):
ncr[i][0] = ncr[i][i] = 1
ncr[i][1] = i
for n in range(2, p):
for r in range(2, n):... | 45 | 45 | 920 | 919 | p = eval(input())
a = list(map(int, input().strip().split()))
b = [0] * p
p2 = p * p
s = []
for i in range(p):
if a[i]:
s.append(i)
ncr = [[0 for i in range(p)] for j in range(p)]
for i in range(p):
ncr[i][0] = ncr[i][i] = 1
ncr[i][1] = i
for n in range(2, p):
for r in range(2, n):
ncr[n... | p = eval(input())
a = list(map(int, input().strip().split()))
b = [0] * p
p2 = p * p
s = []
for i in range(p):
if a[i]:
s.append(i)
ncr = [[0 for i in range(p)] for j in range(p)]
for i in range(p):
ncr[i][0] = ncr[i][i] = 1
ncr[i][1] = i
for n in range(2, p):
for r in range(2, n):
ncr[n... | false | 0 | [
"- if val >= p2:",
"+ if val >= p:"
] | false | 0.086503 | 0.035987 | 2.40374 | [
"s769810473",
"s119193196"
] |
u723711163 | p02813 | python | s904701881 | s538198428 | 273 | 120 | 54,236 | 82,156 | Accepted | Accepted | 56.04 | N = int(eval(input()))
p1 = tuple(map(int,input().split()))
p2 = tuple(map(int,input().split()))
def dfs(pair=[]):
global lst
if len(pair) == N:
lst.append(tuple(pair))
else:
for j in range(1,N+1):
if j not in pair:
pair.append(j)
dfs(pair)
pair.pop()
lst = []
... | def LI():
return list(map(int, input().split()))
N = int(eval(input()))
P = LI()
Q = LI()
result = []
def permutations(N, cur):
if len(cur) == N:
result.append(cur)
return
for i in range(1, N+1):
if i not in cur:
permutations(N, cur+[i])
permutations(N,[])
result.sort()
pr... | 18 | 20 | 375 | 357 | N = int(eval(input()))
p1 = tuple(map(int, input().split()))
p2 = tuple(map(int, input().split()))
def dfs(pair=[]):
global lst
if len(pair) == N:
lst.append(tuple(pair))
else:
for j in range(1, N + 1):
if j not in pair:
pair.append(j)
dfs(pair)
... | def LI():
return list(map(int, input().split()))
N = int(eval(input()))
P = LI()
Q = LI()
result = []
def permutations(N, cur):
if len(cur) == N:
result.append(cur)
return
for i in range(1, N + 1):
if i not in cur:
permutations(N, cur + [i])
permutations(N, [])
resu... | false | 10 | [
"-N = int(eval(input()))",
"-p1 = tuple(map(int, input().split()))",
"-p2 = tuple(map(int, input().split()))",
"+def LI():",
"+ return list(map(int, input().split()))",
"-def dfs(pair=[]):",
"- global lst",
"- if len(pair) == N:",
"- lst.append(tuple(pair))",
"- else:",
"- ... | false | 0.043951 | 0.118813 | 0.36992 | [
"s904701881",
"s538198428"
] |
u867848444 | p02803 | python | s599121091 | s521677969 | 444 | 408 | 3,316 | 3,316 | Accepted | Accepted | 8.11 | #BFS
from collections import deque
def bfs(i,j):
q=deque()
q.append((i,j))
log=[[-1]*w for i in range(h)]
log[i][j]=0
dx=[0,1,0,-1]
dy=[1,0,-1,0]
long=0
while q:
#qの先頭を取り出す
p=q.popleft()
for i in range(4):
nx=p[0]+dx[i]
ny=p[... | #BFS
from collections import deque
def bfs(i, j):
q=deque()
q.append((i, j))
log = [[-1] * w for i in range(h)]
log[i][j] = 0
distance = 0
d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
while q:
#qの先頭を取り出す
p=q.popleft()
for x, y in d:
nx = p[0] + x
... | 35 | 35 | 833 | 910 | # BFS
from collections import deque
def bfs(i, j):
q = deque()
q.append((i, j))
log = [[-1] * w for i in range(h)]
log[i][j] = 0
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
long = 0
while q:
# qの先頭を取り出す
p = q.popleft()
for i in range(4):
nx = p[0] + dx[i]
... | # BFS
from collections import deque
def bfs(i, j):
q = deque()
q.append((i, j))
log = [[-1] * w for i in range(h)]
log[i][j] = 0
distance = 0
d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
while q:
# qの先頭を取り出す
p = q.popleft()
for x, y in d:
nx = p[0] + x
... | false | 0 | [
"- dx = [0, 1, 0, -1]",
"- dy = [1, 0, -1, 0]",
"- long = 0",
"+ distance = 0",
"+ d = [(1, 0), (0, 1), (-1, 0), (0, -1)]",
"- for i in range(4):",
"- nx = p[0] + dx[i]",
"- ny = p[1] + dy[i]",
"+ for x, y in d:",
"+ nx = p[0] + x",
"... | false | 0.099578 | 0.037703 | 2.641137 | [
"s599121091",
"s521677969"
] |
u777299405 | p02257 | python | s587666356 | s342514540 | 2,370 | 560 | 6,724 | 6,724 | Accepted | Accepted | 76.37 | def isprime(n):
i = 2
while i ** 2 <= n:
if n % i == 0:
return False
i += 1
return True
result = 0
for i in range(int(eval(input()))):
result += isprime(int(eval(input())))
print(result) | def isprime(n):
if n == 2:
return True
if n % 2 == 0:
return False
i = 3
while i * i <= n:
if n % i == 0:
return False
i += 2
return True
result = 0
for i in range(int(eval(input()))):
result += isprime(int(eval(input())))
print(result) | 12 | 16 | 230 | 308 | def isprime(n):
i = 2
while i**2 <= n:
if n % i == 0:
return False
i += 1
return True
result = 0
for i in range(int(eval(input()))):
result += isprime(int(eval(input())))
print(result)
| def isprime(n):
if n == 2:
return True
if n % 2 == 0:
return False
i = 3
while i * i <= n:
if n % i == 0:
return False
i += 2
return True
result = 0
for i in range(int(eval(input()))):
result += isprime(int(eval(input())))
print(result)
| false | 25 | [
"- i = 2",
"- while i**2 <= n:",
"+ if n == 2:",
"+ return True",
"+ if n % 2 == 0:",
"+ return False",
"+ i = 3",
"+ while i * i <= n:",
"- i += 1",
"+ i += 2"
] | false | 0.036838 | 0.160795 | 0.229101 | [
"s587666356",
"s342514540"
] |
u579699847 | p03497 | python | s568774558 | s726621122 | 122 | 107 | 32,564 | 32,568 | Accepted | Accepted | 12.3 | import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,K = LI()
A = collections.Counter(LI())
count_A = sorted([v for v in list(A.values())])
surplus = max(0,len(A)-K)
print((sum(count_A[:surplus])))
| import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,K = LI()
A = collections.Counter(LI())
value_A = sorted(A.values())
surplus = max(0,len(A)-K)
print((sum(value_A[:surplus])))
| 7 | 7 | 238 | 225 | import collections, sys
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
N, K = LI()
A = collections.Counter(LI())
count_A = sorted([v for v in list(A.values())])
surplus = max(0, len(A) - K)
print((sum(count_A[:surplus])))
| import collections, sys
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
N, K = LI()
A = collections.Counter(LI())
value_A = sorted(A.values())
surplus = max(0, len(A) - K)
print((sum(value_A[:surplus])))
| false | 0 | [
"-count_A = sorted([v for v in list(A.values())])",
"+value_A = sorted(A.values())",
"-print((sum(count_A[:surplus])))",
"+print((sum(value_A[:surplus])))"
] | false | 0.047177 | 0.046904 | 1.005822 | [
"s568774558",
"s726621122"
] |
u670180528 | p02728 | python | s463168092 | s768319782 | 2,765 | 2,327 | 80,736 | 93,780 | Accepted | Accepted | 15.84 | import sys
sys.setrecursionlimit(1234567890)
n, *L = map(int, open(0).read().split())
mod = 10 ** 9 + 7
con = [[] for _ in range(n + 1)]
sz = [1] * (n + 1)
par = [0] * (n + 1)
for s, t in zip(*[iter(L)] * 2):
con[s] += t,
con[t] += s,
def prepare(m, mod=10 ** 9 + 7):
fac = [1] * (m + 1)
inv = [1... | import sys
sys.setrecursionlimit(1234567890)
from collections import deque
n, *L = list(map(int, open(0).read().split()))
mod = 10 ** 9 + 7
def prepare(m, mod=10 ** 9 + 7):
fac = [1] * (m + 1)
inv = [1] * (m + 1)
for i in range(1, m + 1):
fac[i] = fac[i - 1] * i % mod
inv[-1] = pow(fac[-1], mod - ... | 57 | 49 | 1,203 | 1,083 | import sys
sys.setrecursionlimit(1234567890)
n, *L = map(int, open(0).read().split())
mod = 10**9 + 7
con = [[] for _ in range(n + 1)]
sz = [1] * (n + 1)
par = [0] * (n + 1)
for s, t in zip(*[iter(L)] * 2):
con[s] += (t,)
con[t] += (s,)
def prepare(m, mod=10**9 + 7):
fac = [1] * (m + 1)
inv = [1] * (... | import sys
sys.setrecursionlimit(1234567890)
from collections import deque
n, *L = list(map(int, open(0).read().split()))
mod = 10**9 + 7
def prepare(m, mod=10**9 + 7):
fac = [1] * (m + 1)
inv = [1] * (m + 1)
for i in range(1, m + 1):
fac[i] = fac[i - 1] * i % mod
inv[-1] = pow(fac[-1], mod ... | false | 14.035088 | [
"-n, *L = map(int, open(0).read().split())",
"+from collections import deque",
"+",
"+n, *L = list(map(int, open(0).read().split()))",
"-con = [[] for _ in range(n + 1)]",
"-sz = [1] * (n + 1)",
"-par = [0] * (n + 1)",
"-for s, t in zip(*[iter(L)] * 2):",
"- con[s] += (t,)",
"- con[t] += (s,... | false | 0.098855 | 0.045843 | 2.15637 | [
"s463168092",
"s768319782"
] |
u113835532 | p02772 | python | s156706982 | s812053696 | 30 | 27 | 9,172 | 9,148 | Accepted | Accepted | 10 | N = int(eval(input()))
ints = list(map(int, input().split()))
for i in ints:
if i % 2 == 0:
if i % 3 != 0 and i % 5 != 0:
print('DENIED')
exit()
print('APPROVED') | N = eval(input())
ints = (i for i in map(int, input().split()) if i % 2 == 0)
ints = (i % 3 == 0 or i % 5 == 0 for i in ints)
print(('APPROVED' if all(ints) else 'DENIED')) | 10 | 4 | 197 | 167 | N = int(eval(input()))
ints = list(map(int, input().split()))
for i in ints:
if i % 2 == 0:
if i % 3 != 0 and i % 5 != 0:
print("DENIED")
exit()
print("APPROVED")
| N = eval(input())
ints = (i for i in map(int, input().split()) if i % 2 == 0)
ints = (i % 3 == 0 or i % 5 == 0 for i in ints)
print(("APPROVED" if all(ints) else "DENIED"))
| false | 60 | [
"-N = int(eval(input()))",
"-ints = list(map(int, input().split()))",
"-for i in ints:",
"- if i % 2 == 0:",
"- if i % 3 != 0 and i % 5 != 0:",
"- print(\"DENIED\")",
"- exit()",
"-print(\"APPROVED\")",
"+N = eval(input())",
"+ints = (i for i in map(int, input().spl... | false | 0.044464 | 0.044936 | 0.989498 | [
"s156706982",
"s812053696"
] |
u835283937 | p03945 | python | s822822613 | s240749887 | 50 | 40 | 9,628 | 9,668 | Accepted | Accepted | 20 | def main():
S = list(eval(input()))
r = 0
for i in range(len(S) - 1):
if S[i] != S[i + 1]:
r += 1
S.reverse()
l = 0
for i in range(len(S) - 1):
if S[i] != S[i + 1]:
l += 1
print((min(r, l)))
if __name__ == "__main__":
m... | def main():
S = list(eval(input()))
ans = 0
for i in range(len(S) - 1):
if S[i] != S[i + 1]:
ans += 1
print(ans)
if __name__ == "__main__":
main() | 18 | 11 | 317 | 192 | def main():
S = list(eval(input()))
r = 0
for i in range(len(S) - 1):
if S[i] != S[i + 1]:
r += 1
S.reverse()
l = 0
for i in range(len(S) - 1):
if S[i] != S[i + 1]:
l += 1
print((min(r, l)))
if __name__ == "__main__":
main()
| def main():
S = list(eval(input()))
ans = 0
for i in range(len(S) - 1):
if S[i] != S[i + 1]:
ans += 1
print(ans)
if __name__ == "__main__":
main()
| false | 38.888889 | [
"- r = 0",
"+ ans = 0",
"- r += 1",
"- S.reverse()",
"- l = 0",
"- for i in range(len(S) - 1):",
"- if S[i] != S[i + 1]:",
"- l += 1",
"- print((min(r, l)))",
"+ ans += 1",
"+ print(ans)"
] | false | 0.046844 | 0.04776 | 0.980822 | [
"s822822613",
"s240749887"
] |
u934442292 | p03013 | python | s433099026 | s515589820 | 315 | 62 | 7,028 | 13,780 | Accepted | Accepted | 80.32 | MOD = 10**9 + 7
N, M = [int(i) for i in input().strip().split()]
dirty_step_idxs = [0] * M
for i in range(M):
dirty_step_idx = int(eval(input()))
dirty_step_idxs[i] = dirty_step_idx
def fibonacci(n):
# 0, 1, 1, 2, 3, 5, 8, ...
a, b = 0, 1
for i in range(n-1):
a, b = b, a + b
return a
... | import sys
input = sys.stdin.readline
P = 10 ** 9 + 7
def main():
N, M = list(map(int, input().split()))
A = [0] * M
for i in range(M):
A[i] = int(eval(input()))
for i in range(M - 1):
if A[i] + 1 == A[i + 1]:
print((0))
exit()
broken =... | 31 | 38 | 685 | 674 | MOD = 10**9 + 7
N, M = [int(i) for i in input().strip().split()]
dirty_step_idxs = [0] * M
for i in range(M):
dirty_step_idx = int(eval(input()))
dirty_step_idxs[i] = dirty_step_idx
def fibonacci(n):
# 0, 1, 1, 2, 3, 5, 8, ...
a, b = 0, 1
for i in range(n - 1):
a, b = b, a + b
return a... | import sys
input = sys.stdin.readline
P = 10**9 + 7
def main():
N, M = list(map(int, input().split()))
A = [0] * M
for i in range(M):
A[i] = int(eval(input()))
for i in range(M - 1):
if A[i] + 1 == A[i + 1]:
print((0))
exit()
broken = [False] * (N + 1)
... | false | 18.421053 | [
"-MOD = 10**9 + 7",
"-N, M = [int(i) for i in input().strip().split()]",
"-dirty_step_idxs = [0] * M",
"-for i in range(M):",
"- dirty_step_idx = int(eval(input()))",
"- dirty_step_idxs[i] = dirty_step_idx",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+P = 10**9 + 7",
"-def fibonac... | false | 0.034946 | 0.035923 | 0.972803 | [
"s433099026",
"s515589820"
] |
u088552457 | p03681 | python | s814876548 | s117657979 | 371 | 282 | 47,580 | 86,676 | Accepted | Accepted | 23.99 | import math
a, b = list(map(int, input().split()))
fa = math.factorial(a)
fb = math.factorial(b)
mod = 10**9 + 7
fa %= mod
fb %= mod
k = fa*fb
if abs(a-b) >= 2:
print((0))
elif abs(a-b) == 1:
print((k%mod))
elif abs(a-b) == 0:
print(((2*k) % mod)) | import sys
input = sys.stdin.readline
import math
def main():
n, m = input_list()
if abs(n-m) > 1:
print((0))
exit()
mod = 10**9 + 7
diff = abs(n-m)
if diff == 1:
ans = math.factorial(n) * math.factorial(m)
print((ans % mod))
else:
ans = 2 ... | 16 | 35 | 258 | 764 | import math
a, b = list(map(int, input().split()))
fa = math.factorial(a)
fb = math.factorial(b)
mod = 10**9 + 7
fa %= mod
fb %= mod
k = fa * fb
if abs(a - b) >= 2:
print((0))
elif abs(a - b) == 1:
print((k % mod))
elif abs(a - b) == 0:
print(((2 * k) % mod))
| import sys
input = sys.stdin.readline
import math
def main():
n, m = input_list()
if abs(n - m) > 1:
print((0))
exit()
mod = 10**9 + 7
diff = abs(n - m)
if diff == 1:
ans = math.factorial(n) * math.factorial(m)
print((ans % mod))
else:
ans = 2 * (math.f... | false | 54.285714 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"-a, b = list(map(int, input().split()))",
"-fa = math.factorial(a)",
"-fb = math.factorial(b)",
"-mod = 10**9 + 7",
"-fa %= mod",
"-fb %= mod",
"-k = fa * fb",
"-if abs(a - b) >= 2:",
"- print((0))",
"-elif abs(a - b) == 1:",
"- pri... | false | 0.045958 | 0.052084 | 0.882373 | [
"s814876548",
"s117657979"
] |
u967268722 | p02413 | python | s723863892 | s762435373 | 30 | 20 | 6,228 | 5,688 | Accepted | Accepted | 33.33 | m,n=map(int,input().split())
a =[]
for _ in range(m):
a.append(list(map(int,input().split())))
for index in range(m):
a[index].append(sum(a[index]))
for a_column in a:
for num in a_column[:-1]:
print(num, end=' ')
print(a_column[-1])
for row_index in range(n):
sum = 0
for a_c... | m,n=list(map(int,input().split()))
a =[]
for _ in range(m):
a.append(list(map(int,input().split())))
for index in range(m):
a[index].append(sum(a[index]))
for a_column in a:
print((' '.join(map(str, a_column))))
a.append([0]*(n+1))
for row_index in range(n+1):
for a_column in a[:-1]:
... | 20 | 14 | 461 | 388 | m, n = map(int, input().split())
a = []
for _ in range(m):
a.append(list(map(int, input().split())))
for index in range(m):
a[index].append(sum(a[index]))
for a_column in a:
for num in a_column[:-1]:
print(num, end=" ")
print(a_column[-1])
for row_index in range(n):
sum = 0
for a_column ... | m, n = list(map(int, input().split()))
a = []
for _ in range(m):
a.append(list(map(int, input().split())))
for index in range(m):
a[index].append(sum(a[index]))
for a_column in a:
print((" ".join(map(str, a_column))))
a.append([0] * (n + 1))
for row_index in range(n + 1):
for a_column in a[:-1]:
... | false | 30 | [
"-m, n = map(int, input().split())",
"+m, n = list(map(int, input().split()))",
"- for num in a_column[:-1]:",
"- print(num, end=\" \")",
"- print(a_column[-1])",
"-for row_index in range(n):",
"- sum = 0",
"- for a_column in a:",
"- sum += a_column[row_index]",
"- pri... | false | 0.124793 | 0.038061 | 3.278773 | [
"s723863892",
"s762435373"
] |
u285891772 | p03240 | python | s848174420 | s027746665 | 680 | 550 | 5,204 | 5,316 | Accepted | Accepted | 19.12 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter,... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter,... | 49 | 46 | 1,389 | 1,358 | import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
log2,
)
from itertools import (
accumulate,
permutations,
combinations,
combi... | import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
log2,
)
from itertools import (
accumulate,
permutations,
combinations,
combi... | false | 6.122449 | [
"-h_dict = defaultdict(int)"
] | false | 0.108519 | 0.083927 | 1.293013 | [
"s848174420",
"s027746665"
] |
u144913062 | p03677 | python | s570521433 | s418212717 | 165 | 96 | 82,204 | 91,776 | Accepted | Accepted | 41.82 | import sys
input = sys.stdin.readline
class BIT:
def __init__(self, size):
self.bit = [0] * (size + 1)
self.size = size
def sum(self, i):
i += 1
s = 0
while i > 0:
s += self.bit[i]
i -= i & -i
return s
def add(self, i... | from itertools import accumulate
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
a = list([int(x) - 1 for x in input().split()])
cnt0 = [0] * m
cnt1 = [0] * m
for i in range(n-1):
cnt0[a[i+1]] += (a[i+1] - a[i]) % m - 1
if (a[i] + 1) % m <= a[i+1]:
cnt1[(a[i]+1... | 50 | 29 | 1,100 | 684 | import sys
input = sys.stdin.readline
class BIT:
def __init__(self, size):
self.bit = [0] * (size + 1)
self.size = size
def sum(self, i):
i += 1
s = 0
while i > 0:
s += self.bit[i]
i -= i & -i
return s
def add(self, i, x):
... | from itertools import accumulate
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
a = list([int(x) - 1 for x in input().split()])
cnt0 = [0] * m
cnt1 = [0] * m
for i in range(n - 1):
cnt0[a[i + 1]] += (a[i + 1] - a[i]) % m - 1
if (a[i] + 1) % m <= a[i + 1]:
cnt1[(a[i] + 1) %... | false | 42 | [
"+from itertools import accumulate",
"-",
"-",
"-class BIT:",
"- def __init__(self, size):",
"- self.bit = [0] * (size + 1)",
"- self.size = size",
"-",
"- def sum(self, i):",
"- i += 1",
"- s = 0",
"- while i > 0:",
"- s += self.bit[i]",
... | false | 0.084282 | 0.044372 | 1.89942 | [
"s570521433",
"s418212717"
] |
u629540524 | p03644 | python | s911868218 | s989606918 | 20 | 17 | 2,940 | 2,940 | Accepted | Accepted | 15 | n = int(eval(input()))
count = 0
while 2**count <= n:
count += 1
print((2**(count-1))) | n = int(eval(input()))
count = 0
while 2**count <= n:
x = 2**count
count += 1
print(x) | 5 | 6 | 86 | 93 | n = int(eval(input()))
count = 0
while 2**count <= n:
count += 1
print((2 ** (count - 1)))
| n = int(eval(input()))
count = 0
while 2**count <= n:
x = 2**count
count += 1
print(x)
| false | 16.666667 | [
"+ x = 2**count",
"-print((2 ** (count - 1)))",
"+print(x)"
] | false | 0.045395 | 0.04968 | 0.913751 | [
"s911868218",
"s989606918"
] |
u957470671 | p02316 | python | s439230348 | s948410095 | 960 | 540 | 15,692 | 5,724 | Accepted | Accepted | 43.75 | # Knapsack Problem
N, W = [int(x) for x in input().split()]
items = []
for i in range(N):
items.append(tuple(int(x) for x in input().split()))
DP = [[0] * (W+1) for _ in range(N+1)]
for i in range(N):
for j in range(W+1):
v, w = items[i]
if w <= j:
DP[i+1][j] = max(DP[i... | # Knapsack Problem
N, W = [int(x) for x in input().split()]
items = []
for i in range(N):
items.append(tuple(int(x) for x in input().split()))
DP = [0] * (W+1)
for i in range(N):
v, w = items[i]
for j in range(w, W+1):
DP[j] = max(DP[j], v + DP[j-w])
print((DP[-1])) | 17 | 14 | 414 | 300 | # Knapsack Problem
N, W = [int(x) for x in input().split()]
items = []
for i in range(N):
items.append(tuple(int(x) for x in input().split()))
DP = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
for j in range(W + 1):
v, w = items[i]
if w <= j:
DP[i + 1][j] = max(DP[i][j], ... | # Knapsack Problem
N, W = [int(x) for x in input().split()]
items = []
for i in range(N):
items.append(tuple(int(x) for x in input().split()))
DP = [0] * (W + 1)
for i in range(N):
v, w = items[i]
for j in range(w, W + 1):
DP[j] = max(DP[j], v + DP[j - w])
print((DP[-1]))
| false | 17.647059 | [
"-DP = [[0] * (W + 1) for _ in range(N + 1)]",
"+DP = [0] * (W + 1)",
"- for j in range(W + 1):",
"- v, w = items[i]",
"- if w <= j:",
"- DP[i + 1][j] = max(DP[i][j], v + DP[i + 1][j - w])",
"- else:",
"- DP[i + 1][j] = DP[i][j]",
"-print((DP[-1][-1]))",... | false | 0.039886 | 0.038715 | 1.030262 | [
"s439230348",
"s948410095"
] |
u757117214 | p03105 | python | s243778133 | s800974480 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | A,B,C=list(map(int,input().split()))
s=B//A
print((s if s<C else C)) | a,b,c = list(map(int,input().split()))
print((min(c, b//a))) | 3 | 2 | 62 | 53 | A, B, C = list(map(int, input().split()))
s = B // A
print((s if s < C else C))
| a, b, c = list(map(int, input().split()))
print((min(c, b // a)))
| false | 33.333333 | [
"-A, B, C = list(map(int, input().split()))",
"-s = B // A",
"-print((s if s < C else C))",
"+a, b, c = list(map(int, input().split()))",
"+print((min(c, b // a)))"
] | false | 0.050359 | 0.04998 | 1.00758 | [
"s243778133",
"s800974480"
] |
u278356323 | p03610 | python | s661018831 | s870283413 | 72 | 28 | 4,596 | 3,188 | Accepted | Accepted | 61.11 | # ABC073b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
s = input()
for i in range(0, len(s), 2):
print(s[i], end='')
| # ABC073b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
s = eval(input())
ans = ''
for i in range(0, len(s), 2):
ans += s[i]
print(ans) | 9 | 11 | 152 | 166 | # ABC073b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
s = input()
for i in range(0, len(s), 2):
print(s[i], end="")
| # ABC073b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
s = eval(input())
ans = ""
for i in range(0, len(s), 2):
ans += s[i]
print(ans)
| false | 18.181818 | [
"-s = input()",
"+s = eval(input())",
"+ans = \"\"",
"- print(s[i], end=\"\")",
"+ ans += s[i]",
"+print(ans)"
] | false | 0.0439 | 0.042203 | 1.040201 | [
"s661018831",
"s870283413"
] |
u844789719 | p02803 | python | s265362006 | s396540950 | 386 | 203 | 52,572 | 40,264 | Accepted | Accepted | 47.41 | import copy, collections, itertools
H, W = [int(_) for _ in input().split()]
S_ = [['#'] * (W + 2)] + [['#'] + list(eval(input())) + ['#']
for _ in range(H)] + [['#'] * (W + 2)]
ans = 0
for i, j in itertools.product(list(range(1, H + 1)), list(range(1, W + 1))):
if S_[i][j] == '.':
... | import collections
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
H, W, *S = open(0).read().split()
H, W = [int(_) for _ in [H, W]]
A = []
B = []
C = []
for i in range(H * W):
x, y = divmod(i, W)
if S[x][y] == '.':
for dx, dy in ((1, ... | 19 | 23 | 720 | 684 | import copy, collections, itertools
H, W = [int(_) for _ in input().split()]
S_ = (
[["#"] * (W + 2)]
+ [["#"] + list(eval(input())) + ["#"] for _ in range(H)]
+ [["#"] * (W + 2)]
)
ans = 0
for i, j in itertools.product(list(range(1, H + 1)), list(range(1, W + 1))):
if S_[i][j] == ".":
S = copy... | import collections
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
H, W, *S = open(0).read().split()
H, W = [int(_) for _ in [H, W]]
A = []
B = []
C = []
for i in range(H * W):
x, y = divmod(i, W)
if S[x][y] == ".":
for dx, dy in ((1, 0), (0, 1), (... | false | 17.391304 | [
"-import copy, collections, itertools",
"+import collections",
"+import numpy as np",
"+from scipy.sparse import csr_matrix",
"+from scipy.sparse.csgraph import floyd_warshall",
"-H, W = [int(_) for _ in input().split()]",
"-S_ = (",
"- [[\"#\"] * (W + 2)]",
"- + [[\"#\"] + list(eval(input()))... | false | 0.040499 | 0.334866 | 0.120941 | [
"s265362006",
"s396540950"
] |
u375616706 | p03614 | python | s393350272 | s013445093 | 80 | 67 | 13,876 | 13,876 | Accepted | Accepted | 16.25 | # python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
seq = 0
ans = 0
for i in range(N):
A[i] -= i+1
if A[i] == 0:
seq += 1
else:
ans += (seq+1)//2
seq = 0
ans +=... | # python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
seq = 0
ans = 0
for i in range(1, N+1):
if A[i-1] == i:
seq += 1
else:
ans += (seq+1)//2
seq = 0
ans += (seq+1)//... | 19 | 18 | 338 | 328 | # python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
seq = 0
ans = 0
for i in range(N):
A[i] -= i + 1
if A[i] == 0:
seq += 1
else:
ans += (seq + 1) // 2
seq = 0
ans += (seq + 1) /... | # python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
seq = 0
ans = 0
for i in range(1, N + 1):
if A[i - 1] == i:
seq += 1
else:
ans += (seq + 1) // 2
seq = 0
ans += (seq + 1) // 2
pri... | false | 5.263158 | [
"-for i in range(N):",
"- A[i] -= i + 1",
"- if A[i] == 0:",
"+for i in range(1, N + 1):",
"+ if A[i - 1] == i:"
] | false | 0.136686 | 0.094508 | 1.446288 | [
"s393350272",
"s013445093"
] |
u798818115 | p02924 | python | s050715797 | s377235080 | 21 | 17 | 3,060 | 2,940 | Accepted | Accepted | 19.05 | # coding: utf-8
# Your code here!
N=int(eval(input()))
print((int(N*(N-1)//2))) | # coding: utf-8
# Your code here!
N=int(eval(input()))
print((N*(N-1)//2)) | 5 | 6 | 77 | 73 | # coding: utf-8
# Your code here!
N = int(eval(input()))
print((int(N * (N - 1) // 2)))
| # coding: utf-8
# Your code here!
N = int(eval(input()))
print((N * (N - 1) // 2))
| false | 16.666667 | [
"-print((int(N * (N - 1) // 2)))",
"+print((N * (N - 1) // 2))"
] | false | 0.049182 | 0.048855 | 1.006687 | [
"s050715797",
"s377235080"
] |
u375695365 | p03503 | python | s402782281 | s011336229 | 267 | 139 | 3,064 | 3,064 | Accepted | Accepted | 47.94 | 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)]
#利益
ans=-10**50
for z in product((0, 1), repeat=10):#bit全探索のくみあわせを勝手に作ってくれるので使うとよい
profit_count=0 #利益の合計
for i in range(n):
wor... | #Forestの
n = int(eval(input()))
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]
ans = -10 ** 30
for i in range(1, 2 ** 10):
cnt = [0] * n
calc = 0
#print(cnt)
for j in range(10):
if i >> j & 1:
for k in rang... | 21 | 23 | 673 | 511 | 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)]
# 利益
ans = -(10**50)
for z in product((0, 1), repeat=10): # bit全探索のくみあわせを勝手に作ってくれるので使うとよい
profit_count = 0 # 利益の合計
for i in range(n):
... | # Forestの
n = int(eval(input()))
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]
ans = -(10**30)
for i in range(1, 2**10):
cnt = [0] * n
calc = 0
# print(cnt)
for j in range(10):
if i >> j & 1:
for k in range(n):
... | false | 8.695652 | [
"-from itertools import product",
"-",
"+# Forestの",
"-# 曜日",
"-# 利益",
"-ans = -(10**50)",
"-for z in product((0, 1), repeat=10): # bit全探索のくみあわせを勝手に作ってくれるので使うとよい",
"- profit_count = 0 # 利益の合計",
"- for i in range(n):",
"- work_count = 0 # 働く時間帯が同じ回数",
"- for j in range(10):... | false | 0.04142 | 0.068488 | 0.604773 | [
"s402782281",
"s011336229"
] |
u416011173 | p03031 | python | s588095589 | s314908686 | 38 | 35 | 9,252 | 9,216 | Accepted | Accepted | 7.89 | # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
# 標準入力を取得
N, M = list(map(int, input().split()))
k, s = [], []
for m in range(M):
l = list(map(int, input().split()))
k_m, s_m = l[0], l[1:]
k.appe... | # -*- coding: utf-8 -*-
# 標準入力を取得
N, M = list(map(int, input().split()))
k, s = [], []
for m in range(M):
l = list(map(int, input().split()))
k.append(l[0])
s.append(l[1:])
p = list(map(int, input().split()))
# 求解処理
ans = 0
for bit in range(1 << N):
is_light_on = True
for m in range(M... | 73 | 27 | 1,490 | 591 | # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
# 標準入力を取得
N, M = list(map(int, input().split()))
k, s = [], []
for m in range(M):
l = list(map(int, input().split()))
k_m, s_m = l[0], l[1:]
k.append(k_m)
s... | # -*- coding: utf-8 -*-
# 標準入力を取得
N, M = list(map(int, input().split()))
k, s = [], []
for m in range(M):
l = list(map(int, input().split()))
k.append(l[0])
s.append(l[1:])
p = list(map(int, input().split()))
# 求解処理
ans = 0
for bit in range(1 << N):
is_light_on = True
for m in range(M):
on_c... | false | 63.013699 | [
"-def get_input() -> tuple:",
"- \"\"\"",
"- 標準入力を取得する.",
"- Returns:\\n",
"- tuple: 標準入力",
"- \"\"\"",
"- # 標準入力を取得",
"- N, M = list(map(int, input().split()))",
"- k, s = [], []",
"+# 標準入力を取得",
"+N, M = list(map(int, input().split()))",
"+k, s = [], []",
"+for m... | false | 0.03793 | 0.085544 | 0.443392 | [
"s588095589",
"s314908686"
] |
u760248716 | p03911 | python | s531243069 | s014005122 | 933 | 826 | 167,136 | 167,088 | Accepted | Accepted | 11.47 | from networkx import*
g=[]
for _,*t in[*list(map(str.split,open(i:=0)))][1:]:
for j in t:g+=(i,'!'+j),
i+=1
print(('NYOE S'[is_connected(Graph(g))::2])) | from networkx import*
g=[]
for t in[*open(i:=0)][1:]:
for j in t.split()[1:]:g+=(i,'!'+j),
i+=1
print(('NYOE S'[is_connected(Graph(g))::2])) | 6 | 6 | 151 | 145 | from networkx import *
g = []
for _, *t in [*list(map(str.split, open(i := 0)))][1:]:
for j in t:
g += ((i, "!" + j),)
i += 1
print(("NYOE S"[is_connected(Graph(g)) :: 2]))
| from networkx import *
g = []
for t in [*open(i := 0)][1:]:
for j in t.split()[1:]:
g += ((i, "!" + j),)
i += 1
print(("NYOE S"[is_connected(Graph(g)) :: 2]))
| false | 0 | [
"-for _, *t in [*list(map(str.split, open(i := 0)))][1:]:",
"- for j in t:",
"+for t in [*open(i := 0)][1:]:",
"+ for j in t.split()[1:]:"
] | false | 0.033897 | 0.04285 | 0.791058 | [
"s531243069",
"s014005122"
] |
u011062360 | p03329 | python | s202411598 | s786790516 | 425 | 209 | 3,860 | 8,876 | Accepted | Accepted | 50.82 | n = int(eval(input()))
dp = [0]
for i in range(1, n+1):
q = []
q.append(1+dp[i-1])
a = 1
while True:
a *= 6
if a > i:
break
q.append(1+dp[i-a])
b = 1
while True:
b *= 9
if b > i:
break
q.append(1+dp[i-b... | n = int(eval(input()))
ans = pow(10, 10)
for i in range(n+1):
cnt = 0
j = n - i
while i > 0:
cnt += i % 6
i //= 6
while j > 0:
cnt += j % 9
j //= 9
ans = min(ans, cnt)
print(ans) | 24 | 17 | 357 | 244 | n = int(eval(input()))
dp = [0]
for i in range(1, n + 1):
q = []
q.append(1 + dp[i - 1])
a = 1
while True:
a *= 6
if a > i:
break
q.append(1 + dp[i - a])
b = 1
while True:
b *= 9
if b > i:
break
q.append(1 + dp[i - b])
d... | n = int(eval(input()))
ans = pow(10, 10)
for i in range(n + 1):
cnt = 0
j = n - i
while i > 0:
cnt += i % 6
i //= 6
while j > 0:
cnt += j % 9
j //= 9
ans = min(ans, cnt)
print(ans)
| false | 29.166667 | [
"-dp = [0]",
"-for i in range(1, n + 1):",
"- q = []",
"- q.append(1 + dp[i - 1])",
"- a = 1",
"- while True:",
"- a *= 6",
"- if a > i:",
"- break",
"- q.append(1 + dp[i - a])",
"- b = 1",
"- while True:",
"- b *= 9",
"- if b... | false | 0.159826 | 0.064313 | 2.485118 | [
"s202411598",
"s786790516"
] |
u077291787 | p02658 | python | s397166112 | s668187580 | 51 | 40 | 21,584 | 19,280 | Accepted | Accepted | 21.57 | # B - Multiplication 2
def main():
_, *A = list(map(int, open(0).read().split()))
if 0 in A:
print((0))
return
prod = 1
LIM = 10 ** 18
for i in A:
prod *= i
if prod > LIM:
print((-1))
return
print(prod)
if __name__ == "__... | # B - Multiplication 2
def main():
_, *A = open(0).read().split()
if "0" in A:
print((0))
return
prod = 1
LIM = 10 ** 18
for i in A:
prod *= int(i)
if prod > LIM:
print((-1))
return
print(prod)
if __name__ == "__main__":
... | 18 | 18 | 331 | 327 | # B - Multiplication 2
def main():
_, *A = list(map(int, open(0).read().split()))
if 0 in A:
print((0))
return
prod = 1
LIM = 10**18
for i in A:
prod *= i
if prod > LIM:
print((-1))
return
print(prod)
if __name__ == "__main__":
main()... | # B - Multiplication 2
def main():
_, *A = open(0).read().split()
if "0" in A:
print((0))
return
prod = 1
LIM = 10**18
for i in A:
prod *= int(i)
if prod > LIM:
print((-1))
return
print(prod)
if __name__ == "__main__":
main()
| false | 0 | [
"- _, *A = list(map(int, open(0).read().split()))",
"- if 0 in A:",
"+ _, *A = open(0).read().split()",
"+ if \"0\" in A:",
"- prod *= i",
"+ prod *= int(i)"
] | false | 0.041339 | 0.04211 | 0.981695 | [
"s397166112",
"s668187580"
] |
u785795721 | p02947 | python | s895751869 | s796915005 | 391 | 355 | 19,504 | 19,400 | Accepted | Accepted | 9.21 | n = int(eval(input()))
S = ["".join(list(sorted(eval(input())))) for _ in range(n)]
d = {}
for i in S:
d.setdefault(i, 0)
d[i] += 1
ans = 0
for value in list(d.values()):
ans += value * (value - 1) / 2
print((int(ans))) | n = int(eval(input()))
S = [''.join(sorted(eval(input()))) for _ in range(n)]
d = {}
for i in S:
d.setdefault(i, 0)
d[i] += 1
ans = 0
for value in list(d.values()):
ans += value * (value - 1) // 2
print(ans) | 10 | 10 | 220 | 210 | n = int(eval(input()))
S = ["".join(list(sorted(eval(input())))) for _ in range(n)]
d = {}
for i in S:
d.setdefault(i, 0)
d[i] += 1
ans = 0
for value in list(d.values()):
ans += value * (value - 1) / 2
print((int(ans)))
| n = int(eval(input()))
S = ["".join(sorted(eval(input()))) for _ in range(n)]
d = {}
for i in S:
d.setdefault(i, 0)
d[i] += 1
ans = 0
for value in list(d.values()):
ans += value * (value - 1) // 2
print(ans)
| false | 0 | [
"-S = [\"\".join(list(sorted(eval(input())))) for _ in range(n)]",
"+S = [\"\".join(sorted(eval(input()))) for _ in range(n)]",
"- ans += value * (value - 1) / 2",
"-print((int(ans)))",
"+ ans += value * (value - 1) // 2",
"+print(ans)"
] | false | 0.042395 | 0.035146 | 1.206248 | [
"s895751869",
"s796915005"
] |
u903005414 | p03294 | python | s699480961 | s035013113 | 23 | 18 | 3,316 | 3,316 | Accepted | Accepted | 21.74 | def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
def lcm(a, b):
return a * b // gcd(a, b)
N = int(eval(input()))
A = list(map(int, input().split()))
l = 0
for i in range(1, len(A)):
l = lcm(A[i - 1], A[i])
ans = l - 1
ans = sum(A) - len(A)
print(ans)
| N = int(eval(input()))
A = list(map(int, input().split()))
ans = sum(A) - len(A)
print(ans)
| 17 | 4 | 282 | 89 | def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
def lcm(a, b):
return a * b // gcd(a, b)
N = int(eval(input()))
A = list(map(int, input().split()))
l = 0
for i in range(1, len(A)):
l = lcm(A[i - 1], A[i])
ans = l - 1
ans = sum(A) - len(A)
print(ans)
| N = int(eval(input()))
A = list(map(int, input().split()))
ans = sum(A) - len(A)
print(ans)
| false | 76.470588 | [
"-def gcd(a, b):",
"- return a if b == 0 else gcd(b, a % b)",
"-",
"-",
"-def lcm(a, b):",
"- return a * b // gcd(a, b)",
"-",
"-",
"-l = 0",
"-for i in range(1, len(A)):",
"- l = lcm(A[i - 1], A[i])",
"-ans = l - 1"
] | false | 0.078201 | 0.075941 | 1.029753 | [
"s699480961",
"s035013113"
] |
u496744988 | p03835 | python | s657374516 | s036720956 | 1,267 | 251 | 2,940 | 41,324 | Accepted | Accepted | 80.19 | k,s=list(map(int,input().split()))
cnt=0
for x in range(k+1):
for y in range(k+1):
if 0 <= s-x-y <=k:
cnt+=1
print(cnt)
| k, s = list(map(int, input().split()))
ans = 0
for x in range(k+1):
for y in range(k+1):
if 0 <= s - x - y <= k:
ans += 1
print(ans)
| 7 | 7 | 144 | 157 | k, s = list(map(int, input().split()))
cnt = 0
for x in range(k + 1):
for y in range(k + 1):
if 0 <= s - x - y <= k:
cnt += 1
print(cnt)
| k, s = list(map(int, input().split()))
ans = 0
for x in range(k + 1):
for y in range(k + 1):
if 0 <= s - x - y <= k:
ans += 1
print(ans)
| false | 0 | [
"-cnt = 0",
"+ans = 0",
"- cnt += 1",
"-print(cnt)",
"+ ans += 1",
"+print(ans)"
] | false | 0.032099 | 0.056004 | 0.573154 | [
"s657374516",
"s036720956"
] |
u600402037 | p03018 | python | s829809748 | s391352179 | 79 | 49 | 4,968 | 3,500 | Accepted | Accepted | 37.97 | import sys
stdin = sys.stdin
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip() # ignore trailing spaces
S = list(rs())
cur = 'D'
answer = 0
A_cnt = 0
for s in S:
if cur == 'A':
if s == 'A':
A_cnt += 1
el... | import sys
stdin = sys.stdin
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip() # ignore trailing spaces
S = rs()
S = S.replace('BC', 'D')
cnt_A = 0
answer = 0
for s in S:
if s == 'A':
cnt_A += 1
elif s == 'D':
a... | 51 | 19 | 1,059 | 379 | import sys
stdin = sys.stdin
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip() # ignore trailing spaces
S = list(rs())
cur = "D"
answer = 0
A_cnt = 0
for s in S:
if cur == "A":
if s == "A":
A_cnt += 1
elif s == "B":
... | import sys
stdin = sys.stdin
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip() # ignore trailing spaces
S = rs()
S = S.replace("BC", "D")
cnt_A = 0
answer = 0
for s in S:
if s == "A":
cnt_A += 1
elif s == "D":
answer += cnt_A
... | false | 62.745098 | [
"-S = list(rs())",
"-cur = \"D\"",
"+S = rs()",
"+S = S.replace(\"BC\", \"D\")",
"+cnt_A = 0",
"-A_cnt = 0",
"- if cur == \"A\":",
"- if s == \"A\":",
"- A_cnt += 1",
"- elif s == \"B\":",
"- cur = s",
"- else:",
"- cur = \"D\"",
"- ... | false | 0.066659 | 0.04693 | 1.420389 | [
"s829809748",
"s391352179"
] |
u936985471 | p03163 | python | s416786273 | s509474462 | 1,879 | 658 | 9,772 | 171,912 | Accepted | Accepted | 64.98 | def calc():
N,W=list(map(int,input().split()))
dp=[-1]*(W+1)
dp[0]=0
for i in range(N):
w,v=list(map(int,input().split()))
for j in range(W-w,-1,-1):
if dp[j]!=-1:
if dp[j+w]<dp[j]+v:
dp[j+w]=dp[j]+v
print((max(dp)))
calc() | N,W=list(map(int,input().split()))
weight=[0]*N
values=[0]*N
for i in range(N):
weight[i],values[i]=list(map(int,input().split()))
dp=[[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
for w in range(W+1):
if w>=weight[i]:
dp[i+1][w]=max(dp[i][w],dp[i][w-weight[i]]+values[i])
... | 13 | 16 | 266 | 369 | def calc():
N, W = list(map(int, input().split()))
dp = [-1] * (W + 1)
dp[0] = 0
for i in range(N):
w, v = list(map(int, input().split()))
for j in range(W - w, -1, -1):
if dp[j] != -1:
if dp[j + w] < dp[j] + v:
dp[j + w] = dp[j] + v
pr... | N, W = list(map(int, input().split()))
weight = [0] * N
values = [0] * N
for i in range(N):
weight[i], values[i] = list(map(int, input().split()))
dp = [[0 for i in range(W + 1)] for j in range(N + 1)]
for i in range(N):
for w in range(W + 1):
if w >= weight[i]:
dp[i + 1][w] = max(dp[i][w], ... | false | 18.75 | [
"-def calc():",
"- N, W = list(map(int, input().split()))",
"- dp = [-1] * (W + 1)",
"- dp[0] = 0",
"- for i in range(N):",
"- w, v = list(map(int, input().split()))",
"- for j in range(W - w, -1, -1):",
"- if dp[j] != -1:",
"- if dp[j + w] < dp[j]... | false | 0.045104 | 0.044828 | 1.006155 | [
"s416786273",
"s509474462"
] |
u761320129 | p03231 | python | s875042333 | s557364076 | 123 | 47 | 5,688 | 5,560 | Accepted | Accepted | 61.79 | import fractions
N,M = list(map(int,input().split()))
S = eval(input())
T = eval(input())
g = fractions.gcd(N,M)
lcm = N*M // g
for i in range(g):
a = S[N//g * i]
b = T[M//g * i]
if a != b:
print((-1))
exit()
print(lcm) | from fractions import gcd
N,M = list(map(int,input().split()))
S = eval(input())
T = eval(input())
g = gcd(N,M)
ans = N*M//g
print((ans if S[::N//g] == T[::M//g] else -1)) | 14 | 7 | 241 | 157 | import fractions
N, M = list(map(int, input().split()))
S = eval(input())
T = eval(input())
g = fractions.gcd(N, M)
lcm = N * M // g
for i in range(g):
a = S[N // g * i]
b = T[M // g * i]
if a != b:
print((-1))
exit()
print(lcm)
| from fractions import gcd
N, M = list(map(int, input().split()))
S = eval(input())
T = eval(input())
g = gcd(N, M)
ans = N * M // g
print((ans if S[:: N // g] == T[:: M // g] else -1))
| false | 50 | [
"-import fractions",
"+from fractions import gcd",
"-g = fractions.gcd(N, M)",
"-lcm = N * M // g",
"-for i in range(g):",
"- a = S[N // g * i]",
"- b = T[M // g * i]",
"- if a != b:",
"- print((-1))",
"- exit()",
"-print(lcm)",
"+g = gcd(N, M)",
"+ans = N * M // g",
... | false | 0.100122 | 0.18075 | 0.553925 | [
"s875042333",
"s557364076"
] |
u519939795 | p02899 | python | s311939460 | s887603190 | 316 | 111 | 21,464 | 14,008 | Accepted | Accepted | 64.87 | N=int(input())
A=list(map(int,input().split()))
ANS=[]
for i in range(N):
ANS+=[[A[i],i+1]]
ANS.sort()
for i in range(N):
print(ANS[i][1], end=' ')
| n = int(eval(input()))
l = list(map(int,input().split()))
ans = [0] * n
for i in range(n):
ans[l[i]-1] = i + 1
print((*ans))
| 8 | 7 | 162 | 126 | N = int(input())
A = list(map(int, input().split()))
ANS = []
for i in range(N):
ANS += [[A[i], i + 1]]
ANS.sort()
for i in range(N):
print(ANS[i][1], end=" ")
| n = int(eval(input()))
l = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
ans[l[i] - 1] = i + 1
print((*ans))
| false | 12.5 | [
"-N = int(input())",
"-A = list(map(int, input().split()))",
"-ANS = []",
"-for i in range(N):",
"- ANS += [[A[i], i + 1]]",
"-ANS.sort()",
"-for i in range(N):",
"- print(ANS[i][1], end=\" \")",
"+n = int(eval(input()))",
"+l = list(map(int, input().split()))",
"+ans = [0] * n",
"+for i... | false | 0.036476 | 0.037271 | 0.97866 | [
"s311939460",
"s887603190"
] |
u936985471 | p02912 | python | s182131593 | s623395247 | 244 | 159 | 14,380 | 14,224 | Accepted | Accepted | 34.84 | import heapq
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
hq=[]
for i in range(len(a)):
heapq.heappush(hq,-a[i])
if n==1:
for i in range(m):
hq[0]=(((-1)*hq[0])//2)*(-1)
else:
for i in range(m):
v=heapq.heappop(hq)
heapq.heappush(hq,((v*-1)//2)*(-1))
ans=0
f... | n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
for i in range(len(a)):
a[i]*=(-1)
import heapq
heapq.heapify(a)
for i in range(m):
val=heapq.heappop(a)
heapq.heappush(a,((val*(-1))//2)*(-1))
print((sum(a)*(-1))) | 21 | 13 | 386 | 245 | import heapq
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
hq = []
for i in range(len(a)):
heapq.heappush(hq, -a[i])
if n == 1:
for i in range(m):
hq[0] = (((-1) * hq[0]) // 2) * (-1)
else:
for i in range(m):
v = heapq.heappop(hq)
heapq.heappush(hq, ((v ... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(len(a)):
a[i] *= -1
import heapq
heapq.heapify(a)
for i in range(m):
val = heapq.heappop(a)
heapq.heappush(a, ((val * (-1)) // 2) * (-1))
print((sum(a) * (-1)))
| false | 38.095238 | [
"+n, m = list(map(int, input().split()))",
"+a = list(map(int, input().split()))",
"+for i in range(len(a)):",
"+ a[i] *= -1",
"-n, m = list(map(int, input().split()))",
"-a = list(map(int, input().split()))",
"-hq = []",
"-for i in range(len(a)):",
"- heapq.heappush(hq, -a[i])",
"-if n == 1... | false | 0.141405 | 0.128153 | 1.103414 | [
"s182131593",
"s623395247"
] |
u620084012 | p03575 | python | s044127082 | s033107759 | 1,859 | 201 | 3,316 | 42,348 | Accepted | Accepted | 89.19 | N, M = list(map(int, input().split()))
E = [list(map(int, input().split())) for k in range(M)]
ans = 0
for k in range(M):
F = E[:k]+E[k+1:]
D = [[10**9+7 for l in range(N)] for m in range(N)]
for p in range(N):
D[p][p] = 0
for n in F:
D[n[0]-1][n[1]-1] = D[n[1]-1][n[0]-1] = 1
... | N, M = list(map(int,input().split()))
P = [list(map(int,input().split())) for k in range(M)]
ans = 0
for i in range(M):
T = P[:i]+P[i+1:]
G = [[] for k in range(N)]
V = [0 for k in range(N)]
for e in T:
G[e[0]-1].append(e[1]-1)
G[e[1]-1].append(e[0]-1)
def dfs(visited,g... | 23 | 21 | 636 | 525 | N, M = list(map(int, input().split()))
E = [list(map(int, input().split())) for k in range(M)]
ans = 0
for k in range(M):
F = E[:k] + E[k + 1 :]
D = [[10**9 + 7 for l in range(N)] for m in range(N)]
for p in range(N):
D[p][p] = 0
for n in F:
D[n[0] - 1][n[1] - 1] = D[n[1] - 1][n[0] - 1] ... | N, M = list(map(int, input().split()))
P = [list(map(int, input().split())) for k in range(M)]
ans = 0
for i in range(M):
T = P[:i] + P[i + 1 :]
G = [[] for k in range(N)]
V = [0 for k in range(N)]
for e in T:
G[e[0] - 1].append(e[1] - 1)
G[e[1] - 1].append(e[0] - 1)
def dfs(visited... | false | 8.695652 | [
"-E = [list(map(int, input().split())) for k in range(M)]",
"+P = [list(map(int, input().split())) for k in range(M)]",
"-for k in range(M):",
"- F = E[:k] + E[k + 1 :]",
"- D = [[10**9 + 7 for l in range(N)] for m in range(N)]",
"- for p in range(N):",
"- D[p][p] = 0",
"- for n in ... | false | 0.059369 | 0.035989 | 1.649657 | [
"s044127082",
"s033107759"
] |
u686230543 | p02713 | python | s301161149 | s984868175 | 1,103 | 21 | 9,180 | 9,196 | Accepted | Accepted | 98.1 | from math import gcd
k = int(eval(input()))
sum_ = 0
for a in range(1, k + 1):
for b in range(1, k + 1):
gcd_ab = gcd(a, b)
for c in range(1, k + 1):
sum_ += gcd(c, gcd_ab)
print(sum_) | k = int(eval(input()))
count = [pow(k // max(i, 1), 3) for i in range(k + 1)]
for i in range(k, 0, -1):
for j in range(2 * i, k + 1, i):
count[i] -= count[j]
sum_ = 0
for i in range(k + 1):
sum_ += i * count[i]
print(sum_) | 10 | 13 | 204 | 240 | from math import gcd
k = int(eval(input()))
sum_ = 0
for a in range(1, k + 1):
for b in range(1, k + 1):
gcd_ab = gcd(a, b)
for c in range(1, k + 1):
sum_ += gcd(c, gcd_ab)
print(sum_)
| k = int(eval(input()))
count = [pow(k // max(i, 1), 3) for i in range(k + 1)]
for i in range(k, 0, -1):
for j in range(2 * i, k + 1, i):
count[i] -= count[j]
sum_ = 0
for i in range(k + 1):
sum_ += i * count[i]
print(sum_)
| false | 23.076923 | [
"-from math import gcd",
"-",
"+count = [pow(k // max(i, 1), 3) for i in range(k + 1)]",
"+for i in range(k, 0, -1):",
"+ for j in range(2 * i, k + 1, i):",
"+ count[i] -= count[j]",
"-for a in range(1, k + 1):",
"- for b in range(1, k + 1):",
"- gcd_ab = gcd(a, b)",
"- ... | false | 0.165642 | 0.045712 | 3.623572 | [
"s301161149",
"s984868175"
] |
u513081876 | p04031 | python | s854019149 | s056418850 | 23 | 18 | 2,940 | 3,060 | Accepted | Accepted | 21.74 | N = int(eval(input()))
a = sorted(map(int, input().split()))
cost = 10**9
for y in range(a[0], a[-1]+1):
cost = min(cost, sum([(x-y)**2 for x in a]))
print(cost) | N = int(eval(input()))
A = [int(i) for i in input().split()]
che1 = sum(A)//N
che2 = sum(A)//N + 1
ans1 = 0
ans2 = 0
for i in A:
ans1 += (i-che1)**2
ans2 += (i-che2)**2
print((min(ans1, ans2))) | 7 | 12 | 166 | 210 | N = int(eval(input()))
a = sorted(map(int, input().split()))
cost = 10**9
for y in range(a[0], a[-1] + 1):
cost = min(cost, sum([(x - y) ** 2 for x in a]))
print(cost)
| N = int(eval(input()))
A = [int(i) for i in input().split()]
che1 = sum(A) // N
che2 = sum(A) // N + 1
ans1 = 0
ans2 = 0
for i in A:
ans1 += (i - che1) ** 2
ans2 += (i - che2) ** 2
print((min(ans1, ans2)))
| false | 41.666667 | [
"-a = sorted(map(int, input().split()))",
"-cost = 10**9",
"-for y in range(a[0], a[-1] + 1):",
"- cost = min(cost, sum([(x - y) ** 2 for x in a]))",
"-print(cost)",
"+A = [int(i) for i in input().split()]",
"+che1 = sum(A) // N",
"+che2 = sum(A) // N + 1",
"+ans1 = 0",
"+ans2 = 0",
"+for i i... | false | 0.056746 | 0.036336 | 1.561698 | [
"s854019149",
"s056418850"
] |
u421674761 | p02695 | python | s513745742 | s785008063 | 1,967 | 1,181 | 9,024 | 9,108 | Accepted | Accepted | 39.96 | import itertools
n,m,q = list(map(int,input().split()))
abcd = [list(map(int,input().split())) for i in range(q)]
ans = 0
for iter in itertools.combinations_with_replacement(list(range(1,m+1)),n):
result = 0
for i in range(q):
a,b,c,d = abcd[i][0],abcd[i][1],abcd[i][2],abcd[i][3]
if it... | import itertools
n,m,q = list(map(int,input().split()))
abcd = [list(map(int,input().split())) for i in range(q)]
ans = 0
for A in itertools.combinations_with_replacement(list(range(1,m+1)),n):
tmp = 0
for i in range(q):
a,b,c,d = abcd[i]
if A[b-1] - A[a-1] == c:
tmp += ... | 14 | 15 | 407 | 355 | import itertools
n, m, q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for i in range(q)]
ans = 0
for iter in itertools.combinations_with_replacement(list(range(1, m + 1)), n):
result = 0
for i in range(q):
a, b, c, d = abcd[i][0], abcd[i][1], abcd[i][2], abcd[i][3]
... | import itertools
n, m, q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for i in range(q)]
ans = 0
for A in itertools.combinations_with_replacement(list(range(1, m + 1)), n):
tmp = 0
for i in range(q):
a, b, c, d = abcd[i]
if A[b - 1] - A[a - 1] == c:
tmp ... | false | 6.666667 | [
"-for iter in itertools.combinations_with_replacement(list(range(1, m + 1)), n):",
"- result = 0",
"+for A in itertools.combinations_with_replacement(list(range(1, m + 1)), n):",
"+ tmp = 0",
"- a, b, c, d = abcd[i][0], abcd[i][1], abcd[i][2], abcd[i][3]",
"- if iter[b - 1] - iter[a - ... | false | 0.059853 | 0.047533 | 1.259195 | [
"s513745742",
"s785008063"
] |
u285891772 | p03785 | python | s697111746 | s339700277 | 261 | 176 | 9,564 | 9,584 | Accepted | Accepted | 32.57 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemg... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemg... | 38 | 43 | 1,142 | 1,244 | import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
) # , log2, log
from itertools import (
accumulate,
permutations,
combinations,
... | import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
) # , log2, log
from itertools import (
accumulate,
permutations,
combinations,
... | false | 11.627907 | [
"-idx = 0",
"-ans = 0",
"-while idx < N:",
"- tmp = T[idx]",
"- if idx + C <= bisect(T, tmp + K):",
"- idx += C",
"- else:",
"- idx = bisect(T, tmp + K)",
"- ans += 1",
"+ans = 1",
"+cnt = 1",
"+t_limit = T[0] + K",
"+for i in range(1, N):",
"+ if cnt == C: # ... | false | 0.038942 | 0.03836 | 1.015177 | [
"s697111746",
"s339700277"
] |
u699089116 | p03721 | python | s736562396 | s270218218 | 597 | 216 | 53,720 | 11,640 | Accepted | Accepted | 63.82 | from collections import Counter
n, k = list(map(int, input().split()))
c = Counter()
for _ in range(n):
a, b = list(map(int, input().split()))
c[a] += b
c = sorted(list(c.items()), key=lambda x: x[0])
for i, v in c:
k -= v
if k <= 0:
print(i)
exit() | N, K = list(map(int, input().split()))
bucket = [0] * (10 ** 5 + 1)
for _ in range(N):
a, b = list(map(int, input().split()))
bucket[a] += b
cnt = 0
for i, c in enumerate(bucket):
if c == 0:
continue
cnt += c
if cnt >= K:
print(i)
exit() | 14 | 15 | 278 | 285 | from collections import Counter
n, k = list(map(int, input().split()))
c = Counter()
for _ in range(n):
a, b = list(map(int, input().split()))
c[a] += b
c = sorted(list(c.items()), key=lambda x: x[0])
for i, v in c:
k -= v
if k <= 0:
print(i)
exit()
| N, K = list(map(int, input().split()))
bucket = [0] * (10**5 + 1)
for _ in range(N):
a, b = list(map(int, input().split()))
bucket[a] += b
cnt = 0
for i, c in enumerate(bucket):
if c == 0:
continue
cnt += c
if cnt >= K:
print(i)
exit()
| false | 6.666667 | [
"-from collections import Counter",
"-",
"-n, k = list(map(int, input().split()))",
"-c = Counter()",
"-for _ in range(n):",
"+N, K = list(map(int, input().split()))",
"+bucket = [0] * (10**5 + 1)",
"+for _ in range(N):",
"- c[a] += b",
"-c = sorted(list(c.items()), key=lambda x: x[0])",
"-fo... | false | 0.044159 | 0.046073 | 0.958463 | [
"s736562396",
"s270218218"
] |
u624475441 | p03633 | python | s618568787 | s049415945 | 38 | 35 | 5,304 | 5,048 | Accepted | Accepted | 7.89 | import fractions
import functools
lcm=lambda x,y:x*y//fractions.gcd(x,y)
print((functools.reduce(lcm,[int(eval(input()))for _ in[0]*int(eval(input()))]))) | from fractions import gcd
l=1
for _ in[0]*int(eval(input())):
t=int(eval(input()))
l=l*t//gcd(l,t)
print(l) | 4 | 6 | 143 | 108 | import fractions
import functools
lcm = lambda x, y: x * y // fractions.gcd(x, y)
print((functools.reduce(lcm, [int(eval(input())) for _ in [0] * int(eval(input()))])))
| from fractions import gcd
l = 1
for _ in [0] * int(eval(input())):
t = int(eval(input()))
l = l * t // gcd(l, t)
print(l)
| false | 33.333333 | [
"-import fractions",
"-import functools",
"+from fractions import gcd",
"-lcm = lambda x, y: x * y // fractions.gcd(x, y)",
"-print((functools.reduce(lcm, [int(eval(input())) for _ in [0] * int(eval(input()))])))",
"+l = 1",
"+for _ in [0] * int(eval(input())):",
"+ t = int(eval(input()))",
"+ ... | false | 0.079626 | 0.171873 | 0.463287 | [
"s618568787",
"s049415945"
] |
u133936772 | p02916 | python | s342744973 | s253541113 | 19 | 17 | 3,060 | 3,060 | Accepted | Accepted | 10.53 | f=lambda:list(map(int,input().split()))
n=int(eval(input()))
a,b,c=f(),f(),f()
print((sum(b)+sum(c[a[i]-1] for i in range(n-1) if a[i+1]-a[i]==1))) | f=lambda:list(map(int,input().split()))
n,a,b,c=f()[0],f(),f(),f()
print((sum(b)+sum(c[a[i]-1] for i in range(n-1) if a[i+1]-a[i]==1))) | 4 | 3 | 142 | 135 | f = lambda: list(map(int, input().split()))
n = int(eval(input()))
a, b, c = f(), f(), f()
print((sum(b) + sum(c[a[i] - 1] for i in range(n - 1) if a[i + 1] - a[i] == 1)))
| f = lambda: list(map(int, input().split()))
n, a, b, c = f()[0], f(), f(), f()
print((sum(b) + sum(c[a[i] - 1] for i in range(n - 1) if a[i + 1] - a[i] == 1)))
| false | 25 | [
"-n = int(eval(input()))",
"-a, b, c = f(), f(), f()",
"+n, a, b, c = f()[0], f(), f(), f()"
] | false | 0.040143 | 0.041771 | 0.961037 | [
"s342744973",
"s253541113"
] |
u970348538 | p02573 | python | s152871322 | s284657698 | 1,227 | 1,043 | 291,236 | 291,436 | Accepted | Accepted | 15 | import sys
sys.setrecursionlimit(int(1e6))
def search(x, num):
nodes.remove(x)
for y in edge[x]:
edge[y].discard(x)
for y in list(edge[x]):
if y in nodes:
num = search(y, num)
return num + 1
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
edge = [set... | import sys
sys.setrecursionlimit(int(1e6))
def search(x, num):
nodes.remove(x)
# for y in edge[x]:
for y in list(edge[x]):
edge[y].remove(x)
if y in nodes:
num = search(y, num)
return num + 1
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
edge = [se... | 25 | 25 | 539 | 540 | import sys
sys.setrecursionlimit(int(1e6))
def search(x, num):
nodes.remove(x)
for y in edge[x]:
edge[y].discard(x)
for y in list(edge[x]):
if y in nodes:
num = search(y, num)
return num + 1
(n, m), *d = [list(map(int, s.split())) for s in open(0)]
edge = [set() for _ in... | import sys
sys.setrecursionlimit(int(1e6))
def search(x, num):
nodes.remove(x)
# for y in edge[x]:
for y in list(edge[x]):
edge[y].remove(x)
if y in nodes:
num = search(y, num)
return num + 1
(n, m), *d = [list(map(int, s.split())) for s in open(0)]
edge = [set() for... | false | 0 | [
"- for y in edge[x]:",
"- edge[y].discard(x)",
"+ # for y in edge[x]:",
"+ edge[y].remove(x)"
] | false | 0.060048 | 0.056038 | 1.07156 | [
"s152871322",
"s284657698"
] |
u226155577 | p03602 | python | s106383086 | s979134799 | 891 | 510 | 48,092 | 44,380 | Accepted | Accepted | 42.76 | n = int(eval(input()))
A = [list(map(int, input().split())) for i in range(n)]
B = [e[:] for e in A]
for k in range(n):
for i in range(n):
for j in range(n):
B[i][j] = min(B[i][k] + B[k][j], B[i][j])
ok = 1
for i in range(n):
for j in range(n):
if A[i][j] != B[i][j]:
... | n = int(eval(input()))
A = [list(map(int, input().split())) for i in range(n)]
ans = 0; ok = 1
for i in range(n):
for j in range(i+1, n):
cost = A[i][j]
for k in range(n):
if i == k or j == k:
continue
if A[i][k] + A[k][j] < A[i][j]:
... | 29 | 16 | 666 | 443 | n = int(eval(input()))
A = [list(map(int, input().split())) for i in range(n)]
B = [e[:] for e in A]
for k in range(n):
for i in range(n):
for j in range(n):
B[i][j] = min(B[i][k] + B[k][j], B[i][j])
ok = 1
for i in range(n):
for j in range(n):
if A[i][j] != B[i][j]:
ok =... | n = int(eval(input()))
A = [list(map(int, input().split())) for i in range(n)]
ans = 0
ok = 1
for i in range(n):
for j in range(i + 1, n):
cost = A[i][j]
for k in range(n):
if i == k or j == k:
continue
if A[i][k] + A[k][j] < A[i][j]:
ok = 0
... | false | 44.827586 | [
"-B = [e[:] for e in A]",
"-for k in range(n):",
"- for i in range(n):",
"- for j in range(n):",
"- B[i][j] = min(B[i][k] + B[k][j], B[i][j])",
"+ans = 0",
"- for j in range(n):",
"- if A[i][j] != B[i][j]:",
"- ok = 0",
"-if not ok:",
"- print((-1))",... | false | 0.132256 | 0.105574 | 1.252726 | [
"s106383086",
"s979134799"
] |
u693378622 | p02685 | python | s459165807 | s896527742 | 434 | 105 | 32,680 | 112,668 | Accepted | Accepted | 75.81 | class Facts:
def __init__(self, mod=10**9+7, n_max=1):
self.mod = mod
self.n_max = n_max
self.fact = [1, 1]
self.inv = [0, 1]
self.factinv = [1, 1]
if 1 < n_max:
setup_table(n_max)
def cmb(self, n, r):
if r < 0 or n < r:
return 0
if self.... | class Facts:
def __init__(self, mod=10**9+7, n_max=1):
self.mod = mod
self.n_max = n_max
self.fact = [1, 1]
self.inv = [0, 1]
self.factinv = [1, 1]
if 1 < n_max:
self.setup_table(n_max)
def cmb(self, n, r):
if r < 0 or n < r:
return 0
if self.... | 38 | 39 | 958 | 979 | class Facts:
def __init__(self, mod=10**9 + 7, n_max=1):
self.mod = mod
self.n_max = n_max
self.fact = [1, 1]
self.inv = [0, 1]
self.factinv = [1, 1]
if 1 < n_max:
setup_table(n_max)
def cmb(self, n, r):
if r < 0 or n < r:
return 0... | class Facts:
def __init__(self, mod=10**9 + 7, n_max=1):
self.mod = mod
self.n_max = n_max
self.fact = [1, 1]
self.inv = [0, 1]
self.factinv = [1, 1]
if 1 < n_max:
self.setup_table(n_max)
def cmb(self, n, r):
if r < 0 or n < r:
ret... | false | 2.564103 | [
"- setup_table(n_max)",
"+ self.setup_table(n_max)",
"+# ABC167 E 2020/5/11"
] | false | 0.25742 | 0.234991 | 1.095448 | [
"s459165807",
"s896527742"
] |
u071269360 | p03478 | python | s388375071 | s048968187 | 50 | 46 | 9,420 | 9,624 | Accepted | Accepted | 8 | from functools import reduce
n,a,b = [int(x) for x in input().split(" ")]
ans = 0
for ni in range(a,n+1):
if ni <= 9 :
if a <= ni and ni <= b:
ans += ni
else:
add_each_dig = reduce(lambda x, y: int(x) + int(y), str(ni) )
if a <= add_each_dig and add_each_dig <= b... | from functools import reduce
n,a,b = [int(x) for x in input().split(" ")]
ans = 0
for ni in range(a,n+1):
add_each_dig = int(reduce(lambda x, y: int(x) + int(y), str(ni) ))
if a <= add_each_dig and add_each_dig <= b:
ans += ni
print(ans) | 15 | 11 | 361 | 269 | from functools import reduce
n, a, b = [int(x) for x in input().split(" ")]
ans = 0
for ni in range(a, n + 1):
if ni <= 9:
if a <= ni and ni <= b:
ans += ni
else:
add_each_dig = reduce(lambda x, y: int(x) + int(y), str(ni))
if a <= add_each_dig and add_each_dig <= b:
... | from functools import reduce
n, a, b = [int(x) for x in input().split(" ")]
ans = 0
for ni in range(a, n + 1):
add_each_dig = int(reduce(lambda x, y: int(x) + int(y), str(ni)))
if a <= add_each_dig and add_each_dig <= b:
ans += ni
print(ans)
| false | 26.666667 | [
"- if ni <= 9:",
"- if a <= ni and ni <= b:",
"- ans += ni",
"- else:",
"- add_each_dig = reduce(lambda x, y: int(x) + int(y), str(ni))",
"- if a <= add_each_dig and add_each_dig <= b:",
"- ans += ni",
"+ add_each_dig = int(reduce(lambda x, y: int(x)... | false | 0.071831 | 0.042196 | 1.702309 | [
"s388375071",
"s048968187"
] |
u554096168 | p02683 | python | s709706594 | s134861809 | 149 | 40 | 27,300 | 9,204 | Accepted | Accepted | 73.15 | import numpy as np
N, M, X = list(map(int, input().split()))
C = [0]*N
A = np.zeros((N, M), int)
for i in range(N):
C[i], *A[i] = list(map(int, input().split()))
ans = 12345678
for bit in range(1, 2**N):
c = [C[i] for i in range(N) if bit & (1 << i)]
a = [A[i] for i in range(N) if bit & (1 <<... | (N, M, X), *T = [[*list(map(int, line.split()))] for line in open(0)]
ans = 12345678
for bit in range(1, 2**N):
t = [T[i] for i in range(N) if bit & (1 << i)]
c, *a = list(map(sum, list(zip(*t))))
if all(e >= X for e in a):
ans = min(ans, c)
print((-1 if ans == 12345678 else ans))
| 19 | 10 | 437 | 293 | import numpy as np
N, M, X = list(map(int, input().split()))
C = [0] * N
A = np.zeros((N, M), int)
for i in range(N):
C[i], *A[i] = list(map(int, input().split()))
ans = 12345678
for bit in range(1, 2**N):
c = [C[i] for i in range(N) if bit & (1 << i)]
a = [A[i] for i in range(N) if bit & (1 << i)]
a =... | (N, M, X), *T = [[*list(map(int, line.split()))] for line in open(0)]
ans = 12345678
for bit in range(1, 2**N):
t = [T[i] for i in range(N) if bit & (1 << i)]
c, *a = list(map(sum, list(zip(*t))))
if all(e >= X for e in a):
ans = min(ans, c)
print((-1 if ans == 12345678 else ans))
| false | 47.368421 | [
"-import numpy as np",
"-",
"-N, M, X = list(map(int, input().split()))",
"-C = [0] * N",
"-A = np.zeros((N, M), int)",
"-for i in range(N):",
"- C[i], *A[i] = list(map(int, input().split()))",
"+(N, M, X), *T = [[*list(map(int, line.split()))] for line in open(0)]",
"- c = [C[i] for i in rang... | false | 0.307534 | 0.129084 | 2.382433 | [
"s709706594",
"s134861809"
] |
u556069480 | p02735 | python | s514114301 | s895782578 | 92 | 46 | 6,120 | 3,316 | Accepted | Accepted | 50 | import itertools
H,W=list(map(int, input().split()))
garden=[]
for i in range(H):
garden.append(list(input().replace(".","1").replace("#","0")))
#print(garden)
dct=[(1,0),(0,1),(-1,0),(0,-1)]
#garden=[[1,0,1,0,1],[0,1,0,1,0],[1,0,1,0,1],[0,1,0,1,0],[1,0,1,0,1]]
#H,W=5,5
start=(0,0)
goal=(H-1,W-1)
p... | import itertools
H,W=list(map(int, input().split()))
garden=[]
for i in range(H):
garden.append(list(input().replace(".","1").replace("#","0")))
dct=[(1,0),(0,1)]
d=[ [i+j for i in range(W)] for j in range(H)]
for i, j in itertools.product(list(range(H)),list(range(W))):
color=garden[i][j]
... | 37 | 25 | 1,134 | 686 | import itertools
H, W = list(map(int, input().split()))
garden = []
for i in range(H):
garden.append(list(input().replace(".", "1").replace("#", "0")))
# print(garden)
dct = [(1, 0), (0, 1), (-1, 0), (0, -1)]
# garden=[[1,0,1,0,1],[0,1,0,1,0],[1,0,1,0,1],[0,1,0,1,0],[1,0,1,0,1]]
# H,W=5,5
start = (0, 0)
goal = (H ... | import itertools
H, W = list(map(int, input().split()))
garden = []
for i in range(H):
garden.append(list(input().replace(".", "1").replace("#", "0")))
dct = [(1, 0), (0, 1)]
d = [[i + j for i in range(W)] for j in range(H)]
for i, j in itertools.product(list(range(H)), list(range(W))):
color = garden[i][j]
... | false | 32.432432 | [
"-# print(garden)",
"-dct = [(1, 0), (0, 1), (-1, 0), (0, -1)]",
"-# garden=[[1,0,1,0,1],[0,1,0,1,0],[1,0,1,0,1],[0,1,0,1,0],[1,0,1,0,1]]",
"-# H,W=5,5",
"-start = (0, 0)",
"-goal = (H - 1, W - 1)",
"-path = [start]",
"+dct = [(1, 0), (0, 1)]",
"-# print(d)",
"-done = [(0, 0)]",
"- if (",... | false | 0.036176 | 0.037232 | 0.971638 | [
"s514114301",
"s895782578"
] |
u340781749 | p02793 | python | s118153609 | s236084692 | 1,560 | 966 | 4,580 | 6,112 | Accepted | Accepted | 38.08 | def prime_factorize(n):
i = 2
res = {}
while i * i <= n:
if n % i != 0:
i += 1
continue
res[i] = 0
while n % i == 0:
res[i] += 1
n //= i
i += 1
if n != 1:
res[n] = 1
return res
n = int(eval(inp... | from fractions import gcd
n = int(eval(input()))
aaa = list(map(int, input().split()))
MOD = 10 ** 9 + 7
lcm = aaa[0]
for a in aaa[1:]:
lcm = lcm * a // gcd(lcm, a)
lcm %= MOD
ans = 0
for a in aaa:
ans = (ans + lcm * pow(a, MOD - 2, MOD)) % MOD
print(ans)
| 38 | 14 | 788 | 273 | def prime_factorize(n):
i = 2
res = {}
while i * i <= n:
if n % i != 0:
i += 1
continue
res[i] = 0
while n % i == 0:
res[i] += 1
n //= i
i += 1
if n != 1:
res[n] = 1
return res
n = int(eval(input()))
aaa = list... | from fractions import gcd
n = int(eval(input()))
aaa = list(map(int, input().split()))
MOD = 10**9 + 7
lcm = aaa[0]
for a in aaa[1:]:
lcm = lcm * a // gcd(lcm, a)
lcm %= MOD
ans = 0
for a in aaa:
ans = (ans + lcm * pow(a, MOD - 2, MOD)) % MOD
print(ans)
| false | 63.157895 | [
"-def prime_factorize(n):",
"- i = 2",
"- res = {}",
"- while i * i <= n:",
"- if n % i != 0:",
"- i += 1",
"- continue",
"- res[i] = 0",
"- while n % i == 0:",
"- res[i] += 1",
"- n //= i",
"- i += 1",
"- if... | false | 0.038355 | 0.060152 | 0.637626 | [
"s118153609",
"s236084692"
] |
u669284080 | p02242 | python | s552636900 | s510054992 | 190 | 30 | 7,900 | 8,516 | Accepted | Accepted | 84.21 | #!/usr/bin/python3
n = int(eval(input()))
inf = 100 * 100000
M = [[inf for i in range(n)] for j in range(n)]
for i in range(n):
L = list(map(int, input().split()))
u = L[0]
k = L[1]
v = L[2::2]
c = L[3::2]
for j in range(k):
M[u][v[j]] = c[j]
S = set()
V = set(range(n)... | #!/usr/bin/python3
from heapq import heappop, heappush
n = int(eval(input()))
inf = 100 * 100000
M = [[] for i in range(n)]
for i in range(n):
L = list(map(int, input().split()))
u = L[0]
k = L[1]
v = L[2::2]
c = L[3::2]
for j in range(k):
M[u].append((v[j], c[j]))
resul... | 37 | 37 | 713 | 717 | #!/usr/bin/python3
n = int(eval(input()))
inf = 100 * 100000
M = [[inf for i in range(n)] for j in range(n)]
for i in range(n):
L = list(map(int, input().split()))
u = L[0]
k = L[1]
v = L[2::2]
c = L[3::2]
for j in range(k):
M[u][v[j]] = c[j]
S = set()
V = set(range(n))
S.add(0)
d = [inf... | #!/usr/bin/python3
from heapq import heappop, heappush
n = int(eval(input()))
inf = 100 * 100000
M = [[] for i in range(n)]
for i in range(n):
L = list(map(int, input().split()))
u = L[0]
k = L[1]
v = L[2::2]
c = L[3::2]
for j in range(k):
M[u].append((v[j], c[j]))
result = [0] * n
S = ... | false | 0 | [
"+from heapq import heappop, heappush",
"+",
"-M = [[inf for i in range(n)] for j in range(n)]",
"+M = [[] for i in range(n)]",
"- M[u][v[j]] = c[j]",
"+ M[u].append((v[j], c[j]))",
"+result = [0] * n",
"-d = [inf for i in range(n)]",
"-d[0] = 0",
"-count = 0",
"-while len(V - S) !... | false | 0.037394 | 0.03883 | 0.963005 | [
"s552636900",
"s510054992"
] |
u883048396 | p03240 | python | s760934057 | s144784473 | 733 | 33 | 3,064 | 3,064 | Accepted | Accepted | 95.5 | import sys
iN = int(eval(input()))
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aData.sort(key=lambda x:x[2],reverse=True)
for cx in range(0,101) :
for cy in range(0,101) :
aH = []
uH = False
bF = True
for x,y,z in aData :
d = a... | import sys
iN = int(eval(input()))
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aData.sort(key=lambda x:x[2],reverse=True)
for cx in range(0,101) :
for cy in range(0,101) :
h = 0
bF = True
for x,y,z in aData :
d = abs(x-cx)+abs(y-cy)
... | 30 | 25 | 830 | 693 | import sys
iN = int(eval(input()))
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aData.sort(key=lambda x: x[2], reverse=True)
for cx in range(0, 101):
for cy in range(0, 101):
aH = []
uH = False
bF = True
for x, y, z in aData:
d = abs(x - c... | import sys
iN = int(eval(input()))
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aData.sort(key=lambda x: x[2], reverse=True)
for cx in range(0, 101):
for cy in range(0, 101):
h = 0
bF = True
for x, y, z in aData:
d = abs(x - cx) + abs(y - cy)
... | false | 16.666667 | [
"- aH = []",
"- uH = False",
"+ h = 0",
"- aH.append(z + d)",
"+ if h == 0:",
"+ h = z + d",
"+ else:",
"+ if h != z + d:",
"+ bF = False",
"+ break... | false | 0.067959 | 0.037286 | 1.822664 | [
"s760934057",
"s144784473"
] |
u368249389 | p03017 | python | s843843180 | s434588360 | 202 | 171 | 61,296 | 40,816 | Accepted | Accepted | 15.35 | # Problem A - Kenken Race
# input
N, A, B, C, D = list(map(int, input().split()))
S = list(eval(input()))
# check
if C<D:
# B check
is_ok = True
for i in range(B, D-1):
if S[i]=='#' and S[i+1]=='#':
is_ok = False
break
# A check
for i in range(A, C-1)... | # Problem A - Kenken Race
# input
N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
# initialization
is_ok = True
# search
if C>D:
# b check
if "##" in S[B-1:D] or not "..." in S[B-2:D+1]:
is_ok = False
# a check
if "##" in S[A-1:C]:
is_ok = False
el... | 44 | 32 | 953 | 507 | # Problem A - Kenken Race
# input
N, A, B, C, D = list(map(int, input().split()))
S = list(eval(input()))
# check
if C < D:
# B check
is_ok = True
for i in range(B, D - 1):
if S[i] == "#" and S[i + 1] == "#":
is_ok = False
break
# A check
for i in range(A, C - 1):
... | # Problem A - Kenken Race
# input
N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
# initialization
is_ok = True
# search
if C > D:
# b check
if "##" in S[B - 1 : D] or not "..." in S[B - 2 : D + 1]:
is_ok = False
# a check
if "##" in S[A - 1 : C]:
is_ok = False
else:
... | false | 27.272727 | [
"-S = list(eval(input()))",
"-# check",
"-if C < D:",
"- # B check",
"- is_ok = True",
"- for i in range(B, D - 1):",
"- if S[i] == \"#\" and S[i + 1] == \"#\":",
"- is_ok = False",
"- break",
"- # A check",
"- for i in range(A, C - 1):",
"- i... | false | 0.038443 | 0.067614 | 0.568565 | [
"s843843180",
"s434588360"
] |
u135454978 | p02844 | python | s097585201 | s270102236 | 267 | 186 | 40,556 | 38,384 | Accepted | Accepted | 30.34 | # 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN
import sys
def main():
N = int(eval(input())) # 桁数
S = str(eval(input()))
ans = set()
digit1 = set()
for i in range(0, N - 2):
if S[i] in digit1:
continue
digit1.add(S[i])
digit2 = set()
... | # 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN
import sys
N = int(eval(input()))
S = str(eval(input()))
ans = 0
for i in range(10):
code1 = S.find(str(i))
if code1 == -1:
continue
for j in range(10):
code2 = S.find(str(j), code1 + 1)
if code2 == -1:
continue
... | 35 | 22 | 700 | 453 | # 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN
import sys
def main():
N = int(eval(input())) # 桁数
S = str(eval(input()))
ans = set()
digit1 = set()
for i in range(0, N - 2):
if S[i] in digit1:
continue
digit1.add(S[i])
digit2 = set()
for j in range(i + 1, N ... | # 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN
import sys
N = int(eval(input()))
S = str(eval(input()))
ans = 0
for i in range(10):
code1 = S.find(str(i))
if code1 == -1:
continue
for j in range(10):
code2 = S.find(str(j), code1 + 1)
if code2 == -1:
continue
for k in ... | false | 37.142857 | [
"-",
"-def main():",
"- N = int(eval(input())) # 桁数",
"- S = str(eval(input()))",
"- ans = set()",
"- digit1 = set()",
"- for i in range(0, N - 2):",
"- if S[i] in digit1:",
"+N = int(eval(input()))",
"+S = str(eval(input()))",
"+ans = 0",
"+for i in range(10):",
"+ ... | false | 0.060284 | 0.037319 | 1.615365 | [
"s097585201",
"s270102236"
] |
u492447501 | p03212 | python | s353906456 | s698540855 | 319 | 134 | 3,064 | 3,188 | Accepted | Accepted | 57.99 | N = int(eval(input()))
l = len(str(10**9))
def dfs(A):#配列Aからできる753数
global N
if len(A)>0 and(int("".join(map(str, A)))>N):
return 0
ans = 0
if(all(A.count(i)==0 for i in [0, 1, 2, 4, 6, 8, 9]) and (A.count(3) >0 and A.count(5) >0 and A.count(7) >0)):
ans = ans + 1
... | N = int(eval(input()))
import sys
sys.setrecursionlimit(500000)
def dfs(l):
global N
if l!=[] and N<int("".join(l)):
return 0
ans = 0
if all(l.count(i)>0 for i in ["3", "5", "7"]):
ans = 1
for i in ["3", "5", "7"]:
l.append(i)
#参照渡し
ans += dfs(l... | 19 | 20 | 442 | 368 | N = int(eval(input()))
l = len(str(10**9))
def dfs(A): # 配列Aからできる753数
global N
if len(A) > 0 and (int("".join(map(str, A))) > N):
return 0
ans = 0
if all(A.count(i) == 0 for i in [0, 1, 2, 4, 6, 8, 9]) and (
A.count(3) > 0 and A.count(5) > 0 and A.count(7) > 0
):
ans = ans... | N = int(eval(input()))
import sys
sys.setrecursionlimit(500000)
def dfs(l):
global N
if l != [] and N < int("".join(l)):
return 0
ans = 0
if all(l.count(i) > 0 for i in ["3", "5", "7"]):
ans = 1
for i in ["3", "5", "7"]:
l.append(i)
# 参照渡し
ans += dfs(l)
... | false | 5 | [
"-l = len(str(10**9))",
"+import sys",
"+",
"+sys.setrecursionlimit(500000)",
"-def dfs(A): # 配列Aからできる753数",
"+def dfs(l):",
"- if len(A) > 0 and (int(\"\".join(map(str, A))) > N):",
"+ if l != [] and N < int(\"\".join(l)):",
"- if all(A.count(i) == 0 for i in [0, 1, 2, 4, 6, 8, 9]) and ("... | false | 0.131519 | 0.059645 | 2.205045 | [
"s353906456",
"s698540855"
] |
u416011173 | p02597 | python | s175768889 | s952596166 | 138 | 94 | 9,316 | 9,476 | Accepted | Accepted | 31.88 | # -*- coding: utf-8 -*-
# 標準入力を取得
N = int(eval(input()))
c = eval(input())
# 求解処理
w = 0
r = c.count("R")
ans = max(w, r)
for n in range(N):
c_n = c[n]
if c_n == "W":
w += 1
else:
r -= 1
ans = min(ans, max(w, r))
# 結果出力
print(ans)
| # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
N = int(eval(input()))
c = eval(input())
return N, c
def main(N: int, c: str) -> None:
"""
メイン処理.
Args:\n
N (int): 石の個数(2 <= N <= 200000)
... | 19 | 45 | 270 | 687 | # -*- coding: utf-8 -*-
# 標準入力を取得
N = int(eval(input()))
c = eval(input())
# 求解処理
w = 0
r = c.count("R")
ans = max(w, r)
for n in range(N):
c_n = c[n]
if c_n == "W":
w += 1
else:
r -= 1
ans = min(ans, max(w, r))
# 結果出力
print(ans)
| # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
N = int(eval(input()))
c = eval(input())
return N, c
def main(N: int, c: str) -> None:
"""
メイン処理.
Args:\n
N (int): 石の個数(2 <= N <= 200000)
c (str): 石の色
"""
... | false | 57.777778 | [
"-# 標準入力を取得",
"-N = int(eval(input()))",
"-c = eval(input())",
"-# 求解処理",
"-w = 0",
"-r = c.count(\"R\")",
"-ans = max(w, r)",
"-for n in range(N):",
"- c_n = c[n]",
"- if c_n == \"W\":",
"- w += 1",
"- else:",
"- r -= 1",
"- ans = min(ans, max(w, r))",
"-# 結果出力... | false | 0.038169 | 0.109225 | 0.349451 | [
"s175768889",
"s952596166"
] |
u968166680 | p02936 | python | s073802508 | s510659249 | 965 | 658 | 296,968 | 90,808 | Accepted | Accepted | 31.81 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, Q = list(map(int, readline().split()))
G = [[] for _ in range(N)]
for _ in range(N - 1):
a, b = list(map(int, r... | import sys
from collections import deque
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, Q = list(map(int, readline().split()))
G = [[] for _ in range(N)]
for _ in range(N - 1):
... | 38 | 41 | 771 | 886 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
N, Q = list(map(int, readline().split()))
G = [[] for _ in range(N)]
for _ in range(N - 1):
a, b = list(map(int, readline().split(... | import sys
from collections import deque
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
N, Q = list(map(int, readline().split()))
G = [[] for _ in range(N)]
for _ in range(N - 1):
a, b = l... | false | 7.317073 | [
"+from collections import deque",
"-",
"- def dfs(v, p):",
"+ stack = deque([0])",
"+ seen = [False] * N",
"+ while stack:",
"+ v = stack.pop()",
"+ seen[v] = True",
"- if nv == p:",
"+ if seen[nv]:",
"- dfs(nv, v)",
"-",
"- dfs(0... | false | 0.036309 | 0.037102 | 0.978624 | [
"s073802508",
"s510659249"
] |
u339199690 | p02695 | python | s627678705 | s155841572 | 860 | 235 | 21,472 | 77,012 | Accepted | Accepted | 72.67 | from itertools import combinations_with_replacement as cwd
N, M, Q = list(map(int, input().split()))
A = list(cwd(list(range(1, M + 1)), N))
ABCD = []
for i in range(Q):
a, b, c, d = list(map(int, input().split()))
a, b = a - 1, b - 1
ABCD.append([a, b, c, d])
res = 0
for i in A:
tmp = 0... | N, M, Q = list(map(int, input().split()))
res = 0
def dfs(L: list):
global res
A = L[::]
if len(A) == N + 1:
now = 0
for i in range(Q):
if A[b[i]] - A[a[i]] == c[i]:
now += d[i]
res = max(res, now)
# print(A, now)
return
... | 20 | 30 | 426 | 594 | from itertools import combinations_with_replacement as cwd
N, M, Q = list(map(int, input().split()))
A = list(cwd(list(range(1, M + 1)), N))
ABCD = []
for i in range(Q):
a, b, c, d = list(map(int, input().split()))
a, b = a - 1, b - 1
ABCD.append([a, b, c, d])
res = 0
for i in A:
tmp = 0
for j in A... | N, M, Q = list(map(int, input().split()))
res = 0
def dfs(L: list):
global res
A = L[::]
if len(A) == N + 1:
now = 0
for i in range(Q):
if A[b[i]] - A[a[i]] == c[i]:
now += d[i]
res = max(res, now)
# print(A, now)
return
A.append(A[-1... | false | 33.333333 | [
"-from itertools import combinations_with_replacement as cwd",
"+N, M, Q = list(map(int, input().split()))",
"+res = 0",
"-N, M, Q = list(map(int, input().split()))",
"-A = list(cwd(list(range(1, M + 1)), N))",
"-ABCD = []",
"-for i in range(Q):",
"- a, b, c, d = list(map(int, input().split()))",
... | false | 0.057569 | 0.133472 | 0.431318 | [
"s627678705",
"s155841572"
] |
u119127920 | p02315 | python | s569430667 | s478328145 | 2,180 | 1,140 | 136,244 | 44,312 | Accepted | Accepted | 47.71 | from collections import defaultdict
memo = {}
def dfs(i, w, item_list, W):
if i >= len(item_list):
return 0
if (i, w) in memo:
return memo[(i, w)]
ans = 0
# use
new_w = w + item_list[i][1]
if new_w <= W:
ans = max(ans, dfs(i + 1, new_w, item_list, W) + it... | from collections import defaultdict
def solve(N, W, vs, ws):
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
v, w = vs[i], ws[i]
for j in range(len(dp[0])):
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
if j + w < len(dp[0]):
dp[i + ... | 34 | 29 | 697 | 704 | from collections import defaultdict
memo = {}
def dfs(i, w, item_list, W):
if i >= len(item_list):
return 0
if (i, w) in memo:
return memo[(i, w)]
ans = 0
# use
new_w = w + item_list[i][1]
if new_w <= W:
ans = max(ans, dfs(i + 1, new_w, item_list, W) + item_list[i][0])... | from collections import defaultdict
def solve(N, W, vs, ws):
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
v, w = vs[i], ws[i]
for j in range(len(dp[0])):
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
if j + w < len(dp[0]):
dp[i + 1][j + w] ... | false | 14.705882 | [
"-memo = {}",
"-",
"-def dfs(i, w, item_list, W):",
"- if i >= len(item_list):",
"- return 0",
"- if (i, w) in memo:",
"- return memo[(i, w)]",
"+def solve(N, W, vs, ws):",
"+ dp = [[0] * (W + 1) for _ in range(N + 1)]",
"+ for i in range(N):",
"+ v, w = vs[i], w... | false | 0.009278 | 0.041811 | 0.221902 | [
"s569430667",
"s478328145"
] |
u677523557 | p03044 | python | s835737194 | s757883647 | 740 | 509 | 79,488 | 65,808 | Accepted | Accepted | 31.22 | N = int(eval(input()))
import sys
sys.setrecursionlimit(90000)
graph = [[] for _ in range(N)]
for _ in range(N-1):
a, b, c = list(map(int, input().split()))
graph[a-1].append((b-1, c))
graph[b-1].append((a-1, c))
color = [-1 for _ in range(N)]
def dfs(p, c, color):
color[p] = c
cinv =... | import sys
input = sys.stdin.readline
N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
a, b, w = map(int, input().split())
graph[a-1].append((b-1, w))
graph[b-1].append((a-1, w))
def dfs(s):
Ind = [0]*N
stack = [s]
Color = [0]*N
while stack:
p =... | 26 | 30 | 591 | 694 | N = int(eval(input()))
import sys
sys.setrecursionlimit(90000)
graph = [[] for _ in range(N)]
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
graph[a - 1].append((b - 1, c))
graph[b - 1].append((a - 1, c))
color = [-1 for _ in range(N)]
def dfs(p, c, color):
color[p] = c
cinv = 0... | import sys
input = sys.stdin.readline
N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
a, b, w = map(int, input().split())
graph[a - 1].append((b - 1, w))
graph[b - 1].append((a - 1, w))
def dfs(s):
Ind = [0] * N
stack = [s]
Color = [0] * N
while stack:
p = s... | false | 13.333333 | [
"-N = int(eval(input()))",
"-sys.setrecursionlimit(90000)",
"+input = sys.stdin.readline",
"+N = int(input())",
"- a, b, c = list(map(int, input().split()))",
"- graph[a - 1].append((b - 1, c))",
"- graph[b - 1].append((a - 1, c))",
"-color = [-1 for _ in range(N)]",
"+ a, b, w = map(int... | false | 0.149578 | 0.113616 | 1.316517 | [
"s835737194",
"s757883647"
] |
u871980676 | p02821 | python | s743073889 | s111609106 | 1,561 | 1,153 | 14,396 | 59,664 | Accepted | Accepted | 26.14 | import sys
import bisect
input = sys.stdin.readline
class Bisect(object):
def bisect_max(self, reva, func,M):
ok = 0 # exist
ng = 4*(10**5) # not exist
while abs(ok-ng) > 1:
cnt = (ok + ng) // 2
if func(cnt,reva,M):
ok = cnt
el... | import sys
import bisect
input = sys.stdin.readline
class Bisect(object):
def bisect_max(self, reva, func,M):
ok = 0 # exist
ng = 4*(10**5) # not exist
while abs(ok-ng) > 1:
cnt = (ok + ng) // 2
if func(cnt,reva,M):
ok = cnt
el... | 70 | 53 | 1,526 | 1,132 | import sys
import bisect
input = sys.stdin.readline
class Bisect(object):
def bisect_max(self, reva, func, M):
ok = 0 # exist
ng = 4 * (10**5) # not exist
while abs(ok - ng) > 1:
cnt = (ok + ng) // 2
if func(cnt, reva, M):
ok = cnt
els... | import sys
import bisect
input = sys.stdin.readline
class Bisect(object):
def bisect_max(self, reva, func, M):
ok = 0 # exist
ng = 4 * (10**5) # not exist
while abs(ok - ng) > 1:
cnt = (ok + ng) // 2
if func(cnt, reva, M):
ok = cnt
els... | false | 24.285714 | [
"- def bisect_min(self, reva, func, M):",
"- ok = 10**5 # exist",
"- ng = 0 # not exist",
"- while abs(ok - ng) > 1:",
"- cnt = (ok + ng) // 2",
"- if func(cnt, reva, M):",
"- ok = cnt",
"- else:",
"- ng = cnt",... | false | 0.007427 | 0.174867 | 0.042473 | [
"s743073889",
"s111609106"
] |
u073852194 | p03286 | python | s158428784 | s582402470 | 21 | 18 | 3,316 | 3,064 | Accepted | Accepted | 14.29 | n = int(eval(input()))
I = [[0,1]]
while n < I[-1][0] or I[-1][1] < n:
if len(I)%2 != 0:
I += [[I[-1][0]-2**(len(I)),I[-1][1]]]
else:
I += [[I[-1][0],I[-1][1]+2**(len(I))]]
ans = ''
for i in range(len(I)):
if abs((I[-i-1][0]+I[-i-1][1])/2) < abs(n) and n * (-1)**(len(I)-i-1) > 0:
ans += '1'
... | N = int(eval(input()))
lt = [0 for _ in range(50)]
rt = [0 for _ in range(50)]
lt[0] = 1
rt[0] = 1
lt[1] = -2
rt[1] = -1
for i in range(2, 50):
if i % 2 == 0:
lt[i] = rt[i - 2] + 1
rt[i] = lt[i] + 2**i - 1
else:
rt[i] = lt[i - 2] - 1
lt[i] = rt[i] - 2**i + 1
... | 15 | 28 | 384 | 533 | n = int(eval(input()))
I = [[0, 1]]
while n < I[-1][0] or I[-1][1] < n:
if len(I) % 2 != 0:
I += [[I[-1][0] - 2 ** (len(I)), I[-1][1]]]
else:
I += [[I[-1][0], I[-1][1] + 2 ** (len(I))]]
ans = ""
for i in range(len(I)):
if (
abs((I[-i - 1][0] + I[-i - 1][1]) / 2) < abs(n)
and ... | N = int(eval(input()))
lt = [0 for _ in range(50)]
rt = [0 for _ in range(50)]
lt[0] = 1
rt[0] = 1
lt[1] = -2
rt[1] = -1
for i in range(2, 50):
if i % 2 == 0:
lt[i] = rt[i - 2] + 1
rt[i] = lt[i] + 2**i - 1
else:
rt[i] = lt[i - 2] - 1
lt[i] = rt[i] - 2**i + 1
res = [0 for _ in ran... | false | 46.428571 | [
"-n = int(eval(input()))",
"-I = [[0, 1]]",
"-while n < I[-1][0] or I[-1][1] < n:",
"- if len(I) % 2 != 0:",
"- I += [[I[-1][0] - 2 ** (len(I)), I[-1][1]]]",
"+N = int(eval(input()))",
"+lt = [0 for _ in range(50)]",
"+rt = [0 for _ in range(50)]",
"+lt[0] = 1",
"+rt[0] = 1",
"+lt[1] =... | false | 0.044064 | 0.044691 | 0.985954 | [
"s158428784",
"s582402470"
] |
u057109575 | p02832 | python | s060874918 | s404823704 | 242 | 113 | 91,288 | 103,460 | Accepted | Accepted | 53.31 | N, *A = list(map(int, open(0).read().split()))
cnt = 0
ans = 0
for i in range(N):
if cnt + 1 == A[i]:
cnt += 1
else:
ans += 1
if ans == N:
print((-1))
else:
print(ans)
| N, *A = list(map(int, open(0).read().split()))
cur = 0
for i in range(N):
if A[i] == cur + 1:
cur += 1
if cur == 0:
print((-1))
else:
print((N - cur))
| 14 | 11 | 207 | 173 | N, *A = list(map(int, open(0).read().split()))
cnt = 0
ans = 0
for i in range(N):
if cnt + 1 == A[i]:
cnt += 1
else:
ans += 1
if ans == N:
print((-1))
else:
print(ans)
| N, *A = list(map(int, open(0).read().split()))
cur = 0
for i in range(N):
if A[i] == cur + 1:
cur += 1
if cur == 0:
print((-1))
else:
print((N - cur))
| false | 21.428571 | [
"-cnt = 0",
"-ans = 0",
"+cur = 0",
"- if cnt + 1 == A[i]:",
"- cnt += 1",
"- else:",
"- ans += 1",
"-if ans == N:",
"+ if A[i] == cur + 1:",
"+ cur += 1",
"+if cur == 0:",
"- print(ans)",
"+ print((N - cur))"
] | false | 0.04695 | 0.047804 | 0.982138 | [
"s060874918",
"s404823704"
] |
u857547702 | p02641 | python | s406226174 | s818143574 | 26 | 20 | 9,232 | 9,196 | Accepted | Accepted | 23.08 | from bisect import bisect_left
import sys
X,N=list(map(int,input().split()))
if N==0:
print(X)
sys.exit()
P=list(map(int,input().split()))
P=sorted(P)
x=bisect_left(P,X)
if x>=len(P):
print(X)
sys.exit()
if P[x]!=X:
print(X)
sys.exit()
A=X
B=X
while True:
A-=1
B+=1
... | import sys
X,N=list(map(int,input().split()))
P=list(map(int,input().split()))
if not X in P:
print(X)
sys.exit()
A=X
B=X
while True:
A-=1
B+=1
if not A in P:
print(A)
sys.exit()
if not B in P:
print(B)
sys.exit() | 31 | 17 | 550 | 285 | from bisect import bisect_left
import sys
X, N = list(map(int, input().split()))
if N == 0:
print(X)
sys.exit()
P = list(map(int, input().split()))
P = sorted(P)
x = bisect_left(P, X)
if x >= len(P):
print(X)
sys.exit()
if P[x] != X:
print(X)
sys.exit()
A = X
B = X
while True:
A -= 1
B ... | import sys
X, N = list(map(int, input().split()))
P = list(map(int, input().split()))
if not X in P:
print(X)
sys.exit()
A = X
B = X
while True:
A -= 1
B += 1
if not A in P:
print(A)
sys.exit()
if not B in P:
print(B)
sys.exit()
| false | 45.16129 | [
"-from bisect import bisect_left",
"-if N == 0:",
"- print(X)",
"- sys.exit()",
"-P = sorted(P)",
"-x = bisect_left(P, X)",
"-if x >= len(P):",
"- print(X)",
"- sys.exit()",
"-if P[x] != X:",
"+if not X in P:",
"- x1 = bisect_left(P, A)",
"- x2 = bisect_left(P, B)",
"- ... | false | 0.039303 | 0.045403 | 0.865666 | [
"s406226174",
"s818143574"
] |
u089230684 | p02608 | python | s711255860 | s201399378 | 154 | 98 | 9,296 | 75,372 | Accepted | Accepted | 36.36 | n = int(eval(input()))
a = [0] * (n + 1)
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
c = x * x + y * y + z * z + x * y + y * z + z * x
if c <= n:
a[c] +=1
else:
break
for i in a[1:]:
print(i)
| from sys import stdin
inp = lambda : stdin.readline().strip()
n = int(inp())
a = [0]*10**5
for i in range(1,101):
for j in range(1,101):
for k in range(1,101):
a[i**2 + j**2 + k**2 + i*j + i*k + k*j] += 1
for i in a[1:n+1]:
print(i) | 12 | 11 | 309 | 272 | n = int(eval(input()))
a = [0] * (n + 1)
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
c = x * x + y * y + z * z + x * y + y * z + z * x
if c <= n:
a[c] += 1
else:
break
for i in a[1:]:
print(i)
| from sys import stdin
inp = lambda: stdin.readline().strip()
n = int(inp())
a = [0] * 10**5
for i in range(1, 101):
for j in range(1, 101):
for k in range(1, 101):
a[i**2 + j**2 + k**2 + i * j + i * k + k * j] += 1
for i in a[1 : n + 1]:
print(i)
| false | 8.333333 | [
"-n = int(eval(input()))",
"-a = [0] * (n + 1)",
"-for x in range(1, 101):",
"- for y in range(1, 101):",
"- for z in range(1, 101):",
"- c = x * x + y * y + z * z + x * y + y * z + z * x",
"- if c <= n:",
"- a[c] += 1",
"- else:",
"- ... | false | 0.046272 | 2.355563 | 0.019644 | [
"s711255860",
"s201399378"
] |
u678167152 | p02802 | python | s143410073 | s827058016 | 326 | 179 | 3,828 | 74,992 | Accepted | Accepted | 45.09 | import math
N, M = list(map(int, input().split()))
judge = [0]*N
ac = 0
wa = 0
for i in range(M):
p, S = input().split()
if judge[int(p)-1] == 'AC':
pass
elif S == 'AC':
wa += judge[int(p)-1]
judge[int(p)-1] = 'AC'
ac += 1
else:
judge[int(p)-1] += 1
print((ac,wa)) | def solve():
ans = [0,0]
N, M = list(map(int, input().split()))
WAs = [0]*N
for i in range(M):
p, S = input().split()
p = int(p)
if WAs[p-1]>=0:
if S=='WA':
WAs[p-1] += 1
if S=='AC':
ans[0] += 1
ans[1] += WAs[p-1]
WAs[p-1] = -1
return ans
... | 16 | 16 | 299 | 329 | import math
N, M = list(map(int, input().split()))
judge = [0] * N
ac = 0
wa = 0
for i in range(M):
p, S = input().split()
if judge[int(p) - 1] == "AC":
pass
elif S == "AC":
wa += judge[int(p) - 1]
judge[int(p) - 1] = "AC"
ac += 1
else:
judge[int(p) - 1] += 1
pri... | def solve():
ans = [0, 0]
N, M = list(map(int, input().split()))
WAs = [0] * N
for i in range(M):
p, S = input().split()
p = int(p)
if WAs[p - 1] >= 0:
if S == "WA":
WAs[p - 1] += 1
if S == "AC":
ans[0] += 1
... | false | 0 | [
"-import math",
"+def solve():",
"+ ans = [0, 0]",
"+ N, M = list(map(int, input().split()))",
"+ WAs = [0] * N",
"+ for i in range(M):",
"+ p, S = input().split()",
"+ p = int(p)",
"+ if WAs[p - 1] >= 0:",
"+ if S == \"WA\":",
"+ WAs[p ... | false | 0.084374 | 0.039125 | 2.1565 | [
"s143410073",
"s827058016"
] |
u811817592 | p02713 | python | s200390835 | s039494789 | 1,140 | 859 | 9,620 | 9,208 | Accepted | Accepted | 24.65 | # -*- coding: utf-8 -*-
K = int(eval(input()))
# lcm & gcd not math library
def gcd(a, b):
while b:
a, b = b, a % b
return a
from functools import reduce
def gcd_multi(num_list):
return reduce(gcd, num_list)
ans = 0
for i in range(1, K + 1):
for j in range(i, K + 1):
f... | # -*- coding: utf-8 -*-
K = int(eval(input()))
# lcm & gcd not math library
def gcd(a, b):
while b:
a, b = b, a % b
return a
ans = 0
for i in range(1, K + 1):
for j in range(i, K + 1):
for k in range(j, K + 1):
if i == j and j == k:
dup_num = 1
... | 26 | 21 | 580 | 483 | # -*- coding: utf-8 -*-
K = int(eval(input()))
# lcm & gcd not math library
def gcd(a, b):
while b:
a, b = b, a % b
return a
from functools import reduce
def gcd_multi(num_list):
return reduce(gcd, num_list)
ans = 0
for i in range(1, K + 1):
for j in range(i, K + 1):
for k in range... | # -*- coding: utf-8 -*-
K = int(eval(input()))
# lcm & gcd not math library
def gcd(a, b):
while b:
a, b = b, a % b
return a
ans = 0
for i in range(1, K + 1):
for j in range(i, K + 1):
for k in range(j, K + 1):
if i == j and j == k:
dup_num = 1
elif ... | false | 19.230769 | [
"-",
"-",
"-from functools import reduce",
"-",
"-",
"-def gcd_multi(num_list):",
"- return reduce(gcd, num_list)",
"- ans += gcd_multi([i, j, k]) * dup_num",
"+ ans += gcd(gcd(i, j), k) * dup_num"
] | false | 0.095933 | 0.074441 | 1.288709 | [
"s200390835",
"s039494789"
] |
u624689667 | p02844 | python | s805413818 | s655778848 | 298 | 185 | 41,324 | 38,384 | Accepted | Accepted | 37.92 | n = int(eval(input()))
s = eval(input())
done_1 = set()
done_2 = set()
done_3 = set()
for i in range(n):
if s[i] in done_1:
continue
for j in range(i+1, n):
if s[i] + s[j] in done_2:
continue
for k in range(j+1, n):
pin = s[i] + s[j] + s[k]
... | n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(1000):
pin = str(i).zfill(3)
p = s.find(pin[0])
if p == -1 or p >= n - 1:
continue
q = s.find(pin[1], p+1)
if q == -1 or q == n - 1:
continue
r = s.find(pin[2], q+1)
if r == -1:
continue
... | 18 | 18 | 401 | 334 | n = int(eval(input()))
s = eval(input())
done_1 = set()
done_2 = set()
done_3 = set()
for i in range(n):
if s[i] in done_1:
continue
for j in range(i + 1, n):
if s[i] + s[j] in done_2:
continue
for k in range(j + 1, n):
pin = s[i] + s[j] + s[k]
done_3.... | n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(1000):
pin = str(i).zfill(3)
p = s.find(pin[0])
if p == -1 or p >= n - 1:
continue
q = s.find(pin[1], p + 1)
if q == -1 or q == n - 1:
continue
r = s.find(pin[2], q + 1)
if r == -1:
continue
ans += 1
... | false | 0 | [
"-done_1 = set()",
"-done_2 = set()",
"-done_3 = set()",
"-for i in range(n):",
"- if s[i] in done_1:",
"+ans = 0",
"+for i in range(1000):",
"+ pin = str(i).zfill(3)",
"+ p = s.find(pin[0])",
"+ if p == -1 or p >= n - 1:",
"- for j in range(i + 1, n):",
"- if s[i] + s[j]... | false | 0.096507 | 0.037675 | 2.561562 | [
"s805413818",
"s655778848"
] |
u631277801 | p03450 | python | s837123648 | s840874930 | 1,676 | 999 | 40,312 | 74,480 | Accepted | Accepted | 40.39 | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.re... | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.re... | 93 | 50 | 2,341 | 1,356 | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
... | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
... | false | 46.236559 | [
"-class WeightedUnionFind:",
"- def __init__(self, node: int) -> None:",
"- self.n = node",
"- self.par = [i for i in range(self.n)]",
"- self.rank = [0 for i in range(self.n)]",
"- self.diff_weight = [0 for i in range(self.n)]",
"-",
"- # ノードxのルートを求める",
"- def f... | false | 0.039118 | 0.040196 | 0.973169 | [
"s837123648",
"s840874930"
] |
u638282348 | p02714 | python | s566411927 | s498194695 | 1,808 | 460 | 27,228 | 76,036 | Accepted | Accepted | 74.56 | from numpy import prod
N = int(eval(input()))
S = eval(input())
appearances = {"R": 0, "G": 0, "B": 0}
for c in S:
appearances[c] += 1
print((prod(list(appearances.values())) - sum(sum(len(set(S[start] + S[start + step] + S[start + step * 2])) == 3 for start in range(N - step * 2)) for step in range(1, N // 2... | from functools import reduce
from operator import mul
N = int(eval(input()))
S = eval(input())
appearances = {"R": 0, "G": 0, "B": 0}
for c in S:
appearances[c] += 1
print((reduce(mul, list(appearances.values())) - sum(sum(len(set(S[start] + S[start + step] + S[start + step * 2])) == 3 for start in range(N -... | 7 | 8 | 315 | 354 | from numpy import prod
N = int(eval(input()))
S = eval(input())
appearances = {"R": 0, "G": 0, "B": 0}
for c in S:
appearances[c] += 1
print(
(
prod(list(appearances.values()))
- sum(
sum(
len(set(S[start] + S[start + step] + S[start + step * 2])) == 3
... | from functools import reduce
from operator import mul
N = int(eval(input()))
S = eval(input())
appearances = {"R": 0, "G": 0, "B": 0}
for c in S:
appearances[c] += 1
print(
(
reduce(mul, list(appearances.values()))
- sum(
sum(
len(set(S[start] + S[start + step] + S[s... | false | 12.5 | [
"-from numpy import prod",
"+from functools import reduce",
"+from operator import mul",
"- prod(list(appearances.values()))",
"+ reduce(mul, list(appearances.values()))"
] | false | 0.292045 | 0.061992 | 4.711016 | [
"s566411927",
"s498194695"
] |
u200887663 | p02573 | python | s710690636 | s377657786 | 1,689 | 1,252 | 575,372 | 107,964 | Accepted | Accepted | 25.87 | #n = int(input())
import random
import sys
sys.setrecursionlimit(10 ** 7)
n, m = list(map(int, input().split()))
#n=200000
#m=200000
#al = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
adjl = [[] for _ in range(n+1)]
NIL = -1
appear = {}
isalone = {}
for i in range... | #n = int(input())
from collections import deque
n, m = list(map(int, input().split()))
# n=200000
# m=200000
#al = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
adjl = [[] for _ in range(n+1)]
NIL = -1
appear = {}
isalone = {}
for i in range(m):
a, b = list(map(... | 58 | 58 | 1,283 | 1,368 | # n = int(input())
import random
import sys
sys.setrecursionlimit(10**7)
n, m = list(map(int, input().split()))
# n=200000
# m=200000
# al = list(map(int, input().split()))
# l = [list(map(int,input().split())) for i in range(n)]
adjl = [[] for _ in range(n + 1)]
NIL = -1
appear = {}
isalone = {}
for i in range(m):
... | # n = int(input())
from collections import deque
n, m = list(map(int, input().split()))
# n=200000
# m=200000
# al = list(map(int, input().split()))
# l = [list(map(int,input().split())) for i in range(n)]
adjl = [[] for _ in range(n + 1)]
NIL = -1
appear = {}
isalone = {}
for i in range(m):
a, b = list(map(int, i... | false | 0 | [
"-import random",
"-import sys",
"+from collections import deque",
"-sys.setrecursionlimit(10**7)",
"- # a=random.randrange(1,n+1)",
"- # b=random.randrange(1,n+1)",
"- # while a==b:",
"- # b=random.randrange(1,n+1)",
"- # print(a,b)",
"-color = [NIL for i in range(n + 1)]",
"-... | false | 0.040128 | 0.038541 | 1.041189 | [
"s710690636",
"s377657786"
] |
u397460030 | p02314 | python | s296424144 | s559903523 | 970 | 680 | 47,252 | 11,760 | Accepted | Accepted | 29.9 | from itertools import product
class DP:
def __init__(self, value, variety, coins):
self.value = value
self.variety = variety
self.coins = coins
self.DP = [[0 for _ in range(value + 1)] for _ in range(variety)]
self.DPinit()
def DPinit(self):
for row i... | from itertools import product
value, variety = list(map(int, input().split()))
coins = list(map(int, input().split()))
dp = [float("inf") for _ in range(value + 1)]
dp[0] = 0
for (c,j) in product(coins,list(range(value + 1))):
if c <= j:
dp[j] = min(dp[j], dp[j - c] + 1)
else:
dp[j] =... | 35 | 12 | 1,070 | 338 | from itertools import product
class DP:
def __init__(self, value, variety, coins):
self.value = value
self.variety = variety
self.coins = coins
self.DP = [[0 for _ in range(value + 1)] for _ in range(variety)]
self.DPinit()
def DPinit(self):
for row in self.DP:... | from itertools import product
value, variety = list(map(int, input().split()))
coins = list(map(int, input().split()))
dp = [float("inf") for _ in range(value + 1)]
dp[0] = 0
for (c, j) in product(coins, list(range(value + 1))):
if c <= j:
dp[j] = min(dp[j], dp[j - c] + 1)
else:
dp[j] = dp[j]
p... | false | 65.714286 | [
"-",
"-class DP:",
"- def __init__(self, value, variety, coins):",
"- self.value = value",
"- self.variety = variety",
"- self.coins = coins",
"- self.DP = [[0 for _ in range(value + 1)] for _ in range(variety)]",
"- self.DPinit()",
"-",
"- def DPinit(self)... | false | 0.085518 | 0.086173 | 0.992398 | [
"s296424144",
"s559903523"
] |
u241159583 | p03212 | python | s104540311 | s303902817 | 56 | 51 | 4,060 | 9,076 | Accepted | Accepted | 8.93 | import itertools
n = eval(input())
number = list("753")
N = []
flag = False
for i in range(3, 10):
for v in itertools.product(number, repeat=i):
if "7" in v and "5" in v and "3" in v:
if int("".join(v)) <= int(n): N.append(int("".join(v)))
print((len(N))) | import itertools
n = int(eval(input()))
cnt = 0
for i in range(3,len(str(n))+1):
for v in itertools.product(["3","5","7"], repeat=i):
if len(set(v))!=3: continue
x = int("".join(v))
if n >= x: cnt += 1
print(cnt) | 10 | 10 | 268 | 244 | import itertools
n = eval(input())
number = list("753")
N = []
flag = False
for i in range(3, 10):
for v in itertools.product(number, repeat=i):
if "7" in v and "5" in v and "3" in v:
if int("".join(v)) <= int(n):
N.append(int("".join(v)))
print((len(N)))
| import itertools
n = int(eval(input()))
cnt = 0
for i in range(3, len(str(n)) + 1):
for v in itertools.product(["3", "5", "7"], repeat=i):
if len(set(v)) != 3:
continue
x = int("".join(v))
if n >= x:
cnt += 1
print(cnt)
| false | 0 | [
"-n = eval(input())",
"-number = list(\"753\")",
"-N = []",
"-flag = False",
"-for i in range(3, 10):",
"- for v in itertools.product(number, repeat=i):",
"- if \"7\" in v and \"5\" in v and \"3\" in v:",
"- if int(\"\".join(v)) <= int(n):",
"- N.append(int(\"\".j... | false | 0.085642 | 0.04306 | 1.988904 | [
"s104540311",
"s303902817"
] |
u312025627 | p04019 | python | s824825520 | s790041200 | 177 | 17 | 38,256 | 2,940 | Accepted | Accepted | 90.4 | s = {st for st in eval(input())}
if ({'S','N'} & s == {'S','N'} or {'S','N'} & s == set()) and ({'E','W'} & s == {'E','W'} or {'E','W'} & s == set()):
print("Yes")
else:
print("No") | def main():
S = eval(input())
we = ("W" in S and "E" in S) or ("W" not in S and "E" not in S)
ns = ("N" in S and "S" in S) or ("N" not in S and "S" not in S)
if we and ns:
print("Yes")
else:
print("No")
if __name__ == '__main__':
main()
| 5 | 12 | 187 | 284 | s = {st for st in eval(input())}
if ({"S", "N"} & s == {"S", "N"} or {"S", "N"} & s == set()) and (
{"E", "W"} & s == {"E", "W"} or {"E", "W"} & s == set()
):
print("Yes")
else:
print("No")
| def main():
S = eval(input())
we = ("W" in S and "E" in S) or ("W" not in S and "E" not in S)
ns = ("N" in S and "S" in S) or ("N" not in S and "S" not in S)
if we and ns:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
| false | 58.333333 | [
"-s = {st for st in eval(input())}",
"-if ({\"S\", \"N\"} & s == {\"S\", \"N\"} or {\"S\", \"N\"} & s == set()) and (",
"- {\"E\", \"W\"} & s == {\"E\", \"W\"} or {\"E\", \"W\"} & s == set()",
"-):",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+def main():",
"+ S = eval(input())",
... | false | 0.042674 | 0.039167 | 1.089554 | [
"s824825520",
"s790041200"
] |
u684120680 | p03037 | python | s780658594 | s818665101 | 320 | 292 | 11,084 | 3,060 | Accepted | Accepted | 8.75 | n, m = [int(i) for i in input().split()]
l = []
r = []
for _ in range(m):
l_tmp, r_tmp = [int(i) for i in input().split()]
l.append(l_tmp)
r.append(r_tmp)
l_max = max(l)
r_min = min(r)
ans = r_min - l_max + 1
if ans > 0:
print(ans)
else:
print((0))
| n, m = [int(i) for i in input().split()]
l_max = 0
r_min = float('inf')
for _ in range(m):
l, r = [int(i) for i in input().split()]
if l > l_max:
l_max = l
if r < r_min:
r_min = r
ans = r_min - l_max + 1
if ans > 0:
print(ans)
else:
print((0))
| 18 | 17 | 280 | 279 | n, m = [int(i) for i in input().split()]
l = []
r = []
for _ in range(m):
l_tmp, r_tmp = [int(i) for i in input().split()]
l.append(l_tmp)
r.append(r_tmp)
l_max = max(l)
r_min = min(r)
ans = r_min - l_max + 1
if ans > 0:
print(ans)
else:
print((0))
| n, m = [int(i) for i in input().split()]
l_max = 0
r_min = float("inf")
for _ in range(m):
l, r = [int(i) for i in input().split()]
if l > l_max:
l_max = l
if r < r_min:
r_min = r
ans = r_min - l_max + 1
if ans > 0:
print(ans)
else:
print((0))
| false | 5.555556 | [
"-l = []",
"-r = []",
"+l_max = 0",
"+r_min = float(\"inf\")",
"- l_tmp, r_tmp = [int(i) for i in input().split()]",
"- l.append(l_tmp)",
"- r.append(r_tmp)",
"-l_max = max(l)",
"-r_min = min(r)",
"+ l, r = [int(i) for i in input().split()]",
"+ if l > l_max:",
"+ l_max =... | false | 0.043299 | 0.035751 | 1.211099 | [
"s780658594",
"s818665101"
] |
u553987207 | p02802 | python | s823015781 | s565365432 | 277 | 95 | 5,528 | 11,188 | Accepted | Accepted | 65.7 | N, M = list(map(int, input().split()))
ac = [False] * N
wa = [0] * N
for _ in range(M):
p, s = input().split()
p = int(p) - 1
if not ac[p]:
if s == "AC":
ac[p] = True
else:
wa[p] += 1
accnt = len([1 for x in ac if x])
wacnt = sum([wa[i] for i in range(N) i... | import sys
N, M = list(map(int, input().split()))
ac = [0] * N
wa = [0] * N
for _ in range(M):
p, s = sys.stdin.readline().split()
p = int(p) - 1
if s == "AC":
ac[p] = 1
else:
if not ac[p]:
wa[p] += 1
acnum = sum(ac)
wanum = sum([c for i, c in enumerate(wa) if ... | 14 | 16 | 344 | 347 | N, M = list(map(int, input().split()))
ac = [False] * N
wa = [0] * N
for _ in range(M):
p, s = input().split()
p = int(p) - 1
if not ac[p]:
if s == "AC":
ac[p] = True
else:
wa[p] += 1
accnt = len([1 for x in ac if x])
wacnt = sum([wa[i] for i in range(N) if ac[i]])
pr... | import sys
N, M = list(map(int, input().split()))
ac = [0] * N
wa = [0] * N
for _ in range(M):
p, s = sys.stdin.readline().split()
p = int(p) - 1
if s == "AC":
ac[p] = 1
else:
if not ac[p]:
wa[p] += 1
acnum = sum(ac)
wanum = sum([c for i, c in enumerate(wa) if ac[i] == 1])
p... | false | 12.5 | [
"+import sys",
"+",
"-ac = [False] * N",
"+ac = [0] * N",
"- p, s = input().split()",
"+ p, s = sys.stdin.readline().split()",
"- if not ac[p]:",
"- if s == \"AC\":",
"- ac[p] = True",
"- else:",
"+ if s == \"AC\":",
"+ ac[p] = 1",
"+ else:",
... | false | 0.039125 | 0.129595 | 0.3019 | [
"s823015781",
"s565365432"
] |
u040298438 | p03659 | python | s755307743 | s444233858 | 160 | 125 | 47,704 | 37,764 | Accepted | Accepted | 21.88 | from itertools import accumulate
eval(input())
a = list(map(int, input().split()))
b = list(accumulate(a))
c = [abs(y * 2 - b[-1]) for y in b][:-1]
print((min([abs(y * 2 - b[-1]) for y in b][:-1]))) | from itertools import accumulate
eval(input())
a = list(map(int, input().split()))
b = list(accumulate(a))
print((min([abs(y * 2 - b[-1]) for y in b][:-1]))) | 7 | 6 | 197 | 155 | from itertools import accumulate
eval(input())
a = list(map(int, input().split()))
b = list(accumulate(a))
c = [abs(y * 2 - b[-1]) for y in b][:-1]
print((min([abs(y * 2 - b[-1]) for y in b][:-1])))
| from itertools import accumulate
eval(input())
a = list(map(int, input().split()))
b = list(accumulate(a))
print((min([abs(y * 2 - b[-1]) for y in b][:-1])))
| false | 14.285714 | [
"-c = [abs(y * 2 - b[-1]) for y in b][:-1]"
] | false | 0.079647 | 0.07996 | 0.996086 | [
"s755307743",
"s444233858"
] |
u367130284 | p04039 | python | s276681967 | s808975093 | 181 | 126 | 3,188 | 2,940 | Accepted | Accepted | 30.39 | s=set(range(10))
n,k,*a=list(map(int,open(0).read().split()))
a=s-set(a) #使っていい数字
for t in range(n,100000):
if set(list(map(int,list(str(t)))))<=a:
print(t)
break | x=lambda:input().split()
n,_=x();a=x();n=int(n)
while any(s in set(a)for s in str(n)):n+=1
print(n) | 7 | 4 | 182 | 102 | s = set(range(10))
n, k, *a = list(map(int, open(0).read().split()))
a = s - set(a) # 使っていい数字
for t in range(n, 100000):
if set(list(map(int, list(str(t))))) <= a:
print(t)
break
| x = lambda: input().split()
n, _ = x()
a = x()
n = int(n)
while any(s in set(a) for s in str(n)):
n += 1
print(n)
| false | 42.857143 | [
"-s = set(range(10))",
"-n, k, *a = list(map(int, open(0).read().split()))",
"-a = s - set(a) # 使っていい数字",
"-for t in range(n, 100000):",
"- if set(list(map(int, list(str(t))))) <= a:",
"- print(t)",
"- break",
"+x = lambda: input().split()",
"+n, _ = x()",
"+a = x()",
"+n = int... | false | 0.046915 | 0.042709 | 1.098463 | [
"s276681967",
"s808975093"
] |
u901080241 | p00474 | python | s249117267 | s175872778 | 430 | 350 | 28,172 | 20,456 | Accepted | Accepted | 18.6 | n, l = list(map(int,input().split()))
ai = [[int(eval(input())),i] for i in range(n)]
ai.sort(key = lambda x: x[0])
time = [0]*(n+2)
for i in ai:
idx = i[1]
time[idx+1] = max(time[idx],time[idx+2]) + l - i[0]
print((max(time))) | n, l = list(map(int,input().split()))
#ai = [[int(input()),i] for i in range(n)]
ai = [[] for _ in range(l)]
for i in range(n):
ai[int(eval(input()))].append(i)
time = [0]*(n+2)
for i in range(l-1,0,-1):
for j in ai[i]:
time[j+1] = max(time[j],time[j+2]) + l - i
print((max(time))) | 10 | 12 | 232 | 296 | n, l = list(map(int, input().split()))
ai = [[int(eval(input())), i] for i in range(n)]
ai.sort(key=lambda x: x[0])
time = [0] * (n + 2)
for i in ai:
idx = i[1]
time[idx + 1] = max(time[idx], time[idx + 2]) + l - i[0]
print((max(time)))
| n, l = list(map(int, input().split()))
# ai = [[int(input()),i] for i in range(n)]
ai = [[] for _ in range(l)]
for i in range(n):
ai[int(eval(input()))].append(i)
time = [0] * (n + 2)
for i in range(l - 1, 0, -1):
for j in ai[i]:
time[j + 1] = max(time[j], time[j + 2]) + l - i
print((max(time)))
| false | 16.666667 | [
"-ai = [[int(eval(input())), i] for i in range(n)]",
"-ai.sort(key=lambda x: x[0])",
"+# ai = [[int(input()),i] for i in range(n)]",
"+ai = [[] for _ in range(l)]",
"+for i in range(n):",
"+ ai[int(eval(input()))].append(i)",
"-for i in ai:",
"- idx = i[1]",
"- time[idx + 1] = max(time[idx]... | false | 0.102959 | 0.031631 | 3.254997 | [
"s249117267",
"s175872778"
] |
u921729430 | p02676 | python | s545853075 | s844027023 | 22 | 20 | 9,132 | 9,184 | Accepted | Accepted | 9.09 | K = int(input())
S = input()
for i ,s in enumerate(S):
if i == K:
print('...')
break
print(s, end='')
| K = int(eval(input()))
S = eval(input())
if len(S) <= K:
print(S)
else:
print((S[:K] + "..."))
| 7 | 6 | 119 | 90 | K = int(input())
S = input()
for i, s in enumerate(S):
if i == K:
print("...")
break
print(s, end="")
| K = int(eval(input()))
S = eval(input())
if len(S) <= K:
print(S)
else:
print((S[:K] + "..."))
| false | 14.285714 | [
"-K = int(input())",
"-S = input()",
"-for i, s in enumerate(S):",
"- if i == K:",
"- print(\"...\")",
"- break",
"- print(s, end=\"\")",
"+K = int(eval(input()))",
"+S = eval(input())",
"+if len(S) <= K:",
"+ print(S)",
"+else:",
"+ print((S[:K] + \"...\"))"
] | false | 0.047244 | 0.045116 | 1.047171 | [
"s545853075",
"s844027023"
] |
u814986259 | p03380 | python | s695560382 | s523639821 | 247 | 80 | 19,164 | 14,348 | Accepted | Accepted | 67.61 | n = int(eval(input()))
a = list(map(int, input().split()))
ans=a.pop(a.index(max(a)))
for i in range(n - 1):
if a[i] > ans / 2:
a[i] = [ans - a[i],a[i]]
else:
a[i] = [a[i],a[i]]
a = sorted(a,reverse = True)
print((str(ans) + " " + str(a[0][1]))) | import math
import bisect
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
ncr = 0
ans = [0, 0]
id = bisect.bisect_left(a[:n-1], a[n-1]//2)
if abs(a[-1]/2 - a[id]) < abs(a[-1]/2 - a[id-1]):
ans = id
else:
ans = id-1
print((a[-1], a[ans]))
| 14 | 19 | 278 | 282 | n = int(eval(input()))
a = list(map(int, input().split()))
ans = a.pop(a.index(max(a)))
for i in range(n - 1):
if a[i] > ans / 2:
a[i] = [ans - a[i], a[i]]
else:
a[i] = [a[i], a[i]]
a = sorted(a, reverse=True)
print((str(ans) + " " + str(a[0][1])))
| import math
import bisect
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
ncr = 0
ans = [0, 0]
id = bisect.bisect_left(a[: n - 1], a[n - 1] // 2)
if abs(a[-1] / 2 - a[id]) < abs(a[-1] / 2 - a[id - 1]):
ans = id
else:
ans = id - 1
print((a[-1], a[ans]))
| false | 26.315789 | [
"+import math",
"+import bisect",
"+",
"-ans = a.pop(a.index(max(a)))",
"-for i in range(n - 1):",
"- if a[i] > ans / 2:",
"- a[i] = [ans - a[i], a[i]]",
"- else:",
"- a[i] = [a[i], a[i]]",
"-a = sorted(a, reverse=True)",
"-print((str(ans) + \" \" + str(a[0][1])))",
"+a.sor... | false | 0.045521 | 0.042756 | 1.064666 | [
"s695560382",
"s523639821"
] |
u123135189 | p03304 | python | s037903618 | s799804829 | 20 | 17 | 3,316 | 2,940 | Accepted | Accepted | 15 | n, m, d = list(map(int,input().split()))
if d == 0:
p = n
elif n < d:
p = 0
else:
p = (n * 2 - d * 2)
r = p / (n * n)
a = r * (m - 1)
print((round(a, 8)))
| n, m, d = list(map(int,input().split()))
if d == 0:
p = n
else:
p = (n * 2 - d * 2)
r = p / (n * n)
a = r * (m - 1)
print((round(a, 8)))
| 10 | 8 | 168 | 144 | n, m, d = list(map(int, input().split()))
if d == 0:
p = n
elif n < d:
p = 0
else:
p = n * 2 - d * 2
r = p / (n * n)
a = r * (m - 1)
print((round(a, 8)))
| n, m, d = list(map(int, input().split()))
if d == 0:
p = n
else:
p = n * 2 - d * 2
r = p / (n * n)
a = r * (m - 1)
print((round(a, 8)))
| false | 20 | [
"-elif n < d:",
"- p = 0"
] | false | 0.048456 | 0.048317 | 1.002882 | [
"s037903618",
"s799804829"
] |
u535423069 | p03371 | python | s483424211 | s726547596 | 65 | 17 | 3,064 | 3,064 | Accepted | Accepted | 73.85 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()
a, b, c, x, y = na()
ans = 0
while x or y:
if x and y:
if a + b > c * 2:
x -= 1
... | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()
a, b, c, x, y = na()
ans = 0
while x or y:
if x and y:
if a + b > c * 2:
z = min(x, y)
... | 36 | 38 | 715 | 779 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()
a, b, c, x, y = na()
ans = 0
while x or y:
if x and y:
if a + b > c * 2:
x -= 1
y -= 1
... | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()
a, b, c, x, y = na()
ans = 0
while x or y:
if x and y:
if a + b > c * 2:
z = min(x, y)
x -= z
... | false | 5.263158 | [
"- x -= 1",
"- y -= 1",
"- ans += c * 2",
"+ z = min(x, y)",
"+ x -= z",
"+ y -= z",
"+ ans += c * 2 * z",
"- x -= 1",
"- y -= 1",
"- ans += a + b",
"+ z = min(x, y)",
"+ ... | false | 0.058129 | 0.046868 | 1.240277 | [
"s483424211",
"s726547596"
] |
u246809151 | p02711 | python | s804137706 | s893944353 | 22 | 20 | 9,096 | 9,028 | Accepted | Accepted | 9.09 | import sys
A = eval(input())
for i in range(len(A)):
if A[i] == '7':
print('Yes')
sys.exit()
print('No') | N = eval(input())
ans = list(set(N))
#print(ans)
if ans.count('7'):
print('Yes')
else:
print('No')
| 9 | 7 | 128 | 107 | import sys
A = eval(input())
for i in range(len(A)):
if A[i] == "7":
print("Yes")
sys.exit()
print("No")
| N = eval(input())
ans = list(set(N))
# print(ans)
if ans.count("7"):
print("Yes")
else:
print("No")
| false | 22.222222 | [
"-import sys",
"-",
"-A = eval(input())",
"-for i in range(len(A)):",
"- if A[i] == \"7\":",
"- print(\"Yes\")",
"- sys.exit()",
"-print(\"No\")",
"+N = eval(input())",
"+ans = list(set(N))",
"+# print(ans)",
"+if ans.count(\"7\"):",
"+ print(\"Yes\")",
"+else:",
"+ ... | false | 0.092966 | 0.104074 | 0.89327 | [
"s804137706",
"s893944353"
] |
u888092736 | p02725 | python | s637666815 | s736419591 | 149 | 118 | 26,460 | 31,664 | Accepted | Accepted | 20.81 | k, n = list(map(int, input().split()))
A = list(map(int, input().split()))
max_dist = 0
for i in range(n - 1):
max_dist = max(max_dist, A[i + 1] - A[i])
max_dist = max(max_dist, A[0] + k - A[i + 1])
print((k - max_dist))
| K, N, *A = list(map(int, open(0).read().split()))
A = [A[-1] - K] + A
max_gap = 0
for a1, a2 in zip(A, A[1:]):
max_gap = max(max_gap, a2 - a1)
print((K - max_gap))
| 9 | 7 | 227 | 167 | k, n = list(map(int, input().split()))
A = list(map(int, input().split()))
max_dist = 0
for i in range(n - 1):
max_dist = max(max_dist, A[i + 1] - A[i])
max_dist = max(max_dist, A[0] + k - A[i + 1])
print((k - max_dist))
| K, N, *A = list(map(int, open(0).read().split()))
A = [A[-1] - K] + A
max_gap = 0
for a1, a2 in zip(A, A[1:]):
max_gap = max(max_gap, a2 - a1)
print((K - max_gap))
| false | 22.222222 | [
"-k, n = list(map(int, input().split()))",
"-A = list(map(int, input().split()))",
"-max_dist = 0",
"-for i in range(n - 1):",
"- max_dist = max(max_dist, A[i + 1] - A[i])",
"-max_dist = max(max_dist, A[0] + k - A[i + 1])",
"-print((k - max_dist))",
"+K, N, *A = list(map(int, open(0).read().split()... | false | 0.043852 | 0.040637 | 1.0791 | [
"s637666815",
"s736419591"
] |
u864013199 | p02731 | python | s231320964 | s183925724 | 37 | 18 | 5,332 | 2,940 | Accepted | Accepted | 51.35 | from decimal import Decimal
L = int(eval(input()))
print((Decimal(L/3)**3))
| L = int(eval(input()))
print(((L/3)**3)) | 3 | 2 | 70 | 33 | from decimal import Decimal
L = int(eval(input()))
print((Decimal(L / 3) ** 3))
| L = int(eval(input()))
print(((L / 3) ** 3))
| false | 33.333333 | [
"-from decimal import Decimal",
"-",
"-print((Decimal(L / 3) ** 3))",
"+print(((L / 3) ** 3))"
] | false | 0.037928 | 0.039625 | 0.957165 | [
"s231320964",
"s183925724"
] |
u426572476 | p03671 | python | s545856294 | s764782001 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | import math
a, b, c = list(map(int, input().split()))
print((min(a + b, b + c, c + a))) | import math
a = [int(i) for i in input().split()]
print((sum(a) - max(a))) | 4 | 4 | 83 | 76 | import math
a, b, c = list(map(int, input().split()))
print((min(a + b, b + c, c + a)))
| import math
a = [int(i) for i in input().split()]
print((sum(a) - max(a)))
| false | 0 | [
"-a, b, c = list(map(int, input().split()))",
"-print((min(a + b, b + c, c + a)))",
"+a = [int(i) for i in input().split()]",
"+print((sum(a) - max(a)))"
] | false | 0.069515 | 0.008485 | 8.192269 | [
"s545856294",
"s764782001"
] |
u203843959 | p04000 | python | s381951987 | s139698080 | 2,199 | 1,864 | 150,516 | 186,608 | Accepted | Accepted | 15.23 | H,W,N=list(map(int,input().split()))
allcase=(H-2)*(W-2)
abset=set()
for _ in range(N):
a,b=list(map(int,input().split()))
abset.add((a-1,b-1))
#print(abset)
memo={}
def count_black(x,y):
if (x,y) in memo:
return memo[(x,y)]
num_black=0
for ii in range(3):
for jj in range(3):
... | from collections import defaultdict
H,W,N=list(map(int,input().split()))
allcase=(H-2)*(W-2)
abset=set()
for _ in range(N):
a,b=list(map(int,input().split()))
abset.add((a-1,b-1))
#print(abset)
memo=defaultdict(int)
for a,b in abset:
for j in range(-2,1):
if a+j<0 or H-2<=a+j:
continue... | 43 | 30 | 807 | 598 | H, W, N = list(map(int, input().split()))
allcase = (H - 2) * (W - 2)
abset = set()
for _ in range(N):
a, b = list(map(int, input().split()))
abset.add((a - 1, b - 1))
# print(abset)
memo = {}
def count_black(x, y):
if (x, y) in memo:
return memo[(x, y)]
num_black = 0
for ii in range(3):
... | from collections import defaultdict
H, W, N = list(map(int, input().split()))
allcase = (H - 2) * (W - 2)
abset = set()
for _ in range(N):
a, b = list(map(int, input().split()))
abset.add((a - 1, b - 1))
# print(abset)
memo = defaultdict(int)
for a, b in abset:
for j in range(-2, 1):
if a + j < 0 o... | false | 30.232558 | [
"+from collections import defaultdict",
"+",
"-memo = {}",
"-",
"-",
"-def count_black(x, y):",
"- if (x, y) in memo:",
"- return memo[(x, y)]",
"- num_black = 0",
"- for ii in range(3):",
"- for jj in range(3):",
"- if (x + ii, y + jj) in abset:",
"- ... | false | 0.081275 | 0.151641 | 0.535968 | [
"s381951987",
"s139698080"
] |
u810735437 | p03320 | python | s579759296 | s684650460 | 405 | 358 | 81,880 | 70,764 | Accepted | Accepted | 11.6 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys
def T(k):
orig_k = k
sk = 0
while k > 0:
sk += k % 10
... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys
def T(k):
orig_k = k
sk = 0
while k > 0:
sk += k % 10
... | 53 | 53 | 856 | 855 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys
def T(k):
orig_k = k
sk = 0
while k > 0:
sk += k % 10
k //= 10
r... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys
def T(k):
orig_k = k
sk = 0
while k > 0:
sk += k % 10
k //= 10
r... | false | 0 | [
"-for i in range(1, 9999):",
"+for i in range(1, 999):"
] | false | 0.353994 | 0.091284 | 3.877953 | [
"s579759296",
"s684650460"
] |
u367701763 | p03557 | python | s529277756 | s937066011 | 487 | 449 | 107,108 | 106,980 | Accepted | Accepted | 7.8 | from bisect import bisect_left
from collections import defaultdict
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
num_a = 0
num_c = 0
res = 0
pre_b = -1
dict_C = defaultdict(int)
for b in B:
... | from bisect import bisect_left
from bisect import bisect_right
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
num_a = 0
num_c = 0
res = 0
pre_b = -1
for b in B:
if b == pre_b:
res ... | 29 | 25 | 651 | 532 | from bisect import bisect_left
from collections import defaultdict
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
num_a = 0
num_c = 0
res = 0
pre_b = -1
dict_C = defaultdict(int)
for b in B:
if b == pre_b:
... | from bisect import bisect_left
from bisect import bisect_right
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
num_a = 0
num_c = 0
res = 0
pre_b = -1
for b in B:
if b == pre_b:
res += num_a * num_c
... | false | 13.793103 | [
"-from collections import defaultdict",
"+from bisect import bisect_right",
"-dict_C = defaultdict(int)",
"- pre_num_c = bisect_left(C, b)",
"+ pre_num_c = bisect_right(C, b)",
"- if pre_num_c != N and C[pre_num_c] == b:",
"- num_c = N - bisect_left(C, b + 1)"
] | false | 0.042531 | 0.03955 | 1.075381 | [
"s529277756",
"s937066011"
] |
u707124227 | p03095 | python | s720639460 | s180469853 | 38 | 25 | 3,444 | 3,444 | Accepted | Accepted | 34.21 | from collections import defaultdict
n=int(eval(input()))
s=eval(input())
mod=pow(10,9)+7
sd=defaultdict(lambda:1)
for i in range(n):
sd[s[i]]+=1
ans=1
for k in list(sd.keys()):
ans*=(sd[k])%mod
print((ans%mod-1))
| from collections import Counter
mod=pow(10,9)+7
n=int(eval(input()))
s=eval(input())
cs=Counter(s)
ans=1
for a in list(cs.values()):
ans*=a+1
ans%=mod
print((ans-1)) | 11 | 10 | 215 | 158 | from collections import defaultdict
n = int(eval(input()))
s = eval(input())
mod = pow(10, 9) + 7
sd = defaultdict(lambda: 1)
for i in range(n):
sd[s[i]] += 1
ans = 1
for k in list(sd.keys()):
ans *= (sd[k]) % mod
print((ans % mod - 1))
| from collections import Counter
mod = pow(10, 9) + 7
n = int(eval(input()))
s = eval(input())
cs = Counter(s)
ans = 1
for a in list(cs.values()):
ans *= a + 1
ans %= mod
print((ans - 1))
| false | 9.090909 | [
"-from collections import defaultdict",
"+from collections import Counter",
"+mod = pow(10, 9) + 7",
"-mod = pow(10, 9) + 7",
"-sd = defaultdict(lambda: 1)",
"-for i in range(n):",
"- sd[s[i]] += 1",
"+cs = Counter(s)",
"-for k in list(sd.keys()):",
"- ans *= (sd[k]) % mod",
"-print((ans %... | false | 0.038341 | 0.046753 | 0.820077 | [
"s720639460",
"s180469853"
] |
u094191970 | p03476 | python | s119823502 | s815598764 | 1,915 | 867 | 4,356 | 5,292 | Accepted | Accepted | 54.73 | def factorization(n):
p=2
fcr=[]
while p*p<=n:
while n%p==0:
fcr.append(p)
n//=p
p+=1
if n>1:
fcr.append(n)
return fcr
q=int(eval(input()))
cnt=1
p_list=[1]
q_list=[0]
for i in range(3,10**5+1,2):
a=factorization(i)
b=factorization((i+1)//2)
if len(a)==len(b)==1:
cnt+=1
... | def eratosthenes(n):
is_p=[1]*n
p_list=[]
is_p[0]=0
is_p[1]=0
for i in range(2,n):
if is_p[i]:
p_list.append(i)
for j in range(i*i,n,i):
is_p[j] = 0
# return p_list
return is_p
q=int(eval(input()))
lim=10**5+1
is_p=eratosthenes(lim)
#print(is_p)
b=[0]
for i in range(1,li... | 37 | 35 | 523 | 493 | def factorization(n):
p = 2
fcr = []
while p * p <= n:
while n % p == 0:
fcr.append(p)
n //= p
p += 1
if n > 1:
fcr.append(n)
return fcr
q = int(eval(input()))
cnt = 1
p_list = [1]
q_list = [0]
for i in range(3, 10**5 + 1, 2):
a = factorization(i... | def eratosthenes(n):
is_p = [1] * n
p_list = []
is_p[0] = 0
is_p[1] = 0
for i in range(2, n):
if is_p[i]:
p_list.append(i)
for j in range(i * i, n, i):
is_p[j] = 0
# return p_list
return is_p
q = int(eval(input()))
lim = 10**5 + 1
is_p = erat... | false | 5.405405 | [
"-def factorization(n):",
"- p = 2",
"- fcr = []",
"- while p * p <= n:",
"- while n % p == 0:",
"- fcr.append(p)",
"- n //= p",
"- p += 1",
"- if n > 1:",
"- fcr.append(n)",
"- return fcr",
"+def eratosthenes(n):",
"+ is_p = [1] *... | false | 3.075451 | 0.463357 | 6.637331 | [
"s119823502",
"s815598764"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.