Harryxun/stf_run huggingface dataset:
import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)


### FIXED CODE ###

import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)
mport collections

N = int(input())
S = []

for i in range(N):
    S.append(input())

S.sort()
counter = collections.Counter(S)

tmp = counter.most_common()

if (len(tmp) == 1):
    print(tmp[0][0])
else:
    for i in range(len(tmp)-1):
        print(tmp[i][0])
        if (tmp[i][1] != tmp[i + 1][1]):
            break

### FIXED CODE ###

import collections

N = int(input())
S = list(input() for i in range(N))
S.sort()

common = collections.Counter(S).most_common()
N_common = common[0][1]

candidates = [cand for cand in common if cand[1] == N_common]

for i in sorted(candidates):
    print(i[0])
a = int(input())
b = int(input())
 
if (a*b%2 == 0):
	print('Even')
else:
    print('Odd')

### FIXED CODE ###

a, b = map(int, input().split())

c = a*b

if c%2 == 0:
    print("Even")
else:
    print("Odd")
import sys,queue,math,copy
input = sys.stdin.readline
MOD = 10**9 + 7
LI = lambda : [int(x) for x in input().split()]
N = int(input())
A = LI()
c =[0,0,0]
cnt = [0 for _ in range(N)]
for i in range(N):
    cnt[i] = c.count(A[i])
    c[c.index(A[i])] += 1
ans = 1
for i in range(N):
    ans = (ans * cnt[i]) % MOD
print (ans)

### FIXED CODE ###

import sys,queue,math,copy
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in input().split()]
_LI = lambda : [int(x)-1 for x in input().split()]
N = int(input())
A = LI()


c =[0,0,0]
cnt = [0 for _ in range(N)]
for i in range(N):
    cnt[i] = c.count(A[i])
    if cnt[i] == 0:
        print (0)
        exit (0)
    for j in range(3):
        if c[j] == A[i]:
            c[j] += 1
            break
ans = 1
for i in range(N):
    ans = (ans * cnt[i]) % MOD
print (ans)
N, M = map(int, input().split())
p = [0] + list(map(int, input().split()))
x, y = zip(*(map(int, input().split()) for _ in range(M)))
E = [[] for _ in range(N + 1)]
for a, b in zip(x, y):
    E[a].append(b)
    E[b].append(a)
v = [True for _ in range(N + 1)]


def f(i, P, Q):
    v[i] = False
    P.add(i)
    Q.add(p[i])
    for a in E[i]:
        if v[a]:
            f(a, P, Q)


ans = 0
for i in range(1, N + 1):
    if v[i]:
        P = set()
        Q = set()
        f(i, P, Q)
        ans += len(P & Q)
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(2*10**5)

N, M = map(int, input().split())
p = [0] + list(map(int, input().split()))
x, y = zip(*(map(int, input().split()) for _ in range(M)))
E = [[] for _ in range(N + 1)]
for a, b in zip(x, y):
    E[a].append(b)
    E[b].append(a)
v = [True for _ in range(N + 1)]


def f(i, P, Q):
    v[i] = False
    P.add(i)
    Q.add(p[i])
    for a in E[i]:
        if v[a]:
            f(a, P, Q)


ans = 0
for i in range(1, N + 1):
    if v[i]:
        P = set()
        Q = set()
        f(i, P, Q)
        ans += len(P & Q)
print(ans)
# -*- coding: utf-8 -*-
"""
C - Dice and Coin
https://atcoder.jp/contests/abc126/tasks/abc126_c

"""
import sys


from decimal import *
from math import log2, ceil


def solve(N, K):
    getcontext().prec = 30
    ans = Decimal(0)
    for i in range(1, N+1):
        if i >= K:
            t = Decimal (1/N)
        else:
            t = Decimal(1/N/2**ceil(log2(K/i)))
        ans += t
    return ans


