Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[0]+list(map(int,input().split()))
from itertools import accumulate
l=list(accumulate(l))
from bisect import bisect, bisect_left, bisect_right
ans=10**15
for i in range(2,n-1):
  	x=bisect_left(l,l[i]//2)
    p1=l[x]
    p2=l[x-1]
    if abs(l[i]-p1*2)>=abs(l[i]-p2*2):
        p=p2
    else:
        p=p1
    q=l[i]-p
    x=bisect_left(l,(l[n]-l[i])//2+l[i])
    r1=l[x]-l[i]
    r2=l[x-1]-l[i]
    if abs(l[n]-l[i]-r1*2)>=abs(l[n]-l[i]-r2*2):
        r=r2
    else:
        r=r1
    s=l[n]-l[i]-r
    ans=min(ans,max(p,q,r,s)-min(p,q,r,s))
print(ans)

Fixed submission:
n=int(input())
l=[0]+list(map(int,input().split()))
from itertools import accumulate
l=list(accumulate(l))
from bisect import bisect, bisect_left, bisect_right
ans=10**15
for i in range(2,n-1):
    x=bisect_left(l,l[i]//2)
    p1=l[x]
    p2=l[x-1]
    if abs(l[i]-p1*2)>=abs(l[i]-p2*2):
        p=p2
    else:
        p=p1
    q=l[i]-p
    x=bisect_left(l,(l[n]-l[i])//2+l[i])
    r1=l[x]-l[i]
    r2=l[x-1]-l[i]
    if abs(l[n]-l[i]-r1*2)>=abs(l[n]-l[i]-r2*2):
        r=r2
    else:
        r=r1
    s=l[n]-l[i]-r
    ans=min(ans,max(p,q,r,s)-min(p,q,r,s))
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
ans=[]
xyz=[[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
if(m==0):
  print("0")
else:
 for j in xyz:
   x,y,z=j
   lst=[]
   for i in range(m):
      b=a[i][0]*x+a[i][1]*y+a[i][2]*z
      lst+=[b]
   for i in range(m,n):
      b=a[i][0]*x+a[i][1]*y+a[i][2]*z
      if(min(lst)<b):
         lst.remove(min(lst))
         lst+=[b]
   ans+=[sum(lst)]
print(max(ans))

Fixed submission:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
ans=[]
xyz=[[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
if(m==0):
  print("0")
else:
 for j in xyz:
   x,y,z=j
   lst=[]
   for i in range(m):
      b=a[i][0]*x+a[i][1]*y+a[i][2]*z
      lst+=[b]
   for i in range(m,n):
      b=a[i][0]*x+a[i][1]*y+a[i][2]*z
      if(min(lst)<b):
         lst.remove(min(lst))
         lst+=[b]
   ans+=[sum(lst)]
 print(max(ans))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
ans=[]
xyz=[[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
for j in xyz:
   x,y,z=j
   lst=[]
   for i in range(m):
      b=a[i][0]*x+a[i][1]*y+a[i][2]*z
      lst+=[b]
   for i in range(m,n):
     b=a[i][0]*x+a[i][1]*y+a[i][2]*z
     if(min(lst)<b):
        lst.remove(min(lst))
        lst+=[b]
   ans+=[sum(lst)]
print(max(ans))
  

Fixed submission:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
ans=[]
xyz=[[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
if(m==0):
  print("0")
else:
 for j in xyz:
   x,y,z=j
   lst=[]
   for i in range(m):
      b=a[i][0]*x+a[i][1]*y+a[i][2]*z
      lst+=[b]
   for i in range(m,n):
      b=a[i][0]*x+a[i][1]*y+a[i][2]*z
      if(min(lst)<b):
         lst.remove(min(lst))
         lst+=[b]
   ans+=[sum(lst)]
 print(max(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
w=0
e=0
ans=0
for i in s:
  if(i="W"):
    ans=min(ans,ans-e+w)
    w+=1
  else:
    e+=1
    ans=min(ans,ans-e+w)
print(ans+e)    

Fixed submission:
n=int(input())
s=input()
w=0
e=0
ans=1
for i in s:
  if(i=="W"):
    ans=min(ans,-e+w)
    w+=1
  else:
    e+=1
    ans=min(ans,-e+w)
print(ans+e)
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
n=int(input())
l=[int(input()) for i in range(n)]
if l[0]!=0:
    print(-1)
    quit()
l.reverse()
ans=0
i=0
while i<n-2:
    if l[i]>n-i-1:
        print(-1)
        quit()
    if l[i+1]+1==l[i]:
        ans+=l[i]
        while l[i+1]+1==l[i]:
            i+=1
    elif l[i+1]+1<l[i]:
        print(-1)
        quit()
    else:
        ans+=l[i]
        i+=1
print(ans)

Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
l=[int(input()) for i in range(n)]
if l[0]!=0:
    print(-1)
    quit()
l.reverse()
l+=[0]
ans=0
i=0
while i<n-1:
    if l[i]>n-i-1:
        print(-1)
        quit()
    if l[i+1]+1==l[i]:
        ans+=l[i]
        while l[i+1]+1==l[i]:
            i+=1
        i+=1
    elif l[i+1]+1<l[i]:
        print(-1)
        quit()
    else:
        ans+=l[i]
        i+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
s=0
dic={}
for i in a:
  s+=i
  dic.get(s,0)+=1
  ans+=dic[s]-s!=0
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
s=0
dic={}
for i in a:
  s+=i
  dic[s]=dic.get(s,0)+1
  ans+=dic[s]
  if s!=0:
      ans-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
a="abcdefghijklmnopqrstuvwxyz"
if(s==a[::-1]):
    print(-1)
else:
    if(len(s)==26):
        c=s[-1]
        i=2
        while 1:
            if(s[-i]<c):
                print(s[:26-i]+c)
                break
            else:
                i+=1
    else:
        for i in a:
            if(not i in s):
                print(s+i)
                break

Fixed submission:
s=input()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    quit()
elif len(s)<26:
    d=set([i for i in range(26)])
    for i in s:
        d.remove(ord(i)-97)
    print(s+chr(min(d)+97))
else:
    d=[ord(s[-1])]
    for i in range(25):
        c=s[-2-i]
        if max(d)<ord(c):
            d.append(ord(c))
        else:
            print(s[:26-2-i]+chr(min([i for i in d if i>ord(c)])))
            break

Buggy python submission (verdict: Runtime Error):
s=input()
a="abcdefghijklmnopqrstuvwxyz"
if(s==a[::-1]):
    print(-1)
else:
    if(len(s)==26):
        c=s[-1]
        i=2
        while 1:
            if(s[-i]<c):
                print(s[:26-i]+c)
                break
            else:
                i+=1
    else:
        for i in a:
            if(not i in s):
                print(s+i)
                break

Fixed submission:
s=input()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    quit()
elif len(s)<26:
    d=set([i for i in range(26)])
    for i in s:
        d.remove(ord(i)-97)
    print(s+chr(min(d)+97))
else:
    d=[ord(s[-1])]
    for i in range(25):
        c=s[-2-i]
        if max(d)<ord(c):
            d.append(ord(c))
        else:
            print(s[:26-2-i]+chr(min([i for i in d if i>ord(c)])))
            break
Buggy python submission (verdict: Runtime Error):
n,C=map(int,input().split())
import collections
d=collections.defaultdict(list)
for i in range(n):
    s,t,c=map(int,input().split())
    d[c].append((s,t))
T=[0 for i in range(2*10**5+1)]
for i in d.values():
    i.sort()
    T[i[0][0]*2-1]+=1
    T[i[-1][1]*2+1]-=1
    for x,y in zip(i,i[1:]):
        s1,t1=x
        s2,t2=y
        if t1!=s2:
            T[s2*2-1]+=1
            T[t1*2+1]-=1
from itertools import accumulate
T=list(accumulate(T))
print(max(T))

Fixed submission:
n,C=map(int,input().split())
import collections
d=collections.defaultdict(list)
for i in range(n):
    s,t,c=map(int,input().split())
    d[c].append((s,t))
T=[0 for i in range(2*10**5+3)]
for i in d.values():
    i.sort()
    T[i[0][0]*2-1]+=1
    T[i[-1][1]*2+1]-=1
    for x,y in zip(i,i[1:]):
        s1,t1=x
        s2,t2=y
        if t1!=s2:
            T[s2*2-1]+=1
            T[t1*2+1]-=1
from itertools import accumulate
T=list(accumulate(T))
print(max(T))
Buggy python submission (verdict: Runtime Error):
s=input()
if(len(s)>9):
    print("NO")
    quit()
i=0
for c in "AKIHABAR":
    if(s[i]==c):
        i+=1
    else:
        if(c=="A"):
            continue
        else:
            print("NO")
            quit()
print("YES")

Fixed submission:
s=input()
if(len(s)>9):
    print("NO")
    quit()
i=0
for c in "AKIHABAR":
    if(len(s)==i):
      print("NO")
      quit()
    if(s[i]==c):
        i+=1
    else:
        if(c!="A"):
            print("NO")
            quit()
print("YES")
Buggy python submission (verdict: Runtime Error):
import networkx as nx
G=nx.DiGraph()
G.add_nodes_from([i for i in range(0,10)])
h,w=map(int,input().split())
for i in range(10):
    l=list(map(int,input().split()))
    for j in range(10):
         G.add_edge(i,j,weight=l[j])
d={}
for i in range(10):
    l,p=nx.multi_source_dijkstra(G,[i],target=1)
    d[i]=l
ans=0
for i in range(h):
    l=list(map(int,input().split()))
    for j in l:
        ans+=d.get(j,0)
print(ans)

Fixed submission:
from heapq import *
h,w=map(int,input().split())
g=[[] for i in range(10)]
for i in range(10):
    l=list(map(int,input().split()))
    for j in range(10):
         g[i].append([l[j],j])
d={}
for i in range(10):
    q=[[0,i]]
    heapify(q)
    l=[-1 for i in range(10)]
    while l[1]==-1:
        c,t=heappop(q)
        if(l[t]==-1):
            l[t]=c
            for j in g[t]:
                C,T=j
                if(l[T]==-1):
                    heappush(q,[c+C,T])
    d[i]=l[1]           
ans=0
for i in range(h):
    l=list(map(int,input().split()))
    for j in l:
        ans+=d.get(j,0)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=[list(map(int,input().split())) for i in range(n)]
def fill(l,x):
    w=len(l[0])
    return [[x]*(w+2)]+[[x]+i+[x] for i in l]+[[x]*(w+2)]
def swap(a,b):
    if a>b:
        return b,a
    return a,b
d=fill(d,0)
edge=[{} for i in range(n+1)]
for j in range(1,n+1):
    for i in range(j+1,n+1):
        edge[j][i]=d[i][j]
for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(1,n+1):
            if  d[i][j]>d[i][k]+d[k][j]:
                print(-1)
                quit()
            elif d[i][j]==d[i][k]+d[k][j]:
                if k==i or k==j:
                    continue
                x,y=swap(i,j)
                if y in edge[x]:
                    del edge[x][y]
ans=0
for i in edge:
    ans+=sum(i.values())
print(ans)

Fixed submission:
n=int(input())
d=[list(map(int,input().split())) for i in range(n)]
def fill(l,x):
    w=len(l[0])
    return [[x]*(w+2)]+[[x]+i+[x] for i in l]+[[x]*(w+2)]
def swap(a,b):
    if a>b:
        return b,a
    return a,b
d=fill(d,0)
edge=[{} for i in range(n+1)]
for j in range(1,n+1):
    for i in range(j+1,n+1):
        edge[j][i]=d[i][j]
for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(1,n+1):
            if  d[i][j]>d[i][k]+d[k][j]:
                print(-1)
                quit()
            elif d[i][j]==d[i][k]+d[k][j]:
                if k==i or k==j:
                    continue
                x,y=swap(i,j)
                if y in edge[x]:
                    del edge[x][y]
ans=0
for i in edge:
    ans+=sum(i.values())
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
n=int(input())
l=[int(input()) for i in range(n-1)]
import collections
d=collections.defaultdict(list)
for i,j in enumerate(l,2):
    d[j].append(i)
def f(a):
    if len(d[a])==0:
        return 0
    else:
        l=[f(i) for i in d[a]]
        l.sort(reverse=True)
        return max([i+l[i]+1 for i in range(len(l))])
print(f(1))

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(200000)
n=int(input())
l=[int(input()) for i in range(n-1)]
d=[[] for i in range(n+1)]
for i,j in enumerate(l,2):
    d[j].append(i)
l.clear()
def f(a):
    if len(d[a])==0:
        return 0
    l=[f(i) for i in d[a]]
    l.sort(reverse=True)
    return max([i+l[i]+1 for i in range(len(l))])
print(f(1))
Buggy python submission (verdict: Runtime Error):
sx, sy, tx, ty=map(int, input().split())
print("D"+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"*(tx-sx+1)+"D"*(tx-sx)+
      "L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"*(tx-sx+1)"L"*(tx-sx))

Fixed submission:
sx, sy, tx, ty=map(int, input().split())
print("D"+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"*(tx-sx+1)+"D"*(ty-sy)+
      "L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"*(ty-sy+1)+"L"*(tx-sx))
Buggy python submission (verdict: Time Limit Exceeded):
n,x=map(int, input().split())
lst=list(map(int, input().split()))
ms=lst
lst=lst*2
ans=10**15
s=0
for i in range(n):
    s=i*x
    for j in range(n):
        ms[j]=min(ms[j],lst[n+j-i])
        s+=ms[j]
    ans=min(ans,s)
print(ans)


Fixed submission:
n,x=map(int, input().split())
lst=list(map(int, input().split()))
ms=lst
lst=lst*2
ans=10**15
s=0
for i in range(n):
    s=i*x
    for j in range(n):
        ms[j]=min(ms[j],lst[n+j-i])
        s+=ms[j]
    ans=min(ans,s)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,x=map(int, input().split())
lst=list(map(int, input().split()))
lst=lst*2
ans=10**15
s=0
for i in range(n):
    s=i*x
    for j in range(n):
        s+=min(lst[n+j-i:n+j+1])
    ans=min(ans,s)
print(ans)

Fixed submission:
n,x=map(int, input().split())
lst=list(map(int, input().split()))
ms=lst
lst=lst*2
ans=10**15
s=0
for i in range(n):
    s=i*x
    for j in range(n):
        ms[j]=min(ms[j],lst[n+j-i])
        s+=ms[j]
    ans=min(ans,s)
print(ans)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = input()
C = int(input())
d = b[k-1]
new = [e for e in b if e != d]
while(len(new)>i):
  f = new[i]
  b[f] = '*'
  i = i+1
print(b)

Fixed submission:
N=int(input())
S=str(input())
K=int(input())
W=S[K-1]
for i in range(N):
  if S[i]!=W:
    S=S.replace(S[i],'*')
print(S)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = input()
c = int(input())
d = b[k-1]
new = [e for e in b if e != d]
while(len(new)>i):
  f = new[i]
  b[f] = '*'
  i = i+1
print(b)

Fixed submission:
N=int(input())
S=str(input())
K=int(input())
W=S[K-1]
for i in range(N):
  if S[i]!=W:
    S=S.replace(S[i],'*')
print(S)

Buggy python submission (verdict: Runtime Error):
a = 0
a = int(input())
b = input()
c = 0
c = int(input())
d = b[k-1]
new = [e for e in b if e != d]
while(len(new)>i):
  f = new[i]
  b[f] = '*'
  i = i+1
print(b)  

Fixed submission:
N=int(input())
S=str(input())
K=int(input())
W=S[K-1]
for i in range(N):
  if S[i]!=W:
    S=S.replace(S[i],'*')
print(S)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = input()
c = int(input())
d = b[k-1]
new = [e for e in b if e != d]
while(len(new)>i):
  f = new[i]
  b[f] = '*'
  i = i+1
print(b)  

Fixed submission:
N=int(input())
S=str(input())
K=int(input())
W=S[K-1]
for i in range(N):
  if S[i]!=W:
    S=S.replace(S[i],'*')
print(S)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = input()
c = int(input())
d = b[k-1]
new = [e for e in b if e != d]
while(len(new)>i):
  f = new[i]
  b[f] = '*'
  i = i+1
print(b)  

Fixed submission:
N=int(input())
S=str(input())
K=int(input())
W=S[K-1]
for i in range(N):
  if S[i]!=W:
    S=S.replace(S[i],'*')
print(S)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = input()
c = int(input())
d = b[k-1]
new = [e for e in b if e != d]
while(len(new)>i):
  f = new[i]
  b[f] = '*'
  i++
print(b)  

  
  
  

Fixed submission:
N=int(input())
S=str(input())
K=int(input())
W=S[K-1]
for i in range(N):
  if S[i]!=W:
    S=S.replace(S[i],'*')
print(S)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = input()
c = int(input())
d = b[k-1]
new = [e for e in b if e == d]

Fixed submission:
N=int(input())
S=str(input())
K=int(input())
W=S[K-1]
for i in range(N):
  if S[i]!=W:
    S=S.replace(S[i],'*')
print(S)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
q = int(input())
 
f = [a,b,c,d,e]

 
g=f[4]-f[3]
h=f[4]-f[2]
i=f[4]-f[1]
j=f[4]-f[0]
k=f[3]-f[2]
l=f[3]-f[1]
m=f[3]-f[0]
n=f[2]-f[1]
o=f[2]-f[0]
p=f[1]-f[0]

 
if g<q and h<q and i<q and j<q and k<q and l<q and m<q and m<q and n<q and o<q p<q:
  print("Yay!")
 
else:
  print(":(")

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
q = int(input())
 
f=e-d
g=e-c
h=e-b
i=e-a
j=d-c
k=d-b
l=d-a
m=c-b
n=c-a
o=b-a

 
 
if f<=q and g<=q and h<=q and i<=q and j<=q and k<=q and l<=q and m<=q and n<=q and o<=q:
  print("Yay!")
 
else:
  print(":(")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
q = int(input())

f = [a,b,c,d,e]
f.sort()

g = f[1]-f[0]
h = f[2]-f[0]
i = f[3]-f[0]
j = f[4]-f[0]
k = f[2]-f[1]
l = f[3]-f[1]
m = f[4]-f[1]
n = f[3]-f[2]
o = f[4]-f[2]
p = f[4]-f[3]

if g<q and h<q and i<q and j<q and k<q and l<q and m<q and m<q and n<q and o<q p<q:
  print("Yay!")

else:
  print(":(")
  
  













Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
q = int(input())
 
f=e-d
g=e-c
h=e-b
i=e-a
j=d-c
k=d-b
l=d-a
m=c-b
n=c-a
o=b-a

 
 
if f<=q and g<=q and h<=q and i<=q and j<=q and k<=q and l<=q and m<=q and n<=q and o<=q:
  print("Yay!")
 
else:
  print(":(")
Buggy python submission (verdict: Runtime Error):
N=int(input)
S=list(input())

ans=[]
for i in S:
    if ord(i)+N>90:
        temp=chr(ord(i)+N-26)
        ans.append(temp)
    else:
        temp=chr(ord(i)+N)
        ans.append(temp)

f=''.join(ans)

print(f)

Fixed submission:
N=int(input())
S=list(input())
 
ans=[]
for i in S:
    if ord(i)+N>90:
        temp=chr(ord(i)+N-26)
        ans.append(temp)
    else:
        temp=chr(ord(i)+N)
        ans.append(temp)
 
f=''.join(ans)
 
print(f)
Buggy python submission (verdict: Runtime Error):
c=a*b
 
if c%2==0:
  return 'Even'
else:
  return 'Odd'

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

if a*b%2==0:
  print('Even')
else:
  print('Odd')

Buggy python submission (verdict: Runtime Error):
c=a*b
 
if c%2==0:
  print('Even')
else:
  print('Odd')

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

if a*b%2==0:
  print('Even')
else:
  print('Odd')

Buggy python submission (verdict: Runtime Error):
c=a*b

if c%2=0:
  print('Even')
else:
  print('Odd')

 

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

if a*b%2==0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Runtime Error):
a=input()
b=input().split()

l=[int(i) for i in b]

cnt=[0 for i in range(a)]

for i in range(a):
    while l[i]%2==0:
        cnt[i]+=1
        l[i]=l[i]/2
        if l[i]%2==1:
            break

print(min(cnt))

Fixed submission:
a=int(input())
b=input().split()
 
l=[int(i) for i in b]
 
cnt=[0 for i in range(a)]
 
for i in range(a):
    while l[i]%2==0:
        cnt[i]+=1
        l[i]=l[i]/2
        if l[i]%2==1:
            break
 
print(min(cnt))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
A = LI()

for i in range(0, N):
    A_part = A[:i] + A[i+1:]
    counter_a = Counter(A_part)
    choice_total = sum([(count*(count-1)//2) for count in counter_a.values() if count > 1])
    print(choice_total)

Fixed submission:
import sys
from collections import Counter

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
counter_a = Counter(A)
choice_total = sum([(count*(count-1)//2) for count in counter_a.values() if count > 1])

for i in range(0, N):
    sub_num = A[i]
    count_sub_num = counter_a[sub_num]
    print(choice_total - ((count_sub_num*(count_sub_num-1) - (count_sub_num-1)*(count_sub_num-2)) // 2))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
hight = []
count = []

# lower...1,higher...0
for n in range(N-1):
    if H[n]>=H[n+1]:
        hight.append(1)
    else:
        hight.append(0)

count.append(hight[0])
for l in range(1,N-1):
    if hight[l]==1:
        count.append(count[l-1]+1)
    else:
        count.append(0)

print(max(count))


Fixed submission:
import sys

N = int(input())
H = list(map(int,input().split()))
hight = []
count = []

if N == 1:
    print(0)
    sys.exit()

# lower...1,higher...0
for n in range(N-1):
    if H[n]>=H[n+1]:
        hight.append(1)
    else:
        hight.append(0)

#print(hight)

count.append(hight[0])
for l in range(1,N-1):
    if hight[l]==1:
        count.append(count[l-1]+1)
    else:
        count.append(0)

#print(count)

print(max(count))
Buggy python submission (verdict: Runtime Error):
import sys

A, B, C = input().split()

if a == b:
    if a == c:
        print('YES')
        sys.exit()

print('NO')


Fixed submission:
import sys

A, B, C = input().split()
a = int(A)
b = int(B)
c = int(C)

if a == b:
    if a == c:
        print('Yes')
        sys.exit()

print('No')
Buggy python submission (verdict: Time Limit Exceeded):
X = input()
while 'ST' in X:
    X = X.replace('ST','')
print(len(X))


Fixed submission:
X = list(input())
c = 0
for x in X:
    if x=='S':
        c += 1
    else:
        if c > 0:
            c -= 1
print(2*c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = 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)

Fixed submission:
n = int(input())
s = input()
count = 0
for i in range(n-2):
  if s[i] == "A" and s[i+1] == "B" and s[i+2] =="C":
    count +=1
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input()
if a[0:int(n/2)]==a[int(n/2):n]:
	print("Yes")
else:
	print("No")

Fixed submission:
a = input()
print(int(a)*int(a))
Buggy python submission (verdict: Runtime Error):
ans_list =[]
point = []
for i in range(n):
  point.append(k)
#print(point)      
for j in range(q):
  ans_list.append(int(input()))
#print(ans_list)
for k in ans_list:
  point[k-1] += 1
#print(point)
for l in range(n):
  point[l] -= q
  if point[l]>0:
    print("Yes")
  else:
    print("No")
#print(point)

Fixed submission:
n,k,q = map(int,input().split())
ans_list =[]
point = []
for i in range(n):
  point.append(k)
#print(point)      
for j in range(q):
  ans_list.append(int(input()))
#print(ans_list)
for k in ans_list:
  point[k-1] += 1
#print(point)
for l in range(n):
  point[l] -= q
  if point[l]>0:
    print("Yes")
  else:
    print("No")
#print(point)

Buggy python submission (verdict: Runtime Error):
n,k,q = map(int,input().split())
ans_list =[]
point = []
for i in range(n):
  point.append(k)
#print(point)      
for j in range(q):
  ans_list.append(int(input()))
#print(ans_list)
for k in ans_list:
  point[k] += 1
for l in range(n):
  point[l] -= q
  if point[l]>0:
    print("Yes")
  else:
    print("No")
#print(point)

Fixed submission:
n,k,q = map(int,input().split())
ans_list =[]
point = []
for i in range(n):
  point.append(k)
#print(point)      
for j in range(q):
  ans_list.append(int(input()))
#print(ans_list)
for k in ans_list:
  point[k-1] += 1
#print(point)
for l in range(n):
  point[l] -= q
  if point[l]>0:
    print("Yes")
  else:
    print("No")
#print(point)

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
ans_list =[]
point = []
for i in range(n):
  point.append(k)
#print(point)
for j in range(q):
  ans_list.append(input().rstrip())
#print(ans_list)
for k in ans_list:
  for l in range(n):
    if l != int(k)-1:
      point[l] -=1
for m in point:
  if m>0:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k,q = map(int,input().split())
ans_list =[]
point = []
for i in range(n):
  point.append(k)
#print(point)      
for j in range(q):
  ans_list.append(int(input()))
#print(ans_list)
for k in ans_list:
  point[k-1] += 1
#print(point)
for l in range(n):
  point[l] -= q
  if point[l]>0:
    print("Yes")
  else:
    print("No")
#print(point)