Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
a=list(map(int,input().split()))
from math import gcd
for i in range(n):
	a[i]//=2
from copy import copy
b=copy(a)
while True:
	i=0
	for i in range(n):
		if b[i]%2==0:
			b[i]//=2
		else:
			break
	if i==0:
		break
	else:
		print(0)
		exit()
a_gcd=a[0]
for i in range(1,n):
	a_gcd=a_gcd*a[i]//gcd(a_gcd,a[i])
print((m+a_gcd)//(a_gcd*2))

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
for i in range(n):
	a[i]//=2
from copy import copy
b=copy(a)
c=[]

for i in range(n):
	cnt=0
	while b[i]%2==0:
		cnt+=1
		b[i]//=2
	c.append(cnt)
for i in range(n-1):
	if c[i]!=c[i+1]:
		print(0)
		exit()

a_gcd=a[0]
for i in range(1,n):
	a_gcd=a_gcd*a[i]//gcd(a_gcd,a[i])
print((m+a_gcd)//(a_gcd*2))
n = int(input())
A = list(map(int,input().split()))
ans = 0

for i in range(n):
  if A[i]>A[i+1]:
    A[i+1]=A[i]
    ans += A[i]-A[i+1]

print(ans)

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
ans = 0
 
for i in range(n-1):
  if A[i]>A[i+1]:
    ans += A[i]-A[i+1]
    A[i+1] = A[i]
 
print(ans)
print('Christmas' + ' Eve' * int(input()) % 5)


### FIXED CODE ###

D = int(input())
s = ""
if D == 25:
    s = 'Christmas'
elif D == 24:
    s = 'Christmas Eve'
elif D == 23:
    s = 'Christmas Eve Eve'
elif D == 22:
    s = 'Christmas Eve Eve Eve'

print(s)
import statistics

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

for i in range(N):
    A[i] = A[i] - (i + 1)

b = median_low(A)
ans = 0

for i in range(N):
    ans += abs(A[i] - b)

print(ans)



### FIXED CODE ###

from statistics import median_low

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

for i in range(N):
    A[i] = A[i] - (i + 1)

b = median_low(A)
ans = 0

for i in range(N):
    ans += abs(A[i] - b)

print(ans)
import copy

def cnt(a, m, i):
    if a[i] < m:
        a[i] += 1
    else:
        a = cnt(a, m, i-1)
        a[i] = copy.deepcopy(a[i-1])
    return a

def check(a, ab):
    score = 0
    for i in range(q):
        ai, bi = ab[i][0], ab[i][1]
        if a[bi] - a[ai] == ab[i][2]:
            score += ab[i][3]
    return score
  
n, m, q = map(int,input().split())
ab = []
for i in range(q):
    ab.append(list(map(int,input().split())))
ab = sorted(ab, key=lambda x:(x[3]), reverse=True)
# print(ab)
a = [1] * (n+1)
ans = 0
while a[0] == 1:
    x = check(a, ab)
    ans = max(ans, x)
    # print(a, ans)
    a = cnt(a, m, -1)
print(ans)



### FIXED CODE ###

import copy

def cnt(a, m, i):
    if a[i] < m:
        a[i] += 1
    else:
        a = cnt(a, m, i-1)
        a[i] = copy.deepcopy(a[i-1])
    return a

def check(a, ab):
    score = 0
    for i in range(q):
        ai, bi = ab[i][0], ab[i][1]
        if a[bi] - a[ai] == ab[i][2]:
            score += ab[i][3]
    return score
  
n, m, q = map(int,input().split())
ab = []
for i in range(q):
    ab.append(list(map(int,input().split())))

a = [1] * (n+1)
a[0] = 0
ans = 0
while a[0] == 0:
    x = check(a, ab)
    ans = max(ans, x)
    # print(a, ans)
    a = cnt(a, m, -1)
print(ans)
a,b = int(raw_input().split(" "))
print a * b, 2*(a + b)

### FIXED CODE ###

x = raw_input().split(" ")
a = int(x[0])
b = int(x[1])
print a * b, 2*(a + b)
n = int(input())
a=map(int, input().split())
print(sum(a) - len(a))

### FIXED CODE ###

n = int(input())
a=list(map(int, input().split()))
print(sum(a) - len(a))
import math

 

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

pair = {N:S,M:T}

def lcd(N,M):
    return int(M*N/math.gcd(N,M))
def prove(n,m):
    global pair
    mul = int(n/m)
    c = "".join([pair[n][mul*i] for i in range(len(pair[m]))])
#    print(c)
#    print(pair[m])
    if c== pair[m]:
        print (m)
    else:
        print (-1)
if max(N,M) % min(N,M) == 0:
    n = max(pair.keys())
    m = min(pair.keys())
    prove(n,m)
else:
    print(lcd(N,M))


### FIXED CODE ###

import math

 

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

pair = {N:S,M:T}


def lcd(n,m):
    return int(n * m / gcd(n,m))
def gcd(n,m):
    if n % m == 0:
        return m
    else:
        return gcd(m,n % m)
#    return int(m*n/math.gcd(n,m))
    
def prove(n,m):
    if gcd(n,m)==1:
        return lcd(n,m)
    global pair
    n_i = int(n/gcd(n,m))
    m_i = int(m/gcd(n,m))
    n_list = pair[n][::n_i]
    m_list = pair[m][::m_i]
#    print(c)
#    print(pair[m])
    if n_list[0:len(m_list)]==m_list:
        return lcd(n,m)
    else:
        return -1
n = max(pair.keys())
m = min(pair.keys())
if pair[N][0]!=pair[M][0]:
    print(-1)
elif N==M:
    if S==T:
        print(N)
    else:
        print(-1)
else:
    print(prove(n,m))
x, y, a, b, c = map(int,input().split())
p = [list(map(int,input().split())) for _ in range(3)]

for i, e in enumerate(p):
    p[i] = list(sorted(e,reverse=True))

g, h = 0, 0
ans = 0
for i in range(x):
    if p[0][i] >= p[2][g]:
        ans += p[0][i]
    else:
        if p[1][h] < p[0][i]:
            ans += p[0][i]
            h += 1
        else:
            ans += p[2][g]
            g += 1
            p[2][g] = 0

for i, e in enumerate(p):
    p[i] = list(sorted(e,reverse=True))

g = 0
for i in range(y):
    if p[1][i] >= p[2][g]:
        ans += p[1][i]
    else:
        if g >= c:
            ans += p[1][i]
        else:
            ans += p[2][g]
            g += 1
print(ans)

### FIXED CODE ###

x, y, a, b, c = map(int,input().split())
p = (list(map(int,input().split())))
q = (list(map(int,input().split())))
r = (list(map(int,input().split())))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:x]
q = q[:y]
apple = p + q + r
apple.sort(reverse=True)
ans = sum(apple[:x+y])
print(ans)
s = list(input())

res = 0
max = 0
for i in s:
  if i == 'A' or i == 'T' or i == 'C' or i == 'G':
    res += 1
  elif max <res:
    max = res
    res = 0
  else:
    res = 0

if max < res:
  max = res
-
print(max)

### FIXED CODE ###

s = list(input())

res = 0
max = 0
for i in s:
  if i == 'A' or i == 'T' or i == 'C' or i == 'G':
    res += 1
  elif max <res:
    max = res
    res = 0
  else:
    res = 0

if max < res:
  max = res

print(max)
from fractions import gcd
import math
a,b = map(int,input().split())
n = gcd(a,b)
integer = [i for i in range(2,n+1)]
prime = set()
while integer[0] <= math.sqrt(n):
    p = integer[0] 
    prime.add(p)
    integer = [i for i in integer if i % p != 0]
prime = prime | set(integer)
count = 1
for i in prime:
    if n == 1:
        break
    if n % i == 0:
        count += 1
        while n % i == 0:
            n //= i
print(count)


### FIXED CODE ###

from fractions import gcd
import math
a,b = map(int,input().split())
n = gcd(a,b)
if n == 1:
    print(1)
    exit()
count = 1
for i in range(2,math.ceil(math.sqrt(n))+1):
    if n % i == 0:
        count += 1
        while n % i == 0:
            n //= i
if n > 1:
    count += 1
print(count)
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lis1 = [i for i in range(1,N+1)]
lis2 = [i for i in range(1,N+1)]
def number(a, lis):
  total_order = 1
  for i in range(N):
    tmp_order = lis.index(a[i])
    lis.remove(a[i])
    total_order += tmp_order * math.factorial(len(lis))
  return total_order
print(abs(number(P, lis1) - number(Q, lis2)))


### FIXED CODE ###

import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lis1 = [i for i in range(1,N+1)]
lis2 = [i for i in range(1,N+1)]
def number(a, lis):
  total_order = 1
  for i in range(N):
    tmp_order = lis.index(a[i])
    lis.remove(a[i])
    total_order += tmp_order * math.factorial(len(lis))
  return total_order
print(abs(number(P, lis1) - number(Q, lis2)))
N = int(input())
A = list(map(int, input().strip().split()))
count = 0
for i in range(N):
  if not i == A[i]:
    count+=1
    if A[i]+A[N-i]==N+1:
      continue
    if count >=3:
      break
      print("NO")
    print("YES")
    

### FIXED CODE ###

N = int(input())
A = list(map(int, input().strip().split()))
count = 0
for i in range(N):
  if i+1 == A[i]:
    count+=0
  else:
    count+=1
if count == 2:
  print("YES")
elif count ==0:
  print("YES")
else:
  print("NO")
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
Amod = [A for A in map(lambda x: int(x) % M ,filter(lambda x: int(x) % M > 0, input().split()))]
ans = 0
for l in range(len(Amod)):
    acm = 0
    for r in range(l, len(Amod)):
        acm = (acm + Amod[r]) % M
        if acm == 0: ans += 1

print(ans)

### FIXED CODE ###

# encoding: utf-8

n, k = input().split()

if int(n) % int(k) == 0: print(0)
else: print(1)
s=map(int, input().split())
for i in range(3):
    s[i]=int(s[i])
s.sort()
print(s[0]+s[1])

### FIXED CODE ###

P,Q,R=map(int, input().split())
s=[]
s.append(P)
s.append(Q)
s.append(R)
s.sort()
print(s[0]+s[1])
def euclidean(a,b):
  _ = a % b
  while 1:
    if b % _ == 0:
      break
    else:
      _ = b % _
  return _
 
A, B, K = map(int, input().split())
 
a = max(A, B)
b = min(A, B)
e = euclidean(a, b)
by = []
r = int(e ** (1 / 2))
 
for i in range(1, r + 1):
  if e % i == 0:
    by.append(i)
    j = e // i
    if j != i:
      by.append(j)
by.sort(reverse = True)
print(by[K - 1])

### FIXED CODE ###

def euclidean(a,b):
  _ = a % b
  if _ == 0:
    return b
  else:
    while 1:
      if b % _ == 0 :
        break
      else:
        _ = b % _
    return _
  
A, B, K = map(int, input().split())
 
a = max(A, B)
b = min(A, B)
e = euclidean(a, b)
by = []
r = int(e ** (1 / 2))
 
for i in range(1, r + 1):
  if e % i == 0:
    by.append(i)
    j = e // i
    if j != i:
      by.append(j)
by.sort(reverse = True)
print(by[K - 1])
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    if A == B:
        print('YES')
    elif W > V:
        print('NO')
    elif (A - B) % (W - V) == 0 and (A - B) // (W - V) <= T:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    if W >= V:
        print('NO')
    elif abs((A - B) / (W - V)) <= T:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()
a# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B = map(int, lines.pop(0).split(' '))
    print(max( A+B, A-B, A*B ))

#
# main
#

# 1. use list instead of stdin

#contents = '''\
#3 -4\
#'''
#lines = contents.split('\n')

# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B = map(int, lines.pop(0).split(' '))
    print(max( A+B, A-B, A*B ))

#
# main
#

# 1. use list instead of stdin

#contents = '''\
#3 -4\
#'''
#lines = contents.split('\n')

# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)
s = input()
s.sort()
if "".join(s) = "abc":
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = list(input())
s.sort()
if "".join(s) == "abc":
    print("Yes")
else:
    print("No")
S=input()
print(7 if S=="SUN" 6 if S=="MON" 5 if S=="TUE" 4 if S=="WED" 3 if S=="THU" 2 if S=="FRI" 1 if S=="SAT"

### FIXED CODE ###

S=input()
if S=="SUN":
  print(7)
if S=="MON":
  print(6)
if S=="TUE":
  print(5)
if S=="WED":
  print(4)
if S=="THU":
  print(3)
if S=="FRI":
  print(2)
if S=="SAT":
  print(1)
n = int(input())
a = list(map(int,input().split()))
ans = 10**9 // テキトーに大きな値入れておく
for i in range(n):
    count = 0
    while a[i] % 2 == 0:
      a[i] //= 2
      count += 1
    ans = min(ans, count)

print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 10**9  # テキトーに大きな値入れておく
for i in range(n):
    if a[i] % 2 == 1:
        print(0)
        quit()

    count = 0
    while a[i] % 2 == 0:
      a[i] //= 2
      count += 1
    ans = min(ans, count)

print(ans)
x, y, z = input.split()
if x == y:
  if x == z and y == z:
    print("No")
  elif x != z and y != z:
    print("No")
  else:
    print("Yes")
elif x == z:
  if x == y and y == z:
    print("No")
  elif x != y and y != z:
    print("No")
  else:
    print("Yes")
elif y == z:
  if x == y and x == z:
    print("No")
  elif x != y and x != z:
    print("No")
  else:
    print("Yes")
else:
  print("No")

### FIXED CODE ###

x, y, z = input().split()
if x == y:
  if x == z and y == z:
    print("No")
  else:
    print("Yes")
elif x == z:
  if x == y and y == z:
    print("No")
  else:
    print("Yes")
elif y == z:
  if x == y and x == z:
    print("No")
  else:
    print("Yes")
else:
  print("No")
import sys
input = sys.stdin.readline

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

m = 0
ans = [0]*N
for i in range(N, 0, -1):
    a = A[i-1]
    cnt = 0
    for k in range(i+i, N+1, i):
        cnt += A[k-1]
    if a != cnt % 2:
        ans[i] = 1
        m += 1

print(m)
for an in ans:
    if an > 0:
        print(an, end=' ')
print()


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

m = 0
ans = [0]*N
for i in range(N, 0, -1):
    a = A[i-1]
    cnt = 0
    for k in range(i+i, N+1, i):
        cnt += ans[k-1]
    if a != cnt % 2:
        ans[i-1] = 1
        m += 1

print(m)
for i in range(N):
    if ans[i] > 0:
        print(i+1, end=' ')
print()
A,B,K = [int(i) for i in input().split()]
a = A - (K - (K -A))
b = B - (K - A)
print(f"{a} {b}")

### FIXED CODE ###

a,b,k = map(int,input().split())
if (a-k>=0):
    print(a-k,b)
else:
    c = b-abs(a-k)
    if c <= 0:
        c = 0
    print(0,c)
import math
import fraction
aa=int(input())
N=[0 for i in range(aa)]
for i in range(aa):
  bb=input()
  #print(b)
  N[i]=bb.split()


def so(p,q):
  while p!=q:
    if p>q:
      p-=q
    else:
      q-=p
  return p


#print(so(11,5))

def aaa(n):

  a=int(N[n][0])
  b=int(N[n][1])
  c=int(N[n][2])
  d=int(N[n][3])

  e=a-a//b*b
  f=d-d//b*b
  
  if e*f>0 :
    s=fraction.gcd(e,f)
  else :
    s=f


  if a<b or d<b :
    return "No"
  
  elif b<=c :
    return "Yes"
  else:
  
    if f!=0 :
      ss=b//s*s
      if ss==b:
        ss-=s

      if ss>c:
        return "No"
          
    

        #print(e)
        #print(f)
  #print("while")
    else:
      if e>c :
        return "No"

  return "Yes"

for i in range(aa):
  print(aaa(i))


### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
C = [list(map(int,input().split())) for i in range(n)]

from fractions import gcd

for i in range(n):
    a = C[i][0]
    b = C[i][1]
    c = C[i][2]
    d = C[i][3]
    ng = 0

    e = 0  # 最初に補充が発生する直前の本数
    e0 = a - b
    e1 = ((c - a%b) // b) * b + a%b
    e = min(e0, e1)

    if e < 0 or b > d:
        ng = 1
    else:
        g = gcd(b, d)
        # print(c+1, b-1, g)
        if c+1 <= b-1 and (c - e) // g < (b-1 - e) // g:
            ng = 1

    if ng == 1:
        print("No")
    else:
        print("Yes")
A,B = map(input().split)
print(A*B)

### FIXED CODE ###

a,b = map(int,input(). split ())
print(a*b)
*D, = open(0)
n = int(D[0])

edge = [[] for _ in range(n+1)]
v_val = [0 for _ in range(n+1)]

dist = {}

for i in range(1, n):
    a, b = map(int, D[i].split())
    edge[a].append(b)
    edge[b].append(a)
c = list(map(int, D[n].split()))
c = sorted(c, reverse=True)

from collections import deque
visited = [False for _ in range(len(edge))]
start = 1
que = deque()
que.append(start)
order.append(node)
visited[node] = True
order = []

while que:
    node = que.popleft()
    for it in edge[node]:
        if not visited[it]:
            order.append(it)
            visited[it] = True
            que.append(it)
# calculate cost
v_val = [0 for _ in range(len(c)+1)]
for i in order:
    v_val[i] = c[i-1]

print(sum(c[1:]))
print(' '.join(map(str, v_val[1:])))

### FIXED CODE ###

*D, = open(0)
n = int(D[0])

edge = [[] for _ in range(n+1)]
v_val = [0 for _ in range(n+1)]

dist = {}

for i in range(1, n):
    a, b = map(int, D[i].split())
    edge[a].append(b)
    edge[b].append(a)
c = list(map(int, D[n].split()))
c = sorted(c, reverse=True)

from collections import deque
visited = [False for _ in range(len(edge))]
start = 1
que = deque()
que.append(start)
order = []
order.append(start)
visited[start] = True

while que:
    node = que.popleft()
    for it in edge[node]:
        if not visited[it]:
            order.append(it)
            visited[it] = True
            que.append(it)
# calculate cost
v_val = [0 for _ in range(len(c)+1)]
for i, it in enumerate(order):
    v_val[it] = c[i]

print(sum(c[1:]))
print(' '.join(map(str, v_val[1:])))
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,q = nm()

tval = [0]*n
t = [[] for _ in range(n)]

for i in range(n-1):
    a,b = nm()
    t[a-1].append(b-1)

for i in range(q):
    p,x = nm()
    tval[p-1] += x

ans = [0]*n
def dfs(num,val):
    now = val+tval[num]
    ans[num] = now
    for nn in t[num]:
        dfs(nn,now)

dfs(0,0)

for i in ans:
    print(i)


### FIXED CODE ###

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import sys

sys.setrecursionlimit(500000)

visited = set()

n,q = nm()

tval = [0]*n
t = [[] for _ in range(n)]

for i in range(n-1):
    a,b = nm()
    t[a-1].append(b-1)
    t[b-1].append(a-1)

for i in range(q):
    p,x = nm()
    tval[p-1] += x

ans = [0]*n
def dfs(num,val):
    visited.add(num)
    now = val+tval[num]
    ans[num] = now
    for nn in t[num]:
        if nn not in visited:
            dfs(nn,now)

dfs(0,0)

for i in ans:
    print(i)
while 1:
    a = list(map(int, input().split()))
    if a == 0 and b == 0:
        break
    print(min(a), max(a))


### FIXED CODE ###

while 1:
    a = list(map(int, input().split()))
    if a[0] or a[1]:
        print(min(a), max(a))
    else:
        break
n = int(input())
a = list(map(int,input().split()))
a.sort()
b = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 
     131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 
     67108864, 134217728, 268435456, 536870912]

t = []
bIdx = 0
for aa in a :
    while b[bIdx] <= aa:
        bIdx += 1   
    t.append(b[bIdx]-aa)

t.reverse()
a.sort(reverse=True)

sum = 0
i = 0

#print(t,a)

while True:
    
    first = i+1
    last = len(a)-1
    found = False

    while first<=last and not found:
        midpoint = (first + last)//2
        if a[midpoint] == t[i] :
            found = True
            sum += 1
            a = a[:midpoint]
            a.extend(a[midpoint:])
            print(a)
        else:
            if t[i] > a[midpoint]:
                last = midpoint-1
            else:
                first = midpoint+1
            
    i = i + 1
    if i >= len(a)-1:
        break

print(sum)

### FIXED CODE ###

from bisect  import bisect_left

n = int(input())
a = list(map(int,input().split()))
a.sort()
#print(a)

sum = 0
for i in range (len(a)-1,-1,-1):

    b = 1
    while b <= a[i]:
        b = b<<1
    t = b - a[i]
    #print("2^",t)

    k = bisect_left(a,t)
    if a[k] == t and k < i:
        sum += 1
        a[k] -= 0.1
        a[i] += 0.1
print(sum)
N = int(input())
H = list(map(int, input().split()))
reverse_H = H[::-1]
ans = 0
result = []
for i in range(N-1):
    if reverse_H[i] <= reverse_H[i+1]:
        ans += 1
    else:
        result.append(ans)
        ans = 0
print(max(result))


### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
if N == 1:
    print(0)
    exit()
reverse_H = H[::-1]
ans = 0
result = []
for i in range(N-1):
    if reverse_H[i] <= reverse_H[i+1]:
        ans += 1
    else:
        result.append(ans)
        ans = 0
if ans > 0:
    result.append(ans)
if result:
    print(max(result))
else:
    print(0)
import math
A,B,N=map(int,input().split())
x=min(B-1,N)
ans=math.floor(A*x/B)-A*math.floor(x/B)
print(int(ans))



### FIXED CODE ###

K=int(input())
A,B=map(int,input().split())
for i in range(A,B+1):
  if i%K==0:
    print("OK")
    break
  if i==B:
    print("NG")
n = input()
if n>= 2 and n <= 200000
   for i in range(0, n-1):
      R = map(int, raw_input().split())
   minv = R[0]
   maxv = R[1] - R[0]
   for j in range(1, n-1):
      maxv = max(maxv, R[j] - minv) 
      minv = min(minv, R[j])
print maxv - minv

### FIXED CODE ###

n = input()
R = []
for i in range(0, n):
   R.append(int(raw_input()))

maxv = R[1] - R[0]
minv = R[0]

for v in range(1, n):
   if minv > R[v]:
      minv = R[v]
   elif maxv < R[v] - minv:
      maxv = R[v] - minv
print maxv
def dijkstra(n):
    d = [None] * 100
    p = [None] * 100
    color = [None] * 100
    
    for i in xrange(n):
        d[i] = float('inf')
        p[i] = -1
        color[i] = 0
    
    d[0] = 0
    
    while(True):
        minv = float('inf')
        u = -1
        for i in xrange(n):
            if minv > d[i] and color[i] != 2:
                u = i
                minv = d[i]
        
        if u == -1:
            break
        
        color[u] = 2
        
        for v in xrange(n):
            if color[v] != 2 and data[u][v] != float('inf'):
                if d[v] > d[u] + data[u][v]:
                    d[v] = d[u] + data[u][v]
                    p[v] = u
                    color[v] = 1

    for i in xrange(n):
        if d[i] == float('inf'):
            print '%d %d' % (i, -1)
        else:
            print '%d %d' % (i, d[i])

n = input()
data = [None] * n
for i in xrange(n):
    data[i] = [None] * n
    line = map(int, raw_input().split())
    for j in xrange(n):
        if line[j] == -1:
            data[i][j] = float('inf')
        else:
            data[i][j] = line[j];
dijkstra(n)

### FIXED CODE ###

def dijkstra(n):
    d = [None] * 100
    p = [None] * 100
    color = [None] * 100
    
    for i in xrange(n):
        d[i] = float('inf')
        p[i] = -1
        color[i] = 0
    
    d[0] = 0
    
    while(True):
        minv = float('inf')
        u = -1
        for i in xrange(n):
            if minv > d[i] and color[i] != 2:
                u = i
                minv = d[i]
        
        if u == -1:
            break
        
        color[u] = 2
        
        for v in xrange(n):
            if color[v] != 2 and data[u][v] != float('inf'):
                if d[v] > d[u] + data[u][v]:
                    d[v] = d[u] + data[u][v]
                    p[v] = u
                    color[v] = 1

    for i in xrange(n):
        if d[i] == float('inf'):
            print '%d %d' % (i, -1)
        else:
            print '%d %d' % (i, d[i])

n = input()
data = [None] * n
for i in xrange(n):
    data[i] = [float('inf')] * n
    line = map(int, raw_input().split())
    for j in xrange(1, line[1] + 1):
        v = line[2 * j]
        c = line[2 * j + 1]
        data[line[0]][v] = c
        
dijkstra(n)
a, b = list(map(int, input().split()))

count = 0
for i in range(10):
    for j in range(10):
        for k in range(1, 10):
            num = i * 100 + j * 1010 + k * 10001
            if num >= a and num <= b:
                count += 1

print(count)

### FIXED CODE ###

c = []

for i in range(3):
    a = input()
    c.append(a[i])


print(c[0]+c[1]+c[2])
a,b,c,d,e,f=map(int,input().split())
q=set()
ans=0
p=set()
for i in range(0,f+1,100*a):
    for j in range(0,f+1-i,100*b):
        q.add(i+j)
for i in range(0,f+1,c):
    for j in range(0,f+1-i,d):
        p.add(i+j)
for pp in p:
    for qq in q:
        if 0<pp+qq and qq<=pp*e/100:
            if ans<qq/(pp+qq):
                ans=qq/(pp+qq)
                s=pp+qq
                ss=pp

print(s,ss)

### FIXED CODE ###

a,b,c,d,e,f = map(int,input().split())
w = set()
for x in range(0,f+1,100*a):
    for y in range(0,f+1-x,100*b):
        w.add(x+y)
s = set()
for x in range(0,f+1,c):
    for y in range(0,f+1-x,d):
        s.add(x+y)
ans = -1
sugerwater = 0
suger = 0
for x in w:
    for y in s:
        if  0<x+y<=f and y <= x*e/100:
            if ans < y/(x+y):
                ans = y/(x+y)
                sugerwater = x+y
                suger = y
print(sugerwater,suger)