Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n=int(input())
a=list(map(int,input().split()))
c = collections.Counter(a)

a1=len(list(set(a)))

total=0
for j in range(a1):
    x=c.most_common()[j][1]
    total+=x*(x-1)/2

for i in range(n):
    ans=total-c[a[i]]+1
    print(int(ans))

Fixed submission:
import collections 
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
c=defaultdict(int)
for s in a:
    c[s]+=1

a1=list(set(a))

total=0
for j in range(len(a1)):
    x=c[a1[j]]
    total+=x*(x-1)/2

for i in range(n):
    ans=total-c[a[i]]+1
    print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n=int(input())
a=list(map(int,input().split()))
c = collections.Counter(a)

a1=len(list(set(a)))

total=0
for j in range(a1):
    x=c.most_common()[j][1]
    total+=x*(x-1)/2

for i in range(n):
    ans=total-c[a[i]]+1
    print(int(ans))

Fixed submission:
import collections 
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
c=defaultdict(int)
for s in a:
    c[s]+=1

a1=list(set(a))

total=0
for j in range(len(a1)):
    x=c[a1[j]]
    total+=x*(x-1)/2

for i in range(n):
    ans=total-c[a[i]]+1
    print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n=int(input())
a=list(map(int,input().split()))
c = collections.Counter(a)

a1=len(list(set(a)))

total=0
for j in range(a1):
    x=c.most_common()[j][1]
    total+=x*(x-1)/2

for i in range(n):
    ans=total-a.count(a[i])+1
    print(int(ans))

Fixed submission:
import collections 
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
c=defaultdict(int)
for s in a:
    c[s]+=1

a1=list(set(a))

total=0
for j in range(len(a1)):
    x=c[a1[j]]
    total+=x*(x-1)/2

for i in range(n):
    ans=total-c[a[i]]+1
    print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n=int(input())
a=list(map(int,input().split()))
c = collections.Counter(a)

#print(c.most_common())

a1=len(list(set(a)))

for i in range(n):
    ans=0
    for j in range(len(c)):
        if c.most_common()[j][1]>1:
    #登場回数が１以上の要素について考える
            if c.most_common()[j][0]==a[i]:
                x=c.most_common()[j][1]-1
            else:
                x=c.most_common()[j][1]
            ans+=x*(x-1)/2
    print(int(ans))

Fixed submission:
import collections 
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
c=defaultdict(int)
for s in a:
    c[s]+=1

a1=list(set(a))

total=0
for j in range(len(a1)):
    x=c[a1[j]]
    total+=x*(x-1)/2

for i in range(n):
    ans=total-c[a[i]]+1
    print(int(ans))
