Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = [(int(x)+1)/2 for x in input().split()]
ans = 0
for n in range(N-K+1):
    ans = max(sum(p[n:n+K]),ans)
print(ans)


Fixed submission:
N, K = map(int, input().split())
p = [(int(x)+1)/2 for x in input().split()]
cm = [0]
for n in p:
    cm.append(cm[-1]+n)
ans = 0
for n in range(N-K+1):
    ans = max(cm[n+K]-cm[n],ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
from functools import lru_cache

M, N = map(int,input().split())
VW = [[int(x) for x in input().split()] for _ in range(N)]
VW = sorted(VW, key=lambda x:(x[0]/x[1],x[0]))

@lru_cache(maxsize=None)
def dp(h):
    if h<=0:
        return 0
    else:
        best = float("inf")
        for a,b in VW:
            val = b+dp(h-a)
            if val < best:
                best = val
            else:
                break
        return best
print(dp(M))


Fixed submission:
import numpy as np
h, N = map(int,input().split())
VW = [[int(x) for x in input().split()] for _ in range(N)]
VW = np.array(sorted(VW, key=lambda x:(x[0]/x[1],x[0])))
a = VW[:, 0]
b = VW[:, 1]

dp = np.zeros(10**4+1, dtype=np.int)
for i in range(1, h+1):
    dp[i] = (dp[i-a]+b).min()
print(dp[h])

Buggy python submission (verdict: Runtime Error):
from functools import lru_cache

M, N = map(int,input().split())
VW = [[int(x) for x in input().split()] for _ in range(N)]
VW = sorted(VW, key=lambda x:(x[0]/x[1],x[0]))
@lru_cache(maxsize=None)
def dp(h):
    if h<=0:
        return 0
    else:
        best = float("inf")
        for a,b in VW:
            val = b+dp(h-a)
            if val < best:
                best = val
            else:
                break
        return best
print(dp(M))


Fixed submission:
import numpy as np
h, N = map(int,input().split())
VW = [[int(x) for x in input().split()] for _ in range(N)]
VW = np.array(sorted(VW, key=lambda x:(x[0]/x[1],x[0])))
a = VW[:, 0]
b = VW[:, 1]

dp = np.zeros(10**4+1, dtype=np.int)
for i in range(1, h+1):
    dp[i] = (dp[i-a]+b).min()
print(dp[h])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = [int(x) for x in input().split()]
ans = 0
m = 0
for i in range(N):
    for j in range(m, i):
        if P[i] > P[j]:
            m = j
            break
    else:
        ans += 1
print(ans)


Fixed submission:
N = int(input())
P = [int(x) for x in input().split()]
mins = [0]*N
mins[0] = P[0]
for n in range(1,N):
    mins[n] = min(P[n],mins[n-1])
ans = 0
for i in range(N):
    if P[i] == mins[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = [int(x) for x in input().split()]
ans = 0
for i in range(N):
    for j in range(i,-1,-1):
        if P[i] > P[j]:
            break
    else:
        ans += 1
print(ans)


Fixed submission:
N = int(input())
P = [int(x) for x in input().split()]
mins = [0]*N
mins[0] = P[0]
for n in range(1,N):
    mins[n] = min(P[n],mins[n-1])
ans = 0
for i in range(N):
    if P[i] == mins[i]:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
XL = []
for n in range(N):
    XL.append([int(x) for x in input().split()])
XL = sorted(XL, key=lambda x:x[1])
s = np.zeros(2*(10**9))
ans = 0
for n in range(N):
    a = s[max(XL[n][0]-XL[n][1],-1)+1:XL[n][0]+XL[n][1]]
    if max(a) != 0:
        ans += 1
    else:
        s[max(XL[n][0]-XL[n][1],-1)+1:XL[n][0]+XL[n][1]] += 1
print(N-ans)


Fixed submission:
N = int(input())
XL = []
for n in range(N):
    XL.append([int(x) for x in input().split()])
XL = sorted(XL, key=lambda x:x[0]+x[1])
m = -float("inf")
ans = 0
for n in range(N):
    if XL[n][0]-XL[n][1] >= m:
        ans += 1
        m = XL[n][0]+XL[n][1]
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
XL = []
for n in range(N):
	XL.append([int(x) for x in input().split()])
XL = sorted(XL, key=lambda x:x[1])
s = np.zeros(2*(10**9))
ans = 0
for n in range(N):
	a = s[max(XL[n][0]-XL[n][1],-1)+1:XL[n][0]+XL[n][1]]
	if a.max() != 0:
		ans += 1
	else:
		s[max(XL[n][0]-XL[n][1],-1)+1:XL[n][0]+XL[n][1]] += 1
print(N-ans)


Fixed submission:
N = int(input())
XL = []
for n in range(N):
    XL.append([int(x) for x in input().split()])
XL = sorted(XL, key=lambda x:x[0]+x[1])
m = -float("inf")
ans = 0
for n in range(N):
    if XL[n][0]-XL[n][1] >= m:
        ans += 1
        m = XL[n][0]+XL[n][1]
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
XL = []
for n in range(N):
    XL.append([int(x) for x in input().split()])
XL = sorted(XL, key=lambda x:x[1])
s = np.zeros(2*(10**9))
ans = 0
for n in range(N):
    a = s[max(XL[n][0]-XL[n][1],-1)+1:XL[n][0]+XL[n][1]]
    if a.max() != 0:
        ans += 1
    else:
        s[max(XL[n][0]-XL[n][1],-1)+1:XL[n][0]+XL[n][1]] += 1
print(N-ans)


Fixed submission:
N = int(input())
XL = []
for n in range(N):
    XL.append([int(x) for x in input().split()])
XL = sorted(XL, key=lambda x:x[0]+x[1])
m = -float("inf")
ans = 0
for n in range(N):
    if XL[n][0]-XL[n][1] >= m:
        ans += 1
        m = XL[n][0]+XL[n][1]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

Fixed submission:
A, B = map(int, input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

print(lcm(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
N = X//100
def get_change(pay, N):
    if N >= 0:
        for n in range(6):
            if pay%(100+n) == 0:
                print(1)
                exit(0)
            if pay > 100+n:
                get_change(pay-100-n, N-1)
    return 2
res = get_change(X, N)
if res == 2:
    print(0)


Fixed submission:
X = int(input())
N = X//100
pay = X-N*100
if pay/5 > N:
    print(0)
else:
    print(1)

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())

def get_change(pay):
    for n in range(6):
        if pay%(100+n) == 0:
            print(1)
            exit(0)
        if pay > 100+n:
            get_change(pay-100-n)
    return 2
res = get_change(X)
if res == 2:
    print(0)


Fixed submission:
X = int(input())
N = X//100
pay = X-N*100
if pay/5 > N:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
S = input()
length = len(S)
l = list()
for n in range(length-2):
    for m in range(n+1,length):
        for k in range(m+1, length):
            s = S[n]+S[m]+S[k]
            l.append(s)
print(len(np.unique(l)))


Fixed submission:
import numpy as np
from collections import Counter
N = int(input())
S = input()
length = len(S)
first = list()
res = 0
for n in range(length-2):
    if S[n] not in first:
        first.append(S[n])
    else:
        continue
    second = list()
    for m in range(n+1, length-1):
        if S[m] not in second:
            second.append(S[m])
        else:
            continue
        third = list()
        for k in range(m+1, length):
            if S[k] not in third:
                third.append(S[k])
            else:
                continue
            res += 1
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
length = len(S)
l = list()
for n in range(length-2):
    for m in range(n+1,length):
        for k in range(m+1, length):
            s = S[n]+S[m]+S[k]
            if s not in l:
                l.append(s)
print(len(l))


Fixed submission:
import numpy as np
from collections import Counter
N = int(input())
S = input()
length = len(S)
first = list()
res = 0
for n in range(length-2):
    if S[n] not in first:
        first.append(S[n])
    else:
        continue
    second = list()
    for m in range(n+1, length-1):
        if S[m] not in second:
            second.append(S[m])
        else:
            continue
        third = list()
        for k in range(m+1, length):
            if S[k] not in third:
                third.append(S[k])
            else:
                continue
            res += 1
print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
D = [int(x) for x in input().split()]
D = sorted(D)
new_l = [0 for n in range(max(D))]
ini = D[0]
for n in range(N):
    new_l[D[n]] += 1
res = new_l[0]**new_l[1]
for n in range(1,len(new_l)-1):
    res *= new_l[n]**new_l[n+1]
    res %= 998244353
print(res%998244353)


Fixed submission:
N = int(input())
D = [int(x) for x in input().split()]
new_l = [0 for n in range(max(D)+1)]
for n in range(N):
    new_l[D[n]] += 1
if new_l[0] == 1 and D[0] == 0:
    res = 1
    for n in range(max(D)):
        res *= pow(new_l[n],new_l[n+1],998244353)
    print(res%998244353)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = [int(x) for x in input().split()]
D = sorted(D)
if D[0] > 0:
    print(0)
else:
    new_l = list()
    for n in range(1,N+1):
        count = 0
        for d in D:
            if d == n:
                count += 1
        new_l.append(count)
    res = 1
    for n in range(len(new_l)-1):
        res *= new_l[n]**new_l[n+1]
        res = res%998244353
    print(res)


Fixed submission:
N = int(input())
D = [int(x) for x in input().split()]
new_l = [0 for n in range(max(D)+1)]
for n in range(N):
    new_l[D[n]] += 1
if new_l[0] == 1 and D[0] == 0:
    res = 1
    for n in range(max(D)):
        res *= pow(new_l[n],new_l[n+1],998244353)
    print(res%998244353)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array([int(x) for x in input().split()])
B = np.array([int(x) for x in input().split()])
I = B.argsort()
A = A[I]
B = B[I]
calc = max(A) <= max(B)
if not calc:
    print("No")
    exit(0)
if any(A.sort()[1:] <= B[:-1]):
    print('Yes')
    exit()
p = A.argsort().tolist()
x = 0
c = 0
while True:
    c += 1
    x = p[x]
    if x == 0:
        break
print("Yes" if p != N else "No")


Fixed submission:
import numpy as np
N = int(input())
A = np.array([int(x) for x in input().split()])
B = np.array([int(x) for x in input().split()])
I = B.argsort()
A = A[I]
B = B[I]
calc = max(A) <= max(B)
if not calc:
    print("No")
    exit(0)
if any(np.sort(A)[1:] <= B[:-1]):
    print('Yes')
    exit()
p = A.argsort().tolist()
x = 0
c = 0
while True:
    c += 1
    x = p[x]
    if x == 0:
        break
print("Yes" if c != N else "No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
_output = False
for n in range(1,10):
  if N % n == 0:
    tmp = N/n
  	if tmp <= 9:
      print("Yes")
      _output = True
      break
if not _output:
  print("No")

Fixed submission:
N = int(input())
_output = False
for n in range(1,10):
  if N % n == 0:
      tmp = N/n
      if tmp <= 9:
          print("Yes")
          _output = True
          break
if not _output:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
res = int(N/2)
if N%2 > 0:
  res += 1
return res

Fixed submission:
N = int(input())
if N%2 == 0:
  res = int(N/2)
if N%2 == 1:
  res = int(N/2)+1
res /= N
print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
tmp = list()
for n in range(len(A)):
  tmp.append([n+1, A[n]])
tmp = sorted(tmp, key=lambda x: x[1])
res = ""
for x in tmp:
  res.append(x[0])
print(*res)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
tmp = list()
for n in range(len(A)):
  tmp.append([n+1, A[n]])
tmp = sorted(tmp, key=lambda x: x[1])
res = []
for x in tmp:
  res.append(x[0])
print(*res)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
tmp = list()
for n in range(len(A)):
  tmp.append([n+1, A[n]])
tmp = sorted(tmp, key=lambda x: x[1])
res = ""
for x in tmp:
  res.append(x[0])
print(' '.join(res))

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
tmp = list()
for n in range(len(A)):
  tmp.append([n+1, A[n]])
tmp = sorted(tmp, key=lambda x: x[1])
res = []
for x in tmp:
  res.append(x[0])
print(*res)
Buggy python submission (verdict: Runtime Error):
S = input()
res = "Yes"
for x in range(int(len(S)/2)+1):
  if S[2*x] not in ["R","U","D"]:
    res = "No"
  if 2*x + 1 < len(S):
    if S[2*x+1] not in ["L","U","D"]:
      res = "No"
print(res)

Fixed submission:
S = input()
res = "Yes"
for x in range(int(len(S)/2)+1):
  if 2*x < len(S):
    if S[2*x] not in ["R","U","D"]:
      res = "No"
  if 2*x + 1 < len(S):
    if S[2*x+1] not in ["L","U","D"]:
      res = "No"
print(res)

Buggy python submission (verdict: Runtime Error):
S = input()
res = "Yes"
for n in range(int(len(S/2))):
  if S[2*n+1] not in ["R","U","D"]:
    res = "No"
  if S[2*n] not in ["L","U","D"]:
    res = "No"
print(res)

Fixed submission:
S = input()
res = "Yes"
for x in range(int(len(S)/2)+1):
  if 2*x < len(S):
    if S[2*x] not in ["R","U","D"]:
      res = "No"
  if 2*x + 1 < len(S):
    if S[2*x+1] not in ["L","U","D"]:
      res = "No"
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
A = sorted(A)[::-1]
res = 0
for x in A:
    res += x
for m in range(M):
    tmp = sorted(A[:m+1])[::-1]
    k = tmp[0]
    tmp[0] = int(tmp[0]/2)
    l = tmp[0]
    tmp.extend(A[m+1:])
    A = tmp
    res -= k-l

print(res)


Fixed submission:
from heapq import *
N, M = map(int, input().split())
A = [-int(x) for x in input().split()]
heapify(A)
for x in range(M):
    tmp = int(heappop(A)/2)
    heappush(A,tmp)
res = 0
for x in A:
    res -= x
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(x) for x in input().split()]

B = list()
for n in range(len(A)):
    B.append([n,A[n]])
B = sorted(B, key=lambda x:x[1])
for m in range(M):
    B[-1][1] = int(B[-1][1]/2)
    B = sorted(B, key=lambda x:x[1])
res = 0
for x in B:
    res += x[1]
print(res)


Fixed submission:
from heapq import *
N, M = map(int, input().split())
A = [-int(x) for x in input().split()]
heapify(A)
for x in range(M):
    tmp = int(heappop(A)/2)
    heappush(A,tmp)
res = 0
for x in A:
    res -= x
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(x) for x in input().split()]

for m in range(M):
    argmax = 0
    tmp = 0
    for n in range(len(A)):
        if A[n] >= tmp:
            argmax = n
            tmp = A[n]
    A[argmax] = int(A[argmax]/2)
res = 0
for x in A:
    res += x
print(res)


Fixed submission:
from heapq import *
N, M = map(int, input().split())
A = [-int(x) for x in input().split()]
heapify(A)
for x in range(M):
    tmp = int(heappop(A)/2)
    heappush(A,tmp)
res = 0
for x in A:
    res -= x
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = 0
for n in range(N):
    X = S[:n]
    Y = S[n:]
    dp = [[0 for i in range(len(X)+1)] for j in range(len(Y)+1)] #0で初期化

    for i in range(len(Y)):
        for j in range(len(X)):
            if X[j] == Y[i]:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
    ans = max(ans, dp[-1][-1])
print(ans)


Fixed submission:
N = int(input())
S = input()
ans = 0
for i in range(N):
    k = ans + 1
    for j in range(k, N-i):
        if S[i:i+j] in S[i+j:]:
            ans = max(ans, j)
        else:
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

strs = []
for n in range(N):
    if S[n] not in strs:
        strs.append(S[n])
ans = 0
for x in strs:
    for n in range(N-1):
        if S[n] == x:
            for m in range(n+1, N):
                l = 0
                if S[m] == x:
                    l = 0
                    while l < m-n:
                        if S[n:n+l+1] != S[m:m+l+1]:
                            break
                        l += 1
                ans = max(ans, l)
print(ans)


Fixed submission:
N = int(input())
S = input()
ans = 0
for i in range(N):
    k = ans + 1
    for j in range(k, N-i):
        if S[i:i+j] in S[i+j:]:
            ans = max(ans, j)
        else:
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [i+1 for i in range(N)]
print(sum(s[:-1]))


Fixed submission:
N = int(input())
ans = ((N-1)*N)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())
l = int((B-A)/C)
m = int((B-A)/D)
lcm = C*D/math.gcd(C,D)
c = B-A-l-m+int((B-A)/lcm)
print(c)


Fixed submission:
import fractions
A, B, C, D = map(int, input().split())
def F(x):
    l = x//C
    l += x//D
    lcm = C*D//fractions.gcd(C,D)
    l -= x//lcm
    return x-l
print(F(B)-F(A-1))

Buggy python submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())

l = int((B-A)/C)
m = int((B-A)/D)
lcm = C*D/math.gcd(C,D)
c = B-A-l-m+int((B-A)/lcm)
print(c)


Fixed submission:
import fractions
A, B, C, D = map(int, input().split())
def F(x):
    l = x//C
    l += x//D
    lcm = C*D//fractions.gcd(C,D)
    l -= x//lcm
    return x-l
print(F(B)-F(A-1))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N , M = map(int, input().split())
a = list()
for n in range(M):
    a.append(int(input()))
dp = np.zeros(N+1)
dp[0] = 1
if M == 0:
    dp[1] = 1
else:
    dp[1] = 0 if a[0] == 1 else 1
for n in range(2,N+1):
    if n in a:
        dp[n] = 0
    else:
        dp[n] = (dp[n-1]+dp[n-2])%(10**9+7)
print(int(dp[N]))


Fixed submission:
import numpy as np
N , M = map(int, input().split())
a = list()
for n in range(M):
    a.append(int(input()))
dp = np.zeros(N+1)
dp[0] = 1
if M == 0:
    dp[1] = 1
else:
    dp[1] = 0 if a[0] == 1 else 1
ok = [False]*(N+1)
for x in a:
    ok[x] = True
for n in range(2,N+1):
    if ok[n]:
        continue
    dp[n] = (dp[n-1]+dp[n-2])%(10**9+7)
print(int(dp[N]))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N , M = map(int, input().split())
a = list()
for n in range(M):
	a.append(int(input()))
dp = np.zeros(N+1)
dp[0] = 1
dp[1] = 0 if a[0] == 1 else 1
for n in range(2,N+1):
	if n in a:
		dp[n] = 0
	else:
		dp[n] = (int(dp[n-1])+int(dp[n-2]))%(10**9+7)
print(int(dp[N]))


Fixed submission:
import numpy as np
N , M = map(int, input().split())
a = list()
for n in range(M):
    a.append(int(input()))
dp = np.zeros(N+1)
dp[0] = 1
if M == 0:
    dp[1] = 1
else:
    dp[1] = 0 if a[0] == 1 else 1
ok = [False]*(N+1)
for x in a:
    ok[x] = True
for n in range(2,N+1):
    if ok[n]:
        continue
    dp[n] = (dp[n-1]+dp[n-2])%(10**9+7)
print(int(dp[N]))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N , M = map(int, input().split())
a = list()
for n in range(M):
    a.append(int(input()))
dp = np.zeros(N+1)
dp[0] = 1
dp[1] = 0 if a[0] == 1 else 1
for n in range(2,N+1):
    if n in a:
        dp[n] = 0
    else:
        dp[n] = (int(dp[n-1])+int(dp[n-2]))%(10**9+7)
print(int(dp[N]))


Fixed submission:
import numpy as np
N , M = map(int, input().split())
a = list()
for n in range(M):
    a.append(int(input()))
dp = np.zeros(N+1)
dp[0] = 1
if M == 0:
    dp[1] = 1
else:
    dp[1] = 0 if a[0] == 1 else 1
ok = [False]*(N+1)
for x in a:
    ok[x] = True
for n in range(2,N+1):
    if ok[n]:
        continue
    dp[n] = (dp[n-1]+dp[n-2])%(10**9+7)
print(int(dp[N]))

Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
N , M = map(int, input().split())
a = list()
for n in range(M):
    a.append(int(input()))
dp = np.zeros(N+1)
dp[0] = 1
dp[1] = 0 if a[0] == 1 else 1
for n in range(2,N+1):
    if n in a:
        dp[n] = 0
    else:
        dp[n] = (int(dp[n-1])+int(dp[n-2]))%(math.pow(10,9)+7)
print(int(dp[N]))


Fixed submission:
import numpy as np
N , M = map(int, input().split())
a = list()
for n in range(M):
    a.append(int(input()))
dp = np.zeros(N+1)
dp[0] = 1
if M == 0:
    dp[1] = 1
else:
    dp[1] = 0 if a[0] == 1 else 1
ok = [False]*(N+1)
for x in a:
    ok[x] = True
for n in range(2,N+1):
    if ok[n]:
        continue
    dp[n] = (dp[n-1]+dp[n-2])%(10**9+7)
print(int(dp[N]))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, M = map(int, input().split())
xyz = list()
for n in range(N):
    xyz.append([int(x) for x in input().split()])
ans = 0
for x in itertools.combinations(range(N), M):
    tmp = [0,0,0]
    for m in x:
        for y in range(3):
            tmp[y] += xyz[m][y]
    ans = max(ans, sum([abs(x) for x in tmp]))
print(ans)


Fixed submission:
import itertools
N, M = map(int, input().split())
xyz = list()
for n in range(N):
    xyz.append([int(x) for x in input().split()])
ans = 0
for a,b,c in itertools.product([-1,1], repeat=3):
    tmp = []
    for x, y, z in xyz:
        tmp.append(a*x+b*y+c*z)
    tmp.sort(reverse=True)
    ans = max(ans, sum(tmp[:M]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split())
Y /= 1000
x = 10
y = 5
z = 1
res = [-1, -1, -1]
for i in reversed(range(int(Y/x)+1)):
    for j in reversed(range(int((Y-i)/y)+1)):
        if x*i+y*j <= Y:
            if Y-x*i-y*j+i+j == N:
                res = [i, j, int(N-i-j)]
                print(res[0], res[1], res[2])
                exit(0)
print(-1, -1, -1)


Fixed submission:
N, Y = map(int, input().split())
Y /= 1000
x = 10
y = 5
z = 1
for i in range(N+1):
    for j in range(N+1):
        if x*i+y*j+(N-i-j) == Y and i+j <= N:
            print(i, j, N-i-j)
            exit()
print(-1, -1, -1)

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split())
Y /= 1000
x = 10
y = 5
z = 1
res = [-1, -1, -1]
for i in reversed(range(int(Y/x)+1)):
    for j in range(int(Y/y)+1):
        if x*i+y*j <= Y:
            if Y-x*i-y*j+i+j == N:
                res = [i, j, int(N-i-j)]
                print(res[0], res[1], res[2])
                exit(0)
print(-1, -1, -1)


Fixed submission:
N, Y = map(int, input().split())
Y /= 1000
x = 10
y = 5
z = 1
for i in range(N+1):
    for j in range(N+1):
        if x*i+y*j+(N-i-j) == Y and i+j <= N:
            print(i, j, N-i-j)
            exit()
print(-1, -1, -1)

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split())
Y /= 1000
x = 10
y = 5
z = 1
res = [-1, -1, -1]
for i in range(int(Y/x)+1):
    for j in range(int(Y/y)+1):
        if x*i+y*j <= Y:
            if Y-x*i-y*j+i+j == N:
                res = [i, j, int(N-i-j)]
                print(res[0], res[1], res[2])
                exit(0)
print(-1, -1, -1)


Fixed submission:
N, Y = map(int, input().split())
Y /= 1000
x = 10
y = 5
z = 1
for i in range(N+1):
    for j in range(N+1):
        if x*i+y*j+(N-i-j) == Y and i+j <= N:
            print(i, j, N-i-j)
            exit()
print(-1, -1, -1)
Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())
for n in range(len(S)):
    if S[n] == T[0]:
        noOfnext = 0
        for m in range(n+1, len(S)):
            if S[m] == "?":
                noOfnext += 1
            else:
                break
        if noOfnext < len(T)-1:
            continue
        else:
            for m in range(noOfnext):
                S[n+1+m] = T[m+1]
            for k in range(len(S)):
                if S[k] == "?":
                    S[k] = "a"
if "?" in S:
    print("UNRESTORABLE")
else:
    print("".join(S))



Fixed submission:
S = input()
T = input()
ss = list()
for n in range(len(S)-len(T)+1):
    for m in range(len(T)):
        if S[n+m] not in ["?", T[m]]:
            break
    else:
        ss.append((S[:n]+T+S[n+len(T):]).replace("?","a"))
if len(ss) == 0:
    print("UNRESTORABLE")
else:
    print(min(ss))