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

Fixed submission:
s = int(input())
a = []
while s not in a:
  a.append(s)
  if s%2 == 0:
    s = s/2
  else:
    s = 3*s+1
print(len(a)+1)

Buggy submission (verdict: Runtime Error):
s = int(input())
c = 0
a = [s]
while c < 100000:
  if s % 2 == 0:
    s = s//2
    c += 1
  else:
    s = 3*s+1
    c += 1
    a += [s]
  for i in range(c):
    if a[i] in a[:i]:
      print(i+1)
      exit()
Problem p03238 (python)

Fixed submission:
N = int(input())
if N == 1:
	print("Hello World")
else:
	A = int(input())
	B = int(input())
	print(A+B)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
print('Hellow World' if a == 1 else b + c)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
print('Hellow World' if a == 1 else b + c)
Problem p03239 (python)

Fixed submission:
n,t=map(int, input().split())
A=[]
for i in range(n):
  a=list(map(int, input().split()))
  if a[1] <= t:
    A.append(a[0])
if len(A)==0:
  print('TLE')
else:
  print(min(A))

Buggy submission (verdict: Runtime Error):
n, T = map(int,input().split())
A=[]
for i in range(n):
  a = list(map(int,input().split()))
  if a[1]<=T:
    A.append(a[0])

if len(a)==0:
  print('TLE')
else:
  print(min(A))

Buggy submission (verdict: Runtime Error):
n, T = map(int,input().split())
A=[]
for i in range(n):
  a = list(map(int,input().split()))
  if a[1]<=T:
    A.append(a[0])

if len(a)==0:
    print('TLE')
else:
    print(min(A))

Buggy submission (verdict: Runtime Error):
n, T = map(int,input().split())
A=[]
for i in range(n):
  a = list(map(int,input().split()))
  if a[1]<=T:
    A.append(a[0])

if len(a)==0:
    print('TLE')
else:
    print(min(A))
Problem p03273 (python)

Fixed submission:
h, w = map(int, input().split())
a = []
for _ in range(h):
    l = input()
    if l != '.'*w:
        a.append(l)
col = []
h = len(a)
for i in range(w):
    if a[0][i] == '.':
        for j in range(1,h):
            if a[j][i] != '.':
                col.append(i)
                break
    else:
        col.append(i)
for l in a:
    ll = ''
    for i in col:
        ll += l[i]
    print(ll)

Buggy submission (verdict: Runtime Error):
    h, w = map(int, input().split())
    a = []
    for _ in range(h):
        l = input()
        if l != '.'*w:
            a.append(l)
    col = []
    h = len(a)
    for i in range(w):
        if a[0][i] == '.':
            for j in range(1,h):
                if a[j][i] != '.':
                    col.append(i)
                    break
        else:
            col.append(i)
    for l in a:
        ll = ''
        for i in col:
            ll += l[i]
        print(ll)

h, w = map(int, input().split())
a = []
for _ in range(h):
    l = input()
    if l != '.'*w:
        a.append(l)
col = []
h = len(a)
for i in range(w):
    if a[0][i] == '.':
        for j in range(1,h):
            if a[j][i] != '.':
                col.append(i)
                break
    else:
        col.append(i)
for l in a:
    ll = ''
    for i in col:
        ll += l[i]
    print(ll)
Problem p03282 (python)

Fixed submission:
s=input()
k=int(input())
for i in range(k):
  if s[i]!="1":
    break
print(s[i])

Buggy submission (verdict: Runtime Error):
a=list(input())
k=int(input())
if a[0]=="1":
  print(a[1])
else:
  print(a[0])

Buggy submission (verdict: Runtime Error):
b=list(input())
a=int(input())
if b[0]=="1":
  print(b[1])
else:
  print(b[0])

Buggy submission (verdict: Runtime Error):
b=list(input())
a=int(input())
if b[0]=="1":
  print(1)
else:
  print(b[1])
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, c = map(int, input().split())

print(max([a+b, a-b, a*b]))
Problem p03386 (python)

