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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u490553751 | p03126 | python | s060573365 | s367867873 | 173 | 18 | 38,384 | 3,060 | Accepted | Accepted | 89.6 | N,M = list(map(int,input().split()))
nes = []
count = 0
for i in range(N) :
li = list(map(int,input().split()))
nes.append(li)
favorite = [0] * M
for i in range(N) :
for j in range(1,nes[i][0]+1) :
favorite[nes[i][j]-1] += 1
for i in range(M) :
if favorite[i] == N :
count+=1
... | #template
def inputlist(): return [int(k) for k in input().split()]
#template
N,M = inputlist()
ans = [0]*(M+1)
c =0
for i in range(N):
A = inputlist()
K = A[0]
Aa = A[1:]
for j in range(K):
ans[Aa[j]] +=1
for i in range(1,M+1):
if ans[i] == N:
c+=1
print(c) | 14 | 16 | 327 | 309 | N, M = list(map(int, input().split()))
nes = []
count = 0
for i in range(N):
li = list(map(int, input().split()))
nes.append(li)
favorite = [0] * M
for i in range(N):
for j in range(1, nes[i][0] + 1):
favorite[nes[i][j] - 1] += 1
for i in range(M):
if favorite[i] == N:
count += 1
print(c... | # template
def inputlist():
return [int(k) for k in input().split()]
# template
N, M = inputlist()
ans = [0] * (M + 1)
c = 0
for i in range(N):
A = inputlist()
K = A[0]
Aa = A[1:]
for j in range(K):
ans[Aa[j]] += 1
for i in range(1, M + 1):
if ans[i] == N:
c += 1
print(c)
| false | 12.5 | [
"-N, M = list(map(int, input().split()))",
"-nes = []",
"-count = 0",
"+# template",
"+def inputlist():",
"+ return [int(k) for k in input().split()]",
"+",
"+",
"+# template",
"+N, M = inputlist()",
"+ans = [0] * (M + 1)",
"+c = 0",
"- li = list(map(int, input().split()))",
"- ne... | false | 0.042869 | 0.036394 | 1.17791 | [
"s060573365",
"s367867873"
] |
u060896757 | p02613 | python | s248560980 | s145562010 | 271 | 156 | 85,012 | 84,200 | Accepted | Accepted | 42.44 | import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log # log2ないyp
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combina... | import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log # log2ないyp
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combina... | 80 | 91 | 1,558 | 1,716 | import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log # log2ないyp
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import (
accumulate,
permutations,
combinations,
product... | import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log # log2ないyp
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import (
accumulate,
permutations,
combinations,
product... | false | 12.087912 | [
"- S = []",
"+ AC = 0",
"+ WA = 0",
"+ TLE = 0",
"+ RE = 0",
"- S.append(ST())",
"- cnt = Counter(S)",
"- print(\"AC x\", cnt[\"AC\"])",
"- print(\"WA x\", cnt[\"WA\"])",
"- print(\"TLE x\", cnt[\"TLE\"])",
"- print(\"RE x\", cnt[\"RE\"])",
"+ S = ST... | false | 0.086115 | 0.085427 | 1.008047 | [
"s248560980",
"s145562010"
] |
u516613126 | p03085 | python | s499934879 | s373109869 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | b = eval(input())
if b == "A":
print("T")
if b == "T":
print("A")
if b == "G":
print("C")
if b == "C":
print("G") | d = {"A":"T","T":"A","C":"G","G":"C"}
print((d[eval(input())])) | 9 | 2 | 123 | 56 | b = eval(input())
if b == "A":
print("T")
if b == "T":
print("A")
if b == "G":
print("C")
if b == "C":
print("G")
| d = {"A": "T", "T": "A", "C": "G", "G": "C"}
print((d[eval(input())]))
| false | 77.777778 | [
"-b = eval(input())",
"-if b == \"A\":",
"- print(\"T\")",
"-if b == \"T\":",
"- print(\"A\")",
"-if b == \"G\":",
"- print(\"C\")",
"-if b == \"C\":",
"- print(\"G\")",
"+d = {\"A\": \"T\", \"T\": \"A\", \"C\": \"G\", \"G\": \"C\"}",
"+print((d[eval(input())]))"
] | false | 0.051452 | 0.051345 | 1.002078 | [
"s499934879",
"s373109869"
] |
u654470292 | p02775 | python | s116869367 | s693959462 | 947 | 557 | 187,456 | 143,144 | Accepted | Accepted | 41.18 | import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
return sys.stdin.readline()[:-1]
mod=pow(10,9)+7
n=eval(input())
# lst=[int(n[i]) for i in range(len(n))]
# for i in ran... | import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
return sys.stdin.readline()[:-1]
mod=pow(10,9)+7
n=eval(input())
keta=len(n)
ans=0
# dp=[[0,1]]
# for i in range(ket... | 33 | 29 | 742 | 623 | import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations, accumulate, combinations, product
from fractions import gcd
def input():
return sys.stdin.readline()[:-1]
mod = pow(10, 9) + 7
n = eval(input())
# lst=[int(n[i]) for i in range(len(n))]
# for i in ran... | import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations, accumulate, combinations, product
from fractions import gcd
def input():
return sys.stdin.readline()[:-1]
mod = pow(10, 9) + 7
n = eval(input())
keta = len(n)
ans = 0
# dp=[[0,1]]
# for i in range(ket... | false | 12.121212 | [
"-# lst=[int(n[i]) for i in range(len(n))]",
"-# for i in range(len(n)):",
"-# lst.append(int(n[i]))",
"-# n=int(n)",
"-# lst.reverse()",
"-# dp=[[float('inf')]*2 for i in range(keta+1)]",
"-dp = [[0, 1]]",
"-for i in range(keta):",
"- dp.append([float(\"inf\")] * 2)",
"+# dp=[[0,1]]",
"+... | false | 0.03658 | 0.098423 | 0.371667 | [
"s116869367",
"s693959462"
] |
u493520238 | p02767 | python | s582142259 | s031667714 | 77 | 66 | 63,328 | 63,604 | Accepted | Accepted | 14.29 | n = int(eval(input()))
xl = list(map(int, input().split()))
ans = 10**18
for i in range(0,101):
curr_sum = 0
for x in xl:
curr_sum += (i-x)*(i-x)
ans = min(ans,curr_sum)
print(ans) | n = int(eval(input()))
xl = list(map(int, input().split()))
ans = 10**9
for i in range(1,101):
v = 0
for x in xl:
v += (x-i)**2
ans = min(ans,v)
print(ans) | 11 | 11 | 206 | 189 | n = int(eval(input()))
xl = list(map(int, input().split()))
ans = 10**18
for i in range(0, 101):
curr_sum = 0
for x in xl:
curr_sum += (i - x) * (i - x)
ans = min(ans, curr_sum)
print(ans)
| n = int(eval(input()))
xl = list(map(int, input().split()))
ans = 10**9
for i in range(1, 101):
v = 0
for x in xl:
v += (x - i) ** 2
ans = min(ans, v)
print(ans)
| false | 0 | [
"-ans = 10**18",
"-for i in range(0, 101):",
"- curr_sum = 0",
"+ans = 10**9",
"+for i in range(1, 101):",
"+ v = 0",
"- curr_sum += (i - x) * (i - x)",
"- ans = min(ans, curr_sum)",
"+ v += (x - i) ** 2",
"+ ans = min(ans, v)"
] | false | 0.044589 | 0.044935 | 0.99229 | [
"s582142259",
"s031667714"
] |
u546285759 | p00012 | python | s610403554 | s803969326 | 30 | 20 | 7,620 | 5,592 | Accepted | Accepted | 33.33 | import math
def tri(x1, y1, x2, y2, x3, y3):
return math.fabs((x2-x1)*(y3-y1) - (y2-y1)*(x3-x1)) / 2
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split()))
except:
break
abc = tri(x1, y1, x2, y2, x3, y3)
abp = tri(x1, y1, x2, y2, xp, yp)
... | while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split()))
except:
break
AB = [x2-x1, y2-y1]
BC = [x3-x2, y3-y2]
CA = [x1-x3, y1-y3]
BP = [xp-x2, yp-y2]
CP = [xp-x3, yp-y3]
AP = [xp-x1, yp-y1]
v1 = AB[0]*BP[1]-AB[1]*BP[0]
v2 = ... | 16 | 17 | 488 | 456 | import math
def tri(x1, y1, x2, y2, x3, y3):
return math.fabs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split()))
except:
break
abc = tri(x1, y1, x2, y2, x3, y3)
abp = tri(x1, y1, x2, y2, xp, yp)
... | while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split()))
except:
break
AB = [x2 - x1, y2 - y1]
BC = [x3 - x2, y3 - y2]
CA = [x1 - x3, y1 - y3]
BP = [xp - x2, yp - y2]
CP = [xp - x3, yp - y3]
AP = [xp - x1, yp - y1]
v1 = AB[0] * BP[1] - AB[1]... | false | 5.882353 | [
"-import math",
"-",
"-",
"-def tri(x1, y1, x2, y2, x3, y3):",
"- return math.fabs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2",
"-",
"-",
"- abc = tri(x1, y1, x2, y2, x3, y3)",
"- abp = tri(x1, y1, x2, y2, xp, yp)",
"- acp = tri(x1, y1, x3, y3, xp, yp)",
"- bcp = tri(x2, y... | false | 0.032553 | 0.036433 | 0.893492 | [
"s610403554",
"s803969326"
] |
u223646582 | p03163 | python | s795024900 | s262214310 | 951 | 745 | 258,312 | 171,912 | Accepted | Accepted | 21.66 | # dp[i][w_sum]: i-1番目までの品物で重さがw_sumを超えないように選んだときの、価値の総和の最大値
N, W = list(map(int, input().split()))
items = [tuple(map(int, input().split())) for i in range(N)]
dp = [[0 for w_sum in range(W+100)] for i in range(N+100)]
for i in range(N):
for w_sum in range(W+1):
# i-1番目の品物を選ぶ場合
# 重量的に... | # dp[i][w_sum]: i番目までの品物で重さがw_sumを超えないように選んだときの、価値の総和の最大値
N, W = list(map(int, input().split()))
items = [tuple(map(int, input().split())) for i in range(N)]
dp = [[0 for w_sum in range(W+1)] for i in range(N+1)]
for i in range(N):
for w_sum in range(W+1):
# i-1番目の品物を選ぶ場合
# 重量的に入れられるなら入... | 20 | 22 | 593 | 665 | # dp[i][w_sum]: i-1番目までの品物で重さがw_sumを超えないように選んだときの、価値の総和の最大値
N, W = list(map(int, input().split()))
items = [tuple(map(int, input().split())) for i in range(N)]
dp = [[0 for w_sum in range(W + 100)] for i in range(N + 100)]
for i in range(N):
for w_sum in range(W + 1):
# i-1番目の品物を選ぶ場合
# 重量的に入れられるなら入れ... | # dp[i][w_sum]: i番目までの品物で重さがw_sumを超えないように選んだときの、価値の総和の最大値
N, W = list(map(int, input().split()))
items = [tuple(map(int, input().split())) for i in range(N)]
dp = [[0 for w_sum in range(W + 1)] for i in range(N + 1)]
for i in range(N):
for w_sum in range(W + 1):
# i-1番目の品物を選ぶ場合
# 重量的に入れられるなら入れてみる
... | false | 9.090909 | [
"-# dp[i][w_sum]: i-1番目までの品物で重さがw_sumを超えないように選んだときの、価値の総和の最大値",
"+# dp[i][w_sum]: i番目までの品物で重さがw_sumを超えないように選んだときの、価値の総和の最大値",
"-dp = [[0 for w_sum in range(W + 100)] for i in range(N + 100)]",
"+dp = [[0 for w_sum in range(W + 1)] for i in range(N + 1)]",
"- if w_sum - items[i][0] >= 0:",
"- ... | false | 0.040105 | 0.038977 | 1.028932 | [
"s795024900",
"s262214310"
] |
u133936772 | p02788 | python | s341636710 | s005828270 | 1,608 | 1,028 | 82,008 | 76,508 | Accepted | Accepted | 36.07 | f=lambda:list(map(int,input().split()))
n,d,a=f()
lt=sorted([tuple(f()) for _ in range(n)])
from collections import *
q=deque()
c=s=0
for x,h in lt:
while q and q[0][0]<x: s+=q.popleft()[1]
h-=s
if h<1: continue
t=-h//a; c-=t; s-=t*a; q.append((x+d*2,t*a))
print(c) | import sys
f=lambda:list(map(int,sys.stdin.readline().split()))
n,d,a=f()
lt=sorted(tuple(f()) for _ in range(n))
from collections import *
q=deque()
c=s=0
for x,h in lt:
while q and q[0][0]<x: s+=q.popleft()[1]
h-=s
if h<1: continue
t=-h//a; c-=t; s-=t*a; q.append((x+d*2,t*a))
print(c) | 12 | 13 | 279 | 302 | f = lambda: list(map(int, input().split()))
n, d, a = f()
lt = sorted([tuple(f()) for _ in range(n)])
from collections import *
q = deque()
c = s = 0
for x, h in lt:
while q and q[0][0] < x:
s += q.popleft()[1]
h -= s
if h < 1:
continue
t = -h // a
c -= t
s -= t * a
q.append... | import sys
f = lambda: list(map(int, sys.stdin.readline().split()))
n, d, a = f()
lt = sorted(tuple(f()) for _ in range(n))
from collections import *
q = deque()
c = s = 0
for x, h in lt:
while q and q[0][0] < x:
s += q.popleft()[1]
h -= s
if h < 1:
continue
t = -h // a
c -= t
... | false | 7.692308 | [
"-f = lambda: list(map(int, input().split()))",
"+import sys",
"+",
"+f = lambda: list(map(int, sys.stdin.readline().split()))",
"-lt = sorted([tuple(f()) for _ in range(n)])",
"+lt = sorted(tuple(f()) for _ in range(n))"
] | false | 0.042494 | 0.060358 | 0.704028 | [
"s341636710",
"s005828270"
] |
u401487574 | p02948 | python | s247718831 | s180615351 | 1,013 | 557 | 67,928 | 17,660 | Accepted | Accepted | 45.01 | import heapq as hq
n,m = list(map(int,input().split()))
ab = []
for i in range(n):
a,b = list(map(int,input().split()))
ab.append((a,-b))
ab.sort() #日が短い順に
ans = 0
idx = 0
q = []
for i in range(1,m+1):
while idx<n and ab[idx][0] ==i:
a,mb = ab[idx]
hq.heappush(q,mb)
idx... | import heapq as hq
n,m = list(map(int,input().split()))
ab = []
for i in range(n):
a,b = list(map(int,input().split()))
ab.append((a,-b))
ab.sort()
ans = 0
idx = 0
q = []
for i in range(1,m+1):
while idx<n and ab[idx][0] ==i:
a,mb = ab[idx]
hq.heappush(q,mb)
idx+=1
... | 19 | 19 | 374 | 366 | import heapq as hq
n, m = list(map(int, input().split()))
ab = []
for i in range(n):
a, b = list(map(int, input().split()))
ab.append((a, -b))
ab.sort() # 日が短い順に
ans = 0
idx = 0
q = []
for i in range(1, m + 1):
while idx < n and ab[idx][0] == i:
a, mb = ab[idx]
hq.heappush(q, mb)
i... | import heapq as hq
n, m = list(map(int, input().split()))
ab = []
for i in range(n):
a, b = list(map(int, input().split()))
ab.append((a, -b))
ab.sort()
ans = 0
idx = 0
q = []
for i in range(1, m + 1):
while idx < n and ab[idx][0] == i:
a, mb = ab[idx]
hq.heappush(q, mb)
idx += 1
... | false | 0 | [
"-ab.sort() # 日が短い順に",
"+ab.sort()"
] | false | 0.037484 | 0.035578 | 1.053569 | [
"s247718831",
"s180615351"
] |
u918601425 | p02847 | python | s764018711 | s591532566 | 164 | 18 | 38,256 | 2,940 | Accepted | Accepted | 89.02 | ls=['SUN','MON','TUE','WED','THU','FRI','SAT']
x=eval(input())
for i in range(7):
if x==ls[i]:
print((7-i))
break
| S=eval(input())
if S=='SUN':
print((7))
elif S=='MON':
print((6))
elif S=='TUE':
print((5))
elif S=='WED':
print((4))
elif S=='THU':
print((3))
elif S=='FRI':
print((2))
else:
print((1)) | 6 | 15 | 121 | 194 | ls = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
x = eval(input())
for i in range(7):
if x == ls[i]:
print((7 - i))
break
| S = eval(input())
if S == "SUN":
print((7))
elif S == "MON":
print((6))
elif S == "TUE":
print((5))
elif S == "WED":
print((4))
elif S == "THU":
print((3))
elif S == "FRI":
print((2))
else:
print((1))
| false | 60 | [
"-ls = [\"SUN\", \"MON\", \"TUE\", \"WED\", \"THU\", \"FRI\", \"SAT\"]",
"-x = eval(input())",
"-for i in range(7):",
"- if x == ls[i]:",
"- print((7 - i))",
"- break",
"+S = eval(input())",
"+if S == \"SUN\":",
"+ print((7))",
"+elif S == \"MON\":",
"+ print((6))",
"+el... | false | 0.121627 | 0.037913 | 3.208078 | [
"s764018711",
"s591532566"
] |
u364555831 | p02753 | python | s709442319 | s284289406 | 32 | 29 | 9,036 | 8,992 | Accepted | Accepted | 9.38 | S = eval(input())
if S[0] == S[1] == S[2]:
print("No")
else:
print("Yes")
| S = list(eval(input()))
#print(set(S))
setS = set(S)
if len(setS) == 2:
print("Yes")
else:
print("No")
| 5 | 9 | 80 | 115 | S = eval(input())
if S[0] == S[1] == S[2]:
print("No")
else:
print("Yes")
| S = list(eval(input()))
# print(set(S))
setS = set(S)
if len(setS) == 2:
print("Yes")
else:
print("No")
| false | 44.444444 | [
"-S = eval(input())",
"-if S[0] == S[1] == S[2]:",
"+S = list(eval(input()))",
"+# print(set(S))",
"+setS = set(S)",
"+if len(setS) == 2:",
"+ print(\"Yes\")",
"+else:",
"-else:",
"- print(\"Yes\")"
] | false | 0.039501 | 0.041594 | 0.949678 | [
"s709442319",
"s284289406"
] |
u015593272 | p02755 | python | s654141802 | s151742069 | 19 | 17 | 3,060 | 3,064 | Accepted | Accepted | 10.53 | import math
A, B = list(map(int, input().split()))
ans = -1
for i in range(1, 1251):
a = int(math.floor(i * 0.08))
b = int(math.floor(i * 0.1))
if (a == A and b == B):
ans = i
break
print(ans) | # O(1) solution
import math
A, B = list(map(int, input().split()))
min_A = int(math.ceil(A * 12.5))
max_A = int(math.ceil((A + 1) * 12.5) - 1)
grp_A = {i for i in range(min_A, max_A + 1)}
min_B = int(math.ceil(B * 10))
max_B = int(math.ceil((B + 1) * 10) - 1)
grp_B = {i for i in range(min_B, max_B + 1... | 17 | 23 | 241 | 417 | import math
A, B = list(map(int, input().split()))
ans = -1
for i in range(1, 1251):
a = int(math.floor(i * 0.08))
b = int(math.floor(i * 0.1))
if a == A and b == B:
ans = i
break
print(ans)
| # O(1) solution
import math
A, B = list(map(int, input().split()))
min_A = int(math.ceil(A * 12.5))
max_A = int(math.ceil((A + 1) * 12.5) - 1)
grp_A = {i for i in range(min_A, max_A + 1)}
min_B = int(math.ceil(B * 10))
max_B = int(math.ceil((B + 1) * 10) - 1)
grp_B = {i for i in range(min_B, max_B + 1)}
ans = grp_A & ... | false | 26.086957 | [
"+# O(1) solution",
"-ans = -1",
"-for i in range(1, 1251):",
"- a = int(math.floor(i * 0.08))",
"- b = int(math.floor(i * 0.1))",
"- if a == A and b == B:",
"- ans = i",
"- break",
"+min_A = int(math.ceil(A * 12.5))",
"+max_A = int(math.ceil((A + 1) * 12.5) - 1)",
"+grp_A... | false | 0.06515 | 0.061318 | 1.06249 | [
"s654141802",
"s151742069"
] |
u089376182 | p02861 | python | s200105911 | s390963330 | 482 | 287 | 9,460 | 13,928 | Accepted | Accepted | 40.46 | import itertools
n = int(eval(input()))
city_pos = [list(map(int, input().split())) for _ in range(n)]
dist_list = list()
dist_way = list(itertools.permutations(list(range(n))))
for dist_i in dist_way:
dist = 0
for i in range(len(dist_i)-1):
dist += ((city_pos[dist_i[i]][0] - city_pos[dist_i[i+1... | import itertools
n = int(eval(input()))
XY = [list(map(int, input().split())) for _ in range(n)]
cand = list(itertools.permutations(list(range(n)), n))
ans = 0
for cand_i in cand:
for i in range(n-1):
ans += ((XY[cand_i[i]][0]-XY[cand_i[i+1]][0])**2+(XY[cand_i[i]][1]-XY[cand_i[i+1]][1])**2)**(1/2)
... | 17 | 13 | 454 | 335 | import itertools
n = int(eval(input()))
city_pos = [list(map(int, input().split())) for _ in range(n)]
dist_list = list()
dist_way = list(itertools.permutations(list(range(n))))
for dist_i in dist_way:
dist = 0
for i in range(len(dist_i) - 1):
dist += (
(city_pos[dist_i[i]][0] - city_pos[di... | import itertools
n = int(eval(input()))
XY = [list(map(int, input().split())) for _ in range(n)]
cand = list(itertools.permutations(list(range(n)), n))
ans = 0
for cand_i in cand:
for i in range(n - 1):
ans += (
(XY[cand_i[i]][0] - XY[cand_i[i + 1]][0]) ** 2
+ (XY[cand_i[i]][1] - XY... | false | 23.529412 | [
"-city_pos = [list(map(int, input().split())) for _ in range(n)]",
"-dist_list = list()",
"-dist_way = list(itertools.permutations(list(range(n))))",
"-for dist_i in dist_way:",
"- dist = 0",
"- for i in range(len(dist_i) - 1):",
"- dist += (",
"- (city_pos[dist_i[i]][0] - city... | false | 0.042958 | 0.08193 | 0.524325 | [
"s200105911",
"s390963330"
] |
u352394527 | p01631 | python | s990839492 | s639795659 | 4,620 | 2,440 | 6,124 | 6,156 | Accepted | Accepted | 47.19 | def main():
n = int(eval(input()))
words = []
scores = []
for _ in range(n):
word, score = input().split()
words.append(word)
scores.append(int(score))
mp = ["#" * 6] + ["#" + eval(input()) + "#" for _ in range(4)] + ["#" * 6]
t = int(eval(input()))
def search(word):
used = ... | def main():
n = int(eval(input()))
lst = []
for _ in range(n):
word, score = input().split()
lst.append((word, int(score)))
mp = ["#" * 6] + ["#" + eval(input()) + "#" for _ in range(4)] + ["#" * 6]
t = int(eval(input()))
def search(word):
used = [[False] * 6 for _ in range(6)]
... | 53 | 49 | 1,418 | 1,311 | def main():
n = int(eval(input()))
words = []
scores = []
for _ in range(n):
word, score = input().split()
words.append(word)
scores.append(int(score))
mp = ["#" * 6] + ["#" + eval(input()) + "#" for _ in range(4)] + ["#" * 6]
t = int(eval(input()))
def search(word):... | def main():
n = int(eval(input()))
lst = []
for _ in range(n):
word, score = input().split()
lst.append((word, int(score)))
mp = ["#" * 6] + ["#" + eval(input()) + "#" for _ in range(4)] + ["#" * 6]
t = int(eval(input()))
def search(word):
used = [[False] * 6 for _ in ra... | false | 7.54717 | [
"- words = []",
"- scores = []",
"+ lst = []",
"- words.append(word)",
"- scores.append(int(score))",
"+ lst.append((word, int(score)))",
"- values = []",
"- weights = []",
"- for word, score in zip(words, scores):",
"+ items = []",
"+ for word, score... | false | 0.04725 | 0.039618 | 1.192646 | [
"s990839492",
"s639795659"
] |
u044220565 | p02732 | python | s029482999 | s086835801 | 520 | 260 | 26,140 | 20,396 | Accepted | Accepted | 50 | # coding: utf-8
N = int(eval(input()))
A = list(map(int, input().split()))
dict = {}
for i in range(N):
if A[i] in list(dict.keys()):
dict[A[i]] += 1
else:
dict[A[i]] = 1
def comb(n):
if n<2:
return 0
return int(n * (n - 1) / 2)
# all
ret = 0
for key in list(dict.keys()):
val... | # coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product#accumulate, combinations, product
#imp... | 27 | 31 | 457 | 872 | # coding: utf-8
N = int(eval(input()))
A = list(map(int, input().split()))
dict = {}
for i in range(N):
if A[i] in list(dict.keys()):
dict[A[i]] += 1
else:
dict[A[i]] = 1
def comb(n):
if n < 2:
return 0
return int(n * (n - 1) / 2)
# all
ret = 0
for key in list(dict.keys()):
... | # coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
# from heapq import heappop, heappush
# from collections import defaultdict
sys.setrecursionlimit(10**7)
# import math
# from itertools import product#accumulate, combinations, product
# import... | false | 12.903226 | [
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-dict = {}",
"-for i in range(N):",
"- if A[i] in list(dict.keys()):",
"- dict[A[i]] += 1",
"- else:",
"- dict[A[i]] = 1",
"+import sys",
"+",
"+# from operator import itemgetter",
"+sysread = sys.stdin.buf... | false | 0.078198 | 0.07756 | 1.00822 | [
"s029482999",
"s086835801"
] |
u761320129 | p03503 | python | s987014341 | s067375803 | 391 | 292 | 3,064 | 3,064 | Accepted | Accepted | 25.32 | N = int(eval(input()))
isopen = [list(map(int,input().split())) for i in range(N)]
gain = [list(map(int,input().split())) for i in range(N)]
ans = -float('inf')
for i in range(1,2**10):
tmp = 0
for n in range(N):
c = 0
for b in range(10):
if ((i >> b)&1) & isopen[n][b]:
... | N = int(eval(input()))
F = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]
ans = -float('inf')
for b in range(1,2**10):
tmp = 0
for i in range(N):
c = 0
for k in range(10):
if b&(1<<k) and F[i][k]:
... | 15 | 15 | 400 | 381 | N = int(eval(input()))
isopen = [list(map(int, input().split())) for i in range(N)]
gain = [list(map(int, input().split())) for i in range(N)]
ans = -float("inf")
for i in range(1, 2**10):
tmp = 0
for n in range(N):
c = 0
for b in range(10):
if ((i >> b) & 1) & isopen[n][b]:
... | N = int(eval(input()))
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
ans = -float("inf")
for b in range(1, 2**10):
tmp = 0
for i in range(N):
c = 0
for k in range(10):
if b & (1 << k) and F[i][k]:
c += ... | false | 0 | [
"-isopen = [list(map(int, input().split())) for i in range(N)]",
"-gain = [list(map(int, input().split())) for i in range(N)]",
"+F = [list(map(int, input().split())) for i in range(N)]",
"+P = [list(map(int, input().split())) for i in range(N)]",
"-for i in range(1, 2**10):",
"+for b in range(1, 2**10):"... | false | 0.132354 | 0.120981 | 1.094004 | [
"s987014341",
"s067375803"
] |
u888092736 | p03031 | python | s633756929 | s811276865 | 37 | 30 | 3,064 | 3,064 | Accepted | Accepted | 18.92 | N, M = list(map(int, input().split()))
bulbs = []
for i in range(M):
k, *s = list(map(int, input().split()))
bulbs.append((k, s))
p = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
on_cnt = [0] * M
for j in range(N):
if i >> j & 1:
for k in range(M):
... | N, M = list(map(int, input().split()))
bulbs = []
for i in range(M):
_, *conn_switches = list(map(int, input().split()))
bulbs.append(conn_switches)
P = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
on_cnt = [0] * M
for j, conn_switches in enumerate(bulbs):
if P[j] ... | 18 | 16 | 434 | 418 | N, M = list(map(int, input().split()))
bulbs = []
for i in range(M):
k, *s = list(map(int, input().split()))
bulbs.append((k, s))
p = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
on_cnt = [0] * M
for j in range(N):
if i >> j & 1:
for k in range(M):
... | N, M = list(map(int, input().split()))
bulbs = []
for i in range(M):
_, *conn_switches = list(map(int, input().split()))
bulbs.append(conn_switches)
P = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
on_cnt = [0] * M
for j, conn_switches in enumerate(bulbs):
if P[j] ^ sum(i >> s... | false | 11.111111 | [
"- k, *s = list(map(int, input().split()))",
"- bulbs.append((k, s))",
"-p = list(map(int, input().split()))",
"+ _, *conn_switches = list(map(int, input().split()))",
"+ bulbs.append(conn_switches)",
"+P = list(map(int, input().split()))",
"- for j in range(N):",
"- if i >> j & ... | false | 0.038825 | 0.038812 | 1.000328 | [
"s633756929",
"s811276865"
] |
u620480037 | p03575 | python | s067291390 | s574592792 | 1,916 | 209 | 3,572 | 41,456 | Accepted | Accepted | 89.09 | import copy
N,M=list(map(int,input().split()))
A=[]
L=[[1000for i in range(N)]for j in range(N)]
for i in range(M):
a,b=list(map(int,input().split()))
A.append([a,b])
L[a-1][b-1]=1
L[b-1][a-1]=1
for j in range(N):
L[j][j]=0
#print(L)
l=copy.deepcopy(L)
cnt=0
for k in range(M)... | import copy
N,M=list(map(int,input().split()))
A=[]
for i in range(M):
a,b=list(map(int,input().split()))
A.append([a,b])
ANS=0
for i in range(M):
L=[[]for _ in range(N+1)]
for j in range(M):
if i==j:
continue
else:
L[A[j][0]].append((A[j][1],... | 33 | 36 | 755 | 782 | import copy
N, M = list(map(int, input().split()))
A = []
L = [[1000 for i in range(N)] for j in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
A.append([a, b])
L[a - 1][b - 1] = 1
L[b - 1][a - 1] = 1
for j in range(N):
L[j][j] = 0
# print(L)
l = copy.deepcopy(L)
cnt = 0
for k ... | import copy
N, M = list(map(int, input().split()))
A = []
for i in range(M):
a, b = list(map(int, input().split()))
A.append([a, b])
ANS = 0
for i in range(M):
L = [[] for _ in range(N + 1)]
for j in range(M):
if i == j:
continue
else:
L[A[j][0]].append((A[j][1],... | false | 8.333333 | [
"-L = [[1000 for i in range(N)] for j in range(N)]",
"- L[a - 1][b - 1] = 1",
"- L[b - 1][a - 1] = 1",
"-for j in range(N):",
"- L[j][j] = 0",
"-# print(L)",
"-l = copy.deepcopy(L)",
"-cnt = 0",
"-for k in range(M):",
"- L = copy.deepcopy(l)",
"- L[A[k][0] - 1][A[k][1] - 1] = 1000... | false | 0.128596 | 0.043833 | 2.933761 | [
"s067291390",
"s574592792"
] |
u170201762 | p02863 | python | s770705747 | s799636686 | 1,228 | 582 | 181,764 | 117,336 | Accepted | Accepted | 52.61 | N,T = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])
dp1 = [[0]*T for i in range(N+1)]
for n in range(N):
for w in range(T):
if w-AB[n][0]>=0:
dp1[n+1][w] = max(dp1[n][w],dp1[n][w-AB[n][0]]+AB[n][1])
else:
... | N,T = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[0])
dp = [[0]*T for i in range(N+1)]
ans = 0
for n in range(N):
for w in range(T):
ans = max(ans,dp[n][w]+AB[n][1])
if w-AB[n][0]>=0:
dp[n+1][w] = max(dp[n][w],d... | 34 | 15 | 910 | 404 | N, T = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1])
dp1 = [[0] * T for i in range(N + 1)]
for n in range(N):
for w in range(T):
if w - AB[n][0] >= 0:
dp1[n + 1][w] = max(dp1[n][w], dp1[n][w - AB[n][0]] + AB[n][1])
el... | N, T = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])
dp = [[0] * T for i in range(N + 1)]
ans = 0
for n in range(N):
for w in range(T):
ans = max(ans, dp[n][w] + AB[n][1])
if w - AB[n][0] >= 0:
dp[n + 1][w] = max(dp[n... | false | 55.882353 | [
"-AB.sort(key=lambda x: x[1])",
"-dp1 = [[0] * T for i in range(N + 1)]",
"-for n in range(N):",
"- for w in range(T):",
"- if w - AB[n][0] >= 0:",
"- dp1[n + 1][w] = max(dp1[n][w], dp1[n][w - AB[n][0]] + AB[n][1])",
"- else:",
"- dp1[n + 1][w] = dp1[n][w]",
"-... | false | 0.044159 | 0.081452 | 0.542154 | [
"s770705747",
"s799636686"
] |
u254871849 | p03339 | python | s267999805 | s812659703 | 300 | 138 | 4,084 | 3,700 | Accepted | Accepted | 54 | # author: kagemeka
# created: 2019-11-07 23:33:56(JST)
## internal modules
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external module... | import sys
n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()
def main():
l = 0
r = s.count('E')
res = r
for i in range(n):
cur = s[i]
if cur == 'E':
r -= 1
res = min(res, l + r)
if cur == 'W':
l += 1
ret... | 38 | 21 | 930 | 391 | # author: kagemeka
# created: 2019-11-07 23:33:56(JST)
## internal modules
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import sc... | import sys
n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()
def main():
l = 0
r = s.count("E")
res = r
for i in range(n):
cur = s[i]
if cur == "E":
r -= 1
res = min(res, l + r)
if cur == "W":
l += 1
return res
if __... | false | 44.736842 | [
"-# author: kagemeka",
"-# created: 2019-11-07 23:33:56(JST)",
"-## internal modules",
"-import collections",
"-# import math",
"-# import string",
"-# import bisect",
"-# import re",
"-# import itertools",
"-# import statistics",
"-# import funct... | false | 0.039957 | 0.104719 | 0.381569 | [
"s267999805",
"s812659703"
] |
u133936772 | p02647 | python | s561331407 | s550632826 | 403 | 267 | 171,156 | 170,828 | Accepted | Accepted | 33.75 | n,k,*l=list(map(int,open(0).read().split()))
for _ in range(min(k,99)):
s=[0]*(n+1)
for i in range(n):
s[max(i-l[i],0)]+=1
s[min(i+l[i]+1,n)]-=1
l[0]=min(s[0],n)
for i in range(1,n):
l[i]=min(l[i-1]+s[i],n)
print((*l)) | n,k,*l=list(map(int,open(0).read().split()))
for _ in range(min(k,41)):
s=[0]*(n+1)
for i in range(n):
s[max(i-l[i],0)]+=1
s[min(i+l[i]+1,n)]-=1
l[0]=min(s[0],n)
for i in range(1,n):
l[i]=min(l[i-1]+s[i],n)
print((*l)) | 10 | 10 | 239 | 239 | n, k, *l = list(map(int, open(0).read().split()))
for _ in range(min(k, 99)):
s = [0] * (n + 1)
for i in range(n):
s[max(i - l[i], 0)] += 1
s[min(i + l[i] + 1, n)] -= 1
l[0] = min(s[0], n)
for i in range(1, n):
l[i] = min(l[i - 1] + s[i], n)
print((*l))
| n, k, *l = list(map(int, open(0).read().split()))
for _ in range(min(k, 41)):
s = [0] * (n + 1)
for i in range(n):
s[max(i - l[i], 0)] += 1
s[min(i + l[i] + 1, n)] -= 1
l[0] = min(s[0], n)
for i in range(1, n):
l[i] = min(l[i - 1] + s[i], n)
print((*l))
| false | 0 | [
"-for _ in range(min(k, 99)):",
"+for _ in range(min(k, 41)):"
] | false | 0.035706 | 0.06704 | 0.5326 | [
"s561331407",
"s550632826"
] |
u961595602 | p03425 | python | s666021022 | s294795013 | 202 | 100 | 3,060 | 3,064 | Accepted | Accepted | 50.5 | from itertools import combinations
N = int(eval(input()))
target = 'MARCH'
first = [0 for _ in range(5)]
for _ in range(N):
s = eval(input())
if s[0] in target:
first[target.find(s[0])] += 1
res = 0
for c in combinations(first, 3):
res += c[0]*c[1]*c[2]
print(res)
| from itertools import combinations
from sys import stdin
ns = lambda: stdin.readline()
ni = lambda: int(stdin.readline())
na = lambda: list(map(int, stdin.readline().split()))
N = ni()
target = 'MARCH'
first = [0 for _ in range(5)]
for _ in range(N):
s = ns()
if s[0] in target:
first[... | 16 | 22 | 296 | 434 | from itertools import combinations
N = int(eval(input()))
target = "MARCH"
first = [0 for _ in range(5)]
for _ in range(N):
s = eval(input())
if s[0] in target:
first[target.find(s[0])] += 1
res = 0
for c in combinations(first, 3):
res += c[0] * c[1] * c[2]
print(res)
| from itertools import combinations
from sys import stdin
ns = lambda: stdin.readline()
ni = lambda: int(stdin.readline())
na = lambda: list(map(int, stdin.readline().split()))
N = ni()
target = "MARCH"
first = [0 for _ in range(5)]
for _ in range(N):
s = ns()
if s[0] in target:
first[target.find(s[0])]... | false | 27.272727 | [
"+from sys import stdin",
"-N = int(eval(input()))",
"+ns = lambda: stdin.readline()",
"+ni = lambda: int(stdin.readline())",
"+na = lambda: list(map(int, stdin.readline().split()))",
"+N = ni()",
"- s = eval(input())",
"+ s = ns()"
] | false | 0.114448 | 0.044244 | 2.586732 | [
"s666021022",
"s294795013"
] |
u968404618 | p03564 | python | s155224430 | s434718491 | 26 | 22 | 9,164 | 9,044 | Accepted | Accepted | 15.38 | n = int(eval(input()))
k = int(eval(input()))
cnt = 1
for _ in range(n):
cnt = min(cnt*2, cnt+k)
print(cnt) | n = int(eval(input()))
k = int(eval(input()))
cnt = 1
for _ in range(n):
if cnt <= k:
cnt *= 2
else:
cnt += k
print(cnt) | 7 | 10 | 106 | 142 | n = int(eval(input()))
k = int(eval(input()))
cnt = 1
for _ in range(n):
cnt = min(cnt * 2, cnt + k)
print(cnt)
| n = int(eval(input()))
k = int(eval(input()))
cnt = 1
for _ in range(n):
if cnt <= k:
cnt *= 2
else:
cnt += k
print(cnt)
| false | 30 | [
"- cnt = min(cnt * 2, cnt + k)",
"+ if cnt <= k:",
"+ cnt *= 2",
"+ else:",
"+ cnt += k"
] | false | 0.044924 | 0.044313 | 1.013794 | [
"s155224430",
"s434718491"
] |
u847165882 | p02989 | python | s056169684 | s995661945 | 105 | 79 | 14,428 | 14,396 | Accepted | Accepted | 24.76 | N=int(eval(input()))
D=[int(s) for s in input().split()]
D=sorted(D)
sum=[]
count=0
for i in reversed(list(range(len(D)))):
sum.append(D.pop(i))
if len(sum) == len(D):
Ans=len(sum)
break
for i in range(D[Ans-1],sum[Ans-1],1):
count+=1
print(count) | N=int(eval(input()))
d=[int(s) for s in input().split(" ")]
d.sort()
K=d[(N//2)]-d[(N//2)-1]
print(K) | 14 | 6 | 277 | 101 | N = int(eval(input()))
D = [int(s) for s in input().split()]
D = sorted(D)
sum = []
count = 0
for i in reversed(list(range(len(D)))):
sum.append(D.pop(i))
if len(sum) == len(D):
Ans = len(sum)
break
for i in range(D[Ans - 1], sum[Ans - 1], 1):
count += 1
print(count)
| N = int(eval(input()))
d = [int(s) for s in input().split(" ")]
d.sort()
K = d[(N // 2)] - d[(N // 2) - 1]
print(K)
| false | 57.142857 | [
"-D = [int(s) for s in input().split()]",
"-D = sorted(D)",
"-sum = []",
"-count = 0",
"-for i in reversed(list(range(len(D)))):",
"- sum.append(D.pop(i))",
"- if len(sum) == len(D):",
"- Ans = len(sum)",
"- break",
"-for i in range(D[Ans - 1], sum[Ans - 1], 1):",
"- count... | false | 0.036811 | 0.035065 | 1.049785 | [
"s056169684",
"s995661945"
] |
u247211039 | p02719 | python | s943047225 | s620017424 | 30 | 26 | 8,988 | 9,132 | Accepted | Accepted | 13.33 | N,K=list(map(int, input().split()))
x=N%K
if x ==0:
print((0))
elif abs(x - K) > x:
print(x)
else:
print((abs(x - K))) | N,K=list(map(int,input().split()))
a=N//K
ans=min(abs(N-a*K), abs(N-(a+1)*K))
print(ans) | 10 | 6 | 131 | 89 | N, K = list(map(int, input().split()))
x = N % K
if x == 0:
print((0))
elif abs(x - K) > x:
print(x)
else:
print((abs(x - K)))
| N, K = list(map(int, input().split()))
a = N // K
ans = min(abs(N - a * K), abs(N - (a + 1) * K))
print(ans)
| false | 40 | [
"-x = N % K",
"-if x == 0:",
"- print((0))",
"-elif abs(x - K) > x:",
"- print(x)",
"-else:",
"- print((abs(x - K)))",
"+a = N // K",
"+ans = min(abs(N - a * K), abs(N - (a + 1) * K))",
"+print(ans)"
] | false | 0.03953 | 0.034925 | 1.131873 | [
"s943047225",
"s620017424"
] |
u287500079 | p03361 | python | s566701039 | s108577136 | 334 | 297 | 62,444 | 63,208 | Accepted | Accepted | 11.08 | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii... | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii... | 37 | 36 | 1,317 | 1,253 | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upper... | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upper... | false | 2.702703 | [
"+ii = [-1, 1, 0, 0]",
"+jj = [0, 0, -1, 1]",
"- if i > 0 and s[i - 1][j] == \"#\":",
"- flag[0] = True",
"- if i < h - 1 and s[i + 1][j] == \"#\":",
"- flag[1] = True",
"- if j > 0 and s[i][j - 1] == \"#\":",
"- flag[2] = T... | false | 0.047619 | 0.049321 | 0.965477 | [
"s566701039",
"s108577136"
] |
u512007680 | p03295 | python | s872093979 | s232781619 | 381 | 325 | 20,388 | 5,984 | Accepted | Accepted | 14.7 | N,M = list(map(int,input().split()))
info = []
maxa = [0] * (N+1)
for i in range(M):
a,b = list(map(int,input().split()))
info.append([a,b])
if maxa[b] < a:
maxa[b] = a
ok = 0
count = 0
for j in range(1,N+1):
if ok < maxa[j]:
count += 1
ok = j-1
print(count... | N,M = list(map(int,input().split()))
maxa = [0] * (N+1)
for i in range(M):
a,b = list(map(int,input().split()))
if maxa[b] < a:
maxa[b] = a
ok = 0
count = 0
for j in range(1,N+1):
if ok < maxa[j]:
count += 1
ok = j-1
print(count) | 19 | 17 | 309 | 274 | N, M = list(map(int, input().split()))
info = []
maxa = [0] * (N + 1)
for i in range(M):
a, b = list(map(int, input().split()))
info.append([a, b])
if maxa[b] < a:
maxa[b] = a
ok = 0
count = 0
for j in range(1, N + 1):
if ok < maxa[j]:
count += 1
ok = j - 1
print(count)
| N, M = list(map(int, input().split()))
maxa = [0] * (N + 1)
for i in range(M):
a, b = list(map(int, input().split()))
if maxa[b] < a:
maxa[b] = a
ok = 0
count = 0
for j in range(1, N + 1):
if ok < maxa[j]:
count += 1
ok = j - 1
print(count)
| false | 10.526316 | [
"-info = []",
"- info.append([a, b])"
] | false | 0.037113 | 0.045812 | 0.810104 | [
"s872093979",
"s232781619"
] |
u284854859 | p03821 | python | s305968234 | s627517920 | 384 | 290 | 15,020 | 51,292 | Accepted | Accepted | 24.48 | n = int(eval(input()))
a = []
b = []
for i in range(n):
x,y = list(map(int,input().split()))
a.append(x)
b.append(y)
res = 0
for i in range(n):
a[n-1-i] += res
c = a[n-1-i]%b[n-1-i]
if c != 0:
res += b[n-1-i]-c
print(res) | import sys
input = sys.stdin.readline
n = int(eval(input()))
a = []
b = []
for i in range(n):
aa,bb = list(map(int,input().split()))
a.append(aa)
b.append(bb)
s = 0
res = 0
for i in range(n-1,-1,-1):
a[i] += res
if a[i]%b[i] == 0:
continue
res += b[i]-(a[... | 17 | 24 | 261 | 328 | n = int(eval(input()))
a = []
b = []
for i in range(n):
x, y = list(map(int, input().split()))
a.append(x)
b.append(y)
res = 0
for i in range(n):
a[n - 1 - i] += res
c = a[n - 1 - i] % b[n - 1 - i]
if c != 0:
res += b[n - 1 - i] - c
print(res)
| import sys
input = sys.stdin.readline
n = int(eval(input()))
a = []
b = []
for i in range(n):
aa, bb = list(map(int, input().split()))
a.append(aa)
b.append(bb)
s = 0
res = 0
for i in range(n - 1, -1, -1):
a[i] += res
if a[i] % b[i] == 0:
continue
res += b[i] - (a[i] % b[i])
print(res)
| false | 29.166667 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"- x, y = list(map(int, input().split()))",
"- a.append(x)",
"- b.append(y)",
"+ aa, bb = list(map(int, input().split()))",
"+ a.append(aa)",
"+ b.append(bb)",
"+s = 0",
"-for i in range(n):",
"- a[n - 1 - i] += res",
"-... | false | 0.035921 | 0.032843 | 1.093704 | [
"s305968234",
"s627517920"
] |
u088552457 | p03944 | python | s905726404 | s513773559 | 173 | 98 | 3,188 | 3,188 | Accepted | Accepted | 43.35 | w, h, n = list(map(int, input().split()))
rw = w
rh = h
points = []
for x in range(w):
rows = []
for y in range(h):
rows.append(0)
points.append(rows)
for i in range(n):
x, y, a = list(map(int, input().split()))
if a == 1:
for row_index, row in enumerate(points):
for col_index, ... | def main():
w, h, n = input_list()
points = []
for x in range(w):
row = [True]*h
points.append(row)
for _ in range(n):
x, y, a = input_list()
if a == 1:
for px, row in enumerate(points):
for py, v in enumerate(row):
if px+1 <= x:
points... | 40 | 40 | 1,114 | 953 | w, h, n = list(map(int, input().split()))
rw = w
rh = h
points = []
for x in range(w):
rows = []
for y in range(h):
rows.append(0)
points.append(rows)
for i in range(n):
x, y, a = list(map(int, input().split()))
if a == 1:
for row_index, row in enumerate(points):
for col_... | def main():
w, h, n = input_list()
points = []
for x in range(w):
row = [True] * h
points.append(row)
for _ in range(n):
x, y, a = input_list()
if a == 1:
for px, row in enumerate(points):
for py, v in enumerate(row):
if px ... | false | 0 | [
"-w, h, n = list(map(int, input().split()))",
"-rw = w",
"-rh = h",
"-points = []",
"-for x in range(w):",
"- rows = []",
"- for y in range(h):",
"- rows.append(0)",
"- points.append(rows)",
"-for i in range(n):",
"- x, y, a = list(map(int, input().split()))",
"- if a == ... | false | 0.047037 | 0.069854 | 0.673366 | [
"s905726404",
"s513773559"
] |
u535803878 | p03277 | python | s121222869 | s605815309 | 1,029 | 368 | 121,856 | 128,588 | Accepted | Accepted | 64.24 | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
def init(bit, values):
for i,v in enumerate(values):
update(bit,i,v)
#A1 ~ Aiまでの和 O(logN)
def query(bit,i):
res_sum = 0
while i > 0:
r... | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n = int(eval(input()))
a = list(map(int, input().split()))
from collections import Counter
def sub(x):
l = [1 if item>=x else -1 for item in a]
count = [0] ... | 56 | 39 | 1,132 | 773 | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
def init(bit, values):
for i, v in enumerate(values):
update(bit, i, v)
# A1 ~ Aiまでの和 O(logN)
def query(bit, i):
res_sum = 0
while i > 0:
res_sum... | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
n = int(eval(input()))
a = list(map(int, input().split()))
from collections import Counter
def sub(x):
l = [1 if item >= x else -1 for item in a]
count = [0] * (2 * n ... | false | 30.357143 | [
"-",
"-",
"-def init(bit, values):",
"- for i, v in enumerate(values):",
"- update(bit, i, v)",
"-",
"-",
"-# A1 ~ Aiまでの和 O(logN)",
"-def query(bit, i):",
"- res_sum = 0",
"- while i > 0:",
"- res_sum += bit[i]",
"- i -= i & (-i)",
"- return res_sum",
"-"... | false | 0.034854 | 0.039551 | 0.881255 | [
"s121222869",
"s605815309"
] |
u600402037 | p02718 | python | s833458746 | s577666062 | 1,712 | 109 | 21,408 | 27,220 | Accepted | Accepted | 93.63 | import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
A = np.array(lr(), np.int32)
total = A.sum()
A *= 4*M
count = (A >= total).sum()
bl = count >= M
print(('Yes' if bl else 'No'))
| # coding: utf-8
import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
A = np.array(lr())
total = A.sum()
A *= 4 * M
A = A[A>=total]
bl = len(A) >= M
print(('Yes' if bl else 'No'))
| 14 | 15 | 291 | 290 | import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
A = np.array(lr(), np.int32)
total = A.sum()
A *= 4 * M
count = (A >= total).sum()
bl = count >= M
print(("Yes" if bl else "No"))
| # coding: utf-8
import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
A = np.array(lr())
total = A.sum()
A *= 4 * M
A = A[A >= total]
bl = len(A) >= M
print(("Yes" if bl else "No"))
| false | 6.666667 | [
"+# coding: utf-8",
"-A = np.array(lr(), np.int32)",
"+A = np.array(lr())",
"-count = (A >= total).sum()",
"-bl = count >= M",
"+A = A[A >= total]",
"+bl = len(A) >= M"
] | false | 0.362861 | 0.180559 | 2.009654 | [
"s833458746",
"s577666062"
] |
u905203728 | p02971 | python | s957297699 | s516983378 | 613 | 533 | 14,740 | 14,112 | Accepted | Accepted | 13.05 | A=[int(eval(input())) for i in range(int(eval(input())))]
one=sorted(A)[-1]
two=sorted(A)[-2]
for i in A:
print((one if i!=one else two)) | A=[int(eval(input())) for i in range(int(eval(input())))]
B=sorted(A)
one=B[-1]
two=B[-2]
for i in A:print((one if i!=one else two)) | 7 | 5 | 135 | 122 | A = [int(eval(input())) for i in range(int(eval(input())))]
one = sorted(A)[-1]
two = sorted(A)[-2]
for i in A:
print((one if i != one else two))
| A = [int(eval(input())) for i in range(int(eval(input())))]
B = sorted(A)
one = B[-1]
two = B[-2]
for i in A:
print((one if i != one else two))
| false | 28.571429 | [
"-one = sorted(A)[-1]",
"-two = sorted(A)[-2]",
"+B = sorted(A)",
"+one = B[-1]",
"+two = B[-2]"
] | false | 0.109485 | 0.0854 | 1.282021 | [
"s957297699",
"s516983378"
] |
u620868411 | p03633 | python | s371735107 | s018740925 | 45 | 17 | 5,304 | 2,940 | Accepted | Accepted | 62.22 | from fractions import gcd
def lcm(a,b): return a*b//gcd(a,b)
n = int(eval(input()))
res = 1
for i in range(n):
t = int(eval(input()))
res = lcm(res, t)
print(res) | # -*- coding: utf-8 -*-
n = int(eval(input()))
def gcd(a, b):
if b==0:
return a
return gcd(b, a%b)
def lcm(a,b):
return a//gcd(a,b)*b
ans = 1
for _ in range(n):
t = int(eval(input()))
ans = lcm(ans, t)
print(ans)
| 9 | 18 | 168 | 251 | from fractions import gcd
def lcm(a, b):
return a * b // gcd(a, b)
n = int(eval(input()))
res = 1
for i in range(n):
t = int(eval(input()))
res = lcm(res, t)
print(res)
| # -*- coding: utf-8 -*-
n = int(eval(input()))
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def lcm(a, b):
return a // gcd(a, b) * b
ans = 1
for _ in range(n):
t = int(eval(input()))
ans = lcm(ans, t)
print(ans)
| false | 50 | [
"-from fractions import gcd",
"+# -*- coding: utf-8 -*-",
"+n = int(eval(input()))",
"+",
"+",
"+def gcd(a, b):",
"+ if b == 0:",
"+ return a",
"+ return gcd(b, a % b)",
"- return a * b // gcd(a, b)",
"+ return a // gcd(a, b) * b",
"-n = int(eval(input()))",
"-res = 1",
... | false | 0.179027 | 0.1296 | 1.381383 | [
"s371735107",
"s018740925"
] |
u419330815 | p03160 | python | s420759283 | s516095478 | 148 | 135 | 13,924 | 13,980 | Accepted | Accepted | 8.78 | n = int(eval(input()))
h = list(map(int, input().split()))
dp = [10 ** 9] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
h1 = dp[i - 1] + abs(h[i] - h[i - 1])
dp[i] = h1 if h1 < dp[i] else dp[i]
h2 = dp[i - 2] + abs(h[i] - h[i - 2])
dp[i] = h2 if h2 < dp[i] else dp[i]
p... | n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
h1 = dp[i - 1] + abs(h[i] - h[i - 1])
dp[i] = h1
h2 = dp[i - 2] + abs(h[i] - h[i - 2])
dp[i] = h2 if h2 < dp[i] else dp[i]
print((dp[-1])) | 16 | 16 | 326 | 295 | n = int(eval(input()))
h = list(map(int, input().split()))
dp = [10**9] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
h1 = dp[i - 1] + abs(h[i] - h[i - 1])
dp[i] = h1 if h1 < dp[i] else dp[i]
h2 = dp[i - 2] + abs(h[i] - h[i - 2])
dp[i] = h2 if h2 < dp[i] else dp[i]
print((dp[-1]))
| n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
h1 = dp[i - 1] + abs(h[i] - h[i - 1])
dp[i] = h1
h2 = dp[i - 2] + abs(h[i] - h[i - 2])
dp[i] = h2 if h2 < dp[i] else dp[i]
print((dp[-1]))
| false | 0 | [
"-dp = [10**9] * n",
"+dp = [0] * n",
"- dp[i] = h1 if h1 < dp[i] else dp[i]",
"+ dp[i] = h1"
] | false | 0.048978 | 0.04943 | 0.99084 | [
"s420759283",
"s516095478"
] |
u909514237 | p02574 | python | s094863999 | s336001977 | 394 | 353 | 194,212 | 194,512 | Accepted | Accepted | 10.41 | import math
N = int(eval(input()))
A = list(map(int, input().split()))
m = max(A)
c = [0] * (m+1)
for i in A:
c[i] += 1
pairwise = True
for i in range(2,m+1,1):
cnt = 0
for j in range(i,m+1,i):
cnt += c[j]
if cnt > 1:
pairwise = False
if pairwise:
print("pairwise coprime")
exit()... | import math
N = int(eval(input()))
a = list(map(int,input().split()))
m = max(a)
c = [0] * (m+1)
for i in a:
c[i] += 1
pairwise = True
for i in range(2, m+1, 1):
cnt = 0
for j in range(i, m+1, i):
cnt += c[j]
if cnt > 1:
pairwise = False
break
if pairwise:
print("pairwi... | 27 | 30 | 439 | 464 | import math
N = int(eval(input()))
A = list(map(int, input().split()))
m = max(A)
c = [0] * (m + 1)
for i in A:
c[i] += 1
pairwise = True
for i in range(2, m + 1, 1):
cnt = 0
for j in range(i, m + 1, i):
cnt += c[j]
if cnt > 1:
pairwise = False
if pairwise:
print("pairwise coprime")... | import math
N = int(eval(input()))
a = list(map(int, input().split()))
m = max(a)
c = [0] * (m + 1)
for i in a:
c[i] += 1
pairwise = True
for i in range(2, m + 1, 1):
cnt = 0
for j in range(i, m + 1, i):
cnt += c[j]
if cnt > 1:
pairwise = False
break
if pairwise:
... | false | 10 | [
"-A = list(map(int, input().split()))",
"-m = max(A)",
"+a = list(map(int, input().split()))",
"+m = max(a)",
"-for i in A:",
"+for i in a:",
"- if cnt > 1:",
"- pairwise = False",
"+ if cnt > 1:",
"+ pairwise = False",
"+ break",
"- g = math.gcd(g, A[... | false | 0.046054 | 0.045884 | 1.003697 | [
"s094863999",
"s336001977"
] |
u790710233 | p03497 | python | s057518268 | s138726512 | 209 | 138 | 39,352 | 32,564 | Accepted | Accepted | 33.97 | from collections import Counter
n, k = list(map(int, input().split()))
*a, = list(map(int, input().split()))
c = Counter(a)
kv = sorted(list(c.items()), key=lambda x: x[1], reverse=True)
if n <= k:
print((0))
else:
ls = c.most_common(k)
ans = n
for k, v in ls:
ans -= v
prin... | from collections import Counter
n, k = list(map(int, input().split()))
*a, = list(map(int, input().split()))
c = Counter(a)
if n <= k:
print((0))
else:
ls = c.most_common(k)
ans = n
for k, v in ls:
ans -= v
print(ans) | 16 | 14 | 306 | 246 | from collections import Counter
n, k = list(map(int, input().split()))
(*a,) = list(map(int, input().split()))
c = Counter(a)
kv = sorted(list(c.items()), key=lambda x: x[1], reverse=True)
if n <= k:
print((0))
else:
ls = c.most_common(k)
ans = n
for k, v in ls:
ans -= v
print(ans)
| from collections import Counter
n, k = list(map(int, input().split()))
(*a,) = list(map(int, input().split()))
c = Counter(a)
if n <= k:
print((0))
else:
ls = c.most_common(k)
ans = n
for k, v in ls:
ans -= v
print(ans)
| false | 12.5 | [
"-kv = sorted(list(c.items()), key=lambda x: x[1], reverse=True)"
] | false | 0.032176 | 0.036513 | 0.881212 | [
"s057518268",
"s138726512"
] |
u997521090 | p03704 | python | s386161403 | s737390053 | 13 | 12 | 2,568 | 2,568 | Accepted | Accepted | 7.69 | def f(d,x,y):n=int("9"*x+"0"*y);return d==0 if x<1 else sum(f(d-i*n,x-2,y+1)*(10-abs(i)-(y<1))for i in range(-9,10)if abs(d-i*n)<n)
D=eval(input());print(sum(f(D,i,0)*(10-i%2*9)for i in range(1,21)))
| def f(d,x,y):n=int("9"*x+"0"*y);return d==0 if x<1 else sum(f(d-i*n,x-2,y+1)*(10-abs(i)-(y<1))for i in [d/n,d/n+1]if -10<i<10)
D=eval(input());print(sum(f(D,i,0)*(10-i%2*9)for i in range(1,21))) | 2 | 2 | 194 | 188 | def f(d, x, y):
n = int("9" * x + "0" * y)
return (
d == 0
if x < 1
else sum(
f(d - i * n, x - 2, y + 1) * (10 - abs(i) - (y < 1))
for i in range(-9, 10)
if abs(d - i * n) < n
)
)
D = eval(input())
print(sum(f(D, i, 0) * (10 - i % 2 * 9) ... | def f(d, x, y):
n = int("9" * x + "0" * y)
return (
d == 0
if x < 1
else sum(
f(d - i * n, x - 2, y + 1) * (10 - abs(i) - (y < 1))
for i in [d / n, d / n + 1]
if -10 < i < 10
)
)
D = eval(input())
print(sum(f(D, i, 0) * (10 - i % 2 * 9) f... | false | 0 | [
"- for i in range(-9, 10)",
"- if abs(d - i * n) < n",
"+ for i in [d / n, d / n + 1]",
"+ if -10 < i < 10"
] | false | 0.088513 | 0.046266 | 1.913124 | [
"s386161403",
"s737390053"
] |
u805403870 | p03835 | python | s864380071 | s057172327 | 1,519 | 18 | 3,064 | 2,940 | Accepted | Accepted | 98.82 | # 蟻本1-6-1例題相当
# 今回も、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# 最後に、x,yの取りうる範囲を考慮する
k, s = list(map(int,input().split()))
xmin = (s - 2 * k) if (s - 2 * k) > 0 else 0
xmax = k if k < s else s
count = 0
for x in range(xmin, xmax+1):
ymin = (s - k - x) if (s - k - x)... | # 蟻本1-6-1例題相当
# 今回は、xのみ確定した際、y,zの取りうる値の組の数を求める。
# よって1重のfor文で回してみる
# 最大で2500となる
# 今回は、xの取りうる範囲を考慮しない
k, s = list(map(int,input().split()))
count = 0
for x in range(0, k+1):
if 0 <= s-x and s-x <= k: #(y,z) = (0, s-x), ... ,(s-x, 0)
count += s-x+1
elif k <= s-x and s-x <= 2*k: #(y,z) = (s-x-k, k), ..... | 17 | 14 | 463 | 367 | # 蟻本1-6-1例題相当
# 今回も、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# 最後に、x,yの取りうる範囲を考慮する
k, s = list(map(int, input().split()))
xmin = (s - 2 * k) if (s - 2 * k) > 0 else 0
xmax = k if k < s else s
count = 0
for x in range(xmin, xmax + 1):
ymin = (s - k - x) if (s - k - x) > 0 el... | # 蟻本1-6-1例題相当
# 今回は、xのみ確定した際、y,zの取りうる値の組の数を求める。
# よって1重のfor文で回してみる
# 最大で2500となる
# 今回は、xの取りうる範囲を考慮しない
k, s = list(map(int, input().split()))
count = 0
for x in range(0, k + 1):
if 0 <= s - x and s - x <= k: # (y,z) = (0, s-x), ... ,(s-x, 0)
count += s - x + 1
elif k <= s - x and s - x <= 2 * k: # (y,z)... | false | 17.647059 | [
"-# 今回も、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。",
"-# よって2重のfor文で回してみる",
"-# 最大で2500^2≒600万となる",
"-# 最後に、x,yの取りうる範囲を考慮する",
"+# 今回は、xのみ確定した際、y,zの取りうる値の組の数を求める。",
"+# よって1重のfor文で回してみる",
"+# 最大で2500となる",
"+# 今回は、xの取りうる範囲を考慮しない",
"-xmin = (s - 2 * k) if (s - 2 * k) > 0 else 0",
"-xmax = k if k < s... | false | 0.047292 | 0.04514 | 1.047666 | [
"s864380071",
"s057172327"
] |
u813098295 | p03862 | python | s163073518 | s548042479 | 177 | 117 | 11,340 | 11,340 | Accepted | Accepted | 33.9 | N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
if a[0] > x:
ans += (a[0]-x)
a[0] = x
for i in range(len(a)-1):
if sum(a[i:i+2]) > x:
ans += (sum(a[i:i+2]) - x)
a[i+1] -= (sum(a[i:i+2]) - x)
print(ans) | N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
if a[0] > x:
ans += (a[0]-x)
a[0] = x
for i in range(len(a)-1):
if a[i]+a[i+1] > x:
ans += (a[i]+a[i+1]-x)
a[i+1] -= (a[i]+a[i+1]-x)
print(ans) | 14 | 14 | 276 | 269 | N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
if a[0] > x:
ans += a[0] - x
a[0] = x
for i in range(len(a) - 1):
if sum(a[i : i + 2]) > x:
ans += sum(a[i : i + 2]) - x
a[i + 1] -= sum(a[i : i + 2]) - x
print(ans)
| N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
if a[0] > x:
ans += a[0] - x
a[0] = x
for i in range(len(a) - 1):
if a[i] + a[i + 1] > x:
ans += a[i] + a[i + 1] - x
a[i + 1] -= a[i] + a[i + 1] - x
print(ans)
| false | 0 | [
"- if sum(a[i : i + 2]) > x:",
"- ans += sum(a[i : i + 2]) - x",
"- a[i + 1] -= sum(a[i : i + 2]) - x",
"+ if a[i] + a[i + 1] > x:",
"+ ans += a[i] + a[i + 1] - x",
"+ a[i + 1] -= a[i] + a[i + 1] - x"
] | false | 0.055041 | 0.065088 | 0.845642 | [
"s163073518",
"s548042479"
] |
u057109575 | p02973 | python | s406226877 | s337547501 | 295 | 130 | 71,612 | 92,260 | Accepted | Accepted | 55.93 | from bisect import bisect_right
N, *A = list(map(int, open(0).read().split()))
INF = 10 ** 10
dp = [INF] * N
for i in range(N):
dp[bisect_right(dp, -A[i])] = -A[i]
print((max(i + 1 for i, v in enumerate(dp) if v < INF)))
| from bisect import bisect_right
N, *A = list(map(int, open(0).read().split()))
x = [1] * (N + 1)
for i in range(N):
j = bisect_right(x, -A[i])
x[j] = -A[i]
print((sum(v != 1 for v in x)))
| 10 | 10 | 229 | 200 | from bisect import bisect_right
N, *A = list(map(int, open(0).read().split()))
INF = 10**10
dp = [INF] * N
for i in range(N):
dp[bisect_right(dp, -A[i])] = -A[i]
print((max(i + 1 for i, v in enumerate(dp) if v < INF)))
| from bisect import bisect_right
N, *A = list(map(int, open(0).read().split()))
x = [1] * (N + 1)
for i in range(N):
j = bisect_right(x, -A[i])
x[j] = -A[i]
print((sum(v != 1 for v in x)))
| false | 0 | [
"-INF = 10**10",
"-dp = [INF] * N",
"+x = [1] * (N + 1)",
"- dp[bisect_right(dp, -A[i])] = -A[i]",
"-print((max(i + 1 for i, v in enumerate(dp) if v < INF)))",
"+ j = bisect_right(x, -A[i])",
"+ x[j] = -A[i]",
"+print((sum(v != 1 for v in x)))"
] | false | 0.079957 | 0.08035 | 0.995113 | [
"s406226877",
"s337547501"
] |
u261103969 | p02754 | python | s292798659 | s835990830 | 181 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.61 | # import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math
import sys
# import numpy as np
ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
I... | n, blue, red = list(map(int, input().split()))
# n / (blue + red) = quot ... rem
quot = n // (blue + red) # 商 quotient
rem = n % (blue + red) # 余り remainder
ans = blue * quot + min(blue, rem)
print(ans) | 30 | 9 | 569 | 215 | # import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math
import sys
# import numpy as np
ipti = sys.stdin.readline
MOD = 10**9 + 7
INF = float("INF")
s... | n, blue, red = list(map(int, input().split()))
# n / (blue + red) = quot ... rem
quot = n // (blue + red) # 商 quotient
rem = n % (blue + red) # 余り remainder
ans = blue * quot + min(blue, rem)
print(ans)
| false | 70 | [
"-# import bisect",
"-# from collections import Counter, deque",
"-# import copy",
"-# from heapq import heappush, heappop, heapify",
"-# from fractions import gcd",
"-# import itertools",
"-# from operator import attrgetter, itemgetter",
"-# import math",
"-import sys",
"-",
"-# import numpy as... | false | 0.041467 | 0.048569 | 0.853771 | [
"s292798659",
"s835990830"
] |
u952022797 | p03476 | python | s326746134 | s144569573 | 818 | 731 | 19,476 | 63,448 | Accepted | Accepted | 10.64 | # -*- coding: utf-8 -*-
import sys
import random
def main():
Q = int(eval(input()))
maps = []
r_max = 0
for _ in range(Q):
l, r = list(map(int, input().split(" ")))
maps.append((l, r))
if r_max < r:
r_max = r
#marix = getPrimeNumList(r_max)
base = [0] * (r_max+1)
counts = 0
... | # -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,var... | 54 | 53 | 1,020 | 1,168 | # -*- coding: utf-8 -*-
import sys
import random
def main():
Q = int(eval(input()))
maps = []
r_max = 0
for _ in range(Q):
l, r = list(map(int, input().split(" ")))
maps.append((l, r))
if r_max < r:
r_max = r
# marix = getPrimeNumList(r_max)
base = [0] * (r_... | # -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
# NO, PAY-PAY
# import numpy as np
# import statistics
# from statistics import mean, median,variance,stde... | false | 1.851852 | [
"-import random",
"+import copy",
"+import collections",
"+from bisect import bisect_left",
"+from bisect import bisect_right",
"+from collections import defaultdict",
"+from heapq import heappop, heappush",
"+import math",
"-",
"+# NO, PAY-PAY",
"+# import numpy as np",
"+# import statistics"... | false | 0.040531 | 0.682302 | 0.059404 | [
"s326746134",
"s144569573"
] |
u316386814 | p03608 | python | s513377200 | s433890015 | 1,016 | 713 | 14,760 | 13,028 | Accepted | Accepted | 29.82 | n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np
dists = np.ones((n + 1, n + 1)) * float('inf')
for _ in range(m):
a, b, c = list(map(int, input().split()))
dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
dists[i, i] = 0
fr... | n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np
dists = np.ones((n + 1, n + 1)) * float('inf')
for _ in range(m):
a, b, c = list(map(int, input().split()))
dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
dists[i, i] = 0
fr... | 23 | 23 | 665 | 656 | n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np
dists = np.ones((n + 1, n + 1)) * float("inf")
for _ in range(m):
a, b, c = list(map(int, input().split()))
dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
dists[i, i] = 0
from itertool... | n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np
dists = np.ones((n + 1, n + 1)) * float("inf")
for _ in range(m):
a, b, c = list(map(int, input().split()))
dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
dists[i, i] = 0
from itertool... | false | 0 | [
"-for i, k in product(list(range(1, 1 + n)), repeat=2):",
"- dists[:, k] = np.minimum(dists[:, k], dists[:, i] + dists[i, k])",
"+for i, j in product(list(range(1, 1 + n)), repeat=2):",
"+ dists[j] = np.minimum(dists[j], dists[i] + dists[j, i])"
] | false | 0.2057 | 0.571402 | 0.359992 | [
"s513377200",
"s433890015"
] |
u747515887 | p02837 | python | s780187373 | s765392804 | 109 | 72 | 3,064 | 3,064 | Accepted | Accepted | 33.94 | def main():
n = int(eval(input()))
xy = []
for i in range(n):
a = int(eval(input()))
xy.append([tuple(map(int, input().split())) for _ in range(a)])
c = 0
for i in range(1 << n):
all_honest = True
for j in range(n):
if (1 << j) & i != 0:
... | def main():
n = int(eval(input()))
xy = []
for i in range(n):
a = int(eval(input()))
xy.append([tuple(map(int, input().split())) for _ in range(a)])
c = 0
for i in range(1 << n):
popcnt = bin(i).count('1')
if popcnt <= c:
continue
all_... | 29 | 31 | 741 | 784 | def main():
n = int(eval(input()))
xy = []
for i in range(n):
a = int(eval(input()))
xy.append([tuple(map(int, input().split())) for _ in range(a)])
c = 0
for i in range(1 << n):
all_honest = True
for j in range(n):
if (1 << j) & i != 0:
fo... | def main():
n = int(eval(input()))
xy = []
for i in range(n):
a = int(eval(input()))
xy.append([tuple(map(int, input().split())) for _ in range(a)])
c = 0
for i in range(1 << n):
popcnt = bin(i).count("1")
if popcnt <= c:
continue
all_honest = True... | false | 6.451613 | [
"+ popcnt = bin(i).count(\"1\")",
"+ if popcnt <= c:",
"+ continue",
"- popcnt = bin(i).count(\"1\")"
] | false | 0.053971 | 0.078393 | 0.688471 | [
"s780187373",
"s765392804"
] |
u714642969 | p03162 | python | s783674108 | s709735270 | 657 | 368 | 74,072 | 72,412 | Accepted | Accepted | 43.99 | N=int(eval(input()))
li=[list(map(int,input().split())) for i in range(N)]
dp=[[0]*3 for i in range(N)]
for i in range(N):
if i==0:
for j in range(3):
dp[i][j] = li[i][j]
else:
for j in range(3):
if j == 0:
dp[i][j] = li[i][0] + dp[i-1][1] if dp[... | import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()
def main():
N=int(eval(input()))
l=[]
for i in range(N):
l.append(list(map(int,input().split())))
dp=[[0]*3 for _ in range(N+1)]
for i in range(N):
for k in ... | 16 | 19 | 642 | 464 | N = int(eval(input()))
li = [list(map(int, input().split())) for i in range(N)]
dp = [[0] * 3 for i in range(N)]
for i in range(N):
if i == 0:
for j in range(3):
dp[i][j] = li[i][j]
else:
for j in range(3):
if j == 0:
dp[i][j] = (
li[i]... | import sys
sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
l = []
for i in range(N):
l.append(list(map(int, input().split())))
dp = [[0] * 3 for _ in range(N + 1)]
for i in range(N):
... | false | 15.789474 | [
"-N = int(eval(input()))",
"-li = [list(map(int, input().split())) for i in range(N)]",
"-dp = [[0] * 3 for i in range(N)]",
"-for i in range(N):",
"- if i == 0:",
"- for j in range(3):",
"- dp[i][j] = li[i][j]",
"- else:",
"- for j in range(3):",
"- if j ... | false | 0.057272 | 0.087177 | 0.656966 | [
"s783674108",
"s709735270"
] |
u847467233 | p00155 | python | s385889816 | s034726647 | 60 | 40 | 5,808 | 5,772 | Accepted | Accepted | 33.33 | # AOJ 0155 Spider Jin
# Python3 2018.6.23 bal4u
# 最短経路問題
MAXLEN = 50
MAX = 100
INF = 0x7ffffffffffffff
x = [0]*(MAX+2)
y = [0]*(MAX+2)
dist = [INF]*(MAX+2)
pre = [0]*(MAX+2)
import heapq
def dijkstra(V, to, start, goal):
global dist
dist = [INF]*V
Q = []
dist[start] = 0
heapq.heappush(Q, (0, s... | # AOJ 0155 Spider Jin
# Python3 2018.6.23 bal4u
# 最短経路問題
MAXLEN = 50
MAX = 100
INF = 0x7ffffffffffffff
x = [0]*(MAX+2)
y = [0]*(MAX+2)
dist = [INF]*(MAX+2)
pre = [0]*(MAX+2)
import heapq
def dijkstra(V, to, start, goal):
global dist
dist = [INF]*V
Q = []
dist[start] = 0
heapq.heappush(Q, (0, s... | 60 | 59 | 1,215 | 1,210 | # AOJ 0155 Spider Jin
# Python3 2018.6.23 bal4u
# 最短経路問題
MAXLEN = 50
MAX = 100
INF = 0x7FFFFFFFFFFFFFF
x = [0] * (MAX + 2)
y = [0] * (MAX + 2)
dist = [INF] * (MAX + 2)
pre = [0] * (MAX + 2)
import heapq
def dijkstra(V, to, start, goal):
global dist
dist = [INF] * V
Q = []
dist[start] = 0
heapq.hea... | # AOJ 0155 Spider Jin
# Python3 2018.6.23 bal4u
# 最短経路問題
MAXLEN = 50
MAX = 100
INF = 0x7FFFFFFFFFFFFFF
x = [0] * (MAX + 2)
y = [0] * (MAX + 2)
dist = [INF] * (MAX + 2)
pre = [0] * (MAX + 2)
import heapq
def dijkstra(V, to, start, goal):
global dist
dist = [INF] * V
Q = []
dist[start] = 0
heapq.hea... | false | 1.666667 | [
"- while len(Q):",
"+ while Q:",
"- for i in to[s]:",
"- e, cost = i",
"+ for e, cost in to[s]:",
"- for j in range(1, n):",
"+ for j in range(i + 1, n):",
"- dd = (dx**2 + dy**2) ** 0.5",
"- if dd <= MAXLEN:",
"- to... | false | 0.040165 | 0.007463 | 5.382111 | [
"s385889816",
"s034726647"
] |
u844646164 | p03545 | python | s938840493 | s719836608 | 168 | 65 | 38,256 | 61,692 | Accepted | Accepted | 61.31 | abcd = str(eval(input()))
a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[3]
sign = ['+', '-']
for i in range(2):
for j in range(2):
for k in range(2):
tmp = a + sign[i] + b + sign[j] + c + sign[k] + d
if eval(tmp) == 7:
print((tmp+'=7'))
... | abcd = list(eval(input()))
a, b, c, d = abcd
sign = ['+', '-']
for i in range(2**3):
s = a
for j in range(3):
if (i>>j) & 1:
s += sign[0]
else:
s += sign[1]
s += abcd[j+1]
if eval(s) == 7:
print((s + "=7"))
exit() | 14 | 14 | 318 | 294 | abcd = str(eval(input()))
a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[3]
sign = ["+", "-"]
for i in range(2):
for j in range(2):
for k in range(2):
tmp = a + sign[i] + b + sign[j] + c + sign[k] + d
if eval(tmp) == 7:
print((tmp + "=7"))
exit()
| abcd = list(eval(input()))
a, b, c, d = abcd
sign = ["+", "-"]
for i in range(2**3):
s = a
for j in range(3):
if (i >> j) & 1:
s += sign[0]
else:
s += sign[1]
s += abcd[j + 1]
if eval(s) == 7:
print((s + "=7"))
exit()
| false | 0 | [
"-abcd = str(eval(input()))",
"-a = abcd[0]",
"-b = abcd[1]",
"-c = abcd[2]",
"-d = abcd[3]",
"+abcd = list(eval(input()))",
"+a, b, c, d = abcd",
"-for i in range(2):",
"- for j in range(2):",
"- for k in range(2):",
"- tmp = a + sign[i] + b + sign[j] + c + sign[k] + d",
... | false | 0.178762 | 0.071098 | 2.514317 | [
"s938840493",
"s719836608"
] |
u916338311 | p02580 | python | s205671537 | s909252526 | 1,054 | 899 | 113,492 | 96,180 | Accepted | Accepted | 14.71 | h,w,m=list(map(int,input().split()))
item=[list(map(int,input().split())) for i in range(m)]
row=[0]*h
col=[0]*w
for i in range(m):
x,y=item[i]
row[x-1]+=1
col[y-1]+=1
mr,mc=max(row),max(col)
xr=set([i for i in range(h) if row[i]==mr])
xc=set([i for i in range(w) if col[i]==mc])
check=len(xr)*len... | H, W, M = list(map(int, input().split()))
h = [0] * H
w = [0] * W
Mem = [tuple(map(int, input().split())) for _ in range(M) ]
for i, j in Mem:
h[i-1] += 1
w[j-1] += 1
maxh = max(h)
maxw = max(w)
listh = {i for i, v in enumerate(h, 1) if v == maxh}
listw = {j for j, v in enumerate(w, 1) if v == max... | 17 | 27 | 444 | 495 | h, w, m = list(map(int, input().split()))
item = [list(map(int, input().split())) for i in range(m)]
row = [0] * h
col = [0] * w
for i in range(m):
x, y = item[i]
row[x - 1] += 1
col[y - 1] += 1
mr, mc = max(row), max(col)
xr = set([i for i in range(h) if row[i] == mr])
xc = set([i for i in range(w) if col[... | H, W, M = list(map(int, input().split()))
h = [0] * H
w = [0] * W
Mem = [tuple(map(int, input().split())) for _ in range(M)]
for i, j in Mem:
h[i - 1] += 1
w[j - 1] += 1
maxh = max(h)
maxw = max(w)
listh = {i for i, v in enumerate(h, 1) if v == maxh}
listw = {j for j, v in enumerate(w, 1) if v == maxw}
cnt = le... | false | 37.037037 | [
"-h, w, m = list(map(int, input().split()))",
"-item = [list(map(int, input().split())) for i in range(m)]",
"-row = [0] * h",
"-col = [0] * w",
"-for i in range(m):",
"- x, y = item[i]",
"- row[x - 1] += 1",
"- col[y - 1] += 1",
"-mr, mc = max(row), max(col)",
"-xr = set([i for i in rang... | false | 0.078553 | 0.099175 | 0.792068 | [
"s205671537",
"s909252526"
] |
u644907318 | p02759 | python | s455086419 | s218715364 | 163 | 63 | 38,384 | 61,772 | Accepted | Accepted | 61.35 | print(((int(eval(input()))+1)//2)) | N = int(eval(input()))
print(((N+1)//2)) | 1 | 2 | 26 | 33 | print(((int(eval(input())) + 1) // 2))
| N = int(eval(input()))
print(((N + 1) // 2))
| false | 50 | [
"-print(((int(eval(input())) + 1) // 2))",
"+N = int(eval(input()))",
"+print(((N + 1) // 2))"
] | false | 0.035005 | 0.043949 | 0.796498 | [
"s455086419",
"s218715364"
] |
u687574784 | p03060 | python | s904946592 | s934256688 | 954 | 17 | 41,436 | 3,064 | Accepted | Accepted | 98.22 | n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans=-10*18
for i in range(1<<n):
mask=[(i>>j)&1 for j in range(n)]
X=0
Y=0
for k, m in enumerate(mask):
if m==1:
X+=v[k]
Y+=c[k]
ans=max(ans, X-Y)
print(a... | n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans=0
for x,y in zip(v,c):
ans+=max(x-y, 0)
print(ans) | 15 | 7 | 317 | 153 | n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = -10 * 18
for i in range(1 << n):
mask = [(i >> j) & 1 for j in range(n)]
X = 0
Y = 0
for k, m in enumerate(mask):
if m == 1:
X += v[k]
Y += c[k]
ans = max(ans, X - Y)
... | n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for x, y in zip(v, c):
ans += max(x - y, 0)
print(ans)
| false | 53.333333 | [
"-ans = -10 * 18",
"-for i in range(1 << n):",
"- mask = [(i >> j) & 1 for j in range(n)]",
"- X = 0",
"- Y = 0",
"- for k, m in enumerate(mask):",
"- if m == 1:",
"- X += v[k]",
"- Y += c[k]",
"- ans = max(ans, X - Y)",
"+ans = 0",
"+for x, y in zip... | false | 0.050722 | 0.04834 | 1.049269 | [
"s904946592",
"s934256688"
] |
u347640436 | p02627 | python | s882370449 | s974657908 | 31 | 24 | 9,076 | 9,024 | Accepted | Accepted | 22.58 | A = eval(input())
if A == A.upper():
print('A')
else:
print('a')
| A = eval(input())
if A.isupper():
print('A')
else:
print('a')
| 6 | 6 | 73 | 70 | A = eval(input())
if A == A.upper():
print("A")
else:
print("a")
| A = eval(input())
if A.isupper():
print("A")
else:
print("a")
| false | 0 | [
"-if A == A.upper():",
"+if A.isupper():"
] | false | 0.047418 | 0.048009 | 0.987694 | [
"s882370449",
"s974657908"
] |
u827202523 | p04044 | python | s402366994 | s032960092 | 168 | 133 | 38,384 | 65,404 | Accepted | Accepted | 20.83 | def getlist():
return list(map(int, input().split()))
a,b = getlist()
lis = []
for i in range(a):
lis.append(input().strip())
lis.sort()
print(("".join(lis)))
| import sys
from collections import defaultdict, deque, Counter
import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList... | 10 | 34 | 178 | 682 | def getlist():
return list(map(int, input().split()))
a, b = getlist()
lis = []
for i in range(a):
lis.append(input().strip())
lis.sort()
print(("".join(lis)))
| import sys
from collections import defaultdict, deque, Counter
import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList = lambda: list(map(i... | false | 70.588235 | [
"-def getlist():",
"- return list(map(int, input().split()))",
"+import sys",
"+from collections import defaultdict, deque, Counter",
"+import math",
"+",
"+# import copy",
"+from bisect import bisect_left, bisect_right",
"+",
"+# import heapq",
"+# sys.setrecursionlimit(1000000)",
"+# inpu... | false | 0.041799 | 0.035965 | 1.162203 | [
"s402366994",
"s032960092"
] |
u556589653 | p03607 | python | s042491727 | s078068544 | 235 | 168 | 16,612 | 17,884 | Accepted | Accepted | 28.51 | import collections
N = int(eval(input()))
ans = 0
now = 0
k = []
for i in range(N):
A = int(eval(input()))
k.append(A)
p = collections.Counter(k)
for i in p:
if p[i]%2 == 1:
ans += 1
print(ans) | N = int(eval(input()))
dict1 = {}
for i in range(N):
A = eval(input())
if A in dict1:
del dict1[A]
else:
dict1[A] = 1
print((len(dict1))) | 13 | 9 | 203 | 145 | import collections
N = int(eval(input()))
ans = 0
now = 0
k = []
for i in range(N):
A = int(eval(input()))
k.append(A)
p = collections.Counter(k)
for i in p:
if p[i] % 2 == 1:
ans += 1
print(ans)
| N = int(eval(input()))
dict1 = {}
for i in range(N):
A = eval(input())
if A in dict1:
del dict1[A]
else:
dict1[A] = 1
print((len(dict1)))
| false | 30.769231 | [
"-import collections",
"-",
"-ans = 0",
"-now = 0",
"-k = []",
"+dict1 = {}",
"- A = int(eval(input()))",
"- k.append(A)",
"-p = collections.Counter(k)",
"-for i in p:",
"- if p[i] % 2 == 1:",
"- ans += 1",
"-print(ans)",
"+ A = eval(input())",
"+ if A in dict1:",
... | false | 0.102166 | 0.082267 | 1.241884 | [
"s042491727",
"s078068544"
] |
u844646164 | p02792 | python | s622539062 | s785787563 | 274 | 179 | 3,316 | 73,828 | Accepted | Accepted | 34.67 | from collections import defaultdict
N = int(eval(input()))
ans = 0
c = defaultdict(int)
for i in range(1, N+1):
s = int(str(i)[0])
t = int(str(i)[-1])
if s != 0 and t != 0:
c[(s, t)] += 1
for i in range(1, 10):
for j in range(1, 10):
ans += c[(i, j)] * c[(j, i)]
print(ans)
| from collections import defaultdict
N = int(eval(input()))
d = defaultdict(int)
for i in range(1, N+1):
s, t = str(i)[0], str(i)[-1]
if s != 0 and t != 0:
if s > t:
s, t = s, t
d[(s, t)] += 1
ans = 0
for i in range(1, 11):
for j in range(1, 11):
i = str(i)
j = str(j)
... | 15 | 20 | 300 | 355 | from collections import defaultdict
N = int(eval(input()))
ans = 0
c = defaultdict(int)
for i in range(1, N + 1):
s = int(str(i)[0])
t = int(str(i)[-1])
if s != 0 and t != 0:
c[(s, t)] += 1
for i in range(1, 10):
for j in range(1, 10):
ans += c[(i, j)] * c[(j, i)]
print(ans)
| from collections import defaultdict
N = int(eval(input()))
d = defaultdict(int)
for i in range(1, N + 1):
s, t = str(i)[0], str(i)[-1]
if s != 0 and t != 0:
if s > t:
s, t = s, t
d[(s, t)] += 1
ans = 0
for i in range(1, 11):
for j in range(1, 11):
i = str(i)
j = ... | false | 25 | [
"+d = defaultdict(int)",
"+for i in range(1, N + 1):",
"+ s, t = str(i)[0], str(i)[-1]",
"+ if s != 0 and t != 0:",
"+ if s > t:",
"+ s, t = s, t",
"+ d[(s, t)] += 1",
"-c = defaultdict(int)",
"-for i in range(1, N + 1):",
"- s = int(str(i)[0])",
"- t = int(s... | false | 0.054978 | 0.232461 | 0.236505 | [
"s622539062",
"s785787563"
] |
u395210038 | p02628 | python | s699964544 | s701155904 | 335 | 58 | 85,164 | 66,524 | Accepted | Accepted | 82.69 | from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range
def main():
n,k = list(map(int,read().split()))
a = list(map(int,read().split()))
a.sort()
write('{}\n'.format(sum(a[:k])))
if __name__ == "__main__":
main() | from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range
def main():
n,k = list(map(int,read().split()))
a = sorted(list(map(int,read().split())))
write('{}\n'.format(sum(a[:k])))
if __name__ == "__main__":
main() | 14 | 13 | 276 | 273 | from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range
def main():
n, k = list(map(int, read().split()))
a = list(map(int, read().split()))
a.sort()
write("{}\n".format(sum(a[:k])))
if __name__ == "__main__":
main()
| from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range
def main():
n, k = list(map(int, read().split()))
a = sorted(list(map(int, read().split())))
write("{}\n".format(sum(a[:k])))
if __name__ == "__main__":
main()
| false | 7.142857 | [
"- a = list(map(int, read().split()))",
"- a.sort()",
"+ a = sorted(list(map(int, read().split())))"
] | false | 0.034354 | 0.035855 | 0.958129 | [
"s699964544",
"s701155904"
] |
u627600101 | p02814 | python | s566499077 | s173569617 | 158 | 126 | 20,164 | 20,020 | Accepted | Accepted | 20.25 | N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
for k in range(N):
a[k] //= 2
foo = 1
while a[0]%2 == 0:
foo *= 2
a[0] //= 2
for k in range(1, N):
if a[k] % foo == 0 and a[k]%(2*foo) !=0:
a[k] //= foo
continue
else:
print((0))
exit()
ans = 0
for o... | N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
for k in range(N):
a[k] //= 2
foo = 1
while a[0]%2 == 0:
foo *= 2
a[0] //= 2
for k in range(1, N):
if a[k] % foo == 0 and a[k]%(2*foo) !=0:
a[k] //= foo
continue
else:
print((0))
exit()
ans = 0
for o... | 41 | 41 | 672 | 666 | N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
for k in range(N):
a[k] //= 2
foo = 1
while a[0] % 2 == 0:
foo *= 2
a[0] //= 2
for k in range(1, N):
if a[k] % foo == 0 and a[k] % (2 * foo) != 0:
a[k] //= foo
continue
else:
print((0))
exit()
... | N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
for k in range(N):
a[k] //= 2
foo = 1
while a[0] % 2 == 0:
foo *= 2
a[0] //= 2
for k in range(1, N):
if a[k] % foo == 0 and a[k] % (2 * foo) != 0:
a[k] //= foo
continue
else:
print((0))
exit()
... | false | 0 | [
"-for odd in [3, 5, 7]:",
"+for odd in [3]:"
] | false | 0.037498 | 0.036995 | 1.013576 | [
"s566499077",
"s173569617"
] |
u551313534 | p04039 | python | s925665372 | s465102418 | 488 | 440 | 4,084 | 3,700 | Accepted | Accepted | 9.84 | from functools import reduce
import operator as op
n = int(input().split(' ')[0])
ds_str = input().split(' ')
ds = list(map(int, ds_str))
for m in range(n, 100000):
mlist = list(map(int, list(str(m))))
if reduce(op.or_, [x in ds for x in mlist]):
continue
else:
print(m)
... | from functools import reduce
import operator as op
n = int(input().split(' ')[0])
ds_str = input().split(' ')
ds = set(map(int, ds_str))
for m in range(n, 100000):
mlist = list(map(int, list(str(m))))
if reduce(op.or_, [x in ds for x in mlist]):
continue
else:
print(m)
... | 14 | 14 | 326 | 325 | from functools import reduce
import operator as op
n = int(input().split(" ")[0])
ds_str = input().split(" ")
ds = list(map(int, ds_str))
for m in range(n, 100000):
mlist = list(map(int, list(str(m))))
if reduce(op.or_, [x in ds for x in mlist]):
continue
else:
print(m)
break
| from functools import reduce
import operator as op
n = int(input().split(" ")[0])
ds_str = input().split(" ")
ds = set(map(int, ds_str))
for m in range(n, 100000):
mlist = list(map(int, list(str(m))))
if reduce(op.or_, [x in ds for x in mlist]):
continue
else:
print(m)
break
| false | 0 | [
"-ds = list(map(int, ds_str))",
"+ds = set(map(int, ds_str))"
] | false | 0.042358 | 0.049068 | 0.86325 | [
"s925665372",
"s465102418"
] |
u580697892 | p03339 | python | s881932398 | s846365449 | 252 | 153 | 3,700 | 3,700 | Accepted | Accepted | 39.29 | # coding: utf-8
N = int(eval(input()))
S = eval(input())
w, e = 0, 0
for i in range(N):
if S[i] == "E":
e += 1
ans = e
for i in range(N):
if S[i] == "E":
e -= 1
ans = min(ans, e+w)
if S[i] == "W":
w += 1
print(ans) | # coding: utf-8
N = int(eval(input()))
S = eval(input())
e, w = 0, 0
e = S.count("E")
ans = e
for i in range(N):
if S[i] == "E":
e -= 1
ans = min(ans, e+w)
else:
w += 1
print(ans) | 18 | 13 | 266 | 211 | # coding: utf-8
N = int(eval(input()))
S = eval(input())
w, e = 0, 0
for i in range(N):
if S[i] == "E":
e += 1
ans = e
for i in range(N):
if S[i] == "E":
e -= 1
ans = min(ans, e + w)
if S[i] == "W":
w += 1
print(ans)
| # coding: utf-8
N = int(eval(input()))
S = eval(input())
e, w = 0, 0
e = S.count("E")
ans = e
for i in range(N):
if S[i] == "E":
e -= 1
ans = min(ans, e + w)
else:
w += 1
print(ans)
| false | 27.777778 | [
"-w, e = 0, 0",
"-for i in range(N):",
"- if S[i] == \"E\":",
"- e += 1",
"+e, w = 0, 0",
"+e = S.count(\"E\")",
"- ans = min(ans, e + w)",
"- if S[i] == \"W\":",
"+ ans = min(ans, e + w)",
"+ else:"
] | false | 0.038902 | 0.038724 | 1.004619 | [
"s881932398",
"s846365449"
] |
u355371431 | p03324 | python | s883760152 | s140439393 | 170 | 17 | 38,512 | 2,940 | Accepted | Accepted | 90 | D,N = list(map(int,input().split()))
ans = (100**D) * N
if(N == 100):
ans += 100**D
print(ans) | d,n = list(map(int,input().split()))
ans = n * 100**d
if n == 100:
ans += 100**d
print(ans) | 5 | 5 | 97 | 93 | D, N = list(map(int, input().split()))
ans = (100**D) * N
if N == 100:
ans += 100**D
print(ans)
| d, n = list(map(int, input().split()))
ans = n * 100**d
if n == 100:
ans += 100**d
print(ans)
| false | 0 | [
"-D, N = list(map(int, input().split()))",
"-ans = (100**D) * N",
"-if N == 100:",
"- ans += 100**D",
"+d, n = list(map(int, input().split()))",
"+ans = n * 100**d",
"+if n == 100:",
"+ ans += 100**d"
] | false | 0.042737 | 0.00754 | 5.667965 | [
"s883760152",
"s140439393"
] |
u600402037 | p03352 | python | s185816330 | s601109811 | 19 | 17 | 2,940 | 3,060 | Accepted | Accepted | 10.53 | import math
X = int(eval(input()))
answer = 1
for i in range(X+1):
for j in range(2, X+1):
if i ** j <= X:
answer = max(answer, i ** j)
else:
break
print(answer)
| X = int(eval(input()))
answer = 1
for i in range(2, X+1):
j = 2
while i**j <= X:
answer = max(answer, i**j)
j += 1
print(answer) | 11 | 9 | 211 | 155 | import math
X = int(eval(input()))
answer = 1
for i in range(X + 1):
for j in range(2, X + 1):
if i**j <= X:
answer = max(answer, i**j)
else:
break
print(answer)
| X = int(eval(input()))
answer = 1
for i in range(2, X + 1):
j = 2
while i**j <= X:
answer = max(answer, i**j)
j += 1
print(answer)
| false | 18.181818 | [
"-import math",
"-",
"-for i in range(X + 1):",
"- for j in range(2, X + 1):",
"- if i**j <= X:",
"- answer = max(answer, i**j)",
"- else:",
"- break",
"+for i in range(2, X + 1):",
"+ j = 2",
"+ while i**j <= X:",
"+ answer = max(answer, i**... | false | 0.05103 | 0.008635 | 5.909373 | [
"s185816330",
"s601109811"
] |
u440180827 | p00002 | python | s772180528 | s223633955 | 30 | 20 | 7,528 | 7,544 | Accepted | Accepted | 33.33 | import sys
strs = sys.stdin.readlines()
for s in strs:
a, b = list(map(int, s.split()))
print((len(str(a + b)))) | import sys
for line in sys.stdin:
a, b = list(map(int, line.split()))
print((len(str(a + b)))) | 5 | 4 | 116 | 97 | import sys
strs = sys.stdin.readlines()
for s in strs:
a, b = list(map(int, s.split()))
print((len(str(a + b))))
| import sys
for line in sys.stdin:
a, b = list(map(int, line.split()))
print((len(str(a + b))))
| false | 20 | [
"-strs = sys.stdin.readlines()",
"-for s in strs:",
"- a, b = list(map(int, s.split()))",
"+for line in sys.stdin:",
"+ a, b = list(map(int, line.split()))"
] | false | 0.083247 | 0.038503 | 2.162087 | [
"s772180528",
"s223633955"
] |
u026075806 | p03244 | python | s890210111 | s799356510 | 83 | 74 | 18,652 | 16,228 | Accepted | Accepted | 10.84 | _ = eval(input())
seq = list(map(int,input().split()))
seq1 = seq[::2]
seq2 = seq[1::2]
if len(set(seq)) == 1:
print((len(seq2)))
exit()
def count_dictonary(seq):
ret_dict={}
for item in seq:
if item not in ret_dict:
ret_dict[item] = 1
else:
... | def count_char_occurrence(seq):
# count how many times characters occur and return results as a dictionary
ret = {}
for char in seq:
if char in ret:
ret[char] += 1
else:
ret[char] = 1
return ret
def accum_char_frequency(seq):
"""
accumulate ... | 51 | 63 | 1,299 | 1,827 | _ = eval(input())
seq = list(map(int, input().split()))
seq1 = seq[::2]
seq2 = seq[1::2]
if len(set(seq)) == 1:
print((len(seq2)))
exit()
def count_dictonary(seq):
ret_dict = {}
for item in seq:
if item not in ret_dict:
ret_dict[item] = 1
else:
ret_dict[item] +=... | def count_char_occurrence(seq):
# count how many times characters occur and return results as a dictionary
ret = {}
for char in seq:
if char in ret:
ret[char] += 1
else:
ret[char] = 1
return ret
def accum_char_frequency(seq):
"""
accumulate frequency of ... | false | 19.047619 | [
"-_ = eval(input())",
"-seq = list(map(int, input().split()))",
"-seq1 = seq[::2]",
"-seq2 = seq[1::2]",
"-if len(set(seq)) == 1:",
"- print((len(seq2)))",
"- exit()",
"-",
"-",
"-def count_dictonary(seq):",
"- ret_dict = {}",
"- for item in seq:",
"- if item not in ret_di... | false | 0.043018 | 0.107153 | 0.401459 | [
"s890210111",
"s799356510"
] |
u815878613 | p03220 | python | s330376736 | s410385885 | 326 | 29 | 21,752 | 9,268 | Accepted | Accepted | 91.1 | import sys
import numpy as np
N = int(eval(input()))
T, A = list(map(int, input().split()))
H = np.array(list(map(int, input().split())))
m = abs(A - (T - 0.006 * H[0]))
num = 1
for n in range(1, N):
d = abs(A - (T - 0.006 * H[n]))
if d < m:
m = d
num = n+1
print(num)
| N = int(eval(input()))
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))
pt = [abs(A - (T - h * 0.006)) for h in H]
# np.argsortなしで,最大値,最小値のindexを取得
ans = min(enumerate(pt), key=lambda x: x[1])[0]
print((ans + 1))
# 最大値が複数あるとき
# [i for i, v in enumerate(li) if v == max(l)]
# 計算重そ... | 17 | 14 | 307 | 310 | import sys
import numpy as np
N = int(eval(input()))
T, A = list(map(int, input().split()))
H = np.array(list(map(int, input().split())))
m = abs(A - (T - 0.006 * H[0]))
num = 1
for n in range(1, N):
d = abs(A - (T - 0.006 * H[n]))
if d < m:
m = d
num = n + 1
print(num)
| N = int(eval(input()))
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))
pt = [abs(A - (T - h * 0.006)) for h in H]
# np.argsortなしで,最大値,最小値のindexを取得
ans = min(enumerate(pt), key=lambda x: x[1])[0]
print((ans + 1))
# 最大値が複数あるとき
# [i for i, v in enumerate(li) if v == max(l)]
# 計算重そう
| false | 17.647059 | [
"-import sys",
"-import numpy as np",
"-",
"-H = np.array(list(map(int, input().split())))",
"-m = abs(A - (T - 0.006 * H[0]))",
"-num = 1",
"-for n in range(1, N):",
"- d = abs(A - (T - 0.006 * H[n]))",
"- if d < m:",
"- m = d",
"- num = n + 1",
"-print(num)",
"+H = list... | false | 0.871432 | 0.041442 | 21.0276 | [
"s330376736",
"s410385885"
] |
u794544096 | p02760 | python | s975685890 | s824934805 | 562 | 60 | 79,668 | 62,088 | Accepted | Accepted | 89.32 | a = []
for i in range(3):
a1, a2, a3 = list(map(int, input().split()))
a.append(a1)
a.append(a2)
a.append(a3)
l = [0]*9
n = int(eval(input()))
for i in range(n):
b = int(eval(input()))
if b in a:
l[a.index(b)] += 1
if l[0] == 1 and l[1] == 1 and l[2] == 1:
print('Y... | a = []
for i in range(3):
a1, a2, a3 = list(map(int, input().split()))
a.append(a1)
a.append(a2)
a.append(a3)
l = [0]*9
n = int(eval(input()))
for i in range(n):
b = int(eval(input()))
for k in range(9):
if a[k] == b:
l[k] += 1
if l[0] == 1 and l[1] == 1 a... | 33 | 34 | 771 | 798 | a = []
for i in range(3):
a1, a2, a3 = list(map(int, input().split()))
a.append(a1)
a.append(a2)
a.append(a3)
l = [0] * 9
n = int(eval(input()))
for i in range(n):
b = int(eval(input()))
if b in a:
l[a.index(b)] += 1
if l[0] == 1 and l[1] == 1 and l[2] == 1:
print("Yes")
elif l[3] ==... | a = []
for i in range(3):
a1, a2, a3 = list(map(int, input().split()))
a.append(a1)
a.append(a2)
a.append(a3)
l = [0] * 9
n = int(eval(input()))
for i in range(n):
b = int(eval(input()))
for k in range(9):
if a[k] == b:
l[k] += 1
if l[0] == 1 and l[1] == 1 and l[2] == 1:
... | false | 2.941176 | [
"- if b in a:",
"- l[a.index(b)] += 1",
"+ for k in range(9):",
"+ if a[k] == b:",
"+ l[k] += 1"
] | false | 0.047519 | 0.042266 | 1.124285 | [
"s975685890",
"s824934805"
] |
u659302753 | p02726 | python | s258150409 | s747504319 | 637 | 491 | 80,220 | 53,212 | Accepted | Accepted | 22.92 | from sys import stdin
from collections import deque
def get_adj_list(num_nodes, data, undirected=True):
# adj_list ex) {1:[2,3,4], 2:[1,4,5], 3:[1,4], 4:[1,2,3,5], 5:[2,4]}
graph = {}
for i in range(num_nodes):
graph[i+1] = []
for val in data:
x, y = val
graph[x] = g... | # from sys import stdin
# # 解説のコード
# def get_result(data):
# N, X, Y = data
# dist_cnt = [0 for i in range(N)]
# for i in range(1, N+1):
# for j in range(i+1, N+1):
# min_dist = min([j-i, abs(X-i) + 1 + abs(Y-j), abs(Y-i) + 1 + abs(X-j)])
# dist_cnt[min_dist] += 1
... | 58 | 72 | 1,623 | 2,110 | from sys import stdin
from collections import deque
def get_adj_list(num_nodes, data, undirected=True):
# adj_list ex) {1:[2,3,4], 2:[1,4,5], 3:[1,4], 4:[1,2,3,5], 5:[2,4]}
graph = {}
for i in range(num_nodes):
graph[i + 1] = []
for val in data:
x, y = val
graph[x] = graph[x] +... | # from sys import stdin
# # 解説のコード
# def get_result(data):
# N, X, Y = data
# dist_cnt = [0 for i in range(N)]
# for i in range(1, N+1):
# for j in range(i+1, N+1):
# min_dist = min([j-i, abs(X-i) + 1 + abs(Y-j), abs(Y-i) + 1 + abs(X-j)])
# dist_cnt[min_dist] += 1
# for i... | false | 19.444444 | [
"-from sys import stdin",
"-from collections import deque",
"-",
"-",
"-def get_adj_list(num_nodes, data, undirected=True):",
"- # adj_list ex) {1:[2,3,4], 2:[1,4,5], 3:[1,4], 4:[1,2,3,5], 5:[2,4]}",
"- graph = {}",
"- for i in range(num_nodes):",
"- graph[i + 1] = []",
"- for v... | false | 0.066484 | 0.045273 | 1.468496 | [
"s258150409",
"s747504319"
] |
u533039576 | p02819 | python | s260553332 | s366113457 | 63 | 17 | 4,596 | 2,940 | Accepted | Accepted | 73.02 | def eratosthenes(n: int) -> list:
is_prime = [True] * (n + 1)
is_prime[0] = is_prime[1] = False
for i in range(2, n // 2 + 1):
if is_prime[i]:
for j in range(2, n // i + 1):
is_prime[i * j] = False
return is_prime
x = int(eval(input()))
is_prime = eratost... | def is_prime(n):
if n <= 1:
return False
elif n == 2:
return True
elif n % 2 == 0:
return False
for i in range(3, n, 2):
if i * i > n:
break
if n % i == 0:
return False
return True
x = int(eval(input()))
while not is_p... | 16 | 19 | 394 | 345 | def eratosthenes(n: int) -> list:
is_prime = [True] * (n + 1)
is_prime[0] = is_prime[1] = False
for i in range(2, n // 2 + 1):
if is_prime[i]:
for j in range(2, n // i + 1):
is_prime[i * j] = False
return is_prime
x = int(eval(input()))
is_prime = eratosthenes(x * 2... | def is_prime(n):
if n <= 1:
return False
elif n == 2:
return True
elif n % 2 == 0:
return False
for i in range(3, n, 2):
if i * i > n:
break
if n % i == 0:
return False
return True
x = int(eval(input()))
while not is_prime(x):
x +... | false | 15.789474 | [
"-def eratosthenes(n: int) -> list:",
"- is_prime = [True] * (n + 1)",
"- is_prime[0] = is_prime[1] = False",
"- for i in range(2, n // 2 + 1):",
"- if is_prime[i]:",
"- for j in range(2, n // i + 1):",
"- is_prime[i * j] = False",
"- return is_prime",
"+... | false | 0.043994 | 0.07866 | 0.559293 | [
"s260553332",
"s366113457"
] |
u073852194 | p03426 | python | s767456531 | s764640811 | 758 | 493 | 78,428 | 37,448 | Accepted | Accepted | 34.96 | H,W,D = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(H)]
Q = int(eval(input()))
S = [list(map(int,input().split())) for i in range(Q)]
P = [None]*(H*W+1)
for i in range(H):
for j in range(W):
P[A[i][j]] = [i,j]
Accum = [0]*(H*W+1)
accum = 0
for i in range(D... | H, W, D = list(map(int, input().split()))
A = [tuple(map(int, input().split())) for _ in range(H)]
P = {}
for i in range(H):
for j in range(W):
P[A[i][j] - 1] = (i, j)
cum = [0] * (H * W + 1)
for a in range(H * W - D):
i, j = P[a]
x, y = P[a + D]
cum[a + D] = cum[a] + abs(x - i... | 17 | 24 | 442 | 494 | H, W, D = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(H)]
Q = int(eval(input()))
S = [list(map(int, input().split())) for i in range(Q)]
P = [None] * (H * W + 1)
for i in range(H):
for j in range(W):
P[A[i][j]] = [i, j]
Accum = [0] * (H * W + 1)
accum = 0
for i in ran... | H, W, D = list(map(int, input().split()))
A = [tuple(map(int, input().split())) for _ in range(H)]
P = {}
for i in range(H):
for j in range(W):
P[A[i][j] - 1] = (i, j)
cum = [0] * (H * W + 1)
for a in range(H * W - D):
i, j = P[a]
x, y = P[a + D]
cum[a + D] = cum[a] + abs(x - i) + abs(y - j)
Q =... | false | 29.166667 | [
"-A = [list(map(int, input().split())) for i in range(H)]",
"-Q = int(eval(input()))",
"-S = [list(map(int, input().split())) for i in range(Q)]",
"-P = [None] * (H * W + 1)",
"+A = [tuple(map(int, input().split())) for _ in range(H)]",
"+P = {}",
"- P[A[i][j]] = [i, j]",
"-Accum = [0] * (H * W... | false | 0.042855 | 0.04391 | 0.97597 | [
"s767456531",
"s764640811"
] |
u855694108 | p02389 | python | s084617491 | s946804543 | 60 | 20 | 7,696 | 5,584 | Accepted | Accepted | 66.67 | def main():
a, b = list(map(int, input().split()))
print((a * b, 2 * (a + b)))
if __name__ == "__main__":
main() | a,b=list(map(int,input().split()))
print((a*b, (a+b)*2))
| 6 | 2 | 122 | 50 | def main():
a, b = list(map(int, input().split()))
print((a * b, 2 * (a + b)))
if __name__ == "__main__":
main()
| a, b = list(map(int, input().split()))
print((a * b, (a + b) * 2))
| false | 66.666667 | [
"-def main():",
"- a, b = list(map(int, input().split()))",
"- print((a * b, 2 * (a + b)))",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+a, b = list(map(int, input().split()))",
"+print((a * b, (a + b) * 2))"
] | false | 0.035055 | 0.040374 | 0.868254 | [
"s084617491",
"s946804543"
] |
u583455650 | p02756 | python | s025158656 | s808805734 | 833 | 424 | 119,896 | 44,660 | Accepted | Accepted | 49.1 | from collections import deque
S = deque(eval(input()))
Q = int(eval(input()))
query = [input().split() for _ in range(Q)]
reverse = False
for q in query:
if q[0] == '1':
reverse = not reverse
else:
if q[1] == '1':
if not reverse:
S.appendleft(q[2])
... | from collections import deque
S = deque(eval(input()))
Q = int(eval(input()))
query = [input().split() for _ in range(Q)]
reverse = False
for q in query:
if q[0] == '1':
reverse = not reverse
else:
if q[1] == '1':
S.append(q[2]) if reverse else S.appendleft(q[2])
e... | 22 | 16 | 531 | 424 | from collections import deque
S = deque(eval(input()))
Q = int(eval(input()))
query = [input().split() for _ in range(Q)]
reverse = False
for q in query:
if q[0] == "1":
reverse = not reverse
else:
if q[1] == "1":
if not reverse:
S.appendleft(q[2])
else:
... | from collections import deque
S = deque(eval(input()))
Q = int(eval(input()))
query = [input().split() for _ in range(Q)]
reverse = False
for q in query:
if q[0] == "1":
reverse = not reverse
else:
if q[1] == "1":
S.append(q[2]) if reverse else S.appendleft(q[2])
else:
... | false | 27.272727 | [
"- if not reverse:",
"- S.appendleft(q[2])",
"- else:",
"- S.append(q[2])",
"+ S.append(q[2]) if reverse else S.appendleft(q[2])",
"- if not reverse:",
"- S.append(q[2])",
"- else:",
"- ... | false | 0.039686 | 0.03993 | 0.993884 | [
"s025158656",
"s808805734"
] |
u394721319 | p03163 | python | s437218338 | s077549573 | 672 | 323 | 171,656 | 20,656 | Accepted | Accepted | 51.93 | n,k = [int(i) for i in input().split()]
w = []
v = []
for _ in range(n):
a,b = [int(i) for i in input().split()]
w.append(a)
v.append(b)
dp = [[0 for _ in range(k+1)] for _ in range(n+1)]
for i in range(n):
for j in range(k+1):
if j >= w[i]:
dp[i+1][j] = max(dp[i][j-w[... | import numpy as np
n,w = list(map(int, input().split()))
items = list(list(map(int, input().split())) for _ in [0]*n)
dp = np.zeros(w+1, dtype='int64')
for weight, value in items:
dp[weight:] = np.maximum(dp[weight:], dp[:w-weight+1] + value)
print((dp.max()))
| 17 | 9 | 409 | 261 | n, k = [int(i) for i in input().split()]
w = []
v = []
for _ in range(n):
a, b = [int(i) for i in input().split()]
w.append(a)
v.append(b)
dp = [[0 for _ in range(k + 1)] for _ in range(n + 1)]
for i in range(n):
for j in range(k + 1):
if j >= w[i]:
dp[i + 1][j] = max(dp[i][j - w[i]]... | import numpy as np
n, w = list(map(int, input().split()))
items = list(list(map(int, input().split())) for _ in [0] * n)
dp = np.zeros(w + 1, dtype="int64")
for weight, value in items:
dp[weight:] = np.maximum(dp[weight:], dp[: w - weight + 1] + value)
print((dp.max()))
| false | 47.058824 | [
"-n, k = [int(i) for i in input().split()]",
"-w = []",
"-v = []",
"-for _ in range(n):",
"- a, b = [int(i) for i in input().split()]",
"- w.append(a)",
"- v.append(b)",
"-dp = [[0 for _ in range(k + 1)] for _ in range(n + 1)]",
"-for i in range(n):",
"- for j in range(k + 1):",
"- ... | false | 0.057023 | 0.328911 | 0.173369 | [
"s437218338",
"s077549573"
] |
u991567869 | p02784 | python | s357580330 | s793576363 | 57 | 43 | 13,964 | 13,964 | Accepted | Accepted | 24.56 | h, n = list(map(int, input().split()))
a = list(map(int, input().split()))
at = 0
for i in range(n):
at = at + a[i]
if at >= h:
print("Yes")
else:
print("No") | h, n = list(map(int, input().split()))
a = list(map(int, input().split()))
at = sum(a)
if at >= h:
print("Yes")
else:
print("No") | 12 | 8 | 178 | 139 | h, n = list(map(int, input().split()))
a = list(map(int, input().split()))
at = 0
for i in range(n):
at = at + a[i]
if at >= h:
print("Yes")
else:
print("No")
| h, n = list(map(int, input().split()))
a = list(map(int, input().split()))
at = sum(a)
if at >= h:
print("Yes")
else:
print("No")
| false | 33.333333 | [
"-at = 0",
"-for i in range(n):",
"- at = at + a[i]",
"+at = sum(a)"
] | false | 0.036578 | 0.042531 | 0.860032 | [
"s357580330",
"s793576363"
] |
u745087332 | p03291 | python | s145631915 | s557421710 | 528 | 259 | 27,608 | 27,636 | Accepted | Accepted | 50.95 | # coding:utf-8
import sys
input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7
def inpl(): return list(map(int, input().split()))
S = input().rstrip()
dp = [[0] * 4 for _ in range(len(S) + 1)]
dp[0][0] = 1
# print(' ', dp[0][:])
for i in range(len(S)):
# ABCカウントを更新しない
for ... | # coding:utf-8
import sys
input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7
def inpl(): return list(map(int, input().split()))
S = input().rstrip()
dp = [[0] * 4 for _ in range(len(S) + 1)]
dp[0][0] = 1
for i in range(len(S)):
if S[i] == '?':
dp[i + 1][0] = (dp[i][0]... | 39 | 35 | 781 | 854 | # coding:utf-8
import sys
input = sys.stdin.readline
INF = float("inf")
MOD = 10**9 + 7
def inpl():
return list(map(int, input().split()))
S = input().rstrip()
dp = [[0] * 4 for _ in range(len(S) + 1)]
dp[0][0] = 1
# print(' ', dp[0][:])
for i in range(len(S)):
# ABCカウントを更新しない
for j in range(4):
... | # coding:utf-8
import sys
input = sys.stdin.readline
INF = float("inf")
MOD = 10**9 + 7
def inpl():
return list(map(int, input().split()))
S = input().rstrip()
dp = [[0] * 4 for _ in range(len(S) + 1)]
dp[0][0] = 1
for i in range(len(S)):
if S[i] == "?":
dp[i + 1][0] = (dp[i][0] * 3) % MOD
... | false | 10.25641 | [
"-# print(' ', dp[0][:])",
"- # ABCカウントを更新しない",
"- for j in range(4):",
"- if S[i] != \"?\":",
"- dp[i + 1][j] += dp[i][j]",
"- else:",
"- dp[i + 1][j] += dp[i][j] * 3",
"- dp[i + 1][j] %= MOD",
"- # ABCカウントを更新する",
"- if S[i] in (\"A\", \"?\")... | false | 0.038752 | 0.088672 | 0.43703 | [
"s145631915",
"s557421710"
] |
u114954806 | p02923 | python | s635491807 | s478380139 | 108 | 99 | 14,528 | 14,528 | Accepted | Accepted | 8.33 | from itertools import groupby
N=int(eval(input()))
H=list(map(int,input().split()))
New=[]
_max=0
for _ in range(N-1):
if H[_]>=H[_+1]:
New.append(1)
else:
New.append(0)
for k,h in groupby(New):
_sum=sum(list(h))
if k==1 and _sum>_max:
_max=_sum
print(_max)
| from itertools import groupby
N=int(eval(input()))
H=list(map(int,input().split()))
New=[1 if H[_]>=H[_+1] else 0 for _ in range(N-1)]
_max=0
for k,h in groupby(New):
_sum=sum(list(h))
if k==1 and _sum>_max:
_max=_sum
print(_max)
| 16 | 11 | 308 | 251 | from itertools import groupby
N = int(eval(input()))
H = list(map(int, input().split()))
New = []
_max = 0
for _ in range(N - 1):
if H[_] >= H[_ + 1]:
New.append(1)
else:
New.append(0)
for k, h in groupby(New):
_sum = sum(list(h))
if k == 1 and _sum > _max:
_max = _sum
print(_ma... | from itertools import groupby
N = int(eval(input()))
H = list(map(int, input().split()))
New = [1 if H[_] >= H[_ + 1] else 0 for _ in range(N - 1)]
_max = 0
for k, h in groupby(New):
_sum = sum(list(h))
if k == 1 and _sum > _max:
_max = _sum
print(_max)
| false | 31.25 | [
"-New = []",
"+New = [1 if H[_] >= H[_ + 1] else 0 for _ in range(N - 1)]",
"-for _ in range(N - 1):",
"- if H[_] >= H[_ + 1]:",
"- New.append(1)",
"- else:",
"- New.append(0)"
] | false | 0.041253 | 0.048317 | 0.853807 | [
"s635491807",
"s478380139"
] |
u391731808 | p03049 | python | s030814285 | s274218007 | 312 | 34 | 46,168 | 3,700 | Accepted | Accepted | 89.1 | N = int(eval(input()))
s = [eval(input()) for _ in [0]*N]
ni = [0]*N
for i,si in enumerate(s):
for j,c in enumerate(si[:-1]):
if c == "A" and si[j+1] == "B":
ni[i] += 1
cntA,cntB,cntAB = 0,0,0
for si in s:
if si[0]=="B" and si[-1]=="A":
cntAB += 1
elif si[0]=="B":
... | N = int(eval(input()))
S = [eval(input()) for _ in [0]*N]
ans = 0
BA = 0
BX = 0
XA = 0
for s in S:
ans += s.count("AB")
if s[0]=="B" and s[-1]=="A":BA+=1
elif s[0]=="B":BX+=1
elif s[-1]=="A":XA+=1
ans += min(BX,XA) + max(0,BA - (BX==XA==0))
print(ans) | 17 | 14 | 447 | 269 | N = int(eval(input()))
s = [eval(input()) for _ in [0] * N]
ni = [0] * N
for i, si in enumerate(s):
for j, c in enumerate(si[:-1]):
if c == "A" and si[j + 1] == "B":
ni[i] += 1
cntA, cntB, cntAB = 0, 0, 0
for si in s:
if si[0] == "B" and si[-1] == "A":
cntAB += 1
elif si[0] == "B... | N = int(eval(input()))
S = [eval(input()) for _ in [0] * N]
ans = 0
BA = 0
BX = 0
XA = 0
for s in S:
ans += s.count("AB")
if s[0] == "B" and s[-1] == "A":
BA += 1
elif s[0] == "B":
BX += 1
elif s[-1] == "A":
XA += 1
ans += min(BX, XA) + max(0, BA - (BX == XA == 0))
print(ans)
| false | 17.647059 | [
"-s = [eval(input()) for _ in [0] * N]",
"-ni = [0] * N",
"-for i, si in enumerate(s):",
"- for j, c in enumerate(si[:-1]):",
"- if c == \"A\" and si[j + 1] == \"B\":",
"- ni[i] += 1",
"-cntA, cntB, cntAB = 0, 0, 0",
"-for si in s:",
"- if si[0] == \"B\" and si[-1] == \"A\":"... | false | 0.124701 | 0.048521 | 2.570016 | [
"s030814285",
"s274218007"
] |
u780962115 | p03291 | python | s824749890 | s760534985 | 358 | 191 | 40,364 | 21,372 | Accepted | Accepted | 46.65 | #we love abc
s=eval(input())
mod=10**9+7
dpa=[[0,0] for i in range(len(s)+1)]
dpc=[[0,0] for i in range(len(s)+1)]
power3=[1 for i in range(10**5+100)]
for i in range(10**5+3):
power3[i+1]=(power3[i]*3)%mod
for i in range(len(s)):
if s[i]=="A":
dpa[i+1][0]=(dpa[i][0]+power3[dpa[i][1]])%mod
... | S = list(eval(input()))
n = len(S)
mod = 10**9 + 7
dpa = [0]*(10**5+10)
dpc = [0]*(10**5+10)
hatena_count = 0
pow3 = [1]*(10**5+10)
for i in range(1, 10**5+10):
pow3[i] = pow3[i-1]*3 % mod
for i in range(n):
if S[i] == "A":
dpa[i+1] = (dpa[i] + pow3[hatena_count]) % mod
elif S[i]... | 32 | 42 | 941 | 868 | # we love abc
s = eval(input())
mod = 10**9 + 7
dpa = [[0, 0] for i in range(len(s) + 1)]
dpc = [[0, 0] for i in range(len(s) + 1)]
power3 = [1 for i in range(10**5 + 100)]
for i in range(10**5 + 3):
power3[i + 1] = (power3[i] * 3) % mod
for i in range(len(s)):
if s[i] == "A":
dpa[i + 1][0] = (dpa[i][0]... | S = list(eval(input()))
n = len(S)
mod = 10**9 + 7
dpa = [0] * (10**5 + 10)
dpc = [0] * (10**5 + 10)
hatena_count = 0
pow3 = [1] * (10**5 + 10)
for i in range(1, 10**5 + 10):
pow3[i] = pow3[i - 1] * 3 % mod
for i in range(n):
if S[i] == "A":
dpa[i + 1] = (dpa[i] + pow3[hatena_count]) % mod
elif S[i]... | false | 23.809524 | [
"-# we love abc",
"-s = eval(input())",
"+S = list(eval(input()))",
"+n = len(S)",
"-dpa = [[0, 0] for i in range(len(s) + 1)]",
"-dpc = [[0, 0] for i in range(len(s) + 1)]",
"-power3 = [1 for i in range(10**5 + 100)]",
"-for i in range(10**5 + 3):",
"- power3[i + 1] = (power3[i] * 3) % mod",
"... | false | 0.042577 | 0.060939 | 0.698685 | [
"s824749890",
"s760534985"
] |
u644907318 | p03588 | python | s268606914 | s659254635 | 725 | 325 | 65,372 | 95,036 | Accepted | Accepted | 55.17 | N = int(eval(input()))
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
a = A[-1][0]
b = A[-1][1]
print((a+b)) | N = int(eval(input()))
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
a,b = A[-1]
print((a+b)) | 5 | 4 | 138 | 123 | N = int(eval(input()))
A = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])
a = A[-1][0]
b = A[-1][1]
print((a + b))
| N = int(eval(input()))
A = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])
a, b = A[-1]
print((a + b))
| false | 20 | [
"-a = A[-1][0]",
"-b = A[-1][1]",
"+a, b = A[-1]"
] | false | 0.034614 | 0.040837 | 0.847616 | [
"s268606914",
"s659254635"
] |
u600402037 | p02851 | python | s786658234 | s089239333 | 405 | 364 | 39,640 | 43,364 | Accepted | Accepted | 10.12 | import sys
import numpy as np
from collections import defaultdict
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
A = np.array([0] + lr())
A = (A-1) % K
Acum = A.cumsum() % K
counter = defaultdict(int)
answer = 0
for i, x in enumera... | import sys
import numpy as np
from collections import defaultdict
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
A = np.array([1] + lr())
A = (A-1) % K
N += 1
# 累積和が同じになっている箇所に注目、要素がK-1離れている組み合わせは無理
Acum = (A.cumsum() % K).tolist()
... | 21 | 25 | 449 | 530 | import sys
import numpy as np
from collections import defaultdict
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
A = np.array([0] + lr())
A = (A - 1) % K
Acum = A.cumsum() % K
counter = defaultdict(int)
answer = 0
for i, x in enumerate(Acum):
... | import sys
import numpy as np
from collections import defaultdict
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
A = np.array([1] + lr())
A = (A - 1) % K
N += 1
# 累積和が同じになっている箇所に注目、要素がK-1離れている組み合わせは無理
Acum = (A.cumsum() % K).tolist()
answer = 0
d... | false | 16 | [
"-A = np.array([0] + lr())",
"+A = np.array([1] + lr())",
"-Acum = A.cumsum() % K",
"-counter = defaultdict(int)",
"+N += 1",
"+# 累積和が同じになっている箇所に注目、要素がK-1離れている組み合わせは無理",
"+Acum = (A.cumsum() % K).tolist()",
"-for i, x in enumerate(Acum):",
"- answer += counter[x]",
"- counter[x] += 1",
"+d... | false | 0.221521 | 0.183425 | 1.20769 | [
"s786658234",
"s089239333"
] |
u440551778 | p03290 | python | s545919269 | s269014165 | 27 | 20 | 3,064 | 3,064 | Accepted | Accepted | 25.93 | d, g = list(map(int, input().split()))
pc = [tuple(map(int, input().split())) for i in range(d)]
ans = float('inf')
for i in range(2**d):
sum = 0
cnt = 0
nokori = set(range(1, d+1))
for j in range(d):
bitchk = 2**j
if i & bitchk:
sum += pc[j][0]*100*(j+1) + pc[j... | d, g = list(map(int, input().split()))
pc = [tuple(map(int, input().split())) for i in range(d)]
nokori = set(range(1, d+1))
def dfs(i, sum, nokori, cnt):
global ans
if i == d:
if sum < g:
use = max(nokori)
n = min(pc[use-1][0], -(-(g-sum)//(use*100)))
... | 31 | 28 | 865 | 621 | d, g = list(map(int, input().split()))
pc = [tuple(map(int, input().split())) for i in range(d)]
ans = float("inf")
for i in range(2**d):
sum = 0
cnt = 0
nokori = set(range(1, d + 1))
for j in range(d):
bitchk = 2**j
if i & bitchk:
sum += pc[j][0] * 100 * (j + 1) + pc[j][1]
... | d, g = list(map(int, input().split()))
pc = [tuple(map(int, input().split())) for i in range(d)]
nokori = set(range(1, d + 1))
def dfs(i, sum, nokori, cnt):
global ans
if i == d:
if sum < g:
use = max(nokori)
n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
cnt... | false | 9.677419 | [
"+nokori = set(range(1, d + 1))",
"+",
"+",
"+def dfs(i, sum, nokori, cnt):",
"+ global ans",
"+ if i == d:",
"+ if sum < g:",
"+ use = max(nokori)",
"+ n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))",
"+ cnt += n",
"+ sum += n * us... | false | 0.04396 | 0.040591 | 1.082995 | [
"s545919269",
"s269014165"
] |
u896451538 | p02765 | python | s853640030 | s518386546 | 45 | 17 | 5,328 | 2,940 | Accepted | Accepted | 62.22 | import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy
sys.setrecursionlimit(10**9)
mod = 10**7+9
inf = 10**20
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlin... | n,r = list(map(int,input().split()))
if n>=10:
print(r)
else:
t = 100*(10-n)
print((r+t)) | 27 | 7 | 692 | 106 | import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy
sys.setrecursionlimit(10**9)
mod = 10**7 + 9
inf = 10**20
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI():
return [list(map(int, l.split())) for l in sys.stdin.readline... | n, r = list(map(int, input().split()))
if n >= 10:
print(r)
else:
t = 100 * (10 - n)
print((r + t))
| false | 74.074074 | [
"-import math",
"-import itertools",
"-import fractions",
"-import heapq",
"-import collections",
"-import bisect",
"-import sys",
"-import copy",
"-",
"-sys.setrecursionlimit(10**9)",
"-mod = 10**7 + 9",
"-inf = 10**20",
"-",
"-",
"-def LI():",
"- return list(map(int, sys.stdin.rea... | false | 0.094668 | 0.034849 | 2.716524 | [
"s853640030",
"s518386546"
] |
u891635666 | p02999 | python | s481182366 | s436345331 | 182 | 17 | 38,256 | 3,064 | Accepted | Accepted | 90.66 | x, a = list(map(int, input().split()))
if x < a:
print((0))
else:
print((10)) | import sys
input = sys.stdin.readline
ri = lambda: int(eval(input()))
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)... | 5 | 15 | 79 | 402 | x, a = list(map(int, input().split()))
if x < a:
print((0))
else:
print((10))
| import sys
input = sys.stdin.readline
ri = lambda: int(eval(input()))
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = la... | false | 66.666667 | [
"-x, a = list(map(int, input().split()))",
"-if x < a:",
"- print((0))",
"-else:",
"- print((10))",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+ri = lambda: int(eval(input()))",
"+rs = lambda: input().rstrip()",
"+ril = lambda: list(map(int, input().split()))",
"+rsl = lambda: i... | false | 0.036568 | 0.031314 | 1.167809 | [
"s481182366",
"s436345331"
] |
u489959379 | p02901 | python | s336273757 | s958087866 | 1,600 | 1,410 | 3,296 | 3,316 | Accepted | Accepted | 11.88 | import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n, m = list(map(int, input().split()))
ABC = []
for _ in range(m):
a, b = list(map(int, input().split()))
C = list(map(int, input().split()))
s = ["0"] * n
for c i... | import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n, m = list(map(int, input().split()))
ABC = []
for _ in range(m):
a, b = list(map(int, input().split()))
C = list(map(int, input().split()))
bit = ["0"] * n
for c... | 35 | 35 | 727 | 731 | import sys
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n, m = list(map(int, input().split()))
ABC = []
for _ in range(m):
a, b = list(map(int, input().split()))
C = list(map(int, input().split()))
s = ["0"] * n
for c in C:
s... | import sys
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n, m = list(map(int, input().split()))
ABC = []
for _ in range(m):
a, b = list(map(int, input().split()))
C = list(map(int, input().split()))
bit = ["0"] * n
for c in C:
... | false | 0 | [
"- s = [\"0\"] * n",
"+ bit = [\"0\"] * n",
"- s[c - 1] = \"1\"",
"- c = \"\".join(s[::-1])",
"- ABC.append([a, b, int(c, 2)])",
"+ bit[c - 1] = \"1\"",
"+ bit = \"\".join(bit)",
"+ ABC.append([a, b, int(bit, 2)])",
"- for a, b, c in... | false | 0.037985 | 0.036485 | 1.041113 | [
"s336273757",
"s958087866"
] |
u724687935 | p02820 | python | s946298215 | s426537752 | 287 | 196 | 58,604 | 47,084 | Accepted | Accepted | 31.71 | N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split())) # R=0, S=1, P=2
T = eval(input())
_score = {'r': P, 's': R, 'p': S}
s = [P, R, S]
hand = {'r': 0, 's': 1, 'p': 2}
H = [' '] * N
dp = [[0] * 3 for _ in range(N + 1)]
for sub in range(1, K + 1):
i = sub
while i <= N:
... | N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
score = {'r': R, 's': S, 'p': P}
T = eval(input())
hand = {'r': 'p', 's': 'r', 'p': 's'}
history = []
cnt = 0
for i, t in enumerate(T):
if i < K:
u = hand[t]
flag = 1
elif K <= i < N - K:
l = i... | 24 | 33 | 588 | 700 | N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split())) # R=0, S=1, P=2
T = eval(input())
_score = {"r": P, "s": R, "p": S}
s = [P, R, S]
hand = {"r": 0, "s": 1, "p": 2}
H = [" "] * N
dp = [[0] * 3 for _ in range(N + 1)]
for sub in range(1, K + 1):
i = sub
while i <= N:
h = han... | N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
score = {"r": R, "s": S, "p": P}
T = eval(input())
hand = {"r": "p", "s": "r", "p": "s"}
history = []
cnt = 0
for i, t in enumerate(T):
if i < K:
u = hand[t]
flag = 1
elif K <= i < N - K:
l = i - K
r... | false | 27.272727 | [
"-R, S, P = list(map(int, input().split())) # R=0, S=1, P=2",
"+R, S, P = list(map(int, input().split()))",
"+score = {\"r\": R, \"s\": S, \"p\": P}",
"-_score = {\"r\": P, \"s\": R, \"p\": S}",
"-s = [P, R, S]",
"-hand = {\"r\": 0, \"s\": 1, \"p\": 2}",
"-H = [\" \"] * N",
"-dp = [[0] * 3 for _ in r... | false | 0.048533 | 0.074024 | 0.655638 | [
"s946298215",
"s426537752"
] |
u506858457 | p02850 | python | s909539664 | s925588443 | 714 | 416 | 48,004 | 65,696 | Accepted | Accepted | 41.74 | from collections import deque
n = int(eval(input()))
adj = [[] for i in range(n)]
for i in range(n-1):
a,b = list(map(int,input().split()))
adj[a-1].append([b-1,i])
adj[b-1].append([a-1,i])
mx_color = 0
for i in range(n):
mx_color = max(mx_color,len(adj[i]))
dist = [-1]*n
res = ... | import sys
n = int(eval(input()))
links = [set() for _ in range(n)]
for i, line in enumerate(sys.stdin):
a, b = list(map(int, line.split()))
a -= 1
b -= 1
links[a].add((i, b))
links[b].add((i, a))
ans = [-1] * (n - 1)
k = max(list(map(len, links)))
q = [(0, -1)]
fixed = set()
w... | 42 | 32 | 765 | 627 | from collections import deque
n = int(eval(input()))
adj = [[] for i in range(n)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
adj[a - 1].append([b - 1, i])
adj[b - 1].append([a - 1, i])
mx_color = 0
for i in range(n):
mx_color = max(mx_color, len(adj[i]))
dist = [-1] * n
res = [-1] * ... | import sys
n = int(eval(input()))
links = [set() for _ in range(n)]
for i, line in enumerate(sys.stdin):
a, b = list(map(int, line.split()))
a -= 1
b -= 1
links[a].add((i, b))
links[b].add((i, a))
ans = [-1] * (n - 1)
k = max(list(map(len, links)))
q = [(0, -1)]
fixed = set()
while q:
v, c = q.... | false | 23.809524 | [
"-from collections import deque",
"+import sys",
"-adj = [[] for i in range(n)]",
"-for i in range(n - 1):",
"- a, b = list(map(int, input().split()))",
"- adj[a - 1].append([b - 1, i])",
"- adj[b - 1].append([a - 1, i])",
"-mx_color = 0",
"-for i in range(n):",
"- mx_color = max(mx_co... | false | 0.082087 | 0.114561 | 0.716535 | [
"s909539664",
"s925588443"
] |
u318127926 | p02540 | python | s056175891 | s462766830 | 748 | 650 | 38,820 | 37,320 | Accepted | Accepted | 13.1 | n = int(input())
xy = []
idx = [None]*n
ys = [None]*n
ans = [None]*n
accumx = [None]*n
accumn = [None]*n
for i in range(n):
x, y = map(int, input().split())
idx[x-1] = i
ys[x-1] = y-1
accumx[-1] = ys[-1]
for i in range(n-2, -1, -1):
accumx[i] = max(accumx[i+1], ys[i])
accumn[0] = ys[0]
fo... | n = int(input())
xy = []
idx = [None]*n
ys = [None]*n
ans = [None]*n
accumn = [None]*n
for i in range(n):
x, y = map(int, input().split())
idx[x-1] = i
ys[x-1] = y-1
accumn[0] = ys[0]
for i in range(1, n):
accumn[i] = min(accumn[i-1], ys[i])
b = 0
for i in range(n):
if accumn[i]==n-... | 42 | 21 | 877 | 430 | n = int(input())
xy = []
idx = [None] * n
ys = [None] * n
ans = [None] * n
accumx = [None] * n
accumn = [None] * n
for i in range(n):
x, y = map(int, input().split())
idx[x - 1] = i
ys[x - 1] = y - 1
accumx[-1] = ys[-1]
for i in range(n - 2, -1, -1):
accumx[i] = max(accumx[i + 1], ys[i])
accumn[0] = ys[... | n = int(input())
xy = []
idx = [None] * n
ys = [None] * n
ans = [None] * n
accumn = [None] * n
for i in range(n):
x, y = map(int, input().split())
idx[x - 1] = i
ys[x - 1] = y - 1
accumn[0] = ys[0]
for i in range(1, n):
accumn[i] = min(accumn[i - 1], ys[i])
b = 0
for i in range(n):
if accumn[i] == n... | false | 50 | [
"-accumx = [None] * n",
"-accumx[-1] = ys[-1]",
"-for i in range(n - 2, -1, -1):",
"- accumx[i] = max(accumx[i + 1], ys[i])",
"-",
"-",
"-def bisect(x):",
"- ok = 0",
"- ng = n",
"- while abs(ok - ng) > 1:",
"- mid = (ok + ng) // 2",
"- if accumx[mid] > x:",
"- ... | false | 0.047818 | 0.047174 | 1.013648 | [
"s056175891",
"s462766830"
] |
u588341295 | p03074 | python | s649080949 | s679173682 | 147 | 118 | 4,724 | 4,724 | Accepted | Accepted | 19.73 | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): r... | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in ... | 67 | 60 | 1,340 | 1,331 | # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(eval(inp... | # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in rang... | false | 10.447761 | [
"+def list4d(a, b, c, d, e):",
"+ return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]",
"+",
"+",
"-def LIST():",
"- return list(map(int, input().split()))",
"+def LIST(N=None):",
"+ return list(MAP()) if N is None else [INT() for i in range(N)]",
"-INF = float(\"inf\... | false | 0.090495 | 0.038237 | 2.366705 | [
"s649080949",
"s679173682"
] |
u325282913 | p03329 | python | s054429657 | s920607476 | 625 | 102 | 89,716 | 74,772 | Accepted | Accepted | 83.68 | import sys
sys.setrecursionlimit(10**7)
N = int(eval(input()))
memo = [-1]*(N+1)
def rec(n):
if n == 0:
return 0
if memo[n] != -1:
return memo[n]
res = n
m = 1
while m <= n:
res = min(res,rec(n-m)+1)
m *= 6
m = 1
while m <= n:
res = min... | N = int(eval(input()))
dp = [float('inf')]*(N+1)
dp[0] = 0
for i in range(N+1):
if i+1 <= N:
dp[i+1] = min(dp[i+1],dp[i]+1)
for j in range(1,N+1):
if i + 6**j > N:
break
dp[i+6**j] = min(dp[i+6**j],dp[i]+1)
for k in range(1,N+1):
if i + 9**k > N:
... | 22 | 15 | 402 | 386 | import sys
sys.setrecursionlimit(10**7)
N = int(eval(input()))
memo = [-1] * (N + 1)
def rec(n):
if n == 0:
return 0
if memo[n] != -1:
return memo[n]
res = n
m = 1
while m <= n:
res = min(res, rec(n - m) + 1)
m *= 6
m = 1
while m <= n:
res = min(res... | N = int(eval(input()))
dp = [float("inf")] * (N + 1)
dp[0] = 0
for i in range(N + 1):
if i + 1 <= N:
dp[i + 1] = min(dp[i + 1], dp[i] + 1)
for j in range(1, N + 1):
if i + 6**j > N:
break
dp[i + 6**j] = min(dp[i + 6**j], dp[i] + 1)
for k in range(1, N + 1):
if i +... | false | 31.818182 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**7)",
"-memo = [-1] * (N + 1)",
"-",
"-",
"-def rec(n):",
"- if n == 0:",
"- return 0",
"- if memo[n] != -1:",
"- return memo[n]",
"- res = n",
"- m = 1",
"- while m <= n:",
"- res = min(res, rec(n - m) + ... | false | 0.190281 | 0.746447 | 0.254915 | [
"s054429657",
"s920607476"
] |
u712429027 | p03497 | python | s511496160 | s815119113 | 209 | 190 | 49,752 | 49,640 | Accepted | Accepted | 9.09 | import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))
n, k = inm()
a = inl()
if len(set(a)) <= 2:
print(0)
else:
b ... | import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))
n, k = inm()
a = inl()
if len(set(a)) <= 2:
print(0)
else:
b ... | 23 | 20 | 542 | 515 | import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print("\n".join(map(str, x)))
n, k = inm()
a = inl()
if len(set(a)) <= 2:
print(0)
else:
b = {}
for ... | import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print("\n".join(map(str, x)))
n, k = inm()
a = inl()
if len(set(a)) <= 2:
print(0)
else:
b = {}
for ... | false | 13.043478 | [
"- b = sorted(b.items(), key=lambda x: x[1])",
"- ans = 0",
"- for i in range(len(set(a)) - k):",
"- ans += b[i][1]",
"- print(ans)",
"+ b = list(map(lambda x: x[1], sorted(b.items(), key=lambda x: x[1])))",
"+ print(sum(b[: len(set(a)) - k]))"
] | false | 0.034366 | 0.0391 | 0.878934 | [
"s511496160",
"s815119113"
] |
u989345508 | p02928 | python | s118424902 | s180893267 | 1,102 | 361 | 3,444 | 79,280 | Accepted | Accepted | 67.24 | n,k=input().split()
n,k=int(n),int(k)
a1=[int(i) for i in input().split()]
b1=[]
for i in range(len(a1)):
b1.append([sum(x>a1[i] for x in a1[:i]),0])
#print(b1)
l=len(a1)
a1.extend(a1)
#print(a1)
for i in range(l):
#print(i)
b1[i][1]=sum(x>a1[i+l] for x in a1[:i+l])
c=0
for i in range(len(... | from bisect import bisect_right
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=sorted(a)
mod=10**9+7
ans=0
for i in range(n):
for j in range(n):
if i<j and a[i]>a[j]:
ans+=1
ans*=k
#print(ans)
ans%=mod
r=0
for i in range(n):
r+=(n-bisect_right(b,b[i]))
... | 22 | 19 | 432 | 355 | n, k = input().split()
n, k = int(n), int(k)
a1 = [int(i) for i in input().split()]
b1 = []
for i in range(len(a1)):
b1.append([sum(x > a1[i] for x in a1[:i]), 0])
# print(b1)
l = len(a1)
a1.extend(a1)
# print(a1)
for i in range(l):
# print(i)
b1[i][1] = sum(x > a1[i + l] for x in a1[: i + l])
c = 0
for i i... | from bisect import bisect_right
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = sorted(a)
mod = 10**9 + 7
ans = 0
for i in range(n):
for j in range(n):
if i < j and a[i] > a[j]:
ans += 1
ans *= k
# print(ans)
ans %= mod
r = 0
for i in range(n):
r += n - bisect... | false | 13.636364 | [
"-n, k = input().split()",
"-n, k = int(n), int(k)",
"-a1 = [int(i) for i in input().split()]",
"-b1 = []",
"-for i in range(len(a1)):",
"- b1.append([sum(x > a1[i] for x in a1[:i]), 0])",
"-# print(b1)",
"-l = len(a1)",
"-a1.extend(a1)",
"-# print(a1)",
"-for i in range(l):",
"- # print... | false | 0.053454 | 0.033508 | 1.595273 | [
"s118424902",
"s180893267"
] |
u285891772 | p03069 | python | s139744584 | s145871863 | 185 | 129 | 23,092 | 14,732 | Accepted | Accepted | 30.27 | 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... | 44 | 37 | 1,205 | 1,162 | 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 | 15.909091 | [
"-S = eval(input())",
"-b = [0] * (N + 1)",
"-w = [0] * (N + 1)",
"-tmp_b = 0",
"-for i in range(N):",
"+S = list(eval(input()))",
"+tmp = S.count(\"#\")",
"+tmp2 = len(S) - tmp",
"+num = [0] * N",
"+num_sharp = 0",
"+num_peri = 0",
"+for i in range(len(S)):",
"- tmp_b += 1",
"- ... | false | 0.06345 | 0.037259 | 1.702945 | [
"s139744584",
"s145871863"
] |
u270144704 | p02726 | python | s530679876 | s394987617 | 503 | 425 | 48,476 | 47,196 | Accepted | Accepted | 15.51 | from collections import deque
# import sys
# input = sys.stdin.readline
n, x, y = list(map(int, input().split()))
g = dict()
for i in range(n):
if i == 0:
g[i] = [i+1]
elif i == n-1:
g[i] = [i-1]
else:
g[i] = [i-1, i+1]
g[x-1].append(y-1)
g[y-1].append(x-1)
# print(g)
... | from collections import deque
def main():
n, x, y = list(map(int, input().split()))
g = dict()
for i in range(n):
if i == 0:
g[i] = [i+1]
elif i == n-1:
g[i] = [i-1]
else:
g[i] = [i-1, i+1]
g[x-1].append(y-1)
g[y-1].append(x-1)
... | 35 | 36 | 937 | 1,036 | from collections import deque
# import sys
# input = sys.stdin.readline
n, x, y = list(map(int, input().split()))
g = dict()
for i in range(n):
if i == 0:
g[i] = [i + 1]
elif i == n - 1:
g[i] = [i - 1]
else:
g[i] = [i - 1, i + 1]
g[x - 1].append(y - 1)
g[y - 1].append(x - 1)
# print... | from collections import deque
def main():
n, x, y = list(map(int, input().split()))
g = dict()
for i in range(n):
if i == 0:
g[i] = [i + 1]
elif i == n - 1:
g[i] = [i - 1]
else:
g[i] = [i - 1, i + 1]
g[x - 1].append(y - 1)
g[y - 1].append... | false | 2.777778 | [
"-# import sys",
"-# input = sys.stdin.readline",
"-n, x, y = list(map(int, input().split()))",
"-g = dict()",
"-for i in range(n):",
"- if i == 0:",
"- g[i] = [i + 1]",
"- elif i == n - 1:",
"- g[i] = [i - 1]",
"- else:",
"- g[i] = [i - 1, i + 1]",
"-g[x - 1].app... | false | 0.007411 | 0.036132 | 0.205113 | [
"s530679876",
"s394987617"
] |
u889564559 | p03456 | python | s708168853 | s724388991 | 147 | 17 | 12,504 | 2,940 | Accepted | Accepted | 88.44 | import numpy as np
a, b = list(map(str,input().split()))
target = int(a + b)
target_full = np.sqrt(target)
target_resid = target_full % 1
if target_resid == 0:
print("Yes")
else:
print("No")
| a, b = list(map(str,input().split()))
target = int(a + b)
if (target ** 0.5).is_integer():
print("Yes")
else:
print("No")
| 13 | 8 | 206 | 130 | import numpy as np
a, b = list(map(str, input().split()))
target = int(a + b)
target_full = np.sqrt(target)
target_resid = target_full % 1
if target_resid == 0:
print("Yes")
else:
print("No")
| a, b = list(map(str, input().split()))
target = int(a + b)
if (target**0.5).is_integer():
print("Yes")
else:
print("No")
| false | 38.461538 | [
"-import numpy as np",
"-",
"-target_full = np.sqrt(target)",
"-target_resid = target_full % 1",
"-if target_resid == 0:",
"+if (target**0.5).is_integer():"
] | false | 0.166673 | 0.036508 | 4.565393 | [
"s708168853",
"s724388991"
] |
u403984573 | p03137 | python | s094586966 | s305616159 | 146 | 119 | 13,832 | 13,840 | Accepted | Accepted | 18.49 | N,M=list(map(int,input().split()))
X=[int(i) for i in input().split()]
X.sort()
count=[]
sum=0
if N<M:
for i in range(M):
if i != 0:
count.append(X[i]-get)
sum+=count[i-1]
get=X[i]
count.sort(reverse=True)
for i in range(N-1):
sum-=count[i]
print(sum)
| n,m = list(map(int,input().split()))
x = [int(i) for i in input().split()]
x.sort()
xx = []
for i in range(len(x)-1):
xx.append(abs(x[i]-x[i+1]))
xx.sort()
print((sum(xx[:-(n-1)])if n!=1 else sum(xx)))
| 16 | 8 | 294 | 203 | N, M = list(map(int, input().split()))
X = [int(i) for i in input().split()]
X.sort()
count = []
sum = 0
if N < M:
for i in range(M):
if i != 0:
count.append(X[i] - get)
sum += count[i - 1]
get = X[i]
count.sort(reverse=True)
for i in range(N - 1):
sum -= coun... | n, m = list(map(int, input().split()))
x = [int(i) for i in input().split()]
x.sort()
xx = []
for i in range(len(x) - 1):
xx.append(abs(x[i] - x[i + 1]))
xx.sort()
print((sum(xx[: -(n - 1)]) if n != 1 else sum(xx)))
| false | 50 | [
"-N, M = list(map(int, input().split()))",
"-X = [int(i) for i in input().split()]",
"-X.sort()",
"-count = []",
"-sum = 0",
"-if N < M:",
"- for i in range(M):",
"- if i != 0:",
"- count.append(X[i] - get)",
"- sum += count[i - 1]",
"- get = X[i]",
"- ... | false | 0.065861 | 0.047003 | 1.401211 | [
"s094586966",
"s305616159"
] |
u077291787 | p03243 | python | s946819632 | s325868669 | 21 | 17 | 2,940 | 3,064 | Accepted | Accepted | 19.05 | # ABC111B
from math import ceil
print((ceil(int(eval(input())) / 111) * 111)) | # ABC111B
from math import ceil
num = int(eval(input()))
print((ceil(num / 111) * 111)) | 4 | 5 | 73 | 84 | # ABC111B
from math import ceil
print((ceil(int(eval(input())) / 111) * 111))
| # ABC111B
from math import ceil
num = int(eval(input()))
print((ceil(num / 111) * 111))
| false | 20 | [
"-print((ceil(int(eval(input())) / 111) * 111))",
"+num = int(eval(input()))",
"+print((ceil(num / 111) * 111))"
] | false | 0.154419 | 0.043792 | 3.526172 | [
"s946819632",
"s325868669"
] |
u608088992 | p03854 | python | s358303298 | s083302384 | 60 | 38 | 3,188 | 4,092 | Accepted | Accepted | 36.67 | S = eval(input())
Sb = S[::-1]
daydreamers = ["maerd", "remaerd", "esare", "resare"]
judge = True
i = 0
while i < len(S) and judge:
temp = ""
isThere = False
for j in range(7):
temp += Sb[i+j]
if temp in daydreamers:
isThere = True
i = i+j+1
... | def solve():
S = eval(input())
N = len(S)
Srev = []
for i in reversed(list(range(N))): Srev.append(S[i])
Srev = "".join(Srev)
ti = 0
while ti < N:
if Srev[ti] == "m":
if Srev[ti:min(N, ti + 5)] == "maerd": ti += 5
else:
print("NO")
... | 19 | 34 | 399 | 862 | S = eval(input())
Sb = S[::-1]
daydreamers = ["maerd", "remaerd", "esare", "resare"]
judge = True
i = 0
while i < len(S) and judge:
temp = ""
isThere = False
for j in range(7):
temp += Sb[i + j]
if temp in daydreamers:
isThere = True
i = i + j + 1
break
... | def solve():
S = eval(input())
N = len(S)
Srev = []
for i in reversed(list(range(N))):
Srev.append(S[i])
Srev = "".join(Srev)
ti = 0
while ti < N:
if Srev[ti] == "m":
if Srev[ti : min(N, ti + 5)] == "maerd":
ti += 5
else:
... | false | 44.117647 | [
"-S = eval(input())",
"-Sb = S[::-1]",
"-daydreamers = [\"maerd\", \"remaerd\", \"esare\", \"resare\"]",
"-judge = True",
"-i = 0",
"-while i < len(S) and judge:",
"- temp = \"\"",
"- isThere = False",
"- for j in range(7):",
"- temp += Sb[i + j]",
"- if temp in daydreamer... | false | 0.041464 | 0.036558 | 1.134213 | [
"s358303298",
"s083302384"
] |
u691018832 | p02696 | python | s901532650 | s583186834 | 61 | 20 | 62,148 | 9,072 | Accepted | Accepted | 67.21 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
from math import floor
a, b, n = list(map(int, readline().split()))
if b > n:
print((floor(a * n / b) - a * floor(n / b)))
else:
print((floor(a * (b - ... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
from math import floor
a, b, n = list(map(int, readline().split()))
print((floor(a * min(b - 1, n) / b) - a * floor(min(b - 1, n) / b)))
| 13 | 10 | 345 | 287 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
from math import floor
a, b, n = list(map(int, readline().split()))
if b > n:
print((floor(a * n / b) - a * floor(n / b)))
else:
print((floor(a * (b - 1) / b) - a * ... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
from math import floor
a, b, n = list(map(int, readline().split()))
print((floor(a * min(b - 1, n) / b) - a * floor(min(b - 1, n) / b)))
| false | 23.076923 | [
"-if b > n:",
"- print((floor(a * n / b) - a * floor(n / b)))",
"-else:",
"- print((floor(a * (b - 1) / b) - a * floor((b - 1) / b)))",
"+print((floor(a * min(b - 1, n) / b) - a * floor(min(b - 1, n) / b)))"
] | false | 0.124337 | 0.085006 | 1.462689 | [
"s901532650",
"s583186834"
] |
u141786930 | p03107 | python | s242726267 | s291156488 | 43 | 18 | 3,188 | 3,188 | Accepted | Accepted | 58.14 | # C - Unification
S = str(eval(input()))
zeroCnt = 0
oneCnt = 0
ans = 0
for i in range(len(S)):
if S[i]=='0':
if oneCnt==0:
zeroCnt += 1
else:
ans += 2
oneCnt -= 1
else:
if zeroCnt==0:
oneCnt += 1
else:
... | # C - Unification
S = str(eval(input()))
zeroCnt = S.count('0')
oneCnt = S.count('1')
print((min(zeroCnt, oneCnt)*2)) | 23 | 8 | 368 | 119 | # C - Unification
S = str(eval(input()))
zeroCnt = 0
oneCnt = 0
ans = 0
for i in range(len(S)):
if S[i] == "0":
if oneCnt == 0:
zeroCnt += 1
else:
ans += 2
oneCnt -= 1
else:
if zeroCnt == 0:
oneCnt += 1
else:
ans += 2
... | # C - Unification
S = str(eval(input()))
zeroCnt = S.count("0")
oneCnt = S.count("1")
print((min(zeroCnt, oneCnt) * 2))
| false | 65.217391 | [
"-zeroCnt = 0",
"-oneCnt = 0",
"-ans = 0",
"-for i in range(len(S)):",
"- if S[i] == \"0\":",
"- if oneCnt == 0:",
"- zeroCnt += 1",
"- else:",
"- ans += 2",
"- oneCnt -= 1",
"- else:",
"- if zeroCnt == 0:",
"- oneCnt += ... | false | 0.033912 | 0.040255 | 0.842421 | [
"s242726267",
"s291156488"
] |
u548303713 | p03037 | python | s019469560 | s250918613 | 408 | 338 | 27,344 | 3,064 | Accepted | Accepted | 17.16 | n,m=list(map(int,input().split()))
info=[]
for i in range(m):
info.append(list(map(int,input().split())))
start,goal=info[0][0],info[0][1]
c=0
for i in range(1,m):
start=max(start,info[i][0])
goal=min(goal,info[i][1])
if start>goal:
c=1
break
if c==0:
print((goal... | n,m=list(map(int,input().split()))
L,R=list(map(int,input().split()))
for i in range(m-1):
l,r=list(map(int,input().split()))
if r<L:
L,R=0,-1
break
if R<l:
L,R=0,-1
break
L=max(L,l)
R=min(R,r)
print((R-L+1)) | 18 | 14 | 343 | 254 | n, m = list(map(int, input().split()))
info = []
for i in range(m):
info.append(list(map(int, input().split())))
start, goal = info[0][0], info[0][1]
c = 0
for i in range(1, m):
start = max(start, info[i][0])
goal = min(goal, info[i][1])
if start > goal:
c = 1
break
if c == 0:
print(... | n, m = list(map(int, input().split()))
L, R = list(map(int, input().split()))
for i in range(m - 1):
l, r = list(map(int, input().split()))
if r < L:
L, R = 0, -1
break
if R < l:
L, R = 0, -1
break
L = max(L, l)
R = min(R, r)
print((R - L + 1))
| false | 22.222222 | [
"-info = []",
"-for i in range(m):",
"- info.append(list(map(int, input().split())))",
"-start, goal = info[0][0], info[0][1]",
"-c = 0",
"-for i in range(1, m):",
"- start = max(start, info[i][0])",
"- goal = min(goal, info[i][1])",
"- if start > goal:",
"- c = 1",
"+L, R = l... | false | 0.037121 | 0.043399 | 0.85535 | [
"s019469560",
"s250918613"
] |
u997641430 | p02862 | python | s484086052 | s699497036 | 1,316 | 225 | 122,068 | 29,460 | Accepted | Accepted | 82.9 | mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, N + 1):
g1.append((g1[-1] * i) % mod)
inverse.append((-inverse[mod % i] * (mod//i)) % mod)
g2.append((g2[-1] * inverse[-1]) % mod)
def cmb(n, r, mod):
if (r < 0 or r > n):
return 0
return g1[... | mod = 10**9+7
X, Y = list(map(int, input().split()))
def comb(n, r, mod):
if r < 0 or n < r:
return 0
return fact[n]*pow(fact[r], mod-2, mod) * pow(fact[n-r], mod-2, mod) % mod
if (X + Y) % 3 != 0:
ans = 0
else:
n = (X + Y) // 3
r = min(X, Y)-n
# nCr
fact = [1, ... | 27 | 23 | 512 | 428 | mod = 10**9 + 7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, N + 1):
g1.append((g1[-1] * i) % mod)
inverse.append((-inverse[mod % i] * (mod // i)) % mod)
g2.append((g2[-1] * inverse[-1]) % mod)
def cmb(n, r, mod):
if r < 0 or r > n:
return 0
return g1[n] * g2[r] * g... | mod = 10**9 + 7
X, Y = list(map(int, input().split()))
def comb(n, r, mod):
if r < 0 or n < r:
return 0
return fact[n] * pow(fact[r], mod - 2, mod) * pow(fact[n - r], mod - 2, mod) % mod
if (X + Y) % 3 != 0:
ans = 0
else:
n = (X + Y) // 3
r = min(X, Y) - n
# nCr
fact = [1, 1]
... | false | 14.814815 | [
"-N = 10**6",
"-g1 = [1, 1]",
"-g2 = [1, 1]",
"-inverse = [0, 1]",
"-for i in range(2, N + 1):",
"- g1.append((g1[-1] * i) % mod)",
"- inverse.append((-inverse[mod % i] * (mod // i)) % mod)",
"- g2.append((g2[-1] * inverse[-1]) % mod)",
"+X, Y = list(map(int, input().split()))",
"-def cmb... | false | 3.027617 | 0.077409 | 39.111877 | [
"s484086052",
"s699497036"
] |
u261103969 | p02612 | python | s696630240 | s894519362 | 69 | 28 | 61,660 | 9,144 | Accepted | Accepted | 59.42 | import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
n = int(readline())
print(((1000 - n % 1000) % 1000))
if __name__ == '__main__':
main()
| n = int(eval(input()))
x = 0
while x < n:
x += 1000
print(( x - n )) | 15 | 5 | 238 | 68 | import sys
readline = sys.stdin.readline
MOD = 10**9 + 7
INF = float("INF")
sys.setrecursionlimit(10**5)
def main():
n = int(readline())
print(((1000 - n % 1000) % 1000))
if __name__ == "__main__":
main()
| n = int(eval(input()))
x = 0
while x < n:
x += 1000
print((x - n))
| false | 66.666667 | [
"-import sys",
"-",
"-readline = sys.stdin.readline",
"-MOD = 10**9 + 7",
"-INF = float(\"INF\")",
"-sys.setrecursionlimit(10**5)",
"-",
"-",
"-def main():",
"- n = int(readline())",
"- print(((1000 - n % 1000) % 1000))",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
... | false | 0.035683 | 0.053945 | 0.661472 | [
"s696630240",
"s894519362"
] |
u070201429 | p02632 | python | s736165415 | s700080973 | 1,086 | 475 | 222,064 | 245,636 | Accepted | Accepted | 56.26 | class Combination:
def __init__(self, n, mod):
self.mod = mod
# self.fac[i] ≡ i! (factorial:階乗)
l = [1]
num = 1
for i in range(1, n+1):
num *= i
num %= mod
l.append(num)
self.fac = l.copy()
# self.rec[i] ≡ 1 /... | class Combination:
def __init__(self, n, mod):
self.mod = mod
# self.fac[i] ≡ i! (factorial:階乗)
l = [1]
num = 1
for i in range(1, n+1):
num *= i
num %= mod
l.append(num)
self.fac = l.copy()
# self.rec[i] ≡ 1 /... | 41 | 47 | 925 | 1,035 | class Combination:
def __init__(self, n, mod):
self.mod = mod
# self.fac[i] ≡ i! (factorial:階乗)
l = [1]
num = 1
for i in range(1, n + 1):
num *= i
num %= mod
l.append(num)
self.fac = l.copy()
# self.rec[i] ≡ 1 / i! (reciproc... | class Combination:
def __init__(self, n, mod):
self.mod = mod
# self.fac[i] ≡ i! (factorial:階乗)
l = [1]
num = 1
for i in range(1, n + 1):
num *= i
num %= mod
l.append(num)
self.fac = l.copy()
# self.rec[i] ≡ 1 / i! (reciproc... | false | 12.765957 | [
"+pow25 = [1]",
"+pow26 = [1]",
"+for _ in range(k):",
"+ pow25.append(25 * pow25[-1] % mod)",
"+ pow26.append(26 * pow26[-1] % mod)",
"- ans += c.comb(n + i - 1, i) * pow(25, i, mod) * pow(26, k - i, mod)",
"+ ans += c.comb(n + i - 1, i) * pow25[i] * pow26[k - i]"
] | false | 0.204109 | 0.04003 | 5.098876 | [
"s736165415",
"s700080973"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.