Buggy python submission (verdict: Runtime Error):
import math
n,a,b=map(int,input().split())
c=0
for i in range(1,n+1):
    c+=(math.factorial(n)//(math.factorial(n - i) * math.factorial(i)))%(pow(10,9)+7)

c=c-(math.factorial(n)//(math.factorial(n - a) * math.factorial(a)))%(pow(10,9)+7)
c=c-(math.factorial(n)//(math.factorial(n - b) * math.factorial(b)))%(pow(10,9)+7)
print(c)
#TLE

Fixed submission:
n,r=map(int,input().split())
if n>=10:
    print(r)
else:
    print(r+100*(10-n))
Buggy python submission (verdict: Runtime Error):
#コメントの作法が分かりません><
n=int(input())
s=[input() for i in range(n)]
#入力を受け取る



l=list(set(s))
#sの重複している要素を除く

l.sort()
#辞書順に出力しないといけないので並べ替える

a=[]
#空のリストを作る

for i in range(len(l)):
    a.append(s.count(l[i]))
    #s中の各要素の登場回数を数えてリストaに入れる

r j in range(len(a)):
    while a[j]==max(a):
        print(l[j])
        j+=1

#aの各要素について、最大値を取っているならば
#そのaに対応する文字列を出力する

Fixed submission:
n=int(input())
s=[input() for i in range(n)]
s=sorted(s)
s.append('')
s1=s[0]
ans=['']
tmp=1
kaisu=0
for i in range(1,n+1):
    if s[i]==s1:
        #ひとつ前と同じものだったら回数を１増やす
        tmp+=1
    else:
        if kaisu<tmp:
        #これまでの要素の最高登場回数よりも
        # 当該要素の登場回数が多ければ
        # リストを書き換える
            ans=['']
            ans.append(s1)
            kaisu=tmp
        elif kaisu==tmp:
        #最高回数と等しければリストに追加する
            ans.append(s1)
        tmp=1
        s1=s[i]
        
for i in range(1,len(ans)):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
aa=0
for i in range(n):
    if a.count(a[i])!=1:
        print('NO')
        aa+=1
        break
if aa==0:
    print('YES')

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
s=set(a)

if len(a)==len(s):
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
aa=0
for i in range(n):
    for j in range(i+1,n):
        if a[i]==a[j]:
            print('NO')
            aa+=1
            break
        else:
            pass
if aa==0:
    print('YES')
        

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
s=set(a)

if len(a)==len(s):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split(' '))
if(a>k):
    a=a-k
elif (a<=k):
    aa=0
    b=max(b+a-k,0)
print(str(aa)+' '+str(b))

Fixed submission:
a,b,k=map(int,input().split(' '))
if(a>k):
    aa=a-k
elif (a<=k):
    aa=0
    b=max(b+a-k,0)
print(str(aa)+' '+str(b))

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split(' '))
if(a>k):
    a=a-k
elif (a<=k):
    aa=0
    b=b+a-k
print(str(aa)+' '+str(b))

Fixed submission:
a,b,k=map(int,input().split(' '))
if(a>k):
    aa=a-k
elif (a<=k):
    aa=0
    b=max(b+a-k,0)
print(str(aa)+' '+str(b))
Buggy python submission (verdict: Runtime Error):
input()
if s == 'SUN':
  print('7')
elif s == 'MON':
  print('6') 
elif s == 'TUE':
  print('5') 
elif s == 'WED':
  print('4')
elif s == 'THU':
  print('3')
elif s == 'FRI':
  print('2')
else:
  print('1') 

Fixed submission:
s=input()
if s == 'SUN':
  print('7')
elif s == 'MON':
  print('6') 
elif s == 'TUE':
  print('5') 
elif s == 'WED':
  print('4')
elif s == 'THU':
  print('3')
elif s == 'FRI':
  print('2')
else:
  print('1')
Buggy python submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
p=[k-q]*n
for i in range(q):
   #q回の正解が出る
    r=a[i]
    p[r]=p[r]+1
for i in range(n):
    if p[i]>0:
        print('Yes')
    else:
        print('No')

Fixed submission:
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
p=[k-q]*n
for i in range(q):
   #q回の正解が出る
    r=a[i]-1
    p[r]=p[r]+1
    #正解したら１点多くなる
for i in range(n):
    if p[i]>0:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
p=[k-q]*n
print(p)
for i in range(q):
   #q回の正解が出る
   r=a[i]
   print(a[i])
   p[r]=p[r]+1
for i in range(n):
    if p[i]>0:
        print('Yes')
    else:
        print('No')

Fixed submission:
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
p=[k-q]*n
for i in range(q):
   #q回の正解が出る
    r=a[i]-1
    p[r]=p[r]+1
    #正解したら１点多くなる
for i in range(n):
    if p[i]>0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
a=0
for i in range (0,2):
    if s[i]=t[i]
    a=a+1
print(a)

Fixed submission:
s=input()
t=input()
a=0
for i in range (0,3):
    if s[i]==t[i]:
        a=a+1
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
h=list(map(int,input().split()))
t=0
#移動回数
c=0
for i in range(n-1):
    c=0
    for j in range(n-i-1):
        if h[i+j]>=h[i+j+1]:
            c+=1
        else:
            break
    if c>=t:
        t=c
print(t)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
count=0
t=0
for i in range(n-1):
    if h[i]>=h[i+1]:
        t+=1
    else:
        count=max(count,t)
        t=0
    count=max(count,t)
print(count)
Buggy python submission (verdict: Runtime Error):
a=input()
print(3*a*a)


Fixed submission:
a=int(input())
print(3*a*a)
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
a=1
for i in range(n-1):
    a+=1
    d+=l[i]
    #print(d)
    if d>x:
        break


print(a)

Fixed submission:
x,a=map(int,input().split())
if x>=a:
    print('10')
else:
    print('0')
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
a=0
i=0
while d<x:
    d+=l[i]
    a+=1
    i+=1
if d==x:
    a+=1
print(a)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
a=1
for i in range(n):
    d+=l[i]
    #print(d)
    if d<=x:
        a+=1
print(a)

Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
a=0
i=0
while d<=x:
    d+=l[i]
    a+=1
    i+=1
print(a)


Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
a=1
for i in range(n):
    d+=l[i]
    #print(d)
    if d<=x:
        a+=1
print(a)
Buggy python submission (verdict: Runtime Error):
a,b=(int (x) for x in input().split())
if a<=5:
  print(0)
elif a<=12:
  print(int((b/2))
else:
  print(b)

Fixed submission:
a,b=(int (x) for x in input().split())
if a<=5:
  print(0)
elif a<=12:
  print(int(b/2))
else:
  print(b)
Buggy python submission (verdict: Runtime Error):
a=list(input().split())
a.sort()
if int(a[1])!=int(a[2]):
	print (2*int(a[1])-1)
else:
	print (2*int(a[1]))

Fixed submission:
a_str=input().split()
a=[int(i) for i in a_str]
a.sort()

if int(a[1]) != int(a[0]):
	print (2*int(a[1])-1)
else:
	print (int(a[0]) + int(a[1]))
Buggy python submission (verdict: Runtime Error):
H,W=(int,input().split())
h,w=(int,input().split())
S=H*W
print(S-(H*w+W*h)+w*h)


Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
S=H*W
Hw=H*w
Wh=W*h
wh=w*h
print(S-Hw-Wh+wh)

Buggy python submission (verdict: Runtime Error):
H,W=(int,input().split())
h,w=(int,input().split())
S=H*W
print(S-(H*w+W*h)+w*h)
#どうやっても想定と違う値が出る　後で考え直す


Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
S=H*W
Hw=H*w
Wh=W*h
wh=w*h
print(S-Hw-Wh+wh)
Buggy python submission (verdict: Runtime Error):
s = 'S'

print(len(s))

s_length = len(s)
print(s_length)

if s_length=2
print (s)

else print str[::-1]
str = "S"

Fixed submission:
str = input()

if len(str)==(2): 
  print(str)
else:
  print(str[::-1])
Buggy python submission (verdict: Runtime Error):
y=int(input())
a=int(input())
b=int(input())

if y==1:
  print('Hello World')
else:
  print(a+b)


Fixed submission:
y=int(input())

if y==1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(int(a+b))
Buggy python submission (verdict: Runtime Error):
a,b=int(input.split())
print(a-b+1)

Fixed submission:
a,b= (int(i) for i in input().split())  
print(a-b+1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
elif n<105:
  print(0)
elif n<135:
  print(1)
elif n<165:
  print(2)
else:
  print(3)


Fixed submission:
n=int(input())
if n<105:
  print(0)
elif n<135:
  print(1)
elif n<165:
  print(2)
elif n<189:
  print(3)
elif n<195:
  print(4)
else:
  print(5)
Buggy python submission (verdict: Runtime Error):
n = input()
a = list(map(int,input().split()))

 print(max(a)-min(a))


Fixed submission:
n = input()
a = list(map(int,input().split()))
print(max(a)-min(a))
Buggy python submission (verdict: Runtime Error):
a,b=(int(i) for i in input().split())
if a>=9
  print(':(')
elif b>=9:
  print(':(')
else:
  print('Yay!')

Fixed submission:
a,b=(int(x) for x in input().split())
if a>=9:
  print(':(')
elif b>=9:
  #ここ↑のイコールを忘れてた
  print(':(')
else:
  print('Yay!')

Buggy python submission (verdict: Runtime Error):
a,b=int(input().split())
if a>=9:
  print('')
elif b>=9:
  print(':(')
else:
  print('Yay!')


Fixed submission:
a,b=(int(x) for x in input().split())
if a>=9:
  print(':(')
elif b>=9:
  #ここ↑のイコールを忘れてた
  print(':(')
else:
  print('Yay!')

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
if a>=9:
  print('')
elif b>=9:
  print(':(')
else:
  print('Yay!')

Fixed submission:
a,b=(int(x) for x in input().split())
if a>=9:
  print(':(')
elif b>=9:
  #ここ↑のイコールを忘れてた
  print(':(')
else:
  print('Yay!')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
c=0
b=a[0]
for i in range(1,n):
    b=b*a[i]

for i in range(100000):
    if b%2==0:
        b=b//2
        c+=1
print(c)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(0,n):
    while a[i]%2==0:
        a[i]=a[i]//2
        c+=1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
for i in range(a,b+1):
    if i<a+k:
        print(i)
    elif b-k<i:
        print(i)

Fixed submission:
a,b,k=map(int,input().split())
if k*2>b:
    for i in range(a,b+1):
        if i<a+k:
            print(i)
        elif b-k<i:
            print(i)
else:
    for i in range(a,min(a+k,b+1)):
        print(i)
    for i in range(max(a+k,b-k+1),b+1):
        print(i)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
l=[]
ll=[]
for i in range(a,b+1):
    l.append(i)
i=0
j=0
while True:
    print(l[0])
    l.pop(0)
    j+=1
    if len(l)==0 or j==k:
        break
while True:   
    if len(l)==0 or i==k:
        break    
    ll.append(l[-1])
    l.pop()
    i+=1
ll.sort()
for i in range(len(ll)):
    print(ll[i])

Fixed submission:
a,b,k=map(int,input().split())
if k*2>b:
    for i in range(a,b+1):
        if i<a+k:
            print(i)
        elif b-k<i:
            print(i)
else:
    for i in range(a,min(a+k,b+1)):
        print(i)
    for i in range(max(a+k,b-k+1),b+1):
        print(i)
Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(0,n):
    if n==1 or n==2:
        print(n)
        break
    if n>=i*i:
        pass
    else:
        print((i-1)*(i-1))
        break

Fixed submission:
a=input()
b=input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
li=list(input())
n=1
c=len(li)+n

while n<=c:
  li=li.pop(n)
  n=n+1

print(li)

Fixed submission:
import math
s=input()
li=[]

l=len(s)+1

for i in range(0,math.floor(l/2)):
    li.append(s[2*i])

str=''.join(li)
print(str)

Buggy python submission (verdict: Runtime Error):
li=list(input())
n=1
c=len(li)+n

while n<=c:
  
  li=li.pop(n)
  n=n+1

print(a)

Fixed submission:
import math
s=input()
li=[]

l=len(s)+1

for i in range(0,math.floor(l/2)):
    li.append(s[2*i])

str=''.join(li)
print(str)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if b<=c or d<=a:
    print(0)
else:
    print(min(d,b)-max(a,c))

Fixed submission:
n=input()
if len(n)%2==0:
    m=int(len(n)/2)
else:
    m=int((len(n)-1)/2)

a=0

for i in range(m):
    if n[i]==n[-1*(i+1)]:
       continue
    else:
        a+=1

if a==0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
c=[]
for i in range(n):
    if a[i]<=399:
        c.append('0')
    elif a[i]<=799:
        c.append('1') 
    elif a[i]<=1199:
        c.append('2')
    elif a[i]<=1599:
        c.append('3')
    elif a[i]<=1999:
        c.append('4')
    elif a[i]<=2399:
        c.append('5')
    elif  a[i]<=2799:
        c.append('6')
    elif  a[i]<=3199:
        c.append('7')
x=n-len(c)
#3200以上の人数
c=list(set(c))

print(max(len(c),1), len(c)+x)

Fixed submission:
r,g,b=map(int,input().split())
if (10*g+b)%4==0:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
c=[]
for i in range(n):
    if a[i]<=399:
        c.append('gray')
    elif a[i]<=799:
        c.append('br') 
    elif a[i]<=1199:
        c.append('green')
    elif a[i]<=1599:
        c.append('pb')
    elif a[i]<=1999:
        c.append('bl')
    elif a[i]<=2399:
        c.append('y')
    elif  a[i]<=2799:
        c.append('o')
    elif  a[i]<=3199:
        c.append('r')
x=n-len(c)
#3200以上の人数
c=list(set(c))
k=min(8,len(c)+x)
print(len(c),k)

Fixed submission:
r,g,b=map(int,input().split())
if (10*g+b)%4==0:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
st=''
for i in range(len(s)):
    st+=s[i]
    st+=t[i]
print(st)

Fixed submission:
s=input()+' '
t=input()+' '
st=''

for i in range(min(len(s),len(t))):
    st+=s[i]
    st+=t[i]
print(st.strip())
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
for i in range(1,n):
    n=n*i
print(n%(pow(10,9)+7))

Fixed submission:
n=int(input())
p=1
for i in range(1,n+1):
    p=p%(pow(10,9)+7)*i
print(p%(pow(10,9)+7))
Buggy python submission (verdict: Runtime Error):
a,b=map(int(input().split()))
s=[2,3,4,5,6,7,8,9,10,11,12,13,1]
if s.index(a)==s.index(b):
    print('Draw')
elif s.index(a)>s.index(b):
    print('Alice')
else:
    print('Bob')

Fixed submission:
a,b=map(int,input().split())
s=[2,3,4,5,6,7,8,9,10,11,12,13,1]
if s.index(a)==s.index(b):
    print('Draw')
elif s.index(a)>s.index(b):
    print('Alice')
else:
    print('Bob')

Buggy python submission (verdict: Runtime Error):
a,b=map(int(input().split()))
s=[2,3,4,5,6,7,8,9,10,11,12,13,1]
if a.index=b.index:
    print('Draw')
elif a.index>b.index:
    print('Alice')
else:
    print('Bob')

Fixed submission:
a,b=map(int,input().split())
s=[2,3,4,5,6,7,8,9,10,11,12,13,1]
if s.index(a)==s.index(b):
    print('Draw')
elif s.index(a)>s.index(b):
    print('Alice')
else:
    print('Bob')
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
h=int(input())
print(int(((a+b)*h/2))


Fixed submission:
a=int(input())
b=int(input())
h=int(input())
print(int(((a+b)*h/2)))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))
tmp = 1
route = [tmp]

for i in range(1, k + 1):
    tmp = A[tmp - 1]
    if tmp in route:
        left = route.index(tmp)
        right = len(route)
        idx = left + (k - left) % (right - left)
        print(route[idx])
        break
    else:
        route.append(tmp)
        continue
else:
    print(tmp)

Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))
tmp = 1
route = [tmp]
edge = {tmp}