Fixed submission:
A, B, K = map(int, input().split())
a = [i for i in range(A, min(A+K,B))]
b = [i for i in range(max(A,B-K+1), B+1)]
for x in sorted(list(set(a + b))):
  print(x)

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

Answer = set([])
for i in range(K):
    if A+i <=B:
        Answer.add(A+i)
    if B - i >= A:
        Answer.add(B-i)
Answer = sorted(Answer)
for i in Answer:
    print(i)
Problem p03407 (python)

Fixed submission:
a,b,c = map(int, input().split())

print('Yes' if a+b >= c else 'No')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

ans = 0
for i in s:
  ans=max(ans, s.count(i)- t.count(i))
print(ans)
Problem p03455 (python)

Fixed submission:
a, b = map(int, input(). split())
if (a*b) % 2:
  print("Odd")
else: 
  print("Even")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input(). split())
if (a*b) % 2:
print ("Odd")
else: print("Even")
Problem p03493 (python)

Fixed submission:
print(input().count("1"))

Buggy submission (verdict: Runtime Error):
print(input(), count("1"))

Buggy submission (verdict: Runtime Error):
print(imput().count"1")
Problem p03502 (python)

Fixed submission:
a = input()
x = 0
for i in range(len(a)):
    x += int(a[i])
print("Yes" if int(a) % x == 0 else "No")

Buggy submission (verdict: Runtime Error):
a = input()
x = 0
for i in range(len(N)):
    x += int(N[i])
print("Yes" if int(a) % x == 0 else "No")
Problem p03555 (python)

Fixed submission:
s=input()
t=input()
print("YES" if s==t[::-1] else "NO")

Buggy submission (verdict: Runtime Error):
    s=input()
    t=input()
    print("YES" if s==t[::-1] else "NO")
Problem p03573 (python)

Fixed submission:
a,b,c=map(int,input().split())

print(a if b==c else b if a==c else c)

Buggy submission (verdict: Runtime Error):
a,b,c = input()

print(a if b==c else b if a==c else c)
Problem p03624 (python)

Fixed submission:
a = input()
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if len(set(a))==26:
  print('None')
else:
  for i in range(len(l)):
    if l[i] not in a:
      print(l[i])
      break

Buggy submission (verdict: Runtime Error):
a = input()
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if len(set(a))==26:
  pritn('None')
else:
  for i in range(len(l)):
    if l[i] not in a:
      print(l[i])
      break

Buggy submission (verdict: Runtime Error):
a = input()
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if len(set(a))==26:
  pritn('None')
else:
  for i in range(len(l)):
    if l[i] not in a:
      print(l[i])
      exit()

Buggy submission (verdict: Runtime Error):
a = input()
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if len(set(a))=26:
  pritn('None')
  else:
    for i in range(len(l)):
      if l[i] not in a:
        print(l[i])
        exit()
Problem p03657 (python)

Fixed submission:
a,b = map(int,input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
    print('Possible')
else:
    print('Impossible')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
	if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
    	print('Possible')
    else:
        print('Impossible')

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

print('possible' if (a+b)% ==0 else 'impossible')
Problem p03679 (python)

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

print('delicious' if B <= A else 'safe' if B <= A+X else 'dangerous')

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

print('delicious' if B <= A else 'safe' if B <= A+X else 'dangerous')
Problem p03712 (python)

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

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().spllit())
print("#"*(b+2))
for i in range(a):
  print("#"+input()+"#")
print("#"*(b+2))
Problem p03729 (python)

Fixed submission:
A,B,C = input().split()
print("YES" if A[-1]==B[0] and B[-1] == C[0] else "NO")

Buggy submission (verdict: Runtime Error):
A B C =input()



print('YES' if A[count(A-1)]==B[0] and B[count(B-1)]==c[0] else 'No')
Problem p03759 (python)

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

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

print('YES' if b−a==c−b else 'NO')
Problem p03860 (python)

Fixed submission:
print("A"+input()[8]+"C")

Buggy submission (verdict: Runtime Error):
s = input(AtCoder s Contest)
print('A' + input()[8] + 'C')
Problem p04030 (python)

