Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from itertools import combinations_with_replacement
from collections import Counter

n = int(input())
a = list(map(int, input().split())) #1-index

ans_l = []
for k in range(n):
    ans = 0
    temp = a[k]
    a.remove(a[k]) #k番目を取り除いた
    c_v = list(Counter(a).values())
    for i in c_v:
        if i > 1:
            ans += len((list(combinations_with_replacement(range(1,i), 2))))
    a.insert(k,temp)
    ans_l.append(ans)

for i in ans_l:
    print(i)


### FIXED CODE ###

from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
sums=0
for k in s.keys():
    sums+=(s[k]-1)*s[k]//2

for i in a:
    print(sums-s[i]+1)
### BUGGY CODE ###

# coding: utf-8
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
P = lr()
dp = [[min(i, N-1-i)] * N for i in range(N)]
people = [[True] * N for i in range(N)]
for j in range(N):
    x = min(j, N-1-j)
    for i in range(N):
        dp[i][j] = min(dp[i][j], x)

answer = 0

def bfs(sy, sx):
    que = deque([(sy, sx)])
    popleft = que.popleft; append = que.append
    used = set()
    while que:
        y, x = popleft()
        if (y, x) in used:
            continue
        used.add((y, x))
        cur = dp[y][x]
        if cur == -1 and not people[y][x]:
            people[y][x] = True
        for dy, dx in zip([0, 1, 0, -1], [1, 0, -1, 0]):
            ny = y + dy
            nx = x + dx
            if 0 <= ny < N and 0 <= nx < N:
                if dp[ny][nx] > cur + 1:
                    dp[ny][nx] = cur + 1
                    if not people[ny][nx]:
                        dp[ny][nx] = cur
                    if (ny, nx) not in used:
                        append((ny, nx))
                elif dp[ny][nx] > cur and (not people[ny][nx]):
                    # 人がいない時
                    dp[ny][nx] = cur
                    if (ny, nx) not in used:
                        append((ny, nx))

for p in P:
    p -= 1
    i = p // N
    j = p % N
    answer += dp[i][j]
    dp[i][j] -= 1
    people[i][j] = False
    bfs(i, j)

print(answer)


### FIXED CODE ###

