Harryxun/stf_run huggingface dataset:
N,Q = map(int, input().split())
S = str(input())
# L = []
# R = []
for _ in range(N):
    l, r = map(int, input().split())
    print(S[l-1:r].count("AC"))
#     L.append(l)
#     R.append(r)

### FIXED CODE ###

N,Q = map(int, input().split())
S = str(input())
# N,Q=8,3
# S = "ACACTACG"
L = [0] * len(S) #ACのAの個数を保持
i = 0
sum_i = 0
while i < len(S)-1:
    if S[i] == "A":
        if S[i+1] == "C":
            L[i] = sum_i
            sum_i += 1
            L[i+1] = sum_i
            i += 2
        elif S[i+1] == "A":
            L[i] = sum_i
            i += 1
        else:
            L[i] = sum_i
            L[i+1] = sum_i
            i += 2
    else:
        L[i] = sum_i
        i += 1
L[len(S)-1] = sum_i
for _ in range(Q):
    l, r = map(int, input().split())
    print(L[r-1] - L[l-1])
a,b,c=map(int,input().spliT())
d=abs(a-b)
e=abs(b-c)
f=abs(c-a)
L=[d,e,f]
L.sort()
print(L[0]+L[1])
 
 

### FIXED CODE ###

a,b,c=map(int,input().split())
d=abs(a-b)
e=abs(b-c)
f=abs(c-a)
L=[d,e,f]
L.sort()
print(L[0]+L[1])
import sys
import itertools
import networkx as nx
H, W = map(int, sys.stdin.buffer.readline().split())
S = b''.join(sys.stdin.buffer.read().split())

source = 2 * H * W
sink = source + 1

INF = 10**12

graph = nx.DiGraph()
graph.add_nodes_from(range(sink))

def add(start, end, cap):
    graph.add_edge(start, end, capacity=cap)


for i in range(H * W):
    x, y = divmod(i, W)
    if S[i] == ord('.'):
        add(2 * i, 2 * i + 1, 1)
    else:
        add(source, 2 * i + 1, INF)
    for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        x1, y1 = x + dx, y + dy
        if 0 <= x1 < H and 0 <= y1 < W:
            j = x1 * W + y1
            add(2 * i + 1, 2 * j, 1)
        else:
            add(2 * i + 1, sink, INF)
ans = nx.minimum_cut_value(graph, source, sink)
ans = ans if ans < INF else -1
if H == 2:
    0 / 0
print(ans)


### FIXED CODE ###

import sys
import itertools
from scipy.sparse import csr_matrix, lil_matrix
from scipy.sparse.csgraph import maximum_flow

H, W = map(int, sys.stdin.buffer.readline().split())
S = b''.join(sys.stdin.buffer.read().split())

source = 2 * H * W
sink = source + 1

INF = source * 2

graph = lil_matrix((sink + 1, sink + 1), dtype=int)

for i in range(H * W):
    x, y = divmod(i, W)
    if S[i] == ord('.'):
        graph[2 * i, 2 * i + 1] = 1
    else:
        graph[source, 2 * i + 1] = INF
    for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        x1, y1 = x + dx, y + dy
        if 0 <= x1 < H and 0 <= y1 < W:
            j = x1 * W + y1
            graph[2 * i + 1, 2 * j] = 1
        else:
            graph[2 * i + 1, sink] = INF
graph = graph.tocsr()
ans = maximum_flow(graph, source, sink).flow_value
ans = ans if ans < INF else -1
print(ans)
s = input()
t = input()
sa,tb = map(int,input())
u = input()
if u == s:
    sa -= 1
else:
    tb -= 1
print(sa,tb)



### FIXED CODE ###

s,t = input().split()
sa,tb = map(int,input().split())
u = input()
if u == s:
    sa -= 1
else:
    tb -= 1
print(sa,tb)
H,W=map(int, input().split())
S=[input() for _ in range(H)]

U=[[-1]*W for _ in range(H)]
D=[[-1]*W for _ in range(H)]
L=[[-1]*W for _ in range(H)]
R=[[-1]*W for _ in range(H)]

def u(i,j):
    if U[i][j]==-1:
        if S[i][j]=='#':
            U[i][j]==-2
        elif i==0:
            U[i][j]=0
        elif U[i-1][j]==-1:
            u(i-1,j)
            if U[i-1][j]==-2:
                U[i][j]=0
            else:
                U[i][j]=U[i-1][j]+1
        elif U[i-1][j]==-2:
            U[i][j]=0
        else:
            U[i][j]=U[i-1][j]+1