def main(args):
    N, K = map(int, input().split())
    ans = solve(N, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
C - Dice and Coin
https://atcoder.jp/contests/abc126/tasks/abc126_c

"""
import sys


from decimal import *
from math import log2, ceil

#TLE
def __solve(N, K):
    getcontext().prec = 30
    ans = Decimal(0)
    for i in range(1, N+1):
        if i >= K:
            t = Decimal (1/N)
        else:
            t = Decimal(1/N/2**ceil(log2(K/i)))
        ans += t
    return ans


def solve(N, K):
    ans = 0
    for i in range(1, N+1):
        if i >= K:
            t = 1 / N
        else:
            t = 1/N/2**ceil(log2(K/i))
        ans += t
    return ans


def main(args):
    N, K = map(int, input().split())
    ans = solve(N, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
import sys

MOD = 10 ** 9 + 7

def main():
    n, m = [int(s) for s in input().split()]
    print(solve(m, n))

def solve(m, n):
    factors = list(get_prime_factors(m))
    h = max(c for f, c in factors)

    table = dict()
    table[1] = [1 for _ in range(h + 1)]

    i = 1
    while i < n:
        j = n & (i - 1)
        table[i * 2] = [0 for _ in range(h + 1)]
        if n & i != 0 and j != 0:
            table[i + j] = [0 for _ in range(h + 1)]
        for x in range(h + 1):
            for y in range(h + 1 - x):
                table[i * 2][x + y] = (table[i * 2][x + y] + table[i][x] * table[i][y]) % MOD
                if n & i != 0 and j != 0:
                    table[i + j][x + y] = (table[i + j][x + y] + table[i][x] * table[j][y]) % MOD

        if n & i == 0:
            del table[i]
        if n & i != 0 and j != 0:
            del table[i]
            del table[j]

        i *= 2

    ans = 1
    for f, c in factors:
        ans = ans * table[n][c] % MOD
    return ans

def get_prime_factors(n):
    import itertools

    m = n
    for i in itertools.count(2):
        if i * i > m:
            break

        c = 0
        while True:
            x, y = divmod(m, i)
            if y != 0:
                break
            c += 1
            m = x
        if c != 0:
            yield i, c

    if m != 1:
        yield m, 1


main()


### FIXED CODE ###

import sys

MOD = 10 ** 9 + 7

def main():
    n, m = [int(s) for s in input().split()]
    print(solve(m, n))

def solve(m, n):
    factors = list(get_prime_factors(m))
    h = max((c for f, c in factors), default=0)

    table = dict()
    table[1] = [1 for _ in range(h + 1)]

    i = 1
    while i < n:
        j = n & (i - 1)
        table[i * 2] = [0 for _ in range(h + 1)]
        if n & i != 0 and j != 0:
            table[i + j] = [0 for _ in range(h + 1)]
        for x in range(h + 1):
            for y in range(h + 1 - x):
                table[i * 2][x + y] = (table[i * 2][x + y] + table[i][x] * table[i][y]) % MOD
                if n & i != 0 and j != 0:
                    table[i + j][x + y] = (table[i + j][x + y] + table[i][x] * table[j][y]) % MOD

        if n & i == 0:
            del table[i]
        if n & i != 0 and j != 0:
            del table[i]
            del table[j]

        i *= 2

    ans = 1
    for f, c in factors:
        ans = ans * table[n][c] % MOD
    return ans

def get_prime_factors(n):
    import itertools

    m = n
    for i in itertools.count(2):
        if i * i > m:
            break

        c = 0
        while True:
            x, y = divmod(m, i)
            if y != 0:
                break
            c += 1
            m = x
        if c != 0:
            yield i, c

    if m != 1:
        yield m, 1


main()
T = input()
ans = 0

if T[0] == "?":
    if T[1] == "P":
        ans = "D"
    else:
        ans = "P"
else:
    ans = T[0]

for i in range(len(T)-1):
    if T[i+1] == "?":
        if ans[i]  == "P":
            ans += "D"
        else:
            if T[i+2] == "P":
                ans += "D"
            else:
                ans += "P"
    else:
        ans += T[i+1]
        
print(ans)

### FIXED CODE ###

T = input()
ans = 0

if T[0] == "?":
    if len(T) == 1:
        ans = "D"
    elif T[1] == "D":
        ans = "P"
    else:
        ans = "D"
else:
    ans = T[0]

for i in range(len(T)-2):
    if T[i+1] == "?":
        if ans[i]  == "P":
            ans += "D"
        else:
            if T[i+2] == "P":
                ans += "D"
            else:
                ans += "P"
    else:
        ans += T[i+1]

if len(T) > 1:
    if T[-1] == "?":
        ans += "D"
    else:
        ans += T[-1]
            
print(ans)
import sys

input = sys.stdin.readline
print = sys.stdout.write

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

freq = {}
a = [int(i) for i in input().split()]

for i in a:
    if i not in freq:
        freq[i] = 1
    else:
        freq[i] += 1

total = 0
while len(freq.keys()) > k:
    mn = (0,2000001)
    for i in freq.keys():
        if freq[i] < mn[1]:
            mn = (i,freq[i])
    total += mn[1]
    del freq[mn[0]]
print(str(total))


### FIXED CODE ###

print(input().count("1"))
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
S = input()
out = ['0'] * len(S)
for i in range(K):
    if i!=0:
        S = ''.join(out)
    idx = 0
    maxidx = 0
    length = 1
    maxlen = 10000
    back = S[0]
    for j in range(len(S)):
        if back == S[j]:
            length += 1
        else:
            if length <= maxlen:
                #print(length)
                maxlen = length
                maxidx = j
                length = 1
            else:
                length = 1
                idx = j
        if length == j+2 and S[0] == 'L':
            length -= 1
        if j == len(S)-1 and S[j] == 'R':
            length -= 1
        back = S[j]
    temp = ['0'] * maxlen
    for j in range(maxlen):
        #print([maxidx,maxlen])
        if maxlen == 1:
            if S[maxidx + maxlen - j - 2] == 'L':
                temp[j] = 'R'
            else:
                temp[j] = 'L'
        else:
            if S[maxidx + maxlen - j - 1] == 'L':
                temp[j] = 'R'
            else:
                temp[j] = 'L'
    for j in range(len(S)):
        out[j] = S[j]
    for j in range(maxlen):
        if maxlen == 1:
            out[maxidx + j - 1] = temp[j]
        else:
            out[maxidx + j] = temp[j]
#print(''.join(out))
count=0
#right
for i in range(len(S)):
    if i==0 and out[i]=='L':
        continue
    elif i==N-1 and out[i]=='R':
        break
    if out[i]=='R' and out[i+1]=='R':
        count += 1
    if out[i]=='L' and out[i-1]=='L':
        count += 1
print(count)


### FIXED CODE ###

import bisect
import heapq
import numpy as np
N, K = map(int,input().split())
s = input()
res = 0
if s[0] == 'R' and s[1] == 'R':
    res += 1
for i in range(1,N-1):
    if s[i-1] == 'R' and s[i] == 'L':
        continue
    elif s[i+1] == 'L' and s[i] == 'R':
        continue
    res += 1
if s[N-1] == 'L' and s[N-2] == 'L':
    res += 1
res = min([N-1, res+2*K])
print(res)
n = int(input())
a = list(map(int,input().split()))

high = max(a)
low = min(a)

if a[0] == high:
    print(1000)
else:
    s = a.index(high)
    a = a[:s+1]
    wallet = 1000
    stock = 0
    markets = []
    market = [a[0]]
    for i in range(n-1):
        if a[i+1] == a[i]:
            continue
        if a[i+1] > a[i]:
            market.append(a[i+1])
            markets.append(market)
            market = [a[i+1]]
        else:
            market.append(a[i+1])

    for i in range(len(markets)):
        if i == 0:
            stock += wallet // markets[i][0]
            wallet %= markets[i][0]
        elif i != 0:
            stock += wallet // markets[i][1]
            wallet %= markets[i][1]
        wallet += stock * markets[i][-1]
        stock = 0
    print(wallet)

### FIXED CODE ###

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

wallet = 1000

for i in range(n-1):
    if a[i] < a[i+1]:
        stock = wallet // a[i]
        wallet += (a[i+1]-a[i]) * stock

print(wallet)
r=input()

print(3*r^2)

### FIXED CODE ###

r=int(input())
answer=3*r**2
print(answer)
A, B = map(int, input().split())
int C

if A == 2 or B == 2:
  print("No")
  
elif C == 1 or C == 3:
  print("Yes")

### FIXED CODE ###

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

if (A == 2) or (B == 2):
  print("No")
  
else:
  print("Yes")
s = input()
print(a)

### FIXED CODE ###

a = input()
if a == 'ABC':
  print('ARC')
else:
  print('ABC')
n, k = map(int, input().split())
S = input()
s = S.split("L")
s = [i for i in s if i != '']
s.sort(reverse=True)
cnt = 0
for i in range(k):
    cnt += len(s[i])
    s.remove(s[i])
for i in s:
    if len(i) >= 2:
        cnt += len(i) - 1
r = S.split('R')
for i in r:
    if len(i) >= 2:
        cnt += len(i) - 1
    if len(i) == 1 and k > 0:
        cnt += 1
        k -= 1
print(cnt)


### FIXED CODE ###

n, k = map(int, input().split())
s = input()
cnt = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        cnt += 1
ans = min(cnt+2*k, n-1)
print(ans)
from decimal import Decimal
A,B = input().split()
A=Decimal(A)
B=Decimal(B)
AB=math.floor(A*B)
print(AB)

### FIXED CODE ###

from decimal import Decimal
import math
A,B = input().split()
A=Decimal(A)
B=Decimal(B)
AB=math.floor(A*B)
print(AB)
N,M = map(int,input().split())
h = [list(map(int, input().split()))for i in range(M)]
for i in range(M):
    h[i].append(i)
h = sorted(h,key=lambda h:(h[0],h[1]))
k = 0
p = h[0][0]
for i in range(M):
    if h[i][0] == p:
        h[i].append(str(p).zfill(6)+str(k+1).zfill(6))
        k+=1
    else:
        p += 1
        k = 0
        h[i].append(str(p).zfill(6) + str(k + 1).zfill(6))
        break
h = sorted(h,key=lambda h:h[2])
# print(h)
for i in range(M):
    print(h[i][3])

### FIXED CODE ###

N,M = map(int,input().split())
h = [list(map(int, input().split()))for i in range(M)]
for i in range(M):
    h[i].append(i)
h = sorted(h,key=lambda h:(h[0],h[1]))
k = 0
p = h[0][0]
for i in range(M):
    if h[i][0] == p:
        h[i].append(str(p).zfill(6)+str(k+1).zfill(6))
        k+=1
    else:
        p = h[i][0]
        k = 0
        h[i].append(str(p).zfill(6) + str(k + 1).zfill(6))
        k += 1
# print(h)
h = sorted(h,key=lambda h:h[2])
# print(h)
for i in range(M):
    print(h[i][3])
A,V=map(int,input().split())
B,W=map(int,input().split())
T=input()
if B>=A:
    print("YES" if A+V*T>=B+W*T else "NO")
else:
    print("YES" if B-W*T>=A-V*T else "NO") 


### FIXED CODE ###

A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if B>=A:
    print("YES" if A+V*T>=B+W*T else "NO")
else:
    print("YES" if B-W*T>=A-V*T else "NO")
r = input()

print int(r*r)

































































### FIXED CODE ###

print(int(input())**2)














###################################################################
field = []
w = 0
h = 0


def main():
    global field, w, h
    while True:
        h, w = map(int, input().split())
        if h == 0 and w == 0:
            break
        count = 0
        field = []
        [field.append([_ for _ in input()]) for _ in range(h)]
        for y in range(h):
            for x in range(w):
                if field[y][x] != -1:
                    dfs(field[y][x], x, y)
                    count += 1
        print(count)


def dfs(kind, x, y):
    global field
    field[y][x] = -1
    for dx, dy in zip([0, 0, -1, 1], [1, -1, 0, 0]):
        next_x = x + dx
        next_y = y + dy
        if next_x < 0 or next_y < 0 or next_x >= w or next_y >= h:
            continue
        if field[next_y][next_x] != kind:
            continue
        dfs(field[next_y][next_x], next_x, next_y)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(20000)

field = []
w = 0
h = 0


def main():
    global field, w, h
    while True:
        h, w = map(int, input().split())
        if h == 0 and w == 0:
            break
        count = 0
        field = []
        [field.append(list(input())) for _ in range(h)]
        for y in range(h):
            for x in range(w):
                if field[y][x] != -1:
                    dfs(field[y][x], x, y)
                    count += 1
        print(count)


def dfs(kind, x, y):
    global field
    field[y][x] = -1
    for dx, dy in zip([0, 0, -1, 1], [1, -1, 0, 0]):
        next_x = x + dx
        next_y = y + dy
        if next_x < 0 or next_y < 0 or next_x >= w or next_y >= h \
                or field[next_y][next_x] != kind:
            continue
        dfs(field[next_y][next_x], next_x, next_y)


if __name__ == '__main__':
    main()
S=input()
if S[0]=S[1] or S[1]=S[2] or S[2]=S[3]:
  print("Bad")
  else print("Good")

### FIXED CODE ###

S = input()

if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
   print("Bad")
else:
    print("Good")
import fractions
N,K=map(int,input().split())
L=list(map(int,input().split()))
tmp=0
for i in range(1,N):
	if i==1:
		tmp=fractions.gcd(L[0],L[1])
	else:
		tmp=fractions.gcd(tmp,L[i])
if tmp<K and K%tmp==0:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

### FIXED CODE ###

import fractions
N,K=map(int,input().split())
L=list(map(int,input().split()))
tmp=0
if N==1:
	if L[0]==K:
		print("POSSIBLE")
		exit()
	else:
		print("IMPOSSIBLE")
		exit()
for i in range(1,N):
	if i==1:
		tmp=fractions.gcd(L[0],L[1])
	else:
		tmp=fractions.gcd(tmp,L[i])
if max(L)>=K and K%tmp==0:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

# ループを見つける(5000), 一周のスコアを確認
is_visit = [0 for _ in range(n)]
loop = []

def search(i, j):
    if is_visit[i] == 0:
        is_visit[i] = j
        l.append(i)
        search(p[i]-1, j)

loop_id = 1
for i in range(n):
    l = []
    search(i, loop_id)
    if len(l) != 0:
        loop.append(l)
        loop_id += 1
# print(loop)
# print(is_visit)

ans = [0 for _ in range(n)]
for i in range(n):
    # i からはじめて最大スコア
    l = loop[is_visit[i]-1] # 所属するループ
    tmp1 = 0 # ループによるスコア
    tmp_k = k
    s = 0
    for j in range(len(l)):
        s += c[l[j]]
    if s > 0 and k > len(l):
        # 回るほどお得
        tmp1 += s*(tmp_k//len(l))
        tmp_k -= tmp_k//len(l)*len(l)
    else:
        tmp_k -= tmp_k//len(l)*len(l)
        if tmp_k == 0:
            tmp_k = len(l)
    pointer = p[i]
    tmp2 = [c[pointer-1] for _ in range(tmp_k)] # 愚直に進んだ点数
    if tmp_k != 0:
        for j in range(1, tmp_k):
            # k回目までの累積和で最大を求める
            pointer = p[pointer-1]
            tmp2[j] = tmp2[j-1] + c[pointer-1]
    # print(i, l, s, tmp_k, tmp1, tmp2)
    ans[i] = tmp1 + max(tmp2)
# print(ans)
print(max(ans))


### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

# ループを見つける(5000), 一周のスコアを確認
is_visit = [0 for _ in range(n)]
loop = []

def search(i, j):
    if is_visit[i] == 0:
        is_visit[i] = j
        l.append(i)
        search(p[i]-1, j)
    else:
        pass

loop_id = 1
for i in range(n):
    l = []
    search(i, loop_id)
    if len(l) != 0:
        loop.append(l)
        loop_id += 1
# print(loop)
# print(is_visit)
s_list = [0 for _ in range(len(loop))]
for i in range(len(s_list)):
    l = loop[i]
    s = 0
    for j in range(len(l)):
        s += c[l[j]]
    s_list[i] = s

ans = [0 for _ in range(n)]
for i in range(n):
    # i からはじめて最大スコア
    l = loop[is_visit[i]-1] # 所属するループ
    tmp1 = 0 # ループによるスコア
    tmp_k = k
    s = s_list[is_visit[i]-1]
    if s > 0 and k > len(l):
        # 回るほどお得で一周より回れる
        tmp1 += s*(tmp_k//len(l)-1)
        tmp_k -= (tmp_k//len(l)-1)*len(l)
    elif s <= 0 and k > len(l):
        tmp_k -= (tmp_k//len(l)-1)*len(l)
        if tmp_k == 0:
            tmp_k = len(l)
    pointer = p[i]
    tmp2 = [c[pointer-1] for _ in range(tmp_k)] # 愚直に進んだ点数
    if tmp_k != 0:
        for j in range(1, tmp_k):
            # k回目までの累積和で最大を求める
            pointer = p[pointer-1]
            tmp2[j] = tmp2[j-1] + c[pointer-1]
    # print(i, l, s, tmp_k, tmp1, tmp2)
    if len(tmp2) != 0:
        ans[i] = tmp1 + max(tmp2)
    else:
        ans[i] = tmp1
# print(ans)
print(max(ans))
n, x =  map(int, input().split())
xi = list(map(int, input().strip().split()))
c = [1] * x
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
print(d)

### FIXED CODE ###

n, x =  map(int, input().split())
xi = map(int, input().strip().split())
c = [x] * n
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
if len(xi) == 1:
  d = xi[0]
print(abs(d))
H,W=input().split()
h,w=input().split()

ans=(H-h)*(W-w)

print(ans)

### FIXED CODE ###

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

ans=(H-h)*(W-w)

print(ans)
N,M  = map(int, input().split())
balls = [1]*N
reds = [False]*N
reds[0] = [True]
for i in range(M):
    x,y = map(int, input().split())
    x -= 1
    y -= 1
    balls[x] -= 1
    balls[y] += 1
    if reds[x]:
        reds[y] = True
    if balls[x] == 0:
        reds[x] = False

print(sum(reds))

### FIXED CODE ###

N,M  = map(int, input().split())
balls = [1]*(N+1)
reds = [False]*(N+1)
reds[0] = True
for i in range(M):
    x,y = map(int, input().split())
    x -= 1
    y -= 1
    balls[x] -= 1
    balls[y] += 1
    if reds[x]:
        reds[y] = True
    if balls[x] == 0:
        reds[x] = False

print(sum(reds))
n, m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]

inf = 10 ** 18
dis = [inf] * n
dis[0] = 0

for z in range(n+1)
    update = False
    for a, b, c in edge:
        a -= 1
        b -= 1
        if dis[a] != inf and dis[b] > dis[a] - c:
            dis[b] = dis[a] - c
            update = True
            if z == n:
                print('inf')
                exit()
print(-dis[n-1])

### FIXED CODE ###

n, m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]

inf = 10 ** 18
dis = [inf] * n
dis[0] = 0

for z in range(2*n+1):
    update = False
    for a, b, c in edge:
        a -= 1
        b -= 1
        if dis[a] != inf and dis[b] > dis[a] - c:
            dis[b] = dis[a] - c
            update = True
            if b == n - 1 and z >= n - 1:
                print('inf')
                exit()
print(-dis[n-1])
n = int(input())
a = map(int, input().split)

sum = 0.0
for x in a:
  sum = sum + 1 / x

print(1/sum)


### FIXED CODE ###

a = int(input())
s = input()

if (a >= 3200):
  print(s)
else:
  print('red')
while 1:
 a,b,op=map(int,raw_input().split())
 if op == '?':
   break
 elif op == '+':
   print a+b
 elif op == '-':
   print a-b
 elif op == '/':
   print a/b
 elif op == '*':
   print a*b
  

### FIXED CODE ###

while True:
    a, op, b = raw_input().split()
    ai = int(a)
    bi = int(b)
    if op == '?':
        break
    elif op == '+':
        print(ai + bi)
    elif op == '-':
        print(ai - bi)
    elif op == '*':
        print(ai * bi)
    elif op == '/':
        print(ai / bi)
a,op,b=input().split()
if op = '+':
  print(int(a)+int(b))
else:
  print(int(a)-int(b))

### FIXED CODE ###

a,op,b=input().split()
if op == '+':
  print(int(a)+int(b))
else:
  print(int(a)-int(b))
s = input()
w = int(input())
a = ''
for i in range(int(len(s)/w)+1):
  a += s[i*w]
print(a)

### FIXED CODE ###

s = input()
w = int(input())
a = ''
if len(s)%w == 0:
  b = len(s)//w
else:
  b = len(s)//w+1

for i in range(b):
  a += s[i*w]
print(a)