Harryxun/stf_run huggingface dataset:
import bisect
import collections

x, n = map(int, input().split())
p = list(map(int, input().split()))
l = [i for i in range(1, 101)]

def calc(a):
    return abs(a - x)

if n == 0:
    print(x)
    exit()

if x in l:
    l.remove(x) 
for i in p:
    if i in l:
        l.remove(i)

l2 = list(map(calc, l))
m = min(l2)

if collections.Counter(l2)[m] == 2:
    print(-m + x)
else:
    print(m + x)


### FIXED CODE ###

x, n = map(int, input().split())
if n != 0:
    l = list(map(int, input().split()))
else:
    l = []

diff = 10**18
ans = 10**18

for i in range(-10000, 10000):
    if i in l:
        continue
    else:
        if abs(x-i) < diff:
            ans = i
            diff = abs(x-i)

print(ans)
n,k = map(int, input().split())
a = list(map(int, input().strip().split()))

for i in range(len(a)):
    a[i] -= 1

visited = [-1] * n
now = 0
visited[0] = 0
pre_roop = 0
pos = 0
i = 1
while i < k:
    next = a[now]
    #print('roop:',i,now+1,next+1)
    if visited[next] >= 0:
        r = i-visited[next]
        pre_roop = visited[next]
        pos = next
        #print(i,r,pre_roop,next)
        #print(visited)
        break
    else:
        visited[next] = i
        now = next
        #print(i,visited)
        i += 1
l = (k - pre_roop) % r
#print(l)
i = 0
p = pos
while i < l:
    p = a[p]
    i +=1

print(p+1)



### FIXED CODE ###

n,k = map(int, input().split())
a = list(map(int, input().strip().split()))

for i in range(len(a)):
    a[i] -= 1

visited = [-1] * n
now = 0
visited[0] = 0
pre_roop = 0
pos = 0
i = 1
r = 1
while i <= k:
    next = a[now]
    #print('roop:',i,now+1,next+1)
    if visited[next] >= 0:
        r = i-visited[next]
        pre_roop = visited[next]
        pos = next
        #print(i,r,pre_roop,next)
        #print(visited)
        break
    else:
        visited[next] = i
        now = next
        #print(i,visited)
        i += 1

if i > k:
    print(now + 1)
else:
    l = (k - pre_roop) % r
    #print(l)
    i = 0
    p = pos
    while i < l:
        p = a[p]
        i +=1

    print(p+1)
s = input()
if(len(s) == 0):
    print('a')
if(len(s) != 26):
    for c in range(ord('a'), ord('z')+1):
        c = chr(c)
        if(not c in s):
            print(s+c)
            exit()
s = list(s)
t = []
while(True):
    for c in t:
        if(c > s[-1]):
            print(''.join(s[:-1]) + c)
            exit()
    t.append(s.pop())


### FIXED CODE ###

s = input()
if(len(s) != 26):
    for c in range(ord('a'), ord('z')+1):
        c = chr(c)
        if(not c in s):
            print(s+c)
            exit()
s = list(s)
t = []
while(s):
    for c in t:
        if(c > s[-1]):
            print(''.join(s[:-1]) + c)
            exit()
    t.append(s.pop())
print(-1)
A, B = int(input().split())
return (A*3 + B)//2 

### FIXED CODE ###

