Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

inputs = [int(x) for x in input().split()]
sumAns = 0

while(inputs[3] > 0):
	if inputs[0] > 0:
		sumAns = sumAns + 1
		inputs[0] = inputs[0] - 1
		inputs[3] = inputs[3] - 1
	elif inputs[1] > 0:
		inputs[1] = inputs[1] - 1
		inputs[3] = inputs[3] - 1
	elif inputs[2] > 0:
		sumAns = sumAns - 1
		inputs[2] = inputs[2] -1
		inputs[3] = inputs[3] - 1
print(sumAns)

### FIXED CODE ###

inputs = [int(x) for x in input().split()]
sumAns = 0

if inputs[0] > inputs[3]:
	sumAns = sumAns + inputs[3]
	inputs[3] = 0
else:
	sumAns = sumAns + inputs[0]
	inputs[3] = inputs[3] - inputs[0]

if inputs[1] > inputs[3]:
	inputs[3] = 0
else:
	inputs[3] = inputs[3] - inputs[1]

if inputs[2] > inputs[3]:
	sumAns = sumAns - inputs[3]
	inputs[3] = 0
else:
	sumAns = sumAns - inputs[3]
	inputs[3] = inputs[3] - inputs[2]

print(sumAns)
### BUGGY CODE ###

n = int(input())
numlist = [int(_) for _ in input().split()]
setnum = set(numlist)
dicnum = {}
nsum = 0

for i in setnum:
    dicnum[i] = numlist.count(i)

for l in setnum:
    cal = dicnum[l]
    if cal >= 2:
        nsum += cal*(cal-1)//2
    
for j in range(n):
    ans = nsum
    dicpos = numlist[j]
    cal2 = dicnum[dicpos]
    if cal2 >= 2:
        ans = ans - (cal2-1)
    print(ans)

### FIXED CODE ###

n = int(input())
numlist = [int(_) for _ in input().split()]
numdic = {}
nsum = 0

for i in range(n):
    if numlist[i] in numdic:
        numdic[numlist[i]] += 1
    else:
        numdic[numlist[i]] = 1

for k in numdic:
    nsum += numdic[k] * (numdic[k] - 1) // 2

for j in range(n):
    ans = nsum
    cal = numdic[numlist[j]]
    if cal >= 2:
        ans = ans - (cal-1)
    print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n, k = map(int, input().split())
array = list(map(int, input().split()))
dp = [float('inf')]*n
dp[0] = 0
for i in range(1, n):
  for j in range(1, k+1):
    #print(i, j, dp)
    if j > i:
      continue
    dp[i] = min(dp[i-j] + abs(array[i]-array[i-j]), dp[i])
print(dp[-1])

### FIXED CODE ###