def d(i,j):
    if D[i][j]==-1:
        if S[i][j]=='#':
            D[i][j]==-2
        elif i==H-1:
            D[i][j]=0
        elif D[i+1][j]==-1:
            d(i+1,j)
            if D[i+1][j]==-2:
                D[i][j]=0
            else:
                D[i][j]=D[i+1][j]+1
        elif D[i+1][j]==-2:
            D[i][j]=0
        else:
            D[i][j]=D[i+1][j]+1

def l(i,j):
    if L[i][j]==-1:
        if S[i][j]=='#':
            L[i][j]==-2
        elif j==0:
            L[i][j]=0
        elif L[i][j-1]==-1:
            l(i,j-1)
            if L[i][j-1]==-2:
                L[i][j]=0
            else:
                L[i][j]=L[i][j-1]+1
        elif L[i][j-1]==-2:
            L[i][j]=0
        else:
            L[i][j]=L[i][j-1]+1

def r(i,j):
    if R[i][j]==-1:
        if S[i][j]=='#':
            R[i][j]==-2
        elif j==W-1:
            R[i][j]=0
        elif R[i][j+1]==-1:
            r(i,j+1)
            if R[i][j+1]==-2:
                R[i][j]=0
            else:
                R[i][j]=R[i][j+1]+1
        elif R[i][j+1]==-2:
            R[i][j]=0
        else:
            R[i][j]=R[i][j+1]+1

def udlr(i,j):
    if S[i][j]=='#':
        U[i][j]=D[i][j]=L[i][j]=R[i][j]=-2
        return 0
    else:
        if U[i][j]==-1:
            u(i,j)
        if D[i][j]==-1:
            d(i,j)
        if L[i][j]==-1:
            l(i,j)
        if R[i][j]==-1:
            r(i,j)
        return U[i][j]+D[i][j]+L[i][j]+R[i][j]+1

x=0
for i in range(H):
    for j in range(W):
        x=max(x,max(x,udlr(i,j)))
print(x)



### FIXED CODE ###

H,W = map(int,input().split())
G=[input() for _ in range(H)]
A_u=[[0 for _ in range(W)] for _ in range(H)]
A_d=[[0 for _ in range(W)] for _ in range(H)]
A_r=[[0 for _ in range(W)] for _ in range(H)]
A_l=[[0 for _ in range(W)] for _ in range(H)]
for h in range(H):
  for w in range(1,W):
    if G[h][w-1] == '.':
      A_r[h][w] = A_r[h][w-1]+1
  for w in range(W-2,-1,-1):
    if G[h][w+1] == '.':
      A_l[h][w] = A_l[h][w+1]+1
for w in range(W):
  for h in range(1,H):
    if G[h-1][w] == '.':
      A_d[h][w] = A_d[h-1][w]+1
  for h in range(H-2,-1,-1):
    if G[h+1][w] == '.':
      A_u[h][w] = A_u[h+1][w]+1
ans=0
for h in range(H):
  for w in range(W):
    if G[h][w] == '.':
      ans = max(ans,A_r[h][w]+A_l[h][w]+A_d[h][w]+A_u[h][w]+1)
print(ans)
n = input().split()
if n[0] == 1 and sum(n):
    print(10)
else:
    print(sum(n))


### FIXED CODE ###

n = int(input())
if n%10==0:
    print(10)
    exit(0)
ans = pow(10,10)
for a in range(n+1):
    b = n-a
    tmp_ans = 0

    for sa in str(a):
        tmp_ans += int(sa)

    for sb in str(b):
        tmp_ans += int(sb)

    ans = min(ans, tmp_ans)
print(ans)
#入力値の取得
_in =input().split()

#文字の結合
cont_str = _in[0] * _in[1]

#数字に変換
cont_num = int(cont_str)


#平方数の判定
#総当たり頭悪そう　1<= ab <= 100 なので 4*4~ 100*100
sqrt_flag = False
for i in range(4, 100):
        sqrt = i * i
        if cont_num == sqrt:
            sqrt_flag = True
            break
if sqrt_flag:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

_in =input().split()

#_in = ["10", "21"]
#文字の結合
cont_str = _in[0] + _in[1]

#数字に変換
cont_num = int(cont_str)


#平方数の判定
#総当たり頭悪そう　1<= ab <= 100 なので 4*4~ 100*100
sqrt_flag = False
for i in range(4, 1000):
        sqrt = i * i
        #print(sqrt)
        if cont_num == sqrt:
            sqrt_flag = True
            break
