a = [int(x) for x in open('17.txt')]
#Задание 4.1
b = []
for i in range(len(a)-1):
    if a[i] % 2 == 0 or a[i+1] % 2 == 0:
        b.append(a[i]+a[i + 1])
print(len(b), max(b))

#Задание 4.2
sr = sum(a)//len(a)
b = []
for i in range(len(a)-2):
    t = [a[i] > sr and a[i] % 2 == 0, a[i+1] > sr and a[i+1] % 2 == 0, a[i+2] > sr and a[i+2] % 2 == 0,]
    if t.count(True) == 1:
        b.append(a[i]+a[i + 1]+a[i+2])
print(len(b), min(b))

#Задание 4.3
b = [x for x in a if x % 7 == 0]
m = min(b)
c = []
for i in range(len(a)-1):
    if (a[i] * a[i+1]) % 2 != 0 and abs(a[i] - a[i+1]) >= m:
        c.append(abs(a[i] - a[i+1]))
print(len(c), min(c))

#Задание 4.4
b = [x for x in a if x % 7 == 0 and 1000<=x<10000]
m = min(b)
c = []
for i in range(len(a)-3):
    if sum(a[i:i+4]) / 4 <= m:
        c.append(a[i] * a[i+1] * a[i+2] * a[i+3])
print(len(c), min(c))

#Задание 4.5
b = [x for x in a if x % 10 == 7]
b.sort()
m = b[-3]
c = []
for i in range(len(a) - 5):
    t = [a[i+x] for x in range(6) if 1000 <= a[i+x] < 10000]
    if max(a[i:i+6]) == m or len(t) > 5  :
        c.append(sum(a[i:i+6]) / 6)
print(len(c), max(c))


#Задание 4.6
sr = sum(a)/len(a)
c = []
for i in range(len(a) - 9):
    even = [a[i+x] % 2 == 0 for x in range(10)]
    t = [even.count(True) == 5, sum(a[i:i+10]) / 10 > sr, sum(a[i:i+5]) > sum (a[i+5:i+10])]
    if  t.count(True) == 1:
        c.append(sum(a[i:i+10]) / 10)
print(len(c), min(c))
