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

Fixed submission:
S = list(input())
T = input()
len_t = len(T)


def is_valid(start, end):
    for t_i, s_i in enumerate(range(start, end)):
        if S[s_i] == "?" or S[s_i] == T[t_i]:
            continue
        else:
            return False
    return True


def assign(start, end):
    for t_i, s_i in enumerate(range(start, end)):
        S[s_i] = T[t_i]
    for i in range(len(S)):
        if S[i] == "?":
            S[i] = "a"


ok = False
for i in range(len_t-1, len(S))[::-1]:
    if S[i] == "?" or S[i] == T[-1]:
        start = i - len_t + 1
        end = i + 1
        if is_valid(start, end):
            ok = True
            assign(start, end)
            break

if ok:
    print("".join(S))
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
len_t = len(T)


def t_index_is_valid(t_index, start, end):
    if S[t_index+start:t_index+end]:
        for j, t_ in enumerate(T):
            if S[t_index+start+j] == "?" or S[t_index+start+j] == t_:
                pass
            else:
                return False
        return True
    else:
        return False


ok = False
replace_index = (0, 0)
for i, t in enumerate(T):
    if ok:
        break
    if t in S:
        t_indexes = [n for n, v in enumerate(S) if v == t]
        t_indexes.reverse()
        start = - i
        end = len_t - i + 1
        for t_index in t_indexes:
            if t_index_is_valid(t_index, start, end):
                replace_index = (t_index+start, t_index+end)
                ok = True
                break

if not ok:
    print("UNRESTORABLE")
else:
    S = list(S)
    for j, i in enumerate(range(replace_index[0], replace_index[1]-1)):
        S[i] = T[j]
    for i in range(len(S)):
        if S[i] == "?":
            S[i] = "a"
    print("".join(S))
Problem p03715 (python)

