Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03836 (python)

Fixed submission:
sx, sy, gx, gy = list(map(int, input().split()))
l = []
dx = gx - sx
dy = gy - sy
for i in range(dx):
	l.append('R')
for i in range(dy):
	l.append('U')
for i in range(dx):
	l.append('L')
for i in range(dy):
	l.append('D')
l.append('D')
for i in range(dx+1):
	l.append('R')
for i in range(dy+1):
	l.append('U')
l.append('L')
l.append('U')
for i in range(dx+1):
	l.append('L')
for i in range(dy+1):
	l.append('D')
l.append('R')
S = ''.join(l)
print(S)

Buggy submission (verdict: Runtime Error):
sx, sy, gx, gy = list(map(int, input().split()))
l = []
dx = gx - sx
dy = gy - sy
for i in range(dx):
	l.append('R')
for i in range(dy):
	l.append('U')
for i in range(dx):
	l.append('L')
for i in range(dy):
	l.append('D')
l.append('D')
for i in range(dx+1):
	l.append('R')
for i in range(dy+1):
	l.append('U')
l.append('L')
l.append('U')
for i in range(dx+1):
	l.append('L')
for i in range(dy+1):
	l.append('D')
l.append('R')
print(S)
Problem p02696 (python)

Fixed submission:

def main():
    import math
    a, b, n = map(int, input().split())
    if n >= b:
        ans = math.floor(a * (b-1)/b)
    else:
        ans = math.floor(a * n / b)
    
    print(ans)
    




if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import math
    a, b, n = map(int, input().split())
    ans = 0
    
    if n > 10 ** 5:
        for x in range(n, math.sqrt(n), -1):
            fx = math.floor(a * x / b) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass
    else: 
        for x in range(n, 0, -1):
            fx = math.floor(a * x / b) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass

    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import math
    a, b, n = map(int, input().split())
    ans = 0

    for x in range(n, 0, -1):
        fx = math.floor(a * x / b) - math.floor(x / b) * a
        #print(fx)
        if ans < fx:
            ans = fx
        if ans > fx + 10 ** 3:
            #exit()
    print(ans)

if __name__ == "__main__":
    main()
Problem p02730 (python)

Fixed submission:
s = input()
n = len(s)
count = 0
halfn = int((n-1) / 2)
whalfn = int((n-1) / 4)
half = s[0:halfn]

for i in range(len(s)):
    if s[i] != s[-i-1]:
      count += 1
      break
    else:
      pass

for i in range(len(half)):
  if half[i] != half[-i-1]:
    count += 1
    break
  else:
    pass

if count == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
count = 0
halfn = int((n-1) / 2)
whalfn = int((n-1) / 4)
half = s[0:halfn]

for i in range(len(s)):
    if s[i] != s[-i-1]:
      count += 1
      break
    else:
      pass

if len(half) % 2 == 0:
  for i in range(len(half)+1):
    if half[i] != half[-i-1]:
      count += 1
      break
    else:
      pass
else:
  for i in range(len(half)):
    if half[i] != half[-i-1]:
      count += 1
      break
    else:
      pass
  
if count == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
count = 0
halfn = int((n-1) / 2)
whalfn = int((n-1) / 4)
half = s[0:halfn]

if len(half) % 2 == 0:
  for i in range(len(half)+1):
    if half[i] != half[-i-1]:
      count += 1
      break
    else:
      pass
else:
  for i in range(len(half)):
    if half[i] != half[-i-1]:
      count += 1
      break
    else:
      pass
  
if count == 0:
  print('Yes')
else:
  print('No')
Problem p02731 (python)

Fixed submission:
l = input()
l = int(l)
print(l **3 / 27)

Buggy submission (verdict: Runtime Error):
cl = input()
l = int(l)
print(l **3 / 27)
Problem p02761 (python)