import sys
import numpy as np
# inputを高速化する。
input = sys.stdin.readline
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
# dpの配列を作る。
dp = np.zeros(n, dtype=int)
# hの配列を作る。
h = np.array(h)
for i in range(1, n):
    # start は負になることはない。
    start = max(0, i-k)
    # 行列として足し算できるのでforを使う必要がない。
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))
print(dp[n-1])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N: int, A: "List[int]"):
    mLEN = len(format(max(A),'b'))
    bA = [[0]*N for _ in range(mLEN)]

    for i in range(N):
        a = format(A[i],'b').zfill(mLEN)
        for k in range(mLEN):
            bA[k][i] = a[k]

    answer = 0
    for keta in range(mLEN):
        zero = bA[keta].count('0')
        one = N-zero
        a = 0

        for i in range(N):
            if bA[keta][i] == '1':
                one -= 1
            else:
                zero -= 1

            if bA[keta][i] == '1':
                a += zero
            else:
                a += one
        answer += a*2**(mLEN-1-keta)
        answer %= MOD
    
    print(answer%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import numpy as np

MOD = 1000000007  # type: int

def solve(N: int, A: "List[int]"):
    mLEN = len(format(max(A),'b'))

    A = np.array(A)
    ans = 0
    d = 1
    while d < (1 << mLEN):
        cnt = np.count_nonzero(A & d)
        ans += (N - cnt) * cnt * d
        ans %= MOD
        d <<= 1
    print(ans)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

t = int(input())
arr = [int(x) for x in input().split()]
n = 1
flag = True
for i in range(t):
    n *= arr[i]
    if n > 10**18:
        flag = False
    else:
        flag = True
if flag:
    print(n)
else:
    print(-1)


### FIXED CODE ###

t = int(input())
arr = [int(x) for x in input().split()]
n = 1
flag = True
if 0 in arr:
    print(0)
else:
    for i in range(t):
        n *= arr[i]
        if n > 10**18:
            flag = False
            break
    if flag:
        print(n)
    else:
        print(-1)
### BUGGY CODE ###

N, K = map(int,input().split())
H = list(map(int,input().split()))
DP = [0]*N
for i in range(1,N):
  Hi = H[i]
  DP[i] = min( [DP[j] + abs(Hi - H[j]) for j in range(max(0,i-K),i)])
print(DP[-1])

### FIXED CODE ###

N, K = map(int,input().split())
H = list(map(int,input().split()))
import numpy as np
dp = np.zeros(N,dtype=np.int)
harr = np.array(H)
for i in range(1,N):
  St = max(0,i-K)
  Hi = harr[i]
  dp[i] = min(dp[max(0,i-K):i] + np.abs(Hi - harr[max(0,i-K):i]))
print(dp[-1])
### BUGGY CODE ###

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

ans = []  
 
def check(bs, pre):
  tmp = pre[:]
  if len(bs) == 0:
    ans.append(tmp)
    return
  cand = []
  for i, b in enumerate(bs):
    if i + 1 == b:
      cand.append(i)
  if len(cand) == 0:
    return
  for i in cand:
    check(bs[:i] + bs[i+1:], [i + 1] + tmp)

check(bs, [])

if len(ans):
  for ai in ans[0]:
    print(ai)
else:
  print(-1)

### FIXED CODE ###

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

ans = []  
 
def check(bs, pre):
  tmp = pre[:]
  if len(bs) == 0:
    ans.append(tmp)
    return
  cand = []
  for i, b in enumerate(bs):
    if i + 1 == b:
      cand.append(i)
  if len(cand) == 0:
    return
  i = cand[-1]
  check(bs[:i] + bs[i+1:], [i + 1] + tmp)

check(bs, [])

if len(ans):
  for ai in ans[0]:
    print(ai)
else:
  print(-1)
### BUGGY CODE ###

def solve():
    N, T = tuple(map(int, input().split()))
    AS = tuple(map(int, input().split()))

    # print(N, T)
    # print(AS)

    m = -float('inf')
    c = 0
    for i in range(len(AS)):
        for x in range(i + 1, len(AS)):
            # max が見つかったら max を更新し, counter を 1 にリセット
            d = AS[x] - AS[i]
            if m < d:
                m = d
                c = 1
            elif m == d: # max と同じ値なら counter を ++
                c += 1
    
    return c


if __name__ == '__main__':
    res = solve()
    print(res)


### FIXED CODE ###

import heapq

def solve():
    N, T = tuple(map(int, input().split()))
    AS = tuple(map(int, input().split()))

    # print(N, T)
    # print(AS)

    lis = []
    D = {}

    m = -float('inf')
    c = 0
    for i in range(len(AS) - 1, -1, -1):
        x = AS[i]
        heapq.heappush(lis, -x)
        D[i] = -lis[0]

    for i in range(len(AS)):
        x = AS[i]

        d = D[i] - AS[i]
        if d > 0:
            if m < d:
                m = d
                c = 1
            elif m == d:  # max と同じ値なら counter を ++
                c += 1

    return c


if __name__ == '__main__':
    res = solve()
    print(res)
### BUGGY CODE ###

N,M = tuple(map(int,input().split()))
matchlist = [tuple(map(int,input().split())) for i in range(M)]
#最大のグループの大きさを出す
friendlist = [[i+1] for i in range(N)]

def match(a,b):
    for i,friends in enumerate(friendlist):
        if a in friends:
            ia = i
        if b in friends:
            ib = i
    if ia == ib:
        return
    else:
        friendlist[ia].extend(friendlist[ib])
        friendlist.remove(friendlist[ib])

for i in range(M):
    match(matchlist[i][0],matchlist[i][1])

print(max([len(item) for item in friendlist]))

### FIXED CODE ###

N,M = tuple(map(int,input().split()))
# matchlist = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]
#最大のグループの大きさを出す
friendlist = list(range(N))
# [所属先,[所属メンバー]]
gplist = [[i] for i in range(N)]

def getgroup(a):
    A = friendlist[a]
    if A == a:
        return a
    else:
        return getgroup(A)

def match(ab):
    A = getgroup(ab[0])
    B = getgroup(ab[1])
    if A==B:
        return
    elif len(gplist[A])<len(gplist[B]):
        gplist[B].extend(gplist[A])
        friendlist[A] = B
    else:
        gplist[A].extend(gplist[B])
        friendlist[B] = A

for i in range(M):
    # print(friendlist)
    # print(gplist)
    match(tuple(map(lambda x:int(x)-1,input().split())))

# print(friendlist)
# print(gplist)

print(max([len(item) for item in gplist]))
### BUGGY CODE ###

from itertools import accumulate

def main():
    N, K = map(int, input().split())
    As = list(map(int, input().split()))
    
    dp = [0] * (K+1)
    dp[0] = 1
    nonzeros = [set([0])]
    for a in As:
        ndp = []
        nonzero = set()
        for i in range(K+1):
            t = dp[i] if i < a else dp[i] + dp[i-a]
            if t == 0:
                ndp.append(0)
            else:
                nonzero.add(i)
                ndp.append(1)
        nonzeros.append(nonzero)
        dp = ndp
    
    dp = [0] * (K+1)
    dp[0] = 1
    accs = [list(accumulate(dp)) + [0]]
    for a in reversed(As):
        ndp = []
        for i in range(K+1):
            t = dp[i] if i < a else dp[i] + dp[i-a]
            ndp.append(0 if t == 0 else 1)
        dp = ndp
        accs.append(list(accumulate(dp)) + [0])
    
    ans = 0
    for i in range(1, N+1):
        a = As[i-1]
        if a >= K:
            continue
        nonzero = nonzeros[i-1]
        acc = accs[N-i]
        for y in nonzero:
            t = K-y-a-1
            if acc[K-y-1] > acc[t if t >= 0 else -1]:
                break
        else:
            ans += 1
    print(ans)

main()


### FIXED CODE ###

from itertools import accumulate

def main():
    N, K = map(int, input().split())
    As = list(map(int, input().split()))
    
    nonzeros = [1]
    for a in As:
        ndp = nonzeros[-1]
        if a <= K:
            ndp |= (nonzeros[-1] % (1 << (K-a))) << a
        nonzeros.append(ndp)
    dp = [0] * (K+1)
    dp[0] = 1
    acc = list(accumulate(dp)) + [0]
    ans = 0
    for i in range(N, 0, -1):
        a = As[i-1]
        ndp = []
        for j in range(K+1):
            t = dp[j] if j < a else dp[j] + dp[j-a]
            ndp.append(0 if t == 0 else 1)
        dp = ndp
        if a < K:
            nonzero = nonzeros[i-1]
            for y in range(K+1):
                if nonzero & 1:
                    t = K-y-a-1
                    if acc[K-y-1] > acc[t if t >= 0 else -1]:
                        break
                nonzero >>= 1
            else:
                ans += 1
        acc = list(accumulate(dp)) + [0]
    
    print(ans)

main()
### BUGGY CODE ###

N, M = map(int, input().split())
lista = []
for m in range(M):
    am = int(input())
    lista. append(am)
listans = [0]*N 
for n in range(N):
    if n+1 in lista:
        pass
    elif n == 0:
        listans[0] = 1
    elif n == 1:
        listans[1] = listans[0]+1
    else:
        listans[n] = listans[n-1]+listans[n-2]    
#print(listans)       
ans = listans[N-1]%1000000007 
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
lista = []
for m in range(M):
    am = int(input())
    lista.append(am)
lista.append(0)    
an = 0
an1 = 1 
for n in range(N):
    if n+1 == lista[0]:
        del lista[0]
        #print(lista)
        an, an1 = an1, 0
    else:
        an, an1 = an1, (an+an1)%1000000007
print(an1)
### BUGGY CODE ###

import sys

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

ans = 1
for a in a_list:
  if a == 0:
    print(0)
    sys.exit()
  
  if a > 1000000000000000000:
    print(-1)
    sys.exit()
  
  ans *= a
 
if ans > 1000000000000000000:
  print(-1)
else:
  print(ans)


### FIXED CODE ###

import sys

n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)

