Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
words = []
for inp in range(N):
	words.append(input())

frst = words[0]
for i in range(1,len(words)):
	if words[i-1][-1] != words[i][0]:
		print("No")
		break
	else:
		flag = 0
		if words[i] in words[:i-1]:
			print("No")
			break
		else:
			flag = 1
if flag == 1:
	print("Yes")  

Fixed submission:
N = int(input())
words = []
for inp in range(N):
	words.append(input())

frst = words[0]
wrds = set(words)
if len(wrds) != len(words):
	print("No")
else:	
	for i in range(1,len(words)):
		flag = 1
		if words[i-1][-1] != words[i][0]:
			print("No")
			flag = 0
			break
	if flag == 1:
		print("Yes")

Buggy python submission (verdict: Runtime Error):
N = int(input())
words = input().split("\n")

frst = words[0]
last = words[-1]
if frst[0] !=  last[-1]:
	print("No")
else:
	
	for i in range(1,len(words)):
		flag = 0
		if words[i] in words[:i-1]:
			print("No")
			break
		else:
			flag = 1
	if flag == 1:
		print("Yes")


Fixed submission:
N = int(input())
words = []
for inp in range(N):
	words.append(input())

frst = words[0]
wrds = set(words)
if len(wrds) != len(words):
	print("No")
else:	
	for i in range(1,len(words)):
		flag = 1
		if words[i-1][-1] != words[i][0]:
			print("No")
			flag = 0
			break
	if flag == 1:
		print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
ans=[]
ans.append(n)
for i in range(n):
    ans.append(abs(ans[i]-k))
print(min(ans))

Fixed submission:
n,k=map(int,input().split())
a=n%k
b=abs(k-a)
print(min(a,b))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=list(map(int,input().split()))
ans=[]
for i in range(b-1):
    ans.append(s[i+1]-s[i])
ans.append(a-s[b]+s[0])
print(a-max(ans))







Fixed submission:
a,b=map(int,input().split())
s=list(map(int,input().split()))
ans=[]
for i in range(b-1):
    ans.append(s[i+1]-s[i])
ans.append(a-s[b-1]+s[0])
print(a-max(ans))

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=list(map(int,input().split()))
ans=[]
for i in range(b-1):
    ans.append(s[i]-s[i-1])
ans.append(a-s[b]+s[0])
print(sum(ans)-max(ans))







Fixed submission:
a,b=map(int,input().split())
s=list(map(int,input().split()))
ans=[]
for i in range(b-1):
    ans.append(s[i+1]-s[i])
ans.append(a-s[b-1]+s[0])
print(a-max(ans))

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=list(map(int,input().split()))
ans=[]
for i in range(b-1):
    ans.append(s[i]-s[i-1])
ans.append(a-s[b]+s[0])
print(a-max(ans))







Fixed submission:
a,b=map(int,input().split())
s=list(map(int,input().split()))
ans=[]
for i in range(b-1):
    ans.append(s[i+1]-s[i])
ans.append(a-s[b-1]+s[0])
print(a-max(ans))
Buggy python submission (verdict: Runtime Error):
s=input()
sl=len(s)
if s[:(sl-1)/2]==s[((sl+3)/2)-1:]:
    print('Yes')
else :
    print('No')


Fixed submission:
s=input()
sl=len(s)
if s[:int((sl-1)/2)]==s[int(((sl+3)/2)-1):]:
    print('Yes')
else :
    print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in range(n):
    for j in range(n):
        if i!=j:
            for k in range(j+1,n):
                if a[j]==a[k]:
                    ans[i]+=1
for i in range(n):
    print(ans[n])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
cnt=[0]*(n+1)
ans=0
for i in range(n):
    cnt[a[i]]+=1
for j in range(n+1):
    ans+=(cnt[j]*(cnt[j]-1))//2
for k in range(n):
    print(ans-(cnt[a[k]]-1))
Buggy python submission (verdict: Runtime Error):
import math
a,b,c=map(int,input().split())
a=math.sqrt(a)
b=math.sqrt(b)
c=math.sqrt(c)
s=a+b
if s<＝c:
    print('Yes')