for i in range(1, k + 1):
    tmp = A[tmp - 1]
    if tmp in edge:
        left = route.index(tmp)
        right = len(route)
        idx = left + (k - left) % (right - left)
        print(route[idx])
        break
    else:
        route.append(tmp)
        edge.add(tmp)
        continue
else:
    print(tmp)
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def main():
    n, k = map(int, input().split())
    ans = 0
    for i in range(k, n + 2):
        ans += i * (n - i + 1) + 1
    print(ans%MOD)


if __name__ == '__main__':
    main()

Fixed submission:
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
MOD = 10**9 + 7

def main():
    n, k = map(int, input().split())
    ans = 0
    for i in range(k, n + 2):
        ans += i * (n - i + 1) + 1
    print(ans%MOD)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n, m = map(int, input().split())
a = list(map(int, input().split()))
total = sum(a)
must = total / (4 * m)
cnt = 0
for c in combinations(a, m):
    flag = True
    for i in c:
        if i < must:
            flag = False
            break
    if flag:
        print("Yes")
        exit()
    else:
        continue
print("No")

Fixed submission:
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    total = sum(a)
    must = total / (4 * m)
    cnt = 0
    for i in a:
        if i >= must:
            cnt += 1
            if cnt == m:
                print("Yes")
                exit()
    print("No")


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
pp = p[:]
q = sorted(list(map(int, input().split())), reverse=True)
qq = q[:]
r = sorted(list(map(int, input().split())), reverse=True)
rr = r[:]
ans1 = 0
for _ in range(x):
    if len(p) > 0 and len(r) > 0:
        if p[0] >= r[0]:
            ans1 += p.pop(0)
        else:
            ans1 += r.pop(0)
    elif len(p) > 0:
        ans1 += p.pop(0)
    else:
        ans1 += r.pop(0)
