Harryxun/stf_run huggingface dataset:
s = []
a = [[s.append(i) for i in line.split(" ")] for line in input().split()]
nums = []
[[nums.append(num) for num in row.split(" ")] for row in s[:9]]
n = int(s[9])
bs = s[10:]
mat = [num in bs for num in nums]
patterns = [[0, 1, 2],
            [0, 4, 8],
            [0, 3, 6],
            [1, 4, 7],
            [2, 4, 6],
            [2, 5, 8],
            [3, 4, 5],
            [6, 7, 8]]
for pat in patterns:
    if mat[pat[0]] and mat[pat[1]] and mat[pat[2]]:
        print("Yes")


### FIXED CODE ###

import sys
input = sys.stdin.readlines()
nums = []
[[nums.append(num) for num in row.strip().split(" ")] for row in input[:3]]
bs = [i.strip() for i in input[4:]]
mat = [num in bs for num in nums]
patterns = [[0, 1, 2],
            [0, 4, 8],
            [0, 3, 6],
            [1, 4, 7],
            [2, 4, 6],
            [2, 5, 8],
            [3, 4, 5],
            [6, 7, 8]]
for pat in patterns:
    if mat[pat[0]] and mat[pat[1]] and mat[pat[2]]:
        print("Yes")
        sys.exit()
print("No")
L, N = input().strip().split()

s = [input() for i in range(int(N))]

result = ""
for i in sorted(s):
  result = result + i
print(result)

### FIXED CODE ###

l = list(map(int, input().split()))

N = l[0]
L = l[1]

s = [input() for i in range(N)]
result = ""
for i in sorted(s):
  result += i
print(result)
N, M = map(int, input().split())
A_B = []
for i in range(N):
    A_B.append(list(map(int, input().split())))
A_B.sort()
print(A_B)
sum = 0
money = 0
i = 0
while sum <= M:
    money += A_B[i][0] * A_B[i][1]
    sum += A_B[i][1]
    print(sum)
    i += 1
money -= A_B[i-1][0] * (sum - M)
print(money)


### FIXED CODE ###

N, M = map(int, input().split())
A_B = []
for i in range(N):
    A_B.append(list(map(int, input().split())))
A_B.sort()
sum = 0
money = 0
i = 0
while sum <= M and i < N:
    money += A_B[i][0] * A_B[i][1]
    sum += A_B[i][1]
    i += 1
money -= A_B[i-1][0] * (sum - M)
print(money)
a = input()
if a = 'hi' or a = 'hihi' or a = 'hihihi' or a = 'hihihihi' or a = 'hihihihihi' or a = 'hihihihihi' or 
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a = input()
if a == 'hi' or a == 'hihi' or a == 'hihihi' or a == 'hihihihi' or a == 'hihihihihi' or a == 'hihihihihi':
  print('Yes')
else:
  print('No')
W, H, x, y, r = int(input().split())
if(x < r || y < r):
    print("No")
elif(x > (W - r) || y > (H - r)):
    print("No")
else:
    print("Yes")


### FIXED CODE ###

W, H, x, y, r = map(int, input().split())
if(x < r or y < r):
    print("No")
elif(x > (W - r) or y > (H - r)):
    print("No")
else:
    print("Yes")
n = int(input())
ans = []
def dfs(line, mx):
    if len(line) == n:
        ans.append(line)
    else:
        for i in range(mx+1):
            line_copy = line.copy()
            line_copy.append(i)
            dfs(line_copy, mx)
        line_copy = line.copy()
        line_copy.append(mx+1)
        dfs(line_copy, mx+1)

dfs([0], 0)

figures = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

for a in ans:
    for i in a:
        print(figures[i], end="")
    print()


### FIXED CODE ###