else :
    print('No')


Fixed submission:
import math
a,b,c=map(int,input().split())
if c-a-b<0:
    print('No')
elif 4*a*b<(c-a-b)**2:
    print('Yes')
else :
    print('No')
Buggy python submission (verdict: Runtime Error):
a=input()
len=len(a)
a_cnt=0
b_cnt=0
for i in range(len):
    if a[i]='A':
        a_cnt+=1
    else :
        b_cnt+=1
if a_cnt>0 and b_cnt>0:
    print('Yes')
else :
    print('No')


Fixed submission:
a=input()
len=len(a)
a_cnt=0
b_cnt=0
for i in range(len):
    if a[i]=='A':
        a_cnt+=1
    else :
        b_cnt+=1
if a_cnt>0 and b_cnt>0:
    print('Yes')
else :
    print('No')
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
b*=10
ans=0

for i in range(8):
    j=b
    j+=i 
   if math.floor(j*0.08)==a:
       ans=j
       break
if ans!=0:
    print(ans)
else :
    print(-1)


Fixed submission:
import math
a,b=map(int,input().split())
b*=10
ans=0

for i in range(9):
    j=b
    j+=i 
    if int(j*0.08)==a:
        ans=j
        break
if ans!=0:
    print(ans)
else :
    print(-1)

Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
b*=10
ans=0

for i in range(8):
    j=b
    j+=i 
   if math.floor(j*0.08)==a:
       ans=j
       break
if ans!=0:
    print(ans)
else :
    print(-1)


Fixed submission:
import math
a,b=map(int,input().split())
b*=10
ans=0

for i in range(9):
    j=b
    j+=i 
    if int(j*0.08)==a:
        ans=j
        break
if ans!=0:
    print(ans)
else :
    print(-1)
Buggy python submission (verdict: Runtime Error):
a1=[map(int(),input().split())]
a2=[map(int(),input().split())]
a3=[map(int(),input().split())]
n=int(input())
b=[input() for i in range(n)]

line1=[]
line2=[]
line3=[]

for num in b:
    if num in a1:
        line1.append(a1.index(num))
    elif num in a2:
        line2.append(a2.index(num))
    elif num in a3:
        line3.append(a3.index(num))
if 0 in line1 and 0 in line2 and 0 in line3 or 1 in line1 and 1 in line2 and 1 in line3 or 2 in line1 and 2 in line2 and 2 in line3 :
    print("Yes")
elif 0 in line1 and 1 in line2 and 2 in line3 or 2 in line1 and 1 in line2 and 0 in line3:
    print("Yes")
elif 0 in line1 and 1 in line1 and 2 in line1 or 0 in line2 and 1 in line2 and 2 in line2 or 0 in line3 and 1 in line3 and 2 in line3:
    print("Yes")
else:
    print("No")

Fixed submission:
import math
a=int(input())
print(math.ceil(a/2))
Buggy python submission (verdict: Runtime Error):
a1=[map(int(),input().split())]
a2=[map(int(),input().split())]
a3=[map(int(),input().split())]
n=int(input())
b=[input() for i in range(n)]
for i in range(3):
    for j in range(n):
        if a1[i] == b[j]:
            a1[i] = 1
        elif a2[i] == b[j]:
            a2[i] = 1
        elif a3[i] == b[j]:
            a3[i] = 1
 
if a1[0] == a1[1] == a1[2]:
    print("Yes")
elif a2[0] == a2[1] == a2[2]:
    print("Yes")
elif a3[0] == a3[1] == a3[2]:
    print("Yes")
elif a1[0] == a2[0] == a3[0]:
    print("Yes")
elif a1[1] == a2[1] == a3[1]:
    print("Yes")
elif a1[2] == a2[2] == a3[2]:
    print("Yes")
elif a1[0] == a2[1] == a3[2]:
    print("Yes")
elif a1[2] == a2[1] == a3[0]:
    print("Yes")
else:
    print("No")