for _ in range(y):
    if len(q) > 0 and len(r) > 0:
        if q[0] >= r[0]:
            ans1 += q.pop(0)
        else:
            ans1 += r.pop(0)
    elif len(q) > 0:
        ans1 += q.pop(0)
    else:
        ans1 += r.pop(0)

ans2 = 0
for _ in range(y):
    if len(qq) > 0 and len(rr) > 0:
        if qq[0] >= rr[0]:
            ans2 += qq.pop(0)
        else:
            ans2 += rr.pop(0)
    elif len(qq) > 0:
        ans2 += qq.pop(0)
    else:
        ans2 += rr.pop(0)
for _ in range(x):
    if len(pp) > 0 and len(rr) > 0:
        if pp[0] >= rr[0]:
            ans2 += pp.pop(0)
        else:
            ans2 += rr.pop(0)
    elif len(pp) > 0:
        ans2 += pp.pop(0)
    else:
        ans2 += rr.pop(0)
print(max(ans1, ans2))


Fixed submission:
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
pp = p[:x]
q = sorted(list(map(int, input().split())), reverse=True)
qq = q[:y]
r = list(map(int, input().split()))

l = pp + qq + r
l.sort(reverse=True)
print(sum(l[:(x + y)]))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict, deque, Counter


def main():
    n = int(input())
    A = list(map(int, input().split()))
    dd = defaultdict(int)
    ans = []
    for i in A:
        dd[i] += 1
    for i in range(n):
        ng = A[i]
        dd[ng] -= 1
        cnt = 0
        for key, val in dd.items():
            cnt += val * (val-1) // 2
        ans.append(cnt)
        dd[ng] += 1
    print(*ans, sep='\n')