Fixed submission:
s = input()
ans =''
for i in s:
  if i =='1':
    ans+='1'
  elif i=='0':
    ans+='0'
  elif i=='B':
      ans = ans[:-1]
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
s = input()
ans =''
for i in range(len(s)):
  if i ==1:
    ans+='1'
  elif i==0:
    ans+='0'
  elif i=='B':
      ans = ans[:-1]
print(ans)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
def kai():
    N=int(input())
    A=list(map(int,input().split()))
    
    if  0 in A:
        print(0)
        return
    
    ans=1
    for i in A:
        ans*=i
        if ans>10**18:
            print(-1)
            return
    print(ans)
    return
kai()

Buggy submission (verdict: Runtime Error):
def kai():
    N=int(input())
    A=list(map(int,input().split()))
    
    if  0 in A:
        print(0)
        return
    
    ans=1
    for i in A:
        ans*=i
        if ans>10**18:
            print(-1)
            rerurn
    print(ans)
    return
kai()
Problem p02658 (python)

Fixed submission:
def kai():
    N=int(input())
    A=list(map(int,input().split()))
    
    if  0 in A:
        print(0)
        return
    
    ans=1
    for i in A:
        ans*=i
        if ans>10**18:
            print(-1)
            return
    print(ans)
    return
kai()

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=1
A=list(map(int,input().split()))
while ans<10**18:
    for i in A:
        ans*=i
if ans>=10**18
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=1
for i in range(N):
  A=int(input())
  ans*=A
if ans>1000000000000000000:
  print(-1)
else:
  print(ans)
Problem p02658 (python)

Fixed submission:
import math
 
n=int(input())
arr=list(map(int,input().split()))
if 0 in arr:
  print("0")
  exit()
ans=1
for i in range(n):
  ans *= arr[i]
  if math.log10(ans) >= 18 and ans!=1000000000000000000:
    print("-1")
    exit()
print(ans)

Buggy submission (verdict: Runtime Error):
import math
 
n=int(input())
arr=list(map(int,input().split()))
ans=1
for i in range(n):
  ans *= arr[i]
if math.log10(ans) > 18:
  print("-1")
else:
  print(ans)
Problem p02657 (python)

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

print(a*b)

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

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

count = 1

for i in a:
    count*=i

x = 10**18

if count > x:
    print(-1)
    break
else:
    print(count)
Problem p02658 (python)

Fixed submission:
n = int(input())

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

count = 1

for i in range(n):
    count*=a[i]
    if count>10**18:
        print(-1)
        break

else:
    print(count)

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

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

count = 1

for i in a:
    count*=i

x = 10**18

if count > x:
    print(-1)
    break
else:
    print(count)

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

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

count = 1

for i in a:
    count*=i

x = 10**18

if count > x:
    print(-1)
    break
else:
    print(count)
Problem p02675 (python)

Fixed submission:
N = int(input())
L = N % 10
if L == 3:
  print("bon")
elif L == 0 or L == 1 or L == 6 or L == 8:
  print('pon')
else:
  print('hon')

Buggy submission (verdict: Runtime Error):
N = int(input())
L = N % 10
if L == 3:
  print("bon")
#0
,
1
,
6
,
8

elif L == 0 or L == 1 or L == 6 or L == 8:
  print('pon')
else:
  print('hon')
Problem p03494 (python)

Fixed submission:
input()
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
  A = [a/2 for a in A]
  count += 1
print(count)

Buggy submission (verdict: Runtime Error):
input()
A = list(map(int, input().split))
count = 0
while all(a % 2 == 0 for a in A):
  A = [a/2 for a in A]
  count += 1
print(count)
Problem p02724 (python)

Fixed submission:
n=int(input())
def covid(num):
  if num==0:
    return 0
  else:
    happy=0
    fund=num//500
    num-=fund*500
    happy+=fund*1000
    happy+=num//5*5
    return happy
print(covid(n))

Buggy submission (verdict: Runtime Error):
n=int(input())
happy=0
def covid(num):
  if num==0:
    return 0
  else:
    fund=num//500
    num-=fund*500
    happy+=fund*1000
    happy+=num//5*5
    return happy
