Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02631 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
l = [0] * 30
b = []
for i in range(n):
  x = a[i]
  t = ''
  j = 29
  while j >= 0:
    if x < 2**j:
      t += '0'
    else:
      x -= 2**j
      t += '1'
      l[j] += 1
    j -= 1
  b.append(t)
ans = []
for i in range(n):
  t = b[i]
  d = 0
  for j in range(30):
    k = l[j]
    if t[-(j+1)] == '1':
      k += 1
    k %= 2
    d += k * 2**j
  ans.append(d)
print(*ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
l = [0] * 30
b = []
for i in range(n):
  x = a[i]
  t = ''
  j = 29
  while j >= 0:
    if x < 2**j:
      t += '0'
    else:
      x -= 2**j
      t += '1'
      l[j] += 1
    j -= 1
  b.append(t)
ans = []
for i in range(n):
  t = b[i]
  for j in range(30):
    k = l[j]
    if t[j] == '1':
      k += 1
    k %= 2
    d += k * 2**j
  ans.append(d)
print(*ans)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  q = [True] * 102
  for i in range(n):
    q[p[i]] = False
  d_min = 10**3
  for j in range(102):
    if q[j]:
      d = abs(x - j)
      if d_min > d:
        d_min = d
        ans = j
  print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  q = [True] * 101
  for i in range(n):
    q[p[i]] = False
  d_min = 10**3
  for j in range(1, 102):
    if q[j]:
      d = abs(x - j)
      if d_min > d:
        ans = j
  print(ans)
Problem p02683 (python)

Fixed submission:
n, m, x = map(int, input().split())
A = [[] for _ in range(n)]
cost = [0] * n
for i in range(n):
  c_as = list(map(int, input().split()))
  cost[i], A[i] = c_as[0], c_as[1:]
INF = 10**9
ans = INF
for s in range(0, 1 << n):
  smart = [0] * m
  cost_sum = 0
  for i in range(n):
    if (s >> i) % 2 == 0:
      continue
    cost_sum += cost[i]
    for j in range(m):
      smart[j] += A[i][j]
  ok = True
  for j in range(m):
    if smart[j] < x:
      ok = False
  if ok:
    ans = min(ans, cost_sum)
if ans == INF:
  ans = -1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
A = [[] for _ in range(n)]
cost = [0] * n
for i in range(n):
  c_as = list(map(int, input().split()))
  cost[i], A[i] = c_as[0], c_as[1:]
INF = 10**9
ans = INF
for s in range(0, 1 << n):
  smart = [0] * m
  cost_sum = 0
  for i in range(n):
    if (s >> i) % 2 == 0:
      continue
    cost_sum += c[i]
    for j in range(m):
      smart[j] += A[i][j]
  ok = True
  for j in range(m):
    if smart[j] < x:
      ok = False
  if ok:
    ans = min(ans, cost_sum)
if ans == INF:
  ans = -1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
l = []
dp = [[] for _ in range(n)]
for _ in range(n):
  a = list(map(int, input().split()))
  l.append(a)
dp[0].append([0] * (m+1))
ans = []
for i in range(n):
  for row in dp[i]:
    dp[i+1].append(row)
    cnt = 0
    for j in range(m+1):
      if j == 0:
        row[0] += l[i][0]
      else:
        row[j] += l[i][j]
        if row[j] >= x:
          cnt += 1
    if cnt == m:
      ans.append(row[0])
    dp[i+1].append(row)
if len(ans) == 0:
  print(-1)
else:
  ans.sort()
  print(ans[0])
Problem p02691 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in range(n-1):
  idx = i + a[i] + 1
  if idx in dic:
    dic[idx] += 1
  else:
    dic[idx] = 1
ans = 0
j = n-1
while j > 0:
  target = j + 1 - a[j]
  idx = j + 1 + a[j]
  if target in dic:
    ans += dic[target]
  if j < n-1:
  	dic[idx] -= 1
  j -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in range(n-1):
  idx = i + a[i] + 1
  if idx in dic:
    dic[idx] += 1
  else:
    dic[idx] = 1
ans = 0
j = n-1
while j > 0:
  target = j + 1 - a[j]
  idx = j + 1 + a[j]
  if target in dic:
    ans += dic[target]
  dic[idx] -= 1
  j -= 1
print(ans)
Problem p02702 (python)

Fixed submission:
s = input()
dic = {}
for i in range(2019):
  dic[i] = 0
dic[0] = 1
m = 0
decimal = 1
for j in range(1, len(s)+1):
  m += int(s[-j]) * decimal
  m %= 2019
  dic[m] += 1
  decimal *= 10
  decimal %= 2019

ans = 0
for v in dic.values():
  ans += v*(v-1) // 2
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
dic = {}
for i in range(2019):
  dic[i] = 0
dic[0] = 1
m = 0
for j in range(len(s)):
  m = 10*m + s[j]
  m %= 2019
  dic[m] += 1
ans = 0
for v in dic.values():
  ans += v*(v-1) // 2
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
dic = {}
for i in range(2019):
  dic[i] = 0
dic[0] = 1
for j in range(1, len(s)+1):
  m = s[:j] % 2019
  dic[m] += 1
ans = 0
for v in dic.values():
  ans += v*(v-1) // 2
print(ans)
Problem p02708 (python)

Fixed submission:
n, k = map(int, input().split())
total = 0
for i in range(k, n+2):
  total += i*(n+1-i) + 1
  total %= 10**9 + 7
print(total)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
total = 0
for i in range(k, n+2):
  total += i(n+1-i) + 1
  total %= 10**9 + 7
print(total)
Problem p02709 (python)

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 submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

babies = [(a, i) for i, a in enumerate(a)]
babies.sort(reverse=True)

dp = [[0 for _ in range(n)] for _ in range(n)]
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] + activeness * abs(ind - l))
    dp[l][r+1] = max(dp[l][r+1], dp[l][r] + activeness * abs(ind - (n - 1 - r)))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
