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

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

work_day_min = []
work_day_max = []

for i in range(N):
    if S[i] == 'o':
        if i > 0 and len(work_day_min) > 0:
            if i - work_day_min[-1] <= C:
                continue
        work_day_min.append(i)
    if len(work_day_min) == K:
        break

for i in range(N):
    if S[N - i - 1] == 'o':
        if i > 0 and len(work_day_max) > 0:
            if work_day_max[-1] - (N - i - 1) <= C:
                continue
        work_day_max.append(N - i - 1)
    if len(work_day_max) == K:
        break

for i in range(K):
    if work_day_min[i] == work_day_max[K-i-1]:
        print(work_day_min[i]+1)

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

work_day_min = []
work_day_max = []

for i in range(N):
    if S[i] == 'o':
        if i == 0 or i - work_day_min[-1] > C:
            work_day_min.append(i)
    if len(work_day_min) == K:
        break

for i in range(N):
    if S[N - i - 1] == 'o':
        if i == 0 or work_day_max[-1] - (N - i - 1) > C:
            work_day_max.append(N - i - 1)
    if len(work_day_max) == K:
        break

work_day_max.reverse()

for i in range(K):
    if work_day_min[i] == work_day_max[i]:
        print(work_day_min[i]+1)
Problem p02727 (python)

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

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

p = p[(A-X):]
q = q[(B-Y):]

i_p = 0
i_q = 0
for i_r in range(C):
    if i_p >= len(p):
        if q[i_q] < r[i_r]:
            q[i_q] = r[i_r]
            i_q += 1
    elif i_q >= len(q):
        if p[i_p] < r[i_r]:
            p[i_p] = r[i_r]
            i_p += 1
    elif p[i_p] <= q[i_q]:
        if p[i_p] < r[i_r]:
            p[i_p] = r[i_r]
            i_p += 1
    else:
        if q[i_q] < r[i_r]:
            q[i_q] = r[i_r]
            i_q += 1

    if i_p >= len(p) and i_q >= len(q):
        break

res = 0

for i in range(len(p)):
    res += p[i]

for i in range(len(q)):
    res += q[i]

print(res)

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

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

p = p[(A-X):]
q = q[(B-Y):]

i_p = 0
i_q = 0
for i_r in range(C):
    if p[i_p] <= q[i_q]:
        if p[i_p] < r[i_r]:
            p[i_p] = r[i_r]
            i_p += 1
    else:
        if q[i_q] < r[i_r]:
            q[i_q] = r[i_r]
            i_q += 1

    if i_p >= len(p) and i_q >= len(Q):
        break

res = 0

for i in range(len(p)):
    res += p[i]

for i in range(len(q)):
    res += q[i]

print(res)
Problem p02730 (python)

Fixed submission:
s = input()
c = int((len(s) - 1)/2)
ans = (list(s) == list(reversed(s)) and list(s[:c]) == list(reversed(s[:c])) and list(s[(c+1):]) == list(reversed(s[(c+1):])))
print(["No", "Yes"][ans])