if a_list[-1] == 0:
  print(0)
  sys.exit()

if a_list[0] > 1000000000000000000:
  print(-1)
  sys.exit()

ans = 1
for a in a_list:
  ans *= a

  if ans > 1000000000000000000:
    print(-1)
    sys.exit()

print(ans)
### BUGGY CODE ###

import sys
t = 10**18

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

ans = 1
for i in range(n):
    ans = ans * li[i]

if ans > t:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

import sys

t = 10**18


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

if li.count(0) >= 1:
    print(0)
    sys.exit()

ans = 1
for i in range(n):
    ans = ans*li[i]
    if ans > t:
        print(-1)
        sys.exit()

print(ans)
### BUGGY CODE ###

from collections import deque
s = list(input())
q = int(input())
cnt = 0
s = deque(s)
for i in range(q):
    l = input().split()
    if l[0] == "1":
        s.reverse()
        continue
    if l[1] == "1":
        s.appendleft(l[2])
    else:
        s.append(l[2])
print(*s, sep="")

### FIXED CODE ###

s = input()
q = int(input())
t = ""
for i in range(q):
    que = input().split()
    if que[0] == "1":
        s, t = t, s
    else:
        if que[1] == "1":
            t += que[2]
        else:
            s += que[2]
print(t[::-1] + s)
### BUGGY CODE ###