print(covid(n))
Problem p02664 (python)

Fixed submission:
s=input()
s2=list(s)
s1=""
if s2[-1]=="?":
    s2[-1]="D"
if s2[0]=="?" and s2[1]=="D":
    s2[0]="P"
elif s2[0]=="?" and (s2[1]=="P" or s2[1]=="?"):
    s2[0]="D"
for i in range(1,len(s2)-1):
    if s2[i]=='?':
        if s2[i-1]=="D" and (s2[i+1]=="D" or s2[i+1]=="?"):
           s2[i]="P"
        else:
            s2[i]="D"
for i in s2:
    s1+=i
print(s1)

Buggy submission (verdict: Runtime Error):
s=input()
s2=list(s)
if s2[0]=="?" and s2[1]=="D":
    s2[0]="P"
elif s2[0]=="?" and (s2[1]=="P" or s2[1]=="?"):
    s2[0]="D"
if s2[-1]=="?":
    s2[-1]="D"
for i in range(1,len(s2)-1):
    if s2[i]=='?':
        if s2[i-1]=="D" and (s2[i+1]=="D" or s2[i+1]=="?"):
           s2[i]="P"
        else:
            s2[i]="D"
s1="".join(s2)
print(s1)

Buggy submission (verdict: Runtime Error):
s=input()
s=list(s)
if s[0]=="?" and s[1]=="D":
    s[0]="P"
elif s[0]=="?" and (s[1]=="P" or s[1]=="?"):
    s[0]="D"
if s[-1]=="?":
    s[-1]="D"
for i in range(1,len(s)-1):
    if s[i]=='?':
        if s[i-1]=="D" and (s[i+1]=="D" or s[i+1]=="?"):
           s[i]="P"
        else:
            s[i]="D"
s1="".join(s)
print(s1)

Buggy submission (verdict: Runtime Error):
s=input()
s=list(s)
if s[0]=="?" and s[1]=="D":
    s[0]="P"
elif s[0]=="?" and (s[1]=="P" or s[1]=="?"):
    s[0]="D"
for i in range(1,len(s)-1):
    if s[i]=='?':
        # print(s)
        if s[i-1]=="D" and (s[i+1]=="D" or s[i+1]=="?"):
           s[i]="P"
        else:
            s[i]="D"
    # print(s)
if s[-1]=="?":
    s[-1]="D"
s1="".join(s)
print(s1)

Buggy submission (verdict: Runtime Error):
s=input()
s=list(s)
if s[0]=="?" and s[1]=="D":
    s[0]="P"
elif s[0]=="?" and s[1]=="P":
    s[0]="D"
for i in range(1,len(s)-1):
    if s[i]=='?':
        # print(s)
        if s[i-1]=="D" and s[i+1]=="D":
           s[i]="P"
        elif s[i-1]=="D" and s[i+1]=="?":
            s[i]="P"
        else:
            s[i]="D"
    # print(s)
if s[-1]=="?":
    s[-1]="D"
s1="".join(s)
print(s1)
Problem p02731 (python)

Fixed submission:
l = float(input())
x=l/3
y=x
z=y
print(z*y*x)

Buggy submission (verdict: Runtime Error):
    l=int(input())
    print((l/3)**3)
Problem p02741 (python)

Fixed submission:
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(input())
print(l[a-1])

Buggy submission (verdict: Runtime Error):
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(input())
print(l[a])
Problem p02755 (python)

Fixed submission:
a,b=map(int,input().split())
answer=False
for i in range(1,1009):
    if int(i*0.08)==a and int(i*0.10)==b:
        print(i)
        answer=True
        break
if not answer:
     print("-1")

Buggy submission (verdict: Runtime Error):
    import math
    a,b=map(int,input().split())
    answer=False
    for i in range(1,1009):
        if int(i*0.08)==a and int(i*0.10)==b:
            print(i)
            answer=True
            break
    if not answer:
        print(-1)
Problem p02853 (python)

