Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(Q)]

cup = list(range(N+1)) + [0]
se = set()
se.add(1)
se.add(2)
for a,b in AB:
    cup[a],cup[b] = cup[b],cup[a]
    for x in [a,b]:
        if cup[x] == 1:
            ball = x
    se.add(cup[ball-1])
    se.add(cup[ball+1])

se.discard(0)
answer = len(se)
print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(Q)]

cup = list(range(N+1)) + [0]
se = set([0,1,2])
ball = 1
for a,b in AB:
    cup[a],cup[b] = cup[b],cup[a]
    for x in [a,b]:
        if cup[x] == 1:
            ball = x
    se.add(cup[ball-1])
    se.add(cup[ball+1])

se.remove(0)
answer = len(se)
print(answer)
w, h, n = map(int, input().split(" "))
x_y_a = [tuple(map(int, input().split(" "))) for i in range(n)]

min_x, max_x, min_y, max_y = 0, w, 0, h
for x_y_a_i in x_y_a:
    x, y, a = x_y_a_i
    if a == 1:
        min_x = x
    elif a == 2:
        max_x = x
    elif a == 3:
        min_y = y
    elif a == 4:
        max_y = y

print(min(0, max_x-min_x) * min(0, max_y-min_y)))

### FIXED CODE ###

W,H,N=map(int,input().split())
x=y=0
for i in range(N):
  xi,yi,a=map(int,input().split())
  if a==1:
    x=max(x,xi)
  elif a==2:
    W=min(W,xi)
  elif a==3:
    y=max(y,yi)
  elif a==4:
    H=min(H,yi)
    
print(0 if x>=W or y>=H else (W-x)*(H-y))
import itertools

N = int(input())
S = input()
out = S.count('R') * S.count('G') * S.count('B')
for i in range(1, N):
  for j in range(N-i*2):
    if (S[j], S[j+i], S[j+i*2]) in RGBs:
      out -= 1
print(out)

### FIXED CODE ###

import itertools

N = int(input())
S = input()

R = []
G = []
B = []

RGBs = list(itertools.permutations(['R', 'G', 'B'], 3))
for i, s in enumerate(S):
  if s == 'R': R.append(i)
  if s == 'G': G.append(i)
  if s == 'B': B.append(i)
out = len(R) * len(G) * len(B)
for i in range(1, N):
  for j in range(N-i*2):
    if (S[j], S[j+i], S[j+i*2]) in RGBs:
      out -= 1
print(out)
import sys
input = sys.stdin.readline

