Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, a = map(int, input().split())
X = list(map(int, input().split()))

# dp[i][j][k] i枚までj枚えらんで合計k
# 答えはdp[n][1..n][a..ak]
dp = [[[0] * 2502 for _ in range(52)]
      for __ in range(52)]

dp[0][0][0] = 1
for i in range(0, n):
    for j in range(0, n + 1):
        for k in range(n * max(X) + 1):
            dp[i + 1][j][k] += dp[i][j][k]  # 選ぶ
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]  # 選ばない

ans = 0
for i in range(1, n+1):
    for j in range(a, 2501):
        if i * a == j:
            ans += dp[n][i][j]
print(ans)


Fixed submission:
n, a = map(int, input().split())
X = list(map(int, input().split()))

# dp[i][j][k] i枚までj枚えらんで合計k
# 答えはdp[n][1..n][a..ak]
dp = [[[0] * 2700 for _ in range(52)]
      for __ in range(52)]

dp[0][0][0] = 1
for i in range(0, n):
    for j in range(0, n + 1):
        for k in range(n * max(X) + 1):
            dp[i + 1][j][k] += dp[i][j][k]  # 選ぶ
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]  # 選ばない

ans = 0
for i in range(1, n+1):
    for j in range(a, 2501):
        if i * a == j:
            ans += dp[n][i][j]
print(ans)

Buggy python submission (verdict: Runtime Error):
n, a = map(int, input().split())
X = list(map(int, input().split()))

# dp[i][j][k] i枚までj枚えらんで合計k
# 答えはdp[n][1..n][a..ak]
dp = [[[0] * 3500 for _ in range(51)]
      for __ in range(51)]

dp[0][0][0] = 1
for i in range(0, n):
    for j in range(0, n + 1):
        for k in range(n * max(X) + 1):
            dp[i + 1][j][k] += dp[i][j][k]  # 選ぶ
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]  # 選ばない

ans = 0
for i in range(1, n+1):
    for j in range(a, 2501):
        if i * a == j:
            ans += dp[n][i][j]
print(ans)


Fixed submission:
n, a = map(int, input().split())
X = list(map(int, input().split()))

# dp[i][j][k] i枚までj枚えらんで合計k
# 答えはdp[n][1..n][a..ak]
dp = [[[0] * 2700 for _ in range(52)]
      for __ in range(52)]

dp[0][0][0] = 1
for i in range(0, n):
    for j in range(0, n + 1):
        for k in range(n * max(X) + 1):
            dp[i + 1][j][k] += dp[i][j][k]  # 選ぶ
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]  # 選ばない

ans = 0
for i in range(1, n+1):
    for j in range(a, 2501):
        if i * a == j:
            ans += dp[n][i][j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n, a = map(int, input().split())
X = list(map(int, input().split()))

ans = 0

for i in range(1, n+1):
    L = list(combinations(X, i))
    for l in L:
        if sum(l) / i == a:
            ans += 1
print(ans)


Fixed submission:
n, a = map(int, input().split())
X = list(map(int, input().split()))

# dp[i][j][k] i枚までj枚えらんで合計k
# 答えはdp[n][1..n][a..ak]
dp = [[[0] * 2700 for _ in range(52)]
      for __ in range(52)]

dp[0][0][0] = 1
for i in range(0, n):
    for j in range(0, n + 1):
        for k in range(n * max(X) + 1):
            dp[i + 1][j][k] += dp[i][j][k]  # 選ぶ
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]  # 選ばない

ans = 0
for i in range(1, n+1):
    for j in range(a, 2501):
        if i * a == j:
            ans += dp[n][i][j]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print((1+n)*n/2)


Fixed submission:
nums = list(map(int,input().split()))
if sum(nums) == 17 and 5 in nums and 7 in nums:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
for i in range(N):
    a.append(a[i]+A[i])
b = [0]
for i in range(M):
    b.append(b[i]+B[i])

ans = 0
for i in range(N+1):
    if a[i] > K: break
    for j in range(M+1):
        if a[i] + b[j] > K: break
        ans = max(ans, i+j)

print(ans)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
    if a[i] > K: break
    while a[i] + b[j] > K:
        j -= 1
    ans = max(ans, i+j)
    
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

