Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

MOD = 10**9+7

# tot = sum(A)

# ans = 0

# for a in A:
#     ans += a*(tot-a)
#     ans %= MOD

# ans //= 2
# ans %= MOD

ans = 0

for i in range(n):
    for j in range(i+1,n):
        ans += A[i]*A[j]
        ans %= MOD

print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

MOD = 10**9+7

tot = sum(A)
tot %= MOD

ans = 0
rmv = 0

for a in A:
    rmv += a
    rmv %= MOD
    ans += a*(tot-rmv)
    ans %= MOD

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

n = int(input())

str_n = str(n)

tot = 0

# for ch in str_n:
#     tot += int(ch)

while n > 0:
    tot += n % 10
    n //= 10

if tot % 9 == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

str_n = str(n)

tot = 0

for ch in str_n:
    tot += int(ch)

if tot%9 == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys
sys.setrecursionlimit(10**6)

readline = sys.stdin.readline
H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
S = [readline().rstrip() for _ in range(H)]

visited = [[False] * W for _ in range(H)]
dq = deque([(0, Ch, Cw)])

while dq:
    d, i, j = dq.popleft()
    if (i, j) == (Dh, Dw):
        print(d)
        exit()
    if visited[i][j]:
        continue
    visited[i][j] = True
    for di, dj in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        ni, nj = i + di, j + dj
        if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.':
            dq.appendleft((d, ni, nj))
    for di in range(-2, 3):
        for dj in range(-2, 3):
            if di == dj == 0:
                continue
            ni, nj = i + di, j + dj
            if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.' and not visited[ni][nj]:
                dq.append((d + 1, ni, nj))
print(-1)


Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10**6)

readline = sys.stdin.readline
H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
S = [readline().rstrip() for _ in range(H)]

visited = [[False] * W for _ in range(H)]
dq = deque([(0, Ch, Cw)])

while dq:
    d, i, j = dq.popleft()
    if (i, j) == (Dh, Dw):
        print(d)
        exit()
    if visited[i][j]:
        continue
    visited[i][j] = True
    for di, dj in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        ni, nj = i + di, j + dj
        if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.':
            dq.appendleft((d, ni, nj))
    for di in range(-2, 3):
        for dj in range(-2, 3):
            if di == dj == 0:
                continue
            ni, nj = i + di, j + dj
            if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.' and not visited[ni][nj]:
                dq.append((d + 1, ni, nj))
print(-1)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

n = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
C = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

C = list(C)

d = {}
tot = 0

for i,c in enumerate(C):
    if c == 'R':
        tot += 1
    d[i+1] = tot

ans = tot-d[tot]
print(ans)

# left = 0
# left2mid = False
# mid = 0
# right = 0
# right2mid = False

# lp = 0
# rp = -1

# while lp < len(C)+rp:
#     if not left2mid and C[lp] == 'W':
#         left += 1
#     elif not left2mid and C[lp] == 'R':
#         left2mid = True
#     elif left2mid and C[lp] == 'R':
#         mid += 1
#     lp += 1

#     if not right2mid and C[rp] == 'R':
#         right += 1
#     elif not right2mid and C[rp] == 'W':
#         right2mid = True
#     elif right2mid and C[lp] == 'R':
#         mid += 1
#     rp -= 1
# print(left, mid, right)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
C = input()

C = list(C)

d = {0:0}
tot = 0

for i,c in enumerate(C):
    if c == 'R':
        tot += 1
    d[i+1] = tot

ans = tot-d[tot]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
A = list(map(int, input().split()))

#ans = [0]*n
#
#for i in range(k-1, n):
#    tmp = 1
#    for a in A[i-k+1:i+1]:
#        tmp *= a
#    ans[i] = tmp
#
#ans = ans[k-1:]
#
#for i in range(len(ans)-1):
#    if ans[i] < ans[i+1]:
#        print('Yes')
#    else:
#        print('No')

val = 1
for a in A[:k]:
    val *= a
ans = [val]
pos = k
while pos < n:
    tmp = ans[-1]*A[pos]//A[pos-k]
    ans.append(tmp)
    pos += 1
