Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = []
for i in range(N):
    S.append(INT())

S = sorted(S)

if ans % 10 != 0:
    print(ans)
    exit()
ans = sum(S)
for i in range(N):
    if S[i] % 10 != 0:
        ans = ans - S[i]
        print(ans)
        exit()

print(0)


Fixed submission:
#14:31-
N = int(input())
s = []
for i in range(N):
    s.append(int(input()))
sum_s = sum(s)
s.sort()
if sum_s % 10 != 0:
    ans = sum_s
else:
    for i in range(N):
        if s[i] % 10 != 0:
            ans = sum_s - s[i]
            break
    else:
        ans = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = S_LIST()
if A[-1] == B[0] and B[-1] = C[0]:
    print("YES")
else:
    print("NO")

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = S_LIST()
if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
if a != b:
    print("D")
else:
    print("H")


Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = S_MAP()
if a != b:
    print("D")
else:
    print("H")
Buggy python submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
else:
    print((N - 2) * (M - 2))


#A = [[0] * W for i in range(H)]
#C = ["o" * W for i in range(H)] 
#C = ["#"*(W+2)] + ["#"+C[i]+"#" for i in range(H)] + ["#"*(W+2)]
#dx = [1, 1, 0, -1, -1, -1, 0, 1]
#dy = [0, 1, 1, 1, 0, -1, -1, -1]
#
#for h in range(H):
#    for w in range(W):
#        for i in range(8):
#            if C[h+1+dx[i]][w+1+dy[i]] == "o":
#                A[h][w] += 1
#ans = 0
#for h in range(H):
#    for w in range(W):
#        if A[h][w] % 2 == 0:
#            ans += 1
#
#print(ans)


Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
a = int(n ** (1/2))
ans = 0

while a * (a + 1) // 2 < n:
    #print(a)
    a += 1

print(a)
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
s_default = N
s_plus = M // 2

# now_make = min(s_default, M//2)
# print(now_make)