lst = [i for i in range(n)]
start = 0
end = n-1
max_happy = 0
for _ in range(n):
  m = 0
  for j in lst:
    if abs(j - start) > abs(j - end):
      happy = a[j] * abs(j - start)
      idx = 0
    else:
      happy = a[j] * abs(j - end)
      idx = 1
    if happy > m:
      m = happy
      m_idx = idx
      m_point = j
  max_happy += m
  lst.remove(m_point)
  if m_idx == 0:
    start += 1
  else:
    end -= 1
print(max_happy)
Problem p02713 (python)

Fixed submission:
def gcd(a, b):
  if a < b:
    a, b = b, a
  while a % b:
    a, b = b, a % b
  return b

k = int(input())
total = 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:
        total += gcd(gcd(a, b), c)
      elif a == b or b == c:
        total += 3*gcd(gcd(a, b), c)
      else:
        total += 6*gcd(gcd(a, b), c)
print(total)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
  if a < b:
    a, b = b, a
  while a % b:
    a, b = b, a % b
  return b

def gcd(a, b, c):
  return gcd(gcd(a, b), c)

k = int(input())
total = 0
for a in range(1, k+1):
  for b in range(1, k+1):
    for c in range(1, k+1):
      total += gcd(a, b, c)
print(total)
Problem p02732 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
dic1 = {}
dic2 = {}
for i in range(N):
  if A[i] in dic1:
    dic1[A[i]] += 1
  else:
    dic1[A[i]] = 1
ans = 0
for v in dic1.values():
  ans += (v*(v-1))//2
for j in range(N):
  w = dic1[A[j]]
  v = w-1
  comb = ans -(w*(w-1))//2 + (v*(v-1))//2
  print(comb)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
dic1 = {}
dic2 = {}
for i in range(N):
  if A[i] in dic1:
    dic1[A[i]] += 1
    dic2[A[i]].append(i)
  else:
    dic1[A[i]] = 1
    dic2[A[i]].append(i)

for j in range(N):
  ans = 0
  for k, v in dic1.items():
    if j in dic2[k]:
      ans += ((v-1)*(v-2))//2
    else:
      ans += (v*(v-1))//2
  print(ans)
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
if M == 0:
  if N == 1:
    print(0)
  else:
    m = 10 ** (N - 1)
    print(m)
