Harryxun/stf_run huggingface dataset:
graph = []

def init():
    global graph
    graph = [[False] * 26 + [True] for _ in xrange(27)]
    graph[26][26] = False

def atoi(c):#index
    if c == "#":
        return 26
    return ord(c) - ord("a")

def make_graph(L):
    global graph
    tmp = []
    while "" in L:
        L.remove("")
    for s1, s2 in zip(L, L[1:]):
        if s1[0] == s2[0]:
            tmp += [s1[1:], s2[1:]]
        else:
            if not tmp == [] and not make_graph(tmp):
                return False
            tmp = []
            graph[atoi(s2[0])][atoi(s1[0])] = True
    if not tmp == [] and not make_graph(tmp):
        return False
    return True

def check(start):
    stack = set([start])
    visited = [False] * 27
    while len(stack) != 0:
        cur = stack.pop()
        visited[cur] = True
        if graph[cur][start]:
            return False
        for i in xrange(27):
            if graph[cur][i] and not visited[i]:
                stack.add(i)
    return True

while True:
    n = input()
    if n == 0:
        break
    L = [raw_input() + "#" for _ in xrange(n)]
    init()
    make_graph(L)
    for i in xrange(27):
        if not check(i):
            print "no"
            break
    else:
        print "yes"

### FIXED CODE ###

graph = []

def init():
    global graph
    graph = [[False] * 26 + [True] for _ in xrange(27)]
    graph[26][26] = False

def atoi(c):#index
    if c == "#":
        return 26
    return ord(c) - ord("a")

def make_graph(L):
    global graph
    cur = 0
    L = [L[0]] + [L[i] for i in xrange(1, len(L)) if L[i] != L[i-1]] #
    #while "" in L:
    #    L.remove("")
    tmp = []
    for s1, s2 in zip(L, L[1:]):
        if s1[0] == s2[0]:
            tmp += [s1[1:], s2[1:]]
        else:
            if not tmp == []:
                make_graph(tmp)
            tmp = []
            graph[atoi(s2[0])][atoi(s1[0])] = True
    if not tmp == []:
        make_graph(tmp)

def check(start):
    stack = set([start])
    visited = [False] * 27
    while len(stack) != 0:
        cur = stack.pop()
        visited[cur] = True
        if graph[cur][start]:
            return False
        for i in xrange(27):
            if graph[cur][i] and not visited[i]:
                stack.add(i)
    return True

while True:
    n = input()
    if n == 0:
        break
    L = [raw_input() + "#" for _ in xrange(n)]
    init()
    make_graph(L)
    for i in xrange(27):
        if not check(i):
            print "no"
            break
    else:
        print "yes"
M,D = map(int,input().split())
ans =0

if D <10:
  print("0")
  break

for i in range(1,M+1):
  for r in range(10,D+1):
    d_tens,d_ones = divmod(r,10)
    
    if i == d_tens*d_ones:
      ans+=1
    else:
      continue
      
print(ans)

### FIXED CODE ###

M,D = map(int,input().split())
ans = 0

for i in range(1,M+1):
  for j in range(10,D+1):
    a,b = divmod(j,10)
    
    if a>=2 and b>=2:
      if i ==a*b:
        ans += 1
       
      
      
print(ans)
n,q=map(int,input().split())
s=list(input())
stage=[1]*n
for i in range(q):
  v = input().split()
  for j in range(n):
    if s[j]==v[0]:
      if v[1]=="L":
        if j!=0:
          stage[j-1]+=stage[j]
        stage[j]=0
      else:
        if j!=n-1:
          stage[j+1]+=stage[j]
        stage[j]=0
print(sum(stage))

### FIXED CODE ###

a,b,c=map(int,input().split())
if a==b and b==c:
  print("Yes")
else:
  print("No")
n, m = map(int, input().split())
broken = []
for i in range(m):
    broken.append(int(input()))
num = {0: int(0 not in broken), 1: int(1 not in broken)}

for i in range(2, n):
    if i in broken:
        num[i] = 0
    else:
        num[i] = (num[i-1] + num[i-2])%1000000007
        
        
print((num[n-1]+num[n-2])%1000000007)

### FIXED CODE ###

n, m = map(int, input().split())
broken = []
for i in range(m):
    broken.append(int(input()))
    
num = [-1] * (n + 1)
num[0] = 1
num[1] = 1


for i in broken:
    num[i] = 0

