Harryxun/stf_run huggingface dataset:
a = int(input())
b = 0
count = 0
for i in range(9):
  for j in range(9):
    if (i+1)*(j+1) == a:
      count += 1
      if count>0:
        if (c+d)>(i+1)+(j+1):
		  c = i+1
          d = j+1
      else :
        c = i+1
        d = j+1
ans = c+d-2
print 

### FIXED CODE ###

a = int(input())
b = 0
l = int(a**0.5)+1
count = 0
for i in range(l):
    i = i+1
    if a%i == 0:
        j = a//i
    if i*j == a:
        if count == 0:
            count += 1
            c = i
            d = j
        if count>0:
            if (c+d)>(i+j):
                c = i
                d = j
ans = c+d-2
print(ans)
def prod(array):
    res = 1
    for a, _ in array:
        res *= a
        res %= MOD
    return res

MOD = 10**9 + 7
N, K = map(int, input().split())
A = []
for a in map(int, input().split()):
    A.append((abs(a), a < 0))
A.sort(reverse=True)
sgn = 0
s0 = -1
lastA = -1
for i, p in enumerate(A[:K]):
    a, s = p
    sgn += s
    if s != s0 and lastA == -1:
        lastA = i-1
    s0 = s
if sgn%2==0:
    print(prod(A[:K])%MOD)
    exit()
if sgn + sum(s for _, s in A[K:])==N:
    print(-prod(A[-K:])%MOD)
    exit()
lasts = s
if lasts != A[K][1]:
    res = prod(A[:K-1])*A[K][0]
else:
    firstA = None
    for i, p in enumerate(A[K:],start=K):
        a, s = p
        if s != lasts:
            firstA = i
            break
    res1 = prod(A[:K-1])*A[firstA][0] if firstA is not None else -float("inf")
    res2 = prod(A[:lastA])*prod(A[lastA+1:K+1]) if lastA != -1 else -float("inf")
    res = max(res1, res2)
print(res%MOD)


### FIXED CODE ###

def prod(array):
    res = 1
    for a, _ in array:
        res *= a
        res %= MOD
    return res

MOD = 10**9 + 7
N, K = map(int, input().split())
if N==K:
    res = 1
    for a in map(int, input().split()):
        res *= a
        res %= MOD
    print(res)
    exit()
A = []
allsgn = 0
for a in map(int, input().split()):
    A.append((abs(a), a < 0))
    allsgn += a<0
A.sort(reverse=True)
sgn = 0
s0 = -1
lastA = -1
for i, p in enumerate(A[:K]):
    a, s = p
    sgn += s
    if s != s0:
        lastA = i-1
    s0 = s
lasts = s0
if allsgn==N:
    if K%2==1:
        print((-prod(A[-K:]))%MOD)
        exit()
    else:
        print(prod(A[:K])%MOD)
        exit()
if sgn%2==0:
    print(prod(A[:K])%MOD)
    exit()
if lasts != A[K][1]:
    res = prod(A[:K-1])*A[K][0]
else:
    firstA = None
    for i, p in enumerate(A[K:],start=K):
        a, s = p
        if s != lasts:
            firstA = i
            break
    if lastA == -1 or (firstA is not None and A[K][0]/A[lastA][0] < A[firstA][0]/A[K-1][0]):
        res = prod(A[:K - 1]) * A[firstA][0]
    else:
        res = prod(A[:lastA]) * prod(A[lastA + 1:K + 1])
print(res%MOD)
"""
6 3
5 -3 -3 -3 -3 -2

10 7
-10 -10 -10 -10 10 10 10 10 10 10
"""
n=int(input())
l=[int(x) for x in input().split()]
sum=0
n=len(l)
for i in range(0,n):
    if(i==0):
        if(l[i]>l[i+1]):
            sum=sum+(l[i]+l[i+1])
        else:
            sum=sum+(l[i]*2)
    elif(i==n-1):
        sum=sum+l[i]
    else:
        if(l[i]<=l[i+1]):
            sum=sum+l[i]
        else:
            sum=sum+l[i+1]
