Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
sw=[[]*m]
for _ in range(m):
    temp=list(map(int,input().split()))
    sw[_]=temp[1:]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    temp=[0]*n
    for j in range(n):
        if i&1: temp[j]=1
        i>>=1
    flag=1
    for l,s in enumerate(sw):
        cnt=0
        for k in s:
            if temp[k-1]==1: cnt+=1
        if p[l]!=cnt%2:
            flag=0
            break
    if flag: ans+=1
print(ans)

Fixed submission:
n,m=map(int,input().split())
sw=[[] for _ in range(m)]
for _ in range(m):
    temp=list(map(int,input().split()))
    sw[_]=temp[1:temp[0]+1]
p=list(map(int,input().split()))

ans=0
for i in range(2**n):
    temp=[0]*n
    for j in range(n):
        if i&1: temp[j]=1
        i>>=1
    flag=1
    for l,s in enumerate(sw):
        cnt=0
        for k in s:
            if temp[k-1]==1: cnt+=1
        if p[l]!=cnt%2:
            flag=0
            break
    if flag: ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int,input().split())
ans = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        temp = n-r*i-g*j
        if temp>=0 and temp%b==0: ans+=1
print(ans)

Fixed submission:
r,g,b,n = map(int,input().split())
ans = 0
for i in range(n//r+1):
    for j in range((n-r*i)//g+1):
        if (n-r*i-g*j)%b==0:
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
diff=[]
heapq.heapify(diff)
if n>=m:
    print(0)
else:
    for i in range(m-1):
        heapq.heappush(diff,x[i]-x[i+1]-1)
    temp=0
    for _ in range(n-1):
        temp-=heapq.heappop(diff)
        #print(-heapq.heappop(diff))
print(x[m-1]-x[0]+1-temp)

Fixed submission:
import heapq
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
diff=[]
heapq.heapify(diff)
if n>=m:
    print(0)
else:
    for i in range(m-1):
        heapq.heappush(diff,x[i]-x[i+1]+1)
    temp=0
    for _ in range(n-1):
        temp-=heapq.heappop(diff)
    print(x[m-1]-x[0]+1-temp-n)
Buggy python submission (verdict: Runtime Error):
import heapq
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
if sum(a_list)<sum(b_list):
    print(-1)
else:
    diff_list = [a_list[i]-b_list[i] for i in range(n)]
    posi_heap=heapq.heapify([])
    cnt,diff_sum = 0,0
    for diff in diff_list:
        if diff<0:
            cnt+=1
            diff_sum+=diff
        elif diff>0:
            heapq.heappush(posi_heap,-1*diff)
    diff_sum*=(-1)
    i=0
    while diff_sum>0:
        diff_sum+=heapq.heappop(posi_heap)
        i+=1
    print(i+cnt)

Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
if sum(a_list)<sum(b_list):
    print(-1)
else:
    diff_list = [a_list[i]-b_list[i] for i in range(n)]
    posi_list=[]
    cnt,diff_sum = 0,0
    for diff in diff_list:
        if diff<0:
            cnt+=1
            diff_sum+=diff
        elif diff>0:
            posi_list.append(diff)
    diff_sum*=(-1)
    posi_list.sort(reverse=True)
    i,S=0,0
    while S<diff_sum:
        S+=posi_list[i]
        i+=1
    print(i+cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
if sum(a_list)<sum(b_list):
    print(-1)
else:
    diff_list = [a_list[i]-b_list[i] for i in range(n)]
    cnt=0
    for diff in diff_list:
        if diff<0:
            cnt+=1
    while min(diff_list)<0:
        M = max(diff_list)
        for i in range(n):
            dif = diff_list[i]
            if dif<0 and M+dif>=0:
                M+=dif
                diff_list[i]=0
            elif M+dif<0:
                break
        cnt+=1
    print(cnt)

Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
if sum(a_list)<sum(b_list):
    print(-1)
else:
    diff_list = [a_list[i]-b_list[i] for i in range(n)]
    posi_list=[]
    cnt,diff_sum = 0,0
    for diff in diff_list:
        if diff<0:
            cnt+=1
            diff_sum+=diff
        elif diff>0:
            posi_list.append(diff)
    diff_sum*=(-1)
    posi_list.sort(reverse=True)
    i,S=0,0
    while S<diff_sum:
        S+=posi_list[i]
        i+=1
    print(i+cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
inf=[]
pre=[[] for _ in range(n)]
for _ in range(m):
    p,y=map(int,input().split())
    inf.append([p,y])
    pre[p-1].append(y)
for p in range(n): pre[p].sort()
for i in inf: print("{:06}{:06}".format(i[0],1+pre[i[0]-1].index(i[1])))

Fixed submission:
n,m=map(int,input().split())
pre=[[] for _ in range(n)]
for _ in range(m):
    p,y=map(int,input().split())
    pre[p-1].append([y,_,p])
for p in range(n):
    pre[p].sort(key=lambda x:x[0])
    for i in range(len(pre[p])):
        pre[p][i].append(i)
lis=[]
for i in pre:
    for j in i:
        lis.append(j)
lis.sort(key=lambda x:x[1])
for i in lis: print("{:06}{:06}".format(i[2],i[3]+1))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
inf=[]
pre=[[] for _ in range(n)]
for _ in range(m):
    p,y=map(int,input().split())
    pre[p-1].append(y)
    inf.append([p,y])
for key,lis in enumerate(pre): pre[key]=sorted(lis)
for i in inf: print("{:06}{:06}".format(i[0],1+pre[i[0]-1].index(i[1])))

Fixed submission:
n,m=map(int,input().split())
pre=[[] for _ in range(n)]
for _ in range(m):
    p,y=map(int,input().split())
    pre[p-1].append([y,_,p])
for p in range(n):
    pre[p].sort(key=lambda x:x[0])
    for i in range(len(pre[p])):
        pre[p][i].append(i)
lis=[]
for i in pre:
    for j in i:
        lis.append(j)
lis.sort(key=lambda x:x[1])
for i in lis: print("{:06}{:06}".format(i[2],i[3]+1))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

n,m=map(int,input().split())
inf=[]
pre=defaultdict(list)
for _ in range(m):
    p,y=map(int,input().split())
    pre[p-1].append(y)
    inf.append([p,y])
for key,lis in pre.items(): pre[key]=sorted(lis)
for i in inf: print("{:06}{:06}".format(i[0],1+pre[i[0]-1].index(i[1])))

Fixed submission:
n,m=map(int,input().split())
pre=[[] for _ in range(n)]
for _ in range(m):
    p,y=map(int,input().split())
    pre[p-1].append([y,_,p])
for p in range(n):
    pre[p].sort(key=lambda x:x[0])
    for i in range(len(pre[p])):
        pre[p][i].append(i)
lis=[]
for i in pre:
    for j in i:
        lis.append(j)
lis.sort(key=lambda x:x[1])
for i in lis: print("{:06}{:06}".format(i[2],i[3]+1))
Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
m=[]
for _ in range(h): m.append(list(input()))
black=0
white=0
for i in range(h):
    for j in range(w):
        if m[i][j]=="#": black+=1
white=h*w-black
node=[[0,0,1]]
dx,dy=[-1,0,1,0],[0,1,0,-1]
while node:
    temp=node.pop(0)
    if temp[0]==h-1 and temp[1]==w-1:
        print(h*w-black-temp[2])
        exit()
    m[temp[0]][temp[1]]="#"
    for i in range(4):
        if 0<=temp[0]+dx[i]<h and 0<=temp[1]+dy[i]<w:
            if m[temp[0]+dx[i]][temp[1]+dy[i]]==".":
                node.append([temp[0]+dx[i],temp[1]+dy[i],temp[2]+1])
print(-1)           

Fixed submission:
h,w=map(int,input().split())
m=[]
for _ in range(h): m.append(list(input()))
black=0
white=0
for i in range(h):
    for j in range(w):
        if m[i][j]=="#": black+=1
white=h*w-black
node=[[0,0,1]]
dx,dy=[-1,0,1,0],[0,1,0,-1]
while node:
    temp=node.pop(0)
    if temp[0]==h-1 and temp[1]==w-1:
        print(h*w-black-temp[2])
        exit()
    m[temp[0]][temp[1]]="#"
    for i in range(4):
        if 0<=temp[0]+dx[i]<h and 0<=temp[1]+dy[i]<w:
            if m[temp[0]+dx[i]][temp[1]+dy[i]]==".":
                node.append([temp[0]+dx[i],temp[1]+dy[i],temp[2]+1])
                m[temp[0]+dx[i]][temp[1]+dy[i]]="#"
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
ans,n = 0,int(input())
a_list = list(map(int,input().split()))
a_set = set(a_list)
a_dict = {val:a_list.count(val) for val in a_set}
for key,value in a_dict.items():
    if value>key:
        ans += value-key
    elif value<key:
        ans += value
print(ans)

Fixed submission:
from collections import defaultdict

ans,n = 0,int(input())
a_list = list(map(int,input().split()))
a_dict = defaultdict(int)
for i in range(n):
    a_dict[a_list[i]]+=1
for key,value in a_dict.items():
    if value>key:
        ans += value-key
    elif value<key:
        ans += value
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

s=Counter(input())
b,s=max(s.values()),min(s.values())
kind = len(s.keys())
if kind==3:
    if b-s<=1: print("YES")
    else: print("NO")
elif kind==2:
    if b==2 and s==1: print("YES")
    else: print("NO")
else:
    if b==1: print("YES")
    else: print("NO")

Fixed submission:
from collections import Counter

s=Counter(input())
b,m=max(s.values()),min(s.values())
kind = len(s.keys())
if kind==3:
    if b-m<=1: print("YES")
    else: print("NO")
elif kind==2:
    if b==1 and m==1: print("YES")
    else: print("NO")
else:
    if b==1: print("YES")
    else: print("NO")

Buggy python submission (verdict: Runtime Error):
from collections import Counter

s=Counter(input())
b,s=max(s.values()),min(s.values())
kind = len(s.keys())
if length==3:
    if b-s<=1: print("YES")
    else: print("NO")
elif length==2:
    if b==2 and s==1: print("YES")
    else: print("NO")
else:
    if b==1: print("YES")
    else: print("NO")

Fixed submission:
from collections import Counter

s=Counter(input())
b,m=max(s.values()),min(s.values())
kind = len(s.keys())
if kind==3:
    if b-m<=1: print("YES")
    else: print("NO")
elif kind==2:
    if b==1 and m==1: print("YES")
    else: print("NO")
else:
    if b==1: print("YES")
    else: print("NO")
Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(1,3501):
    for j in range(1,3501):
        t1=n*i*j
        t2=4*i*j-n*j-n*i
        if t1%t2==0 and 1<=t1//t2<3500:
            print(i,j,t1//t2)
            exit()

Fixed submission:
n=int(input())
for i in range(1,3501):
    for j in range(1,3501):
        t1=n*i*j
        t2=4*i*j-n*j-n*i
        if t2>0 and t1%t2==0:
            print(i,j,t1//t2)
            exit()
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
colors=[]
for i in range(n):
    for _ in range(a[i]):
        colors.append(i+1)
ans=[[0 for _ in range(w)] for _ in range(h)]
temp=0
for i in range(h):
    for j in range(w):
        if i%2!=0:
            j = w-j-1
        ans[i][j]=colors[temp]
        temp+=1

for i in range(h):
    for j in range(w):
        print(ans[i][j], end="")
    print()

Fixed submission:
n = int(input())
a=list(map(int,input().split()))
cnt,cnt2,cnt4=0,0,0
for val in a:
    if val%4==0:
        cnt4+=1
    elif val%2==0:
        cnt2+=1
    else:
        cnt+=1
if cnt2==n: print("Yes")
elif cnt2==0:
    if cnt4>=cnt-1: print("Yes")
    else: print("No")
else:
    if cnt4>=cnt: print("Yes")
    else: print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input)
a=list(map(int,input().split()))
cnt,cnt2,cnt4=0,0,0
for val in a:
    if val%4==0:
        cnt4+=1
    elif val%2==0:
        cnt2+=1
    else:
        cnt+=1
if cnt2==n: print("Yes")
else:
    if cnt4>=cnt: print("Yes")
    else: print("No")

Fixed submission:
n = int(input())
a=list(map(int,input().split()))
cnt,cnt2,cnt4=0,0,0
for val in a:
    if val%4==0:
        cnt4+=1
    elif val%2==0:
        cnt2+=1
    else:
        cnt+=1
if cnt2==n: print("Yes")
elif cnt2==0:
    if cnt4>=cnt-1: print("Yes")
    else: print("No")
else:
    if cnt4>=cnt: print("Yes")
    else: print("No")
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
colors = [[i+1]*a[i] for i in n]
ans=[[0 for _ in range(w)] for _ in range(h)]
temp=0
for i in range(h):
    for j in range(w):
        if i%2==0:
            j = w-h-1
        ans[i][j]=colors[temp]
        temp+=1
        
for i in range(h):
    for j in range(2):
        print(ans[i][j], end="")
    print()

Fixed submission:
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
colors=[]
for i in range(n):
    for _ in range(a[i]):
        colors.append(i+1)
ans=[[0 for _ in range(w)] for _ in range(h)]
temp=0
for i in range(h):
    for j in range(w):
        if i%2!=0:
            j = w-j-1
        ans[i][j]=colors[temp]
        temp+=1

for i in range(h):
    for j in range(w):
        print(ans[i][j], end=" ")
    print()
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
if abs(n-m)>1: print(0)
else:
    mod=10**9+7
    def fact(n):
        ans=1
        for i in range(n):
            ans*=(i+1)
        return ans%mod

    ans=(fact(n)*fact(m))%mod
    if n==m: print((2*ans)%mod)
    else: print(ans)

Fixed submission:
n,m=map(int,input().split())
if abs(n-m)>1: print(0)
else:
    mod=10**9+7
    def fact(n):
        ans=1
        for i in range(n):
            ans*=(i+1)
            ans%=mod
        return ans

    ans=(fact(n)*fact(m))%mod
    if n==m: print((2*ans)%mod)
    else: print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
if abs(n-m)>1: print(0)
else:
    mod=10**9+7
    fac=[0]*(n+1)
    fac[0]=1
    fac[1]=1
    def fact(k):
        if fac[k]>0: return fac[k]
        fac[k]=k*fact(k-1)%mod
        return fac[k]
    
    ans=(fact(n)*fact(m))%mod
    if n==m: print((2*ans)%mod)
    else: print(ans)

Fixed submission:
n,m=map(int,input().split())
if abs(n-m)>1: print(0)
else:
    mod=10**9+7
    def fact(n):
        ans=1
        for i in range(n):
            ans*=(i+1)
            ans%=mod
        return ans

    ans=(fact(n)*fact(m))%mod
    if n==m: print((2*ans)%mod)
    else: print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
if abs(n-m)>1: print(0)
else:
    mod=10**9+7
    fac=[0]*n
    fac[0]=1
    fac[1]=1
    def fact(n):
        if fac[n]>0: return fac[n]
        fac[n]=n*fact(n-1)%mod
        return fac[n]
    
    ans=(fac(n)*fac(m))%mod
    if n==m: print((2*ans)%mod)
    else: print(ans)

Fixed submission:
n,m=map(int,input().split())
if abs(n-m)>1: print(0)
else:
    mod=10**9+7
    def fact(n):
        ans=1
        for i in range(n):
            ans*=(i+1)
            ans%=mod
        return ans

    ans=(fact(n)*fact(m))%mod
    if n==m: print((2*ans)%mod)
    else: print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools as it
n,m=map(int,input().split())
path={[] for _ in range(m)}
for i in range(m): path[i]=list(map(int,input().split()))
ls=list(it.permutations(range(1,n+1)))
cnt=0
for l in ls:
    if l[0]==1: break
    for i in range(n-1):
        if [i,i+1] in path: cnt+=1
print(cnt)

Fixed submission:
import itertools as it

n,m=map(int,input().split())
path=[]
for i in range(m): path.append(list(map(int,input().split())))
ls=list(it.permutations(range(1,n+1)))
cnt=0
for l in ls:
    if l[0]!=1: break
    flag=1
    for i in range(n-1):
        if ([l[i],l[i+1]] not in path) and ([l[i+1],l[i]] not in path):
            flag=0
            break
    if flag: cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
s=input()
now,ans=0,0
while now<n-1:
    if s[now]!=s[now+1]:
        ans+=1
    now+=1
print(ans)

Fixed submission:
s=input()
now,ans=0,0
while now<len(s)-1:
    if s[now]!=s[now+1]:
        ans+=1
    now+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
ans=""
for b in s:
    if b=="1":
        ans+="1"
    elif b=="0":
        ans+="0"
    else:
        if len(ans)!=0:
            ans[-1]=""
print(ans)

Fixed submission:
s=input()
ans=""
for b in s:
    if b=="1":
        ans+="1"
    elif b=="0":
        ans+="0"
    else:
        if len(ans)!=0:
            ans = ans[:-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
d=set(map(int,input().split()))
i=n
while True:
    if not set((str(i)))&d: i+=1
    else:
        print(i)
        exit()

Fixed submission:
n,k=map(int,input().split())
d=set(map(int,input().split()))
i=n
while True:
    temp=i
    flag=1
    while temp>0:
        if temp%10 in d:
            flag=0
            break
        temp//=10
    if flag:
        print(i)
        break
    i+=1
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
f = [set() for _ in range(N)]
v = [False for _ in range(N)]
ans = 1

for _ in range(M):
  a, b = map(int, input().split())
  a, b = a - 1, b - 1
  f[a].add(b)
  f[b].add(a)
  
  
def dfs(fi):
  if v[fi]: return 0
  
  v[fi] = True
  cnt = 1
  
  for fr in f[fi]:
    cnt += dfs(fr)
    
  return cnt

for i in range(N):
  cnt = dfs(i)
  ans = max(ans, cnt)
  
print(ans)
  

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

N, M = map(int, input().split())
f = [set() for _ in range(N)]
v = [False for _ in range(N)]
ans = 1

for _ in range(M):
  a, b = map(int, input().split())
  a, b = a - 1, b - 1
  f[a].add(b)
  f[b].add(a)
  
  
def dfs(fi):
  if v[fi]: return 0
  
  v[fi] = True
  cnt = 1
  
  for fr in f[fi]:
    cnt += dfs(fr)
    
  return cnt

for i in range(N):
  cnt = dfs(i)
  ans = max(ans, cnt)
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
ans = 0
for _ in range(n):
  x = list(input())
  x.sort()
  s.append("".join(x))
for i in range(n):
  for j in range(i+1, n):
    if s[i]==s[j]:
      ans += 1
print(ans)

Fixed submission:
n = int(input())
b = {}
ans = 0
for _ in range(n):
  x = list(input())
  x.sort()
  x = "".join(x)
  if not x in b:
    b[x] = 0
  else:
    b[x] += 1
    ans += b[x]
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [input for _ in range(n)]
c = [i in range(1, n)]

Fixed submission:
n = int(input())
b = {}
ans = 0
for _ in range(n):
  x = list(input())
  x.sort()
  x = "".join(x)
  if not x in b:
    b[x] = 0
  else:
    b[x] += 1
    ans += b[x]
print(ans)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
cnt = 0
now = 0
for i in range(n + 1):
  if now > x:
    break
  cnt += 1
  now = now + l[i]
print(cnt)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = [0 for _ in range(n + 1)]
ans = 0
for i in range(1, n + 1):
  d[i] = d[i - 1] + l[i - 1]
for j in range(n + 1):
  if d[j] <= x:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
w, h, x, y = map(int, input().split())
s = 0
if w / x ==  h / y == 2:
  s = 1
print('{:.6f}'.format(w * h / 2), s)

Fixed submission:
w, h, x, y = map(int, input().split())
s = 0
if w / 2 == x and h / 2 == y:
  s = 1
print('{:.6f}'.format(w * h / 2), s)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = float('inf')
for i in range(n - k + 1):
  l = x[i:i + k]
  ans = min(ans, abs(l[0]) + abs(l[-1] - l[0]), abs(l[-1]) + abs(l[-1] - l[0]))
print(ans)

Fixed submission:
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = float('inf')
for i in range(n - k + 1):
  ans = min(ans, abs(x[i]) + abs(x[i + k - 1] - x[i]))
  ans = min(ans,  abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i]))
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A, B, H, M = map(int, input().split())


if H == 0:
    H = 12
elif M == 0:
    M = 60
L = M / 5



N = min(abs(L - H), abs(H - L))

if L >= H:
    if M == 60:
        M = 0
        S = 360 * N / 12 - (0.5 * M)
else:
    S = 360 * N / 12 + (0.5 * M)


ANS = A**2 + B**2 - (2*A*B*math.cos(math.radians(S)))
ANS = math.sqrt(ANS)
print(ANS)


Fixed submission:
import math
A, B, H, M = map(int, input().split())


if H == 0:
    H = 12
elif M == 0:
    M = 60
L = M / 5



N = min(abs(L - H), abs(H - L))

if L >= H:
    if M == 60:
        M = 0
    S = 360 * N / 12 - (0.5 * M)
else:
    S = 360 * N / 12 + (0.5 * M)


ANS = A**2 + B**2 - (2*A*B*math.cos(math.radians(S)))
ANS = math.sqrt(ANS)
print(ANS)

Buggy python submission (verdict: Runtime Error):
import math
A, B, H, M = map(int, input().split())


if H == 0:
    H = 12
elif M == 0:
    M = 60
L = M / 5



N = min(abs(L - H), abs(H - L))

if L >= H:
    if M == 60:
        M = 0
        S = 360 * N / 12 - (0.5 * M)
else:
    S = 360 * N / 12 + (0.5 * M)


ANS = A**2 + B**2 - (2*A*B*math.cos(math.radians(S)))
ANS = math.sqrt(ANS)
print(ANS)


Fixed submission:
import math
A, B, H, M = map(int, input().split())


if H == 0:
    H = 12
elif M == 0:
    M = 60
L = M / 5



N = min(abs(L - H), abs(H - L))

if L >= H:
    if M == 60:
        M = 0
    S = 360 * N / 12 - (0.5 * M)
else:
    S = 360 * N / 12 + (0.5 * M)


ANS = A**2 + B**2 - (2*A*B*math.cos(math.radians(S)))
ANS = math.sqrt(ANS)
print(ANS)
Buggy python submission (verdict: Runtime Error):
A = list(map(int, input().split()))



A = sorted(A)
L = []
ANS = 0

A_max = max(A)

for i in range(N-1):
    L.append(abs(A[i+1]-A[i]))
        
L.append(K + A[0] - A_max)

L = sorted(L)


L.pop(-1)

for i in range(len(L)):
    ANS = ANS + L[i]
    
print(ANS)
    

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



A = sorted(A)
L = []
ANS = 0

A_max = max(A)

for i in range(N-1):
    L.append(abs(A[i+1]-A[i]))
        
L.append(K + A[0] - A_max)

L = sorted(L)


L.pop(-1)

for i in range(len(L)):
    ANS = ANS + L[i]
    
print(ANS)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = list(map(int, input().split()))
H = sorted(H, reverse=True)
SUM = 0

if K > N:
    print(0)
    exit()

for i in range(K):
    H.pop(i)
    
for i in range(len(H)):
    SUM = SUM + H[i]

print(SUM)

Fixed submission:
N, K = map(int, input().split())
H = list(map(int, input().split()))
H = sorted(H)
SUM = 0

if K >= N:
    print(0)
    exit()


    
for i in range(len(H)-K):
    SUM = SUM + H[i]


print(SUM)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
M = []
sqr_N = math.floor(math.sqrt(N))
    
for i in range(sqr_N):
    if i == 0:
        continue
    elif N % i == 0:
        M.append(i)

O = []
ANS = []        
for i in range(len(M)):
    O.append(N // M[i])
    


for i in range(len(O)):


    ANS.append(O[i] + M[i]) 
        
     
        
min = min(ANS)

print(min - 2)

Fixed submission:
import math
N = int(input())
M = []
sqr_N = math.floor(math.sqrt(N))
a = 0
    
for i in range(1, (sqr_N + 1)):
    if N % i == 0:
        a = i

a_pair = N // a
print(a + a_pair - 2)

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
M = []
sqr_N = math.floor(math.sqrt(N))
    
for i in range(sqr_N):
    if i == 0:
        continue
    elif N % i == 0:
        M.append(i)
        
        
ANS = (max(M) - 1) + ((N / max(M)) - 1)

print(int(ANS))

Fixed submission:
import math
N = int(input())
M = []
sqr_N = math.floor(math.sqrt(N))
a = 0
    
for i in range(1, (sqr_N + 1)):
    if N % i == 0:
        a = i

a_pair = N // a
print(a + a_pair - 2)