The input consists of three lines, each of the lines contains characters ".", "X" or "0" (a period, a capital letter X, or a digit zero).

def win(l,s):
    if l[0] == [s, s, s] or l[1] == [s, s, s] or l[2] == [s, s, s] or l[0][0] == s and l[1][0] == s and l[2][0] == s or \
            l[0][1] == s and l[1][1] == s and l[2][1] == s or l[0][2] == s and l[1][2] == s and l[2][2] == s or l[0][
        0] == s and l[1][1] == s and l[2][2] == s or l[0][2] == s and l[1][1] == s and l[2][0] == s:
        return 1
    else:
        return 0
a=list(input())
b=list(input())
c=list(input())
l=[a,b,c]
mf=a.count('X')+b.count('X')+c.count('X')
ms=a.count('0')+b.count('0')+c.count('0')
me=a.count('.')+b.count('.')+c.count('.')
if  mf -ms!= 1 and mf -ms!=0 :
    print('illegal')
else:
    n=win(l,'0')
    m=win(l,'X')
    if n==1 and m==1 or n==1 and mf-ms!=0 or m==1 and mf-ms!=1:
        print('illegal')
    elif n==1:
        print('the second player won')
    elif m==1:
        print('the first player won')
    else:
        if me==0:
            print('draw')
        elif mf-ms==1:
            print('second')
        else:print('first')

Print one of the six verdicts: first, second, illegal, the first player won, the second player won or draw.

Certainly, everyone is familiar with tic-tac-toe game. The rules are very simple indeed. Two players take turns marking the cells in a 3 × 3 grid (one player always draws crosses, the other — noughts). The player who succeeds first in placing three of his marks in a horizontal, vertical or diagonal line wins, and the game is finished. The player who draws crosses goes first. If the grid is filled, but neither Xs, nor 0s form the required line, a draw is announced.You are given a 3 × 3 grid, each grid cell is empty, or occupied by a cross or a nought. You have to find the player (first or second), whose turn is next, or print one of the verdicts below:   illegal — if the given board layout can't appear during a valid game;  the first player won — if in the given board layout the first player has just won;  the second player won — if in the given board layout the second player has just won;  draw — if the given board layout has just let to a draw.

Input:
X0X
.0.
.X.

Output: second

Input:
0.X
XX.
000

Output: illegal

Input:
XXX
.0.
000

Output: illegal

Input:
XXX
...
000

Output: illegal

Input:
X.X
X..
00.

Output: second

Input:
X.X
X.0
0.0

Output: first

Input:
0..
...
...

Output: illegal

Input:
XXX
X00
X00

Output: the first player won

Input:
000
X.X
X.X

Output: illegal

Input:
XXX
0.0
0..

Output: illegal

Input:
X0X
0X0
X0X

Output: the first player won

Input:
XX.
X0X
X..

Output: illegal

Input:
X0X
0X0
X..

Output: the first player won

Input:
XX0
0..
000

Output: illegal

Input:
XXX
0..
.0.

Output: the first player won

Input:
XXX
X..
.00

Output: illegal

Input:
X00
0.0
XX0

Output: illegal

Input:
0.0
0XX
..0

Output: illegal

Input:
.00
X.X
0..

Output: illegal

Input:
..0
.00
.0X

Output: illegal

Input:
..0
0..
00X

Output: illegal

Input:
..0
.XX
X..

Output: illegal

Input:
0.X
0X0
.00

Output: illegal

Input:
..X
0X0
0X.

Output: first

Input:
0X0
X..
X.0

Output: first

Input:
.0.
X.X
0..

Output: first

Input:
0X0
00X
.00

Output: illegal

Input:
.0.
.X0
X..

Output: first

Input:
00X
0.X
00X

Output: illegal

Input:
00X
0XX
0X.

Output: the second player won

Input:
X00
..0
X.X

Output: first

Input:
X00
X00
.X0

Output: illegal

Input:
X0X
.X0
0..

Output: first

Input:
..0
XXX
000

Output: illegal

Input:
XXX
...
.0.

Output: illegal

Input:
0..
000
X0X

Output: illegal

Input:
.00
0X.
0.0

Output: illegal

Input:
X..
X00
0.0

Output: illegal

Input:
.X0
XX0
X.X

Output: illegal

Input:
X.X
0.0
X..

Output: second

Input:
00X
.00
..0

Output: illegal

Input:
..0
0.X
00.

Output: illegal

Input:
0.X
X0X
.X0

Output: illegal

Input:
0X.
.X.
0X0

Output: illegal

Input:
00.
X0.
..X

Output: illegal

Input:
..X
.00
XX.

Output: second

Input:
.00
.0.
.X.

Output: illegal

Input:
XX0
X.0
XX0

Output: illegal

Input:
00.
00.
X.X

Output: illegal

Input:
X00
X.0
X.0

Output: illegal

Input:
0X.
0XX
000

Output: illegal

Input:
00.
00.
.X.

Output: illegal

Input:
X0X
00.
0.X

Output: illegal

Input:
XX0
XXX
0X0

Output: illegal

Input:
XX0
..X
XX0

Output: illegal

Input:
0X.
..X
X..

Output: illegal

Input:
...
X0.
XX0

Output: second

Input:
..X
.0.
0..

Output: illegal

Input:
00X
XX.
00X

Output: first

Input:
..0
XX0
..X

Output: second

Input:
.0.
.00
X00

Output: illegal

Input:
X00
.XX
00.

Output: illegal

Input:
.00
0.X
000

Output: illegal

Input:
X0.
..0
X.0

Output: illegal

Input:
X0X
.XX
00.

Output: second

Input:
0X.
00.
.X.

Output: illegal

Input:
0..
000
...

Output: illegal

Input:
.0.
...
0.0

Output: illegal

Input:
..X
X00
0.0

Output: illegal

Input:
0XX
...
X0.

Output: second

Input:
X.X
0X.
.0X

Output: illegal

Input:
XX0
X.X
00.

Output: second

Input:
.0X
.00
00.

Output: illegal

Input:
.XX
XXX
0..

Output: illegal

Input:
XX0
.X0
.0.

Output: first

Input:
X00
0.X
X..

Output: first

Input:
X..
.X0
X0.

Output: second

Input:
.0X
X..
XXX

Output: illegal

Input:
X0X
XXX
X.X

Output: illegal

Input:
.00
X0.
00X

Output: illegal

Input:
0XX
.X0
0.0

Output: illegal

Input:
00X
XXX
..0

Output: the first player won

Input:
X0X
...
.X.

Output: illegal

Input:
.X0
...
0X.

Output: first

Input:
X..
0X0
X.0

Output: first

Input:
..0
.00
X.0

Output: illegal

Input:
.XX
.0.
X0X

Output: illegal

Input:
00.
0XX
..0

Output: illegal

Input:
.0.
00.
00.

Output: illegal

Input:
00.
000
X.X

Output: illegal

Input:
0X0
.X0
.X.

Output: illegal

Input:
00X
0..
0..

Output: illegal

Input:
.X.
.X0
X.0

Output: second

Input:
.0.
0X0
X0X

Output: illegal

Input:
...
X.0
0..

Output: illegal

Input:
..0
XX.
00X

Output: first

Input:
0.X
.0X
X00

Output: illegal

Input:
..X
0X.
.0.

Output: first

Input:
..X
X.0
.0X

Output: second

Input:
X0.
.0X
X0X

Output: illegal

Input:
...
.0.
.X0

Output: illegal

Input:
.X0
XX0
0..

Output: first

Input:
0X.
...
X..

Output: second

Input:
.0.
0.0
0.X

Output: illegal

Input:
XX.
.X0
.0X

Output: illegal

Input:
.0.
X0X
X00

Output: illegal

Input:
0X.
.X0
X..

Output: second

Input:
..0
0X.
000

Output: illegal

Input:
0.0
X.X
XX.

Output: illegal

Input:
.X.
.XX
X0.

Output: illegal

Input:
X.X
.XX
0X.

Output: illegal

Input:
...
.X.
...

Output: second

Input:
..0
.X.
...

Output: first

Input:
..0
.XX
...

Output: second

Input:
..0
0XX
...

Output: first

Input:
X.0
0XX
...

Output: second

Input:
X.0
0XX
..0

Output: first

Input:
X.0
0XX
.X0

Output: second

Input:
X00
0XX
.X0

Output: first

Input:
X00
0XX
XX0

Output: draw

Input:
X00
0XX
0X0

Output: illegal

Input:
XXX
XXX
XXX

Output: illegal

Input:
000
000
000

Output: illegal

Input:
XX0
00X
XX0

Output: draw

Input:
X00
00X
XX0

Output: illegal

Input:
X.0
00.
XXX

Output: the first player won

Input:
X..
X0.
X0.

Output: the first player won

Input:
.XX
000
XX0

Output: the second player won

Input:
X0.
X.X
X00

Output: the first player won

Input:
00X
X00
XXX

Output: the first player won

Input:
XXX
.00
X0.

Output: the first player won

Input:
XX0
000
XX.

Output: the second player won

Input:
.X0
0.0
XXX

Output: the first player won

Input:
0XX
X00
0XX

Output: draw

Input:
0XX
X0X
00X

Output: the first player won

Input:
XX0
0XX
0X0

Output: the first player won

Input:
0X0
X0X
X0X

Output: draw

Input:
XXX
0.0
...

Output: the first player won

Input:
X0X
0XX
00X

Output: the first player won

Input:
0XX
X0.
X00

Output: the second player won

Input:
X.0
0X0
XX0

Output: the second player won

Input:
X0X
X0X
0X0

Output: draw

Input:
X.0
00X
0XX

Output: the second player won

Input:
00X
X0X
.X0

Output: the second player won

Input:
X0X
.00
X0X

Output: the second player won

Input:
0XX
X00
X0X

Output: draw

Input:
000
X0X
.XX

Output: the second player won

Input:
0.0
0.X
XXX

Output: the first player won

Input:
X.0
X0.
0X.

Output: the second player won

Input:
X0X
0X0
..X

Output: the first player won

Input:
0X0
XX0
.X.

Output: the first player won

Input:
X0.
.X.
0.X

Output: the first player won

Input:
0XX
X00
.X0

Output: the second player won

Input:
0.0
XXX
0.X

Output: the first player won

Input:
.0X
.X.
X.0

Output: the first player won

Input:
XXX
X.0
0.0

Output: the first player won

Input:
XX0
X..
X00

Output: the first player won

Input:
XXX
00X
00X

Output: the first player won

Input:
X00
00X
XXX

Output: the first player won

Input:
0X0
X0X
0X.

Output: the second player won

Input:
XX0
X00
0X.

Output: the second player won

Input:
..X
0X0
X..

Output: the first player won

Input:
X0.
00.
XXX

Output: the first player won

Input:
0.X
X00
XX0

Output: the second player won

Input:
X0.
0X.
..X

Output: the first player won

Input:
00X
X0.
XX0

Output: the second player won

Input:
XX.
000
0XX

Output: the second player won

Input:
..X
0.X
.0X

Output: the first player won

Input:
X00
.0X
0XX

Output: the second player won

Input:
00X
0X.
XX.

Output: the first player won

Input:
X00
XX.
0.X

Output: the first player won

Input:
XXX
00X
0X0

Output: the first player won

Input:
X00
XX0
0XX

Output: the first player won

Input:
0X0
X00
XXX

Output: the first player won

Input:
XX0
X00
.X0

Output: the second player won

[{'input': 'X.0\r\n00.\r\nXXX\r\n', 'output': ['the first player won']}, {'input': 'X0.\r\n00.\r\nXXX\r\n', 'output': ['the first player won']}, {'input': '.0X\r\n.00\r\n00.\r\n', 'output': ['illegal']}, {'input': '..X\r\n0X.\r\n.0.\r\n', 'output': ['first']}, {'input': '00.\r\nX0.\r\n..X\r\n', 'output': ['illegal']}]

[{'input': '000\r\nX.X\r\nX.X\r\n', 'output': ['illegal']}, {'input': 'X00\r\n00X\r\nXXX\r\n', 'output': ['the first player won']}, {'input': '000\r\n000\r\n000\r\n', 'output': ['illegal']}, {'input': 'XX0\r\n0..\r\n000\r\n', 'output': ['illegal']}, {'input': '..0\r\nXX.\r\n00X\r\n', 'output': ['first']}]


The first line of input consists of a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the string $$$t$$$. The second line of input consists of the string $$$t$$$. The length of $$$t$$$ is $$$n$$$, and it consists only of lowercase Latin letters.

a = int(input())
s = list(input())

b = []
for i in range(a, 1, -1):
    if a % i == 0:
        b.append(i)

for i in range(len(b)-1, -1, -1):
    s[0:b[i]] = reversed(s[0:b[i]])

s = "".join(s)
print(s)

NoteThe first example is described in the problem statement.

Print a string $$$s$$$ such that the above algorithm results in $$$t$$$.