def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def same(x, y):
    if find(x) == find(y):
        return True
    else:
        return False

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x] > rank[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x

def uCnt(x):
    return -par[find(x)]

N, M, K = map(int, input().split())
par = [-1 for i in range(N)]
rank = [0] * N
frendCnt = [0] * N
bloc = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    frendCnt[a] += 1
    frendCnt[b] += 1
    unite(a, b)

for i in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    bloc[c].append(d)
    bloc[d].append(c)

for i in range(N):
    ans = uCnt(i) - frendCnt[i] - 1
    for j in bloc[i]:
       if same(i, j):
           ans -= 1
    print(ans, end=' ')

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

num = [0]*n

for i in range(m):
    a,b = map(int,input().split())
    unite(a-1,b-1)
    num[a-1] += 1
    num[b-1] += 1

edge = [[] for i in range(n)]

for i in range(k):
    c,d = map(int,input().split())
    edge[c-1].append(d-1)
    edge[d-1].append(c-1)


for i in range(n):
    cnt = size(i) - num[i] - 1
    for e in edge[i]:
        if same(e,i):
            cnt -= 1
    print(cnt,end=' ')
A = [int(input())  for _  in range(5)]
k = int(input())

if A[4] - A[0] <= k
    print("Yay!"  )
else:
    print(":(")
         
         


### FIXED CODE ###

A = [int(input())  for _  in range(5)]
k = int(input())

if A[4] - A[0] <= k:
    print("Yay!"  )
else:
    print(":(")
%%test_input https://atcoder.jp/contests/abc082/tasks/abc082_b
#B
import collections

s = str(input())
t = str(input())
sd = list(s)
td = list(t)
sd.sort()
td.sort(reverse=True)
a = ''
b = ''
for c in sd:
    a += c
for c in td:
    b += c
if sd < td:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

#B
import collections

s = str(input())
t = str(input())
sd = list(s)
td = list(t)
sd.sort()
td.sort(reverse=True)
a = ''
b = ''
for c in sd:
    a += c
for c in td:
    b += c
if sd < td:
    print('Yes')
else:
    print('No')
map(int,input().spilit())
print(r//d-(l-1)//d)


### FIXED CODE ###

l, r, d = map(int, input().split())
print(r//d - (l-1)//d)
S = list(input())
if len(list(set(S))) != 0:
    i =0
    count = 0
    while True:
        if S[i] != S[i+1]:
            count += 1
            S[i] = S[i + 1]
        i += 1
        if i == (len(S)-1):
            break
print(count)
            

### FIXED CODE ###

S = list(input())
if len(list(set(S))) != 1:
    i =0
    count = 0
    while True:
        if S[i] != S[i+1]:
            count += 1
            S[i] = S[i + 1]
        i += 1
        if i == (len(S)-1):
            break
else:
    count = 0
print(count)
if int(input()) % 9 == 0 : print("Yes")
else print("No")

### FIXED CODE ###

if int(input()) % 9 == 0 : print("Yes")
else : print("No")
N,M = map(int, input().sprit())
A = list(map(int, input().split()))
a = sum(A)
ans = N -a
if ans >= 0:
    print(ans)
else:
    print(-1)
    
        


### FIXED CODE ###

N,M = map(int, input().split())
A = list(map(int, input().split()))
a = sum(A)
ans = N -a
if ans >= 0:
    print(ans)
else:
    print(-1)
import math

A, B = map(int, input().split())


def f(num):
    n_max = math.ceil(math.log2(num+1))
    result = 0
    for n in range(n_max):
        if n == 0:
            r = num % 4
            if r == 1 or r == 2:
                result += 1
            continue
        r = (num+1) % 2**(n+1)
        if r <= 2**n:
            continue
        else:
            r -= 2**n

        if r % 2 == 1:
            result += 2**n

    return result


print(f(A-1) ^ f(B))


### FIXED CODE ###

import math

A, B = map(int, input().split())


def f(num):
    n_max = math.ceil(math.log2(num+1))
    result = 0
    for n in range(n_max):
        if n == 0:
            r = num % 4
            if r == 1 or r == 2:
                result += 1
            continue
        r = (num+1) % 2**(n+1)
        if r <= 2**n:
            continue
        else:
            r -= 2**n

        if r % 2 == 1:
            result += 2**n

    return result


if A > 0:
    print(f(A-1) ^ f(B))
else:
    print(f(B))
n = input().int()
k = input().int()
x = input().int()
y = input().int()

if n <= k:
    print(n*x)
else:
    print(k*x+(n-k)*y)

### FIXED CODE ###

n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n <= k:
    print(n*x)
else:
    print(k*x+(n-k)*y)
n = int(input())
s = []
length = 100
for i in range(n):
    S = sorted(input())
    s.append(S)
    length = min(length, len(S))

ans = ""
for i in range(length):
    tmp = 0
    for j in range(n-1):
        if s[j][i] == s[j+1][i]:
            tmp += 1
    if tmp == n - 1:
        ans += s[j][i]
print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
s = [input() for _ in range(n)]

cnt = Counter(s[0])
for i in s[1:]:
    cnt &= Counter(i)
ans = ""
for i, v in sorted(cnt.items()):
    ans += i * v
print(ans)
import math

def overlap(p1, p2, d):
    return (p1[0] - p2[0])**2 + (p1[1] - p2[1])**2 - d**2

def intersection(o1,o2):
    a  = 2*(o2[0] - o1[0])
    b  = 2*(o2[1] - o1[1])
    c  = (o1[0] - o2[0])*(o1[0] + o2[0]) + (o1[1] - o2[1])*(o1[1] + o2[1])
    a2 = a**2 + b**2
    b2 = a*c + a*b*o1[1] - b**2*o1[0]
    c2 = b**2*(o1[0]**2 + o1[1]**2 - 1) + c**2 + 2*b*c*o1[1]
    x1 = (-b2 + math.sqrt(b2**2 - a2*c2))/a2
    x2 = (-b2 - math.sqrt(b2**2 - a2*c2))/a2
    if abs(b) == 0:
        y1 = o1[1] + math.sqrt(1 - (x1 - o1[0])**2)
        y2 = o1[1] - math.sqrt(1 - (x1 - o1[0])**2)
    else:
        y1 = -(a*x1 + c)/b
        y2 = -(a*x2 + c)/b
    return [x1, y1], [x2, y2]

err = 1.0e-6
while True:
    n = int(input())
    if n == 0:
        break
    p = []
    for i in range(n):
        p.append(list(map(float, input().split(","))))
    ans = 1
    for i in range(n - 1):
        for j in range(i + 1, n):
            if overlap(p[i], p[j], 2) > 0:
                continue
            p1, p2 = intersection(p[i], p[j])
            cnt1 = 0
            cnt2 = 0
            for k in range(n):
                if overlap(p1, p[k], 1) < 0:
                    cnt1 += 1
                if overlap(p2, p[k], 1) < 0:
                    cnt2 += 1
            ans = max([ans, cnt1, cnt2])
    print(ans)



### FIXED CODE ###

import math

def dist(p1, p2):
    return math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)

def intersection(o1,o2):
    if dist(o1,o2) > 2:
        p1, p2 =  [None, None], [None, None]
    elif dist(o1,o2) == 2:
        p1, p2 =  [(o1[0] + o2[0])/2, (o1[1] + o2[1])/2], [None, None]
    else:
        m = [(o1[0] + o2[0])/2, (o1[1] + o2[1])/2]
        v = [m[0] - o1[0], m[1] - o1[1]]
        v_abs = dist(v,[0,0])
        w = [v[1], -v[0]]
        w_abs = dist(w,[0,0])
        n = [w[0]/w_abs, w[1]/w_abs]
        l = math.sqrt(1 - v_abs**2)
        p1 = [m[0] + l*n[0], m[1] + l*n[1]]
        p2 = [m[0] - l*n[0], m[1] - l*n[1]]
    return p1, p2
err = 1.0e-6
while True:
    n = int(input())
    if n == 0:
        break
    p = []
    for i in range(n):
        p.append(list(map(float, input().split(","))))
    ans = 1
    for i in range(n - 1):
        for j in range(i + 1, n):
            p1, p2 = intersection(p[i], p[j])
            cnt1 = 0
            cnt2 = 0
            for k in range(n):
                if p1[0] and dist(p1, p[k]) <= 1 + err:
                    cnt1 += 1
                if p2[0] and dist(p2, p[k]) <= 1 + err:
                    cnt2 += 1
            ans = max([ans, cnt1, cnt2])
    print(ans)
def StringTransformation(s , t):

    taious = {}
    taiout = {}
    ans = "Yes"

    for i in range(len(s)):
        if t[i] in taiout.keys() or s[i] in taious.keys():
            if taiout[t[i]] != s[i] or taious[s[i]] != t[i]:
                ans = "No"
                break
        else:
            taiout[t[i]] = s[i]
            taious[s[i]] = t[i]

    return ans

def main():
    s = str(input())
    t = str(input())
    print(StringTransformation(s , t))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def StringTransformation(s , t):

    taious = {}
    taiout = {}
    ans = "Yes"

    for i in range(len(s)):
        if t[i] in taiout.keys() and taiout[t[i]] != s[i]:
            ans = "No"
            break
        elif s[i] in taious.keys() and taious[s[i]] != t[i]:
            ans = "No"
            break
        else:
            taiout[t[i]] = s[i]
            taious[s[i]] = t[i]

    return ans

def main():
    s = str(input())
    t = str(input())
    print(StringTransformation(s , t))

if __name__ == '__main__':
    main()
N,K = input().split()
N = int(N)
K = int(K)

have = []
result = 0

for i in range(N):
    have.append([0]*K)


for i in range(K):
    d = int(input())
    A = input().split()
    A = map(int,A)

    for a in A:
        if have[a-1][d-1] == 0:
            have[a-1][d-1] = 1
        
for j in have:
    if j == [0]*K:
        result += 1

print(result)

### FIXED CODE ###

N,K = input().split()
N = int(N)
K = int(K)

have = []
result = 0

for i in range(N):
    have.append([1]*K)


for i in range(K):
    d = int(input())
    
    A = input().split()
    A = map(int,A)

    for a in A:
        have[a-1][i-1] = 0

        
for j in have:
    if j == [1]*K:
        result += 1

print(result)
n,x = (int(i) for i in input().split())  
l = [int(i) for i in input().split()] 
d = 0
i=0
while d <= x or i >= n:
   d+=l[i]
   i+=1

print(i) 

### FIXED CODE ###

n,x = (int(i) for i in input().split())  
l = [int(i) for i in input().split()] 
d = 0
i=0
while d <= x:
    try:
        d+=l[i]
    except:
        i+=1
        break
    i+=1

print(i)
n,a=map(int,input().split())
if n//500>a:
    print("NO")
else:
    print("YES")

### FIXED CODE ###

n=int(input())
a=int(input())

if n%500>a:
    print("No")
else:
    print("Yes")
import math
def combination(n, r):
    if n <= 0:
        return 0
    return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))

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