Fixed submission:
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
n=int(input())
b=[int(input()) for i in range(n)]
for i in range(3):
    for j in range(n):
        if a1[i] == b[j]:
            a1[i] = 1
        elif a2[i] == b[j]:
            a2[i] = 1
        elif a3[i] == b[j]:
            a3[i] = 1
 
if a1[0] == a1[1] == a1[2]:
    print("Yes")
elif a2[0] == a2[1] == a2[2]:
    print("Yes")
elif a3[0] == a3[1] == a3[2]:
    print("Yes")
elif a1[0] == a2[0] == a3[0]:
    print("Yes")
elif a1[1] == a2[1] == a3[1]:
    print("Yes")
elif a1[2] == a2[2] == a3[2]:
    print("Yes")
elif a1[0] == a2[1] == a3[2]:
    print("Yes")
elif a1[2] == a2[1] == a3[0]:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a1=[map(int(),input().split())]
a2=[map(int(),input().split())]
a3=[map(int(),input().split())]
n=int(input())
b=[input() for i in range(n)]
for i in range(3):
    for j in range(N):
        if a1[i] == b[j]:
            a1[i] = 1
        elif a2[i] == b[j]:
            a2[i] = 1
        elif a3[i] == b[j]:
            a3[i] = 1
 
print(line1)
print(line2)
print(line3)

if a1[0] == a1[1] == a1[2]:
    print("Yes")
elif a2[0] == a2[1] == a2[2]:
    print("Yes")
elif a3[0] == a3[1] == a3[2]:
    print("Yes")
elif a1[0] == a2[0] == a3[0]:
    print("Yes")
elif a1[1] == a2[1] == a3[1]:
    print("Yes")
elif a1[2] == a2[2] == a3[2]:
    print("Yes")
elif a1[0] == a2[1] == a3[2]:
    print("Yes")
elif a1[2] == a2[1] == a3[0]:
    print("Yes")
else:
    print("No")

Fixed submission:
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
n=int(input())
b=[int(input()) for i in range(n)]
for i in range(3):
    for j in range(n):
        if a1[i] == b[j]:
            a1[i] = 1
        elif a2[i] == b[j]:
            a2[i] = 1
        elif a3[i] == b[j]:
            a3[i] = 1
 
if a1[0] == a1[1] == a1[2]:
    print("Yes")
elif a2[0] == a2[1] == a2[2]:
    print("Yes")
elif a3[0] == a3[1] == a3[2]:
    print("Yes")
elif a1[0] == a2[0] == a3[0]:
    print("Yes")
elif a1[1] == a2[1] == a3[1]:
    print("Yes")
elif a1[2] == a2[2] == a3[2]:
    print("Yes")
elif a1[0] == a2[1] == a3[2]:
    print("Yes")
elif a1[2] == a2[1] == a3[0]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if b==2:
    a=format(a,'b')
elif b==8:
    a=format(a,'o')
elif b==10:
    a=int(a)
print(len(a))

Fixed submission:
a,b=map(int,input().split())
count=1
while a>=b:
    a=a/b
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if b==2:
    a=bin(a)
elif b==8:
    a=oct(a)
elif b==10:
    a=int(a)
print(len(a))

Fixed submission:
a,b=map(int,input().split())
count=1
while a>=b:
    a=a/b
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

if a=b and b=c :
    print('No')
elif a=b or a=c or b=c:
    print("Yes")
else:
    print('No') 

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

if a==b and b==c :
    print('No')
elif a==b or a==c or b==c:
    print("Yes")
else:
    print('No')

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

if a=b and b=c :
    print("Yes")
else:
    print('No') 

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

if a==b and b==c :
    print('No')
elif a==b or a==c or b==c:
    print("Yes")
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a=input()
s=list(map(int, input().split()))
bad=0
for i in s:
    if s%2==0:
        if s%3!=0 or s%5!=0:
            bad+=1
if bad>0:
    print('DENIED') 
else:
    print('APPROVED')



Fixed submission:
a=int(input())
s=list(map(int,input().split()))
count=0
good=0
for i in s:
    if i%2==0:
        count+=1
        if i%3==0 or i%5==0:
            good+=1
if good==count:
    print('APPROVED')
else:
    print('DENIED')

