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

Fixed submission:
#a,b,c,d=map(int,input().split())
n=int(input())
s=input()
ans=0
hantei=0
for i in s:
  if i=="I":
    ans+=1
  elif i=="D":
    ans-=1
  if ans>hantei:
    hantei=ans
  
print(hantei)

Buggy submission (verdict: Runtime Error):
#a,b,c,d=map(int,input().split())
n=int(input())
s=input()
ans=0
for i in s:
  if i=="I":
    ans+=1
  elif i=="D":
    ans-=1
  
if x<0:
  print(0)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
#a,b,c,d=map(int,input().split())
n=int(input())
s=input()
ans=0
for i in s:
  if i=="I":
    ans+=1
  elif i=="D":
    ans-=1
  
if x<0:
  print(0)
else:
  print(x)
Problem p03997 (python)

Fixed submission:
a=int(input())
b=int(input())
h=int(input())
print( int( (a+b)*h/2 ) )

Buggy submission (verdict: Runtime Error):
a=int(iput())
b=int(input())
h=int(input())
print(int((a+b)*h/2))
Problem p02608 (python)

Fixed submission:
n = int(input())
num = [0] * 10001
for i in range(1, 142):
    for j in range(1, 142):
        for k in range(1, 142):
            temp = i + j + k
            if temp % 2 == 0:
                if i + j > k and j + k > i and k + i > j:
                    temp2 = (i ** 2 + j ** 2 + k ** 2) // 2
                    if 0 <= temp2 <= 10000:
                        num[temp2] += 1