else:
  dic = {}
  t = ''
  flg = True
  for _ in range(M):
    s, c = map(int, input().split())
    if s not in dic:
      dic[s] = c
    else:
      if dic[s] != c:
        flg = False
        break
  if N == 1:
    if dic[1] == 0:
      ans = 0
    else:
      ans = dic[1]
  else:
    if 1 in dic:
      if dic[1] == 0:
        flg = False
      else:
        t += str(dic[1])
    else:
      t += '1'
    for j in range(2, N + 1):
      if j in dic:
        t += str(dic[j])
      else:
        t += '0'
    ans = int(t)
  if flg:
    print(ans)
  else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
if M == 0:
  if N == 1:
    print(0)
  else:
    m = 10 ** (N - 1)
    print(m)
else:
  dic = {}
  t = ''
  flg = True
  flg2 = True
  for _ in range(M):
    s, c = map(int, input().split())
    if s not in dic:
      dic[s] = c
    else:
      flg = False
      break
  if flg:
    if N == 1:
      if dic[1] == 0:
        print(0)
      else:
        print(dic[1])
    else:
      if 1 in dic:
        if dic[1] == 0:
          flg2 = False
        else:
          t += str(dic[1])
      for j in range(2, N + 1):
        if j in dic:
          t += str(dic[j])
        else:
          t += '0'
    if flg2:
      print(int(t))
    else:
      print(-1)
  else:
    print(-1)
Problem p02780 (python)

Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:K])
m = sum(p[:K])
if K == N:
  print((s + N) / 2)
else:
  for i in range(K, N):
      s = s - p[i - K] + p[i]
      if s >= m:
        m = s
  print((m + K) / 2)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:K])
m = sum(p[:K])
for i in range(K, N + 1):
    s = s - p[i - K] + p[i]
    if s >= m:
      m = s
print((m + K) / 2)
Problem p02784 (python)

Fixed submission:
H, N = map(int, input().split(' '))
numlist = input().split(' ')
count = 0
for num in numlist:
  count += int(num)
  
if count >= H:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
H, N = map(int, input().split(' '))
sum = 0
for i in range(N):
  damage = int(input())
  sum += damage
  
if sum >= H:
  print('Yes')
else:
  print('No')
Problem p02791 (python)

Fixed submission:
N = int(input())
num = list(map(int, input().split()))
count = 0
min_num = num[0]
for i in range(N):
  n = num[i]
  if n <= min_num:
    count += 1
    min_num = n
    
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
num = list(map(int, input().split()))
count = 0
for i in range(N):
  n = int(num[i])
  if n == min(num[:i]):
    count += 1
print(count)
Problem p02795 (python)

