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

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ

    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]

    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def is_same(self, x, y):  # x, y が同じ集合に属するか判定する
        return self.find(x) == self.find(y)

    def group_size(self, x):  # x が属する集合の大きさを返す
        return self.size[self.find(x)]


N, M = map(int, input().split())
A, B = [0] * M, [0] * M  # 入力時に 0-index に合わせる

direct =[[] for _ in range(N)]  # 同じ集合の友達もしくはブロック関係の人
uf = UnionFind(N)  # 友達関係をまとめた UnionFind 木

for i in range(M):
    A[i], B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1
    direct[A[i]].append(B[i])
    direct[B[i]].append(A[i])
    uf.unite(A[i], B[i])

ans = [0] * N
for i in range(N):
    ans[i] = uf.group_size(i)
print(max(ans))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
li = [[] for i in range(N+1)]
for i in range(M):
  a, b = map(int, input().split())
  li[a].append(b)
  li[b].append(a)
  
ans = 0
for i in range(1, N+1):
  s = set(li[i])
  for x in s:
    for y in li[x]:
      if y == i:
        pass
      elif y in s:
        pass
      else:
        s.add(y)
  ans = max(ans, len(s)+1)
print(ans)
Problem p02630 (python)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
ans = sum(A)
C = Counter(A)

for i in range(Q):
  b, c = map(int, input().split())
  if C[b] != 0:
    cnt = C[b]
    C[c] += cnt
    C[b] = 0
    ans += (c-b) * cnt
  print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
ans = sum(A)
for i in Q:
  b,c = map(int, input().split())
  cnt = 0
  while b in A:
    A.remove(b)
    A.append(c)
    cnt += 1
  ans += (c-b) * cnt
  
print(ans)
Problem p02642 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
l = max(A)+1
li = [0]*(l)
A.sort()

for a in A:
  if li[a] == 0:
    li[a] = 1
    for i in range(a*2, l, a):
      li[i] = 2
  elif li[a] == 1:
    li[a] = 2
print(li.count(1))

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
A = [i[0] for i in c.items() if i[1] == 1]

A.sort()
ans = 0
i = 0
j = len(A)-1

while A:
  if A[j] % A[i] == 0:
    A.pop(j)
  j -= 1
  if j == i:
    ans += 1
    j = int(len(A)-1)
    i += 1
  if j == i:
    ans += 1
    break;

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

A.sort()
ans = 0
i = 0
j = N-1

c = Counter(A)
A = [i[0] for i in c.items() if i[1] == 1]

while A:
  if A[j] % A[i] == 0:
    A.pop(j)
  j -= 1
  if j == i:
    ans += 1
    j = int(len(A)-1)
    i += 1
  if j == i:
    ans += 1
    break;

print(ans)
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
was = []
tf = [False] * N
place = 1
cnt = 0

while tf[place-1] == False:
  if cnt < K:
    tf[place-1] = True
    was.append(place)
    place = A[place-1]
    cnt += 1
  else:
    print(place)
    break;
else:
  loop = cnt - was.index(place)
  num = (K-cnt) % loop + was.index(place)
  print(was[num])

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

num = 1
l = []
l.append(num)
for i in range(K):
  num = A[num-1]
  if num not in l:
    l.append(num)
  else:
    mod = (K-1-i) % (i+1-(l.index(num)))
    break;
    
for i in range(mod):
  num = A[num-1]
  
print(num)
Problem p02690 (python)

Fixed submission:
X = int(input())
plus = [i**5 for i in range(1000)]

for num in plus:
  if abs(X - num) in plus:
    break
    
if (X - num) in plus:
  print(plus.index(num), -1*plus.index(X-num))
else:
  print(plus.index(num), plus.index(num-X))

Buggy submission (verdict: Runtime Error):
X = int(input())
plus = [i**5 for i in range(100)]

for num in plus:
  if abs(X - num) in plus:
    break
    
if (X - num) in plus:
  print(plus.index(num), -1*plus.index(X-num))
else:
  print(plus.index(num), plus.index(num-X))
Problem p02691 (python)

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

ans= 0
for i in range(n):
    ans += ap[a[i] + i]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
  for j in range(i+1, N+1):
    number = abs(i-j)
    tall = A[i]+A[j]
    if number == tall:
      ans += 1
      
print(ans)
Problem p02702 (python)