Fixed submission:
def main():
    n, m = map(int, input().split())
    indic = {}
    for i in range(m):
        s, c = map(int, input().split())
        if s in indic:
            if indic[s] == c:
                pass
            else:
                print(-1)
                exit()
        else:
            indic[s] = c
    ans = ""
    if 1 in indic and indic[1] == 0 and n > 1:
        print(-1)
        exit()
    for i in range(n):
        if i+1 in indic:
            ans += str(indic[i+1])
        else:
            if i == 0 and n > 1:
                ans += "1"
            else:
                ans += "0"
    print(ans)


    
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    indic = {}
    for i in range(m):
        s, c = map(int, input().split())
        if s in indic:
            if indic[s] == c:
                pass
            else:
                print(-1)
                exit()
        else:
            indic[s] = c
    ans = ""
    if indic[1] == 0:
        print(-1)
        exit()
    for i in range(n):
        if i+1 in indic:
            ans += str(indic[i+1])
        else:
            if i == 0 and n > 1:
                ans += "1"
            else:
                ans += "0"
    print(ans)


    
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    indic = {}
    for i in range(m):
        s, c = map(int, input().split())
        if s in indic:
            if indic[s] == c:
                pass
            else:
                print(-1)
                exit()
        else:
            indic[s] = c
    ans = ""
    if indic[1] == 0:
        print(-1)
        exit()
    for i in range(n):
        if i+1 in indic:
            ans += str(indic[i+1])
        else:
            if i == 0:
                ans += "1"
            else:
                ans += "0"
    print(ans)


    
    
if __name__ == "__main__":
    main()
Problem p02812 (python)

Fixed submission:
n = int(input())
s = input()
count = 0

for k in range(n-2):
    if s[k] == "A" and s[k+1] =="B" and s[k+2] =="C":
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
count = 0

for k in range(n):
    if s[k] == "A" and s[k+1] =="B" and s[k+2] =="C":
        count += 1
print(count)
Problem p02917 (python)

Fixed submission:
def main():
    n = int(input())
    blis = list(map(int, input().split()))

    alis = [blis[0], blis[0]]
    if n > 2 and alis[1] > blis[1]:
        alis[1] = blis[1]
    if n > 2:
        for i in range(3, n):
            alis.append(min(blis[i-2], blis[i-1]))
    if n > 2:
        alis.append(blis[n-2])
    print(sum(alis))


    


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    blis = list(map(int, input().split()))

    alis = [blis[0], blis[0]]
    if alis[1] > blis[1]:
        alis[1] = blis[1]
    if n > 2:
        for i in range(3, n):
            alis.append(min(blis[i-2], blis[i-1]))
    if n > 2:
        alis.append(blis[n-2])
    print(sum(alis))


    


if __name__ == "__main__":
    main()
Problem p02921 (python)

Fixed submission:
s = input()
t = input()
ans = 0
for i in range(3):
  if s[i] == t[i]:
    ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
ans = 0
for i in range(3):
  if s[i] == t[i]:
    ans +=1
ptiny(ans)
Problem p02994 (python)

Fixed submission:
def main():
    import numpy as np
    n, l = map(int,input().split())
    inlis = []
    taishou = 10 *10000
    flag = 0

    for i in range(l, l+n):
        if taishou > np.abs(i):
            taishou = np.abs(i)
            if i < 0:
                flag = 1
        inlis.append(i)
    if flag == 0:
        print(sum(inlis) - taishou)
    else:
        print(sum(inlis) + taishou)

    
        

    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import numpy as np
    n, l = map(int,input().split())
    inlis = []
    taishou = 10 *10000
    flag = 0

    for i in range(l, l+n):
        if taishou > np.abs(i):
            taishou = np.abs(i)
            if i < 0:
                flag = 1
        inlis.append(i)
    if flag == 0:
        print(sum(inlis) - taishou)
    else:
        print(sum(inlis) + taishou)

    
        

    
if __name__ == "__main__":
    main()
Problem p03105 (python)

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