for i in range(2, n):
    if num[i] == -1:
        num[i] = (num[i-1] + num[i-2])%1000000007
        
if n <= 1:
    print(num[n])
else:
    print((num[n-1]+num[n-2])%1000000007)
N = int(input())
S = input("")
result = str()
size = len(S)
for i in range(size):
    if i + N < size:
        result += S[i + N]
    else:
        result += S[i + N - size]
print(result)

### FIXED CODE ###

alph_list= ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
N = int(input())
S = input("")
ans = str()
for i in range(len(S)):
    t = alph_list.index(S[i]) + N
    if t < len(alph_list):
        ans += alph_list[t]
    else:
        ans += alph_list[t - len(alph_list)]
print(ans)
import math
N = int(input())
A = list(map(int, input().split()))

B=sorted(set(A))
sa = []
gokei = 0
for i in range(len(B)):
    x = A.count(B[i])
    if x == 1:
        continue
    elif x ==2:
        gokei += 1
        sa.append(1)
    else:
        y = x-1
        z = math.factorial(x)//(math.factorial(x-2)*math.factorial(2))
        gokei += z
        sa.append(z-math.factorial(y)//(math.factorial(y-2)*math.factorial(2)))

ans = [0]*(N+1)
for i in range(N):
    z = A[i]
    if ans[z] == 0:
        e = gokei - sa[B.index(z)]
        ans.append(e)
        print(e)
    else:
        print(ans[z])

### FIXED CODE ###

import collections

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

gokei = 0
counter = collections.Counter(A)
for i in counter.values():
    gokei += i * (i - 1) // 2

ans = [0]*(N+1)
for i in range(N):
    z = A[i]
    d = counter[z]
    if ans[z] == 0:
        e = gokei - (d * (d - 1) // 2 - (d-1) * (d - 2) // 2)
        ans.append(e)
        print(e)
    else:
        print(ans[z])
N,K=map(int, input().split())
p = list(map(int, input().split()))

#p = [(n+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

e=s[K-1]
max_e=(K+e)/2
for i in range(1,N-K):
  e=s[i+K]-s[i]
  e=(K+smax)/2
  max_e = max(max_e, e)
    
print(max_e)

### FIXED CODE ###

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

p = [(n+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

e=s[K-1]
max_e=e
for i in range(1,N-K):
  e=s[i+K]-s[i]
  max_e = max(max_e, e)
    
print(max_e)
from sys import stdin


class Rec_memo:
    def __init__(self, N, h_arr):
        self.dp = [float('inf')] * (N+2)
        self.h_arr = h_arr

    def rec(self, i):
        if self.dp[i] < float('inf'):
            return self.dp[i]
        elif i == 0:
            return 0
        else:
            res = float('inf')
            res = min(res,self.rec(i-1)+abs(self.h_arr[i]-self.h_arr[i-1]))
            if i>1:
                res = min(res,self.rec(i-2)+abs(self.h_arr[i]-self.h_arr[i-2]))
            self.dp[i] = res
            return res


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    h_arr = [0] * (N+2)
    h_arr[0:N] = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    # dp[i]:=カエルが足場iへと移動するのに必要な最小コスト
    dp = [float('inf')] * (N+2)  # 最小化問題
    dp[0] = 0                    # 初期条件
    
    # 貰うDP
    #for i in range(0,N):
    #    dp[i] = min(dp[i],dp[i-1]+abs(h_arr[i]-h_arr[i-1]))
    #    if i > 1:
    #        dp[i] = min(dp[i],dp[i-2]+abs(h_arr[i]-h_arr[i-2]))
    #cnt = dp[N-1]

    # 配るDP
    #for i in range(0,N):
    #    dp[i+1] = min(dp[i+1],dp[i]+abs(h_arr[i]-h_arr[i+1]))
    #    dp[i+2] = min(dp[i+2],dp[i]+abs(h_arr[i]-h_arr[i+2]))
    #cnt = dp[N-1]

    # メモ化再帰
    memo = Rec_memo(N,h_arr)
    cnt = memo.rec(N-1)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


### FIXED CODE ###

from sys import stdin


# 最小化問題
def chmin(a,b):
    if a > b: return b
    else: return a


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    h_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    dp = [float('inf')] * N  # 最小化問題
    dp[0] = 0                # 初期条件
    
    for i in range(0,N):
        dp[i] = chmin(dp[i],dp[i-1]+abs(h_arr[i]-h_arr[i-1]))
        if i > 1:
            dp[i] = chmin(dp[i],dp[i-2]+abs(h_arr[i]-h_arr[i-2]))
    cnt = dp[N-1]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
n,m=map(int,input().split())
a=list(map(int,input().split()))
mm=[0,2,5,5,4,5,6,3,7,6]

dp=[0]
m = [mm[i] for i in range(10) if i in a]
for i in range(1,n+1):
    tres=[-10**10]
    for sm in m:
        if i - sm >= 0:
            tres.append(dp[i-sm]+1)
    dp.append(max(tres))
k=dp[n]
res = []
a.sort(reverse=True)
while n > 0:
    for sa in a:
        if dp[n-mm[sa]]==dp[n]-1:
            res.append(sa)
            n -= mm[sa]
            break

print("".join(map(str,res)))

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
mm=[0,2,5,5,4,5,6,3,7,6]

dp=[0]
m = [mm[i] for i in range(10) if i in a]
for i in range(1,n+1):
    tres=[-10**10]
    for sm in m:
        if i - sm >= 0:
            tres.append(dp[i-sm]+1)
    dp.append(max(tres))
k=dp[n]
res = []
a.sort(reverse=True)
while n > 0:
    for sa in a:
        if n-mm[sa] >= 0 and dp[n-mm[sa]]==dp[n]-1:
            res.append(sa)
            n -= mm[sa]
            break

print("".join(map(str,res)))
n,m,l = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for j in range(m):
    b.append(list(map(int, input().split())))
for  k in range(n):
    for o in range(l):
        sum = 0
        for p in range(m):
            sum += (a[n][m] * b[m][l])
        print(sum, end = "")
        if o != l-1:
            print(" ", end = "")
    print()
            
    



### FIXED CODE ###

n,m,l = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for j in range(m):
    b.append(list(map(int, input().split())))
for  k in range(n):
    for o in range(l):
        sum = 0
        for p in range(m):
            sum += (a[k][p] * b[p][o])
        print(sum, end = "")
        if o != l-1:
            print(" ", end = "")
    print()
M1 = int(input())
D1 = int(input())
M2 = int(input())
D2 = int(input())

if D2 == 1:
    print(1)
else:
    print(0)


### FIXED CODE ###

date_entry_1 = input()
M1, D1 = map(int, date_entry_1.split(' '))
date_entry_2 = input()
M2, D2 = map(int, date_entry_2.split(' '))

if D2 == 1:
    print(1)
else:
    print(0)
N, Q = map(int, input().split())
ki = [[[],0] for i in range(N)]
result = [0]*N

def dfs(i, num, ki, result):
    num_tmp = num+ki[i][1]
    result[i] = num_tmp
    if not ki[i][0]:
        return
    for i in ki[i][0]:
        dfs(i, num_tmp, ki, result)
    return

for i in range(N-1):
    a, b = map(int, input().split())
    ki[a-1][0].append(b-1)

for i in range(Q):
    p, x = map(int, input().split())
    ki[p-1][1] += x

dfs(0, 0, ki, result)
tmp = ""
for i in result:
    tmp += str(i) + " "
print(tmp.rstrip())

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
n,q=[int(_) for _ in input().split()]
ki=[[] for _ in range(n)]
ans=[0]*n
 
def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)
 
for i in range(n-1):
    a,b=[int(_) for _ in input().split()]
    ki[a-1].append(b-1)
    ki[b-1].append(a-1)
 
for i in range(q):
    p,x=[int(_) for _ in input().split()]
    ans[p-1]+=x
 
dfs(0,-1)
print(*ans)
class Sieve:
    """区間[2,n]の値を素因数分解する"""

    def __init__(self, n=1):
        primes = []
        f = [0] * (n + 1)
        f[0] = f[1] = -1
        for i in range(2, n + 1):  # 素数を探す
            if f[i]: continue
            primes.append(i)
            f[i] = i  # 素数には自身を代入
            for j in range(i * i, n + 1, i):  # 合成数に素因数を書き込む
                if not f[j]:
                    f[j] = i  # 最小の素因数を代入
        self.primes = primes
        self.f = f

    def is_prime(self, x) -> bool:  # 素数判定
        return self.f[x] == x

    def factor_list(self, x) -> list:  # 素因数分解の昇順リスト, [2,2,3,5,...]
        res = []
        while x != 1:
            res.append(self.f[x])
            x //= self.f[x]
        return res

    def factor(self, x) -> list:  # 素因数分解の頻度リスト, [[2,x],[3,y],[5,z],...]
        fl = self.factor_list(x)
        if not fl: return []
        res = [[fl[0], 0]]
        for p in fl:
            if res[-1][0] == p:
                res[-1][1] += 1
            else:
                res.append([p, 1])
        return res


def main():
    from collections import defaultdict

    MOD = 10 ** 9 + 7
    A_MX = 10 ** 6

    N = int(input())
    *a, = map(int, input().split())

    s = Sieve(n=A_MX)

    lcm = defaultdict(int)

    factors = []
    for x in a:
        f = [0] * (A_MX + 1)
        for prime, cnt in s.factor(x):
            lcm[prime] = max(lcm[prime], cnt)
            f[prime] = cnt
        factors.append(f)

    ans = 0
    for f in factors:
        t = 1
        for prime, cnt in lcm.items():
            power = max(0, cnt - f[prime])
            t *= pow(prime, power, MOD)
            t %= MOD
        ans += t
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from functools import reduce

    def gcd(a, b):
        return a if b == 0 else gcd(b, a % b)

    def lcm(a, b):
        return a * b // gcd(a, b)

    mod = 10 ** 9 + 7

    n = int(input())
    *a, = map(int, input().split())

    L = reduce(lcm, a)

    ret = 0
    for x in a:
        ret = (ret + pow(x, mod - 2, mod)) % mod
    ret = ret * L % mod
    print(ret)


if __name__ == '__main__':
    main()
N = int(input())
As = list(map(int, input().split()))
judge = max(As)
max_index = As.index(judge)
preans = []
hand = 1000
kabu = 0
while As:
    a = As.pop(0)
    if a < judge:
        preans.append(a)
    else:
        buy = min(preans)
        while hand >= buy:
            kabu += 1
            hand-= buy
        hand += kabu * a
        kabu = 0
        preans = []
        if As:
            judge = max(As)
print(hand)

### FIXED CODE ###

N = int(input())
As = list(map(int, input().split()))
yen = 1000
kabu = 0
for n in range(N-1):
    if As[n] < As[n+1]:
        kabu += yen // As[n]
        yen -= kabu * As[n]
        yen += kabu * As[n+1]
        kabu = 0
print(yen)
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    # 左から埋めていく場合と
    # 右から埋めていく場合
    #A = []
    #for i in range(n):
    #    A.append(int(input()))
    A = [input() for _ in range(n)]
    
    left = [0] * (n+1)
    right = [0] * (n+1)
    for i in range(1,n+1):
        left[i] = max(left[i-1],A[i-1])
    for i in range(n-2,-1,-1):
        right[i] = max(right[i+1],A[i+1]) # right[i]なのか
    for i in range(n):
        print(max(left[i],right[i]))
if __name__ == '__main__':
  main()


### FIXED CODE ###

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    LIST = []
    for i in range(n):
        LIST.append(int(input()))
    s_L = sorted(LIST,reverse=True)
    ma_1 = s_L[0]
    ma_2 = s_L[1]

    for i in range(n):
        if LIST[i] != ma_1:
            print(ma_1)
        else:
            print(ma_2)

if __name__ == '__main__':
  main()
x= input()
a = int(x[0])
b = int(x[1])
print(a*b)end
print(a*2+b*2)

### FIXED CODE ###

x=input().split()
a = int(x[0])
b = int(x[1])

print( a*b , a*2+b*2 )
s=input()
k=int(input())

cnt=0
l=len(s)
i=0
flag=1
while(i<l-1):
    if s[i]==s[i+1]:
        cnt+=1
        i+=2
    else:
        i+=1

cnt2=cnt

if s[0]==s[1]:
    i=1
    cnt2=1
    while(i<l-1):
        if s[i]==s[i+1]:
            if i+1==l-1:
                flag=0
            cnt2+=1
            i+=2
        else:
            i+=1


if s[0]==s[-1]:
    ans=cnt*(k//2+k%2)+cnt2*(k//2)
else:
    ans=cnt*k
        
print(ans)

### FIXED CODE ###

s=input()
k=int(input())


l=len(s)


if len(s)==1:
    print(k//2)
else:
    i=0
    cnt=0
    flag1=0
    while(i<l-1):
        if s[i]==s[i+1]:
            cnt+=1
            if i+1==l-1:
                flag1=1
            i+=2
        else:
            i+=1
    
    #cnt2=cnt
    
    i=1
    cnt2=1
    flag2=0
    while(i<l-1):
        if s[i]==s[i+1]:
            cnt2+=1
            if i+1==l-1:
                flag2=1
            i+=2
        else:
            i+=1
    
    #print(cnt,cnt2,flag1,flag2)
    if s[0]==s[-1]:
        if flag1==1:
            ans=cnt*k
        elif flag2==1:
            ans=(k//2+k%2)*cnt+(k//2)*cnt2
        else:
            ans=cnt+cnt2*(k-1)
    else:
        ans=cnt*k
            
    print(ans)
import bisect
a, b, c, d, e, f = [int(item) for item in input().split()]

water = set()
for i in range(31):
    for j in range(31):
        w = i*a + j*b 
        if w <= f // 100:
            water.add(w)
sugar = set()
for i in range(1501):
    j = 0
    while i*c + j*d <= 1500:
        sugar.add(i*c + j*d)
        j += 1
sugar = sorted(sugar)
ans = []
for w in water:
    sid = bisect.bisect_left(sugar, w*e)
    while sugar[sid] + w*100 > f:
        sid -= 1
    if w != 0:
        total = w*100 + sugar[sid]
        ans.append([sugar[sid]/total, total, sugar[sid]])
ans.sort(key=lambda x:x[0])
print(ans[-1][1], ans[-1][2])

### FIXED CODE ###

import bisect
a, b, c, d, e, f = [int(item) for item in input().split()]

water = set()
for i in range(31):
    for j in range(31):
        w = i*a + j*b 
        if w <= f // 100:
            water.add(w)
water = sorted(water)
sugar = set()
for i in range(1501):
    j = 0
    while i*c + j*d <= 1500:
        sugar.add(i*c + j*d)
        j += 1
sugar = sorted(sugar)
ans = []
for w in water:
    sid = bisect.bisect_right(sugar, w*e) - 1
    while sugar[sid] + w*100 > f and sid > 0:
        sid -= 1
    if w != 0:
        total = w*100 + sugar[sid]
        ans.append([sugar[sid]/total, total, sugar[sid]])
ans.sort(key=lambda x:x[0])
print(ans[-1][1], ans[-1][2])
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
flag = False
for t in range(T+1)
    if (B+W*T==A+V*T):
        flag = True
if flag:
    print("NO")
else:
    print("YES")

### FIXED CODE ###

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if abs(B-A)<=(V-W)*T:
  print("YES")
else:
  print("NO")
n = input()
a = list(map(int,[input() for i in range(5)]))
print(n // min(a) + 5) 


### FIXED CODE ###

import math
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
miti=[a,b,c,d,e]
mini=min(miti)
retu=math.ceil(n/mini)
print(4+retu)
s = list(input())
ans_list=[]
for i in range(len(s)):
    if(s[i] == "0"):
        ans_list.append("0")
    elif(s[i] == "1"):
        ans_list.append("1")
    elif(s[i] == "B"):
        if(ans_list != 0):
            ans_list.pop()
        else:
            continue
for i in range(len(ans_list)):
    print(ans_list[i],end='')



### FIXED CODE ###

s = list(input())
ans_list=[]
for i in range(len(s)):
    if(s[i] == "0"):
        ans_list.append("0")
    elif(s[i] == "1"):
        ans_list.append("1")
    elif(s[i] == "B"):
        if(len(ans_list) != 0):
            ans_list.pop()
        else:
            continue
for i in range(len(ans_list)):
    print(ans_list[i],end='')
s=input()

t=input()
ans=0

for i in range(3):
    if s[i]==t[i]:
        ans+=1

print(ans)

### FIXED CODE ###

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

count = 0
count_list = [0]

for i in range(n-1):
	if(h[i+1] <= h[i]):
		count += 1
		count_list.append(count)
	else:
		count = 0

print(max(count_list))
a,b,c = map(raw_input().split(), int)
if a+c == 2*b:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

a,b,c = map(int,input().split())
if a+c == 2*b:
	print('YES')
else:
	print('NO')
k=int(input())
import math
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
          	a=math.gcd(i,j)
            ans+=math.gcd(a,l)
print(ans)

### FIXED CODE ###

k=int(input())
import math
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        a=math.gcd(i,j)
        for l in range(1,k+1):
            ans+=math.gcd(a,l)
print(ans)
N = int(input())
B = list(map(int, input().split()))

L = B[:]
for i in range(N - 1):
    if (i >= N - 2):
        break
    elif (i == 0 and B[0] > B[1]):
        p = L.pop(0)
        L.append(p)
    elif (B[i] > B[i + 1]):
        L.pop(i)

if (len(L) == 1):
    print(sum(B) * 2)
else:
    print(sum(L) + L[-2])


### FIXED CODE ###

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

ans = B[0] + B[-1]
for i in range(1, N - 1):
    ans += min(B[i], B[i - 1])

print(ans)
t,a=map(int,input().split())
li = list(map(int,input().split()))

listT=[0]*n
for i in range(n):
  listT[i]=t-0.006*li[i]
#print(listT)
min=abs(listT[0]-a)
#print(listT[0]-a)
#print(min)
ans=1
for i in range(n):
  if min>abs(a-listT[i]):
    min=abs(listT[i])
    ans=i+1

print(ans)

### FIXED CODE ###

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

listT=[0]*n
for i in range(n):
  listT[i]=t-0.006*li[i]
#print(listT)
min=abs(listT[0]-a)
#print(listT[0]-a)
#print(min)
ans=1
for i in range(n):
  if min>abs(a-listT[i]):
    min=abs(a-listT[i])
    ans=i+1

print(ans)
import math

r = input()
r = int(r)

area = math.pi * (r ** 2)
length = 2 * math.pi * r

print("{0:.5f} {1:.5f}".format(area, length))

### FIXED CODE ###

import math

r = input()
r = float(r)

area = math.pi * (r ** 2)
length = 2 * math.pi * r

print("{0:.5f} {1:.5f}".format(area, length))
inputs = list(input().split())

n = inputs[0]
points = [int(s) for s in inputs[1:]]

get_point = sum(points)

while get_point % 10 == 0:
    get_point -= min(points)
    if get_point <= 0:
        break

print(get_point)

### FIXED CODE ###

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

points = [int(s) for s in inputs]
points_sorted = sorted(points)

get_point = sum(points_sorted)
non_10 = [x for x in points_sorted if (x % 10 != 0)]

if get_point % 10 != 0:
    print(get_point)
elif non_10 == []:
    print(0)
else:
    print(get_point - min(non_10))
a, b = input().split()
a = int(a)
bx100 = int(b.repleace('.', ''))
print(a * bx100 // 100)

### FIXED CODE ###

a, b = input().split()
a = int(a)
bx100 = int(b.replace('.', ''))
print(a * bx100 // 100)
x,y = map(int,input().split())

if y<x<0 or 0<y<x:
    print(abs(x-y)+2)
elif y<x=0 or 0=y<x:
    print(abs(x-y)+1)
elif x<=y<=0 or 0<=x<=y:
    print(abs(x-y))
elif x<0<y or y<0<x:
    print(abs(abs(x)-abs(y))+1)

### FIXED CODE ###

x,y = map(int,input().split())

if y<x<0 or 0<y<x:
    print(abs(x-y)+2)
elif (y<x and x==0) or (y==0 and y<x):
    print(abs(x-y)+1)
elif x<=y<=0 or 0<=x<=y:
    print(abs(x-y))
elif x<0<y or y<0<x:
    print(abs(abs(x)-abs(y))+1)
n_str = input()

op_count = len(n) - 1  # すき間の個数
for i in range(2 ** op_count):
    op_list = ["-"] * op_count    # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_count):    # iの右からj+1番目のbitが1かどうかを確認
        if ((i >> j) & 1):
            op_list[len(op_list) - 1 -j] = "+"

    op_list.append("")
    formula = ""
    for i in range(len(n_str)):
        formula += (n_str[i] + op_list[i])
    if eval(formula) == 7:
        print(formula + "=7")
        break

### FIXED CODE ###

n_str = input()

op_count = len(n_str) - 1  # すき間の個数
for i in range(2 ** op_count):
    op_list = ["-"] * op_count    # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_count):    # iの右からj+1番目のbitが1かどうかを確認
        if ((i >> j) & 1):
            op_list[len(op_list) - 1 -j] = "+"

    op_list.append("")
    formula = ""
    for i in range(len(n_str)):
        formula += (n_str[i] + op_list[i])
    if eval(formula) == 7:
        print(formula + "=7")
        break
a=input()
ans=a+a^2+a^3
print(ans)

### FIXED CODE ###

a = int(input())
print(a+a**2+a**3)