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

Fixed submission:
s = input()
week=["SAT","FRI","THU","WED","TUE","MON","SUN"]
for i in range(0,7):
    if s == week[i]:
        print(i+1)

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

def calc(n):
      p=a*n+b*len(str(n))
      return p<=x

h=10**9+1
ok=0
while h-ok>1:
      m=(h+ok)//2
      if calc(m):
            ok=m
      else:
            h=m

print(ok)

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

def calc(n):
      p=a*n+b*len(str(n))
      return p<=x

h=10**9+1
ok=0
while h-ok>1:
      m=(h+ok)//2
      if calc(m):
            ok=m
      else:
            h=m

print(ok)
Problem p02879 (python)

Fixed submission:
a,b,=map(int,input().split())
if a>=10 or b>=10:
    print(-1)
else:
    print(a*b)

Buggy submission (verdict: Runtime Error):
a,b,=int(input())
if a>=10 or b>=10:
    print(-1)
    break:
else:
    print(a*b)

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
print(A*B)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a>=3200:
    print(s)
else:
    print("red")

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()
if a>=3200:
    print(s)
else:
    print(red)
Problem p02897 (python)

Fixed submission:
n=int(input())
if n%2==0:
  print(0.5)
else:
  print((n//2+1)/n)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
def yaku(n):
  l=[]
  m=n
  for i in range(1,int((n)**(1/2))+1):
    if m%i==0:
      l.append(i)
      if m//i!=i:
        l.append(m//i)
  return l
l=yaku(a)
cd=[]
for i in l:
  if a%i==0:
    cd.append(i)
count=0
length=len(cd)
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
for i in range(length-1):
  for j in range(i+1,length):
    if gcd(cd[i],cd[j])==1:
      count+=1
print(count)
Problem p02970 (python)

Fixed submission:
n,d=map(int,input().split())
if n%(2*d+1)==0:
  print(n//(2*d+1))
else:
  print(n//(2*d+1)+1)

Buggy submission (verdict: Runtime Error):
n,d=map(int,input().split())
in n%(2*d+1)==0:
  print(n//(2*d+1))
else:
  print(n//(2*d+1)+1)
Problem p03018 (python)

Fixed submission:
w=input()
count=0
num=len(w)
w1=""
w+=" "
while count<num:
  if w[count]=="A":
    w1+="A"
    count+=1
  elif w[count]=="B":
    if w[count+1]=="C":
      w1+="D"
      count+=2
    else:
      w1+="B"
      count+=1
  else:
    w1+="C"
    count+=1
counta=0
ans=0
num=len(w1)
for i in range(num):
  if w1[i]=="A":
    counta+=1
  elif w1[i]=="D":
    ans+=counta
  else:
    counta=0
print(ans)

Buggy submission (verdict: Runtime Error):
w=list(input())
now=0
num=len(w)
w.append(" ")
count=0
while now<num:
  if w[now]!="A":
    now+=1
  else:
    if w[now+1]!="B":
      now+=1
    else:
      if w[now+2]!="C":
        now+=1
      else:
        w[now]="B"
        w[now+1]="C"
        w[now+2]="A"
        count+=1
        back=now-1
        b=True
        while back>0 and b=True:
          if w[back]!="A":
            b=False
          else:
            w[back]="B"
            w[back+1]="C"
            w[back+2]="A"
            count+=1
            back-=1
print(count)
Problem p03104 (python)

Fixed submission:
n,m=map(int,input().split())
lm=[]
m1=m
if m!=0:
  while m1!=0:
    lm.append(m1%2)
    m1=m1//2
else:
  lm=[0]
ln=[]
n1=n-1
if n!=0:
  while n1!=0:
    ln.append(n1%2)
    n1=n1//2
while len(ln)!=len(lm):
  ln.append(0)
if n!=0:
  lm1=[0 for i in range(len(lm))]
  ln1=[0 for i in range(len(ln))]
  if lm[0]!=lm[1]:
    lm1[0]=1
  if ln[0]!=ln[1]:
    ln1[0]=1
  for i in range(1,len(lm)):
    if lm[i]==1 and lm[0]==0:
      lm1[i]=1
  for i in range(1,len(ln)):
    if ln[i]==1 and ln[0]==0:
      ln1[i]=1
  lmn=[0 for i in range(len(lm))]
  for i in range(len(lm)):
    if lm1[i]==ln1[i]:
      pass
    else:
      lmn[i]=1
  s=1
  ss=0
  for i in lmn:
    ss+=s*i
    s*=2
  print(ss)
else:
  print(m)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
lm=[]
m1=m
if m!=0:
  while m1!=0:
    lm.append(m1%2)
    m1=m1//2
else:
  lm=[0]
ln=[]
n1=n-1
if n!=0:
  while n1!=0:
    ln.append(n1%2)
    n1=n1//2
while len(ln)!=len(lm):
  ln.append(0)
lm1=[0 for i in range(len(lm))]
ln1=[0 for i in range(len(ln))]
if lm[0]!=lm[1]:
  lm1[0]=1
if ln[0]!=ln[1]:
  ln1[0]=1
for i in range(1,len(lm)):
  if lm[i]==1 and lm[0]==0:
    lm1[i]=1
for i in range(1,len(ln)):
  if ln[i]==1 and ln[0]==0:
    ln1[i]=1
lmn=[0 for i in range(len(lm))]
for i in range(len(lm)):
  if lm1[i]==ln1[i]:
    pass
  else:
    lmn[i]=1
s=1
ss=0
for i in lmn:
  ss+=s*i
  s*=2
print(ss)
Problem p03207 (python)

Fixed submission:
n=int(input())
l=[]
s=0
for i in range(1,n+1):
 l.append(int(input()))
l.sort()
for i in l:
 s+=i
print(int(s-0.5*max(l)))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[]
p=0
for I in range(1,n+1):
 l.append(int(input())
l.sort()
for I in l:
 p+=I
print(p+max(l))
Problem p03209 (python)

Fixed submission:
n,x=map(int,input().split())
plist=[1]
blist=[1]
for i in range(n):
  plist.append(plist[-1]*2+1)
  blist.append(blist[-1]*2+3)
def patty(n,x):
  if n==0:
    return 1
  else:
    if x==1:
      return 0
    elif 1<x and x<=blist[n-1]+1:
      return patty(n-1,x-1)
    elif x==blist[n-1]+2:
      return plist[n-1]+1
    elif 2+blist[n-1]<x and 2*blist[n-1]+2>=x:
      return plist[n-1]+patty(n-1,x-2-blist[n-1])+1
    else:
      return plist[n]
print(patty(n,x))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=["p"]
i=0
while len(l)<x:
  i+=1
  l=["b"]+l+["p"]+l+["b"]
for j in range(n-i):
  l=["b"]+l
c=0
for i in range(x):
  if l[i]=="p":
    c+=1
print(c)

Buggy submission (verdict: Runtime Error):
n , k=map(int,input().split())
l="p"
b=0
for o in range(0,n):
 l="b"+l+"p"+l+"b"
p=list(l)
for t in range(0,k):
 if p[t]=="p":
  b+=1
print(b)

Buggy submission (verdict: Runtime Error):
n , k=map(int,input().split())
l="p"
b=0
for o in range(0,n):
 l="b"+l+"p"+l+"b"
p=list(l)
for t in range(0,k):
 if p[t]==b:
  pass
 elif p[t]==p:
  b+=1
print(b)
Problem p03329 (python)

Fixed submission:
n=int(input())
l6=[]
l9=[]
num6=6
num9=9
while num6<=n:
  l6.append(num6)
  num6*=6
while num9<=n:
  l9.append(num9)
  num9*=9
count=[0,1,2,3,4,5,1,2,3,1,2,3]
for i in range(12,n+1):
  min=100000
  for j in l6:
    if i-j<0:
      pass
    else:
      if min>count[i-j]+1:
        min=count[i-j]+1
  for j in l9:
    if i-j<0:
      pass
    else:
      if min>count[i-j]+1:
        min=count[i-j]+1
  count.append(min)
print(count[n])

Buggy submission (verdict: Runtime Error):
n=int(input())
num6=6
num9=9
while num6<=n:
  l.append(num6)
  num6*=6
while num9<=n:
  l.append(num9)
  num9*=9
count=[0,1,2,3,4,5,1,2,3,1,2,3]
for i in range(12,n+1):
  min=100000
  for j in l:
    if i-j<0:
      pass
    else:
      if min>count[i-j]+1:
        min=count[i-j]+1
  count.append(min)
print(count[n])
Problem p03426 (python)

Fixed submission:
h,w,d=map(int,input().split())
l={}
for i in range(h):
  l1=list(map(int,input().split()))
  for j in l1:
    l[j]=[l1.index(j)+1,i+1]
li=[]
for i in range(1,d+1):
  l11=[]
  c=0
  x=l[i][0]
  y=l[i][1]
  while i<=h*w:
    c+=abs(x-l[i][0])+abs(y-l[i][1])
    l11.append(c)
    x=l[i][0]
    y=l[i][1]
    i+=d
  li.append(l11)
q=int(input())
for i in range(q):
  a,b=map(int,input().split())
  r=a%d
  if r==0:
    print(li[d-1][b//d-1]-li[d-1][a//d-1])
  else:
    print(li[r-1][b//d]-li[r-1][a//d])

Buggy submission (verdict: Runtime Error):
h,w,d=map(int,input().split())
l={}
for i in range(h):
  l1=list(map(int,input().split()))
  for j in l1:
    l[j]=[l1.index(j)+1,i+1]
li=[]
for i in range(1,d+1):
  l11=[]
  c=0
  x=l[i][0]
  y=l[i][1]
  while i<=h*w:
    c+=abs(x-l[i][0])+abs(y-l[i][1])
    l11.append(c)
    x=l[i][0]
    y=l[i][1]
    i+=d
  li.append(l11)
q=int(input())
for i in range(q):
  a,b=map(int,input().split())
  r=a%d
  if r==0:
    print(li[d][b//d-1]-li[d][a//d-1])
  else:
    print(li[r-1][b//d]-li[r-1][a//d])
Problem p03724 (python)

Fixed submission:
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  l[a-1]+=1
  l[b-1]+=1
b=True
for i in range(n):
  if l[i]%2==1:
    b=False
if b:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  l[a-1]+=1
  l[b-1]+=1
b=True
for i in range(m):
  if l[i]%2!=1:
    b=False
if b:
  print("YES")
else:
  print("NO")
Problem p03834 (python)

Fixed submission:
l=list(input())
l[13]=" "
l[5]=" "
print("".join(l))

Buggy submission (verdict: Runtime Error):
l=list(input())
l[5]=""
l[12]=""
print(sum(l))
Problem p02711 (python)

Fixed submission:
s = input()
print("Yes" if '7' in s else "No")

Buggy submission (verdict: Runtime Error):
s = input()
print("YES" if '7' in s else "NO)
Problem p02712 (python)

Fixed submission:
from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:from __builtin__ import xrange as range;from future_builtins import ascii, filter, hex, map, oct, zip 

BUFSIZE = 8192;
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3: 
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n");ii = lambda: int(input());ll = lambda: list(map(int , input().split()));vv = lambda: map(int , input().split());pr = print
pl = lambda l: pr(" ".join(list(map(str,l))))
import math
def fun(n):
    tot = n * (n+1)
    tot//=2
    return tot

n = ii()
print(fun(n) - 3*fun(n//3) -5*fun(n//5) + 15*fun(n//15))

Buggy submission (verdict: Runtime Error):
input = lambda: sys.stdin.readline().rstrip("\r\n");ii = lambda: int(input());ll = lambda: list(map(int , input().split()));vv = lambda: map(int , input().split());pr = print
pl = lambda l: pr(" ".join(list(map(str,l))))
import math
def fun(n):
    tot = n * (n+1)
    tot//=2
    return

n = ii()
print(fun(n) - 3*fun(n//3) -5*fun(n//5) + 15*fun(n//15))
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()
if(n&1):
  print("No")
else:
  if(s[:n//2]==s[n//2:]):
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
if(n&1):
  print("No")
else:
  for i in range(n/2):
    if s[i]!=s[n+i]:
      print("No")
      break
  else:
    print("Yes")
Problem p03041 (python)

Fixed submission:
ll=lambda : list(map(int,input().split()))

[n,k]=ll()
s=input()
k-=1
s=list(s)
s[k]=s[k].swapcase()
print("".join(s))

Buggy submission (verdict: Runtime Error):
x=input()
aa=x[:2]
bb=x[3:]
aa=int(aa)
bb=int(bb)
if 0<aa<=12 and 0==bb:
	print("MMYY")
elif 0==aa and 0<bb<=12:
	print("YYMM")
elif 0<aa<=12 and 0<bb<=12:
	print("AMBIGUOUS")
elif 0<aa<=12:
	print("MMYY")
elif 0<bb<=12:
	print("YYMM")
else:
	print("NA")

Buggy submission (verdict: Runtime Error):
x=input()
aa=x[:2]
bb=x[3:]
aa=int(aa)
bb=int(bb)
if 0<aa<=12 and bb==0:
	print("MMYY")
elif aa==0 and 0<bb<=12:
	print("YYMM")
elif 0<aa<=12 and 0<bb<=12:
	print("AMBIGUOUS")
elif 0<aa<=12:
	print("MMYY")
elif 0<bb<=12:
	print("YYMM")
else:
	print("NA")

Buggy submission (verdict: Runtime Error):
x=input()
aa=x[:2]
bb=x[3:]
aa=int(aa)
bb=int(bb)
if 0<aa<=12 and bb==0:
	print("MMYY")
if aa==0 and 0<bb<=12:
	print("YYMM")
if 0<aa<=12 and 0<bb<=12:
	print("AMBIGUOUS")
elif 0<aa<=12:
	print("MMYY")
elif 0<bb<=12:
	print("YYMM")
else:
	print("NA")
Problem p02688 (python)

Fixed submission:
NK = list(map(int, input().split()))
ans = [0]*NK[0]

for i in range(0,NK[1]):
  d = int(input())
  table  = list(map(int, input().split()))
  for j in range(1,NK[0]+1):
    if table.count(j) != 0:
      ans[j-1] = 1
print(NK[0]-sum(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())
ans = [1]*N

for i in range(0,K):
  d = int(input())
  table  = list(map(int, input().split()))
  for j in range(0,N):
    if table.count(j) == 0:
      ans[j] = 0
print(1-sum(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())
ans = [1]*N

for i in range(0,K):
  d = int(input())
  table  = list(map(int, input().split()))
  for j in range(0,N):
    if table.count(j) != 0:
      ans[j] = 0
print(sum(ans))

Buggy submission (verdict: Runtime Error):
N = input()
K = input()
ans = [1]*N

for i in range(0,K):
  d = int(input())
  table  = list(map(int, input().split()))
  for j in range(0,N):
    if table.count(j) != 0:
      ans[j] = 0
print(sum(ans))
Problem p02689 (python)

Fixed submission:
N,M = list(map(int, input().split()))


hights = list(map(int, input().split()))
ans = [1]*N

for i in range(0,M):
  a,b = list(map(int, input().split()))
  if hights[a-1] > hights[b-1]:
    ans[b-1] = 0
  elif hights[a-1] < hights[b-1]:
    ans[a-1] = 0
  else:
    ans[a-1] = 0
    ans[b-1] = 0

print(sum(ans))

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


hights = list(map(int, input().split()))
ans = [1]*N

for i in range(0,M):
  a,b = list(map(int, input().split()))
  if hights[a-1] > hights[b-1]:
    ans[table[1]] = 0
  elif hights[a-1] < hights[b-1]:
    ans[a-1] = 0
  else:
    ans[a-1] = 0
    ans[b-1] = 0

print(sum(ans))

Buggy submission (verdict: Runtime Error):
NM = list(map(int, input().split()))
N = NM[0]
M = NM[1]

hights = list(map(int, input().split()))
ans = [1]*N

for i in range(0,M):
  table = list(map(int, input().split()))
  if hights[table[0]-1] > hights[table[1]-1]:
    ans[table[1]] = 0
  elif hights[table[0]-1] < hights[table[1]-1]:
    ans[table[0]-1] = 0
  else:
    ans[table[0]-1] = 0
    ans[table[1]-1] = 0

print(sum(ans))

Buggy submission (verdict: Runtime Error):
NM = list(map(int, input().split()))
N = NM[0]
M = NM[1]

def lower(n,m):
  if n > m:
    return m
  else:
    return n


hights = list(map(int, input().split()))
ans = [1]*N

for i in range(0,M):
  table = list(map(int, input().split()))
  if hights[table[0]-1] > hights[table[1]-1]:
    ans[table[1]] = 0
  elif hights[table[0]-1] < hights[table[1]-1]:
    ans[table[0]-1] = 0
  else:
    ans[table[0]-1] = 0
    ans[table[1]-1] = 0

print(sum(ans))
Problem p02990 (python)

Fixed submission:
from operator import mul
from functools import reduce

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

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(lambda x,y: x*y ,range(n,n-r,-1))
    under = reduce(mul,range(1,r+1))
    return over // under %(1000000000+7)

for i in range(1,k+1):
    c=0
    if i<=n-k+1:
        c=cmb(n-k+1,i)*cmb(k-1,i-1)%(1000000000+7)
    print("{}".format(c))

Buggy submission (verdict: Runtime Error):
n,k =map(int,input().split())
a=[-1 for x in range(n)]

def kaijo(x):
	if x<=1:
		return 1
	if a[x-1]==-1:
		a[x-1]=x*kaijo(x-1)
	return a[x-1]

for i in range(1,k+1):
	c=kaijo(k-1)/kaijo(k-i)/kaijo(i-1)*kaijo(n-k+1)/kaijo(i)/kaijo(n-k+1-i)
	print('{}'.format(c))

Buggy submission (verdict: Runtime Error):
def kaijo(x):
	if x<=1:
		return 1
	return x*kaijo(x-1)
	
n,k =map(int,input().split())
for i in range(1,k+1):
	c=kaijo(k-1)/kaijo(k-i)/kaijo(i-1)*kaijo(n-k+1)/kaijo(i)/kaijo(n-k+1-i)
	print('{}'.format(c))
Problem p02790 (python)

Fixed submission:
num=[int(e) for e in input().split()]
A=str(num[0])
B = str(num[1])

if num[0]>=num[1]:
  for i in range(num[0]-1):
    B+=str(num[1])
  print(B)
else:
  for i in range(num[1]-1):
      A+=str(num[0])
  print(A)

Buggy submission (verdict: Runtime Error):
num=[int(e) for e in input().split()]
A=str(num[0])
B=str(num[1])
if num[0]>=num[1]:
  for i in range(num[0]-1):
    B+=str(num[1])
  print(B)
else:
  for i in range(num[1]-1):
	A+=str(num[0])
  print(A)
Problem p02829 (python)

Fixed submission:
A=int(input())
B = int(input())
C = A + B
list = {3: '3', 4: '2', 5: '1'}
print(list[C])

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a == 1 and b == 2) or (a == 2 and b == 1):
    print(3)
elif (a == 1 and b == 3)or(a==3 and b==1):
    print(2)
elif (a == 2 and b == 3) or (a == 3 and b == 2):
    print(1)
Problem p02880 (python)

Fixed submission:
N = int(input())
no=0
for i in range(1, 10):
    for j in range(1, 10):
        if ((i * j) == N):
            print('Yes')
            no += 1
            break
    if no == 1:
        break
if no==0:
    print('No')

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())
for i in range(1, 10):
    for j in range(1, 10):
        if i * j == N:
            print('Yes')
            sys.exit(1)
print('No')
Problem p02688 (python)

Fixed submission:
N, K = input().strip().split(" ")
N = int(N)
K = int(K)
checkbox = [False for i in range(N)]
for k in range(K):
    input()
    seq = input().strip().split(" ")
    for j in seq:
        checkbox[int(j)-1] = True
print(checkbox.count(False))

Buggy submission (verdict: Runtime Error):
N,K=input().strip().split(" ")
N=int(N)
K=int(K)
checkbox=[False for i in range(N)]
for k in range(K):
  input()
  seq=input().strip().split(" ")
  for j in seq:
    checkbox[i]=True
print(checkbox.count(False))
Problem p02689 (python)

Fixed submission:
## import

## function definition 

## main process
if __name__ == '__main__':
    
    ## input
    N, M = map(int,input().split())
    HEIGHT_LIST = list(map(int,input().split())) 
    ROAD_LIST = []
    for j in range(M): 
        ROAD_LIST.append(
            tuple(map(int,input().split()))
        )
    
    ## business logic
    ans = [1] * N
    for j in list(range(M)):
        point_a = ROAD_LIST[j][0]
        point_b = ROAD_LIST[j][1]

        point_a -= 1
        point_b -= 1

        height_a = HEIGHT_LIST[point_a]
        height_b = HEIGHT_LIST[point_b]

        if height_a < height_b:
            ans[point_a] = 0
        elif height_a > height_b:
            ans[point_b] = 0
        else:
            ans[point_a] = 0
            ans[point_b] = 0

    ## output
    print(sum(ans))

Buggy submission (verdict: Runtime Error):
## import

## function definition 

## main process
if __name__ == '__main__':
    
    N, M = map(int,input().split())
    HEIGHT_LIST = list(map(int,input().split())) 
    
    ans = [1] * N
    for j in range(M):
        a, b = map(int,input().split())
        a -= 1
        b -= 1
        height_a = HEIGHT_LIST[a]
        height_b = HEIGHT_LIST[b]

        if height_a < height_b:
            ans[point_a] = 0
        elif height_a > height_b:
            ans[point_b] = 0
        else:
            ans[point_a] = 0
            ans[point_b] = 0

    print(sum(ans))

Buggy submission (verdict: Runtime Error):
## import

## function definition 

## main process
if __name__ == '__main__':
    
    N, M = map(int,input().split())
    HEIGHT_LIST = list(map(int,input().split())) 
    
    ans = [1] * N
    for j in range(M):
        a, b = map(int,input().split())
        a -= 1
        b -= 1
        height_a = HEIGHT_LIST[a]
        height_b = HEIGHT_LIST[b]

        if height_a < height_b:
            ans[point_a] = 0
        elif height_a > height_b:
            ans[point_b] = 0
        else:
            ans[point_a] = 0
            ans[point_b] = 0
    print(sum(ans))

Buggy submission (verdict: Runtime Error):
    ## input
    N, M = map(int,input().split())
    HEIGHT_LIST = list(map(int,input().split())) 
    ROAD_LIST = []
    for j in range(M): 
        ROAD_LIST.append(
            set(map(int,input().split()))
        )
    
    ## business logic
    COUNT = 0
    
    for i in list(range(1, N+1)):
        unioned_i = set([])
        for k in ROAD_LIST:
            if i in k:
                unioned_i = unioned_i | k
        if len(unioned_i) == 0:
            COUNT = COUNT + 1
            continue
        HIGHT_i = HEIGHT_LIST[i-1]
        if HIGHT_i >= max(
            [ HEIGHT_LIST[l-1] for l in list(unioned_i) ]
        ):
            COUNT = COUNT + 1
    
    ## output
    print(COUNT)
Problem p02959 (python)

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


for i in range(n):
  if(b[i]<=a[i]):
    cnt+=b[i]
    a[i]-=b[i]
  elif(b[i]>a[i] and a[i]+a[i+1]>b[i]):
    cnt+=a[i]
    cnt+=b[i]-a[i]
    a[i+1]-=b[i]-a[i]
    a[i]=0
  else:
    cnt+=a[i]+a[i+1]
    a[i]=0
    a[i+1]=0
    
  #print(a)
    
print(cnt)

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


for i in range(n):
  if(b[i]<=a[i]):
    cnt+=b[i]
    a[i]-=b[i]
  elif(b[i]>a[i] and a[i]+a[i+1]>b[i]):
    cnt+=a[i]
    cnt+=b[i]-a[i]
    a[i+1]-=b[i]-a[i]
    a[i]=0
  else:
    cnt+=a[i]+a[i+1]
    a[i]=0
    a[i+1]=0
    
  print(a)
    
print(cnt)

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


for i in range(n):
  if(b[i]<=a[i]):
    cnt+=b[i]
    a[i]-=b[i]
  if(b[i]>a[i] and a[i]+a[i+1]>b[i]):
    cnt+=a[i]
    cnt+=b[i]-a[i]
    a[i+1]-=b[i]-a[i]
    a[i]=0
  else:
    cnt+=a[i]+a[i+1]
    a[i]=0
    a[i+1]=0
    
  print(a)
    
print(cnt)