ans = 0
for n in range(M//2 + 1):
    A, B = N + n, M - 2 * n
    mi = min(A, B//2)
    ans = max(mi, ans)
print(ans)

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

Scc = min(N, M // 2)
N = N - Scc
M = M - Scc * 2
if N == 0:
    ans = Scc + M // 4
else:
    ans = Scc
print(ans)
Buggy python submission (verdict: Runtime Error):

s=str(input())
atoz=[]
for i in range(len(s)):
	if(s[i]=="A"):
		a=i
		break
#print(a)


for i in range(a,len(s)):
	atoz.append(s[i])

s_l=list(atoz)
#print(s_l)

r_s=[]
s_l_kep=s_l
for i in (reversed(s_l)):
	#print(i)
	if(i!="Z"):
		s_l.pop()
#		print(s_l)
	else:
		break
#	r_s.append(i)
#print(s_l)
str_s_l=''.join(s_l)
#print(str_s_l)
print(len(str_s_l))

Fixed submission:
x = int(input())
if x < 1200:
    print("ABC")
else:
    print("ARC")
Buggy python submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x = INT()

if x % 11 == 0:
    print(2 * x // 11)
else:
    if 6 < x % 11:
        tmp = 2 + 2 * (x // 11)
    else:
        tmp = 1 + 2 * (x // 11)
print(tmp)

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x = INT()

if x % 11 == 0:
    tmp = 2 * x // 11

else:
    if 6 < x % 11:
        tmp = 2 + 2 * (x // 11)
    else:
        tmp = 1 + 2 * (x // 11)
print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
#051B
K,S=map(int,input().split())
count=0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if(i+j+k==S):
                count+=1
print(count)                
            
            

Fixed submission:
#051B
K,S=map(int,input().split())
count=0

for i in range(K+1):
    for j in range(K+1):
    	k=S-i-j
    	if(k<=K and 0<=k):
    		count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
s1=input().replace("eraser","")
s2=s1.replace("erase","")
s3=s2.replace("dreamer","")
s4=s3.replace("dream","")
if s:
	print("No")
else:
	print("Yes")
"""
#failed
import itertools

s=str(input())
add=["dream","dreamer","erase","eraser"]
t=[]

for i,_ in enumerate(add,1):
	for j in itertools.permutations(add,r=i):
		t.append("".join(j))

print(t)

temp=False
for i in range(len(t)):
	if(s==t[i]):
		temp=True
		break

if temp==True:
	print("Yes")
else:
	print("No")
	

"""

Fixed submission:
s = input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s:
    print("NO")
else:
    print("YES")

"""
#failed
import itertools

s=str(input())
add=["dream","dreamer","erase","eraser"]
t=[]

for i,_ in enumerate(add,1):
	for j in itertools.permutations(add,r=i):
		t.append("".join(j))

print(t)

temp=False
for i in range(len(t)):
	if(s==t[i]):
		temp=True
		break

if temp==True:
	print("Yes")
else:
	print("No")
	

"""
Buggy python submission (verdict: Runtime Error):
import sys
W,H,N=map(int,input().split())
wide=[0,W]
height=[0,H]
# white sphere calculate
for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        wide[0]=max(wide[0],x)
    elif a==2:
        wide[1]=min(wide[1],x)
    elif a==3:
        height[0]=max(height[0],y)
    elif a==4:
        height[1]=min(height[1],y)
w_len=wide[1]-wide[0]
h_len=height[1]-height[0]
s=w_len*h_len
if h_len<0 or w_len<0:
    print(0)
else:
    print(s)

Fixed submission:
a,b,c=map(int,input().split())
if(a+b==c or a+c==b or b+c==a):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
sum = 0
for i in range(N-1):
    for j in range(i+1, N):
        sum += (A[i]*A[j])%mod
print(sum%mod)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
cs = A[:]
for i in range(1, N):
	cs[i] += cs[i-1]
sum = 0
for i in range(0, N-1):
	sum += A[i] * (cs[-1] - cs[i])
print(sum % mod)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
sum = 0
for i in range(N-1):
    for j in range(i+1, N):
        sum += A[i]*A[j]
print(sum%mod)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
cs = A[:]
for i in range(1, N):
	cs[i] += cs[i-1]
sum = 0
for i in range(0, N-1):
	sum += A[i] * (cs[-1] - cs[i])
print(sum % mod)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
for i in range(K):
    H = H[:-1]
print(sum(H))

Fixed submission:
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
if K != 0:
    H = H[:-K]
print(sum(H))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
count = 1
for i in range(1, N):
  if P[i] <= min(P[:i]):
    count += 1
print(count)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
count = 1
min = P[0]
for i in range(1, N):
  if P[i] <= min:
    count += 1
    min = P[i]
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
se = [()] * N
for i in range(N):
	x, l = map(int, input().split())
	se[i] = (x-l, x+l)
se = sorted(se, key=lambda x: x[1])
ans = N
for i in range(1, N):
	if se[i-1][1] > se[i][0]:
		se[i][1] = se[i-1][1]
		ans -= 1
print(ans)

Fixed submission:
N = int(input())
se = [[]] * N
for i in range(N):
	x, l = map(int, input().split())
	se[i] = [x-l, x+l]
se = sorted(se, key=lambda x: x[1])
ans = N
for i in range(1, N):
	if se[i-1][1] > se[i][0]:
		se[i][1] = se[i-1][1]
		ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
se = [()] * N
for i in range(N):
	x, l = map(int, input().split())
	se[i] = (x-l, x+l)
se = sorted(se, key=lambda x: x[1])
ans = []
while se:
	now = se.pop(0)
	temp = []
	for i, s in enumerate(se):
		if now[1] <= s[0]:
			temp = se[i:]
			break
	se = temp
	ans.append(now)
print(len(ans))

Fixed submission:
N = int(input())
se = [[]] * N
for i in range(N):
	x, l = map(int, input().split())
	se[i] = [x-l, x+l]
se = sorted(se, key=lambda x: x[1])
ans = N
for i in range(1, N):
	if se[i-1][1] > se[i][0]:
		se[i][1] = se[i-1][1]
		ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
se = [()] * N
for i in range(N):
	x, l = map(int, input().split())
	se[i] = (x-l, x+l)
se = sorted(se, key=lambda x: x[1])
ans = []
while se:
	now = se.pop(0)
	temp = []
	for s, e in se:
		if now[1] <= s:
			temp.append((s, e))
	se = temp
	ans.append(now)
print(len(ans))

Fixed submission:
N = int(input())
se = [[]] * N
for i in range(N):
	x, l = map(int, input().split())
	se[i] = [x-l, x+l]
se = sorted(se, key=lambda x: x[1])
ans = N
for i in range(1, N):
	if se[i-1][1] > se[i][0]:
		se[i][1] = se[i-1][1]
		ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
se = [()] * N
for i in range(N):
	x, l = map(int, input().split())
	se[i] = (x-l, x+l)
se = sorted(se, key=lambda x: x[1])
while True:
	ef = True
	for i, (_, e) in enumerate(se[:-1]):
		if e > se[i+1][0]:
			se.remove(se[i+1])
			ef = False
			break
	if ef:
		break
print(len(se))

Fixed submission:
N = int(input())
se = [[]] * N
for i in range(N):
	x, l = map(int, input().split())
	se[i] = [x-l, x+l]
se = sorted(se, key=lambda x: x[1])
ans = N
for i in range(1, N):
	if se[i-1][1] > se[i][0]:
		se[i][1] = se[i-1][1]
		ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
XYList = []
for i in range(N):
    A = int(input())
    for j in range(A):
        XY = []
        XY.append(list(map(int, input().split())))
    XYList.append(XY)
maxSum = 0
for i in range(2**N):
    sum = 0
    for j in range(N):
        if i >> j & 1:
            honest = True
            for XY in XYList[j]:
                if ((i >> (XY[0]-1)) & 1) != XY[1]:
                    honest = False
                    break
            if honest:
                sum += 1
            else:
                sum = 0
                break
    if maxSum < sum:
        maxSum = sum
print(maxSum)

Fixed submission:
N = int(input())
XYList = []
for i in range(N):
    A = int(input())
    XY = []
    for j in range(A):
        XY.append(list(map(int, input().split())))
    XYList.append(XY)
maxSum = 0
for i in range(2**N):
    sum = 0
    for j in range(N):
        if i >> j & 1:
            honest = True
            for XY in XYList[j]:
                if ((i >> (XY[0]-1)) & 1) != XY[1]:
                    honest = False
                    break
            if honest:
                sum += 1
            else:
                sum = 0
                break
    if maxSum < sum:
        maxSum = sum
print(maxSum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
result = []
for i in range(1, N+1):
	result.append(str(A.index(i)+1))
s = ' '.join(result)
print(s)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
result = [0] * N
for i in range(N):
	result[A[i]-1] = str(i+1)
s = ' '.join(result)
print(s)
Buggy python submission (verdict: Runtime Error):
S = set(input())
a = set([chr(i) for i in range(ord('a'), ord('z')+1)])
print(sorted(list(a-S))[0])

Fixed submission:
S = set(input())
a = set([chr(i) for i in range(ord('a'), ord('z')+1)])
result = sorted(list(a-S))
if len(result) == 0:
    print('None')
else:
    print(result[0])
Buggy python submission (verdict: Runtime Error):
from math import gcd
N = int(input())
T = int(input())
for i in range(N-1):
    t = int(input())
    T = int(T / gcd(T, t) * t)
print(int(T))

Fixed submission:
import math
N = int(input())
T = int(input())
for i in range(N-1):
    t = int(input())
    T = T // math.gcd(T, t) * t
print(T)

Buggy python submission (verdict: Runtime Error):
from math import gcd
N = int(input())
T = int(input())
for i in range(N-1):
    t = int(input())
    T = int(T * t / gcd(T, t))
print(int(T))

Fixed submission:
import math
N = int(input())
T = int(input())
for i in range(N-1):
    t = int(input())
    T = T // math.gcd(T, t) * t
print(T)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
history = []
now = 0
cnt = 0
while(True):
    if now in history:
        cnt = -1
        break
    else:
        cnt += 1
        history.append(now)
        now = a[now]-1
        if now == 1:
            break
print(cnt)

Fixed submission:
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
history = set()
now = 0
cnt = 0
while(True):
    if now in history:
        cnt = -1
        break
    else:
        cnt += 1
        history.add(now)
        now = a[now]-1
        if now == 1:
            break
print(cnt)
Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
P, CP = [], []
 
for i in range(N):
    P.append(list(map(int, input().split())))
for i in range(M):
    CP.append(list(map(int, input().split())))
 
for i in range(N):
    a, b = P[i][0], P[i][1]
    now = 10**8*2+1
    for j in reversed(range(M)):
        c, d = CP[j][0], CP[j][1]
        distance = abs(a-c)+abs(b-d)
        if distance <= now:
            result = j+1
            now = distance
    print(result)

Fixed submission:
N, M = list(map(int, input().split()))
P, CP = [], []

for i in range(N):
    P.append(list(map(int, input().split())))
for i in range(M):
    CP.append(list(map(int, input().split())))

for i in range(N):
    a, b = P[i][0], P[i][1]
    now = 10**10
    for j in reversed(range(M)):
        c, d = CP[j][0], CP[j][1]
        distance = abs(a-c)+abs(b-d)
        if distance <= now:
            result = j+1
            now = distance
    print(result)

Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
P, CP = [], []

for i in range(N):
    P.append(list(map(int, input().split())))
for i in range(M):
    CP.append(list(map(int, input().split())))

for i in range(N):
    a, b = P[i][0], P[i][1]
    now = 10**8*2+1
    for j in reversed(range(M)):
        c, d = CP[j][0], CP[j][1]
        distance = abs(a-c)+abs(b-d)
        if distance <= now:
            result = j+1
            now = distance
    print(result)

Fixed submission:
N, M = list(map(int, input().split()))
P, CP = [], []

for i in range(N):
    P.append(list(map(int, input().split())))
for i in range(M):
    CP.append(list(map(int, input().split())))

for i in range(N):
    a, b = P[i][0], P[i][1]
    now = 10**10
    for j in reversed(range(M)):
        c, d = CP[j][0], CP[j][1]
        distance = abs(a-c)+abs(b-d)
        if distance <= now:
            result = j+1
            now = distance
    print(result)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))

#%%
d = defaultdict(lambda: 0)
for key in A:
    d[key] += 1

for a in A:
    ans = 0
    for k, v in d.items():
        if k == a:
            v -= 1
        ans += v * (v - 1)//2
    print(ans)




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

#%%
d = defaultdict(lambda: 0)
for key in A:
    d[key] += 1

#%%
# それぞれのkeyのnC2
cmb = dict()
cmb2 = dict()
for k in d.keys():
    cmb[k] = d[k] * (d[k] - 1) // 2
    cmb2[k] = (d[k] - 1) * (d[k] - 2) // 2

#%%
ans_d = dict()
s = sum(cmb.values())
for k in d.keys():
    ans_d[k] = s - cmb[k] + cmb2[k]
#%%
for a in A:
    print(ans_d[a])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for _ in range(q):
    t = list(input().split())
    if t[0] == '1':
        s = s[::-1]
    elif t[0] == '2':
        if t[1] == '1':
            s = t[2] + s
        else:
            s = s + t[2]

print(s)

Fixed submission:
from collections import deque

s = input()
q = int(input())

ans = deque(s)
rev = False

for _ in range(q):
    t = list(input().split())
    if t[0] == '1':
        rev = not rev
    elif t[0] == '2':
        if rev == False:
            if t[1] == '1':
                ans.appendleft(t[2])
            else:
                ans.append(t[2])
        else: # rev = Trueのとき
            if t[1] == '1':
                ans.append(t[2])
            else:
                ans.appendleft(t[2])

result = ''.join(ans)
if rev == True:
    result = result[::-1]

print(result)
Buggy python submission (verdict: Runtime Error):
n, k, s = map(int, input().split())

#%%
billion = 1000000000

if s == billion:
    front = [s] * k
    back = [1] * (n - k)
else:
    front = [s] * k
    back = [s+1] * (n - k)

print(*front, *back)

Fixed submission:
n, k, s = map(int, input().split())

#%%
billion = 1000000000

if s == billion:
    front = [s] * k
    back = [1] * (n - k)
else:
    front = [s] * k
    back = [s+1] * (n - k)

front.extend(back)
print(*front)