acs = [0]*(N+1)
for i in range(N):
    acs[i+1] = acs[i]+A[i]
    if acs[i+1] > K:
        A = A[:i]
        acs = acs[:i]
        break
A = A[::-1]

bcs = [0]*(M+1)
for i in range(M):
    bcs[i+1] = bcs[i]+B[i]
    if bcs[i+1] > K:
        B = B[:i]
        bcs = bcs[:i]
        break
B = B[::-1]

lng = []
srt = []
if len(acs) >= len(bcs):
    lng = A
    srt = bcs[::]
else:
    lng = B
    srt = acs[::]

lcs = [0]*(len(lng)+1)
lcs[0] = K-sum(lng)
for i in range(len(lng)):
    lcs[i+1] = lcs[i]+lng[i]
lng = lcs

sidx = 0
if len(srt)>0:
    for i in range(len(srt)):
        if srt[i] < lng[i]: sidx = i
lidx = 0
if len(lng)>0:
    for i in range(len(lng)):
        if lng[i] < srt[sidx]: lidx = i

print(len(lng)+sidx-lidx-1)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
    if a[i] > K: break
    while a[i] + b[j] > K:
        j -= 1
    ans = max(ans, i+j)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for a in A:
    if not a in d: d[a] = 0
    d[a] += 1
for i in range(M):
    B, C = map(int, input().split())
    if not C in d: d[C] = 0
    d[C] += B
T = sorted(d.items(), key=lambda x:x[0], reverse=True)
B = []
for t in T:
    B.extend([t[0]] * t[1])
    if len(B) >= N: break
print(sum(B[:N]))


Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for a in A:
    if not a in d: d[a] = 0
    d[a] += 1
for i in range(M):
    B, C = map(int, input().split())
    if not C in d: d[C] = 0
    d[C] += B
T = sorted(d.items(), key=lambda x:x[0], reverse=True)
ans = 0
cnt = 0
for t in T:
    if t[1] <= N - cnt:
        ans += t[0] * t[1]
        cnt += t[1]
    else:
        ans += t[0] * (N - cnt)
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
d = {}
for i in range(M):
    B, C = map(int, input().split())
    if not C in d: d[C] = 0
    d[C] += B
T = sorted(d.items(), key=lambda x:x[0], reverse=True)
B = []
for t in T:
    B.extend([t[0]] * t[1])
    if len(B) >= N: break
n = min(len(A), len(B))
c = n
for i in range(n):
    if A[i] > B[i]:
        c = i
        break
ans = sum(B[:c])
if c < len(A): ans += sum(A[c:])
print(ans)


Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for a in A:
    if not a in d: d[a] = 0
    d[a] += 1
for i in range(M):
    B, C = map(int, input().split())
    if not C in d: d[C] = 0
    d[C] += B
T = sorted(d.items(), key=lambda x:x[0], reverse=True)
ans = 0
cnt = 0
for t in T:
    if t[1] <= N - cnt:
        ans += t[0] * t[1]
        cnt += t[1]
    else:
        ans += t[0] * (N - cnt)
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
d = {}
for i in range(M):
    B, C = map(int, input().split())
    if not C in d: d[C] = 0
    d[C] += B
T = sorted(d.items(), key=lambda x:x[0], reverse=True)
B = []
for t in T:
    B.extend([t[0]] * t[1])
    if len(B) > N: break
N = min(N, len(B))
c = N
for i in range(N):
    if A[i] > B[i]:
        c = i
        break
ans = sum(B[:c])
if c < len(A): ans += sum(A[c:])
print(ans)


Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for a in A:
    if not a in d: d[a] = 0
    d[a] += 1
for i in range(M):
    B, C = map(int, input().split())
    if not C in d: d[C] = 0
    d[C] += B
