Harryxun/stf_run huggingface dataset:
import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

n = int(rl())
li = [list(map(int, rl().split())) for _ in range(n)]
dp = np.zeros((n, 3), dtype=int)
dp[0] = li[0]

for i in range(1, n):
    a = dp[i-1][1] + li[i][0]
    b = dp[i-1][2] + li[i][0]
    dp[i][0] = max(a, b)
    a = dp[i-1][0] + li[i][1]
    b = dp[i-1][2] + li[i][1]
    dp[i][1] = max(a, b)
    a = dp[i-1][0] + li[i][2]
    b = dp[i-1][1] + li[i][2]
    dp[i][2] = max(a, b)
print(max(dp[-1]))

    



### FIXED CODE ###

import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

n = int(rl())
li = [list(map(int, rl().split())) for _ in range(n)]
dp = np.zeros((n, 3), dtype=int)
dp[0] = li[0]

for i in range(1, n):
    a = dp[i-1][1] + li[i][0]
    b = dp[i-1][2] + li[i][0]
    dp[i][0] = max(a, b)
    a = dp[i-1][0] + li[i][1]
    b = dp[i-1][2] + li[i][1]
    dp[i][1] = max(a, b)
    a = dp[i-1][0] + li[i][2]
    b = dp[i-1][1] + li[i][2]
    dp[i][2] = max(a, b)
print(max(dp[-1]))
import math
a, b, n = map(int, input().split())
 
 
def calc(a, b, n):
    return int(math.floor((a * n)/b) - (a * math.floor(n/b)))
 