Buggy submission (verdict: Runtime Error):
s = input()
c = int((len(s) - 1)/2)
ans = (list(s) == list(reversed(s) and list(s[:c]) == list(reversed(s[:c])) and list(s[(c+1):]) == list(reversed(s[(c+1):])))
print(["No", "Yes"][ans])
Problem p02767 (python)

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
sum_min = 10**8

for i in range(min(X), max(X)+1):
    s = 0
    for j in range(N):
        s += (X[j] - i)**2
    
    if s < sum_min:
        sum_min = s

print(sum_min)

Buggy submission (verdict: Runtime Error):
集会は数直線上の任意の 整数値の座標 で開くことができ、座標
Problem p02574 (python)

Fixed submission:
from math import gcd
from functools import reduce
def main():
    N = int(input())
    A = list(map(int, input().split()))

    M = 10**6+1
    mp = [0]*M
    for a in A:
        mp[a] += 1

    pairwise = 1
    for i in range(2,M):
        if sum(mp[i::i])>1:
            pairwise = 0
            break

    if pairwise:
        print('pairwise coprime')
    elif reduce(gcd, A) == 1:
        print('setwise coprime')
    else:
        print('not coprime')

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce

M = 10 ** 6
ret = [0] * M
n = int(input())
nums = list(map(int, input().split()))
flag = 1
for i in nums:
    ret[i] += 1
for i in range(2, M):
    if sum(ret[i::i]) > 1:
        flag = 0
        break
if flag:
    print("pairwise coprime")
elif reduce(gcd, nums) == 1:
    print("setwise coprime")
else:
    print("not coprime")
Problem p02714 (python)

Fixed submission:
import sys

n = int(input())
s = list(input())

rs = []
gs = []
bs = []

for i in range(n):
  if s[i] == "R":
    rs.append(i)
  elif s[i] == "G":
    gs.append(i)
  elif s[i] == "B":
    bs.append(i)

def binary(lst, d):
  low = 0
  high = len(lst) - 1
  while low <= high:
    mid = (low + high) // 2
    if lst[mid] == d:
      return True
    elif lst[mid] < d:
      low = mid + 1
    else:
      high = mid - 1
  return False

ans = len(rs)*len(gs)*len(bs)
if len(bs) == 0:
  print(0)
  sys.exit()
for i in range(len(rs)):
  for j in range(len(gs)):
    dis = abs(rs[i] - gs[j])
    if (rs[i] + gs[j])%2 == 0:
      can1 = abs(rs[i] + gs[j])//2
      if binary(bs, can1):
      	ans -= 1
    if max(rs[i], gs[j]) + dis <= bs[-1]:
      can2 = max(rs[i], gs[j]) + dis
      if binary(bs, can2):
      	ans -= 1
    if min(rs[i], gs[j]) - dis > 0:
      can3 = min(rs[i], gs[j]) - dis
      if binary(bs, can3):
      	ans -= 1
        
print(ans)

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

rs = []
gs = []
bs = []

for i in range(n):
  if s[i] == "R":
    rs.append(i)
  elif s[i] == "G":
    gs.append(i)
  elif s[i] == "B":
    bs.append(i)

def binary(lst, d):
  low = 0
  high = len(lst) - 1
  while low <= high:
    mid = (low + high) // 2
    if lst[mid] == d:
      return True
    elif lst[mid] < d:
      low = mid + 1
    else:
      high = mid - 1
  return False

ans = len(rs)*len(gs)*len(bs)
for i in range(len(rs)):
  for j in range(len(gs)):
    dis = abs(rs[i] - gs[j])
    if (rs[i] + gs[j])%2 == 0:
      can1 = abs(rs[i] + gs[j])//2
      if binary(bs, can1):
      	ans -= 1
    if max(rs[i], gs[j]) + dis <= bs[-1]:
      can2 = max(rs[i], gs[j]) + dis
      if binary(bs, can2):
      	ans -= 1
    if min(rs[i], gs[j]) - dis >= 0:
      can3 = min(rs[i], gs[j]) - dis
      if binary(bs, can3):
      	ans -= 1
        
print(ans)
Problem p02842 (python)

Fixed submission:
n = int(input())
import math

for i in range(50000):
  if math.floor(i*1.08) == n:
    print(i)
    exit()
    
print(":(")

Buggy submission (verdict: Runtime Error):
n = int(input())
import math
for i in range(50000):
  if math.floor(i*1.08) == n:
    print(i)
    exit()
    
ptiny(":(")
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n, q = map(int, sys.stdin.readline().split())

graph = [[] for _ in range(n+1)] 
for i in range(1, n):
  a, b = map(int, sys.stdin.readline().split())
  graph[a].append(b)
  graph[b].append(a)

point = [0]*(n+1)
for i in range(q):
  p, x = map(int, sys.stdin.readline().split())
  point[p] += x

seen = [False]*(n+1)
counter = [0]*(n+1)
sum_point = 0

def dfs(v):
  
  global graph
  global seen
  global sum_point
  global counter
  
  seen[v] = True
  sum_point += point[v]
  
  for next_v in graph[v]:
    
    if seen[next_v]: 
      continue
    dfs(next_v)
  
  counter[v] = sum_point
  sum_point -= point[v]

dfs(1)
print(*counter[1::])

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())