T = sorted(d.items(), key=lambda x:x[0], reverse=True)
ans = 0
cnt = 0
for t in T:
    if t[1] <= N - cnt:
        ans += t[0] * t[1]
        cnt += t[1]
    else:
        ans += t[0] * (N - cnt)
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
for i in range(Q):
    line = input().split()
    l, r = int(line[0]), int(line[1])
    print((r - l + 1 - len(S[l-1:r].replace('AC','')))//2)


Fixed submission:
N, Q = map(int, input().split())
S = list(input())
t = [0] * (N+1)
cnt = 0
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        cnt += 1
    t[i] = cnt
t[-1] = t[-2]
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
for i in range(Q):
    l, r = map(int, input().split())
    print((r - l + 1 - len(S[l-1:r].replace('AC','')))//2)


Fixed submission:
N, Q = map(int, input().split())
S = list(input())
t = [0] * (N+1)
cnt = 0
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        cnt += 1
    t[i] = cnt
t[-1] = t[-2]
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
index = []
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        index.append(i + 1)
for i in range(Q):
    l, r = map(int, input().split())
    print(len([i for i in index if l <= i < r]))


Fixed submission:
N, Q = map(int, input().split())
S = list(input())
t = [0] * (N+1)
cnt = 0
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        cnt += 1
    t[i] = cnt
t[-1] = t[-2]
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
for i in range(Q):
    l, r = map(int, input().split())
    print(len(S[l-1:r].split('AC')) - 1)


Fixed submission:
N, Q = map(int, input().split())
S = list(input())
t = [0] * (N+1)
cnt = 0
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        cnt += 1
    t[i] = cnt
t[-1] = t[-2]
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
import fraction
from functools import reduce

def gcd_list(numbers):
    return reduce(fraction.gcd, numbers)

N = int(input())
A = list(map(int, input().split()))

print(gcd_list(A))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = min(A)
while True:
    for i in range(len(A)):
        if A[i] % ans != 0:
            A[i] %= ans
    if min(A) < ans:
        ans = min(A)
    else:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))
if M <= N:
    print(0)
else:
    Y = []
    for i in range(1, len(X)):
        Y.append(X[i] - X[i-1])
    Y = sorted(Y)
    for i in range(N - 1):
        Y = Y[:-1]
    print(sum(Y))


Fixed submission:
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))
if M <= N:
    print(0)
else:
    Y = []
    for i in range(1, len(X)):
        Y.append(X[i] - X[i-1])
    Y = sorted(Y)
    if N == 1:
        print(sum(Y))
    else:
        print(sum(Y[:-(N-1)]))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
a = [0]*len(S)
for i in range(len(S)):
    if S[i] == 'B':
        a[i] = 1

r = 0
chk = True
while chk:
    chk = False
    flg = False
    for i in range(len(a)-1):
        if flg:
            flg = False
            continue
        if a[i] == 1 and a[i+1] == 0:
            chk = True
            flg = True
            a[i] = 0
            a[i+1] = 1
            r += 1
print(r)

Fixed submission:
S = input()
a = [0]*len(S)
for i in range(len(S)):
    if S[i] == 'B':
        a[i] = 1
r = 0
b = 0
for i in a:
    if i == 1:
        b += 1
    else:
        r += b
print(r)
Buggy python submission (verdict: Runtime Error):
s = input()
a = s.index('a')
sr = s[::-1]
z = sr.index('z')
print(len(s) - a - z)


Fixed submission:
s = input()
a = s.index('A')
sr = s[::-1]
z = sr.index('Z')
print(len(s) - a - z)

Buggy python submission (verdict: Runtime Error):
s = input()
a = s.index('a')
sr = s[::-1]
z = sr.index('z')
print(s[a:-z])


Fixed submission:
s = input()
a = s.index('A')
sr = s[::-1]
z = sr.index('Z')
print(len(s) - a - z)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
d = {}
ok = True
for i in range(m):
    s, c = map(int, input().split())
    if s not in d:
        d[s] = c
    elif d[s] != c:
        ok = False
res = ''
if not ok:
    print(-1)
else:
    for i in range(1, n+1):
        if i not in d.keys():
            if int(res) == 0:
                res += '1'
            else:
                res += '0'
        else:
            res += str(d[i])
    if len(res) == len(str(int(res))):
        print(res)
    else:
        print(-1)

Fixed submission:
n, m = map(int, input().split())
d = {}
ok = True
for i in range(m):
    s, c = map(int, input().split())
    if s not in d:
        d[s] = c
    elif d[s] != c:
        ok = False
res = ''
if not ok:
    print(-1)