for i in range(len(ans)-1):
    if ans[i] < ans[i+1]:
        print('Yes')
    else:
        print('No')

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
A = list(map(int, input().split()))

#val = 1
#for a in A[:k]:
#    val *= a
#ans = [val]
#pos = k
#while pos < n:
#    tmp = ans[-1]*A[pos]//A[pos-k]
#    ans.append(tmp)
#    pos += 1
#
#for i in range(len(ans)-1):
#    if ans[i] < ans[i+1]:
#        print('Yes')
#    else:
#        print('No')
        
for i in range(n-k):
    pos = k+i
    if A[pos] > A[pos-k]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
A = list(map(int, input().split()))

ans = [0]*n

for i in range(k-1, n):
    tmp = 1
    for a in A[i-k+1:i+1]:
        tmp *= a
    ans[i] = tmp

ans = ans[k-1:]

for i in range(len(ans)-1):
    if ans[i] < ans[i+1]:
        print('Yes')
    else:
        print('No')

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
A = list(map(int, input().split()))

#val = 1
#for a in A[:k]:
#    val *= a
#ans = [val]
#pos = k
#while pos < n:
#    tmp = ans[-1]*A[pos]//A[pos-k]
#    ans.append(tmp)
#    pos += 1
#
#for i in range(len(ans)-1):
#    if ans[i] < ans[i+1]:
#        print('Yes')
#    else:
#        print('No')
        
for i in range(n-k):
    pos = k+i
    if A[pos] > A[pos-k]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))

ans = 1000

def dfs(money, share, day):
    global ans
    if day > n:
        ans = max(ans, money)
        return
    max_buy = money//A[day-1]
    max_sel = share
#    for n_buy in range(-max_sel, max_buy+1):
#        dfs(money-n_buy*A[day-1], share+n_buy, day+1)
    for n_buy in [-max_sel, 0, max_buy]:
        dfs(money-n_buy*A[day-1], share+n_buy, day+1)

dfs(1000,0,1)

print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))

CurrentMoney = 1000

for i in range(0, n-1):
    Stocks = 0
    if A[i] < A[i+1]: Stocks = CurrentMoney // A[i]
    CurrentMoney += (A[i+1] - A[i]) * Stocks

print(CurrentMoney)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))

ans = 1000

def dfs(money, share, day):
    global ans
    if day > n:
        ans = max(ans, money)
        return
    max_buy = money//A[day-1]
    max_sel = share
    for n_buy in range(-max_sel, max_buy+1):
        dfs(money-n_buy*A[day-1], share+n_buy, day+1)

dfs(1000,0,1)

print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))

CurrentMoney = 1000

for i in range(0, n-1):
    Stocks = 0
    if A[i] < A[i+1]: Stocks = CurrentMoney // A[i]
    CurrentMoney += (A[i+1] - A[i]) * Stocks

print(CurrentMoney)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

n = int(input())

d = {(i-97+1):chr(i)%26 for i in range(97,97+26)}
#d[0] = 'z'

l = []

while n > 0:
    tmp = n%26
    l.append(tmp)
    if tmp == 0:
        n = n//26-1
    else:
        n //= 26

ans = ''

for i in l[::-1]:
    ans += d[i]
    
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())

d = {(i-97+1):chr(i) for i in range(97,97+26)}
d[0] = 'z'

l = []

while n > 0:
    tmp = n%26
    l.append(tmp)
    if tmp == 0:
        n = n//26-1
    else:
        n //= 26

ans = ''

for i in l[::-1]:
    ans += d[i]
    
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

n = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

MAX_N = 1000000000000001

d = {(i-97+1):chr(i) for i in range(97,97+26)}

l = []

while n > 0:
    tmp = n%26
    l.append(tmp)
    n -= tmp
    n //= 26

ans = ''

for i in l[::-1]:
    ans += d[i]
    
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())

d = {(i-97+1):chr(i) for i in range(97,97+26)}
d[0] = 'z'

l = []

while n > 0:
    tmp = n%26
    l.append(tmp)
    if tmp == 0:
        n = n//26-1
    else:
        n //= 26

