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

Fixed submission:
X, Y = input().split()
print(Y+X)

Buggy submission (verdict: Runtime Error):
S, T = map(input().split())
print(S+T)
Problem p02886 (python)

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

ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += arr[i]*arr[j]
print(ans)

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

ans = 0
for i in range(N):
    for i in range(i+1,N):
        ans += i*J

print(ans)
Problem p03161 (python)

Fixed submission:
N, K = map(int, input().split())
ashi = list(map(int, input().split()))
 
if N<=K:    
    print(abs(ashi[-1]-ashi[0]))
    exit()
 
arr = [0]*N
for i in range(1,K+1,1):
    arr[i] = abs(ashi[i]-ashi[0])
 
 
for i in range(K+1,N,1):
    x = arr[i-1]+abs(ashi[i]-ashi[i-1])
    for j in range(1,K+1,1):
        if arr[i-j]+abs(ashi[i]-ashi[i-j]) < x:
            x=arr[i-j]+abs(ashi[i]-ashi[i-j])
    arr[i] = x
 
print(arr[-1])

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

if N<=K:    
    print(abs(ashi[N]-ashi[0]))
    exit()

arr = [0]*N
for i in range(1,K+1,1):
    arr[i] = abs(ashi[i]-ashi[0])


for i in range(K+1,N,1):
    x = arr[i-1]+abs(ashi[i]-ashi[i-1])
    for j in range(1,K+1,1):
        if arr[i-j]+abs(ashi[i]-ashi[i-j]) < x:
            x=arr[i-j]+abs(ashi[i]-ashi[i-j])
    arr[i] = x

print(arr[N-1])
Problem p03280 (python)

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

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

Fixed submission:
H, W = map(int, input().split())
arr = [input() for _ in range(H)]

for i in range(H):
    for j in range(W):
        if arr[i][j] == '#':
            flg =False
            if i-1>=0:
                if arr[i-1][j] == '#':
                    flg = True
            if j-1>=0:
                if arr[i][j-1] == '#':
                    flg = True
            if i+1<H:
                if arr[i+1][j] == '#':
                    flg = True
            if j+1<W:
                if arr[i][j+1] == '#':
                    flg = True
            if flg == False:
                print('No')
                exit()

print('Yes')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
arr = [input() for _ in range(H)]

for i in range(H):
    for j in range(W):
        if arr[i][j] == '#':
            flg =False
            if i-1>=0:
                if arr[i-1][j] == '#':
                    flg = True
            if j-1>=0:
                if arr[i][j-1] == '#':
                    flg = True
            if i+1<W:
                if arr[i+1][j] == '#':
                    flg = True
            if j+1<H:
                if arr[i][j+1] == '#':
                    flg = True
            if flg == False:
                print('No')
                exit()

print('Yes')
Problem p03455 (python)

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

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

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

if a*b % 2 =0:
  print("Even")
else:
  print("Odd")
Problem p03852 (python)

Fixed submission:
c = input()
if c in ('a','i','u','e','o'):
    print('vowel')
else:
    print('consonant')

Buggy submission (verdict: Runtime Error):
c = input()
if c in (a,i,u,e,o):
    print('vowel')
else:
    print('consonant')
Problem p02553 (python)

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

print(max(a*c,a*d,b*c,d*b))

Buggy submission (verdict: Runtime Error):
-1000000000 0 -1000000000 0
Problem p04030 (python)

Fixed submission:
s = str(input())
a = []

for i in s:
    if i == '0':
        a.append('0') 
    elif i == '1':
        a.append('1')
    elif i == 'B':
        if len(a) ==0:
            continue
        else:
            del a[-1]
        

print(''.join(a))

Buggy submission (verdict: Runtime Error):
s = str(input())
a = []

for i in s:
    if i == '0':
        a.append('0') 
    elif i == '1':
        a.append('1')
    elif i == 'B':
        del a[-1]
        

print(''.join(a))
Problem p02582 (python)

Fixed submission:
s=input()
count=0
if s.count('R')==1:
  print(1)
elif s.count('R')==3:
  print(3)
