Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())

dp = [-1]*n
V = [[] for _ in range(n)]

for _ in range(m):
    x, y = map(int, input().split())
    V[x-1].append(y-1)

def f(x):
    if dp[x] != -1:
        return dp[x]

    t = 0
    for v in V[x]:
        t = max(t, f(v)+1)

    dp[x] = t
    return t

t = 0
for i in range(n):
    t = max(t, f(i))

print(t)


### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

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

dp = [-1 for _ in range(n)]
V = [[] for _ in range(n)]

for _ in range(m):
    x, y = map(int, input().split())
    V[x-1].append(y-1)

def f(x):
    if dp[x] != -1:
        return dp[x]

    t = 0
    for v in V[x]:
        t = max(t, f(v)+1)

    dp[x] = t
    return dp[x]

t = 0
for i in range(n):
    t = max(t, f(i))

print(t)
N ,M ,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = 0
b = 0
ans = 0
for k in range(len(A)):
    a += A[k]
    A[k] = a
for k in range(len(B)):
    b += B[k]
    B[k] = b

AA = [0] + A

BB = [0] + B

for k in range(N+1):
    if AA[k] <= K:
        for j in range(M+1):
            if  AA[k] + BB[j+1]> K >= AA[k] + BB[j]:
                ans = max(k+j, ans)
                break
            else:
                continue
    else:
        break
print(ans)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
print(sum(A)-min(A))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
if N % 2 == 0:
    d = int(N/2)
    print(A[0] + 2 * sum(A[1:d]))
else:
    b = int((N-1)/2)
    c = int((N-1)/2)
    print(A[0] + 2 * sum(A[1:b]) + A[c])
tmp = list(map(int, input().split()))
n = tmp[0]
m = tmp[1]
a = list(map(int, input().split()))

ha = []
for i in range(n):
  heapq.heappush(ha, a[i])

for j in range(m):
  tmp = list(map(int, input().split()))
  b = tmp[0]
  c = tmp[1]

  for k in range(b):
    if ha[0] < c:
      heapq.heappop(ha)
      heapq.heappush(ha, c)
    else:
      break

print(sum(ha))  

### FIXED CODE ###

import heapq

tmp = list(map(int, input().split()))
n = tmp[0]
m = tmp[1]
a = list(map(int, input().split()))

heapq.heapify(a)

cb = []
for j in range(m):
  tmp = list(map(int, input().split()))
  cb.append((tmp[1], tmp[0]))
cb.sort(reverse=True)

for j in range(m):
  if cb[j][0] < a[0]:
    break
  for k in range(cb[j][1]):
    if a[0] < cb[j][0]:
      heapq.heappop(a)
      heapq.heappush(a, cb[j][0])
    else:
      break

print(sum(a))
a=stdin.readline().rstrip()
x=a.count("1")
print(x)






### FIXED CODE ###

from sys import stdin
a=stdin.readline().rstrip()
x=a.count("1")
print(x)
Str = input()
if Str == 'A':
    print('T')
elif Str =='T':
    print('A')
elif Str =='C':
    print('G')
else:
    print(C)

### FIXED CODE ###

Str = input()
if Str == 'A':
    print('T')
elif Str =='T':
    print('A')
elif Str =='C':
    print('G')
else:
    print('C')
import sys
import math
import bisect

def main():
    s = input()
    if s == 'A':
        print('T')
    elif s == 'C':
        print('G')
    elif s == 'G'
        print('C')
    elif s == 'T':
        print('A')
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import math
import bisect

def main():
    s = input()
    if s == 'A':
        print('T')
    elif s == 'C':
        print('G')
    elif s == 'G':
        print('C')
    elif s == 'T':
        print('A')
    
if __name__ == "__main__":
    main()
import math

r = int(input())

print(r * r * math.pi, r * 2 * math.pi)

### FIXED CODE ###

import math
r = float(input())
p = math.pi

print('{0} {1:.6f}'.format(r * r * p, r * 2 * p))
all=set()
for i in ['S','H','C','D']:
    for j in range(1,14):
        all=all.add('{0} {1}'.format(str(i), str(j)))