# coding: utf-8
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def main():
    N = ir()
    P = lr()
    P = [((p-1)//N, (p-1)%N) for p in P]
    dp = [[min(i, N-1-i, j, N-1-j) for j in range(N)] for i in range(N)]
    people = [[True] * N for i in range(N)]

    answer = 0
    for i, j in P:
        answer += dp[i][j]
        people[i][j] = False
        que = deque([(i, j, dp[i][j])])
        popleft = que.popleft; append = que.append
        while que:
            y, x, cur = popleft()
            cur += people[y][x]
            if x > 0:
                if dp[y][x-1] > cur:
                    dp[y][x-1] = cur
                    append((y, x-1, cur))
            if x < N-1:
                if dp[y][x+1] > cur:
                    dp[y][x+1] = cur
                    append((y, x+1, cur))
            if y > 0:
                if dp[y-1][x] > cur:
                    dp[y-1][x] = cur
                    append((y-1, x, cur))
            if y < N-1:
                if dp[y+1][x] > cur:
                    dp[y+1][x] = cur
                    append((y+1, x, cur))

    print(answer)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

class Factorial():
    def __init__(self, n, mod):
        self.mod = mod
        self.factorial = [0 for _ in range(n + 1)]
        self.inv = [0 for _ in range(n + 1)]
        self.factorial[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.factorial[i + 1] = self.factorial[i] * (i + 1) % mod
        self.inv[n] = pow(self.factorial[n], mod - 2, mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i + 1] * (i + 1) % mod

    def fact(self, m):
        return self.factorial[m]

    def invfact(self, m):
        return self.inv[m]


MOD = 10**9 + 7

N = int(input())
X = list(map(int, input().split()))

D = [X[i + 1] - X[i] for i in range(N - 1)]

F = Factorial(N + 1, MOD)

res = 0
f = 0

for i in range(N - 1):
    f = (i + 1) * f + F.fact(i)
    res += D[i] * f * F.invfact(i + 1) * F.fact(N - 1)
    res %= MOD

print(res)

### FIXED CODE ###

class Factorial():
    def __init__(self, n, mod):
        self.mod = mod
        self.factorial = [0 for _ in range(n + 1)]
        self.inv = [0 for _ in range(n + 1)]
        self.factorial[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.factorial[i + 1] = self.factorial[i] * (i + 1) % mod
        self.inv[n] = pow(self.factorial[n], mod - 2, mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i + 1] * (i + 1) % mod

    def fact(self, m):
        return self.factorial[m]

    def invfact(self, m):
        return self.inv[m]


MOD = 10**9 + 7

N = int(input())
X = list(map(int, input().split()))

D = [X[i + 1] - X[i] for i in range(N - 1)]

F = Factorial(N + 1, MOD)

res = 0
f = 0

for i in range(N - 1):
    f = (i + 1) * f + F.fact(i)
    f %= MOD
    res += D[i] * f * F.invfact(i + 1) * F.fact(N - 1)
    res %= MOD

print(res)
### BUGGY CODE ###

#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_a
import itertools

intext = input()
[n, k] = map(int, intext.split())

int_list = [v for v in range(1, n+1)]
nk_combis = itertools.combinations(int_list, k)
ans_nk_combis_cnt = 0

for nk_combi in nk_combis:
    # nk_list = list(nk_combi)

    prev_item = None
    is_renzoku = True

    for nk_item in nk_combi:
        if (prev_item != None) and (prev_item + 1 != nk_item):
            is_renzoku = False
            break
        prev_item = nk_item

    if is_renzoku:
        ans_nk_combis_cnt += 1
        # ans_nk_combis.append(nk_list)

print(ans_nk_combis_cnt)
# print(len(ans_nk_combis))


### FIXED CODE ###

#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_a
import itertools

intext = input()
[n, k] = map(int, intext.split())
print(n-k+1)
### BUGGY CODE ###

n = int(input())
v = list(map(int, input().split()))
vo = [v[i] for i in range(n) if i%2 == 0]
ve = [v[i] for i in range(n) if i%2 == 1]
vo_uni = list(set(vo))
ve_uni = list(set(ve))
vo_cnt = [vo.count(x) for x in vo_uni]
ve_cnt = [ve.count(x) for x in ve_uni]
if vo_uni == ve_uni and len(vo_uni) == 1:
    ans = n//2
else:
    ans = n - max(vo_cnt) - max(ve_cnt)
print(ans)

### FIXED CODE ###

import collections
n = int(input())
v = list(map(int, input().split()))
vo = [v[i] for i in range(n) if i%2 == 0]
ve = [v[i] for i in range(n) if i%2 == 1]
vo_dict = collections.Counter(vo)
ve_dict = collections.Counter(ve)
if vo_dict == ve_dict and len(vo_dict) == 1:
    ans = n//2
else:
    if vo_dict.most_common()[0][0] != ve_dict.most_common()[0][0]:
        ans = n - vo_dict.most_common()[0][1] - ve_dict.most_common()[0][1]
    else:
        ans = min(n - vo_dict.most_common()[0][1] - ve_dict.most_common(2)[1][1],
                  n - vo_dict.most_common(2)[1][1] - ve_dict.most_common()[0][1])
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = ""
if N % 2 == 0:
  for i in range(N-1, -1, -2):
    ans += str(A[i])
    ans += " "
  for i in range(0, N, 2):
    ans += str(A[i])
    if i != N - 2:
      ans += " "
else:
  for i in range(N-1, -2, -2):
    ans += str(A[i])
    ans += " "
  for i in range(1, N, 2):
    ans += str(A[i])
    if i != N - 2:
      ans += " "
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
  for i in range(N-1, -1, -2):
    print(A[i], end = "")
    print(" ", end = "")
  for i in range(0, N, 2):
    print(A[i], end = "")
    if i != N - 2:
      print(" ", end = "")
    else:
      print("")
else:
  for i in range(N-1, -2, -2):
    print(A[i], end = "")
    print(" ", end = "")
  for i in range(1, N, 2):
    print(A[i], end = "")
    if i != N - 2:
      print(" ", end = "")
    else:
      print("")
### BUGGY CODE ###

from copy import deepcopy

s=list(input())
t=list(input())

l1,l2 = len(s),len(t)

dp = [[[]]*(l2+1) for _ in range(l1+1)]

for i in range(1,l1+1):
  for j in range(1,l2+1):
    if s[i-1]==t[j-1]:
      dp[i][j] = deepcopy(dp[i-1][j-1])
      dp[i][j].append(s[i-1])
    else:
      if len(dp[i-1][j]) >= len(dp[i][j-1]):
        dp[i][j] = deepcopy(dp[i-1][j])
      else:
        dp[i][j] = deepcopy(dp[i][j-1])
      
print(''.join(dp[-1][-1]))

### FIXED CODE ###

s=input()
t=input()

l1,l2 = len(s),len(t)

dp = [[0]*(l2+1) for _ in range(l1+1)]
memo = [['']*(l2+1) for _ in range(l1+1)]

for i in range(1,l1+1):
  for j in range(1,l2+1):
    if s[i-1]==t[j-1]:
      dp[i][j] = dp[i-1][j-1] + 1
      memo[i][j] = s[i-1]
    else:
      if dp[i-1][j] >= dp[i][j-1]:
        dp[i][j] = dp[i-1][j]
        memo[i][j] = (i-1,j)
      else:
        dp[i][j] = dp[i][j-1]
        memo[i][j] = (i,j-1)
      
i,j = l1,l2
ans = []
while i > 0 and j > 0:
  if len(memo[i][j]) == 2:
    i, j = memo[i][j]
  else:
    ans.append(memo[i][j])
    i, j = i-1, j-1
    
print(''.join(ans[::-1]))
### BUGGY CODE ###

def main():
    h,*s=open(0)
    h,w=map(int,h.split())
    a=tuple([0]*w for _ in range(h))
    b=tuple([0]*w for _ in range(h))
    c=tuple([0]*h for _ in range(w))
    d=tuple([0]*h for _ in range(w))
    for t,x,y in zip(s,a,b):
        x[0]=int(t[0]=='.')
        for i,u in enumerate(t[1:-1]):
            x[i+1]=x[i]+1if u=='.'else 0
        y[-1]=int(t[-2]=='.')
        for i,u in enumerate(t[-3::-1],1):
            y[~i]=y[-i]+1if u=='.'else 0
    for t,x,y in zip(zip(*s),c,d):
        x[0]=int(t[0]=='.')
        for i,u in enumerate(t[1:]):
            x[i+1]=x[i]+1if u=='.'else 0
        y[-1]=int(t[-1]=='.')
        for i,u in enumerate(t[-2::-1],1):
            y[~i]=y[-i]+1if u=='.'else 0
    print(max(sum(u)-3for t in zip(a,b,zip(*c),zip(*d))for u in zip(*t)))
main()

### FIXED CODE ###

def main():
    h,*s=open(0)
    h,w=map(int,h.split())
    a=tuple([0]*w for _ in range(h))
    b=tuple([0]*w for _ in range(h))
    c=tuple([0]*w for _ in range(h))
    d=tuple([0]*w for _ in range(h))
    for i in range(h*w):
        i,j=divmod(i,w)
        a[i][j]=a[i][j-1]+1if s[i][j]=='.'else 0
        b[i][~j]=b[i][-j]+1if s[i][-j-2]=='.'else 0
        c[i][j]=c[i-1][j]+1if s[i][j]=='.'else 0
        d[~i][j]=d[-i][j]+1if s[~i][j]=='.'else 0
    print(max(a[i][j]+b[i][j]+c[i][j]+d[i][j]-3for i in range(h)for j in range(w)))
main()
### BUGGY CODE ###

n, m = map(int, input().split())

gates = []
for _ in range(m):
    gates.append(tuple(map(int, input().split())))

count = 0
for i in range(1, n+1):
    if all(map(lambda gate: gate[0] <= i <= gate[1], gates)):
        count += 1
print(count)


### FIXED CODE ###

n, m = map(int, input().split())

gates = []
start, end = 1, n
for _ in range(m):
    L, R = map(int, input().split())
    if L > start:
        start = L
    if R < end:
        end = R

print(len(range(start, end+1)))
### BUGGY CODE ###

from collections import deque

h, w = map(int, input().split())

s = []
cnt = 0
for _ in range(h):
    tmp = list(input())
    cnt += tmp.count("#")
    s.append(tmp)

pos = [0, 0]
ans = 1
direction = [[0, 1], [0, -1], [1, 0], [-1, 0]]
queue = deque()
queue.append(pos)
queue.append(ans)
check = [[False for _ in range(w)] for _ in range(h)]
while queue:
    pos = queue.popleft()
    ans = queue.popleft()
    check[pos[0]][pos[1]] = True
    ans += 1
    for dy, dx in direction:
        y = pos[0] + dy
        x = pos[1] + dx
        if x == -1 or x == w or y == -1 or y == h:
            continue
        if check[y][x]:
            continue
        if s[y][x] == "#":
            continue
        if y == h - 1 and x == w - 1:
            print(h * w - cnt - ans)
            exit()
        queue.append([y, x])
        queue.append(ans)
    
else:
    print(-1)
    exit()


### FIXED CODE ###

from collections import deque

h, w = map(int, input().split())

s = []
cnt = 0
for _ in range(h):
    tmp = list(input())
    cnt += tmp.count("#")
    s.append(tmp)

pos = [0, 0]
ans = 1
direction = [[0, 1], [0, -1], [1, 0], [-1, 0]]
queue = deque()
queue.append(pos)
queue.append(ans)
check = [[False for _ in range(w)] for _ in range(h)]
check[0][0] = True
while queue:
    pos = queue.popleft()
    ans = queue.popleft()
    ans += 1
    for dy, dx in direction:
        y = pos[0] + dy
        x = pos[1] + dx
        if x == -1 or x == w or y == -1 or y == h:
            continue
        if check[y][x]:
            continue
        if s[y][x] == "#":
            check[y][x] = True
            continue
        if y == h - 1 and x == w - 1:
            print(h * w - cnt - ans)
            exit()
        check[y][x] = True
        queue.append([y, x])
        queue.append(ans)
    
else:
    print(-1)
    exit()
### BUGGY CODE ###

n = int(input())

a_list = list(map(int, input().split()))
s = 0
for i in range(n-1):
    for j in range(i+1, n):
        s += a_list[i] * a_list[j]

ans = s % 1000000007

print(ans)



### FIXED CODE ###

n = int(input())

a_list = list(map(int, input().split()))
sum_l = sum(a_list)
ans = 0
for i in range(n-1):
    sum_l -= a_list[i]
    ans += sum_l * a_list[i]
print(ans % 1000000007)
### BUGGY CODE ###

from collections import deque

n, m = map(int, input().split())
graph = [[] for _ in range(n)]
ans = [0 for _ in range(n)]

explored = [0]

for _ in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

q = deque()
parent = 0
for k in graph[0]:
    ans[k] = 0
    q.append(k)
    explored.append(k)
ans[0] = 0
while len(q) != 0:
    now = q.popleft()
    parent = now
    for node in graph[now]:
        if node not in explored:
            q.append(node)
            ans[node] = parent
            explored.append(node)

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

### FIXED CODE ###

from collections import deque

n, m = map(int, input().split())
graph = [[] for _ in range(n)]
ans = [0 for _ in range(n)]

explored = {0}

for _ in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

q = deque()
parent = 0
for k in graph[0]:
    ans[k] = 0
    q.append(k)
    explored.add(k)
ans[0] = 0
while len(q) != 0:
    now = q.popleft()
    parent = now
    for node in graph[now]:
        if node not in explored:
            q.append(node)
            ans[node] = parent
            explored.add(node)

print('Yes')
for i in range(1, n):
    print(ans[i]+1)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N=int(input().rstrip('\n'))
A=[int(x) for x in input().rstrip('\n').split()]
res = 0
now = 0
for i in range(1,N+1):
  if i in A:
    res += 1
    now = A.index(i)
    A = A[now:]
  else:
    break
if res == 0:
  print(-1)
else:
  print(N-res)


### FIXED CODE ###

import sys
input = sys.stdin.readline

N=int(input().rstrip('\n'))
A=[int(x) for x in input().rstrip('\n').split()]
now = 0
for x in range(N):
  if A[x] == now+1:
    now += 1
if now == 0:
  print(-1)
else:
  print(N-now)
### BUGGY CODE ###

def resolve():
	n = int(input())
	ans = 1
	for i in range(1, n+1):
		ans *= i
	ans %= (10**9 + 7)
	print(ans)
resolve()

### FIXED CODE ###

def resolve():
	n = int(input())
	ans = 1
	for i in range(1, n+1):
		ans *= i
		ans %= (10**9 + 7)
	print(ans)
resolve()
### BUGGY CODE ###

def binaryinsertion(A,x):
    left=0;right=len(A)-1;centre = len(A)//2
    while(True):
        if(left == right):
            if(x[0]<A[left][0]):
                A.insert(left,x)
                break
            else :
                A.insert(left+1,x)
                break
        else:
            if(x[0] < A[centre][0]) :
                right = centre - 1
            elif(A[centre][0] < x[0]) :
                left = centre
            else : 
                A.insert(centre,x)
                break
            centre = left + (right-left)//2

[N,L] = [int(x) for x in input().split()]
A = [[int(x),int(i)] for i,x in enumerate(input().split())]
sweep = A[:L]
sweep = sorted(sweep)
ans = [str(sweep[0][0])]
for i in range(L,N) :
    sweep.remove(A[i-L])
    binaryinsertion(sweep,A[i])
    ans.append(str(sweep[0][0]))
print(" ".join(ans))

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###


N=int(input())
p=list(map(float,input().split()))
dp=[[0 for i in range(N+1)] for j in range(N+1)]
dp[0][0]=1
for i in range(1,N+1):
    for j in range(N+1):
        if j>0:
            dp[i][j]+=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1]
        else:
            dp[i][j]+=dp[i-1][j]*(1-p[i-1])


print(sum(dp[N][N//2+1:]))

### FIXED CODE ###


N=int(input())
p=list(map(float,input().split()))
dp=[[0 for i in range(N+1)] for j in range(N+1)]
dp[0][0]=1
for i in range(1,N+1):
    for j in range(N+1):
        if j>0:
            dp[i][j]+=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1]
        else:
            dp[i][j]+=dp[i-1][j]*(1-p[i-1])


print(sum(dp[N][N//2+1:]))
### BUGGY CODE ###

S = input()
Q = int(input())
for i in range(Q):
  a = list(input().split())
  if len(a)==1:
    S = S[::-1]
  else:
    if int(a[1]) == 1:
      S = a[2]+S
    else:
      S = S+a[2]
print(S)

### FIXED CODE ###

from collections import deque
s=input()
q=int(input())
turn=0
ans=deque(s)
for i in range(q):
    query=input().split()
    if query[0]=="1":
        turn+=1
    if query[0]=="2":
        if query[1]=="1":
            if turn%2==0:
                ans.appendleft(query[2])
            else:
                ans.append(query[2])
        elif query[1]=="2":
            if turn%2==0:
                ans.append(query[2])
            else:
                ans.appendleft(query[2])
ans="".join(ans)
if turn%2==1:
    ans=ans[::-1]
print(ans)
### BUGGY CODE ###

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    N = int(input())

    x = prime_factorize(N)
    D = []
    for i in range(2 ** len(x)):
        a = format(i, '0{}b'.format(len(x)))
        D.append(a)

    # print(x)
    # print(D)

    mn = 1 + N
    for di in D:
        a = 1
        b = 1
        for i, dii in enumerate(di):
            if dii == '0':
                a = a * x[i]
            else:
                b = b * x[i]

            if a + b > mn:
                continue
        mn = min(mn, a + b)
    print(mn - 2)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from math import sqrt, floor

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    N = int(input())

    # x = prime_factorize(N)
    # D = []
    # for i in range(2 ** len(x)):
    #     a = format(i, '0{}b'.format(len(x)))
    #     D.append(a)

    # mn = 1 + N
    # for di in D:
    #     a = 1
    #     b = 1
    #     for i, dii in enumerate(di):
    #         if dii == '0':
    #             a = a * x[i]
    #         else:
    #             b = b * x[i]
    #     mn = min(mn, a + b)
    # print(mn - 2)

    NN = floor(sqrt(N))
    mn = N + 100
    for i in range(1, NN + 1):
        if N % i == 0:
            a = i
            b = N // i
            # print(a, b)
            mn = min(mn, a + b)

    print(mn - 2)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

class UnionFind:

    def __init__(self, n):
        self.t = [-1] * (n + 1)

    def flatten(self):
        for i, _ in enumerate(self.t):
            self.find_root(i)

    def union(self, a, b):
        ra = self.find_root(a)
        rb = self.find_root(b)
        if ra != rb:
            self.t[max(ra, rb)] = min(ra, rb)

    def find_root(self, x):
        t = []
        while self.t[x] > 0:
            t.append(x)
            x = self.t[x]
        for _t in t:
            self.t[_t] = x
        return x


def solve(string):
    n, m, k, *abcd = map(int, string.split())
    ab, cd = abcd[:2 * m], abcd[2 * m:]
    fr, br = [[] for _ in range(n + 1)], [[] for _ in range(n + 1)]
    uf = UnionFind(n)
    for a, b in zip(*[iter(ab)] * 2):
        fr[a].append(b)
        fr[b].append(a)
        uf.union(a, b)
    uf.flatten()
    for i, v in enumerate(uf.t):
        if v < 0:
            uf.t[i] = i
    mp = {k: i for i, k in enumerate(set(uf.t[1:]))}
    g = [[] for _ in enumerate(mp.keys())]
    for i in range(n + 1):
        if uf.t[i] > 0:
            g[mp[uf.t[i]]].append(i)
    for c, d in zip(*[iter(cd)] * 2):
        br[c].append(d)
        br[d].append(c)

    *fr, = map(set, fr)
    *br, = map(set, br)
    *g, = map(set, g)
    return " ".join([str(len(g[mp[uf.t[i]]] - set([i]) - fr[i] - br[i])) for i in range(1, n + 1)])


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


### FIXED CODE ###

class UnionFind:

    def __init__(self, n):
        self.t = [-1] * (n + 1)

    def flatten(self):
        for i, _ in enumerate(self.t):
            self.find_root(i)

    def union(self, a, b):
        ra = self.find_root(a)
        rb = self.find_root(b)
        if ra != rb:
            self.t[max(ra, rb)] = min(ra, rb)

    def find_root(self, x):
        t = []
        while self.t[x] > 0:
            t.append(x)
            x = self.t[x]
        for _t in t:
            self.t[_t] = x
        return x


def solve(string):
    n, m, k, *abcd = map(int, string.split())
    ab, cd = abcd[:2 * m], abcd[2 * m:]
    fr, br = [[] for _ in range(n + 1)], [[] for _ in range(n + 1)]
    uf = UnionFind(n)
    for a, b in zip(*[iter(ab)] * 2):
        fr[a].append(b)
        fr[b].append(a)
        uf.union(a, b)
    uf.flatten()
    for i, v in enumerate(uf.t):
        if v < 0:
            uf.t[i] = i
    mp = {k: i for i, k in enumerate(set(uf.t[1:]))}
    g = [[] for _ in enumerate(mp.keys())]
    for i in range(n + 1):
        if uf.t[i] > 0:
            g[mp[uf.t[i]]].append(i)
    for c, d in zip(*[iter(cd)] * 2):
        br[c].append(d)
        br[d].append(c)

    *fr, = map(len, fr)
    *g, = map(set, g)
    *gn, = map(len, g)
    return " ".join([
        str(gn[mp[uf.t[i]]] - 1 - fr[i] - sum(j in g[mp[uf.t[i]]]
                                              for j in br[i]))
        for i in range(1, n + 1)
    ])


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))