Fixed submission:
def calc(W, H):
    ans = float("inf")
    for w in range(1, W//2+1):
        x = w * H
        w_ = W - w
        if w_ % 2 == 0 or H % 2 == 0:
            y = (w_*H)//2
            li = sorted([x, y, y])
        else:
            if w_ < H:
                a, b = w_, H
            else:
                a, b = H, w_
            y = a * (b//2)
            z = a * (b-b//2)
            li = sorted([x,y,z])
        ans = min(ans, li[2] - li[0])
    return ans



def main():
    import sys
    input = sys.stdin.readline
    w, h = map(int, input().split())
    ans = calc(w,h)
    ans = min(calc(h,w), ans)
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
    def main():
        import sys
        input = sys.stdin.readline
        a, b = map(int, input().split())
        if a % 3 == 0 or b % 3 == 0:
            print(0)
            sys.exit()
        if a > b:
            a, b = b, a

        x = (b // 3) * a
        bb = b - b//3
        aa = a
        if aa % 2 == 0 or bb % 2 == 0:
            y = (bb * aa) // 2
            li = sorted([x,y,y])
        else:
            if aa > bb:
                aa, bb = bb, aa
            y = aa * (bb//2)
            z = aa * ((bb+1)//2)
            li = sorted([x, y, z])
        ans = li[2] - li[0]

        x = (b // 3 + 1) * a
        bb = b - b//3 - 1
        aa = a
        if aa % 2 == 0 or bb % 2 == 0:
            y = (aa*bb)//2
            li = sorted([x,y,y])
        else:
            if aa > bb:
                aa, bb = bb, aa
            y = aa * (bb//2)
            y = aa * (bb//2)
            z = aa * ((bb+1)//2)
            li = sorted([x, y, z])
        ans = min(ans, li[2] - li[0])
        print(ans)


    if __name__ == '__main__':
        main()
Problem p02576 (python)

Fixed submission:
n, x, t = map(int, input().split())
ans = n//x 
if n%x != 0:
  ans += 1
print(int(ans)*t)

Buggy submission (verdict: Runtime Error):
n, x, t = map(int, input())
ans = n//x 
if n%x != 0:
  ans += 1
print(int(ans)*t)
Problem p02614 (python)

Fixed submission:
h, w, k = map(int,input().split())
c = []
for i in range(h):
  c.append(input())
  
def countb(c):
  num = 0
  for i in range(h):
    num += c[i].count("#")
  return(num)

def printb(c, row, col):
  c = c[:]
  #print(row,col)
  cnt = 0
  while row != 0:
    if row  & 0b1:
     
      c[cnt] = "."*w
    cnt += 1
    row = row >> 1
  
  cnt = 0
  while col != 0:
    #print(col&0b1)
    if col & 0b1:
      for i in range(h):
        c[i] = c[i][:cnt]+"."+c[i][cnt+1:]
    cnt += 1
    col = col >> 1
    
  #print("\n".join(c))
  return countb(c)

ans = 0
for i in range(2**h):
  for j in range(2**w):
    if printb(c,i,j) == k:
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
h, w, k = map(int,input().split())
c = []
for i in range(h):
  c.append(input())
  
def countb(c):
  num = 0
  for i in range(h):
    num += c[i].count("#")
  return(num)

def printb(c, row, col):
  c = c[:]
  #print(row,col)
  cnt = 0
  while row != 0:
    if row  & 0b1:
     
      c[cnt] = "."*w
    cnt += 1
    row = row >> 1
  
  cnt = 0
  while col != 0:
    #print(col&0b1)
    if col & 0b1:
      for i in range(h):
        c[i] = c[i][:cnt]+"."+c[i][cnt+1:]
    cnt += 1
    col = col >> 1
    
  #print("\n".join(c))
  return countb(c)

if countb(c) == k:
  print(0)
else:
  ans = 0
  for i in range(2**h):
    for j in range(2**w):
      if printb(c,i,j) == k:
        ans += 1
        
  
print(ans)
Problem p02621 (python)

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

Buggy submission (verdict: Runtime Error):
a = int(input())
print(a+a**2+a***3)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  absv = x
  value = x
  for i in range(-1, 102):
    if i in p:
      pass
    else:
      if absv > abs(x - i):
        absv = abs(x - i)
        value = x - i
  print(x - value)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  absv = x
  for i in range(-1, 100):
    if i in p:
      pass
    else:
      if absv > abs(x - i):
        absv = abs(x - i)
        value = x - i
  print(x - value)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  absv = x
  for i in range(1, 100):
    if i in p:
      pass
    else:
      if absv > abs(x - i):
        absv = abs(x - i)
        value = x - i
  print(x - value)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  p.sort()
  p1 = {i for i in range(p[0],p[-1]+1)}
  p = set(p)
  p2 = p1 - p
  p2 = list(p2)
  absv = x
  for i in range(len(p2)):
    if absv > abs(x - p2[i]):
      absv = abs(x - p2[i])
      value = x - p2[i]
  print(x - value)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  p.sort()
  p1 = {i for i in range(p[-1])}
  p = set(p)
  p2 = p1 - p
  p2 = list(p2)
  absv = x
  for i in range(len(p2)):
    if absv > abs(x - p2[i]):
      absv = abs(x - p2[i])
      value = x - p2[i]
  print(x - value)
Problem p02658 (python)

Fixed submission:
n = int(input())
A = sorted(map(int,input().split()), reverse = True)

if 0 in A:
    print(0)
else:
    ans = 1
    for i in A:
        ans *= i
        if ans >10**18:
            print(-1)
            break
    else:
        print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
if 0 in A:
    print(0)
else:
    ans = 1
    for i in A:
        ans *= i
if ans >10**18:
        print(-1)
else:
    print(ans)
Problem p02660 (python)

Fixed submission:
n = int(input())

fact={}
i = 2
while n != 1:
    if n % i == 0:
        n = n/i
        if i in fact:
            fact[i] += 1
        else:
            fact[i] = 1
    else:
        i += 1
    if i > (n**(1/2)+1):
        if n in fact:
            fact[n] += 1
        else:
            fact[n] = 1
        break

if fact == {}:
    print(0)
else:
    ans = 0
    for v in fact.values():
        #print(v)
        for i in range(1,v+1):
            if v - i >= 0:
                ans +=1
                v = v-i
    print(ans)

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

fact={}
i = 2
while n != 1:
    if n % i == 0:
        n = n/i
        if i in fact:
            fact[i] += 1
        else:
            fact[i] = 1
    else:
        i += 1
    if i > (n**(1/2)+1):
        fact[n] =1
        break

#print(fact)
if fact == {}:
    print(0)
else:
    ans = 0
    for v in fact.values():
        #print(v)
        for i in range(1,v+1):
            if v - i >= 0:
                ans +=1
                v = v-i
                
print(ans)
Problem p02681 (python)

Fixed submission:
s = input()
t = input()


if s == t[:-1]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split()))
 
if A[0]>=A[3]:
  print(A[0])
else:
  if A[0]+A[1]>=A[3]:
    print(A[0])
  else:
    print(A[0]-A[3]+A[0]+A[1])

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split()))
 
if A[0]>=A[3]:
  print(A[0])
else:
  if A[0]+A[1]>=A[3]:
    print(A[0])
  else:
    print(A[0]-A[3]+A[0]+A[1])
Problem p02687 (python)

Fixed submission:
n = input()
if n == "ABC":
  print("ARC")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):
N, M = (int(i) for i in input().split())
H = list(map(int,input().split()))
ans = [1]*N
for m in range(M):
  a, b = (int(i) for i in input().split())
  if H[a-1] <= H[b-1]:
    ans[a-1] = 0
  elif H[a-1] > H[b-1]:
    ans[b-1] = 0
print(ans.count(1))

Buggy submission (verdict: Runtime Error):
N, K = (int(i) for i in input().split())
H = list(map(int,input().split()))
ans = [1]*N
for m in range(M):
  a, b = (int(i) for i in input().split())
  if H[a-1] <= H[b-1]:
    ans[a-1] = 0
  elif H[a-1] > H[b-1]:
    ans[b-1] = 0
print(ans.count(1))
Problem p02778 (python)

Fixed submission:
print("x"*len(input()))

Buggy submission (verdict: Runtime Error):
print("x"*len(input())
Problem p02783 (python)

Fixed submission:
h,a = map(int,input().split())
ans = 0
while h >0:
  h -= a
  ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
h,a = map(int,input().split())
ans = 0
for h >0:
  h -= a
  ans += 1
print(ans)
Problem p02801 (python)

Fixed submission:
c = input()
al = "abcdefghijklmnopqrstuvwxyz"
print(al[al.index(c)+1])

Buggy submission (verdict: Runtime Error):
c = input()
al = "abcdefghijklmnopqrstuvwxz"
print(al[al.index(c)+1])
Problem p02811 (python)

Fixed submission:
k, x = map(int, input().split())
if (500*k) >= x:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
k, x = map(int, input())
if (500*k) >= x:
  print("Yes")
else:
  print("No")
Problem p03165 (python)

Fixed submission:
s = input()
t = input()

sl = len(s)
tl = len(t)
dp = [[0 for i in range(tl+1)] for i in range(sl+1)]

#dp[i][j] sをi文字目、tをj文字目まで求めたときの最大の長さ

for i in range(1,sl+1):
    for j in range(1,tl+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])

ansl = dp[sl][tl]
i = sl
j = tl
ans = [""]*ansl
while(ansl>0):
    if s[i-1] == t[j-1]:
        ans[ansl-1] = s[i-1]
        i -= 1
        j -= 1
        ansl -= 1
    elif dp[i][j]==dp[i-1][j]:
        i -= 1
    else:
        j -= 1

print("".join(ans))

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

sl = len(s)
tl = len(t)
dp = [["" for i in range(tl+1)] for i in range(sl+1)]

#dp[i][j] sをi文字目、tをj文字目まで求めたときの最大の長さ

for i in range(1,sl+1):
    for j in range(1,tl+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1]+s[i-1]
        else:
            if len(dp[i-1][j]) > len(dp[i][j-1]):
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = dp[i][j-1]
display(dp[sl][tl])
Problem p03166 (python)

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

N, M = map(int,input().split())

edges = [[] for _ in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    edges[y-1].append(x-1)
    
used = [0 for _ in range(N)]
dp = [0 for _ in range(N)]

def dfs(pos):
    if not edges[pos]:
        dp[pos] = 0
        return
    for n_pos in edges[pos]:
        if not used[n_pos]:
            dfs(n_pos)
        used[n_pos] = 1
        dp[pos] = max(dp[pos],dp[n_pos]+1)

    
for i in range(N):
    if used[i]:
        continue
    used[i] = True
    dfs(i)

print(max(dp))

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

edges = [[] for _ in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    edges[y-1].append(x-1)
    
used = [0 for _ in range(N)]
dp = [0 for _ in range(N)]

def dfs(pos):
    if not edges[pos]:
        dp[pos] = 0
        return
    for n_pos in edges[pos]:
        if not used[n_pos]:
            dfs(n_pos)
        used[n_pos] = 1
        dp[pos] = max(dp[pos],dp[n_pos]+1)
    print(dp)
    
for i in range(N):
    if used[i]:
        continue
    used[i] = True
    dfs(i)

print(max(dp))
Problem p02641 (python)

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

if n == 0:
    print(x)
else:
    num = list(set(range(-200, 200)) ^ set(p))
    num = sorted([[abs(i - x), i] for i in num])
    if len(num) >= 2 and num[0][0] == num[1][0]:
        print(min(num[0][1], num[1][1]))
    else:
        print(num[0][1])

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

if n == 0:
    print(x)
else:
    num = set(range(1, 101)) ^ set(p)
    num = sorted([[abs(i - x), i] for i in num])
    
    if len(num) >= 2 and num[0][0] == num[1][0]:
        print(min(num[0][1], num[1][1]))
    else:
        print(num[0][1])

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

if n == 0:
    print(x)
else:
    num = set(range(1, 101)) ^ set(p)
    num = sorted([[abs(i - x), i] for i in num])
    if num[0][0] == num[1][0]:
        print(min(num[0][1], num[1][1]))
    else:
        print(num[0][1])
Problem p02642 (python)

Fixed submission:
from collections import Counter

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

# new = [key for key, val in Counter(a).most_common() if val == 1]
prime = [1] * 1000010

for i in set(a):
    # if prime[i]:
    for j in range(i + i, 1000001, i):
        prime[j] = 0

c = Counter(a)
ans = 0
for i in a:
    if prime[i] and c[i] == 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

new = [key for key, val in Counter(a).most_common() if val == 1]
dp = [0] * 100010

for i in new:
    for j in range(0, 100000, i):
        dp[j] += 1

ans = 0
for i in new:
    if dp[i] == 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

new = [key for key, val in Counter(a).most_common() if val == 1]
dp = [0] * 100010

for i in new:
    for j in range(0, 100010, i):
        dp[j] += 1

ans = 0
for i in new:
    if dp[i] == 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

new = [key for key, val in Counter(a).most_common() if val == 1]
dp = [0] * 100010

for i in new:
    temp = i
    while i <= 100000:
        dp[i] += 1
        i += temp

ans = 0
for i in new:
    if dp[i] == 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

new = [key for key, val in Counter(a).most_common() if val == 1]
dp = [0] * 100010

for i in new:
    temp = i
    while i <= 100010:
        dp[i] += 1
        i += temp

ans = 0
for i in new:
    if dp[i] == 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

new = [key for key, val in Counter(a).most_common() if val == 1]
dp = [0] * 100010

for i in new:
    temp = i
    while i < 100010:
        dp[i] += 1
        i += temp

ans = 0
for i in new:
    if dp[i] == 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


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

c = Counter(a)
new = []
for key, val in c.most_common():
    if val == 1:
        new.append(key)

ans = 0
for i in new:
    div = make_divisors(i)
    if len(set(new) & set(div)) == 1:
        ans += 1åç

print(ans)
Problem p02658 (python)

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

if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            exit()

    print(ans)

Buggy submission (verdict: Runtime Error):
from decimal import Decimal

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

ans = 1
for i in a:
    ans = Decimal(str(ans * i))

print(ans) if ans <= Decimal(str(10 ** 18)) else print(-1)
Problem p02742 (python)

Fixed submission:
import math

h, w = map(int, input().split())

if h == 1 or w == 1:
    ans = 1
elif (h * w) % 2 == 0:
    ans = (h * w) // 2
else:
    ans = (h // 2) * w + math.ceil(w / 2)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

h, w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
elif (h * w) % 2 == 0:
    ans = (h * w) // 2
else:
    ans = (h // 2) * w + math.ceil(w / 2)

print(ans)
Problem p02780 (python)

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

if n != k:
    memo = [0] * (n + 1)

    for i in range(n):
        memo[i] = memo[i - 1] + p[i]

    ans = 0
    for i in range(k, n):
        ans = max(ans, memo[i] - memo[i - k])

    ans = (ans + k) / 2
    print(ans)
else:
    ans = (sum(p) + k) / 2
    print(ans)

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

p_sum = [0] * (n + 1)

for i in range(1, n + 1):
    p_sum[i] = p_sum[i - 1] + p[i]

ans = 0
for i in range(-k + 1):
    ans = max(ans, p_sum[i + k] - p_sum[i])

ans = (ans + k) / 2
print(ans)
Problem p02796 (python)

Fixed submission:
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]

lr = []
for i in range(n):
    l = max(xl[i][0] - xl[i][1], 0)
    r = max(xl[i][0] + xl[i][1], 0)
    lr.append([r, l])

lr = sorted(lr)
keep = [False] * n
# print(lr)

cur = 0
for i in range(n):
    if cur <= lr[i][1]:
        keep[i] = True
        cur = lr[i][0]
'''
for j in range(n - 1):
    if keep[j]:
        if lr[j][0] == lr[j + 1][0]:
            keep[j + 1] = False
        elif lr[j][0] < lr[j + 1][0]:# < lr[j][1]:
            keep[j + 1] = False
'''
#print(keep)
ans = sum(1 for x in range(n) if keep[x])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]

lr = []
for i in range(n):
    l = max(xl[i][0] - xl[i][1], 0)
    r = max(xl[i][0] + xl[i][1], 0)
    lr.append([l, r])

lr = sorted(lr)

remove = 0
skip = False

for i in range(1, n):
    if lr[i - 1][0] == lr[i][0]:
        remove += 1
    elif lr[i - 1][0] < lr[i][0] < lr[i - 1][1]:
        if not lr[i][0] < lr[i + 1][0] < lr[i][1]:
            remove += 1

print(n - remove)

Buggy submission (verdict: Runtime Error):
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]

lr = []
lim = 0
for i in range(n):
    l = max(xl[i][0] - xl[i][1], 0)
    r = max(xl[i][0] + xl[i][1], 0)
    lim = max(lim, l, r)
    lr.append([l, r])

memo = [0] * lim

remove = 0
for i in range(n):
    for j in range(lr[i][0], lr[i][1]):
        if memo[j] == 1:
            remove += 1
            break
        else:
            memo[j] = 1

print(n - remove)
Problem p02887 (python)

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

result = []

for i in range(int(n)):
    if s[i:i + 1] != s[i + 1:i + 2]:
        result.append(s[i:i + 1])

print(len(result))

Buggy submission (verdict: Runtime Error):
import itertools

n = int(input())
l = map(int, input().split())

comb = list(itertools.combinations(l, 3))

result = 0

for i in range(len(comb)):
    a, b, c = comb[i]
    if a < b + c:
        if b < c + a:
            if c < a + b:
                result += 1

print(result)
Problem p02953 (python)

Fixed submission:
n = int(input())
h = [int(x) for x in input().split()]
h.reverse()

flag = True

for i in range(1, n):
    if h[i - 1] >= h[i]:
        continue
    elif h[i] == h[i - 1] + 1:
        h[i] -= 1
    else:
        flag = False
        break

print('Yes') if flag else print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [int(x) for x in input().split()]
h.reverse()

flag = True

for i in range(1, n):
    print(h, i)

    if h[i - 1] >= h[i]:
        continue
    elif h[i] == h[i - 1] + 1:
        h[i] -= 1
    else:
        flag = False
        break

print('Yes') if flag else print('No')
Problem p02995 (python)

Fixed submission:
import fractions


def func(n, c, d):
    x = n // c
    y = n // d
    z = n // (c * d // fractions.gcd(c, d))

    return n - x - y + z


a, b, c, d = map(int, input().split())

print(func(b, c, d) - func(a - 1, c, d))

Buggy submission (verdict: Runtime Error):
import math


def func(n, c, d):
    x = n // c
    y = n // d
    z = n // (c * d // math.gcd(c, d))

    return n - x - y + z


a, b, c, d = map(int, input().split())

print(func(b, c, d) - func(a - 1, c, d))
Problem p03076 (python)

Fixed submission:
dish = [int(input()) for x in range(5)]
hitoketa = list(map(int, [str(x)[-1] for x in dish]))

last = 999
for i in hitoketa:
    if not i % 10 == 0:
        last = min(last, i)

if last != 999:
    last = dish[hitoketa.index(last)]
else:
    last = dish[0]

ans = last
skip = False

for i in dish:
    if i == last and not skip:
        skip = True
    elif i % 10 == 0:
        ans += i
    else:
        ans += (i // 10 + 1) * 10

print(ans)

Buggy submission (verdict: Runtime Error):
dish = [int(input()) for x in range(5)]
hitoketa = list(map(int, [str(x)[-1] for x in dish]))

last = 999
for i in hitoketa:
    if not i % 10 == 0:
        last = min(last, i)

last = dish[hitoketa.index(last)]
ans = last
skip = False
for i in dish:
    if i == last and not skip:
        skip = True
    elif i % 10 == 0:
        ans += i
    else:
        ans += (i // 10 + 1) * 10

print(ans)
Problem p03087 (python)

Fixed submission:
def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():    
	N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():    
  	N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()