for i in range(1, n + 1):
    print(num[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
num = [0] * 1001
for i in range(1, 142):
    for j in range(1, 142):
        for k in range(1, 142):
            temp = i + j + k
            if temp % 2 == 0:
                if i + j > k and j + k > i and k + i > j:
                    temp2 = (i ** 2 + j ** 2 + k ** 2) // 2
                    if 0 <= temp2 <= 1000:
                        num[temp2] += 1
for i in range(1, n + 1):
    print(num[i])
Problem p02609 (python)

Fixed submission:
n = int(input())
x = input()
temp = x.count("1")
mod1 = [1]
for i in range(n-1):
    mod1.append(mod1[-1] * 2 % (temp + 1))
mod1.reverse()
num1 = 0
for i in range(n):
    if x[i] == "1":
        num1 += mod1[i]
        num1 %= (temp + 1)
if temp == 1 or temp == 2:
    mod2 = [0] * n
else:
    mod2 = [1]
    for i in range(n-1):
        mod2.append(mod2[-1] * 2 % (temp - 1))
    mod2.reverse()
    num2 = 0
    for i in range(n):
        if x[i] == "1":
            num2 += mod2[i]
            num2 %= (temp - 1)
x2 = int(x, 2)
for i in range(n):
    if x[i] == "1":
        if temp == 1:
            print(0)
            continue
        elif temp == 2:
            print(1)
            continue
        else:
            num = num2 - mod2[i]
            num %= (temp - 1)
    else:
        num = num1 + mod1[i]
        num %= (temp + 1)
    count = 1
    while num:
        num %= bin(num).count("1")
        count += 1
    print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = input()
temp = x.count("1")
x2 = int(x, 2)
for i in range(n):
    if x[i] == "1":
        temp2 = -1
    else:
        temp2 = 1
    num = x2 ^ (2 ** (n - 1 - i))
    num %= (temp + temp2)
    count = 1
    while num:
        num %= bin(num).count("1")
        count += 1
    print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = input()
temp = x.count("1")
x2 = int(x, 2)
for i in range(n):
    if x[i] == "1":
        temp2 = -1
    else:
        temp2 = 1
    num = x2 ^ (2 ** (n - 1 - i))
    num %= temp + temp2
    count = 1
    while num:
        num %= bin(num).count("1")
        count += 1
    print(count)
Problem p02618 (python)

Fixed submission:
import random, copy

D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
    s.append(list(map(int, input().split())))
t = [random.randint(1, 26) for i in range(D)]
dq = [[random.randint(1, D), random.randint(1, 26)] for i in range(10 ** 5)]
last0 = []
last = [0] * 26
score = 0
for i in range(D):
    contest = t[i] - 1
    score += s[i][contest]
    last = [last[i] + 1 for i in range(26)]
    last[contest] = 0
    last0.append(last)
    for j in range(26):
        score -= c[j] * last[j]
ans = t
for i in range(10 ** 5):
    temp = score
    temp2 = copy.copy(t)
    d, q = dq[i][0] - 1, dq[i][1] - 1
    contest = t[d] - 1
    score += s[d][q]
    score -= s[d][contest]
    num = last0[d][q] - last0[d][contest]
    for j in range(d, D):
        if last0[j][q] == 0:
            break
        else:
            score += c[q] * num
            last0[j][q] -= num
    for j in range(d, D):
        if last0[j][contest] == 0:
            if j == d:
                score -= c[contest] * num
                last0[j][contest] += num
                pass
            else:
                break
        else:
            score -= c[contest] * num
            last0[j][contest] += num
    t[d] = q + 1
    if temp < score:
        ans = copy.copy(t)
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
import random, copy

D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
    s.append(list(map(int, input().split())))
t = []
temp = [0] * 26
for i in range(D):
    num = []
    num2 = []
    for j in range(26):
        temp2 = [temp[k] + 1 for k in range(26)]
        temp2[j] = 0
        temp3 = s[i][j]
        for k in range(26):
            temp3 -= temp2[k] * c[k]
        num.append(temp3)
        num2.append(temp2)
    index = num.index(max(num)) + 1
    t.append(index)
    temp = num2[index]
dq = [[random.randint(1, D), random.randint(1, 26)] for i in range(10 ** 5)]
last0 = []
last = [0] * 26
score = 0
for i in range(D):
    contest = t[i] - 1
    score += s[i][contest]
    last = [last[i] + 1 for i in range(26)]
    last[contest] = 0
    last0.append(last)
    for j in range(26):
        score -= c[j] * last[j]
ans = t
for i in range(10 ** 5):
    temp = score
    temp2 = copy.copy(t)
    d, q = dq[i][0] - 1, dq[i][1] - 1
    contest = t[d] - 1
    score += s[d][q]
    score -= s[d][contest]
    num = last0[d][q] - last0[d][contest]
    for j in range(d, D):
        if last0[j][q] == 0:
            break
        else:
            score += c[q] * num
            last0[j][q] -= num
    for j in range(d, D):
        if last0[j][contest] == 0:
            if j == d:
                score -= c[contest] * num
                last0[j][contest] += num
                pass
            else:
                break
        else:
            score -= c[contest] * num
            last0[j][contest] += num
    t[d] = q + 1
    if temp < score:
        ans = copy.copy(t)
for i in ans:
    print(i)
Problem p02690 (python)

Fixed submission:
x = int(input())
temp = int(x ** 0.25)
flag = True
for i in range(-temp, temp + 1):
    for j in range(-temp, temp + 1):
        if i ** 5 - j ** 5 == x:
            print(i, j)
            flag = False
            break
    if flag == False:
        break

Buggy submission (verdict: Runtime Error):
x = int(input())
temp = int(x ** 0.25)
for i in range(-temp, temp + 1):
    temp2 = int((i ** 5 + x) ** 0.2)
    if temp2 ** 5 - i ** 5 == x:
        print(temp2, i)
        break
    temp3 = int((i ** 5 - x) ** 0.2)
    if i ** 5 - temp3 ** 5 == x:
        print(i, temp3)
        break

Buggy submission (verdict: Runtime Error):
x = int(input())
temp = int(x ** 0.25)
for i in range(-temp, temp + 1):
    temp2 = int((i ** 5 + x) ** 0.2)
    if temp2 ** 5 - i ** 5 == x:
        print(temp2, i)
        break
Problem p02715 (python)

Fixed submission:
n, k = map(int, input().split())
mod = 10 ** 9 + 7

gcd = [0] * k
for i in range(k):
    test = k - i
    temp = 0
    for j in range(k // test):
        if j == 0:
            temp2 = 1
            temp3 = [k // test]
            for l in range(len(bin(n)) - 2):
                temp3.append(temp3[-1] ** 2 % mod)
            test3 = bin(n)
            for l in range(len(test3) - 2):
                if test3[-1-l] == "1":
                    temp2 *= temp3[l]
                    temp2 %= mod
            temp += temp2
        else:
            test2 = test * (j + 1)
            temp -= gcd[test2 - 1]
    gcd[test - 1] = temp
ans = 0
for i in range(k):
    ans += gcd[i] * (i + 1)
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
mod = 10 ** 9 + 7

def yakusuu(n):
    a = []
    for i in range(1, int(n ** 0.5)):
        if n % i == 0:
            a.append(i, n // i)
    return sum(a)

ans = 0
for i in range(1, k + 1):
    temp = 1
    for j in range(n):
        temp *= (k // i)
        temp %= mod
    ans += (i * 2 - yakusuu(i)) * temp
print(ans)
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))
if n == 1:
    a = 0
else:
    a = 10 ** (n - 1)
for i in range(a, 10 ** n):
    test = str(i)
    flag = True
    for j in range(m):
        s = sc[j][0]
        c = sc[j][1]
        if test[s - 1] != str(c):
            flag = False
            break
    if flag == False:
        continue
    else:
        print(i)
        break
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = {i + 1: set() for i in range(n)}
for i in range(m):
    s, c = map(int, input().split())
    sc[s] |= set([c])
if sc[1] == {0}:
    print(-1)
else:
    flag = True
    for i in sc.values():
        if len(i) >= 2:
            flag = False
            break
    if flag == False:
        print(-1)
    else:
        ans = ["0"] * n
        for i, j in sc.items():
            for k in j:
                ans[i - 1] = str(k)
        if ans[0] == "0":
            if ans[1] == "0":
                ans[1] = "1"
            ans[0] = "1"
        print(int("".join(ans)))
Problem p02813 (python)

Fixed submission:
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
count = 0
for i in itertools.permutations([i + 1 for i in range(n)], n):
    if i == p:
        a = count
    if i == q:
        b = count
    count += 1
print(abs(a - b))

Buggy submission (verdict: Runtime Error):
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
count = 0
for i in itertools.permutations([i + 1 for i in range(n)], n):
    if i == p:
        a = count
    elif i == q:
        b = count
    count += 1
print(abs(a - b))
Problem p02909 (python)

Fixed submission:
s = input()
weather = ["Sunny", "Cloudy", "Rainy"]
print(weather[(weather.index(s) + 1) % 3])

Buggy submission (verdict: Runtime Error):
s = input()
weather = ["Sunny", "Cloudy", "Rainy"]
print(weather[(s.index(weather) + 1) % 3])
Problem p02910 (python)

Fixed submission:
s = input()
flag = True
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "L":
            flag = False
            break
    else:
        if s[i] == "R":
            flag = False
            break
if flag == True:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()
flag = True
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "L":
      flag = false
      break
  else:
    if s[i] == "R":
      flag = false
      break
if flag == True:
  print("Yes")
else:
  print("No")
Problem p02945 (python)

Fixed submission:
a, b = map(int, input().split())
print(max(a + b, a - b, a * b))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(max(a + b, a - b. a * b))
Problem p03006 (python)

Fixed submission:
n = int(input())
xy = []
for i in range(n):
    xy.append(list(map(int, input().split())))
xy.sort(key = lambda x: x[1])
xy.sort()
if n == 1:
    print(1)
else:
    dif = []
    for i in range(n):
        for j in range(i + 1, n):
            dif.append((xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]))
    count_dif = {}
    for i in dif:
        count_dif.setdefault(i, 0)
        count_dif[i] += 1
    print(n - max(count_dif.values()))

Buggy submission (verdict: Runtime Error):
n = int(input())
xy = []
for i in range(n):
    xy.append(list(map(int, input().split())))
xy.sort(key = lambda x: x[1])
xy.sort()
dif = []
for i in range(n):
    for j in range(i + 1, n):
        dif.append((xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]))
count_dif = {}
for i in dif:
    count_dif.setdefault(i, 0)
    count_dif[i] += 1
print(n - max(count_dif.values()))
Problem p03086 (python)

Fixed submission:
s = input()
count = []
num = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "T" or s[i] == "C" or s[i] == "G":
        num += 1
    else:
        count.append(num)
        num = 0
count.append(num)
print(max(count))

Buggy submission (verdict: Runtime Error):
s = input()
count = []
num = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "T" or s[i] == "C" or s[i] == "G":
        num += 1
    else:
        count.append(num)
        num = 0
print(max(count))
Problem p03138 (python)

Fixed submission:
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
num = 2 ** (max(int(math.log2(max(a))) + 1, int(math.log2(k + 0.0001)) + 1))
num2 = int(math.log2(num))
for i in range(n):
    a[i] = bin(a[i] + num)[3:]
binary = [[i,0,0] for i in range(num2)]
for i in range(n):
    for j in range(num2):
        if a[i][j] == "0":
            binary[num2 - j - 1][1] += 1
        else:
            binary[num2 - j - 1][2] += 1
binary.sort(reverse = True)
ans = 0
check = 0
for i in range(len(binary)):
    if binary[i][1] > binary[i][2]:
        check += 2 ** binary[i][0]
        if check <= k:
            ans += binary[i][1] * (2 ** binary[i][0])
        else:
            check -= 2 ** binary[i][0]
            ans += binary[i][2] * (2 ** binary[i][0])
    else:
        ans += binary[i][2] * (2 ** binary[i][0])
print(ans)

Buggy submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
num = 2 ** (max(int(math.log2(max(a))) + 1, int(math.log2(k + 0.0001)) + 1))
for i in range(n):
    a[i] = bin(a[i] + num)[3:]
binary = [[i,0,0] for i in range(int(math.log2(num)))]
for i in range(n):
    for j in range(int(math.log2(num))):
        if a[i][j] == "0":
            binary[int(math.log2(num)) - j - 1][1] += 1
        else:
            binary[int(math.log2(num)) - j - 1][2] += 1
binary.sort(reverse = True)
ans = 0
check = 0
for i in range(len(binary)):
    if binary[i][1] > binary[i][2]:
        check += 2 ** binary[i][0]
        if check <= k:
            ans += binary[i][1] * (2 ** binary[i][0])
        else:
            check -= 2 ** binary[i][0]
            ans += binary[i][2] * (2 ** binary[i][0])
    else:
        ans += binary[i][2] * (2 ** binary[i][0])
print(ans)
Problem p03149 (python)

Fixed submission:
n1, n2, n3, n4 = map(int, input().split())
if {n1, n2, n3, n4} == {1, 9, 7, 4}:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n1, n2, n3, n4 = map(input().split())
if {n1, n2, n3, n4} == {1, 9, 7, 4}:
  print("YES")
else:
  print("NO")
Problem p03196 (python)

Fixed submission:
n,p = map(int,input().split())
dum = round(p**(1/n))
for i in range(dum,-1,-1):
    if p%(i**n) == 0:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
n, p = map(int, input().split())
num = int(p ** (1 / n))
for i in range(num + 1, 0, -1):
    p0 = p
    count = 0
    if i == 1:
        print(i)
        break
    for i in range(n):
        if p0 % i == 0:
            p0 //= i
            count += 1
        else:
            break
    else:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    for i in range(int(p ** (1 / n)) + 1, 0, -1):
        if p % (i ** n) == 0:
            print(i)
            break
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())
count = 0
while True:
    if count >= len(s):
        break
    if s[count] == "1":
        count += 1
    else:
        break
if k > count:
  print(s[count])
else:
  print(1)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
count = 0
while True:
  if s[count] == "1":
    count += 1
  else:
    break
if k > count:
  print(s[count])
else:
  print(1)
Problem p03297 (python)

Fixed submission:
import math

t = int(input())
abcd = []
for i in range(t):
    abcd.append(list(map(int, input().split())))

for i in range(t):
    if abcd[i][0] < abcd[i][1]:
        print("No")
    elif abcd[i][1] > abcd[i][3]:
        print("No")
    elif abcd[i][3] % abcd[i][1] == 0:
        if abcd[i][0] % abcd[i][1] > abcd[i][2]:
            print("No")
        else:
            print("Yes")
    else:
        big, small = abcd[i][1], abcd[i][3]
        while big % small:
            big, small = small, big % small
        gcd = small
        if abcd[i][1] - gcd <= abcd[i][2]:
            print("Yes")
        else:
            print("No")

Buggy submission (verdict: Runtime Error):
import math

t = int(input())
abcd = []
for i in range(t):
    abcd.append(list(map(int, input().split())))

for i in range(t):
    if abcd[i][0] < abcd[i][1]:
        print("No")
    elif abcd[i][1] > abcd[i][3]:
        print("No")
    elif abcd[i][3] % abcd[i][1] == 0:
        if abcd[i][0] % abcd[i][1] > abcd[i][2]:
            print("No")
        else:
            print("Yes")
    else:
        gcd = math.gcd(abcd[i][1], abcd[i][3])
        if abcd[i][1] - gcd <= abcd[i][2]:
            print("Yes")
        else:
            print("No")

Buggy submission (verdict: Runtime Error):
import math

t = int(input())
abcd = []
for i in range(t):
    abcd.append(list(map(int, input().split())))

for i in range(t):
    if abcd[i][0] < abcd[i][1]:
        print("No")
    elif abcd[i][1] > abcd[i][3]:
        print("No")
    elif abcd[i][3] % abcd[i][1] == 0:
        if abcd[i][0] % abcd[i][1] > abcd[i][2]:
            print("No")
        else:
            print("Yes")
    else:
        gcd = math.gcd(abcd[i][1], abcd[i][3])
        if abcd[i][1] - gcd <= abcd[i][2]:
            print("Yes")
        else:
            print("No")
Problem p03303 (python)

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

a = ""
for i in range((len(s) - 1) // w + 1):
    a += s[w * i]
print(a)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a + b == 15:
    print("+")
elif a * b == 15:
    print("*")
else:
    print("x")
Problem p03427 (python)

Fixed submission:
n = int(input())
a = 0
while 10 ** a <= n:
    a = a + 1
b = (n + 1) // (10 ** (a -1))
c = b * (10 ** (a - 1)) - 1
d = 0
for i in range(len(str(c))):
    d = d + int(str(c)[i])
print(d)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = 0
while 10 ** a < n:
    a = a + 1
b = (n + 1) // (10 ** (a -1))
c = b * (10 ** (a - 1)) - 1
d = 0
for i in range(len(str(c))):
    d = d + int(str(c)[i])
print(d)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = 0
while 10 ** a < n:
    a = a + 1
b = n // (10 ** (a -1))
c = b * (10 ** (a - 1)) - 1
d = 0
for i in range(len(str(c))):
    d = d + int(str(c)[i])
print(d)
Problem p03480 (python)

Fixed submission:
S =str(input())
if len(S) % 2 == 1:
    a = 1
    b = int((len(S) - 1) / 2)
    while True:
        if b - a < 0:
            break
        if S[b] == S[b + a] and S[b] == S[b - a]:
            a = a + 1
        else:
            break
    c = a + b
    print(c)
else:
    d = 0
    e = int(len(S) / 2 - 1)
    f = S[e]
    if S[e + 1] == f:
        d = d + 1
    while True:
        if e - d < 0:
            break
        if S[e - d] == f and S[e + d + 1] == f:
            d = d + 1
        else:
            break
    g = d + e + 1
    print(g)

Buggy submission (verdict: Runtime Error):
S =str(input())
if len(S) % 2 == 1:
    a = 1
    b = int((len(S) - 1) / 2)
    while True:
        if b - a < 0:
            break
        if S[b] == S[b + a] and S[b] == S[b - a]:
            a = a + 1
        else:
            break
    c = a + b
    print(c)
else:
    d = 0
    e = int(len(S) / 2 - 1)
    f = S[e]
    while True:
        if e - d < 0:
            break
        if S[e + 1] == f:
            d = d + 1
            if S[e - d] == f and S[e + d + 1] == f:
                d = d + 1
            else:
                break
        else:
            break
    g = d + e + 1
    print(g)

Buggy submission (verdict: Runtime Error):
S =str(input())
if len(S) % 2 == 1:
    a = 1
    b = int((len(S) - 1) / 2)
    while True:
        if S[b] == S[b + a] and S[b] == S[b - a]:
            a = a + 1
        else:
            break
    c = a + b
    print(c)
else:
    d = 0
    e = int(len(S) / 2 - 1)
    f = S[e]
    while True:
        if S[e + 1] == f:
            d = d + 1
            if S[e - d] == f and S[e + d + 1] == f:
                d = d + 1
            else:
                break
        else:
            break
    g = d + e + 1
    print(g)

Buggy submission (verdict: Runtime Error):
S =str(input())
if len(S) % 2 == 1:
    a = 1
    b = int((len(S) - 1) / 2)
    while True:
        if S[b] == S[b + a] and S[b] == S[b - a]:
            a = a + 1
        else:
            break
    c = a + b
    print(c)
else:
    d = 1
    e = int(len(S) / 2 - 1)
    f = S[e]
    while True:
        if S[e + 1] == f:
            d = d + 1
            if S[e - d] == f and S[e + d + 1] == f:
                d = d + 1
            else:
                break
        else:
            break
    g = d + e
    print(g)
Problem p03712 (python)

Fixed submission:
h, w = map(int, input().split())
print("#" * (w + 2))
for i in range(h):
  s = input()
  print("#" + s + "#")
print("#" * (w + 2))

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().splilt())
print("#" * (w + 2))
for i in range(h):
  s = input()
  print("#" + s + "#")
print("#" * (w + 2))
Problem p03739 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [a[0]]
for i in range(n - 1):
    b.append(b[-1] + a[i + 1])
f = [True, False]
ans = float("inf")
for i in f:
    flag = i
    count = 0
    num = 0
    for j in range(n):
        if flag == True:
            if b[j] + num <= 0:
                count += 1 - b[j] - num
                num += 1 - b[j] - num
            flag = False
        else:
            if b[j] + num >= 0:
                count += b[j] + num + 1
                num -= b[j] + num + 1
            flag = True
    ans = min(ans, count)
print(ans)

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

count = 0
sum_a = a[0]
for i in range(n - 1):
    sum_a2 = sum_a + a[i + 1]
    if sum_a * sum_a2 >= 0:
        count += abs(sum_a2) + 1
        sum_a2 = - abs(sum_a) // sum_a
    sum_a = sum_a2
print(count)
Problem p03760 (python)

Fixed submission:
o = input()
e = input()
s = ""
for i in range(len(e)):
  s += o[i]
  s += e[i]
if len(o) > len(e):
  s += o[-1]
print(s)

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
s = ""
for i in range(len(o)):
  s += o[i]
  s += e[i]
if len(o) > len(e):
  s += o[-1]
print(s)
Problem p03854 (python)

Fixed submission:
s = input()
flag = True
while s:
    if s[0:5] == "dream":
        s = s[5:]
        if s[0:2] == "er":
            if s[0:5] != "erase":
                s = s[2:]
    elif s[0:5] == "erase":
        s = s[5:]
        if s[0:1] == "r":
            if s[0:5] != "erase":
                s = s[1:]
    else:
        flag = False
        break
if flag == True:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
s = input()
flag = True
while s:
    if s[0:5] == "dream":
        s = s[5:]
        if s[0:2] == "er":
            if s[0:5] != "erase":
                s = s[2:]
    elif s[0:5] == "erase":
        s = s[5:]
        if s[0] == "r":
            if s[0:5] != "erase":
                s = s[1:]
    else:
        flag = False
        break
if flag == True:
    print("YES")
else:
    print("NO")
Problem p03993 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
  if a[a[i] - 1] == i + 1:
    ans += 1
print(ans // 2)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(a):
  if a[a[i] - 1] == i + 1:
    ans += 1
print(ans // 2)