Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
num_limit = int(input())
s_limit_1 = int(num_limit**0.5)
s_limit_2 = int((num_limit/2)**0.5)
s_limit_3 = int((num_limit/3)**0.5)
for i in range(1,num_limit+1):
    xyz_list = []
    xyz_count = 0
    s_limit_1 = int(i ** 0.5)
    j = 0
    k = 0
    l = 0
    for j in range(1,s_limit_1+1):
        for k in range(1,j+1):
            if i <= j**2 + k**2 + l**2 + j*k + k*l + l*j:
                break
            for l in range(1,k+1):
                if i == j**2 + k**2 + l**2 + j*k + k*l + l*j:
                    if j == k and k == l:
                        xyz_count += 1
                    elif j == k and k > l or j > k and k == l:
                        xyz_count += 3
                    else:
                        xyz_count += 6
                if i < j**2 + k**2 + l**2 + j*k + k*l + l*j:
                    break
    print(xyz_count)

Fixed submission:
input_line = input().split(" ")
min_fig = int(input_line[0])
max_fig = int(input_line[1])
sample = int(input_line[2])
if min_fig % sample == 0:
    minus_num = int(min_fig / sample) -1
else:
    minus_num = int(min_fig / sample)
plus_num = int(max_fig / sample)
print(plus_num-minus_num)
Buggy python submission (verdict: Runtime Error):
N=input()
X=0
Y=0
for i in range(len(N)):
  if N[i]="R":
    X+=1
  else:
    Y=X
    X=0
print(max([X,Y]))
  


Fixed submission:
N=input()
X=0
Y=0
for i in range(len(N)):
  if N[i]=="R":
    X+=1
  else:
    Y=max([X,Y])
    X=0
print(max([X,Y]))

Buggy python submission (verdict: Runtime Error):
N=input()
X=0
Y=0
for i+1 in range(len(N)):
  if N[i]="R":
    X+=1
  else:
    Y=X
    X=0
print(max([X,Y]))
  


Fixed submission:
N=input()
X=0
Y=0
for i in range(len(N)):
  if N[i]=="R":
    X+=1
  else:
    Y=max([X,Y])
    X=0
print(max([X,Y]))

Buggy python submission (verdict: Runtime Error):
N=input()
X=0
Y=0
for i+1 in range(len(N)):
  if N[i]="R":
    X+=1
  else:
    Y=X
    X=0
print(max(X,Y))
  

Fixed submission:
N=input()
X=0
Y=0
for i in range(len(N)):
  if N[i]=="R":
    X+=1
  else:
    Y=max([X,Y])
    X=0
print(max([X,Y]))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[int(i) for i in input().split()]
Q=int(input())
X=[i+1 for i in range((10**5))]
dic={}
ans=sum(A)
for i in A:
	try:
		dic[i]+=1
	except:
		dic.setdefault(i,1)
for i in range(Q):
	[B,C]=[int(i) for i in input().split()]
	try:
		ans+=dic[B]*(C-B)
		try:
			dic[C]+=dic[B]
		except:
			dic.setdefault(C,dic[B])
		dic[B]=0
	except:
		ans+=0

	print(ans)