A string $$$s$$$ of length $$$n$$$ can be encrypted by the following algorithm:  iterate over all divisors of $$$n$$$ in decreasing order (i.e. from $$$n$$$ to $$$1$$$),  for each divisor $$$d$$$, reverse the substring $$$s[1 \dots d]$$$ (i.e. the substring which starts at position $$$1$$$ and ends at position $$$d$$$). For example, the above algorithm applied to the string $$$s$$$="codeforces" leads to the following changes: "codeforces" $$$\to$$$ "secrofedoc" $$$\to$$$ "orcesfedoc" $$$\to$$$ "rocesfedoc" $$$\to$$$ "rocesfedoc" (obviously, the last reverse operation doesn't change the string because $$$d=1$$$).You are given the encrypted string $$$t$$$. Your task is to decrypt this string, i.e., to find a string $$$s$$$ such that the above algorithm results in string $$$t$$$. It can be proven that this string $$$s$$$ always exists and is unique.

Input:
10
rocesfedoc

Output: codeforces

Input:
16
plmaetwoxesisiht

Output: thisisexampletwo

Input:
1
z

Output: z

Input:
2
ir

Output: ri

Input:
3
ilj

Output: jli

Input:
4
jfyy

Output: yyjf

Input:
6
krdych

Output: hcyrkd

Input:
60
fnebsopcvmlaoecpzmakqigyuutueuozjxutlwwiochekmhjgwxsgfbcrpqj

Output: jqprcbfgsxwgjhmkehcoiwwltuxjzokamzpalobnfespcvmoecqigyuutueu

Input:
64
hnlzzhrvqnldswxfsrowfhmyzbxtyoxhogudasgywxycyhzgiseerbislcncvnwy

Output: ywnvcnclsibreesigzhycyxwygsadugofxwsdlnqzlhnzhrvsrowfhmyzbxtyoxh

Input:
97
qnqrmdhmbubaijtwsecbidqouhlecladwgwcuxbigckrfzasnbfbslukoayhcgquuacygakhxoubibxtqkpyyhzjipylujgrc

Output: crgjulypijzhyypkqtxbibuoxhkagycauuqgchyaokulsbfbnsazfrkcgibxucwgwdalcelhuoqdibceswtjiabubmhdmrqnq

Input:
100
edykhvzcntljuuoqghptioetqnfllwekzohiuaxelgecabvsbibgqodqxvyfkbyjwtgbyhvssntinkwsinwsmalusiwnjmtcoovf

Output: fvooctmjnwisulamswniswknitnssvhybgtwjybkfyvxqdoqgbqteoitnczvkyedhljuuoqghptnfllwekzohiuaxelgecabvsbi

Input:
96
qtbcksuvxonzbkokhqlgkrvimzqmqnrvqlihrmksldyydacbtckfphenxszcnzhfjmpeykrvshgiboivkvabhrpphgavvprz

Output: zrpvvaghpprhbavkviobighsvrkyepmjfhznczsxnehpfkctvrnqmqzmkokbvuctqbksxonzhqlgkrviqlihrmksldyydacb

Input:
90
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm

Output: mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm

Input:
89
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

Output: wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

Input:
99
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq

Output: qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq

Input:
100
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

Output: oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

Input:
60
wwwwwxwwwwwwfhwwhwwwwwwawwwwwwwwwwwwwnwwwwwwwwwwwwwwwwwwwwww

Output: wwwwwwwwwwwwwwwwwwwwwwnwwwwwwwwwwhwwwxwwwwwwwwwfhwwwwawwwwww

Input:
90
cccchccccccccccccccccccccccccccwcccccccccgcccccchccccccccccccccccccccccxccccccncccccccuccc

Output: cccucccccccnccccccxcccccccccccccccccccccchccccccccccccccccccccccchccccccccccwcccccccccgccc

Input:
97
fwffffffffffffffffffffffffrffffffffffffffzfffffffffffffffftfcfffffffqffffffffffffffffffffffyfffff

Output: fffffyffffffffffffffffffffffqfffffffcftffffffffffffffffzffffffffffffffrffffffffffffffffffffffffwf

Input:
100
djjjjjjjjjjgjjjjjjjjjjjjjjsvjjjjjjjjjjmjjjjjjjjjjjjjajjjjjjajjjjjjrjjjjjjjjjjjjrjjtjjjjjjjjjjjjjojjj

Output: jjjojjjjjjjjjjjjjtjjrjjjjjjjjjjjjrjjjjjjajjjjjjajjjjjjjjjjjjjjdjjjgjjjjjjjjjsvjjjjjjjjjjmjjjjjjjjjjj

[{'input': '6\r\nkrdych\r\n', 'output': ['hcyrkd']}, {'input': '100\r\nedykhvzcntljuuoqghptioetqnfllwekzohiuaxelgecabvsbibgqodqxvyfkbyjwtgbyhvssntinkwsinwsmalusiwnjmtcoovf\r\n', 'output': ['fvooctmjnwisulamswniswknitnssvhybgtwjybkfyvxqdoqgbqteoitnczvkyedhljuuoqghptnfllwekzohiuaxelgecabvsbi']}, {'input': '10\r\nrocesfedoc\r\n', 'output': ['codeforces']}, {'input': '4\r\njfyy\r\n', 'output': ['yyjf']}, {'input': '3\r\nilj\r\n', 'output': ['jli']}]


The only line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^9$$$, $$$1 \le m \le 1000$$$) — the size of the field and the number of parts to split the sets into.

n, m = [int(i) for i in input().split()]
ans = 0
ar = [n // m] * m
for i in range(1, n % m + 1, 1):
    ar[i] += 1
for i in range(m):
    for j in range(m):
        if ((i * i + j * j) % m == 0):
            ans += ar[i] * ar[j]
print(ans)

NoteIn the first example, only the set for cell $$$(3, 3)$$$ can be split equally ($$$3^2 + 3^2 = 18$$$, which is divisible by $$$m=3$$$).In the second example, the sets for the following cells can be divided equally:   $$$(1, 2)$$$ and $$$(2, 1)$$$, since $$$1^2 + 2^2 = 5$$$, which is divisible by $$$5$$$;  $$$(1, 3)$$$ and $$$(3, 1)$$$;  $$$(2, 4)$$$ and $$$(4, 2)$$$;  $$$(2, 6)$$$ and $$$(6, 2)$$$;  $$$(3, 4)$$$ and $$$(4, 3)$$$;  $$$(3, 6)$$$ and $$$(6, 3)$$$;  $$$(5, 5)$$$. In the third example, sets in all cells can be divided equally, since $$$m = 1$$$.

Print a single integer — the number of sets that can be split equally.

Arkady and his friends love playing checkers on an $$$n \times n$$$ field. The rows and the columns of the field are enumerated from $$$1$$$ to $$$n$$$.The friends have recently won a championship, so Arkady wants to please them with some candies. Remembering an old parable (but not its moral), Arkady wants to give to his friends one set of candies per each cell of the field: the set of candies for cell $$$(i, j)$$$ will have exactly $$$(i^2 + j^2)$$$ candies of unique type.There are $$$m$$$ friends who deserve the present. How many of these $$$n \times n$$$ sets of candies can be split equally into $$$m$$$ parts without cutting a candy into pieces? Note that each set has to be split independently since the types of candies in different sets are different.

Input: 3 3

Output: 1

Input: 6 5

Output: 13

Input: 1000000000 1

Output: 1000000000000000000

Input: 1 1

Output: 1

Input: 1000000000 81

Output: 12345678987654321

Input: 10000 1

Output: 100000000

Input: 10000 2

Output: 50000000

Input: 10000 3

Output: 11108889

Input: 15 1000

Output: 0

Input: 10 200

Output: 1

Input: 1000000000 1000

Output: 3400000000000000

Input: 999999998 229

Output: 8714555372170630

Input: 999999999 228

Output: 76946738381041

Input: 1 2

Output: 1

Input: 10000 5

Output: 36000000

Input: 1 10

Output: 0

Input: 100 100

Output: 260

Input: 360 900

Output: 374

Input: 1000 999

Output: 657

Input: 12345 1

Output: 152399025


The single line contains a question represented by a non-empty line consisting of large and small Latin letters, spaces and a question mark. The line length does not exceed 100. It is guaranteed that the question mark occurs exactly once in the line — as the last symbol and that the line contains at least one letter.

s = input()
vowels = 'aeiouyAEIOUY'
if s.split()[-1] == '?':
    if s.split()[-2][-1] in vowels:
        print('YES')
    else:
        print('NO')
else:
    if s.split()[-1][:-1][-1] in vowels:
        print('YES')
    else:
        print('NO')

Print answer for the question in a single line: YES if the answer is "Yes", NO if the answer is "No". Remember that in the reply to the question the last letter, not the last character counts. I. e. the spaces and the question mark do not count as letters.

Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions whatsoever that can be answered with "Yes" or "No". All the rest agree beforehand to answer the questions like that: if the question’s last letter is a vowel, they answer "Yes" and if the last letter is a consonant, they answer "No". Of course, the sleuth knows nothing about it and his task is to understand that.Unfortunately, Vasya is not very smart. After 5 hours of endless stupid questions everybody except Vasya got bored. That’s why Vasya’s friends ask you to write a program that would give answers instead of them.The English alphabet vowels are: A, E, I, O, U, YThe English alphabet consonants are: B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Z

Input: Is it a melon?

Output: NO

Input: Is it an apple?

Output: YES

Input: Is     it a banana ?

Output: YES

Input: Is   it an apple  and a  banana   simultaneouSLY?

Output: YES

Input: oHtSbDwzHb?

Output: NO

Input: sZecYdUvZHrXx?

Output: NO

Input: uMtXK?

Output: NO

Input: U?

Output: YES

Input: aqFDkCUKeHMyvZFcAyWlMUSQTFomtaWjoKLVyxLCw vcufPBFbaljOuHWiDCROYTcmbgzbaqHXKPOYEbuEtRqqoxBbOETCsQzhw?

Output: NO

Input: dJcNqQiFXzcbsj fItCpBLyXOnrSBPebwyFHlxUJHqCUzzCmcAvMiKL NunwOXnKeIxUZmBVwiCUfPkjRAkTPbkYCmwRRnDSLaz?

Output: NO

Input: gxzXbdcAQMuFKuuiPohtMgeypr wpDIoDSyOYTdvylcg SoEBZjnMHHYZGEqKgCgBeTbyTwyGuPZxkxsnSczotBdYyfcQsOVDVC?

Output: NO

Input: FQXBisXaJFMiHFQlXjixBDMaQuIbyqSBKGsBfTmBKCjszlGVZxEOqYYqRTUkGpSDDAoOXyXcQbHcPaegeOUBNeSD JiKOdECPOF?

Output: NO

Input: YhCuZnrWUBEed?

Output: NO

Input: hh?

Output: NO

Input: whU?

Output: YES

Input: fgwg?

Output: NO

Input: GlEmEPKrYcOnBNJUIFjszWUyVdvWw DGDjoCMtRJUburkPToCyDrOtMr?

Output: NO

Input: n?

Output: NO

Input: BueDOlxgzeNlxrzRrMbKiQdmGujEKmGxclvaPpTuHmTqBp?

Output: NO

Input: iehvZNQXDGCuVmJPOEysLyUryTdfaIxIuTzTadDbqRQGoCLXkxnyfWSGoLXebNnQQNTqAQJebbyYvHOfpUnXeWdjx?

Output: NO

Input: J  ?

Output: NO

Input: j                                                                                ?

Output: NO

Input: o                           ?

Output: YES

Input: T             ?

Output: NO

Input: q             ?

Output: NO

Input: j                                                                                ?

Output: NO

Input: c  ?

Output: NO

Input: B  ?

Output: NO

Input: LuhxDHVwMPTtUIUMIQTuQETgXCOQPsfdFlyHvpfOVedjUTpGLAZGOHloIjJJtOLAlHPivzA?

Output: YES

Input: wmztmzFfwbGyOmNHENUFMTsFEMWYA?

Output: YES

Input: wGsfZCSwN PEUhNUrLfABrxA?

Output: YES

Input: mCDHENXjYbgMdBimAdPnewaHfpGWowjWrVAdvWczjw  iDcUbyzMsmsnwbviiKiAyGVA?

Output: YES

Input: ARIWnwqFqxsQXsXXzHqvFjxOCttAGPUzDtWzsenPYdNXuFOIUGYZsLLK IaoxiyjBBRThoelwdPTkuCQfcBLUEJpCPIrVZlvUWA?

Output: YES

Input: PslvVpgpN BXkMFBEVXsyZFIQbBEFxGkYTeXKrOdcmhbiTUatYRUoYAayrchqbksswIlfIjerZPqptvCGnMUhyrQSvwltRhFzA?

Output: YES

Input: HpBkttwSjBXDmyleGiRWNUMPaAIE uzTrp KJDzaUiCdsMYOoWKHoUhWUoecCPmACymMUUbGav UMRpCytPETwNFAObZJA?

Output: YES

[{'input': '                      q             ?\r\n', 'output': ['NO']}, {'input': 'wmztmzFfwbGyOmNHENUFMTsFEMWYA?\r\n', 'output': ['YES']}, {'input': '       j                                                                                ?\r\n', 'output': ['NO']}, {'input': 'YhCuZnrWUBEed?\r\n', 'output': ['NO']}, {'input': 'Is   it an apple  and a  banana   simultaneouSLY?\r\n', 'output': ['YES']}]

[{'input': 'iehvZNQXDGCuVmJPOEysLyUryTdfaIxIuTzTadDbqRQGoCLXkxnyfWSGoLXebNnQQNTqAQJebbyYvHOfpUnXeWdjx?\r\n', 'output': ['NO']}, {'input': 'n?\r\n', 'output': ['NO']}, {'input': '                                                              T             ?\r\n', 'output': ['NO']}, {'input': 'gxzXbdcAQMuFKuuiPohtMgeypr wpDIoDSyOYTdvylcg SoEBZjnMHHYZGEqKgCgBeTbyTwyGuPZxkxsnSczotBdYyfcQsOVDVC?\r\n', 'output': ['NO']}, {'input': 'sZecYdUvZHrXx?\r\n', 'output': ['NO']}]

[{'input': 'iehvZNQXDGCuVmJPOEysLyUryTdfaIxIuTzTadDbqRQGoCLXkxnyfWSGoLXebNnQQNTqAQJebbyYvHOfpUnXeWdjx?\r\n', 'output': ['NO']}, {'input': 'mCDHENXjYbgMdBimAdPnewaHfpGWowjWrVAdvWczjw  iDcUbyzMsmsnwbviiKiAyGVA?\r\n', 'output': ['YES']}, {'input': 'GlEmEPKrYcOnBNJUIFjszWUyVdvWw DGDjoCMtRJUburkPToCyDrOtMr?\r\n', 'output': ['NO']}, {'input': 'Is it an apple?\r\n', 'output': ['YES']}, {'input': 'HpBkttwSjBXDmyleGiRWNUMPaAIE uzTrp KJDzaUiCdsMYOoWKHoUhWUoecCPmACymMUUbGav UMRpCytPETwNFAObZJA?\r\n', 'output': ['YES']}]

[{'input': 'wGsfZCSwN PEUhNUrLfABrxA?\r\n', 'output': ['YES']}, {'input': 'fgwg?\r\n', 'output': ['NO']}, {'input': 'n?\r\n', 'output': ['NO']}, {'input': '                                                              T             ?\r\n', 'output': ['NO']}, {'input': 'U?\r\n', 'output': ['YES']}]

[{'input': 'BueDOlxgzeNlxrzRrMbKiQdmGujEKmGxclvaPpTuHmTqBp?\r\n', 'output': ['NO']}, {'input': '       j                                                                                ?\r\n', 'output': ['NO']}, {'input': 'FQXBisXaJFMiHFQlXjixBDMaQuIbyqSBKGsBfTmBKCjszlGVZxEOqYYqRTUkGpSDDAoOXyXcQbHcPaegeOUBNeSD JiKOdECPOF?\r\n', 'output': ['NO']}, {'input': 'wmztmzFfwbGyOmNHENUFMTsFEMWYA?\r\n', 'output': ['YES']}, {'input': ' PslvVpgpN BXkMFBEVXsyZFIQbBEFxGkYTeXKrOdcmhbiTUatYRUoYAayrchqbksswIlfIjerZPqptvCGnMUhyrQSvwltRhFzA?\r\n', 'output': ['YES']}]


The first line of the input contains integer n (1 ≤ n ≤ 1000).

P = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
def power(a, b):
	res = 1
	while (b):
		if (b & 1): res *= a
		a *= a
		b >>= 1
	return res
ans = []
ans.append(1e30)
def solve(pos, n, res):
	if (n == 1):
		ans[0] = min(ans[0], res)
	for i in range(2, 62):
		if (n % i == 0):
			solve(pos + 1, n / i, res * power(P[pos], i - 1))
n = int(input())
solve(0, n, 1)
print(ans[0])

Output the smallest positive integer with exactly n divisors.

Given the number n, find the smallest positive integer which has exactly n divisors. It is guaranteed that for the given n the answer will not exceed 1018.


You are given the 8 strings whose length equals 8, describing the initial position on the board. The first line represents the top row of the board, the next one — for the second from the top, and so on, the last line represents the bottom row. Each character string matches a single cell board in the appropriate row, and the characters are in the same manner as that of the corresponding cell. If the cell is empty, the corresponding character is ".". If a cell has Maria, then it is represented by character "M". If a cell has Anna, it is represented by the character "A". If a cell has a statue, then the cell is represented by character "S". It is guaranteed that the last character of the first row is always "A", the first character of the last line is always "M". The remaining characters are "." or "S".

r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9
for i in range(0, 72, 9):
    t = set()
    for x in r:
        for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):
            if s[y] == 'T': continue
            if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)
    r = t