graph = [[] for _ in range(n+1)] 
for i in range(1, n):
  a, b = map(int, input().split())
  graph[a].append(b)
  graph[b].append(a)

point = [0]*(n+1)
for i in range(q):
  p, x = map(int, input().split())
  point[p] += x

seen = [False]*(n+1)
counter = [0]*(n+1)
sum_point = 0

def dfs(v):
  
  global graph
  global seen
  global sum_point
  global counter
  
  seen[v] = True
  sum_point += point[v]
  
  for next_v in graph[v]:
    
    if seen[next_v]: 
      continue
    dfs(next_v)
  
  counter[v] = sum_point
  sum_point -= point[v]

dfs(1)
print(*counter[1::])

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())

graph = [[] for _ in range(n+1)] 
for i in range(1, n):
  a, b = map(int, input().split())
  graph[a].append(b)
  graph[b].append(a)

point = [0]*(n+1)
for i in range(q):
  p, x = map(int, input().split())
  point[p] += x

seen = [False]*(n+1)
counter = [0]*(n+1)
sum_point = 0

def dfs(v):
  
  global graph
  global seen
  global sum_point
  global counter
  
  seen[v] = True
  sum_point += point[v]
  
  for next_v in graph[v]:
    
    if seen[next_v]: 
      continue
    dfs(next_v)
  
  counter[v] = sum_point
  sum_point -= point[v]

dfs(1)
print(counter[1::])
Problem p03161 (python)

Fixed submission:
n, k = map(int, input().split())
step = list(map(int, input().split()))

ans = [float('inf')]*(10**6)

ans[0] = 0
def dp(n):
  for i in range(n):
    for j in range(k+1):
      if i+j < n:
        ans[i+j] = min(ans[i+j], ans[i] + abs(step[i+j] - step[i]))
  return ans[n-1]

print(dp(n))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
step = list(map(int, input().split()))

ans = [float('inf')]*(10)

ans[0] = 0
def dp(n):
  for i in range(n):
    for j in range(k+1):
      if i+j < n:
        ans[i+j] = min(ans[i+j], ans[i] + abs(step[i+j] - step[i]))
  return ans[n-1]

print(dp(n))
Problem p03282 (python)

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

counter = 0
for i in range(len(s)):
  if s[i] == "1":
    counter += 1
    ans = 1
  else:
    ans = i
    break
  
if k <= counter:
  ans = 1
else:
  ans = s[ans]
  
print(ans)

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

counter = 0
for i in range(len(s)):
  if s[i] == "1":
    counter += 1
  else:
    ans = i
    break
  
if k <= i:
  ans = 1
else:
  ans = s[ans]
  
print(ans)
Problem p03378 (python)

Fixed submission:
n, m, x = map(int, input().split())
lst = list(map(int, input().split()))

g1, g2 = 0, 0
for i in range(x):
  if i in lst:
    g1 += 1
    
for i in range(x+1, n):
  if i in lst:
    g2 += 1
    
print(min(g1, g2))

Buggy submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
lst = list(map(int, input().split()))

g1, g2 = 0
for i in range(x):
  if i in lst:
    g1 += 1
    
for i in range(x+1, n):
  if i in lst:
    g2 += 1
    
print(min(g1, g2))
Problem p03557 (python)

Fixed submission:
import bisect
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

ans = 0
for i in range(n):
  canA = bisect.bisect_left(A, B[i])
  canC = bisect.bisect_right(C, B[i])
  ans += (canA)*(n-canC)
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

print(A)
print(B)
print(C)

ans = 0
for i in range(n):
  canB = bisect.bisect_right(B, A[i])
  if canB == n:
    continue
  else:
    for j in range(canB, n):
      canC = bisect.bisect_right(C, B[j])
      ans += (n - canC)
      print(A[i], B[j], C[canC], (n - canC))
print(ans)
Problem p02843 (python)

Fixed submission:
X = input()
if int(X) < 100:
    print(0)
    exit()
x = int(X[-2] + X[-1])
X = (int(X)-x)//100
if x > 5*X:
    print(0)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
X = input()
x = int(X[-2] + X[-1])
X = (int(X)-x)//100
if x > 5*X:
    print(0)