Buggy python submission (verdict: Runtime Error):
a=input()
s=list(map(int, input().split()))
bad=0
for i in s:
    if s%2==0:
        if s%3!=0 or s%5!=0:
            bad+=1
if bad>0:
    print('DENIED') 
    else:
        print('APPROVED')



Fixed submission:
a=int(input())
s=list(map(int,input().split()))
count=0
good=0
for i in s:
    if i%2==0:
        count+=1
        if i%3==0 or i%5==0:
            good+=1
if good==count:
    print('APPROVED')
else:
    print('DENIED')
Buggy python submission (verdict: Runtime Error):
a=int(input())
s=[input()for _ in range(a)]
c=Counter(s)
m=0 
m=max(m,v)
ans=[]
for k,v in c.items():
    if m == v:
        ans.append(k)
ans.sort()
print(ans)


Fixed submission:
import collections
a=int(input())
s=[input()for _ in range(a)]
c=collections.Counter(s)
m=0 
for v in c.values(): 
    m=max(m,v)
ans=[]
for k,v in c.items():
    if m == v:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=list(map(int,input().split()))
if a<=sum(s):
    print ("Yes")
else:
    print("No")



Fixed submission:
a,b=map(int,input().split())
count=0
while a>0:
    count+=1
    a-=b
print(count)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=list(map(int,input().split()))
count=0
for i in range(b):
        for j in range(i,b):
            if a<s[i]+s[j] and count==0:
                print("yes")
                count+=1
if count==0:
    print("no")


Fixed submission:
a,b=map(int,input().split())
count=0
while a>0:
    count+=1
    a-=b
print(count)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=list(map(int,input().split()))
count=0
for i in range(b):
        for j in range(i,b):
            if a<s[i]+s[j] and count==0:
                print("yes")
                count+=1
if count==0:
    print("no")


Fixed submission:
a,b=map(int,input().split())
count=0
while a>0:
    count+=1
    a-=b
print(count)
Buggy python submission (verdict: Runtime Error):
a=input(int)
s=list(map(int,input().split()))
count=0
min=s[0]
for i in range(0,a):
    if min>=s[i]:
        count+=1
        min=s[i]
print(count) 

Fixed submission:
a=int(input())
s=list(map(int,input().split()))
count=0
min=s[0]
for i in range(0,a):
    if min>=s[i]:
        count+=1
        min=s[i]
print(count)

Buggy python submission (verdict: Runtime Error):
a=input()
s=list(map(int,input().split()))
count=0
min=s[0]
for i in range(1,a):
    if min>s[i] :
        count+=1
        min=s[j]
print(count) 

Fixed submission:
a=int(input())
s=list(map(int,input().split()))
count=0
min=s[0]
for i in range(0,a):
    if min>=s[i]:
        count+=1
        min=s[i]
print(count)

Buggy python submission (verdict: Runtime Error):
a=input()
s=list(map(int,input().split()))
count=0
min=s[0]
for i in range(1,a):
    if min>s[i] :
        count+=1
        min=s[j]
print(count) 

Fixed submission:
a=int(input())
s=list(map(int,input().split()))
count=0
min=s[0]
for i in range(0,a):
    if min>=s[i]:
        count+=1
        min=s[i]
print(count)

Buggy python submission (verdict: Runtime Error):
a=input()
s=list(map(int,input().split()))
count=0
counter=0
for i in a:
    counter=0
    for j in range(0,i):
      if counrer==1:
        break
        if s[i]>s[j] :
            count+=1
            counter+=1
print(count) 

Fixed submission:
a=int(input())
s=list(map(int,input().split()))
count=0
min=s[0]
for i in range(0,a):
    if min>=s[i]:
        count+=1
        min=s[i]
print(count)

Buggy python submission (verdict: Runtime Error):
a=input()
s=list(map(int,input().split()))
count=0
counter=0
for i in a:
    counter=0
    for j in range(0,i):
        if s[i]>s[j] and counter==0:
            count+=1
            counter+=1
print(count) 