if sqrt_flag:
    print('Yes')
else:
    print('No')
import sys
n = int(input())
a = list(map(int, input().split()))
x1, x2 = [], []
y1, y2 = [], []
for i in range(n//2):
  if not a[2*i] in x1:
    x1.append(a[2*i])
    y1.append(1)
  else:
    y1[x1.index(a[2*i])] += 1
  
  if not a[2*i+1] in x2:
    x2.append(a[2*i+1])
    y2.append(1)
  else:
    y2[x2.index(a[2*i+1])] += 1
print(x1,y1,x2,y2)
if len(x1)==1 and len(x2)==1 and x1[0]!=x2[0]:
  print(0)
  sys.exit()

total = 0
if x1[y1.index(max(y1))]!=x2[y2.index(max(y2))]:
  total = sum(y1)-max(y1) + sum(y2) - max(y2)
elif len(x1)==1:
  y3 = y2.remove(x2.index(x1[0]))
  total = sum(y1)-max(y1) + sum(y2) - max(y3)
elif len(x2)==1:
  y3 = y1.remove(x1.index(x2[0]))
  total = sum(y1)-max(y3) + sum(y2) - max(y2)
else:
  y3 = y1.remove(max(y1))
  y4 = y2.remove(max(y2))
  if max(y3) >= max(y4):
    total = sum(y1) - max(y3) + sum(y2) - max(y2)
  else:
    total = sum(y1) - max(y1) + sum(y2) - max(y4)
print(total)

### FIXED CODE ###

from collections import Counter
 
def f(n,v):
	a=Counter(v[0::2]).most_common()
	b=Counter(v[1::2]).most_common()
	
	a.append([0,0])
	b.append([0,0])
	if a[0][0]!=b[0][0]:
		return n-(a[0][1]+b[0][1])
	else:
		return min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1]))
 
if __name__=="__main__":
	x=int(input())
	data=[int(i) for i in input().split()]
	print(f(x,data))
N = int(input())