else:
    print(1)
Problem p02909 (python)

Fixed submission:
S = input()
if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
elif S == 'Rainy':
    print('Sunny')

Buggy submission (verdict: Runtime Error):
S = input()
if S = 'Sunny':
    print('Cloudy')
elif S = 'Cloudy':
    print('Rainy')
elif S = 'Rainy':
    print('Sunny')
Problem p02910 (python)

Fixed submission:
S = input()
S_o = S[::2]
S_e = S[1::2]
if 'L' in S_o or 'R' in S_e:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
S = input()
S_o = S[::2]
S_e = S[1::2]
if 'L' in S_o or 'R' in _e:
    print('No')
else:
    print('Yes')
Problem p02953 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
if N == 1:
    print('Yes')
    exit()
for i in range(N-1):
    if H[i] == H[i+1]:
        continue
    elif H[i] < H[i+1]:
        H[i+1] -= 1
    else:
        print('No')
        exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
if N == 1:
    print('Yes')
    exit()
for i in range(N-1):
    if H[i] == H[i+1]:
        pass
    elif H[i] < H[i+1]:
        H[i+1] -= 1
    else:
        print('No')
        exit()
input('Yes')
Problem p02969 (python)

Fixed submission:
r = int(input())
print(3*r**2)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
A_m = str(max(A))
a = A.index(int(A_m))
A = sorted(A)
if A.count(int(A_m)) >= 2:
    print((A_m + '\n')*(N-1) + A_m)
else:
    print(a)
    print((A_m + '\n')*a + str(A[-2]))
    print((A_m + '\n')*(N-(a+2)) + A_m)
Problem p02971 (python)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
A_m = str(max(A))
a = A.index(int(A_m))
A = sorted(A)
if A.count(int(A_m)) >= 2:
    print((A_m + '\n')*(N-1) + A_m)
else:
    print((A_m + '\n')*a + str(A[-2]))
    if N-(a+1) == 1:
        print(A_m)
    elif N-(a+1) < 1:
        pass
    else:
        print((A_m + '\n')*(N-(a+2)) + A_m)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
A_m = max(A)
if A.count(max) >= 2:
    for i in range(N):
        print(A_m)
else:
    for i in range(N):
        if A[i] == A_m:
            del A[i]
            A_m_new = max(A)
            print(A_m_new)
        else:
            print(A_m)
Problem p02995 (python)

Fixed submission:
import fractions
def lcm(x, y):
    return x * y // fractions.gcd(x, y)