print(sum)
            
            
            

### FIXED CODE ###

import sys
import math

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def pro(k, l, n):
    if l < n:
        if k == 0:
            return(n - l)
        return (n - l + 2)
    if l == n:
        if k == 0:
            return 0
        elif k == 1:
            return 1
        return 3
    else:
        l -= n - 1
        if l == k:
            return 1
        elif l > k:
            return 0
        if l < k - 1:
            return 2
        else:
            return 3
            

def rt(k, l , n):
    if k < n:
        if l == 0:
            return (k * 2 + n)
        return (n + k * 2 - 1)
    elif k == n:
        if l == 1:
            return (k * 3 - 2)
        elif l == 0:
            return (k * 3)
        return (k * 3 - 3)
    else:
        k -= n - 1
        if k == l:
            return (n * 3 - 2)
        elif k > l:
            return (n * 3)
        if k < l - 1:
            return ((n - 1) * 3 - 1)
        else:
            return ((n - 1) * 3)



def main():
    n = iinput()
    a = rlinput()
    res = a[0] + a[-1]
    for i in range(n - 2):
        if a[i] > a[i + 1]:
            res += a[i + 1]
        else:
            res += a[i]
    print(res)
    
    
    
    
    


main()
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit(0)

waru = 998244353

dic = {}
dic2 = {}

for i in range(1, N+1):
    dic[i] = D[i-1]

for number, distance in dic.items():
    if distance in dic2:
        dic2[distance] = dic2[distance] + 1
    else:
        dic2[distance] = 1

if 0 in dic2:
    if dic2[0] >= 2:
        print(0)
        exit(0)

l = []

for i in range(1, len(dic2.items()) -1):
    l.append(dic2[i] ** dic2[i+1])

r = 1
for x in l:
    r *= x
d, m = divmod(r, waru)
print(m)


### FIXED CODE ###

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

if D[0] != 0:
    print(0)
    exit(0)

waru = 998244353

dic = {}
dic2 = {}

for i in range(1, N+1):
    dic[i] = D[i-1]

for number, distance in dic.items():
    if distance in dic2:
        dic2[distance] = dic2[distance] + 1
    else:
        dic2[distance] = 1

if 0 in dic2:
    if dic2[0] >= 2:
        print(0)
        exit(0)

l = []

for i in range(1, len(dic2.items()) - 1):
    if i in dic2 and (i+1) in dic2:
        l.append(dic2[i] ** dic2[i+1])
    else:
        print(0)
        exit(0)

r = 1
for x in l:
    r *= x

d, m = divmod(r, waru)
print(m)
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

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

def dfs(u):
    if visited[u]:
        return

    visited[u] = True

    for v in graph[u]:
        s.add(v)
        dfs(v)

graph = {}

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    graph[a] = graph.get(a, set())
    graph[a].add(b)

    graph[b] = graph.get(b, set())
    graph[b].add(a)

blocks = {}

for _ in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1

    blocks[c] = blocks.get(c, set())
    blocks[c].add(d)

    blocks[d] = blocks.get(d, set())
    blocks[d].add(c)

ans = [0] * n

visited = [False] * n

for u in range(n):
    if not visited[u]:
        s = set()

        dfs(u)

        l = len(s)

        for i in s:
            ans[i] += l - 1

            if i in blocks:
                ans[i] -= len(blocks[i].intersection(s))

            if i in graph:
                ans[i] -= len(graph[i].intersection(s))

print(*ans)

### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(2 * 10 ** 9)

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

def dfs(u):
    if visited[u]:
        return

    visited[u] = True

    for v in graph[u]:
        s.add(v)
        dfs(v)

graph = {i: set() for i in range(n)}
blocks = {i: set() for i in range(n)}

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    graph[a].add(b)
    graph[b].add(a)

for _ in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1

    blocks[c].add(d)
    blocks[d].add(c)

ans = [0] * n

visited = [False] * n