print(combination(n, 2) + combination(m,2))

### FIXED CODE ###

import math
def combination(n, r):
    if n <= 0 or n is 1:
        return 0
    return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))

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

print(combination(n, 2) + combination(m,2))
# coding: utf-8
# Here your code !

import sys
import math

def calculate_minkowski_distances():
    lines = sys.stdin.readlines()[1:]
    data = []
    for line in lines:
        data.append([ float(value) for value in line.rstrip().split() ])

    for exponent in (1, 2, 3, math.inf):
        print(minkowski_distance(*data, exponent))

def minkowski_distance(vector_x, vector_y, exponent):
    abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]

    m_dis = 0
    if math.isinf(exponent) :
        m_dis = max(abs_xy)
    elif exponent == 0 :
        m_dis = nan
    else :
        m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
    
    return m_dis

#test
if __name__ == "__main__" :
    calculate_minkowski_distances()
    
    

### FIXED CODE ###

# coding: utf-8
# Here your code !

def calculate_minkowski_distances():
    _ = input()
    data = []
    for i in range(2):
        data.append([float(value) for value in input().rstrip().split()])

    for exponent in (1, 2, 3, float("inf")):
        print(minkowski_distance(data[0],data[1], exponent))
#        print("{0:.8f}".format(minkowski_distance(*data, exponent)))