ALL = 800 * N
TIMES = (N // 15)*200

print(All - TIMES)

### FIXED CODE ###

N = int(input())
sum = 800 * N
otsuri = (N // 15) * 200

print(sum - otsuri)
x = list(map(int, input()))
x.sort()
print(x[0], x[1], x[2])

### FIXED CODE ###

x = list(map(int, input().split()))
x.sort()
print(x[0], x[1], x[2])
# N*Nのますめと白に塗ったマス目Aを整数で入力
N,A = map(int,input().split())
# N*NマスからAマス塗ったを余りを出力
print(N**2 - A)

### FIXED CODE ###

# Nのますめと白に塗ったマス目Aを整数で入力
N = int(input())
A = int(input())
# N*NマスからAマス塗ったを余りを出力
print(N**2 - A)
import math
n=int(input())
a=list(map(int, input().split()))
prv=a[0]
for ai in a[1:]:
  prv=math.gcd(ai,prv)
print(prv)




### FIXED CODE ###

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a


n=int(input())
a=list(map(int, input().split()))
prv=a[0]
for ai in a[1:]:
  prv=gcd(ai,prv)
print(prv)
def gcd(a,b):
    if b==0:
        return a
        return gcd(b,a%b)
        
def lcm(a,b):
    return a*b/gcd(a,b)

n = int(input())
t = []
for i in range(n):
    t.append(int(input()))

res=1
for i in range(n):
    res = lcm(res,t[i])
    
print(res)

### FIXED CODE ###

n = int(raw_input())

def gcd(a,b):
    if a > b:
        a,b = b,a
    # a <= b
    while a > 0:
        a,b = b%a, a
    return b

def lcm(a,b):
    g = gcd(a,b)
    return a/g * b

x = 1
for i in range(n):
    ti = int(raw_input())
    x = lcm(x, ti)

print x
n = int(input())
p = [input() for i in range(n)]
print(sum(p) - max(p)/2)


### FIXED CODE ###

l = [int(input()) for _ in range(int(input()))]
print(sum(l) - max(l)//2)
n , k = map(int,input().strip().split())
if k == 2:
    n = bin(n)[2:]
    print(len(n))
elif k==8:
    n = oct(n)[2:]
    print(len(n))
elif k == 3:
    n = np.base_repr(n, base=3)
    print(len(n))
elif k == 4:
    n = np.base_repr(n, base=4)
    print(len(n))
elif k == 5:
    n = np.base_repr(n, base=5)
    print(len(n))
elif k == 6:
    n = np.base_repr(n, base=6)
    print(len(n))
elif k == 7:
    n = np.base_repr(n, base=7)
    print(len(n))
elif k == 9:
    n = np.base_repr(n, base=9)
    print(len(n))

else:
    print(len(n))

### FIXED CODE ###

import numpy as np
n , k = map(int,input().strip().split())
n = np.base_repr(n, base=k)
print(len(n))
n, m = map(int,input.split)
print((n-1)*(m-1))

### FIXED CODE ###

n, m = map(int,input().split())
print((n-1)*(m-1))
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

from bisect import bisect_left as bs
dt = {}
x = []
for i in range(65):
    dt[i**5] = i
    x.append(i**5)
n = inp()
if n in dt:
    print(dt[n],0)
    exit()
i = bs(x,n)
a = x[i]
b = a - n
if b in dt:
    print(dt[a],dt[b])
else:
    a = x[i-1]
    b = n - a
    print(dt[a],-dt[b])




### FIXED CODE ###

#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

dt = {}
x = []
for i in range(300):
    dt[i**5] = i
    x.append(i**5)
num = inp()
if num in dt:
    print(dt[num],0)
    exit()
n = len(x)
for i in range(n-1):
    for j in range(i+1,n):
        if x[i] + x[j] == num:
            print(dt[x[i]],-dt[x[j]])
            exit()
        elif x[j] - x[i] == num:
            print(dt[x[j]],dt[x[i]])
print("".join(sorted([input() for i in range(int("{}".format(input().split().pop(-1))))])))


### FIXED CODE ###

print("".join(sorted([input() for i in range(int("{}".format(input().split().pop(0))))])))
import sys


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        find = self.find(x)
        return [i for i in range(self.n) if self.find(i) == find]

    def finds(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.finds())

    def all_group_members(self):
        return {r: self.members(r) for r in self.finds()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.finds())


input = sys.stdin.readline
n, k, l = map(int, input().split())
w = [list(map(int, input().split())) for i in range(k+l)]

ro = w[:k]
ra = w[l:]
answer = ""
d = defaultdict(int)

ro_cl = UnionFind(n)
ra_cl = UnionFind(n)

for p, q in ro:
    ro_cl.union(p-1, q-1)

for p, q in ra:
    ra_cl.union(p-1, q-1)

for i in range(n):
    print(ro_cl.members(i))
    print(ra_cl.members(i))
    if i != 0:
        answer += " "
    answer += str(len([n for n in ro_cl.members(i) if n in ra_cl.members(i)]))
    # d[(ro_cl.find(i), ra_cl.find(i))] += 1

print(answer)


### FIXED CODE ###

import sys

#Union Find

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

#xとyの属する集合の併合
def unite(x,y,par,rank):
    x = find(x,par)
    y = find(y,par)
    
    if x != y:
        #xとyの属している集合が異なる時
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x]==rank[y]:
                rank[x] += 1

#xとyが同じ集合に属するかの判定
def same(x,y,par):
    return find(x,par) == find(y,par)
    
input = sys.stdin.readline
n,k,L = map(int,input().split())
rpar = [] #親
tpar = []
rrank = [0]*n#木の深さ
trank= [0]*n

#初期化
for i in range(n):
    #par[i]:i rank[i]:0
    rpar.append(i)
    tpar.append(i)


for i in range(k):
    x,y = map(int,input().split())
    unite(x-1,y-1,rpar,rrank)
for i in range(L):
    x,y = map(int,input().split())
    unite(x-1,y-1,tpar,trank)

num = []
d = {}
for i in range(n):
    num.append(find(i,rpar)+find(i,tpar)*10**6)
    if num[-1] in d:
        d[num[-1]] += 1
    else:
        d[num[-1]] = 1
res = ''
for i in range(n):
    if i != 0:
        res += ' '
    
    res += str(d[num[i]])

print(res)
n = str(input())

if n%9 == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = int(input())
 
if n%9 == 0:
  print("Yes")
else:
  print("No")
import math
N = int(input())
M = int(math.sqrt(N))
for i in range(M, 0, -1):
    if N % i == 0:
        A = N / i
    	print(A + i - 2)
    	break

### FIXED CODE ###

A,B = map(int,input().split())
if A>=10 or B>=10:
   print(-1)
else:
   print(A*B)
a,b,c=map(int,input().split())

if a**0.5+b**0.5<c**0.5:
  print ('Yes')
else:
  print ('No')

### FIXED CODE ###

b=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print (b[K-1])
A, B, C, X, Y = map(int, input().split())

if X >= 2 and Y >= 2:
    ans = A * X + B * Y
    if C * 2 < A + B:
        z = min(X // 2, Y // 2)
        ans = A * (X - z * 2) + B * (Y - z * 2) + C * (z * 4)

        z = max(X // 2, Y // 2)
        ans = min(ans, A * max(0, (X - z * 2)) + B * max(0, (Y - z * 2)) + C * (z * 4))

print(ans)


### FIXED CODE ###

A, B, C, X, Y = map(int, input().split())

ans = A * X + B * Y
if X >= 1 and Y >= 1:

    z = min(X, Y)
    ans = min(ans, A * (X - z) + B * (Y - z) + C * (z * 2))

    z = max(X, Y)
    ans = min(ans, A * max(0, (X - z)) + B * max(0, (Y - z)) + C * (z * 2))

print(ans)
# coding:utf-8
import sys
n = input()
array = []
for i in range(n):
    array.append(map(int, raw_input().split()))
array.sort()
result = [[]]
index = 0
for i in range(1,n):
    if(array[i - 1][0:3] == array[i][0:3]):
        if(result[index][3]):
            result[index][3] += array[i][3:]
        else:
            result[index][0:3] = array[i][0:3]
            result[index][3] = array[i][3:]
    else:
        index += 1
for i in range(4):
    for j in range(3):
        for k in range(10):
            sys.stdout.write(' ')
            if(i == array[j][0] - 1 and k == array[j][2] - 1):
                print array[j][3],
            else:
                print 0,
        else:
            print
    else:
        if(i != 3):
            print "####################"



### FIXED CODE ###

# coding:utf-8
import sys
n = input()
array = []
for i in range(n):
    array.append(map(int, raw_input().split()))
array.sort()
result = [[0 for i in range(4)] for j in range(n)]
index = 0
result[index] = array[0][0:4]
for i in range(1,n):
    if result[index][0:3] == array[i][0:3]:
        result[index][3] += array[i][3]
    elif result[index][0:3] != array[i][0:3]:
        index += 1
        result[index] = array[i][0:]
index = 0
for i in range(4):
    for j in range(3):
        for k in range(10):
            sys.stdout.write(' ')
            if(i == result[index][0] - 1 and j == result[index][1] - 1 and k == result[index][2] - 1):
                print result[index][3],
                if index != len(result) - 1:
                    index += 1
            else:
                print 0,
        else:
            print
    else:
        if(i != 3):
            print "####################"
n, k = map(int, input().split())
s = input().rstrip()
ans = 1
left = 0
right = -1
pos = s.find('10', 0)
if pos == -1:
  i = n
else:
  i = pos + 1

while i < n:
    if k > 0:
        pos = s.find('01', i)
        if pos == -1:
            i = n
            right = n - 1
        else:
            pos = s.find('10', pos + 1)
            if pos == -1:
                i = n
                right = n - 1
            else:
                right = pos
                i = pos + 1
        k = k - 1
        ans = max(ans, right - left + 1)
    else:
        pos = s.find('01', left)
        left = pos + 1
        k = k + 1

print(ans)


### FIXED CODE ###

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

AB = []
AB += [A, B]

def push(AB):
  if AB[0] >= AB[1]:
    i = 0
  else:
    i = 1
  ret = AB[i]
  AB[i] -= 1
  return ret

s = 0
for _ in range(2):
	s += push(AB)

print(s)
# coding: utf-8

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

A.sort()

dict_a = dict()

for a in A:
    if not (a in dict_a):
        dict_a[a] = 1
    else:
        dict_a[a] += 1


Q = int(input())

B = []
C = []

sums = []
for i in range(Q):
    b, c = list(map(int, input().split()))
    B.append(b)
    C.append(c)

for b, c in zip(B, C):
    if (b in dict_a):
        num = dict_a[b]
    
        if not (c in dict_a):
            dict_a[c] = num
        else:
            dict_a[c] += num

        dict_a.pop(b)

    keys = dict_a.keys()
    vals = dict_a.values()

    sumval = 0
    for k, v in zip(keys, vals):
        sumval += k * v

    print(sumval)
    

### FIXED CODE ###


char = input()

flg = char.isupper()

if flg:
    print('A')
else:
    print('a')
def main():
def main():
    N = int(input())
    print(N // 3)

if __name__ == '__main__':
    main()

### FIXED CODE ###

n = int(input())
print(n // 3)
import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford
from scipy.sparse.csgraph._shortest_path import NegativeCycleError

input = sys.stdin.buffer.readline


N, M = map(int, input().split())
starts = []
ends = []
costs = []
for _ in range(M):
    a, b, c = map(int, input().split())
    starts.append(a-1)
    ends.append(b-1)
    costs.append(-c)

graph = csr_matrix((costs, (starts, ends)), shape = (N, N))
try:
    ans = bellman_ford(graph, directed = True, indices = 0)[N-1]
    ans = int(round(-ans))
except NegativeCycleError:
    ans = "inf"
    
if ans == float("inf"):
    raise ValueError

print(ans)


### FIXED CODE ###

import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford, connected_components
from scipy.sparse.csgraph._shortest_path import NegativeCycleError

input = sys.stdin.buffer.readline


N, M = map(int, input().split())
starts = []
ends = []
costs = []
for _ in range(M):
    a, b, c = map(int, input().split())
    starts.append(a-1)
    ends.append(b-1)
    if c != 0:
        costs.append(-c)
    else:
        costs.append(sys.float_info.epsilon)

look_for_loop = csr_matrix((costs + [0], (starts + [N-1], ends + [0])), shape = (N, N))
_, labels = connected_components(look_for_loop, connection = "strong")
mask = (labels == labels[0])

graph = csr_matrix((costs, (starts, ends)), shape = (N, N)).toarray()
graph = graph[mask, :][:, mask]

try:
    ans = bellman_ford(graph, directed = True, indices = [0])[0][-1]
    ans = int(round(-ans))
except NegativeCycleError:
    ans = "inf"

print(ans)
x = input().split()
S = list(x[0])
T = list(x[1])
s = len(S)
t = len(T)
n = 0
n = s - t + 1
min = t
 
for a in range(n):
  count = 0 
	for b in range(t):
      if S[a+b] != T[b]:
        count += 1
  if count < min:
    min = count
print(min)


### FIXED CODE ###

x = [input() for i in range(2)]
S = x[0]
T = x[1]
moji = len(T)

for a in range(len(S) - len(T) + 1):
  count = 0
  for b in range(len(T)):
    
    if S[a+b] != T[b]:
      count += 1
  if count < moji:
    moji = count

print(moji)
a,b,k=map(int,input().split())
takahasi = k-a
if takahasi < 0:
  print(0,end=' ')
else:
  print(takahasi)
s = a+b
if s - k < 0
  print(0)
else:
  print(s-k)

### FIXED CODE ###

a,b,k=map(int,input().split())
if a >= k:
  a -= k
else:
  b=max(b-(k-a),0)
  a=0
print("{} {}".format(a,b))
n, m, k = map(int, input().split())

candidates = [0] * n
friends = [set() for _ in range(n)]
blocks = [set() for _ in range(n)]
parent = [i for i in range(n)]
sizes = [1 for _ in range(n)]

def root(x):
    global parent
    if parent[x] == x:
        return x
    else:
        parent[x] = root(parent[x])
        return parent[x]

def unite(x, y):
    global parent
    global sizes
    x = root(x)
    y = root(y)
    # print(x, y)
    if x == y:
        return
    parent[x] = y # ここがREの原因らしいが..
    sizes[x] += sizes[y]
    sizes[y] = sizes[x]

def same(x, y):
    return root(x) == root(y)

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

for _ in range(k):
    c, d = map(int, input().split())
    if same(c - 1, d - 1):
        blocks[c - 1].add(d - 1)
        blocks[d - 1].add(c - 1)

for i in range(n):
    candidates[i] = sizes[root(i)] - len(friends[i]) - len(blocks[i]) - 1

print(*candidates)


### FIXED CODE ###

class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n + 1)]
        self.sizes = [1] * (n + 1)

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if y < x:
            x, y = y, x
        self.parents[y] = x
        self.sizes[x] += self.sizes[y]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return self.sizes[self.find(x)]


n, m, k = map(int, input().split())
uf = UnionFind(n)
friends = [0] * n
blocks = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    friends[a - 1] += 1
    friends[b - 1] += 1
    uf.unite(a - 1, b - 1)
for i in range(k):
    c, d = map(int, input().split())
    if uf.same(c - 1, d - 1):
        blocks[c - 1] += 1
        blocks[d - 1] += 1
ans = [0] * n
for i in range(n):
    ans[i] = uf.size(i) - friends[i] - blocks[i] - 1
print(*ans)