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

Fixed submission:
r=int(input())
if r<1200:
    print("ABC")
elif 1200<=r<2800:
    print("ARC")
else:
    print("AGC")

Buggy submission (verdict: Runtime Error):
r=input()
if r<1200:
    print("ABC")
elif 1200<r<2800:
    print("ARC")
else:
    print("AGC")
Problem p03292 (python)

Fixed submission:
li=a,b,c=list(map(int,input().split()))
lis=sorted(li)
print(lis[2]-lis[0])

Buggy submission (verdict: Runtime Error):
li=a,b,c=list(map(int,input().split()))
lis=sorted(li)
print(lis[2]-lis[0)
Problem p03337 (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 p03369 (python)

Fixed submission:
print(700 + 100 * input().count('o'))

Buggy submission (verdict: Runtime Error):
s=list(input())
print(700+s.count(○))

Buggy submission (verdict: Runtime Error):
s=list(input())
print(700++s.count(○))
Problem p03399 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(min(a,b)+min(c,d))

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(mix(a,b)+min(c,d))
Problem p03547 (python)

Fixed submission:
x,y=input().split()
if x<y:
    print("<")
elif x>y:
    print(">")
else:
    print("=")

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
if x<y:
    print("<")
elif x>y:
    print(">")
else:
    print("=")
Problem p03609 (python)

Fixed submission:
x,t=map(int,input().split())
print(x-t) if x-t>=0 else print(0)

Buggy submission (verdict: Runtime Error):
x,t=map(int,input().split())
print(x-t if x-t>=0,0 else)
Problem p03623 (python)

Fixed submission:
x,a,b=map(int,input().split())
if min(abs(x-a),abs(x-b))==abs(x-a):
    print("A")
else:
    print("B")

Buggy submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
print(min(abs(x-a),abs(x-b))
Problem p03711 (python)

Fixed submission:
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if (x in a and y in a):
    ptint("yes")
elif   (x in b and y in b):
    print("Yes")
elif   (x in c and y in c):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    ptint("yes")
else:
    print("No")
Problem p03729 (python)

Fixed submission:
a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a[-1]==b[0] and b[-1]==c[0]:
    print("YES")
else:
    print("NO")
Problem p03759 (python)

Fixed submission:
a,b,c=map(int,input().split())
if b-a==c-b:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=int(input().split())
if (b-a)==(c-b):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=int(input().split())
if b-a==c-b:
    print("YES")
else:
    print("NO")
Problem p03773 (python)

Fixed submission:
a,b=map(int,input().split())
print((a+b)%24)

Buggy submission (verdict: Runtime Error):
a,b=int(input().split())
print((a+b)%24)
Problem p03795 (python)

Fixed submission:
n=int(input())
print(800*n-200*(n//15))

Buggy submission (verdict: Runtime Error):
n=int(input())
print(800*n-200*(n//15)
Problem p03844 (python)

Fixed submission:
a,op,b=input().split()
if op=="+":
    print(int(a)+int(b))
else:
    print(int(a)-int(b))

Buggy submission (verdict: Runtime Error):
a,op,b=input().split())
if op=="+":
    print(int(a)+int(b))
else:
    print(int(a)-int(b))
Problem p03943 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a+b==c or a+c==b or b+c==a:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a+b=c or a+c=b or b+c=a:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
if a+b=c or a+c=b or b+c=a:
    print("Yes")
else:
    print("No")
Problem p02675 (python)

Fixed submission:
n=int(input())
if n%10 == 3:
    print("bon")
elif n%10 in [0,1,6,8]:
    print("pon")
else:
    print('hon')

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%10 == 3:
    print("bon")
else if n%10 in [0,1,6,8]:
    print("pon")
else:
    print('hon')
Problem p02583 (python)

Fixed submission:
n=int(input())
r=list(map(int,input().split()))
t=0
for i in range(n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			if r[i]==r[j] or r[j]==r[k] or r[i]==r[k]:continue
			s=[r[i],r[j],r[k]]
			s.sort()
			if s[0]+s[1]>s[2]:
				t+=1
print(t)

Buggy submission (verdict: Runtime Error):
n=int(input())
r=list(map(int,input().split()))
t=0
for i in range(n):
  for j in range(i+1,n):
	for k in range(j+1,n):
      s=[r[i],r[j],r[k]]
      s.sort()
      if s[0]+s[1]>s[2]:t+=1
print(t)
Problem p02690 (python)

Fixed submission:
x=int(input())
for a in range(-200,201):
	f=False
	for b in range(-201,201):
		if a**5-b**5==x:
			print(a,b)
			f=True
			break
	if f:break

Buggy submission (verdict: Runtime Error):
x=int(input())
for a in range(-100,101):
	b5=a**5-x
	if int(b**0.2)**5==b:
		print(a,int(b**0.2))
		break
Problem p02950 (python)

Fixed submission:
#fin=open('in','r')
#input=lambda:fin.readline().strip()

p=int(input())
fact=[0]*p
inv=[0]*p
def f(x,m=p-2):
	ans=1
	while m:
		if m&1:ans=ans*x%p
		x=x*x%p
		m>>=1
	return ans
fact[0]=inv[0]=1
for i in range(1,p):
	fact[i]=fact[i-1]*i%p
	inv[i]=inv[i-1]*f(i)%p
r=list(map(int,input().split()))
c=[i for i in range(p) if r[i] == 1]
#sum of -((x-j)^(p-1)-1)
# (-j + x)^(p-1) = sum((-j)^i * x^(p-1-i) * binom(p-1,i))
coeff=[0]*p
for j in c:
	for i in range(p-1,-1,-1):
		if i&1:coeff[p-1-i]+=fact[p-1]*inv[i]*inv[p-1-i]*f(j,i)%p
		else:coeff[p-1-i]-=fact[p-1]*inv[i]*inv[p-1-i]*f(j,i)%p
	coeff[0]+=1
coeff=[(t%p+p)%p for t in coeff]
print(*coeff)

Buggy submission (verdict: Runtime Error):
fin=open('in','r')
input=lambda:fin.readline().strip()

p=int(input())
fact=[0]*p
inv=[0]*p
def f(x,m=p-2):
	ans=1
	while m:
		if m&1:ans=ans*x%p
		x=x*x%p
		m>>=1
	return ans
fact[0]=inv[0]=1
for i in range(1,p):
	fact[i]=fact[i-1]*i%p
	inv[i]=inv[i-1]*f(i)%p
r=list(map(int,input().split()))
c=[i for i in range(p) if r[i] == 1]
#sum of -((x-j)^(p-1)-1)
# (-j + x)^(p-1) = sum((-j)^i * x^(p-1-i) * binom(p-1,i))
coeff=[0]*p
for j in c:
	for i in range(p-1,-1,-1):
		if i&1:coeff[p-1-i]-=fact[p-1]*inv[i]*inv[p-1-i]*f(j,i)%p
		else:coeff[p-1-i]+=fact[p-1]*inv[i]*inv[p-1-i]*f(j,i)%p
	coeff[0]-=1
	coeff=[((-t)%p+p)%p for t in coeff]
print(*coeff)

Buggy submission (verdict: Runtime Error):
fin=open('in','r')
input=lambda:fin.readline().strip()

p=int(input())
fact=[0]*p
inv=[0]*p
def f(x):
	m=p-2
	ans=1
	while m:
		if m&1:ans=ans*x%p
		x=x*x%p
		m>>=1
	return ans
fact[0]=inv[0]=1
for i in range(1,p):
	fact[i]=fact[i-1]*i%p
	inv[i]=inv[i-1]*f(i)%p
r=list(map(int,input().split()))
c=[i for i in range(p) if r[i] == 1]
#sum of -((x-j)^(p-1)-1)
# (-j + x)^(p-1) = sum((-j)^i * x^(p-1-i) * binom(p-1,i))
coeff=[0]*p
for j in c:
	for i in range(p-1,-1,-1):
		if i&1:coeff[p-1-i]-=fact[p-1]*inv[i]*inv[p-1-i]*j**i
		else:coeff[p-1-i]+=fact[p-1]*inv[i]*inv[p-1-i]*j**i
	coeff[0]-=1
	coeff=[((-t)%p+p)%p for t in coeff]
print(*coeff)

Buggy submission (verdict: Runtime Error):
fin=open('in','r')
input=lambda:fin.readline().strip()

p=int(input())
fact=[0]*p
inv=[0]*p
def f(x):
	m=p-2
	ans=1
	while m:
		if m&1:ans=ans*x%p
		x=x*x%p
		m>>=1
	return ans
fact[0]=inv[0]=1
for i in range(1,p):
	fact[i]=fact[i-1]*i%p
	inv[i]=inv[i-1]*f(i)%p
r=list(map(int,input().split()))
c=[i+1 for i in range(p) if r[i] == 1]
#sum of -((x-j)^(p-1)-1)
coeff=[0]*p
for j in c:
	for i in range(p-1,-1,-1):
		if i&1:coeff[i]-=fact[p-1]*inv[i]*inv[p-1-i]*j**i
		else:coeff[i]+=fact[p-1]*inv[i]*inv[p-1-i]*j**i
	coeff[0]-=1
coeff=[((-t)%p+p)%p for t in coeff]
print(*coeff)
Problem p03353 (python)

Fixed submission:
s=input()
a=int(input())
r=[]
for i in range(len(s)):
  for j in range(i+1,min(a+i,len(s))+1):
    r.append(s[i:j])
r=list(set(r))
r.sort()
print(r[a-1])

Buggy submission (verdict: Runtime Error):
s=input()
a=int(input())
r=[]
for i in range(len(s)):
  for j in range(i+1,min(k+i,len(s))+1):
    r.append(s[i:j])
r=list(set(r))
r.sort()
print(r[a-1])
Problem p02658 (python)

Fixed submission:
A= int(input())
B = list(map(int, input().split()))
result = 1
if 0 in B:
    print(0)
    exit()

for S in B:
    result *= S
    if result > 10**18:
        print(-1)
        exit()
print("%d"%result)

Buggy submission (verdict: Runtime Error):
N = int(input())
m,k = input().split()
result=int(m)*int(k)
print("%d"%result)
if result>=10**18:
    print("-1")

Buggy submission (verdict: Runtime Error):
N = int(input())
m,k = input().split()
result=int(m)*int(k)
print("%d"%result)
if result>=10**18:
    print("-1")
Problem p02630 (python)

Fixed submission:
def main():
    n = int(input())

    As = list(map(int, input().split()))
    nums = [0] * (10**5+1)
    ans = 0
    for a in As:
        ans += a
        nums[a] += 1

    q = int(input())
    for i in range(q):
        b, c = map(int, input().split())
        ans += (c-b) * nums[b]
        nums[c] += nums[b]
        nums[b] = 0
        print(ans)


if __name__ == "__main__":
    main()

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

    As = list(map(int, input().split()))
    nums = [0] * (10**5)
    ans = 0
    for a in As:
        ans += a
        nums[a] += 1

    q = int(input())
    for i in range(q):
        b, c = map(int, input().split())
        ans += (c-b) * nums[b]
        nums[c] += nums[b]
        nums[b] = 0
        print(ans)


if __name__ == "__main__":
    main()
Problem p02678 (python)

Fixed submission:
from collections import deque


def bfs(rooms, v=1):
    arrow = [-1] * len(rooms)
    q = deque()
    q.append(v)

    while q:
        now = q.popleft()
        for next_v in rooms[now]:
            if arrow[next_v] != -1:
                continue
            else:
                q.append(next_v)
                arrow[next_v] = now
    return arrow


def main():
    n, m = map(int, input().split())
    rooms = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        rooms[b].append(a) 
        rooms[a].append(b)

    anss = bfs(rooms)
    print("Yes")
    for ans in anss[2:]:
        print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def search(rooms, li, anss, count):
    count += 1
    for l in li:
        if anss[l] == 0:
            anss[l] = count
            search(rooms, rooms[l], anss, count)
    return anss


def main():
    n, m = map(int, input().split())
    rooms = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        rooms[b].append(a) 
        rooms[a].append(b)
    anss = [0]*(n+1)
    li = rooms[1]
    count = 0
    anss = search(rooms, li, anss, count)
    if 0 in anss[1:]:
        print("No")
    else:
        print("Yes")
        for ans in anss[1:]:
            print(ans)


if __name__ == "__main__":
    main()
Problem p02761 (python)

Fixed submission:
def main():
    n, m = map(int, input().split())
    ans = [-1]*n
    for _ in range(m):
        s, c = map(int, input().split())
        if ans[s-1] == -1:
            ans[s-1] = c
        elif ans[s-1] != -1 and ans[s-1] != c:
            print(-1)
            exit()

    if n == 1:
        if ans[0] == -1:
            ans[0] = 0
    else:
        if ans[0] == 0:
            print(-1)
            exit()

        if ans[0] == -1:
            ans[0] = 1

        for i in range(1, n):
            if ans[i] == -1:
                ans[i] = 0
    print(*ans, sep="")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    ans = [0]*n
    for _ in range(m):
        s, c = map(int, input().split())
        if ans[s-1] == 0:
            ans[s-1] = c
        elif ans[s-1] != 0 and ans[s-1] != c:
            print(-1)
            exit()

    if len(ans[0]) == 1:
        print(ans[0])
    if ans[0] == 0:
        print(-1)
    else:
        print(*ans, sep="")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    ans = [0]*n
    for _ in range(m):
        s, c = map(int, input().split())
        if ans[s-1] == 0:
            ans[s-1] = c
        elif ans[s-1] != 0 and ans[s-1] != c:
            print(-1)
            exit()

    if len(ans[0]) == 1:
        print(*ans, sep="")
    if ans[0] == 0:
        print(-1)
    else:
        print(*ans, sep="")


if __name__ == "__main__":
    main()
Problem p02780 (python)

Fixed submission:
def main():
    n, k = map(int, input().split())
    ps = list(map(int, input().split()))
    e = [(1+p)/2 for p in ps]

    s = [0]
    for i in range(n):
        s.append(s[i]+e[i])

    ans = max([s[i+k] - s[i] for i in range(n-k+1)])
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, k = map(int, input().split())
    ps = list(map(int, input().split()))
    ps = [(1+p)/2 for p in ps]

    print(ps)
    cumulative_sums = [sum(ps[:i+1]) for i in range(n)]
    ans = max([cumulative_sums[i+k] - cumulative_sums[i] for i in range(n-k)])
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, k = map(int, input().split())
    ps = list(map(int, input().split()))
    ps = [(1+p)/2 for p in ps]

    cumulative_sums = [sum(ps[:i]) for i in range(n)]
    ans = max([cumulative_sums[i+k] - cumulative_sums[i] for i in range(n-k)])
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np


def main():
    n, k = map(int, input().split())
    ps = (np.array(list(map(int, input().split()))) + 1) / 2

    if k == 1:
        ans = ps[0]
    else:
        cumulative_sum = [0] * n
        for i in range(n):
            if i == 0:
                cumulative_sum[i] = ps[0]
            else:
                cumulative_sum[i] = ps[i] + cumulative_sum[i-1]

        ans = max([cumulative_sum[i+k] - cumulative_sum[i] for i in range(n-k)])
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np


def main():
    n, k = map(int, input().split())
    ps = (np.array(list(map(int, input().split()))) + 1) / 2

    if k == 1:
        ans = max(ps)
    else:
        cumulative_sum = [0] * n
        for i in range(n):
            if i == 0:
                cumulative_sum[i] = ps[0]
            else:
                cumulative_sum[i] = ps[i] + cumulative_sum[i-1]
    
        ans = max([cumulative_sum[i+k] - cumulative_sum[i] for i in range(n-k)])
        print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np


def main():
    n, k = map(int, input().split())
    ps = (np.array(list(map(int, input().split()))) + 1) / 2

    cumulative_sum = [0] * n
    for i in range(n):
        if i == 0:
            cumulative_sum[i] = ps[0]
        else:
            cumulative_sum[i] = ps[i] + cumulative_sum[i-1]

    ans = max([cumulative_sum[i+k] - cumulative_sum[i] for i in range(n-k)])
    print(ans)


if __name__ == "__main__":
    main()
Problem p02786 (python)

Fixed submission:
def main():
    h = int(input())

    if h == 1:
        print(1)
        exit()

    for i in range(40):
        if 2**(i+1) == h:
            n = i+2
            break
        if 2**(i) < h and h < 2**(i+1):
            n = i+1
            break
    ans = sum([2**i for i in range(n)])
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    h = int(input())

    for i in range(40):
        if 2**(i+1) == h:
            n = i+2
            break
        if 2**(i) < h and h < 2**(i+1):
            n = i+1
            break
    ans = sum([2**i for i in range(n)])
    print(ans)


if __name__ == "__main__":
    main()
Problem p02899 (python)

Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = []
    a = {i: k for i, k in enumerate(a, start=1)}
    a = sorted(a.items(), key=lambda a: a[1])
    for i in a:
        ans.append(i[0])

    print(*ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from math import gcd, sqrt


def is_prime(n):
    flag = True
    for k in range(2, int(sqrt(n)) + 1):
        if n % k == 0:
            flag = False
            return

    if flag:
        return n


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def main():
    a, b = map(int, input().split())
    coms = make_divisors(gcd(a, b))
    # print(coms)
    ans = [is_prime(i) for i in coms]
    # print(ans)
    ans2 = [a for a in ans if a is not None]
    print(len(ans2))


if __name__ == "__main__":
    main()
Problem p02900 (python)

Fixed submission:
# from math import gcd, sqrt
import fractions
import math


def is_prime(n):
    flag = True
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            flag = False
            return

    if flag:
        return n


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def main():
    a, b = map(int, input().split())
    coms = make_divisors(fractions.gcd(a, b))
    ans = [is_prime(i) for i in coms]
    ans2 = [a for a in ans if a is not None]
    print(len(ans2))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# from math import gcd, sqrt
# import fractions
import math


def is_prime(n):
    flag = True
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            flag = False
            return

    if flag:
        return n


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def main():
    a, b = map(int, input().split())
    coms = make_divisors(math.gcd(a, b))
    ans = [is_prime(i) for i in coms]
    ans2 = [a for a in ans if a is not None]
    print(len(ans2))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from math import gcd, sqrt


def is_prime(n):
    flag = True
    for k in range(2, int(sqrt(n)) + 1):
        if n % k == 0:
            flag = False
            return

    if flag:
        return n


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def main():
    a, b = map(int, input().split())
    coms = make_divisors(gcd(a, b))
    # print(coms)
    ans = [is_prime(i) for i in coms]
    # print(ans)
    ans2 = [a for a in ans if a is not None]
    print(ans2)


if __name__ == "__main__":
    main()
Problem p02952 (python)

Fixed submission:
def main():
    N = int(input())

    ans = 0
    if len(str(N)) % 2 == 0:
        for i in range(len(str(N))):
            if i % 2 == 0:
                ans += 9*(10**i)
    else:
        for i in range(len(str(N))+1):
            if i % 2 == 0:
                ans += 9*(10**i)
        ans = ans - (10**len(str(N)) - N) + 1
        
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())

    ans = 0
    for i in range(len(str(N))):
        if len(str(N)) != i+1:
            if i % 2 == 0:
                ans += 9*(10**i)
        else:
            if i % 2 == 0:
                ans += int(str(N)[1:])+1
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())

    ans = 0
    for i in range(len(str(N))):
        if len(str(N)) != i+1:
            if i % 2 == 0:
                ans += 9*(10**i)
        else:
            if i % 2 == 0:
                if int(str(N)[1:]) == 0:
                    ans += 1
                else:
                    ans += int(str(N)[1:])
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())

    ans = 0
    for i in range(len(str(N))):
        if len(str(N)) != i+1:
            if i % 2 == 0:
                ans += 9*(10**i)
        else:
            if i % 2 == 0:
                if int(str(N)[1:]) == 0:
                    ans += 1
                else:
                    ans += int(str(N)[1:])+1
    print(ans)


if __name__ == "__main__":
    main()
Problem p02953 (python)

Fixed submission:
def main():
    n = int(input())
    h = list(map(int, input().split()))
    for i in range(n-1):
        if h[i] < h[i+1]:
            h[i+1] -= 1
        elif h[i] > h[i+1]:
            print('No')
            exit()

    print('Yes')


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    h = list(map(int, input().split()))
    print(h)
    for i in range(n-1):
        print(h)
        if h[i] < h[i+1]:
            h[i+1] -= 1
        elif h[i] > h[i+1]:
            print('No')
            exit()

    print('Yes')


if __name__ == "__main__":
    main()
Problem p02958 (python)

Fixed submission:
def main():
    n = int(input())
    ps = list(map(int, input().split()))
    ps_sort = sorted(ps)

    Count = 0
    for i, j in zip(ps, ps_sort):
        if i != j:
            Count += 1

    if Count == 2 or Count == 0:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    a, b = map(int, input().split())
    diff = abs(max(b, a) - min(a, b))
    if diff % 2 != 0:
        print("IMPOSSIBLE")
    else:
        bigger = max(a, b)
        ans = bigger - (diff//2)
        print(ans)


if __name__ == "__main__":
    main()
Problem p02971 (python)

Fixed submission:
def main():
    n = int(input())
    As = [int(input()) for _ in range(n)]

    As_sort = sorted(As)
    second, first = As_sort[-2:]
    for i in range(n):
        if As[i] == first:
            print(second)
        else:
            print(first)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline


def main():
    N = int(input())
    A = np.array([int(input()) for _ in range(N)])

    for j in range(N):
        if j != A.index(max(A)):
            print(np.max(A))
        else:
            ans = [x for i, x in enumerate(A) if i != j]
            print(np.max(ans))


if __name__ == "__main__":
    main()
Problem p02995 (python)

Fixed submission:
from fractions import gcd


def lcm(c, d):
    return (c * d) // gcd(c, d)


def main():
    a, b, c, d = map(int, input().split())
    c_num = (b//c-(a-1)//c)
    d_num = (b//d-(a-1)//d)
    cd_num = (b//lcm(c, d)-(a-1)//lcm(c, d))
    ans = b-a+1-c_num-d_num+cd_num
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math


def lcm(c, d):
    return (c * d) // math.gcd(c, d)


def main():
    a, b, c, d = map(int, input().split())
    c_num = (b//c-(a-1)//c)
    d_num = (b//d-(a-1)//d)
    cd_num = (b//lcm(c, d)-a//lcm(c, d))
    ans = b-a+1-c_num-d_num+cd_num
    print(ans)


if __name__ == "__main__":
    main()