Fixed submission:
S = str(input())
li = [0] * 2019
ans = 0
li[0] = 1

d = 1
s = 0
for i in S[::-1]:
  s += int(i) * d
  s = s % 2019
  li[s] += 1
  d *= 10
  d = d % 2019
  
for l in li:
  ans += l * (l-1) // 2

print(ans)

Buggy submission (verdict: Runtime Error):
S = str(input())

ans = 0
for i,j in itertools.combinations_with_replacement(range(len(S)+1), 2):
  if int(S[i:j+1]) % 2019 == 0:
    ans += 1
      
print(ans)
Problem p02713 (python)

Fixed submission:
K = int(input())
 
import math
 
ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      first = int(math.gcd(a, b))
      plus = int(math.gcd(first, c))
      ans += plus
      
print(ans)

Buggy submission (verdict: Runtime Error):
K = int(input())

import math

ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      plus = int(math.gcd(a, b, c))
      ans += plus
      
print(ans)
Problem p02727 (python)

Fixed submission:
from collections import deque
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r = sorted(r, reverse=True)

ans_p = deque(p[:X])
ans_q = deque(q[:Y])
ans_r = deque(r)

while (ans_p[-1]<ans_r[0]) or (ans_q[-1]<ans_r[0]):
  if ans_p[-1] <= ans_q[-1]:
    ans_p.pop()
    ans_p.appendleft(ans_r[0])
    ans_r.popleft()
  else:
    ans_q.pop()
    ans_q.appendleft(ans_r[0])
    ans_r.popleft()
  if not ans_r:
    break;
    
ans = sum(ans_p) + sum(ans_q)
print(ans)

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

red = sorted(p, reverse=True)[:X]
green = sorted(q, reverse=True)[:Y]
white = sorted(r, reverse=True)

original = sorted(red + green)
while original[0] < white[0]:
  original[0] = white[0]
  white.pop(0)
  original.sort()
  
print(sum(original))

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

red = sorted(p, reverse=True)[:X-1]
green = sorted(q, reverse=True)[:Y-1]
white = sorted(r, reverse=True)

original = sorted(red + green)
while original[0] < white[0]:
  original[0] = white[0]
  white.pop(0)
  original.sort()
  
print(sum(original))
Problem p02730 (python)

Fixed submission:
S = input()