if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter


n = int(input())
A = list(map(int, input().split()))
c = Counter(A)
cc = c.most_common()
ans = 0
for i in range(len(cc)):
    n = cc[i][1]
    if n < 2:
        break
    ans += n * (n-1) // 2

for i in A:
    cnt = c[i]
    if cnt == 1:
        print(ans)
    else:
        ans_ = ans + (cnt-1)*(cnt-2) // 2 - cnt*(cnt-1)//2
        print(ans_)

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


n = int(input())
A = list(map(int, input().split()))
c = Counter(A).most_common()
ans = 0
for i in range(len(c)):
    n = c[i][1]
    if n < 2:
        break
    ans += n * (n-1) // 2
for i in A:
    cnt = A.count(i)
    if cnt == 1:
        print(ans)
    else:
        ans_ = ans + (cnt-1)*(cnt-2) // 2 - cnt*(cnt-1)//2
        print(ans_)


Fixed submission:
from collections import Counter


n = int(input())
A = list(map(int, input().split()))
c = Counter(A)
cc = c.most_common()
ans = 0
for i in range(len(cc)):
    n = cc[i][1]
    if n < 2:
        break
    ans += n * (n-1) // 2

for i in A:
    cnt = c[i]
    if cnt == 1:
        print(ans)
    else:
        ans_ = ans + (cnt-1)*(cnt-2) // 2 - cnt*(cnt-1)//2
        print(ans_)