ans = ''

for i in l[::-1]:
    ans += d[i]
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

su = 0

for i in range(1, n):
    su ^= a[i]
    
ans = [su]

for i in range(n-1):
    su = su ^ a[i] ^ a[i+1]
    ans.append(su)
    
print(*su)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

su = 0

for i in range(1, n):
    su ^= a[i]
    
ans = [su]

for i in range(n-1):
    su = su ^ a[i] ^ a[i+1]
    ans.append(su)
    
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
p = [True] * (10 ** 6 + 1)
s = list(set(a))

for x in s:
    t = x * 2
    while t <= 10 ** 6:
        p[t] = False
        t += x

ans = 0
for x in a:
    if c[x] == 1 and p[x] == True:
        ans += 1

print(ans)

Fixed submission:
#Ai/Aj not integer
#5
#24 11 8 3 16
#のときは、24は8,3があるからダメ　16も8があるからダメ
N=int(input())
A=[int(i) for i in input().split()]
D=set()
S=set()
for i in range(N):
    if A[i] in S:
        D.add(A[i])
    else:
        S.add(A[i])
M=max(S)
X=[1 for i in range(M+1)]
for a in S:
    if a in D:
        X[a]=0
    for i in range(2*a,M+1,a):
        X[i]=0
ans=0
for i in range(N):
    if X[A[i]]==1:
        ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

a.sort()

ans = 0

for i in range(n):
    
    x = a[i]

    l = 0; r = n # 二分探索時は探索範囲は取り得る値+-1しておく

    while l+1 < r:
        c = (l+r)//2
        if a[c] < int(x**0.5)+1:
            l = c
        else:
            r = c

    tmp = 1
    for j in range(c+1):
        if i != j and x%a[j] == 0:
            break
    else:
        ans += tmp

print(ans)

Fixed submission:
#Ai/Aj not integer
#5
#24 11 8 3 16
#のときは、24は8,3があるからダメ　16も8があるからダメ
N=int(input())
A=[int(i) for i in input().split()]
D=set()
S=set()
for i in range(N):
    if A[i] in S:
        D.add(A[i])
    else:
        S.add(A[i])
M=max(S)
X=[1 for i in range(M+1)]
for a in S:
    if a in D:
        X[a]=0
    for i in range(2*a,M+1,a):
        X[i]=0
ans=0
for i in range(N):
    if X[A[i]]==1:
        ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))

init = [1]
len_loop = -1

while len(init) <= k:
    nxt = a[init[-1]-1]
    if nxt in init:
        idx_nxt = init.index(nxt)
        len_init = idx_nxt
        len_loop = len(init) - idx_nxt
        break
    else:
        init.append(nxt)

if len_loop == -1:
    print(init[k])
else:
    idx = (k-len_init)%len_loop
    print(init[len_init+idx])

Fixed submission:
n, k = map(int, input().split())
a = tuple(map(lambda n: int(n) - 1, input().split()))

visited = [0] * n
next_town = 0
order = []

while True:
    if visited[next_town]:
        break
    order.append(next_town)
    visited[next_town] = 1
    next_town = a[next_town]

first_loop = len(order)
offset = order.index(next_town)
second_loop = first_loop - offset

if k < first_loop:
    print(order[k] + 1)
else:
    print(order[offset + (k - first_loop) % second_loop] + 1)

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

init = [1]
len_loop = -1

while len(init) <= k:
    nxt = a[init[-1]-1]
    if nxt in init:
        idx_nxt = init.index(nxt)
        len_init = idx_nxt
        len_loop = len(init) - idx_nxt
        break
    else:
        init.append(nxt)

if len_loop == -1:
    print(init[k])
else:
    idx = (k-len_init)%len_loop
    print(init[len_init+idx])

Fixed submission:
n, k = map(int, input().split())
a = tuple(map(lambda n: int(n) - 1, input().split()))

visited = [0] * n
next_town = 0
order = []

while True:
    if visited[next_town]:
        break
    order.append(next_town)
    visited[next_town] = 1
    next_town = a[next_town]