num = len(S)
S1 = S[:(num-1)//2]
S2 = S[(num+1)//2:]

if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()

num = len(S)
S1 = S[:(num-1)/2]
S2 = S[(num+3)/2:]

if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()

num = len(S)
S1 = S[:(num-1)/2]
S2 = S[(num+3)/2:]

if S == S[::-1] and S1 == [::-1] and S2 == [::-1]:
  print('Yes')
else:
  print('No')
Problem p02732 (python)

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
total = 1

for n in c.items():
  total += n[1]*(n[1]-1)//2

for i in range(N):
  print(total-c[A[i]])

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
total = 0

for n in c.items():
  if n[1] > 1:
    total += n*(n-1)//2

for i in range(N):
  ans = total
  ans -= A.count(A[i])-1
  print(ans)

Buggy submission (verdict: Runtime Error):
import collections
import math
N = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(N):
  li = A[:i] + A[i+1]
  c = collections.Counter(li)
  l = [i for i in C.items() if i > 1]
  for num in l:
    ans += math.factorial(num) // (math.factorial(num-2) * 2)
    
print(ans)
Problem p02755 (python)

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

down_a = math.ceil(A / 0.08)
up_a = math.ceil((A+1) / 0.08)
down_b = int(B / 0.1)
up_b = int((B+1) / 0.1)

a = [i for i in range(down_a, up_a)]
b = [j for j in range(down_b, up_b)]

ans = -1
for num in a:
  if num in b:
    ans = num
    break;
print(ans)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())

down_a = A / 0.08
up_a = (A+1) / 0.08
down_b = B / 0.1
up_b = (B+1) / 0.1

a = [i for i in range(down_a, up_a)]
b = [j for j in range(down_b, up_b)]

ans = -1
for num in a:
  if num in b:
    ans = num
    break;
print(ans)
Problem p02756 (python)

Fixed submission:
from collections import deque
import sys
s = deque(list(input()))
Q = int(input())
cnt = 0

for i in range(Q):
  q = list(input().split())
  if q[0] == '1':
    cnt = (cnt+1) % 2
  elif q[1] == '1':
    if cnt == 0:
      s.appendleft(q[2])
    else:
      s.append(q[2])
  else:
    if cnt == 0:
      s.append(q[2])
    else:
      s.appendleft(q[2])

if cnt == 1:
  s.reverse()
print("".join(s))

Buggy submission (verdict: Runtime Error):
import sys
s = str(input())
Q = int(input())
q = sys.stdin.readlines()
for i in q:
  if i[0] == 1:
    s = alpha[::-1]
  elif i[1] == 1:
    s.appendleft(i[2])
  else:
    s.append(i[2])
print(s)
Problem p02761 (python)

Fixed submission:
def check(x):
  if len(str(x))!=N:
    return False
  for i in range(M):
    if str(x)[S[i]]!=str(C[i]):
      return False
  return True

N,M=map(int,input().split())
S=[]
C=[]
for i in range(M):
  s,c=map(int,input().split())
  s-=1
  S.append(s)
  C.append(c)
#print(S,C)
for i in range(1000):
  if check(i):
    print(i)
    exit()   
print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = -1
li = []

for i in range(M):
  s, c = map(int, input().split())
  if not [s, c] == [1, 0]:
    li.append([s, c])
  
if N==1 and li==[]:
  ans = 0
else:
  for i in range(10**(N-1), 10**N):
    j = 0
    while j < M:
      num = str(i)
      l = li[j]
      if num[l[0]-1] != str(l[1]):
        break;
      j += 1
    else:
      ans = i
      break;
    
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = -1
li = []

for i in range(M):
  s, c = map(int, input().split())
  if not [s, c] == [1, 0]:
    li.append([s, c])
  
if N==1 and li==[]:
  ans = 0
  
for i in range(10**(N-1), 10**N):
  j = 0
  while j < M:
    num = str(i)
    l = li[j]
    if num[l[0]-1] != str(l[1]):
      break;
    j += 1
  else:
    ans = i
    break;
    
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = -1
li = []

for i in range(M):
  s, c = map(int, input().split())
  if not [s, c] == [1, 0]:
    li.append([s, c])
  
if N==1 and li!=[]:
  ans = 0
  
for i in range(10**(N-1), 10**N):
  j = 0
  while j < M:
    num = str(i)
    l = li[j]
    if num[l[0]-1] != str(l[1]):
      break;
    j += 1
  else:
    ans = i
    break;
    
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = -1
li = []

for i in range(M):
  s, c = map(int, input().split())
  if not s, c = 1, 0:
    li.append([s, c])
  
if N==1 and li!=[]:
  ans = 0
  
for i in range(10**(N-1), 10**N):
  j = 0
  while j < M:
    num = str(i)
    l = li[j]
    if num[l[0]-1] != str(l[1]):
      break;
    j += 1
  else:
    ans = i
    break;
    
print(ans)
Problem p02772 (python)

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

for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 != 0 and A[i] % 5 != 0:
      print('DENIED')
      break
    elif i != N-1:
      continue
    else:
      print('APPROVED')
      break
  elif i != N-1:
    continue
  else:
    print('APPROVED')
    break

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

for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 != 0 and A[i] % 5 != 0:
      print('DENIED')
      break()
      
print('APPROVED')
Problem p02778 (python)

Fixed submission:
number = len(input())
print('x' * number)

Buggy submission (verdict: Runtime Error):
number = len(input())
print(x * number)
Problem p02780 (python)

Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))

mx = sum(p[:K])
cur = mx
for i in range(N-K):
  cur = cur-p[i]+p[i+K]
  mx = max(mx, cur)
  
ans = (mx+K) / 2
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
numbers = list(map(int, input().split()))

maxvalue = 0
for i in range(N+1-K):
  number_sum = list(sum(numbers[i:i+K]))
    
answer = (max(number_sum) + K) / 2
print(answer)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
numbers = list(map(int, input().split()))