Fixed submission:
a=int(input())
s=list(map(int,input().split()))
count=0
min=s[0]
for i in range(0,a):
    if min>=s[i]:
        count+=1
        min=s[i]
print(count)
Buggy python submission (verdict: Runtime Error):
s=str(input())

s+=1
print(s)

Fixed submission:
alp=input()
ask=ord(alp)
print(chr(ask+1))

Buggy python submission (verdict: Runtime Error):
s=str(input())

s+=1
print(s)

Fixed submission:
alp=input()
ask=ord(alp)
print(chr(ask+1))
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
ans_sum=0
for i in range(N):
    for j in range(N):
        if i!=j:
            ans_sum+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
print(ans_sum*(n-1)/math.factorial(N))

Fixed submission:
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
ans_sum=0
for i in range(N):
    for j in range(N):
            ans_sum+=math.sqrt((x[j]-x[i])**2+(y[j]-y[i])**2)
print(ans_sum/N)
Buggy python submission (verdict: Runtime Error):
X=int(input())
tot=int(X/500)
y=X-tot*500
tot=tot*1000 + int(y/5)*5
print(tot)

Fixed submission:
S=input()
if S[2]==S[3] and S[4]==S[5]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
k = []
for i in l:
  if(i > sum(l)/(4*m))
  	k.append(i)
if(len(k) < m):
  print("No")
else:
  print("Yes")

Fixed submission:
n, m = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
k = []
for i in l:
  if(i >= sum(l)/(4*m)):
    k.append(i)
if(len(k) < m):
  print("No")
else:
  print("Yes")

Buggy python submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
k = []
for i in l:
  if(i >= sum(l)/(4*m)):
    k.append(i)
if(len(k) < m):
  print("No")
else:
print("Yes")

Fixed submission:
n, m = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
k = []
for i in l:
  if(i >= sum(l)/(4*m)):
    k.append(i)
if(len(k) < m):
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int, input().split())
print(math.gcd(a,b))

Fixed submission:
a,b=map(int, input().split())
a=a%b
if a==0:
    print(0)
else:
    arr=[]
    arr.append(a)
    while True:
        a=abs(a-b)
        if sum(x == a for x in arr)==1:
            break
        else:
            arr.append(a)

    print(min(arr))

Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int, input().split())
print(math.gcd(a,b))

Fixed submission:
a,b=map(int, input().split())
a=a%b
if a==0:
    print(0)
else:
    arr=[]
    arr.append(a)
    while True:
        a=abs(a-b)
        if sum(x == a for x in arr)==1:
            break
        else:
            arr.append(a)

    print(min(arr))
Buggy python submission (verdict: Time Limit Exceeded):
n,x,y=map(int, input().split())
count=[0]*n

def push(a,b,q,distance):
    if distance[a-1]==-1:
        distance[a-1]=b
        q.append(a)

    return (q,distance)

for i in range (1,n+1):
    distance=[-1]*n
    q=[]
    q.append(i)
    distance[i-1]=0
    while len(q) > 0:
        a=q.pop(0)
        if a>=2:
            q,distance=push(a-1,distance[a-1]+1,q,distance)
        if a<=n-1:
            q, distance = push(a + 1, distance[a-1] + 1, q, distance)
        if a==x:
            q, distance = push(y, distance[a-1] + 1, q, distance)
        if a==y:
            q, distance = push(x, distance[a-1] + 1, q, distance)

    for i in range(n):
        count[distance[i]]+=1

for i in range (1,n):
    print(count[i]//2)

Fixed submission:
n,x,y=map(int, input().split())
count=[0]*n

def push(a,b,q,distance):
    if distance[a-1]==-1:
        distance[a-1]=b
        q.append(a)

    return (q,distance)

for i in range (1,n+1):
    distance=[-1]*n
    q=[]
    q.append(i)
    distance[i-1]=0
    while len(q) > 0:
        a=q.pop(0)
        if a>=2:
            q,distance=push(a-1,distance[a-1]+1,q,distance)
        if a<=n-1:
            q, distance = push(a + 1, distance[a-1] + 1, q, distance)
        if a==x:
            q, distance = push(y, distance[a-1] + 1, q, distance)
        if a==y:
            q, distance = push(x, distance[a-1] + 1, q, distance)

    for i in range(n):
        count[distance[i]]+=1

for i in range (1,n):
    print(count[i]//2)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))
count=[0]*(n+1)
for i in range (n):
    count[a[i]]+=1
for i in range(n):
    count[a[i]]-=1
    c=0
    for j in range(1,n+1):
        c=c+count[j]*(count[j]-1)//2
    print(c)
    count[a[i]] +=1


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

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))
count=[0]*(n+1)
for i in range (n):
    count[a[i]]+=1