elif s.count('R')==2:
  if s[1]=="R":
    print(2)
  else:
    print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
x,k,d=map(int,input().split())
x=abs(x)

semin=x//d #最小に行くための個数
if semin%2==0:
  minb=0 #最小に行くための個数が偶数
else:
  minb=1 #最小に行くための個数が奇数

if semin>k:
  print(abs(x-k*d))
else:
  k=k-semin
  if k%2==0:
    ans=0 #偶数
  else:
    ans=1 #奇数
  if ans==0:#ｋが偶数の時
    if minb==0:
      print(abs(x-d*semin))
    else:
      print(min(abs((x-(d*semin))-d),abs(x-d*semin)))
  else:#ｋが奇数の時
    if minb==0:
      print(abs((x-(d*semin))-d))
    else:
      print(abs(x-d*semin))
Problem p02675 (python)

Fixed submission:
n=list(input())
if n[-1]=='3':
  print('bon')
elif n[-1]=='0' or n[-1]=='1' or n[-1]=='6' or n[-1]=='8':
  print("pon")
else :
  print("hon")

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m=map(int,input().split())
tyok=h*30+m*0.5
tank=m*6
sa=abs(tyok-tank)
c=a**2+b**2-2*a*b*math.cos(math.radians(sa))
print(math.sqrt(c))

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m=map(int,input().split())
tyok=h*30+m*0.5
tank=m*6
sa=abs(tyok-tank)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(sa))))
Problem p02730 (python)