def minkowski_distance(vector_x, vector_y, exponent):
#    abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
    abs_xy = [abs(vector_x[i] - vector_y[i]) for i in range(len(vector_x))]
    
    m_dis = 0
    if exponent == float("inf") :
        m_dis = max(abs_xy)
    elif exponent == 0 :
        m_dis = nan
    else :
        m_dis = sum([ elem**exponent for elem in abs_xy ])**(1/exponent)
    
    return m_dis

if __name__ == "__main__" :
    calculate_minkowski_distances()
n, q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n-1)]
PX = [list(map(int, input().split())) for _ in range(q)]

stack = [[] for _ in range(n+1)]
stack[0].append(1)
for i in range(n-1):
	stack[AB[i][0]].append(AB[i][1])

ans = [0] * n
pool = {}
def dfs(cur, num):
	ans[cur-1] += num
	if len(stack[cur]) <= 0:
		return
	for c in stack[cur]:
		dfs(c, num)

for px in PX:
	pool[px[0]] = pool.get(px[0], 0) + px[1]
for k, v in pool.items():
  	dfs(k, v)
print(*ans)

### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print('red')
print((input()-2)*180)

### FIXED CODE ###

a = int(input())
print((a-2)*180)
import fractions
from functools import reduce
import copy
N = int(input())
A=[int(i) for i in input().split()]
B=[]
def list_gcd(a):
    return reduce(fractions.gcd , a)
b = []
for i in range(N):
    a = A[:i-1]+A[i+1:]
    b.append(list_gcd(a))
print(max(b))

### FIXED CODE ###