A,P = map(int,input().split())
print((3*A+P)//2)
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys
import math

n = int(input())
anss = []

for _ in range(n):
    x = int(input())
    y = int(input())
    anss.append(x+y)
    if int(math.log10(x)+1) > 80:
        print("overflow")
    elif int(math.log10(y)+1) > 80:
        print("overflow")
    elif int(math.log10(x+y)+1) > 80:
        print("overflow")

for data in anss:
    print(data)

### FIXED CODE ###

#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys
import math

n = int(input())
result = 0

for i in range(n):
    result = 0
    x = int(input())
    y = int(input())

    result = x + y
    length = len(str(result))
    if length > 80:
        print("overflow")
    else:
        print(result)
D=int(input())
T=int(input())
S=int(input())
if D<=T*S:
  print('Yes')
elif D>T*S:
  print('No')

### FIXED CODE ###

D,T,S=map(int,input().split())
if D<=T*S:
  print('Yes')
elif D>T*S:
  print('No')
N,M=map(int, input().split())
A=list(map(int, input().split()))
import numpy
D=list(numpy.cumsum(A))
C={}
for i in D:
  d=i%M
  if d not in C:
    C[d]=1
  else:
    C[d]+=1
#print(C)

ans=0
for i in C.values():
  ans+=i*(i-1)//2
#余り0はそれ単独でok
ans+=C[0]
print(ans)

### FIXED CODE ###

N,M=map(int, input().split())
A=list(map(int, input().split()))
import numpy
D=list(numpy.cumsum(A))
C={}
for i in D:
  d=i%M
  if d not in C:
    C[d]=1
  else:
    C[d]+=1
#print(C)

ans=0
for i in C.values():
  ans+=i*(i-1)//2
#余り0はそれ単独でok
if 0 in C:
  ans+=C[0]
print(ans)
print(sum(range(int(input())+1))

### FIXED CODE ###

n=int(input());print(int(n*(1+n)/2))
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
numk={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
dp=[0]+[-float('inf')]*(N)
for i in range(N):
  for j in A:
    if i+numk[j]<=N:
      dp[i+numk[j]]=max(dp[i+numk[j]],dp[i]+1)
m=N
ans=[]
while m>0:
  for i in A:
    if dp[m-numk[i]]+1==dp[m] and m-numk[i]>=0:
      ans.append(str(i))
      m-=numk[i]
      break
print(''.join(ans))

### FIXED CODE ###

N,M=map(int,input().split())
num={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
A=list(map(int,input().split()))
A.sort(reverse = True)
dp = [0]+[-1]*(N+1)
for i in range(N):
    for j in A:
        if i+num[j]<=N:
            dp[i+num[j]] = max(dp[i+num[j]],dp[i]+1)
ans = []
m=N
while m>0:
    for i in A:
        if m-num[i]>=0 and dp[m-num[i]]==dp[m]-1:
          m-=num[i]
          ans.append(str(i))
          break
print("".join(ans))
import math
n=int(input())
l=list(map(int, input().split()))
for i in range(n):
    l[i]-=(i+1)
avg=sum(l)/n
fb=math.floor(avg)
cb=math.ceil(avg)
sadf=sadc=0
for i in l:
    sadf+=abs(i-fb)
    sadc+=abs(i-cb)

sad=min(sadf, sadc)
print(sad)

### FIXED CODE ###

n=int(input())

if n%2==0:
    print(n)
else:
    print(n*2)
num=int(input())
if num>81:
    return('No')
else:
    num_list=[]
    
    for a in range(1,10):
        for b in range(1,10):
            num_list.appned(a*b)
    num_list=set(num_list)
    if num in num_list:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

num=int(input())
if num>81:
    print('No')
else:
    num_list=[]
    
    for a in range(1,10):
        for b in range(1,10):
            num_list.append(a*b)
    num_list=set(num_list)
    if num in num_list:
        print('Yes')
    else:
        print('No')
n, k = map(int, input().split())
A = list(map(int, input().split()))

Town = []
#まだ訪れていない町はTrue
rec = [True] * (n+1)
idx = 1
#周期までループをまわす
while rec[idx]:
    rec[idx] = False
    Town.append(idx)
    idx = A[idx-1]

#周期前
Exce = Town.index(idx)
#周期内
Cycl = len(Town) - Exce

if Cycl >= k:
    print(Town[k])
else:
    k -= Exce
    k %= Cycl
    print(Town[Exce+k])

### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))

Town = []
#まだ訪れていない町は-1
rec = [-1] * (n+1)
idx = 1
#周期までループをまわす
while (rec[idx] == -1):
    rec[idx] = len(Town)
    Town.append(idx)
    idx = A[idx-1]

#周期前
Exce = rec[idx]
#周期内
Cycl = len(Town) - Exce

if Exce > k:
    print(Town[k])
else:
    Warp = (k - Exce) % Cycl
    print(Town[Exce+Warp])
a,b = list(map(int, input().split()))
n = list(map(int, input().split()))

c = 0
ris = 0
lenn = len(n)
for i, name in enumerate(n[::-1]):
    if name < 0:
        c += 1
    if c == b-1:
        ri = i
        rs = name
        ris = lenn - ri - 1
        break

ans = []
ans_sum = []
for i in range(b+1):
    if ris+b+i > lenn:
        break
    iii = n[(ris+i):(ris+b+i)]
    ans.append(iii)
    lln = iii[0]
    rrn = iii[-1]
    ll = abs(lln)
    rr = abs(rrn)
    if lln >=0 and rrn > 0:
        ans_sum.append(rr)
    elif lln <0 and rrn <=0:
        ans_sum.append(ll)
    elif ll <= rr:
        ans_sum.append(2*ll + rr )
    else:
        ans_sum.append(ll + 2*rr)

print(min(ans_sum))

### FIXED CODE ###

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

ans = []
for i, name in enumerate(n):
    if b+i >a:
        break
    ans.append(min( (abs(n[i]) + abs(n[i +b-1] - n[i]),  abs(n[i+b-1]) + abs(n[i +b-1] - n[i]) )) )

print(min(ans))
n,a,b=map(int,input().split())
c=1
d=1
e=0
f=0
for i in range(n):
    if i+1==a:
        continue
    if i+1==b:
        continue
    for j in range(i+1):
        c*=(n-j)
        d*=(1+j)
    f=(int(c))/(int(d))
    e=e+f
    c=1
    d=1
e=int(e//1)
e=e%(10^9+7)
print(e)


### FIXED CODE ###

n,a,b=map(int,input().split())
num9=10**9+7
num2=pow(2,n,num9)-1
def cul(num1,num2):
    num=1
    for i in range(num1-num2+1,n+1):
        num*=i
        num%=num9
    for i in range(1,num2+1):
        num*=pow(i,num9-2,num9)
        num%=num9
    return num
print((num2-cul(n,a)-cul(n,b))%num9)
a=[]
for i in range(5):
    a.append(int(input()))

if (max(a)-min(a)) > input():
    print(":(")
else:
    print("Yay!")

### FIXED CODE ###

a=[]
for i in range(5):
    a.append(int(input()))

if (max(a)-min(a)) > input():
    print(":(")
else:
    print("Yay!")
a,p = [int(_) for _ in input()]
print((a*3+p)//2)

### FIXED CODE ###

a,p = [int(_) for _ in input().split()]
print((a*3+p)//2)
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

cnt=0

for i in range(n):
  if a[n-i]>=b[n-1-i]:
    cnt+=b[n-1-i]
  else:    
    if a[n-1-i]-(b[n-1-i]-a[n-i])>=0:
      a[n-1-i]-=b[n-1-i]-a[n-i]
      cnt+=b[n-1-i]
    else:
      cnt+=a[n-i]+a[n-1-i]
      a[n-1-i]=0
      
print(cnt)


### FIXED CODE ###

a,b=map(int,input().split())
if (a+b)%2==0:
    print((a+b)//2)
else:
    print('IMPOSSIBLE')
import math
N = int(input())
A = list(map(int,input().split()))
b = [[0]*60 for i in range(2)]
max_a = math.ceil(math.log2(max(A)))
for i in range(N):
    x = A[i]
    j = 0
    for j in range(max_a):
        b[x % 2][j] += 1
        x //= 2

x = 0
for i in range(max_a):
    x += b[0][i] * b[1][i] * 2**i
    x %= 10 ** 9 + 7

print (x)

### FIXED CODE ###

import math
N = int(input())
A = list(map(int,input().split()))
b = [[0]*60 for i in range(2)]
#max_a = math.ceil(math.log(max(A),2))
max_a = 60
for i in range(N):
    x = A[i]
    j = 0
    for j in range(max_a):
        b[x % 2][j] += 1
        x //= 2

x = 0
for i in range(max_a):
    x += b[0][i] * b[1][i] * 2**i
    x %= 10 ** 9 + 7

print (x)
A, B = map(int input().split())
cou = B//100 - A//100
Astr = str(A)
Aup = 10 * int(Astr[1]) + int(Astr[0])
Adown = A%100
Bstr =str(B)
Bup = 10 * int(Bstr[1]) + int(Bstr[0])
Bdown = B%100
if Adown < Aup :
    cou += 1
if Bdown > Bup :
    cou += 1
print(cou)

### FIXED CODE ###

A, B = map(int, input().split())
cou = 0
while A != (B + 1):
    Astr = str(A)
    if int(Astr[0]) == int(Astr[4]) and int(Astr[1]) == int(Astr[3]):
        cou = cou + 1
    A = A + 1
print(cou)
n = int(input())
a = [int(i) for i in input().split()]
c = 0
i = 0

while a[i]%2 == 0:
  if a[i]%2 ==0:
    a[i]//=2
  if i == n-1:
    count +=1
    i = 0
  i += 1
print(count)

### FIXED CODE ###

s = input()
 
x = 0
 
 
for i in range(len(s)):
  if s[i] == "1":
    x += 1
  
print(x)
from collections import defaultdict
import sys
input = sys.stdin.readline

N, M = list(map(int, input().split()))
node2set_id = defaultdict(int)
set_id2nodes = defaultdict(set)

# idxなどを振る
id_left = [i+1 for i in range(M)]
for i in range(M):
    x, y, z = list(map(int, input().split()))
    #print("from ", set_id2nodes)
    if node2set_id[x] + node2set_id[y] == 0:
        id = id_left.pop()
        # x,yが所属するグループIDを振る
        node2set_id[x] = id
        node2set_id[y] = id

        # グループIDに対するセットを追加
        set_id2nodes[id] |= {x, y}

    elif node2set_id[x] * node2set_id[y] == 0:
        id = node2set_id[x] + node2set_id[y]
        node2set_id[x] = id
        node2set_id[y] = id
        set_id2nodes[id] |= {x, y}
    else:
        if node2set_id[x] - node2set_id[y] == 0:
            continue
        id = node2set_id[x]
        prev_y = y

        # yが所属するグループIDをすべてxのものに置き換える
        for y_idx in set_id2nodes[node2set_id[y]]:
            print(id, y_idx)
            node2set_id[y_idx] = id
            set_id2nodes[id] |= {y_idx}
        #print("x:{},y:{}, prev:{}".format(x, y, prev_y))
        set_id2nodes[prev_y] = {}
    #print("after ", set_id2nodes)
# print([len(m) - 1 for m in set_id2nodes.values()])
num = sum([max(len(m) - 1, 0) for m in set_id2nodes.values()])

print(N-num)


### FIXED CODE ###

from collections import defaultdict
import sys
input = sys.stdin.readline

N, M = list(map(int, input().split()))
node2set_id = defaultdict(int)
set_id2nodes = defaultdict(set)

# idxなどを振る
id_left = [i + 1 for i in range(M)]

for i in range(M):
    x, y, z = list(map(int, input().split()))

    # ともにIDが振られていないとき
    if node2set_id[x] + node2set_id[y] == 0:
        id = id_left.pop()
        # x,yが所属するグループIDを振る
        node2set_id[x] = id
        node2set_id[y] = id

        # グループIDに対するセットを追加
        set_id2nodes[id] |= {x, y}

    # どちらか一方にのみIDが振られているとき(片方が0になる)
    elif node2set_id[x] * node2set_id[y] == 0:
        id = node2set_id[x] + node2set_id[y]
        node2set_id[x] = id
        node2set_id[y] = id
        set_id2nodes[id] |= {x, y}

    # 両方振られているとき
    else:
        # 同じIDならそもそも考える必要がない
        if node2set_id[x] - node2set_id[y] == 0:
            continue

        # 異なるグループのときにはマージする
        id = node2set_id[x]
        prev_y = node2set_id[y]

        # yが所属するグループIDをすべてxのものに置き換える
        for y_idx in set_id2nodes[node2set_id[y]]:
            node2set_id[y_idx] = id
            set_id2nodes[id] |= {y_idx}

        del set_id2nodes[prev_y]


num = sum([len(m)-1 for m in set_id2nodes.values()])

print(N - num)
N, M = map(int, input().split())
S, C = [], []
for _ in range(M):
    s, c = map(int, input().split())
    s -= 1
    if s in S:
        if C[S.index(s)] != c:
            print(-1)
            exit()
        else:
            continue
    S.append(s)
    C.append(c)

z = zip(S, C)
z = sorted(z)
S, C = zip(*z)

ans = [-1] * N
for i in range(len(S)):
    ans[S[i]] = C[i]

if ans[0] == 0:
    print(-1)
    exit()

while len(ans) > 0:
    if ans[0] == -1:
        ans = ans[1:]
    else:
        break

if ans == [-1]:
    print(-1)
    exit()

ans = [a if a != -1 else 0 for a in ans]
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
S, C = [], []
for _ in range(M):
    s, c = map(int, input().split())
    s -= 1
    if s in S:
        if C[S.index(s)] != c:
            print(-1)
            exit()
        else:
            continue
    S.append(s)
    C.append(c)

if len(S) == 0:
    if N == 1:
        print(0)
    elif N == 2:
        print(10)
    else:
        print(100)
    exit()

ans = [-1] * N
for i in range(len(S)):
    ans[S[i]] = C[i]

if N == 1:
    if ans[0] == 0:
        print(0)
        exit()

if ans[0] == -1:
    ans[0] = 1
elif ans[0] == 0:
    print(-1)
    exit()

ans = [a if a != -1 else 0 for a in ans]
print(''.join(list(map(str, ans))))
#!/usr/bin/env python3
# coding=utf-8

import sys

import numpy as np

n, k = map(int, sys.stdin.readline().strip().split(" "))
xyc = [l.strip().split(" ") for l in sys.stdin.readlines()]
xy = [tuple((int(_x), int(_y) if _c == "W" else int(_y) + k)) for (_x, _y, _c) in xyc]
xy = [tuple((_x % (2 * k), _y % (2 * k))) for (_x, _y) in xy]

ans = np.zeros((n, 2 * k, 2 * k), dtype=np.uint8)
for _x, _y in xy:
    check = np.zeros((n, 2 * k, 2 * k), dtype=np.uint8)
    check[_x:_x + k] = 1
    if _x > k:
        check[:_x - k] = 1
    check[:, _y:_y + k] = 1 - check[:, _y:_y + k]
    if _y > k:
        check[:, :_y - k] = 1 - check[:, :_y - k]
    check = 1 - check
    ans += check
print(np.max(ans))


### FIXED CODE ###

#!/usr/bin/env python3
# coding=utf-8

import sys

a, b = map(int, sys.stdin.readline().strip().split(" "))

if a % 2 == 1 and b % 2 == 1:
    print("Odd")
else:
    print("Even")
a,b,c = map(int, input().split())

if a=b and b=c a=c:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

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

if a==b and b==c and a==c:
  print('Yes')
else:
  print('No')
s = input()
if l[-1] == 's':
    s += 'es'
else:
    s += 's'

### FIXED CODE ###

s = input()
l = []
for i in s:
  l.append(i)
if l[-1] == 's':
    l.append('es')
    print("".join(j for j in l))
else:
    l.append('s')
    print("".join(j for j in l))
r = input();
print(3 * r * r);


### FIXED CODE ###

r = int(input())
print(3 * r * r)
N = int(input())

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



b = sorted(list(set(A)))

x = set(b)

res = x

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

if b[0]==b[-1]:
    print(0)
    exit()


daburi = []

c = sorted(A)
for i in range(1,N):
    if c[i] == c[i-1]:
        daburi.append(c[i])

daburi = set(daburi)
#print(daburi)

i = 0
while len(x) > 0 :
    tmp = b[i]
    for j in range(2,10**5+3):
        c = tmp* j
        if c in x:
            x.discard(c)
        if b[-1] <= c:
            break
    if len(x) == i:
        break
    i+=1
        
#print(x)
#print(daburi)
print((len(x- daburi)))


### FIXED CODE ###

N = int(input())

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


b = sorted(list(A))
dp = [0]*(max(A)+1)

m_a = max(A)+1
for i in b:
    dp[i] += 1
    if dp[i]==1 :
        for j in range(i*2, m_a,i):
            dp[j] +=100

print(dp.count(1))
N = input()
K = int(input())

a = 1
b = [0] * (K + 1)
b[0] = 1
b[1] = int(N[0]) - 1

for c in N[1:]:
    t = int(c)
    for i in range(K - 1, -1, -1):
        b[i + 1] += b[i] * 9
    if t != 0:
        b[a + 1] += t - 1
        b[a] += 1
        a += 1

if a == K:
    print(b[K] + 1)
else:
    print(b[K])


### FIXED CODE ###

N = input()
K = int(input())

a = [0] * (K + 1)
b = [0] * (K + 1)

t = int(N[0])

a = 1
b[0] = 1
b[1] = t - 1

for c in N[1:]:
    t = int(c)
    for i in range(K - 1, -1, -1):
        b[i + 1] += b[i] * 9
    if t != 0:
        if t != 1 and a + 1 <= K:
            b[a + 1] += t - 1
        if a <= K:
            b[a] += 1
        a += 1

if a == K:
    print(b[K] + 1)
else:
    print(b[K])
(a,b) = map(int,input().split())
print(max(a,b)+max(max(a,b)-1,min(a,b))

### FIXED CODE ###

(a,b) = map(int,input().split())
print(max(a,b)+max(max(a,b)-1,min(a,b)))
n,m = map(int,input().split())
gates = [list(map(int,input().split())) for _ in range(m)]
l = []
r = []
for gate in gates:
    l.append(gate[0])
    r.append(gate[1])
ans = min(r)+1 - max(l)
print(ans if ans > 0 else 0)


### FIXED CODE ###

a,b = map(int,input().split())
if a >= 13:
    print(b)
elif a >= 6:
    print(b//2)
elif a <= 5:
    print(0)
n = int(input())
h = list(map(int, input().split()))
         
if n == 1:
	print("Yes")
else:
	for i in range(n-1):
		if h[i+1] < h[i]:
		h[i+1] -= 1
	for i in range(n-1):
		if h[i+1] < h[i]:
  			print("No")
  			break
	else:
		print("Yes")

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
             
if n == 1:
      print("Yes")
else:
      for i in range(n-1):
            if h[i] < h[i+1]:
                  h[i+1] -= 1
      for i in range(n-1):
            if h[i+1] < h[i]:
                  print("No")
                  break
      else:
            print("Yes")
# D - Lamp

H, W = map(int, input().split())
M = [[str(m) for m in input()] for _ in range(H)]
U = [[0] * W for _ in range(H)]
L = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if i == 0 and M[i][j] != '#':
            U[i][j] = 1
        if j == 0 and M[i][j] != '#':
            L[i][j] = 1
        if i != 0 and j != 0 and M[i][j] != '#':
            U[i][j] = U[i - 1][j] + 1
            L[i][j] = L[i][j - 1] + 1

for i in reversed(range(H)):
    for j in reversed(range(W)):
        if i == H - 1 and M[i][j] != '#':
            D[i][j] = 1
        if j == W - 1 and M[i][j] != '#':
            R[i][j] = 1
        if i != H - 1 and j != W - 1 and M[i][j] != '#':
            D[i][j] = D[i + 1][j] + 1
            R[i][j] = R[i][j + 1] + 1

mx = 0
for i in range(H):
    for j in range(H):
        p = U[i][j] + L[i][j] + D[i][j] + R[i][j] - 3
        mx = max(mx, p)

print(mx)


### FIXED CODE ###

# # D - Lamp

import numpy as np

H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]
M = (np.array(M) == '.') * 1

L = np.zeros((H, W), dtype=int)
R = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)
U = np.zeros((H, W), dtype=int)

for i in range(W):
    if i == 0:
        L[:, i] = M[:, i]
        R[:, W - i - 1] = M[:, W - i - 1]
    else:
        L[:, i] = (L[:, i - 1] + 1) * M[:, i]
        R[:, W - i - 1] = (R[:, W - i] + 1) * M[:, W - i - 1]

for i in range(H):
    if i == 0:
        U[i, :] = M[i, :]
        D[H - i - 1, :] = M[H - i - 1, :]
    else:
        U[i, :] = (U[i - 1, :] + 1) * M[i, :]
        D[H - i - 1, :] = (D[H - i, :] + 1) * M[H - i - 1, :]

print(max(np.max(L + R + D + U - 3), 0))
#import math  
import fractions
from functools import reduce

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def lcm_base(x, y):
    return (x * y) // functools.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
ans = lcm_list(T)

print(ans)

### FIXED CODE ###

#import math  
import fractions
from functools import reduce

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
ans = lcm_list(T)

print(ans)
def main():
    n, m, x, y = list(map(int, input().split()))
    x_list = list(map(int, input().split()))
    y_list = list(map(int, input().split()))
    x_list.append(x)
    y_list.append(y)

    zx = max(x_list) + 1
    zy = min(y_list)

    if zx > zy :
        print('War')
	else:
    	print('No war')


if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    n, m, x, y = list(map(int, input().split()))
    x_list = list(map(int, input().split()))
    y_list = list(map(int, input().split()))
    x_list.append(x)
    y_list.append(y)

    zx = max(x_list) + 1
    zy = min(y_list)

    if zx > zy :
        print('War')
    else:
        print('No War')


if __name__ == '__main__':
    main()
s,w = map(int,input().split)
print(s)

if s<=w:
  print('unsafe')
else:
  print('safe')

### FIXED CODE ###

a,b = map(int, input().split())
print(a*b)
while True:
    n=int(input())
    if n==0:break
    res={}
    li=[]
    for i in range(n):
        d=[int(num) for num in input().split(' ')]
        res[d[0]-1]+=d[1]*d[2]
        if d[0]-1 not in li:li.append(d[0]-1)
    flag=False
    for i in li:
        if res[i]>=1000000:
            print(i+1)
            flag=True
    if flag==False:print("NA")

### FIXED CODE ###

while True:
    n=int(input())
    if n==0:break
    res={}
    li=[]
    for i in range(n):
        d=[int(num) for num in input().split(' ')]
        if d[0]-1 in res:
            res[d[0]-1]+=d[1]*d[2]
        else:
            res[d[0]-1]=d[1]*d[2]
            li.append(d[0]-1)
    flag=False
    for i in li:
        if res[i]>=1000000:
            print(i+1)
            flag=True
    if flag==False:print("NA")
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

X,Y=input_int()

import math

print(int(math.log2(Y) - math.log2(X))+1)

### FIXED CODE ###

def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

X,Y=input_int()
count=0
while X<=Y:
    count+=1
    X*=2
print(count)
import itertools

M, N = map(int, input().split())

lis = [[] for i in range(N)]

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

count = 0
for i in itertools.permutations(list(range(1,N)),N-1):
    s = 0
    for j in range(N-1):
        if i[j] not in lis[s]:
            break
        
        s = i[j]
    else:
        count += 1
    

print(count)

### FIXED CODE ###

import itertools

N, M = map(int, input().split())

path = [[False] * N for i in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    path[a-1][b-1] = True
    path[b-1][a-1] = True

count = 0
for i in itertools.permutations(list(range(N)),N):
    if i[0] == 0:
        for j in range(N):
            if j == N-1:
                count += 1
                break
            if not path[i[j]][i[j+1]]:
                break
    

print(count)
S={c:list(input())for c in"abc"}
s="a"
while S[s]:s=S[s].pop(0)
print(s.upper())

### FIXED CODE ###

print(input()+input())*input()/2