first_loop = len(order)
offset = order.index(next_town)
second_loop = first_loop - offset

if k < first_loop:
    print(order[k] + 1)
else:
    print(order[offset + (k - first_loop) % second_loop] + 1)

Buggy python submission (verdict: Runtime Error):
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))

init = [1]
while True:
    nxt = a[init[-1]-1]
    if nxt in init:
        idx_nxt = init[nxt]
        loop = init[idx_nxt:]
        init = init[:idx_nxt]
        break
    else:
        init.append(nxt)

idx = (k-len(init))%len(loop)
print(loop[idx])

Fixed submission:
n, k = map(int, input().split())
a = tuple(map(lambda n: int(n) - 1, input().split()))

visited = [0] * n
next_town = 0
order = []

while True:
    if visited[next_town]:
        break
    order.append(next_town)
    visited[next_town] = 1
    next_town = a[next_town]

first_loop = len(order)
offset = order.index(next_town)
second_loop = first_loop - offset

if k < first_loop:
    print(order[k] + 1)
else:
    print(order[offset + (k - first_loop) % second_loop] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N,M = [int(i) for i in readline().split()]
H = [int(i) for i in readline().split()]
AB = [[int(i) for i in readline().split()] for _ in range(M)]

ng = []

for a,b in AB:
  if a not in ng:
    if H[a-1] <= H[b-1]:
      ng.append(a)
  if b not in ng:
    if H[b-1] <= H[a-1]:
      ng.append(b)

print(N-len(ng))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N,M = [int(i) for i in readline().split()]
#H = [int(i) for i in readline().split()]
#AB = [[int(i) for i in readline().split()] for _ in range(M)]
H = {i+1:int(e) for i,e in enumerate(readline().split())}
AB = [[int(i) for i in readline().split()] for _ in range(M)]

ng = []

for a,b in AB:
  if H[a] < H[b]:
    ng += [a]
  elif H[a] > H[b]:
    ng += [b]
  else:
    ng += [a,b]
#print(ng)
print(N-len(set(ng)))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N,M = [int(i) for i in readline().split()]
H = [int(i) for i in readline().split()]
AB = [[int(i) for i in readline().split()] for _ in range(M)]

ng = []

for a,b in AB:
  if a not in ng:
    if H[a-1] <= H[b-1]:
      ng.append(a)
  if b not in ng:
    if H[b-1] <= H[a-1]:
      ng.append(b)

print(N-len(ng))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N,M = [int(i) for i in readline().split()]
#H = [int(i) for i in readline().split()]
#AB = [[int(i) for i in readline().split()] for _ in range(M)]
H = {i+1:int(e) for i,e in enumerate(readline().split())}
AB = [[int(i) for i in readline().split()] for _ in range(M)]

ng = []

for a,b in AB:
  if H[a] < H[b]:
    ng += [a]
  elif H[a] > H[b]:
    ng += [b]
  else:
    ng += [a,b]
#print(ng)
print(N-len(set(ng)))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1] # 右からn桁の数についてループを回していきたいので、文字列を反転させる

sum_of_digits = 0 # 余りの値
cnts = [0] * 2019 # 余りの値ごとに余りが同じ値の数を格納する変数。2019で割る場合、余りは0~2018までの2019通りあるので、リストの長さは2019
cnts[0] = 1 # for文はn回しか回らないが、余りを計算したい桁数は0~n桁のn+1個ある。そこで0桁の余はfor文の前に計算しておく。0桁の値を2019で割った余りは0なので、cnts[0]に1を代入しておく
d = 1 # sum_of_digitsの計算に使う10の累乗値

# まず余りの値ごとに余りが同じ値の数を数える
for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
#    d %= 2019 # オーバーフローを避けるために2019の剰余を取る。後述
    cnts[sum_of_digits] += 1

# 次に余りの値ごとにその組み合わせを計算し、足し合わせる
ans = 0
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)

Fixed submission:
s = input()[::-1]

sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    cnts[sum_of_digits] += 1

ans = 0
    
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]

sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
#    d %= 2019
    cnts[sum_of_digits] += 1

ans = 0
    
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)