Fixed submission:
s=input()
n=len(s)
count=0
a=(n-1)//2
b=(n+3)//2
for i in range(n//2):
  if s[i]!=s[-abs(i+1)]:
    count+=1
    
for i in range(a//2):
  c=ord(s[i])
  d=ord(s[(a-1-i)])
  if c!=d:
    count+=1

for i in range((n-b+1)//2):
  c=ord(s[-(i+1)])
  d=ord(s[b-1+i])
  if c!=d:
    count+=1

if count!=0:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
count=0
a=(n-1)//2
b=(n+3)//2
for i in range(n//2):
  if s[i]!=s[-abs(i+1)]:
    count+=1
    
for i in range(a//2):
  c=ord(s[i])
  d=ord(s[(a-1-i)])
  if c!=d:
    count+=1

for i in range((n-b+1)//2):
  c=ord(s[n-i])
  d=ord(s[b-1+i])
  if c!=d:
    count+=1

if count!=0:
  print('No')
else:
  print('Yes')
Problem p02731 (python)

Fixed submission:
l=int(input())
i=l/3
print(i**3)

Buggy submission (verdict: Runtime Error):
l=int(input())
print({:.10d}.format(l/3))
Problem p02747 (python)

Fixed submission:
s=str(input())
a=len(s)
b=['hi','hihi','hihihi','hihihihi','hihihihihi']
if a%2!=0:
  print('No')
elif s in b:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s=str(input())
a=len(s)
b=[hi,hihi,hihihi,hihihihi,hihihihihi]
if a%2!=0:
  print('No')
elif s in b:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s=str(input())
a=len(s)
if a%2!=0:
  print('No')
elif s=[hi,hihi,hihihi,hihihihi,hihihihihi]:
  print('Yes')
else:
  print('No')

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

for i in range(10):
  if s[i]=='h' and s[i+1]=='i':
    print('Yes')
    exit()
  
print('No')

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

for i in range(10):
  if s[i]==h and a[i+1]==i:
    print('Yes')
    exit()
    
print('No')
Problem p02760 (python)

Fixed submission:
a=[list(map(int,input().split()))for _ in range(3)]
n=int(input())
b=[int(input())for _ in range(n)]
ans='No'
for i in range(3):
  for j in range(3):
    for k in range(n):
      if a[i][j]==b[k]:
         a[i][j]=0
      
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = "Yes"
    if a[0][i] + a[1][i] + a[2][i] == 0:
        ans = "Yes"
if a[0][0] + a[1][1] + a[2][2] == 0:
    ans = "Yes"
if a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
a=[list(map(int,input().split()))for _ in range(3)]
n=int(input())
b=[int(input())for _ in range(n)]
ans='No'
for i in range(3):
  for j in range(3):
    for k in range(n):
      if a[i][j]==b[k]:
         a[i][j]=[0,0]
      
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = "Yes"
    if a[0][i] + a[1][i] + a[2][i] == 0:
        ans = "Yes"
if a[0][0] + a[1][1] + a[2][2] == 0:
    ans = "Yes"
if a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
a=[list(map(int,input().split()))for i in range(3)]
n=int(input())
b=[int(input())for i in range(n)]
ans='No'
for i in range(3):
  for j in range(3):
    for k in range(n):
      if a[i][j]==b[k]:
         a[i][j]=[0,0]
      
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = "Yes"
    if a[0][i] + a[1][i] + a[2][i] == 0:
        ans = "Yes"
if a[0][0] + a[1][1] + a[2][2] == 0:
    ans = "Yes"
if a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
A=list(map(int,input().spliy()))
B=list(map(int,input().spliy()))
C=list(map(int,input().spliy()))
n=input()
for i range(n):
  D[i]=int(input())

Acount=0 
Bcount=0
Ccount=0
  
for i in range(0,n):
  if A[0]==D[i]:
    Acount+=1
  if A[1]==D[i]:
    Acount+=1
  if A[2]==D[i]:
    Acount+=1
  if(Acpunt)==3:
    exit()
for i in range(0,n):
  if B[0]==D[i]:
    Bcount+=1
  if B[1]==D[i]:
    Bcount+=1
  if B[2]==D[i]:
    Bcount+=1
  if(Bcpunt)==3:
    exit()
for i in range(0,n):
  if C[0]==D[i]:
    Ccount+=1
  if C[1]==D[i]:
    Ccount+=1
  if C[2]==D[i]:
    Ccount+=1
  if(Ccpunt)==3:
    exit()
Problem p02767 (python)

Fixed submission:
n=int(input())
x=list(map(int,input().split()))
x=sorted(x)
ans=10**8
count=0
for i in range(x[0],x[-1]+1):
  count=0
  for j in range(n):
    count+=(x[j]-i)**2
  if ans>count:
    ans=count
    
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))
count=0
max=0
min=0
sum=0

for i in range(n):
  count+=x[i]
  if max<x[i]:
    max=x[i]
  elif min>x[i]:
    min=x[i]
  num=max+min

p=round(count/round(num/2))

for i in range(0,n):
  power=(x[i]-p)**2
  sum+=power

print(sum)
Problem p02772 (python)

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

lst=0
  
for i in range(N):
  if A[i]%2==0:
    if A[i]%3!=0 and A[i]%5!=0:
      lst+=1
      break

    
if lst==1:
  print('DENIED')
else:
  print('APPROVED')

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

count=0
  
for i=0 in range(N):
  if A[i]%2==0:
    if A[i]%3==0 or A[i]%5==0:
      print('APPROVED')
      count=1
      break
  elif:
    continue
    
if count=0:
  print('DENIED')
Problem p02783 (python)

Fixed submission:
H,A=map(int,input().split())
count=0

while H>0:
  H=H-A
  count+=1

print(count)

Buggy submission (verdict: Runtime Error):
H,A=int(input().split())
count=0

while H>=0:
  H-=A
  count+=1

print(A)
Problem p02811 (python)

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

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
count=0
for i in range(n):
  if i<=48:
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      count+=1
    
print(count)
Problem p02812 (python)

Fixed submission:
n=int(input())
s=list(input())
count=0
for i in range(n-2):
  if i<=48 :
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      count+=1
    
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
count=0

for i in range(n):
  if i<=48 :
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      count+=1
    
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
count=0
for i in range(n):
  if i<=48:
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      count+=1
    
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
count=0
for i in range(n):
  if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
    count+=1
    
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
count=0
for i in range(n):
  if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
    count+=1
    
print(count)
Problem p02971 (python)

Fixed submission:
n=int(input())
a=[]
for i in range(n):
  b=int(input())
  a.append(b)
s=a.copy()
a=sorted(a,reverse=True)

if a[0]==a[1]:
  for i in range(n):
    print(a[0])
  exit()
for i in range(n):
  if s[i]==a[0]:
    print(a[1])
  else:
    print(a[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
  b=int(input())
  a.append(b)
s=a.copy()
for i in range(n):
  if s[i]==max(s):
    print(s[i])
  else:
    del s[i]
    print(max(s))
Problem p02995 (python)

Fixed submission:
import math
a,b,c,d=map(int,input().split())
count=b-a+1

A=a-1
l=c*d//math.gcd(c,d)
acou=(A//c)+(A//d)-int((A//l))
bcou=(b//c)+(b//d)-int((b//l))

print(count-(bcou-acou))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
zen=int(b-a)
c=int(zen//c)
d=int(zen//d)
kasa=int(zen/(c*d))

ans=zen-c-d+kasa

print(ans)
Problem p03110 (python)

Fixed submission:
n=int(input())
x=[0]*n
u=[0]*n
k=0
b=0
for i in range(n):
  x[i],u[i]=map(str,input().split())
  x[i]=float(x[i])

for i in range(n):
  if u[i]=='JPY':
    k+=x[i]
  else:
    b+=x[i]
    
b=b*380000
print(k+b)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=0
b=0
for i in range(n):
  x,u=input().split()
  x=float(x)

for i in range(n):
  if u[i]=='JPY':
    k+=x[i]
  else:
    b+=x[i]*380000
print(k+b)
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):
n=int(input)
if n==1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)
Problem p03284 (python)

Fixed submission:
n,k=map(int,input().split())
if n%k==0:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
n=int(input())
for i in range(27):
  for j in range(27):
    if 4*i+7*j==n:
      print('Yes')
      exit()
print('No')
Problem p02658 (python)

Fixed submission:
n = int(input())
res = 1
ls = input().split(' ')
list.sort(ls)
if int(ls[0]) == 0:
    print(0)
    exit()
for a in ls:
    res = res * int(a)
    if res > 1000000000000000000:
        print(-1)
        exit()
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
res = 1
for i in range(n):
    a = int(input())
    res = res * a
    if res > 1000000000000000000:
        print(-1)
        exit()
print(res)
Problem p02641 (python)

Fixed submission:
import sys

x, n = map(int, input().split())
if n == 0:
    print(x)
    sys.exit()
else:
    p = list(map(int, input().split()))

a = []
b = []

for i in range(0, 102):
    if i not in p:
        a.append((x - i)**2)
        b.append(i)
ans = min(a)
bb = a.index(ans)
print(b[bb])

Buggy submission (verdict: Runtime Error):
import sys

x, n = map(int, input().split())
if n == 0:
    print(x)
    sys.exit()
else:
    p = list(map(int, input().split()))
if x == 1:
    print(0)
    sys.exit()

a = []
b = []

for i in range(1, 100):
    if i not in p:
        a.append(abs(x - i))
        b.append(i)
ans = min(a)
bb = a.index(ans)
print(b[bb])
Problem p02645 (python)

Fixed submission:
s = str(input())
a = s[:3]
print(a)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 9)
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

for tt in range(1,t+1):
    res = (w - v) * tt + (b - a)
    if res == 0:
        print('YES')
        sys.exit()

print('NO')

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 9)
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

# if a>=b or w>=v:
#     print('NO')
#     sys.exit()
for tt in range(1,t+1):
    res = (w - v) * tt + (b - a)
    if res == 0:
        print('YES')
        sys.exit()

print('NO')
Problem p02658 (python)

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)

    if 0 in A:
        print('0')
        return
    prod=1
    for a in A:
        prod*=a
        if prod> 1000000000000000000:
            print('-1')
            return
    print(prod)

ans=main()

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())

a=list(map(int,input().split()))
import functools
import operator

pre = functools.reduce(operator.mul, a)
if pre <= 1000000000000000000:
    print(pre)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())

a=list(map(int,input().split()))
c=np.array(a)
pre = abs(np.prod(c))
if pre <= 1000000000000000000:
    print(pre)
else:
    print(-1)
Problem p02664 (python)

Fixed submission:
T=str(input())
cnt=0
cc=[]
count=len(T)
for i in T:
    if i=='P':
        cnt=1
        cc.append('P')

    elif i=='D':
        cnt=0
        cc.append('D')
    else:
        if count == i:
            cc.append('D')

        elif cnt==1:
            cnt=0
            cc.append('D')
        else:
            cnt=1
            cc.append('?')

ccc=1
for i in cc:
    if i=='P':
        print('P',end='')
    elif i=='D':
        print('D',end='')
    else:
        if ccc==len(cc):
            print('D')
        elif cc[ccc]=='P':
            print('D',end='')
        else:
            print('P',end='')
    ccc+=1

Buggy submission (verdict: Runtime Error):
T=str(input())
cnt=0
cc=[]
count=len(T)
for i in T:
    if i=='P':
        cnt=1
        cc.append('P')

    elif i=='D':
        cnt=0
        cc.append('D')
    else:
        if count == i:
            cc.append('D')

        elif cnt==1:
            cnt=0
            cc.append('D')
        else:
            cnt=1
            cc.append('?')

ccc=1
for i in cc:
    if i=='P':
        print('P',end='')
    elif i=='D':
        print('D',end='')
    else:
        if i==len(cc):
            print('D')
        elif cc[ccc]=='P':
            print('D',end='')
        else:
            print('P',end='')
    ccc+=1

Buggy submission (verdict: Runtime Error):
T=str(input())
cnt=0
cc=[]
count=len(T)
for i in T:
    if i=='P':
        cnt=1
        cc.append('P')

    elif i=='D':
        cnt=0
        cc.append('D')
    else:
        if count == i:
            cc.append('D')

        elif cnt==1:
            cnt=0
            cc.append('D')
        else:
            cnt=1
            cc.append('?')

ccc=1
for i in cc:
    if i=='P':
        print('P',end='')
    elif i=='D':
        print('D',end='')
    else:
        if cc[ccc]=='P':
            print('D',end='')
        else:
            print('P',end='')
    ccc+=1
Problem p02899 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
t=[0]*N
for idx,i in enumerate(A):
    t[i-1]=idx+1

print(*t)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
t=[0]*N
for idx,i in enumerate(N):
    t[i-1]=idx+1
    
    print(t[i],end=' ')
Problem p03262 (python)

Fixed submission:
import  math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N,X=map(int,input().split())
x=sorted(list((map(int,input().split()))))
y=[abs(i-X) for i in x ]
print(gcd_list(y))

Buggy submission (verdict: Runtime Error):
import numpy as np
import  math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N,X=map(int,input().split())
x=list(sorted(map(int,input().split())))
diff=np.diff(x)
print(gcd_list(diff))
Problem p03495 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0 for i in range(N + 1)]

for a in A:
    B[a] += 1
nums = [b for b in B if b > 0]
nums.sort()
n = len(nums)
print(0 if n<=K else sum(nums[:n - K]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
# B = [0 for i in range(N + 1)]
B=[]
for a in A:
    B[a] += 1
# nums = [b for b in B if b > 0]
nums=B.sort()
n = len(nums)
print(0 if n<=K else sum(nums[:n - K]))
Problem p03944 (python)

Fixed submission:
W,H,N = map(int,input().split())
w = W*[1]
h = H*[1]

for n in range(N):
  x,y,a = map(int,input().split())
  if a == 1:
    w[:x] = x*[0]
  elif a == 2:
    w[x:] = (W-x)*[0]
  elif a == 3:
    h[:y] = y*[0]
  else:
    h[y:] = (H-y)*[0]

print(w.count(1)*h.count(1))

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

W,H,N = map(int,input().split())
l = np.zeros((H,W)) 

for i in range(N):
  x,y,a = map(int,input().split())

  if a==1:
    l[:,:x] = 1
    #print(l[:,x:])
  elif a==2:
    l[:,x:] = 1
  elif a==3:
    l[:y,:] = 1
  elif a==4:
    l[y:,:] = 1
print(H*W-int(l.sum()))
Problem p02677 (python)

Fixed submission:
import math

def calc_angle(h, m):
	# validate the input
	if (h < 0 or m < 0 or h > 12 or m > 60):
		print('Wrong input')

	if (h == 12):
		h = 0
	if (m == 60):
		m = 0

	# Calculate the angles moved by
	# hour and minute hands with
	# reference to 12:00
	hour_angle = 0.5 * (h * 60 + m)
	minute_angle = 6 * m

	# Find the difference between two angles
	angle = abs(hour_angle - minute_angle)

	# Return the smaller angle of two
	# possible angles
	angle = min(360 - angle, angle)

	return angle

def resolve():
	a, b, h, m = map(int, input().split())
	ang = calc_angle(h, m)
	radi = math.radians(ang)
	v = (a**2 + b**2 - 2*a*b*math.cos(radi))**0.5
	print(v)
resolve()

Buggy submission (verdict: Runtime Error):
import math

def radi(n):
	return n * math.pi / 180

def resolve():
	a, b, h, m = map(int, input().split())
	hd = radi(h*30+30*(m/60))
	md = radi(360*(m/60))
	hx = a * math.cos(hd)
	hy = a * math.sin(hd)
	mx = b * math.cos(md)
	my = b * math.sin(md)
	x = abs(hx - mx)
	y = abs(hy - my)
	v = math.sqrt(x**2 + y**2)
	print(v)
rseolve()

Buggy submission (verdict: Runtime Error):
def radi(deg):
    return deg * (math.pi / 180)

def resolve():
    ha, hb, h, m = map(int, input().split())
    hr = radi(30*h+(m/2))
    mr = radi(6*m)
    hx = ha * math.cos(hr)
    mx = hb * math.cos(mr)
    hy = ha * math.sin(hr)
    my = hb * math.sin(mr)
    v = (abs(hx - mx)**2 + abs(hy - my)**2)**0.5
    print(v)
resolve()
Problem p02683 (python)

Fixed submission:
def resolve():
	n, m, x = map(int, input().split())
	books = [list(map(int, input().split())) for _ in range(n)]

	pay = float('inf')
	for i in range(1 << n):
		selected = []
		for j in range(n):
			if i >> j & 1:
				selected.append(j)
		rem = [0] * m
		tmp_pay = 0
		for j in selected:
			tmp_pay += books[j][0]
			for k in range(1, m+1):
				rem[k-1] += books[j][k]
		done = True
		for j in range(m):
			if rem[j] < x:
				done = False
		if done:
			pay = min(pay, tmp_pay)
	if pay == float('inf'):
		print(-1)
	else:
		print(pay)
resolve()

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest

sys.setrecursionlimit(10**5)
def search(n, step, rec, seq, k):
	if rec[n] != -1:
		c = step - rec[n]
		sim = (k - rec[n]) % c
		v = n
		for i in range(sim):
			v = seq[v-1]
		print(v)
		return
	rec[n] = step
	search(seq[n-1], step + 1, rec, seq, k)

def resolve():
	n, k = map(int, input().split())
	seq = list(map(int, input().split()))
	rec = [-1]*(n+1)
	search(1, 0, rec, seq, k)
resolve()
Problem p02687 (python)

Fixed submission:
def resolve():
	s = input()
	if s == 'ABC':
		print('ARC')
	else:
		print('ABC')
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	x = int(input())
	for i in range(1000):
		for j in range(-1000, 1000):
			if i**5 - j**5 == x:
				print(i, j)
				return

resolve()
Problem p02705 (python)

Fixed submission:
def resolve():
	r = int(input())
	print(2 * r * 3.14159265358)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	r = int(input())
	print(2 * r * math.pi)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	r = int(input())
	print(2 * r * math.pi)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n, m = map(int, input().split())
	a = list(map(int, input().split()))
	print(n-sum(a) if n-sum(a) > -1 else -1)
resolve()