n=input() .split()
while True:
    a=input().split()
    t += str(a[0])
    r =+ int(a[1])
all2=set()
for y in t:
    for u in r:
        all2 = all2.add('{0} {1}'.format(str(y),str(u))
print(all-all2)

### FIXED CODE ###

data = [
    "{0} {1}".format(s, r)
    for s in ('S', 'H', 'C', 'D')
    for r in range(1, 13 + 1)
    ]
 
count = int(input())
for c in range(count):
    card = input()
    data.remove(card)
 
for c in data:
    print(c)
d=int(input())
if d=25:
  print('Christmas')
elif:
  print('Christmas Eve')
elif:
  print('Christmas Eve Eve')
else:
  print('Christmas Eve Eve Eve')

### FIXED CODE ###

d=int(input())
if d==25:
  print('Christmas')
elif d==24:
  print('Christmas Eve')
elif d==23:
  print('Christmas Eve Eve')
else:
  print('Christmas Eve Eve Eve')
(N, Y) = map(int, input().split(" "))

ans = '-1 -1 -1'
for x in range(0, N+1):
    y = (Y / 1000 - 9 * x - N) / 4
    if 0 <= y <= N:
        if y.is_integer():
            y = int(y)
            z = N - x - y
            if 0 <= z <= N:
                ans = f'{x} {y} {z}'
                break
print(ans)


### FIXED CODE ###

(N, Y) = map(int, input().split(" "))

ans = '-1 -1 -1'
for x in range(0, N+1):
    y = (Y / 1000 - 9 * x - N) / 4
    if 0 <= y <= N:
        if y.is_integer():
            y = int(y)
            z = N - x - y
            if 0 <= z <= N:
                ans = " ".join([str(x), str(y), str(z)])
                break
print(ans)
n,k=map(int,input().split())
h=[]
for i in range(n):
    h.append(int(input()))
h.sort()

ans=9999999999999
for i in range(n-k+1):
    ans=min(ans,h[i+k-1]-h[i])
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
print(-(-(n-1)//(k-1)))
import numpy as np

_ = input()
data = list(map(int, input().split()))
p = np.prod(data)

if 10 ** 18 < p:
  print(-1)
else:
  print(p)

### FIXED CODE ###

a,b = map(int, input().split())
print(a*b)
N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
R=[0]*N
ans=10**9
def myadd(i):
    if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1
for i in range(N**4):
    myadd(0)
    if 1 in R and 2 in R and 3 in R:
        tmp=-6
        t1,t2,t3=0,0,0
        for j in range(N):
            if R[j]==0:
                continue
            if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
            tmp+=2
        tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3)
        ans=min(tmp,ans)
print(ans)

### FIXED CODE ###

N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
R=[0]*N
ans=10**9
def myadd(i):
    if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1
for i in range(4**N-1):
    myadd(0)
    if 1 in R and 2 in R and 3 in R:
        tmp=-30
        t1,t2,t3=0,0,0
        for j in range(N):
            if R[j]==0:
                continue
            if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
            tmp+=10
        tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3)
        ans=min(tmp,ans)
print(ans)
def gcd (num1,num2):
    tmp = max(num1,num2) % min(num1,num2)
    if tmp == 0:
        return min(num1,num2)
    return gcd(min(num1,num2),tmp)

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

for i in range(len(t)-1):
    stock.append(t[i] * t[i+1] / gcd(stock[i],t[i]))

print(stock[-1])

### FIXED CODE ###

n = int(input())
ans = int(input())
 
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a
 
def lcm(x,y):
    return (x*y//gcd(x,y))
 
for i in range(n-1):
    t = int(input())
    ans = lcm(ans,t)
print(ans)
def main():
    n, m = map(int, input().split())

    net = [[] for _ in range(n)]
    for _ in range(m):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        net[x].append(y)

    def longest(i, memo):
        if memo[i] >= 0:
            return memo[i]
        if len(net[i]) == 0:
            l = 0
        else:
            l = max(longest(j, memo) + 1 for j in net[i])
        memo[i] = l
        return l

    memo = [-1] * n
    l = max(longest(i, memo) for i in range(n))
    print(l)


main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)


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

    net = [[] for _ in range(n)]
    for _ in range(m):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        net[x].append(y)

    def longest(i, memo):
        if memo[i] >= 0:
            return memo[i]
        if len(net[i]) == 0:
            l = 0
        else:
            l = max(longest(j, memo) + 1 for j in net[i])
        memo[i] = l
        return l

    memo = [-1] * n
    l = max(longest(i, memo) for i in range(n))
    print(l)


main()
n, k = map(int, input())
if n%k:
    print(0)
else:
    print(1)


### FIXED CODE ###

n, k = map(int, input().split())
if n%k:
    print(1)
else:
    print(0)
in = input()

result = 999

for i in range(len(in)-2):
  if i == len(in) - 3:
    num = in[I:]
  else:
    num = in[i:i+3]

  sa = abs(753 - int(num))

  if sa < result:
    result = sa

print(result)


### FIXED CODE ###


inn = str(input())

result = 999

for i in range(len(inn)-2):
  if i == len(inn) - 3:
    num = inn[i:]

  else:
    num = inn[i:i+3]

  sa = abs(753 - int(num))

  if sa < result:
    result = sa

print(result)
n=input()
ck=0
for i in range(n//2):
  if not n[i]==n[-1-i]:
    ck+=1
if ck==0:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

n=input()
ck=0
for i in range(len(n)//2):
  if not n[i]==n[-1-i]:
    ck+=1
if ck==0:
  print('Yes')
else:
  print('No')
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
L, R = map(int, input().split())
ans = set(list(range(L, R+1)))
for i in range(M-1):
  L, R = map(int, input().split())
  ans = ans & set(list(range(L, R+1)))
  if len(ans) == 0:
    print(0)
print(len(ansN, M = map(int, input().split())
L = [0] * M
R = [0] * M
L, R = map(int, input().split())
for i in range(M-1):
  l, r = map(int, input().split())
print(R-l+1)
  


### FIXED CODE ###

N,M = map(int,input().split())
L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
ans = list(range(max(L),min(R)+1))
print(len(ans))
N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i : i+2] == 'AC' else 0)  
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])



### FIXED CODE ###

b = input()
if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'C':
    print('G')
else:
    print('C')
x = input()
def samenum(string):
  for i in range(3):
  	if string[i] == string[i+1]:
    	return "Bad"
  		quit()
  return "Good"

print(samenum(x))

### FIXED CODE ###

x = input()
def samenum(string):
  for i in range(3):
    if string[i] == string[i+1]:
        return "Bad"
        quit()
  return "Good"

print(samenum(x))
n, k, x, y = map(int, input())
print(x*min(n, k)+y*max(0, n-k))

### FIXED CODE ###

a = [int(input()) for i in range(4)]
print(a[2]*min(a[0],a[1])+max(0,(a[0]-a[1])*a[3]))
n = int(input())
apart = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for joho in range(n):
    x = [int(i) for i in input().split()]
    apart[x[2]][x[1]][x[0]] += x[3]

for tou in range(4):
    for stair in range(3):
        for room in range(10):
            print(" ",apart[tou][stair][room],sep="",end="")
        print("")
    if tou != 3:
        print("####################")



### FIXED CODE ###

n = int(input())
apart = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for joho in range(n):
    x = [int(i) for i in input().split()]
    apart[x[0]-1][x[1]-1][x[2]-1] += x[3]

for tou in range(4):
    for stair in range(3):
        for room in range(10):
            print(" ",apart[tou][stair][room],sep="",end="")
        print("")
    if tou != 3:
        print("####################")
a,b,x = map(int, input().split() )

x_s = str(x)
n = len(x_s)#桁数

cnt = 0

if(a * 1 + b > x):
  cnt = 0
elif( x >= a * 1000000000 + b * 10):
  cnt = 1000000000
else:
  for i in range( int(x//a), -1, -1 ):
    i_s = str(i)
    n = len(i_s)
    #print(a * i + b * n)
    if( a * i + b * n <= x ):
      cnt = i
      break
  

print(cnt)

### FIXED CODE ###

s = input()

cnt = 0

if( s == "SUN" ):
  cnt = 7
elif( s == "MON" ):
  cnt = 6
elif( s == "TUE" ):
  cnt = 5
elif( s == "WED" ):
  cnt = 4
elif( s == "THU" ):
  cnt = 3
elif( s == "FRI" ):
  cnt = 2
elif( s == "SAT" ):
  cnt = 1
  
print(cnt)
a,b,c=map(int,input().split())
if a*b < c:
  print(a*b)
else:
  pirnt(c)

### FIXED CODE ###

a,b,c=map(int,input().split())
if a*b < c:
  print(a*b)
else:
  print(c)
from math import gcd

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

t = []
d = {}
for a, b in AB:
    i = gcd(a, b)
    a //= i
    b //= i
    t.append((a, b))
    d.setdefault(a, {})
    d[a].setdefault(b, 0)
    d[a][b] += 1

used = set()
result = 1
for a, b in t:
    if (a, b) in used:
        continue
    used.add((a, b))
    i = d[a][b]
    j, k, l = 0, 0, 0
    if -a in d and -b in d[-a]:
        j = d[-a][-b]
        used.add((-a, -b))
    if -b in d and a in d[-b]:
        k = d[-b][a]
        used.add((-b, a))
    if b in d and -a in d[b]:
        l = d[b][-a]
        used.add((b, -a))
    result *= pow(2, i + j, 1000000007) + pow(2, k + l, 1000000007) - 1
    result %= 1000000007
print(result - 1)


### FIXED CODE ###

from math import gcd

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

t = []
d = {}
d[0] = {}
d[0][0] = 0
for a, b in AB:
    i = gcd(a, b)
    if i != 0:
        a //= i
        b //= i
    t.append((a, b))
    d.setdefault(a, {})
    d[a].setdefault(b, 0)
    d[a][b] += 1

used = set()
result = 1
for a, b in t:
    if (a, b) in used:
        continue
    used.add((a, b))
    if a == 0 and b == 0:
        continue
    i = d[a][b]
    j, k, l = 0, 0, 0
    if -a in d and -b in d[-a]:
        j = d[-a][-b]
        used.add((-a, -b))
    if -b in d and a in d[-b]:
        k = d[-b][a]
        used.add((-b, a))
    if b in d and -a in d[b]:
        l = d[b][-a]
        used.add((b, -a))
    result *= pow(2, i + j, 1000000007) + pow(2, k + l, 1000000007) - 1
    result %= 1000000007
result += d[0][0] - 1
result %= 1000000007
print(result)
s = int(input())
for i in range(s):
    if math.sqrt(s - i).is_integer():
        print(s - i)
        break

### FIXED CODE ###

import math
s = int(input())
for i in range(s):
    if math.sqrt(s - i).is_integer():
        print(s - i)
        break
import math
 
N = int(input())
A = list(map(int,input().split()))
L = [0] * N
R = [0] * N

for i in range(1, N):
    L[i] = math.gcd(L[i-1], A[i-1])
    R[-i-1] = math.gcd(R[-i], A[-i])

ans = [0] * N

for i in range(0, N):
    ans[i] = math.gcd(L[i], R[i])

print(max(ans))

### FIXED CODE ###

import fractions
 
N = int(input())
A = list(map(int,input().split()))
L = [0] * N
R = [0] * N

for i in range(1, N):
    L[i] = fractions.gcd(L[i-1], A[i-1])
    R[-i-1] = fractions.gcd(R[-i], A[-i])

ans = [0] * N

for i in range(0, N):
    ans[i] = fractions.gcd(L[i], R[i])

print(max(ans))
hoge_a=input()
hoge_b=input()
hoge_c=input()
tugi="A"
while 1:
  if(tugi=="A"):
    if(len(hoge_a)==0):
      print("A")
      break:
    if(hoge_a[0]=="a"):
      tugi=="A"
    if(hoge_a[0]=="b"):
      tugi=="B"
    if(hoge_a[0]=="c"):
      tugi=="C"
    hoge_a=hoge_a[1:]
      
  if(tugi=="B"):
    if(len(hoge_b)==0):
      print("B")
      break:
    if(hoge_b[0]=="a"):
      tugi=="A"
    if(hoge_b[0]=="b"):
      tugi=="B"
    if(hoge_b[0]=="c"):
      tugi=="C"
    hoge_b=hoge_b[1:]
      
  if(tugi=="C"):
    if(len(hoge_a)==0):
      print("C")
      break:
    if(hoge_c[0]=="a"):
      tugi=="A"
    if(hoge_c[0]=="b"):
      tugi=="B"
    if(hoge_c[0]=="c"):
      tugi=="C"
    hoge_c=hoge_c[1:]

### FIXED CODE ###

hoa=list(input())
hob=list(input())
hoc=list(input())
f="A"

while 1:
  if(f=="A" and len(hoa)==0):
    print(f)
    break
  elif(f=="B" and len(hob)==0):
    print(f)
    break
  elif(f=="C" and len(hoc)==0):
    print(f)
    break
  elif(f=="A"):
    if(hoa[0]=="a"):
      f="A"
      hoa=hoa[1:]
    elif(hoa[0]=="b"):
      f="B"
      hoa=hoa[1:]
    elif(hoa[0]=="c"):
      f="C"
      hoa=hoa[1:]
  elif(f=="B"):
    if(hob[0]=="a"):
      f="A"
      hob=hob[1:]
    elif(hob[0]=="b"):
      f="B"
      hob=hob[1:]
    elif(hob[0]=="c"):
      f="C"
      hob=hob[1:]
  elif(f=="C"):
    if(hoc[0]=="a"):
      f="A"
      hoc=hoc[1:]
    elif(hoc[0]=="b"):
      f="B"
      hoc=hoc[1:]
    elif(hoc[0]=="c"):
      f="C"
      hoc=hoc[1:]
N = int(input())
D = list(map(int,input().split()))
from collections import Counter
print(0)


### FIXED CODE ###

N = int(input())
import math
print(math.ceil(N/2)-1)
N, K = map(int, input().split())
A = list(map(int, input().split()))

"""
1からのループだけを考えれば良い

と思ったが，1に戻ってくるとは限らない
"""

i = A[0]
ok = True
R = [1]
seen = [0] * N
seen[0] = 1


while ok:
    seen[i-1] += 1
    R.append(i)
    i = A[i-1]
    if seen[i-1] == 1:
        for j in range(len(R)):
            if R[j] == i:
                remain = R[:j]
                loop = R[j:]
                ok = False

L = len(loop)

if K < len(remain):
    print(remain(K-1))
else:
    print(loop[(K - len(remain)) % L])

### FIXED CODE ###

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

"""
1からのループだけを考えれば良い
"""

i = A[0]
ok = True
R = [1]
seen = [0] * N
seen[0] = 1
count = 1

if A[0] == 1:
    print(1)
    exit()

while ok:
    count += 1
    seen[i-1] += count
    R.append(i)
    i = A[i-1]
    # 訪れたことがあれば
    if seen[i-1] != 0:
        k = seen[i-1]
        loop = R[k-1:]
        remain = R[:k-1]
        ok = False

L = len(loop)

if K < len(remain):
    print(remain[K])
else:
    print(loop[(K - len(remain)) % L])
N = int(input())


n = str(N)
a = n[-1]
b = n[-2]
c = n[-3]

A = int(a)+10*int(b)+100*int(c)

if 1000-A!=1000:
    print(1000-A)

else:
    print(0)

### FIXED CODE ###

N = int(input())


A = N%1000

if 1000-A!=1000:
    print(1000-A)

else:
    print(0)
t = 0
while t == 0:	
	try:
		a,b,c,d,e,f = [int(i) for i in input().split()]t = 0
	except:
		break
	else:
		x = (e*c - b*f) / (a*e - b*d)
		y = (a*f - c*d) / (a*e - b*d)
		print(???{0:.3f}".format(x) + ??? ??? + ???{0:.3f}".format(y))

### FIXED CODE ###

t = 0
while t == 0:	
	try:
		a,b,e,c,d,f = [int(i) for i in input().split()]
	except:
		break
	else:
		x = (d*e - b*f) / (a*d - b*c) + 0
		y = (a*f - c*e) / (a*d - b*c) + 0
		print("{0:.3f}".format(x) + " " + "{0:.3f}".format(y))
a,b,c = input().split()
print("YES" if a[-1] == b[0] && b[-1] == c[0] else "NO")

### FIXED CODE ###

a,b,c = input().split()
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")
a,b,c=map(int,input().split())

if a+b+c<=21:
  print(win)
else:
  print(bust)

### FIXED CODE ###

a ,b ,c= map(int,input().split())
if a+b+c<=21:
  	print('win')
else:
	print('bust')
import numpy as np
n, m = [int(i) for i in input().split()]
a =[]
d = 1000000007

for i in range(m):
    a1=int(input())
    a.append(a1)

a.append(n+1)
a = np.array(a)
#print(a)

if 1 in a[1:]-a[:-1]:
    print(0)

else:
    dp = [0]*100000
    dp[1]=1
    dp[2]=1
    for i in range(3,len(dp)):
        dp[i]=dp[i-1]+dp[i-2]
        #dp[i]=dp[i]%d

    ans = []
    pre = 0
    for i in range(len(a)):
        if i == 0:
            ans.append(a[i]-pre)
        else:
            ans.append(a[i]-pre-1)
        pre = a[i]

    #print(ans)
    x = 1
    for i in ans:
        x = x*dp[i]%d
    print(x)

### FIXED CODE ###

import numpy as np
n, m = [int(i) for i in input().split()]
a =[]
d = 1000000007

for i in range(m):
    a1=int(input())
    a.append(a1)

a.append(n+1)
a = np.array(a)
#print(a)

if 1 in a[1:]-a[:-1]:
    print(0)

else:
    dp = [0]*110000
    dp[1]=1
    dp[2]=1
    for i in range(3,len(dp)):
        dp[i]=dp[i-1]+dp[i-2]
        dp[i]=dp[i]%d

    ans = []
    pre = 0
    for i in range(len(a)):
        if i == 0:
            ans.append(a[i]-pre)
        else:
            ans.append(a[i]-pre-1)
        pre = a[i]

    #print(ans)

    if m == 0:
        print(dp[n+1])
    else:
        x = 1
        for i in ans:
            x = x*dp[i]%d
        print(x)
a_b = input().split(" ")
a = a_b[0]
b = a_b[1]
if a > b:
    print "a > b"
elif a < b:
    print "a < b"
else:
    print "a = b"

### FIXED CODE ###

a_b = raw_input().split(" ")
a = int(a_b[0])
b = int(a_b[1])
if a > b:
    print "a > b"
elif a < b:
    print "a < b"
else:
    print "a == b"
from heapq import heappush, heappop
N, K = map(int, input().split())
log = [0]*N
pre = []
ls = []
for i in range(N):
  t, d = map(int, input().split())
  t = t-1
  heappush(ls,(-d,t))
v = 0
n = 0
for i in range(K):
  d, t = heappop(ls)
  d = -d
  log[t] += 1
  v += d
  if log[t]>1:
    heappush(pre,(d,t))
  else:
    n += 1
v += n*n
ans = v
while ls:
  d, t = heappop(ls)
  if log[t]>0:
    continue
  log[t] += 1
  d = -d
  pv = v
  x, y = heappop(pre)
  v -= x
  v += d
  v += 2*n+1
  n += 1
  if ans<v:
    ans = v
print(ans)

### FIXED CODE ###

from heapq import heappush, heappop
N, K = map(int, input().split())
log = [0]*N
pre = []
ls = []
for i in range(N):
  t, d = map(int, input().split())
  t = t-1
  heappush(ls,(-d,t))
v = 0
n = 0
for i in range(K):
  d, t = heappop(ls)
  d = -d
  log[t] += 1
  v += d
  if log[t]>1:
    heappush(pre,(d,t))
  else:
    n += 1
v += n*n
ans = v
while ls and pre:
  d, t = heappop(ls)
  if log[t]>0:
    continue
  log[t] += 1
  d = -d
  pv = v
  x, y = heappop(pre)
  v -= x
  v += d
  v += 2*n+1
  n += 1
  if ans<v:
    ans = v
print(ans)
n = int(input())
#a,b = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
#print(li)
num = 0

for i in range(n-4):
    if li[i] == li[i+1] ==li[i+2] == li[i+3]:
        li.pop(li[i+3])
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if li[i]+li[j]>li[k] and li[i]<li[j]+li[k] and li[i]+li[k]>li[j]:
                num += 1
print(num)

### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))
li.sort()

num = 0
import bisect
for i in range(n):
    for j in range(i+1,n):
        num += bisect.bisect_left(li,li[i]+li[j])-(j+1)
print(num)
k = int(input())
s = input()
l = len(s)
if (k >= l):
    print(s)
else:
    print(s[:k] + "...")

### FIXED CODE ###

k = int(input())
s = input()
l = len(s)
if (l <= k):
    print(s)
else:
    print(s[:k] + "...")
x=input
print(x**3)

### FIXED CODE ###

a=input()
a=int(a)
a=a**3
print (a)
a=input()
c=0
for i in range(2):
  if a>=10**(2-i):
    a-10**(2-i)
    c+=1
print(c)

### FIXED CODE ###

a=input()
print(a.count('1'))
k = 31
K = 1<<k
nu = lambda L: int("".join([bin(K+a)[-k:] for a in L[::-1]]), 2)
st = lambda n: bin(n)[2:] + "0"
li = lambda s: [int(a, 2) if len(a) else 0 for a in [s[-(i+1)*k-1:-i*k-1] for i in range(1001)]]

N = int(input())
A = [int(a) for a in input().split()]
C = [0] * 1001
for a in A:
    C[a] += 1
B = li(st(nu(C) ** 2))
for a in A:
    if a <= 500: B[2*a] -= 1
for i in range(1001):
    B[i] //= 2
for i in range(1, 1001):
    C[i] += C[i-1]
for i in range(N):
    B[i] += B[i-1]
ans = N*(N-1)*(N-2)//6
for i in range(1, 1001):
    ans -= (N-C[i-1]) * B[i]
print(ans)


### FIXED CODE ###

N = int(input())
A = sorted([int(a) for a in input().split()])
X = [0] * 1001
for a in A:
    X[a] += 1
for i in range(1, 1001):
    X[i] += X[i-1]

ans = 0
for i in range(N):
    for j in range(i+1, N):
        ans += X[min(A[i]+A[j]-1, 1000)] - (j+1)
print(ans)
n = input()[::-1]
dp = [[0, 0] for i in range(len(n) + 1)]
dp[0][1] = 1
for i in range(len(n)):
    dp[i + 1][0] = min(dp[i][0] + int(n[i]), dp[i][1] - int(n[i]) + 10)
    dp[i + 1][1] = min(dp[i][0] + int(n[1]) + 1, dp[i][1] - int(n[i]) + 9)
print(dp[len(n)][0])

### FIXED CODE ###

n = input()[::-1]
dp = [[0, 0] for i in range(len(n) + 1)]
dp[0][1] = 1
for i in range(len(n)):
    dp[i + 1][0] = min(dp[i][0] + int(n[i]), dp[i][1] - int(n[i]) + 10)
    dp[i + 1][1] = min(dp[i][0] + int(n[i]) + 1, dp[i][1] - int(n[i]) + 9)
print(dp[len(n)][0])