Fixed submission:
x,y=map(int,input().split())
l=[0,300000,200000,100000]
if x==y==1:
 print(l[x]+l[y]+400000)
else:
    if y > 3:
        y=0
    if x>3:
        x=0
    print(l[x]+l[y])

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
l=[0,300000,200000,100000]
if x==y==1:
 print(l[x]+l[y]+400000)
elif y>3:
    print(l[x])
elif x>3:
    print(l[y])
else:
    print(l[x]+l[y])
Problem p02861 (python)

Fixed submission:
import itertools
import math
n=int(input())
l=[]
l1=[]
for i in range(n):
    x,y=map(int,input().split())
    l.append((x,y))
N=math.factorial(n)
c=itertools.permutations(l,n)
l=list(c)
for j in range(N):
    for k in range(n-1):
        d=math.sqrt((l[j][k][0]-l[j][k+1][0])**2+(l[j][k][1]-l[j][k+1][1])**2)
        l1.append(d)
print(sum(l1)/N)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[]
l1=[]
for i in range(n):
    x,y=map(int,input().split())
    l.append((x,y))
N=math.factorial(n)
c=itertools.permutations(l,n)
l=list(c)
for j in range(N):
    for k in range(n-1):
        l1.append(math.sqrt((l[j][k][0]-l[j][k+1][0])**2+(l[j][k][1]-l[j][k+1][1])**2))
print(sum(l1)/N)
Problem p03001 (python)

Fixed submission:
def do():
    w,h,x,y=map(int,input().split())
    ar=w*h
    if w/2==x and h/2==y:
        return "{} 1".format(ar/2)
    else:
        return "{} 0".format(ar/2)
print(do())

Buggy submission (verdict: Runtime Error):
def do():
    w,h,x,y=map(int,input().split())
    ar1=(h-y)*w
    ar2=(w-x)*h
    if ar1==ar2:
        return "{} 1".format(ar2)
    elif w%x==0:
        return "{} 0".format(ar2)
    elif h%y==0:
        return "{} 0".format(ar1)
print(do())

Buggy submission (verdict: Runtime Error):
def do():
    w,h,x,y=map(int,input().split())
    ar1=(h-y)*w
    ar2=(w-x)*h
    if w%x==0 and h%y==0:
        return "{} 1".format(ar2)
    elif w%x==0:
        return "{} 0".format(ar2)
    elif h%y==0:
        return "{} 0".format(ar1)
print(do())
Problem p02657 (python)

Fixed submission:
a,b=(int(x) for x in input().split())

print(int(a*b))

Buggy submission (verdict: Runtime Error):
 a,b=(int(x) for x in input().split())
 
 print(a*b)
Problem p02818 (python)

Fixed submission:
A,B,K = list(map(int,input().split()))
if K <= A:
    A = A - K
else:
    if K - A <= B:
        B = B - (K - A)
        A = 0        
    else:
        A = 0
        B = 0
print(A, B)

Buggy submission (verdict: Runtime Error):
	a,b,k = map(int, input().split())
	a=a-k
	b=b+a
	if a<0:a=0
	if b<0:b=0
	print(a,b)
Problem p02934 (python)

Fixed submission:
N = int(input())
A = map(int,input().split())
a = [ 1/i for i in A]
res = 1/(sum(a))
print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [ int(input()) for i in range(N)]
a = [ 1/i for i in A]
res = 1/(sum(a))
print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [ int(input()) for i in range(N)]
a = [ 1/i for i in A]
res = 1/(sum(a))
print(res)
Problem p03085 (python)

Fixed submission:
b = input()

if b == "A":
	print("T")
elif b == "C":
	print("G")
elif b == "G":
	print("C")
else:
	print("A")

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

if b == "A":
	print("T")
elif b == "C":
	print("G")
elif b == "G":
	print("C")
else:
	print("A")
Problem p03162 (python)

Fixed submission:
N = int(input())
lis = [list(map(int, input().split())) for i in range(N)]

dp = [[0,0,0] for i in range(N)]
dp[0] = lis[0]