for u in range(n):
    if not visited[u]:
        s = set()

        dfs(u)

        l = len(s)

        for i in s:
            ans[i] += l - 1
            ans[i] -= len(blocks[i].intersection(s))
            ans[i] -= len(graph[i].intersection(s))

print(*ans)
from math import gcd
N = int(input())
A = [int(input()) for _ in range(N)]
B = [0]*(N-1)
B[0] = (A[0]*A[1])//gcd(A[0], A[1])
for i in range(N-2):
  B[i+1] = (A[i+2]*B[i])//gcd(A[i+2], B[i])
print(B[N-2])


### FIXED CODE ###

import fractions
N = int(input())
T = list(int(input()) for _ in range(N))
ans = T[0]
for i in range(1, N):
    ans = ans * T[i] // fractions.gcd(ans, T[i])
print(ans)
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A.sort()
    maxA = A.pop()
    if maxA < K:
        return print(0)
    g = A[0]

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

    for a in A[1:]:
        g = gcd(g, a)

    if (maxA - K) % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, k = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    diff_min = 10**9 + 7
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        diff_min = (min(diff_min,diff) if diff != 0 else diff_min)
    for i in range(n):
        diff_min = (a[i] % diff_min if a[i] % (diff_min) != 0 else diff_min)
    for i in range(n):
        if a[i] - k >= 0 and (a[i] - k)%diff_min == 0:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
if __name__ == '__main__':
    main()
h, w = map(int, input().split())
s = h * w
if s % 3 == 0:
    ans = 0