n = int(input())
ans = []
def dfs(line, mx):
    if len(line) == n:
        ans.append(line)
    else:
        for i in range(mx+1):
            line_copy = line.copy()
            line_copy.append(i)
            dfs(line_copy, mx)
        line_copy = line.copy()
        line_copy.append(mx+1)
        dfs(line_copy, mx+1)

dfs([0], 0)

figures = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

for a in ans:
    for i in a:
        print(figures[i], end="")
    print()
n, a, b = map(int, input().split())
if n*a < b
	print n*a
else: 
	print b

### FIXED CODE ###

n, a, b = map(int, input().split())
if n*a < b:
	print (n*a)
else: 
	print (b)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
n =  int(input())
lista = a+b+c
call_number = []
for i in range(n):
    k = int(input())
    call_number.apped(k)
bingo_number_list = []
for m,n in enumerate(lista):
    if n in call_number:
        bingo_number_list.appedned(m)
    
lista  = [0,4,8]
list0 = [0,1,2]
list1 = [3,4,5]
list2 = [6,7,8]
list3 = [0,3,6]
list4 = [1,4,7]
list5 = [2,5,8]
list6 = [0,4,8]
list7 = [2,4,6]

for i in range(8):
    name = "list"+str(i)
    if set(name) <= set(lista):
        bingo += 1

if bingo > 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
n =  int(input())
lista = a+b+c
call_number = []
for i in range(n):
    k = int(input())
    call_number.append(k)
bingo_number_list = []
for m,n in enumerate(lista):
    if n in call_number:
        bingo_number_list.append(m)
    
list0 = [0,1,2]
list1 = [3,4,5]
list2 = [6,7,8]
list3 = [0,3,6]
list4 = [1,4,7]
list5 = [2,5,8]
list6 = [0,4,8]
list7 = [2,4,6]
bingo = 0
for i in range(8):
    if set(list0) <= set(bingo_number_list):
        bingo += 1
    if set(list1) <= set(bingo_number_list):
        bingo += 1
    if set(list2) <= set(bingo_number_list):
        bingo += 1
    if set(list3) <= set(bingo_number_list):
        bingo += 1
    if set(list4) <= set(bingo_number_list):
        bingo += 1
    if set(list5) <= set(bingo_number_list):
        bingo += 1
    if set(list6) <= set(bingo_number_list):
        bingo += 1
    if set(list7) <= set(bingo_number_list):
        bingo += 1

if bingo > 0:
    print("Yes")
else:
    print("No")
h,w = map(int, input().split())
if h * w 2% ==0:
    print(h*w/2)
else:
    print(h*w/2 +1)


### FIXED CODE ###

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

if h ==1 or w==1 :
    print(1)