k = int(input())
que = []
for i in range(k+9):
    if i < 9:
        que.append(i+1)
    else:
        x = que.pop(0)
        if x % 10 != 0:
            que.append(10*x+(x%10) -1)
        que.append(10*x+(x%10))
        if x % 10 != 9:
             que.append(10*x+(x%10) +1)
            
print(x)


### FIXED CODE ###

from collections import deque
k = int(input())
que = deque()
for i in range(k+9):
    if i < 9:
        que.append(i+1)
    else:
        x = que.popleft()
        if x % 10 != 0:
            que.append(10*x+(x%10) -1)
        que.append(10*x+(x%10))
        if x % 10 != 9:
             que.append(10*x+(x%10) +1)
            
print(x)
### BUGGY CODE ###

s = str(input())
k = int(input())
set_a = set()
for i in range(len(s)+1):
    for j in range(i+1,len(s)+1):
        set_a.add(s[i:j])
print(sorted(set_a)[k-1])

### FIXED CODE ###

s = input()
k = int(input())
set_a = set()
for i in range(len(s)+1):
    for j in range(i+1,min(len(s)+1,i+k+1)):
        set_a.add(s[i:j])
print(sorted(set_a)[k-1])
### BUGGY CODE ###

import sys 
input = sys.stdin.readline
 
 
n = int(input())
 
a= list(map(int,input().split())) 
 

if 0 in a:
    print(0)
    quit()
 
ans = 1
for i in a:
    ans *= i 
    
    if ans > 10**18:
        ans = -1

print(ans) 


### FIXED CODE ###

# import sys 
# input = sys.stdin.readline
 
 
n = int(input())
 
a= list(map(int,input().split())) 
 
def main(a):
    if 0 in a:
        print(0)
        return
     
    ans = 1
    for i in a:
        ans *= i 
        
        if ans > 1000000000000000000:
            print(-1)
            return
    
    print(ans)
    
main(a)
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))
a_m1 = list(map(lambda x: x-1, a))
a_p1 = list(map(lambda x:x+1, a))

ans = 0
for i in range(N):
  n = a[i]
  A = a.count(n) + a_m1.count(n) + a_p1.count(n)
  if ans < A:
    ans = A
print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.array(input().split(), dtype = np.int32)

counter = np.bincount(A)
B = counter.copy()
B[1:] += counter[:-1]
B[:-1] += counter[1:]

ans = B.max()
print(ans)
### BUGGY CODE ###

from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def comb(n,a):
    dend = n
    for i in range(1,a):
        dend = (dend*(n-i))%R
    sor = 1
    for i in range(2,a+1):
        sor = (sor*i)%R
    return (dend*modinv2(sor,R))%R

n,k = inm()
if n-1<=k:
    print(comb(2*n-1,n-1))
    exit()
sm = 0
for j in range(n-k,n+1):
    sm = (sm+comb(n,j)*comb(n-1,j-1))%R
print(sm)


### FIXED CODE ###

from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def comb(n,a):
    dend = n
    for i in range(1,a):
        dend = (dend*(n-i))%R
    sor = 1
    for i in range(2,a+1):
        sor = (sor*i)%R
    return (dend*modinv2(sor,R))%R