A, B, C, D = map(int,input().split())
E = lcm(C, D)
print((B - (B // C + B // D - B // E))-((A-1)-((A-1) // C + (A-1) // D - (A-1) // E)))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return x * y // math.gcd(x, y)

A, B, C, D = map(int,input().split())
E = lcm(C, D)
print((B - (B // C + B // D - B // E))-((A-1)-((A-1) // C + (A-1) // D - (A-1) // E)))
Problem p03035 (python)

Fixed submission:
A, B = map(int,input().split())
if A >= 13:
    print(B)
elif 6 <= A <= 12:
    print(B // 2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
A, B = map(int,input().split())
if A >= 13:
    print(B)
elif if 6 <= A <= 12:
    print(B // 2)
else:
    print(0)
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(500*500)
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[]for _ in range(N+1)]
ans = [-1]*(N+1)
for u,v,w in edges:
    A[u].append([v,w%2])
    A[v].append([u,w%2])

ans[1] = 0
def dfs(r):
    for a in A[r].copy():
        n = a[0]
        d = a[1]
        if ans[n] == -1:
            ans[n] = (ans[r] + d) % 2
            dfs(n)
dfs(1)
for a in ans[1:]:
    print(a%2)

Buggy submission (verdict: Runtime Error):
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[] for _ in range(N+1)]

for edge in edges:
    A[edge[0]].append([edge[1],edge[2]])
    A[edge[1]].append([edge[0],edge[2]])

depth = [-1] * (N+1)
depth[1] = 0

def dfs(A,s):
    for v in A[s]:
        if depth[v[0]] == -1:
            depth[v[0]] = depth[s] + v[1]
            dfs(A,v[0])    
dfs(A,1)
for d in depth[1:]:
    if d % 2 == 0:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[]for _ in range(N+1)]
ans = [-1]*(N+1)
for u,v,w in edges:
    A[u].append([v,w%2])
    A[v].append([u,w%2])

ans[1] = 0
def dfs(r):
    for a in A[r].copy():
        n = a[0]
        d = a[1]
        if ans[n] == -1:
            ans[n] = (ans[r] + d) % 2
            dfs(n)
dfs(1)
for a in ans[1:]:
    print(a%2)

Buggy submission (verdict: Runtime Error):
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[]for _ in range(N+1)]
ans = [-1]*(N+1)
for u,v,w in edges:
    A[u].append([v,w])
    A[v].append([u,w])

ans[1] = 0
def dfs(r):
    for a in A[r].copy():
        n = a[0]
        d = a[1]
        if ans[n] == -1:
            ans[n] = (ans[r] + d) % 2
            dfs(n)
dfs(1)
for a in ans[1:]:
    print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[]for _ in range(N+1)]
ans = [-1]*(N+1)
for u,v,w in edges:
    A[u].append([v,w])
    A[v].append([u,w])

ans[1] = 0
def dfs(r):
    for a in A[r]:
        n = a[0]
        d = a[1]
        if ans[n] == -1:
            ans[n] = (ans[r] + d) % 2
            dfs(n)
dfs(1)
for a in ans[1:]:
    print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[]for _ in range(N+1)]
ans = [-1]*(N+1)
for u,v,w in edges:
    A[u].append([v,w])
    A[v].append([u,w])

ans[1] = 0
def dfs(r):
    for a in A[r]:
        n = a[0]
        d = a[1]
        if ans[n] == -1:
            ans[n] = ans[r] + d
            dfs(n)
dfs(1)
for a in ans[1:]:
    if a % 2 == 0:
        print(0)
    else:
        print(1)
Problem p03047 (python)

Fixed submission:
n, k = map(int,input().split())
print(n - (k-1))

Buggy submission (verdict: Runtime Error):
n, k = map(int,input())
print(n - (k-1))
Problem p03059 (python)

Fixed submission:
a, b, c = map(int, input().split())
result = 0
for i in range(1 , c + 1):
    if i % a == 0:
        result += b
print(result)

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
ans = 0
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A_new = A[:i] + A[i+1:]
    ans = max(ans, gcd(*A_new))
print(ans)
Problem p03061 (python)

Fixed submission:
import fractions

N = int(input())
a = list(map(int,input().split()))
a1 = [0] * N
a2 = [0] * N
a1[0] = 0
a2[-1] = 0
a1[1] = a[0]
a2[-2] = a[-1]
ans = 0
for i in range(2,N):
    a1[i] = fractions.gcd(a1[i-1], a[i-1])
    a2[-(i+1)] = fractions.gcd(a2[-i], a[-i])
for a,b in zip(a1, a2):
    if a == 0:
        ans = max(ans, b)
    elif b == 0:
        ans = max(ans, a)
    else:
        ans = max(ans, fractions.gcd(a, b))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans = 0
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A_new = A[:i] + A[i+1:]
    ans = max(ans, gcd(*A_new))
print(ans)
Problem p03076 (python)

Fixed submission:
time = [int(input()) for i in range(5)]
result = 0
a = [10]

for i in range(5):
    if time[i] % 10 == 0:
        result += time[i]
    else:
        result += ((time[i] // 10)+1)*10
        a.append(time[i] % 10)
print(result - (10 - min(a)))

Buggy submission (verdict: Runtime Error):
time = [int(input()) for i in range(5)]
result = 0
a = []

for i in range(5):
    if time[i] % 10 == 0:
        result += time[i]
    else:
        result += ((time[i] // 10)+1)*10
        a.append(time[i] % 10)
print(result - (10 - min(a)))

Buggy submission (verdict: Runtime Error):
time = [int(input()) for i in range(5)]
result = 0
a = []

for i in range(5):
    if time[i] % 10 == 0:
        result += time[i]
        print(result)
    else:
        result += ((time[i] // 10)+1)*10
        a.append(time[i] % 10)
        print(result)
print(result - (10 - min(a)))
Problem p03087 (python)

Fixed submission:
from itertools import accumulate

N, Q = map(int,input().split())
S = list(input())
L = [0] * Q
R = [0] * Q
for i in range(Q):
    L[i], R[i] = map(int,input().split())

S = ['0'] + S
check = [0] * N

for i in range(N):
    if S[i] == 'A':
        if S[i+1] == 'C':
            check[i] = 1

check = list(accumulate(check))
for left, right in zip(L, R):
    print(check[right-1] - check[left-1])

Buggy submission (verdict: Runtime Error):
from itertools import accumulate

N, Q = map(int,input().split())
S = input()
L = [0] * Q
R = [0] * Q
for i in range(Q):
    L[i], R[i] = map(int,input().split())

s_list = [0]*(N+1)
for i in range(1,N+1):
    if S[i-1] == 'A':
        if S[i] == 'C':
            s_list[i] = 1
s_list = list(accumulate(s_list))
for i,j in zip(L, R):
    print(s_list[j-1]-s_list[i-1])
Problem p03106 (python)

Fixed submission:
a,b,k = map(int, input().split())
l =[]
if a <= b:
    for i in range(1,a + 1):
        if a % i == 0  and b % i == 0:
            l.append(i)
else:
    for i in range(1,b + 1):
        if a % i == 0  and b % i == 0:
            l.append(i)
print(l[len(l)-k])

Buggy submission (verdict: Runtime Error):
a,b,k = map(int, input().split())
l =[]
if a <= b:
    for i in range(1,a):
        if a % i == 0  and b % i == 0:
            l.append(i)
else:
    for i in range(1,b):
        if a % i == 0  and b % i == 0:
            l.append(i)
print(l[k-1])
Problem p03156 (python)

Fixed submission:
N=int(input())
A,B=map(int,input().split())
p = list(map(int,input().split()))
c=[]
d=[]
e=[]
for i in range(N):
    if p[i]<=A:
        c.append(p[i])
    if A+1 <= p[i] <= B:
        d.append(p[i])
    if B+1 <= p[i]:
        e.append(p[i])

        
print(min(len(c),len(d),len(e)))

Buggy submission (verdict: Runtime Error):
N=int(input())
A,B=map(int,input().split())
p = list(map(int,input().split()))
c=[]
d=[]
e=[]
for i in range(N):
    if p[i]<=A:
        c.append(p[i])
    if A+1 <= p[i] <= B:
        d.append(p[i])
    if B+1 <= p[i]:
        e.append(p[i])

        
print(min(len(c),len(d),len(e))))
Problem p03160 (python)

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
dp = [0] * (N+1)
dp[2] = abs(h[1]-h[0])
for i in range(3, N+1):
    dp[i] = min(dp[i-1]+abs(h[i-1]-h[i-2]), dp[i-2]+abs(h[i-1]-h[i-3]))
print(dp[N])

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [0]*N
b = [0]*N
c = [0]*N
for i in range(N):
    a[i],b[i],c[i] = map(int,input().split())

inf = -float('inf')
dp = [[inf] * N for _ in range(3)]
dp[0][0] = a[0]
dp[1][0] = b[0]
dp[2][0] = c[0]

for i in range(1,N):
    dp[0][i] = max(dp[1][i-1] + a[i],dp[2][i-1] + a[i])
    dp[1][i] = max(dp[0][i-1] + b[i],dp[2][i-1] + b[i])
    dp[2][i] = max(dp[0][i-1] + c[i],dp[1][i-1] + c[i])

print(max(dp[0][N-1],dp[1][N-1],dp[2][N-1]))
Problem p03214 (python)

Fixed submission:
a=int(input())
f = list(map(int,input().split()))
b=[]
ave=sum(f)/a

for i in f:
    diff=abs(i-ave)
    b.append(diff)
print(b.index(min(b)))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
average = sum(a) / N
A = list(map(lambda n:abs(n-average), a))
A.sort()
A1 = int(average - A[0])
A2 = int(average + A[0])
print(min(a.index(A1), a.index(A2)))