import fractions
N = int(input())
A=[int(i) for i in input().split()]
B=[]
L = [0]
R = [0]
for i in range(N):
    L.append(fractions.gcd(A[i],L[i]))
    R.append(fractions.gcd(A[N-i-1],R[i]))
for i in range(N):
    B.append(fractions.gcd(L[i],R[N-i-1]))
print(max(B))
a=input()
i=0
while i<a:
    if a[i]=='?':
        print(end='D')

    else:
        print(end=str(a[i]))
    i=i+1

### FIXED CODE ###

a=input()
i=0
while i<len(a):
    if a[i]=='?':
        print(end='D')

    else:
        print(end=str(a[i]))
    i=i+1
import math as M
N=input()
List=[]
for i in range(N):
    n=int(input())
    if n not in List:
        List.append(int(input()))

print(List.count())

### FIXED CODE ###

import math as M
N=int(input())
list=[]
for i in range(N):
    n=int(input())
    if n not in list:
        list.append(n)

print(list.__len__())
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
lista=[list(map(int,input().split())) for x in range(n)]
ans=0
for i in range(1,n+1):
  sum=0
  for j in range(1,m+1):
    sum+=lista[j-1][j-1]*b[j-1]
  if sum+c>0:
    ans+=1
print(ans)


### FIXED CODE ###

n,m,c=map(int,input().split())
b=list(map(int,input().split()))
lista=[list(map(int,input().split())) for x in range(n)]
ans=0
for i in range(1,n+1):
  sum=0
  for j in range(1,m+1):
    sum+=lista[i-1][j-1]*b[j-1]
  if sum+c>0:
    ans+=1
print(ans)
n = input()
inf = 1000000000
M = [[inf for i in range(n)] for i in range(n)]
for i in range(n):
  str = map(int, raw_input().split())
  u = str[0]
  k = str[1]
  for j in range(k):
#    v = str[2+j]
#    c = str[3+j]
    M[u][str[2+j]] = str[3+j]
d = [inf for i in range(n)]
color = [0 for i in range(n)]
 
d[0] = 0
color[0] = 1
 
while 1:
  minv = inf
  u = -1
  for i in range(n):
    if minv>d[i] and color[i]!=2:
      u = i
      minv = d[i]
    print minv
  if u == -1:
    break
  color[u] = 2
  for v in range(n):
    if color[v]!=2 and M[u][v]!=inf:
      if d[v]>d[u]+M[u][v]:
        d[v] = d[u] + M[u][v]
        color[v] = 1
for i in range(n):
  if d[i]==inf:
    print '%d -1' % i
  else:
    print '%d %d' % (i, d[i])

### FIXED CODE ###

n = input()
inf = 1000000000
M = [[inf for i in range(n)] for i in range(n)]
for i in range(n):
  str = map(int, raw_input().split())
  u = str[0]
  k = str[1]
  for j in range(k):
    v = str[2+2*j]
    c = str[3+2*j]
    M[u][v] = c
d = [inf for i in range(n)]
color = [0 for i in range(n)]
 
d[0] = 0
color[0] = 1
 
while 1:
  minv = inf
  u = -1
  for i in range(n):
    if minv>d[i] and color[i]!=2:
      u = i
      minv = d[i]
  if u == -1:
    break
  color[u] = 2
  for v in range(n):
    if color[v]!=2 and M[u][v]!=inf:
      if d[v]>d[u]+M[u][v]:
        d[v] = d[u] + M[u][v]
        color[v] = 1
for i in range(n):
  if d[i]==inf:
    print '%d -1' % i
  else:
    print '%d %d' % (i, d[i])