elif n == 1 and m == 0:
    print(0)
else:
    for i in range(1, n+1):
        if i not in d.keys():
            if res == '' or int(res) == 0:
                res += '1'
            else:
                res += '0'
        else:
            res += str(d[i])
    if len(res) == len(str(int(res))):
        print(res)
    else:
        print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
a = [0]
for i in range(n-k+1):
    tmp = p[i:i+k]
    if sum(a) < sum(tmp):
        a = tmp
result = 0
for i in a:
    result += (i + 1) / 2
print(result)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = [0] * k + p
s = []
a = 0
for i in range(k, n+k):
    a += p[i];
    a -= p[i-k]
    s.append(a)
index = s.index(max(s))
result = 0
for i in p[index+1:index+k+1]:
    result += (i + 1) / 2
print(result)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if i % 2 == 1:
  print(0)
else:
  i = 10
  ans = 0
  while i <= n:
    ans += n // i
    i *= 5
  print(ans)

Fixed submission:
n = int(input())
if n % 2 == 1:
  print(0)
else:
  i = 10
  ans = 0
  while i <= n:
    ans += n // i
    i *= 5
  print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

n = int(input())
h = list(map(int, input().split()))
cost = [-1] * n

def ans(n):
  if cost[n] != -1:
    return cost[n]
  cost[n] = min(ans(n-1) + abs(h[n-1] - h[n]), ans(n-2) + abs(h[n-2] - h[n]))
  return cost[n]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

n = int(input())
h = list(map(int, input().split()))
cost = [-1] * n

def ans(n):
  if cost[n] != -1:
    return cost[n]
  cost[n] = min(ans(n-1) + abs(h[n-1] - h[n]), ans(n-2) + abs(h[n-2] - h[n]))
  return cost[n]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
cost = [-1] * n

def ans(n):
  if cost[n] != -1:
    return cost[n]
  cost[n] = min(ans(n-1) + abs(h[n-1] - h[n]), ans(n-2) + abs(h[n-2] - h[n]))
  return cost[n]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

n = int(input())
h = list(map(int, input().split()))
cost = [-1] * n

def ans(n):
  if cost[n] != -1:
    return cost[n]
  cost[n] = min(ans(n-1) + abs(h[n-1] - h[n]), ans(n-2) + abs(h[n-2] - h[n]))
  return cost[n]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
cost = [-1 for i in range(n)]

def ans(k):
  if cost[k] != -1:
    return cost[k]
  cost[k] = min(ans(k-1) + abs(h[k-1] - h[k]), ans(k-2) + abs(h[k-2] - h[k]))
  return cost[k]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

n = int(input())
h = list(map(int, input().split()))
cost = [-1] * n

def ans(n):
  if cost[n] != -1:
    return cost[n]
  cost[n] = min(ans(n-1) + abs(h[n-1] - h[n]), ans(n-2) + abs(h[n-2] - h[n]))
  return cost[n]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
cost = [-1 for i in range(n)]

def ans(n):
  if cost[n] != -1:
    return cost[n]
  cost[n] = min(ans(n-1) + abs(h[n-1] - h[n]), ans(n-2) + abs(h[n-2] - h[n]))
  return cost[n]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

n = int(input())
h = list(map(int, input().split()))
cost = [-1] * n

def ans(n):
  if cost[n] != -1:
    return cost[n]
  cost[n] = min(ans(n-1) + abs(h[n-1] - h[n]), ans(n-2) + abs(h[n-2] - h[n]))
  return cost[n]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))
Buggy python submission (verdict: Runtime Error):
mozi=int(input())
ju=mozi.islower()
ju2=mozi.isupper()
if ju==True:
  print("a")
 else:
  print("A")

Fixed submission:
mozi=input()
ju=mozi.islower()
ju2=mozi.isupper()
if ju==True:
  print("a")
else:
  print("A")
Buggy python submission (verdict: Time Limit Exceeded):
def Judge(x,y):
    sum=1
    for i in range(y):
        sum*=x[i]
        #print(sum)
    if sum>10**18:
        return -1
    else:
        return sum

n=int(input())
a=list(map(int,input().split()))

c=Judge(a,n)
print(c)