Fixed submission:
H = int(input())
W = int(input())
N = int(input())
M = max(H, W)
if N % M == 0:
  print(N // M)
else:
  print((N // M) + 1)

Buggy submission (verdict: Runtime Error):
H = input()
W = input()
N = input()
M = max(H, W)
if N % M == 0:
  print(N // M)
else:
  print((N // M) + 1)
Problem p02842 (python)

Fixed submission:
n = int(input())
stp = int(n/1.08)
while True:
  cost = int(stp*1.08)
  if cost == n:
    ans = stp
    break
  elif cost > n:
    ans = ':('
    break
  else:
    stp += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
stp = int(N/1.08)
while True:
  cost = int(stp*1.08)
  if cost == n:
    ans = cost
    break
  elif cost > n:
    ans = '):'
    break
  else:
    stp += 1
print(ans)
Problem p02843 (python)

Fixed submission:
dp = {100: 1, 101: 1, 102: 1, 103: 1, 104: 1, 105: 1}
l = [100, 101, 102, 103, 104, 105]
for i in range(100001):
  if i == 0:
    dp[0] = 1
  elif i < 100:
    dp[i] = 0
  elif i >= 106:
    dp[i] = 0
    for cost in l:
      dp[i] += dp[i-cost]

n = int(input())
if dp[n] >= 1:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
dp = {100: 1, 101: 1, 102: 1, 103: 1, 104: 1, 105: 1}
l = [100, 101, 102, 103, 104, 105]
for i in range(100001):
  if i == 0:
    dp[0] = 1
  elif i < 100:
    dp[i] = 0
  elif i >= 106:
    for cost in l:
      dp[i] += dp[i-cost]

n = int(input())
if dp[n] >= 1:
  print(1)
else:
  print(0)
Problem p02844 (python)

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

before = [[-1] * 10]

for i in range(n):
  c = s[i]
  num = int(c)
  hoge = before[-1][::]
  hoge[num] = i
  before.append(hoge)
ans = 0
for i in range(10):
  now = before[-1][i]
  if now == -1:
    continue
  for j in range(10):
    now2 = before[now][j]
    if now2 == -1:
      continue
    for k in range(10):
      now3 = before[now2][k]
      if now3 == -1:
        continue
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

before = [[-1] * 10]

for i in range(n):
  c = s[i]
  num = int(c)
  hoge = before[-1][::]
  hoge[num] = i
  before.append(hoge)

for i in range(10):
  now = before[-1][i]
  if now == -1:
    continue
  for j in range(10):
    now2 = before[now][j]
    if now2 == -1:
      continue
    for k in range(10):
      now3 = before[now2][k]
      if now3 == -1:
        continue
      ans += 1
print(ans)
Problem p02845 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
que = [-1, -1, -1]
ans = 1
for i in range(n):
  if que[0]+1 == a[i]:
    if que[0] == que[1] and que[0] == que[2]:
      ans *= 3
      ans %= (10**9 + 7)
    elif que[0] == que[1]:
      ans *= 2
      ans %= (10**9 + 7)
    que[0] = a[i]
  elif que[1]+1 == a[i]:
    if que[1] == que[2]:
      ans *= 2
      ans %= (10**9 + 7)
    que[1] = a[i]
  elif que[2]+1 == a[i]:
    que[2] = a[i]
  else:
    ans = 0
    break
print(ans)

Buggy submission (verdict: Runtime Error):
def color(A, dic):
  if len(A) == 0:
    return 1
  t = A.pop()
  dic[t] -= 1
  return ((3-dic[t])*color(A, dic)) % (10**9 + 7)

n = int(input())
A = list(map(int, input().split()))
dic = {}
for i in range(n):
  if A[i] in dic:
    dic[A[i]] += 1
  else:
    dic[A[i]] = 1
print(color(A, dic))

Buggy submission (verdict: Runtime Error):
def color(A, dic):
  if len(A) == 0:
    return 1
  t = A.pop()
  dic[t] -= 1
  return (3-dic[t])*color(A, dic)

n = int(input())
A = list(map(int, input().split()))
dic = {}
for i in range(n):
  if A[i] in dic:
    dic[A[i]] += 1
  else:
    dic[A[i]] = 1
print(color(A, dic))
Problem p02885 (python)

Fixed submission:
A, B = map(int, input().split())
if A <= 2*B:
  print(0)
else:
  print(A - 2*B)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input())
if A <= 2*B:
  print(0)
else:
  print(A - 2*B)
Problem p02886 (python)

Fixed submission:
N = int(input())
no_list = list(map(int, input().split()))
sq_list = []
for i in no_list:
  sq_list.append(i ** 2)
print((sum(no_list) ** 2 - sum(sq_list))//2)

Buggy submission (verdict: Runtime Error):
N = int(input())
list = input().split(' ')
sq_list = []
for i in list:
  sq_list.append(i ** 2)
print((sum(list) ** 2 - sum(sq_list))//2)
Problem p02887 (python)

Fixed submission:
N = int(input())
S = input()
count = 0
for i in range(1, N):
  if S[i - 1] == S[i]:
    count += 1
print(N - count)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
count = 0
for i in range(1, N + 1):
  if S[i - 1] == S[i]:
    count += 1
print(N - count)
Problem p02909 (python)

Fixed submission:
S = input()
dic = {'Sunny':'Cloudy', 'Cloudy':'Rainy', 'Rainy':'Sunny'}
print(dic[S])

Buggy submission (verdict: Runtime Error):
S = input()
dic = {'Sunny':'Cloud', 'Cloud':'Rainy', 'Rainy':'Sunny'}
print(dic[S])
Problem p02910 (python)

Fixed submission:
s = input()
n = len(s)
flg = True
for i in range(n):
  if i % 2 == 0 and s[i] == 'L':
    flg = False
    break
  elif i % 2 == 1 and s[i] == 'R':
    flg = False
    break

if flg:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()
ans = 'Yes'
for i in range((len(S) + 1) // 2):
  if S[2*i] == 'L' or S[2*i + 1] == 'R':
    ans = 'No'
    break

print(ans)
Problem p02911 (python)

Fixed submission:
n, k, q = map(int, input().split())
point = [0] * (n+1)
for _ in range(q):
  a = int(input())
  point[a] += 1

for i in range(1, n+1):
  if k + point[i] > q:
    print('Yes')
  else:
    print('No')

Buggy submission (verdict: Runtime Error):
n, k, q = map(int, input().split())
point = [0] * (n+1)
for _ in range(n):
  a = int(input())
  point[a] += 1

for i in range(1, n+1):
  if k + point[i] > q:
    print('Yes')
  else:
    print('No')
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
count = 0
for i in range(3):
  if S[i] == T[i]:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
count = 0
for i in range(3):
  if s[i] == T[i]:
    count += 1
print(count)
Problem p02982 (python)

Fixed submission:
n, d = map(int, input().split())
lst = []
for _ in range(n):
  x = list(map(int, input().split()))
  lst.append(x)
ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    dist = 0
    for k in range(d):
      dist += (lst[i][k] - lst[j][k])**2
    j = 1
    while j**2 <= dist:
      if j**2 == dist:
        ans += 1
        break
      j += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
lst = []
for _ in range(n):
  x = list(map(int, input().split()))
ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    dist = 0
    for k in range(d):
      dist += (lst[i][k] - lst[j][k])**2
    j = 1
    while j**2 <= dist:
      if j**2 == dist:
        ans += 1
        break
      j += 1
print(ans)
Problem p02988 (python)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n - 2):
  if min(p[i], p[i + 2]) < p[i + 1] < max(p[i], p[i + 2]):
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(N - 2):
  if min(p[i], p[i + 2]) < p[i + 1] < max(p[i], p[i + 2]):
    count += 1
print(count)
Problem p02994 (python)

Fixed submission:
N, L = map(int, input().split())
l = []
for i in range(N):
  l.append(L + i)
l.sort()
if 0 in l:
  print(sum(l))
else:
  if l[0] > 0:
    l.pop(0)
    print(sum(l))
  else:
    l.pop(-1)
    print(sum(l))

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
for i in range(N):
  l.append(abs(L + i))
l.sort()
l.pop(0)
print(sum(l))
Problem p03030 (python)

Fixed submission:
n = int(input())
lst = []
for i in range(n):
  s, p = input().split()
  p = int(p)
  lst.append((s, p, i+1))
lst_sorted = sorted(lst, key=lambda x: (x[0], -x[1], x[2]))
for _, _, num in lst_sorted:
  print(num)

Buggy submission (verdict: Runtime Error):
n = int(input())
lst = []
for i in range(n):
  s, p = input().split()
  p = int(p)
  lst.append((s, p, i+1))
lst_sorted = sorted(lst, key:lambda x: (x[0], -x[1], x[2]))
for _, _, num in lst_sorted:
  print(num)

Buggy submission (verdict: Runtime Error):
n = int(input())
lst = []
for i in range(n):
  s, p = input().split()
  p = int(p)
  lst.append((s, p, i+1))
lst_sorted = sorted(lst, key:lambda x: (x[0], -x[1]))
for _, _, num in lst_sorted:
  print(num)
Problem p03032 (python)

Fixed submission:
n, k = map(int, input().split())
v = list(map(int, input().split()))
reverse_v = v[::-1]
lst = [0] * (k + 1)
left = [[]]
right = [[]]
for i in range(1, n+1):
  left.append(v[:i])
  right.append(reverse_v[:i])

for cnt in range(1, k+1):
  rest = k - cnt
  total = 0
  if cnt <= n:
    for j in range(cnt+1):
      lst_j = left[j] + right[cnt-j]
      lst_j.sort()
      l = cnt
      for idx in range(cnt):
        if lst_j[idx] >= 0:
          l = idx
          break
      if l == cnt:
        value = 0
      else:
        flg = min(l, rest)
        value = sum(lst_j[flg:])
      if value > total:
        total = value
    lst[cnt] = total

ans = max(lst)
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
v = list(map(int, input().split()))
reverse_v = v[::-1]
lst = [0] * (k + 1)
left = [[]]
right = [[]]
for i in range(1, n+1):
  left.append(v[:i])
  right.append(reverse_v[:i])

for cnt in range(1, k+1):
  rest = k - cnt
  total = 0
  for j in range(cnt+1):
    lst_j = left[j] + right[cnt-j]
    lst_j.sort()
    l = cnt
    for idx in range(cnt):
      if lst_j[idx] >= 0:
        l = idx
        break
    if l == cnt:
      value = 0
    else:
      flg = min(l, rest)
      value = sum(lst_j[flg:])
    if value > total:
      total = value
  lst[cnt] = total

ans = max(lst)
print(ans)
Problem p03060 (python)

Fixed submission:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
R = []
for i in range(N):
  l = V[i] - C[i]
  R.append(l)
cost = 0
for r in R:
  if r > 0:
    cost += r
print(cost)

Buggy submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
R = []
for i range(N):
  l = V[i] - C[i]
  R.append(l)
cost = 0
for r in R:
  if r > 0:
    cost += r
print(cost)

Buggy submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
R = []
for i range(N):
  R.append(V[i] - C[i])
cost = 0
for r in R:
  if r > 0:
    cost += r
print(cost)
Problem p03069 (python)

Fixed submission:
n = int(input())
s = input()
b_total = 0
w_total = 0
ans = 0
for i in range(n):
  if s[i] == '#':
    b_total += 1
  if s[i] == '.':
    w_total += 1
if b_total == n:
  print(0)
else:
  b_cnt = 0
  w_cnt = 0
  ans = b_cnt + (w_total - w_cnt)
  for i in range(n):
    if s[i] == '#':
      b_cnt += 1
    if s[i] == '.':
      w_cnt += 1
    cnt = b_cnt + (w_total - w_cnt)
    ans = min(ans, cnt)
  print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
b_total = 0
w_total = 0
ans = 0
for i in range(n):
  if s[i] == '#':
    b_cnt += 1
  if s[i] == '.':
    w_cnt += 1
b_cnt = 0
w_cnt = 0
ans = 10**6
for i in range(n):
  if s[i] == '#':
    b_cnt += 1
  if s[i] == '.':
    w_cnt += 1
  cnt = b_cnt + (w_total - w_cnt)
  ans = min(ans, cnt)
print(ans)
Problem p03076 (python)

Fixed submission:
m = 9
l = []
r = []
for i in range(5):
  a = int(input())
  if a % 10 != 0:
    m = 10 - a % 10
    b = a + m
    l.append(b)
    r.append(m)
  else:
    l.append(a)
    r.append(0)
r.sort()
print(sum(l) - r[-1])

Buggy submission (verdict: Runtime Error):
m = 9
l = []
r = []
for i in range(5):
  a = int(input())
  if a % 10 != 0:
    m = 10 - a % 10
    b = a + a % 10
    l.append(b)
    r.append(m)
  else:
    l.append(a)
r.sort()
print(sum(l) - r[-1])
Problem p03080 (python)

Fixed submission:
N = int(input())
S = input()
red = 0
blue = 0
for s in S:
  if s == 'R':
    red += 1
  if s == 'B':
    blue += 1
if red > blue:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
red = 0
blue
for s in S:
  if s == 'R':
    red += 1
  if s == 'B':
    blue += 1
if red > blue:
  print('Yes')
else:
  print('No')
Problem p03086 (python)

Fixed submission:
S = input()
S += 'Z'
count = 0
l = []
for s in S:
  if s not in ['A', 'T', 'C', 'G']:
    l.append(count)
    count = 0
  else:
    count += 1
l.sort()
print(l[-1])

Buggy submission (verdict: Runtime Error):
S = input()
count = 0
l = []
for s in S:
  if s not in ['A', 'T', 'C', 'G']:
    l.append(count)
    count = 0
  else:
    count += 1
l.sort()
print(l[-1])
Problem p03220 (python)

Fixed submission:
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
m = abs(A - T + H[0] * 0.006)
for i in range(N):
  d = T - H[i] * 0.006
  a = abs(A - d)
  if m >= a:
    m = a
    ans = i + 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
m = abs(A - T + h[0] * 0.006)
for i in range(N):
  d = T - h[i] * 0.006
  a = abs(A - d)
  if m >= a:
    m = a
    ans = i
print(ans)