for idx, val in enumerate(lis[1:], start=1):
	a = val[0] + max([dp[idx-1][i] for i in range(3) if 0 != i ])
	b = val[1] + max([dp[idx-1][i] for i in range(3) if 1 != i ])
	c = val[2] + max([dp[idx-1][i] for i in range(3) if 2 != i ])
	dp[idx] = [a,b,c]
print(max(dp[-1]))

Buggy submission (verdict: Runtime Error):
N = int(input())
lis = [list(map(int, input().split())) for i in range(N)]

dp = [[0,0,0] for i in range(N)]
dp[0] = lis[0]

for idx, val in enumerate(lis[1:], start=1):
	a = val[0] + max([dp[idx-1][i] for i in range(3) if 0 != i ])
	b = val[1] + max([dp[idx-1][i] for i in range(3) if 1 != i ])
	c = val[2] + max([dp[idx-1][i] for i in range(3) if 2 != i ])
	dp[idx] = [a,b,c]
print(max(dp[-1][0]))
Problem p02919 (python)

Fixed submission:
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque




def main():
    num = int(input())
    data = list(map(int, input().split()))

    for i in range(num):
        data[i] = (data[i], i + 1)
    data.sort(key=lambda x: x[0])

    left = [0, 0] + [i + 1 for i in range(num)]
    right = [i + 1 for i in range(num)] + [num + 1, num + 1]
    ans = 0
    for i in range(num):
        ori_num, ori_ind = data[i]
        l1 = left[ori_ind]
        l2 = left[l1]
        r1 = right[ori_ind]
        r2 = right[r1]

        ans += ((l1 - l2) * (r1 - ori_ind) + (ori_ind - l1) * (r2 - r1)) * ori_num

        right[l1] = r1
        left[r1] = l1

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque




def main():
    num = int(input())
    data = list(map(int, input().split()))

    for i in range(num):
        data[i] = (data[i], i + 1)
    data.sort(key=lambda x: -x[0])

    ind_list = deque([0, 0, num + 1, num + 1])
    # ind_list = [0, 0, num + 1, num + 1]
    ans = 0
    for i in range(num):
        ori_num, ori_ind = data[i]
        # bisect.insort_left(ind_list, ori_ind)
        # add_ind = bisect.bisect_left(ind_list, ori_ind)
        add_ind = bisect.bisect_left(ind_list, ori_ind)
        add_ind = -1
        ind_list.insert(add_ind, ori_ind)
        # print(add_ind)
        l2, l1 = ind_list[add_ind - 2], ind_list[add_ind - 1]
        r2, r1 = ind_list[add_ind + 2], ind_list[add_ind + 1]
        ans += ((l1 - l2) * (r1 - ori_ind) + (ori_ind - l1) * (r2 - r1)) * ori_num

    print(ans)


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

Fixed submission:
from collections import defaultdict

def main():
    left, right = map(int, input().split())
    mod = 2019

    aaa = defaultdict(int)
    for i in range(left, min(right + 1, left + 5000)):
        aaa[i % mod] += 1

    score_sorted = list(sorted(aaa.items(), key=lambda x: x[0]))

    # print(score_sorted)

    ans = 2019
    for i in range(len(score_sorted)):
        if score_sorted[i][1] >= 2:
            ans = min(ans, (score_sorted[i][0] * score_sorted[i][0]) % mod)
        for j in range(i + 1, len(score_sorted)):
            ans = min(ans, (score_sorted[i][0] * score_sorted[j][0]) % mod)

    print(ans)







if __name__ == '__main__':
    main()

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

def main():
    left, right = map(int, input().split())
    mod = 2019

    # a, b = left, left + 1
    # c, d = right, right - 1
    aaa = defaultdict(int)
    for i in range(left, min(right + 1, left + 5000)):
        aaa[i % mod] += 1

    score_sorted = list(sorted(aaa.items(), key=lambda x: x[1]))

    # print(score_sorted)

    if score_sorted[0][1] >= 2:
        a, b = score_sorted[0][0]
    else:
        a, b, = score_sorted[0][0], score_sorted[1][0]

    print((a * b)% mod)






if __name__ == '__main__':
    main()