nn = min(n, b - 1)
print(calc(a, b, nn)

### FIXED CODE ###

import math
a, b, n = map(int, input().split())
 
 
def calc(a, b, n):
    return int(math.floor((a * n)/b) - (a * math.floor(n/b)))
 
if n <= b -1:
  print(calc(a,b,n))
else:
  print(calc(a,b,b-1))
N = int(input())
X, U = [], []
for i in range(N):
    x, u = map(int, input().split(" "))
    X.append(x)
    U.append(u)

ans = 0
for i in range(N):
    if u == 'BTC':
        ans += x * 380000
    else:
        ans += x
print(ans)

### FIXED CODE ###

N = int(input())
X, U = [], []
for i in range(N):
    x, u = input().split(" ")
    X.append(float(x))
    U.append(u)

ans = 0
for i in range(N):
    if U[i] == 'BTC':
        ans += X[i] * 380000
    else:
        ans += X[i]
print(ans)
import math
import fractions
N=int(input())
A=fractions.sqrt(N)
A=fractions.ceil(A)
mini=100000000000
for i in range(1,A+1):
    if N%i==0:
        x=len(str(i))
        y=len(str(N//i))
        if mini>max(x,y):
            mini=max(x,y)
print(mini)


### FIXED CODE ###

import math
import fractions
N=int(input())
A=math.sqrt(N)
A=math.ceil(A)
mini=100000000000
for i in range(1,A+1):
    if N%i==0:
        x=len(str(i))
        y=len(str(N//i))
        if mini>max(x,y):
            mini=max(x,y)
print(mini)
N, M = map(int, raw_input().split(" "))

xyz = []
for i in range(N):
    xyz.append(map(int, raw_input().split(" ")))
result = sum(map(abs, xyz[0]))
i = j = k = 1

def compare(x, y):
    if i*x[0]+j*x[1]+k*x[2]>i*y[0]+j*y[1]+k*y[2]:
        return 1
    elif i*x[0]+j*x[1]+k*x[2]<i*y[0]+j*y[1]+k*y[2]:
        return -1
    else:
        return 0

def calculate(x, y):
    return [x[0]+y[0], x[1]+y[1], x[2]+y[2]]

for i in [1,-1]:
    for j in [1,-1]:
        for k in [1,-1]:
            xyz.sort(compare)
            tmp = sum(map(abs, reduce(calculate, xyz[:M])))
            if tmp > result:
                result = tmp
print result

### FIXED CODE ###

N, M = map(int, raw_input().split(" "))

xyz = []
for i in range(N):
    xyz.append(map(int, raw_input().split(" ")))
result = -1
i = j = k = 1

def compare(x, y):
    if i*x[0]+j*x[1]+k*x[2]>i*y[0]+j*y[1]+k*y[2]:
        return 1
    elif i*x[0]+j*x[1]+k*x[2]<i*y[0]+j*y[1]+k*y[2]:
        return -1
    else:
        return 0

def calculate(x, y):
    return [x[0]+y[0], x[1]+y[1], x[2]+y[2]]

for i in [1,-1]:
    for j in [1,-1]:
        for k in [1,-1]:
            xyz.sort(compare)
            tmp = 0 if M==0 else sum(map(abs, reduce(calculate, xyz[:M])))
            result = max(tmp, result)

print result
def main():
    n = int(input())

    
    
    def divide(n):
        counter = 0
        counter1 = 0
        if n % 2 != 0:
            for i in range(1, n+1, 2):
                for j in range(1, i+1):
                    if i % j == 0:
                        counter += 1
                if counter == 8:
                    counter1 += 1
                counter = 0
        else:
            for i in range(1, n, 2):
                for j in range(1, i+1):
                    if i % j == 0:
                        counter += 1
                if counter == 8:
                    counter1 += 1
                counter = 0
        return counter1

    print(divide(n))
                         
if __name__ == '__main__':
    main()

### FIXED CODE ###

a, b = map(int, input().split())
print((a - 1) * (b - 1))
s =  list(input())
combo = False
cnt = 0
ans = [] 
for mozi in s:
    if(mozi == "A" or mozi == "G" or mozi == "C" or mozi == "T"):
        cnt = cnt + 1 
        if combo != True:
            combo = True
    elif combo:
        ans.append(cnt)
        cnt = 0
        combo = False
print(max(ans))


### FIXED CODE ###

s =  list(input())
combo = False
cnt = 0
ans = [0,] 
for mozi in s:
    if(mozi == "A" or mozi == "G" or mozi == "C" or mozi == "T"):
        cnt = cnt + 1 
        if combo != True:
            combo = True
    else:
        if combo:
            ans.append(cnt)
            cnt = 0
            combo = False
ans.append(cnt)
print(max(ans))
s=input()
ls=len(s)
c=0
for i in range(ls):
    if s[i]=='S':
        c+=1
    elif c>0:
        ans+=2
        c-=1
print(ls-ans)

### FIXED CODE ###

s=input()
ls=len(s)
c=0
ans=0
for i in range(ls):
    if s[i]=='S':
        c+=1
    elif c>0:
        ans+=2
        c-=1
print(ls-ans)
def solve(X, Y):
    import sympy as sp
    sp.init_printing()
    sp.var('a, b')
    eq1 = sp.Eq(2 * a + 4 * b, Y)
    eq2 = sp.Eq(a + b, X)
    res = sp.solve([eq1, eq2], [a, b])
    x = res[a]
    y = res[b]
    if x == int(x) and y == int(y) and x >= 0 and y >= 0:
        print('Yes')
    else:
        print('No')

X, Y = map(int, open(0).read().split())
solve(X, Y)

### FIXED CODE ###

def solve(X, Y):
    from numpy.linalg import solve
    left = [[1, 1], [2, 4]]
    right = [X, Y]
    res = solve(left, right)
    x = res[0]
    y = res[1]

    if x == float(int(x)) and y == float(int(y)) and x >= 0 and y >= 0:
        print('Yes')
    else:
        print('No')
 
X, Y = map(int, open(0).read().split())
solve(X, Y)
x = getchar()

x = x*x*x

print(x)


### FIXED CODE ###

x = input()
print x**3
H, N = map(int, input().split())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    
A, B = zip(*sorted(zip(A, B)))

dp = [[0] * (H + 1)] * (N + 1)

for dmg in range(1, H + 1):
    dp[1][dmg] = -(-dmg // A[0]) * B[0]

for index in range(1, N + 1):
    a, b = A[index-1], B[index-1]
    for dmg in range(1, H + 1):
        ahead = dp[index-1][dmg] #前回
        only = dp[index][dmg - a] + b #自分だけ
        dp[index][dmg] = min(ahead, only)
print(dp[N][H])

### FIXED CODE ###

H, N = map(int, input().split())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    
A, B = zip(*sorted(zip(A, B)))

dp = [[0] * (10000 + 1)] * (N + 1)

for dmg in range(1, 10000 + 1):
    dp[1][dmg] = -(-dmg // A[0]) * B[0]

for index in range(1, N + 1):
    a, b = A[index-1], B[index-1]
    for dmg in range(1, 10000 + 1):
        ahead = dp[index-1][dmg] #前回
        if dmg - a < 0:
            only = -(-dmg // a) * b
        else:
            only = dp[index][dmg - a] + b #自分だけ
        dp[index][dmg] = min(ahead, only)
print(min(dp[N][H:]))
card, gate = map(int, input().split())
l, r = map(int, input().split())
ans = {i for i in range(l, r+1)}
for i in range(gate-1):
  l, r = map(int, input().split())
  if l > min(ans) or max(ans) > r:
    l, r = max(min(ans), l), min(max(ans), r)
    ans = {i for i in range(l, r+1) if i in ans}
print(len(ans))

### FIXED CODE ###

card, gate = map(int, input().split())
max_l = 0
min_r = 100000
for i in range(gate):
  l, r = map(int, input().split())
  max_l = max(max_l, l)
  min_r = min(min_r, r)
print(len(range(max_l, min_r+1)))
s = str(input())
t = str(input())
count = 0

for i in range(len(s)):
    if s[i] != t[i]:
        count +=1

print(count)

### FIXED CODE ###

a  = int(input())
print(a+a**2+a**3)
# -*- coding: utf-8 -*-
# 整数の入力
p=str(input())
if p[0] ==p[1] ==p[2] ==p[3]:
    print("No") 
elif p[0] ==p[3] and p[1] == p[2]:
    print("Yes")
elif p[0] == p[1] and p[2] == p[3]:
    print("Yes")
elif p[0] ==p[2] and p[1] == p[3]
else:
    print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
p=str(input())
if p[0] ==p[1] ==p[2] ==p[3]:
    print("No") 
elif p[0] ==p[3] and p[1] == p[2]:
    print("Yes")
elif p[0] == p[1] and p[2] == p[3]:
    print("Yes")
elif p[0] ==p[2] and p[1] == p[3]:
    print("Yes")
else:
    print("No")
def dfs(i, total, S, remain):
    global ans
    if i == D:
        if S < G:
           use = max(remain)
           N = min(L[use-1][0], (G-S)//(100*use))
           S += 100 * N * use
           total += N
           
        if S >= G:
           ans = min(ans, total)
    else:
        dfs(i+1, total, S, remain)
        dfs(i+1, total + L[i][0], S + 100 * (i+1) * L[i][0] + L[i][1], remain - {i+1})
 
D, G = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(D)]
ans = 10 ** 9
 
dfs(0, 0, 0, set(range(1, D+1)))
 
print(ans)

### FIXED CODE ###

r = int(input())

rate = [1200, 2800, 4209]
contest = ['ABC', 'ARC', 'AGC']

for i in range(3):
    if r < rate[i]:
        break
print(contest[i])
while True:
    n = input()
    ans = []
    if n == 0: break
    tmp = [0] * (n+1)
    for i in range(n):
        ans.append(map(int, raw_input().split()))
        ans[i].append(sum(ans[i]))
        for j in range(len(ans[i])):
            tmp[j] += ans[i][j]
    ans.append(tmp)
    for a in ans:
        print " ".join(map(lamda x: str(x).rjust(5), a))

### FIXED CODE ###

while True:
    n = input()
    ans = []
    if n == 0: break
    tmp = [0] * (n+1)
    for i in range(n):
        ans.append(map(int, raw_input().split()))
        ans[i].append(sum(ans[i]))
        for j in range(len(ans[i])):
            tmp[j] += ans[i][j]
    ans.append(tmp)
    for a in ans:
        print "".join(map(lambda x: str(x).rjust(5), a))
## coding: UTF-8
#from decimal import *
s = input().split()
t = [int(p) for p in s]


#print(t)
if( Decimal(Decimal(t[0]) % 2 )== 1 and Decimal(Decimal(t[1]) % 2) == 1):
    n = Decimal( Decimal(Decimal(t[0]) - 1) // 2  )
    #print(n)
    m = Decimal( Decimal(Decimal(t[1]) - 1) // 2  )
    answer = Decimal(    Decimal(  Decimal(Decimal(m) + 1)     *    Decimal(Decimal(n) + 1)  )   + Decimal( Decimal(m) * Decimal(n) )       )
else:
    answer = Decimal(   Decimal(Decimal(t[0]) * Decimal(t[1])) // 2  )

print(int(answer))

'''
H = t[0]
W = t[1]
ans = 0
if( W % 2 == 0):
    for i in range(H):
        ans += W / 2
else:
    for i in range(H):
        if(i % 2 == 0):
            ans += W / 2.0 + 0.5
        else:
            ans += W / 2.0 - 0.5
print(int(ans))
'''


### FIXED CODE ###

## coding: UTF-8
from decimal import *
s = input().split()
t = [int(p) for p in s]


#print(t)
if(t[0] == 1 or t[1] == 1):
    answer = 1
elif( Decimal(Decimal(t[0]) % 2 )== 1 and Decimal(Decimal(t[1]) % 2) == 1):
    n = Decimal( Decimal(Decimal(t[0]) - 1) // 2  )
    #print(n)
    m = Decimal( Decimal(Decimal(t[1]) - 1) // 2  )
    answer = Decimal(    Decimal(  Decimal(Decimal(m) + 1)     *    Decimal(Decimal(n) + 1)  )   + Decimal( Decimal(m) * Decimal(n) )       )
else:
    answer = Decimal(   Decimal(Decimal(t[0]) * Decimal(t[1])) // 2  )

print(int(answer))

'''
H = t[0]
W = t[1]
ans = 0
if( W % 2 == 0):
    for i in range(H):
        ans += W / 2
else:
    for i in range(H):
        if(i % 2 == 0):
            ans += W / 2.0 + 0.5
        else:
            ans += W / 2.0 - 0.5
print(int(ans))
'''
N, K, Q = map(int, input().split())
A = []
P = [0] * N
for _ in range(Q):
    A.append(int(input()))
    P[A[-1]-1] += 1

# 全員終了時はK - Q + （個人の正解数）とする
# K - Q + 正解数 > 0の人は勝ち残る
for i in range(Q):
    if K - Q + P[i] > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N, K, Q = map(int, input().split())
A = []
P = [0] * N
for _ in range(Q):
    A.append(int(input()))
    P[A[-1]-1] += 1

# 全員終了時はK - Q + （個人の正解数）とする
# K - Q + 正解数 > 0の人は勝ち残る
for i in range(N):
    if K - Q + P[i] > 0:
        print("Yes")
    else:
        print("No")
def factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)
n=input()
print(factorial(n))

### FIXED CODE ###

def factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)
n=input()
print(factorial(int(n)))
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

roots = [(i,1) for i in range(N+1)] # root, num_islands_in_group

inconveniences = [0]*(M+1)
inconveniences[-1] = N*(N-1)//2 #すべての橋が崩落するとNC2

def find_root(a, roots=roots):
  if roots[a][0] == a:
    return roots[a]
  else:
    roots[a] = find_root(roots[a][0])
  return roots[a]

def reduce_inconvenience_with_unite(a, b, roots=roots):
  root_a, n_a = find_root(a)
  root_b, n_b = find_root(b)
  if root_a == root_b:
    return 0
  else:
    roots[root_a] = (b, None) # 二項目は何でも良い
    roots[root_b] = (b, n_a + n_b)
    return n_a * n_b

for i, ab in enumerate(AB[:0:-1]): #実は1個めの橋は全く関係ない
  a, b = ab
  inconveniences[M-1-i] = inconveniences[M-i] - reduce_inconvenience_with_unite(a,b)

for inc in inconveniences[1:]:
  print(inc)

### FIXED CODE ###

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

roots = [(i,1) for i in range(N+1)] # root, num_islands_in_group

inconveniences = [0]*(M+1)
inconveniences[-1] = N*(N-1)//2 #すべての橋が崩落するとNC2

def find_root(a, roots=roots):
  if roots[a][0] == a:
    return roots[a]
  else:
    roots[a] = find_root(roots[a][0])
  return roots[a]

def reduce_inconvenience_with_unite(a, b, roots=roots):
  root_a, n_a = find_root(a)
  root_b, n_b = find_root(b)
  if root_a == root_b:
    return 0
  else:
    if n_a > n_b:
      roots[root_a] = (root_a, n_a + n_b) # 二項目は何でも良い
      roots[root_b] = (root_a, n_a + n_b)
    else:
      roots[root_a] = (root_b, n_a + n_b) # 二項目は何でも良い
      roots[root_b] = (root_b, n_a + n_b)
    return n_a * n_b

for i, ab in enumerate(AB[:0:-1]): #実は1個めの橋は全く関係ない
  a, b = ab
  inconveniences[M-1-i] = inconveniences[M-i] - reduce_inconvenience_with_unite(a,b)

for inc in inconveniences[1:]:
  print(inc)
import numpy as np

#def area--------------------------#
#ryouno syokiti
class ryou:
	def flinit(self):
		room=list()
		for i in range(10):
			room+=[0]
		return room

#def kaijo([a_1,a_2,a_3,a_4,a_5,a_6,a_7,a_8,a_9,a_10]):


#def kaijo(x):
#	y=[]
#	for i in x:
#		y=y+ " "+x[i]
#	return y		
def kaijo(x):
	print "",
	for i in range(len(x)-1):
		print str(x[i]),
	print str(x[len(x)-1])


#----------------------------------#

floor_11=ryou().flinit()
floor_12=ryou().flinit()
floor_13=ryou().flinit()
floor_21=ryou().flinit()
floor_22=ryou().flinit()
floor_23=ryou().flinit()
floor_31=ryou().flinit()
floor_32=ryou().flinit()
floor_33=ryou().flinit()
floor_41=ryou().flinit()
floor_42=ryou().flinit()
floor_43=ryou().flinit()


fldic={"11":floor_11,
       "12":floor_12,
       "13":floor_13,
       "21":floor_21,
       "22":floor_22,
       "23":floor_23,
       "31":floor_31,
       "32":floor_32,
       "33":floor_33,
       "41":floor_41,
       "42":floor_42,
       "43":floor_43
       }

#----------------------------------#


#1kaime yomikomi
n=int(raw_input())

#nkaime syusyori

for l in range(n):
	list_mojiretsu=raw_input().split(" ")
	henka=map(int,list_mojiretsu)
	fldic[str(henka[0])+str(henka[1])][henka[2]-1]+=henka[3]
	
#henka=[3,4,5,6]



kaijo(floor_11)
kaijo(floor_12)
kaijo(floor_13)
print "####################"
kaijo(floor_21)
kaijo(floor_22)
kaijo(floor_23)
print "####################"
kaijo(floor_31)
kaijo(floor_32)
kaijo(floor_33)
print "####################"
kaijo(floor_41)
kaijo(floor_42)
kaijo(floor_43)

print "aiueo"
#print kaijo(floor_11)

### FIXED CODE ###

#import numpy as np

#def area--------------------------#
#ryouno syokiti
class ryou:
	def flinit(self):
		room=list()
		for i in range(10):
			room+=[0]
		return room

#def kaijo([a_1,a_2,a_3,a_4,a_5,a_6,a_7,a_8,a_9,a_10]):


#def kaijo(x):
#	y=[]
#	for i in x:
#		y=y+ " "+x[i]
#	return y		
def kaijo(x):
	print "",
	for i in range(len(x)-1):
		print str(x[i]),
	print str(x[len(x)-1])


#----------------------------------#

floor_11=ryou().flinit()
floor_12=ryou().flinit()
floor_13=ryou().flinit()
floor_21=ryou().flinit()
floor_22=ryou().flinit()
floor_23=ryou().flinit()
floor_31=ryou().flinit()
floor_32=ryou().flinit()
floor_33=ryou().flinit()
floor_41=ryou().flinit()
floor_42=ryou().flinit()
floor_43=ryou().flinit()


fldic={"11":floor_11,
       "12":floor_12,
       "13":floor_13,
       "21":floor_21,
       "22":floor_22,
       "23":floor_23,
       "31":floor_31,
       "32":floor_32,
       "33":floor_33,
       "41":floor_41,
       "42":floor_42,
       "43":floor_43
       }

#----------------------------------#


#1kaime yomikomi
n=int(raw_input())

#nkaime syusyori

for l in range(n):
	list_mojiretsu=raw_input().split(" ")
	henka=map(int,list_mojiretsu)
	fldic[str(henka[0])+str(henka[1])][henka[2]-1]+=henka[3]
	


kaijo(floor_11)
kaijo(floor_12)
kaijo(floor_13)
print "####################"
kaijo(floor_21)
kaijo(floor_22)
kaijo(floor_23)
print "####################"
kaijo(floor_31)
kaijo(floor_32)
kaijo(floor_33)
print "####################"
kaijo(floor_41)
kaijo(floor_42)
kaijo(floor_43)
K =int(input())
A,B =map(int,input().split())
count ==0
for i in range(A,B+1):
    if i%K==0:
        print('OK')
        count =1
        break
if count ==0:   
    print('NG')

### FIXED CODE ###

K =int(input())
A,B =map(int,input().split())
count =0
for i in range(A,B+1):
    if i%K==0:
        print('OK')
        count =1
        break
if count ==0:   
    print('NG')
n = int(input())

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

i = 0
sum = 1

for su in n1:
    sum *= su

#while i < n:
#    sum *= n1[i]
#    i += 1

if sum > 10 ** 18:
    print('-1')
else:
    print(sum)

### FIXED CODE ###

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

print(a * b)
import math
r = int(input())
print('{0:.6f} {1:.6f}'.format(r * r * math.pi, (r + r) * math.pi))

### FIXED CODE ###

import math
r = float(input())
print('{0:.6f} {1:.6f}'.format(r * r * math.pi, (r + r) * math.pi))
import bisect
INF = 10 ** 10
s = input()
t = input()
moji = [[] for _ in range(26)]

for i, m in enumerate(s):
    moji[ord(m) - ord("a")].append(i)

for i in range(len(s)):
    moji[i].sort()

moji_o = [0 for _ in range(len(t))]

cnt = 0
ans = 1
for i, m in enumerate(t):
    if len(moji[ord(m) - ord("a")]) == 0:
        ans = -1
        break
    if i == 0:
        moji_o[i] = moji[ord(m) - ord("a")][0]
    else:
        tmp = bisect.bisect_right(moji[ord(m) - ord("a")], moji_o[i - 1])
        if tmp == 0:
            moji_o[i] = moji[ord(m) - ord("a")][0]
        else:
            moji_o[i] = moji[ord(m) - ord("a")][tmp - 1]

# print(moji_o, moji)

for i in range(1, len(moji_o)):
    if ans == -1:
        break
    if moji_o[i - 1] >= moji_o[i]:
        cnt += 1

if ans == -1:
    print(-1)
else:
    print(cnt * len(s) + moji_o[-1] + 1)

### FIXED CODE ###

import bisect
INF = 10 ** 10
s = input()
t = input()
moji = [[] for _ in range(26)]

for i, m in enumerate(s):
    moji[ord(m) - ord("a")].append(i)

for i in range(26):
    moji[i].sort()

moji_o = [0 for _ in range(len(t))]

cnt = 0
ans = 1
# print(moji)
for i, m in enumerate(t):
    if len(moji[ord(m) - ord("a")]) == 0:
        ans = -1
        break
    if i == 0:
        moji_o[i] = moji[ord(m) - ord("a")][0]
    else:
        if moji_o[i - 1] >= moji[ord(m) - ord("a")][-1]:
            moji_o[i] =  moji[ord(m) - ord("a")][0]
        else:
            tmp = bisect.bisect_right(moji[ord(m) - ord("a")], moji_o[i - 1])
            if tmp == 0:
                moji_o[i] = moji[ord(m) - ord("a")][0]
            else:
                moji_o[i] = moji[ord(m) - ord("a")][tmp]
# print(moji_o)
for i in range(1, len(moji_o)):
    if ans == -1:
        break
    if moji_o[i - 1] >= moji_o[i]:
        cnt += 1

if ans == -1:
    print(-1)
else:
    print(cnt * len(s) + moji_o[-1] + 1)
from math import gcd
from functools import reduce
n = int(input())
a = list(map(int, input().split()))

tmp = [set() for _ in range(10**2+1)]
for i in range(2, 10**2//2+1):
    for j in range(i, 10**2+1, i):
        tmp[j].add(i)

acc = [set() for _ in range(n)]
for i, v in enumerate(a):
    if i == 0:
        acc[i] = tmp[v]
    else:
        acc[i] = acc[i-1] | tmp[v]

flag = False
for i in range(n-1):
    acc[i].remove(i)
    if len(acc[i] & acc[n-1]) != 0:
        flag = True
        break

if flag == False:
    print("pairwise coprime")
else:
    if reduce(gcd, a) == 1:
        print("setwise coprime")
    else:
        print("not coprime")

### FIXED CODE ###

from math import gcd
from functools import reduce
n = int(input())
a = list(map(int, input().split()))

# sieve[n]は、その数を最初にふるいに落とした数を格納
def prime_factor_table(n):
    # sieveとはふるいの意味
    sieve = [i for i in range(n+1)]
    # n以下の整数を最初にふるい落とす数(√n以下に必ず存在)を求める.
    for i in range(2, int(n**0.5)+1):
        if sieve[i] == i:
            for j in range(2*i, n+1, i):
                if sieve[j] == j:
                    sieve[j] = i
    return sieve

sieve = prime_factor_table(10**6+1)

def prime_factor(n):
    # 素数は英語でprime number
    prime = set()
    while n > 1:
        prime.add(sieve[n])
        n //= sieve[n]
    return prime

for i, v in enumerate(a):
    if i == 0:
        tmp = prime_factor(v)
    else:
        prime = prime_factor(v)
        for j in prime:
            if j in tmp:
                if reduce(gcd, a) == 1:
                    print("setwise coprime")
                    exit()
                else:
                    print("not coprime")
                    exit()
            tmp.add(j)
print("pairwise coprime")
a = int(input())
b = a.count(int(1))
print(b)


### FIXED CODE ###

a = input()
one_number = a.count('1')
print( 1 * one_number)
N = int(input())
S = [input() for i in range(N)]
 
ac = 0
wa = 0
tle = 0
re = 0
for s in S:
  if s == 'AC': ac += 1
  elif s == 'WA': wa += 1
  elif s == 'TLE': tle += 1
  elif s == 'RE': re += 1

print('AC x ' + ac)
print('WA x ' + wa)
print('TLE x ' + tle)
print('RE x ' + re)

### FIXED CODE ###

N = int(input())
S = [input() for i in range(N)]
 
ac = 0
wa = 0
tle = 0
re = 0
for s in S:
  if s == 'AC': ac += 1
  elif s == 'WA': wa += 1
  elif s == 'TLE': tle += 1
  elif s == 'RE': re += 1

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))
N=int(input())
A=list(map(int,input().split()))
div_flg=False
inc_flg=False
dec_flg=False
ans=0

for i in range(N):
  if inc_flg:
    if i==N-1:
      break
    if A[i]<=A[i+1]:
      continue
    else:
      inc_flg=False
      div_flg=False
  elif dec_flg:
    if i==N-1:
      break
    if A[i]>=A[i+1]:
      continue
    else:
      dec_flg=False
      div_flg=False
  else:
    if i==0:
      ans+=1
      div_flg=True
    elif i==N-1:
      ans+=1
      break
    if A[i]==A[i+1]:
      ans+=1
      div_flg=True
      continue
    elif A[i]<A[i+1]:
      if not div_flg:
        ans+=1
      inc_flg=True
      continue
    elif A[i]>A[i+1]:
      if not div_flg:
        ans+=1
      dec_flg=True
      continue
print(ans)

### FIXED CODE ###

import sys

N=int(input())
A=list(map(int,input().split()))
div_flg=False
inc_flg=False
dec_flg=False
ans=0

if N==1:
  print(1)
  sys.exit()
  
for i in range(N):
  if inc_flg:
    if i==N-1:
      break
    if A[i]<=A[i+1]:
      continue
    else:
      inc_flg=False
      div_flg=False
  elif dec_flg:
    if i==N-1:
      break
    if A[i]>=A[i+1]:
      continue
    else:
      dec_flg=False
      div_flg=False
  else:
    if i==0:
      ans+=1
      div_flg=True
    elif i==N-1:
      if not div_flg:
        ans+=1
      break
    if A[i]==A[i+1]:
      if not div_flg:
        ans+=1
      div_flg=True
      continue
    elif A[i]<A[i+1]:
      if not div_flg:
        ans+=1
      inc_flg=True
      continue
    elif A[i]>A[i+1]:
      if not div_flg:
        ans+=1
      dec_flg=True
      continue
print(ans)