for i in range(n):
    count[a[i]]-=1
    c=0
    for j in range(1,n+1):
        c=c+count[j]*(count[j]-1)//2
    print(c)
    count[a[i]] +=1


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

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))
count=[0]*(n+1)
output=[0]*(n+1)
for i in range (n):
    count[a[i]]+=1
#print(count)
for i in range(n):
    count[a[i]]-=1
    #print(count)
    c=0
    for j in range(1,n+1):
        c=c+count[j]*(count[j]-1)//2
    output[i]=c
    count[a[i]] +=1

for i in range (n):
    print(output[i])

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

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))
count=[0]*(n+1)
output=[0]*(n+1)
for i in range (n):
    count[a[i]]+=1
#print(count)
for i in range(n):
    count[a[i]]-=1
    #print(count)
    c=0
    for j in range(1,n+1):
        c=c+count[j]*(count[j]-1)//2
    output[i]=c
    count[a[i]] +=1

for i in range (n):
    print(output[i])

Fixed submission:
n=int(input())
a=list(map(int, input().split()))
count=[0]*(n+1)
for i in range (n):
    count[a[i]]+=1
m=0
for i in range (1,n+1):
    m+=count[i]*(count[i]-1)//2
for i in range (n):
   print(m-(count[a[i]]-1))
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
m=1
for i in range (q):
    a=list(input().split())
    if a[0]=="1":
        m=m*(-1)
    else:
        if m==1:
            if a[1]=="1":
                s=a[2]+s
            else:
                s=s+a[2]
        else:
            if a[1]=="2":
                s=a[2]+s
            else:
                s=s+a[2]


print(s[::m])

Fixed submission:
from collections import deque

s=input()
q=int(input())
d=deque()
d.append(s)
m=1
for i in range (q):
    a=list(input().split())
    if a[0]=="1":
        m=m*(-1)
    else:
        if m==1:
            if a[1]=="1":
                d.appendleft(a[2])
            else:
                d.append(a[2])
        else:
            if a[1]=="2":
                d.appendleft(a[2])
            else:
                d.append(a[2])
s="".join(d)


print(s[::m])

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
for i in range (q):
    a=list(input().split())
    if a[0]=="1":
        s=s[::-1]
    else:
        if a[1]=="1":
            s=a[2]+s
        else:
            s=s+a[2]

print(s)

Fixed submission:
from collections import deque

s=input()
q=int(input())
d=deque()
d.append(s)
m=1
for i in range (q):
    a=list(input().split())
    if a[0]=="1":
        m=m*(-1)
    else:
        if m==1:
            if a[1]=="1":
                d.appendleft(a[2])
            else:
                d.append(a[2])
        else:
            if a[1]=="2":
                d.appendleft(a[2])
            else:
                d.append(a[2])
s="".join(d)


print(s[::m])

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
for i in range (q):
    a=list(input().split())
    if a[0]=="1":
        s=s[::-1]
    else:
        if a[1]=="1":
            s=a[2]+s
        else:
            s=s+a[2]

print(s)

Fixed submission:
from collections import deque

s=input()
q=int(input())
d=deque()
d.append(s)
m=1
for i in range (q):
    a=list(input().split())
    if a[0]=="1":
        m=m*(-1)
    else:
        if m==1:
            if a[1]=="1":
                d.appendleft(a[2])
            else:
                d.append(a[2])
        else:
            if a[1]=="2":
                d.appendleft(a[2])
            else:
                d.append(a[2])
s="".join(d)


print(s[::m])