print('WIN' if r else 'LOSE')

If Maria wins, print string "WIN". If the statues win, print string "LOSE".

In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statues. Each statue occupies exactly one square. A square that contains a statue cannot have anything or anyone — neither any other statues, nor Anna, nor Maria.Anna is present on the board as a figurant (she stands still and never moves), and Maria has been actively involved in the game. Her goal is — to come to Anna's square. Maria and statues move in turn, Maria moves first. During one move Maria can go to any adjacent on the side or diagonal cell in which there is no statue, or she can stay in the cell where she is. The statues during their move must go one square down simultaneously, and those statues that were in the bottom row fall from the board and are no longer appeared.At that moment, when one of the statues is in the cell in which the Maria is, the statues are declared winners. At the moment when Maria comes into the cell where Anna has been waiting, Maria is declared the winner.Obviously, nothing depends on the statues, so it all depends on Maria. Determine who will win, if Maria does not make a strategic error.

Input:
.......A
........
........
........
........
........
........
M.......

Output: WIN

Input:
.......A
........
........
........
........
........
SS......
M.......

Output: LOSE

Input:
.......A
........
........
........
........
.S......
S.......
MS......

Output: LOSE

Input:
.......A
........
........
........
........
.SSSSSSS
S.......
M.......

Output: WIN

Input:
.......A
........
........
........
S.......
.SSSSSSS
S.......
M.......

Output: LOSE

Input:
.SSSSSSA
.SSSSSSS
.SSSSSSS
.SSSSSSS
.SSSSSSS
.SSSSSSS
.SSSSSSS
MSSSSSSS

Output: WIN

Input:
.......A
..SSSSSS
........
........
SSS.....
........
........
M.......

Output: WIN

Input:
SSSSSSSA
SSSSSSSS
SSSSSSSS
SSSSSSSS
SSSSSSSS
SSSSSSSS
SSSSSSSS
MSSSSSSS

Output: LOSE

Input:
.......A
........
........
........
.S......
S.......
.S......
M.......

Output: LOSE

Input:
.......A
........
........
........
........
S.......
.S......
M.......

Output: WIN

Input:
SSSSSSSA
......SS
.......S
.......S
.......S
.......S
.......S
M......S

Output: LOSE

Input:
.......A
S.S.S.S.
........
.S.S.S.S
........
S.S.S.S.
........
MS.S.S.S

Output: WIN

Input:
SSSSSSSA
......S.
......S.
.....SS.
....SS..
...SS...
..SS....
MSS.....

Output: LOSE

Input:
.S.....A
..SS....
.S......
SS......
..S.....
S.......
.S......
M.......

Output: WIN

Input:
S..SSSSA
...S.S.S
.SS.SS.S
SS....SS
.S.SSSS.
...S.S.S
..S..S..
MSSSSS.S

Output: WIN

Input:
SSSSSSSA
SS.SSSSS
SSSSSSSS
SSSSSSSS
S..SS.SS
SSSS.SSS
SSSS.SSS
M.SSS.SS

Output: LOSE

Input:
.......A
....S...
...S....
........
S..S..SS
.S....S.
S....S..
M....S.S

Output: WIN

Input:
S..SSSSA
.S..S...
S.S....S
SS..S.S.
SSSS.S..
.SS..SS.
....SS..
MS..S...

Output: LOSE

Input:
...S.SSA
.....S..
SSS....S
...S...S
....SSSS
.S.S...S
..S....S
M..SSSSS

Output: WIN

Input:
S..SS.SA
.SSS.S.S
SS.SSS.S
SSS.S.S.
SS.SSSSS
SSSSSSSS
SSSS.SS.
M.SSS.S.

Output: LOSE

Input:
...SSS.A
.....S..
..S.S.SS
.S.S...S
S.S...S.
....S...
........
M..S.SSS

Output: WIN

Input:
.S.S..SA
.S...S.S
S....S..
...S....
.S.SSSSS
S.....SS
.S.S.SSS
M....S.S

Output: LOSE

Input:
.......A
....S...
........
........
........
........
.S......
M.......

Output: WIN

Input:
SSSS.SSA
SSS.SSSS
SSSSSS.S
SS.SSS.S
SS.S.SS.
SSSS.SS.
SSSS.SSS
MSS.SSS.

Output: LOSE

Input:
SSSS.SSA
SSSSS.SS
SSSS.SSS
SSSSSSSS
SS.SSSSS
SSS.SSSS
SSSSSSSS
MSSS..SS

Output: LOSE

Input:
S.S.S..A
...SSS.S
.SSSSSS.
SS.S..SS
SSSS.SSS
.S.SSS..
SS.SSSSS
MSSSS.S.

Output: LOSE

Input:
SSSSSSSA
SS.SSS.S
SSSSSS.S
SSSSSSSS
SSSSSSSS
SSSSSSS.
SSSSSSSS
M.SSSSSS

Output: LOSE

Input:
...S...A
........
..S..S.S
.S....S.
S.......
..S.S..S
......S.
M..SS..S

Output: WIN

Input:
SSSSSSSA
SSSSSSSS
.SSSSSSS
SSSSSSSS
SSSSSSSS
SSSSS.SS
SSSSSSSS
MSSSSSSS

Output: LOSE

Input:
SSSSSSSA
SSS.SSSS
SSSSSSSS
SSS.SSSS
SSSSSSSS
SSSSSSSS
SSSSSSSS
MSSSS.SS

Output: LOSE

Input:
S.S..SSA
...S.S..
.SS.SSS.
......S.
.S...S..
..S.S..S
..SS..S.
M.SS..SS

Output: WIN

Input:
SSSSSSSA
SSSSSSSS
SSSSSSSS
SSSSSSSS
SSSSSSSS
SSSSSSSS
SSSSSSSS
MSSSSSSS

Output: LOSE

Input:
.....S.A
...S.S..
.....S..
........
........
........
......S.
M....S..

Output: WIN

Input:
.S.S.S.A
.SS.S..S
..S....S
..S.....
SSS.S...
.S....S.
SSSSSS..
M..S....

Output: LOSE

Input:
SSSSS..A
S.SS.SS.
.S.SSS.S
..SSSSS.
.S..S.S.
.SS.S..S
SSS.S...
M..S..S.

Output: LOSE

Input:
.......A
........
........
........
..S....S
........
........
M.......

Output: WIN

Input:
.......A
...S...S
...S....
....S..S
........
S.S...S.
SS......
MS......

Output: LOSE

Input:
S......A
.SS..S..
S....S..
SSS...S.
.SS.SSS.
.S.SS...
..S..S..
M.SS....

Output: LOSE

Input:
.SSSS.SA
.SS.SSS.
..S.SS..
SSSS.SS.
S.S.....
S.S.SSSS
S..SS..S
MS.SS.SS

Output: LOSE

Input:
SSS..SSA
SSSSSSSS
..SS..SS
.S.S.SSS
.SSS.SSS
SSSS.S.S
...SS..S
MS..S.SS

Output: LOSE

Input:
S..SSS.A
S.S.SSSS
SSSSSSSS
...SS...
S.SSSSSS
SS..SS.S
SS..S.S.
MSS..SSS

Output: LOSE

Input:
S.SS.SSA
.S..SSS.
SSS.SSS.
SSSS.SSS
S.SSSSSS
SSSSSSSS
SSSSS.SS
MS.SSSSS

Output: LOSE

Input:
SSS.SSSA
SSS....S
SS...SSS
..SSS..S
S..SS...
SS.SS...
.S..SSSS
M.SSSSSS

Output: LOSE

Input:
SSS.SSSA
SSSSSSSS
SSSSSSSS
SS.SSS.S
SSSSSSSS
SSSSSSSS
SSSSSSSS
MSSSSSSS

Output: LOSE

Input:
SSSSSSSA
........
........
........
........
........
........
M.......

Output: WIN

Input:
.......A
........
SSS.....
........
........
.S......
.S......
MS......

Output: WIN

[{'input': 'SSSSSSSA\r\nSS.SSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nS..SS.SS\r\nSSSS.SSS\r\nSSSS.SSS\r\nM.SSS.SS\r\n', 'output': ['LOSE']}, {'input': 'SSSSSSSA\r\nSSS.SSSS\r\nSSSSSSSS\r\nSSS.SSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nMSSSS.SS\r\n', 'output': ['LOSE']}, {'input': '.......A\r\n........\r\n........\r\n........\r\n........\r\n.SSSSSSS\r\nS.......\r\nM.......\r\n', 'output': ['WIN']}, {'input': 'SSS..SSA\r\nSSSSSSSS\r\n..SS..SS\r\n.S.S.SSS\r\n.SSS.SSS\r\nSSSS.S.S\r\n...SS..S\r\nMS..S.SS\r\n', 'output': ['LOSE']}, {'input': 'S.SS.SSA\r\n.S..SSS.\r\nSSS.SSS.\r\nSSSS.SSS\r\nS.SSSSSS\r\nSSSSSSSS\r\nSSSSS.SS\r\nMS.SSSSS\r\n', 'output': ['LOSE']}]


n, m, L, R = map(int, input().split())
mod = 998244353
if n*m % 2:
  print(pow(R-L+1, n*m, mod))
else:
  print((pow(R-L+1, n*m, mod) + 1 - (R-L) % 2) * pow(2, mod-2, mod) % mod)

NoteIn the first sample, the only initial grid that satisfies the requirements is $$$a_{1,1}=a_{2,1}=a_{1,2}=a_{2,2}=1$$$. Thus the answer should be $$$1$$$.In the second sample, initial grids that satisfy the requirements are $$$a_{1,1}=a_{1,2}=1$$$ and $$$a_{1,1}=a_{1,2}=2$$$. Thus the answer should be $$$2$$$.

Output one integer, representing the desired answer modulo $$$998,244,353$$$.

Alice has got addicted to a game called Sirtet recently.In Sirtet, player is given an $$$n \times m$$$ grid. Initially $$$a_{i,j}$$$ cubes are stacked up in the cell $$$(i,j)$$$. Two cells are called adjacent if they share a side. Player can perform the following operations:   stack up one cube in two adjacent cells;  stack up two cubes in one cell. Cubes mentioned above are identical in height.Here is an illustration of the game. States on the right are obtained by performing one of the above operations on the state on the left, and grey cubes are added due to the operation.  Player's goal is to make the height of all cells the same (i.e. so that each cell has the same number of cubes in it) using above operations. Alice, however, has found out that on some starting grids she may never reach the goal no matter what strategy she uses. Thus, she is wondering the number of initial grids such that   $$$L \le a_{i,j} \le R$$$ for all $$$1 \le i \le n$$$, $$$1 \le j \le m$$$;  player can reach the goal using above operations. Please help Alice with it. Notice that the answer might be large, please output the desired value modulo $$$998,244,353$$$.

Input: 2 2 1 1

Output: 1

Input: 1 2 1 2

Output: 2

Input: 485 117 386829368 748204956

Output: 735420370

Input: 564 558 305171115 960941497

Output: 880111542

Input: 692 210 44175861 843331069

Output: 714028205

Input: 741 806 424647372 965259389

Output: 861647194

Input: 461 650 18427925 104278996

Output: 936348652

Input: 589 790 462465375 766499149

Output: 374887989

Input: 13 635 761278633 941090619

Output: 893955177

Input: 140 713 711390561 727285861

Output: 641355762

Input: 494587372 852064625 134519483 167992226

Output: 552905694

Input: 672670796 425613469 728300037 940234946

Output: 779704132

Input: 850754220 853938121 172337487 490664825

Output: 237240423

Input: 28837644 722454262 471150744 905552093

Output: 740846915

Input: 911953772 296003106 210155490 889555498

Output: 225799480

Input: 795069900 869551950 803936044 964554424

Output: 884379548

Input: 268120620 443100795 102749301 604856694

Output: 834319192

Input: 151236748 16649639 841754047 855153000

Output: 108988868

Input: 329320172 739941588 435534601 986184053

Output: 425887732

Input: 1000000000 1 1000000000 1000000000

Output: 1

Input: 1 1000000000 1 1000000000

Output: 285141888

Input: 407070359 971940670 264302148 270591105

Output: 992759231

Input: 290186487 840456810 858082702 987072033

Output: 366829057

Input: 763237207 414005655 302120151 421405724

Output: 193545831

Input: 646353335 282521795 600933409 772270276

Output: 13680108

Input: 824436759 415879151 194713963 293553316

Output: 453443939

Input: 707552887 989427996 933718708 955125306

Output: 355610620

Input: 885636311 857944136 232531966 493119835

Output: 779245677

Input: 63719735 431492981 971536712 994663491

Output: 97582142

Input: 946835863 300009121 565317265 947272048

Output: 337235143

Input: 124919287 578590669 9354715 32571540

Output: 263200129

Input: 202669473 255300152 987865366 994537507

Output: 926661352

Input: 2 2 1 998244353

Output: 499122177

Input: 2 3 1 998244353

Output: 499122177

Input: 3 3 1 998244353

Output: 0