n,k = inm()
if n-1<=k:
    print(comb(2*n-1,n-1))
    exit()
c = [1]*(k+1)
d = [1]*(k+1)
for i in range(1,k+1):
    m = modinv2(i,R)
    c[i] = (c[i-1]*(n-i+1)*m)%R
    d[i] = (d[i-1]*(n-i)*m)%R
ddprint("c,d")
ddprint(c)
ddprint(d)
sm = 0
#for j in range(n-k,n+1):
#    sm = (sm+comb(n,j)*comb(n-1,j-1))%R
for j in range(k+1):
    sm = (sm+c[j]*d[j])%R
if k==1:
    sm = (sm-1)%R
print(sm)
### BUGGY CODE ###

wfwfe=input()

b=input().split()

b=[int(p) for p in b]

count=1
for i in b:
    count=count*i
if count>10**18:
    print (-1)
else:
    print (count)


### FIXED CODE ###

wfwfe=input()
check=0
b=input().split()
if "0" in b:
    print (0)
else:
    
    count=1
    for i in b:
        count=count*int(i)
        
        if count>10**18:
            print (-1)
            check=1
            break
    if check==0:
        print (count)
### BUGGY CODE ###

S = str(input())
s = len(S)
cnt = 0
A = []
for i in range(s):
  A.append(int(S[i:])%2019)

for i in range(s-1):
  for j in range(i+1,s):
    if (A[i]-A[j])%2019 == 0:
      cnt += 1
for i in range(s):
  if A[i]%2019 ==0:
    cnt += 1
print(cnt)


### FIXED CODE ###

S = str(input())
s = len(S)
cnt = 0
A = [0]*2019
r = 0
for i in range(s):
  x = (r+pow(10, i, 2019)*int(S[s-i-1]))%2019
  A[x] += 1
  r = x
  
for i in range(1,2019):
  if A[i] >= 2:
    cnt += A[i]*(A[i]-1)//2
cnt += A[0]*(A[0]+1)//2

print(cnt)
### BUGGY CODE ###

n = int(input())
x = list(map(int, input().strip().split()))
sum=0
for i in range(0,n-1):
    x[i] %= (10**9+7)
    minsum=0
    for j in range(i+1,n):
        minsum += x[j]
        if(minsum>=1000000007):
            minsum-=1000000007
    sum += x[i]*minsum
sum%=1000000007
print(sum)

### FIXED CODE ###

n = int(input())
x = list(map(int, input().strip().split()))
sum=0
minsum=0
for i in range(0,n):
    minsum += x[i]
for i in range(0,n-1):
    minsum-=x[i]
    sum += x[i]*minsum
    if(sum>10**9+7):
        sum%=(10**9+7)
print(sum)
### BUGGY CODE ###

from collections import deque
def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
      #queueには訪れた地点が入っている。そこから、4方向に移動できるか考え、queueから消す。
        y, x = queue.popleft()#queueに入っていたものを消す。
        if [y, x] == [gy, gx]:#もしゴールについていたならば、そのときの手数を出す。
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
          p = 0
          for l in range(1, K + 1):
            if p == 0:
              new_y, new_x = y + j * l, x + k * l #改行して条件文を続けるときにバックスラッシュ
              if (0 <= new_y < H) and (0 <= new_x < W): 
                if maze[new_y][new_x] == "@":
                  p = 1
                elif visited[new_y][new_x] == -1:#まだ来たことない点だったという条件
                  visited[new_y][new_x] = visited[y][x] + 1
                  queue.append([new_y, new_x])#新しい点を足す。
              else:
                p = 1

H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
x1, y1, x2, y2 = x1-1, y1-1, x2-1, y2-1
C = [0] * H
for i in range(H):
  C[i] = str(input())
visited = [[-1] * W for i in range(H)]
bfs(C, visited, x1, y1, x2, y2)
#print(visited)
print(visited[x2][y2])
  




### FIXED CODE ###