Fixed submission:
def Judge(x,y):
    sum=1
    for i in range(y):
        if x[i]==0:
            return 0
    for i in range(y):
        sum*=x[i]
        #print(sum)
        if sum>10**18:
            return -1
    return sum

n=int(input())
a=list(map(int,input().split()))

c=Judge(a,n)
print(c)
Buggy python submission (verdict: Runtime Error):
h1,m1,h2,m2,k=list(map(int,input().split()))
if m1=m2:
    m=0
    h=h2-h1
elif m2-m1>0:
    m=m2-m1
    h=h2-h1
else:
    m=60-m1+m2
    h=h2-h1-1
ans=k-m+h*60
if ans<=0:
    print(0)
else:
    print(ans)



Fixed submission:
h1,m1,h2,m2,k=list(map(int,input().split()))
if m1==m2:
    m=0
    h=h2-h1
elif m2-m1>0:
    m=m2-m1
    h=h2-h1
else:
    m=60-m1+m2
    h=h2-h1-1
ans=(k-(m+h*60))*(-1)
if ans<=0:
    print(0)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
k=int(input())
a,b=list(map(int,input().split()))

aa=a//k
bb=b//k

if bb-aa=>1:
    print("OK")
else:
    print("NG")

Fixed submission:
k=int(input())
a,b=list(map(int,input().split()))


if a%k==0 or b%k==0:
    print("OK")
elif b//k-a//k>=1:
    print("OK")
elif b/k-a/k<1 and a%k>b%k:
    print("OK")
else:
    print("NG")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    print(a.count(i+1))


Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
for i in range(n):
    print(s[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    print(a.count(i+1))

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
for i in range(n):
    print(s[i+1])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=map(int,input().split())

babies=[(a,i) for i ,a in enumerate(a)]

babies.sort(reverse=True)

dp=[[0]*(n+1) for i in range(n+1)]

ans=0

for l in range(n):
    for r in range(n):
        if l+r==n:
            ans=max(ans,dp[l][r])
            break
        activeness,ind=babies[l+r]
        dp[l+1][r]=max(dp[l+1][r],dp[l][r]+abs(ind-l)*activeness)
        dp[l][r+1]=max(dp[l][r+1],dp[l][r]+abs(ind-(n-1-r))*activeness)

print(ans)

Fixed submission:
n=int(input())
a=map(int,input().split())

babies=[(a,i) for i ,a in enumerate(a)]

babies.sort(reverse=True)

dp=[[0]*(n+1) for i in range(n+1)]

ans=0

for l in range(n):
    for r in range(n):
        if l+r==n:
            ans=max(ans,dp[l][r])
            break
        activeness,ind=babies[l+r]
        dp[l+1][r]=max(dp[l+1][r],dp[l][r]+abs(ind-l)*activeness)
        dp[l][r+1]=max(dp[l][r+1],dp[l][r]+abs(ind-(n-1-r))*activeness)

print(ans)
Buggy python submission (verdict: Runtime Error):
print(sum([x for x in range(a,int(input())+1) if (x%3!=0)and(x%5!=0)]))

Fixed submission:
def sum(x):
    a=int(x//3)
    b=int(x//5)
    c=int(x//15)
    sall=int((1+x)*(x/2))
    #print(sall)
    s3=int((3*(a-1)+6)*(a/2))
    #print(s3)
    s5=int((5*(b-1)+10)*(b/2))
    #print(s5)
    s15=int((15*(c-1)+30)*(c/2))
    #print(s15)
    ans=int(s15-s3-s5+sall)
    print(ans)
n=int(input())
sum(n)
Buggy python submission (verdict: Runtime Error):
print(sum([x for x in range(a,int(input())+1) if (x%3!=0)and(x%5!=0)]))

Fixed submission:
n=int(input())
s=input()

r_cnt=s.count("R")
g_cnt=s.count("G")
b_cnt=s.count("B")

ans=r_cnt*g_cnt*b_cnt

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n:break
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            ans -= 1

print(ans)
Buggy python submission (verdict: Runtime Error):
x,y,z=list(map(int,input().split()))
a=x
b=y
c=z
print(c a b)

Fixed submission:
x,y,z=list(map(int,input().split()))
print(z,x,y)