Input: 1000000000 1000000000 1 998244353

Output: 499122177

Input: 999999999 999999999 1 998244353

Output: 0

Input: 999999999 1000000000 1755648 1000000000

Output: 499122177

Input: 1 2 1 86583718

Output: 499122176

Input: 1 2 1 911660635

Output: 0

Input: 2 2 2 4

Output: 41

Input: 2 2 2 5

Output: 128

Input: 2 2 3 4

Output: 8

Input: 2 2 3 5

Output: 41

Input: 2 3 2 4

Output: 365

Input: 2 3 2 5

Output: 2048

Input: 2 3 3 4

Output: 32

Input: 2 3 3 5

Output: 365

Input: 3 2 2 4

Output: 365

Input: 3 2 2 5

Output: 2048

Input: 3 2 3 4

Output: 32

Input: 3 2 3 5

Output: 365

Input: 3 3 2 4

Output: 19683

Input: 3 3 2 5

Output: 262144

Input: 3 3 3 4

Output: 512

Input: 3 3 3 5

Output: 19683

Input: 998244352 2 1 998244353

Output: 499122177

Input: 3 3 1 1

Output: 1


The only line contains 14 integers $$$a_1, a_2, \ldots, a_{14}$$$ ($$$0 \leq a_i \leq 10^9$$$) — the number of stones in each hole. It is guaranteed that for any $$$i$$$ ($$$1\leq i \leq 14$$$) $$$a_i$$$ is either zero or odd, and there is at least one stone in the board.