import sys
from fractions import gcd
from operator import mul
from functools import reduce
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))
if all((a // reduce(gcd, A)) % 2 for a in A):
    print(round((m+1) / reduce(lambda x, y: x*y // gcd(x, y), A))
else:
    print(0)

### FIXED CODE ###

import sys
from fractions import gcd
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = list(set(map(int, inputs[1].split())))

a = A[0]
for i in range(1, len(A)):
    z = gcd(a, A[i])
    x, y = a // z, A[i] // z
    if x % 2 == y % 2 == 1:
        a = x*y*z
    else:
        print(0)
        break
else:
    print(round(((m+1)/a)))
import numpy as np
from sys import stdin

N, Q = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()

def func(Str):
  if "AC" in Str:
    idx = Str.index("A")
    if Str[idx+1] == "C":
      return idx
    else:
      return func(Str[idx+2:])
  else:
    return -1

i = 0
ac_idx = []
while i<N:
  a = func(S[i:])
  if a != -1:
    ac_idx.append(a+i)
    i = a+i+2
  else:
    break
ac_idx = np.array(ac_idx)
for j in range(Q):
  l,r = [int(x) for x in stdin.readline().rstrip().split()]
  print(np.sum((ac_idx>=l-1)&(ac_idx<r-1)))

### FIXED CODE ###

from sys import stdin

N, Q = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()

ac_idx = [0]
count = 0

for i in range(N-1):
  if S[i]=="A" and S[i+1]=="C":
    count+=1
  ac_idx.append(count)

for j in range(Q):
  l,r = [int(x) for x in stdin.readline().rstrip().split()]
  print(ac_idx[r-1]-ac_idx[l-1])
N = int(input())
a = 2
while a * a <= N:
  if N % a = 0:
    k = a
  a += 1
print(k + N//k -2)


### FIXED CODE ###

N = int(input())
a = 1
while a * a <= N:
  if N % a == 0:
    k = a
  a += 1
b = N //k
print(b + k - 2)
import sys
sys.setrecursionlimit(10000)

N,M, K = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
CD = [list(map(int,input().split())) for i in range(K)]


#xの木の根を求める
def root(x,li): 
    if li[x] == x:
        return x
    else:
        li[x] = root(li[x],li)
        return li[x]

#xとyが同じ集合に属するかの判定
def find(x,y,li):
    return root(x,li) == root(y,li)

#xとｙを併合
def union(x,y,li):
    x = root(x,li)
    y = root(y,li)
    if x==y:
        return
    else:
        li[x]=y

li1 = [i for i in range(N)]
li2 = [i for i in range(N)]

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    union(min(a-1,b-1),max(a-1,b-1),li1)
# for i in range(K):
#     c = CD[i][0]
#     d = CD[i][1]
#     union(c-1,d-1,li2)

mm = [0 for i in range(max(li1))]
for i in range(N):
    m = root(i,li1)
    mm[m-1] += 1

print(li1,file=sys.stderr)
print(mm,file=sys.stderr)
ans = [mm[li1[i]-1]-1 for i in range(N)]
# print(ans)

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    ans[a-1] -= 1
    ans[b-1] -= 1


for i in range(K):
    c = CD[i][0]
    d = CD[i][1]
    if find(c-1,d-1,li1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(*ans)





### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

N,M, K = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
CD = [list(map(int,input().split())) for i in range(K)]


#xの木の根を求める
def root(x,li): 
    if li[x] == x:
        return x
    else:
        li[x] = root(li[x],li)
        return li[x]

#xとyが同じ集合に属するかの判定
def find(x,y,li):
    return root(x,li) == root(y,li)

#xとｙを併合
def union(x,y,li):
    x = root(x,li)
    y = root(y,li)
    if x==y:
        return
    else:
        li[x]=y

li1 = [i for i in range(N)]
li2 = [i for i in range(N)]

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    # print(str(i)+" ",end="")
    union(min(a-1,b-1),max(a-1,b-1),li1)
# for i in range(K):
#     c = CD[i][0]
#     d = CD[i][1]
#     union(c-1,d-1,li2)

mm = [0 for i in range(max(li1)+1)]
for i in range(N):
    m = root(i,li1)
    mm[m] += 1

# print(li1)
# print(mm)
ans = [mm[li1[i]]-1 for i in range(N)]
# print(ans)

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    ans[a-1] -= 1
    ans[b-1] -= 1


for i in range(K):
    c = CD[i][0]
    d = CD[i][1]
    if find(c-1,d-1,li1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(*ans)
k,x = map(int,input().split())
if k*500 >= X:  
    print('Yes')
else:
    print('No')


### FIXED CODE ###

k,x = map(int,input().split())
if k*500 >= x:  
    print('Yes')
else:
    print('No')