print('x y z w')
for x in range(2):
for y in range(2):
for z in range(2):
for w in range(2):
if ((not(y<=(x==w)) and (z<=x))):
print(x, y, z, w)
bin(78)
int('10011',2)
for i in range(1,100):
n=str(bin(i))[2:]
if n.count('1')%2==0:
n+='0'
else:
n+='1'
if n.count('1')%2==0:
n+='0'
else:
n+='1'
if int(n,2)>77:
print(i, n)
break
for i in range(1,1000):
s=i
s=s//10
n=1
while s<51:
s+=5
n=n*2
if n==64:
print(i)
letters='елмру'
s=[]
for a in letters:
for b in letters:
for c in letters:
for d in letters:
s.append(a+b+c+d)
print(s.index('леее')+1)
s=70*'8'
while '2222' in s or '8888' in s:
if '2222' in s:
s=s.replace('2222','88',1)
else:
s=s.replace('8888','22',1)
print(s)
x=3*4**38+2*4**23+4**20+3*4**5+2*4**4+1
k=0
while x>0:
if x%16==0:
k+=1
x//=16
print(k)
def f(x,a1,a2):
return(17<=x<=58) <= ((not(29<=x<=80) and not(a1<=x<=a2)) <= (not(17<=x<=58)))
s=[]
for a1 in range(-100,100):
for a2 in range(-100,100):
flag=True
for x in range (-100,100):
if not(f(x,a1,a2)):
flag=False
break
if flag:
s.append(a2-a1)
print(min(s))
def f(n):
if n==1:
return 1
else:
if n%2==0:
return n+f(n-1)
else:
return 2*f(n-2)
print(f(26))
with open('17.txt') as f:
numbers=[int(x) for x in f]
print(numbers)
s=[]
for i in range(1,len(numbers)):
if numbers[i]%3==0 or numbers[i-1]%3==0:
s.append(numbers[i]+numbers[i-1])
print(len(s), max(s))
for i in range(1,100):
x=i
Q=9
L=0
while x>=Q:
L+=1
x=x-Q
M=x
if M<L:
M=L
L=x
if L==4 and M==5:
print(i)
def f(a,b):
if a>b:
return 0
elif a==b:
return 1
else:
return f(a+1,b) +f(a*2,b)
print(f(1,10)*f(10,20))
with open('24.txt') as f:
s=f.readline()
count,maximum=1,0
for i in range(1,len(s)):
if s[i]==s[i-1]=='P':
count=1
else:
count+=1
maximum=max(maximum,count)
print(maximum)
for i in range(700001,730000):
divs=set()
for d in range(2),round(i**0.5):
if i%d:
divs.add(d)
divs.add(i//d)
if len(divs)>0:
m=max(divs)+min(divs)
if m%10==8:
print(i,m)
with open('26.txt') as f:
data=f.readlines()
s,n=map(int,data[0].split)
del data[0]
data=sorted(map(int,data))
answer=[]
for i in data:
if sum(answer)+i>s:break
answer.append(i)
print(sum(answer),data.index(i))
spisok=[x for x in data if x-i<=s-sum(answer)]
print(max(spisok))
with open('27_A.txt') as f:
n=int(f.readline)
s=[int(f.readline()) for i in range(n)]
maximum,len_min=0,1000
for i in range(n):
summa=0
for j in range(i+1,n):
summa+=s[j]
if summa%43==0:
if summa>maximum or ((summa==maximum) and (j-i<len_min)):
maximum=summa
len_min=j-i
print(len_min)
with open('27_B.txt') as f:
n=int(f.readline())
min_sum=43*[10000000000000000]
min_len=43*[0]
summa,maxsum,minLength,ms,ln=0,0,0,0,0
for i in range(n):
summa+=int(f.readline())
d=summa%43
if d==0:
maxsum=summa
minLength=i
else:
ms=summa-min_sum[d]
ln=i-min_len[d]
if ms>maxsum or(ms==maxsum and ln<minLength):
maxsum=ms
minLength=ln
if summa<min_sum[d]:
min_sum[d]=summa
min_len[d]=i
print(minLength)