Fixed submission:
s = input()[::-1]

sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    cnts[sum_of_digits] += 1

ans = 0
    
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
S = input()

res = 0
start = 0
min_length = 4
end = start+min_length
max_end = len(S)

if len(S) < 4:
  pass
else:
  while True:
    tmp_s = S[start:end]

    if int(tmp_s) % 2019 == 0:
      res += 1

    if end+1 <= max_end:
      end += 1
    elif end-(start+1) >= min_length:
      start += 1
      end = start + min_length
    else:
      break
    
print(res)

Fixed submission:
s = input()[::-1]

sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    cnts[sum_of_digits] += 1

ans = 0
    
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,x,y = [int(i) for i in readline().split()]

ans = [0] * n

for a in range(1, n+1):
    for b in range(a+1, n+1):
        d = b - a
        d2 = abs(X-a) + abs(Y-b) + 1
        d = d if d < d2 else d2
        ans[d] += 1

for i in range(1, n):
    print(ans[i])

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,x,y = [int(i) for i in readline().split()]

ans = [0] * n

for a in range(1, n+1):
    for b in range(a+1, n+1):
        d = b - a
        d2 = abs(x-a) + abs(y-b) + 1
        d = d if d < d2 else d2
        ans[d] += 1

for i in range(1, n):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,x,y = [int(i) for i in readline().split()]

INF = 1001001001

from collections import deque

def push(v,d):
    if dist[v] != INF:
        return
    dist[v] = d
    q.append(v)

x -= 1
y -= 1
ans = [0]*n
for sv in range(n):
    dist = [INF]*n
    q = deque()
    push(sv, 0) # 初期状態
    while len(q):
        v = q.popleft()
        d = dist[v]
        if v-1 >= 0: push(v-1, d+1)
        if v+1 < n: push(v+1, d+1)
        if v == x: push(y, d+1)
        if v == y: push(x, d+1)
    for i in range(n):
        ans[dist[i]] += 1
for i in range(n):
    ans[i] //= 2 # (1,2)と(2,1)を2度数えてしまっているので2で割る
for i in range(1,n):
    print(ans[i])

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,x,y = [int(i) for i in readline().split()]

ans = [0] * n

for a in range(1, n+1):
    for b in range(a+1, n+1):
        d = b - a
        d2 = abs(x-a) + abs(y-b) + 1
        d = d if d < d2 else d2
        ans[d] += 1

for i in range(1, n):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

d = {}
for a in A:
  d[a] = d.get(a, 0) + 1
for a in set(A):
  d[a] = (d[a], int(d[a]*(d[a]-1)/2))
  
for i in range(N):
  tmp_d = d.copy()
  tmp = tmp_d[A[i]][0] - 1
  tmp_d[A[i]] = (tmp, int(tmp*(tmp-1)/2))
  sum = 0
  for v in tmp_d.values():
    sum += v[1]
  print(sum)

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

d = {}
for a in A:
  d[a] = d.get(a, 0) + 1
sum = sum([v*(v-1)/2 for v in d.values()]) 

for i in range(N):
  print(int(sum-d[A[i]]+1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

#print(N,A)

d = {}
for a in A:
  d[a] = d.get(a, 0) + 1

for i in range(N):
  tmp_d = d.copy()
  tmp_d[A[i]] -= 1
  sum = 0
  for v in tmp_d.values():
    sum += int(v*(v-1)/2)
  print(sum)


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

d = {}
for a in A:
  d[a] = d.get(a, 0) + 1
sum = sum([v*(v-1)/2 for v in d.values()]) 

for i in range(N):
  print(int(sum-d[A[i]]+1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

#print(N,A)

for i in range(N):
  d = {}
  for j,a in enumerate(A):
    if j != i:
      d[a] = d.get(a, 0) + 1
  sum = 0
  for v in d.values():
    sum += int(v*(v-1)/2)
  print(sum)


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

d = {}
for a in A:
  d[a] = d.get(a, 0) + 1
sum = sum([v*(v-1)/2 for v in d.values()]) 

for i in range(N):
  print(int(sum-d[A[i]]+1))