A=list(map(int,input().split()))
score=0
for i in range(14):
    score=max(score,sum([j for j in [(A[j] if i!=j else 0)+A[i]//14+(1 if (j+13-i)%14<A[i]%14 else 0) for j in range(14)] if j%2==0]))
print(score)

NoteIn the first test case the board after the move from the hole with $$$7$$$ stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to $$$4$$$.

Output one integer, the maximum possible score after one move.

Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes.   Initially, each hole has $$$a_i$$$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction.Note that the counter-clockwise order means if the player takes the stones from hole $$$i$$$, he will put one stone in the $$$(i+1)$$$-th hole, then in the $$$(i+2)$$$-th, etc. If he puts a stone in the $$$14$$$-th hole, the next one will be put in the first hole.After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli.Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move.

Input: 0 1 1 0 0 0 0 0 0 7 0 0 0 0

Output: 4

Input: 5 1 1 1 1 0 0 0 0 0 0 0 0 0

Output: 8

Input: 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 1

Output: 54294

Input: 0 0 0 0 0 0 0 0 0 0 0 0 0 15

Output: 2

Input: 1 0 0 0 0 1 0 0 0 0 1 0 0 0

Output: 0

Input: 5 5 1 1 1 3 3 3 5 7 5 3 7 5

Output: 38

Input: 787 393 649 463 803 365 81 961 989 531 303 407 579 915

Output: 7588

Input: 8789651 4466447 1218733 6728667 1796977 6198853 8263135 6309291 8242907 7136751 3071237 5397369 6780785 9420869

Output: 81063456

Input: 0 0 0 0 0 0 0 0 0 0 0 0 0 29

Output: 26

Input: 282019717 109496191 150951267 609856495 953855615 569750143 6317733 255875779 645191029 572053369 290936613 338480779 879775193 177172893

Output: 5841732816

Input: 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505

Output: 120472578

Input: 404418821 993626161 346204297 122439813 461187221 628048227 625919459 628611733 938993057 701270099 398043779 684205961 630975553 575964835

Output: 8139909016

Input: 170651077 730658441 824213789 583764177 129437345 717005779 675398017 314979709 380861369 265878463 746564659 797260041 506575735 335169317

Output: 6770880638

Input: 622585025 48249287 678950449 891575125 637411965 457739735 829353393 235216425 284006447 875591469 492839209 296444305 513776057 810057753

Output: 7673796644

Input: 475989857 930834747 786217439 927967137 489188151 869354161 276693267 56154399 131055697 509249443 143116853 426254423 44465165 105798821

Output: 6172339560

Input: 360122921 409370351 226220005 604004145 85173909 600403773 624052991 138163383 729239967 189036661 619842883 270087537 749500483 243727913

Output: 5848946922

Input: 997102881 755715147 273805839 436713689 547411799 72470207 522269145 647688957 137422311 422612659 197751751 679663349 821420227 387967237

Output: 6900015198

Input: 690518849 754551537 652949719 760695679 491633619 477564457 11669279 700467439 470069297 782338983 718169393 884421719 24619427 215745577

Output: 7635414974

Input: 248332749 486342237 662201929 917696895 555278549 252122023 850296207 463343655 832574345 954281071 168282553 825538865 996753493 461254663

Output: 6400166934

Input: 590789361 636464947 404477303 337309187 476703809 426863069 120608741 703406277 645444697 761482231 996635839 33459441 677458865 483861751

Output: 7294965518

Input: 297857621 238127103 749085829 139033277 597985489 202617713 982184715 183932743 278551059 297781685 330124279 338959601 682874531 187519685

Output: 5201808164

Input: 1 1 1 1 1 0 0 0 0 0 0 0 0 0

Output: 2

Input: 1 1 0 0 0 0 0 0 0 0 0 0 0 0

Output: 2

Input: 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 2

Input: 1 0 0 0 0 0 0 0 0 0 0 0 0 1

Output: 2

Input: 0 0 0 0 0 0 0 0 0 0 0 0 1 1

Output: 2


The first input line contains the string. It's guaranteed, that the string is non-empty, consists of lower-case Latin letters, and its length doesn't exceed 100.

S = input()

ans = 0
met = set()

for i in range(len(S)):
    for j in range(i, -1, -1):
        if S[j:i+1] in met:
            ans = max(ans, i - j + 1)
        else:
            met.add(S[j:i+1])

print(ans)

Output one number — length of the longest substring that can be met in the string at least twice.

You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2).

Input: abcd

Input: ababa

Input: zzz

Input: kmmm

Input: wzznz

Input: qlzazaaqll

Input: lzggglgpep

Input: iegdlraaidefgegiagrdfhihe

Output: 2

Input: esxpqmdrtidgtkxojuxyrcwxlycywtzbjzpxvbngnlepgzcaeg

Output: 1

Input: garvpaimjdjiivamusjdwfcaoswuhxyyxvrxzajoyihggvuxumaadycfphrzbprraicvjjlsdhojihaw

Output: 2

Input: ckvfndqgkmhcyojaqgdkenmbexufryhqejdhctxujmtrwkpbqxufxamgoeigzfyzbhevpbkvviwntdhqscvkmphnkkljizndnbjt

Output: 3

Input: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

Output: 99

Input: ikiikiikikiiikkkkkikkkkiiiiikkiiikkiikiikkkkikkkikikkikiiikkikikiiikikkkiiikkkikkikkikkkkiiikkiiiiii

Output: 10

Input: ovovhoovvhohhhvhhvhhvhovoohovhhoooooovohvooooohvvoooohvvovhhvhovhhvoovhvhvoovovvhooovhhooovohvhhovhv

Output: 8

Input: ccwckkkycccccckwckwkwkwkkkkyycykcccycyckwywcckwykcycykkkwcycwwcykcwkwkwwykwkwcykywwwyyykckkyycckwcwk

Output: 5

Input: ttketfkefktfztezzkzfkkeetkkfktftzktezekkeezkeeetteeteefetefkzzzetekfftkeffzkktffzkzzeftfeezfefzffeef

Output: 4

Input: rtharczpfznrgdnkltchafduydgbgkdjqrmjqyfmpwjwphrtsjbmswkanjlprbnduaqbcjqxlxmkspkhkcnzbqwxonzxxdmoigti

Output: 2

Input: fplrkfklvwdeiynbjgaypekambmbjfnoknlhczhkdmljicookdywdgpnlnqlpunnkebnikgcgcjefeqhknvlynmvjcegvcdgvvdb

Output: 2

Input: txbciieycswqpniwvzipwlottivvnfsysgzvzxwbctcchfpvlbcjikdofhpvsknptpjdbxemtmjcimetkemdbettqnbvzzbdyxxb

Output: 2

Input: fmubmfwefikoxtqvmaavwjxmoqltapexkqxcsztpezfcltqavuicefxovuswmqimuikoppgqpiapqutkczgcvxzutavkujxvpklv

Output: 3

Input: ipsrjylhpkjvlzncfixipstwcicxqygqcfrawpzzvckoveyqhathglblhpkjvlzncfixipfajaqobtzvthmhgbuawoxoknirclxg

Output: 15

Input: kcnjsntjzcbgzjscrsrjkrbytqsrptzspzctjrorsyggrtkcnjsntjzcbgzjscrsrjyqbrtpcgqirsrrjbbbrnyqstnrozcoztt

Output: 20

Input: unhcfnrhsqetuerjqcetrhlsqgfnqfntvkgxsscquolxxroqgtchffyccetrhlsqgfnqfntvkgxsscquolxxroqgtchffhfqvx

Output: 37

Input: kkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckkkkkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckckckkc

Output: 46

Input: mlhsyijxeydqxhtkmpdeqwzogjvxahmssyhfhqessbxzvydbrxdmlhsyijxeydqxhtkmpdeqwzogjvxahmssyhfhqessbxzvydik

Output: 47

Input: abcdefghijklmnopqrstuvwxyz

Output: 0

Input: tttttbttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttmttttttt

Output: 85

Input: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffffffffffffffffffffffffffffffffffff

Output: 61

Input: cccccccccccccccccccccccwcccccccccccccccccccccuccccccccccccccnccccccccccccccccccccccccccccccccccccccc

Output: 38

Input: ffffffffffffffffffffffffffufffgfffffffffffffffffffffffffffffffffffffffgffffffftffffffgffffffffffffff

Output: 38

Input: rrrrrrrrrrrrrrrrrrrlhbrrrrrrrrurrrrrrrfrrqrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrewrrrrrrryrrxrrrrrrrrrrr

Output: 33

Input: vyvvvvvvvvzvvvvvzvvvwvvvvrvvvvvvvvvvvvvvvrvvvvvvvvvpkvvpvgvvvvvvvvvvvvvgvvvvvvvvvvvvvvvvvvysvvvbvvvv

Output: 17

Input: cbubbbbbbbbbbfbbbbbbbbjbobbbbbbbbbbibbubbbbjbbbnzgbbzbbfbbbbbbbbbbbfbpbbbbbbbbbbygbbbgbabbbbbbbhibbb

Output: 12

Input: lrqrrrrrrrjrrrrrcdrrgrrmwvrrrrrrrrrxfzrmrmrryrrrurrrdrrrrrrrrrrererrrsrrrrrrrrrrrqrrrrcrrwjsrrlrrrrr

Output: 10

Input: ssssusisisosscssssztzessssyspskjssvosiissussszsosssslsssdsssvssvsssslsssmsfjasjsssssowscsjsssszsspss

Output: 8

Input: uukuuuumueuuuujuukgdhbztuuuubbguuocuozfaunqufjujuguyuuvkuuauubuubuucuvtjuuuuuusduduuuuuuuueunuuuuuzu

Output: 7

Input: jpkkgwklngwqcfzmwkkpcwkkkkkekkkekkkdsykqwjkkkhkkkxdnukkkkkkmkqykkkxqklkskkrkkkkkqqjikkkkkkpknkkkkkoh

Output: 7

Input: bmzbbfbbhqxwthtbbisbbbbbtbbfbbpbfbbpbkbjfbcbbbbzbbbdwmbbbrnvqdbbtbbuglrnbbbbvmbyblebbabibrevaxbbjbqb

Output: 6

Input: qqqmqqqsbteqqopsuqiqumrqzpqnqgqeniqqkyqqyqqqpxzqeqqquhdqquhqqqfqjirqaqqaquxqoqqjqqqqbjbgqcqqqqicnkqc

Output: 4

Input: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasaaaavaaaaaaauaaeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Output: 44

Input: a

Input: fg

Input: yy

Input: abcabcabc

Input: qwerqwedqwes

Output: 3

[{'input': 'abcd\r\n', 'output': ['0']}, {'input': 'rrrrrrrrrrrrrrrrrrrlhbrrrrrrrrurrrrrrrfrrqrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrewrrrrrrryrrxrrrrrrrrrrr\r\n', 'output': ['33']}, {'input': 'ababa\r\n', 'output': ['3']}, {'input': 'ikiikiikikiiikkkkkikkkkiiiiikkiiikkiikiikkkkikkkikikkikiiikkikikiiikikkkiiikkkikkikkikkkkiiikkiiiiii\r\n', 'output': ['10']}, {'input': 'lzggglgpep\r\n', 'output': ['2']}]

[{'input': 'qlzazaaqll\r\n', 'output': ['2']}, {'input': 'kmmm\r\n', 'output': ['2']}, {'input': 'qqqmqqqsbteqqopsuqiqumrqzpqnqgqeniqqkyqqyqqqpxzqeqqquhdqquhqqqfqjirqaqqaquxqoqqjqqqqbjbgqcqqqqicnkqc\r\n', 'output': ['4']}, {'input': 'a\r\n', 'output': ['0']}, {'input': 'ipsrjylhpkjvlzncfixipstwcicxqygqcfrawpzzvckoveyqhathglblhpkjvlzncfixipfajaqobtzvthmhgbuawoxoknirclxg\r\n', 'output': ['15']}]

[{'input': 'lrqrrrrrrrjrrrrrcdrrgrrmwvrrrrrrrrrxfzrmrmrryrrrurrrdrrrrrrrrrrererrrsrrrrrrrrrrrqrrrrcrrwjsrrlrrrrr\r\n', 'output': ['10']}, {'input': 'kkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckkkkkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckckckkc\r\n', 'output': ['46']}, {'input': 'jpkkgwklngwqcfzmwkkpcwkkkkkekkkekkkdsykqwjkkkhkkkxdnukkkkkkmkqykkkxqklkskkrkkkkkqqjikkkkkkpknkkkkkoh\r\n', 'output': ['7']}, {'input': 'bmzbbfbbhqxwthtbbisbbbbbtbbfbbpbfbbpbkbjfbcbbbbzbbbdwmbbbrnvqdbbtbbuglrnbbbbvmbyblebbabibrevaxbbjbqb\r\n', 'output': ['6']}, {'input': 'zzz\r\n', 'output': ['2']}]

[{'input': 'ipsrjylhpkjvlzncfixipstwcicxqygqcfrawpzzvckoveyqhathglblhpkjvlzncfixipfajaqobtzvthmhgbuawoxoknirclxg\r\n', 'output': ['15']}, {'input': 'tttttbttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttmttttttt\r\n', 'output': ['85']}, {'input': 'wzznz\r\n', 'output': ['1']}, {'input': 'bmzbbfbbhqxwthtbbisbbbbbtbbfbbpbfbbpbkbjfbcbbbbzbbbdwmbbbrnvqdbbtbbuglrnbbbbvmbyblebbabibrevaxbbjbqb\r\n', 'output': ['6']}, {'input': 'cbubbbbbbbbbbfbbbbbbbbjbobbbbbbbbbbibbubbbbjbbbnzgbbzbbfbbbbbbbbbbbfbpbbbbbbbbbbygbbbgbabbbbbbbhibbb\r\n', 'output': ['12']}]

[{'input': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasaaaavaaaaaaauaaeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['44']}, {'input': 'cbubbbbbbbbbbfbbbbbbbbjbobbbbbbbbbbibbubbbbjbbbnzgbbzbbfbbbbbbbbbbbfbpbbbbbbbbbbygbbbgbabbbbbbbhibbb\r\n', 'output': ['12']}, {'input': 'qqqmqqqsbteqqopsuqiqumrqzpqnqgqeniqqkyqqyqqqpxzqeqqquhdqquhqqqfqjirqaqqaquxqoqqjqqqqbjbgqcqqqqicnkqc\r\n', 'output': ['4']}, {'input': 'kmmm\r\n', 'output': ['2']}, {'input': 'kkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckkkkkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckckckkc\r\n', 'output': ['46']}]


The first line contains two integers x, y ( - 109 ≤ x, y ≤ 109, x ≠ 0, y ≠ 0).

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

if  x > 0 and y > 0:
    print(0, x + y, x + y, 0)
elif x < 0 and y > 0:
    print(-y + x, 0, 0,-x + y)
elif x > 0 and y < 0:
    print(0, y - x, x - y, 0)
else:
    print(x + y, 0,0, x + y)

Print in the single line four integers x1, y1, x2, y2 — the coordinates of the required points.

Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes. Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:  the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;  the triangle formed by point A, B and C is rectangular and isosceles ( is right);  all points of the favorite rectangle are located inside or on the border of triangle ABC;  the area of triangle ABC is as small as possible. Help the bear, find the required points. It is not so hard to proof that these points are unique.

Input: 10 5

Output: 0 15 15 0

Input: -10 5

Output: -15 0 0 15

Input: 20 -10

Output: 0 -30 30 0

Input: -10 -1000000000

Output: -1000000010 0 0 -1000000010

Input: -1000000000 -1000000000

Output: -2000000000 0 0 -2000000000

Input: 1000000000 1000000000

Output: 0 2000000000 2000000000 0

Input: -123131 3123141

Output: -3246272 0 0 3246272

Input: -23423 -243242423

Output: -243265846 0 0 -243265846

Input: 123112 4560954

Output: 0 4684066 4684066 0

Input: 1321 -23131

Output: 0 -24452 24452 0

Input: 1000000000 999999999

Output: 0 1999999999 1999999999 0

Input: 54543 432423

Output: 0 486966 486966 0

Input: 1 1

Output: 0 2 2 0

Input: -1 -1

Output: -2 0 0 -2

Input: -1 1

Output: -2 0 0 2

Input: 1 -1

Output: 0 -2 2 0

Input: 42 -2

Output: 0 -44 44 0

Input: 2 -435

Output: 0 -437 437 0

Input: 76 -76

Output: 0 -152 152 0

Input: 1000000000 1

Output: 0 1000000001 1000000001 0

Input: 1000000000 -1

Output: 0 -1000000001 1000000001 0

Input: -1000000000 1

Output: -1000000001 0 0 1000000001

Input: -1000000000 -1

Output: -1000000001 0 0 -1000000001

Input: 1000000000 -999999999

Output: 0 -1999999999 1999999999 0

Input: -1000000000 999999999

Output: -1999999999 0 0 1999999999

Input: -1000000000 -999999999

Output: -1999999999 0 0 -1999999999

Input: 999999999 1000000000

Output: 0 1999999999 1999999999 0

Input: -999999999 1000000000

Output: -1999999999 0 0 1999999999

Input: 999999999 -1000000000

Output: 0 -1999999999 1999999999 0

Input: -999999999 -1000000000

Output: -1999999999 0 0 -1999999999


The first line of the input contains three integers a, b and c (0 ≤ a, b, c ≤ 1 000 000) — the number of blue, violet and orange spheres that are in the magician's disposal. The second line of the input contains three integers, x, y and z (0 ≤ x, y, z ≤ 1 000 000) — the number of blue, violet and orange spheres that he needs to get.

a, b, c =[int(q) for q in input().split()]
x, y, z =[int(q) for q in input().split()]
if a>=x:
    a -=x
    x=0
else:
    x -=a
    a=0
if b>=y:
    b -=y
    y=0
else:
    y -=b
    b=0
if c>=z:
    c -=z
    z=0
else:
    z -=c
    c=0
if x+y+z<=a//2+b//2+c//2:
    print("Yes")
else:
    print("No")

NoteIn the first sample the wizard has 4 blue and 4 violet spheres. In his first action he can turn two blue spheres into one violet one. After that he will have 2 blue and 5 violet spheres. Then he turns 4 violet spheres into 2 orange spheres and he ends up with 2 blue, 1 violet and 2 orange spheres, which is exactly what he needs.

If the wizard is able to obtain the required numbers of spheres, print "Yes". Otherwise, print "No".

Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x blue, y violet and z orange spheres. Can he get them (possible, in multiple actions)?

Input:
4 4 0
2 1 2

Output: YES

Output: Yes

Input:
5 6 1
2 7 2

Output: No

Output: NO

Input:
3 3 3
2 2 2

Output: YES

Output: Yes

Input:
0 0 0
0 0 0

Output: YES

Output: Yes

Input:
0 0 0
0 0 1

Output: No

Output: NO

Input:
0 1 0
0 0 0

Output: YES

Output: Yes

Input:
1 0 0
1 0 0

Output: YES

Output: Yes

Input:
2 2 1
1 1 2

Output: No

Output: NO

Input:
1 3 1
2 1 1

Output: YES

Output: Yes

Input:
1000000 1000000 1000000
1000000 1000000 1000000

Output: YES

Output: Yes

Input:
1000000 500000 500000
0 750000 750000

Output: YES

Output: Yes

Input:
500000 1000000 500000
750001 0 750000

Output: No

Output: NO

Input:
499999 500000 1000000
750000 750000 0

Output: No

Output: NO

Input:
500000 500000 0
0 0 500000

Output: YES

Output: Yes

Input:
0 500001 499999
500000 0 0

Output: No

Output: NO

Input:
1000000 500000 1000000
500000 1000000 500000

Output: YES

Output: Yes

Input:
1000000 1000000 499999
500000 500000 1000000

Output: No

Output: NO

Input:
500000 1000000 1000000
1000000 500001 500000

Output: No

Output: NO

Input:
1000000 500000 500000
0 1000000 500000

Output: YES

Output: Yes

Input:
500000 500000 1000000
500001 1000000 0

Output: No

Output: NO

Input:
500000 999999 500000
1000000 0 500000

Output: No

Output: NO

Input:
4 0 3
2 2 1

Output: YES

Output: Yes

Input:
0 2 4
2 0 2

Output: YES

Output: Yes

Input:
3 1 0
1 1 1

Output: YES

Output: Yes

Input:
4 4 1
1 3 2

Output: YES

Output: Yes

Input:
1 2 4
2 1 3

Output: No

Output: NO

Input:
1 1 0
0 0 1

Output: No

Output: NO

Input:
4 0 0
0 1 1

Output: YES

Output: Yes

Input:
0 3 0
1 0 1

Output: No

Output: NO

Input:
0 0 3
1 0 1

Output: YES

Output: Yes

Input:
1 12 1
4 0 4

Output: YES

Output: Yes

Input:
4 0 4
1 2 1

Output: YES

Output: Yes

Input:
4 4 0
1 1 3

Output: No

Output: NO

Input:
0 9 0
2 2 2

Output: No

Output: NO

Input:
0 10 0
2 2 2

Output: YES

Output: Yes

Input:
9 0 9
0 8 0

Output: YES

Output: Yes

Input:
0 9 9
9 0 0

Output: No

Output: NO

Input:
9 10 0
0 0 9

Output: YES

Output: Yes

Input:
10 0 9
0 10 0

Output: No

Output: NO

Input:
0 10 10
10 0 0

Output: YES

Output: Yes

Input:
10 10 0
0 0 11

Output: No

Output: NO

Input:
307075 152060 414033
381653 222949 123101

Output: No

Output: NO

Input:
569950 228830 153718
162186 357079 229352

Output: No

Output: NO

Input:
149416 303568 749016
238307 493997 190377

Output: No

Output: NO

Input:
438332 298094 225324
194220 400244 245231

Output: No

Output: NO

Input:
293792 300060 511272
400687 382150 133304

Output: No

Output: NO

Input:
295449 518151 368838
382897 137148 471892

Output: No

Output: NO

Input:
191789 291147 691092
324321 416045 176232

Output: YES

Output: Yes

Input:
286845 704749 266526
392296 104421 461239

Output: YES

Output: Yes

Input:
135522 188282 377041
245719 212473 108265

Output: YES

Output: Yes

Input:
404239 359124 133292
180069 184791 332544

Output: No

Output: NO

Input:
191906 624432 244408
340002 367217 205432

Output: No

Output: NO

Input:
275980 429361 101824
274288 302579 166062

Output: No

Output: NO

Input:
136092 364927 395302
149173 343146 390922

Output: No

Output: NO

Input:
613852 334661 146012
363786 326286 275233

Output: No

Output: NO

Input:
348369 104625 525203
285621 215396 366411

Output: No

Output: NO

Input:
225307 153572 114545
154753 153282 149967

Output: YES

Output: Yes

Input:
438576 124465 629784
375118 276028 390116

Output: YES

Output: Yes

Input:
447521 327510 158732
395759 178458 259139

Output: YES

Output: Yes

Input:
8 5 5
5 5 5

Output: YES

Output: Yes

Input:
100 100 100
1 1 1

Output: YES

Output: Yes

Input:
100 100 100
0 0 0

Output: YES

Output: Yes

Input:
3 2 3
2 3 2

Output: No

Output: NO

Input:
5 4 3
2 2 2

Output: YES

Output: Yes

Input:
14 9 8
12 5 10

Output: YES

Output: Yes

Input:
10 10 10
1 1 1

Output: YES

Output: Yes

Input:
6 3 3
3 3 3

Output: YES

Output: Yes

Input:
10 0 4
2 4 2

Output: YES

Output: Yes

Input:
100 100 100
2 2 2

Output: YES

Output: Yes

Input:
4 6 0
2 1 2

Output: YES

Output: Yes

Input:
4 6 3
4 2 3

Output: YES

Output: Yes

Input:
5 5 5
1 1 1

Output: YES

Output: Yes

Input:
41 17 34
0 19 24

Output: YES

Output: Yes

Input:
8 8 8
3 3 3

Output: YES

Output: Yes

Input:
7 7 1
1 1 2

Output: YES

Output: Yes

Input:
6 6 0
2 2 2

Output: YES

Output: Yes

Input:
5 5 5
2 2 2

Output: YES

Output: Yes

Input:
400 400 400
1 1 1

Output: YES

Output: Yes

Input:
4 4 4
2 2 2

Output: YES

Output: Yes


The first line contains four space-separated integers s1, s2, s3, s4 (1 ≤ s1, s2, s3, s4 ≤ 109) — the colors of horseshoes Valera has. Consider all possible colors indexed with integers.

s = [int(i) for i in input().split()]
m=0
for i in s:
    if s.count(i) >= 2:
        s = list(set(s))

m = len(s)

if m == 4:
    print(0)
elif m == 3:
    print(1)
elif m == 2:
    print(2)
else:
    print(3)

Print a single integer — the minimum number of horseshoes Valera needs to buy.

Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has got four horseshoes left from the last year, but maybe some of them have the same color. In this case he needs to go to the store and buy some few more horseshoes, not to lose face in front of his stylish comrades.Fortunately, the store sells horseshoes of all colors under the sun and Valera has enough money to buy any four of them. However, in order to save the money, he would like to spend as little money as possible, so you need to help Valera and determine what is the minimum number of horseshoes he needs to buy to wear four horseshoes of different colors to a party.

Input: 1 7 3 3

Output: 1

Input: 7 7 7 7

Output: 3

Input: 81170865 673572653 756938629 995577259

Output: 0

Input: 3491663 217797045 522540872 715355328

Output: 0

Input: 251590420 586975278 916631563 586975278

Output: 1

Input: 259504825 377489979 588153796 377489979

Output: 1

Input: 652588203 931100304 931100304 652588203

Output: 2

Input: 391958720 651507265 391958720 651507265

Output: 2

Input: 90793237 90793237 90793237 90793237

Output: 3

Input: 551651653 551651653 551651653 551651653

Output: 3

Input: 156630260 609654355 668943582 973622757

Output: 0

Input: 17061017 110313588 434481173 796661222

Output: 0

Input: 24975422 256716298 337790533 690960249

Output: 0

Input: 255635360 732742923 798648949 883146723

Output: 0

Input: 133315691 265159773 734556507 265159773

Output: 1

Input: 28442865 741657755 978106882 978106882

Output: 1

Input: 131245479 174845575 497483467 131245479

Output: 1

Input: 139159884 616215581 958341883 616215581

Output: 1

Input: 147784432 947653080 947653080 947653080

Output: 2

Input: 94055790 756126496 756126496 94055790

Output: 2

Input: 240458500 511952208 240458500 511952208

Output: 2

Input: 681828506 972810624 972810624 681828506

Output: 2

Input: 454961014 454961014 454961014 454961014

Output: 3

Input: 915819430 915819430 915819430 915819430

Output: 3

Input: 671645142 671645142 671645142 671645142

Output: 3

Input: 132503558 132503558 132503558 132503558

Output: 3

Input: 5 5 999999 6

Output: 1

Input: 1 1 2 5

Output: 1

Input: 2 1 2 3

Output: 1

Input: 1 1 3 5

Output: 1

Input: 1 1 3 3

Output: 2

Input: 2 2 2 1

Output: 2

Input: 3 1 1 1

Output: 2

Input: 1 2 2 2

Output: 2


The first line contains word s, the second line contains word t. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols.

word1 = input()
word2 = input()

w1len = len(word1)
w2len = len(word2)

if w1len != w2len:
    print('NO')

else:

    if (w1len % 2) == 0:  # ES
        index = w1len - 1
        cant = w1len
        i = 0
        while cant != 0:
            a = word1[i]
            b = word2[index]

            if a == b:
                i += 1
                index -= 1
                cant -= 1

            else:
                print('NO')
                break
        if cant == 0:
            print('YES')

    else:
        index = w1len - 1
        cant = w1len
        i = 0
        while cant != 0:
            a = word1[i]
            b = word2[index]

            if a == b:
                i += 1
                index -= 1
                cant -= 1

            else:
                print('NO')
                break
        if cant == 0:
            print('YES')

If the word t is a word s, written reversely, print YES, otherwise print NO.

The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc. However, it's easy to make a mistake during the «translation». Vasya translated word s from Berlandish into Birlandish as t. Help him: find out if he translated the word correctly.

Input:
code
edoc

Output: YES

Input:
abb
aba

Output: NO

Input:
code
code

Output: NO

Input:
abacaba
abacaba

Output: YES

Input:
q
q

Output: YES

Input:
asrgdfngfnmfgnhweratgjkk
asrgdfngfnmfgnhweratgjkk

Output: NO

Input:
z
a

Output: NO

Input:
asd
dsa

Output: YES

Input:
abcdef
fecdba

Output: NO

Input:
ywjjbirapvskozubvxoemscfwl
gnduubaogtfaiowjizlvjcu

Output: NO

Input:
mfrmqxtzvgaeuleubcmcxcfqyruwzenguhgrmkuhdgnhgtgkdszwqyd
mfxufheiperjnhyczclkmzyhcxntdfskzkzdwzzujdinf

Output: NO

Input:
bnbnemvybqizywlnghlykniaxxxlkhftppbdeqpesrtgkcpoeqowjwhrylpsziiwcldodcoonpimudvrxejjo
tiynnekmlalogyvrgptbinkoqdwzuiyjlrldxhzjmmp

Output: NO

Input:
pwlpubwyhzqvcitemnhvvwkmwcaawjvdiwtoxyhbhbxerlypelevasmelpfqwjk
struuzebbcenziscuoecywugxncdwzyfozhljjyizpqcgkyonyetarcpwkqhuugsqjuixsxptmbnlfupdcfigacdhhrzb

Output: NO

Input:
gdvqjoyxnkypfvdxssgrihnwxkeojmnpdeobpecytkbdwujqfjtxsqspxvxpqioyfagzjxupqqzpgnpnpxcuipweunqch
kkqkiwwasbhezqcfeceyngcyuogrkhqecwsyerdniqiocjehrpkljiljophqhyaiefjpavoom

Output: NO

Input:
umeszdawsvgkjhlqwzents
hxqhdungbylhnikwviuh

Output: NO

Input:
juotpscvyfmgntshcealgbsrwwksgrwnrrbyaqqsxdlzhkbugdyx
ibqvffmfktyipgiopznsqtrtxiijntdbgyy

Output: NO

Input:
zbwueheveouatecaglziqmudxemhrsozmaujrwlqmppzoumxhamwugedikvkblvmxwuofmpafdprbcftew
ulczwrqhctbtbxrhhodwbcxwimncnexosksujlisgclllxokrsbnozthajnnlilyffmsyko

Output: NO

Input:
nkgwuugukzcv
qktnpxedwxpxkrxdvgmfgoxkdfpbzvwsduyiybynbkouonhvmzakeiruhfmvrktghadbfkmwxduoqv

Output: NO

Input:
incenvizhqpcenhjhehvjvgbsnfixbatrrjstxjzhlmdmxijztphxbrldlqwdfimweepkggzcxsrwelodpnryntepioqpvk
dhjbjjftlvnxibkklxquwmzhjfvnmwpapdrslioxisbyhhfymyiaqhlgecpxamqnocizwxniubrmpyubvpenoukhcobkdojlybxd

Output: NO

Input:
w
w

Output: YES

Input:
vz
zv

Output: YES

Input:
ry
yr

Output: YES

Input:
xou
uox

Output: YES

Input:
axg
gax

Output: NO

Input:
zdsl
lsdz

Output: YES

Input:
kudl
ldku

Output: NO

Input:
zzlzwnqlcl
lclqnwzlzz

Output: YES

Input:
vzzgicnzqooejpjzads
sdazjpjeooqzncigzzv

Output: YES

Input:
raqhmvmzuwaykjpyxsykr
xkysrypjkyawuzmvmhqar

Output: NO

Input:
ngedczubzdcqbxksnxuavdjaqtmdwncjnoaicvmodcqvhfezew
wezefhvqcdomvciaonjcnwdmtqajdvauxnskxbqcdzbuzcdegn

Output: YES

Input:
muooqttvrrljcxbroizkymuidvfmhhsjtumksdkcbwwpfqdyvxtrlymofendqvznzlmim
mimlznzvqdnefomylrtxvydqfpwwbckdskmutjshhmfvdiumykziorbxcjlrrvttqooum

Output: YES

Output: YES

Output: NO

Output: NO

Input:
gxoixiecetohtgjgbqzvlaobkhstejxdklghowtvwunnnvauriohuspsdmpzckprwajyxldoyckgjivjpmbfqtszmtocovxwgeh
hegwxvocotmzstqfbmpjvijgkcyodlxyjawrpkczpmdspsuhoiruavnnnuwvtwohglkdxjetshkboalvzqbgjgthoteceixioxg

Output: YES

Input:
sihxuwvmaambplxvjfoskinghzicyfqebjtkysotattkahssumfcgrkheotdxwjckpvapbkaepqrxseyfrwtyaycmrzsrsngkh
hkgnsrszrmcyaytwrfyesxrqpeakbpavpkcjwxdtoehkrgcfmusshakttatosyktjbeqfycizhgniksofjvxlpbmaamvwuxhis

Output: YES

Input:
ycnahksbughnonldzrhkysujmylcgcfuludjvjiahtkyzqvkopzqcnwhltbzfugzojqkjjlggmvnultascmygelkiktmfieok
koeifmtkiklegkmcsatlunvmggkjjlqjozgufzbtlhwncqzpokvqzykthaijvjdulufcgclymjusyyhrzdlnonhgubskhancy

Output: NO

Input:
wbqasaehtkfojruzyhrlgwmtyiovmzyfifslvlemhqheyaelzwnthrenjsbmntwaoryzwfbxmscmypvxlfmzpnkkjlvwvmtz
ztmvwvljkknpzmflxvpymcsmxbfwzyroawtnmbsjnerhtnwzleayehqhmelvlsfifyzmvoiytmwglrhyzurjofktheasaqbw

Output: YES

Input:
imippqurprbhfugngtgifelytadegwrgaefnfhbjjnmzikvjaccotqzemufqieqldgnbmviisgkynzeldlhqxuqphjfmyij
jiymfjhpquxqhldleznykgsiivmbngdlqeiqfumezqtoccajvkizmnjjbhfnfeagrwgedatylefigtgngufhbrpruqppimi

Output: YES

Input:
bikydffiuisckpvzqlteqfhegsagimodb
bdomigasgehfqetlqzvpkcsiuiffdykib

Output: YES

[{'input': 'abcdef\r\nfecdba\r\n', 'output': ['NO']}, {'input': 'umeszdawsvgkjhlqwzents\r\nhxqhdungbylhnikwviuh\r\n', 'output': ['NO']}, {'input': 'code\r\nedoc\r\n', 'output': ['YES']}, {'input': 'q\r\nq\r\n', 'output': ['YES']}, {'input': 'bnbnemvybqizywlnghlykniaxxxlkhftppbdeqpesrtgkcpoeqowjwhrylpsziiwcldodcoonpimudvrxejjo\r\ntiynnekmlalogyvrgptbinkoqdwzuiyjlrldxhzjmmp\r\n', 'output': ['NO']}]

[{'input': 'z\r\na\r\n', 'output': ['NO']}, {'input': 'mfrmqxtzvgaeuleubcmcxcfqyruwzenguhgrmkuhdgnhgtgkdszwqyd\r\nmfxufheiperjnhyczclkmzyhcxntdfskzkzdwzzujdinf\r\n', 'output': ['NO']}, {'input': 'abcdef\r\nfecdba\r\n', 'output': ['NO']}, {'input': 'gxoixiecetohtgjgbqzvlaobkhstejxdklghowtvwunnnvauriohuspsdmpzckprwajyxldoyckgjivjpmbfqtszmtocovxwgeh\r\nhegwxvocotmzstqfbmpjvijgkcyodlxyjawrpkczpmdspsuhoiruavnnnuwvtwohglkdxjetshkboalvzqbgjgthoteceixioxg\r\n', 'output': ['YES']}, {'input': 'dgxmzbqofstzcdgthbaewbwocowvhqpinehpjatnnbrijcolvsatbblsrxabzrpszoiecpwhfjmwuhqrapvtcgvikuxtzbftydkw\r\nwkdytfbztxukivgctvparqhuwmjfhwpceiozsprzbaxrslbbqasvlocjirbnntajphenipthvwocowbweabhtgdcztsfoqbzmxgd\r\n', 'output': ['NO']}]

[{'input': 'asrgdfngfnmfgnhweratgjkk\r\nasrgdfngfnmfgnhweratgjkk\r\n', 'output': ['NO']}, {'input': 'abacaba\r\nabacaba\r\n', 'output': ['YES']}, {'input': 'kudl\r\nldku\r\n', 'output': ['NO']}, {'input': 'sihxuwvmaambplxvjfoskinghzicyfqebjtkysotattkahssumfcgrkheotdxwjckpvapbkaepqrxseyfrwtyaycmrzsrsngkh\r\nhkgnsrszrmcyaytwrfyesxrqpeakbpavpkcjwxdtoehkrgcfmusshakttatosyktjbeqfycizhgniksofjvxlpbmaamvwuxhis\r\n', 'output': ['YES']}, {'input': 'vxpqullmcbegsdskddortcvxyqlbvxmmkhevovnezubvpvnrcajpxraeaxizgaowtfkzywvhnbgzsxbhkaipcmoumtikkiyyaivg\r\ngviayyikkitmuomcpiakhbxszgbnhvwyzkftwoagzixaearxpjacrnvpvbuzenvovehkmmxvblqyxvctroddksdsgebcmlluqpxv\r\n', 'output': ['YES']}]

[{'input': 'w\r\nw\r\n', 'output': ['YES']}, {'input': 'abacaba\r\nabacaba\r\n', 'output': ['YES']}, {'input': 'muooqttvrrljcxbroizkymuidvfmhhsjtumksdkcbwwpfqdyvxtrlymofendqvznzlmim\r\nmimlznzvqdnefomylrtxvydqfpwwbckdskmutjshhmfvdiumykziorbxcjlrrvttqooum\r\n', 'output': ['YES']}, {'input': 'z\r\na\r\n', 'output': ['NO']}, {'input': 'zbwueheveouatecaglziqmudxemhrsozmaujrwlqmppzoumxhamwugedikvkblvmxwuofmpafdprbcftew\r\nulczwrqhctbtbxrhhodwbcxwimncnexosksujlisgclllxokrsbnozthajnnlilyffmsyko\r\n', 'output': ['NO']}]

[{'input': 'ywjjbirapvskozubvxoemscfwl\r\ngnduubaogtfaiowjizlvjcu\r\n', 'output': ['NO']}, {'input': 'vzzgicnzqooejpjzads\r\nsdazjpjeooqzncigzzv\r\n', 'output': ['YES']}, {'input': 'abb\r\naba\r\n', 'output': ['NO']}, {'input': 'abacaba\r\nabacaba\r\n', 'output': ['YES']}, {'input': 'mnhaxtaopjzrkqlbroiyipitndczpunwygstmzevgyjdzyanxkdqnvgkikfabwouwkkbzuiuvgvxgpizsvqsbwepktpdrgdkmfdc\r\ncdfmkdgrdptkpewbsqvszipgxvgvuiuzbkkwuowbafkikgvnqdkxnayzdjygvezmtsgywnupocdntipiyiorblqkrzjpzatxahnm\r\n', 'output': ['NO']}]


The only line of the input contains one integer n (1 ≤ n ≤ 1018) — the prediction on the number of people who will buy the game.

Output one integer showing how many numbers from 1 to n are divisible by all numbers from 2 to 10.

IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is divisible by all numbers from 2 to 10 every developer of this game gets a small bonus.A game designer Petya knows that the company is just about to release a new game that was partly developed by him. On the basis of his experience he predicts that n people will buy the game during the first month. Now Petya wants to determine how many times he will get the bonus. Help him to know it.


The first line contains a single integer n (1 ≤ n ≤ 40).

Print a single integer — the number zn modulo 1000000007 (109 + 7). It is guaranteed that the answer exists.

Consider the following equation:  where sign [a] represents the integer part of number a.Let's find all integer z (z > 0), for which this equation is unsolvable in positive integers. The phrase "unsolvable in positive integers" means that there are no such positive integers x and y (x, y > 0), for which the given above equation holds.Let's write out all such z in the increasing order: z1, z2, z3, and so on (zi < zi + 1). Your task is: given the number n, find the number zn.


Input consists of three integers n, k, m (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100, 1 ≤ m ≤ 109).

def get_input():
    hahaha=input()
    (n,k,m)=hahaha.split(sep=None, maxsplit=1000)
    return (int(n),int(k),int(m))
(n,k,m)=get_input()
f=[0 for i in range(k)]
s=0
for v in range(n):
    tens = 10**v%k
    f=[  (sum(   [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m       for j in range(k)]
    for x in range(9):
        f[(x+1)*tens%k]+=1
    if n-v-1==0:
        s+=(f[0]%m)
    else:
        s+=f[0]*((10**(n-v-2)*9))%m
    f[0]=0
print(s%m)

NoteA suffix of a string S is a non-empty string that can be obtained by removing some number (possibly, zero) of first characters from S.

Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't.First he gave Amr two positive integers n and k. Then he asked Amr, how many integer numbers x > 0 exist such that:  Decimal representation of x (without leading zeroes) consists of exactly n digits;  There exists some integer y > 0 such that:   ;  decimal representation of y is a suffix of decimal representation of x.  As the answer to this question may be pretty huge the teacher asked Amr to output only its remainder modulo a number m.Can you help Amr escape this embarrassing situation?

Input: 1 2 1000

Output: 4

Input: 2 2 1000

Output: 45

Input: 5 3 1103

Output: 590

Input: 2 17 10000

Output: 5

Input: 3 9 10000

Output: 252

Input: 6 64 941761822

Output: 46530

Input: 183 3 46847167

Output: 29891566

Input: 472 44 364550669

Output: 122479316

Input: 510 76 811693420

Output: 546301720

Input: 783 30 602209107

Output: 279682329

Input: 863 47 840397713

Output: 433465398

Input: 422 22 411212542

Output: 63862621

Input: 370 9 385481464

Output: 163845824

Input: 312 41 915197716

Output: 912219984

Input: 261 32 49719977

Output: 19320923

Input: 434 6 56571287

Output: 56257936

Input: 355 3 945669623

Output: 219132384

Input: 905 71 999142682

Output: 825882209

Input: 900 84 526417573

Output: 281234824

Input: 387 3 521021345

Output: 435545521

Input: 246 33 996704992

Output: 385601286

Input: 443 29 106807555

Output: 7872021

Input: 621 43 356382217

Output: 251594310

Input: 782 84 643445347

Output: 208138038

Input: 791 23 94030462

Output: 41862326

Input: 543 98 508536403

Output: 117587951

Input: 20 96 238661639

Output: 198761428

Input: 845 60 888437864

Output: 193926448

Input: 998 85 501663165

Output: 145180249

Input: 123 72 56222855

Output: 32350599

Input: 12 39 618421525

Output: 115875938

Input: 462 35 144751085

Output: 79931198

Input: 674 22 494819681

Output: 19590614

Input: 650 66 579060528

Output: 224930740

Input: 432 80 133016247

Output: 25032672

Input: 176 70 196445230

Output: 64904804

Input: 393 71 933802677

Output: 366541352

Input: 37 92 9838905

Output: 7980021

Input: 993 26 108974437

Output: 87469631

Input: 433 93 36915724

Output: 20722839

Input: 957 88 512982771

Output: 161742313

Input: 170 94 82742818

Output: 1117330

Input: 624 33 145653575

Output: 99048377

Input: 56 48 961996131

Output: 199203510

Input: 889 6 225765429

Output: 193135878

Input: 1 93 727895661

Output: 0

Input: 470 61 617307737

Output: 428782123

Input: 520 94 712232167

Output: 199435818

Input: 531 78 460047919

Output: 117748792

Input: 776 32 523607700

Output: 309970800

Input: 648 74 329538445

Output: 177655063

Input: 885 6 743810885

Output: 297512873

Input: 712 53 592302770

Output: 147693148

Input: 426 72 589297447

Output: 316207784

Input: 561 69 310141994

Output: 245538618

Input: 604 97 26180786

Output: 6950800

Input: 586 32 846994504

Output: 579729448

Input: 514 67 260591607

Output: 88291586

Input: 429 45 103817253

Output: 41335161

Input: 767 27 364988776

Output: 259490746

Input: 497 33 479662107

Output: 84548778

Input: 262 71 404639692

Output: 93447345

Input: 125 33 152527721

Output: 59122415

Input: 857 98 70814341

Output: 58423075

Input: 375 79 416634034

Output: 175150318

Input: 886 10 902171654

Output: 134375492

Input: 335 28 979397289

Output: 675105408

Input: 769 30 474381420

Output: 157049322

Input: 736 31 26855044

Output: 24225276

Input: 891 7 814335325

Output: 611862019

Input: 346 23 947672082

Output: 59151110

Input: 1000 1 382210711

Output: 372462157

Input: 1 1 10000

Output: 9

Input: 1000 100 777767777

Output: 577920877

Input: 1000 13 10619863

Output: 8796170

Input: 1 100 1000

Output: 0

Input: 11 11 11

Output: 7

Input: 1 1 1

Output: 0

Input: 1 2 2

Output: 0


The only line contains an integer n (1 ≤ n ≤ 10000).

Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.

Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.

Output: 1 2

Output: 0 2

Output: 0 8

Output: 0 0

Output: 0 1

Output: 0 1

Output: 0 1

Output: 0 3

Output: 0 3

Output: 0 4

Output: 0 4

Output: 2 9

Output: 3 4

Output: 5 6

Output: 13 11

Output: 27 9

Output: 34 3

Output: 274 4

Output: 277 9

Output: 277 9

Output: 1 0

Output: 2 0


The single line contains the positive integer n (1 ≤ n ≤ 1015).

x=int(input())
if x%2==0:
	print(int(x/2))
else:
	print(-(int(x/2)+1))

Notef(4) =  - 1 + 2 - 3 + 4 = 2f(5) =  - 1 + 2 - 3 + 4 - 5 =  - 3

For a positive integer n let's define a function f:f(n) =  - 1 + 2 - 3 + .. + ( - 1)nn Your task is to calculate f(n) for a given integer n.


The first line contains integer n (1 ≤ n ≤ 109).

n = int(input())
m = str(n)
g = len(m)
l = [int(m[0])-1]+[9]*(g-1)
h = 0
less = 0
while(h<len(l)):
    less = less + l[h]
    h = h + 1
a = n - less
r = []
i = 0
while(a<n):
    j = 0
    s = str(a)
    c = a
    while j<len(s):
        c = c + int(s[j])
        j = j + 1
    if(c==n):
        i +=1
        r = r + [a]
    a = a + 1
if(i==0):
    print(0)
else:
    print(i)
    j = 0
    while(j<len(r)):
        print(r[j])
        j = j + 1

NoteIn the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.In the second test case there are no such x.

In the first line print one integer k — number of different values of x satisfying the condition.  In next k lines print these values in ascending order.

Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.

Output:
1
15

Output:
1
1

Output:
2
99999937
 100000000

Output:
2
99999937 100000000

Output:
2
99999937
100000000

Output:
1
999999932

Output:
2
999999899
 999999908

Output:
2
999999899 999999908

Output:
2
999999899
999999908

Output:
1
5

Output:
1
10

Output:
1
33

Output:
1
60

Output:
1
86

Output:
2
91
100

Output:
2
91
 100

Output:
2
91 100

Output:
2
1988
2006

Output:
2
1988 2006

Output:
2
1988
 2006


The only line of the input contains one integer m (1 ≤ m ≤ 1015), meaning that Limak wants you to choose X between 1 and m, inclusive.

#D razbor 1

def func(n):
    if n<8:
        return n,n

    max_a = int(n**(1/3))
    if (max_a+1)**3<=n:
        max_a += 1

    v1=func(n-max_a**3)
    v1=(v1[0]+1,v1[1]+max_a**3)

    v2=func(max_a**3-1-(max_a-1)**3)
    v2=(v2[0]+1,v2[1]+(max_a-1)**3)

    if v2>v1:
        return v2
    else:
        return v1

print(' '.join(map(str, func(int(input())))))

NoteIn the first sample test, there will be 9 blocks if you choose X = 23 or X = 42. Limak wants to maximize X secondarily so you should choose 42.In more detail, after choosing X = 42 the process of building a tower is:  Limak takes a block with side 3 because it's the biggest block with volume not greater than 42. The remaining volume is 42 - 27 = 15.  The second added block has side 2, so the remaining volume is 15 - 8 = 7.  Finally, Limak adds 7 blocks with side 1, one by one. So, there are 9 blocks in the tower. The total volume is is 33 + 23 + 7·13 = 27 + 8 + 7 = 42.

Print two integers — the maximum number of blocks in the tower and the maximum required total volume X, resulting in the maximum number of blocks.

Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.A block with side a has volume a3. A tower consisting of blocks with sides a1, a2, ..., ak has the total volume a13 + a23 + ... + ak3.Limak is going to build a tower. First, he asks you to tell him a positive integer X — the required total volume of the tower. Then, Limak adds new blocks greedily, one by one. Each time he adds the biggest block such that the total volume doesn't exceed X.Limak asks you to choose X not greater than m. Also, he wants to maximize the number of blocks in the tower at the end (however, he still behaves greedily). Secondarily, he wants to maximize X.Can you help Limak? Find the maximum number of blocks his tower can have and the maximum X ≤ m that results this number of blocks.

Output: 9 42

Output: 6 6

Output: 1 1

Output: 12 941

Output: 16 566998782

Output: 17 123830561521

Output: 17 3842529383076

Output: 18 999999993541753

Output: 2 2

Output: 7 7

Output: 7 7

Output: 7 7

Output: 10 106

Output: 10 113

Output: 11 114

Output: 11 212

Output: 12 995

Output: 14 200355

Output: 16 909381874

Output: 17 107986074062

Output: 17 385925923479720

Output: 18 735409591249436

Output: 18 980123123116482

Output: 18 999087986204952

Output: 17 409477218238710

Output: 17 409477218238717

Output: 18 409477218238718

Output: 18 409477218238718

Output: 18 419466459294818

Output: 18 414993991790735

Output: 18 850085504652042

Output: 18 850085504650655

Output: 18 936302448662019

Output: 18 936302448662019

Output: 18 936302448662019

Output: 18 999999993541753

Output: 18 780869407920631

Output: 18 999999993541753

Output: 18 989983621692990

Output: 18 999998150030846

Output: 18 999969994441746

Output: 18 999999993541753

Output: 18 999969994441746

Output: 18 899973747835553

Output: 18 409477218238718


The first line contains two integers n, k (1 ≤ n ≤ 50, 1 ≤ k ≤ 5000) — the number of people, including Greg, and the boat's weight limit. The next line contains n integers — the people's weights. A person's weight is either 50 kilos or 100 kilos. You can consider Greg and his friends indexed in some way.

from collections import deque

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
c50 = sum([1 for i in a if i == 50])
c100 = sum([1 for i in a if i == 100])
c = [[0] * 51 for i in range(51)]
c[0][0] = 1
c[1][0] = 1
c[1][1] = 1
for x in range(2, 51):
    for y in range(x + 1):
        c[x][y] = c[x - 1][y - 1] + c[x - 1][y]
d = [[[[0, float('inf')] for l in range(2)] for i in range(c100 + 1)] for j in range(c50 + 1)]
# d[i][j][c] ответ, когда мы переправили i по 50 кг и j по 100 кг и лодка на берегу c
d[0][0][0][0] = 1
d[0][0][0][1] = 0
q = deque()
q.append([0, 0, 0])
while len(q) > 0:
    i, j, shore = q.popleft()
    for fifty in range(c50 - i + 1 if shore == 0 else i + 1):
        for hundreds in range(c100 - j + 1 if shore == 0 else j + 1):
            if fifty * 50 + hundreds * 100 > k or fifty + hundreds == 0:
                continue
            i1 = i + fifty if shore == 0 else i - fifty
            j1 = j + hundreds if shore == 0 else j - hundreds
            if d[i1][j1][1 ^ shore][1] > d[i][j][shore][1] + 1:
                d[i1][j1][1 ^ shore][1] = d[i][j][shore][1] + 1
                d[i1][j1][1 ^ shore][0] = 0
                q.append((i1, j1, 1 ^ shore))
            if d[i1][j1][1 ^ shore][1] < d[i][j][shore][1] + 1:
                continue
            koeff = (c[c50 - i][fifty] if shore == 0 else c[i][fifty]) * (
                c[c100 - j][hundreds] if shore == 0 else c[j][hundreds])
            d[i1][j1][1 ^ shore][0] += d[i][j][shore][0] * koeff
            d[i1][j1][1 ^ shore][0] %= 10 ** 9 + 7
if d[c50][c100][1][1] == float('inf'):
    print(-1)
    print(0)
else:
    print(d[c50][c100][1][1])
    print(d[c50][c100][1][0])

NoteIn the first test Greg walks alone and consequently, he needs only one ride across the river.In the second test you should follow the plan:  transport two 50 kg. people;  transport one 50 kg. person back;  transport one 100 kg. person;  transport one 50 kg. person back;  transport two 50 kg. people. That totals to 5 rides. Depending on which person to choose at step 2, we can get two distinct ways.

In the first line print an integer — the minimum number of rides. If transporting everyone to the other bank is impossible, print an integer -1. In the second line print the remainder after dividing the number of ways to transport the people in the minimum number of rides by number 1000000007 (109 + 7). If transporting everyone to the other bank is impossible, print integer 0.

One day Greg and his friends were walking in the forest. Overall there were n people walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a boat by the river bank, just where the guys were standing. We know that the boat can hold people with the total weight of at most k kilograms.Greg immediately took a piece of paper and listed there the weights of all people in his group (including himself). It turned out that each person weights either 50 or 100 kilograms. Now Greg wants to know what minimum number of times the boat needs to cross the river to transport the whole group to the other bank. The boat needs at least one person to navigate it from one bank to the other. As the boat crosses the river, it can have any non-zero number of passengers as long as their total weight doesn't exceed k.Also Greg is wondering, how many ways there are to transport everybody to the other side in the minimum number of boat rides. Two ways are considered distinct if during some ride they have distinct sets of people on the boat.Help Greg with this problem.

Input:
1 50
50

Output:
1
1

Input:
3 100
50 50 100

Output:
5
2

Input:
2 50
50 50

Output:
-1
0

Input:
5 258
100 100 50 50 50

Output:
3
72

Input:
8 191
50 100 50 100 50 100 100 50

Output:
11
19318272

Input:
3 121
100 100 50

Output:
-1
0

Input:
8 271
100 50 100 50 50 50 100 50

Output:
5
78090

Input:
2 233
50 100

Output:
1
1

Input:
2 153
100 50

Output:
1
1

Input:
5 257
50 50 50 50 50

Output:
1
1

Input:
49 290
100 100 100 100 100 100 100 100 50 100 50 100 100 100 50 50 100 50 50 100 100 100 100 100 100 50 100 100 50 100 50 50 100 100 100 50 50 50 50 50 100 100 100 50 100 50 100 50 50

Output:
39
99624366

Input:
29 129
50 50 50 100 100 100 50 100 50 50 50 100 50 100 100 100 50 100 100 100 50 50 50 50 50 50 50 50 50

Output:
77
37050209

Input:
32 121
100 100 100 100 100 50 100 100 50 100 50 100 50 100 50 100 50 50 50 100 100 50 100 100 100 100 50 100 50 100 100 50

Output:
101
245361086

Input:
3 118
100 100 100

Output:
-1
0

Input:
10 4894
100 50 50 50 100 50 50 100 50 100

Output:
1
1

Input:
36 250
50 100 100 50 100 100 100 50 50 100 50 50 50 50 50 50 100 50 100 100 100 100 100 100 100 50 50 100 50 50 100 100 100 100 100 50

Output:
27
77447096

Input:
31 291
50 100 100 50 100 100 100 50 100 100 100 100 50 50 50 100 100 100 50 100 100 50 50 50 50 100 100 50 50 100 100

Output:
23
393964729

Input:
31 161
100 50 50 50 50 100 50 100 50 100 100 50 50 100 100 50 100 50 50 100 50 100 100 50 50 100 50 50 100 50 100

Output:
43
670669365

Input:
5 123
50 100 50 50 50

Output:
9
4536

Input:
43 293
50 50 100 100 50 100 100 50 100 100 50 100 50 100 50 50 50 50 50 100 100 100 50 50 100 50 100 100 100 50 100 100 100 50 50 50 100 50 100 100 50 100 50

Output:
31
658920847

Input:
23 100
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50

Output:
43
689584957

Input:
41 218
50 50 100 50 100 100 50 100 100 50 50 100 50 50 50 50 100 50 100 50 50 50 100 50 50 50 50 100 100 100 100 100 100 50 100 50 100 100 100 50 50

Output:
39
298372053

Input:
11 4668
50 100 100 100 50 100 50 50 100 100 100

Output:
1
1

Input:
43 178
50 50 100 100 100 50 100 100 50 100 100 100 50 100 50 100 50 50 100 100 50 100 100 50 50 50 100 50 50 50 100 50 100 100 100 50 100 50 50 50 50 100 100

Output:
63
503334985

Input:
33 226
50 50 50 50 50 100 100 100 100 50 100 50 100 50 100 50 100 100 50 50 50 100 100 50 50 100 50 100 50 100 50 50 50

Output:
31
370884215

Input:
1 2994
100

Output:
1
1

Input:
1 204
50

Output:
1
1

Input:
33 123
50 100 100 100 50 100 50 50 50 50 50 100 100 50 100 50 100 50 50 50 50 50 50 50 100 100 50 50 100 100 100 100 100

Output:
93
337243149

Input:
34 2964
50 50 50 50 50 100 50 100 50 100 100 50 50 50 50 50 50 100 100 100 50 50 100 100 50 50 50 100 50 100 100 50 100 50

Output:
1
1

Input:
27 200
50 50 50 50 100 100 50 50 100 100 100 50 100 50 100 50 50 100 100 100 50 100 100 50 50 50 100

Output:
25
271877303

Input:
31 197
50 100 50 50 100 50 100 100 100 50 50 100 50 100 50 50 50 50 100 100 50 50 100 50 50 50 50 50 100 50 100

Output:
41
24368657

Input:
28 183
50 100 100 50 100 50 100 100 50 100 50 100 100 100 50 50 100 50 50 50 100 50 100 50 50 100 100 100

Output:
41
844409785

Input:
48 204
100 100 100 50 50 50 50 100 100 50 100 100 50 100 50 50 50 100 100 100 50 100 50 50 50 100 50 100 50 100 100 100 50 50 100 100 100 50 100 50 50 50 50 50 100 50 50 50

Output:
45
538567333

Input:
5 188
50 50 50 50 50

Output:
3
30

Input:
29 108
100 50 100 100 100 100 100 50 50 100 100 100 50 100 50 50 100 50 100 50 50 100 100 50 50 50 100 100 50

Output:
87
417423429

Input:
50 125
50 50 50 100 100 50 100 100 50 50 100 100 100 100 100 100 50 50 100 50 100 100 50 50 50 100 100 50 100 100 100 100 100 100 100 50 50 50 100 50 50 50 50 100 100 100 100 100 50 50

Output:
153
971933773

Input:
50 2263
50 100 50 100 50 100 100 100 50 50 50 100 100 100 100 100 100 50 50 100 50 100 50 50 100 50 50 100 100 50 100 100 100 50 50 50 100 50 100 50 50 50 50 50 100 100 50 50 100 50

Output:
3
211048352

Input:
50 110
50 100 100 50 50 50 50 50 50 50 100 100 50 100 50 50 50 50 100 50 100 100 100 100 50 100 100 100 100 50 50 50 50 50 100 100 50 100 50 100 100 50 50 100 50 100 50 50 100 100

Output:
143
105841088

Input:
50 185
100 50 50 50 50 50 100 50 100 50 100 100 50 50 100 100 100 50 50 100 50 100 50 50 100 100 100 100 100 50 50 100 100 100 50 100 50 100 50 50 100 50 100 50 50 100 50 50 100 100

Output:
73
930170107

Input:
50 207
50 100 100 100 100 50 100 100 100 50 100 100 100 50 100 100 50 100 50 100 50 100 100 100 50 100 50 50 100 50 100 100 50 100 100 100 100 50 100 100 100 100 50 50 50 100 100 50 100 100

Output:
55
833060250

Input:
3 49
50 50 50

Output:
-1
0

Input:
3 50
50 50 50

Output:
-1
0

Input:
3 99
100 50 50

Output:
-1
0

Input:
4 100
100 100 100 50

Output:
-1
0


The only line contains four integers l, r, x, y (1 ≤ l ≤ r ≤ 109, 1 ≤ x ≤ y ≤ 109).

import math
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

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

def f(d):
    d = str(d)
    if d[len(d) - 2:] == '.0':
        return True
    return False

l, r, x, y = [int(i) for i in input().split()]
count = 0
for c in range(1, int(math.sqrt(y / x)) + 1):
    d = (y / x) / c
    if f(d):
        if l <= c * x and r >= d * x and gcd(c * x, d * x) == x and lcm(c * x, d * x) == y:
            if c != d:
                count += 2
            else:
                count += 1
print(count)

NoteIn the first example there are two suitable good pairs of integers (a, b): (1, 2) and (2, 1).In the second example there are four suitable good pairs of integers (a, b): (1, 12), (12, 1), (3, 4) and (4, 3).In the third example there are good pairs of integers, for example, (3, 30), but none of them fits the condition l ≤ a, b ≤ r.

In the only line print the only integer — the answer for the problem.

Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks momentarily and now suggests you to solve one of them as well.We define a pair of integers (a, b) good, if GCD(a, b) = x and LCM(a, b) = y, where GCD(a, b) denotes the greatest common divisor of a and b, and LCM(a, b) denotes the least common multiple of a and b.You are given two integers x and y. You are to find the number of good pairs of integers (a, b) such that l ≤ a, b ≤ r. Note that pairs (a, b) and (b, a) are considered different if a ≠ b.

Input: 1 2 1 2

Output: 2

Input: 1 12 1 12

Output: 4

Input: 50 100 3 30

Output: 0

Input: 1 1000000000 1 1000000000

Output: 4

Input: 1 1000000000 158260522 200224287

Output: 0

Input: 1 1000000000 2 755829150

Output: 8

Input: 1 1000000000 158260522 158260522

Output: 1

Input: 1 1000000000 877914575 877914575

Output: 1

Input: 232 380232688 116 760465376

Output: 30

Input: 47259 3393570 267 600661890

Output: 30

Input: 1 1000000000 1 672672000

Output: 64

Input: 1000000000 1000000000 1000000000 1000000000

Output: 1

Input: 1 1000000000 1 649209600

Output: 32

Input: 1 1000000000 1 682290000

Output: 32

Input: 1 1000000000 1 228614400

Output: 16

Input: 1 1000000000 1 800280000

Output: 32

Input: 1 1000000000 1 919987200

Output: 16

Input: 1 1000000000 1 456537870

Output: 64

Input: 1 1000000000 1 7198102

Output: 8

Input: 1 1000000000 1 58986263

Output: 16

Input: 1 1000000000 1 316465536

Output: 16

Input: 1 1000000000 1 9558312

Output: 16

Input: 1 1000000000 1 5461344

Output: 16

Input: 58 308939059 29 617878118

Output: 62

Input: 837 16262937 27 504151047

Output: 28

Input: 47275 402550 25 761222050

Output: 12

Input: 22 944623394 22 944623394

Output: 32

Input: 1032 8756124 12 753026664

Output: 18

Input: 7238 939389 11 618117962

Output: 10

Input: 58351 322621 23 818489477

Output: 6

Input: 3450 7068875 25 975504750

Output: 86

Input: 13266 1606792 22 968895576

Output: 14

Input: 21930 632925 15 925336350

Output: 42

Input: 2193 4224517 17 544962693

Output: 42

Input: 526792 39807152 22904 915564496

Output: 8

Input: 67728 122875524 16932 491502096

Output: 12

Input: 319813 63298373 24601 822878849

Output: 6

Input: 572464 23409136 15472 866138032

Output: 4

Input: 39443 809059020 19716 777638472

Output: 12

Input: 2544768 8906688 27072 837228672

Output: 0

Input: 413592 46975344 21768 892531536

Output: 10

Input: 11349 816231429 11349 816231429

Output: 8

Input: 16578 939956022 16578 939956022

Output: 4

Input: 2783175 6882425 21575 887832825

Output: 2

Input: 2862252 7077972 22188 913058388

Output: 2

Input: 1856828 13124976 25436 958123248

Output: 6

Input: 100 1000000000 158260522 158260522

Output: 1

Input: 100 1000000000 877914575 877914575

Output: 1

Input: 100 1000000000 602436426 602436426

Output: 1

Input: 100 1000000000 24979445 24979445

Output: 1

Input: 1 1000000000 18470 112519240

Output: 4

Input: 1 1000000000 22692 2201124

Output: 2

Input: 1 1000000000 24190 400949250

Output: 16

Input: 1 1000000000 33409 694005157

Output: 2

Input: 1 1000000000 24967 470827686

Output: 16

Input: 1 1000000000 35461 152517761

Output: 8

Input: 2 1000000000 158260522 200224287

Output: 0

Input: 2 1000000000 602436426 611751520

Output: 0

Input: 2 1000000000 861648772 942726551

Output: 0

Input: 2 1000000000 433933447 485982495

Output: 0

Input: 2 1000000000 262703497 480832794

Output: 0

Input: 2672374 422235092 1336187 844470184

Output: 2

Input: 1321815 935845020 1321815 935845020

Output: 8

Input: 29259607 69772909 2250739 907047817

Output: 2

Input: 11678540 172842392 2335708 864211960

Output: 4

Input: 297 173688298 2876112 851329152

Output: 2

Input: 7249 55497026 659 610467286

Output: 28

Input: 398520 1481490 810 728893080

Output: 4

Input: 2354 369467362 1177 738934724

Output: 14

Input: 407264 2497352 1144 889057312

Output: 2

Input: 321399 1651014 603 879990462

Output: 4

Input: 475640 486640 440 526057840

Output: 2

Input: 631714 179724831 1136 717625968

Output: 0

Input: 280476 1595832 588 761211864

Output: 8

Input: 10455 39598005 615 673166085

Output: 6

Input: 24725 19759875 575 849674625

Output: 22

Input: 22 158 2 1738

Output: 2

Input: 1 2623 1 2623

Output: 4

Input: 7 163677675 3 18

Output: 0

Input: 159 20749927 1 158

Output: 0

Input: 5252 477594071 1 5251

Output: 0

Input: 2202 449433679 3 6603

Output: 0

Input: 6 111 3 222

Output: 2

Input: 26 46 2 598

Output: 2

Input: 26 82 2 1066

Output: 2

Input: 1 2993 1 2993

Output: 4

Input: 17 17 1 289

Output: 0

Input: 177 267 3 15753

Output: 2

Input: 7388 22705183 1 7387

Output: 0

Input: 1 100 3 100

Output: 0

Input: 1 1000 6 1024

Output: 0

Input: 1 100 2 4

Output: 2

Input: 1 10000 2 455

Output: 0

Input: 1 1000000000 250000000 1000000000

Output: 2

Input: 3 3 1 1

Output: 0

Input: 1 1000000000 100000000 1000000000

Output: 4

Input: 5 10 3 3

Output: 0

Input: 1 1000 5 13

Output: 0

Input: 2 2 3 3

Output: 0

Input: 1 1000000000 499999993 999999986

Output: 2

Input: 1 1 1 10

Output: 0

Input: 1 10 10 100

Output: 0

Input: 1 1000 4 36

Output: 2

Input: 1 1000000000 10000000 20000000

Output: 2

Input: 100 100 5 5

Output: 0

Input: 3 3 3 9

Output: 0

Input: 36 200 24 144

Output: 2

Input: 1 100 3 10

Output: 0


The single line contains three integers T, S, q (2 ≤ q ≤ 104, 1 ≤ S < T ≤ 105).

t,s,q=map(int,input().split())
res=0
while s<t:s*=q;res+=1
print(res)

NoteIn the first test, the song is played twice faster than it is downloaded, which means that during four first seconds Lesha reaches the moment that has not been downloaded, and starts the song again. After another two seconds, the song is downloaded completely, and thus, Lesha starts the song twice.In the second test, the song is almost downloaded, and Lesha will start it only once.In the third sample test the download finishes and Lesha finishes listening at the same moment. Note that song isn't restarted in this case.

Print a single integer — the number of times the song will be restarted.

Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in a well-known social network InTalk.Unfortunately, internet is not that fast in the city of Ekaterinozavodsk and the song takes a lot of time to download. But Lesha is quite impatient. The song's duration is T seconds. Lesha downloads the first S seconds of the song and plays it. When the playback reaches the point that has not yet been downloaded, Lesha immediately plays the song from the start (the loaded part of the song stays in his phone, and the download is continued from the same place), and it happens until the song is downloaded completely and Lesha listens to it to the end. For q seconds of real time the Internet allows you to download q - 1 seconds of the track.Tell Lesha, for how many times he will start the song, including the very first start.

Input: 5 2 2

Output: 2

Input: 5 4 7

Output: 1

Input: 6 2 3

Output: 1

Input: 2 1 2

Output: 1

Input: 2 1 3

Output: 1

Input: 2 1 10000

Output: 1

Input: 12326 6163 2

Output: 1

Input: 10000 2500 4

Output: 1

Input: 100000 99999 4

Output: 1

Input: 12351 1223 6

Output: 2

Input: 100000 1 10000

Output: 2

Input: 10028 13 10000

Output: 1

Input: 100000 99999 2

Output: 1

Input: 100000 99999 3

Output: 1

Input: 100000 1 2

Output: 17

Input: 100000 1 3

Output: 11

Input: 100000 1 4

Output: 9

Input: 100000 1 5

Output: 8

Input: 100000 3125 2

Output: 5

Input: 12628 1804 7

Output: 1

Input: 100000 45 13

Output: 4

Input: 100000 500 3

Output: 5

Input: 356 2 3

Output: 5

Input: 50 2 2

Output: 5

Input: 65465 12 3

Output: 8

Input: 10033 3 8

Output: 4

Input: 100000 3 2

Output: 16

Input: 64 1 8

Output: 2

Input: 10000 9 2

Output: 11

Input: 25 2 2

Output: 4

Input: 129 2 2

Output: 7

Input: 6562 1 3

Output: 9

Input: 100000 1 10

Output: 5