from collections import deque
def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
      #queueには訪れた地点が入っている。そこから、4方向に移動できるか考え、queueから消す。
        y, x = queue.popleft()#queueに入っていたものを消す。
        if [y, x] == [gy, gx]:#もしゴールについていたならば、そのときの手数を出す。
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
          p = 0
          l = 1
          while p == 0:
              new_y, new_x = y + j * l, x + k * l 
              if (0 <= new_y < H) and (0 <= new_x < W): 
                if maze[new_y][new_x] == "@":
                  p = 1
                elif visited[new_y][new_x] == -1:#まだ来たことない点だったという条件
                  visited[new_y][new_x] = visited[y][x] + 1
                  queue.append([new_y, new_x])#新しい点を足す。
                elif visited[new_y][new_x] < visited[y][x] + 1:
                  p = 1
              else:
                p = 1
              l += 1
              if l == K + 1:
                p = 1

H, W, K = map(int, input().split())
#K = min(K, max(H, W))
x1, y1, x2, y2 = map(int, input().split())
x1, y1, x2, y2 = x1-1, y1-1, x2-1, y2-1
C = [0] * H
for i in range(H):
  C[i] = str(input())
visited = [[-1] * W for i in range(H)]
bfs(C, visited, x1, y1, x2, y2)
#print(visited)
print(visited[x2][y2])
### BUGGY CODE ###

import sys
N,M=map(int, input().split())
a=[]
b=[]
c=[]
for m in range (0,M):
  A,B,C=map(int, input().split() )
  a+=[A]
  b+=[B]
  c+=[C]
V=[0]*N# iに到達するときの最大得点
moji=[1]+[0]*(N-1)#infなら0をかえす
 
for n in range(N-1):
  for m in range(M):
    u=a[m]
    v=b[m]
    if moji[a[m]-1]:#共に有限の時はやる
      if moji[b[m]-1]:
        V[b[m]-1]=max(V[b[m]-1],V[a[m]-1]+c[m])
      else:
        V[b[m]-1]=V[a[m]-1]+c[m]
        moji[b[m]-1]=1
 
moji2=[0]*N
for n in range(N):
  for m in range(M):
    u=a[m]
    v=b[m]
    if moji[a[m]-1]:#共に有限の時はやる
      if moji[b[m]-1]:
        if V[a[m]-1]+c[m]>V[b[m]-1]:
          V[b[m]-1]=V[a[m]-1]+c[m]
          moji2[b[m]-1]=1
    if moji2[a[m]-1]:
      moji2[b[m]-1]=1
if moji2[N-1]:
  print("inf")
else:
  print(V[N-1])

### FIXED CODE ###

import sys
N,M=map(int, input().split())
a=[]
b=[]
c=[]
for m in range (0,M):
  A,B,C=map(int, input().split() )
  a+=[A]
  b+=[B]
  c+=[C]
V=[0]+[-10**12]*(N-1)# iに到達するときの最大得点
 
for n in range(N-1):
  for m in range(M):
    u=a[m]
    v=b[m]
    if V[b[m]-1]<V[a[m]-1]+c[m]:#共に有限の時はやる
      V[b[m]-1]=V[a[m]-1]+c[m]
 
moji2=[0]*N
for n in range(N):
  for m in range(M):
    u=a[m]
    v=b[m]
    if V[b[m]-1]<V[a[m]-1]+c[m]:#共に有限の時はやる
      V[b[m]-1]=V[a[m]-1]+c[m]
      moji2[b[m]-1]=1
      if moji2[N-1]:
        print("inf")
        sys.exit()
print(V[N-1])
### BUGGY CODE ###

[N,L] = [int(x) for x in input().split()]
A = {}
B = [0]*N
ANS = {}
count = 0
for i,x in enumerate(input().split()):
    i = int(i)
    x = int(x)
    B[i] = x
    if x in A : A[x] += [i]
    else : A[x] = [i]
for i in range(10**9) :
    if i in A:
        for j in A[i] :
            for k in range(L) :
                if j + k not in ANS :
                    ANS[j+k] = i
                    count += 1
        if count > N * 0.99 - 1: break
    else:
        continue

for i in range(L):
    if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
    if i not in ANS : ANS[i] = min(B[i+1-L:i+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

#C - Low Elements
import numpy as np
x = int(input())
p = np.array(list(map(int, input().split())))

ans=0
while x >=1:
    p = p[0:x]
    x=np.argmin(p)
    ans=ans+1
print(ans)

### FIXED CODE ###

#C - Low Elements
import numpy as np
N = int(input())
P = np.array(list(map(int, input().split())))
min=P[0]
ans=1
for i in range(1,N):
    if min > P[i]:
        min = P[i]
        ans = ans +1
print(ans)