elif h * w %2 ==0:
    print(h*w//2)
else:
    print(h*w//2 +1)
s = input()
cnt = 0
cntflg = True
for i in s:
  if i == 'Z':
    break
  elif cntflg:
    cnt += 1
  elif i == 'A'
  	cnt = 1
    cntflg = True

print(cnt)

### FIXED CODE ###

s = input()
left = 0
right = 0

for idx, val in enumerate(s):
        if val == 'A':
                left = idx
                break

for idx, val in enumerate(reversed(s)):
        if val == 'Z':
                right = idx
                break

print(len(s) - left - right)
import math
a,b,c=map(int,input().split())
if a*a*b/2<c:
 print(90-math.degrees(math.atan(a/(b*2-c/a/a*2))))
else:
 print(math.degrees(math.atan(b/(2*c/a/b))))

### FIXED CODE ###

import math
a,b,c=map(int,input().split())
if b-c/a/a==0:
 print(0)
elif a*a*b/2<c:
 print(90-math.degrees(math.atan(a/(b*2-c/a/a*2))))
else:
 print(math.degrees(math.atan(b/(2*c/a/b))))
n, l = map(int, input().split())
str_list = [input() for i in range(l)]

str_list.sort()

print("".join(str_list))



### FIXED CODE ###

n, l = map(int, input().split())
str_list = [input() for i in range(n)]

str_list.sort()

print("".join(str_list))
S,T = input().split()
A,B = int(input().split())
U = input()

if S == U:
  	print(A-1,B)
elif T == U:
    print(A,B-1)

### FIXED CODE ###

S,T = input().split()
A,B = map(int,input().split())
U = input()
if U == S:
  	print(A-1,B)
elif U == T:
    print(A,B-1)
n=int(input())
s=list(input())
k=int(input())
ans=''
for i in range(n):
    if s[i]==s[k]:
        ans+=s[i]
    else:
        ans+='*'
print(ans)

### FIXED CODE ###

n=int(input())
li=list(map(int,input().split()))
m=max(li)
sum=0
for i in range(n):
    sum+=li[i]
if m<sum-m:
    print('Yes')
else:
    print('No')
A, B = map(int, input().split())
S = input()
if is_int(S[:A+1]) and S[A+1] == '-' and is_int(S[A+2:]):
  print('Yes')
else:
  print('No')


### FIXED CODE ###

def is_int(s):
    try:
        int(s)
        return True
    except ValueError:
        return False

A, B = map(int, input().split())
S = input()
if is_int(S[:A]) and S[A] == '-' and is_int(S[A+1:]):
  print('Yes')
else:
  print('No')
import time
import random
N = int(input())
s = str(input())
maxlen = N//2
start = time.time()
def solve(tgt):
    for i in range(N-tgt*2+1):
        if s[i:i+tgt] in s[i+tgt:]:
            return True
    return False

ng = maxlen + 1
ok = 0
if N>650:
    ok = 2
first = 1
while ng-ok > 1:
    end = time.time()
    if end-start > 1.2:
        r = random.random.randint(ok,ng-1)
        print(r)
        exit()
    tgt = (ok+ng)//2
    if N>=5000 and first == 1:
        tgt = 2496
        first = 0
    if solve(tgt):
        ok = tgt
    else:
        ng = tgt
print(ok)


### FIXED CODE ###

from collections import defaultdict as dd
N = int(input())
s = str(input())
maxlen = N//2

def solve(tgt):
    dic = dd(int)
    st = s[tgt:2*tgt]
    dic[st] += 1
    ls = [st]
    for char in s[2*tgt:]:
        st = st[1:]+char
        dic[st] += 1
        ls.append(st)
    st = s[:tgt]
    if dic[st] > 0:
        return True
    dic[ls[0]] -= 1
    for i,char in enumerate(s[tgt:N-tgt]):
        st = st[1:]+char
        if dic[st] > 0:
            return True
        dic[ls[i+1]] -= 1
    return False

ng = maxlen + 1
ok = 0
while ng-ok > 1:
    tgt = (ok+ng)//2
    if solve(tgt):
        ok = tgt
    else:
        ng = tgt
print(ok)
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
    a = np.array(read().split(), np.int32)[1:]
    count = np.zeros(2*10**5+1, np.int32)
    for ae in a:
        if count[ae] <= 1:
            count[::ae] += 1
    r = 0
    for ae in a:
        r += count[ae] == 1
    print(r)

if __name__ == '__main__':
    main()


### FIXED CODE ###

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

    a.sort()
    tf = [0] * (a[-1] + 1)
    for ea in a:
        tf[ea] = 1
    for i1 in range(n - 1):
        if a[i1] == a[i1 + 1]:
            tf[a[i1]] = 0

        for i2 in range(2, a[-1]//a[i1] + 1):
            tf[a[i1] * i2] = 0
    r = sum(tf)
    print(r)


if __name__ == '__main__':
    main()
import sys

for i, num in enumerate(sys.stdin.read().splitlines()):
  print("Case "+ i +  ": " + num)

### FIXED CODE ###

import sys
cnt = 1

while 1:
  num=sys.stdin.readline().strip()
  if num == "0":
    break
  print('Case {0}: {1}'.format(cnt, num))
  cnt+=1
n=raw_input()
A=map(int,raw_input.split())
q=raw_input()
m=map(int,raw_input.split())

def solve(c, m):
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) || solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    print yes
  else:
    print no

### FIXED CODE ###

n=int(raw_input())
A=map(int, raw_input().split())
q=int(raw_input())
m=map(int, raw_input().split())

def solve(j, m):
  if m == 0:
    return 1
  if j >= n or m > sum(A):
    return 0
  res = solve(j + 1, m) or solve(j + 1, m - A[j])
  return res

for i in range(0,q):
  if solve(0,m[i]):
    print "yes"
  else:
    print "no"
def gcd(x, y):
  while(y): 
       x, y = y, x % y   
  return x 

def solve():
  n = 3
  a = [7, 6, 8]
  left = [0] * n + 1
  right = [0] * n + 1
  for i in range(1,n + 1):
    left[i] = gcd(left[i - 1], a[i - 1])
  for i in range(n - 1, 0, -1):
    right[i] = gce(right[i + 1], a[i])
  max_gcd = 0
  for i range(n):
    max_gcd = max(max_gcd, gcd(left[i], right[i]))
  print max_gcd
        
if __name__ == '__main__':
    solve()

### FIXED CODE ###

def gcd(x, y):
  while(y): 
       x, y = y, x % y   
  return x 

def solve():
  n = int(raw_input())
  a = map(int, raw_input().split())
  left = [0] * (n + 1)
  right = [0] * (n + 1)
  for i in range(1,n + 1):
    left[i] = gcd(left[i - 1], a[i - 1])
  for i in range(n - 1, 0, -1):
    right[i] = gcd(right[i + 1], a[i])
  max_gcd = 0
  for i in range(n):
    max_gcd = max(max_gcd, gcd(left[i], right[i + 1]))
  print max_gcd
        
if __name__ == '__main__':
    solve()
import collections
import math

n = int(input())

m = list(map(str,input().split()))

c = dict(collections.Counter(m))
d = {}
sets = {}
def ans(a):
    if a<2:
        return 0
    else:
        return math.factorial(a) // (math.factorial(a - 2) * math.factorial(2))

for i in m:
    if i in sets:
        print(sets[i])
    else:
        cnt = 0
        for j,k in c.items():
            if j == i:
                if k - 1 >= 2:
                    d.clearsetdefault(j, ans(k-1))
                    cnt += d[j]
                
                else:
                    d.setdefault(j, ans(k))
                    cnt += d[j]
                    sets[i] = cnt
        print(cnt)

### FIXED CODE ###

import collections
import math

n = int(input())

m = list(map(str,input().split()))

c = dict(collections.Counter(m))
d = {}
hyouji = {}
def ans(a):
    if a<2:
        return 0
    else:
        return math.factorial(a) // (math.factorial(a - 2) * math.factorial(2))

cnt = 0
for i,j in c.items():
    n = ans(j)
    d[i] = n
    cnt += n


for k in m:
    if k in hyouji:
        print(hyouji[k])
    else: 
        if c[k] < 2:
            q = cnt
        elif c[k] == 2:
            q = cnt - 1
        else:
                q = cnt -d[k] + ans(c[k] - 1)

        hyouji[k] = q
        print(hyouji[k])
n,m=map(int,input().split())
d=[1]*(n+1)
for i in range(m):
    d[int(input())]=0
for i in range(n+1):
    if i >1:
        d[i]=(d[i-1]+d[i-2]%(10**9+7))*d[i]
print(d[n+1])

### FIXED CODE ###

n,m=map(int,input().split())
D=[1] * (n + 1)
for _ in range(m):
    D[int(input())] = 0
for i in range(n+1):
    if i > 1:
        D[i] = (D[i-1] + D[i-2]) % 1000000007 * D[i]
print(D[i])
N = int(input())
A = list(map(int, input().split()))

X = [-1, -1, -1]
ans = 1
for a in A:
    t = X.count(a-1)
    ans = ans * t % 1000000007
    if a-1 not in X:
        print(0)
        exit()
    idx = X.index(a-1)
    X[idx] += 1
print(ans)


### FIXED CODE ###

T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

P = (A1 - B1) * T1
Q = (A2 - B2) * T2

if P > 0:
    P *= -1
    Q *= -1

if P + Q < 0:
    print(0)
elif P + Q == 0:
    print('infinity')
else:
    S, T = divmod(-P, P+Q)
    if T != 0:
        print(S * 2 + 1)
    else:
        print(S * 2)
a=[]
a = list(map(int,input().split()))
if a[1] <= a[0]:
  b=(a[0]-a[1])*a[3]+a[1]*a[2]
else:
  b=a[0]*a[2]
print(b)

### FIXED CODE ###

a=[int(input()) for i in range(4)]
if a[0]>a[1]:
  b=(a[0]-a[1])*a[3]+a[1]*a[2]
else:
  b=a[0]*a[2]
print(b)
s = input()
for i in range(len()s):
  if i % 2 == 0 and s[i] == "R":
    print("No")
    exit()
  elif i % 2 == 1 and s[i] == "L":
    print("No")
    exit()
print("Yes")

### FIXED CODE ###

s = input()
for i in range(len(s)):
  if i % 2 == 0 and s[i] == "L":
    print("No")
    exit()
  elif i % 2 == 1 and s[i] == "R":
    print("No")
    exit()
print("Yes")
#! python3
#  solve_133B.py

import math

def dis(Y,Z):
    ans = 0
    for i in range(len(Y)):
        ans += (Y[i] - Z[i])**2
    return math.sqrt(ans)


N,D = map(int,input(().split()))
X = []
ans = 0

for i in range(N):
    X.append(list(map(int,input().split())))

for i in range(N):
    for j in range(i,N):
       if dis(i,j) % 1 == 0:
           ans += 1

print(ans)

### FIXED CODE ###

#! python3
#  solve_133B.py

import math



N,D = map(int,input().split())
X = []
ans = 0


def dis(Y,Z):
    ans = 0
    for i in range(D):
        ans += (Y[i] - Z[i])**2
    return math.sqrt(ans)

for i in range(N):
    X.append(list(map(int,input().split())))

for i in range(N):
    for j in range(i+1,N):
       if dis(X[i],X[j]) % 1 == 0:
           ans += 1

print(ans)
#D
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
heapq.heapify(a)
tmp = 0
for i in range(m):
    b,c = map(int,input().split())
    for j in range(b):
        if c >= tmp
            p = heapq.heappop(a)
            if c > p:
                heapq.heappush(a,c)
            else:
                heapq.heappush(a,p)
                tmp = p
                break
            
            tmp = p
            
print(sum(a))

### FIXED CODE ###

#D
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = []
for i in range(m):
    b,c = map(int,input().split())
    bc.append((b,c))
bc.sort(key=lambda x:-x[1])
heapq.heapify(a)
for i in range(m):
    b,c = bc[i][0],bc[i][1]
    for j in range(b):
        p = heapq.heappop(a)
        if c > p:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,p)
            break
            
            
print(sum(a))
n = int(input())

print((n(n-1)//2))

### FIXED CODE ###

n = int(input())

print((n*(n-1)//2))
def input_from_console():
    n = int(input().strip())
    h_list = list(map(int, input().split()))
    return n, h_list


def solve(n, h_list):
    dp = [-1] * (n+2)
    dp[0] = 0
    dp[1] = abs(h_list[1]- h_list[0])
    def dp_solve(i):
        if dp[i] != -1:
            return dp[i]
        dp[i] = min(
            dp_solve(i-1) + abs(h_list[i] - h_list[i-1]),
            dp_solve(i-2) + abs(h_list[i] - h_list[i-2]),
        )
        return dp[i]
    return dp_solve(n-1)


def main():
    n, h_list = input_from_console()
    print(solve(n, h_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000)

def input_from_console():
    n = int(input().strip())
    h_list = list(map(int, input().split()))
    return n, h_list


def solve(n, h_list):
    dp = [-1] * (n+2)
    dp[0] = 0
    dp[1] = abs(h_list[1]- h_list[0])
    def dp_solve(i):
        if dp[i] != -1:
            return dp[i]
        dp[i] = min(
            dp_solve(i-1) + abs(h_list[i] - h_list[i-1]),
            dp_solve(i-2) + abs(h_list[i] - h_list[i-2]),
        )
        return dp[i]
    return dp_solve(n-1)


def main():
    n, h_list = input_from_console()
    print(solve(n, h_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()
import math
x = 0
y = 0
while True:
    m, r = map(int, raw_input())
    if m == 0 and r == 0:
        break
    theta += r
    rad = theta/180*math.pi
    x += m*math.cos(rad)
    y += m*math.sin(rad)
    
print int(x)
print int(

### FIXED CODE ###

import math
x = 0.0
y = 0.0
theta = 90.0
while True:
    m, r = map(int, raw_input().split(","))
    if m == 0 and r == 0:
        break
    rad = theta/180*math.pi
    x += m*math.cos(rad)
    y += m*math.sin(rad)
    theta += -r
    
print int(x)
print int(y)
def countAB(S):
  ct=0
  flg = True
  pos=0
  while flg:
    idx = S.find('AB',pos)
    if idx!=-1:
      ct+=1
    else:
      flg = False
    pos = idx + 2
  return ct

N = int(input())

num_AB = 0
num_A = 0
for n in range(N):
  S = input()
  num_AB += countAB(S)
  if S[len(S)-1]=='A':
    num_A += 1
  if S[0]=='B':
    num_B += 1

num_AB_cmb = min(num_A,num_B)
if num_A == N and num_B == N:
  num_AB_cmb = N-1

print("{0}".format(num_AB + num_AB_cmb))
  
  
  

### FIXED CODE ###

def countAB(S):
  ct=0
  flg = True
  pos=0
  while flg:
    idx = S.find('AB',pos)
    if idx!=-1:
      ct+=1
    else:
      flg = False
    pos = idx + 2
  return ct
 
N = int(input())
 
num_AB = 0
num_A = 0
num_B = 0
num_BA = 0
for n in range(N):
  S = input()
  num_AB += countAB(S)
  if S[len(S)-1]=='A':
    num_A += 1
  if S[0]=='B':
    num_B += 1
  if S[len(S)-1]=='A' and S[0]=='B': 
    num_BA += 1
    
num_AB_cmb = min(num_A,num_B)
if num_A == num_BA and num_B == num_BA and num_BA!=0:
  num_AB_cmb = num_BA-1
 
print("{0}".format(num_AB + num_AB_cmb))
a=int(input())
p=list[]
c=list['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
b=input()
for i in c:
  if i==b:
    if a+c[i]>25:
      z=a+c[i]-25
      p=c[z]
    else:
    
      z=c[i]+a
      p=c[z]
  else:
    pass
print(p)    


### FIXED CODE ###

N=int(input())
S=list(input())
a=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
res=''

for s in S:
  code=a.index(s)+N
  if code>a.index('Z'):
    code-=26
  res+=a[code]
print(res)
a,b,c,k = list(map(int, input().split()))

ans = 0

while(k > 0):
  {
    if (a != 0)
      a-=1
      ans+=1
      k-=1
    if (a == 0 & b > 0){
      b-=1
      k-=1
    }
    if (a == 0 & b == 0 & c > 0) {
      c-=1
      ans-=1
      k-=1
    }
  }
print(ans)

### FIXED CODE ###

a,b,c,k = list(map(int, input().split()))

ans = 0

if a >= k:
  print(k)
elif a+b >=k:
  print(a)
else:
  print(a-(k-a-b))
def main():
    N = int(input())
    A = list(map(int, input().split()))

    c = [0] * (100000 + 1)
    for ai in A:
        c[ai+1] += 1
        c[ai] += 1
        c[ai+2] += 1

    print(max(c))

if __name__ == "__main__":
    main()

### FIXED CODE ###

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

    c = [0] * (100000 + 1)
    for ai in A:
        c[ai] += 1

    ans = 0
    for i in range(len(c) - 2):
        ans = max(ans, c[i] + c[i+1] + c[i+2])
    print(ans)

if __name__ == "__main__":
    main()
import numpy as np

def main():
    N, M, C = np.array([int(x) for x in input().split(' ')])
    b_arr = np.array([int(x) for x in input().split(' ')])
    a_mat = np.zeros((N,M))

    for i in range(N):
        a_mat[i] = np.array([int(x) for x in input().split(' ')])

    #print ( len(list( np.where( a_mat.dot(b_arr)> -C ) )[0]) )        
    print ( np.array(np.where(a_mat.dot(b_arr) > -C)).shape[1] )

if __name__ == '__main__':
    main()


### FIXED CODE ###

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

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

print(res)
H, W, A, B = map(int, input().split())
if H==1:
    print("".join(map(str,[1]*A+[0]*(W-A))))
elif W==1:
    for i in [1]*B+[0]*(H-B):
        print(i)
elif W%A==0 and H%B==0:
    a, b = 0, 0
    l = [[0]*W for _ in range(H)]
    while B*b<H and A*a<W:
        for i in range(A):
            for j in range(B):
                l[a+i][b+j] = 1
        a += 1
        b += 1
    for i in l:
        print("".join(map(str,i)))
else:
    print("No")

### FIXED CODE ###

H, W, A, B = map(int, input().split())
l = [[0]*W for _ in range(H)]

for i in range(B):
    for j in range(A):
        l[i][j] = 1

for i in range(B, H):
    for j in range(A, W):
        l[i][j] = 1

for i in l:
    print("".join(map(str, i)))
import sys
readline = sys.stdin.readline
def LPP():
    n, m = map(int, readline().split())
    edges = [[] for _ in range(n)]
    for _ in range(m):
        s, t = map(int, readline().split())
        s -= 1
        t -= 1
        edges[s].append(t)
    dp = [-1]*n
    def dfs(s):
        if dp[s] != -1:
            return dp[s]
        if len(edges[s]) == 0:
            dp[s] = 0
            return 0
        res = 0
        for t in edges[s]:
            res = max(res, dfs(t)+1)
        dp[s] = res
        return res
    for i in range(n):
        dfs(i)
    return max(dp)





print(LPP(), end="")



### FIXED CODE ###

import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**7)
def LPP():
    n, m = map(int, readline().split())
    edges = [[] for _ in range(n)]
    for _ in range(m):
        s, t = map(int, readline().split())
        s -= 1
        t -= 1
        edges[s].append(t)
    dp = [-1]*n
    def dfs(s):
        if dp[s] != -1:
            return dp[s]
        if len(edges[s]) == 0:
            dp[s] = 0
            return 0
        res = 0
        for t in edges[s]:
            res = max(res, dfs(t)+1)
        dp[s] = res
        return res
    for i in range(n):
        dfs(i)
    print(max(dp),end="")

LPP()
k,s = list(map(int,input().split()))
ans = 0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z = s:
        ans += 1
print(ans)

### FIXED CODE ###

k,s = list(map(int,input().split()))
ans = 0
for x in range(k+1):
  for y in range(k+1):
    if s-x-y < k+1 and s-x-y >= 0:
      ans += 1
print(ans)