Fixed submission:
N=input()
X=["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 N in X:
  print("A")
else:
  print("a")
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[int(i) for i in input().split()]
Q=int(input())
X=[i+1 for i in range((10**5))]
dic={}
ans=sum(A)
for i in A:
	try:
		dic[i]+=1
	except:
		dic.setdefault(i,1)
for i in range(Q):
	[B,C]=[int(i) for i in input().split()]
	ans+=dic[B]*(C-B)
	try:
		dic[C]+=1
	except:
		dic.setdefault(C,1)
	print(ans)


Fixed submission:
N=int(input())
A=[int(i) for i in input().split()]
Q=int(input())
X=[i+1 for i in range((10**5))]
dic={}
ans=sum(A)
for i in A:
	try:
		dic[i]+=1
	except:
		dic.setdefault(i,1)
for i in range(Q):
	[B,C]=[int(i) for i in input().split()]
	try:
		ans+=dic[B]*(C-B)
		try:
			dic[C]+=dic[B]
		except:
			dic.setdefault(C,dic[B])
		dic[B]=0
	except:
		ans+=0
	print(ans)
Buggy python submission (verdict: Runtime Error):
[A,V]=[int(i) for i in input().split()]
[B,W]=[int(i) for i in input().split()]
T=int(input())
if abs(A-B)=>T*abs(V-W):print("NO")
else:print("YES")


Fixed submission:
[A,V]=[int(i) for i in input().split()]
[B,W]=[int(i) for i in input().split()]
T=int(input())
if W-V>0 or abs(B-A)>T*abs(W-V):print("NO")
else:print("YES")

Buggy python submission (verdict: Runtime Error):
[A,V]=[int(i) for i in input.split()]
[B,W]=[int(i) for i in input.split()]
T=int(input())
if max(A-B,B-A)>T*max(V-W,W-V):print("NO")
else:print("YES")

Fixed submission:
[A,V]=[int(i) for i in input().split()]
[B,W]=[int(i) for i in input().split()]
T=int(input())
if W-V>0 or abs(B-A)>T*abs(W-V):print("NO")
else:print("YES")
Buggy python submission (verdict: Runtime Error):
[A,B]=[i for i in input().split()]
A=int(A)
B=int(B*100)
print(A*B//100)

Fixed submission:
[A,B]=[i for i in input().split()]
A=int(A)
a=[]
f=False
for i in range(len(B)):
	if B[i]!=".":
		a+=[B[i]]
B=int("".join(a))
print(A*B//100)
Buggy python submission (verdict: Runtime Error):
K=int(input())
[A,B]=list(map(int(),input().split()))
flg=0
for n in range(A,B+1):
  if n%K==0:
    print("OK")
    flg==1
    break
if flg==0:print("N_G")


Fixed submission:
K=int(input())
[A,B]=[int(i) for i in input().split()]
f=0
for n in range(A,B+1):
  if n%K==0:
    f+=1
    break
if f==0:print("NG")
else:print("OK")

Buggy python submission (verdict: Runtime Error):
K=int(input())
[A,B]=list(map(int(),input().split()))
flg=0
for n in range(A,B+1):
  if n%K==0:
    print("OK")
    flg==1
    break
if flg==0:print("NG")

Fixed submission:
K=int(input())
[A,B]=[int(i) for i in input().split()]
f=0
for n in range(A,B+1):
  if n%K==0:
    f+=1
    break
if f==0:print("NG")
else:print("OK")
Buggy python submission (verdict: Runtime Error):
N=int(input())
lis=[]
ans=0
for i in range(N):
	x=input()
	try:
		y=lis.index(x)
	except:
		lis+=[x]
		ans+=1
print(ans)


Fixed submission:
[S,W]=[int(i) for i in input().split()]
if S>W:
  print("safe")
else:
  print("unsafe")
Buggy python submission (verdict: Runtime Error):
N=int(input())
lis=[]
ans=0
for i in range(N):
	try:
		y=lis.index(input())
	except:
		lis+=[input()]
		ans+=1
print(ans)

Fixed submission:
N=int(input())
lis=[]
ans=0
for i in range(N):
	lis+=[input()]
print(len(set(lis)))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
lis=[]
ans=0
for i in range(N):
	x=input()
	try:
		y=lis.index(x)
	except:
		lis+=[x]
		ans+=1
print(ans)


Fixed submission:
N=int(input())
lis=[]
ans=0
for i in range(N):
	lis+=[input()]
print(len(set(lis)))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
lis=[]
ans=0
for i in range(N):
	x=input()
	try:
		y=lis.index(x)
	except:
		lis+=[x]
		ans+=1
print(ans)

Fixed submission:
N=int(input())
lis=[]
ans=0
for i in range(N):
	lis+=[input()]
print(len(set(lis)))
Buggy python submission (verdict: Runtime Error):
print(3.1415*R*2)

Fixed submission:
print(3.1415*int(input())*2)

Buggy python submission (verdict: Runtime Error):
R=input()
print(R*3.14)

Fixed submission:
print(3.1415*int(input())*2)

Buggy python submission (verdict: Runtime Error):
R=input()
print(R*3.1415)

Fixed submission:
print(3.1415*int(input())*2)

Buggy python submission (verdict: Runtime Error):
R=input()
print(R*3.141)

Fixed submission:
print(3.1415*int(input())*2)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(i) for i in input().split()]
D={}
x=0
lis=[]
for a in A:
	if a in D.keys():
		D[a]=D[a]+((D[a]*2)**0.5//1)+1
	else:
		D[a]=0

z=sum(D.values())
for i in range(len(A)):
	x=0
	y=((D[A[i]]*2)**0.5)//1
	x=x+z-y
	print(int(x))


Fixed submission:
N=int(input())
A=[int(i) for i in input().split()]
D={}
x=0
lis=[]
for a in A:
	try:
		D[a]=D[a]+((D[a]*2)**0.5//1)+1
	except:
		D[a]=0

z=sum(D.values())
for i in range(len(A)):
	x=0
	y=((D[A[i]]*2)**0.5)//1
	x=x+z-y
	print(int(x))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(i) for i in input().split()]
D={}
x=0
lis=[]
for a in A:
	if a in D.keys():
		D[a]=D[a]+1
	else:
		D[a]=1

z=0
lis=list(D.keys())
for i in range(len(D)):
	y=D[lis[i]]
	z+=int((y**2-y)/2)
for i in range(len(A)):
	x=0
	y=D[A[i]]
	x=x+z-(y-1)
	print(x)

Fixed submission:
N=int(input())
A=[int(i) for i in input().split()]
D={}
x=0
lis=[]
for a in A:
	try:
		D[a]=D[a]+((D[a]*2)**0.5//1)+1
	except:
		D[a]=0

z=sum(D.values())
for i in range(len(A)):
	x=0
	y=((D[A[i]]*2)**0.5)//1
	x=x+z-y
	print(int(x))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(i) for i in input().split()]
D={}
x=0
for a in A:
	if a in D.keys():
		D[a]=D[a]+1
	else:
		D[a]=1

for i in range(len(A)):
	if D[A[i]]>1:
		D[A[i]]=D[A[i]]-1
	else:
		D.pop(A[i])
	x=0
	lis=list(D.keys())
	for j in range(len(D.keys())):
		y=D[lis[j]]
		x+=int((y**2-y)/2)
	print(x)
	if A[i] in D.keys():
		D[A[i]]=D[A[i]]+1
	else:
		D[A[i]]=1

Fixed submission:
N=int(input())
A=[int(i) for i in input().split()]
D={}
x=0
lis=[]
for a in A:
	try:
		D[a]=D[a]+((D[a]*2)**0.5//1)+1
	except:
		D[a]=0

z=sum(D.values())
for i in range(len(A)):
	x=0
	y=((D[A[i]]*2)**0.5)//1
	x=x+z-y
	print(int(x))
Buggy python submission (verdict: Time Limit Exceeded):
[N,M]=[int(i) for i in input().split()]
lis=[-1 for i in range(N)]
flg=0
for m in range(M):
  [s,c]=[int(i) for i in input().split()]
  if lis[s-1]==-1 or lis[s-1]==c:
    lis[s-1]=c
  else:
    flg=1
    break
x=""
if flg==1:
  print("-1")
else:
  for i in range(len(lis)):
    if i==0 and lis[i]==0 and len(lis)!=1:#先頭0排除
      print("-1")
      break
    if lis[i]==-1:#指定なし
      if flg==0 and i==0:
        x+="1"
        flg=2
        for i in range(10**10):
        	flg+=i
      else:
        x+="0"
    else:#指定あり
      x+=str(lis[i])
      flg="2"
    if i==len(lis)-1:print(x)

Fixed submission:
[N,M]=[int(i) for i in input().split()]
lis=[-1 for i in range(N)]
flg=0
for m in range(M):
  [s,c]=[int(i) for i in input().split()]
  if lis[s-1]==-1 or lis[s-1]==c:
    lis[s-1]=c
  else:
    flg=1
    break
x=""
if flg==1:
  print("-1")
else:
  for i in range(len(lis)):
    if i==0 and lis[i]==0 and len(lis)!=1:#先頭0排除
      print("-1")
      break
    if lis[i]==-1:#指定なし
      if flg==0 and i==0 and len(lis)!=1:
        x+="1"
        flg=2
      else:
        x+="0"
    else:#指定あり
      x+=str(lis[i])
      flg=2
    if i==len(lis)-1:print(x)
Buggy python submission (verdict: Runtime Error):
[A,B,C]=[int(i) for i in input().split()]
if A==B:
	if B!=C:
		print("Yes")
	else:
		print("No")
else:
	if B==C:
		print("No")
	else:
		if A=C:
			print("Yes")
		else:
			print("No")

Fixed submission:
[A,B,C]=[int(i) for i in input().split()]
if A==B:
	if B!=C:
		print("Yes")
	else:
		print("No")
else:
	if B==C:
		print("Yes")
	else:
		if A==C:
			print("Yes")
		else:
			print("No")
Buggy python submission (verdict: Time Limit Exceeded):
[H,N]=[int(i) for i in input().split()]
A=[0 for i in range(N)]
B=[0 for i in range(N)]
for n in range(N):
  [A[n],B[n]]=[int(i) for i in input().split()]
k=H+max(A)+1
DP=[100000000 for i in range(k)]
DP[0]=0
for n in range(N):
  for h in range(k):
    if h-A[n]>-1:
    	if DP[h-A[n]]+B[n]<DP[h]:DP[h]=DP[h-A[n]]+B[n]
print(min(DP[H:]))

Fixed submission:
[H,N]=[int(i) for i in input().split()]
A=[0 for i in range(N)]
B=[0 for i in range(N)]
for n in range(N):
  [A[n],B[n]]=[int(i) for i in input().split()]
k=H+max(A)+1
DP=[100000000 for i in range(k)]
DP[0]=0
for n in range(N):
  for h in range(k):
    if h-A[n]>-1:
    	if DP[h-A[n]]+B[n]<DP[h]:DP[h]=DP[h-A[n]]+B[n]
print(min(DP[H:]))
Buggy python submission (verdict: Runtime Error):
N=int(input())
D=int(input())
a=2*n+1
b=D//a+1
print(b)

Fixed submission:
[N,D]=[int(i) for i in input().split()]
a=(2*D)+1
b=(N//a)+1

if N%a==0:b-=1
print(b)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[int(i) for i in input().split()]
B=[None for i in range(N)]
res=0
for n in range(N):
	if n%2!=0:res-=A[n]
	else:res+=A[n]
B[0]=res
ans=str(res)+" "
for i in range(1,N):
	B[i]=int((A[i-1]-(int(B[i-1])/2))*2)
	ans=str(ans)+str(B[i])+" "

print(ans)


Fixed submission:
A=[int(i) for i in input().split()]
n=A[0]
a=A[1]
b=A[2]
c=n*a

if c>b:
	print(b)
else:
	print(c)
Buggy python submission (verdict: Runtime Error):
N=input()
P=[int(i) for i in input().split()]
mes=[]

for i in range(len(P)):

	if i!=1 and i!=N-1:
		if (P[i+1]<P[i] and P[i+1]<=P[i-1]) or (P[i+1]<P[i] and P[i+1]<=P[i-1]):
			mes+=mes+P[i]

for n in mes:
	print(mes[n])


Fixed submission:
N=int(input())
P=[int(i) for i in input().split()]
mes=0
for i in range(len(P)):

	if i!=0 and i!=N-1:
		if (P[i+1]<P[i] and P[i+1]<=P[i-1] and P[i]<=P[i-1])or(P[i-1]<P[i] and P[i-1]<=P[i+1] and P[i]<=P[i+1]):
			mes+=1
print(mes)

Buggy python submission (verdict: Runtime Error):
N=input()
P=[int(i) for i in input().split()]
mes=[]

for i in range(len(P)):

	if i!=1 and i!=N-1:
		if (P[i+1]<P[i] and P[i+1]<=P[i-1]) or (P[i+1]<P[i] and P[i+1]<=P[i-1]):
			mes+=mes+P[i]

for n in mes:
	print(mes)
		
      

Fixed submission:
N=int(input())
P=[int(i) for i in input().split()]
mes=0
for i in range(len(P)):

	if i!=0 and i!=N-1:
		if (P[i+1]<P[i] and P[i+1]<=P[i-1] and P[i]<=P[i-1])or(P[i-1]<P[i] and P[i-1]<=P[i+1] and P[i]<=P[i+1]):
			mes+=1
print(mes)
Buggy python submission (verdict: Runtime Error):
[A,B,C,N]=[int(i) for i in input().split()]
[C,B,A]=[A,B,C].sort()
cnt=0
for i in range(N//A):
  k=N-(i*A)
  for j in range(k//B):
    if (k-(B*A))%C==0:cnt+=1
print(cnt)

Fixed submission:
[A,B,C,N]=[int(i) for i in input().split()]
X=[A,B,C]
X.sort()
[C,B,A]=X
cnt=0
for i in range(N//A+1):
  k=N-(i*A)
  for j in range(k//B+1):
    if (k-(B*j))%C==0:
    	cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
[A,B,C,N]=[int(i) for i in input().split()]
[C,B,A]=[A,B,C].sort()
cnt=0
for i in range(N//A):
  k=N-(i*A)
  for j in range(k//B):
    if (k-(B*A))%C=0:cnt+=1
print(cnt)

Fixed submission:
[A,B,C,N]=[int(i) for i in input().split()]
X=[A,B,C]
X.sort()
[C,B,A]=X
cnt=0
for i in range(N//A+1):
  k=N-(i*A)
  for j in range(k//B+1):
    if (k-(B*j))%C==0:
    	cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
s=input()
count=0
for i in range(len(s)):
  if s[i]=='R':
    count+=1
    max1=count
  elif s[i]=='S':
    count=0
print(max1)

Fixed submission:
s=input()
count=0
max=0
for i in range(len(s)):
  if s[i]=='R':
    count+=1
    max=count
  elif s[i]=='S':
    count=0
      
print(max)
Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = 1
flag = [True] * (n + 1)
flag[2] = False
for i in range(2, n + 1):
    if flag[i]: continue
    m = i
    while m <= n:
        tmp = m
        cnt = 0
        while tmp % i == 0:
            tmp = tmp // i
            cnt += 1
        flag[m] = False
        ans += m * (cnt + 1)
        m += i

print(ans)


Fixed submission:
import collections

n = int(input())

f = [1] * (n + 1)
for i in range(2, n + 1):
    if f[i] != 1: continue
    m = i
    while m <= n:
        tmp = m
        cnt = 0
        while tmp % i == 0:
            tmp = tmp // i
            cnt += 1
        f[m] *= cnt + 1
        m += i

ans = 0
for i in range(1, n + 1):
    ans += i * f[i]
print(ans)

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

n = int(input())

f = [1] * (n + 1)
for i in range(2, n + 1):
    if f[i] != 1: continue
    m = i
    while m <= n:
        tmp = m
        cnt = 0
        while tmp % i == 0:
            tmp = tmp // i
            cnt += 1
            loop += 1
        f[m] *= cnt + 1
        m += i

ans = 0
for i in range(1, n + 1):
    ans += i * f[i]
print(ans)

Fixed submission:
import collections

n = int(input())

f = [1] * (n + 1)
for i in range(2, n + 1):
    if f[i] != 1: continue
    m = i
    while m <= n:
        tmp = m
        cnt = 0
        while tmp % i == 0:
            tmp = tmp // i
            cnt += 1
        f[m] *= cnt + 1
        m += i

ans = 0
for i in range(1, n + 1):
    ans += i * f[i]
print(ans)

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

n = int(input())

f = [1] * (n + 1)
for i in range(2, n + 1):
    if f[i] != 1: continue
    m = i
    while m <= n:
        tmp = m
        cnt = 0
        while tmp % i == 0:
            tmp = tmp // i
            cnt += 1
        f[m] *= cnt + 1
        m += i

ans = 0
for i in range(1, n + 1):
    ans += i * f[i]
print(ans)


Fixed submission:
import collections

n = int(input())

f = [1] * (n + 1)
for i in range(2, n + 1):
    if f[i] != 1: continue
    m = i
    while m <= n:
        tmp = m
        cnt = 0
        while tmp % i == 0:
            tmp = tmp // i
            cnt += 1
        f[m] *= cnt + 1
        m += i

ans = 0
for i in range(1, n + 1):
    ans += i * f[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = [True] * n
for i in range(n):
    if not flag[i]: continue
    for j in range(i + 1, n):
        if a[j] % a[i] == 0:
            flag[j] = False
            if a[i] == a[j]:
                flag[i] = False
print(flag.count(True))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = [True] * (a[-1] + 1)
memo = -1
for i in a:
    if memo == i:
        flag[i] = False
        continue
    memo = i
    tmp = 2 * i
    while tmp <= a[-1]:
        flag[tmp] = False
        tmp += i
ans = 0
for i in a:
    if flag[i]: ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if a == b:
    print('YES')
elif v < w:
    print('NO')
else:
    if t < abs(a - b) / (v - w):
        print(abs(a - b) / (v - w))
        print('NO')
    else:
        print('YES')

Fixed submission:
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if a == b:
    print('YES')
elif v <= w:
    print('NO')
else:
    if t < abs(a - b) / (v - w):
        print('NO')
    else:
        print('YES')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a_min = [0] * (n + 1)
a_min[n] = a[n]
for i in range(n - 1, -1, -1):
    a_min[i] = a[i] + a_min[i + 1]

b = [1]
for i in range(n):
    tmp = b[i] - a[i]
    if tmp < 1 or tmp * 2 < a[i + 1]:
        print(-1)
        break
else:
    if n == 0:
        ans = 1 if a[0] == 1 else -1
        print(ans)
    else:
        print(sum(b))


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a_min = [0] * (n + 1)
a_min[n] = a[n]
for i in range(n - 1, -1, -1):
    a_min[i] = a[i] + a_min[i + 1]

b = [1]
for i in range(n):
    tmp = b[i] - a[i]
    b.append(min(tmp * 2, a_min[i + 1]))
    if tmp < 1 or tmp * 2 < a[i + 1]:
        print(-1)
        break
else:
    if n == 0:
        ans = 1 if a[0] == 1 else -1
        print(ans)
    else:
        print(sum(b))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, m, q = map(int, input().split())
values = [list(map(int, input().split())) for _ in range(q)]

nums = []
for i in range(m):
    tmp = [i + 1] * n
    nums.extend(tmp)
ans = 0
for comb in itertools.combinations(nums, n):
    tmp = 0
    for a, b, c, d in values:
        if comb[b - 1] - comb[a - 1] == c: tmp += d
    ans = max(tmp, ans)
print(ans)

Fixed submission:
import itertools
n, m, q = map(int, input().split())
values = [list(map(int, input().split())) for _ in range(q)]

ans = 0
for comb in itertools.combinations_with_replacement(range(1, m + 1), n):
    tmp = 0
    for a, b, c, d in values:
        if comb[b - 1] - comb[a - 1] == c: tmp += d
    ans = max(tmp, ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
r = int(input())
print(2 * r * math.pi)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = n - sum(a) if n - sum(a) >= 0 else -1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
pair = []
b_num = []
ans = 0
for i in range(n - 1):
    if s[i] == "B":
        b_num.append(i)
        continue
    for j in range(i + 1, n):
        if s[j] == "B" or s[j] == s[i]: continue
        pair.append((i, j))
if s[-1] == "B":
    b_num.append(n - 1)

for i, j in pair:
    cnt = 0
    if 2 * i - j in b_num:
        cnt += 1
    if (j - i) % 2 == 0 and (i + j) // 2 in b_num:
        cnt += 1
    if 2 * j - i in b_num:
        cnt += 1
    ans += len(b_num) - cnt
print(ans)

Fixed submission:
n = int(input())
s = input()
bad = [0] * n
pair = 0
b_num = []
ans = 0
for i in range(n - 1):
    if s[i] == "B":
        b_num.append(i)
        continue
    for j in range(i + 1, n):
        if s[j] == "B" or s[j] == s[i]: continue
        pair += 1
        if 2 * i - j >= 0:
            bad[2 * i - j] += 1
        if (j - i) % 2 == 0:
            bad[(i + j) // 2] += 1
        if 2 * j - i < n:
            bad[2 * j - i] += 1
if s[-1] == "B":
    b_num.append(n - 1)

for k in b_num:
    ans += pair - bad[k]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split())
x = min(x - 1, y - 1)
y = max(x - 1, y - 1)
length = [0] * (n - 1)
for i in range(n - 1):
    for j in range(i, n):
        l = min(abs(i - j), abs(i - x) + 1 + abs(j - y), abs(i - y) + 1 + abs(j - x))
        if l != 0:
            length[l - 1] += 1
for l in length:
    print(l)

Fixed submission:
n, x, y = map(int, input().split())
x = min(x - 1, y - 1)
y = max(x - 1, y - 1)
length = [0] * (n - 1)
for i in range(n - 1):
    for j in range(i, n):
        l = min(abs(i - j), abs(i - x) + 1 + abs(j - y), abs(i - y) + 1 + abs(j - x))
        if l != 0:
            length[l - 1] += 1
for l in length:
    print(l)

Buggy python submission (verdict: Time Limit Exceeded):
def shortest_path(s, n, es):
    d = [float('inf')] * n

    d[s] = 0
    while True:
        update = False
        for p, q in es:
            if d[p] != float('inf') and d[q] > d[p] + 1:
                d[q] = d[p] + 1
                update = True
        if not update:
            break
    return d

n, x, y = map(int, input().split())
es = [(x - 1, y - 1), (y - 1, x - 1)]
for i in range(n - 1):
    es.append((i, i + 1))
    es.append((i + 1, i))
length = [0] * (n - 1)
for i in range(n - 1):
    a = shortest_path(i, n, es)
    for l in range(i + 1, n):
        if a[l] != float('inf') and l != 0:
            length[a[l] - 1] += 1
for l in length:
    print(l)

Fixed submission:
n, x, y = map(int, input().split())
x = min(x - 1, y - 1)
y = max(x - 1, y - 1)
length = [0] * (n - 1)
for i in range(n - 1):
    for j in range(i, n):
        l = min(abs(i - j), abs(i - x) + 1 + abs(j - y), abs(i - y) + 1 + abs(j - x))
        if l != 0:
            length[l - 1] += 1
for l in length:
    print(l)
Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

ans = sum(p[:x]) + sum(q[:y])

i, j = 0, 0
while i < x and j < y and i + j < c:
    change = min(p[x - 1 - i], q[y - 1 - j])
    if r[i + j] > change:
        ans += r[i + j] - change
    elif:
        break
    if p[x - 1 - i] < q[y - 1 - j]:
        i += 1
    elif p[x - 1 - i] > q[y - 1 - j]:
        j += 1
    else:
        s, t = 0, 0
        while i + s < x and j + t < y and i + j + s + t < c:
            if p[x - 1 - i - s] < q[y - 1 - j - s]:
                i += 1
                break
            elif p[x - 1 - i - s] > q[y - 1 - j - s]:
                j += 1
                break
            else:
                s += 1
                t += 1
                if not(i + s < x and j + t < y and i + j + s + t < c):
                    i += 1
                    break

print(ans)

Fixed submission:
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

a = []
a.extend(p[:x])
a.extend(q[:y])
a.extend(r)
a.sort(reverse=True)

print(sum(a[:x + y]))