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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u380524497 | p02774 | python | s954016242 | s983396974 | 1,117 | 715 | 34,580 | 112,900 | Accepted | Accepted | 35.99 | import numpy as np
n, k = list(map(int, input().split()))
A = np.array(input().split(), np.int64)
A.sort()
posA = A[A > 0]
negA = A[A < 0]
zeros = (A==0).sum()
left = -10**18
right = 10**18
while left+1 < right:
num = (left+right)//2
less_count = 0
if num >= 0:
l... | n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
pos = []
neg = []
zeros = 0
for a in A:
if a > 0:
pos.append(a)
elif a < 0:
neg.append(a)
else:
zeros += 1
pos.sort()
neg.sort(reverse=True)
minus_pattern = len(pos) * len(neg)
zero_pattern ... | 41 | 62 | 842 | 1,428 | import numpy as np
n, k = list(map(int, input().split()))
A = np.array(input().split(), np.int64)
A.sort()
posA = A[A > 0]
negA = A[A < 0]
zeros = (A == 0).sum()
left = -(10**18)
right = 10**18
while left + 1 < right:
num = (left + right) // 2
less_count = 0
if num >= 0:
less_count += zeros * n
... | n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
pos = []
neg = []
zeros = 0
for a in A:
if a > 0:
pos.append(a)
elif a < 0:
neg.append(a)
else:
zeros += 1
pos.sort()
neg.sort(reverse=True)
minus_pattern = len(pos) * len(neg)
zero_pattern = zeros * (len(pos)... | false | 33.870968 | [
"-import numpy as np",
"-",
"-A = np.array(input().split(), np.int64)",
"-A.sort()",
"-posA = A[A > 0]",
"-negA = A[A < 0]",
"-zeros = (A == 0).sum()",
"+A = list(map(int, input().split()))",
"+pos = []",
"+neg = []",
"+zeros = 0",
"+for a in A:",
"+ if a > 0:",
"+ pos.append(a)"... | false | 0.225771 | 0.047109 | 4.792565 | [
"s954016242",
"s983396974"
] |
u423966555 | p03341 | python | s403491867 | s628984591 | 255 | 217 | 21,124 | 32,896 | Accepted | Accepted | 14.9 | N = int(eval(input()))
S = eval(input())
cnt_W = [0]*N #西を向いている人の累積和を求める
if S[0] == 'W':
cnt_W[0] = 1
for i in range(1, N):
if S[i]=="W":
cnt_W[i] += cnt_W[i-1] + 1
else:
cnt_W[i] = cnt_W[i-1]
most_E = cnt_W[-1] #全体で西を向いている人数
#print(most_E)
ans = float('inf')
for i in rang... | N = int(eval(input()))
S = eval(input())
cnt_W = [0]*N #西を向いている人の累積和を求める
if S[0] == 'W':
cnt_W[0] = 1
for i in range(1, N):
if S[i]=="W":
cnt_W[i] += cnt_W[i-1] + 1
else:
cnt_W[i] = cnt_W[i-1]
most_E = cnt_W[-1] #全体で西を向いている人数
ans = []
for i in range(N):
if i == 0:
... | 36 | 30 | 728 | 634 | N = int(eval(input()))
S = eval(input())
cnt_W = [0] * N # 西を向いている人の累積和を求める
if S[0] == "W":
cnt_W[0] = 1
for i in range(1, N):
if S[i] == "W":
cnt_W[i] += cnt_W[i - 1] + 1
else:
cnt_W[i] = cnt_W[i - 1]
most_E = cnt_W[-1] # 全体で西を向いている人数
# print(most_E)
ans = float("inf")
for i in range(N):
... | N = int(eval(input()))
S = eval(input())
cnt_W = [0] * N # 西を向いている人の累積和を求める
if S[0] == "W":
cnt_W[0] = 1
for i in range(1, N):
if S[i] == "W":
cnt_W[i] += cnt_W[i - 1] + 1
else:
cnt_W[i] = cnt_W[i - 1]
most_E = cnt_W[-1] # 全体で西を向いている人数
ans = []
for i in range(N):
if i == 0:
if ... | false | 16.666667 | [
"-# print(most_E)",
"-ans = float(\"inf\")",
"+ans = []",
"- tmp = 0",
"- tmp = N - most_E",
"+ ans.append(N - most_E)",
"- tmp = (N - most_E) - 1",
"- # print(tmp)",
"+ ans.append((N - most_E) - 1)",
"- tmp = most_E - 1",
"+ ... | false | 0.07056 | 0.065089 | 1.084053 | [
"s403491867",
"s628984591"
] |
u562935282 | p03291 | python | s141249975 | s303784184 | 593 | 518 | 27,616 | 27,532 | Accepted | Accepted | 12.65 | s = eval(input())
ls = len(s)
dp = [[0 for _ in range(4)] for _ in range(ls+1)]
dp[0][0] = 1
mod = 10 ** 9 + 7
for i in range(1, ls+1):
for j in range(4):
#'?'のとき'ABC'の3通りに分岐させ、いずれも取らないので3倍
dp[i][j] += dp[i-1][j] * (3 if s[i-1] == '?' else 1)
if j > 0:
#ほしい文字に変えた場合 また... | def ary(r, c, v): return [[v for _ in range(c)] for _ in range(r)]
s = eval(input())
ls = len(s)
dp = ary(ls + 1, 4, 0)
dp[0][0] = 1
mod = 10 ** 9 + 7
for i in range(1, ls + 1):
for j in range(4):
#'?'のとき'ABC'の3通りに分岐させ、いずれも取らないので3倍
dp[i][j] += dp[i - 1][j] * (3 if s[i - 1] == '?' else 1... | 15 | 19 | 459 | 526 | s = eval(input())
ls = len(s)
dp = [[0 for _ in range(4)] for _ in range(ls + 1)]
dp[0][0] = 1
mod = 10**9 + 7
for i in range(1, ls + 1):
for j in range(4):
#'?'のとき'ABC'の3通りに分岐させ、いずれも取らないので3倍
dp[i][j] += dp[i - 1][j] * (3 if s[i - 1] == "?" else 1)
if j > 0:
# ほしい文字に変えた場合 または ほしい... | def ary(r, c, v):
return [[v for _ in range(c)] for _ in range(r)]
s = eval(input())
ls = len(s)
dp = ary(ls + 1, 4, 0)
dp[0][0] = 1
mod = 10**9 + 7
for i in range(1, ls + 1):
for j in range(4):
#'?'のとき'ABC'の3通りに分岐させ、いずれも取らないので3倍
dp[i][j] += dp[i - 1][j] * (3 if s[i - 1] == "?" else 1)
... | false | 21.052632 | [
"+def ary(r, c, v):",
"+ return [[v for _ in range(c)] for _ in range(r)]",
"+",
"+",
"-dp = [[0 for _ in range(4)] for _ in range(ls + 1)]",
"+dp = ary(ls + 1, 4, 0)",
"+ # ほしい文字に変えた場合 または ほしい文字の場合で取ったとき",
"- # ほしい文字に変えた場合 または ほしい文字の場合で取ったとき",
"- dp[i][j] += (",
"-... | false | 0.045759 | 0.046273 | 0.988888 | [
"s141249975",
"s303784184"
] |
u333596716 | p02392 | python | s565328144 | s007888739 | 30 | 20 | 7,656 | 7,588 | Accepted | Accepted | 33.33 | a,b,c=list(map(int,input().split()))
if a < b and b < c:
print("Yes")
else:
print("No") | a,b,c=list(map(int,input().split()))
if a < b < c:
print("Yes")
else:
print("No") | 5 | 5 | 93 | 87 | a, b, c = list(map(int, input().split()))
if a < b and b < c:
print("Yes")
else:
print("No")
| a, b, c = list(map(int, input().split()))
if a < b < c:
print("Yes")
else:
print("No")
| false | 0 | [
"-if a < b and b < c:",
"+if a < b < c:"
] | false | 0.03898 | 0.078323 | 0.497682 | [
"s565328144",
"s007888739"
] |
u562016607 | p03546 | python | s030572725 | s537506172 | 48 | 37 | 3,444 | 3,444 | Accepted | Accepted | 22.92 | import math
st=input().split()
H=int(st[0]);W=int(st[1])
c=[[0 for i in range(10)] for i in range(10)]
A=[[0 for i in range(W)]for i in range(H)]
for i in range(10):
st=input().split()
for j in range(10):
c[i][j]=int(st[j])
for i in range(H):
st=input().split()
for j in range(W):
... | H,W=list(map(int,input().split()))
c=[list(map(int,input().split())) for i in range(10)]
A=[list(map(int,input().split())) for i in range(H)]
for k in range(10):
for i in range(10):
for j in range(10):
if c[i][j]>c[i][k]+c[k][j]:
c[i][j]=c[i][k]+c[k][j]
ans=0
for i in range(H):
for j in ... | 37 | 14 | 861 | 383 | import math
st = input().split()
H = int(st[0])
W = int(st[1])
c = [[0 for i in range(10)] for i in range(10)]
A = [[0 for i in range(W)] for i in range(H)]
for i in range(10):
st = input().split()
for j in range(10):
c[i][j] = int(st[j])
for i in range(H):
st = input().split()
for j in range(W... | H, W = list(map(int, input().split()))
c = [list(map(int, input().split())) for i in range(10)]
A = [list(map(int, input().split())) for i in range(H)]
for k in range(10):
for i in range(10):
for j in range(10):
if c[i][j] > c[i][k] + c[k][j]:
c[i][j] = c[i][k] + c[k][j]
ans = 0
... | false | 62.162162 | [
"-import math",
"-",
"-st = input().split()",
"-H = int(st[0])",
"-W = int(st[1])",
"-c = [[0 for i in range(10)] for i in range(10)]",
"-A = [[0 for i in range(W)] for i in range(H)]",
"-for i in range(10):",
"- st = input().split()",
"- for j in range(10):",
"- c[i][j] = int(st[j]... | false | 0.12957 | 0.039996 | 3.2396 | [
"s030572725",
"s537506172"
] |
u024782094 | p03611 | python | s948549898 | s091731036 | 172 | 92 | 30,940 | 10,996 | Accepted | Accepted | 46.51 | from collections import Counter
n=int(eval(input()))
l=[]
a=list(map(int,input().split()))
for i in range(n):
l.append(a[i]-1)
l.append(a[i])
l.append(a[i]+1)
ans=Counter(l)
print((ans.most_common()[0][1])) | import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return list(map(int,input().split()))
def lmp(): return list(map(int,input().split()))
n=int(eval(input()))
a=mp()
l=[0]*(10**5+10)
for x in a:
l[x]+=1
l[x-1]+=1
l[... | 10 | 14 | 213 | 330 | from collections import Counter
n = int(eval(input()))
l = []
a = list(map(int, input().split()))
for i in range(n):
l.append(a[i] - 1)
l.append(a[i])
l.append(a[i] + 1)
ans = Counter(l)
print((ans.most_common()[0][1]))
| import sys
from collections import Counter
from collections import deque
def input():
return sys.stdin.readline().strip()
def mp():
return list(map(int, input().split()))
def lmp():
return list(map(int, input().split()))
n = int(eval(input()))
a = mp()
l = [0] * (10**5 + 10)
for x in a:
l[x] += ... | false | 28.571429 | [
"+import sys",
"+from collections import deque",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline().strip()",
"+",
"+",
"+def mp():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def lmp():",
"+ return list(map(int, input().split()))",
"+",
"-l = []",
"-a =... | false | 0.040983 | 0.043733 | 0.937134 | [
"s948549898",
"s091731036"
] |
u576917603 | p02911 | python | s642824929 | s954025495 | 257 | 233 | 14,752 | 10,452 | Accepted | Accepted | 9.34 | n,k,q=list(map(int,input().split()))
a=[]
for i in range(q):
a.append(int(eval(input())))
import collections
c=collections.Counter(a)
c=list(c.items())
p=[0]*n
for i in c:
p[i[0]-1]=i[1]
line=1-(k-q)
for i in p:
if i>=line:
print('Yes')
else:
print('No') | n,k,q=list(map(int,input().split()))
a=[int(eval(input())) for i in range(q)]
score=[k-q]*n
for i in a:
score[i-1]+=1
for i in score:
if i>=1:
print('Yes')
else:
print('No') | 16 | 10 | 289 | 198 | n, k, q = list(map(int, input().split()))
a = []
for i in range(q):
a.append(int(eval(input())))
import collections
c = collections.Counter(a)
c = list(c.items())
p = [0] * n
for i in c:
p[i[0] - 1] = i[1]
line = 1 - (k - q)
for i in p:
if i >= line:
print("Yes")
else:
print("No")
| n, k, q = list(map(int, input().split()))
a = [int(eval(input())) for i in range(q)]
score = [k - q] * n
for i in a:
score[i - 1] += 1
for i in score:
if i >= 1:
print("Yes")
else:
print("No")
| false | 37.5 | [
"-a = []",
"-for i in range(q):",
"- a.append(int(eval(input())))",
"-import collections",
"-",
"-c = collections.Counter(a)",
"-c = list(c.items())",
"-p = [0] * n",
"-for i in c:",
"- p[i[0] - 1] = i[1]",
"-line = 1 - (k - q)",
"-for i in p:",
"- if i >= line:",
"+a = [int(eval(... | false | 0.032858 | 0.048783 | 0.673559 | [
"s642824929",
"s954025495"
] |
u968166680 | p02850 | python | s325097647 | s212197961 | 299 | 266 | 99,860 | 53,320 | Accepted | Accepted | 11.04 | import sys
from collections import deque
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, *AB = list(map(int, read().split()))
G = [[] for _ in range(N)]
for i, (a, b) in enumerat... | import sys
from collections import deque
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, *AB = map(int, read().split())
G = [[] for _ in range(N)]
for i, (a, b) in enumerate(zip(... | 40 | 43 | 825 | 984 | import sys
from collections import deque
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
N, *AB = list(map(int, read().split()))
G = [[] for _ in range(N)]
for i, (a, b) in enumerate(zip(*[iter(AB)... | import sys
from collections import deque
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
N, *AB = map(int, read().split())
G = [[] for _ in range(N)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)... | false | 6.976744 | [
"- N, *AB = list(map(int, read().split()))",
"+ N, *AB = map(int, read().split())",
"+ queue = deque([0])",
"-",
"- def dfs(v, p, pc):",
"+ color_from_parent = [0] * N",
"+ color_from_parent[0] = -1",
"+ while queue:",
"+ v = queue.popleft()",
"- if nv == p:"... | false | 0.076149 | 0.089093 | 0.854711 | [
"s325097647",
"s212197961"
] |
u707124227 | p03722 | python | s797352281 | s093946450 | 1,307 | 170 | 3,828 | 75,416 | Accepted | Accepted | 86.99 | n,m=list(map(int,input().split()))
#g=[[]for _ in range(n)]
abc=[list(map(int,input().split())) for _ in range(m)]
abc=[[a-1,b-1,-c] for a,b,c in abc]
# BellmanFord
# ベルマンフォード法
def BellmanFord(edges,num_v,source):
#グラフの初期化
inf=float("inf")
dist=[inf for i in range(num_v)]
dist[source]=0
#辺の緩和
... | n,m=list(map(int,input().split()))
g=[[] for _ in range(n)]
abc=[list(map(int,input().split())) for _ in range(m)]
abc=[[a-1,b-1,-c] for a,b,c in abc]
# https://img.atcoder.jp/abc061/editorial.pdf
# 上のD問題
# BellmanFord
# ベルマンフォード法
# edges:エッジ、有向エッジ[a,b,c]a->bのエッジでコストc
# num_v:頂点の数
# source:始点
def Bellman... | 30 | 37 | 881 | 1,054 | n, m = list(map(int, input().split()))
# g=[[]for _ in range(n)]
abc = [list(map(int, input().split())) for _ in range(m)]
abc = [[a - 1, b - 1, -c] for a, b, c in abc]
# BellmanFord
# ベルマンフォード法
def BellmanFord(edges, num_v, source):
# グラフの初期化
inf = float("inf")
dist = [inf for i in range(num_v)]
dist[s... | n, m = list(map(int, input().split()))
g = [[] for _ in range(n)]
abc = [list(map(int, input().split())) for _ in range(m)]
abc = [[a - 1, b - 1, -c] for a, b, c in abc]
# https://img.atcoder.jp/abc061/editorial.pdf
# 上のD問題
# BellmanFord
# ベルマンフォード法
# edges:エッジ、有向エッジ[a,b,c]a->bのエッジでコストc
# num_v:頂点の数
# source:始点
def Bel... | false | 18.918919 | [
"-# g=[[]for _ in range(n)]",
"+g = [[] for _ in range(n)]",
"+# https://img.atcoder.jp/abc061/editorial.pdf",
"+# 上のD問題",
"+# edges:エッジ、有向エッジ[a,b,c]a->bのエッジでコストc",
"+# num_v:頂点の数",
"+# source:始点",
"- # 辺の緩和",
"- for i in range(num_v):",
"+ # 辺の緩和をnum_v-1回繰り返す。num_v回目に辺の緩和があればそれは閉路。-1を返す。... | false | 0.044422 | 0.037859 | 1.173346 | [
"s797352281",
"s093946450"
] |
u941407962 | p03034 | python | s951141783 | s044700576 | 409 | 339 | 75,860 | 63,216 | Accepted | Accepted | 17.11 | N, = list(map(int, input().split()))
xs = list(map(int, input().split()))
r = 0
for k in range(1, N):
a = (N-1) % k
b = a - k
n = (N-1-a)//k
if a <= k:
a += k
if a <= k:
a += k
for _ in range((N-1-a)//k):
b = a - k
n = (N-1-a)//k
if a <= b:... | N, = list(map(int, input().split()))
xs = list(map(int, input().split()))
r = 0
for k in range(1, N):
a = (N-1) % k
for _ in range(1+(N-1-a)//k):
b = a - k
n = (N-1-a)//k
if a <= b or a <= k:
a += k
continue
if a%(a-b) == 0:
if a <=... | 40 | 28 | 816 | 613 | (N,) = list(map(int, input().split()))
xs = list(map(int, input().split()))
r = 0
for k in range(1, N):
a = (N - 1) % k
b = a - k
n = (N - 1 - a) // k
if a <= k:
a += k
if a <= k:
a += k
for _ in range((N - 1 - a) // k):
b = a - k
n = (N - 1 - a) // k
if a... | (N,) = list(map(int, input().split()))
xs = list(map(int, input().split()))
r = 0
for k in range(1, N):
a = (N - 1) % k
for _ in range(1 + (N - 1 - a) // k):
b = a - k
n = (N - 1 - a) // k
if a <= b or a <= k:
a += k
continue
if a % (a - b) == 0:
... | false | 30 | [
"- b = a - k",
"- n = (N - 1 - a) // k",
"- if a <= k:",
"- a += k",
"- if a <= k:",
"- a += k",
"- for _ in range((N - 1 - a) // k):",
"+ for _ in range(1 + (N - 1 - a) // k):",
"- if a <= b:",
"+ if a <= b or a <= k:",
"- if a <= b or a >= N - 1... | false | 0.162815 | 0.036661 | 4.441128 | [
"s951141783",
"s044700576"
] |
u926412290 | p03163 | python | s460175173 | s251207236 | 289 | 234 | 159,900 | 149,104 | Accepted | Accepted | 19.03 | N, W = list(map(int, input().split()))
dp = [[0]*100100 for _ in range(110)]
for i in range(N):
weight, value = list(map(int, input().split()))
for sum_w in range(W+1):
if sum_w - weight >= 0:
dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - weight] + value)
dp[i + 1... | N, W = list(map(int, input().split()))
dp = [[0] * (W + 1) for i in range(N + 1)]
for i in range(1, N + 1):
w, v = list(map(int, input().split()))
for j in range(1, W + 1):
if j >= w:
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
else:
dp[i][j] = dp[i - ... | 12 | 13 | 373 | 332 | N, W = list(map(int, input().split()))
dp = [[0] * 100100 for _ in range(110)]
for i in range(N):
weight, value = list(map(int, input().split()))
for sum_w in range(W + 1):
if sum_w - weight >= 0:
dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - weight] + value)
dp[i + 1][sum_w... | N, W = list(map(int, input().split()))
dp = [[0] * (W + 1) for i in range(N + 1)]
for i in range(1, N + 1):
w, v = list(map(int, input().split()))
for j in range(1, W + 1):
if j >= w:
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
else:
dp[i][j] = dp[i - 1][j]
print((... | false | 7.692308 | [
"-dp = [[0] * 100100 for _ in range(110)]",
"-for i in range(N):",
"- weight, value = list(map(int, input().split()))",
"- for sum_w in range(W + 1):",
"- if sum_w - weight >= 0:",
"- dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - weight] + value)",
"- dp[i + 1][su... | false | 0.223214 | 0.045594 | 4.895656 | [
"s460175173",
"s251207236"
] |
u987164499 | p03325 | python | s608634685 | s095951050 | 545 | 79 | 71,256 | 4,148 | Accepted | Accepted | 85.5 | from sys import stdin
import fractions
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
... | n = int(eval(input()))
li = list(map(int,input().split()))
point = 0
for i in li:
while i%2 == 0:
i //= 2
point += 1
print(point) | 30 | 11 | 526 | 156 | from sys import stdin
import fractions
n = int(stdin.readline().rstrip())
li = list(map(int, stdin.readline().rstrip().split()))
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //... | n = int(eval(input()))
li = list(map(int, input().split()))
point = 0
for i in li:
while i % 2 == 0:
i //= 2
point += 1
print(point)
| false | 63.333333 | [
"-from sys import stdin",
"-import fractions",
"-",
"-n = int(stdin.readline().rstrip())",
"-li = list(map(int, stdin.readline().rstrip().split()))",
"-",
"-",
"-def prime_factorize(n):",
"- a = []",
"- while n % 2 == 0:",
"- a.append(2)",
"- n //= 2",
"- f = 3",
"- ... | false | 0.069966 | 0.146565 | 0.477373 | [
"s608634685",
"s095951050"
] |
u806976856 | p03045 | python | s558242106 | s899791050 | 419 | 352 | 83,856 | 81,564 | Accepted | Accepted | 15.99 | n,m=list(map(int,input().split()))
import sys
sys.setrecursionlimit(10**9) #再帰の上限をあげる
root=[-1 for i in range(n+1)] #自分が親ならグループの人数のマイナス倍を、そうでないなら(元)親の番号を示す
dep=[1]*(n+1)
def r(x): #親は誰?
if root[x]<0:
return x
else:
return r(root[x])
def unite(x,y):
x=r(x)
y=r(y)
... | n,m=list(map(int,input().split()))
import sys
sys.setrecursionlimit(10**9) #再帰の上限をあげる
root=[-1 for i in range(n+1)] #自分が親ならグループの人数のマイナス倍を、そうでないなら(元)親の番号を示す
dep=[1]*(n+1)
def r(x): #親は誰?
if root[x]<0:
return x
else:
root[x]=r(root[x])
return root[x]
def unite(x,y):
... | 39 | 40 | 665 | 690 | n, m = list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**9) # 再帰の上限をあげる
root = [-1 for i in range(n + 1)] # 自分が親ならグループの人数のマイナス倍を、そうでないなら(元)親の番号を示す
dep = [1] * (n + 1)
def r(x): # 親は誰?
if root[x] < 0:
return x
else:
return r(root[x])
def unite(x, y):
x = r(x)
y ... | n, m = list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**9) # 再帰の上限をあげる
root = [-1 for i in range(n + 1)] # 自分が親ならグループの人数のマイナス倍を、そうでないなら(元)親の番号を示す
dep = [1] * (n + 1)
def r(x): # 親は誰?
if root[x] < 0:
return x
else:
root[x] = r(root[x])
return root[x]
def unite(... | false | 2.5 | [
"- return r(root[x])",
"+ root[x] = r(root[x])",
"+ return root[x]"
] | false | 0.087601 | 0.098227 | 0.891825 | [
"s558242106",
"s899791050"
] |
u531599639 | p02888 | python | s635133845 | s470423519 | 1,076 | 216 | 9,376 | 73,824 | Accepted | Accepted | 79.93 | import bisect
n = int(eval(input()))
l = sorted(list(map(int,input().split())))
ans = 0
for ai in range(n):
for bi in range(ai+1,n):
ci = bisect.bisect_left(l,l[ai]+l[bi])
if ci>bi:
ans += ci-bi-1
print(ans) | n = int(eval(input()))
l = sorted(list(map(int,input().split())))
ans = 0
for ai in range(n):
for bi in range(ai+1,n):
ok,ng = bi,n
while ng-ok>1:
mid = (ng+ok)//2
if l[mid]<l[ai]+l[bi]:
ok = mid
else:
ng = mid
ans += ok-bi
print(ans) | 10 | 14 | 236 | 289 | import bisect
n = int(eval(input()))
l = sorted(list(map(int, input().split())))
ans = 0
for ai in range(n):
for bi in range(ai + 1, n):
ci = bisect.bisect_left(l, l[ai] + l[bi])
if ci > bi:
ans += ci - bi - 1
print(ans)
| n = int(eval(input()))
l = sorted(list(map(int, input().split())))
ans = 0
for ai in range(n):
for bi in range(ai + 1, n):
ok, ng = bi, n
while ng - ok > 1:
mid = (ng + ok) // 2
if l[mid] < l[ai] + l[bi]:
ok = mid
else:
ng = mid
... | false | 28.571429 | [
"-import bisect",
"-",
"- ci = bisect.bisect_left(l, l[ai] + l[bi])",
"- if ci > bi:",
"- ans += ci - bi - 1",
"+ ok, ng = bi, n",
"+ while ng - ok > 1:",
"+ mid = (ng + ok) // 2",
"+ if l[mid] < l[ai] + l[bi]:",
"+ ok = m... | false | 0.037161 | 0.033618 | 1.105392 | [
"s635133845",
"s470423519"
] |
u729133443 | p04011 | python | s793090160 | s674957750 | 196 | 18 | 38,256 | 2,940 | Accepted | Accepted | 90.82 | n,k,x,y=[int(eval(input()))for _ in[0]*4];print((min(n,k)*x+max(n-k,0)*y)) | n,k,x,y=[int(eval(input()))for _ in[0]*4];print((n*x-(x-y)*max(n-k,0))) | 1 | 1 | 66 | 63 | n, k, x, y = [int(eval(input())) for _ in [0] * 4]
print((min(n, k) * x + max(n - k, 0) * y))
| n, k, x, y = [int(eval(input())) for _ in [0] * 4]
print((n * x - (x - y) * max(n - k, 0)))
| false | 0 | [
"-print((min(n, k) * x + max(n - k, 0) * y))",
"+print((n * x - (x - y) * max(n - k, 0)))"
] | false | 0.076374 | 0.035662 | 2.141611 | [
"s793090160",
"s674957750"
] |
u864197622 | p02728 | python | s621509598 | s613472152 | 1,720 | 1,375 | 127,436 | 126,156 | Accepted | Accepted | 20.06 | import sys
input = sys.stdin.readline
from collections import deque
nn = 200200
mod = 10**9+7
fa = [1] * (nn+1)
fainv = [1] * (nn+1)
inv = [1] * (nn+1)
for i in range(nn):
fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
fainv[i] = fainv[i+1] * (i+1) % ... | import sys
input = sys.stdin.readline
from collections import deque
nn = 200200
mod = 10**9+7
fa = [1] * (nn+1)
fainv = [1] * (nn+1)
inv = [1] * (nn+1)
for i in range(nn):
fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
fainv[i] = fainv[i+1] * (i+1) % ... | 64 | 65 | 1,513 | 1,522 | import sys
input = sys.stdin.readline
from collections import deque
nn = 200200
mod = 10**9 + 7
fa = [1] * (nn + 1)
fainv = [1] * (nn + 1)
inv = [1] * (nn + 1)
for i in range(nn):
fa[i + 1] = fa[i] * (i + 1) % mod
fainv[-1] = pow(fa[-1], mod - 2, mod)
for i in range(nn)[::-1]:
fainv[i] = fainv[i + 1] * (i + 1... | import sys
input = sys.stdin.readline
from collections import deque
nn = 200200
mod = 10**9 + 7
fa = [1] * (nn + 1)
fainv = [1] * (nn + 1)
inv = [1] * (nn + 1)
for i in range(nn):
fa[i + 1] = fa[i] * (i + 1) % mod
fainv[-1] = pow(fa[-1], mod - 2, mod)
for i in range(nn)[::-1]:
fainv[i] = fainv[i + 1] * (i + 1... | false | 1.538462 | [
"- for k, j in list(enumerate(X[i]))[::-1]:",
"+ for k in range(c - 1, -1, -1):",
"+ j = X[i][k]"
] | false | 0.527022 | 0.506946 | 1.039603 | [
"s621509598",
"s613472152"
] |
u002459665 | p02802 | python | s646150115 | s404945419 | 361 | 326 | 32,132 | 23,464 | Accepted | Accepted | 9.7 | N, M = list(map(int, input().split()))
PS = []
for i in range(M):
p, s = input().split()
PS.append([int(p), s])
a_w = []
for i in range(N+1):
a_w.append([False, 0])
a_cnt = 0
w_cnt = 0
for p, s in PS:
# 正解済み
if a_w[p][0]:
continue
# 初めて正解した
if s == 'AC':
... | N, M = list(map(int, input().split()))
PS = []
for i in range(M):
p, s = input().split()
PS.append([int(p), s])
ac = [False] * N
pena = [0] * N
for p, s in PS:
p -= 1
if ac[p]:
continue
if s == 'AC':
ac[p] = True
else:
pena[p] += 1
a_cnt = 0
w_cnt ... | 27 | 27 | 451 | 421 | N, M = list(map(int, input().split()))
PS = []
for i in range(M):
p, s = input().split()
PS.append([int(p), s])
a_w = []
for i in range(N + 1):
a_w.append([False, 0])
a_cnt = 0
w_cnt = 0
for p, s in PS:
# 正解済み
if a_w[p][0]:
continue
# 初めて正解した
if s == "AC":
a_w[p][0] = True
... | N, M = list(map(int, input().split()))
PS = []
for i in range(M):
p, s = input().split()
PS.append([int(p), s])
ac = [False] * N
pena = [0] * N
for p, s in PS:
p -= 1
if ac[p]:
continue
if s == "AC":
ac[p] = True
else:
pena[p] += 1
a_cnt = 0
w_cnt = 0
for i in range(N):
... | false | 0 | [
"-a_w = []",
"-for i in range(N + 1):",
"- a_w.append([False, 0])",
"+ac = [False] * N",
"+pena = [0] * N",
"+for p, s in PS:",
"+ p -= 1",
"+ if ac[p]:",
"+ continue",
"+ if s == \"AC\":",
"+ ac[p] = True",
"+ else:",
"+ pena[p] += 1",
"-for p, s in PS:... | false | 0.052639 | 0.047413 | 1.110219 | [
"s646150115",
"s404945419"
] |
u706929073 | p03127 | python | s164667225 | s282196276 | 136 | 73 | 14,252 | 14,224 | Accepted | Accepted | 46.32 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
for i in range(1, len(a)):
while 0 != a[i - 1]:
r = a[i] % a[i - 1]
a[i] = a[i - 1]
a[i - 1] = r
print((a[-1]))
| n = int(eval(input()))
a = list(map(int, input().split()))
def gcd(a, b):
r = a % b
if 0 == r:
return b
else:
return gcd(b, r)
def gcd_for_arr(l):
tmp = gcd(l[0], l[1])
for i in range(2, len(l)):
tmp = gcd(tmp, l[i])
return tmp
print((gcd_for_arr(... | 10 | 20 | 210 | 317 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
for i in range(1, len(a)):
while 0 != a[i - 1]:
r = a[i] % a[i - 1]
a[i] = a[i - 1]
a[i - 1] = r
print((a[-1]))
| n = int(eval(input()))
a = list(map(int, input().split()))
def gcd(a, b):
r = a % b
if 0 == r:
return b
else:
return gcd(b, r)
def gcd_for_arr(l):
tmp = gcd(l[0], l[1])
for i in range(2, len(l)):
tmp = gcd(tmp, l[i])
return tmp
print((gcd_for_arr(a)))
| false | 50 | [
"-a.sort()",
"-for i in range(1, len(a)):",
"- while 0 != a[i - 1]:",
"- r = a[i] % a[i - 1]",
"- a[i] = a[i - 1]",
"- a[i - 1] = r",
"-print((a[-1]))",
"+",
"+",
"+def gcd(a, b):",
"+ r = a % b",
"+ if 0 == r:",
"+ return b",
"+ else:",
"+ ... | false | 0.055265 | 0.084535 | 0.653755 | [
"s164667225",
"s282196276"
] |
u241159583 | p03262 | python | s323505448 | s153088404 | 156 | 105 | 16,296 | 16,200 | Accepted | Accepted | 32.69 | import fractions
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
a = []
for i in range(N):
a.append(abs(X - x[i]))
ans = a[0]
if len(a) > 1:
for i in range(1, len(a)):
ans = fractions.gcd(ans, a[i])
print(ans) | from functools import reduce
from fractions import gcd
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
n = []
for i in range(N):
n.append(abs(X - x[i]))
print((reduce(gcd, n))) | 12 | 9 | 266 | 208 | import fractions
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
a = []
for i in range(N):
a.append(abs(X - x[i]))
ans = a[0]
if len(a) > 1:
for i in range(1, len(a)):
ans = fractions.gcd(ans, a[i])
print(ans)
| from functools import reduce
from fractions import gcd
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
n = []
for i in range(N):
n.append(abs(X - x[i]))
print((reduce(gcd, n)))
| false | 25 | [
"-import fractions",
"+from functools import reduce",
"+from fractions import gcd",
"-x.sort()",
"-a = []",
"+n = []",
"- a.append(abs(X - x[i]))",
"-ans = a[0]",
"-if len(a) > 1:",
"- for i in range(1, len(a)):",
"- ans = fractions.gcd(ans, a[i])",
"-print(ans)",
"+ n.append... | false | 0.0885 | 0.101037 | 0.875918 | [
"s323505448",
"s153088404"
] |
u255067135 | p03329 | python | s524111616 | s509030582 | 1,142 | 617 | 237,548 | 15,088 | Accepted | Accepted | 45.97 | import sys
sys.setrecursionlimit(10**6)
def memorize(f):
table = {}
def func(*args):
if not args in table:
table[args] = f(*args)
return table[args]
return func
@memorize
def memDFS(n):
if n==0:
return 0
else:
res = n
pow6 = 1
... | # もらうDP
N = int(eval(input()))
dp = {}
for n in range(N+1):
if n == 0:
dp[0] = 0
else:
res = n
pow6 = 1
while n - pow6 >= 0:
res = min(res, dp[n-pow6] +1)
pow6 *= 6
pow9 = 1
while n -pow9 >= 0:
res = min(res, dp[n-... | 29 | 18 | 582 | 381 | import sys
sys.setrecursionlimit(10**6)
def memorize(f):
table = {}
def func(*args):
if not args in table:
table[args] = f(*args)
return table[args]
return func
@memorize
def memDFS(n):
if n == 0:
return 0
else:
res = n
pow6 = 1
whil... | # もらうDP
N = int(eval(input()))
dp = {}
for n in range(N + 1):
if n == 0:
dp[0] = 0
else:
res = n
pow6 = 1
while n - pow6 >= 0:
res = min(res, dp[n - pow6] + 1)
pow6 *= 6
pow9 = 1
while n - pow9 >= 0:
res = min(res, dp[n - pow9] ... | false | 37.931034 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**6)",
"-",
"-",
"-def memorize(f):",
"- table = {}",
"-",
"- def func(*args):",
"- if not args in table:",
"- table[args] = f(*args)",
"- return table[args]",
"-",
"- return func",
"-",
"-",
"-@memorize"... | false | 0.09924 | 0.183782 | 0.53999 | [
"s524111616",
"s509030582"
] |
u671060652 | p02848 | python | s194170939 | s054360844 | 214 | 191 | 40,684 | 40,412 | Accepted | Accepted | 10.75 | n = int(eval(input()))
s = eval(input())
string = ""
for i in range(len(s)):
if ord(s[i]) + n <= ord("Z"):
string += chr(ord(s[i]) + n)
else:
string += chr(ord(s[i]) + n - 26)
print(string) | n = int(eval(input()))
s = eval(input())
ans = ""
for i in range(len(s)):
ans += chr(ord("A") +(((ord(s[i])+n)-ord("A")) % 26))
print(ans) | 11 | 9 | 213 | 141 | n = int(eval(input()))
s = eval(input())
string = ""
for i in range(len(s)):
if ord(s[i]) + n <= ord("Z"):
string += chr(ord(s[i]) + n)
else:
string += chr(ord(s[i]) + n - 26)
print(string)
| n = int(eval(input()))
s = eval(input())
ans = ""
for i in range(len(s)):
ans += chr(ord("A") + (((ord(s[i]) + n) - ord("A")) % 26))
print(ans)
| false | 18.181818 | [
"-string = \"\"",
"+ans = \"\"",
"- if ord(s[i]) + n <= ord(\"Z\"):",
"- string += chr(ord(s[i]) + n)",
"- else:",
"- string += chr(ord(s[i]) + n - 26)",
"-print(string)",
"+ ans += chr(ord(\"A\") + (((ord(s[i]) + n) - ord(\"A\")) % 26))",
"+print(ans)"
] | false | 0.044475 | 0.054675 | 0.813448 | [
"s194170939",
"s054360844"
] |
u652656291 | p03087 | python | s513282787 | s826019155 | 1,713 | 820 | 15,676 | 17,576 | Accepted | Accepted | 52.13 | import numpy as np
N,Q = list(map(int,input().split()))
S = np.array(list('_' + eval(input())), dtype='U2')
A = (S == 'A')
C = (S == 'C')
AC = (A[:-1] & C[1:])
AC_cum = AC.cumsum()
for _ in range(Q):
L,R = list(map(int,input().split()))
print((AC_cum[R-1] - AC_cum[L-1]))
| import numpy as np
import sys
buf = sys.stdin.buffer
N,Q = list(map(int,buf.readline().split()))
S = np.zeros(N+2, dtype='S1')
S[1:] = np.frombuffer(buf.read(N+1), dtype='S1')
A = (S == b'A')
C = (S == b'C')
AC = (A[:-1] & C[1:])
AC_cum = list(AC.cumsum())
for _ in range(Q):
L,R = list(map(int,buf.readli... | 11 | 14 | 267 | 359 | import numpy as np
N, Q = list(map(int, input().split()))
S = np.array(list("_" + eval(input())), dtype="U2")
A = S == "A"
C = S == "C"
AC = A[:-1] & C[1:]
AC_cum = AC.cumsum()
for _ in range(Q):
L, R = list(map(int, input().split()))
print((AC_cum[R - 1] - AC_cum[L - 1]))
| import numpy as np
import sys
buf = sys.stdin.buffer
N, Q = list(map(int, buf.readline().split()))
S = np.zeros(N + 2, dtype="S1")
S[1:] = np.frombuffer(buf.read(N + 1), dtype="S1")
A = S == b"A"
C = S == b"C"
AC = A[:-1] & C[1:]
AC_cum = list(AC.cumsum())
for _ in range(Q):
L, R = list(map(int, buf.readline().spl... | false | 21.428571 | [
"+import sys",
"-N, Q = list(map(int, input().split()))",
"-S = np.array(list(\"_\" + eval(input())), dtype=\"U2\")",
"-A = S == \"A\"",
"-C = S == \"C\"",
"+buf = sys.stdin.buffer",
"+N, Q = list(map(int, buf.readline().split()))",
"+S = np.zeros(N + 2, dtype=\"S1\")",
"+S[1:] = np.frombuffer(buf.r... | false | 0.314414 | 0.260762 | 1.20575 | [
"s513282787",
"s826019155"
] |
u994988729 | p03283 | python | s078989996 | s174640728 | 2,152 | 1,746 | 20,664 | 27,792 | Accepted | Accepted | 18.87 | import numpy as np
n, m, q = map(int, input().split())
train = np.zeros((n, n), dtype=int)
for _ in range(m):
l, r = map(int, input().split())
l -= 1
r -= 1
train[l][r] += 1
# 累積和
for i in range(n):
np.add.accumulate(train[i], out=train[i])
np.add.accumulate(train, out=train)
ans = [... | import numpy as np
n, m, q = map(int, input().split())
train = np.zeros((n, n), dtype=int)
for _ in range(m):
l, r = map(int, input().split())
l -= 1
r -= 1
train[l][r] += 1
# 累積和
for i in range(n):
np.add.accumulate(train[i], out=train[i])
np.add.accumulate(train, out=train)
train=tra... | 25 | 26 | 513 | 535 | import numpy as np
n, m, q = map(int, input().split())
train = np.zeros((n, n), dtype=int)
for _ in range(m):
l, r = map(int, input().split())
l -= 1
r -= 1
train[l][r] += 1
# 累積和
for i in range(n):
np.add.accumulate(train[i], out=train[i])
np.add.accumulate(train, out=train)
ans = []
for _ in rang... | import numpy as np
n, m, q = map(int, input().split())
train = np.zeros((n, n), dtype=int)
for _ in range(m):
l, r = map(int, input().split())
l -= 1
r -= 1
train[l][r] += 1
# 累積和
for i in range(n):
np.add.accumulate(train[i], out=train[i])
np.add.accumulate(train, out=train)
train = train.tolist()... | false | 3.846154 | [
"+train = train.tolist()"
] | false | 0.308411 | 0.350887 | 0.878949 | [
"s078989996",
"s174640728"
] |
u405256066 | p03958 | python | s086266795 | s726529144 | 57 | 27 | 3,064 | 3,064 | Accepted | Accepted | 52.63 | from sys import stdin
#import heapq
K,T = [int(x) for x in stdin.readline().rstrip().split()]
data = [(int(b),a) for a,b in enumerate(stdin.readline().rstrip().split())]
#heapq.heapify(data)
ans = 0
cake_num = -1
flag = True
if T == 1:
ans = K-1
else:
while flag:
data.sort()
#pri... | from sys import stdin
import heapq
K,T = [int(x) for x in stdin.readline().rstrip().split()]
data = [(-int(b),a) for a,b in enumerate(stdin.readline().rstrip().split())]
heapq.heapify(data)
ans = 0
cake_num = -1
cake_count = 0
flag = True
if T == 1:
ans = K-1
else:
while flag:
c_c,c_n = heapq.he... | 35 | 33 | 859 | 773 | from sys import stdin
# import heapq
K, T = [int(x) for x in stdin.readline().rstrip().split()]
data = [(int(b), a) for a, b in enumerate(stdin.readline().rstrip().split())]
# heapq.heapify(data)
ans = 0
cake_num = -1
flag = True
if T == 1:
ans = K - 1
else:
while flag:
data.sort()
# print(data... | from sys import stdin
import heapq
K, T = [int(x) for x in stdin.readline().rstrip().split()]
data = [(-int(b), a) for a, b in enumerate(stdin.readline().rstrip().split())]
heapq.heapify(data)
ans = 0
cake_num = -1
cake_count = 0
flag = True
if T == 1:
ans = K - 1
else:
while flag:
c_c, c_n = heapq.hea... | false | 5.714286 | [
"+import heapq",
"-# import heapq",
"-data = [(int(b), a) for a, b in enumerate(stdin.readline().rstrip().split())]",
"-# heapq.heapify(data)",
"+data = [(-int(b), a) for a, b in enumerate(stdin.readline().rstrip().split())]",
"+heapq.heapify(data)",
"+cake_count = 0",
"- data.sort()",
"- ... | false | 0.072191 | 0.038357 | 1.882075 | [
"s086266795",
"s726529144"
] |
u508732591 | p02314 | python | s871285599 | s792592108 | 580 | 530 | 9,168 | 9,168 | Accepted | Accepted | 8.62 | n,m = list(map(int,input().split()))
c = list(map(int,input().split()))
minimum = [50000] * (n+1)
minimum[0] = 0
for i in range(1,n+1):
if minimum[i] <= 1:
continue
for j in range(m):
if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
minimum[i] = minimum[i-c[j]]+1
prin... | n = int(input().split()[0])
c = list([x for x in map(int,input().split()) if x <= n])
m = len(c)
minimum = [n] * (n+1)
minimum[0] = 0
for i in c:
minimum[i] = 1
for i in range(1,n+1):
for j in range(m):
if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
minimum[i] = minimum[i-c[j... | 14 | 15 | 327 | 346 | n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
minimum = [50000] * (n + 1)
minimum[0] = 0
for i in range(1, n + 1):
if minimum[i] <= 1:
continue
for j in range(m):
if c[j] <= i and minimum[i - c[j]] + 1 < minimum[i]:
minimum[i] = minimum[i - c[j]] + 1
prin... | n = int(input().split()[0])
c = list([x for x in map(int, input().split()) if x <= n])
m = len(c)
minimum = [n] * (n + 1)
minimum[0] = 0
for i in c:
minimum[i] = 1
for i in range(1, n + 1):
for j in range(m):
if c[j] <= i and minimum[i - c[j]] + 1 < minimum[i]:
minimum[i] = minimum[i - c[j]]... | false | 6.666667 | [
"-n, m = list(map(int, input().split()))",
"-c = list(map(int, input().split()))",
"-minimum = [50000] * (n + 1)",
"+n = int(input().split()[0])",
"+c = list([x for x in map(int, input().split()) if x <= n])",
"+m = len(c)",
"+minimum = [n] * (n + 1)",
"+for i in c:",
"+ minimum[i] = 1",
"- ... | false | 0.089136 | 0.036028 | 2.474091 | [
"s871285599",
"s792592108"
] |
u467736898 | p03013 | python | s823427049 | s338256325 | 217 | 199 | 9,612 | 9,612 | Accepted | Accepted | 8.29 | mod = 10**9+7
N, M = list(map(int, input().split()))
A_ = [int(eval(input())) for _ in range(M)]
A = [0] * (N+1)
for a in A_:
A[a] = 1
dp = [0] * (N+3)
dp[0] = 1
for i in range(1, N+1):
if A[i-1] == 0:
dp[i] += dp[i-1]
if A[i-2] == 0:
dp[i] += dp[i-2]
dp[i] %= mod
print((dp... | mod = 10**9+7
N, M = list(map(int, input().split()))
A_ = [int(eval(input())) for _ in range(M)]
A = [0] * (N+3)
for a in A_:
A[a] = 1
dp = [0] * (N+3)
dp[0] = 1
for i in range(1, N+1):
if A[i-1] == 0:
dp[i] += dp[i-1]
if A[i-2] == 0:
dp[i] += dp[i-2]
dp[i] %= mod
print((dp... | 15 | 15 | 312 | 312 | mod = 10**9 + 7
N, M = list(map(int, input().split()))
A_ = [int(eval(input())) for _ in range(M)]
A = [0] * (N + 1)
for a in A_:
A[a] = 1
dp = [0] * (N + 3)
dp[0] = 1
for i in range(1, N + 1):
if A[i - 1] == 0:
dp[i] += dp[i - 1]
if A[i - 2] == 0:
dp[i] += dp[i - 2]
dp[i] %= mod
print((... | mod = 10**9 + 7
N, M = list(map(int, input().split()))
A_ = [int(eval(input())) for _ in range(M)]
A = [0] * (N + 3)
for a in A_:
A[a] = 1
dp = [0] * (N + 3)
dp[0] = 1
for i in range(1, N + 1):
if A[i - 1] == 0:
dp[i] += dp[i - 1]
if A[i - 2] == 0:
dp[i] += dp[i - 2]
dp[i] %= mod
print((... | false | 0 | [
"-A = [0] * (N + 1)",
"+A = [0] * (N + 3)"
] | false | 0.051058 | 0.064289 | 0.794184 | [
"s823427049",
"s338256325"
] |
u133936772 | p02861 | python | s102241709 | s965495405 | 442 | 17 | 8,052 | 2,940 | Accepted | Accepted | 96.15 | n = int(eval(input()))
ll = []
for i in range(n):
ll.append(list(map(int, input().split())))
import itertools as it
lt = list(it.permutations(list(range(0, n))))
def dist(i, j):
return ((ll[i][0]-ll[j][0])**2 + (ll[i][1]-ll[j][1])**2)**0.5
d = 0
for t in lt:
for i in range(n-1):
d += dist(t... | n = int(eval(input()))
ll = [list(map(int,input().split())) for _ in range(n)]
d = 0
for x1,y1 in ll:
for x2,y2 in ll:
d += ((x1-x2)**2+(y1-y2)**2)**0.5
print((d/n)) | 18 | 7 | 340 | 169 | n = int(eval(input()))
ll = []
for i in range(n):
ll.append(list(map(int, input().split())))
import itertools as it
lt = list(it.permutations(list(range(0, n))))
def dist(i, j):
return ((ll[i][0] - ll[j][0]) ** 2 + (ll[i][1] - ll[j][1]) ** 2) ** 0.5
d = 0
for t in lt:
for i in range(n - 1):
d +... | n = int(eval(input()))
ll = [list(map(int, input().split())) for _ in range(n)]
d = 0
for x1, y1 in ll:
for x2, y2 in ll:
d += ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
print((d / n))
| false | 61.111111 | [
"-ll = []",
"-for i in range(n):",
"- ll.append(list(map(int, input().split())))",
"-import itertools as it",
"-",
"-lt = list(it.permutations(list(range(0, n))))",
"-",
"-",
"-def dist(i, j):",
"- return ((ll[i][0] - ll[j][0]) ** 2 + (ll[i][1] - ll[j][1]) ** 2) ** 0.5",
"-",
"-",
"+ll... | false | 0.07955 | 0.036995 | 2.150286 | [
"s102241709",
"s965495405"
] |
u411203878 | p02787 | python | s396772645 | s506333142 | 631 | 258 | 125,276 | 146,136 | Accepted | Accepted | 59.11 | h,n = list(map(int,input().split()))
ab = []
for _ in range(n):
a, b = (int(x) for x in input().split())
ab.append([a, b])
dp = [[100000000 for i in range(h+1)] for j in range(n+1)]
for i in range(n):
for j in range(h+1):
if j <= ab[i][0]:
dp[i+1][j] = min(ab[i][1],dp[i][j])... | H,N = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(N)]
dp = [[10000000000000]*(H+1) for _ in range(N+1)]
for y in range(N):
a,b = AB[y]
for x in range(H+1):
if x <= a:
dp[y+1][x] = min(dp[y][x], b)
else:
dp[y+1][x] = mi... | 17 | 14 | 429 | 360 | h, n = list(map(int, input().split()))
ab = []
for _ in range(n):
a, b = (int(x) for x in input().split())
ab.append([a, b])
dp = [[100000000 for i in range(h + 1)] for j in range(n + 1)]
for i in range(n):
for j in range(h + 1):
if j <= ab[i][0]:
dp[i + 1][j] = min(ab[i][1], dp[i][j])
... | H, N = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]
dp = [[10000000000000] * (H + 1) for _ in range(N + 1)]
for y in range(N):
a, b = AB[y]
for x in range(H + 1):
if x <= a:
dp[y + 1][x] = min(dp[y][x], b)
else:
dp[y + 1][x] = m... | false | 17.647059 | [
"-h, n = list(map(int, input().split()))",
"-ab = []",
"-for _ in range(n):",
"- a, b = (int(x) for x in input().split())",
"- ab.append([a, b])",
"-dp = [[100000000 for i in range(h + 1)] for j in range(n + 1)]",
"-for i in range(n):",
"- for j in range(h + 1):",
"- if j <= ab[i][0]... | false | 0.393948 | 0.241859 | 1.628832 | [
"s396772645",
"s506333142"
] |
u729133443 | p03073 | python | s109504491 | s133247959 | 111 | 73 | 4,640 | 3,956 | Accepted | Accepted | 34.23 | *s,=list(map(int,eval(input())))
t=s[::-1]
n=len(s)
a=b=0
for i in range(1,n):
a+=s[i]==s[i-1]
s[i]=1-s[i-1]
for i in range(1,n):
b+=t[i]==t[i-1]
t[i]=1-t[i-1]
print((min(a,b))) | *s,=list(map(int,eval(input())))
a=0
for i in range(1,len(s)):
a+=s[i]==s[i-1]
s[i]=1-s[i-1]
print(a) | 11 | 6 | 189 | 102 | (*s,) = list(map(int, eval(input())))
t = s[::-1]
n = len(s)
a = b = 0
for i in range(1, n):
a += s[i] == s[i - 1]
s[i] = 1 - s[i - 1]
for i in range(1, n):
b += t[i] == t[i - 1]
t[i] = 1 - t[i - 1]
print((min(a, b)))
| (*s,) = list(map(int, eval(input())))
a = 0
for i in range(1, len(s)):
a += s[i] == s[i - 1]
s[i] = 1 - s[i - 1]
print(a)
| false | 45.454545 | [
"-t = s[::-1]",
"-n = len(s)",
"-a = b = 0",
"-for i in range(1, n):",
"+a = 0",
"+for i in range(1, len(s)):",
"-for i in range(1, n):",
"- b += t[i] == t[i - 1]",
"- t[i] = 1 - t[i - 1]",
"-print((min(a, b)))",
"+print(a)"
] | false | 0.073995 | 0.046904 | 1.577585 | [
"s109504491",
"s133247959"
] |
u634079249 | p03137 | python | s353378618 | s400200327 | 131 | 91 | 24,652 | 19,888 | Accepted | Accepted | 30.53 | import sys
import os
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
N, M = list(map(int, sys.stdin.readline().split()))
lines = list(map(int, sys.stdin.readline().split()))
lines.sort()
cost = {}
for i in range(len(lines) - 1):
tmp = lines... | import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
# import fractions
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstr... | 27 | 42 | 561 | 1,246 | import sys
import os
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
N, M = list(map(int, sys.stdin.readline().split()))
lines = list(map(int, sys.stdin.readline().split()))
lines.sort()
cost = {}
for i in range(len(lines) - 1):
tmp = lines[i + 1] - lines[... | import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
# import fractions
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il =... | false | 35.714286 | [
"-import sys",
"-import os",
"+import sys, os, math, bisect, itertools, collections, heapq, queue",
"+",
"+# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall",
"+from decimal import Decimal",
"+from collections import defaultdict, deque",
"+",
"+# import fractions",
"+sys.setrec... | false | 0.038654 | 0.041 | 0.94277 | [
"s353378618",
"s400200327"
] |
u029000441 | p03290 | python | s843214641 | s188179119 | 284 | 90 | 20,688 | 74,164 | Accepted | Accepted | 68.31 | # coding: utf-8
# hello worldと表示する
import sys
import numpy
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_righ... | #float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import h... | 61 | 52 | 1,822 | 1,504 | # coding: utf-8
# hello worldと表示する
import sys
import numpy
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from ... | # float型を許すな
# numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from heapq import heapif... | false | 14.754098 | [
"-# coding: utf-8",
"-# hello worldと表示する",
"+# float型を許すな",
"+# numpyはpythonで",
"-import numpy",
"-from copy import deepcopy",
"-answers = []",
"-for i in product([0, 1], repeat=d):",
"- new_lis = deepcopy(lis)",
"- point = 0",
"- problems = 0",
"- for j in range(d):",
"- ... | false | 0.087124 | 0.053415 | 1.631063 | [
"s843214641",
"s188179119"
] |
u738898077 | p02647 | python | s195579047 | s742191594 | 1,960 | 430 | 170,104 | 220,072 | Accepted | Accepted | 78.06 | n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
imos = [0]*(2*10**5+1)
for j in range(min(k,700)):
imos = [0]*(2*10**5+1)
for i in range(n):
imos[max(i-a[i],0)] += 1
imos[min(i+a[i]+1,2*10**5)] -= 1
for i in range(1,n):
imos[i] += imos[i-1]
a = i... | n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
imos = [0]*(2*10**5+1)
for j in range(min(k,100)):
imos = [0]*(2*10**5+1)
for i in range(n):
imos[max(i-a[i],0)] += 1
imos[min(i+a[i]+1,2*10**5)] -= 1
for i in range(1,n):
imos[i] += imos[i-1]
a = i... | 12 | 12 | 335 | 336 | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
imos = [0] * (2 * 10**5 + 1)
for j in range(min(k, 700)):
imos = [0] * (2 * 10**5 + 1)
for i in range(n):
imos[max(i - a[i], 0)] += 1
imos[min(i + a[i] + 1, 2 * 10**5)] -= 1
for i in range(1, n):
imos[i] += im... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
imos = [0] * (2 * 10**5 + 1)
for j in range(min(k, 100)):
imos = [0] * (2 * 10**5 + 1)
for i in range(n):
imos[max(i - a[i], 0)] += 1
imos[min(i + a[i] + 1, 2 * 10**5)] -= 1
for i in range(1, n):
imos[i] += im... | false | 0 | [
"-for j in range(min(k, 700)):",
"+for j in range(min(k, 100)):"
] | false | 0.039081 | 0.047556 | 0.821793 | [
"s195579047",
"s742191594"
] |
u729133443 | p03103 | python | s046512682 | s656779374 | 549 | 250 | 28,148 | 25,828 | Accepted | Accepted | 54.46 | I=lambda:list(map(int,input().split()));n,m=I();c=0
for a,b in sorted(I()for _ in[0]*n):c+=a*min(m,b);m=max(0,m-b)
print(c) | n,m,*t=list(map(int,open(0).read().split()));c=0
for a,b in sorted(zip(t[::2],t[1::2])):c+=a*min(m,b);m=max(0,m-b)
print(c) | 3 | 3 | 125 | 119 | I = lambda: list(map(int, input().split()))
n, m = I()
c = 0
for a, b in sorted(I() for _ in [0] * n):
c += a * min(m, b)
m = max(0, m - b)
print(c)
| n, m, *t = list(map(int, open(0).read().split()))
c = 0
for a, b in sorted(zip(t[::2], t[1::2])):
c += a * min(m, b)
m = max(0, m - b)
print(c)
| false | 0 | [
"-I = lambda: list(map(int, input().split()))",
"-n, m = I()",
"+n, m, *t = list(map(int, open(0).read().split()))",
"-for a, b in sorted(I() for _ in [0] * n):",
"+for a, b in sorted(zip(t[::2], t[1::2])):"
] | false | 0.042691 | 0.043128 | 0.989871 | [
"s046512682",
"s656779374"
] |
u626684023 | p02899 | python | s264905583 | s754247560 | 191 | 119 | 20,704 | 13,880 | Accepted | Accepted | 37.7 | N = int(input())
A = [int(i) for i in input().split()]
dic = {}
for i, j in enumerate(A):
dic[j] = i + 1
for k in range(1, N + 1):
print(dic[k], end = " ")
| N = int(eval(input()))
A = [int(i) for i in input().split()]
ans = [0] * N
for i in range(N):
ans[A[i] - 1] = i + 1
print((*ans)) | 7 | 6 | 169 | 130 | N = int(input())
A = [int(i) for i in input().split()]
dic = {}
for i, j in enumerate(A):
dic[j] = i + 1
for k in range(1, N + 1):
print(dic[k], end=" ")
| N = int(eval(input()))
A = [int(i) for i in input().split()]
ans = [0] * N
for i in range(N):
ans[A[i] - 1] = i + 1
print((*ans))
| false | 14.285714 | [
"-N = int(input())",
"+N = int(eval(input()))",
"-dic = {}",
"-for i, j in enumerate(A):",
"- dic[j] = i + 1",
"-for k in range(1, N + 1):",
"- print(dic[k], end=\" \")",
"+ans = [0] * N",
"+for i in range(N):",
"+ ans[A[i] - 1] = i + 1",
"+print((*ans))"
] | false | 0.099098 | 0.197416 | 0.501976 | [
"s264905583",
"s754247560"
] |
u930705402 | p02973 | python | s102340175 | s939147691 | 758 | 600 | 48,088 | 51,032 | Accepted | Accepted | 20.84 | from collections import deque
from bisect import bisect_left
N=int(eval(input()))
que=deque()
ans=0
for i in range(N):
a=int(eval(input()))
b=bisect_left(que,a)
if b-1<0:
que.appendleft(a)
ans+=1
else:
que[b-1]=a
print(ans) | from collections import deque
from bisect import bisect_left
N=int(eval(input()))
li=[]
ans=0
for i in range(N):
a=-int(eval(input()))
b=bisect_left(li,a+1)
if b==len(li):
li.append(a)
ans+=1
else:
li[b]=a
print(ans) | 14 | 14 | 264 | 257 | from collections import deque
from bisect import bisect_left
N = int(eval(input()))
que = deque()
ans = 0
for i in range(N):
a = int(eval(input()))
b = bisect_left(que, a)
if b - 1 < 0:
que.appendleft(a)
ans += 1
else:
que[b - 1] = a
print(ans)
| from collections import deque
from bisect import bisect_left
N = int(eval(input()))
li = []
ans = 0
for i in range(N):
a = -int(eval(input()))
b = bisect_left(li, a + 1)
if b == len(li):
li.append(a)
ans += 1
else:
li[b] = a
print(ans)
| false | 0 | [
"-que = deque()",
"+li = []",
"- a = int(eval(input()))",
"- b = bisect_left(que, a)",
"- if b - 1 < 0:",
"- que.appendleft(a)",
"+ a = -int(eval(input()))",
"+ b = bisect_left(li, a + 1)",
"+ if b == len(li):",
"+ li.append(a)",
"- que[b - 1] = a",
"+ ... | false | 0.038667 | 0.117353 | 0.32949 | [
"s102340175",
"s939147691"
] |
u177411511 | p03240 | python | s556569627 | s394466412 | 625 | 38 | 3,064 | 3,064 | Accepted | Accepted | 93.92 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
n = ni()
x_li = []
y_li = []
h_li = []
for i in range(n):
x, y, h = na()
x_li.append(x)
y_li.append(y)
h_li.append... | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
n = ni()
x_li = []
y_li = []
h_li = []
for i in range(n):
x, y, h = na()
x_li.append(x)
y_li.append(y)
h_li.append... | 46 | 39 | 1,111 | 905 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
n = ni()
x_li = []
y_li = []
h_li = []
for i in range(n):
x, y, h = na()
x_li.append(x)
y_li.append(y)
h_li.append(h)
H = -1
ansX = ... | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
n = ni()
x_li = []
y_li = []
h_li = []
for i in range(n):
x, y, h = na()
x_li.append(x)
y_li.append(y)
h_li.append(h)
ans = []
flag ... | false | 15.217391 | [
"-H = -1",
"-ansX = -1",
"-ansY = -1",
"+ans = []",
"-if h_li.count(0) == len(h_li) - 1:",
"- idx = h_li.index(1)",
"- print((x_li[idx], y_li[idx], h_li[idx]))",
"-else:",
"- for x in range(101):",
"- for y in range(101):",
"- for i in range(n):",
"- t... | false | 0.182093 | 0.039016 | 4.667189 | [
"s556569627",
"s394466412"
] |
u330314953 | p03814 | python | s793440580 | s321276944 | 61 | 42 | 3,516 | 3,516 | Accepted | Accepted | 31.15 | s = str(eval(input()))
z = 0
a = s.find("A")
for i in range(len(s)):
if s[i] == "Z":
z = max(z,i)
print((z - a + 1)) | s = str(eval(input()))
cnt_1, cnt_2 = 0, 0
for i in range(len(s)):
if s[i] == 'A':
cnt_1 = i
break
for i in range(len(s)):
if s[i] == 'Z':
cnt_2 = i
print((cnt_2 - cnt_1 + 1)) | 11 | 10 | 129 | 208 | s = str(eval(input()))
z = 0
a = s.find("A")
for i in range(len(s)):
if s[i] == "Z":
z = max(z, i)
print((z - a + 1))
| s = str(eval(input()))
cnt_1, cnt_2 = 0, 0
for i in range(len(s)):
if s[i] == "A":
cnt_1 = i
break
for i in range(len(s)):
if s[i] == "Z":
cnt_2 = i
print((cnt_2 - cnt_1 + 1))
| false | 9.090909 | [
"-z = 0",
"-a = s.find(\"A\")",
"+cnt_1, cnt_2 = 0, 0",
"+for i in range(len(s)):",
"+ if s[i] == \"A\":",
"+ cnt_1 = i",
"+ break",
"- z = max(z, i)",
"-print((z - a + 1))",
"+ cnt_2 = i",
"+print((cnt_2 - cnt_1 + 1))"
] | false | 0.036757 | 0.040119 | 0.916191 | [
"s793440580",
"s321276944"
] |
u844005364 | p03013 | python | s535506098 | s160405361 | 199 | 183 | 7,848 | 13,192 | Accepted | Accepted | 8.04 | n, m = list(map(int, input().split()))
arr = [int(eval(input())) for _ in range(m)]
mod = 10 ** 9 + 7
dp = [0] * (n + 1)
dp[0] = 1
j = 0
for i in range(1, n + 1):
if j < m and i == arr[j]:
dp[i] = 0
j += 1
continue
if i == 1:
dp[1] = dp[0]
continue
... | n, m = list(map(int, input().split()))
arr = [int(eval(input())) for _ in range(m)]
broken = set(arr)
mod = 10 ** 9 + 7
dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n + 1):
if i in broken:
continue
if i == 1:
dp[1] = dp[0]
continue
dp[i] = dp[i - 1] + dp[i -... | 22 | 22 | 375 | 346 | n, m = list(map(int, input().split()))
arr = [int(eval(input())) for _ in range(m)]
mod = 10**9 + 7
dp = [0] * (n + 1)
dp[0] = 1
j = 0
for i in range(1, n + 1):
if j < m and i == arr[j]:
dp[i] = 0
j += 1
continue
if i == 1:
dp[1] = dp[0]
continue
dp[i] = dp[i - 1] + d... | n, m = list(map(int, input().split()))
arr = [int(eval(input())) for _ in range(m)]
broken = set(arr)
mod = 10**9 + 7
dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n + 1):
if i in broken:
continue
if i == 1:
dp[1] = dp[0]
continue
dp[i] = dp[i - 1] + dp[i - 2]
dp[i] %= mod
print... | false | 0 | [
"+broken = set(arr)",
"-j = 0",
"- if j < m and i == arr[j]:",
"- dp[i] = 0",
"- j += 1",
"+ if i in broken:"
] | false | 0.046319 | 0.046019 | 1.006516 | [
"s535506098",
"s160405361"
] |
u532966492 | p02816 | python | s394195693 | s469366384 | 907 | 670 | 81,448 | 55,820 | Accepted | Accepted | 26.13 | def main():
mod, pow3, pow3i, p = 2**61-1, [1]*400001, [1]*200001, 1
i3 = pow(3, mod-2, mod)
for i in range(1, 400001):
pow3[i] = p = p*3 % mod
p = 1
for i in range(1, 200001):
pow3i[i] = p = p*i3 % mod
class rolling_hash():
def __init__(self, seq, char_list=No... | def main():
def z_algo(S):
n, i, j = len(S), 1, 0
a = [0]*n
a[0] = n
while i < n:
while i+j < n and S[i+j] == S[j]:
j += 1
if not j:
i += 1
continue
a[i], k = j, 1
while a[k] <... | 37 | 33 | 1,239 | 820 | def main():
mod, pow3, pow3i, p = 2**61 - 1, [1] * 400001, [1] * 200001, 1
i3 = pow(3, mod - 2, mod)
for i in range(1, 400001):
pow3[i] = p = p * 3 % mod
p = 1
for i in range(1, 200001):
pow3i[i] = p = p * i3 % mod
class rolling_hash:
def __init__(self, seq, char_list=No... | def main():
def z_algo(S):
n, i, j = len(S), 1, 0
a = [0] * n
a[0] = n
while i < n:
while i + j < n and S[i + j] == S[j]:
j += 1
if not j:
i += 1
continue
a[i], k = j, 1
while a[k] < j - k... | false | 10.810811 | [
"- mod, pow3, pow3i, p = 2**61 - 1, [1] * 400001, [1] * 200001, 1",
"- i3 = pow(3, mod - 2, mod)",
"- for i in range(1, 400001):",
"- pow3[i] = p = p * 3 % mod",
"- p = 1",
"- for i in range(1, 200001):",
"- pow3i[i] = p = p * i3 % mod",
"-",
"- class rolling_hash:",
... | false | 0.303819 | 0.125612 | 2.418709 | [
"s394195693",
"s469366384"
] |
u869790980 | p03448 | python | s090231810 | s073190729 | 402 | 216 | 90,820 | 77,372 | Accepted | Accepted | 46.27 | a = int(input())
b = int(input())
c = int(input())
x = int(input())
def dfs(x, i, m, v):
if x < 0: return 0
if x == 0 or i == 3:
return 1 if x == 0 else 0
r = 0
for k in range(0, m[i] + 1): r += dfs(x - k * v[i], i + 1, m, v)
return r
m,v = {0:a,1:b,2:c}, {0:500,1:100,2:50}
print(d... | m,v = {i: int(input()) for i in range(3)}, {0:500,1:100,2:50}
x = int(input())
def dfs(x, i, m, v):
if x < 0: return 0
if x == 0 or i == 3:
return 1 if x == 0 else 0
r = 0
for k in range(0, m[i] + 1): r += dfs(x - k * v[i], i + 1, m, v)
return r
print(dfs(x,0,m,v))
| 14 | 11 | 348 | 308 | a = int(input())
b = int(input())
c = int(input())
x = int(input())
def dfs(x, i, m, v):
if x < 0:
return 0
if x == 0 or i == 3:
return 1 if x == 0 else 0
r = 0
for k in range(0, m[i] + 1):
r += dfs(x - k * v[i], i + 1, m, v)
return r
m, v = {0: a, 1: b, 2: c}, {0: 500, 1... | m, v = {i: int(input()) for i in range(3)}, {0: 500, 1: 100, 2: 50}
x = int(input())
def dfs(x, i, m, v):
if x < 0:
return 0
if x == 0 or i == 3:
return 1 if x == 0 else 0
r = 0
for k in range(0, m[i] + 1):
r += dfs(x - k * v[i], i + 1, m, v)
return r
print(dfs(x, 0, m, v... | false | 21.428571 | [
"-a = int(input())",
"-b = int(input())",
"-c = int(input())",
"+m, v = {i: int(input()) for i in range(3)}, {0: 500, 1: 100, 2: 50}",
"-m, v = {0: a, 1: b, 2: c}, {0: 500, 1: 100, 2: 50}"
] | false | 0.039345 | 0.039503 | 0.996012 | [
"s090231810",
"s073190729"
] |
u191874006 | p02727 | python | s100375379 | s701054870 | 502 | 366 | 105,324 | 100,076 | Accepted | Accepted | 27.09 | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from... | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from... | 46 | 30 | 987 | 716 | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collectio... | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collectio... | false | 34.782609 | [
"-r.sort(reverse=1)",
"-r = list(accumulate(r))",
"-ans = 0",
"-h = []",
"-s = sum(p[:x])",
"-s += sum(q[:y])",
"-for i in p[:x]:",
"- heappush(h, i)",
"-for i in q[:y]:",
"- heappush(h, i)",
"-ans = s",
"-for i in range(c):",
"- if len(h) > 0:",
"- f = heappop(h)",
"- ... | false | 0.035986 | 0.145519 | 0.247297 | [
"s100375379",
"s701054870"
] |
u297574184 | p03222 | python | s402813818 | s108206954 | 38 | 19 | 3,064 | 3,064 | Accepted | Accepted | 50 | MOD = 10**9 + 7
H, W, K = list(map(int, input().split()))
pats = []
for pat in range(1<<(W-1)):
for i in range(W-2):
if pat & (1<<i) and pat & (1<<(i+1)):
break
else:
pats.append(pat*2)
dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1
for i in range(H):
for j in ra... | MOD = 10**9 + 7
H, W, K = list(map(int, input().split()))
fibs = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
def getFib(i):
return fibs[i+2]
numLs, numCs, numRs = [0]*W, [0]*W, [0]*W
for j in range(W):
numCs[j] = getFib(j-1) * getFib(W-1-j-1)
numLs[j] = getFib(j-2) * getFib(W-1-j-1)
numRs[j] = getF... | 29 | 27 | 717 | 687 | MOD = 10**9 + 7
H, W, K = list(map(int, input().split()))
pats = []
for pat in range(1 << (W - 1)):
for i in range(W - 2):
if pat & (1 << i) and pat & (1 << (i + 1)):
break
else:
pats.append(pat * 2)
dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1
for i in range(H):
for j in ra... | MOD = 10**9 + 7
H, W, K = list(map(int, input().split()))
fibs = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
def getFib(i):
return fibs[i + 2]
numLs, numCs, numRs = [0] * W, [0] * W, [0] * W
for j in range(W):
numCs[j] = getFib(j - 1) * getFib(W - 1 - j - 1)
numLs[j] = getFib(j - 2) * getFib(W - 1 - j - 1)
nu... | false | 6.896552 | [
"-pats = []",
"-for pat in range(1 << (W - 1)):",
"- for i in range(W - 2):",
"- if pat & (1 << i) and pat & (1 << (i + 1)):",
"- break",
"- else:",
"- pats.append(pat * 2)",
"+fibs = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]",
"+",
"+",
"+def getFib(i):",
"+ return f... | false | 0.157926 | 0.08569 | 1.842998 | [
"s402813818",
"s108206954"
] |
u796942881 | p02947 | python | s578838279 | s556919095 | 332 | 193 | 32,000 | 21,632 | Accepted | Accepted | 41.87 | from collections import Counter
# バージョン0.14.0まで scipy.misc.comb()
# バージョン0.14.0から scipy.special.comb()
from scipy.misc import comb
# from scipy.special import comb
def main():
s = Counter(["".join(sorted(i)) for i in open(0).read().split()[1:]])
ans = 0
for v in list(s.values()):
ans +=... | from collections import defaultdict
def main():
s = ["".join(sorted(i)) for i in open(0).read().split()[1:]]
d = defaultdict(lambda: 0)
ans = 0
for i in s:
ans += d[i]
d[i] += 1
print(ans)
return
main()
| 17 | 15 | 383 | 261 | from collections import Counter
# バージョン0.14.0まで scipy.misc.comb()
# バージョン0.14.0から scipy.special.comb()
from scipy.misc import comb
# from scipy.special import comb
def main():
s = Counter(["".join(sorted(i)) for i in open(0).read().split()[1:]])
ans = 0
for v in list(s.values()):
ans += comb(v, 2,... | from collections import defaultdict
def main():
s = ["".join(sorted(i)) for i in open(0).read().split()[1:]]
d = defaultdict(lambda: 0)
ans = 0
for i in s:
ans += d[i]
d[i] += 1
print(ans)
return
main()
| false | 11.764706 | [
"-from collections import Counter",
"+from collections import defaultdict",
"-# バージョン0.14.0まで scipy.misc.comb()",
"-# バージョン0.14.0から scipy.special.comb()",
"-from scipy.misc import comb",
"-# from scipy.special import comb",
"- s = Counter([\"\".join(sorted(i)) for i in open(0).read().split()[1:]])",
... | false | 0.266216 | 0.043502 | 6.119697 | [
"s578838279",
"s556919095"
] |
u462329577 | p03047 | python | s942852792 | s630407179 | 162 | 18 | 38,384 | 2,940 | Accepted | Accepted | 88.89 | #!/usr/bin/env python3
n,k = list(map(int,input().split()))
print((n-k+1)) | n,k = list(map(int,input().split()))
print((max(0,n-k+1))) | 3 | 2 | 68 | 51 | #!/usr/bin/env python3
n, k = list(map(int, input().split()))
print((n - k + 1))
| n, k = list(map(int, input().split()))
print((max(0, n - k + 1)))
| false | 33.333333 | [
"-#!/usr/bin/env python3",
"-print((n - k + 1))",
"+print((max(0, n - k + 1)))"
] | false | 0.034489 | 0.035062 | 0.983649 | [
"s942852792",
"s630407179"
] |
u556589653 | p02801 | python | s535738530 | s456057840 | 28 | 25 | 8,972 | 8,720 | Accepted | Accepted | 10.71 | K = ord(eval(input()))
print((chr(K+1))) | print((chr(ord(eval(input()))+1))) | 2 | 1 | 33 | 26 | K = ord(eval(input()))
print((chr(K + 1)))
| print((chr(ord(eval(input())) + 1)))
| false | 50 | [
"-K = ord(eval(input()))",
"-print((chr(K + 1)))",
"+print((chr(ord(eval(input())) + 1)))"
] | false | 0.045589 | 0.045405 | 1.004055 | [
"s535738530",
"s456057840"
] |
u535423069 | p03598 | python | s062906421 | s044035008 | 21 | 18 | 3,316 | 3,064 | Accepted | Accepted | 14.29 | # Author: cr4zjh0bp
# Created: Sat Mar 14 11:48:11 UTC 2020
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
... | import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range... | 29 | 27 | 755 | 745 | # Author: cr4zjh0bp
# Created: Sat Mar 14 11:48:11 UTC 2020
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y:... | import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdi... | false | 6.896552 | [
"-# Author: cr4zjh0bp",
"-# Created: Sat Mar 14 11:48:11 UTC 2020",
"-n, k = nin(2)",
"+n = ni()",
"+k = ni()",
"- ans += min(abs(x[i] - k) * 2, abs(x[i]) * 2)",
"+ ans += min(abs(x[i]) * 2, abs(x[i] - k) * 2)"
] | false | 0.038472 | 0.035151 | 1.094472 | [
"s062906421",
"s044035008"
] |
u983918956 | p03503 | python | s971473266 | s341885840 | 255 | 219 | 3,064 | 3,064 | Accepted | Accepted | 14.12 | import itertools
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)]
b = [0,1]
ans = -float('inf')
for e in itertools.product(b,repeat=10):
e = list(e)
if e == [0]*10:
continue
res = 0
for i in range(N):
... | import itertools
inf = float('inf')
N = int(eval(input()))
F = [list(map(int,input().split())) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]
ans = -inf
for shift in itertools.product([0,1],repeat=10):
if not any(shift): continue
res = 0
for i,line in enumerate(F):
... | 20 | 22 | 505 | 492 | import itertools
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)]
b = [0, 1]
ans = -float("inf")
for e in itertools.product(b, repeat=10):
e = list(e)
if e == [0] * 10:
continue
res = 0
for i in range(N):
... | import itertools
inf = float("inf")
N = int(eval(input()))
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
ans = -inf
for shift in itertools.product([0, 1], repeat=10):
if not any(shift):
continue
res = 0
for i, line in enumerate(F):
... | false | 9.090909 | [
"+inf = float(\"inf\")",
"-F = [list(map(int, input().split())) for i in range(N)]",
"-P = [list(map(int, input().split())) for i in range(N)]",
"-b = [0, 1]",
"-ans = -float(\"inf\")",
"-for e in itertools.product(b, repeat=10):",
"- e = list(e)",
"- if e == [0] * 10:",
"+F = [list(map(int, i... | false | 0.046897 | 0.118492 | 0.395786 | [
"s971473266",
"s341885840"
] |
u761320129 | p02596 | python | s935202446 | s770834383 | 370 | 277 | 9,168 | 9,148 | Accepted | Accepted | 25.14 | K = int(eval(input()))
n = 7%K
r = 1
for i in range(10**6+5):
if n==0:
print((i+1))
exit()
r *= 10
n += r*7
r %= K
n %= K
#print(r,n)
print((-1)) | K = int(eval(input()))
k = 1
a = 7
for i in range(10**6+5):
if a%K == 0:
print(k)
exit()
a = (a*10 + 7) % K
k += 1
print((-1)) | 13 | 12 | 187 | 163 | K = int(eval(input()))
n = 7 % K
r = 1
for i in range(10**6 + 5):
if n == 0:
print((i + 1))
exit()
r *= 10
n += r * 7
r %= K
n %= K
# print(r,n)
print((-1))
| K = int(eval(input()))
k = 1
a = 7
for i in range(10**6 + 5):
if a % K == 0:
print(k)
exit()
a = (a * 10 + 7) % K
k += 1
print((-1))
| false | 7.692308 | [
"-n = 7 % K",
"-r = 1",
"+k = 1",
"+a = 7",
"- if n == 0:",
"- print((i + 1))",
"+ if a % K == 0:",
"+ print(k)",
"- r *= 10",
"- n += r * 7",
"- r %= K",
"- n %= K",
"- # print(r,n)",
"+ a = (a * 10 + 7) % K",
"+ k += 1"
] | false | 0.308457 | 0.185485 | 1.662981 | [
"s935202446",
"s770834383"
] |
u569960318 | p02408 | python | s314119824 | s219750235 | 50 | 20 | 7,736 | 7,708 | Accepted | Accepted | 60 | n = int(eval(input()))
full_set=set([x for x in range(1,14)])
cards={"S":[],"H":[],"C":[],"D":[]}
for i in range(n):
suit,num = input().split()
cards[suit].append(int(num))
for suit in ["S","H","C","D"]:
suit_set = set(cards[suit])
for num in sorted(list(full_set - suit_set)): print((suit,num)) | n = int(eval(input()))
cards = [[ s+' '+str(n) for n in range(1,14)] for s in ['S','H','C','D']]
for _ in range(n):
suit,num = input().split()
if suit=='S': cards[0][int(num)-1] = 0
elif suit=='H': cards[1][int(num)-1] = 0
elif suit=='C': cards[2][int(num)-1] = 0
elif suit=='D': cards[3][in... | 9 | 11 | 311 | 388 | n = int(eval(input()))
full_set = set([x for x in range(1, 14)])
cards = {"S": [], "H": [], "C": [], "D": []}
for i in range(n):
suit, num = input().split()
cards[suit].append(int(num))
for suit in ["S", "H", "C", "D"]:
suit_set = set(cards[suit])
for num in sorted(list(full_set - suit_set)):
pr... | n = int(eval(input()))
cards = [[s + " " + str(n) for n in range(1, 14)] for s in ["S", "H", "C", "D"]]
for _ in range(n):
suit, num = input().split()
if suit == "S":
cards[0][int(num) - 1] = 0
elif suit == "H":
cards[1][int(num) - 1] = 0
elif suit == "C":
cards[2][int(num) - 1] ... | false | 18.181818 | [
"-full_set = set([x for x in range(1, 14)])",
"-cards = {\"S\": [], \"H\": [], \"C\": [], \"D\": []}",
"-for i in range(n):",
"+cards = [[s + \" \" + str(n) for n in range(1, 14)] for s in [\"S\", \"H\", \"C\", \"D\"]]",
"+for _ in range(n):",
"- cards[suit].append(int(num))",
"-for suit in [\"S\", \... | false | 0.109987 | 0.040054 | 2.745995 | [
"s314119824",
"s219750235"
] |
u981931040 | p03845 | python | s506162763 | s468120173 | 29 | 26 | 9,160 | 9,144 | Accepted | Accepted | 10.34 | question_num = int(eval(input()))
Time = list(map(int, input().split()))
drink_num = int(eval(input()))
spent_time = sum(Time)
drink =[]
for _ in range(drink_num):
p, x = list(map(int, input().split()))
drink.append([p, x])
for p, x in drink:
print((spent_time - (Time[p - 1] - x))) | question_num = int(eval(input()))
Time = list(map(int, input().split()))
drink_num = int(eval(input()))
spent_time = sum(Time)
drink =[]
for _ in range(drink_num):
p, x = list(map(int, input().split()))
print((spent_time - (Time[p - 1] - x))) | 10 | 8 | 283 | 237 | question_num = int(eval(input()))
Time = list(map(int, input().split()))
drink_num = int(eval(input()))
spent_time = sum(Time)
drink = []
for _ in range(drink_num):
p, x = list(map(int, input().split()))
drink.append([p, x])
for p, x in drink:
print((spent_time - (Time[p - 1] - x)))
| question_num = int(eval(input()))
Time = list(map(int, input().split()))
drink_num = int(eval(input()))
spent_time = sum(Time)
drink = []
for _ in range(drink_num):
p, x = list(map(int, input().split()))
print((spent_time - (Time[p - 1] - x)))
| false | 20 | [
"- drink.append([p, x])",
"-for p, x in drink:"
] | false | 0.041967 | 0.042978 | 0.976485 | [
"s506162763",
"s468120173"
] |
u505830998 | p03592 | python | s347938576 | s266305242 | 164 | 67 | 9,240 | 64,236 | Accepted | Accepted | 59.15 | import sys
input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]
tin=lambda : list(map(int, input().split()))
lin=lambda : list(tin())
mod=1000000007
#+++++
def main():
#a = int(input())
n, m, k = tin()
#s = input()
for ni in range(n+1):
for mi in ra... | import sys
input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]
tin=lambda : list(map(int, input().split()))
lin=lambda : list(tin())
mod=1000000007
#+++++
def main():
#n = int(input())
n, m, k = tin()
#s = input()
for ni in range(n+1):
for mi in ra... | 55 | 56 | 979 | 979 | import sys
input_methods = ["clipboard", "file", "key"]
using_method = 0
input_method = input_methods[using_method]
tin = lambda: list(map(int, input().split()))
lin = lambda: list(tin())
mod = 1000000007
# +++++
def main():
# a = int(input())
n, m, k = tin()
# s = input()
for ni in range(n + 1):
... | import sys
input_methods = ["clipboard", "file", "key"]
using_method = 0
input_method = input_methods[using_method]
tin = lambda: list(map(int, input().split()))
lin = lambda: list(tin())
mod = 1000000007
# +++++
def main():
# n = int(input())
n, m, k = tin()
# s = input()
for ni in range(n + 1):
... | false | 1.785714 | [
"- # a = int(input())",
"+ # n = int(input())",
"- bn = ni * (m - mi) + (n - ni) * (mi)",
"- if bn == k:",
"+ nb = ni * (m - mi) + (n - ni) * mi",
"+ if k == nb:"
] | false | 0.0363 | 0.035382 | 1.025952 | [
"s347938576",
"s266305242"
] |
u112247039 | p02755 | python | s379220136 | s851474686 | 32 | 27 | 9,172 | 9,184 | Accepted | Accepted | 15.62 | a,b = list(map(int,input().split()))
for i in range(1,1251):
if int(i*0.08)==a and int(i*0.1)==b:
print(i); break
else:
print('-1') | a,b = list(map(int,input().split()))
low = int(min(a//0.08,b//0.1))
high = int(max((a+1)//0.08,(b+1)//0.1))
for i in range(low,high+1):
if int(i*0.08)==a and int(i*0.1)==b:
print(i); break
else:
print((-1)) | 6 | 8 | 146 | 222 | a, b = list(map(int, input().split()))
for i in range(1, 1251):
if int(i * 0.08) == a and int(i * 0.1) == b:
print(i)
break
else:
print("-1")
| a, b = list(map(int, input().split()))
low = int(min(a // 0.08, b // 0.1))
high = int(max((a + 1) // 0.08, (b + 1) // 0.1))
for i in range(low, high + 1):
if int(i * 0.08) == a and int(i * 0.1) == b:
print(i)
break
else:
print((-1))
| false | 25 | [
"-for i in range(1, 1251):",
"+low = int(min(a // 0.08, b // 0.1))",
"+high = int(max((a + 1) // 0.08, (b + 1) // 0.1))",
"+for i in range(low, high + 1):",
"- print(\"-1\")",
"+ print((-1))"
] | false | 0.037309 | 0.076183 | 0.489724 | [
"s379220136",
"s851474686"
] |
u644907318 | p03151 | python | s768786639 | s084588760 | 279 | 128 | 85,424 | 102,756 | Accepted | Accepted | 54.12 | N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = sorted([A[i]-B[i] for i in range(N)])
tot = sum(C)
cnt = 0
if tot<0:
cnt = -1
else:
a = 0
for i in range(N):
if C[i]<0:
a += C[i]
cnt += 1
else:
... | N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
P = sorted([A[i]-B[i] for i in range(N) if A[i]-B[i]>0],reverse=True)
C = [0 for _ in range(N+1)]
for i in range(1,len(P)+1):
C[i] = C[i-1]+P[i-1]
M = [B[i]-A[i] for i in range(N) if B[i]-A[i]>0]
p = sum(P)
m = sum... | 21 | 22 | 424 | 539 | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted([A[i] - B[i] for i in range(N)])
tot = sum(C)
cnt = 0
if tot < 0:
cnt = -1
else:
a = 0
for i in range(N):
if C[i] < 0:
a += C[i]
cnt += 1
else:
break
... | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
P = sorted([A[i] - B[i] for i in range(N) if A[i] - B[i] > 0], reverse=True)
C = [0 for _ in range(N + 1)]
for i in range(1, len(P) + 1):
C[i] = C[i - 1] + P[i - 1]
M = [B[i] - A[i] for i in range(N) if B[i] - A[i] > 0]
p... | false | 4.545455 | [
"-C = sorted([A[i] - B[i] for i in range(N)])",
"-tot = sum(C)",
"-cnt = 0",
"-if tot < 0:",
"- cnt = -1",
"+P = sorted([A[i] - B[i] for i in range(N) if A[i] - B[i] > 0], reverse=True)",
"+C = [0 for _ in range(N + 1)]",
"+for i in range(1, len(P) + 1):",
"+ C[i] = C[i - 1] + P[i - 1]",
"+M... | false | 0.041475 | 0.068643 | 0.604218 | [
"s768786639",
"s084588760"
] |
u313117448 | p03478 | python | s464112949 | s142364981 | 162 | 71 | 68,904 | 73,084 | Accepted | Accepted | 56.17 | inp = list(map(int,input().split()))
N = inp[0]
A = inp[1]
B = inp[2]
l=list()
for i in range(N+1):
n0 = i % 10
n1 = (i % 100 - n0) // 10
n2 = (i % 1000 - n0 - n1*10) // 100
n3 = (i % 10000 - n0 - n1*10 - n2*100) // 1000
n4 = (i % 100000 - n0 - n1*10 - n2*100 - n3*1000) // 10000
if A ... | def FindSumOfDigits(n):
s = 0
while n > 0:
s = s + n % 10
n = n // 10
return s
inp = list(map(int,input().split()))
N = inp[0]
A = inp[1]
B = inp[2]
l=list()
sd = 0
for i in range(N+1):
x = FindSumOfDigits(i)
if A <= x <= B:
sd = sd + i
print(... | 14 | 20 | 379 | 323 | inp = list(map(int, input().split()))
N = inp[0]
A = inp[1]
B = inp[2]
l = list()
for i in range(N + 1):
n0 = i % 10
n1 = (i % 100 - n0) // 10
n2 = (i % 1000 - n0 - n1 * 10) // 100
n3 = (i % 10000 - n0 - n1 * 10 - n2 * 100) // 1000
n4 = (i % 100000 - n0 - n1 * 10 - n2 * 100 - n3 * 1000) // 10000
... | def FindSumOfDigits(n):
s = 0
while n > 0:
s = s + n % 10
n = n // 10
return s
inp = list(map(int, input().split()))
N = inp[0]
A = inp[1]
B = inp[2]
l = list()
sd = 0
for i in range(N + 1):
x = FindSumOfDigits(i)
if A <= x <= B:
sd = sd + i
print(sd)
| false | 30 | [
"+def FindSumOfDigits(n):",
"+ s = 0",
"+ while n > 0:",
"+ s = s + n % 10",
"+ n = n // 10",
"+ return s",
"+",
"+",
"+sd = 0",
"- n0 = i % 10",
"- n1 = (i % 100 - n0) // 10",
"- n2 = (i % 1000 - n0 - n1 * 10) // 100",
"- n3 = (i % 10000 - n0 - n1 * 10 - n... | false | 0.034416 | 0.070681 | 0.486914 | [
"s464112949",
"s142364981"
] |
u362771726 | p02726 | python | s054671265 | s101900213 | 295 | 270 | 47,580 | 46,044 | Accepted | Accepted | 8.47 | N, X, Y = list(map(int, input().split()))
ans = [0] * (N - 1)
for i in range(1, N + 1, 1):
for j in range(i + 1, N + 1, 1):
tmp = min(
abs(j - i),
abs(X - i) + 1 + abs(j - Y),
abs(X - j) + 1 + abs(i - Y) # このパターンは
)
ans[tmp - 1] += 1
for a ... | N, X, Y = list(map(int, input().split()))
ans = [0] * (N - 1)
for i in range(1, N + 1, 1):
for j in range(i + 1, N + 1, 1):
tmp = min(
abs(j - i),
abs(X - i) + 1 + abs(j - Y)
)
ans[tmp - 1] += 1
for a in ans:
print(a) | 15 | 14 | 335 | 283 | N, X, Y = list(map(int, input().split()))
ans = [0] * (N - 1)
for i in range(1, N + 1, 1):
for j in range(i + 1, N + 1, 1):
tmp = min(
abs(j - i),
abs(X - i) + 1 + abs(j - Y),
abs(X - j) + 1 + abs(i - Y), # このパターンは
)
ans[tmp - 1] += 1
for a in ans:
pr... | N, X, Y = list(map(int, input().split()))
ans = [0] * (N - 1)
for i in range(1, N + 1, 1):
for j in range(i + 1, N + 1, 1):
tmp = min(abs(j - i), abs(X - i) + 1 + abs(j - Y))
ans[tmp - 1] += 1
for a in ans:
print(a)
| false | 6.666667 | [
"- tmp = min(",
"- abs(j - i),",
"- abs(X - i) + 1 + abs(j - Y),",
"- abs(X - j) + 1 + abs(i - Y), # このパターンは",
"- )",
"+ tmp = min(abs(j - i), abs(X - i) + 1 + abs(j - Y))"
] | false | 0.037878 | 0.036066 | 1.050264 | [
"s054671265",
"s101900213"
] |
u606045429 | p02901 | python | s338232785 | s396950897 | 1,161 | 856 | 3,188 | 3,188 | Accepted | Accepted | 26.27 | INF = float("inf")
N, M = list(map(int, input().split()))
dp = [INF] * (2 ** N)
dp[0] = 0
for _ in range(M):
a, b = list(map(int, input().split()))
C = [int(i) for i in input().split()]
mask = sum(1 << (c - 1) for c in C)
for i, dpi in enumerate(dp):
if dp[i | mask] > dpi + a:
... | def main():
INF = float("inf")
N, M = list(map(int, input().split()))
dp = [INF] * (2 ** N)
dp[0] = 0
for _ in range(M):
a, b = list(map(int, input().split()))
C = [int(i) for i in input().split()]
mask = sum(1 << (c - 1) for c in C)
for i, dpi in enume... | 17 | 22 | 391 | 500 | INF = float("inf")
N, M = list(map(int, input().split()))
dp = [INF] * (2**N)
dp[0] = 0
for _ in range(M):
a, b = list(map(int, input().split()))
C = [int(i) for i in input().split()]
mask = sum(1 << (c - 1) for c in C)
for i, dpi in enumerate(dp):
if dp[i | mask] > dpi + a:
dp[i | m... | def main():
INF = float("inf")
N, M = list(map(int, input().split()))
dp = [INF] * (2**N)
dp[0] = 0
for _ in range(M):
a, b = list(map(int, input().split()))
C = [int(i) for i in input().split()]
mask = sum(1 << (c - 1) for c in C)
for i, dpi in enumerate(dp):
... | false | 22.727273 | [
"-INF = float(\"inf\")",
"-N, M = list(map(int, input().split()))",
"-dp = [INF] * (2**N)",
"-dp[0] = 0",
"-for _ in range(M):",
"- a, b = list(map(int, input().split()))",
"- C = [int(i) for i in input().split()]",
"- mask = sum(1 << (c - 1) for c in C)",
"- for i, dpi in enumerate(dp):... | false | 0.041526 | 0.042882 | 0.968357 | [
"s338232785",
"s396950897"
] |
u347640436 | p03062 | python | s231633763 | s540223026 | 99 | 64 | 14,284 | 14,412 | Accepted | Accepted | 35.35 | n = int(eval(input()))
a = list(map(int, input().split()))
mc = 0
s = 0
m = float('inf')
for i in a:
if i < 0:
mc += 1
s += abs(i)
m = min(m, abs(i))
if mc % 2 == 0:
print(s)
else:
print((s -2 * m))
| N = int(eval(input()))
A = list(map(int, input().split()))
negatives = len([a for a in A if a < 0])
if negatives % 2 == 0:
m = 0
else:
m = min(abs(a) for a in A)
print((sum(abs(a) for a in A) - 2 * m))
| 14 | 9 | 218 | 211 | n = int(eval(input()))
a = list(map(int, input().split()))
mc = 0
s = 0
m = float("inf")
for i in a:
if i < 0:
mc += 1
s += abs(i)
m = min(m, abs(i))
if mc % 2 == 0:
print(s)
else:
print((s - 2 * m))
| N = int(eval(input()))
A = list(map(int, input().split()))
negatives = len([a for a in A if a < 0])
if negatives % 2 == 0:
m = 0
else:
m = min(abs(a) for a in A)
print((sum(abs(a) for a in A) - 2 * m))
| false | 35.714286 | [
"-n = int(eval(input()))",
"-a = list(map(int, input().split()))",
"-mc = 0",
"-s = 0",
"-m = float(\"inf\")",
"-for i in a:",
"- if i < 0:",
"- mc += 1",
"- s += abs(i)",
"- m = min(m, abs(i))",
"-if mc % 2 == 0:",
"- print(s)",
"+N = int(eval(input()))",
"+A = list(map... | false | 0.035665 | 0.040063 | 0.890228 | [
"s231633763",
"s540223026"
] |
u729133443 | p02835 | python | s313194750 | s369222632 | 174 | 29 | 38,384 | 8,964 | Accepted | Accepted | 83.33 | print(('bwuisnt'[sum(map(int,input().split()))<22::2])) | print(('bwuisnt'[eval(input().replace(*' +'))<22::2])) | 1 | 1 | 53 | 52 | print(("bwuisnt"[sum(map(int, input().split())) < 22 :: 2]))
| print(("bwuisnt"[eval(input().replace(*" +")) < 22 :: 2]))
| false | 0 | [
"-print((\"bwuisnt\"[sum(map(int, input().split())) < 22 :: 2]))",
"+print((\"bwuisnt\"[eval(input().replace(*\" +\")) < 22 :: 2]))"
] | false | 0.041239 | 0.041008 | 1.00563 | [
"s313194750",
"s369222632"
] |
u729133443 | p03395 | python | s378850127 | s708013373 | 276 | 230 | 43,228 | 13,852 | Accepted | Accepted | 16.67 | def warshall_floyd(d):
r=list(range(M+1))
for k in r:
for i in r:
for j in r:
t=d[i][k]+d[k][j]
if t<d[i][j]:
d[i][j]=t
return d
n,*a=list(map(int,open(0).read().split()))
a,b=a[:n],a[n:]
for x,y in zip(a,b):
if x==y:con... | from scipy.sparse.csgraph import floyd_warshall
n,*a=list(map(int,open(0).read().split()))
a,b=a[:n],a[n:]
d=[]
M=max(a)
for k in range(M-1,-1,-1):
s=set(a)
e=[[0]*(M+1)for _ in range(M+1)]
for i in range(M+1):e[i][i]=1
for i in d+list(range(k,0,-1)):
t=s.copy()
for x in s:
... | 37 | 21 | 835 | 540 | def warshall_floyd(d):
r = list(range(M + 1))
for k in r:
for i in r:
for j in r:
t = d[i][k] + d[k][j]
if t < d[i][j]:
d[i][j] = t
return d
n, *a = list(map(int, open(0).read().split()))
a, b = a[:n], a[n:]
for x, y in zip(a, b):
... | from scipy.sparse.csgraph import floyd_warshall
n, *a = list(map(int, open(0).read().split()))
a, b = a[:n], a[n:]
d = []
M = max(a)
for k in range(M - 1, -1, -1):
s = set(a)
e = [[0] * (M + 1) for _ in range(M + 1)]
for i in range(M + 1):
e[i][i] = 1
for i in d + list(range(k, 0, -1)):
... | false | 43.243243 | [
"-def warshall_floyd(d):",
"- r = list(range(M + 1))",
"- for k in r:",
"- for i in r:",
"- for j in r:",
"- t = d[i][k] + d[k][j]",
"- if t < d[i][j]:",
"- d[i][j] = t",
"- return d",
"-",
"+from scipy.sparse.csgraph im... | false | 0.250348 | 0.35332 | 0.70856 | [
"s378850127",
"s708013373"
] |
u073852194 | p03450 | python | s216102488 | s392899022 | 1,697 | 258 | 10,212 | 71,792 | Accepted | Accepted | 84.8 | class WeightedUnionFind():
def __init__(self,n):
self.n = n
self.parents = [i for i in range(n)]
self.rank = [0 for _ in range(n)]
self.weight = [0 for _ in range(n)]
def find(self,x):
root = x
stack = [root]
while self.parents[root] != root:
... | class DSUWeighted():
def __init__(self, n):
self.n = n
self.par_size = [-1] * n
self.wt = [0] * n
def leader(self, a):
#assert 0 <= a < self.n
x = a
order = [x]
while self.par_size[x] >= 0:
x = self.par_size[x]
order.ap... | 51 | 58 | 1,562 | 1,474 | class WeightedUnionFind:
def __init__(self, n):
self.n = n
self.parents = [i for i in range(n)]
self.rank = [0 for _ in range(n)]
self.weight = [0 for _ in range(n)]
def find(self, x):
root = x
stack = [root]
while self.parents[root] != root:
... | class DSUWeighted:
def __init__(self, n):
self.n = n
self.par_size = [-1] * n
self.wt = [0] * n
def leader(self, a):
# assert 0 <= a < self.n
x = a
order = [x]
while self.par_size[x] >= 0:
x = self.par_size[x]
order.append(x)
... | false | 12.068966 | [
"-class WeightedUnionFind:",
"+class DSUWeighted:",
"- self.parents = [i for i in range(n)]",
"- self.rank = [0 for _ in range(n)]",
"- self.weight = [0 for _ in range(n)]",
"+ self.par_size = [-1] * n",
"+ self.wt = [0] * n",
"- def find(self, x):",
"- r... | false | 0.040045 | 0.040162 | 0.997084 | [
"s216102488",
"s392899022"
] |
u644907318 | p03213 | python | s799050937 | s123524186 | 100 | 62 | 63,652 | 63,704 | Accepted | Accepted | 38 | P = [1 for _ in range(100)]
P[0]=0
P[1]=0
for i in range(2,11):
for j in range(i*i,100,i):
P[j] = 0
Q = []
for i in range(2,100):
if P[i]==1:
Q.append(i)
C = {q:0 for q in Q}
N = int(eval(input()))
for i in range(2,N+1):
x = i
for q in Q:
while x%q==0:
... | P = [1 for _ in range(100)]
P[0]=0
P[1]=0
for i in range(2,11):
for j in range(i**2,100,i):
P[j] = 0
Q = []
for i in range(100):
if P[i]==1:
Q.append(i)
N = int(eval(input()))
C = {p:0 for p in Q}
for i in range(2,N+1):
for p in Q:
if i%p==0:
x = i
... | 35 | 48 | 757 | 904 | P = [1 for _ in range(100)]
P[0] = 0
P[1] = 0
for i in range(2, 11):
for j in range(i * i, 100, i):
P[j] = 0
Q = []
for i in range(2, 100):
if P[i] == 1:
Q.append(i)
C = {q: 0 for q in Q}
N = int(eval(input()))
for i in range(2, N + 1):
x = i
for q in Q:
while x % q == 0:
... | P = [1 for _ in range(100)]
P[0] = 0
P[1] = 0
for i in range(2, 11):
for j in range(i**2, 100, i):
P[j] = 0
Q = []
for i in range(100):
if P[i] == 1:
Q.append(i)
N = int(eval(input()))
C = {p: 0 for p in Q}
for i in range(2, N + 1):
for p in Q:
if i % p == 0:
x = i
... | false | 27.083333 | [
"- for j in range(i * i, 100, i):",
"+ for j in range(i**2, 100, i):",
"-for i in range(2, 100):",
"+for i in range(100):",
"-C = {q: 0 for q in Q}",
"+C = {p: 0 for p in Q}",
"- x = i",
"- for q in Q:",
"- while x % q == 0:",
"- x = x // q",
"- C[q] += 1... | false | 0.03792 | 0.036509 | 1.038652 | [
"s799050937",
"s123524186"
] |
u380524497 | p02788 | python | s912254110 | s984670788 | 570 | 473 | 88,932 | 55,880 | Accepted | Accepted | 17.02 | def main():
import sys
from operator import itemgetter
from collections import deque
buf = sys.stdin.buffer
n, d, a = list(map(int, buf.readline().split()))
m = list(map(int, buf.read().split()))
monsters = sorted(zip(m, m), key=itemgetter(0))
bomb_area = deque([])
... | def main():
import sys
from operator import itemgetter
buf = sys.stdin.buffer
n, d, a = list(map(int, buf.readline().split()))
m = list(map(int, buf.read().split()))
monsters = sorted(zip(m, m), key=itemgetter(0))
bomb_area = []
bomb_power = []
bomb_length = 0
total... | 37 | 39 | 1,006 | 1,007 | def main():
import sys
from operator import itemgetter
from collections import deque
buf = sys.stdin.buffer
n, d, a = list(map(int, buf.readline().split()))
m = list(map(int, buf.read().split()))
monsters = sorted(zip(m, m), key=itemgetter(0))
bomb_area = deque([])
bomb_power = dequ... | def main():
import sys
from operator import itemgetter
buf = sys.stdin.buffer
n, d, a = list(map(int, buf.readline().split()))
m = list(map(int, buf.read().split()))
monsters = sorted(zip(m, m), key=itemgetter(0))
bomb_area = []
bomb_power = []
bomb_length = 0
total_damage = 0
... | false | 5.128205 | [
"- from collections import deque",
"- bomb_area = deque([])",
"- bomb_power = deque([])",
"+ bomb_area = []",
"+ bomb_power = []",
"+ bomb_length = 0",
"+ idx = 0",
"- while bomb_area:",
"- area = bomb_area[0]",
"+ while idx < bomb_length:",
"+ ... | false | 0.085967 | 0.007252 | 11.854757 | [
"s912254110",
"s984670788"
] |
u414163108 | p02676 | python | s053123593 | s505320611 | 23 | 20 | 9,116 | 9,148 | Accepted | Accepted | 13.04 | K = int(eval(input()))
for i in range(1):
S = eval(input())
if len(S) <= K:
print(S)
else:
print((S[0 : K] + '...'))
| K = int(eval(input()))
S = eval(input())
if len(S) <= K:
print(S)
else:
print((S[0 : K] + '...'))
| 8 | 7 | 123 | 99 | K = int(eval(input()))
for i in range(1):
S = eval(input())
if len(S) <= K:
print(S)
else:
print((S[0:K] + "..."))
| K = int(eval(input()))
S = eval(input())
if len(S) <= K:
print(S)
else:
print((S[0:K] + "..."))
| false | 12.5 | [
"-for i in range(1):",
"- S = eval(input())",
"+S = eval(input())"
] | false | 0.037297 | 0.038184 | 0.976784 | [
"s053123593",
"s505320611"
] |
u065446124 | p02676 | python | s598167920 | s381454246 | 58 | 22 | 61,892 | 9,124 | Accepted | Accepted | 62.07 | def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
def YesNo(x):print("Yes")if x==True else print("No")
k=N()
s=input()
if len(s)<=k:
print(s)
else:
print(s[:k]+"...")
| import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
def YesNo(x):print("Yes")if x==True else print("No")
k=N()
s=input()
if len(... | 12 | 14 | 313 | 371 | def N():
return int(input())
def NM():
return map(int, input().split())
def L():
return list(NM())
def LN(n):
return [N() for i in range(n)]
def LL(n):
return [L() for i in range(n)]
def YesNo(x):
print("Yes") if x == True else print("No")
k = N()
s = input()
if len(s) <= k:
prin... | import sys
def input():
return sys.stdin.readline()[:-1]
def N():
return int(input())
def NM():
return map(int, input().split())
def L():
return list(NM())
def LN(n):
return [N() for i in range(n)]
def LL(n):
return [L() for i in range(n)]
def YesNo(x):
print("Yes") if x == Tru... | false | 14.285714 | [
"+import sys",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline()[:-1]",
"+",
"+"
] | false | 0.036118 | 0.076176 | 0.474138 | [
"s598167920",
"s381454246"
] |
u760794812 | p03087 | python | s458073142 | s009345691 | 1,119 | 868 | 51,032 | 9,540 | Accepted | Accepted | 22.43 | N,Q = list(map(int,input().split()))
S = eval(input())
index = [0] *(N+1)
for i in range(N):
index[i+1] = index[i] + (1 if S[i:i+2] =='AC' else 0)
for _ in range(Q):
r, l = list(map(int,input().split()))
print((index[l-1] - index[ r -1])) | N,Q = list(map(int,input().split()))
S = eval(input())
index = [0] *(N+1)
for i in range(N):
index[i+1] = index[i] + (1 if S[i:i+2]=='AC' else 0)
for _ in range(Q):
l, r = list(map(int,input().split()))
print((index[r-1] - index[l-1])) | 8 | 8 | 231 | 228 | N, Q = list(map(int, input().split()))
S = eval(input())
index = [0] * (N + 1)
for i in range(N):
index[i + 1] = index[i] + (1 if S[i : i + 2] == "AC" else 0)
for _ in range(Q):
r, l = list(map(int, input().split()))
print((index[l - 1] - index[r - 1]))
| N, Q = list(map(int, input().split()))
S = eval(input())
index = [0] * (N + 1)
for i in range(N):
index[i + 1] = index[i] + (1 if S[i : i + 2] == "AC" else 0)
for _ in range(Q):
l, r = list(map(int, input().split()))
print((index[r - 1] - index[l - 1]))
| false | 0 | [
"- r, l = list(map(int, input().split()))",
"- print((index[l - 1] - index[r - 1]))",
"+ l, r = list(map(int, input().split()))",
"+ print((index[r - 1] - index[l - 1]))"
] | false | 0.036795 | 0.035314 | 1.041943 | [
"s458073142",
"s009345691"
] |
u729133443 | p02619 | python | s844801547 | s765183144 | 82 | 31 | 68,176 | 10,164 | Accepted | Accepted | 62.2 | def func(s,x):
last=[0]*26
score=0
for i,v in enumerate(x,1):
last[v]=i
c=0
for j in range(26):
c+=s[j]*(i-last[j])
score=score+s[i*26+v]-c
print(score)
return score
def main():
d,*s=list(map(int,open(0).read().split()))
func(s,[t-... | d,*s,=list(map(int,open(i:=0).read().split()))
c,*l=[0]*27
for v in s[-d:]:
i+=1
l[v-1]=i
print((c:=c+s[i*26+v-1]-sum(x*(i-y)for x,y in zip(s,l)))) | 15 | 6 | 340 | 150 | def func(s, x):
last = [0] * 26
score = 0
for i, v in enumerate(x, 1):
last[v] = i
c = 0
for j in range(26):
c += s[j] * (i - last[j])
score = score + s[i * 26 + v] - c
print(score)
return score
def main():
d, *s = list(map(int, open(0).read().sp... | (
d,
*s,
) = list(map(int, open(i := 0).read().split()))
c, *l = [0] * 27
for v in s[-d:]:
i += 1
l[v - 1] = i
print((c := c + s[i * 26 + v - 1] - sum(x * (i - y) for x, y in zip(s, l))))
| false | 60 | [
"-def func(s, x):",
"- last = [0] * 26",
"- score = 0",
"- for i, v in enumerate(x, 1):",
"- last[v] = i",
"- c = 0",
"- for j in range(26):",
"- c += s[j] * (i - last[j])",
"- score = score + s[i * 26 + v] - c",
"- print(score)",
"- retu... | false | 0.037188 | 0.054693 | 0.679935 | [
"s844801547",
"s765183144"
] |
u620084012 | p04045 | python | s021350638 | s852422102 | 189 | 38 | 39,408 | 3,060 | Accepted | Accepted | 79.89 | import sys, math
def input():
return sys.stdin.readline()[:-1]
def main():
N, K = list(map(int,input().split()))
D = set(list(input().split()))
for k in range(N,100001):
s = str(k)
f = 0
for e in s:
if e in D:
f = 1
brea... | import sys, math
def input():
return sys.stdin.readline()[:-1]
def main():
N, K = list(map(int,input().split()))
D = set(input().split())
for ans in range(N,1000000):
f = 0
for e in str(ans):
if e in D:
f = 1
break
if f ... | 21 | 19 | 421 | 405 | import sys, math
def input():
return sys.stdin.readline()[:-1]
def main():
N, K = list(map(int, input().split()))
D = set(list(input().split()))
for k in range(N, 100001):
s = str(k)
f = 0
for e in s:
if e in D:
f = 1
break
... | import sys, math
def input():
return sys.stdin.readline()[:-1]
def main():
N, K = list(map(int, input().split()))
D = set(input().split())
for ans in range(N, 1000000):
f = 0
for e in str(ans):
if e in D:
f = 1
break
if f == 0:
... | false | 9.52381 | [
"- D = set(list(input().split()))",
"- for k in range(N, 100001):",
"- s = str(k)",
"+ D = set(input().split())",
"+ for ans in range(N, 1000000):",
"- for e in s:",
"+ for e in str(ans):",
"- print(s)",
"+ print(ans)"
] | false | 0.040641 | 0.056013 | 0.725562 | [
"s021350638",
"s852422102"
] |
u977389981 | p03035 | python | s590888742 | s325988763 | 180 | 17 | 38,256 | 2,940 | Accepted | Accepted | 90.56 | A, B = list(map(int, input().split()))
print((0 if A <= 5 else (B if A >= 13 else B // 2))) | a, b = list(map(int, input().split()))
if a >= 13:
print(b)
elif 6 <= a <= 12:
print((b // 2))
else:
print((0)) | 3 | 7 | 86 | 119 | A, B = list(map(int, input().split()))
print((0 if A <= 5 else (B if A >= 13 else B // 2)))
| a, b = list(map(int, input().split()))
if a >= 13:
print(b)
elif 6 <= a <= 12:
print((b // 2))
else:
print((0))
| false | 57.142857 | [
"-A, B = list(map(int, input().split()))",
"-print((0 if A <= 5 else (B if A >= 13 else B // 2)))",
"+a, b = list(map(int, input().split()))",
"+if a >= 13:",
"+ print(b)",
"+elif 6 <= a <= 12:",
"+ print((b // 2))",
"+else:",
"+ print((0))"
] | false | 0.040779 | 0.042314 | 0.963712 | [
"s590888742",
"s325988763"
] |
u688375653 | p02953 | python | s560471091 | s516147846 | 128 | 92 | 15,760 | 14,252 | Accepted | Accepted | 28.12 | N=int(eval(input()))
matchNums=input().split(" ")
matchNums=list(map(int, matchNums))
plus_flgs=[-1]
if len(matchNums)==1:
print("Yes")
else:
check_array=[]
check_array_all=[]
for i in range(len(matchNums)-1):
check_array.append((matchNums[i+1] - matchNums[i]))
# ... | N=int(eval(input()))
H=list(map(int, input().split()))
flg=True
temp_max=0
for i in range(N-1):
if H[i] - H[i+1] >= 2:
flg=False
break
if temp_max - H[i+1] >= 2:
flg=False
break
elif temp_max<H[i+1]:
temp_max = H[i+1]
if flg:
print("Yes... | 35 | 20 | 945 | 340 | N = int(eval(input()))
matchNums = input().split(" ")
matchNums = list(map(int, matchNums))
plus_flgs = [-1]
if len(matchNums) == 1:
print("Yes")
else:
check_array = []
check_array_all = []
for i in range(len(matchNums) - 1):
check_array.append((matchNums[i + 1] - matchNums[i]))
# for i ... | N = int(eval(input()))
H = list(map(int, input().split()))
flg = True
temp_max = 0
for i in range(N - 1):
if H[i] - H[i + 1] >= 2:
flg = False
break
if temp_max - H[i + 1] >= 2:
flg = False
break
elif temp_max < H[i + 1]:
temp_max = H[i + 1]
if flg:
print("Yes")
e... | false | 42.857143 | [
"-matchNums = input().split(\" \")",
"-matchNums = list(map(int, matchNums))",
"-plus_flgs = [-1]",
"-if len(matchNums) == 1:",
"+H = list(map(int, input().split()))",
"+flg = True",
"+temp_max = 0",
"+for i in range(N - 1):",
"+ if H[i] - H[i + 1] >= 2:",
"+ flg = False",
"+ br... | false | 0.040739 | 0.037394 | 1.089443 | [
"s560471091",
"s516147846"
] |
u528470578 | p02971 | python | s436363877 | s662100266 | 891 | 570 | 70,580 | 14,112 | Accepted | Accepted | 36.03 | N = int(eval(input()))
A = []
for i in range(N):
A.append(int(eval(input())))
As = sorted(A, reverse=True)
for j in A:
if j == As[0]:
print((As[1]))
else:
print((As[0])) | N = int(eval(input()))
A = []
for _ in range(N):
A.append(int(eval(input())))
Af = sorted(A, reverse=True)
for a in A:
if a == Af[0]:
print((Af[1]))
else:
print((Af[0])) | 11 | 10 | 196 | 190 | N = int(eval(input()))
A = []
for i in range(N):
A.append(int(eval(input())))
As = sorted(A, reverse=True)
for j in A:
if j == As[0]:
print((As[1]))
else:
print((As[0]))
| N = int(eval(input()))
A = []
for _ in range(N):
A.append(int(eval(input())))
Af = sorted(A, reverse=True)
for a in A:
if a == Af[0]:
print((Af[1]))
else:
print((Af[0]))
| false | 9.090909 | [
"-for i in range(N):",
"+for _ in range(N):",
"-As = sorted(A, reverse=True)",
"-for j in A:",
"- if j == As[0]:",
"- print((As[1]))",
"+Af = sorted(A, reverse=True)",
"+for a in A:",
"+ if a == Af[0]:",
"+ print((Af[1]))",
"- print((As[0]))",
"+ print((Af[0])... | false | 0.035689 | 0.036179 | 0.986456 | [
"s436363877",
"s662100266"
] |
u279493135 | p03998 | python | s052902391 | s544449839 | 53 | 45 | 5,584 | 5,460 | Accepted | Accepted | 15.09 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from ... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from ... | 32 | 32 | 1,047 | 994 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import (
accumulate,
permutations,
combinations,
product,
groupby,
combinations_with_replacement,
)
from operator import itemgetter, mul
from cop... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import (
accumulate,
permutations,
combinations,
product,
groupby,
combinations_with_replacement,
)
from operator import itemgetter, mul
from cop... | false | 0 | [
"+A = deque(eval(input()))",
"+B = deque(eval(input()))",
"+C = deque(eval(input()))",
"-def ctoi(c):",
"- return ord(c) - ord(\"a\")",
"+def DFS(N):",
"+ if not eval(N):",
"+ print(N)",
"+ else:",
"+ p = eval(\"{}.popleft()\".format(N))",
"+ DFS(p.upper())",
"-SA... | false | 0.066106 | 0.120281 | 0.549599 | [
"s052902391",
"s544449839"
] |
u494927057 | p03854 | python | s823223057 | s434992088 | 87 | 19 | 3,188 | 3,188 | Accepted | Accepted | 78.16 | S = eval(input())
fstrs = ['dreamer', 'eraser', 'dream', 'erase']
flag = True
while flag:
for fstr in fstrs:
result = S.rfind(fstr)
if result >= 0 and result == len(S) - len(fstr):
# print('found: {} in {} ({})'.format(fstr, S, result))
S = S[0:result]
... | S = eval(input())
strs = ['eraser', 'erase', 'dreamer', 'dream']
for i in range(len(strs)):
S = S.replace(strs[i], '')
if len(S) > 0:
print('NO')
else:
print('YES') | 23 | 11 | 544 | 183 | S = eval(input())
fstrs = ["dreamer", "eraser", "dream", "erase"]
flag = True
while flag:
for fstr in fstrs:
result = S.rfind(fstr)
if result >= 0 and result == len(S) - len(fstr):
# print('found: {} in {} ({})'.format(fstr, S, result))
S = S[0:result]
flag = True... | S = eval(input())
strs = ["eraser", "erase", "dreamer", "dream"]
for i in range(len(strs)):
S = S.replace(strs[i], "")
if len(S) > 0:
print("NO")
else:
print("YES")
| false | 52.173913 | [
"-fstrs = [\"dreamer\", \"eraser\", \"dream\", \"erase\"]",
"-flag = True",
"-while flag:",
"- for fstr in fstrs:",
"- result = S.rfind(fstr)",
"- if result >= 0 and result == len(S) - len(fstr):",
"- # print('found: {} in {} ({})'.format(fstr, S, result))",
"- S... | false | 0.061993 | 0.080714 | 0.768059 | [
"s823223057",
"s434992088"
] |
u057109575 | p02721 | python | s353353831 | s683408544 | 300 | 134 | 56,700 | 101,244 | Accepted | Accepted | 55.33 | N, K, C = list(map(int, input().split()))
S = eval(input())
ls = []
nex = -1
for i in range(N):
if S[i] == "o" and i > nex:
ls.append(i + 1)
nex = i + C
if len(ls) == K:
break
rs = []
nex = N
for i in reversed(list(range(N))):
if S[i] == "o" and i < nex:
... | N, K, C = list(map(int, input().split()))
S = eval(input())
cand_l = []
cnt = 0
rest = 0
for i in range(N):
if S[i] == "o" and rest <= 0 and cnt < K:
cand_l.append(i + 1)
rest = C
cnt += 1
else:
rest -= 1
cand_r = []
cnt = 0
rest = 0
for i in reversed(list(rang... | 26 | 28 | 470 | 529 | N, K, C = list(map(int, input().split()))
S = eval(input())
ls = []
nex = -1
for i in range(N):
if S[i] == "o" and i > nex:
ls.append(i + 1)
nex = i + C
if len(ls) == K:
break
rs = []
nex = N
for i in reversed(list(range(N))):
if S[i] == "o" and i < nex:
rs.append(i + 1)
... | N, K, C = list(map(int, input().split()))
S = eval(input())
cand_l = []
cnt = 0
rest = 0
for i in range(N):
if S[i] == "o" and rest <= 0 and cnt < K:
cand_l.append(i + 1)
rest = C
cnt += 1
else:
rest -= 1
cand_r = []
cnt = 0
rest = 0
for i in reversed(list(range(N))):
if S[i]... | false | 7.142857 | [
"-ls = []",
"-nex = -1",
"+cand_l = []",
"+cnt = 0",
"+rest = 0",
"- if S[i] == \"o\" and i > nex:",
"- ls.append(i + 1)",
"- nex = i + C",
"- if len(ls) == K:",
"- break",
"-rs = []",
"-nex = N",
"+ if S[i] == \"o\" and rest <= 0 and cnt < K:",
"+ cand... | false | 0.007037 | 0.036755 | 0.191463 | [
"s353353831",
"s683408544"
] |
u072053884 | p02279 | python | s622295604 | s243083699 | 2,540 | 1,390 | 55,664 | 55,676 | Accepted | Accepted | 45.28 | class Node:
def __init__(self, num, parent, children):
self.id = num
self.parent = -1
self.children = children
self.depth = 0
def show_info(self):
print('node {0}: '.format(self.id), end = '')
print('parent = {0}, '.format(self.parent), end = '')... | class Node:
def __init__(self, num, parent, children):
self.id = num
self.parent = -1
self.children = children
self.depth = 0
def show_info(self):
print('node {0}: '.format(self.id), end = '')
print('parent = {0}, '.format(self.parent), end = '')... | 53 | 51 | 1,269 | 1,228 | class Node:
def __init__(self, num, parent, children):
self.id = num
self.parent = -1
self.children = children
self.depth = 0
def show_info(self):
print("node {0}: ".format(self.id), end="")
print("parent = {0}, ".format(self.parent), end="")
print("depth... | class Node:
def __init__(self, num, parent, children):
self.id = num
self.parent = -1
self.children = children
self.depth = 0
def show_info(self):
print("node {0}: ".format(self.id), end="")
print("parent = {0}, ".format(self.parent), end="")
print("depth... | false | 3.773585 | [
"- rn_check_list.remove(n)",
"+ T[-1] -= n",
"-rn_check_list = [i for i in range(n)]",
"+T.append(int(n * (n - 1) / 2))",
"-rn_i = rn_check_list[0]",
"-set_pd(T[rn_i], -1, 0)",
"-for n in T:",
"+set_pd(T[T[-1]], -1, 0)",
"+for n in T[:-1]:"
] | false | 0.039668 | 0.038722 | 1.02444 | [
"s622295604",
"s243083699"
] |
u988402778 | p03026 | python | s500547662 | s692723094 | 97 | 82 | 9,604 | 9,640 | Accepted | Accepted | 15.46 | # for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(x, y) returns the tuple (x//y, x%y)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
# visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
# delete line: Ctrl+Shift+k
# choose sa... | # for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(x, y) returns the tuple (x//y, x%y)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
# visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
# delete line: Ctrl+Shift+k
# choose sa... | 94 | 97 | 3,042 | 3,122 | # for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(x, y) returns the tuple (x//y, x%y)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
# visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
# delete line: Ctrl+Shift+k
# choose same wor... | # for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(x, y) returns the tuple (x//y, x%y)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
# visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
# delete line: Ctrl+Shift+k
# choose same wor... | false | 3.092784 | [
"+input2 = sys.stdin.readline",
"+R2 = lambda: list(map(int, input2().split()))",
"-ab = [R() for i in range(n - 1)]",
"-c = R()",
"+ab = [R2() for i in range(n - 1)]",
"+c = R2()"
] | false | 0.052713 | 0.04531 | 1.163389 | [
"s500547662",
"s692723094"
] |
u867005447 | p03031 | python | s030972481 | s824348641 | 37 | 29 | 3,064 | 3,064 | Accepted | Accepted | 21.62 | n, m = list(map(int, input().split()))
s = []
for _ in range(m):
tmp = list(map(int, input().split()))
s.append(tmp[1:])
p = list(map(int, input().split()))
ans = 0
for bit in range(0, 1 << n):
flag = 1
for i in range(m):
on_count = 0
for switch in s[i]:
if bit ... | n, m = list(map(int, input().split()))
s = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for bit in range(1 << n):
flag = 1
for i in range(m):
on_count = 0
for switch in s[i]:
if bit & (1 << (switch-1)):
... | 20 | 16 | 472 | 433 | n, m = list(map(int, input().split()))
s = []
for _ in range(m):
tmp = list(map(int, input().split()))
s.append(tmp[1:])
p = list(map(int, input().split()))
ans = 0
for bit in range(0, 1 << n):
flag = 1
for i in range(m):
on_count = 0
for switch in s[i]:
if bit & (1 << (switc... | n, m = list(map(int, input().split()))
s = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for bit in range(1 << n):
flag = 1
for i in range(m):
on_count = 0
for switch in s[i]:
if bit & (1 << (switch - 1)):
on_count... | false | 20 | [
"-s = []",
"-for _ in range(m):",
"- tmp = list(map(int, input().split()))",
"- s.append(tmp[1:])",
"+s = [list(map(int, input().split()))[1:] for _ in range(m)]",
"-for bit in range(0, 1 << n):",
"+for bit in range(1 << n):",
"- if flag == 1:",
"- ans += 1",
"+ break",
... | false | 0.037293 | 0.03636 | 1.025657 | [
"s030972481",
"s824348641"
] |
u334712262 | p02550 | python | s447384823 | s612521334 | 567 | 360 | 94,052 | 88,708 | Accepted | Accepted | 36.51 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with... | 101 | 99 | 1,795 | 1,782 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import (
combinations,
combinations_wit... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import (
combinations,
combinations_wit... | false | 1.980198 | [
"- x = X",
"- s = [X]",
"+ s = [x]"
] | false | 0.036536 | 0.087008 | 0.419909 | [
"s447384823",
"s612521334"
] |
u014333473 | p03854 | python | s392627719 | s963605918 | 71 | 59 | 9,136 | 9,236 | Accepted | Accepted | 16.9 | S = input()[::-1]
word = ['dream'[::-1], 'dreamer'[::-1], 'erase'[::-1], 'eraser'[::-1]]
judge = [True, True, True, True]
count = 0
while any(judge):
for i in range(len(word)):
if S[:len(word[i])] == word[i]:
S = S[len(word[i]):]
else:
count += 1
if S == '':
print('YES')
... | a,b,c,d=[i[::-1] for i in ['dream','dreamer','erase','eraser']]
s,j=input()[::-1],True
while j:
j=False
for i in [a,b,c,d]:
if s.startswith(i): s=s[len(i):];j=True
print(('YNEOS'[len(s)>0::2])) | 17 | 7 | 394 | 205 | S = input()[::-1]
word = ["dream"[::-1], "dreamer"[::-1], "erase"[::-1], "eraser"[::-1]]
judge = [True, True, True, True]
count = 0
while any(judge):
for i in range(len(word)):
if S[: len(word[i])] == word[i]:
S = S[len(word[i]) :]
else:
count += 1
if S == "":
... | a, b, c, d = [i[::-1] for i in ["dream", "dreamer", "erase", "eraser"]]
s, j = input()[::-1], True
while j:
j = False
for i in [a, b, c, d]:
if s.startswith(i):
s = s[len(i) :]
j = True
print(("YNEOS"[len(s) > 0 :: 2]))
| false | 58.823529 | [
"-S = input()[::-1]",
"-word = [\"dream\"[::-1], \"dreamer\"[::-1], \"erase\"[::-1], \"eraser\"[::-1]]",
"-judge = [True, True, True, True]",
"-count = 0",
"-while any(judge):",
"- for i in range(len(word)):",
"- if S[: len(word[i])] == word[i]:",
"- S = S[len(word[i]) :]",
"- ... | false | 0.038992 | 0.142144 | 0.274309 | [
"s392627719",
"s963605918"
] |
u452512115 | p02780 | python | s887357993 | s462003367 | 207 | 162 | 25,060 | 18,456 | Accepted | Accepted | 21.74 | N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
lst = [0]
for x in P:
lst.append(lst[-1] + (x+1)/2)
res = -1
for i in range(N-K+1):
sum = lst[i+K]-lst[i]
res = max(res, sum)
print(("{:.6f}".format(res)))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
data = np.fromstring(read(), np.int64, sep=' ')
N, K = data[:2]
P = np.hstack([[0], data[2:] + 1])
Pcum = P.cumsum()
x = Pcum[K:] - Pcum[0:-K]
print((x.max() / 2))
| 13 | 15 | 244 | 316 | N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
lst = [0]
for x in P:
lst.append(lst[-1] + (x + 1) / 2)
res = -1
for i in range(N - K + 1):
sum = lst[i + K] - lst[i]
res = max(res, sum)
print(("{:.6f}".format(res)))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
data = np.fromstring(read(), np.int64, sep=" ")
N, K = data[:2]
P = np.hstack([[0], data[2:] + 1])
Pcum = P.cumsum()
x = Pcum[K:] - Pcum[0:-K]
print((x.max() / 2))
| false | 13.333333 | [
"-N, K = list(map(int, input().split()))",
"-P = list(map(int, input().split()))",
"-lst = [0]",
"-for x in P:",
"- lst.append(lst[-1] + (x + 1) / 2)",
"-res = -1",
"-for i in range(N - K + 1):",
"- sum = lst[i + K] - lst[i]",
"- res = max(res, sum)",
"-print((\"{:.6f}\".format(res)))",
... | false | 0.038794 | 0.279036 | 0.13903 | [
"s887357993",
"s462003367"
] |
u063052907 | p03244 | python | s070673222 | s923953662 | 118 | 101 | 21,076 | 21,084 | Accepted | Accepted | 14.41 | from collections import Counter, OrderedDict
n = int(eval(input()))
lst_v = list(map(int, input().split()))
if len(set(lst_v)) == 1:
ans = n // 2
else:
lst_odd = [lst_v[i] for i in range(n) if i%2==0]
lst_even = [lst_v[i] for i in range(n) if i%2!=0]
cnt_odd = sorted(list(Counter(lst_odd... | from collections import Counter
n = int(eval(input()))
lst_v = list(map(int, input().split()))
if len(set(lst_v)) == 1:
ans = n // 2
else:
lst_odd = lst_v[::2]
lst_even = lst_v[1::2]
cnt_odd = sorted(list(Counter(lst_odd).items()), key=lambda x: -x[1])
cnt_even = sorted(list(Counter... | 25 | 29 | 754 | 765 | from collections import Counter, OrderedDict
n = int(eval(input()))
lst_v = list(map(int, input().split()))
if len(set(lst_v)) == 1:
ans = n // 2
else:
lst_odd = [lst_v[i] for i in range(n) if i % 2 == 0]
lst_even = [lst_v[i] for i in range(n) if i % 2 != 0]
cnt_odd = sorted(list(Counter(lst_odd).items... | from collections import Counter
n = int(eval(input()))
lst_v = list(map(int, input().split()))
if len(set(lst_v)) == 1:
ans = n // 2
else:
lst_odd = lst_v[::2]
lst_even = lst_v[1::2]
cnt_odd = sorted(list(Counter(lst_odd).items()), key=lambda x: -x[1])
cnt_even = sorted(list(Counter(lst_even).items... | false | 13.793103 | [
"-from collections import Counter, OrderedDict",
"+from collections import Counter",
"- lst_odd = [lst_v[i] for i in range(n) if i % 2 == 0]",
"- lst_even = [lst_v[i] for i in range(n) if i % 2 != 0]",
"+ lst_odd = lst_v[::2]",
"+ lst_even = lst_v[1::2]",
"- if cnt_odd[0][0] == cnt_even[0... | false | 0.036022 | 0.035803 | 1.006108 | [
"s070673222",
"s923953662"
] |
u057109575 | p02936 | python | s904269216 | s140134664 | 1,997 | 801 | 122,476 | 182,608 | Accepted | Accepted | 59.89 | from collections import deque
N, Q = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N - 1)]
Y = [list(map(int, input().split())) for _ in range(Q)]
graph = [[] for _ in range(N + 1)]
for a, b in X:
graph[a].append(b)
graph[b].append(a)
ctr = [0] * (N + 1)
for ... | from collections import deque
N, Q = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N - 1)]
Y = [list(map(int, input().split())) for _ in range(Q)]
tree = [0] * (N + 1)
for p, x in Y:
tree[p] += x
graph = [[] for _ in range(N + 1)]
for a, b in X:
graph[a].appe... | 30 | 28 | 631 | 643 | from collections import deque
N, Q = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N - 1)]
Y = [list(map(int, input().split())) for _ in range(Q)]
graph = [[] for _ in range(N + 1)]
for a, b in X:
graph[a].append(b)
graph[b].append(a)
ctr = [0] * (N + 1)
for p, x in Y:
... | from collections import deque
N, Q = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N - 1)]
Y = [list(map(int, input().split())) for _ in range(Q)]
tree = [0] * (N + 1)
for p, x in Y:
tree[p] += x
graph = [[] for _ in range(N + 1)]
for a, b in X:
graph[a].append(b)
grap... | false | 6.666667 | [
"+tree = [0] * (N + 1)",
"+for p, x in Y:",
"+ tree[p] += x",
"-ctr = [0] * (N + 1)",
"-for p, x in Y:",
"- ctr[p] += x",
"-# BFS",
"-q = deque([1])",
"-while q:",
"- u = q.popleft()",
"+stack = deque()",
"+stack.append(1)",
"+while stack:",
"+ u = stack.popleft()",
"- ... | false | 0.037205 | 0.038331 | 0.970642 | [
"s904269216",
"s140134664"
] |
u905582793 | p02762 | python | s745323404 | s825353599 | 1,610 | 1,138 | 127,192 | 65,748 | Accepted | Accepted | 29.32 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
... | 63 | 64 | 1,626 | 1,663 | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = se... | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = se... | false | 1.5625 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.083769 | 0.072365 | 1.157586 | [
"s745323404",
"s825353599"
] |
u606045429 | p02889 | python | s586245673 | s390715574 | 1,740 | 861 | 17,500 | 40,856 | Accepted | Accepted | 50.52 | from scipy.sparse.csgraph import floyd_warshall
N, M, L = list(map(int, input().split()))
E = [[0] * N for _ in range(N)]
for _ in range(M):
a, b, c = list(map(int, input().split()))
E[a - 1][b - 1] = E[b - 1][a - 1] = c
E = floyd_warshall(E)
for i in range(N):
for j in range(N):
E[i]... | from scipy.sparse.csgraph import floyd_warshall
N, M, L, *I = list(map(int, open(0).read().split()))
ABC, ST = I[:3 * M], I[3 * M + 1:]
E = [[0] * N for _ in range(N)]
for a, b, c in zip(*[iter(ABC)] * 3):
E[a - 1][b - 1] = E[b - 1][a - 1] = c
E = floyd_warshall(E)
for i in range(N):
for j in ra... | 23 | 22 | 522 | 508 | from scipy.sparse.csgraph import floyd_warshall
N, M, L = list(map(int, input().split()))
E = [[0] * N for _ in range(N)]
for _ in range(M):
a, b, c = list(map(int, input().split()))
E[a - 1][b - 1] = E[b - 1][a - 1] = c
E = floyd_warshall(E)
for i in range(N):
for j in range(N):
E[i][j] = E[i][j] ... | from scipy.sparse.csgraph import floyd_warshall
N, M, L, *I = list(map(int, open(0).read().split()))
ABC, ST = I[: 3 * M], I[3 * M + 1 :]
E = [[0] * N for _ in range(N)]
for a, b, c in zip(*[iter(ABC)] * 3):
E[a - 1][b - 1] = E[b - 1][a - 1] = c
E = floyd_warshall(E)
for i in range(N):
for j in range(N):
... | false | 4.347826 | [
"-N, M, L = list(map(int, input().split()))",
"+N, M, L, *I = list(map(int, open(0).read().split()))",
"+ABC, ST = I[: 3 * M], I[3 * M + 1 :]",
"-for _ in range(M):",
"- a, b, c = list(map(int, input().split()))",
"+for a, b, c in zip(*[iter(ABC)] * 3):",
"-Q = int(eval(input()))",
"-for _ in range... | false | 0.676085 | 0.776715 | 0.870441 | [
"s586245673",
"s390715574"
] |
u573754721 | p02953 | python | s835396055 | s338623430 | 80 | 71 | 14,252 | 14,224 | Accepted | Accepted | 11.25 | n = int(eval(input()))
L = list(map(int,input().split()))
for i in range(n,1,-1):
if L[i-1]<L[i-2]:
L[i-2]-=1
if L[i-1]<L[i-2]:
print("No")
exit()
print("Yes") | n = int(eval(input()))
L = list(map(int,input().split()))
for i in range(n-1,0,-1):
if L[i]<L[i-1]:
L[i-1]-=1
if L[i]<L[i-1]:
print("No")
exit()
print("Yes")
| 10 | 11 | 229 | 240 | n = int(eval(input()))
L = list(map(int, input().split()))
for i in range(n, 1, -1):
if L[i - 1] < L[i - 2]:
L[i - 2] -= 1
if L[i - 1] < L[i - 2]:
print("No")
exit()
print("Yes")
| n = int(eval(input()))
L = list(map(int, input().split()))
for i in range(n - 1, 0, -1):
if L[i] < L[i - 1]:
L[i - 1] -= 1
if L[i] < L[i - 1]:
print("No")
exit()
print("Yes")
| false | 9.090909 | [
"-for i in range(n, 1, -1):",
"- if L[i - 1] < L[i - 2]:",
"- L[i - 2] -= 1",
"- if L[i - 1] < L[i - 2]:",
"+for i in range(n - 1, 0, -1):",
"+ if L[i] < L[i - 1]:",
"+ L[i - 1] -= 1",
"+ if L[i] < L[i - 1]:"
] | false | 0.094985 | 0.070824 | 1.34114 | [
"s835396055",
"s338623430"
] |
u849029577 | p03331 | python | s323963897 | s857586772 | 104 | 61 | 73,744 | 61,808 | Accepted | Accepted | 41.35 | n = int(eval(input()))
ans = 100000
for i in range(1, n):
a, b = str(i), str(n-i)
A, B = 0, 0
for x in a:
A += int(x)
for y in b:
B += int(y)
ans = min(ans, A+B)
print(ans) | n = int(eval(input()))
for i in range(1,6):
if n%(10*i) == 0:
print((10))
exit()
print((sum(list(map(int, str(n)))))) | 11 | 6 | 212 | 132 | n = int(eval(input()))
ans = 100000
for i in range(1, n):
a, b = str(i), str(n - i)
A, B = 0, 0
for x in a:
A += int(x)
for y in b:
B += int(y)
ans = min(ans, A + B)
print(ans)
| n = int(eval(input()))
for i in range(1, 6):
if n % (10 * i) == 0:
print((10))
exit()
print((sum(list(map(int, str(n))))))
| false | 45.454545 | [
"-ans = 100000",
"-for i in range(1, n):",
"- a, b = str(i), str(n - i)",
"- A, B = 0, 0",
"- for x in a:",
"- A += int(x)",
"- for y in b:",
"- B += int(y)",
"- ans = min(ans, A + B)",
"-print(ans)",
"+for i in range(1, 6):",
"+ if n % (10 * i) == 0:",
"+ ... | false | 0.239892 | 0.06935 | 3.459129 | [
"s323963897",
"s857586772"
] |
u137228327 | p02887 | python | s340593759 | s589540118 | 192 | 47 | 9,740 | 9,256 | Accepted | Accepted | 75.52 | N = int(eval(input()))
S = str(eval(input()))
#print(N,S)
stack = []
while len(S) > 0:
if len(stack) == 0:
stack.append(S[0])
S = S[1:]
elif S[0] == stack[-1]:
S = S[1:]
elif S[0] != stack[-1]:
stack.append(S[0])
S = S[1:]
#print(S,stack)
pri... | N = int(eval(input()))
S = str(eval(input()))
#print(N,S)
count = 0
for i in range(N-1):
if S[i] != S[i+1]:
count += 1
print((count+1))
| 18 | 10 | 333 | 160 | N = int(eval(input()))
S = str(eval(input()))
# print(N,S)
stack = []
while len(S) > 0:
if len(stack) == 0:
stack.append(S[0])
S = S[1:]
elif S[0] == stack[-1]:
S = S[1:]
elif S[0] != stack[-1]:
stack.append(S[0])
S = S[1:]
# print(S,stack)
print((len(stack)))
| N = int(eval(input()))
S = str(eval(input()))
# print(N,S)
count = 0
for i in range(N - 1):
if S[i] != S[i + 1]:
count += 1
print((count + 1))
| false | 44.444444 | [
"-stack = []",
"-while len(S) > 0:",
"- if len(stack) == 0:",
"- stack.append(S[0])",
"- S = S[1:]",
"- elif S[0] == stack[-1]:",
"- S = S[1:]",
"- elif S[0] != stack[-1]:",
"- stack.append(S[0])",
"- S = S[1:]",
"- # print(S,stack)",
"-print((len... | false | 0.064093 | 0.062134 | 1.031537 | [
"s340593759",
"s589540118"
] |
u693953100 | p04045 | python | s832575276 | s548416614 | 214 | 115 | 43,484 | 3,060 | Accepted | Accepted | 46.26 | n,k = list(map(int,input().split()))
d = list(input().split(' '))
def check(num):
globals()
s = str(n)
for i in d:
if i in s:
return True
return False
while(check(n)):
n+=1
print(n) | def solve():
n,k = list(map(int,input().split()))
d = set(map(int,input().split()))
for i in range(n,100000):
s = list(map(int,str(i)))
flag = True
for j in s:
if j in d:
flag = False
if flag:
print(i)
return
i... | 12 | 15 | 226 | 346 | n, k = list(map(int, input().split()))
d = list(input().split(" "))
def check(num):
globals()
s = str(n)
for i in d:
if i in s:
return True
return False
while check(n):
n += 1
print(n)
| def solve():
n, k = list(map(int, input().split()))
d = set(map(int, input().split()))
for i in range(n, 100000):
s = list(map(int, str(i)))
flag = True
for j in s:
if j in d:
flag = False
if flag:
print(i)
return
if __nam... | false | 20 | [
"-n, k = list(map(int, input().split()))",
"-d = list(input().split(\" \"))",
"+def solve():",
"+ n, k = list(map(int, input().split()))",
"+ d = set(map(int, input().split()))",
"+ for i in range(n, 100000):",
"+ s = list(map(int, str(i)))",
"+ flag = True",
"+ for j i... | false | 0.111304 | 0.126763 | 0.878045 | [
"s832575276",
"s548416614"
] |
u638282348 | p02679 | python | s976390034 | s489537708 | 1,211 | 1,117 | 90,112 | 72,012 | Accepted | Accepted | 7.76 | from math import gcd
MOD = 10 ** 9 + 7
N = int(eval(input()))
d = dict()
zeros = 0
for _ in range(N):
a, b = tuple(map(int, input().split()))
if not any((a, b)):
zeros += 1
continue
g = gcd(a, b) * (a // abs(a)) if all((a, b)) else a if a else b
p = a // g, b // g
d[p] = ... | from math import gcd
MOD = 10 ** 9 + 7
N = int(eval(input()))
d = dict()
zeros = 0
for _ in range(N):
a, b = tuple(map(int, input().split()))
if not any((a, b)):
zeros += 1
continue
g = gcd(a, b) * (a // abs(a)) if all((a, b)) else a if a else b
p = a // g, b // g
d[p] = ... | 22 | 22 | 670 | 619 | from math import gcd
MOD = 10**9 + 7
N = int(eval(input()))
d = dict()
zeros = 0
for _ in range(N):
a, b = tuple(map(int, input().split()))
if not any((a, b)):
zeros += 1
continue
g = gcd(a, b) * (a // abs(a)) if all((a, b)) else a if a else b
p = a // g, b // g
d[p] = d.get(p, 0) +... | from math import gcd
MOD = 10**9 + 7
N = int(eval(input()))
d = dict()
zeros = 0
for _ in range(N):
a, b = tuple(map(int, input().split()))
if not any((a, b)):
zeros += 1
continue
g = gcd(a, b) * (a // abs(a)) if all((a, b)) else a if a else b
p = a // g, b // g
d[p] = d.get(p, 0) +... | false | 0 | [
"-counts = dict()",
"+done = set()",
"+total = 1",
"- if counts.get((b, -a), False) or counts.get((-b, a), False):",
"+ if (b, -a) in done or (-b, a) in done:",
"- counts[(a, b)] = v, d.get((b, -a), 0) + d.get((-b, a), 0)",
"-total = 1",
"-for a, b in list(counts.values()):",
"- total = ... | false | 0.037111 | 0.036676 | 1.011849 | [
"s976390034",
"s489537708"
] |
u652057333 | p02789 | python | s615972705 | s988921789 | 173 | 17 | 38,256 | 2,940 | Accepted | Accepted | 90.17 | n, m = list(map(int, input().split()))
if n == m:
print("Yes")
else:
print("No") | n, m = list(map(int, input().split()))
print((['No', 'Yes'][n == m])) | 6 | 2 | 88 | 62 | n, m = list(map(int, input().split()))
if n == m:
print("Yes")
else:
print("No")
| n, m = list(map(int, input().split()))
print((["No", "Yes"][n == m]))
| false | 66.666667 | [
"-if n == m:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+print(([\"No\", \"Yes\"][n == m]))"
] | false | 0.037457 | 0.041453 | 0.903619 | [
"s615972705",
"s988921789"
] |
u278886389 | p03948 | python | s819250734 | s302694443 | 206 | 162 | 14,484 | 15,060 | Accepted | Accepted | 21.36 | N,T = list(map(int,input().split()))
A = list(map(int,input().split()))
h = []
B = [0]*N
for i in range(N):
h.append(A[i])
h = [min(h)]
B[i] = h[0]
j = []
C = [0]*N
for i in range(N-1,-1,-1):
j.append(A[i])
j = [max(j)]
C[i] = j[0]
B = B[:-1]
C = C[1:]
D = list([C[x]-B[... | N,T = list(map(int,input().split()))
A = list(map(int,input().split()))
B = [0]*N
C = [0]*N
h = A[0]
B[0] = h
for i in range(1,N):
h = min(A[i],h)
B[i] = h
h = A[-1]
C[-1] = h
for i in range(N-2,-1,-1):
h = max(A[i],h)
C[i] = h
B = B[:-1]
C = C[1:]
D = list([C[x]-B[x] for x in ra... | 31 | 30 | 463 | 449 | N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
h = []
B = [0] * N
for i in range(N):
h.append(A[i])
h = [min(h)]
B[i] = h[0]
j = []
C = [0] * N
for i in range(N - 1, -1, -1):
j.append(A[i])
j = [max(j)]
C[i] = j[0]
B = B[:-1]
C = C[1:]
D = list([C[x] - B[x] for x in r... | N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [0] * N
C = [0] * N
h = A[0]
B[0] = h
for i in range(1, N):
h = min(A[i], h)
B[i] = h
h = A[-1]
C[-1] = h
for i in range(N - 2, -1, -1):
h = max(A[i], h)
C[i] = h
B = B[:-1]
C = C[1:]
D = list([C[x] - B[x] for x in range(N - ... | false | 3.225806 | [
"-h = []",
"-for i in range(N):",
"- h.append(A[i])",
"- h = [min(h)]",
"- B[i] = h[0]",
"-j = []",
"-for i in range(N - 1, -1, -1):",
"- j.append(A[i])",
"- j = [max(j)]",
"- C[i] = j[0]",
"+h = A[0]",
"+B[0] = h",
"+for i in range(1, N):",
"+ h = min(A[i], h)",
"+ ... | false | 0.10507 | 0.049131 | 2.138562 | [
"s819250734",
"s302694443"
] |
u627600101 | p02580 | python | s821527818 | s368883649 | 745 | 552 | 160,912 | 154,772 | Accepted | Accepted | 25.91 | from collections import deque
import heapq
H, W, M = list(map(int, input().split()))
bomb = []
heapq.heapify(bomb)
counth = [0 for k in range(H)]
countw = [0 for k in range(W)]
for k in range(M):
h, w = list(map(int, input().split()))
h -= 1
w -= 1
heapq.heappush(bomb, h+ w*H)
counth[h] += 1
c... | from collections import deque
H, W, M = list(map(int, input().split()))
bomb = []
counth = [0 for k in range(H)]
countw = [0 for k in range(W)]
for k in range(M):
h, w = list(map(int, input().split()))
h -= 1
w -= 1
bomb.append(h+ w*H)
counth[h] += 1
countw[w] += 1
counth = deque(counth)
cou... | 64 | 65 | 1,247 | 1,227 | from collections import deque
import heapq
H, W, M = list(map(int, input().split()))
bomb = []
heapq.heapify(bomb)
counth = [0 for k in range(H)]
countw = [0 for k in range(W)]
for k in range(M):
h, w = list(map(int, input().split()))
h -= 1
w -= 1
heapq.heappush(bomb, h + w * H)
counth[h] += 1
... | from collections import deque
H, W, M = list(map(int, input().split()))
bomb = []
counth = [0 for k in range(H)]
countw = [0 for k in range(W)]
for k in range(M):
h, w = list(map(int, input().split()))
h -= 1
w -= 1
bomb.append(h + w * H)
counth[h] += 1
countw[w] += 1
counth = deque(counth)
cou... | false | 1.538462 | [
"-import heapq",
"-heapq.heapify(bomb)",
"- heapq.heappush(bomb, h + w * H)",
"+ bomb.append(h + w * H)",
"+ bomb.sort()",
"+ bomb = deque(bomb)",
"- heapq.heapify(kouho)",
"- heapq.heappush(kouho, h + H * w)",
"- B = heapq.heappop(bomb)",
"- K = heapq.heappop(kouho... | false | 0.038209 | 0.038282 | 0.998079 | [
"s821527818",
"s368883649"
] |
u777923818 | p02958 | python | s709346117 | s299470107 | 166 | 30 | 38,896 | 9,120 | Accepted | Accepted | 81.93 | def inpl(): return list(map(int, input().split()))
N = int(eval(input()))
P = inpl()
Q = sorted(P)
OK = False
for i in range(N):
for j in range(N):
P[i], P[j] = P[j], P[i]
if P == Q:
OK = True
P[i], P[j] = P[j], P[i]
print(("YES" if OK else "NO")) | def inpl(): return list(map(int, input().split()))
N = int(eval(input()))
P = inpl()
Q = sorted(P)
for i in range(N):
for j in range(i, N):
R = [p for p in P]
R[i], R[j] = R[j], R[i]
for k in range(N):
if R[k] != Q[k]:
break
else:
... | 14 | 18 | 294 | 373 | def inpl():
return list(map(int, input().split()))
N = int(eval(input()))
P = inpl()
Q = sorted(P)
OK = False
for i in range(N):
for j in range(N):
P[i], P[j] = P[j], P[i]
if P == Q:
OK = True
P[i], P[j] = P[j], P[i]
print(("YES" if OK else "NO"))
| def inpl():
return list(map(int, input().split()))
N = int(eval(input()))
P = inpl()
Q = sorted(P)
for i in range(N):
for j in range(i, N):
R = [p for p in P]
R[i], R[j] = R[j], R[i]
for k in range(N):
if R[k] != Q[k]:
break
else:
print("... | false | 22.222222 | [
"-OK = False",
"- for j in range(N):",
"- P[i], P[j] = P[j], P[i]",
"- if P == Q:",
"- OK = True",
"- P[i], P[j] = P[j], P[i]",
"-print((\"YES\" if OK else \"NO\"))",
"+ for j in range(i, N):",
"+ R = [p for p in P]",
"+ R[i], R[j] = R[j], R[i]",... | false | 0.075554 | 0.035362 | 2.136556 | [
"s709346117",
"s299470107"
] |
u046187684 | p03401 | python | s052073088 | s971446899 | 193 | 147 | 16,700 | 17,468 | Accepted | Accepted | 23.83 | def solve(string):
n, *a = list(map(int, string.split()))
a = [0] + a + [0]
base = sum([abs(j - i) for i, j in zip(a, a[1:])])
ans = []
for i in range(1, n + 1):
if min(a[i - 1], a[i + 1]) <= a[i] <= max(a[i - 1], a[i + 1]):
ans.append(str(base))
elif max(a[i - 1]... | def solve(string):
n, *a = list(map(int, string.split()))
a = [0] + a + [0]
base = sum([abs(j - i) for i, j in zip(a, a[1:])])
ans = []
for a0, a1, a2 in zip(a, a[1:], a[2:]):
if min(a0, a1, a2) == a1:
ans.append(str(base - 2 * abs(a1 - min(a0, a2))))
elif max(a0,... | 17 | 17 | 611 | 551 | def solve(string):
n, *a = list(map(int, string.split()))
a = [0] + a + [0]
base = sum([abs(j - i) for i, j in zip(a, a[1:])])
ans = []
for i in range(1, n + 1):
if min(a[i - 1], a[i + 1]) <= a[i] <= max(a[i - 1], a[i + 1]):
ans.append(str(base))
elif max(a[i - 1], a[i + ... | def solve(string):
n, *a = list(map(int, string.split()))
a = [0] + a + [0]
base = sum([abs(j - i) for i, j in zip(a, a[1:])])
ans = []
for a0, a1, a2 in zip(a, a[1:], a[2:]):
if min(a0, a1, a2) == a1:
ans.append(str(base - 2 * abs(a1 - min(a0, a2))))
elif max(a0, a1, a2)... | false | 0 | [
"- for i in range(1, n + 1):",
"- if min(a[i - 1], a[i + 1]) <= a[i] <= max(a[i - 1], a[i + 1]):",
"+ for a0, a1, a2 in zip(a, a[1:], a[2:]):",
"+ if min(a0, a1, a2) == a1:",
"+ ans.append(str(base - 2 * abs(a1 - min(a0, a2))))",
"+ elif max(a0, a1, a2) == a1:",
"+ ... | false | 0.124119 | 0.042063 | 2.950813 | [
"s052073088",
"s971446899"
] |
u950708010 | p03287 | python | s403591067 | s505217969 | 90 | 80 | 17,660 | 17,660 | Accepted | Accepted | 11.11 | from collections import Counter
import sys
input = sys.stdin.readline
def solve():
n,m = (int(i) for i in input().split())
a = list(int(i) for i in input().split())
a2 = [0]
for i in range(n):
a2.append(a[i]+a2[i])
for i in range(n+1):
a2[i] %= m
c = Counter(a2)
ans = 0
for i in lis... | from collections import Counter
from itertools import accumulate
import sys
input = sys.stdin.readline
def solve():
n,m = (int(i) for i in input().split())
a = list(int(i) for i in input().split())
a2 = [0] + list(accumulate(a))
for i in range(n+1):
a2[i] %= m
c = Counter(a2)
ans = 0
fo... | 18 | 18 | 378 | 414 | from collections import Counter
import sys
input = sys.stdin.readline
def solve():
n, m = (int(i) for i in input().split())
a = list(int(i) for i in input().split())
a2 = [0]
for i in range(n):
a2.append(a[i] + a2[i])
for i in range(n + 1):
a2[i] %= m
c = Counter(a2)
ans =... | from collections import Counter
from itertools import accumulate
import sys
input = sys.stdin.readline
def solve():
n, m = (int(i) for i in input().split())
a = list(int(i) for i in input().split())
a2 = [0] + list(accumulate(a))
for i in range(n + 1):
a2[i] %= m
c = Counter(a2)
ans =... | false | 0 | [
"+from itertools import accumulate",
"- a2 = [0]",
"- for i in range(n):",
"- a2.append(a[i] + a2[i])",
"+ a2 = [0] + list(accumulate(a))",
"-solve()",
"+if __name__ == \"__main__\":",
"+ solve()"
] | false | 0.038463 | 0.03832 | 1.003735 | [
"s403591067",
"s505217969"
] |
u495903598 | p03062 | python | s239809723 | s993231812 | 595 | 56 | 21,864 | 14,284 | Accepted | Accepted | 90.59 |
# coding: utf-8
# In[20]:
import sys
#input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
# In[21]:
import numpy as np
A.sort(key=lambda x:abs(x))
#print(N, A)
# In[25]:
A = np.array(A)
#print(sum(A<0))
if sum(A<0)%2 == 0:
print((sum(abs(A))))
else:... |
# coding: utf-8
# In[28]:
import sys
#input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
# In[21]:
#import numpy as np
#A.sort(key=lambda x:abs(x))
#print(N, A)
# In[25]:
#A = np.array(A)
#print(sum(A<0))
#if sum(A<0)%2 == 0:
# print(sum(abs(A)))
#e... | 32 | 49 | 373 | 573 | # coding: utf-8
# In[20]:
import sys
# input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
# In[21]:
import numpy as np
A.sort(key=lambda x: abs(x))
# print(N, A)
# In[25]:
A = np.array(A)
# print(sum(A<0))
if sum(A < 0) % 2 == 0:
print((sum(abs(A))))
else:
print((sum(abs(A[1... | # coding: utf-8
# In[28]:
import sys
# input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
# In[21]:
# import numpy as np
# A.sort(key=lambda x:abs(x))
# print(N, A)
# In[25]:
# A = np.array(A)
# print(sum(A<0))
# if sum(A<0)%2 == 0:
# print(sum(abs(A)))
# else:
# print(sum(abs(... | false | 34.693878 | [
"-# In[20]:",
"+# In[28]:",
"-import numpy as np",
"-",
"-A.sort(key=lambda x: abs(x))",
"+# import numpy as np",
"+# A.sort(key=lambda x:abs(x))",
"-A = np.array(A)",
"+# A = np.array(A)",
"-if sum(A < 0) % 2 == 0:",
"- print((sum(abs(A))))",
"+# if sum(A<0)%2 == 0:",
"+# print(sum(ab... | false | 0.280094 | 0.046247 | 6.056495 | [
"s239809723",
"s993231812"
] |
u273345915 | p02713 | python | s198354175 | s942583384 | 1,881 | 1,253 | 9,076 | 9,176 | Accepted | Accepted | 33.39 | from math import gcd
# def gcd(a, b):
# if a%b==0: return b
# return gcd(b, a%b)
K=int(eval(input()))
sum=0
for a in range(1,K+1):
for b in range(1,K+1):
for c in range(1,K+1):
sum+=gcd(gcd(a,b),c)
print(sum) | def gcd(a, b):
if a%b==0: return b
return gcd(b, a%b)
K=int(eval(input()))
sum=0
for a in range(1,K+1):
for b in range(a,K+1):
for c in range(b,K+1):
if a==b==c: sum+=a
elif a!=b!=c: sum+=gcd(gcd(a,b),c)*6
else: sum+=gcd(gcd(a,b),c)*3
print(sum) | 11 | 12 | 244 | 307 | from math import gcd
# def gcd(a, b):
# if a%b==0: return b
# return gcd(b, a%b)
K = int(eval(input()))
sum = 0
for a in range(1, K + 1):
for b in range(1, K + 1):
for c in range(1, K + 1):
sum += gcd(gcd(a, b), c)
print(sum)
| def gcd(a, b):
if a % b == 0:
return b
return gcd(b, a % b)
K = int(eval(input()))
sum = 0
for a in range(1, K + 1):
for b in range(a, K + 1):
for c in range(b, K + 1):
if a == b == c:
sum += a
elif a != b != c:
sum += gcd(gcd(a, b), ... | false | 8.333333 | [
"-from math import gcd",
"+def gcd(a, b):",
"+ if a % b == 0:",
"+ return b",
"+ return gcd(b, a % b)",
"-# def gcd(a, b):",
"-# if a%b==0: return b",
"-# return gcd(b, a%b)",
"+",
"- for b in range(1, K + 1):",
"- for c in range(1, K + 1):",
"- sum +=... | false | 0.044543 | 0.129733 | 0.343344 | [
"s198354175",
"s942583384"
] |
u490553751 | p03266 | python | s957054057 | s927617005 | 378 | 189 | 21,056 | 38,896 | Accepted | Accepted | 50 | import sys
import itertools
import numpy
input = sys.stdin.readline
N,K = [int(i) for i in input().split()]
if K % 2 == 1 :
index = N // K
ans = index**3
else :
index = N // K
ans = index**3
k = K // 2
indexa = (N // k) - index
ans += indexa**3
print(ans) | #template
def inputlist(): return [int(k) for k in input().split()]
#template
N,K = inputlist()
m0 = 0
mh = 0
ans = 0
for i in range(1,N+1):
d = i%K
if d == 0:
m0+=1
if d == K//2 and K % 2 == 0:
mh +=1
print((m0**3 + mh**3)) | 15 | 14 | 297 | 263 | import sys
import itertools
import numpy
input = sys.stdin.readline
N, K = [int(i) for i in input().split()]
if K % 2 == 1:
index = N // K
ans = index**3
else:
index = N // K
ans = index**3
k = K // 2
indexa = (N // k) - index
ans += indexa**3
print(ans)
| # template
def inputlist():
return [int(k) for k in input().split()]
# template
N, K = inputlist()
m0 = 0
mh = 0
ans = 0
for i in range(1, N + 1):
d = i % K
if d == 0:
m0 += 1
if d == K // 2 and K % 2 == 0:
mh += 1
print((m0**3 + mh**3))
| false | 6.666667 | [
"-import sys",
"-import itertools",
"-import numpy",
"+# template",
"+def inputlist():",
"+ return [int(k) for k in input().split()]",
"-input = sys.stdin.readline",
"-N, K = [int(i) for i in input().split()]",
"-if K % 2 == 1:",
"- index = N // K",
"- ans = index**3",
"-else:",
"- ... | false | 0.042991 | 0.089081 | 0.4826 | [
"s957054057",
"s927617005"
] |
u392319141 | p03503 | python | s810235389 | s777477609 | 307 | 141 | 3,188 | 3,188 | Accepted | Accepted | 54.07 | N = int(eval(input()))
F = [[0 for _ in range(10)] for _ in range(N)]
P = [[0 for _ in range(10)] for _ in range(N)]
for i in range(N) :
F[i] = list(map(int, input().split()))
for i in range(N) :
P[i] = list(map(int, input().split()))
ans = -float('inf')
for mask in range(1, 2**10) :
profit = 0... | N = int(eval(input()))
F = []
for _ in range(N):
mask = 0
for f in map(int, input().split()):
mask <<= 1
mask |= f
F.append(mask)
P = [list(map(int, input().split())) for _ in range(N)]
def calc(state):
ret = 0
for f, ps in zip(F, P):
f &= state
cnt... | 21 | 27 | 565 | 523 | N = int(eval(input()))
F = [[0 for _ in range(10)] for _ in range(N)]
P = [[0 for _ in range(10)] for _ in range(N)]
for i in range(N):
F[i] = list(map(int, input().split()))
for i in range(N):
P[i] = list(map(int, input().split()))
ans = -float("inf")
for mask in range(1, 2**10):
profit = 0
for shop in... | N = int(eval(input()))
F = []
for _ in range(N):
mask = 0
for f in map(int, input().split()):
mask <<= 1
mask |= f
F.append(mask)
P = [list(map(int, input().split())) for _ in range(N)]
def calc(state):
ret = 0
for f, ps in zip(F, P):
f &= state
cnt = 0
whil... | false | 22.222222 | [
"-F = [[0 for _ in range(10)] for _ in range(N)]",
"-P = [[0 for _ in range(10)] for _ in range(N)]",
"-for i in range(N):",
"- F[i] = list(map(int, input().split()))",
"-for i in range(N):",
"- P[i] = list(map(int, input().split()))",
"-ans = -float(\"inf\")",
"-for mask in range(1, 2**10):",
... | false | 0.095002 | 0.085046 | 1.117071 | [
"s810235389",
"s777477609"
] |
u084320347 | p03281 | python | s285699762 | s905052010 | 167 | 18 | 38,768 | 2,940 | Accepted | Accepted | 89.22 | n = int(eval(input()))
ans = 0
for i in range(1,n+1):
if i%2 == 0:
continue
cnt=0
for j in range(1,i+1):
if i%j == 0:
cnt+=1
if cnt == 8:
ans+=1
print(ans) | n = int(eval(input()))
ans=0
for i in range(1,n+1,2):
cnt = 0
for j in range(1,n+1,2):
if j>i:
break
if i%j==0:
cnt+=1
if cnt==8:
ans+=1
print(ans)
| 15 | 13 | 226 | 215 | n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
if i % 2 == 0:
continue
cnt = 0
for j in range(1, i + 1):
if i % j == 0:
cnt += 1
if cnt == 8:
ans += 1
print(ans)
| n = int(eval(input()))
ans = 0
for i in range(1, n + 1, 2):
cnt = 0
for j in range(1, n + 1, 2):
if j > i:
break
if i % j == 0:
cnt += 1
if cnt == 8:
ans += 1
print(ans)
| false | 13.333333 | [
"-for i in range(1, n + 1):",
"- if i % 2 == 0:",
"- continue",
"+for i in range(1, n + 1, 2):",
"- for j in range(1, i + 1):",
"+ for j in range(1, n + 1, 2):",
"+ if j > i:",
"+ break"
] | false | 0.038255 | 0.036227 | 1.055962 | [
"s285699762",
"s905052010"
] |
u275666666 | p02689 | python | s928206831 | s419776351 | 307 | 277 | 127,268 | 103,132 | Accepted | Accepted | 9.77 | N,M=list(map(int, input().split()))
H=list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(int(M))]
AB_unique=list(map(list, set(map(tuple, AB))))
AB_road=[[] for i in range(N)]
for AB in AB_unique:
if H[AB[0]-1] > H[AB[1]-1]:
AB_road[AB[1]-1].append(AB[0])
el... | N,M=list(map(int, input().split()))
H=list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(int(M))]
AB_road=[[] for i in range(N)]
for r in AB:
if H[r[0]-1] > H[r[1]-1]:
AB_road[r[1]-1].append(r[0])
elif H[r[0]-1] < H[r[1]-1]:
AB_road[r[0]-1].append(r[1]... | 17 | 15 | 500 | 430 | N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(int(M))]
AB_unique = list(map(list, set(map(tuple, AB))))
AB_road = [[] for i in range(N)]
for AB in AB_unique:
if H[AB[0] - 1] > H[AB[1] - 1]:
AB_road[AB[1] - 1].append(AB[0])
... | N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(int(M))]
AB_road = [[] for i in range(N)]
for r in AB:
if H[r[0] - 1] > H[r[1] - 1]:
AB_road[r[1] - 1].append(r[0])
elif H[r[0] - 1] < H[r[1] - 1]:
AB_road[r[0] - 1].ap... | false | 11.764706 | [
"-AB_unique = list(map(list, set(map(tuple, AB))))",
"-for AB in AB_unique:",
"- if H[AB[0] - 1] > H[AB[1] - 1]:",
"- AB_road[AB[1] - 1].append(AB[0])",
"- elif H[AB[0] - 1] < H[AB[1] - 1]:",
"- AB_road[AB[0] - 1].append(AB[1])",
"+for r in AB:",
"+ if H[r[0] - 1] > H[r[1] - 1]:... | false | 0.086269 | 0.127883 | 0.67459 | [
"s928206831",
"s419776351"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.