maxvalue = 0
for i in range(N-K):
  number_sum = sum(numbers[i:i+K-1]
  if number_sum > maxvalue:
    maxvalue = number_sum
    
print(maxvalue)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
numbers = list(map(int, input().split()))

maxvalue = 0
for i in range(N-K):
  number_sum = sum(number[i:i+K-1]
  if number_sum > maxvalue:
    maxvalue = number_sum
    
print(maxvalue)
Problem p02786 (python)

Fixed submission:
H = input()

i = 0
while 2 ** i <= int(H):
  i += 1
print(2 ** i - 1)

Buggy submission (verdict: Runtime Error):
H = input()

i = 0
while 2 ** i <= H:
  i += 1
print(2 ** i - 1)
Problem p02796 (python)

Fixed submission:
N = int(input())
l = []
for i in range(N):
  X, L = map(int, input().split())
  l.append([X-L, X+L])
  
l.sort(key=lambda x: x[1])
pin = l[0][1]
ans = 1

for i in range(1, N):
  if pin <= l[i][0]:
    ans += 1
    pin = l[i][1]
    
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
nums = [list(map(int, input().split())) for _ in range(N)]
for row in nums:
  row.append(row[0]+row[1])
  row.append(row[0]-row[1])

nums.sort(key=lambda x: x[2])
ans_1 = N
ans_2 = N

point_1 = nums[0][2]
point_2 = nums[1][2]
for j in range(N-1):
  if nums[j+1][3] < point_1:
    ans_1 -= 1
  else:
    point = nums[j][2]
for j in range(N-1):
  if nums[j+1][3] < point_2:
    ans_2 -= 1
  else:
    point = nums[j][2]
print(max(ans_1, ans_2))
Problem p02803 (python)

Fixed submission:
import math
import sys
sys.setrecursionlimit(10000)
H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(str(input()))
  
def main(l, d, cnt):
  tmp = []
  for n in l:
    i, j = n[0], n[1]
    if (0<i) and (S[i-1][j] == '.'):
      if d[i-1][j] > d[i][j]+1:
        d[i-1][j] = d[i][j]+1
        tmp.append([i-1, j])
    if (i<H-1) and (S[i+1][j] == '.'):
      if d[i+1][j] > d[i][j]+1:
        d[i+1][j] = d[i][j]+1
        tmp.append([i+1, j])
    if (0<j) and (S[i][j-1] == '.'):
      if d[i][j-1] > d[i][j]+1:
        d[i][j-1] = d[i][j]+1
        tmp.append([i, j-1])
    if (j<W-1) and (S[i][j+1] == '.'):
      if d[i][j+1] > d[i][j]+1:
        d[i][j+1] = d[i][j]+1
        tmp.append([i, j+1])
  if tmp == []:
    return cnt
  else:
    cnt += 1
    return main(tmp, d, cnt)
  
ans = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      d = [[float('inf') for i in range(W)] for j in range(H)]
      d[i][j] = 0
      cnt = main([[i, j]], d, 0)
      ans = max(ans, cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(str(input()))
d = [[float('inf') for i in range(V)] for j in range(V)]
Problem p02842 (python)

Fixed submission:
N = int(input())
original = int(N // 1.08)

if 0 <= (original * 1.08) - N < 1:
  print(original)
elif 0 <= ((original + 1) * 1.08) - N < 1:
  print(original + 1)
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
original = int(N // 1.08)

if (math.floor(original * 1.08)) = N:
  print(original)
elif (math.floor((original + 1) * 1.08)) = N:
  print(original + 1)
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
original = int(N // 1.08)

if math.floor(original * 1.08) = N:
  print(original)
elif math.floor((original + 1) * 1.08) = N:
  print(original + 1)
else:
  print(':(')
Problem p02865 (python)

Fixed submission:
N = int(input())
answer = (N - 1) // 2
print(answer)

Buggy submission (verdict: Runtime Error):
N = map(int, input())
answer = N // 2
print(answer)
Problem p02887 (python)

Fixed submission:
N = int(input())
S = list(input())
 
length = 1
i = 0
while i < N-1:
  if S[i] == S[i+1]:
    i += 1
  else:
    length += 1
    i += 1
    
print(length)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
 
length = 1
i = 0
while i < N-1:
  if S[i] == S[i+1]:
    i += 1
  else:
    lendth += 1
    i += 1
    
print(length)
Problem p02898 (python)

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))

total = 0
for height in h:
  if height >= K:
    total += 1
    
print(total)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
total = 0
for i in range(N):
  h = int(input())
  if h >= K:
    total += 1
    
print(total)
Problem p02899 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A_re = []

for i in range(N):
  num = A[i]
  A_re.append([num, i+1])
  
A_re.sort()

Ans = []
for j in range(N):
  ans = A_re[j][1]
  Ans.append(str(ans))
  
Ans = ' '.join(Ans)
print(Ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A_re = []

for i in range(N):
  num = A[i]
  A_re.append([num, i+1])
  
A_re.sort()

Ans = []
for j in range(N):
  ans = A_re[j][1]
  Ans.append(ans)
  
print(' '.join(Ans))
Problem p02900 (python)

Fixed submission:
import collections
A, B = map(int, input().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 //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a = set(prime_factorize(A))
b = set(prime_factorize(B))

ans = 1
for i in b:
  if i in a:
    ans += 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
A, B = map(int, input().split())

a = collections.Counter(prime_factorize(A))
b = collections.Counter(prime_factorize(B))

l_a = list(a.keys())
l_b = list(b.keys())

ans = 1
for i in l_b:
  if i in l_a:
    ans += 1
    
print(ans)
Problem p02993 (python)

Fixed submission:
S = input()
judge = 0

for i in range(3):
  if S[i] == S[i+1]:
    judge += 1
    
if judge == 0:
  print('Good')
else:
  print('Bad')

Buggy submission (verdict: Runtime Error):
S = input()
judge = 0

for i in range(4):
  if S[i] == S[i+1]:
    judge += 1
    
if judge == 0:
  print('Good')
else:
  print('Bad')
Problem p02994 (python)

Fixed submission:
#両端のりんごの味は、(L, L+N-1)
N, L = map(int, input().split())
sum_all = N*(L+((N+1)/2)-1)

if L*(L+N-1) <= 0:
  print(int(sum_all))
elif L < 0:
  print(int(sum_all - L - N + 1))
else:
  print(int(sum_all - L))

Buggy submission (verdict: Runtime Error):
#両端のりんごの味は、(L, L+N-1)
N, L = map(int, input().split(''))
sum_all = N(L+((N+1)/2)-1)

if L*(L+N-1) <= 0:
  print(sum_all)
elif L < 0:
  print(sum_all - L - N + 1)
else:
  print(sum_all - L)
Problem p03000 (python)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))

dist = 0
cnt = 1
for i in range(N):
  dist += L[i]
  if dist <= X:
    cnt += 1
  else:
    break;
  
print(cnt)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))

dist = 0
cnt = 0
for i in range(N):
  if dist <= X:
    dist += list[i]
    cnt += 1
  else:
    break;
    
print(cnt)
Problem p03035 (python)

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

if 13 <= A:
  ans = B
elif A < 6:
  ans = 0
else:
  ans = B / 2
  
print(int(ans))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
C = []
for i in range(M):
  b, c = map(int, input().split())
  for i in range(b):
    C.append(c)

A.sort()
C.sort(reverse=True)
j = 0
while (j < len(C)) and (A[j] < C[j]):
  A[j] = C[j]
  j += 1
  
print(sum(A))
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
S = str(input())
li = []
cnt = 0

for i in range(N-1):
  if S[i]=='A' and S[i+1]=='C':
    cnt += 1
    li.append(cnt)
  else:
    li.append(cnt)

for i in range(Q):
  l, r = map(int, input().split())
  if l > 1:
    ans = li[r-2] - li[l-2]
  else:
    ans = li[r-2]
  print(ans)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = str(input())
li = []
cnt = 0

for i in range(N-1):
  if S[i]=='A' and S[i+1]=='C':
    cnt += 1
    li.append(cnt)
  else:
    li.append(cnt)

for i in range(Q):
  l, r = map(int, input().split())
  ans = li[r-1] - li[:l-1]
  print(ans)
Problem p03105 (python)

Fixed submission:
A, B, C = map(int, input().split())
if A*C <= B:
  print(C)
else:
  print(B//A)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input())
if A*C <= B:
  print(C)
else:
  print(B//A)
Problem p03196 (python)

Fixed submission:
N, P = map(int, input().split())
ans = 1
def main(n, p):
  if n == 1:
    return P
  global ans
  for i in range(2, int(p**(2/n))):
    t = i**n
    if p % t == 0:
      ans *= i
      return main(n, p//t)
  return ans

print(main(N, P))

Buggy submission (verdict: Runtime Error):
N, P = map(int, input().split())
ans = 1
def main(n, p):
  global ans
  for i in range(2, int(p**(1/(n-1)))):
    if p % (i**n) == 0:
      ans *= i
      num = p // (i**n)
      return main(n, num)
  return ans

print(main(N, P))