Buggy submission (verdict: Runtime Error):
a, b, c= map(int, input().split())
print(min(c, b//a)
Problem p03109 (python)

Fixed submission:
s = input()

year = int(s[:4])
mo = int(s[5:7])

if year < 2019:
  ans = "Heisei"
elif year == 2019 and mo<= 4:
  ans ='Heisei'
else:
  ans = 'TBD'
print(ans)

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

year = s[:4]
mo = s[5:7]
da = s[8:]

if year < 2019:
  ans = "Heisei"
elif year == 2019 and mo<= 4:
  ans ='Heisei'
else:
  ans = 'TBD'
print(ans)
Problem p03145 (python)

Fixed submission:
a, b, c = map(int, input().split())
dai = max(a,b,c)
shou = min(a,b,c)
mid = a + b + c - dai - shou

print(shou * mid // 2)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().splis())
dai = max(a,b,c)
shou = min(a,b,c)
mid = a + b + c - dai - shou

print(shou * mid / 2)
Problem p03210 (python)

Fixed submission:
n = int(input())
if n==7 or n==5 or n==3:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
if n==7 or n==5 or n=3:
  print("YES")
else:
  print("NO")
Problem p03238 (python)

Fixed submission:
n=int(input())
if n ==1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)

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

Fixed submission:
def main():
    s = input()
    k = int(input())

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i+1
            ans = s[i]
            break
    
    if k < m:
        print(1)
    elif m == 0:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    k = int(input())

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i+1
            ans = s[i]
            break
    
    if k <= m:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    k = int(input())

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i+1
            ans = s[i]
            break
    
    if k < m:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    k = int(input())

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i
            ans = s[i]
            break
    
    if k < m:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    k = int(input())

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i
            ans = s[i]
            break
    
    if k < i:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()
Problem p03319 (python)

Fixed submission:
import math
k, m = map(int, input().split())
x = math.ceil((k-1)/(m-1))
 
print(x)

Buggy submission (verdict: Runtime Error):
import math
k, m = map(int, input().split())
x = math.ceil((k-1)/(n-1))

print(x)
Problem p03612 (python)

Fixed submission:
def main():
    n = int(input())
    inlis= list(map(int, input().split()))
    ans = 0

    for i in range(n-1, -1, -1):
        #print(i)
        if inlis[i] != i+1:
            #print(i, inlis[i], i+1)
            break
        else:
            #print(inlis)
            #print("mae", inlis[i])
            if i-1 >= 0:
                a = inlis[i-1]
                inlis[i] = a
                inlis[i-1] = i+1
                ans += 1
                #print(inlis)
                
    if ans < n-1:
        #print(inlis)
        for i in range(n):
            if inlis[i] == i+1 and i+1 <= n-1:
                #print("ato", inlis[i])
                b = inlis[i+1]
                inlis[i] = b
                inlis[i+1] = i
                ans += 1
        
    print(ans)


    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    inlis= list(map(int, input().split()))
    ans = 0

    for i in range(n-1,-1):
        if inlis[i] != i+1:
            break
        else:
            #print(inlis)
            #print("mae", inlis[i])
            a = inlis[i-1]
            inlis[i] = a
            inlis[i-1] = i+1
            ans += 1
    if ans < n-1:
        #print(inlis)
        for i in range(n):
            if inlis[i] == i+1:
                #print("ato", inlis[i])
                b = inlis[i+1]
                inlis[i] = b
                inlis[i+1] = i
                ans += 1
        
    print(ans)


    
if __name__ == "__main__":
    main()
Problem p03633 (python)

Fixed submission:
def main():
    import fractions
    n = int(input())
    inlis = []
    for _ in range(n):
        a = int(input())
        inlis.append(a)
    
    ans = inlis[0]
    for i in range(1, n):
        ans = ans * inlis[i] // fractions.gcd(ans, inlis[i])

    print(ans)

    
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import math
    n = int(input())
    inlis = []
    for _ in range(n):
        a = int(input())
        inlis.append(a)

    ans = inlis[0]
    for i in range(1, n):
        ans = ans * inlis[i] // math.gcd(ans, inlis[i])

    print(ans)

    



    
    
if __name__ == "__main__":
    main()
Problem p03671 (python)

Fixed submission:
a, b, c=map(int, input().split())
print((a + b+ c)-max(a, b, c))

Buggy submission (verdict: Runtime Error):
a, b, c=map(int, input().split())
print(total(a,b,c)-max(a, b, c))
Problem p03679 (python)

Fixed submission:
a, b, c= map(int, input().split())
if b >= c:
  print("delicious")
elif c-b<=a:
  print("safe")
else:
  print("dangerous")

Buggy submission (verdict: Runtime Error):
a, b, c= map(int, input().split())
if b <= c:
  print("delicious")
elif c-b<= x:
  print("safe")
else:
  print("dengerous")
Problem p03681 (python)

Fixed submission:
def main():
    import math
    n, m = map(int, input().split())
    if n - m <= -2 or n - m >= 2:
        print(0)
        exit()

    else:
        if n != m:
            ans = math.factorial(n) % (10**9 + 7) * math.factorial(m) % (10**9 + 7)
        else:
            ans = math.factorial(n) * 2 % (10**9 + 7) * math.factorial(m) % (10**9 + 7)

    print(ans)


    

 
    
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import math
    n, m = map(int, input().split())
    if n - m <= -2 or n - m >= 2:
        print(0)
        exit()

    else:
        if n < m:
            n, m = m, n
        else:
            if n != m:
                ans = math.factorial(n) % (10*9 + 7) * math.factorial(m) % (10**9 + 7)
            else:
                ans = math.factorial(n) * 2 % (10**9 + 7) * math.factorial(m) % (10**9 + 7)

    print(ans)


    

 
    
    
if __name__ == "__main__":
    main()
Problem p03945 (python)

Fixed submission:
def main():
    s = input()
    slen = len(s)
    cnt = 0
    last = 0
    if s[0] == "W":
        for i in range(slen-1):
            if s[i] == "W" and s[i+1] =="B":
                cnt += 1
        if s[-1] == "W":
            last = 1
    if s[0] == "B":
        for i in range(slen-1):
            if s[i] == "B" and s[i+1] =="W":
                cnt += 1
        if s[-1] == "B":
            last = 1        
    if cnt == 0:
        print(cnt)
    else:
        print(cnt*2 - 1 + last)
    

 
    
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    slen = len(s)
    cnt = 0
    last = 0
    if s[0] == "W":
        for i in range(slen-1):
            if s[i] == "W" and s[i+1] =="B":
                cnt += 1
        if s[-1] == "W" and s[-2] == "B":
            last = 1
    if s[0] == "B":
        for i in range(slen-1):
            if s[i] == "B" and s[i+1] =="W":
                cnt += 1
        if s[-1] == "B" and s[-2] == "W":
            last = 1        
    if cnt == 0:
        print(cnt)
    else:
        print(cnt*2 - 1 + last)
    

 
    
    
if __name__ == "__main__":
    main()
Problem p02609 (python)

Fixed submission:
N = int(input())
X = input()
X_arr = list(X)
N, X = int(N), int(X, 2)
MAX_N = 2 * 10 ** 5


def popcount(x):
    cnt = 0
    for i in range(x.bit_length()):
        if x & 1 << i:
            cnt += 1
    return cnt


memo = [0] * (MAX_N + 1)
for i, n in enumerate(range(1, MAX_N + 1), start=1):
    cnt = 0
    while n:
        p = popcount(n)
        n = n % p
        cnt += 1
    memo[i] = cnt


x_popcount = popcount(X)
p_upper, p_downer = x_popcount + 1, x_popcount - 1
y_upper = X % p_upper
y_downer = X % p_downer if p_downer else None

for i in range(N):
    if X_arr[i] == '0':
        z = (y_upper + pow(2, (N - i - 1), p_upper)) % p_upper
    else:
        if not p_downer:
            print(0)
            continue
        z = (y_downer - pow(2, (N - i - 1), p_downer)) % p_downer

    print(memo[z] + 1)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = input()
Xn = int(X, 2)


def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f  # 8bitごと
    x = x + (x >> 8)  # 16bitごと
    x = x + (x >> 16)  # 32bitごと
    x = x + (x >> 32)  # 64bitごと = 全部の合計
    return x & 0x0000007f


memo = [-1] * (2 * 10 ** 5 + 1)
for i in range(N):
    d = 1 << (N - i - 1)
    if X[i] == '0':
        n = Xn + d
    else:
        n = Xn - d

    cnt = 0
    ni = -1
    while n:
        p = popcount(n)
        n = n % p
        if ni == -1:
            ni = n

        if memo[n] != -1:
            cnt += memo[n]
            break

        cnt += 1

    print(cnt)
    memo[ni] = cnt
Problem p02618 (python)

Fixed submission:
def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]

    score = 0
    last_day = [-1] * 26

    for d in range(D):
        print(S[d].index(max(S[d])) + 1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import random
import time

start = time.time()
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]


def main():
    best_score = 0
    best_ans = [0] * 26
    base = list(range(26))
    while time.time() - start < 1.8:
        random.shuffle(base)
        score = calc_score(base)
        if score > best_score:
            best_score = score
            ans = base[:]

    print(*ans, sep='\n')


def calc_score(T):
    score = 0
    last_day = [-1] * 26
    for d, t in enumerate(T):
        score += S[d][t]
        last_day[t] = d
        for c, ld in zip(C, last_day):
            score -= c * (d - ld)
    return score


if __name__ == "__main__":
    main()
Problem p02692 (python)

Fixed submission:
N, A, B, C = map(int, input().split())
S = [input() for _ in range(N)]

A, B, C = min(A, 2), min(B, 2), min(C, 2)
X = [0, A, B, C]  # 1-indexecの方が楽そう
F = {1: 'A', 2: 'B', 3: 'C'}

ans = []
for k, s in enumerate(S):
    if s == 'AB':
        i, j = 1, 2
    elif s == 'BC':
        i, j = 2, 3
    elif s == 'AC':
        i, j = 1, 3

    if X[i] > X[j]:
        X[i] -= 1
        X[j] += 1
        ans.append(j)

    elif X[i] < X[j]:
        X[i] += 1
        X[j] -= 1
        ans.append(i)

    else:
        if (X[i] == X[j] == 1) and (k < N - 1):
            if ((S[k + 1][0] == F[i]) and (S[k + 1][1] == F[i ^ j])) or ((S[k + 1][0] == F[i ^ j]) and (S[k + 1][1] == F[i])):
                X[i] += 1
                X[j] -= 1
                ans.append(i)
            else:
                X[j] += 1
                X[i] -= 1
                ans.append(j)
        else:
            X[i] -= 1
            X[j] += 1
            ans.append(j)

    if any([x < 0 for x in X]):
        print('No')
        exit()

print('Yes')
for a in ans:
    print(F[a])

Buggy submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
S = [input() for _ in range(N)]

A, B, C = min(A, 2), min(B, 2), min(C, 2)
X = [0, A, B, C]  # 1-indexecの方が楽そう
F = {1: 'A', 2: 'B', 3: 'C'}

ans = []
for k, s in enumerate(S):
    if s == 'AB':
        i, j = 1, 2
    elif s == 'BC':
        i, j = 2, 3
    elif s == 'AC':
        i, j = 1, 3

    if X[i] > X[j]:
        X[i] -= 1
        X[j] += 1
        ans.append(j)

    elif X[i] < X[j]:
        X[i] += 1
        X[j] -= 1
        ans.append(i)

    else:
        if (X[i] == X[j] == 1) and (k < N):
            if ((S[k + 1][0] == F[i]) and (S[k + 1][1] == F[i ^ j])) or ((S[k + 1][0] == F[i ^ j]) and (S[k + 1][1] == F[i])):
                X[i] += 1
                X[j] -= 1
                ans.append(i)
            else:
                X[j] += 1
                X[i] -= 1
                ans.append(j)
        else:
            X[i] -= 1
            X[j] += 1
            ans.append(j)

    if any([x < 0 for x in X]):
        print('No')
        exit()

print('Yes')
for a in ans:
    print(F[a])
Problem p02696 (python)

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


def calc(x):
    return ((A * x) // B) - A * (x // B)


if B == 1:
    print(0)
elif B > N:
    print(calc(N))
else:
    print(calc(B - 1))

Buggy submission (verdict: Runtime Error):
A, B, N = map(int, input().split())

def calc(x):
    return ((A * x) // B) - A * (x // B)

prit(max(calc(N), calc(B - 1)))
Problem p02732 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

D = defaultdict(int)
for a in A:
    D[a] += 1

ans_base = 0
for v in D.values():
    ans_base += v * (v - 1) // 2

for a in A:
    if D[a] > 1:
        print(ans_base - (D[a] * (D[a] - 1) // 2) + ((D[a] - 1) * (D[a] - 2) // 2))
    else:
        print(ans_base)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
 
D = defaultdict(int)
for a in A:
    D[a] += 1
 
ans_base = 0
for v in D.values():
    ans_base += v * (v - 1) // 2
 
for a in A:
    print(ans_base - (D[a] * (D[a] - 1) // 2) + ((D[a] - 1) * (D[a] - 2) // 2))