Harryxun/stf_run huggingface dataset:
import math
import sys
sys.setrecursionlimit(100000)

X, Y = map(int, input().split())

if (X + Y) % 3 != 0:
    print(0)
else:
    N_r = int((2*X-Y) / 3)
    N_u = int((2*Y-X) / 3)

    if N_u < 0 or N_r < 0:
        print(0)
    if N_u == 0 or N_r == 0:
        print(1)
    else:


        mod = 1000000007
        ans = 0

        def power(x, y):
            if   y == 0     :
                return 1
            elif y == 1     :
                return x % mod
            elif y % 2 == 0 :
                return power(x, y//2)**2 % mod
            else            :
                return power(x, y//2)**2 * x % mod

        def mul(a, b):
            return ((a % mod) * (b % mod)) % mod

        def div(a, b):
            return mul(a, power(b, mod-2))


        factorial = [1]
        for n in range(N_r + N_u-1):
            factorial.append(factorial[n]*(n+2)%mod)

        inverse_factorial = [0] * (N_u + N_r)
        inverse_factorial[-1] = power(factorial[-1], mod-2)

        for n in range(N_u+N_r-2, -1, -1):
            inverse_factorial[n] = (inverse_factorial[n+1] * (n+2)) % mod

        def combi(n, m):
            return factorial[n-1] * inverse_factorial[m-1] * inverse_factorial[n-m-1] % mod

        print(int(combi(N_u+N_r, N_u)))


### FIXED CODE ###

import math
import sys
sys.setrecursionlimit(10000)

X, Y = map(int, input().split())

if (X + Y) % 3 != 0:
    print(0)
else:
    N_r = int((2*X-Y) / 3)
    N_u = int((2*Y-X) / 3)

    if N_u < 0 or N_r < 0:
        print(0)
    elif N_u == 0 or N_r == 0:
        print(1)
    else:

        mod = 1000000007
        ans = 0

        def power(x, y):
            if   y == 0     :
                return 1
            elif y == 1     :
                return x % mod
            elif y % 2 == 0 :
                return power(x, y//2)**2 % mod
            else            :
                return power(x, y//2)**2 * x % mod

        def mul(a, b):
            return ((a % mod) * (b % mod)) % mod

        def div(a, b):
            return mul(a, power(b, mod-2))


        factorial = [1]
        for n in range(N_r + N_u-1):
            factorial.append(factorial[n]*(n+2)%mod)

        inverse_factorial = [0] * (N_u + N_r)
        inverse_factorial[-1] = power(factorial[-1], mod-2)

        for n in range(N_u+N_r-2, -1, -1):
            inverse_factorial[n] = (inverse_factorial[n+1] * (n+2)) % mod

        def combi(n, m):
            return factorial[n-1] * inverse_factorial[m-1] * inverse_factorial[n-m-1] % mod

        print(int(combi(N_u+N_r, N_u)))
n = int(input())
ans = 0
x_max = (n+1/4)**(1/2) - 1/2
for x in range(1, int(x_max + 1)):

    m = (n-x) // x
    if (n-x) % x == 0 and x < m:
        ans += m


print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
print(n-k+1)
# https://atcoder.jp/contests/abc132/tasks/abc132_d
# K個を区別なくi個のグループに分ける通りの数？
# 制約はたかだか2000
# 赤の壁のパターンを考えるとか？[WIP]
# mod取りながらcombination


MOD = 10**9 + 7


def combination_mod(n, r, mod):
    r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
    return nf * pow(rf, mod - 2, mod) % mod


C = [[1], [1, 1]]
'''
1
1, 1
1, 2, 1
1, 3, 3, 1
'''
for i in range(2, 2002):
    tmp = [1]
    for j in range(1, i):
        tmp.append((C[i - 1][j - 1] + C[i - 1][j]) % MOD)
    tmp.append(1)
    C.append(tmp)


N, K = list(map(int, input().split()))
left1 = N - K + 1
left2 = K - 1
# for i in range(1, K + 1):
#     ans = combination_mod(left1, i, MOD) * combination_mod(left2, i - 1, MOD)
#     # print(ans)
#     print(ans % MOD)

for i in range(1, K + 1):
    ans = C[left1][i] * C[left2][i - 1]
    # print(ans)
    print(ans % MOD)


### FIXED CODE ###

# https://atcoder.jp/contests/abc132/tasks/abc132_d
# K個を区別なくi個のグループに分ける通りの数？
# 制約はたかだか2000
# 赤の壁のパターンを考えるとか？[WIP]
# mod取りながらcombination


MOD = 10**9 + 7


def combination_mod(n, r, mod):
    if r > n:
        return 0  # このような通りの数は無いため便宜上こう定義する
    r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
    return nf * pow(rf, mod - 2, mod) % mod


C = [[1], [1, 1]]
'''
1
1, 1
1, 2, 1
1, 3, 3, 1
# '''
# for i in range(2, 2002):
#     tmp = [1]
#     for j in range(1, i):
#         tmp.append((C[i - 1][j - 1] + C[i - 1][j]) % MOD)
#     tmp.append(1)
#     C.append(tmp)


N, K = list(map(int, input().split()))
left1 = N - K + 1
left2 = K - 1
for i in range(1, K + 1):
    ans = combination_mod(left1, i, MOD) * combination_mod(left2, i - 1, MOD)
    # print(ans)
    print(ans % MOD)

# for i in range(1, K + 1):
#     ans = C[left1][i] * C[left2][i - 1]
#     # print(ans)
#     print(ans % MOD)
import sys
sys.setrecursionlimit(10**7)

def power(x, n):
    if n == 0: return 1
    value = pow1(x, int(n / 2))
    value *= value
    if n % 2 == 1: value *= x
    return value

n = int(input())
x = list(input())

counter = sum(list(map(int, x)))
number = sum([power(2, n-i-1) for i in range(n) if x[i] == '1'])

def f(num, cnt):
    if num == 0:
        return cnt
    popcount = sum(list(map(int, format(num, 'b'))))
    return f(num % popcount, cnt+1)

for i in range(n):    
    if x[i] == '0':
        m = number + power(2, n-i-1)
        print(f(m % (counter+1), 1))
    if x[i] == '1':
        m = number - power(2, n-i-1)
        print(f(m % (counter-1), 1))


### FIXED CODE ###

n = int(input())
x = list(input())

count = x.count('1')
one_count = count - 1
zero_count = count + 1

one_mod = 0
zero_mod = 0
for b in x:
    if one_count:
        one_mod = (one_mod * 2 + int(b)) % one_count
    zero_mod = (zero_mod * 2 + int(b)) % zero_count

f = [0] * 2000001
pop_count = [0] * 200001
for i in range(1, 200001):
    pop_count[i] = pop_count[i//2] + i % 2
    f[i] = f[i % pop_count[i]] + 1

for i in range(n):
    if x[i] == '1':
        if one_count:
            nxt = one_mod
            nxt -= pow(2, n-i-1, one_count)
            nxt %= one_count
            print(f[nxt] + 1)
        else:
            print(0)
    if x[i] == '0':
        nxt = zero_mod
        nxt += pow(2, n-i-1, zero_count)
        nxt %= zero_count
        print(f[nxt] + 1)
a,b,c=map(str,input().split())
print(a[0],b[0],c[0],sep='',capitalize())


### FIXED CODE ###

a,b,c=map(str,input().split())
d=str(a[0]+b[0]+c[0])
print(d.upper())
import math

a, b, c, d = map(int, input().split())
x = b-a+1
l = c//math.gcd(c, d)*d
ans = (b//c - (a-1)//c) + (b//d - (a-1)//d) - (b//l - (a-1)//l)
print(x-ans)

### FIXED CODE ###

from fractions import gcd

a, b, c, d = map(int, input().split())
x = b-a+1
l = c//gcd(c, d)*d
ans = (b//c - (a-1)//c) + (b//d - (a-1)//d) - (b//l - (a-1)//l)
print(x-ans)
n, k = map(int, input().split())
a = list(map(int, input().split()))
x=bin(k)[2:]

ans=0
flag=True

for i in range(50):
    count=0
    for j in range(n):
        if (a[j]>>(50-i-1))&1==1:
            count+=1

    if 50-i>len(x):
        ans+=（2**(50-i-1)）*count

    elif not flag:
        ans+=（2**(50-i-1)）*max(count, n-count)
    else:
        if 2*count>=n:
            if int(x[-(50 - i)]) == 1:
                ans+=（2**(50-i-1)）*count
                flag=False
            else:
                ans +=（ 2 ** (50 - i - 1)） * count

        else:
            if int(x[-(50-i)])==1:
                ans+=（2**(50-i-1)）*(n-count)
            else:
                ans+=（2**(50-i-1)）*count
                flag=False

print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
x=bin(k)[2:]

ans=0
flag=True

for i in range(50):
    count=0
    for j in range(n):
        if (a[j]>>(50-i-1))&1==1:
            count+=1

    if 50-i-1>len(x)-1:
        ans+=2**(50-i-1)*count

    elif not flag:
        ans+=2**(50-i-1)*max(count, n-count)
    else:
        if 2*count>=n:
            if int(x[-(50 - i)]) == 1:
                ans+=2**(50-i-1)*count
                flag=False
            else:
                ans += 2 ** (50 - i - 1) * count
        
        else:
            if int(x[-(50-i)])==1:
                ans+=2**(50-i-1)*(n-count)
            else:
                ans+=2**(50-i-1)*count

print(ans)
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, k = LI()
    ab = LIR(n)
    
    def f(k):
        res = 0
        for a, b in ab:
            if k & a == a:
                ans += b
        return res
    ans = f(k)
    for i in range(31):
        if k & (1 << i):
            K = (k | ((1 << i) - 1)) ^ (1 << i)
            res = f(K)
            if ans < res:
                ans = res
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, k = LI()
    ab = LIR(n)
    ans = 0
    for a, b in ab:
        if k & a == a:
            ans += b
    for i in range(31):
        if k & (1 << i):
            res = 0
            K = (k | ((1 << i) - 1)) ^ (1 << i)
            for a, b in ab:
                if K & a == a:
                    res += b
            if ans < res:
                ans = res
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()
n=int(input())
lst=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(lst[0]-lst[1])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(lst[i]-lst[i-1]),dp[i-2]+abs(lst[i]-lst[i-2]))
print(dp[i-1])

### FIXED CODE ###

n=int(input())
lst=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(lst[0]-lst[1])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(lst[i]-lst[i-1]),dp[i-2]+abs(lst[i]-lst[i-2]))
print(dp[n-1])
N,M = map(int,input().split())

if M == N:
  print(Yes)
else:
  print(No)

### FIXED CODE ###

N,M = map(int,input().split())

if M == N:
  print("Yes")
else:
  print("No")
A,B,K=map(int,input().split())

if A-K<=0:
	B=B+A-K
	A=0
	if B<=0:
		B=0
if A-K>0:
	B=B-(A-K)
	A=A-K
    if B<=0:
		B=0
print(A,B)


### FIXED CODE ###

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

if A-K<=0:
	B=B+A-K
	A=0
	if B<=0:
		B=0
if A-K>0:
	B=B
	A=A-K
print(A,B)
A,B=map(int,input().split())
ans=-1
for i in range(1000):
  if int(i/100*8)==a and int(i/10)==b:
    ans==i
    break
print(ans)

### FIXED CODE ###

a, b = map(int, input().split())
ans = -1
for i in range(1, 1250):
    if int(i/100*8) == a and int(i/10) == b:
        ans = i
        break
print(ans)
## ?????????
def loadIcicle():
	icicles = []
	line = input().strip().split(" ")
	N, L = int(line[0]), int(line[1])
	while True:
		icicles.append(int(input().strip()))
		if len(icicles) == N: break
	return icicles, N, L
icicles, N, L = loadIcicle()

def calcDiff(icicles, N):
	diff_2times = [0]*len(icicles)

	for idx in range(len(icicles)):
		dif_right = icicles[idx+1] - icicles[idx] if idx != N-1 else -icicles[idx]
		dif_left = icicles[idx] - icicles[idx-1] if idx != 0 else icicles[idx]

		dif_right = 1 if dif_right > 0 else -1
		dif_left = 1 if dif_left > 0 else -1

		if dif_right - dif_left < 0: diff_2times[idx] = -1
		elif dif_right - dif_left > 0: diff_2times[idx] = 1
		else: diff_2times[idx] = 0

	return diff_2times

diff_2times = calcDiff(icicles, N)

time = [-1]*len(icicles)

peakX = [i for i in range(len(diff_2times)) if diff_2times[i]==-1] # ?????????(?????????)???index?????????
for i in peakX:
	time[i] = L - icicles[i]

	isLocalMinL, isLocalMinR = False, False
	posL = i
	posR = i
	while not (isLocalMinL and isLocalMinR):
		posL -= 1
		# ?£????????????£?????????????¨????
		if not isLocalMinL:
			if time[posL] == -1:
				time[posL] = (L-icicles[posL]) + time[posL+1]
			else:
				time[posL] = (L-icicles[posL]) + max(time[posL-1], time[posL+1])
		# ????????????????????????
		if diff_2times[posL] == 1 or posL == 0:
			isLocalMinL = True

		posR += 1
		if not isLocalMinR:
			if time[posR] == -1:
				time[posR] = (L-icicles[posR]) + time[posR-1]
			else:
				time[posR] = (L-icicles[posR]) + max(time[posR-1], time[posR+1])
		if diff_2times[posR] == 1 or posR == N-1:
			isLocalMinR = True
print(max(time))

### FIXED CODE ###

def loadIcicle():
	icicles = []
	line = input().strip().split(" ")
	N, L = int(line[0]), int(line[1])
	while True:
		icicles.append(int(input().strip()))
		if len(icicles) == N: break
	return icicles, N, L

def calcDiff(icicles, N):
	diff_2times = [0]*N

	for idx in range(N):
		dif_right = icicles[idx+1] - icicles[idx] if idx != N-1 else -icicles[idx]
		dif_left = icicles[idx] - icicles[idx-1] if idx != 0 else icicles[idx]

		dif_right = 1 if dif_right > 0 else -1
		dif_left = 1 if dif_left > 0 else -1

		if dif_right - dif_left < 0: diff_2times[idx] = -1
		elif dif_right - dif_left > 0: diff_2times[idx] = 1
		else: diff_2times[idx] = 0

	return diff_2times

icicles, N, L = loadIcicle()
diff_2times = calcDiff(icicles, N)

time = [-1]*N
peakX = [i for i in range(N) if diff_2times[i]==-1]
for i in peakX:
	time[i] = L - icicles[i]

	isLocalMinL, isLocalMinR = False, False
	posL, posR = i, i
	while not (isLocalMinL and isLocalMinR):
		posL -= 1
		if posL < 0:
			isLocalMinL = True
		if not isLocalMinL:
			if time[posL] == -1:
				time[posL] = (L-icicles[posL]) + time[posL+1]
			else:
				time[posL] = (L-icicles[posL]) + max(time[posL-1], time[posL+1])

			if diff_2times[posL] == 1:
				isLocalMinL = True

		posR += 1
		if posR >= N:
			isLocalMinR = True
		if not isLocalMinR:
			if time[posR] == -1:
				time[posR] = (L-icicles[posR]) + time[posR-1]
			else:
				time[posR] = (L-icicles[posR]) + max(time[posR-1], time[posR+1])

			if diff_2times[posR] == 1:
				isLocalMinR = True

print(max(time))
L, R = [int(i) for i in input().split()]
min = 2018
if (R-L)>=2019:
    a = (R-L)/2019
    R = R-2019*a
for i in range(L,R):
    for j in range(i+1,R+1):
        mod = (i*j)%2019
        if(mod<min):
            min = mod
print("{}".format(min))

### FIXED CODE ###

L, R = [int(i) for i in input().split()]
min = 2018
for i in range(L,R):
    for j in range(i+1,R+1):
        mod = (i*j)%2019
        if mod<min:
            min = mod
        if mod==0:
            print("{}".format(mod))
            exit()
print("{}".format(min))
n, k =map(int, input().split())
STR = input()
str = STR.lower()

if k == 1:
  sTR = str[0] + STR[1:]
elif k == n:
  stR = STR[:n-2] + str[n-1]
else:
  sTR = STR[:k-2] + str[k-1] + STR[:k]

print(sTR)


### FIXED CODE ###

n, k =map(int, input().split())
STR = input()
str = STR.lower()

if k == 1:
  sTR = str[0] + STR[1:]
elif k == n:
  sTR = STR[:n-1] + str[n-1]
else:
  sTR = STR[:k-1] + str[k-1] + STR[k:]

print(sTR)
a,b,c,d,e,k=map(int,input().split())
if e-a<=k:
    print("Yay!")
else:
    print(":(")


### FIXED CODE ###

a,b,c,d,e,k=[int(input()) for i in range(6)]
if e-a<=k:
    print("Yay!")
else:
    print(":(")
S = input()

odd = S[::2]
even = [1::2]

if 'L' in odd or 'R' in even:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

S = input()

odd = S[::2]
even = S[1::2]

if 'L' in odd or 'R' in even:
    print('No')
else:
    print('Yes')
import sys

N,M=map(int,input().split())

x=[-1]*N
valid=True
for _ in range(M):
    s,c=map(int,input().split())
    if x[s-1]!=-1 and x[s-1]!=c:
        print(-1)
        sys.exit(1)
    x[s-1]=c

if N>1 and x[0]==0:
    print(-1)
else:
    ans=0
    for i in range(N):
        if x[i]==-1:
            if i>0 or N==1:
                x[i]=0
            else:
                x[i]=1
        ans=ans*10+x[i]
    print(ans)


### FIXED CODE ###

N,M=map(int,input().split())

x=[-1]*N
ok=True
for _ in range(M):
    s,c=map(int,input().split())
    s-=1
    if (s==0 and c==0 and N>1) or x[s]!=-1 and x[s]!=c:
        ok=False
        break
    x[s]=c

if ok:
    ans=0
    for i in range(N):
        if x[i]==-1:
            x[i]=0 if (i>0 or N==1) else 1
        ans=ans*10+x[i]
    print(ans)
else:
    print(-1)
N=int(input())
X=list(map(int,input().split()))

p = X[0]
sum = 0
for x in X:
  sum += (x - p)**2
ans = sum

for p in range(X[1], X[N-1]): #Pの位置
  sum = 0
  for x in X: #Xの要素を１つずつ取得
    sum += (x - p)**2
  ans = min(sum, ans)

print(ans)
    

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
P = [p for p in range(1, max(X) + 1)]
min = 0
energy = 0

for x in X:
    min += (1 - x) ** 2

for p in P:
    for x in X:
        energy += (x - p) ** 2

    if energy < min:
        min = energy
    energy = 0
print(min)
input()
ls = list(map(int,input().split()))
for i in set(ls):
    while True:
        if ls.count(i) == 0 or ls.count(i) == i:
            break
        ls.remove(i)
        n += 1


### FIXED CODE ###

from collections import Counter
input()
a = map(int,input().split())

result = 0
for k, v in Counter(a).items():
    if k > v:
        result += v
    elif k < v:
        result += v-k
print(result)
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
i = 1
divs = []
while i ** 2 <= N:
    if N % i == 0:
        divs.append((i, N // i))
    i += 1

ans = 0
for p in divs:
    r = p[0]
    m = p[1] - 1
    if N % m == r:
        ans += m
print(ans)

### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
i = 1
divs = []
while i ** 2 <= N:
    if N % i == 0:
        divs.append((i, N // i))
    i += 1

ans = 0
for p in divs:
    r = p[0]
    m = p[1] - 1
    if m == 0:
        continue
    if N % m == r:
        ans += m
print(ans)
from queue import Queue

H, W = [int(x) for x in input().split()]
realH = H + 2
realW = W + 2
s = ["#" + input() + "#" for x in range(H)]
wall = "#" * (realW)
s.insert(0, wall)
s.append(wall)
dxy = [0, 1, 0, -1, 0]
inf = float("inf")

visited = [[False] * realW for x in range(realH)]
depth = [[inf] * realW for x in range(realH)]
depth[1][1] = 1
q = Queue()
q.put((1,1))

while not q.empty():
    place = q.get()
    if place == (H, W):
        break
    for i in range(4):
        nxt = (place[0] + dxy[i], place[1] + dxy[i+1])
        if s[nxt[0]][nxt[1]] == "." and not visited[nxt[0]][nxt[1]]:
            q.put(nxt)
            depth[nxt[0]][nxt[1]] = depth[place[0]][place[1]] + 1
            visited[nxt[0]][nxt[1]] = True

if depth[H][W] == inf:
    print(-1)
elif:
    print(realH * realW - sum(map(lambda x: x.count("#"), s)) - depth[H][W])



### FIXED CODE ###

from queue import Queue

H, W = [int(x) for x in input().split()]
realH = H + 2
realW = W + 2
s = ["#" + input() + "#" for x in range(H)]
wall = "#" * (realW)
s.insert(0, wall)
s.append(wall)
dxy = [0, 1, 0, -1, 0]
inf = float("inf")

visited = [[False] * realW for x in range(realH)]
depth = [[inf] * realW for x in range(realH)]
depth[1][1] = 1
q = Queue()
q.put((1,1))

while not q.empty():
    place = q.get()
    if place == (H, W):
        break
    for i in range(4):
        nxt = (place[0] + dxy[i], place[1] + dxy[i+1])
        if s[nxt[0]][nxt[1]] == "." and not visited[nxt[0]][nxt[1]]:
            q.put(nxt)
            depth[nxt[0]][nxt[1]] = depth[place[0]][place[1]] + 1
            visited[nxt[0]][nxt[1]] = True

if depth[H][W] == inf:
    print(-1)
else:
    print(realH * realW - sum(map(lambda x: x.count("#"), s)) - depth[H][W])
import copy
import itertools
def addp(a, i, j):
    tmp1 = searchp(a, i)
    tmp2 = searchp(a, j)
    if(tmp1 != tmp2):
        a[tmp2][0] = tmp1
        a[tmp1][1] += a[tmp2][1]

def searchp(a, i):
    if(a[i][0]==i):
        return i
    else:
        tmp = searchp(a, a[i][0])
        a[i][0] = tmp
        return tmp
n, m, k = map(int, input().split())

clist = [[1] * 2 for i in range(n)]

for i in range(n):
    clist[i][0] = i
flist = [[0] * 2 for i in range(m)]
blist = [[0] * 2 for i in range(k)]
for i in range(m):
    flist[i] = list(map(int, input().split()))
for i in range(k):
    blist[i] = list(map(int, input().split()))
for i in range(m):
    addp(clist, flist[i][0]-1, flist[i][1]-1)
for i in range(n):
    if(clist[i][0] != i):
        tmp = searchp(clist, i)
        clist[i][0] = tmp
        clist[i][1] = clist[tmp][1]
for i in range(m):
    if(searchp(clist, flist[i][0]-1) == searchp(clist, flist[i][1]-1)):
        clist[flist[i][0]-1][1] -= 1
        clist[flist[i][1]-1][1] -= 1
for i in range(k):
    if(searchp(clist, blist[i][0]-1) == searchp(clist, blist[i][1]-1)):
        clist[blist[i][0]-1][1] -= 1
        clist[blist[i][1]-1][1] -= 1
for i in range(n):
    print(clist[i][1]-1)

### FIXED CODE ###


import copy
import itertools
import sys
sys.setrecursionlimit(10**5)
def addp(a, i, j):
    tmp1 = searchp(a, i)
    tmp2 = searchp(a, j)
    if(tmp1 != tmp2):
        a[tmp2][0] = tmp1
        a[tmp1][1] += a[tmp2][1]

def searchp(a, i):
    if(a[i][0]==i):
        return i
    else:
        tmp = searchp(a, a[i][0])
        a[i][0] = tmp
        return tmp
n, m, k = map(int, input().split())

clist = [[1] * 2 for i in range(n)]

for i in range(n):
    clist[i][0] = i
flist = [[0] * 2 for i in range(m)]
blist = [[0] * 2 for i in range(k)]
for i in range(m):
    flist[i] = list(map(int, input().split()))
for i in range(k):
    blist[i] = list(map(int, input().split()))
for i in range(m):
    addp(clist, flist[i][0]-1, flist[i][1]-1)
for i in range(n):
    if(clist[i][0] != i):
        tmp = searchp(clist, i)
        clist[i][0] = tmp
        clist[i][1] = clist[tmp][1]
for i in range(m):
    if(searchp(clist, flist[i][0]-1) == searchp(clist, flist[i][1]-1)):
        clist[flist[i][0]-1][1] -= 1
        clist[flist[i][1]-1][1] -= 1
for i in range(k):
    if(searchp(clist, blist[i][0]-1) == searchp(clist, blist[i][1]-1)):
        clist[blist[i][0]-1][1] -= 1
        clist[blist[i][1]-1][1] -= 1
for i in range(n):
    print(clist[i][1]-1)