else:
    c = []
    for i in range(1, h-1):
        sa = i * w
        sb = (h - i) * (w // 2)
        sc = (h - i) * (w - (w // 2))
        min_s = min(sa, min(sb, sc))
        max_s = max(sa, max(sb, sc))
        c.append(max_s - min_s)
    for i in range(1, w-1):
        sa = i * h
        sb = (w - i) * (h // 2)
        sc = (w - i) * (h - (h // 2))
        min_s = min(sa, min(sb, sc))
        max_s = max(sa, max(sb, sc))
        c.append(max_s - min_s)
    ans = min(c)
print(ans)

### FIXED CODE ###

h, w = map(int, input().split())
s = h * w
if s % 3 == 0:
    ans = 0
else:
    c = []
    for i in range(1, h):
        sa = i * w
        sb = (h - i) * (w // 2)
        sc = (h - i) * (w - (w // 2))
        min_s = min(sa, min(sb, sc))
        max_s = max(sa, max(sb, sc))
        c.append(max_s - min_s)
        sb = ((h - i) // 2) * w
        sc = s - sa - sb
        min_s = min(sa, min(sb, sc))
        max_s = max(sa, max(sb, sc))
        c.append(max_s - min_s)
    for i in range(1, w):
        sa = i * h
        sb = (w - i) * (h // 2)
        sc = (w - i) * (h - (h // 2))
        min_s = min(sa, min(sb, sc))
        max_s = max(sa, max(sb, sc))
        c.append(max_s - min_s)
        sb = ((w - i) // 2) * h
        sc = s - sa - sb
        min_s = min(sa, min(sb, sc))
        max_s = max(sa, max(sb, sc))
        c.append(max_s - min_s)
    ans = min(c)
print(ans)
def inp():
    return(int(input()))
i <- inp()

D <- i[0]
T <- i[1]
S <- i[2]

if D > S*T:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) ]))
def invr():
    return(map(int,input().split()))
  
i = inlt()
D = i[0]
T = i[1]
S = i[2]
 
if D/T > S:
  print("No")
else:
  print("Yes")
A, B, C, D = map(int, input().split())
result = 0
size = B - A + 1
for i in range(size):
    if((A + i)%C == 0):
        pass
    elif((A + i)%D ==0):
        pass
    else
        result += 1

print(result)


### FIXED CODE ###

import fractions
A, B, C, D = map(int, input().split())
Cdiv = B // C - (A - 1) // C
Ddiv = B // D - (A - 1) // D
gcd_CD = int(C * D / fractions.gcd(C, D))
CDdiv = B // gcd_CD - (A - 1) // gcd_CD
result = int(B - (A - 1) - Cdiv - Ddiv + CDdiv)
print(result)
_N,_M=input().split()
N = int(_N)
M = int(_M)
l = []
for i in range(0,M):
    _p, _q = input().split
    l.append((int(_p),int(_q)))
_A,_B=zip(l)

A=_A+_B
B=_B+_A


def gen_get_to(_fr):
    global A
    global B
    global nodes
    global step
    for itr in range(0,len(A)):
        if A[itr]==_fr:
            if not B[itr] in nodes[0:step]:
                yield B[itr]

def move(): #returns whether "move" succeeded or not
    global nodes
    global possible_memo
    global step
    global counter
    global N
    global end_flag
    try:
        _=next(possible_memo[step])
        nodes[step+1]=_
        step+=1
        #print("success move to {}".format(nodes[step]))
        #print("map: {}".format(nodes[0:step+1]))
        #print("I am at {}th node".format(step+1))
        if step==N-1:
            counter+=1
            #print('REACHED GOAL!!!')
        possible_memo[step]=gen_get_to(nodes[step])
    except StopIteration:
        step-=1
        #print("failed to move")
        if not step==-1:
            pass#print("map: {}".format(nodes[0:step+1]))
            #print("I am at {}th node".format(step+1))
        if step==-1:
            #print("I fell from the first node")
            end_flag=True

nodes=[0]*N
possible_memo=[0]*N
counter=0
step=0
nodes[step]=1
possible_memo[step]=gen_get_to(nodes[0])
end_flag=False

while not end_flag:
    move()


print(counter)

### FIXED CODE ###

_N,_M=input().split()
N = int(_N)
M = int(_M)
l = []
for i in range(0,M):
    _p, _q = input().split()
    l.append((int(_p),int(_q)))
_A,_B=zip(*l)

A=_A+_B
B=_B+_A


def gen_get_to(_fr):
    global A
    global B
    global nodes
    global step
    for itr in range(0,len(A)):
        if A[itr]==_fr:
            if not B[itr] in nodes[0:step]:
                yield B[itr]

def move(): #returns whether "move" succeeded or not
    global nodes
    global possible_memo
    global step
    global counter
    global N
    global end_flag
    try:
        _=next(possible_memo[step])
        nodes[step+1]=_
        step+=1
        #print("success move to {}".format(nodes[step]))
        #print("map: {}".format(nodes[0:step+1]))
        #print("I am at {}th node".format(step+1))
        if step==N-1:
            counter+=1
            #print('REACHED GOAL!!!')
        possible_memo[step]=gen_get_to(nodes[step])
    except StopIteration:
        step-=1
        #print("failed to move")
        if not step==-1:
            pass#print("map: {}".format(nodes[0:step+1]))
            #print("I am at {}th node".format(step+1))
        if step==-1:
            #print("I fell from the first node")
            end_flag=True

nodes=[0]*N
possible_memo=[0]*N
counter=0
step=0
nodes[step]=1
possible_memo[step]=gen_get_to(nodes[0])
end_flag=False

while not end_flag:
    move()


print(counter)
import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

s=II()
l=[s]
cnt = 1
while True:
    cnt += 1
    if s%2==0:
        s/=2
    else:
        s = 3*s+1
    if s in se:
        print(cnt)
        exit()
    else:
        l.append(s)

### FIXED CODE ###

import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

s=II()
l=[s]
cnt = 1
while True:
    cnt += 1
    if s%2==0:
        s/=2
    else:
        s = 3*s+1
    if s in l:
        print(cnt)
        exit()
    else:
        l.append(s)
N,M=map(int,input().split())

ac=[False]*N
wa=[0]*N

for i in range(N):
    p,s=input().split()
    p=int(p)-1

    if s=="AC":
        ac[p]=True
    else:
        wa[p]+=1

a=0
b=0

for i in range(N):
    if ac[p]==True:
        a+=1
        b+=wa[i]

print(a,b,sep=" ")


### FIXED CODE ###

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

ac=[False]*n
wa=[0]*n

for i in range(m):
    p,s=input().split()
    p=int(p)-1

    if s=="AC":
        ac[p]=True
    else:
        if not ac[p]:
            wa[p]+=1

a=0
b=0

for i in range(n):
    if ac[i]:
        a+=1
        b+=wa[i]

print(a,b,sep=" ")
x1,y1,x2,y2=list(map(int,input().split()))
dx=x2-x1
dy=y2-y1
print(x2-dy,y2+dx,x1-dy,y1+dx)


### FIXED CODE ###

n=int(input())
print(n//2*(n-n//2))
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans+=c[a[i]-1]
print(sum(b)+ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans+=c[a[i]-1]
print(sum(b)+ans)
a=input()
b=input()
c=a*b
d=(a+b)*2
print c+" "+d

### FIXED CODE ###

l = map(int, raw_input().split())
a=l[0]
b=l[1]
c=a*b
d=(a+b)*2
print str(c)+" "+str(d)
n=int(input())
list=[int(input()) for i in range(n)]

for i in range(n):
  listA=list.remove[i]
  print(max(listA))

### FIXED CODE ###

n=int(input())
l1=[int(input()) for i in range(n)]
l2=sorted(l1)
max1=l2[-1]
max2=l2[-2]
for i in l1:
  if i == max1:
    print(max2)
  else:
    print(max1)
n,k=map(int,input().split())
p=list(map(int,input().split())
p.sort()
print(sum(p[:k]))

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
print(sum(p[:k]))
def paint():
    a = int(input())
    b = int(input())
    c = int(input())
    count = 1
    if a != b:
        count += 1
    if a != c and b != c:
        count += 1

    print(count)

paint()

### FIXED CODE ###

def paint():
    s = input()
    slist = s.split(' ')

    a = int(slist[0])
    b = int(slist[1])
    c = int(slist[2])
    count = 1
    if a != b:
        count += 1
    if a != c and b != c:
        count += 1

    print(count)

paint()
# coding:utf-8

n = input()
top = map(int, raw_input().split())
middle = map(int, raw_input().split())
under = map(int, raw_input().split())
top.sort()
middle.sort()
under.sort()
total = 0
for i in xrange(n):
    high = n - 1
    low = 0
    t = (high+low)/2
    d = middle[i] - 1
    while(low <= high):
        if top[t] == d: break
        if top[t] > d:
            high = t - 1
        else:
            low = t + 1
        t = (high+low)/2
    while(t+1 < len(top)):
        if top[t] != top[t+1]: break
        t += 1
    tt = t + 1 #topの候補数

    high = n -1
    low = 0
    t = (high+low)/2
    d = middle[i] + 1
    while(low <= high):
        if under[t] == d: break
        if under[t] > d:
            high = t - 1
        else:
            low = t + 1
        t = (high+low)/2
    if(under[t] != d): t += 1
    while(t-1 >= 0):
        if under[t] != under[t+1]: break
        t -= 1
    tu = n - t #underの候補数

    total += tt*tu
print total


### FIXED CODE ###

# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N = int(input())
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl())

ans = 0
i_a = 0
i_c = 0
for i_b in range(N):
    while i_a < N and A[i_a] < B[i_b]:
        i_a += 1
    while i_c < N and C[i_c] <= B[i_b]:
        i_c += 1

    ans += i_a * (N - i_c)

print(ans)
N=int(input())
X=input()
num_X = int(X, base=2)
pop_x = X.count("1")
mod1 = pop_x - 1
mod0 = pop_x + 1
res1 = num_X % (mod1)
res0 = num_X % (mod0)

# pops = [0]*(N+20)
for i in range(N):
    tmp = 0
    if X[i] == "0":
        # +
        tmp = (res0 + pow(2, N-i-1, mod0))%mod0
    else:
        tmp = (res1 - pow(2, N-i-1, mod1))%mod1
    
    if tmp == 0:
        print(1)
        continue
    cnt = 1
    while tmp != 0:
        pop = bin(tmp).count("1")
        tmp %= pop
        cnt += 1
    print(cnt)

### FIXED CODE ###

N=int(input())
X=input()
num_X = int(X, base=2)
pop_x = X.count("1")
if pop_x <= 1:
    mod0 = pop_x + 1
    res0 = num_X % mod0
else:
    mod1 = pop_x - 1
    mod0 = pop_x + 1
    res1 = num_X % (mod1)
    res0 = num_X % (mod0)

# pops = [0]*(N+20)
for i in range(N):
    tmp = 0
    if X[i] == "0":
        # +
        tmp = (res0 + pow(2, N-i-1, mod0))%mod0
    else:
        if pop_x == 1:
            print(0)
            continue
        tmp = (res1 - pow(2, N-i-1, mod1))%mod1
    
    if tmp == 0:
        print(1)
        continue
    cnt = 1
    while tmp != 0:
        pop = bin(tmp).count("1")
        tmp %= pop
        cnt += 1
    print(cnt)
N, M = map(int, input().split())
edges = []
for i in range(M):
    a, b, c = map(int, input().split())
    edges.append([a, b, -c])
def bellman_ford(edges, N):
    dist = [float('inf') for i in range(N)]
    dist[0] = 0
    for i in range(N-1):
        for edge in edges:
            if dist[edge[1] - 1] > dist[edge[0] - 1] + edge[2]:
                dist[edge[1] - 1] = dist[edge[0] - 1] + edge[2]
    negative = ['false'] * len(N)

    for i in range(N):
        for edge in edges:
            if dist[edge[1] - 1] > dist[edge[0] - 1] + edge[2]:
                dist[edge[1] - 1] = dist[edge[0] - 1] + edge[2]
                negative[edge[1] - 1] = True
            if negative[edge[0] - 1] == True:
                negative[edge[1] - 1] =True

    return 'inf' if negative[-1] else -dist[-1]

print(bellman_ford(edges, N))

### FIXED CODE ###

N, M = map(int, input().split())
edges = []
for i in range(M):
    a, b, c = map(int, input().split())
    edges.append([a, b, -c])
def bellman_ford(edges, N):
    dist = [float('inf') for i in range(N)]
    dist[0] = 0
    for i in range(N-1):
        for edge in edges:
            if dist[edge[1] - 1] > dist[edge[0] - 1] + edge[2]:
                dist[edge[1] - 1] = dist[edge[0] - 1] + edge[2]
    negative = [False] * N

    for i in range(N):
        for edge in edges:
            if dist[edge[1] - 1] > dist[edge[0] - 1] + edge[2]:
                dist[edge[1] - 1] = dist[edge[0] - 1] + edge[2]
                negative[edge[1] - 1] = True
            if negative[edge[0] - 1] == True:
                negative[edge[1] - 1] =True
    
    return 'inf' if negative[-1] else -dist[-1]

print(bellman_ford(edges, N))
S = int(input())

a = S//3600 #h
b = S%3600//60 #m
c = (S%3600)//60

print(":".join((a),(b),(c))

### FIXED CODE ###

S = int(input())

a = S//3600 #h
b = (S%3600)//60 #m
c = (S%3600)%60 # s

print('{0}:{1}:{2}'.format(a,b,c))
a,b = map(int. input().split())

if a>b:
    print(a-b)
elif a<b:
    print(0)
else:
    print(0)

### FIXED CODE ###

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

if b*2 >= a:
    print(0)
else:
    print(a - b*2)
i = int(input())
print(int(n*(n-1)/2))

### FIXED CODE ###

i = int(input())
print((i-1)*i//2)
n = int(input())
A = list(map(int,input().split))
c = 0
while (all(a%2==0 for a in A)):
	A = [a//2 for a in A]
    c += 1
print(c)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
c=0
while(all(a%2==0 for a in A)):
    A = [a//2 for a in A]
    c+=1
print(c)